|
@@ -14,7 +14,6 @@ import com.fjhx.item.entity.product.po.ProductInfo;
|
|
|
import com.fjhx.item.enums.ProductAvailableRecordType;
|
|
|
import com.fjhx.item.service.product.ProductInfoService;
|
|
|
import com.fjhx.mes.entity.MaterialBalanceBo;
|
|
|
-import com.fjhx.mes.entity.material.po.MaterialPreparation;
|
|
|
import com.fjhx.mes.entity.production.dto.ProduceOrderSelectDto;
|
|
|
import com.fjhx.mes.entity.production.dto.ProductionOrderDto;
|
|
|
import com.fjhx.mes.entity.production.po.ProductionOrder;
|
|
@@ -58,6 +57,7 @@ import com.fjhx.wms.service.stock.StockWaitDetailsService;
|
|
|
import com.fjhx.wms.service.stock.StockWaitService;
|
|
|
import com.ruoyi.common.core.domain.BasePo;
|
|
|
import com.ruoyi.common.core.domain.entity.SysDept;
|
|
|
+import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
import com.ruoyi.common.utils.wrapper.SqlField;
|
|
@@ -551,6 +551,40 @@ public class ProduceOrderServiceImpl extends ServiceImpl<ProduceOrderMapper, Pro
|
|
|
Contract contract = contractService.getById(contractId);
|
|
|
Assert.notEmpty(contract, "查询不到合同信息!");
|
|
|
|
|
|
+ //============刷新生产任务明细关联的合同产品id=============
|
|
|
+ List<ProductionOrderDetail> tempProdTaskList = new ArrayList<>();
|
|
|
+
|
|
|
+ List<ProductionOrderDetail> prodTaskList = produceOrderDetailService.list(q -> q
|
|
|
+ .eq(ProductionOrderDetail::getProduceOrderId, orderDtoId)
|
|
|
+ );
|
|
|
+ for (ProductionOrderDetail prodTask : prodTaskList) {
|
|
|
+ Long tempOldId = prodTask.getContractDetailId();
|
|
|
+ //遍历出最新一版id
|
|
|
+ int recursion = 0;
|
|
|
+ while (ObjectUtil.isNotEmpty(tempOldId)) {
|
|
|
+ recursion++;
|
|
|
+ Long finalTempOldId = tempOldId;
|
|
|
+ ContractProduct cp = contractProductService.getOne(q -> q.eq(ContractProduct::getOldContractProductId, finalTempOldId));
|
|
|
+ if (ObjectUtil.isEmpty(cp)) {
|
|
|
+ prodTask.setContractDetailId(tempOldId);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ tempOldId = cp.getId();
|
|
|
+
|
|
|
+ //递归超过50次,报错防止死循环
|
|
|
+ if (recursion > 50) {
|
|
|
+ throw new ServiceException("数据异常,请联系管理员!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ProductionOrderDetail tempTask = new ProductionOrderDetail();
|
|
|
+ tempTask.setId(prodTask.getId());
|
|
|
+ tempTask.setContractDetailId(prodTask.getContractDetailId());
|
|
|
+ tempProdTaskList.add(tempTask);
|
|
|
+ }
|
|
|
+ produceOrderDetailService.updateBatchById(tempProdTaskList);
|
|
|
+ //===================================================
|
|
|
+
|
|
|
//创建生产订单明细
|
|
|
List<ProductionOrderDetail> productionOrderDetailList = new ArrayList<>();
|
|
|
List<ContractProduct> contractProductList = contractProductService.list(q -> q.eq(ContractProduct::getContractId, contractId));
|
|
@@ -635,60 +669,60 @@ public class ProduceOrderServiceImpl extends ServiceImpl<ProduceOrderMapper, Pro
|
|
|
productionTaskProgressService.saveOrUpdateBatch(productionTaskProgressList);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 创建生产备料
|
|
|
- */
|
|
|
- private synchronized void createMaterialPreparation(ProductionOrder productionOrder) {
|
|
|
- Long contractId = productionOrder.getContractId();
|
|
|
- Long companyId = productionOrder.getCompanyId();
|
|
|
- //创建生产备料
|
|
|
- List<ProductionOrderDetail> productionOrderDetailList = produceOrderDetailService.list(q -> q
|
|
|
- .eq(ProductionOrderDetail::getProduceOrderId, productionOrder.getId())
|
|
|
- );
|
|
|
- //获取合同产品ids
|
|
|
- List<Long> cpIds = productionOrderDetailList.stream()
|
|
|
- .map(ProductionOrderDetail::getContractDetailId).collect(Collectors.toList());
|
|
|
- Map<Long, List<ContractProductBom>> cpBMap = contractProductBomService.mapKGroup(ContractProductBom::getContractProductId,
|
|
|
- q -> q.in(ContractProductBom::getContractProductId, cpIds)
|
|
|
- );
|
|
|
-
|
|
|
- //获取产品id
|
|
|
- for (ProductionOrderDetail productionOrderDetail : productionOrderDetailList) {
|
|
|
- productionOrderDetail.setProduceStatus(1);
|
|
|
- //创建备料
|
|
|
- List<ContractProductBom> contractProductBomList = cpBMap.get(productionOrderDetail.getContractDetailId());
|
|
|
-
|
|
|
- List<MaterialPreparation> materialPreparationList = new ArrayList<>();
|
|
|
- for (ContractProductBom bomDetail : contractProductBomList) {
|
|
|
- BigDecimal multiply = bomDetail.getQuantity().multiply(productionOrderDetail.getQuantity());
|
|
|
-
|
|
|
- MaterialPreparation materialPreparation = materialPreparationService.getOne(q -> q
|
|
|
- .eq(MaterialPreparation::getProductionOrderDetailId, productionOrderDetail.getId())
|
|
|
- .eq(MaterialPreparation::getMaterialId, bomDetail.getMaterialId())
|
|
|
- );
|
|
|
-
|
|
|
- if (ObjectUtil.isEmpty(materialPreparation)) {
|
|
|
- materialPreparation = new MaterialPreparation();
|
|
|
- materialPreparation.setStatus(0);
|
|
|
- } else {
|
|
|
- if (materialPreparation.getQuantity().compareTo(multiply) != 0 && materialPreparation.getStatus() == 1) {
|
|
|
- materialPreparation.setStatus(0);
|
|
|
- }
|
|
|
- }
|
|
|
- materialPreparation.setContractId(contractId);
|
|
|
- materialPreparation.setContractDetailId(productionOrderDetail.getContractDetailId());
|
|
|
- materialPreparation.setProductionOrderId(productionOrder.getId());
|
|
|
- materialPreparation.setProductionOrderDetailId(productionOrderDetail.getId());
|
|
|
- materialPreparation.setMaterialId(bomDetail.getMaterialId());
|
|
|
- materialPreparation.setQuantity(multiply);
|
|
|
- materialPreparation.setCompanyId(companyId);
|
|
|
- materialPreparationList.add(materialPreparation);
|
|
|
- }
|
|
|
- materialPreparationService.saveOrUpdateBatch(materialPreparationList);
|
|
|
- }
|
|
|
-
|
|
|
- produceOrderDetailService.updateBatchById(productionOrderDetailList);
|
|
|
- }
|
|
|
+// /**
|
|
|
+// * 创建生产备料
|
|
|
+// */
|
|
|
+// private synchronized void createMaterialPreparation(ProductionOrder productionOrder) {
|
|
|
+// Long contractId = productionOrder.getContractId();
|
|
|
+// Long companyId = productionOrder.getCompanyId();
|
|
|
+// //创建生产备料
|
|
|
+// List<ProductionOrderDetail> productionOrderDetailList = produceOrderDetailService.list(q -> q
|
|
|
+// .eq(ProductionOrderDetail::getProduceOrderId, productionOrder.getId())
|
|
|
+// );
|
|
|
+// //获取合同产品ids
|
|
|
+// List<Long> cpIds = productionOrderDetailList.stream()
|
|
|
+// .map(ProductionOrderDetail::getContractDetailId).collect(Collectors.toList());
|
|
|
+// Map<Long, List<ContractProductBom>> cpBMap = contractProductBomService.mapKGroup(ContractProductBom::getContractProductId,
|
|
|
+// q -> q.in(ContractProductBom::getContractProductId, cpIds)
|
|
|
+// );
|
|
|
+//
|
|
|
+// //获取产品id
|
|
|
+// for (ProductionOrderDetail productionOrderDetail : productionOrderDetailList) {
|
|
|
+// productionOrderDetail.setProduceStatus(1);
|
|
|
+// //创建备料
|
|
|
+// List<ContractProductBom> contractProductBomList = cpBMap.get(productionOrderDetail.getContractDetailId());
|
|
|
+//
|
|
|
+// List<MaterialPreparation> materialPreparationList = new ArrayList<>();
|
|
|
+// for (ContractProductBom bomDetail : contractProductBomList) {
|
|
|
+// BigDecimal multiply = bomDetail.getQuantity().multiply(productionOrderDetail.getQuantity());
|
|
|
+//
|
|
|
+// MaterialPreparation materialPreparation = materialPreparationService.getOne(q -> q
|
|
|
+// .eq(MaterialPreparation::getProductionOrderDetailId, productionOrderDetail.getId())
|
|
|
+// .eq(MaterialPreparation::getMaterialId, bomDetail.getMaterialId())
|
|
|
+// );
|
|
|
+//
|
|
|
+// if (ObjectUtil.isEmpty(materialPreparation)) {
|
|
|
+// materialPreparation = new MaterialPreparation();
|
|
|
+// materialPreparation.setStatus(0);
|
|
|
+// } else {
|
|
|
+// if (materialPreparation.getQuantity().compareTo(multiply) != 0 && materialPreparation.getStatus() == 1) {
|
|
|
+// materialPreparation.setStatus(0);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// materialPreparation.setContractId(contractId);
|
|
|
+// materialPreparation.setContractDetailId(productionOrderDetail.getContractDetailId());
|
|
|
+// materialPreparation.setProductionOrderId(productionOrder.getId());
|
|
|
+// materialPreparation.setProductionOrderDetailId(productionOrderDetail.getId());
|
|
|
+// materialPreparation.setMaterialId(bomDetail.getMaterialId());
|
|
|
+// materialPreparation.setQuantity(multiply);
|
|
|
+// materialPreparation.setCompanyId(companyId);
|
|
|
+// materialPreparationList.add(materialPreparation);
|
|
|
+// }
|
|
|
+// materialPreparationService.saveOrUpdateBatch(materialPreparationList);
|
|
|
+// }
|
|
|
+//
|
|
|
+// produceOrderDetailService.updateBatchById(productionOrderDetailList);
|
|
|
+// }
|
|
|
|
|
|
@DSTransactional
|
|
|
@Override
|
|
@@ -717,24 +751,16 @@ public class ProduceOrderServiceImpl extends ServiceImpl<ProduceOrderMapper, Pro
|
|
|
WebSocketPush.byUser(PushTypeEnum.MESSAGE, productionOrder.getCreateUser(), title, PushBusinessTypeEnum.PRODUCTION_ORDER_REJECT.getType(), msg.toString());
|
|
|
} else {
|
|
|
if (produceOrderDetailService.count(q -> q.eq(ProductionOrderDetail::getProduceOrderId, dto.getId())) > 0) {
|
|
|
- //创建待采购
|
|
|
- createMaterialWaitPurchase(productionOrder);
|
|
|
- } else {
|
|
|
//修改待采购
|
|
|
updateMaterialWaitPurchase(productionOrder.getContractId());
|
|
|
+ } else {
|
|
|
+ //创建待采购
|
|
|
+ createMaterialWaitPurchase(productionOrder);
|
|
|
}
|
|
|
|
|
|
//创建生产任务
|
|
|
createOrderDetails(productionOrder);
|
|
|
|
|
|
-// //投产
|
|
|
-// if (ObjectUtil.isNotEmpty(productionOrder.getProduceTime())) {
|
|
|
-// throw new ServiceException("该订单已投产,请勿重复投产!!");
|
|
|
-// }
|
|
|
-
|
|
|
- //生成待备料
|
|
|
- createMaterialPreparation(productionOrder);
|
|
|
-
|
|
|
//生成待出库
|
|
|
createStockWait(productionOrder);
|
|
|
|