| | |
| | | private final ContractMapper contractMapper; |
| | | private final ContractPaymentScheduleProcessMapper scheduleProcessMapper; |
| | | private final ContractOutBoundMapper contractOutBoundMapper; |
| | | private final DeliveryOverdueMapper deliveryOverdueMapper; |
| | | |
| | | @Override |
| | | public R add(OutBoundAddDTO addDTO) { |
| | |
| | | .in(ContractSubjectMatter::getMaterialCode, addDTO.getSubjectMatterList().stream().map(item -> item.getSubjectMatterCode()).collect(Collectors.toList())) |
| | | .exists(Contract.class, contractQuery -> |
| | | contractQuery.select(ContractSubjectMatter::getId) |
| | | .eq(Contract::getContractStatus,2) |
| | | .eq(Contract::getId, ContractSubjectMatter::getContractId) |
| | | .eq(StrUtil.isNotBlank(addDTO.getBusGuestName()), Contract::getPartyA, addDTO.getBusGuestName()) |
| | | .eq(ObjUtil.isNotNull(addDTO.getBusGuestId()), Contract::getPartyAId, addDTO.getBusGuestId()) |
| | |
| | | if (subjectMatter.getDeliveredQuantity().compareTo(new BigDecimal("0")) > 0) { |
| | | remainNum = remainNum.subtract(subjectMatter.getRemainingQuantity()); |
| | | //部分交付状态下 全部出库 |
| | | if (remainNum.compareTo(new BigDecimal("0")) >= 0) { |
| | | if (remainNum.compareTo(new BigDecimal("0")) > 0) { |
| | | BigDecimal currentOut = subjectMatter.getRemainingQuantity(); |
| | | subjectMatter.setDeliveredQuantity(subjectMatter.getQuantity()); |
| | | subjectMatter.setRemainingQuantity(new BigDecimal("0")); |
| | |
| | | } else { |
| | | //未交付状态下 |
| | | remainNum = remainNum.subtract(subjectMatter.getQuantity()); |
| | | if (remainNum.compareTo(new BigDecimal("0")) >= 0) { |
| | | if (remainNum.compareTo(new BigDecimal("0")) > 0) { |
| | | subjectMatter.setDeliveredQuantity(subjectMatter.getQuantity()); |
| | | subjectMatter.setRemainingQuantity(new BigDecimal("0")); |
| | | subjectMatter.setActualDeliveryDate(DateUtil.today()); |
| | |
| | | contractOutBound.setOutBoundAttNames(addDTO.getOutBoundAttNames()); |
| | | contractOutBound.setOutBoundAttPaths(addDTO.getOutBoundAttPaths()); |
| | | contractOutBound.setOutBoundId(outBoundId); |
| | | contractOutBound.setInvoiceStatus("0"); |
| | | contractOutBound.setInvoiceNum(new BigDecimal("0")); |
| | | contractOutBoundMapper.insert(contractOutBound); |
| | | if (StrUtil.isEmpty(contract.getContractCategory())){ |
| | | if (DateUtil.compare(addDTO.getOutBoundTime(),contract.getExpirationDate())>0){ |
| | | saveOverdueOutBound(contract, addDTO, subjectMatter); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void saveOverdueOutBound(Contract contract, OutBoundAddDTO addDTO, ContractSubjectMatter subjectMatter) { |
| | | DeliveryOverdue overdue = new DeliveryOverdue(); |
| | | overdue.setContractId(contract.getId()); |
| | | overdue.setContractName(contract.getContractName()); |
| | | overdue.setBusGuestId(contract.getPartyAId()); |
| | | overdue.setBusGuestName(contract.getPartyA()); |
| | | overdue.setMaterialName(subjectMatter.getMaterialName()); |
| | | overdue.setMaterialInternalName(subjectMatter.getMaterialInternalName()); |
| | | overdue.setMaterialCode(subjectMatter.getMaterialCode()); |
| | | overdue.setOverdueNum(subjectMatter.getLastDeliveredQuantity()); |
| | | overdue.setTotalAmount(subjectMatter.getUnitPrice().multiply(subjectMatter.getLastDeliveredQuantity())); |
| | | overdue.setOverdueDuration(new BigDecimal(DateUtil.betweenDay(addDTO.getOutBoundTime(),contract.getExpirationDate(),true))); |
| | | deliveryOverdueMapper.insert(overdue); |
| | | } |
| | | } |