|
|
|
|
@ -6,6 +6,7 @@ import com.mh.common.utils.StringUtils;
|
|
|
|
|
import com.mh.user.constants.Constant; |
|
|
|
|
import com.mh.user.entity.*; |
|
|
|
|
import com.mh.user.mapper.CollectionParamsManageMapper; |
|
|
|
|
import com.mh.user.mapper.DeviceInstallMapper; |
|
|
|
|
import com.mh.user.model.*; |
|
|
|
|
import com.mh.user.serialport.SerialPortSingle2; |
|
|
|
|
import com.mh.user.service.*; |
|
|
|
|
@ -47,6 +48,9 @@ public class DeviceControlServiceImpl implements DeviceControlService {
|
|
|
|
|
@Resource |
|
|
|
|
private CollectionParamsManageMapper collectionParamsManageMapper; |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private DeviceInstallMapper deviceInstallMapper; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public String getSn(SerialPortModel serialPortModel) { |
|
|
|
|
return collectionParamsManageMapper.selectSn(serialPortModel.getCpmId()); |
|
|
|
|
@ -125,6 +129,30 @@ public class DeviceControlServiceImpl implements DeviceControlService {
|
|
|
|
|
String param = serialPortModel.getParam(); |
|
|
|
|
String deviceName = serialPortModel.getDeviceName(); |
|
|
|
|
|
|
|
|
|
// TODO 因为增加了正帝热泵,collectionParamsManageEntity存储了对呀的地址,所以先判断cpmId是否有值
|
|
|
|
|
String cpmId = serialPortModel.getCpmId(); |
|
|
|
|
if (!StringUtils.isBlank(cpmId)) { |
|
|
|
|
CollectionParamsManageEntity collectionParamsManageEntity = collectionParamsManageMapper.selectById(cpmId); |
|
|
|
|
if (collectionParamsManageEntity == null) { |
|
|
|
|
return Constant.FAIL; |
|
|
|
|
} |
|
|
|
|
// 判断如果是定时,直接更新
|
|
|
|
|
if (collectionParamsManageEntity.getParamTypeGroupId() == 3) { |
|
|
|
|
// 更新定时
|
|
|
|
|
collectionParamsManageEntity.setCurTime(new Date()); |
|
|
|
|
collectionParamsManageEntity.setCurValue(new BigDecimal(serialPortModel.getDataValue())); |
|
|
|
|
collectionParamsManageMapper.updateById(collectionParamsManageEntity); |
|
|
|
|
return Constant.SUCCESS; |
|
|
|
|
} |
|
|
|
|
Long deviceInstallId = collectionParamsManageEntity.getDeviceInstallId(); |
|
|
|
|
DeviceInstallEntity deviceInstallEntity = deviceInstallMapper.selectDeviceById(deviceInstallId); |
|
|
|
|
deviceAddr = deviceInstallEntity.getDeviceAddr(); |
|
|
|
|
deviceType = deviceInstallEntity.getDeviceType(); |
|
|
|
|
buildingId = deviceInstallEntity.getBuildingId(); |
|
|
|
|
deviceCodeParam.setFunCode(collectionParamsManageEntity.getFuncCode()); |
|
|
|
|
deviceCodeParam.setRegisterAddr(collectionParamsManageEntity.getRegisterAddr()); |
|
|
|
|
deviceCodeParam.setRegisterSize(collectionParamsManageEntity.getRegisterSize()); |
|
|
|
|
} |
|
|
|
|
if (StringUtils.isBlank(deviceAddr)) { |
|
|
|
|
List<DeviceModel> list = null; |
|
|
|
|
if (StringUtils.isBlank(deviceName)) { |
|
|
|
|
@ -784,6 +812,8 @@ public class DeviceControlServiceImpl implements DeviceControlService {
|
|
|
|
|
} else if ("海尔2".equals(deviceCodeParam.getBrand())) { |
|
|
|
|
deviceCodeParam.setRegisterAddr(ExchangeStringUtil.addZeroForNum(ExchangeStringUtil.decToHex("1302"), 4)); //寄存器地址
|
|
|
|
|
deviceCodeParam.setFunCode("06"); //功能码写数据
|
|
|
|
|
} else if (Constant.BRAND_ZHENG_DI.equals(deviceCodeParam.getBrand())) { |
|
|
|
|
deviceCodeParam.setFunCode("06"); //功能码写数据
|
|
|
|
|
} else { |
|
|
|
|
deviceCodeParam.setRegisterAddr("0003"); //寄存器地址
|
|
|
|
|
deviceCodeParam.setFunCode("06"); //功能码写数据
|
|
|
|
|
|