|
|
@@ -68,7 +68,7 @@ public class IotAlarmRuleSourceServiceImpl extends ServiceImpl<IotAlarmRuleSourc
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Page<IotAlarmRuleSourceDeviceVo> selectDeviceList(IotAlarmRuleSourceDeviceDto param)throws Exception {
|
|
|
+ public Page<IotAlarmRuleSourceDeviceVo> selectDeviceList(IotAlarmRuleSourceDeviceDto param) throws Exception {
|
|
|
Page<IotAlarmRuleSourceDeviceVo> page = new Page<>();
|
|
|
page.setSize(param.getSize());
|
|
|
page.setCurrent(param.getPage());
|
|
|
@@ -81,12 +81,12 @@ public class IotAlarmRuleSourceServiceImpl extends ServiceImpl<IotAlarmRuleSourc
|
|
|
public void updateRuleAndProductDevice(IotAlarmRuleSourceDetailVo detailDto) throws Exception {
|
|
|
//删除设备绑定数据
|
|
|
LambdaQueryWrapper<IotAlarmRuleSource> qw = new LambdaQueryWrapper<IotAlarmRuleSource>();
|
|
|
- qw.eq(IotAlarmRuleSource::getRuleId,detailDto.getRuleId());
|
|
|
+ qw.eq(IotAlarmRuleSource::getRuleId, detailDto.getRuleId());
|
|
|
iotAlarmRuleSourceMapper.delete(qw);
|
|
|
|
|
|
//重新绑定设置
|
|
|
List<ProductTypeDataVo> deviceData = detailDto.getTypeDataList();
|
|
|
- if(ObjectUtil.isEmpty(deviceData)){
|
|
|
+ if (ObjectUtil.isEmpty(deviceData)) {
|
|
|
return;
|
|
|
}
|
|
|
IotAlarmRuleSource ruleSource = null;
|
|
|
@@ -106,9 +106,9 @@ public class IotAlarmRuleSourceServiceImpl extends ServiceImpl<IotAlarmRuleSourc
|
|
|
for (ProductDeviceTempVo deviceTempVo : productType.getDeviceTempList()) {
|
|
|
//查询当前设备是否有其他规则绑定,如果有则删除,解绑
|
|
|
QueryWrapper<IotAlarmRuleSource> iqw = new QueryWrapper<>();
|
|
|
- iqw.lambda().eq(IotAlarmRuleSource::getOrgId,deviceTempVo.getOrgId())
|
|
|
- .eq(IotAlarmRuleSource::getValue,deviceTempVo.getDeviceId())
|
|
|
- .eq(IotAlarmRuleSource::getSourceType,productType.getType());
|
|
|
+ iqw.lambda().eq(IotAlarmRuleSource::getOrgId, deviceTempVo.getOrgId())
|
|
|
+ .eq(IotAlarmRuleSource::getValue, deviceTempVo.getDeviceId())
|
|
|
+ .eq(IotAlarmRuleSource::getSourceType, productType.getType());
|
|
|
iotAlarmRuleSourceMapper.delete(iqw);
|
|
|
ruleSource.setId(IDHelper.id());
|
|
|
ruleSource.setOrgId(deviceTempVo.getOrgId());
|
|
|
@@ -135,7 +135,7 @@ public class IotAlarmRuleSourceServiceImpl extends ServiceImpl<IotAlarmRuleSourc
|
|
|
IotSensor productDevice = (IotSensor) hashMap.get(deviceId);
|
|
|
if (productDevice == null) {
|
|
|
QueryWrapper<IotSensor> qw = new QueryWrapper<>();
|
|
|
- qw.lambda().eq(IotSensor::getDeviceCode,deviceId).eq(IotSensor::getDeleted,0);
|
|
|
+ qw.lambda().eq(IotSensor::getDeviceCode, deviceId).eq(IotSensor::getDeleted, 0);
|
|
|
hashMap.put(deviceId, productDevice);
|
|
|
}
|
|
|
String code = productDevice.getDeviceType();
|
|
|
@@ -166,37 +166,37 @@ public class IotAlarmRuleSourceServiceImpl extends ServiceImpl<IotAlarmRuleSourc
|
|
|
|
|
|
/**
|
|
|
* 处理每种类型的数据
|
|
|
+ *
|
|
|
* @param pdv
|
|
|
* @return
|
|
|
*/
|
|
|
- private void dealDevice(ProductTypeDataVo pdv){
|
|
|
+ private void dealDevice(ProductTypeDataVo pdv) {
|
|
|
String valueType = pdv.getValueType();
|
|
|
|
|
|
- if(StringUtils.isEmpty(valueType)){
|
|
|
+ if (StringUtils.isEmpty(valueType)) {
|
|
|
//未配置设备关联时
|
|
|
pdv.setIsAllDeviceEnable(false);
|
|
|
pdv.setValueType(ValueTypeEnum.Device.getText());
|
|
|
- }else{
|
|
|
- if(ValueTypeEnum.AllDevice.getText().equals(valueType)){
|
|
|
+ } else {
|
|
|
+ if (ValueTypeEnum.AllDevice.getText().equals(valueType)) {
|
|
|
//配置按设备类型关联时
|
|
|
pdv.setIsAllDeviceEnable(true);
|
|
|
}
|
|
|
|
|
|
- if(ValueTypeEnum.Device.getText().equals(valueType)){
|
|
|
+ if (ValueTypeEnum.Device.getText().equals(valueType)) {
|
|
|
//配置具体设备关联时
|
|
|
List<ProductDeviceTempVo> deviceTempList = pdv.getDeviceTempList();
|
|
|
//获取对应的设备id
|
|
|
List<String> deviceIds = deviceTempList.stream().map(ProductDeviceTempVo::getDeviceId).collect(Collectors.toList());
|
|
|
|
|
|
List<IotSensor> iotSensors = iotCommonSensorMapper.selectByIds(deviceIds);
|
|
|
- Map<String, IotSensor> deviceIdAndName = iotSensors.stream().collect(Collectors.toMap(IotSensor::getDeviceCode, Function.identity()));
|
|
|
+ final Map<String, List<IotSensor>> deviceIdAndName = iotSensors.stream().collect(Collectors.groupingBy(IotSensor::getDeviceCode));
|
|
|
for (ProductDeviceTempVo ptv : deviceTempList) {
|
|
|
- IotSensor iotSensor = deviceIdAndName.get(ptv.getDeviceId());
|
|
|
- if( iotSensor!= null){
|
|
|
+ final List<IotSensor> sensorList = deviceIdAndName.get(ptv.getDeviceId());
|
|
|
+ for (IotSensor iotSensor : sensorList) {
|
|
|
ptv.setDeviceName(iotSensor.getDeviceName());
|
|
|
ptv.setOrgName(iotSensor.getOrgName());
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
}
|