| | |
| | | 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.domain.Dict; |
| | | import me.zhengjie.modules.system.domain.DictDetail; |
| | | import me.zhengjie.modules.system.repository.DictDetailRepository; |
| | | import me.zhengjie.modules.system.repository.DictRepository; |
| | | import me.zhengjie.utils.*; |
| | | import lombok.RequiredArgsConstructor; |
| | | import me.zhengjie.modules.contract.service.ContractService; |
| | |
| | | private final ContractPaymentRepository contractPaymentRepository; |
| | | private final ContractInvoicePaymentRepository contractInvoicePaymentRepository; |
| | | private final ContractInvoiceRepository contractInvoiceRepository; |
| | | private final DictRepository dictRepository; |
| | | private final DictDetailRepository dictDetailRepository; |
| | | private final ContractFirstServiceImpl contractFirstServiceImpl; |
| | | private final ContractSecondServiceImpl contractSecondServiceImpl; |
| | |
| | | for (ContractDto contract : all) { |
| | | String firstName = contractFirstName(contractMapper.toEntity(contract)); |
| | | String secondName = contractSecondName(contractMapper.toEntity(contract)); |
| | | String contractType = contract.getContractType() != null ? dictDetailRepository.findByDictNameAndValue(Constant.CONTRACT_TYPE, contract.getContractType()).getLabel() : ""; |
| | | String contractType = contract.getContractType() != null ? dictDetailRepository.findByDictNameAndValue(Constant.CONTRACT_DICT_TYPE, contract.getContractType()).getLabel() : ""; |
| | | String contractPaymentState = contract.getContractPaymentState() != null ? dictDetailRepository.findByDictNameAndValue(Constant.PAYMENT_STATE, contract.getContractPaymentState()).getLabel() : ""; |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String servicePaymentDate = null; |
| | |
| | | map.put("起始日期", contract.getStartDate()); |
| | | map.put("截止日期", contract.getEndDate()); |
| | | map.put("合同所属地区", contract.getContractArea()); |
| | | map.put("合同类型", contractType); |
| | | map.put("合同类型(一级)", contractType); |
| | | map.put("合同类型(二级)", contract.getContractSecondType()); |
| | | map.put("合同内容", contract.getContractContent()); |
| | | map.put("开票总金额", contract.getBillingTotalAmount()); |
| | | map.put("付款总金额", contract.getPaymentTotalAmount()); |
| | |
| | | * @return |
| | | */ |
| | | public Contract updateAmountData(Contract resources) { |
| | | if (StringUtils.isNotBlank(resources.getContractType()) && StringUtils.isNotBlank(resources.getContractSecondType())) { |
| | | // 判断是否是已存在的合同类型(二级) |
| | | if (ElAdminConstant.Enum.ContractTypeDict.findByDictValue(resources.getContractType()) != null) { |
| | | String secondDictName = ElAdminConstant.Enum.ContractTypeDict.findByDictValue(resources.getContractType()).getSecondDictName(); |
| | | DictDetail dictDetail = dictDetailRepository.findByDictNameAndValue(secondDictName, resources.getContractSecondType()); |
| | | if (dictDetail == null) { |
| | | // 新建合同类型(二级) |
| | | dictDetail = new DictDetail(); |
| | | Dict dict = dictRepository.findByName(secondDictName); |
| | | dictDetail.setDict(dict); |
| | | dictDetail.setLabel(resources.getContractSecondType()); |
| | | dictDetail.setValue(resources.getContractSecondType()); |
| | | dictDetail.setDictSort(10); |
| | | dictDetailRepository.save(dictDetail); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 判断合同类型 |
| | | if (Constant.CONTRACT_DEVELOP_SERVICE.equals(resources.getContractType())) { |
| | | if (Constant.CONTRACT_DEVELOP_SERVICE.equals(resources.getContractSecondType())) { |
| | | // 不处理 |
| | | } else if (Constant.CONTRACT_SERVICE.equals(resources.getContractType())) { |
| | | } else if (Constant.CONTRACT_SERVICE.equals(resources.getContractSecondType())) { |
| | | // 合同费金额 |
| | | resources.setContractAmount(null); |
| | | // 预计付款日期 |
| | |
| | | BigDecimal contractAmount = contractPaymentRepository.findByContractIdAndFundType(contract.getContractId(), Constant.FUND_CONTRACT); |
| | | contractAmount = contractAmount == null ? new BigDecimal(0) : contractAmount; |
| | | // 判断合同款项付款金额 |
| | | if(Constant.CONTRACT_SERVICE.equals(contract.getContractType())) { |
| | | if(Constant.CONTRACT_SERVICE.equals(contract.getContractSecondType())) { |
| | | // 付款状态 |
| | | contract.setContractPaymentState(null); |
| | | } else if(contractAmount.compareTo(new BigDecimal(0)) == 0) { |
| | |
| | | BigDecimal serviceAmount = contractPaymentRepository.findByContractIdAndFundType(contract.getContractId(), Constant.FUND_SERVICE); |
| | | serviceAmount = serviceAmount == null ? new BigDecimal(0) : serviceAmount; |
| | | // 判断服务款项付款金额 |
| | | if(Constant.CONTRACT_DEVELOP.equals(contract.getContractType())) { |
| | | if(Constant.CONTRACT_DEVELOP.equals(contract.getContractSecondType())) { |
| | | // 付款状态 |
| | | contract.setServicePaymentState(null); |
| | | } else if(serviceAmount.compareTo(new BigDecimal(0)) == 0) { |
| | |
| | | Long allCompanySort = contractRepository.countAllContractSort(String.valueOf(calendar.get(Calendar.YEAR)), resources.getContractId()); |
| | | contractNumber.append(String.format("%04d", (allCompanySort == null ? 0L : allCompanySort) + 1)); |
| | | |
| | | System.out.println("新合同编号:" + contractNumber.toString()); |
| | | resources.setContractNumber(contractNumber.toString()); |
| | | } |
| | | |