lengfaqiang 2 anni fa
parent
commit
fd554dfb46

+ 5 - 12
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ThresholdService.java

@@ -212,16 +212,9 @@ public class ThresholdService {
             //翻译
             List<String> collect = basiclElementList.stream().map(DeviceElementDTO::getElement).collect(Collectors.toList());
             if (!CollectionUtils.isEmpty(collect)) {
+                Map<String, SystemDict> dictList = commonService.getDictByDictCode(DictEnum.MODEL_PART);
                 for (String dict : collect) {
                     //不查询数据库【kws_device_model_part】 查字典
-                    Map<String, SystemDict> dictList = commonService.getDictList(null,
-                            new HashMap<>() {
-                                {
-                                    put("code", DictEnum.MODEL_PART.getCodeType());
-                                    put("type", "1");
-                                }
-                            }
-                    );
                     itemNameList.add(dictList == null ? dict : (dictList.get(dict) == null ? dict : dictList.get(dict).getLabel()));
                 }
             }
@@ -233,12 +226,12 @@ public class ThresholdService {
                 itemNameList.addAll(collect1);
             }
             dto.setItemNameCount(itemNameList.size());
-            dto.setItemName(JSONObject.toJSONString(itemNameList));
+            dto.setItemName(JSONObject.toJSONString(itemNameList.stream().distinct().collect(Collectors.toList())));
             //获取总数和设置阈值数
             int deviceTotal = getThresholdNumber(thresholdQuery.getProjectId(), headerData, deviceId);
             dto.setDeviceTotal(String.valueOf(deviceTotal));
             int deviceSetTotal = 0;
-            if (!CollectionUtils.isEmpty(kwsThresholds)) {
+            if (!CollectionUtils.isEmpty(kwsThresholds) && kwsThresholds.size() > 0) {
                 deviceSetTotal = kwsThresholds.stream().map(KwsThreshold::getItemName).distinct().collect(Collectors.toList()).size();
             }
             dto.setDeviceSetTotal(deviceSetTotal);
@@ -246,8 +239,8 @@ public class ThresholdService {
             dto.setStatus(setting);
             dto.setStatusName(statusName);
             dto.setPhones(phones.toString());
-            dto.setCreateByName(CollectionUtils.isEmpty(kwsThresholds) ? null : kwsThresholds.get(0).getCreateBy().toString());
-            dto.setUpdateByName(CollectionUtils.isEmpty(kwsThresholds) ? null : kwsThresholds.get(0).getUpdateBy().toString());
+            dto.setCreateByName(CollectionUtils.isEmpty(kwsThresholds) ? null : (kwsThresholds.get(0).getCreateBy() == null ? null : kwsThresholds.get(0).getCreateBy().toString()));
+            dto.setUpdateByName(CollectionUtils.isEmpty(kwsThresholds) ? null : (kwsThresholds.get(0).getUpdateBy() == null ? null : kwsThresholds.get(0).getUpdateBy().toString()));
             dto.setUpdateTime(CollectionUtils.isEmpty(kwsThresholds) ? null : kwsThresholds.get(0).getCreateTime());
         }
         return PageRes.build(info, dtoList);