|
@@ -1,5 +1,6 @@
|
|
|
package com.rongwei.bscommon.sys.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.collection.ListUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.rongwei.bscommon.sys.service.ZhcxItpTemplateNodesService;
|
|
|
import com.rongwei.bsentity.domain.ZhcxItpTemplateDo;
|
|
@@ -8,9 +9,11 @@ import com.rongwei.bscommon.sys.service.ZhcxItpTemplateService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.rongwei.bsentity.domain.ZhcxItpTemplateNodesDo;
|
|
|
import com.rongwei.bsentity.vo.CopyAddTemplateVo;
|
|
|
+import com.rongwei.commonservice.service.dao.CommonSqlDao;
|
|
|
import com.rongwei.rwcommon.base.exception.CustomException;
|
|
|
import com.rongwei.rwcommon.utils.SecurityUtil;
|
|
|
import com.rongwei.rwcommon.utils.StringUtils;
|
|
|
+import org.apache.commons.collections.ListUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -31,6 +34,8 @@ public class ZhcxItpTemplateServiceImpl extends ServiceImpl<ZhcxItpTemplateDao,
|
|
|
|
|
|
@Autowired
|
|
|
private ZhcxItpTemplateNodesService zhcxItpTemplateNodesService;
|
|
|
+ @Autowired
|
|
|
+ private CommonSqlDao commonSqlDao;
|
|
|
|
|
|
/**
|
|
|
* 复制新增的引用所有子节点
|
|
@@ -38,6 +43,8 @@ public class ZhcxItpTemplateServiceImpl extends ServiceImpl<ZhcxItpTemplateDao,
|
|
|
*/
|
|
|
@Override
|
|
|
public void copyAddTemplateNodes(CopyAddTemplateVo copyAddTemplate) {
|
|
|
+ // 待复制保存的子节点
|
|
|
+ List<ZhcxItpTemplateNodesDo> toCopySaveNodes = new ArrayList<>();
|
|
|
if(StringUtils.isBlank(copyAddTemplate.getTargetTmpId())){
|
|
|
throw new CustomException("数据有问题,ID没有值");
|
|
|
}
|
|
@@ -51,8 +58,6 @@ public class ZhcxItpTemplateServiceImpl extends ServiceImpl<ZhcxItpTemplateDao,
|
|
|
new LambdaQueryWrapper<ZhcxItpTemplateNodesDo>().eq(ZhcxItpTemplateNodesDo::getItpid,copyAddTemplate.getTargetTmpId()));
|
|
|
// 过滤出当前ITP地图模板所有根节点
|
|
|
List<ZhcxItpTemplateNodesDo> rootTargetNodes = targetNodesDos.stream().filter(v -> v.getPid().equals("-1")).collect(Collectors.toList());
|
|
|
- // 待复制保存的子节点
|
|
|
- List<ZhcxItpTemplateNodesDo> toCopySaveNodes = new ArrayList<>();
|
|
|
// 存放老ID和新ID的Map,方便后面的归属大构件ID替换
|
|
|
Map<String,String> oldNewId = new HashMap<>();
|
|
|
for (ZhcxItpTemplateNodesDo copyNodesDo : copyNodesDos) {
|
|
@@ -92,9 +97,59 @@ public class ZhcxItpTemplateServiceImpl extends ServiceImpl<ZhcxItpTemplateDao,
|
|
|
copyNodesDo.setPid(oldNewId.get(copyNodesDo.getPid()));
|
|
|
}
|
|
|
}
|
|
|
- // 保存最终数据
|
|
|
- zhcxItpTemplateNodesService.saveBatch(toCopySaveNodes);
|
|
|
}
|
|
|
}
|
|
|
+ // 保存数据
|
|
|
+ if(toCopySaveNodes != null && toCopySaveNodes.size()>0){
|
|
|
+ // 保存最终数据
|
|
|
+ zhcxItpTemplateNodesService.saveBatch(toCopySaveNodes);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更换层级引用复制节点并保存层级引用、并返回数据
|
|
|
+ * @param copyAddTemplate
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<Map<String, Object>> copyNodesSave(CopyAddTemplateVo copyAddTemplate){
|
|
|
+ if(StringUtils.isNotBlank(copyAddTemplate.getTargetTmpId()) && copyAddTemplate.getTmpIds() != null && copyAddTemplate.getTmpIds().size()>0){
|
|
|
+ ZhcxItpTemplateDo templateDo = this.getById(copyAddTemplate.getTargetTmpId());
|
|
|
+ List<String> newTempIds = new ArrayList<>();
|
|
|
+
|
|
|
+ String tmpids = "";
|
|
|
+ for (String tmpId : copyAddTemplate.getTmpIds()) {
|
|
|
+ if("".equals(tmpids)){
|
|
|
+ tmpids = tmpId;
|
|
|
+ }else{
|
|
|
+ tmpids = tmpids + "," + tmpId;
|
|
|
+ }
|
|
|
+ if(StringUtils.isBlank(templateDo.getTmpid()) || templateDo.getTmpid().indexOf(tmpId) == -1){
|
|
|
+ newTempIds.add(tmpId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String tmpnames = "";
|
|
|
+ for (String tmpName : copyAddTemplate.getTmpNames()) {
|
|
|
+ if("".equals(tmpnames)){
|
|
|
+ tmpnames = tmpName;
|
|
|
+ }else{
|
|
|
+ tmpnames = tmpnames + "," + tmpName;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 复制节点层级
|
|
|
+ CopyAddTemplateVo newCopyAddTemplate = new CopyAddTemplateVo();
|
|
|
+ newCopyAddTemplate.setTargetTmpId(copyAddTemplate.getTargetTmpId());
|
|
|
+ newCopyAddTemplate.setTmpIds(newTempIds);
|
|
|
+ this.copyAddTemplateNodes(newCopyAddTemplate);
|
|
|
+ // 保存模板引用
|
|
|
+ ZhcxItpTemplateDo zhcxItpTemplate = new ZhcxItpTemplateDo();
|
|
|
+ zhcxItpTemplate.setId(copyAddTemplate.getTargetTmpId());
|
|
|
+ zhcxItpTemplate.setTmpid(tmpids);
|
|
|
+ zhcxItpTemplate.setTmpname(tmpnames);
|
|
|
+ this.updateById(zhcxItpTemplate);
|
|
|
+ }
|
|
|
+ // 返回数据
|
|
|
+ String sql = "select * from zhcx_itp_template_nodes where ITPID='"+ copyAddTemplate.getTargetTmpId() +"' and deleted='0' order by sortindex asc";
|
|
|
+ List<Map<String, Object>> nodes = commonSqlDao.sqlExecutu(sql);
|
|
|
+ return nodes;
|
|
|
}
|
|
|
}
|