|
@@ -2,28 +2,36 @@ package org.springblade.business.controller;
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import io.swagger.annotations.*;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
|
|
|
+import lombok.Data;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springblade.business.entity.ContractLog;
|
|
|
import org.springblade.business.service.IContractLogWbsService;
|
|
|
import org.springblade.business.service.IInformationQueryService;
|
|
|
import org.springblade.business.vo.QueryProcessDataVO;
|
|
|
+import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
+import org.springblade.core.log.exception.ServiceException;
|
|
|
import org.springblade.core.mp.support.Condition;
|
|
|
import org.springblade.core.mp.support.Query;
|
|
|
import org.springblade.core.secure.BladeUser;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.core.tool.utils.BeanUtil;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
import org.springblade.manager.entity.WbsTreeContract;
|
|
|
import org.springblade.manager.feign.ContractClient;
|
|
|
import org.springblade.manager.feign.WbsTreeContractClient;
|
|
|
import org.springblade.manager.vo.WbsTreeContractTreeVOS;
|
|
|
+import org.springblade.manager.vo.WbsTreeContractVO8;
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
@@ -33,10 +41,11 @@ import org.springblade.business.wrapper.ConstructionLedgerWrapper;
|
|
|
import org.springblade.business.service.IConstructionLedgerService;
|
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
|
|
|
|
+import java.io.Serializable;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.time.Duration;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -61,6 +70,8 @@ public class ConstructionLedgerController extends BladeController {
|
|
|
|
|
|
private final IContractLogWbsService contractLogWbsService;
|
|
|
|
|
|
+ private final InformationWriteQueryController informationWriteQueryController;
|
|
|
+
|
|
|
/**
|
|
|
* 获取当前合同段的划分树
|
|
|
*
|
|
@@ -103,9 +114,9 @@ public class ConstructionLedgerController extends BladeController {
|
|
|
@PostMapping("/list")
|
|
|
@ApiOperationSupport(order = 2)
|
|
|
@ApiOperation(value = "分页(建议)", notes = "传入constructionLedger")
|
|
|
- public R<IPage<ConstructionLedgerVO>> list(@Valid @RequestBody ConstructionLedgerVO vo) {
|
|
|
-// ConstructionLedger ledger = new ConstructionLedger();
|
|
|
-// BeanUtils.copyProperties(vo, ledger);
|
|
|
+ public R<IPage<ConstructionLedgerVO>> list(@Valid @RequestBody ConstructionLedgerVO vo) throws NoSuchFieldException, IllegalAccessException {
|
|
|
+ //ConstructionLedger ledger = new ConstructionLedger();
|
|
|
+ //BeanUtils.copyProperties(vo, ledger);
|
|
|
|
|
|
Query query = new Query();
|
|
|
query.setCurrent(vo.getCurrent());
|
|
@@ -119,8 +130,17 @@ public class ConstructionLedgerController extends BladeController {
|
|
|
node = this.wbsTreeContractClient.getContractWbsTreeByContractIdAndId(Long.parseLong(vo.getWbsIds().get(0)), vo.getContractId());
|
|
|
}
|
|
|
|
|
|
- List<QueryProcessDataVO> queryDataResult;
|
|
|
- if (!new Integer("6").equals(node.getNodeType()) && ObjectUtil.isNotEmpty(node.getMajorDataType()) && !Arrays.asList("1,2,3,4".split(",")).contains(node.getMajorDataType().toString())) {
|
|
|
+ if (node.getParentId().equals(0L)) {
|
|
|
+ throw new ServiceException("请从第三层级节点开始进行检索");
|
|
|
+ } else if (node.getAncestors().split(",").length == 2) {
|
|
|
+ WbsTreeContract root = wbsTreeContractClient.getContractWbsTreeByContractIdAndId(node.getParentId(), Long.parseLong(node.getContractId()));
|
|
|
+ if (root.getParentId().equals(0L)) {
|
|
|
+ throw new ServiceException("请从第三层级节点开始进行检索");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /*List<QueryProcessDataVO> queryDataResult;
|
|
|
+ if (!new Integer("6").equals(node.getNodeType()) && ObjectUtil.isNotEmpty(node.getMajorDataType()) && !Arrays.asList("1,2,3,4".split(",")).contains(node.getMajorDataType().toString())) {
|
|
|
//非填报节点
|
|
|
queryDataResult = this.informationQueryService.queryProcessDataByParentIdAndContractId(node.getId().toString(), 1, vo.getContractId().toString());
|
|
|
} else {
|
|
@@ -128,6 +148,20 @@ public class ConstructionLedgerController extends BladeController {
|
|
|
queryDataResult = this.informationQueryService.queryProcessDataByPrimaryKeyIdAndClassify(node.getPKeyId().toString(), 1);
|
|
|
}
|
|
|
vo.setWbsIds(queryDataResult.stream().map(QueryProcessDataVO::getPrimaryKeyId).distinct().collect(Collectors.toList()));
|
|
|
+ */
|
|
|
+
|
|
|
+ List<WbsTreeContractVO8> lowestNodes = new ArrayList<>();
|
|
|
+ WbsTreeContractVO8 vo8 = BeanUtil.copyProperties(node, WbsTreeContractVO8.class);
|
|
|
+ informationWriteQueryController.lowestNodesRecursively(lowestNodes, Collections.singleton(vo8), node.getContractId());
|
|
|
+
|
|
|
+ if (lowestNodes.size() <= 0) {
|
|
|
+ if (!node.getNodeType().equals(6)) {
|
|
|
+ return R.data(null);
|
|
|
+ }
|
|
|
+ vo.setWbsIds(Collections.singletonList(String.valueOf(node.getPKeyId())));
|
|
|
+ } else {
|
|
|
+ vo.setWbsIds(lowestNodes.stream().distinct().map(WbsTreeContractVO8::getPKeyId).map(String::valueOf).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
|
|
|
if (vo.getSiteStartTime() != null && vo.getSiteEndTime() != null) {
|
|
|
pages = this.constructionLedgerService.page(Condition.getPage(query), Condition.getQueryWrapper(new ConstructionLedger()).lambda().in(ConstructionLedger::getWbsId, vo.getWbsIds()).between(ConstructionLedger::getSiteStartTime, vo.getSiteStartTime(), vo.getSiteEndTime()));
|
|
@@ -136,10 +170,30 @@ public class ConstructionLedgerController extends BladeController {
|
|
|
}
|
|
|
|
|
|
IPage<ConstructionLedgerVO> voiPage = ConstructionLedgerWrapper.build().pageVO(pages);
|
|
|
+ List<ConstructionLedgerVO> records = voiPage.getRecords();
|
|
|
+ if (records.size() <= 0) {
|
|
|
+ return R.data(null);
|
|
|
+ }
|
|
|
+
|
|
|
+ Set<String> collect = voiPage.getRecords().stream().map(ConstructionLedgerVO::getWbsId).map(String::valueOf).collect(Collectors.toSet());
|
|
|
+ List<String> wbsIds = vo.getWbsIds();
|
|
|
+ List<String> supplementPKeyIds = wbsIds.stream().filter(f -> !collect.contains(f)).distinct().collect(Collectors.toList());
|
|
|
+ if (supplementPKeyIds.size() > 0) {
|
|
|
+ supplementConstructionLedger(supplementPKeyIds, node);
|
|
|
+ }
|
|
|
|
|
|
+ //找到最开始的施工日志,如果存在数据则使用最开始的时间,如果没有再使用自定义编辑的时间
|
|
|
+ List<Long> param = voiPage.getRecords().stream().map(ConstructionLedgerVO::getWbsId).distinct().collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<ContractLog> contractLogs = this.contractLogWbsService.queryContractLogNewOrOldDataBySelectPrimaryKeyIdAndClassify(new ListDTO(param, 7, "OLD"));
|
|
|
+ Map<Long, ContractLog> maps = contractLogs.stream().collect(Collectors.toMap(ContractLog::getId, Function.identity()));
|
|
|
voiPage.getRecords().forEach(vos -> {
|
|
|
+
|
|
|
+ vos.setStation(vos.getSite()); //TODO 暂时这样处理
|
|
|
+
|
|
|
//找到最开始的施工日志,如果存在数据则使用最开始的时间,如果没有再使用自定义编辑的时间
|
|
|
- ContractLog contractLog = this.contractLogWbsService.queryContractLogNewOrOldDataBySelectPrimaryKeyIdAndClassify(vos.getWbsId().toString(), 7, "OLD");
|
|
|
+ //ContractLog contractLog = this.contractLogWbsService.queryContractLogNewOrOldDataBySelectPrimaryKeyIdAndClassify(vos.getWbsId().toString(), 7, "OLD");
|
|
|
+ ContractLog contractLog = maps.getOrDefault(vos.getWbsId(), null);
|
|
|
if (contractLog != null) {
|
|
|
//获取最开始的填报时间
|
|
|
String recordTime = contractLog.getRecordTime();
|
|
@@ -162,7 +216,6 @@ public class ConstructionLedgerController extends BladeController {
|
|
|
vos.setSiteTimeStr(DateUtil.format(vos.getSiteStartTime(), "yyyy-MM-dd"));
|
|
|
}
|
|
|
|
|
|
-
|
|
|
vos.setDetectionTimeStr(DateUtil.format(vos.getSiteEndTime(), "yyyy-MM-dd"));
|
|
|
vos.setDetectionStartTimeValue(DateUtil.format(vos.getDetectionStartTime(), "yyyy-MM-dd"));
|
|
|
vos.setDetectionEndTimeValue(DateUtil.format(vos.getDetectionEndTime(), "yyyy-MM-dd"));
|
|
@@ -180,6 +233,56 @@ public class ConstructionLedgerController extends BladeController {
|
|
|
return R.data(voiPage);
|
|
|
}
|
|
|
|
|
|
+ @Data
|
|
|
+ public class ListDTO implements Serializable {
|
|
|
+ List<Long> pKeyIds;
|
|
|
+ Integer classify;
|
|
|
+ String newOrOld;
|
|
|
+
|
|
|
+ public ListDTO(List<Long> pKeyIds, Integer classify, String newOrOld) {
|
|
|
+ this.pKeyIds = pKeyIds;
|
|
|
+ this.classify = classify;
|
|
|
+ this.newOrOld = newOrOld;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 增补台账
|
|
|
+ */
|
|
|
+ @Async
|
|
|
+ public void supplementConstructionLedger(List<String> supplementPKeyIds, WbsTreeContract node) {
|
|
|
+ List<ConstructionLedger> alreadyExistConstructionLedgers = constructionLedgerService.getBaseMapper().selectList(Wrappers.<ConstructionLedger>lambdaQuery().select(ConstructionLedger::getWbsId).in(ConstructionLedger::getWbsId, supplementPKeyIds));
|
|
|
+ if (!alreadyExistConstructionLedgers.isEmpty()) {
|
|
|
+ Set<String> wbsIds = alreadyExistConstructionLedgers.stream().map(ConstructionLedger::getWbsId).map(String::valueOf).collect(Collectors.toSet());
|
|
|
+ supplementPKeyIds.removeIf(wbsIds::contains);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (supplementPKeyIds.size() > 0) {
|
|
|
+ List<WbsTreeContract> contractNodeByPrimaryKeyIds = wbsTreeContractClient.getContractNodeByPrimaryKeyIds(supplementPKeyIds); //只获取工序节点
|
|
|
+ if (contractNodeByPrimaryKeyIds.size() > 0) {
|
|
|
+ List<ConstructionLedger> constructionLedgers = new ArrayList<>();
|
|
|
+ for (WbsTreeContract wbsTreeContract : contractNodeByPrimaryKeyIds) {
|
|
|
+ ConstructionLedger ledger = new ConstructionLedger();
|
|
|
+ ledger.setId(SnowFlakeUtil.getId());
|
|
|
+ ledger.setStation(ObjectUtil.isNotEmpty(wbsTreeContract.getFullName()) ? wbsTreeContract.getFullName() : wbsTreeContract.getNodeName());
|
|
|
+ ledger.setSite(ObjectUtil.isNotEmpty(wbsTreeContract.getFullName()) ? wbsTreeContract.getFullName() : wbsTreeContract.getNodeName());
|
|
|
+
|
|
|
+ ledger.setIsBeton(wbsTreeContract.getIsConcrete());
|
|
|
+ ledger.setWbsId(wbsTreeContract.getPKeyId());
|
|
|
+
|
|
|
+ ledger.setContractId(Long.parseLong(node.getContractId()));
|
|
|
+ ledger.setProjectId(Long.parseLong(node.getProjectId()));
|
|
|
+ ledger.setCreateTime(new Date());
|
|
|
+ ledger.setCreateUser(AuthUtil.getUserId());
|
|
|
+ ledger.setIsDeleted(0);
|
|
|
+
|
|
|
+ constructionLedgers.add(ledger);
|
|
|
+ }
|
|
|
+ constructionLedgerService.saveBatch(constructionLedgers, 1000);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 新增
|
|
|
*/
|