|
@@ -3066,6 +3066,7 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
createOutboundInfo(dto);
|
|
|
|
|
|
//校验是否能出货(非特批校验,特批跳过)
|
|
|
+ BigDecimal errAmount = BigDecimal.ZERO;
|
|
|
//数量*(1-预付比例%)*单价<=(累计收款金额-预付款金额)-已出货金额
|
|
|
//预付比例-小数
|
|
|
BigDecimal multiply = new BigDecimal(contract.getAdvanceRatio()).multiply(BigDecimal.valueOf(0.01));
|
|
@@ -3074,12 +3075,23 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
//(累计收款金额-预付款金额)-已出货金额
|
|
|
BigDecimal subtract2 = contract.getSumClaimMoney().subtract(contract.getAmount().multiply(multiply)).subtract(contract.getShipmentAmount());
|
|
|
for (ContractOutboundRecords productDto : productDtoList) {
|
|
|
+ //跳过出库数量为空||出库数量为0
|
|
|
+ BigDecimal quantity = productDto.getQuantity();
|
|
|
+ if (ObjectUtil.isEmpty(quantity) || quantity.compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
BigDecimal multiply1 = productDto.getQuantity().multiply(subtract).multiply(productDto.getPrice());
|
|
|
if (multiply1.compareTo(subtract2) > 0) {
|
|
|
- throw new ServiceException(String.format("收款金额不满足出货条件,至少需再收款%s %s 才能出货!", contract.getCurrency(), multiply1.subtract(subtract2).setScale(4, RoundingMode.HALF_UP)));
|
|
|
+ errAmount = errAmount.add(multiply1.subtract(subtract2).setScale(4, RoundingMode.HALF_UP));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (errAmount.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ throw new ServiceException(String.format("收款金额不满足出货条件,至少需再收款%s %s 才能出货!", contract.getCurrency(), errAmount));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
//创建待出库
|
|
|
saleOutboundComm(dto);
|
|
|
}
|
|
@@ -3090,14 +3102,19 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
List<ContractOutboundRecordsDto> productDtoList = dto.getOutboundRecordList();
|
|
|
//补充数据
|
|
|
for (ContractOutboundRecordsDto outboundRecords : productDtoList) {
|
|
|
- ContractProduct byId = contractProductService.getById(outboundRecords.getContractProductId());
|
|
|
- outboundRecords.setProductId(byId.getProductId());
|
|
|
- outboundRecords.setPrice(byId.getPrice());
|
|
|
+ ContractProduct contractProduct = contractProductService.getById(outboundRecords.getContractProductId());
|
|
|
+ outboundRecords.setProductId(contractProduct.getProductId());
|
|
|
+ outboundRecords.setPrice(contractProduct.getPrice());
|
|
|
|
|
|
//赋值生产信息
|
|
|
- ContractOutboundRecordsDto taskInfo = saleService.getProdOrderIdByContractDetailId(byId.getId());
|
|
|
+ ContractOutboundRecordsDto taskInfo = saleService.getProdOrderIdByContractDetailId(contractProduct.getId());
|
|
|
outboundRecords.setProdOrderId(taskInfo.getProdOrderId());
|
|
|
outboundRecords.setProdTaskId(taskInfo.getProdTaskId());
|
|
|
+
|
|
|
+ //获取生产公司
|
|
|
+ ProductInfo productInfo = productInfoService.getById(contractProduct.getProductId());
|
|
|
+ Assert.notEmpty(productInfo, "查询不到产品信息!");
|
|
|
+ outboundRecords.setProdCompanyId(productInfo.getCompanyId());
|
|
|
}
|
|
|
|
|
|
//修改订单出库状态
|
|
@@ -3114,18 +3131,18 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
|
|
|
Assert.notEmpty(contract, "查询不到销售订单信息!");
|
|
|
|
|
|
//根据生产订单id分组
|
|
|
- Map<Long, List<ContractOutboundRecordsDto>> collect = productDtoList.stream().collect(Collectors.groupingBy(ContractOutboundRecordsDto::getProdOrderId));
|
|
|
+ Map<Long, List<ContractOutboundRecordsDto>> collect = productDtoList.stream().collect(Collectors.groupingBy(ContractOutboundRecordsDto::getProdCompanyId));
|
|
|
for (Map.Entry<Long, List<ContractOutboundRecordsDto>> entry : collect.entrySet()) {
|
|
|
//生成待出库数据
|
|
|
StockWait stockWait = new StockWait();
|
|
|
- stockWait.setCompanyId(SecurityUtils.getCompanyId());
|
|
|
stockWait.setType(2);
|
|
|
stockWait.setBusinessCode(contract.getCode());
|
|
|
stockWait.setBusinessType(JournalType.SALE_OUT.getDetailType());
|
|
|
stockWait.setBusinessId(dto.getId());
|
|
|
stockWait.setContractId(contractId);
|
|
|
stockWait.setStatus(0);
|
|
|
- stockWait.setProdOrderId(entry.getKey());
|
|
|
+ stockWait.setProdOrderId(entry.getValue().get(0).getProdOrderId());
|
|
|
+ stockWait.setCompanyId(entry.getKey());
|
|
|
stockWaitService.save(stockWait);
|
|
|
|
|
|
List<StockWaitDetails> stockWaitDetailsList = new ArrayList<>();
|