Commit 3188463d by 李东升

打印日志、计算费用优化

parent 424e8e5f
......@@ -47,7 +47,7 @@ public class ParkMessageController {
*/
@ApiOperation(value = "根据车场编号和通道编号获得通道详细信接口")
@PostMapping("/getChannelMessage")
@GeneralPrintLogAOP(value = "根据车场编号和通道编号获得通道详细信接口", jsonSubs = {-1})
@GeneralPrintLogAOP(value = "根据车场编号和通道编号获得通道详细信接口")
public ResponseResult getChannelMessage(@RequestBody String parkCode, @RequestBody String channelCode) {
logger.info("根据车场编号和通道编号获得通道详细信息 parkCode -> {} , channelCode -> {}", parkCode, channelCode);
ThsChannelMeeageDTO thsChannelMeeageDTO = ThsChannelMeeageDTO.poConvertToDto(channelMessageService.getChannelMessage(parkCode, channelCode));
......@@ -58,4 +58,76 @@ public class ParkMessageController {
return ResponseResult.Builder.init().setFailMessage(ReasonCodeEnums.EMPTY_RESULT, "无此通道信息").build();
}
}
public static int reverse(int x) {
int res = 0;
while (x != 0) {
int temp = x % 10;
if (res > 214748364 || res < -214748364) {
return 0;
}
res = res * 10 + temp;
x = x / 10;
}
return res;
}
//四个方向,顺时针
int[][] direction = {
{-1, 0},
{0, 1},
{1, 0},
{0, -1}
};
int m, n;
boolean[][] visit;
public int dfs(int[][] mat, int x, int y) {
int maxLen = 1;
visit[x][y] = true;
for (int i = 0; i < 4; i++) {
int newX = x + direction[i][0];
int newY = y + direction[i][1];
if (inArr(newX, newY) && !visit[newX][newY] && mat[newX][newY] > mat[x][y]) {
int temp = dfs(mat, newX, newY) + 1;
maxLen = Math.max(temp, maxLen);
}
}
visit[x][y] = false;
return maxLen;
}
public boolean inArr(int x, int y) {
if (x >= 0 && y >= 0 && x < m && y < n) {
return true;
}
return false;
}
public int solo(int[][] mat) {
m = mat.length;
if (m == 0) return 0;
n = mat[0].length;
visit = new boolean[m][n];
int ans = 0;
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
int len = dfs(mat, i, j);
ans = Math.max(ans, len);
}
}
return ans;
}
public static void main(String[] args) {
ParkMessageController controller = new ParkMessageController();
int[][] nums = new int[][]{
{3, 4, 5},
{11, 5, 6},
{12, 8, 7}
};
System.out.println(controller.solo(nums));
}
}
package com.huaching.parking.local.parking_local_general.controller.local;
import com.alibaba.fastjson.JSON;
import com.huaching.parking.local.parking_local_general.domain.ResponseResult;
import com.huaching.parking.local.parking_local_general.domain.local.dto.request.ThsPaySyncDTO;
import com.huaching.parking.local.parking_local_general.domain.local.dto.response.ThsChannelMeeageDTO;
import com.huaching.parking.local.parking_local_general.domain.local.dto.response.ThsRequestChargeDTO;
import com.huaching.parking.local.parking_local_general.enums.local.ReasonCodeEnums;
import com.huaching.parking.local.parking_local_general.intercept.local.GeneralPrintLogAOP;
......@@ -49,7 +51,7 @@ public class PaymentChargesController {
*/
@ApiOperation(value = "根据车场编号和车牌号获得费用信息接口")
@PostMapping("/requestCharge")
@GeneralPrintLogAOP(value = "根据车场编号和车牌号获得费用信息接口", jsonSubs = {-1})
@GeneralPrintLogAOP(value = "根据车场编号和车牌号获得费用信息接口")
public ResponseResult requestCharge(String parkCode, String carNo) {
ThsRequestChargeDTO thsRequestChargeDTO = paymentChargesService.requestCharge(parkCode, carNo, null);
if (thsRequestChargeDTO.getCode() != 1) {
......@@ -72,5 +74,15 @@ public class PaymentChargesController {
return paymentChargesService.paySync(thsPaySyncDTO);
}
/**
* 根据车场编号和通道编号获得通道详细信息
*
* @return
*/
@ApiOperation(value = "tes")
@PostMapping("/tes")
@GeneralPrintLogAOP(value = "tes")
public ResponseResult tes(Integer parkCode, int channelCode) {
return null;
}
}
......@@ -91,7 +91,7 @@ public class RequestController {
*/
@ApiOperation(value = "控制道闸")
@RequestMapping(value = "/controlBarrierGate", method = RequestMethod.POST)
@GeneralPrintLogAOP(value = "控制道闸", jsonSubs = {-1})
@GeneralPrintLogAOP(value = "控制道闸")
public ResponseResult controlBarrierGate(String deviceCode, Integer type) {
return remoteRequestService.controlBarrierGate(deviceCode, type);
}
......
......@@ -37,12 +37,4 @@ public @interface GeneralPrintLogAOP {
* @return
*/
String value() default "";
/**
* 指定参数是否为json数据参数
*
* @return int数组中存储为json参数的顺序(从0开始)
* -1表示不存在json数据
*/
int[] jsonSubs() default {0};
}
......@@ -10,12 +10,11 @@ import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.DefaultParameterNameDiscoverer;
import org.springframework.stereotype.Component;
import java.lang.reflect.Parameter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
/**
* @program: springBootDemo
......@@ -58,25 +57,31 @@ public class GeneralPrintLogAspect {
//.通过这获取到方法的所有参数名称的字符串数组
String[] parameterNames = methodSignature.getParameterNames();
Parameter[] parameters;
if (parameterNames == null) {
parameters = methodSignature.getMethod().getParameters();
if (parameterNames == null) {
parameterNames = new String[parameters != null ? parameters.length : 0];
}
String[] baseTypes = {"String", "string", "Integer", "int", "Double", "double"
, "Float", "float", "Byte", "byte", "Date", "Long", "long", "Boolean", "boolean", "Short", "short"};
List<Integer> onjectParamSubList = new ArrayList<>();
for (int i = 0; i < parameterNames.length; ++i) {
parameterNames[i] = "type:" + parameters[i].getType().getSimpleName();
String typeName = parameters[i].getType().getSimpleName();
if (parameterNames == null) {
parameterNames[i] = "type:" + typeName;
}
if (Arrays.stream(baseTypes).anyMatch(x -> x.equals(typeName))) {
onjectParamSubList.add(i);
}
}
//得到参数值
Object[] args = joinPoint.getArgs();
StringBuilder sb = new StringBuilder("停划算道闸云平台 方法解释 -> " + generalPrintLogAOP.value() + "类名 -> " + className + " 方法名 -> " + methodName
+ " 请求参数 -> ");
int[] jsonSubs = generalPrintLogAOP.jsonSubs();
Arrays.sort(jsonSubs);
int j = 0;
for (int i = 0; i < parameterNames.length; i++) {
sb.append(" " + parameterNames[i] + " -> ");
if (jsonSubs.length > 0 && jsonSubs[j] == i) {
if (onjectParamSubList.contains(i)) {
sb.append(JSON.toJSONString(args[i]) + ",");
j++;
} else {
sb.append(args[i] + ",");
}
......@@ -85,13 +90,14 @@ public class GeneralPrintLogAspect {
long beginExecuteTime = System.currentTimeMillis();
Object obj = null;
try {
obj = joinPoint.proceed();//调用执行目标方法并得到执行方法的返回值
//调用执行目标方法并得到执行方法的返回值
obj = joinPoint.proceed();
} catch (Throwable throwable) {
logger.error("通用日志打印AOP 类名 -> {} 方法名 -> {} 执行出异常,异常信息:", className, methodName, throwable.toString());
throwable.printStackTrace();
}
long endExecuteTime = System.currentTimeMillis();
logger.info("通用日志打印AOP 方法解释 -> {}, 类名 -> {} 方法名 -> {} 执行完成,执行时间 -> {}", generalPrintLogAOP.value(), className, methodName, (endExecuteTime - beginExecuteTime) + "ms");
logger.info("通用日志打印AOP 方法解释 -> {}, 类名 -> {} 方法名 -> {} 执行完成,执行结果 -> {},执行时间 -> {}", generalPrintLogAOP.value(), className, methodName, JSON.toJSONString(obj), (endExecuteTime - beginExecuteTime) + "ms");
return obj;
}
......
......@@ -62,7 +62,7 @@ public class PaymentChargesServiceImpl implements PaymentChargesService {
private ParkMessageService parkMessageService;
@Override
@GeneralPrintLogAOP(value = "场内付请求费用", jsonSubs = {-1})
@GeneralPrintLogAOP(value = "场内付请求费用")
public ThsRequestChargeDTO requestCharge(String parkCode, String carNo, Date outTime) {
Integer thsParkingRecordsId;
String orderNo;
......@@ -104,7 +104,7 @@ public class PaymentChargesServiceImpl implements PaymentChargesService {
}
@Override
@GeneralPrintLogAOP(value = "场内付请求费用 old", jsonSubs = {-1})
@GeneralPrintLogAOP(value = "场内付请求费用 old")
public ThsRequestChargeDTO requestChargeOld(String parkCode, String carNo) {
Integer thsParkingRecordsId;
String orderNo;
......@@ -143,7 +143,7 @@ public class PaymentChargesServiceImpl implements PaymentChargesService {
}
@Override
@GeneralPrintLogAOP(value = "出口付请求费用", jsonSubs = {-1})
@GeneralPrintLogAOP(value = "出口付请求费用")
public ThsRequestChargeDTO outRequestCharge(String parkCode, String channelCode) {
ThsCarAdvanceInOutRecordsPO thsCarAdvanceInOutRecordsPO = carAdvanceInOutRecordsService.selectLastByParkCodeAndChannelCode(parkCode, channelCode);
if (thsCarAdvanceInOutRecordsPO == null) {
......
......@@ -300,20 +300,10 @@ public class ThsTimeFramePayableMoney implements ThsRequestChargeAbstract {
if (endTime == null) {
endTime = DateUtils.stringConvertDate("2020-01-01 " + detail.getEndTime(), 3);
}
switch (detail.getFrameType()) {
//按照分钟收费
case 0:
long minute = DateUtils.subDate(beginTime, endTime, 2);
return minute * detail.getMoney();
//按照小时收费
case 1:
long hour = DateUtils.subDate(beginTime, endTime, 3);
return hour * detail.getMoney();
//按照固定收费
case 2:
return detail.getMoney();
}
return 0;
long sumMoney = 0;
int dateNum = Math.toIntExact(DateUtils.subDate(beginTime, endTime, detail.getFrameType() + 2));
sumMoney += dateNum * detail.getMoney();
return sumMoney;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment