| | |
| | | package me.zhengjie.modules.contract.service.impl; |
| | | |
| | | import me.zhengjie.modules.constant.Constant; |
| | | import me.zhengjie.modules.contract.domain.Contract; |
| | | import me.zhengjie.modules.contract.domain.ContractInvoice; |
| | | import me.zhengjie.modules.contract.domain.ContractInvoicePayment; |
| | | import me.zhengjie.modules.contract.domain.ContractPayment; |
| | | import me.zhengjie.modules.contract.repository.ContractInvoicePaymentRepository; |
| | | import me.zhengjie.modules.contract.repository.ContractInvoiceRepository; |
| | | import me.zhengjie.modules.contract.repository.ContractPaymentRepository; |
| | | import me.zhengjie.modules.contract.service.dto.ContractFirstDto; |
| | | import me.zhengjie.modules.contract.service.dto.ContractSecondDto; |
| | | import me.zhengjie.modules.contract.domain.*; |
| | | import me.zhengjie.modules.contract.repository.*; |
| | | import me.zhengjie.modules.contract.service.dto.*; |
| | | import me.zhengjie.modules.contract.service.mapstruct.ContractProjectMapper; |
| | | import me.zhengjie.modules.project.service.dto.ProjectDto; |
| | | import me.zhengjie.modules.project.service.impl.ProjectServiceImpl; |
| | | import me.zhengjie.modules.system.repository.DictDetailRepository; |
| | | import me.zhengjie.utils.ValidationUtil; |
| | | import me.zhengjie.utils.FileUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import me.zhengjie.modules.contract.repository.ContractRepository; |
| | | import me.zhengjie.modules.contract.service.ContractService; |
| | | import me.zhengjie.modules.contract.service.dto.ContractDto; |
| | | import me.zhengjie.modules.contract.service.dto.ContractQueryCriteria; |
| | | import me.zhengjie.modules.contract.service.mapstruct.ContractMapper; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | private final DictDetailRepository dictDetailRepository; |
| | | private final ContractFirstServiceImpl contractFirstServiceImpl; |
| | | private final ContractSecondServiceImpl contractSecondServiceImpl; |
| | | private final ProjectServiceImpl projectServiceImpl; |
| | | private final ContractProjectRepository contractProjectRepository; |
| | | |
| | | @Override |
| | | public Map<String,Object> queryAll(ContractQueryCriteria criteria, Pageable pageable){ |
| | |
| | | public ContractDto apply(Contract t) { |
| | | // 将实体类转换成DTO |
| | | ContractDto contractDto = contractMapper.toDto(t); |
| | | |
| | | // 合同款延期情况 |
| | | contractDto.setContractPostponement(contractPostponement(t)); |
| | | // 服务款延期情况 |
| | |
| | | contractDto.setFirstName(contractFirstName(t)); |
| | | // 乙方姓名 |
| | | contractDto.setSecondName(contractSecondName(t)); |
| | | // 合同费数量 |
| | | contractDto.setFundContractNum(contractProjectNum(t, Constant.FUND_CONTRACT)); |
| | | // 合同费金额 |
| | | contractDto.setFundContractAmount(contractProjectAmount(t, Constant.FUND_CONTRACT)); |
| | | // 服务费数量 |
| | | contractDto.setFundServiceNum(contractProjectNum(t, Constant.FUND_SERVICE)); |
| | | // 服务费金额 |
| | | contractDto.setFundServiceAmount(contractProjectAmount(t, Constant.FUND_SERVICE)); |
| | | // 返回处理好的DTO |
| | | return contractDto; |
| | | } |
| | |
| | | contractDto.setFirstName(contractFirstName(contractList.get(i))); |
| | | // 乙方姓名 |
| | | contractDto.setSecondName(contractSecondName(contractList.get(i))); |
| | | // 合同费数量 |
| | | contractDto.setFundContractNum(contractProjectNum(contractList.get(i), Constant.FUND_CONTRACT)); |
| | | // 合同费金额 |
| | | contractDto.setFundContractAmount(contractProjectAmount(contractList.get(i), Constant.FUND_CONTRACT)); |
| | | // 服务费数量 |
| | | contractDto.setFundServiceNum(contractProjectNum(contractList.get(i), Constant.FUND_SERVICE)); |
| | | // 服务费金额 |
| | | contractDto.setFundServiceAmount(contractProjectAmount(contractList.get(i), Constant.FUND_SERVICE)); |
| | | // DTO新增 |
| | | contractDtoList.add(contractDto); |
| | | } |
| | |
| | | contractRepository.deleteById(contractId); |
| | | contractInvoiceRepository.deleteByContractId(contractId); |
| | | contractPaymentRepository.deleteByContractId(contractId); |
| | | contractProjectRepository.deleteByContractId(contractId); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 合同项目数量 |
| | | * @param resources |
| | | * @return |
| | | */ |
| | | public Integer contractProjectNum(Contract resources, String fundType) { |
| | | // 查询合同项目数据 |
| | | return contractProjectRepository.countByContractIdAndFundType(resources.getContractId(), fundType); |
| | | } |
| | | |
| | | /** |
| | | * 合同项目金额 |
| | | * @param resources |
| | | * @return |
| | | */ |
| | | public BigDecimal contractProjectAmount(Contract resources, String fundType) { |
| | | // 查询合同项目数据 |
| | | return contractProjectRepository.sumAllocatedAmountByContractIdAndFundType(resources.getContractId(), fundType); |
| | | } |
| | | |
| | | /** |
| | | * 合同款付款金额 |
| | | * @param resources |
| | | * @return |