Merge branch 'main' of https://git.jsspisoft.com/ry-das
This commit is contained in:
commit
fe615898e6
@ -1,8 +1,8 @@
|
||||
package com.das.modules.node.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.das.common.config.SessionUtil;
|
||||
import com.das.common.constant.MeasType;
|
||||
@ -13,7 +13,6 @@ import com.das.modules.auth.entity.SysOrg;
|
||||
import com.das.modules.auth.mapper.SysOrgMapper;
|
||||
import com.das.modules.equipment.domain.vo.SysIotModelFieldVo;
|
||||
import com.das.modules.equipment.domain.vo.SysIotModelServiceVo;
|
||||
import com.das.modules.equipment.entity.SysIotModelField;
|
||||
import com.das.modules.equipment.mapper.SysEquipmentMapper;
|
||||
import com.das.modules.equipment.mapper.SysIotModelFieldMapper;
|
||||
import com.das.modules.equipment.mapper.SysIotModelServiceMapper;
|
||||
@ -52,6 +51,7 @@ import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@ -60,6 +60,8 @@ import java.util.stream.Collectors;
|
||||
public class SysNodeServiceImpl implements SysNodeService {
|
||||
private static final ObjectMapper JSON_MAPPER = new ObjectMapper();
|
||||
|
||||
public static final int COMMIT_COUNT = 10000;
|
||||
|
||||
@Autowired
|
||||
private SysNodeMapper sysNodeMapper;
|
||||
|
||||
@ -327,8 +329,9 @@ public class SysNodeServiceImpl implements SysNodeService {
|
||||
if(mappingVoMap.containsKey(key)){
|
||||
SysTabMappingVo item = mappingVoMap.get(key);
|
||||
PassedMappingIds.add(item.getId());
|
||||
|
||||
SysTabMapping mapping = sysImptabmappingMapper.selectById(item.getId());
|
||||
SysTabMappingVo sysTabMappingVo = mappingVoMap.get(key);
|
||||
SysTabMapping mapping = new SysTabMapping();
|
||||
BeanCopyUtils.copy(sysTabMappingVo,mapping);
|
||||
mapping.setMeasPointName(iotModelVo.getAttributeName());
|
||||
mapping.setHighSpeed(iotModelVo.getHighSpeed());
|
||||
mapping.setPorder(order);
|
||||
@ -369,8 +372,10 @@ public class SysNodeServiceImpl implements SysNodeService {
|
||||
if(mappingVoMap.containsKey(key)){
|
||||
SysTabMappingVo item = mappingVoMap.get(key);
|
||||
PassedMappingIds.add(item.getId());
|
||||
|
||||
SysTabMapping mapping = sysImptabmappingMapper.selectById(item.getId());
|
||||
//根据key拿到配置
|
||||
SysTabMappingVo sysTabMappingVo = mappingVoMap.get(key);
|
||||
SysTabMapping mapping = new SysTabMapping();
|
||||
BeanCopyUtils.copy(sysTabMappingVo,mapping);
|
||||
mapping.setMeasPointName(iotServiceVo.getServiceName());
|
||||
mapping.setPorder(order);
|
||||
order++;
|
||||
@ -394,18 +399,29 @@ public class SysNodeServiceImpl implements SysNodeService {
|
||||
}
|
||||
//批量更新
|
||||
if (!CollectionUtils.isEmpty(addList)) {
|
||||
sysImptabmappingMapper.insertOrUpdateBatch(addList);
|
||||
ListUtil.page(addList,COMMIT_COUNT, item -> {
|
||||
sysImptabmappingMapper.insertOrUpdateBatch(item);
|
||||
});
|
||||
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(updateList)) {
|
||||
sysImptabmappingMapper.insertOrUpdateBatch(updateList);
|
||||
ListUtil.page(updateList,COMMIT_COUNT, item -> {
|
||||
sysImptabmappingMapper.insertOrUpdateBatch(item);
|
||||
});
|
||||
}
|
||||
|
||||
//删除为匹配的历史配置
|
||||
List<Long> deleteList = new ArrayList<>();
|
||||
for(SysTabMappingVo item : mappingVoMap.values()){
|
||||
if(!PassedMappingIds.contains(item.getId())){
|
||||
sysImptabmappingMapper.deleteById(item.getId());
|
||||
deleteList.add(item.getId());
|
||||
}
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(deleteList)){
|
||||
ListUtil.page(deleteList,COMMIT_COUNT, item -> {
|
||||
sysImptabmappingMapper.deleteBatchIds(item);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -414,8 +430,10 @@ public class SysNodeServiceImpl implements SysNodeService {
|
||||
*/
|
||||
@Override
|
||||
public void saveMappingList(List<SysTabMappingVo> impList) {
|
||||
List<SysTabMappingVo> mappingInfoListByLinkId = sysImptabmappingMapper.getMappingInfoListByLinkId(impList.get(0).getLinkId());
|
||||
Map<Long, SysTabMappingVo> mappingVoMap = mappingInfoListByLinkId.stream().collect(Collectors.toMap(SysTabMappingVo::getId, Function.identity(), (value1, value2) -> value1));
|
||||
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));
|
||||
Map<Long, Integer> collect = mappingInfoListByLinkId.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());
|
||||
@ -431,14 +449,19 @@ public class SysNodeServiceImpl implements SysNodeService {
|
||||
List<SysTabMapping> list = new ArrayList<>();
|
||||
SysUserVo sysUserVo = (SysUserVo) StpUtil.getTokenSession().get(SessionUtil.SESSION_USER_KEY);
|
||||
for (SysTabMappingVo imp : impList) {
|
||||
SysTabMapping rec = sysImptabmappingMapper.selectById(imp.getId());
|
||||
rec.setUpdatedTime(new Date());
|
||||
rec.setUpdatedBy(sysUserVo.getAccount());
|
||||
rec.setParams(imp.getParams());
|
||||
list.add(rec);
|
||||
//根据key拿到配置
|
||||
SysTabMappingVo sysTabMappingVo = mappingVoMap.get(imp.getId());
|
||||
SysTabMapping mapping = new SysTabMapping();
|
||||
BeanCopyUtils.copy(sysTabMappingVo,mapping);
|
||||
mapping.setUpdatedTime(new Date());
|
||||
mapping.setUpdatedBy(sysUserVo.getAccount());
|
||||
mapping.setParams(imp.getParams());
|
||||
list.add(mapping);
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
sysImptabmappingMapper.insertOrUpdateBatch(list);
|
||||
ListUtil.page(list,COMMIT_COUNT, item -> {
|
||||
sysImptabmappingMapper.insertOrUpdateBatch(item);
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
Loading…
Reference in New Issue
Block a user