update 打印日志

This commit is contained in:
2024-03-18 16:39:37 +08:00
parent ca5a5d3593
commit 95e74d6d73
5 changed files with 22 additions and 10 deletions

View File

@@ -113,7 +113,7 @@ public class PayController extends BaseController {
*/ */
@PostMapping("/payOrder") @PostMapping("/payOrder")
public RestApiResponse<?> payOrder(HttpServletRequest request, @RequestBody PayOrderDTO dto) { public RestApiResponse<?> payOrder(HttpServletRequest request, @RequestBody PayOrderDTO dto) {
logger.info("支付订单接口 param:{}", dto.toString()); // logger.info("支付订单接口 param:{}", dto.toString());
RestApiResponse<?> response; RestApiResponse<?> response;
// 支付订单加锁 // 支付订单加锁
@@ -150,7 +150,7 @@ public class PayController extends BaseController {
redisCache.unLock(lockKey); redisCache.unLock(lockKey);
} }
} }
logger.info("支付订单接口 result:{}", JSONObject.toJSONString(response)); logger.info("支付订单接口 param:{}, result:{}", JSONObject.toJSONString(dto), JSONObject.toJSONString(response));
return response; return response;
} }

View File

@@ -3,6 +3,7 @@ package com.jsowell.common.util;
import com.google.common.primitives.Bytes; import com.google.common.primitives.Bytes;
import com.jsowell.common.constant.Constants; import com.jsowell.common.constant.Constants;
import javax.xml.bind.DatatypeConverter;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.math.BigInteger; import java.math.BigInteger;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@@ -143,6 +144,15 @@ public class BytesUtil {
return new BigInteger(1, bytes).toString(radix);// 这里的1代表正数 return new BigInteger(1, bytes).toString(radix);// 这里的1代表正数
} }
/**
* 将byte[]转为十六进制的字符串
* @param bytes byte[]
* @return 转换后的字符串
*/
public static String printHexBinary(byte[] bytes) {
return DatatypeConverter.printHexBinary(bytes);
}
/** /**
* @函数功能: BCD码转为10进制串(阿拉伯数据) * @函数功能: BCD码转为10进制串(阿拉伯数据)
* @输入参数: BCD码 * @输入参数: BCD码

View File

@@ -570,8 +570,6 @@ public class TransactionRecordsRequestHandler extends AbstractHandler {
} }
} }
/* /*
应答 应答
确认结果 0x00 上传成功 0x01 非法账单 确认结果 0x00 上传成功 0x01 非法账单

View File

@@ -17,7 +17,6 @@ import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.xml.bind.DatatypeConverter;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@@ -80,13 +79,16 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
Channel channel = ctx.channel(); Channel channel = ctx.channel();
// new // new
String hexString = DatatypeConverter.printHexBinary(msg); // String hexString = DatatypeConverter.printHexBinary(msg);
// 心跳包0x03日志太多造成日志文件过大改为不打印 // 心跳包0x03日志太多造成日志文件过大改为不打印
if (!CollectionUtils.containsAny(notPrintFrameTypeList, frameType)) { if (!CollectionUtils.containsAny(notPrintFrameTypeList, frameType)) {
log.info("【<<<<<平台收到消息<<<<<】channel:{}, 帧类型:{}, 帧名称:{}, 序列号域:{}, 报文:{}, new报文:{}", // log.info("【<<<<<平台收到消息<<<<<】channel:{}, 帧类型:{}, 帧名称:{}, 序列号域:{}, 报文:{}, new报文:{}",
// channel.id(), frameType, YKCFrameTypeCode.getFrameTypeStr(frameType), serialNumber,
// BytesUtil.binary(msg, 16), hexString);
log.info("【<<<<<平台收到消息<<<<<】channel:{}, 帧类型:{}, 帧名称:{}, 序列号域:{}, 报文:{}",
channel.id(), frameType, YKCFrameTypeCode.getFrameTypeStr(frameType), serialNumber, channel.id(), frameType, YKCFrameTypeCode.getFrameTypeStr(frameType), serialNumber,
BytesUtil.binary(msg, 16), hexString); BytesUtil.binary(msg, 16));
} }
// 处理数据 // 处理数据

View File

@@ -579,9 +579,11 @@ public class PileConnectorInfoServiceImpl implements PileConnectorInfoService {
} }
String redisKey = CacheConstants.PILE_CONNECTOR_STATUS_KEY + pileConnectorCode; String redisKey = CacheConstants.PILE_CONNECTOR_STATUS_KEY + pileConnectorCode;
String redisStatus = redisCache.getCacheObject(redisKey); String redisStatus = redisCache.getCacheObject(redisKey);
log.info("更新枪口状态-枪口编号:{}, redisKey:{}, 缓存状态:{}, 传来的状态:{}, 状态描述:{}", pileConnectorCode, redisKey, // log.info("更新枪口状态-枪口编号:{}, redisKey:{}, 缓存状态:{}, 传来的状态:{}, 状态描述:{}", pileConnectorCode, redisKey,
redisStatus, status, PileConnectorDataBaseStatusEnum.getStatusDescription(status)); // redisStatus, status, PileConnectorDataBaseStatusEnum.getStatusDescription(status));
if (!StringUtils.equals(redisStatus, status)) { if (!StringUtils.equals(redisStatus, status)) {
log.info("更新枪口状态ing-枪口编号:{}, redisKey:{}, 缓存状态:{}, 传来的状态:{}, 状态描述:{}", pileConnectorCode, redisKey,
redisStatus, status, PileConnectorDataBaseStatusEnum.getStatusDescription(status));
String pileSn = pileConnectorCode.substring(0, pileConnectorCode.length() - 2); String pileSn = pileConnectorCode.substring(0, pileConnectorCode.length() - 2);
// 只修改一个枪口的状态 // 只修改一个枪口的状态
num = pileConnectorInfoMapper.updateConnectorStatus(pileConnectorCode, status); num = pileConnectorInfoMapper.updateConnectorStatus(pileConnectorCode, status);