作者 钟来

plc004支持定时功能

1 driverClassName=com.mysql.cj.jdbc.Driver 1 driverClassName=com.mysql.cj.jdbc.Driver
2 -url=jdbc:mysql://rm-wz9740un21f09iokuao.mysql.rds.aliyuncs.com:3306/mqtt_broker?useUnicode=true&characterEncoding=utf8&autoReconnect=true 2 +#url=jdbc:mysql://rm-wz9740un21f09iokuao.mysql.rds.aliyuncs.com:3306/mqtt_broker?useUnicode=true&characterEncoding=utf8&autoReconnect=true
  3 +#username=luhui
  4 +#password=Luhui586
  5 +url=jdbc:mysql://rm-wz9446bn79p0r80ew0o.mysql.rds.aliyuncs.com:3306/runing_fish?useUnicode=true&characterEncoding=utf8&autoReconnect=true&useSSL=false&serverTimezone=Asia/Shanghai
3 username=luhui 6 username=luhui
4 password=Luhui586 7 password=Luhui586
5 #\u6700\u5927\u8FDE\u63A5\u6570\u91CF 8 #\u6700\u5927\u8FDE\u63A5\u6570\u91CF
@@ -144,7 +144,7 @@ public class DeviceController { @@ -144,7 +144,7 @@ public class DeviceController {
144 Map<String,Object> map = new HashMap<>(); 144 Map<String,Object> map = new HashMap<>();
145 map.put(skey,Integer.parseInt(data.get("shi")+""+data.get("feng"))); 145 map.put(skey,Integer.parseInt(data.get("shi")+""+data.get("feng")));
146 map.put(ekey,Integer.parseInt(data.get("shi1")+""+data.get("feng1"))); 146 map.put(ekey,Integer.parseInt(data.get("shi1")+""+data.get("feng1")));
147 - if("PW1".equals(pw)) 147 + if("PW1_TS1".equals(skey))
148 { 148 {
149 if((int)map.get("PW1_TS1")==1 && (int)map.get("PW1_TE1")==2) 149 if((int)map.get("PW1_TS1")==1 && (int)map.get("PW1_TE1")==2)
150 { 150 {
@@ -195,6 +195,7 @@ public class DeviceController { @@ -195,6 +195,7 @@ public class DeviceController {
195 return new Message(MessageCode.DEFAULT_FAIL_CODE,"该设备未配置请联系管理员"); 195 return new Message(MessageCode.DEFAULT_FAIL_CODE,"该设备未配置请联系管理员");
196 } 196 }
197 Map<String,Object> map = new HashMap<>(); 197 Map<String,Object> map = new HashMap<>();
  198 +// Map<String,Object> cleanmap = new HashMap<>();
198 for (String key:deviceDataConfigWriteMap.keySet()) 199 for (String key:deviceDataConfigWriteMap.keySet())
199 { 200 {
200 DeviceDataConfig deviceDataConfig = deviceDataConfigWriteMap.get(key); 201 DeviceDataConfig deviceDataConfig = deviceDataConfigWriteMap.get(key);
@@ -202,6 +203,14 @@ public class DeviceController { @@ -202,6 +203,14 @@ public class DeviceController {
202 { 203 {
203 //记录日志 204 //记录日志
204 map.put(deviceDataConfig.getAttribute_name(), data.get("value").toString().equals(deviceDataConfig.getAlarmValue())?1:0); 205 map.put(deviceDataConfig.getAttribute_name(), data.get("value").toString().equals(deviceDataConfig.getAlarmValue())?1:0);
  206 +// if (deviceDataConfig.getAttribute_name().indexOf("_STP_")>0 && (int)map.get(deviceDataConfig.getAttribute_name())==1)
  207 +// {
  208 +// cleanmap.put(deviceDataConfig.getAttribute_name(),0);
  209 +// }
  210 + if (deviceDataConfig.getAttribute_name().indexOf("_ST_")>0 && (int)map.get(deviceDataConfig.getAttribute_name())==1)
  211 + {
  212 + map.put("PW1_ZX",1);
  213 + }
205 } 214 }
206 } 215 }
207 if(map.size()==0) 216 if(map.size()==0)
@@ -33,7 +33,7 @@ public class PLCDataPersistenceService { @@ -33,7 +33,7 @@ public class PLCDataPersistenceService {
33 for (DeviceInfo deviceInfo:list) 33 for (DeviceInfo deviceInfo:list)
34 { 34 {
35 baseDao.update(deviceInfo); 35 baseDao.update(deviceInfo);
36 - log.info("{}设备数据更新{}",topic.getClientid(),list); 36 +// log.info("{}设备数据更新{}",topic.getClientid(),list);
37 } 37 }
38 } 38 }
39 } 39 }
@@ -71,13 +71,13 @@ public class AllPostTopic implements BusinessAgreement<AllPostDto> { @@ -71,13 +71,13 @@ public class AllPostTopic implements BusinessAgreement<AllPostDto> {
71 { 71 {
72 if(deviceDataConfigMap.containsKey(key)) 72 if(deviceDataConfigMap.containsKey(key))
73 { 73 {
74 - log.info("点位{}",key); 74 +// log.info("点位{}",key);
75 String dttribute_value = object.get(key).toString(); 75 String dttribute_value = object.get(key).toString();
76 String newDataValue= ByteUtil.changerTwoStr(dttribute_value); 76 String newDataValue= ByteUtil.changerTwoStr(dttribute_value);
77 77
78 DeviceDataConfig deviceDataConfig = deviceDataConfigMap.get(key); 78 DeviceDataConfig deviceDataConfig = deviceDataConfigMap.get(key);
79 String deviceInfoId = deviceDataConfig.getDeviceInfoId(topic.getClientid()); //根据点位协议解析到设备id 79 String deviceInfoId = deviceDataConfig.getDeviceInfoId(topic.getClientid()); //根据点位协议解析到设备id
80 - log.info("点位对应的设备id{}",deviceInfoId); 80 +// log.info("点位对应的设备id{}",deviceInfoId);
81 if(deviceInfoId.equals(topic.getClientid())) 81 if(deviceInfoId.equals(topic.getClientid()))
82 { 82 {
83 if(null != list && "SYS_AUTO".equals(key)) 83 if(null != list && "SYS_AUTO".equals(key))
@@ -111,22 +111,22 @@ public class AllPostTopic implements BusinessAgreement<AllPostDto> { @@ -111,22 +111,22 @@ public class AllPostTopic implements BusinessAgreement<AllPostDto> {
111 switch (PLCDataType.valueOf(deviceDataConfig.getPlc_data_type())) 111 switch (PLCDataType.valueOf(deviceDataConfig.getPlc_data_type()))
112 { 112 {
113 case 故障代码: 113 case 故障代码:
114 - log.info("故障代码{}",newDataValue); 114 +// log.info("故障代码{}",newDataValue);
115 if(newDataValue.equals(deviceDataConfig.getAlarmValue())) 115 if(newDataValue.equals(deviceDataConfig.getAlarmValue()))
116 { 116 {
117 newAlrmCode = deviceDataConfig.getAlarmCode(); 117 newAlrmCode = deviceDataConfig.getAlarmCode();
118 } 118 }
119 break; 119 break;
120 case 控制柜状态: 120 case 控制柜状态:
121 - log.info("控制柜状态{}",newDataValue); 121 +// log.info("控制柜状态{}",newDataValue);
122 analysisData(data,deviceInfo,deviceDataConfig,newDataValue,topic); 122 analysisData(data,deviceInfo,deviceDataConfig,newDataValue,topic);
123 break; 123 break;
124 case 校准时间: 124 case 校准时间:
125 - log.info("校准时间{}",newDataValue); 125 +// log.info("校准时间{}",newDataValue);
126 analysisData(data,deviceInfo,deviceDataConfig,newDataValue,topic); 126 analysisData(data,deviceInfo,deviceDataConfig,newDataValue,topic);
127 break; 127 break;
128 default: 128 default:
129 - log.info("默认功能{}",newDataValue); 129 +// log.info("默认功能{}",newDataValue);
130 analysisData(data,deviceInfo,deviceDataConfig,newDataValue,topic); 130 analysisData(data,deviceInfo,deviceDataConfig,newDataValue,topic);
131 break; 131 break;
132 } 132 }
@@ -134,7 +134,7 @@ public class AllPostTopic implements BusinessAgreement<AllPostDto> { @@ -134,7 +134,7 @@ public class AllPostTopic implements BusinessAgreement<AllPostDto> {
134 deviceInfo.setDataUpdateTime(DateUtils.getNowTimeMilly()); 134 deviceInfo.setDataUpdateTime(DateUtils.getNowTimeMilly());
135 deviceInfo.setDeviceServiceIp(SysParameter.service_ip); 135 deviceInfo.setDeviceServiceIp(SysParameter.service_ip);
136 deviceInfo.setOnline("01"); 136 deviceInfo.setOnline("01");
137 - log.info("设备信息{}",deviceInfo); 137 +// log.info("设备信息{}",deviceInfo);
138 } 138 }
139 } 139 }
140 private void analysisTime( JSONObject jsonObject,Map<String, DeviceDataConfig> deviceDataConfigMap,Topic topic,List<DeviceInfo> deviceInfoList) 140 private void analysisTime( JSONObject jsonObject,Map<String, DeviceDataConfig> deviceDataConfigMap,Topic topic,List<DeviceInfo> deviceInfoList)
@@ -252,7 +252,7 @@ public class AllPostTopic implements BusinessAgreement<AllPostDto> { @@ -252,7 +252,7 @@ public class AllPostTopic implements BusinessAgreement<AllPostDto> {
252 jsonObject = GsonConstructor.get().fromJson(dataValue,JSONObject.class); 252 jsonObject = GsonConstructor.get().fromJson(dataValue,JSONObject.class);
253 } 253 }
254 String odlDataValue = (String) jsonObject.get(PLCDataType.valueOf(deviceDataConfig.getPlc_data_type()).sensorDataType); 254 String odlDataValue = (String) jsonObject.get(PLCDataType.valueOf(deviceDataConfig.getPlc_data_type()).sensorDataType);
255 - log.info("数据变化"+deviceDataConfig.getAttribute_name()+" "+odlDataValue+"-->"+newDataValue); 255 +// log.info("数据变化"+deviceDataConfig.getAttribute_name()+" "+odlDataValue+"-->"+newDataValue);
256 if(!newDataValue.equals(odlDataValue)) 256 if(!newDataValue.equals(odlDataValue))
257 { 257 {
258 jsonObject.put(PLCDataType.valueOf(deviceDataConfig.getPlc_data_type()).sensorDataType,newDataValue); //更新数据 258 jsonObject.put(PLCDataType.valueOf(deviceDataConfig.getPlc_data_type()).sensorDataType,newDataValue); //更新数据