| doc/宁夏-中盛建材.sql | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/main/java/com/ruoyi/production/service/impl/ProductOrderServiceImpl.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/main/java/com/ruoyi/productionPlan/pojo/ProductOrderPlan.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
| src/main/java/com/ruoyi/productionPlan/service/impl/ProductionPlanServiceImpl.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
doc/ÄþÏÄ-ÖÐÊ¢½¨²Ä.sql
@@ -103,6 +103,7 @@ production_plan_id bigint not null default 0 comment 'ç产计åid', create_time datetime null comment 'å½å ¥æ¶é´', update_time datetime null comment 'æ´æ°æ¶é´', assigned_quantity DECIMAL(10, 4) default 0 not null comment 'ä¸åæ°é', index idx_product_order_id (product_order_id), index idx_production_plan_id (production_plan_id), unique idx_product_order_production_plan (product_order_id, production_plan_id) src/main/java/com/ruoyi/production/service/impl/ProductOrderServiceImpl.java
@@ -15,10 +15,15 @@ import com.ruoyi.production.mapper.*; import com.ruoyi.production.pojo.*; import com.ruoyi.production.service.ProductOrderService; import com.ruoyi.productionPlan.mapper.ProductOrderPlanMapper; import com.ruoyi.productionPlan.mapper.ProductionPlanMapper; import com.ruoyi.productionPlan.pojo.ProductOrderPlan; import com.ruoyi.productionPlan.pojo.ProductionPlan; import com.ruoyi.quality.mapper.QualityInspectMapper; import com.ruoyi.quality.pojo.QualityInspect; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.time.LocalDate; @@ -49,6 +54,12 @@ @Autowired private ProductionProductMainMapper productionProductMainMapper; @Autowired private ProductOrderPlanMapper productOrderPlanMapper; @Autowired private ProductionPlanMapper productionPlanMapper; @Autowired private ProductionProductOutputMapper productionProductOutputMapper; @@ -123,14 +134,25 @@ } @Override @Transactional(rollbackFor = Exception.class) public Boolean revoke(ProductOrder productOrder) { //夿æ¯å¦äº§çå·¥å List<ProductionProductMain> productionProductMains = productionProductMainMapper.selectList(Wrappers.<ProductionProductMain>lambdaQuery().eq(ProductionProductMain::getProductOrderId, productOrder.getId())); if (!productionProductMains.isEmpty()) { throw new RuntimeException("ç产订åå·²ç»æ¥å·¥,ä¸è½æ¤é"); } // todo 夿æ¯å¦äº§çæ¥å·¥ä¿¡æ¯ // æ¥è¯¢åå¹¶çç产计å List<ProductOrderPlan> productOrderPlans = productOrderPlanMapper.selectList(Wrappers.<ProductOrderPlan>lambdaQuery().in(ProductOrderPlan::getProductOrderId, productOrder.getId())); if (productOrderPlans.isEmpty()) { throw new RuntimeException("åå¹¶çç产计åä¸åå¨"); } for (ProductOrderPlan productOrderPlan : productOrderPlans) { ProductionPlan productionPlan = productionPlanMapper.selectById(productOrderPlan.getProductionPlanId()); productionPlan.setAssignedQuantity(productionPlan.getAssignedQuantity().subtract(productOrderPlan.getAssignedQuantity())); productionPlanMapper.updateById(productionPlan); } // å é¤å ³èå ³ç³» productOrderPlanMapper.delete(Wrappers.<ProductOrderPlan>lambdaQuery().in(ProductOrderPlan::getProductOrderId, productOrder.getId())); // å é¤è®¢å productOrderMapper.deleteById(productOrder.getId()); // todo å é¤è®¢åä¸çå·¥èºè·¯çº¿å表 return null; } src/main/java/com/ruoyi/productionPlan/pojo/ProductOrderPlan.java
@@ -6,7 +6,10 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import java.io.Serializable; import java.math.BigDecimal; import java.time.LocalDateTime; import com.ruoyi.framework.aspectj.lang.annotation.Excel; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Getter; @@ -37,6 +40,10 @@ @ApiModelProperty("ç产计åid") private Long productionPlanId; @ApiModelProperty(value = "ä¸åæ°é") @Excel(name = "ä¸åæ°é") private BigDecimal assignedQuantity; @ApiModelProperty("å½å ¥æ¶é´") @TableField(fill = FieldFill.INSERT) private LocalDateTime createTime; src/main/java/com/ruoyi/productionPlan/service/impl/ProductionPlanServiceImpl.java
@@ -107,6 +107,7 @@ // æ¥è¯¢ä¸»ç产计å List<ProductionPlan> plans = productionPlanMapper.selectBatchIds(productionPlanDto.getIds()); plans.sort(Comparator.comparingLong(ProductionPlan::getId)); // æ ¡éªæ¯å¦åå¨ä¸åç产ååç§° String firstProductName = plans.get(0).getProductName(); @@ -128,10 +129,14 @@ .reduce(BigDecimal.ZERO, BigDecimal::add); // 夿ä¸åæ°éæ¯å¦å¤§äºçäºæ¹æ° if (productionPlanDto.getTotalAssignedQuantity().compareTo(totalVolume) > 0) { log.warn("æä½å¤±è´¥ï¼ä¸åæ°éä¸è½å¤§äºæ¹æ°"); return false; throw new BaseException("æä½å¤±è´¥ï¼ä¸åæ°éä¸è½å¤§äºæ¹æ°"); } // å建ç产订å ProductOrder productOrder = new ProductOrder(); productOrder.setQuantity(productionPlanDto.getTotalAssignedQuantity()); productOrder.setPlanCompleteTime(productionPlanDto.getPlanCompleteTime()); productOrderService.addProductOrder(productOrder); // æ ¹æ®ä¸åæ°éï¼ä»ç¬¬ä¸ä¸ªç产计åå¼å§åé æ¹æ° BigDecimal assignedVolume = BigDecimal.ZERO; @@ -141,30 +146,28 @@ continue; } ProductOrderPlan productOrderPlan = new ProductOrderPlan(); productOrderPlan.setProductOrderId(productOrder.getId()); productOrderPlan.setProductionPlanId(plan.getId()); if (assignedVolume.add(volume).compareTo(productionPlanDto.getTotalAssignedQuantity()) >= 0) { // æåä¸ä¸ªè®¡åï¼åé å©ä½æ¹æ° plan.setAssignedQuantity(productionPlanDto.getTotalAssignedQuantity().subtract(assignedVolume)); BigDecimal remainingVolume = productionPlanDto.getTotalAssignedQuantity().subtract(assignedVolume); plan.setAssignedQuantity(plan.getAssignedQuantity().add(remainingVolume)); productOrderPlan.setAssignedQuantity(remainingVolume); productionPlanMapper.updateById(plan); productOrderPlanMapper.insert(productOrderPlan); break; } // åé å½åè®¡åæ¹æ° plan.setAssignedQuantity(volume); plan.setAssignedQuantity(plan.getAssignedQuantity().add(volume)); productOrderPlan.setAssignedQuantity(volume); // æ´æ°ç产计å productionPlanMapper.updateById(plan); assignedVolume = assignedVolume.add(volume); } // å建ç产订å ProductOrder productOrder = new ProductOrder(); productOrder.setQuantity(productionPlanDto.getTotalAssignedQuantity()); productOrder.setPlanCompleteTime(productionPlanDto.getPlanCompleteTime()); productOrderService.addProductOrder(productOrder); for (Long planId : productionPlanDto.getIds()) { ProductOrderPlan productOrderPlan = new ProductOrderPlan(); productOrderPlan.setProductOrderId(productOrder.getId()); productOrderPlan.setProductionPlanId(planId); // åå»ºå ³èå ³ç³» productOrderPlanMapper.insert(productOrderPlan); assignedVolume = assignedVolume.add(volume); } return true; }