Explorar o código

补单超领新增

fgd hai 1 ano
pai
achega
320efa0113

+ 4 - 4
sd-business/src/main/java/com/sd/business/controller/production/ProductionExceedReceiveController.java

@@ -66,10 +66,10 @@ public class ProductionExceedReceiveController {
     }
 
     /**
-     * 计划外超领生产
+     * 补单超领生产
      */
-    @PostMapping("/unplannedExceedReceive")
-    public void unplannedExceedReceive(@Validated @RequestBody ProductionExceedReceiveDto dto) {
-        productionExceedReceiveService.unplannedExceedReceive(dto);
+    @PostMapping("/replenishExceedReceive")
+    public void replenishExceedReceive(@Validated @RequestBody ProductionExceedReceiveDto dto) {
+        productionExceedReceiveService.replenishExceedReceive(dto);
     }
 }

+ 2 - 0
sd-business/src/main/java/com/sd/business/entity/production/dto/ProductionExceedReceiveDto.java

@@ -4,6 +4,7 @@ import com.sd.business.entity.production.po.ProductionExceedReceive;
 import lombok.Getter;
 import lombok.Setter;
 
+import javax.validation.Valid;
 import javax.validation.constraints.NotEmpty;
 import java.util.List;
 
@@ -20,6 +21,7 @@ public class ProductionExceedReceiveDto extends ProductionExceedReceive {
     /**
      * 订单sku超领明细
      */
+    @Valid
     @NotEmpty(message = "订单sku超领明细列表不能为空")
     private List<ProductionExceedReceiveSkuDto> productionExceedReceiveSkuList;
 

+ 41 - 0
sd-business/src/main/java/com/sd/business/entity/production/enums/ExceedReceiveTypeEnum.java

@@ -0,0 +1,41 @@
+package com.sd.business.entity.production.enums;
+
+import com.ruoyi.common.exception.ServiceException;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Getter
+@AllArgsConstructor
+public enum ExceedReceiveTypeEnum {
+    PRODUCTION_DAMAGE(1, "制作损坏"),
+    QUALITY_DEFECTIVE(2, "裸垫质量不良"),
+    PRODUCTION_ERROR(3, "生产错误"),
+    LOSE(4, "丢失"),
+    REPLENISH(5, "补单"),
+    ;
+
+    private static final Map<Integer, ExceedReceiveTypeEnum> map = new HashMap<>();
+
+    static {
+        for (ExceedReceiveTypeEnum exceedReceiveTypeEnum : values()) {
+            map.put(exceedReceiveTypeEnum.getKey(), exceedReceiveTypeEnum);
+        }
+    }
+
+    private final Integer key;
+    private final String value;
+
+    /**
+     * 通过key获取名称
+     */
+    public static ExceedReceiveTypeEnum getEnum(Integer key) {
+        ExceedReceiveTypeEnum exceedReceiveTypeEnum = map.get(key);
+        if (exceedReceiveTypeEnum == null) {
+            throw new ServiceException("未知订单状态:" + key);
+        }
+        return exceedReceiveTypeEnum;
+    }
+}

+ 1 - 2
sd-business/src/main/java/com/sd/business/entity/production/po/ProductionExceedReceive.java

@@ -6,7 +6,6 @@ import lombok.Getter;
 import lombok.Setter;
 
 import javax.validation.constraints.NotNull;
-import java.math.BigDecimal;
 
 /**
  * <p>
@@ -22,7 +21,7 @@ import java.math.BigDecimal;
 public class ProductionExceedReceive extends BasePo {
 
     /**
-     * 类型 1制作损坏 2裸垫质量不良 3生产错误 4计划外超领
+     * 类型 1制作损坏 2裸垫质量不良 3生产错误 4丢件 5补发
      */
     @NotNull(message = "超领类型不能为空")
     private Integer type;

+ 1 - 1
sd-business/src/main/java/com/sd/business/service/production/ProductionExceedReceiveService.java

@@ -38,5 +38,5 @@ public interface ProductionExceedReceiveService extends BaseService<ProductionEx
      * 计划外超领生产
      * @param dto
      */
-    void unplannedExceedReceive(ProductionExceedReceiveDto dto);
+    void replenishExceedReceive(ProductionExceedReceiveDto dto);
 }

