测点映射表保存修改
This commit is contained in:
parent
3658bf02e8
commit
f6e44fb493
@ -32,6 +32,7 @@ import com.das.modules.node.mapper.SysCommunicationLinkMapper;
|
||||
import com.das.modules.node.mapper.SysImpTabMappingMapper;
|
||||
import com.das.modules.node.mapper.SysNodeMapper;
|
||||
import com.das.modules.node.service.SysNodeService;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
@ -407,22 +408,21 @@ public class SysNodeServiceImpl implements SysNodeService {
|
||||
*/
|
||||
@Override
|
||||
public void saveMappingList(List<SysTabMappingVo> impList) {
|
||||
if (impList.get(0).getProtocol() == 9 || impList.get(0).getProtocol() == 17){
|
||||
Map<Long, Integer> collect = sysImptabmappingMapper.getMappingInfoListByLinkId(impList.get(0).getLinkId()).stream().collect(Collectors.toMap(SysTabMappingVo::getId, SysTabMappingVo::getMeasPointType, (value1, value2) -> value1));
|
||||
List<SysTabMappingVo> analogList = impList.stream().filter(item -> collect.get(item.getId()) == 138).collect(Collectors.toList());
|
||||
List<SysTabMappingVo> accumulator = impList.stream().filter(item -> collect.get(item.getId()) == 139).collect(Collectors.toList());
|
||||
List<SysTabMappingVo> discrete = impList.stream().filter(item -> collect.get(item.getId()) == 140).collect(Collectors.toList());
|
||||
List<SysTabMappingVo> setPoint = impList.stream().filter(item -> collect.get(item.getId()) == 146).collect(Collectors.toList());
|
||||
List<SysTabMappingVo> control = impList.stream().filter(item -> collect.get(item.getId()) == 147).collect(Collectors.toList());
|
||||
//校验param里面order不重复
|
||||
if (checkOrderRepeated(analogList) || checkOrderRepeated(accumulator) || checkOrderRepeated(discrete) || checkOrderRepeated(setPoint) || checkOrderRepeated(control)){
|
||||
throw new ServiceException("检查顺序,排序不能重复");
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (!CollectionUtils.isEmpty(impList)) {
|
||||
List<SysTabMapping> list = new ArrayList<>();
|
||||
|
||||
if (impList.get(0).getProtocol() == 9 || impList.get(0).getProtocol() == 17){
|
||||
Map<Long, Integer> collect = sysImptabmappingMapper.getMappingInfoListByLinkId(impList.get(0).getLinkId()).stream().collect(Collectors.toMap(SysTabMappingVo::getId, SysTabMappingVo::getMeasPointType, (value1, value2) -> value1));
|
||||
List<SysTabMappingVo> analogList = impList.stream().filter(item -> collect.get(item.getId()) == 138).collect(Collectors.toList());
|
||||
List<SysTabMappingVo> accumulator = impList.stream().filter(item -> collect.get(item.getId()) == 139).collect(Collectors.toList());
|
||||
List<SysTabMappingVo> discrete = impList.stream().filter(item -> collect.get(item.getId()) == 140).collect(Collectors.toList());
|
||||
List<SysTabMappingVo> setPoint = impList.stream().filter(item -> collect.get(item.getId()) == 146).collect(Collectors.toList());
|
||||
List<SysTabMappingVo> control = impList.stream().filter(item -> collect.get(item.getId()) == 147).collect(Collectors.toList());
|
||||
//校验param里面order不重复
|
||||
if (checkOrderRepeated(analogList) || checkOrderRepeated(accumulator) || checkOrderRepeated(discrete) || checkOrderRepeated(setPoint) || checkOrderRepeated(control)){
|
||||
throw new ServiceException("检查顺序,排序不能重复");
|
||||
}
|
||||
}
|
||||
SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY);
|
||||
for (SysTabMappingVo imp : impList) {
|
||||
SysTabMapping rec = sysImptabmappingMapper.selectById(imp.getId());
|
||||
@ -540,12 +540,19 @@ public class SysNodeServiceImpl implements SysNodeService {
|
||||
|
||||
private Boolean checkOrderRepeated(List<SysTabMappingVo> mappings) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
List<SysTabMappingVo> orderCollect = mappings.stream().filter(item -> {
|
||||
try {
|
||||
JsonNode jsonNode = objectMapper.readTree(item.getParams());
|
||||
return StringUtils.isNotEmpty(jsonNode.get("order").asText());
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
Boolean orderRepeated = false;
|
||||
try {
|
||||
// 提取所有的 order 字段,转换为 Set
|
||||
Set<String> orderSet = new HashSet<>();
|
||||
orderRepeated = mappings.stream()
|
||||
orderRepeated = orderCollect.stream()
|
||||
.map(SysTabMappingVo::getParams) // 提取 param 字段
|
||||
.map(param -> {
|
||||
try {
|
||||
@ -558,7 +565,11 @@ public class SysNodeServiceImpl implements SysNodeService {
|
||||
})
|
||||
.anyMatch(order -> {
|
||||
if (StringUtils.isNotEmpty(order)){
|
||||
return !orderSet.add(order);
|
||||
boolean b = !orderSet.add(order);
|
||||
if (b){
|
||||
log.error("排序重复{}",order);
|
||||
}
|
||||
return b;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user