作者 钟来

plc004支持定时功能

driverClassName=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://rm-wz9740un21f09iokuao.mysql.rds.aliyuncs.com:3306/mqtt_broker?useUnicode=true&characterEncoding=utf8&autoReconnect=true
#url=jdbc:mysql://rm-wz9740un21f09iokuao.mysql.rds.aliyuncs.com:3306/mqtt_broker?useUnicode=true&characterEncoding=utf8&autoReconnect=true
#username=luhui
#password=Luhui586
url=jdbc:mysql://rm-wz9446bn79p0r80ew0o.mysql.rds.aliyuncs.com:3306/runing_fish?useUnicode=true&characterEncoding=utf8&autoReconnect=true&useSSL=false&serverTimezone=Asia/Shanghai
username=luhui
password=Luhui586
#\u6700\u5927\u8FDE\u63A5\u6570\u91CF
... ...
... ... @@ -144,7 +144,7 @@ public class DeviceController {
Map<String,Object> map = new HashMap<>();
map.put(skey,Integer.parseInt(data.get("shi")+""+data.get("feng")));
map.put(ekey,Integer.parseInt(data.get("shi1")+""+data.get("feng1")));
if("PW1".equals(pw))
if("PW1_TS1".equals(skey))
{
if((int)map.get("PW1_TS1")==1 && (int)map.get("PW1_TE1")==2)
{
... ... @@ -195,6 +195,7 @@ public class DeviceController {
return new Message(MessageCode.DEFAULT_FAIL_CODE,"该设备未配置请联系管理员");
}
Map<String,Object> map = new HashMap<>();
// Map<String,Object> cleanmap = new HashMap<>();
for (String key:deviceDataConfigWriteMap.keySet())
{
DeviceDataConfig deviceDataConfig = deviceDataConfigWriteMap.get(key);
... ... @@ -202,6 +203,14 @@ public class DeviceController {
{
//记录日志
map.put(deviceDataConfig.getAttribute_name(), data.get("value").toString().equals(deviceDataConfig.getAlarmValue())?1:0);
// if (deviceDataConfig.getAttribute_name().indexOf("_STP_")>0 && (int)map.get(deviceDataConfig.getAttribute_name())==1)
// {
// cleanmap.put(deviceDataConfig.getAttribute_name(),0);
// }
if (deviceDataConfig.getAttribute_name().indexOf("_ST_")>0 && (int)map.get(deviceDataConfig.getAttribute_name())==1)
{
map.put("PW1_ZX",1);
}
}
}
if(map.size()==0)
... ...
... ... @@ -33,7 +33,7 @@ public class PLCDataPersistenceService {
for (DeviceInfo deviceInfo:list)
{
baseDao.update(deviceInfo);
log.info("{}设备数据更新{}",topic.getClientid(),list);
// log.info("{}设备数据更新{}",topic.getClientid(),list);
}
}
}
... ...
... ... @@ -71,13 +71,13 @@ public class AllPostTopic implements BusinessAgreement<AllPostDto> {
{
if(deviceDataConfigMap.containsKey(key))
{
log.info("点位{}",key);
// log.info("点位{}",key);
String dttribute_value = object.get(key).toString();
String newDataValue= ByteUtil.changerTwoStr(dttribute_value);
DeviceDataConfig deviceDataConfig = deviceDataConfigMap.get(key);
String deviceInfoId = deviceDataConfig.getDeviceInfoId(topic.getClientid()); //根据点位协议解析到设备id
log.info("点位对应的设备id{}",deviceInfoId);
// log.info("点位对应的设备id{}",deviceInfoId);
if(deviceInfoId.equals(topic.getClientid()))
{
if(null != list && "SYS_AUTO".equals(key))
... ... @@ -111,22 +111,22 @@ public class AllPostTopic implements BusinessAgreement<AllPostDto> {
switch (PLCDataType.valueOf(deviceDataConfig.getPlc_data_type()))
{
case 故障代码:
log.info("故障代码{}",newDataValue);
// log.info("故障代码{}",newDataValue);
if(newDataValue.equals(deviceDataConfig.getAlarmValue()))
{
newAlrmCode = deviceDataConfig.getAlarmCode();
}
break;
case 控制柜状态:
log.info("控制柜状态{}",newDataValue);
// log.info("控制柜状态{}",newDataValue);
analysisData(data,deviceInfo,deviceDataConfig,newDataValue,topic);
break;
case 校准时间:
log.info("校准时间{}",newDataValue);
// log.info("校准时间{}",newDataValue);
analysisData(data,deviceInfo,deviceDataConfig,newDataValue,topic);
break;
default:
log.info("默认功能{}",newDataValue);
// log.info("默认功能{}",newDataValue);
analysisData(data,deviceInfo,deviceDataConfig,newDataValue,topic);
break;
}
... ... @@ -134,7 +134,7 @@ public class AllPostTopic implements BusinessAgreement<AllPostDto> {
deviceInfo.setDataUpdateTime(DateUtils.getNowTimeMilly());
deviceInfo.setDeviceServiceIp(SysParameter.service_ip);
deviceInfo.setOnline("01");
log.info("设备信息{}",deviceInfo);
// log.info("设备信息{}",deviceInfo);
}
}
private void analysisTime( JSONObject jsonObject,Map<String, DeviceDataConfig> deviceDataConfigMap,Topic topic,List<DeviceInfo> deviceInfoList)
... ... @@ -252,7 +252,7 @@ public class AllPostTopic implements BusinessAgreement<AllPostDto> {
jsonObject = GsonConstructor.get().fromJson(dataValue,JSONObject.class);
}
String odlDataValue = (String) jsonObject.get(PLCDataType.valueOf(deviceDataConfig.getPlc_data_type()).sensorDataType);
log.info("数据变化"+deviceDataConfig.getAttribute_name()+" "+odlDataValue+"-->"+newDataValue);
// log.info("数据变化"+deviceDataConfig.getAttribute_name()+" "+odlDataValue+"-->"+newDataValue);
if(!newDataValue.equals(odlDataValue))
{
jsonObject.put(PLCDataType.valueOf(deviceDataConfig.getPlc_data_type()).sensorDataType,newDataValue); //更新数据
... ...