|
@@ -1,5 +1,6 @@
|
|
|
package com.zksy.pole.factory;
|
|
package com.zksy.pole.factory;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.json.JSON;
|
|
import cn.hutool.json.JSON;
|
|
|
import cn.hutool.json.JSONArray;
|
|
import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.json.JSONObject;
|
|
import cn.hutool.json.JSONObject;
|
|
@@ -13,46 +14,61 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
@Component
|
|
@Component
|
|
|
public class HandleCmdFactory {
|
|
public class HandleCmdFactory {
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private HandleDgEquipmentAlarmCmd handleDgEquipmentAlarmCmd;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private HandleDgEquipmentStatusCmd handleDgEquipmentStatusCmd;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private HandleDgGatewayRegistrationCmd handleDgGatewayRegistrationCmd;
|
|
private HandleDgGatewayRegistrationCmd handleDgGatewayRegistrationCmd;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private HandleDgGatewayStrategyCmd handleDgGatewayStrategyCmd;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private HandleDgLampControlledHeartbeatCmd handleDgLampControlledHeartbeatCmd;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private HandleDgRelayControlCmd handleDgRelayControlCmd;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private HandleDgRelayTimingStrategyCmd handleDgRelayTimingStrategyCmd;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private HandleDgReportEnvironmentalDataCmd handleDgReportEnvironmentalDataCmd;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private HandleDgTimelyControlCmd handleDgTimelyControlCmd;
|
|
|
public String HandleCmd(String data) {
|
|
public String HandleCmd(String data) {
|
|
|
JSONObject jsonObject = JSONUtil.parseObj(data);
|
|
JSONObject jsonObject = JSONUtil.parseObj(data);
|
|
|
- if(jsonObject.getInt("cmd") == 6031){
|
|
|
|
|
- var c = new HandleDgEquipmentAlarmCmd();
|
|
|
|
|
- String s = c.HandleCmdMethod(jsonObject.toBean(DgEquipmentAlarm.class));
|
|
|
|
|
- return s;
|
|
|
|
|
- }else if(jsonObject.getInt("cmd") == 6012){
|
|
|
|
|
- var c = new HandleDgEquipmentStatusCmd();
|
|
|
|
|
- String s = c.HandleCmdMethod(jsonObject.toBean(DgEquipmentStatus.class));
|
|
|
|
|
- return s;
|
|
|
|
|
- }else if(jsonObject.getInt("cmd") == 1111){
|
|
|
|
|
- var s = handleDgGatewayRegistrationCmd.HandleCmdMethod(jsonObject.toBean(DgGatewayRegistration.class));
|
|
|
|
|
- return s;
|
|
|
|
|
- }else if(jsonObject.getInt("cmd") == 6022){
|
|
|
|
|
- var c = new HandleDgGatewayStrategyCmd();
|
|
|
|
|
- String s = c.HandleCmdMethod(jsonObject.toBean(DgGatewayStrategy.class));
|
|
|
|
|
- return s;
|
|
|
|
|
- }else if(jsonObject.getInt("cmd") == 6010){
|
|
|
|
|
- var c = new HandleDgLampControlledHeartbeatCmd();
|
|
|
|
|
- String s = c.HandleCmdMethod(jsonObject.toBean(DgLampControlledHeartbeat.class));
|
|
|
|
|
- return s;
|
|
|
|
|
- }else if(jsonObject.getInt("cmd") == 6014){
|
|
|
|
|
- var c = new HandleDgRelayControlCmd();
|
|
|
|
|
- String s = c.HandleCmdMethod(jsonObject.toBean(DgRelayControl.class));
|
|
|
|
|
- return s;
|
|
|
|
|
- }else if(jsonObject.getInt("cmd") == 6015){
|
|
|
|
|
- var c = new HandleDgRelayTimingStrategyCmd();
|
|
|
|
|
- String s = c.HandleCmdMethod(jsonObject.toBean(DgRelayTimingStrategy.class));
|
|
|
|
|
- return s;
|
|
|
|
|
- }else if(jsonObject.getInt("cmd") == 2000){
|
|
|
|
|
- var c = new HandleDgReportEnvironmentalDataCmd();
|
|
|
|
|
- String s = c.HandleCmdMethod(jsonObject.toBean(DgReportEnvironmentalData.class));
|
|
|
|
|
- return s;
|
|
|
|
|
- }else if(jsonObject.getInt("cmd") == 6011){
|
|
|
|
|
- var c = new HandleDgTimelyControlCmd();
|
|
|
|
|
- String s = c.HandleCmdMethod(jsonObject.toBean(DgTimelyControl.class));
|
|
|
|
|
- return s;
|
|
|
|
|
|
|
+ int cmd = jsonObject.getInt("cmd");
|
|
|
|
|
+ if(jsonObject.getInt("timestamp") != null){
|
|
|
|
|
+ jsonObject.set("date_time", DateUtil.parseDate(jsonObject.getStr("timestamp")));
|
|
|
|
|
+ }
|
|
|
|
|
+ String s;
|
|
|
|
|
+ switch (cmd) {
|
|
|
|
|
+ case 6031:
|
|
|
|
|
+ s = handleDgEquipmentAlarmCmd.HandleCmdMethod(jsonObject.toBean(DgEquipmentAlarm.class));
|
|
|
|
|
+ return s;
|
|
|
|
|
+ case 6012:
|
|
|
|
|
+ s = handleDgEquipmentStatusCmd.HandleCmdMethod(jsonObject.toBean(DgEquipmentStatus.class));
|
|
|
|
|
+ return s;
|
|
|
|
|
+ case 1111:
|
|
|
|
|
+ s = handleDgGatewayRegistrationCmd.HandleCmdMethod(jsonObject.toBean(DgGatewayRegistration.class));
|
|
|
|
|
+ return s;
|
|
|
|
|
+ case 6022:
|
|
|
|
|
+ s = handleDgGatewayStrategyCmd.HandleCmdMethod(jsonObject.toBean(DgGatewayStrategy.class));
|
|
|
|
|
+ return s;
|
|
|
|
|
+ case 6010:
|
|
|
|
|
+ s = handleDgLampControlledHeartbeatCmd.HandleCmdMethod(jsonObject.toBean(DgLampControlledHeartbeat.class));
|
|
|
|
|
+ return s;
|
|
|
|
|
+ case 6014:
|
|
|
|
|
+ s = handleDgRelayControlCmd.HandleCmdMethod(jsonObject.toBean(DgRelayControl.class));
|
|
|
|
|
+ return s;
|
|
|
|
|
+ case 6015:
|
|
|
|
|
+ s = handleDgRelayTimingStrategyCmd.HandleCmdMethod(jsonObject.toBean(DgRelayTimingStrategy.class));
|
|
|
|
|
+ return s;
|
|
|
|
|
+ case 2000:
|
|
|
|
|
+ s = handleDgReportEnvironmentalDataCmd.HandleCmdMethod(jsonObject.toBean(DgReportEnvironmentalData.class));
|
|
|
|
|
+ return s;
|
|
|
|
|
+ case 6011:
|
|
|
|
|
+ s = handleDgTimelyControlCmd.HandleCmdMethod(jsonObject.toBean(DgTimelyControl.class));
|
|
|
|
|
+ return s;
|
|
|
|
|
+ default:
|
|
|
|
|
+ throw new CommonException("cmd有误或者没有对应的cmd处理", 500);
|
|
|
}
|
|
}
|
|
|
- throw new CommonException("cmd有误或者没有对应的cmd处理", 500);
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|