|
@@ -16,6 +16,7 @@ import com.rongwei.rwcommon.utils.SecurityUtil;
|
|
|
import com.rongwei.rwcommon.utils.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -41,6 +42,7 @@ public class ZhcxItpTemplateNodesServiceImpl extends ServiceImpl<ZhcxItpTemplate
|
|
|
* @param zhcxItpTemplateNodeSyncProjectVo
|
|
|
*/
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = RuntimeException.class)
|
|
|
public void itpTemplateAddNodeSyncProjects(ZhcxItpTemplateNodeSyncProjectVo zhcxItpTemplateNodeSyncProjectVo){
|
|
|
if(StringUtils.isNotBlank(zhcxItpTemplateNodeSyncProjectVo.getNodeid())
|
|
|
&& zhcxItpTemplateNodeSyncProjectVo.getProjectids() != null && zhcxItpTemplateNodeSyncProjectVo.getProjectids().size()>0){
|
|
@@ -51,17 +53,28 @@ public class ZhcxItpTemplateNodesServiceImpl extends ServiceImpl<ZhcxItpTemplate
|
|
|
Map<String,String> tempProMap = new HashMap<>();
|
|
|
// 获取当前报验点
|
|
|
ZhcxItpTemplateNodesDo baNodes = this.getById(zhcxItpTemplateNodeSyncProjectVo.getNodeid());
|
|
|
- // 查询当前报验点及上级节点和归属大构件
|
|
|
+ // 查询当前报验点及上级节点和以及上级节点归属大构件
|
|
|
List<String> nodeids = new ArrayList<>();
|
|
|
nodeids.add(zhcxItpTemplateNodeSyncProjectVo.getNodeid());
|
|
|
- if(StringUtils.isNotBlank(baNodes.getPnodeid())){
|
|
|
- nodeids.add(baNodes.getPnodeid());
|
|
|
- }
|
|
|
+ // 上级节点
|
|
|
if(StringUtils.isNotBlank(baNodes.getPath())){
|
|
|
nodeids.addAll(Arrays.asList(baNodes.getPath().split(",")));
|
|
|
}
|
|
|
// 查询当前报验点及上级节点
|
|
|
List<ZhcxItpTemplateNodesDo> templateNodess = this.list(new LambdaQueryWrapper<ZhcxItpTemplateNodesDo>().in(ZhcxItpTemplateNodesDo::getId, nodeids));
|
|
|
+ // 归属大构件
|
|
|
+ List<ZhcxItpTemplateNodesDo> templateBigNodess = new ArrayList<>();
|
|
|
+ for (ZhcxItpTemplateNodesDo nodess : templateNodess) {
|
|
|
+ if(StringUtils.isNotBlank(nodess.getPnodeid())){
|
|
|
+ ZhcxItpTemplateNodesDo pnode = this.getById(nodess.getPnodeid());
|
|
|
+ templateBigNodess.add(pnode);
|
|
|
+ nodeids.add(nodess.getPnodeid());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(templateBigNodess != null && templateBigNodess.size()>0){
|
|
|
+ templateNodess.addAll(templateBigNodess);
|
|
|
+ }
|
|
|
+
|
|
|
for (String projectid : zhcxItpTemplateNodeSyncProjectVo.getProjectids()) {
|
|
|
// 查询项目ID关联的机号
|
|
|
String projectDeviceNumberIds = null;
|
|
@@ -85,7 +98,7 @@ public class ZhcxItpTemplateNodesServiceImpl extends ServiceImpl<ZhcxItpTemplate
|
|
|
for (ZhcxItpTemplateNodesDo nodess : templateNodess) {
|
|
|
List<ZhcxItpProjectNodesDo> hasProNodes = projectNodesDos.stream().filter(v -> v.getItpnodeid().equals(nodess.getId())).collect(Collectors.toList());
|
|
|
// 不存在直接新增
|
|
|
- if(hasProNodes == null && hasProNodes.size() == 0){
|
|
|
+ if(hasProNodes == null || hasProNodes.size() == 0){
|
|
|
// 相关属性复制
|
|
|
ZhcxItpProjectNodesDo zhcxItpProjectNodesDo = new ZhcxItpProjectNodesDo();
|
|
|
BeanUtil.copyProperties(nodess,zhcxItpProjectNodesDo);
|
|
@@ -125,6 +138,7 @@ public class ZhcxItpTemplateNodesServiceImpl extends ServiceImpl<ZhcxItpTemplate
|
|
|
toUpdateNode.setNodename(nodess.getNodename());
|
|
|
}
|
|
|
toUpdateNodes.add(toUpdateNode);
|
|
|
+ tempProMap.put(nodess.getId(),itpProjectNodesDo.getId());
|
|
|
}
|
|
|
}
|
|
|
}
|