|
@@ -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;
|
|
|
+ }
|
|
|
}
|