Parcourir la source

主机上传诊断绑定,阈值名称更新优化

humingshi-7@163.com il y a 11 mois
Parent
commit
749d5c9352

+ 21 - 1
soc-modules/soc-modules-host/src/main/java/com/xunmei/host/iot/service/impl/IotCameraMissionRuleServiceImpl.java

@@ -97,6 +97,12 @@ public class IotCameraMissionRuleServiceImpl implements IotCameraMissionRuleServ
                     IotDeviceDiagnoseMission bean = missionMapper.selectOne(wrapper);
 
                     if(bean != null){//匹配到missionId
+                        if(!missionReq.getName().equals(bean.getName())){//规则一样,但名称不一样,治理该主机的诊断阈值(添加下发该主机IotToken同步)
+                            missionReq.setName(bean.getName());
+                            //todo:
+                            LogUtils.STATUS_INFO_STATUS_SENSOR.info("主机上传诊断绑定:治理的主机iotToken={},missionId={}",iotToken,missionReq.getMissionId());
+                            iotCodes.add(iotToken);
+                        }
                         missionMapper.updateById(missionReq);
                     }else{//未匹配到missionId
                         wrapper = new QueryWrapper<>();
@@ -171,7 +177,21 @@ public class IotCameraMissionRuleServiceImpl implements IotCameraMissionRuleServ
 
                     IotDeviceDiagnoseThreshold bean = thresholdMapper.selectOne(wrapper);
                     if (bean == null) {
-                        //新增时,使用平台生成的id,然后下发到主机统一治理
+                        //中心存在相同名字的阈值记录
+                        wrapper = new QueryWrapper<>();
+                        wrapper.eq("threshold_name",thresholdReq.getThresholdName()).ne("threshold_code", thresholdReq.getThresholdCode());
+                        wrapper.last(limitOne);
+                        bean = thresholdMapper.selectOne(wrapper);
+                        if(bean != null) {//更改主机上报的阈值名称(并添加下发该主机IotToken同步)
+                            String newThresholdName = thresholdReq.getThresholdName() + "_主机";
+                            thresholdReq.setThresholdName(newThresholdName);
+
+                            //todo:
+                            LogUtils.STATUS_INFO_STATUS_SENSOR.info("主机上传诊断绑定:治理的主机iotToken={},thresholdCode={}",iotToken,thresholdReq.getThresholdCode());
+                            iotCodes.add(iotToken);
+                        }
+
+                        //新增时,使用平台生成的id
                         thresholdId = IDHelper.id();
                         thresholdReq.setThresholdId(thresholdId);
                         thresholdReq.setDiagnoseNumber(0);