|
|
@@ -19,6 +19,7 @@ import com.tmzn.devicelinkykc.frameMsg.frameType.CharngingPushFrame;
|
|
|
import com.tmzn.devicelinkykc.frameMsg.frameType.LoginFrame;
|
|
|
import com.tmzn.devicelinkykc.frameMsg.frameType.RealTimeStatusPushFrame;
|
|
|
import com.tmzn.devicelinkykc.frameMsg.frameType.TransactionFlowPushFrame;
|
|
|
+import com.tmzn.devicelinkykc.msgparser.MessageParseMgr;
|
|
|
import com.tmzn.devicelinkykc.openfeign.transdata.RpcResult;
|
|
|
import com.tmzn.devicelinkykc.redis.RedisCache;
|
|
|
import com.tmzn.devicelinkykc.service.*;
|
|
|
@@ -26,12 +27,14 @@ import com.tmzn.devicelinkykc.socket.DeviceConnectionMsg;
|
|
|
import com.tmzn.devicelinkykc.socket.SocketHandle;
|
|
|
import com.tmzn.devicelinkykc.transdata.constant.NormalChargeConstant;
|
|
|
import com.tmzn.devicelinkykc.transdata.entity.DeviceParam;
|
|
|
+import com.tmzn.devicelinkykc.util.Encrytion;
|
|
|
import org.apache.logging.log4j.util.Strings;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
@@ -39,6 +42,7 @@ import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* @author xp
|
|
|
* @date 2024/3/13
|
|
|
@@ -48,6 +52,8 @@ import java.util.concurrent.TimeUnit;
|
|
|
@Component
|
|
|
public class DeviceMsgHandle {
|
|
|
|
|
|
+
|
|
|
+
|
|
|
@Autowired
|
|
|
private DeviceStatusService deviceStatusService;
|
|
|
@Autowired
|
|
|
@@ -70,6 +76,9 @@ public class DeviceMsgHandle {
|
|
|
@Autowired
|
|
|
private DeviceControlerService deviceControlerService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private MessageParseMgr messageParseMgr;
|
|
|
+
|
|
|
@Autowired
|
|
|
private BillingModelService billingModelService;
|
|
|
|
|
|
@@ -83,6 +92,7 @@ public class DeviceMsgHandle {
|
|
|
|
|
|
public void deviceMsg(String msg) throws Exception {
|
|
|
//必须过滤调非云快充设备
|
|
|
+
|
|
|
//logger.info("redis中msg>>>" + msg);
|
|
|
msg = msg.substring(1, msg.length() - 1);
|
|
|
msg = msg.replace("\\", "");
|
|
|
@@ -109,11 +119,61 @@ public class DeviceMsgHandle {
|
|
|
return;
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
return;
|
|
|
}
|
|
|
logger.info("{},msg>>>" + msg, imei);
|
|
|
//设备状态更新,true:没有type不是设备上送类型不往云快充处理 false:需要根据设备消息类型往下处理是不是需要上报云快充
|
|
|
+
|
|
|
+
|
|
|
+ boolean packageFlag = false;
|
|
|
+ try{
|
|
|
+ int cmd = jsonObject.getInteger("cmd");
|
|
|
+ if(cmd == 75960 && jsonObject.containsKey("data")){
|
|
|
+ JSONArray dataArray = jsonObject.getJSONArray("data");
|
|
|
+ List<Integer> dataListDirect = dataArray.toJavaList(Integer.class);
|
|
|
+ List<List<Integer>> packages = Encrytion.parseMorePackage(dataListDirect);
|
|
|
+ if(packages.size()>0){
|
|
|
+ packageFlag = true;
|
|
|
+ for(int i=0;i<packages.size();i++){
|
|
|
+ try{
|
|
|
+ Integer type = packages.get(i).get(1);
|
|
|
+ JSONObject newObj = new JSONObject();
|
|
|
+ newObj.put("imei", jsonObject.get("imei"));
|
|
|
+ newObj.put("dev_id",jsonObject.get("dev_id"));
|
|
|
+ newObj.put("data",packages.get(i));//重写拆
|
|
|
+ newObj.put("cmd",cmd);// 包data
|
|
|
+ newObj.put("type",type); //重写拆包
|
|
|
+ JSONObject realData = messageParseMgr.parseMessage(cmd+"_"+type,newObj);
|
|
|
+ if(realData!=null){
|
|
|
+ newObj.put("real_data",realData);//重写拆包后real_data
|
|
|
+ }
|
|
|
+ if(packages.size()>1){
|
|
|
+ logger.info("new object,{}",newObj);
|
|
|
+ }
|
|
|
+ handleDeviceMsg(newObj, pileCode);
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ logger.warn("拆包处理异常{},{}",e.getMessage(),msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ logger.error("拆包异常--{}---{}",e.getMessage(),msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(packageFlag){
|
|
|
+// logger.info("p0");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
try {
|
|
|
+
|
|
|
handleDeviceMsg(jsonObject, pileCode);
|
|
|
} catch (Exception e) {
|
|
|
logger.error("处理消息失败{},{}", imei, e.getMessage());
|
|
|
@@ -122,6 +182,8 @@ public class DeviceMsgHandle {
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
public void testMsg(String msg) throws Exception {
|
|
|
logger.info("testmsg>>>" + msg);
|
|
|
JSONObject jsonObject = null;
|