|
@@ -0,0 +1,108 @@
|
|
|
+package org.springblade.business.controller;
|
|
|
+
|
|
|
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.springblade.business.service.IContractLogWbsService;
|
|
|
+import org.springblade.business.service.IInformationQueryService;
|
|
|
+import org.springblade.business.vo.NeiWaiYeProgressVO;
|
|
|
+import org.springblade.business.vo.QueryProcessDataVO;
|
|
|
+import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.core.tool.utils.Func;
|
|
|
+import org.springblade.manager.entity.WbsTreeContract;
|
|
|
+import org.springblade.manager.feign.WbsTreeContractClient;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Iterator;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@AllArgsConstructor
|
|
|
+@RequestMapping("/neiWaiYeProgressController")
|
|
|
+@Api(tags = "内外业进度")
|
|
|
+public class NeiWaiYeProgressController {
|
|
|
+
|
|
|
+ private final WbsTreeContractClient wbsTreeContractClient;
|
|
|
+
|
|
|
+ private final IInformationQueryService informationQueryService;
|
|
|
+
|
|
|
+ private final IContractLogWbsService contractLogWbsService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 内外业进度
|
|
|
+ */
|
|
|
+ @GetMapping("/neiWaiYeProgress")
|
|
|
+ @ApiOperationSupport(order = 1)
|
|
|
+ @ApiOperation(value = "内外业进度")
|
|
|
+ public R<List<NeiWaiYeProgressVO>> neiWaiYeProgress(@RequestParam String primaryKeyId, @RequestParam String contractId){
|
|
|
+ if(StringUtils.isNotEmpty(primaryKeyId)){
|
|
|
+ //判断primaryKeyId是唯一键还是泛用键
|
|
|
+ WbsTreeContract node = this.wbsTreeContractClient.getContractNodeByPrimaryKeyId(primaryKeyId);
|
|
|
+ if(node == null){
|
|
|
+ //说明是监理合同段
|
|
|
+ node = this.wbsTreeContractClient.getContractWbsTreeByContractIdAndId(Long.parseLong(primaryKeyId), Long.parseLong(contractId));
|
|
|
+ }
|
|
|
+ //设置返回集合
|
|
|
+ List<NeiWaiYeProgressVO> result = new ArrayList<>();
|
|
|
+
|
|
|
+ //获取当前节点的子节点
|
|
|
+ List<WbsTreeContract> childList = this.wbsTreeContractClient.queryChildByParentId(node, "");
|
|
|
+
|
|
|
+ //获取当前节点下的所有填报节点
|
|
|
+ List<QueryProcessDataVO> queryProcessDataVOList;
|
|
|
+ if(!new Integer("6").equals(node.getDeptCategory()) && !Arrays.asList("1,2,3,4".split(",")).contains(node.getMajorDataType().toString())){
|
|
|
+ queryProcessDataVOList = this.informationQueryService.queryProcessDataByParentIdAndContractId(node.getId().toString(), 1, contractId);
|
|
|
+ } else {
|
|
|
+ //填报节点
|
|
|
+ queryProcessDataVOList = this.informationQueryService.queryProcessDataByPrimaryKeyIdAndClassify(node.getPKeyId().toString(), 1);
|
|
|
+ childList.clear();
|
|
|
+ //设置填报节点进集合中
|
|
|
+ childList.add(node);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(queryProcessDataVOList != null && queryProcessDataVOList.size() > 0){
|
|
|
+ //删除掉开工报告等节点
|
|
|
+ queryProcessDataVOList.removeIf(vo -> !new Integer("4").equals(vo.getMajorDataType()));
|
|
|
+ //循环子节点
|
|
|
+ for(WbsTreeContract child : childList){
|
|
|
+ //设置返回参数
|
|
|
+ int amount = 0, neiYeSuccessAmount = 0, waiYeSuccessAmount = 0;
|
|
|
+
|
|
|
+ //使用迭代器,减少之后的循环次数
|
|
|
+ Iterator<QueryProcessDataVO> iterator = queryProcessDataVOList.iterator();
|
|
|
+ while (iterator.hasNext()){
|
|
|
+ QueryProcessDataVO vo = iterator.next();
|
|
|
+ //找到自己的子节点
|
|
|
+ if(vo.getAncestors().contains(child.getId().toString()) || vo.getParentId().equals(child.getId().toString()) || vo.getPrimaryKeyId().equals(child.getPKeyId().toString())){
|
|
|
+ //统计内业数量(内业根据已审批的节点资料统计)
|
|
|
+ if(new Integer("2").equals(vo.getStatus())){
|
|
|
+ neiYeSuccessAmount ++;
|
|
|
+ }
|
|
|
+ //统计外业数量(外业根据当前填报节点是否已经生成一份施工日志为准(暂时))
|
|
|
+ Integer logCount = this.contractLogWbsService.countContractLogBySelectPrimaryKeyIdsAndClassify(Func.toStrList(vo.getPrimaryKeyId()), 7);
|
|
|
+ if(logCount != null && logCount > 0){
|
|
|
+ waiYeSuccessAmount ++;
|
|
|
+ }
|
|
|
+ //统计总数
|
|
|
+ amount ++;
|
|
|
+ iterator.remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //添加返回结果
|
|
|
+ result.add(new NeiWaiYeProgressVO(StringUtils.isNotEmpty(child.getFullName()) ? child.getFullName() : child.getDeptName(), amount, neiYeSuccessAmount, waiYeSuccessAmount));
|
|
|
+ }
|
|
|
+ return R.data(result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.data(300, null, "未查询到数据");
|
|
|
+ }
|
|
|
+
|
|
|
+}
|