+ 51 - 14
sd-business/src/main/java/com/sd/business/service/production/impl/ProductionExceedReceiveServiceImpl.java

@@ -25,6 +25,7 @@ import com.sd.business.entity.order.po.OrderSkuProductionCost;
 import com.sd.business.entity.production.dto.ProductionExceedReceiveDto;
 import com.sd.business.entity.production.dto.ProductionExceedReceiveSelectDto;
 import com.sd.business.entity.production.dto.ProductionExceedReceiveSkuDto;
+import com.sd.business.entity.production.enums.ExceedReceiveTypeEnum;
 import com.sd.business.entity.production.po.ProductionExceedReceive;
 import com.sd.business.entity.production.po.ProductionExceedReceiveSku;
 import com.sd.business.entity.production.vo.ProductionExceedReceiveVo;
@@ -150,7 +151,7 @@ public class ProductionExceedReceiveServiceImpl extends ServiceImpl<ProductionEx
         // 入库
         // 制作损坏入库到生产次品仓,裸垫质量不良入库到采购次品仓
         Long warehouseId;
-        if (Objects.equals(dto.getType(), 1)) {
+        if (Objects.equals(dto.getType(), ExceedReceiveTypeEnum.PRODUCTION_DAMAGE.getKey())) {
             warehouseId = WarehouseConstant.PRODUCTION_DEFECTIVE;
         } else {
             warehouseId = WarehouseConstant.PURCHASE_DEFECTIVE;
@@ -162,7 +163,7 @@ public class ProductionExceedReceiveServiceImpl extends ServiceImpl<ProductionEx
                 inOutStorageBomList,
                 StatusConstant.NO);
         // 人为损坏, 新增订单生产成本的材料成本
-        if (Objects.equals(dto.getType(), 1)) {
+        if (Objects.equals(dto.getType(), ExceedReceiveTypeEnum.PRODUCTION_DAMAGE.getKey())) {
             Map<Long, OrderSkuProductionCost> orderSkuProductionCostMap = orderSkuProductionCostService.mapKEntity(
                     OrderSkuProductionCost::getOrderSkuId,
                     q -> q.eq(OrderSkuProductionCost::getOrderId, orderId)
@@ -304,7 +305,7 @@ public class ProductionExceedReceiveServiceImpl extends ServiceImpl<ProductionEx
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public void unplannedExceedReceive(ProductionExceedReceiveDto dto) {
+    public void replenishExceedReceive(ProductionExceedReceiveDto dto) {
         Long orderId = dto.getOrderId();
         OrderInfo orderInfo = orderService.getById(orderId);
         Assert.notNull(orderInfo, "未知订单");
@@ -342,7 +343,7 @@ public class ProductionExceedReceiveServiceImpl extends ServiceImpl<ProductionEx
         this.inOutStorageAdd(InOutTypeEnum.OUT.getKey(),
                 OutDetailTypeEnum.PRODUCTION.getKey(),
                 WarehouseConstant.SEMI_FINISHED_PRODUCT,
-                remark + "计划外超领出库",
+                remark + "超领出库",
                 JSON.parseArray(JSON.toJSONString(semiFinishedProductInOutStorageBomList), InOutStorageBom.class),
                 StatusConstant.NO
         );
@@ -354,17 +355,55 @@ public class ProductionExceedReceiveServiceImpl extends ServiceImpl<ProductionEx
         this.inOutStorageAdd(InOutTypeEnum.OUT.getKey(),
                 OutDetailTypeEnum.PRODUCTION.getKey(),
                 WarehouseConstant.PACKAGING_MATERIAL,
-                remark + "计划外超领出库",
+                remark + "超领出库",
                 packagingMaterialInOutStorageBomList,
                 StatusConstant.NO);
 
-        // 半成品入库次品仓
-        this.inOutStorageAdd(InOutTypeEnum.IN.getKey(),
-                InDetailTypeEnum.ABANDON.getKey(),
-                WarehouseConstant.PRODUCTION_DEFECTIVE,
-                remark + "计划外超领报废入库",
-                semiFinishedProductInOutStorageBomList,
-                StatusConstant.NO);
+        // 丢件不入库
+        if (Objects.equals(dto.getType(), ExceedReceiveTypeEnum.REPLENISH.getKey())) {
+            // 入库
+            List<Long> skuSpecIds = exceedReceiveSkuList.stream().map(ProductionExceedReceiveSku::getExceptionSkuSpecId).collect(Collectors.toList());
+            Map<Long, SkuSpec> skuSpecMap = skuSpecService.byIdsToMap(skuSpecIds);
+            List<InOutStorageBom> inOutStorageBomList = new ArrayList<>();
+            List<InventoryFinished> inventoryFinishedList = new ArrayList<>();
+            for (ProductionExceedReceiveSkuDto exceedReceiveSkuDto : exceedReceiveSkuList) {
+                if (exceedReceiveSkuDto.getExceptionSkuSpecId() == null || exceedReceiveSkuDto.getWarehouseId() == null) {
+                    continue;
+                }
+                SkuSpec skuSpec = skuSpecMap.get(exceedReceiveSkuDto.getExceptionSkuSpecId());
+                if (Objects.equals(exceedReceiveSkuDto.getWarehouseId(), WarehouseConstant.PRODUCTION_DEFECTIVE)) {
+                    InOutStorageBom inStorageBom = new InOutStorageBom();
+                    inStorageBom.setBomSpecId(skuSpec.getBomSpecId());
+                    inStorageBom.setQuantity(exceedReceiveSkuDto.getQuantity());
+                    inOutStorageBomList.add(inStorageBom);
+                } else {
+                    InventoryFinished inventoryFinished = new InventoryFinished();
+                    inventoryFinished.setSkuSpecId(skuSpec.getId());
+                    inventoryFinished.setQuantity(exceedReceiveSkuDto.getQuantity());
+                    inventoryFinishedList.add(inventoryFinished);
+                }
+            }
+
+            if (!inOutStorageBomList.isEmpty()) {
+                this.inOutStorageAdd(InOutTypeEnum.IN.getKey(),
+                        InDetailTypeEnum.ABANDON.getKey(),
+                        WarehouseConstant.PRODUCTION_DEFECTIVE,
+                        remark + "超领报废入库",
+                        inOutStorageBomList,
+                        StatusConstant.NO);
+            }
+            if (!inventoryFinishedList.isEmpty()) {
+                List<OrderSku> orderSkuList = inventoryFinishedList.stream().map(item -> {
+                    OrderSku orderSku = new OrderSku();
+                    orderSku.setSkuSpecId(item.getSkuSpecId());
+                    orderSku.setQuantity(item.getQuantity());
+                    return orderSku;
+                }).collect(Collectors.toList());
+                // 成品入库,并生成明细
+                inventoryFinishedService.inOut(inventoryFinishedList, true);
+                inventoryFinishedOrderService.productionWarehousing(orderSkuList);
+            }
+        }
 
         // 保存超领数据
         this.save(dto);
@@ -372,8 +411,6 @@ public class ProductionExceedReceiveServiceImpl extends ServiceImpl<ProductionEx
                 .peek(item -> {
                     item.setProductionExceedReceiveId(dto.getId());
                     item.setOrderId(dto.getOrderId());
-                    item.setExceptionSkuSpecId(item.getSkuSpecId());
-                    item.setWarehouseId(WarehouseConstant.PRODUCTION_DEFECTIVE);
                 })
                 .collect(Collectors.toList());
         productionExceedReceiveSkuService.saveBatch(productionExceedReceiveSkuList);

+ 2 - 2
sd-business/src/main/resources/mapper/inventory/InventoryFinishedOrderMapper.xml

@@ -13,8 +13,8 @@
                ifod.operation_type operationType,
                ifod.code
         from inventory_finished_order_detail ifod
-                 inner join order_info oi on ifod.order_info_id = oi.id
-                 inner join department d on oi.department_id = d.id
+                 left join order_info oi on ifod.order_info_id = oi.id
+                 left join department d on oi.department_id = d.id
                  inner join sku_spec ss on ifod.sku_spec_id = ss.id
             ${ew.customSqlSegment}
     </select>