|
@@ -32,6 +32,7 @@ import com.fjhx.sale.entity.contract.po.ContractProduct;
|
|
|
import com.fjhx.sale.service.contract.ContractProductService;
|
|
|
import com.fjhx.sale.service.contract.ContractService;
|
|
|
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;
|
|
@@ -186,6 +187,43 @@ public class ProduceOrderServiceImpl extends ServiceImpl<ProduceOrderMapper, Pro
|
|
|
produceOrderDto.setCode(contract.getCode());
|
|
|
produceOrderDto.setProduceStatus(0);
|
|
|
this.save(produceOrderDto);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 投产
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @DSTransactional
|
|
|
+ public synchronized void putProduction(Long id) {
|
|
|
+ ProductionOrder productionOrder = this.getById(id);
|
|
|
+ Assert.notEmpty(productionOrder, "查询不到订单信息!");
|
|
|
+
|
|
|
+ if (ObjectUtil.isNotEmpty(productionOrder.getProduceTime())) {
|
|
|
+ throw new ServiceException("该订单已投产,请勿重复投产!!");
|
|
|
+ }
|
|
|
+
|
|
|
+ //创建生产任务
|
|
|
+ createOrderDetails(productionOrder);
|
|
|
+
|
|
|
+ Date date = new Date();
|
|
|
+ this.update(q -> q
|
|
|
+ .eq(ProductionOrder::getId, id)
|
|
|
+ .set(ProductionOrder::getProduceTime, date)
|
|
|
+ .set(ProductionOrder::getUpdateTime, date)
|
|
|
+ .set(ProductionOrder::getUpdateUser, SecurityUtils.getUserId())
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建生产任务
|
|
|
+ */
|
|
|
+ private void createOrderDetails(ProductionOrder produceOrder) {
|
|
|
+ Long orderDtoId = produceOrder.getId();
|
|
|
+ Long contractId = produceOrder.getContractId();
|
|
|
+ Long companyId = produceOrder.getCompanyId();
|
|
|
+
|
|
|
+ Contract contract = contractService.getById(contractId);
|
|
|
+ Assert.notEmpty(contract, "查询不到合同信息!");
|
|
|
|
|
|
//创建生产订单明细
|
|
|
List<ProductionOrderDetail> productionOrderDetailList = new ArrayList<>();
|
|
@@ -198,7 +236,7 @@ public class ProduceOrderServiceImpl extends ServiceImpl<ProduceOrderMapper, Pro
|
|
|
|
|
|
for (ContractProduct contractProduct : contractProductList) {
|
|
|
ProductionOrderDetail productionOrderDetail = new ProductionOrderDetail();
|
|
|
- productionOrderDetail.setProduceOrderId(produceOrderDto.getId());
|
|
|
+ productionOrderDetail.setProduceOrderId(orderDtoId);
|
|
|
productionOrderDetail.setContractId(contractId);
|
|
|
productionOrderDetail.setContractDetailId(contractProduct.getId());
|
|
|
productionOrderDetail.setProductId(contractProduct.getProductId());
|
|
@@ -221,7 +259,7 @@ public class ProduceOrderServiceImpl extends ServiceImpl<ProduceOrderMapper, Pro
|
|
|
MaterialPreparation materialPreparation = new MaterialPreparation();
|
|
|
materialPreparation.setContractId(contractId);
|
|
|
materialPreparation.setContractDetailId(contractProduct.getId());
|
|
|
- materialPreparation.setProductionOrderId(produceOrderDto.getId());
|
|
|
+ materialPreparation.setProductionOrderId(orderDtoId);
|
|
|
materialPreparation.setProductionOrderDetailId(productionOrderDetail.getId());
|
|
|
materialPreparation.setMaterialId(bomDetail.getMaterialId());
|
|
|
materialPreparation.setQuantity(multiply);
|
|
@@ -270,18 +308,4 @@ public class ProduceOrderServiceImpl extends ServiceImpl<ProduceOrderMapper, Pro
|
|
|
productionTaskProgressService.saveBatch(productionTaskProgressList);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 投产
|
|
|
- */
|
|
|
- @Override
|
|
|
- public void putProduction(Long id) {
|
|
|
- Date date = new Date();
|
|
|
- this.update(q -> q
|
|
|
- .eq(ProductionOrder::getId, id)
|
|
|
- .set(ProductionOrder::getProduceTime, date)
|
|
|
- .set(ProductionOrder::getUpdateTime, date)
|
|
|
- .set(ProductionOrder::getUpdateUser, SecurityUtils.getUserId())
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
}
|