|
@@ -2,6 +2,7 @@ package com.fjhx.mes.service.production.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -31,7 +32,6 @@ import com.fjhx.sale.entity.arrival.vo.ArrivalDetailVo;
|
|
|
import com.fjhx.sale.entity.contract.dto.ContractSelectDto;
|
|
|
import com.fjhx.sale.entity.contract.po.Contract;
|
|
|
import com.fjhx.sale.entity.contract.po.ContractProduct;
|
|
|
-import com.fjhx.sale.entity.contract.vo.ContractProductBomVo;
|
|
|
import com.fjhx.sale.entity.contract.vo.ContractProductVo;
|
|
|
import com.fjhx.sale.entity.contract.vo.ContractVo;
|
|
|
import com.fjhx.sale.entity.purchase.po.EhsdPurchaseProduct;
|
|
@@ -348,6 +348,17 @@ public class ProduceOrderServiceImpl extends ServiceImpl<ProduceOrderMapper, Pro
|
|
|
Contract contract = contractService.getById(contractId);
|
|
|
Assert.notEmpty(contract, "查询不到合同信息!");
|
|
|
|
|
|
+ //获取目前生产订单任务编号最大计数
|
|
|
+ Integer maxTaskCount = 0;
|
|
|
+ ProductionOrderDetail one = produceOrderDetailService.getOne(q -> q.eq(ProductionOrderDetail::getProduceOrderId, produceOrder.getId()));
|
|
|
+ if (ObjectUtil.isNotEmpty(one) && ObjectUtil.isNotEmpty(one.getCode())) {
|
|
|
+ String code = one.getCode();
|
|
|
+ int lastIndex = code.lastIndexOf("-");
|
|
|
+ if (lastIndex >= 0) {
|
|
|
+ maxTaskCount = Integer.valueOf(code.substring(lastIndex + 1));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//创建生产订单明细
|
|
|
List<ProductionOrderDetail> productionOrderDetailList = new ArrayList<>();
|
|
|
List<ContractProductVo> contractProductList = contractProductService.getList(IWrapper.<ContractProduct>getWrapper()
|
|
@@ -374,6 +385,8 @@ public class ProduceOrderServiceImpl extends ServiceImpl<ProduceOrderMapper, Pro
|
|
|
if (ObjectUtil.isEmpty(productionOrderDetail)) {
|
|
|
productionOrderDetail = new ProductionOrderDetail();
|
|
|
productionOrderDetail.setFinishQuantity(BigDecimal.ZERO);
|
|
|
+
|
|
|
+ productionOrderDetail.setCode(StrUtil.format("{}-{}", produceOrder.getCode(), ++maxTaskCount));
|
|
|
}
|
|
|
productionOrderDetail.setProduceOrderId(orderDtoId);
|
|
|
productionOrderDetail.setContractId(contractId);
|
|
@@ -579,8 +592,8 @@ public class ProduceOrderServiceImpl extends ServiceImpl<ProduceOrderMapper, Pro
|
|
|
//创建生产任务
|
|
|
createOrderDetails(productionOrder1);
|
|
|
|
|
|
- //生成待出库
|
|
|
- createStockWait(productionOrder1);
|
|
|
+// //生成待出库
|
|
|
+// createStockWait(productionOrder1);
|
|
|
|
|
|
//创建完工入库
|
|
|
createOrEditProdCompletion(productionOrder1);
|
|
@@ -636,62 +649,62 @@ public class ProduceOrderServiceImpl extends ServiceImpl<ProduceOrderMapper, Pro
|
|
|
|
|
|
}
|
|
|
|
|
|
- private void createStockWait(ProductionOrder productionOrder) {
|
|
|
- //生成待出库
|
|
|
- StockWait stockWait = stockWaitService.getOne(q -> q
|
|
|
- .eq(StockWait::getBusinessId, productionOrder.getId())
|
|
|
- .eq(StockWait::getBusinessType, JournalType.PROD_OUT.getDetailType())
|
|
|
- );
|
|
|
-
|
|
|
- if (ObjectUtil.isEmpty(stockWait)) {
|
|
|
- stockWait = new StockWait();
|
|
|
- stockWait.setStatus(0);//待出库
|
|
|
- } else {
|
|
|
- stockWait.setStatus(1);//部分出库
|
|
|
- }
|
|
|
- stockWait.setCompanyId(productionOrder.getCompanyId());
|
|
|
- stockWait.setBusinessId(productionOrder.getId());
|
|
|
- stockWait.setType(2);//出库
|
|
|
-
|
|
|
- stockWait.setBusinessType(JournalType.PROD_OUT.getDetailType());//生产任务出库
|
|
|
- stockWait.setContractId(productionOrder.getContractId());
|
|
|
- stockWait.setBusinessCode(productionOrder.getCode());
|
|
|
- stockWait.setProdOrderId(productionOrder.getId());
|
|
|
- stockWaitService.saveOrUpdate(stockWait);
|
|
|
-
|
|
|
- List<ContractProductVo> contractProductList = contractProductService.getList(IWrapper.<ContractProduct>getWrapper()
|
|
|
- .eq("cp", ContractProduct::getContractId, productionOrder.getContractId())
|
|
|
- //过滤当前生产公司的产品
|
|
|
- .eq("pi.company_id", productionOrder.getCompanyId())
|
|
|
- );
|
|
|
- List<Long> cpIds = contractProductList.stream().map(ContractProduct::getId).collect(Collectors.toList());
|
|
|
-
|
|
|
- List<StockWaitDetails> stockWaitDetailsList = new ArrayList<>();
|
|
|
- List<ContractProductBomVo> contractProductBomQuantitySum = contractProductBomService.getContractProductBomQuantitySum(IWrapper.getWrapper()
|
|
|
- .eq("cpb.contract_id", productionOrder.getContractId())
|
|
|
- .in("cp.id", cpIds)
|
|
|
- .ne("cpb.type", 3)//过滤掉工序的数据
|
|
|
- );
|
|
|
- for (ContractProductBomVo contractProductBomVo : contractProductBomQuantitySum) {
|
|
|
- //创建待出库明细
|
|
|
- Long stockWaitId = stockWait.getId();
|
|
|
- StockWaitDetails stockWaitDetails = stockWaitDetailsService.getOne(q -> q
|
|
|
- .eq(StockWaitDetails::getStockWaitId, stockWaitId)
|
|
|
- .eq(StockWaitDetails::getProductId, contractProductBomVo.getMaterialId())
|
|
|
- );
|
|
|
-
|
|
|
- if (ObjectUtil.isEmpty(stockWaitDetails)) {
|
|
|
- stockWaitDetails = new StockWaitDetails();
|
|
|
- stockWaitDetails.setReceiptQuantity(BigDecimal.ZERO);
|
|
|
- }
|
|
|
-
|
|
|
- stockWaitDetails.setStockWaitId(stockWaitId);
|
|
|
- stockWaitDetails.setProductId(contractProductBomVo.getMaterialId());
|
|
|
- stockWaitDetails.setQuantity(contractProductBomVo.getQuantity());
|
|
|
- stockWaitDetailsList.add(stockWaitDetails);
|
|
|
- }
|
|
|
- stockWaitDetailsService.saveOrUpdateBatch(stockWaitDetailsList);
|
|
|
- }
|
|
|
+// private void createStockWait(ProductionOrder productionOrder) {
|
|
|
+// //生成待出库
|
|
|
+// StockWait stockWait = stockWaitService.getOne(q -> q
|
|
|
+// .eq(StockWait::getBusinessId, productionOrder.getId())
|
|
|
+// .eq(StockWait::getBusinessType, JournalType.PROD_OUT.getDetailType())
|
|
|
+// );
|
|
|
+//
|
|
|
+// if (ObjectUtil.isEmpty(stockWait)) {
|
|
|
+// stockWait = new StockWait();
|
|
|
+// stockWait.setStatus(0);//待出库
|
|
|
+// } else {
|
|
|
+// stockWait.setStatus(1);//部分出库
|
|
|
+// }
|
|
|
+// stockWait.setCompanyId(productionOrder.getCompanyId());
|
|
|
+// stockWait.setBusinessId(productionOrder.getId());
|
|
|
+// stockWait.setType(2);//出库
|
|
|
+//
|
|
|
+// stockWait.setBusinessType(JournalType.PROD_OUT.getDetailType());//生产任务出库
|
|
|
+// stockWait.setContractId(productionOrder.getContractId());
|
|
|
+// stockWait.setBusinessCode(productionOrder.getCode());
|
|
|
+// stockWait.setProdOrderId(productionOrder.getId());
|
|
|
+// stockWaitService.saveOrUpdate(stockWait);
|
|
|
+//
|
|
|
+// List<ContractProductVo> contractProductList = contractProductService.getList(IWrapper.<ContractProduct>getWrapper()
|
|
|
+// .eq("cp", ContractProduct::getContractId, productionOrder.getContractId())
|
|
|
+// //过滤当前生产公司的产品
|
|
|
+// .eq("pi.company_id", productionOrder.getCompanyId())
|
|
|
+// );
|
|
|
+// List<Long> cpIds = contractProductList.stream().map(ContractProduct::getId).collect(Collectors.toList());
|
|
|
+//
|
|
|
+// List<StockWaitDetails> stockWaitDetailsList = new ArrayList<>();
|
|
|
+// List<ContractProductBomVo> contractProductBomQuantitySum = contractProductBomService.getContractProductBomQuantitySum(IWrapper.getWrapper()
|
|
|
+// .eq("cpb.contract_id", productionOrder.getContractId())
|
|
|
+// .in("cp.id", cpIds)
|
|
|
+// .ne("cpb.type", 3)//过滤掉工序的数据
|
|
|
+// );
|
|
|
+// for (ContractProductBomVo contractProductBomVo : contractProductBomQuantitySum) {
|
|
|
+// //创建待出库明细
|
|
|
+// Long stockWaitId = stockWait.getId();
|
|
|
+// StockWaitDetails stockWaitDetails = stockWaitDetailsService.getOne(q -> q
|
|
|
+// .eq(StockWaitDetails::getStockWaitId, stockWaitId)
|
|
|
+// .eq(StockWaitDetails::getProductId, contractProductBomVo.getMaterialId())
|
|
|
+// );
|
|
|
+//
|
|
|
+// if (ObjectUtil.isEmpty(stockWaitDetails)) {
|
|
|
+// stockWaitDetails = new StockWaitDetails();
|
|
|
+// stockWaitDetails.setReceiptQuantity(BigDecimal.ZERO);
|
|
|
+// }
|
|
|
+//
|
|
|
+// stockWaitDetails.setStockWaitId(stockWaitId);
|
|
|
+// stockWaitDetails.setProductId(contractProductBomVo.getMaterialId());
|
|
|
+// stockWaitDetails.setQuantity(contractProductBomVo.getQuantity());
|
|
|
+// stockWaitDetailsList.add(stockWaitDetails);
|
|
|
+// }
|
|
|
+// stockWaitDetailsService.saveOrUpdateBatch(stockWaitDetailsList);
|
|
|
+// }
|
|
|
|
|
|
@Override
|
|
|
public void editDeliveryPeriod(ProductionOrderDto dto) {
|