|
@@ -10,8 +10,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.item.entity.product.po.ProductInfo;
|
|
|
import com.fjhx.item.service.product.ProductInfoService;
|
|
|
import com.fjhx.mes.entity.applicable.po.ApplicableProducts;
|
|
|
-import com.fjhx.mes.entity.bom.po.BomDetail;
|
|
|
-import com.fjhx.mes.entity.bom.po.BomInfo;
|
|
|
import com.fjhx.mes.entity.production.dto.ProductionTaskDto;
|
|
|
import com.fjhx.mes.entity.production.dto.ProductionTaskSelectDto;
|
|
|
import com.fjhx.mes.entity.production.po.*;
|
|
@@ -19,7 +17,6 @@ import com.fjhx.mes.entity.production.vo.ProductionTaskDetailVo;
|
|
|
import com.fjhx.mes.entity.production.vo.ProductionTaskVo;
|
|
|
import com.fjhx.mes.entity.technology.po.Technology;
|
|
|
import com.fjhx.mes.entity.work.po.WorkOrder;
|
|
|
-import com.fjhx.mes.entity.work.po.WorkOrderBom;
|
|
|
import com.fjhx.mes.entity.work.po.WorkOrderProductionProcesses;
|
|
|
import com.fjhx.mes.mapper.production.ProductionTaskMapper;
|
|
|
import com.fjhx.mes.service.applicable.ApplicableProductsService;
|
|
@@ -30,14 +27,9 @@ import com.fjhx.mes.service.technology.TechnologyService;
|
|
|
import com.fjhx.mes.service.work.WorkOrderBomService;
|
|
|
import com.fjhx.mes.service.work.WorkOrderProductionProcessesService;
|
|
|
import com.fjhx.mes.service.work.WorkOrderService;
|
|
|
-import com.fjhx.mes.utils.code.CodeEnum;
|
|
|
-import com.fjhx.wms.entity.stock.emums.JournalType;
|
|
|
-import com.fjhx.wms.entity.stock.po.StockWait;
|
|
|
-import com.fjhx.wms.entity.stock.po.StockWaitDetails;
|
|
|
import com.fjhx.wms.service.stock.StockWaitDetailsService;
|
|
|
import com.fjhx.wms.service.stock.StockWaitService;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
-import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
import com.ruoyi.system.utils.UserUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -138,60 +130,60 @@ public class ProductionTaskServiceImpl extends ServiceImpl<ProductionTaskMapper,
|
|
|
@DSTransactional
|
|
|
@Override
|
|
|
public void add(ProductionTaskDto productionTaskDto) {
|
|
|
- productionTaskDto.setCode(CodeEnum.PRODUCTION_TASK.getCode());
|
|
|
- this.save(productionTaskDto);
|
|
|
- Long productionPlanId = productionTaskDto.getProductionPlanId();
|
|
|
- //更新生产计划状态为进行中
|
|
|
- ProductionPlan productionPlan = productionPlanService.getById(productionPlanId);
|
|
|
- productionPlan.setStatus(1);
|
|
|
- productionPlanService.updateById(productionPlan);
|
|
|
-
|
|
|
- //根据工单是否是定制工单 创建BOM待出库数据
|
|
|
- WorkOrder workOrder = workOrderService.getById(productionPlan.getWorkOrderId());
|
|
|
- if (ObjectUtil.isEmpty(workOrder)) {
|
|
|
- throw new ServiceException("查询不到该任务的工单信息");
|
|
|
- }
|
|
|
-
|
|
|
- List<BomDetail> bomDetailList = new ArrayList<>();
|
|
|
- if ("1".equals(workOrder.getIsCustomized())) {
|
|
|
- List<WorkOrderBom> workOrderBomList = workOrderBomService.list(q -> q.eq(WorkOrderBom::getWorkOrderId, workOrder.getId()));
|
|
|
- if (ObjectUtil.isEmpty(workOrderBomList)) {
|
|
|
- throw new ServiceException("该工单为定制工单 未配置定制BOM");
|
|
|
- }
|
|
|
- bomDetailList = BeanUtil.copyToList(workOrderBomList, BomDetail.class);
|
|
|
- } else {
|
|
|
- //查询BOM信息
|
|
|
- BomInfo bomInfo = bomInfoService.getOne(q -> q.eq(BomInfo::getProductId, workOrder.getProductId()).eq(BomInfo::getCurrentVersion,1));
|
|
|
- if (ObjectUtil.isEmpty(bomInfo)) {
|
|
|
- throw new ServiceException("查询不到产品的BOM信息");
|
|
|
- }
|
|
|
- bomDetailList = bomDetailService.list(q -> q.eq(BomDetail::getBomInfoId, bomInfo.getId()));
|
|
|
- if (ObjectUtil.isEmpty(bomDetailList)) {
|
|
|
- throw new ServiceException("查询不到BOM明细");
|
|
|
- }
|
|
|
- }
|
|
|
- //创建待出库信息
|
|
|
- StockWait stockWait = new StockWait();
|
|
|
- stockWait.setCompanyId(SecurityUtils.getCompanyId());
|
|
|
- stockWait.setBusinessId(productionTaskDto.getId());
|
|
|
- stockWait.setType(2);//出库
|
|
|
- stockWait.setStatus(0);//待出库
|
|
|
- stockWait.setBusinessType(JournalType.PROD_OUT.getDetailType());//生产任务出库
|
|
|
- stockWaitService.save(stockWait);
|
|
|
- //创建待出库明细
|
|
|
- List<StockWaitDetails> stockWaitDetailsList = new ArrayList<>();
|
|
|
- for (BomDetail bomDetail : bomDetailList) {
|
|
|
- //计算数量
|
|
|
- BigDecimal multiply = bomDetail.getQuantity().multiply(productionTaskDto.getQuantity());
|
|
|
- //创建待出库明细
|
|
|
- StockWaitDetails stockWaitDetails = new StockWaitDetails();
|
|
|
- stockWaitDetails.setStockWaitId(stockWait.getId());
|
|
|
- stockWaitDetails.setProductId(bomDetail.getProductId());
|
|
|
- stockWaitDetails.setQuantity(multiply);
|
|
|
- stockWaitDetails.setReceiptQuantity(BigDecimal.ZERO);
|
|
|
- stockWaitDetailsList.add(stockWaitDetails);
|
|
|
- }
|
|
|
- stockWaitDetailsService.saveBatch(stockWaitDetailsList);
|
|
|
+// productionTaskDto.setCode(CodeEnum.PRODUCTION_TASK.getCode());
|
|
|
+// this.save(productionTaskDto);
|
|
|
+// Long productionPlanId = productionTaskDto.getProductionPlanId();
|
|
|
+// //更新生产计划状态为进行中
|
|
|
+// ProductionPlan productionPlan = productionPlanService.getById(productionPlanId);
|
|
|
+// productionPlan.setStatus(1);
|
|
|
+// productionPlanService.updateById(productionPlan);
|
|
|
+//
|
|
|
+// //根据工单是否是定制工单 创建BOM待出库数据
|
|
|
+// WorkOrder workOrder = workOrderService.getById(productionPlan.getWorkOrderId());
|
|
|
+// if (ObjectUtil.isEmpty(workOrder)) {
|
|
|
+// throw new ServiceException("查询不到该任务的工单信息");
|
|
|
+// }
|
|
|
+//
|
|
|
+// List<BomDetail> bomDetailList = new ArrayList<>();
|
|
|
+// if ("1".equals(workOrder.getIsCustomized())) {
|
|
|
+// List<WorkOrderBom> workOrderBomList = workOrderBomService.list(q -> q.eq(WorkOrderBom::getWorkOrderId, workOrder.getId()));
|
|
|
+// if (ObjectUtil.isEmpty(workOrderBomList)) {
|
|
|
+// throw new ServiceException("该工单为定制工单 未配置定制BOM");
|
|
|
+// }
|
|
|
+// bomDetailList = BeanUtil.copyToList(workOrderBomList, BomDetail.class);
|
|
|
+// } else {
|
|
|
+// //查询BOM信息
|
|
|
+// BomInfo bomInfo = bomInfoService.getOne(q -> q.eq(BomInfo::getProductId, workOrder.getProductId()).eq(BomInfo::getCurrentVersion,1));
|
|
|
+// if (ObjectUtil.isEmpty(bomInfo)) {
|
|
|
+// throw new ServiceException("查询不到产品的BOM信息");
|
|
|
+// }
|
|
|
+// bomDetailList = bomDetailService.list(q -> q.eq(BomDetail::getBomInfoId, bomInfo.getId()));
|
|
|
+// if (ObjectUtil.isEmpty(bomDetailList)) {
|
|
|
+// throw new ServiceException("查询不到BOM明细");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// //创建待出库信息
|
|
|
+// StockWait stockWait = new StockWait();
|
|
|
+// stockWait.setCompanyId(SecurityUtils.getCompanyId());
|
|
|
+// stockWait.setBusinessId(productionTaskDto.getId());
|
|
|
+// stockWait.setType(2);//出库
|
|
|
+// stockWait.setStatus(0);//待出库
|
|
|
+// stockWait.setBusinessType(JournalType.PROD_OUT.getDetailType());//生产任务出库
|
|
|
+// stockWaitService.save(stockWait);
|
|
|
+// //创建待出库明细
|
|
|
+// List<StockWaitDetails> stockWaitDetailsList = new ArrayList<>();
|
|
|
+// for (BomDetail bomDetail : bomDetailList) {
|
|
|
+// //计算数量
|
|
|
+// BigDecimal multiply = bomDetail.getQuantity().multiply(productionTaskDto.getQuantity());
|
|
|
+// //创建待出库明细
|
|
|
+// StockWaitDetails stockWaitDetails = new StockWaitDetails();
|
|
|
+// stockWaitDetails.setStockWaitId(stockWait.getId());
|
|
|
+// stockWaitDetails.setProductId(bomDetail.getProductId());
|
|
|
+// stockWaitDetails.setQuantity(multiply);
|
|
|
+// stockWaitDetails.setReceiptQuantity(BigDecimal.ZERO);
|
|
|
+// stockWaitDetailsList.add(stockWaitDetails);
|
|
|
+// }
|
|
|
+// stockWaitDetailsService.saveBatch(stockWaitDetailsList);
|
|
|
}
|
|
|
|
|
|
@Override
|