|
@@ -46,11 +46,9 @@ import com.sd.business.entity.order.vo.OrderPackageBomVo;
|
|
|
import com.sd.business.entity.order.vo.OrderSkuBomVo;
|
|
|
import com.sd.business.entity.order.vo.OrderSkuExportVo;
|
|
|
import com.sd.business.entity.order.vo.OrderSkuVo;
|
|
|
-import com.sd.business.entity.order.vo.OutBomVo;
|
|
|
import com.sd.business.entity.order.vo.SkuSpecPriceVo;
|
|
|
import com.sd.business.entity.price.po.PriceBillingStandard;
|
|
|
import com.sd.business.entity.price.po.PriceBillingStandardDetail;
|
|
|
-import com.sd.business.entity.production.po.ProductionWorkOrder;
|
|
|
import com.sd.business.entity.sku.po.SkuSpec;
|
|
|
import com.sd.business.entity.sku.po.SkuSpecLink;
|
|
|
import com.sd.business.entity.warehouse.constant.WarehouseConstant;
|
|
@@ -67,7 +65,6 @@ import com.sd.business.service.order.OrderSkuProductionCostService;
|
|
|
import com.sd.business.service.order.OrderSkuService;
|
|
|
import com.sd.business.service.price.PriceBillingStandardDetailService;
|
|
|
import com.sd.business.service.price.PriceBillingStandardService;
|
|
|
-import com.sd.business.service.production.ProductionWorkOrderService;
|
|
|
import com.sd.business.service.sku.SkuSpecLinkService;
|
|
|
import com.sd.business.service.sku.SkuSpecService;
|
|
|
import com.sd.business.util.CodeEnum;
|
|
@@ -87,7 +84,6 @@ import java.math.RoundingMode;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Collections;
|
|
|
-import java.util.Comparator;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.HashSet;
|
|
@@ -97,7 +93,6 @@ import java.util.Objects;
|
|
|
import java.util.Set;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
-import java.util.stream.Stream;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -127,9 +122,6 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|
|
private OrderSkuProductionCostService orderSkuProductionCostService;
|
|
|
|
|
|
@Autowired
|
|
|
- private ProductionWorkOrderService productionWorkOrderService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
private InOutStorageService inOutStorageService;
|
|
|
|
|
|
@Autowired
|
|
@@ -385,8 +377,6 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|
|
&& ObjectUtil.equals(dto.getType(), 2)
|
|
|
&& ObjectUtil.isEmpty(orderSkuBomList)) {
|
|
|
dto.setStatus(OrderStatusEnum.IN_PRODUCTION.getKey());
|
|
|
- // 生成工单
|
|
|
- productionWorkOrderService.addByOrderId(dto.getId());
|
|
|
update(q -> q.set(OrderInfo::getStatus, OrderStatusEnum.IN_PRODUCTION.getKey()).eq(BaseIdPo::getId, dto.getId()));
|
|
|
}
|
|
|
|
|
@@ -479,8 +469,6 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|
|
&& ObjectUtil.equals(dto.getType(), 2)
|
|
|
&& ObjectUtil.isEmpty(orderSkuBomList)) {
|
|
|
dto.setStatus(OrderStatusEnum.IN_PRODUCTION.getKey());
|
|
|
- // 生成工单
|
|
|
- productionWorkOrderService.addByOrderId(dto.getId());
|
|
|
update(q -> q.set(OrderInfo::getStatus, OrderStatusEnum.IN_PRODUCTION.getKey()).eq(BaseIdPo::getId, dto.getId()));
|
|
|
}
|
|
|
|
|
@@ -507,81 +495,6 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|
|
@DSTransactional
|
|
|
@Override
|
|
|
public void delete(Long id) {
|
|
|
- removeById(id);
|
|
|
- orderSkuService.remove(q -> q.eq(OrderSku::getOrderId, id));
|
|
|
- orderSkuBomService.remove(q -> q.eq(OrderSkuBom::getOrderId, id));
|
|
|
- orderPackageBomService.remove(q -> q.eq(OrderPackageBom::getOrderId, id));
|
|
|
- orderSkuProductionCostService.remove(q -> q.eq(OrderSkuProductionCost::getOrderId, id));
|
|
|
- productionWorkOrderService.remove(q -> q.eq(ProductionWorkOrder::getOrderId, id));
|
|
|
-
|
|
|
- ObsFileUtil.removeFile(id);
|
|
|
- }
|
|
|
-
|
|
|
- @DSTransactional
|
|
|
- @Override
|
|
|
- public synchronized void deleteAndStore(Long id) {
|
|
|
- OrderInfo orderInfo = getById(id);
|
|
|
-
|
|
|
- if (orderInfo == null) {
|
|
|
- throw new ServiceException("未找到订单");
|
|
|
- }
|
|
|
-
|
|
|
- if (orderInfo.getStatus() <= OrderStatusEnum.SCHEDULING.getKey()) {
|
|
|
- delete(id);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- // 获取订单商品主材和包材
|
|
|
- List<OrderSku> orderSkuList = orderSkuService.list(q -> q.eq(OrderSku::getOrderId, id));
|
|
|
- List<OrderSkuBom> orderSkuBomList = orderSkuBomService.list(q -> q.eq(OrderSkuBom::getOrderId, id));
|
|
|
-
|
|
|
- Map<Long, OrderSku> orderSkuMap = orderSkuList.stream().collect(Collectors.toMap(BaseIdPo::getId, Function.identity()));
|
|
|
-
|
|
|
- // 合并主材和包材
|
|
|
- List<InOutStorageBom> inOutStorageBomList = orderSkuList.stream().map(item -> {
|
|
|
- InOutStorageBom inOutStorageBom = new InOutStorageBom();
|
|
|
- inOutStorageBom.setBomSpecId(item.getBomSpecId());
|
|
|
- inOutStorageBom.setQuantity(item.getQuantity());
|
|
|
- return inOutStorageBom;
|
|
|
- }).collect(Collectors.toList());
|
|
|
-
|
|
|
- for (OrderSkuBom orderSkuBom : orderSkuBomList) {
|
|
|
- OrderSku orderSku = orderSkuMap.get(orderSkuBom.getOrderSkuId());
|
|
|
- InOutStorageBom inOutStorageBom = new InOutStorageBom();
|
|
|
- inOutStorageBom.setBomSpecId(orderSkuBom.getBomSpecId());
|
|
|
- inOutStorageBom.setQuantity(orderSkuBom.getQuantity().multiply(orderSku.getQuantity()));
|
|
|
- inOutStorageBomList.add(inOutStorageBom);
|
|
|
- }
|
|
|
-
|
|
|
- // 合并数量
|
|
|
- Map<Long, InOutStorageBom> map = inOutStorageBomList.stream().collect(Collectors.toMap(
|
|
|
- InOutStorageBom::getBomSpecId,
|
|
|
- Function.identity(),
|
|
|
- (v1, v2) -> {
|
|
|
- v1.setQuantity(v1.getQuantity().add(v2.getQuantity()));
|
|
|
- return v1;
|
|
|
- }
|
|
|
- ));
|
|
|
- inOutStorageBomList = new ArrayList<>(map.values());
|
|
|
-
|
|
|
- // 区分半成品仓和包材仓库
|
|
|
- Map<Long, BomSpecBo> bomSpecBoMap = bomSpecService.getBomSpecBo(map.keySet());
|
|
|
-
|
|
|
- // 主材从半成品仓入库
|
|
|
- semiFinishedProductOutStorage(inOutStorageBomList, bomSpecBoMap, orderInfo);
|
|
|
-
|
|
|
- // 包材从包材仓出库
|
|
|
- packagingMaterialOutStorage(inOutStorageBomList, bomSpecBoMap, orderInfo);
|
|
|
-
|
|
|
- // 删除订单回滚成品仓库存
|
|
|
- inventoryFinishedService.removeOrder(id);
|
|
|
-
|
|
|
- delete(id);
|
|
|
- }
|
|
|
-
|
|
|
- @DSTransactional
|
|
|
- @Override
|
|
|
- public void deleteValidated(Long id) {
|
|
|
OrderInfo orderInfo = getById(id);
|
|
|
|
|
|
if (orderInfo == null) {
|
|
@@ -590,14 +503,15 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|
|
|
|
|
if (Objects.equals(orderInfo.getDelFlag(), StatusConstant.NOT_DELETED)
|
|
|
&& orderInfo.getStatus() > OrderStatusEnum.SCHEDULING.getKey()) {
|
|
|
- throw new ServiceException("订单正在生产中,无法直接删除,需要走审批流程");
|
|
|
+ throw new ServiceException("订单已生产,无法删除");
|
|
|
}
|
|
|
|
|
|
- // 删除订单回滚成品仓库存
|
|
|
- inventoryFinishedService.removeOrder(id);
|
|
|
-
|
|
|
- // 删除订单以及订单关联数据
|
|
|
- delete(id);
|
|
|
+ removeById(id);
|
|
|
+ orderSkuService.remove(q -> q.eq(OrderSku::getOrderId, id));
|
|
|
+ orderSkuBomService.remove(q -> q.eq(OrderSkuBom::getOrderId, id));
|
|
|
+ orderPackageBomService.remove(q -> q.eq(OrderPackageBom::getOrderId, id));
|
|
|
+ orderSkuProductionCostService.remove(q -> q.eq(OrderSkuProductionCost::getOrderId, id));
|
|
|
+ ObsFileUtil.removeFile(id);
|
|
|
}
|
|
|
|
|
|
@DSTransactional
|
|
@@ -610,11 +524,6 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|
|
throw new ServiceException("订单不在草稿或待确认状态");
|
|
|
}
|
|
|
|
|
|
- // 自主订单需要锁定库存
|
|
|
- List<OrderSkuDto> orderSkuList = dto.getOrderSkuList();
|
|
|
-
|
|
|
- // 更新订单
|
|
|
- dto.setStatus(OrderStatusEnum.SCHEDULING.getKey());
|
|
|
// 订单为委外订单时,订单分类为委外订单,订单费用修改
|
|
|
if (Objects.equals(dto.getType(), 2)) {
|
|
|
dto.setClassify(OrderClassifyEnum.OUTSOURCE_ORDER.getKey());
|
|
@@ -642,12 +551,15 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|
|
dto.setClassify(OrderClassifyEnum.PURCHASE_ORDER.getKey());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 更新订单
|
|
|
+ dto.setStatus(OrderStatusEnum.SCHEDULING.getKey());
|
|
|
updateById(dto);
|
|
|
|
|
|
// 更新订单产品
|
|
|
- List<OrderSku> tempOrderSkuList = orderSkuList.stream()
|
|
|
- .peek(item -> item.setOrderId(dto.getId()))
|
|
|
+ List<OrderSku> tempOrderSkuList = dto.getOrderSkuList().stream()
|
|
|
.peek(item -> {
|
|
|
+ item.setOrderId(dto.getId());
|
|
|
// 委外订单修改金额
|
|
|
if (ObjectUtil.equals(dto.getType(), 2)) {
|
|
|
item.setUnitPrice(BigDecimal.ZERO);
|
|
@@ -662,7 +574,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|
|
orderSkuService.editLinked(tempOrderSkuList, OrderSku::getOrderId, dto.getId());
|
|
|
|
|
|
// 更新包材
|
|
|
- List<OrderSkuBom> orderSkuBomList = orderSkuList.stream()
|
|
|
+ List<OrderSkuBom> orderSkuBomList = dto.getOrderSkuList().stream()
|
|
|
.flatMap(orderSku -> orderSku.getOrderSkuBomList().stream()
|
|
|
.peek(orderSkuBom -> orderSkuBom.setOrderId(dto.getId()))
|
|
|
.peek(orderSkuBom -> orderSkuBom.setOrderSkuId(orderSku.getId())))
|
|
@@ -699,13 +611,11 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|
|
}).collect(Collectors.toList());
|
|
|
orderSkuProductionCostService.editLinked(orderSkuProductionCostList, OrderSkuProductionCost::getOrderId, dto.getId());
|
|
|
|
|
|
- // 是委外订单并且没有包材时,修改订单状态为生产中,并生成生产任务和工单
|
|
|
+ // 是委外订单并且没有包材时,修改订单状态为生产中
|
|
|
if (ObjectUtil.equals(dto.getStatus(), OrderStatusEnum.SCHEDULING.getKey())
|
|
|
&& ObjectUtil.equals(dto.getType(), 2)
|
|
|
&& ObjectUtil.isEmpty(orderSkuBomList)) {
|
|
|
dto.setStatus(OrderStatusEnum.IN_PRODUCTION.getKey());
|
|
|
- // 生成工单
|
|
|
- productionWorkOrderService.addByOrderId(dto.getId());
|
|
|
update(q -> q.set(OrderInfo::getStatus, OrderStatusEnum.IN_PRODUCTION.getKey()).eq(BaseIdPo::getId, dto.getId()));
|
|
|
}
|
|
|
|
|
@@ -721,7 +631,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|
|
orderPackageBomService.editLinked(orderPackageBomList, OrderPackageBom::getOrderId, dto.getId());
|
|
|
|
|
|
// 更新产品不干胶图稿
|
|
|
- for (OrderSkuDto item : orderSkuList) {
|
|
|
+ for (OrderSkuDto item : dto.getOrderSkuList()) {
|
|
|
ObsFileUtil.editFile(item.getSelfAdhesiveStickerFile(), item.getId());
|
|
|
}
|
|
|
|
|
@@ -887,76 +797,6 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<OutBomVo> returnBomList(Long id) {
|
|
|
- OrderInfo orderInfo = getById(id);
|
|
|
- Assert.notNull(orderInfo, "未找到订单");
|
|
|
-
|
|
|
- List<OrderSku> orderSkuList = orderSkuService.list(q -> q.eq(OrderSku::getOrderId, id));
|
|
|
- List<OrderSkuBom> orderSkuBomList = orderSkuBomService.list(q -> q.eq(OrderSkuBom::getOrderId, id));
|
|
|
- Map<Long, OrderSku> orderSkuMap = orderSkuList.stream().collect(Collectors.toMap(BaseIdPo::getId, Function.identity()));
|
|
|
- if (Objects.equals(orderInfo.getClassify(), OrderClassifyEnum.OUTSOURCE_ORDER.getKey())) {
|
|
|
- orderSkuList = Collections.emptyList();
|
|
|
- }
|
|
|
-
|
|
|
- Map<Long, OutBomVo> map = Stream.concat(
|
|
|
- // 主材
|
|
|
- orderSkuList.stream().map(item -> {
|
|
|
- OutBomVo outBomVo = new OutBomVo();
|
|
|
- outBomVo.setBomSpecId(item.getBomSpecId());
|
|
|
- outBomVo.setOutQuantity(item.getQuantity());
|
|
|
- return outBomVo;
|
|
|
- }),
|
|
|
-
|
|
|
- // 包材
|
|
|
- orderSkuBomList.stream().map(item -> {
|
|
|
- OrderSku orderSku = orderSkuMap.get(item.getOrderSkuId());
|
|
|
- OutBomVo outBomVo = new OutBomVo();
|
|
|
- outBomVo.setBomSpecId(item.getBomSpecId());
|
|
|
- outBomVo.setOutQuantity(item.getQuantity().multiply(orderSku.getQuantity()));
|
|
|
- return outBomVo;
|
|
|
- })
|
|
|
- )
|
|
|
- .collect(Collectors.toMap(
|
|
|
- OutBomVo::getBomSpecId,
|
|
|
- Function.identity(),
|
|
|
- (v1, v2) -> {
|
|
|
- v1.setOutQuantity(v1.getOutQuantity().add(v2.getOutQuantity()));
|
|
|
- return v1;
|
|
|
- })
|
|
|
- );
|
|
|
-
|
|
|
- // 合并sku主材和包材
|
|
|
- List<OutBomVo> outBomVoList = new ArrayList<>(map.values());
|
|
|
-
|
|
|
- // 区分半成品仓和包材仓库
|
|
|
- Map<Long, BomSpecBo> bomSpecBoMap = bomSpecService.getBomSpecBo(map.keySet());
|
|
|
-
|
|
|
- for (OutBomVo outBomVo : outBomVoList) {
|
|
|
- Long bomSpecId = outBomVo.getBomSpecId();
|
|
|
- BomSpecBo bomSpecBo = bomSpecBoMap.get(bomSpecId);
|
|
|
- outBomVo.setBomSpecCode(bomSpecBo.getBomSpecCode());
|
|
|
- outBomVo.setBomSpecName(bomSpecBo.getBomSpecName());
|
|
|
- outBomVo.setClassifyId(bomSpecBo.getClassifyId());
|
|
|
- outBomVo.setClassifyName(bomSpecBo.getClassifyName());
|
|
|
- outBomVo.setClassifyParentId(bomSpecBo.getClassifyParentId());
|
|
|
-
|
|
|
- // 主材
|
|
|
- if (Objects.equals(bomSpecBo.getClassifyParentId(), 1L)) {
|
|
|
- outBomVo.setWarehouseId(WarehouseConstant.SEMI_FINISHED_PRODUCT);
|
|
|
- outBomVo.setWarehouseName("半成品仓");
|
|
|
- }
|
|
|
- // 包材
|
|
|
- else {
|
|
|
- outBomVo.setWarehouseId(WarehouseConstant.PACKAGING_MATERIAL);
|
|
|
- outBomVo.setWarehouseName("包材仓");
|
|
|
- }
|
|
|
- }
|
|
|
- return outBomVoList.stream()
|
|
|
- .sorted(Comparator.comparing(OutBomVo::getWarehouseId, Comparator.reverseOrder()).thenComparing(OutBomVo::getBomSpecCode))
|
|
|
- .collect(Collectors.toList());
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
public void editOrderPackageBom(OrderInfoDto dto) {
|
|
|
OrderInfo orderInfo = getById(dto.getId());
|
|
|
Assert.notNull(orderInfo, "未找到订单");
|