|
@@ -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);
|