Ver Fonte

项目添加分包相关信息

chenjun há 8 meses atrás
pai
commit
dc77952b2b

+ 18 - 0
zjugis-business/src/main/java/com/zjugis/business/bean/entity/Project.java

@@ -124,5 +124,23 @@ public class Project extends BaseEntity {
 
     //完成进度
     private BigDecimal finishProgress;
+
+    //分包信息
+    @TableField(exist = false)
+    private BigDecimal contractApplyAmount;
+    @TableField(exist = false)
+    private BigDecimal applyPayAmount;
+
+    /**
+     * 质保金
+     */
+    @TableField(exist = false)
+    private BigDecimal qualityMoney;
+
+    /**
+     * 质保金状态
+     */
+    @TableField(exist = false)
+    private Integer qualityMoneyStatus;
 }
 

+ 4 - 0
zjugis-business/src/main/java/com/zjugis/business/bean/response/ProjectResponse.java

@@ -72,6 +72,10 @@ public class ProjectResponse {
     private BigDecimal receivableAmount;
     private BigDecimal returnAmount;
     private BigDecimal contractBalance;
+    //分包信息
+    private BigDecimal contractApplyAmount;
+    private BigDecimal applyPayAmount;
+    private BigDecimal applyUnPayAmount;
     // 预估合同额
     private BigDecimal planContractAmount;
     //总成本

+ 14 - 2
zjugis-business/src/main/java/com/zjugis/business/mapper/ContractApplyMapper.java

@@ -1,6 +1,5 @@
 package com.zjugis.business.mapper;
 
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.zjugis.business.bean.dto.ContractApplyDto;
 import com.zjugis.business.bean.dto.ContractApplyToPayDto;
@@ -10,10 +9,15 @@ import com.zjugis.business.bean.entity.ContractApply;
 import com.zjugis.business.bean.response.ContractApplyExcelResponse;
 import com.zjugis.business.bean.response.ContractApplyResp;
 import com.zjugis.business.bean.response.SumResponse;
+import com.zjugis.framework.mybatis.core.mapper.BaseMapperX;
+import com.zjugis.framework.mybatis.core.query.LambdaQueryWrapperX;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
 import java.util.List;
+import java.util.Set;
+
+import static com.zjugis.business.constants.FlowStatusConstants.FLOW_FINISHED;
 
 /**
  * (SubcontractApply)表数据库访问层
@@ -22,7 +26,7 @@ import java.util.List;
  * @since 2024-03-12 18:51:34
  */
 @Repository
-public interface ContractApplyMapper extends BaseMapper<ContractApply> {
+public interface ContractApplyMapper extends BaseMapperX<ContractApply> {
 
 
     Page<ContractApplyResp> page(Page<ContractApply> page, @Param("params") ContractApplyDto params);
@@ -36,5 +40,13 @@ public interface ContractApplyMapper extends BaseMapper<ContractApply> {
     List<ManageSegmentDto> infoGroupBySegment();
 
     List<ContractApplyExcelResponse> excelList(@Param("params") ContractApplyDto contractApplyDto);
+
+    default List<ContractApply> getListByProjectId(String projectId) {
+        return selectList(new LambdaQueryWrapperX<ContractApply>().eq(ContractApply::getProjectId,projectId).eq(ContractApply::getFlowStatus,FLOW_FINISHED));
+    }
+
+    default List<ContractApply> getListByProjectIds(Set<String> projectIds){
+        return selectList(new LambdaQueryWrapperX<ContractApply>().eq(ContractApply::getFlowStatus,FLOW_FINISHED).in(ContractApply::getProjectId,projectIds));
+    }
 }
 

+ 16 - 0
zjugis-business/src/main/java/com/zjugis/business/service/ContractApplyService.java

@@ -11,6 +11,7 @@ import com.zjugis.business.bean.response.ContractApplyResp;
 import com.zjugis.business.bean.response.SumResponse;
 
 import java.util.List;
+import java.util.Set;
 
 /**
  * (SUBCONTRACT_APPLY)表服务接口
@@ -58,6 +59,21 @@ public interface ContractApplyService {
 
     int deleteByIdList(List<String> ids);
 
+    /**
+     * 通过项目ID查分包列表
+     * @param projectId
+     * @return
+     */
+    List<ContractApply> getListByProjectId(String projectId);
+
+
+    /**
+     * 通过项目ID查分包列表
+     * @param projectIds
+     * @return
+     */
+    List<ContractApply> getListByProjectIds(Set<String> projectIds);
+
     String processSub(String projectId);
 
     String processOut(String projectId);

+ 3 - 0
zjugis-business/src/main/java/com/zjugis/business/service/ContractService.java

@@ -13,6 +13,7 @@ import com.zjugis.business.bean.response.ContractMessageCountResp;
 import com.zjugis.business.bean.response.ContractResponse;
 
 import java.util.List;
+import java.util.Set;
 
 /**
  * @author  ljy
@@ -46,6 +47,8 @@ public interface ContractService{
 
     List<Contract> selectByProject(String id);
 
+    List<Contract> selectByProjectIds(Set<String> ids);
+
     Contract selectMainByProject(String projectId);
 
     boolean existContract(String projectId);

+ 10 - 0
zjugis-business/src/main/java/com/zjugis/business/service/impl/ContractApplyServiceImpl.java

@@ -123,6 +123,16 @@ public class ContractApplyServiceImpl implements ContractApplyService {
         return this.contractApplyMapper.deleteBatchIds(ids);
     }
 
+    @Override
+    public List<ContractApply> getListByProjectId(String projectId) {
+        return contractApplyMapper.getListByProjectId(projectId);
+    }
+
+    @Override
+    public List<ContractApply> getListByProjectIds(Set<String> projectIds) {
+        return contractApplyMapper.getListByProjectIds(projectIds);
+    }
+
     /**
      * @param projectId
      * @return

+ 8 - 0
zjugis-business/src/main/java/com/zjugis/business/service/impl/ContractServiceImpl.java

@@ -549,6 +549,14 @@ public class ContractServiceImpl implements ContractService{
         return contractMapper.selectList(queryWrapper);
     }
 
+    @Override
+    public List<Contract> selectByProjectIds(Set<String> ids) {
+        QueryWrapper<Contract> queryWrapper = new QueryWrapper<>();
+        queryWrapper.in("PROJECT_ID",ids)
+                .eq("FLOW_STATUS",90);
+        return contractMapper.selectList(queryWrapper);
+    }
+
     @Override
     public Contract selectMainByProject(String projectId) {
         QueryWrapper<Contract> queryWrapper = new QueryWrapper<>();

+ 45 - 2
zjugis-business/src/main/java/com/zjugis/business/service/impl/ProjectServiceImpl.java

@@ -46,6 +46,7 @@ import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.*;
+import java.util.stream.Collectors;
 
 import static com.zjugis.framework.common.exception.util.ServiceExceptionUtil.exception;
 import static com.zjugis.framework.common.util.collection.CollectionUtils.convertSet;
@@ -81,6 +82,9 @@ public class ProjectServiceImpl implements ProjectService {
     @Autowired
     ContractService contractService;
 
+    @Autowired
+    ContractApplyService contractApplyService;
+
     @Autowired
     ContractInvoiceService contractInvoiceService;
 
@@ -124,12 +128,37 @@ public class ProjectServiceImpl implements ProjectService {
             projectDto.setDeptIds(deptIds);
         }
         Page<Project> result = projectMapper.page(page, projectDto);
+        List<Project> records = page.getRecords();
+        Set<String> ids = convertSet(records, Project::getId);
+        List<Contract> contracts = contractService.selectByProjectIds(ids);
+        List<ContractApply> ContractApplys = contractApplyService.getListByProjectIds(ids);
+        Map<String, List<Contract>> contractMap = contracts.stream().collect(Collectors.groupingBy(Contract::getProjectId));
+        Map<String, List<ContractApply>> contractApplyMap = ContractApplys.stream().collect(Collectors.groupingBy(ContractApply::getProjectId));
 //        List<Project> records = result.getRecords();
-//        records.forEach(record -> {
+        records.forEach(record -> {
 //            AmountDto amountDto = contractService.selectAmountByProject(record.getId());
 //            record.setContractBalance(amountDto == null?BigDecimal.ZERO: amountDto.getContractBalance());
 //            record.setReceivableAmount(amountDto == null?BigDecimal.ZERO:amountDto.getReceivableAmount());
-//        });
+            List<Contract> contractList = contractMap.get(record.getId());
+            if (CollectionUtil.isNotEmpty(contractList)){
+                record.setQualityMoney(contractList.get(0).getQualityMoney());
+                record.setQualityMoneyStatus(contractList.get(0).getQualityMoneyStatus());
+            }
+            List<ContractApply> contractApplyList = contractApplyMap.get(record.getId());
+            if (CollectionUtil.isNotEmpty(contractApplyList)){
+                BigDecimal contractApplyAmount = new BigDecimal("0");
+                BigDecimal applyPayAmount = new BigDecimal("0");
+                for (ContractApply contractApply : contractApplyList) {
+                    if (contractApply.getContractAmount()==null){
+                        continue;
+                    }
+                    contractApplyAmount = contractApplyAmount.add(contractApply.getContractAmount());
+                    applyPayAmount = applyPayAmount.add(contractApply.getPayAmount());
+                }
+                record.setContractApplyAmount(contractApplyAmount);
+                record.setApplyPayAmount(applyPayAmount);
+            }
+        });
         return result;
 
     }
@@ -265,6 +294,20 @@ public class ProjectServiceImpl implements ProjectService {
         parent.setReceivableAmount(receivableAmount);
         parent.setReturnAmount(returnAmount);
         parent.setContractBalance(contractBalance);
+        List<ContractApply> applyList = contractApplyService.getListByProjectId(id);
+        BigDecimal contractApplyAmount = new BigDecimal("0");
+        BigDecimal applyPayAmount = new BigDecimal("0");
+        for (ContractApply contractApply : applyList) {
+            if (contractApply.getContractAmount()==null){
+                continue;
+            }
+            contractApplyAmount = contractApplyAmount.add(contractApply.getContractAmount());
+            applyPayAmount = applyPayAmount.add(contractApply.getPayAmount());
+        }
+        BigDecimal applyUnPayAmount = contractApplyAmount.subtract(applyPayAmount);
+        parent.setContractApplyAmount(contractApplyAmount);
+        parent.setApplyPayAmount(applyPayAmount);
+        parent.setApplyUnPayAmount(applyUnPayAmount);
         projects.remove(0);
         parent.setChildren(projects);
         return parent;