浏览代码

精益事件需求开发01

qiangxuan 9 月之前
父节点
当前提交
52f4e9f4e2

+ 31 - 14
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/events/service/impl/LeanEventsHostServiceImpl.java

@@ -11,9 +11,9 @@ import org.jeecg.modules.events.service.ILeanEventsHostService;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * @Description: 精益事件设备启停配置表
@@ -32,31 +32,48 @@ public class LeanEventsHostServiceImpl extends ServiceImpl<LeanEventsHostMapper,
         if(oConvertUtils.listIsNotEmpty(leanEventsHostEditParam.getLeanEventsHosts())){
             LambdaQueryWrapper<LeanEventsHost> deleteQuery = new LambdaQueryWrapper<LeanEventsHost>().eq(LeanEventsHost::getEventsId, leanEventsHostEditParam.getLeanEventsHosts().get(0).getEventsId());
             baseMapper.delete(deleteQuery);
-            leanEventsHostEditParam.getLeanEventsHosts().forEach(leanEventsHost -> {
+            LeanEventsHost leanEventsHost = leanEventsHostEditParam.getLeanEventsHosts().get(0);
+            if (oConvertUtils.isNotEmpty(leanEventsHost.getDeviceInformationList())){
                 baseMapper.insert(leanEventsHost);
-            });
+            }
         }
     }
 
     @Override
     public List<LeanEventsHost> getConfig(String id) {
-
-
-
         LambdaQueryWrapper<LeanEventsHost> query = new LambdaQueryWrapper<LeanEventsHost>().eq(LeanEventsHost::getEventsId, id);
         List<LeanEventsHost> leanEventsHosts = baseMapper.selectList(query);
         leanEventsHosts.forEach(leanEventsHost -> {
-            String deviceTitle = deviceInformationMapper.selectById(leanEventsHost.getDeviceInformationId()).getDeviceTitle();
-            leanEventsHost.setDeviceInformationId(leanEventsHost.getDeviceInformationId()+"|"+deviceTitle);
+            // 检查设备信息 ID 是否包含特定字符串,若不包含则进行处理;(false:峰平谷)
+            if (!containsAny(leanEventsHost.getDeviceInformationId(), "tops", "peaks", "flat", "valleys")) {
+                // 根据设备信息 ID 查询设备标题并赋值到主设备Id
+                String deviceTitle = deviceInformationMapper.selectById(leanEventsHost.getDeviceInformationId()).getDeviceTitle();
+                leanEventsHost.setDeviceInformationId(leanEventsHost.getDeviceInformationId() + "|" + deviceTitle);
+            }
+            // 处理辅设备标题列表
             List<String> deviceChildTites = Arrays.asList(leanEventsHost.getDeviceInformationList().split(","));
-            List<String> resChildTites = new ArrayList<>();
-            deviceChildTites.forEach(deviceChildTite->{
-                String deviceName = deviceInformationMapper.selectById(deviceChildTite).getDeviceTitle();
-                resChildTites.add(deviceChildTite.concat("|"+deviceName));
-            });
-            leanEventsHost.setDeviceInformationList(String.join(",",resChildTites));
+            List<String> resChildTites = deviceInformationMapper.selectBatchIds(deviceChildTites)
+                    .stream()
+                    .map(x -> x.getId() + "|" + x.getDeviceTitle())
+                    .collect(Collectors.toList());
+            // 更新 LeanEventsHost 对象的辅设备配置信息ID集
+            leanEventsHost.setDeviceInformationList(String.join(",", resChildTites));
         });
         return leanEventsHosts;
     }
 
+    /**
+     * 检查字符串是否包含多个子字符串中的任意一个
+     * @param str
+     * @param substrings
+     * @return
+     */
+    private boolean containsAny(String str, String... substrings) {
+        for (String substring : substrings) {
+            if (str.contains(substring)) {
+                return true;
+            }
+        }
+        return false;
+    }
 }

+ 8 - 6
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/systemConfig/peaksAndValleysTimeConfig/entity/PeaksAndValleysTimeConfig.java

@@ -1,18 +1,19 @@
 package org.jeecg.modules.systemConfig.peaksAndValleysTimeConfig.entity;
 
-import java.io.Serializable;
-
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
 import com.fasterxml.jackson.annotation.JsonFormat;
-import org.springframework.format.annotation.DateTimeFormat;
-import org.jeecgframework.poi.excel.annotation.Excel;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
+import org.jeecg.common.aspect.annotation.Dict;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
 
 /**
  * @Description: 峰平谷时段配置
@@ -65,6 +66,7 @@ public class PeaksAndValleysTimeConfig implements Serializable {
     private java.util.Date endTime;
 	/**峰平谷类型*/
 	@Excel(name = "峰平谷类型", width = 15)
-    @ApiModelProperty(value = "峰平谷类型(0:峰 1:平 2:谷)")
+    @ApiModelProperty(value = "峰平谷类型(尖:tops 峰:peaks 平:flat 谷:valleys)")
+    @Dict(dicCode = "fpg_type")
     private String type;
 }

+ 4 - 4
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/systemConfig/peaksAndValleysTimeConfig/service/impl/PeaksAndValleysTimeConfigServiceImpl.java

@@ -23,16 +23,16 @@ public class PeaksAndValleysTimeConfigServiceImpl extends ServiceImpl<PeaksAndVa
         PeaksAndValleysTimeConfigParam res = new PeaksAndValleysTimeConfigParam();
         //获取尖
         res.setTops(baseMapper.selectList(new LambdaQueryWrapper<PeaksAndValleysTimeConfig>()
-                .eq(PeaksAndValleysTimeConfig::getType,"4").orderByAsc(PeaksAndValleysTimeConfig::getStartTime)));
+                .eq(PeaksAndValleysTimeConfig::getType,"tops").orderByAsc(PeaksAndValleysTimeConfig::getStartTime)));
         //获取峰
         res.setPeaks(baseMapper.selectList(new LambdaQueryWrapper<PeaksAndValleysTimeConfig>()
-                .eq(PeaksAndValleysTimeConfig::getType,"0").orderByAsc(PeaksAndValleysTimeConfig::getStartTime)));
+                .eq(PeaksAndValleysTimeConfig::getType,"peaks").orderByAsc(PeaksAndValleysTimeConfig::getStartTime)));
         //获取平
         res.setFlat(baseMapper.selectList(new LambdaQueryWrapper<PeaksAndValleysTimeConfig>()
-                .eq(PeaksAndValleysTimeConfig::getType,"1").orderByAsc(PeaksAndValleysTimeConfig::getStartTime)));
+                .eq(PeaksAndValleysTimeConfig::getType,"flat").orderByAsc(PeaksAndValleysTimeConfig::getStartTime)));
         //获取谷
         res.setValleys(baseMapper.selectList(new LambdaQueryWrapper<PeaksAndValleysTimeConfig>()
-                .eq(PeaksAndValleysTimeConfig::getType,"2").orderByAsc(PeaksAndValleysTimeConfig::getStartTime)));
+                .eq(PeaksAndValleysTimeConfig::getType,"valleys").orderByAsc(PeaksAndValleysTimeConfig::getStartTime)));
         return res;
     }