|
@@ -1,10 +1,10 @@
|
|
|
package org.springblade.manager.service.impl;
|
|
|
|
|
|
-
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springblade.business.entity.ConstructionLedger;
|
|
|
+import org.springblade.business.entity.InformationQuery;
|
|
|
import org.springblade.business.feign.ConstructionLedgerFeignClient;
|
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
import org.springblade.core.log.exception.ServiceException;
|
|
@@ -12,13 +12,12 @@ import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.node.ForestNodeMerger;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
+import org.springblade.core.tool.utils.StringUtil;
|
|
|
import org.springblade.manager.dto.WbsTreeContractDTO;
|
|
|
import org.springblade.manager.entity.*;
|
|
|
-import org.springblade.manager.mapper.WbsInfoMapper;
|
|
|
import org.springblade.manager.mapper.WbsTreeContractMapper;
|
|
|
import org.springblade.manager.mapper.WbsTreePrivateMapper;
|
|
|
import org.springblade.manager.service.IWbsTreeContractService;
|
|
|
-import org.springblade.manager.vo.TreeNodeVO;
|
|
|
import org.springblade.manager.vo.WbsTreeContractTreeVO;
|
|
|
import org.springblade.manager.vo.WbsTreeContractTreeVO3;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -47,10 +46,12 @@ public class WbsTreeContractServiceImpl
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 合同段wbs树保存
|
|
|
+ * 合同段wbs树保存1
|
|
|
+ * @deprecated
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
+ @Deprecated
|
|
|
public boolean submitWbsTreeInContract(WbsTreeContractDTO pawDTO) {
|
|
|
String wbsTreeIds = pawDTO.getWbsTreeIds();
|
|
|
String[] ids = wbsTreeIds.split(",");
|
|
@@ -122,7 +123,7 @@ public class WbsTreeContractServiceImpl
|
|
|
wbsTreePrivateList.stream().forEach(wbsTreePrivate -> {
|
|
|
diffRent1.stream().forEach(id -> {
|
|
|
if (Long.parseLong(id) == (wbsTreePrivate.getId())) {
|
|
|
- WbsTreeContract wbsTreeContract = getWbsTreePrivate(wbsTreePrivate, pawDTO);
|
|
|
+ WbsTreeContract wbsTreeContract = getWbsTreeContract(wbsTreePrivate, pawDTO);
|
|
|
wbsTreeContracts.add(wbsTreeContract);
|
|
|
}
|
|
|
});
|
|
@@ -157,7 +158,7 @@ public class WbsTreeContractServiceImpl
|
|
|
//初始化
|
|
|
wbsTreePrivatesList.stream().forEach(wbsTreePrivate -> {
|
|
|
//节点、表信息
|
|
|
- WbsTreeContract wbsTreeContract = getWbsTreePrivate(wbsTreePrivate, pawDTO);
|
|
|
+ WbsTreeContract wbsTreeContract = getWbsTreeContract(wbsTreePrivate, pawDTO);
|
|
|
wbsTreeContractList.add(wbsTreeContract);
|
|
|
|
|
|
//台账信息
|
|
@@ -195,7 +196,191 @@ public class WbsTreeContractServiceImpl
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- private WbsTreeContract getWbsTreePrivate(WbsTreePrivate wbsTree, WbsTreeContractDTO pawDTO) {
|
|
|
+ /**
|
|
|
+ * 合同段wbs树保存2
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public boolean submitWbsTreeInContract1(WbsTreeContractDTO pawDTO) {
|
|
|
+ String wbsTreeIds = pawDTO.getWbsTreeIds();
|
|
|
+ String[] ids = wbsTreeIds.split(",");
|
|
|
+ List<String> idList = Arrays.asList(ids);
|
|
|
+ List<String> idList1 = idList.stream().filter(string -> !string.isEmpty()).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //获取当前合同段wbs所有节点+表单
|
|
|
+ List<WbsTreeContract> list = baseMapper.findAllNodeList2(pawDTO.getProjectId(), pawDTO.getContractId(), pawDTO.getWbsId());
|
|
|
+
|
|
|
+ //当前合同段所有节点下表单Id
|
|
|
+ List<String> collect3 = new ArrayList<>();
|
|
|
+ //当前合同段所有节点Id
|
|
|
+ List<String> collect7 = new ArrayList<>();
|
|
|
+
|
|
|
+ if (list.size() > 0) {
|
|
|
+ //节点下所有表单Id
|
|
|
+ List<WbsTreeContract> collect2 = list.stream().filter(f -> f.getType() == 2).collect(Collectors.toList());
|
|
|
+ List<Long> collect4 = collect2.stream().map(WbsTreeContract::getId).collect(Collectors.toList());
|
|
|
+ collect3 = collect4.stream().map(String::valueOf).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //所有节点
|
|
|
+ List<WbsTreeContract> collect5 = list.stream().filter(f -> f.getType() == 1).collect(Collectors.toList());
|
|
|
+ List<Long> collect6 = collect5.stream().map(WbsTreeContract::getId).collect(Collectors.toList());
|
|
|
+ collect7 = collect6.stream().map(String::valueOf).collect(Collectors.toList());
|
|
|
+
|
|
|
+ }
|
|
|
+ //idList1-入参ids、collect7-当前项目所有节点ids
|
|
|
+ //需要新增的节点ids
|
|
|
+ List<String> collect8 = collect7;
|
|
|
+ List<String> saveIds = idList1.stream().filter(f -> !collect8.contains(f)).collect(Collectors.toList());
|
|
|
+ //需要删除的节点ids
|
|
|
+ List<String> delIds = collect8.stream().filter(f -> !idList1.contains(f)).collect(Collectors.toList());
|
|
|
+
|
|
|
+ if (saveIds.size() == 0 && delIds.size() == 0) {
|
|
|
+ //节点id未变,只进行节点下的元素表的同步
|
|
|
+ List<WbsTreePrivate> wbsTreePrivateList2 = new ArrayList<>();
|
|
|
+ //获取私有wbs树下所有元素表
|
|
|
+ List<WbsTreePrivate> wbsTreePrivateList = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>query().lambda()
|
|
|
+ .eq(WbsTreePrivate::getProjectId, pawDTO.getProjectId())
|
|
|
+ .eq(WbsTreePrivate::getWbsId, pawDTO.getWbsId())
|
|
|
+ .eq(WbsTreePrivate::getType, 2)
|
|
|
+ );
|
|
|
+
|
|
|
+ //只获取当前引用节点下的所有表
|
|
|
+ wbsTreePrivateList.stream().forEach(wbsTreePrivate -> {
|
|
|
+ idList1.stream().forEach(id -> {
|
|
|
+ if (Long.parseLong(id) == (wbsTreePrivate.getParentId()) && wbsTreePrivate.getType() == 2) {
|
|
|
+ //表
|
|
|
+ wbsTreePrivateList2.add(wbsTreePrivate);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ //私有wbs树下所有元素表的Id collect2
|
|
|
+ List<Long> collect = wbsTreePrivateList2.stream().map(WbsTreePrivate::getId).collect(Collectors.toList());
|
|
|
+ List<String> collect2 = collect.stream().map(String::valueOf).collect(Collectors.toList());
|
|
|
+ //获取所有wbsTreePrivate新增的表单Id
|
|
|
+ List<String> diffRent1 = getDiffrent(collect2, collect3);
|
|
|
+
|
|
|
+ if (collect2.size() == collect3.size()) {
|
|
|
+ throw new ServiceException("未检测到当前引用的私有wbs树下有新增的元素表");
|
|
|
+ }
|
|
|
+ if (collect2.size() > collect3.size()) {
|
|
|
+ //初始化
|
|
|
+ List<WbsTreeContract> wbsTreeContracts = new ArrayList<>();
|
|
|
+ wbsTreePrivateList.stream().forEach(wbsTreePrivate -> {
|
|
|
+ diffRent1.stream().forEach(id -> {
|
|
|
+ if (Long.parseLong(id) == (wbsTreePrivate.getId())) {
|
|
|
+ WbsTreeContract wbsTreeContract = getWbsTreeContract(wbsTreePrivate, pawDTO);
|
|
|
+ wbsTreeContracts.add(wbsTreeContract);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ this.saveBatch(wbsTreeContracts, 10000);
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ //节点id改变,进行新增或删除节点以及该节点下的元素表
|
|
|
+
|
|
|
+ //删除
|
|
|
+ if (delIds.size() > 0) {
|
|
|
+ //判断是否被监理合同引用
|
|
|
+ List<ContractRelationJlyz> contractRelationJLYZList = baseMapper.selectContractRelationInfoByidSG2(pawDTO.getContractId());
|
|
|
+ if (contractRelationJLYZList.size() > 0) {
|
|
|
+ throw new ServiceException("当前施工合同段wbs树被监理或业主合同段引用中,删除失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Long> ids1 = delIds.stream().map(Long::parseLong).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //获取当前节点、表的信息
|
|
|
+ List<WbsTreeContract> wbsTreeContractList = baseMapper.selectTableListInfo(ids1, pawDTO.getWbsId(), pawDTO.getProjectId(), pawDTO.getContractId());
|
|
|
+
|
|
|
+ //获取当前表的pKeyId
|
|
|
+ List<Long> pKeyIds = wbsTreeContractList.stream().filter(f -> f.getType() == 2).
|
|
|
+ map(WbsTreeContract::getPKeyId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //判断客户端在当前节点下的元素表是否有填报记录
|
|
|
+ List<InformationQuery> inFormationQueryInfoList = baseMapper.selectInformationQueryInfo(pKeyIds);
|
|
|
+
|
|
|
+ List<WbsTreeContract> wbsTreeContractTables = new ArrayList<>();
|
|
|
+
|
|
|
+ for (WbsTreeContract wbsTreeContract : wbsTreeContractList) {
|
|
|
+ for (InformationQuery informationQuery : inFormationQueryInfoList) {
|
|
|
+ if (informationQuery.getWbsId().equals(wbsTreeContract.getPKeyId())) {
|
|
|
+ wbsTreeContractTables.add(wbsTreeContract);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<WbsTreeContract> collect = wbsTreeContractList.stream()
|
|
|
+ .filter(f ->
|
|
|
+ wbsTreeContractTables.stream().map(WbsTreeContract::getParentId).collect(Collectors.toList()).contains(f.getId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ List<String> nodeNames = collect.stream().map(WbsTreeContract::getDeptName).collect(Collectors.toList());
|
|
|
+
|
|
|
+ if (inFormationQueryInfoList.size() > 0) {
|
|
|
+ String names = StringUtils.join(nodeNames, " , ");
|
|
|
+ throw new ServiceException(StringUtil.format("节点【{}】 下存在填报数据,删除失败!", names));
|
|
|
+ }
|
|
|
+
|
|
|
+ //删除
|
|
|
+ baseMapper.deleteBatch(ids1, pawDTO.getWbsId(), pawDTO.getProjectId(), pawDTO.getContractId());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //新增
|
|
|
+ if (saveIds.size() > 0) {
|
|
|
+ List<WbsTreeContract> wbsTreeContractList = new ArrayList<>();
|
|
|
+ List<WbsTreePrivate> wbsTreePrivatesList = new ArrayList<>();
|
|
|
+ ArrayList<ConstructionLedger> constructionLedgerList = new ArrayList<>();
|
|
|
+
|
|
|
+ //获取wbs私有树下节点+表 saveIds=新增的节点id
|
|
|
+ List<WbsTreePrivate> wbsTreePrivates = wbsTreePrivateMapper.selectNodeAndTable2(pawDTO.getWbsId(), pawDTO.getProjectId());
|
|
|
+ for (WbsTreePrivate wbsTreePrivate : wbsTreePrivates) {
|
|
|
+ for (String id : saveIds) {
|
|
|
+ if (Long.parseLong(id) == (wbsTreePrivate.getId())) {
|
|
|
+ //节点
|
|
|
+ wbsTreePrivatesList.add(wbsTreePrivate);
|
|
|
+ } else if (Long.parseLong(id) == (wbsTreePrivate.getParentId()) && wbsTreePrivate.getType() == 2) {
|
|
|
+ //表
|
|
|
+ wbsTreePrivatesList.add(wbsTreePrivate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //初始化
|
|
|
+ wbsTreePrivatesList.stream().forEach(wbsTreePrivate -> {
|
|
|
+ //节点、表信息
|
|
|
+ WbsTreeContract wbsTreeContract = getWbsTreeContract(wbsTreePrivate, pawDTO);
|
|
|
+ wbsTreeContractList.add(wbsTreeContract);
|
|
|
+
|
|
|
+ //台账信息
|
|
|
+ if (wbsTreeContract.getDeptCategory() == 6) {
|
|
|
+ ConstructionLedger constructionLedger = new ConstructionLedger();
|
|
|
+ constructionLedger.setIsBeton(0);
|
|
|
+ constructionLedger.setWbsId(wbsTreeContract.getPKeyId());
|
|
|
+ constructionLedger.setSite(wbsTreeContract.getDeptName());
|
|
|
+ constructionLedger.setStation(wbsTreeContract.getDeptName());
|
|
|
+ constructionLedger.setContractId(Long.parseLong(pawDTO.getContractId()));
|
|
|
+ constructionLedgerList.add(constructionLedger);
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ //新增合同段wbs树、元素表
|
|
|
+ this.saveBatch(wbsTreeContractList, 10000);
|
|
|
+
|
|
|
+ //新增施工台账
|
|
|
+ constructionLedgerFeign.initConstructionLedger(constructionLedgerList);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private WbsTreeContract getWbsTreeContract(WbsTreePrivate wbsTree, WbsTreeContractDTO pawDTO) {
|
|
|
WbsTreeContract wbsTreeContract = new WbsTreeContract();
|
|
|
//数据初始化-施工合同
|
|
|
Long snowId = SnowFlakeUtil.getId();
|