|
@@ -6,7 +6,6 @@ import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.common.utils.Assert;
|
|
|
-import com.fjhx.item.entity.product.po.ProductInfo;
|
|
|
import com.fjhx.item.service.product.ProductInfoService;
|
|
|
import com.fjhx.mes.entity.production.dto.ProductionSchedulingDto;
|
|
|
import com.fjhx.mes.entity.production.dto.ProductionSchedulingSelectDto;
|
|
@@ -175,21 +174,8 @@ public class ProductionSchedulingServiceImpl extends ServiceImpl<ProductionSched
|
|
|
}
|
|
|
this.save(dto);
|
|
|
|
|
|
- //获取产品工艺线路
|
|
|
- ProductionOrderDetail productionOrderDetail = produceOrderDetailService.getById(dto.getTaskId());
|
|
|
- Assert.notEmpty(productionOrderDetail, "查询不到生产任务信息!");
|
|
|
- ProductInfo productInfo = productInfoService.getById(productionOrderDetail.getProductId());
|
|
|
- Assert.notEmpty(productInfo, "查询不到产品信息!");
|
|
|
- Technology technology = technologyService.getById(productInfo.getTechnologyId());
|
|
|
- Assert.notEmpty(technology, "查询不到产品工艺信息!");
|
|
|
- String processRoute = technology.getProcessRoute();
|
|
|
- Assert.notEmpty(processRoute, "查询不到产品工艺线路为空!");
|
|
|
- String[] processRouteArr = processRoute.split(",");
|
|
|
-
|
|
|
//如果是第一道工序 创建生产领料待出库
|
|
|
- if (Long.parseLong(processRouteArr[0]) == dto.getProcessesId()) {
|
|
|
- createStockWait(dto);
|
|
|
- }
|
|
|
+ createProdStockWait(dto);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -262,16 +248,32 @@ public class ProductionSchedulingServiceImpl extends ServiceImpl<ProductionSched
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 根据排程创建待出库
|
|
|
+ * 根据排程创建生产待出库
|
|
|
*/
|
|
|
@DSTransactional
|
|
|
- private synchronized void createStockWait(ProductionScheduling dto) {
|
|
|
+ private synchronized void createProdStockWait(ProductionScheduling dto) {
|
|
|
ProductionOrderDetail task = produceOrderDetailService.getById(dto.getTaskId());
|
|
|
Assert.notEmpty(task, "查询不到任务信息!");
|
|
|
+ //获取产品工艺线路
|
|
|
+ Technology technology = technologyService.detailByProductId(task.getProductId());
|
|
|
+ Assert.notEmpty(technology, "查询不到产品工艺信息!");
|
|
|
+ String processRoute = technology.getProcessRoute();
|
|
|
+ Assert.notEmpty(processRoute, "查询不到产品工艺线路为空!");
|
|
|
+ String[] processRouteArr = processRoute.split(",");
|
|
|
+ //如果是第一道工序 创建生产领料待出库
|
|
|
+ if (Long.parseLong(processRouteArr[0]) != dto.getProcessesId()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
//生成待出库
|
|
|
- StockWait stockWait = new StockWait();
|
|
|
- stockWait.setStatus(0);//待出库
|
|
|
+ StockWait stockWait = stockWaitService.getOne(q -> q
|
|
|
+ .eq(StockWait::getBusinessId, dto.getId())
|
|
|
+ .eq(StockWait::getBusinessType, JournalType.PROD_OUT.getDetailType())
|
|
|
+ );
|
|
|
+ if (ObjectUtil.isEmpty(stockWait)) {
|
|
|
+ stockWait = new StockWait();
|
|
|
+ stockWait.setStatus(0);//待出库
|
|
|
+ }
|
|
|
stockWait.setCompanyId(task.getCompanyId());
|
|
|
stockWait.setBusinessId(dto.getId());
|
|
|
stockWait.setType(2);//出库
|
|
@@ -297,20 +299,37 @@ public class ProductionSchedulingServiceImpl extends ServiceImpl<ProductionSched
|
|
|
|
|
|
//创建待出库明细
|
|
|
Long stockWaitId = stockWait.getId();
|
|
|
- StockWaitDetails stockWaitDetails = new StockWaitDetails();
|
|
|
+ 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.setReceiptQuantity(BigDecimal.ZERO);
|
|
|
stockWaitDetails.setContractDetailId(task.getContractDetailId());
|
|
|
stockWaitDetails.setProdOrderId(task.getProduceOrderId());
|
|
|
stockWaitDetails.setProdTaskId(task.getId());
|
|
|
|
|
|
stockWaitDetails.setProductId(contractProductBomVo.getMaterialId());
|
|
|
+
|
|
|
+ //如果需求量小于入库数量 直接等于入库量
|
|
|
+ if (multiply.compareTo(stockWaitDetails.getReceiptQuantity()) < 0) {
|
|
|
+ multiply = stockWaitDetails.getReceiptQuantity();
|
|
|
+ }
|
|
|
+
|
|
|
stockWaitDetails.setQuantity(multiply);
|
|
|
stockWaitDetails.setSchedulingId(dto.getId());
|
|
|
|
|
|
stockWaitDetailsList.add(stockWaitDetails);
|
|
|
}
|
|
|
stockWaitDetailsService.saveOrUpdateBatch(stockWaitDetailsList);
|
|
|
+
|
|
|
+ //更新状态
|
|
|
+ stockWaitService.updateStatus(stockWait.getId());
|
|
|
}
|
|
|
|
|
|
}
|