|
@@ -24,17 +24,21 @@ import lombok.AllArgsConstructor;
|
|
|
import javax.validation.Valid;
|
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
+import org.springblade.business.entity.ConstructionLedger;
|
|
|
import org.springblade.business.entity.ContractTreeDrawings;
|
|
|
import org.springblade.business.entity.TreeContractFirst;
|
|
|
import org.springblade.business.feignClient.ClientTreePublicCodeClientImpl;
|
|
|
+import org.springblade.business.service.IConstructionLedgerService;
|
|
|
import org.springblade.business.service.IContractTreeDrawingsService;
|
|
|
import org.springblade.business.service.ITreeContractFirstService;
|
|
|
+import org.springblade.business.vo.CopyContractTreeNodeVO;
|
|
|
import org.springblade.business.vo.FileUserVO;
|
|
|
import org.springblade.business.vo.InformationQueryVO;
|
|
|
-import org.springblade.business.vo.SaveNodeVO;
|
|
|
+import org.springblade.business.vo.AddContractTreeNodeVO;
|
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
import org.springblade.core.mp.support.Condition;
|
|
|
import org.springblade.core.mp.support.Query;
|
|
|
+import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
import org.springblade.manager.entity.ContractInfo;
|
|
@@ -83,6 +87,169 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
|
|
|
private final ITreeContractFirstService treeContractFirstService;
|
|
|
|
|
|
+ private final IConstructionLedgerService constructionLedgerService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 复制节点
|
|
|
+ */
|
|
|
+ @PostMapping("/copyContractTreeNode")
|
|
|
+ @ApiOperationSupport(order = 15)
|
|
|
+ @ApiOperation(value = "复制节点")
|
|
|
+ public R<Boolean> copyContractTreeNode(@RequestBody CopyContractTreeNodeVO vo){
|
|
|
+
|
|
|
+ //首先查询需要复制的节点及其下级所有子节点的信息
|
|
|
+ WbsTreeContract needCopyNode = this.wbsTreeContractClient.getContractNodeByPrimaryKeyId(vo.getNeedCopyPrimaryKeyId());
|
|
|
+
|
|
|
+ List<WbsTreeContract> parentList = new ArrayList<>(), childList = new ArrayList<>(), allList = new ArrayList<>(), saveList = new ArrayList<>();
|
|
|
+ //新增施工台账
|
|
|
+ List<ConstructionLedger> saveLedger = new ArrayList<>();
|
|
|
+
|
|
|
+ parentList.add(needCopyNode);
|
|
|
+ //查询所有有效子节点
|
|
|
+ this.foreachQueryChildContract(parentList, childList);
|
|
|
+ allList.addAll(parentList);
|
|
|
+ allList.addAll(childList);
|
|
|
+
|
|
|
+ if("1".equals(vo.getCopyType())){
|
|
|
+ if(StringUtils.isNotEmpty(vo.getNeedCopyPrimaryKeyId())){
|
|
|
+ WbsTreeContract parent = this.wbsTreeContractClient.getContractNodeByPrimaryKeyId(vo.getParentPrimaryKeyId());
|
|
|
+ //重塑关键信息
|
|
|
+ Map<Long,Long> oldToNewIdMap = new HashMap<>();
|
|
|
+ allList.forEach(node -> oldToNewIdMap.put(node.getId(), SnowFlakeUtil.getId()));
|
|
|
+ //todo 单份复制
|
|
|
+ allList.forEach(node -> {
|
|
|
+ WbsTreeContract newData = new WbsTreeContract();
|
|
|
+ BeanUtils.copyProperties(node, newData);
|
|
|
+
|
|
|
+ //重塑关键信息
|
|
|
+ //重塑primaryKeyId
|
|
|
+ newData.setPKeyId(SnowFlakeUtil.getId());
|
|
|
+ //设置旧ID
|
|
|
+ newData.setOldId(node.getId().toString());
|
|
|
+ //设置新ID
|
|
|
+ newData.setId(oldToNewIdMap.containsKey(node.getId()) ? oldToNewIdMap.get(node.getId()) : SnowFlakeUtil.getId());
|
|
|
+ //设置父节点ID
|
|
|
+ if(vo.getNeedCopyPrimaryKeyId().equals(node.getPKeyId().toString())){
|
|
|
+ //找到复制的节点,将parentId更改为 parent.getId()
|
|
|
+ newData.setParentId(parent.getId());
|
|
|
+ //设置新名称
|
|
|
+ newData.setDeptName(vo.getNeedCopyNodeName());
|
|
|
+ newData.setFullName(vo.getNeedCopyNodeName());
|
|
|
+ } else {
|
|
|
+ newData.setParentId(oldToNewIdMap.containsKey(node.getParentId()) ? oldToNewIdMap.get(node.getParentId()) : SnowFlakeUtil.getId());
|
|
|
+ }
|
|
|
+ newData.setCreateTime(new Date());
|
|
|
+ newData.setUpdateTime(new Date());
|
|
|
+ newData.setCreateUser(AuthUtil.getUserId());
|
|
|
+ //保存到集合中
|
|
|
+ saveList.add(newData);
|
|
|
+
|
|
|
+ if(new Integer("6").equals(node.getDeptCategory())){
|
|
|
+ //生成施工日志
|
|
|
+ this.createLedger(newData, saveLedger);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ //todo 多份复制
|
|
|
+ //获取需要复制到的位置集合
|
|
|
+ List<CopyContractTreeNodeVO.CopyBatch> copyBatches = vo.getCopyBatchToPaths();
|
|
|
+ if(copyBatches.size() > 0){
|
|
|
+ copyBatches.forEach(copyBatch -> {
|
|
|
+ //查询复制到的位置信息
|
|
|
+ WbsTreeContract copyPath = this.wbsTreeContractClient.getContractNodeByPrimaryKeyId(copyBatch.getPrimaryKeyId());
|
|
|
+
|
|
|
+ //重塑关键信息
|
|
|
+ Map<Long,Long> oldToNewIdMap = new HashMap<>();
|
|
|
+ allList.forEach(node -> oldToNewIdMap.put(node.getId(), SnowFlakeUtil.getId()));
|
|
|
+
|
|
|
+ allList.forEach(node -> {
|
|
|
+ WbsTreeContract newData = new WbsTreeContract();
|
|
|
+ BeanUtils.copyProperties(node, newData);
|
|
|
+
|
|
|
+ //重塑关键信息
|
|
|
+ //设置旧ID
|
|
|
+ newData.setOldId(node.getId().toString());
|
|
|
+ //重塑primaryKeyId
|
|
|
+ newData.setPKeyId(SnowFlakeUtil.getId());
|
|
|
+ //设置新ID
|
|
|
+ newData.setId(oldToNewIdMap.containsKey(node.getId()) ? oldToNewIdMap.get(node.getId()) : SnowFlakeUtil.getId());
|
|
|
+ //设置父节点ID
|
|
|
+ if(vo.getNeedCopyPrimaryKeyId().equals(node.getPKeyId().toString())){
|
|
|
+ //找到复制的节点,将parentId更改为 parent.getId()
|
|
|
+ newData.setParentId(copyPath.getId());
|
|
|
+ //设置新名称
|
|
|
+ newData.setDeptName(copyBatch.getNodeName());
|
|
|
+ newData.setFullName(copyBatch.getNodeName());
|
|
|
+ } else {
|
|
|
+ newData.setParentId(oldToNewIdMap.containsKey(node.getParentId()) ? oldToNewIdMap.get(node.getParentId()) : SnowFlakeUtil.getId());
|
|
|
+ }
|
|
|
+ newData.setCreateTime(new Date());
|
|
|
+ newData.setUpdateTime(new Date());
|
|
|
+ newData.setCreateUser(AuthUtil.getUserId());
|
|
|
+ //保存到集合中
|
|
|
+ saveList.add(newData);
|
|
|
+
|
|
|
+ if(new Integer("6").equals(node.getDeptCategory())){
|
|
|
+ //生成施工日志
|
|
|
+ this.createLedger(newData, saveLedger);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(saveList.size() > 0){
|
|
|
+ //保存施工日志
|
|
|
+ if(saveLedger.size() > 0){
|
|
|
+ this.constructionLedgerService.saveBatch(saveLedger);
|
|
|
+ }
|
|
|
+
|
|
|
+ //保存节点
|
|
|
+ return R.data(this.wbsTreeContractClient.saveBatch(saveList));
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.data(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成施工日志记录
|
|
|
+ */
|
|
|
+ private void createLedger(WbsTreeContract newData, List<ConstructionLedger> saveLedger){
|
|
|
+ //工序,需要新增施工台账
|
|
|
+ ConstructionLedger ledger = new ConstructionLedger();
|
|
|
+ ledger.setSite(newData.getDeptName());
|
|
|
+ ledger.setIsBeton(newData.getIsConcrete());
|
|
|
+ ledger.setWbsId(newData.getPKeyId());
|
|
|
+ ledger.setContractId(Long.parseLong(newData.getContractId()));
|
|
|
+ ledger.setProjectId(Long.parseLong(newData.getProjectId()));
|
|
|
+ ledger.setCreateTime(new Date());
|
|
|
+ ledger.setCreateUser(AuthUtil.getUserId());
|
|
|
+ ledger.setIsDeleted(0);
|
|
|
+ saveLedger.add(ledger);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 循环查询子节点
|
|
|
+ * @param parentList 父节点集合
|
|
|
+ * @param childList 保存集合
|
|
|
+ */
|
|
|
+ private void foreachQueryChildContract(List<WbsTreeContract> parentList, List<WbsTreeContract> childList){
|
|
|
+ parentList.forEach(parent -> {
|
|
|
+ if(!new Integer("6").equals(parent.getDeptCategory())){
|
|
|
+ //查询子节点
|
|
|
+ List<WbsTreeContract> childs = this.wbsTreeContractClient.queryChildByParentId(parent);
|
|
|
+ if(childs != null && childs.size() > 0){
|
|
|
+ //添加入结果集
|
|
|
+ childList.addAll(childs);
|
|
|
+ //还有子级,继续向下
|
|
|
+ this.foreachQueryChildContract(childs, childList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 导图结构树节点查询
|
|
|
* @return 结果
|
|
@@ -216,7 +383,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
@PostMapping("/saveContractTreeNode")
|
|
|
@ApiOperationSupport(order = 10)
|
|
|
@ApiOperation(value = "新增节点及其子节点")
|
|
|
- public R<Boolean> saveContractTreeNode(@RequestBody SaveNodeVO vo){
|
|
|
+ public R<Boolean> saveContractTreeNode(@RequestBody AddContractTreeNodeVO vo){
|
|
|
//先获取当前节点的信息
|
|
|
WbsTreeContract treeContract = this.wbsTreeContractClient.getContractWbsTreeByPrimaryKeyId(Long.parseLong(vo.getCurrentNodePrimaryKeyId()));
|
|
|
|
|
@@ -285,6 +452,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
|
|
|
//保存集合
|
|
|
List<WbsTreeContract> saveList = new ArrayList<>();
|
|
|
+ List<ConstructionLedger> saveLedger = new ArrayList<>();
|
|
|
if(selectedNodeList.size() > 0){
|
|
|
//重塑关键信息
|
|
|
Map<Long, Long> OldIdToNewIdMap = new HashMap<>();
|
|
@@ -310,14 +478,25 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
newData.setCreateTime(new Date());
|
|
|
//设置到保存集合中
|
|
|
saveList.add(newData);
|
|
|
+
|
|
|
+ if(new Integer("6").equals(newData.getDeptCategory())){
|
|
|
+ //生成施工日志
|
|
|
+ this.createLedger(newData, saveLedger);
|
|
|
+ }
|
|
|
+
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if(saveList.size() > 0){
|
|
|
- this.wbsTreeContractClient.saveBatch(saveList);
|
|
|
+ //保存施工日志
|
|
|
+ if(saveLedger.size() > 0){
|
|
|
+ this.constructionLedgerService.saveBatch(saveLedger);
|
|
|
+ }
|
|
|
+ //保存节点
|
|
|
+ return R.data(this.wbsTreeContractClient.saveBatch(saveList));
|
|
|
}
|
|
|
|
|
|
- return R.data(true);
|
|
|
+ return R.data(false);
|
|
|
}
|
|
|
|
|
|
/**
|