10 changed files with 345 additions and 6 deletions
@ -0,0 +1,38 @@ |
|||||||
|
package com.mh.user.entity; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author: ljf |
||||||
|
* @Date: 2018/10/15 14:30 |
||||||
|
* @Version 1.0 |
||||||
|
* 水压数据 |
||||||
|
*/ |
||||||
|
|
||||||
|
@Data |
||||||
|
public class WaterPressureEntity { |
||||||
|
|
||||||
|
private Date curDate; |
||||||
|
private String buildingID; |
||||||
|
private String buildingName; |
||||||
|
private String deviceAddr; |
||||||
|
private String deviceName; |
||||||
|
private String pressure00; |
||||||
|
private String pressure02; |
||||||
|
private String pressure06; |
||||||
|
private String pressure08; |
||||||
|
private String pressure11; |
||||||
|
private String pressure13; |
||||||
|
private String pressure14; |
||||||
|
private String pressure15; |
||||||
|
private String pressure16; |
||||||
|
private String pressure17; |
||||||
|
private String pressure18; |
||||||
|
private String pressure19; |
||||||
|
private String pressure20; |
||||||
|
private String pressure21; |
||||||
|
private String pressure22; |
||||||
|
private String pressure23; |
||||||
|
} |
||||||
@ -0,0 +1,51 @@ |
|||||||
|
package com.mh.user.factory; |
||||||
|
|
||||||
|
import com.mh.user.entity.CollectionParamsManageEntity; |
||||||
|
import com.mh.user.entity.DeviceCodeParamEntity; |
||||||
|
import com.mh.user.entity.DeviceInstallEntity; |
||||||
|
import com.mh.user.strategy.DeviceStrategy; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project CHWS |
||||||
|
* @description 系统参数 |
||||||
|
* @date 2024-03-18 16:53:35 |
||||||
|
*/ |
||||||
|
public class SystemParams implements Device { |
||||||
|
|
||||||
|
private DeviceStrategy strategy; |
||||||
|
|
||||||
|
private static class SingletonHolder { |
||||||
|
private static final SystemParams INSTANCE = new SystemParams(); |
||||||
|
} |
||||||
|
|
||||||
|
private SystemParams() { |
||||||
|
// 防止外部直接实例化
|
||||||
|
} |
||||||
|
|
||||||
|
public static SystemParams getInstance() { |
||||||
|
return SystemParams.SingletonHolder.INSTANCE; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void setStrategy(DeviceStrategy strategy) { |
||||||
|
this.strategy = strategy; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String createOrders(DeviceCodeParamEntity deviceCodeParamEntity) { |
||||||
|
return strategy.createOrders(deviceCodeParamEntity); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String analysisReceiveData(String dateStr, String deviceType, String registerAddr, String brand, String buildingId, String buildingName, String dataStr, DeviceCodeParamEntity deviceCodeParamEntity) { |
||||||
|
return strategy.analysisReceiveData(dateStr, deviceType, registerAddr, brand, buildingId, buildingName, dataStr, deviceCodeParamEntity); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String analysisMQTTReceiveData(String dateStr, String registerAddr, String dataStr, String operateType, DeviceInstallEntity deviceInstallEntity, CollectionParamsManageEntity collectionParamsManageEntity) { |
||||||
|
return strategy.analysisMQTTReceiveData(dateStr, registerAddr, dataStr, operateType, deviceInstallEntity, collectionParamsManageEntity); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,86 @@ |
|||||||
|
package com.mh.user.strategy; |
||||||
|
|
||||||
|
import com.mh.user.constants.Constant; |
||||||
|
import com.mh.user.entity.CollectionParamsManageEntity; |
||||||
|
import com.mh.user.entity.DeviceCodeParamEntity; |
||||||
|
import com.mh.user.entity.DeviceInstallEntity; |
||||||
|
import com.mh.user.entity.NowPublicDataEntity; |
||||||
|
import com.mh.user.service.BuildingService; |
||||||
|
import com.mh.user.service.NowDataService; |
||||||
|
import com.mh.user.service.NowPublicDataService; |
||||||
|
import com.mh.user.utils.ExchangeStringUtil; |
||||||
|
import com.mh.user.utils.SpringBeanUtil; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.springframework.context.ApplicationContext; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author LJF |
||||||
|
* @version 1.0 |
||||||
|
* @project CHWS |
||||||
|
* @description 系统参数策略 |
||||||
|
* @date 2024-03-18 09:51:17 |
||||||
|
*/ |
||||||
|
@Slf4j |
||||||
|
public class SystemParamsStrategy implements DeviceStrategy { |
||||||
|
|
||||||
|
|
||||||
|
// 调用service
|
||||||
|
ApplicationContext context = SpringBeanUtil.getApplicationContext(); |
||||||
|
NowDataService nowDataService = context.getBean(NowDataService.class); |
||||||
|
|
||||||
|
NowPublicDataService nowPublicDataService = context.getBean(NowPublicDataService.class); |
||||||
|
|
||||||
|
BuildingService buildingService = context.getBean(BuildingService.class); |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private static class SingletonHolder { |
||||||
|
private static final SystemParamsStrategy INSTANCE = new SystemParamsStrategy(); |
||||||
|
} |
||||||
|
|
||||||
|
private SystemParamsStrategy() { |
||||||
|
// 防止外部直接实例化
|
||||||
|
} |
||||||
|
|
||||||
|
public static SystemParamsStrategy getInstance() { |
||||||
|
return SystemParamsStrategy.SingletonHolder.INSTANCE; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String createOrders(DeviceCodeParamEntity deviceCodeParamEntity) { |
||||||
|
return ""; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String analysisReceiveData(String dateStr, String deviceType, String registerAddr, String brand, String buildingId, String buildingName, String dataStr, DeviceCodeParamEntity deviceCodeParamEntity) { |
||||||
|
String result = Constant.FAIL; |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String analysisMQTTReceiveData(String dateStr, String registerAddr, String dataStr, String operateType, DeviceInstallEntity deviceInstallEntity, |
||||||
|
CollectionParamsManageEntity collectionParamsManageEntity) { |
||||||
|
String result = Constant.FAIL; |
||||||
|
if (Integer.parseInt(dataStr) < 0) { |
||||||
|
log.info("系统参数报文检验失败: " + dataStr); |
||||||
|
return result; |
||||||
|
} |
||||||
|
String data = ""; |
||||||
|
if (operateType.equalsIgnoreCase(Constant.READ)) {// 读
|
||||||
|
// 水压存储过程
|
||||||
|
if (collectionParamsManageEntity.getParamTypeId() == 5) { |
||||||
|
nowDataService.proWaterPressure(dateStr, |
||||||
|
deviceInstallEntity.getBuildingId(), |
||||||
|
deviceInstallEntity.getBuildingName(), |
||||||
|
collectionParamsManageEntity.getRegisterAddr(), |
||||||
|
collectionParamsManageEntity.getOtherName(), |
||||||
|
dataStr);//保存时间点温度
|
||||||
|
log.info("系统参数id:" + deviceInstallEntity.getDeviceAddr() + ",压力值:" + dataStr + ",保存数据库成功!楼栋名称:" + deviceInstallEntity.getBuildingName()); |
||||||
|
} |
||||||
|
return dataStr; |
||||||
|
} else {// 写
|
||||||
|
result = Constant.SUCCESS; |
||||||
|
} |
||||||
|
return result; |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue