|
|
|
|
@ -1,5 +1,6 @@ |
|
|
|
|
package org.springblade.desk.order.service.impl; |
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
@ -150,6 +151,7 @@ public class YieldOrderCraftServiceImpl extends BaseServiceImpl<YieldOrderCraftM |
|
|
|
|
|
|
|
|
|
// 根据车间订单是否厂内标识判定是否强制厂内(单工序时不进行标识验证)
|
|
|
|
|
if (yieldOrder.getSiteWork() && factor == null) { |
|
|
|
|
log.info("自动分派,流程卡号:{},标注厂内生产", yieldOrder.getCardNo()); |
|
|
|
|
//订单强制分派厂内,若未找到工艺能力对应的作业中心,则提示异常
|
|
|
|
|
if (workCenterMap == null || workCenterMap.isEmpty()) { |
|
|
|
|
throw new BusinessException("此订单需强制分派厂内,未找到满足条件得作业中心,自动分派失败!1"); |
|
|
|
|
@ -169,39 +171,49 @@ public class YieldOrderCraftServiceImpl extends BaseServiceImpl<YieldOrderCraftM |
|
|
|
|
// 先判定规则是否存在零件级强制匹配
|
|
|
|
|
BsAssignEntity partAssign = assignService.getByPartCode(hostAbilityId, yieldOrder.getPartCode()); |
|
|
|
|
if (partAssign != null && partAssign.getCenterId() != null) { |
|
|
|
|
log.info("自动分派,流程卡号:{},指定厂内作业中心生产", yieldOrder.getCardNo()); |
|
|
|
|
// 指定厂内作业中心生产
|
|
|
|
|
workCenter = workCenterService.getWorkCenter(partAssign.getCenterId()); |
|
|
|
|
} else if (partAssign != null && partAssign.getOemId() != null) { |
|
|
|
|
// 指定外协商生产
|
|
|
|
|
log.info("自动分派,流程卡号:{},指定外协商生产", yieldOrder.getCardNo()); |
|
|
|
|
oemCustomer = oemService.getById(partAssign.getOemId()); |
|
|
|
|
} else if (partAssign != null && partAssign.getLimitType().equals(BsAssignEntity.MUST.toString())) { |
|
|
|
|
if (partAssign.getPointType().equals(BsAssignEntity.IN_FACTORY.toString())) { |
|
|
|
|
// 必须厂内生产
|
|
|
|
|
log.info("自动分派,流程卡号:{},必须厂内生产", yieldOrder.getCardNo()); |
|
|
|
|
workCenter = this.inPlantDistribution(hostAbilityId, workCenterMap, yieldOrder, BsWorkCenterEntity.LIMIT_TYPE_MUST); |
|
|
|
|
} else { |
|
|
|
|
//必须外协生产
|
|
|
|
|
log.info("自动分派,流程卡号:{},必须外协生产", yieldOrder.getCardNo()); |
|
|
|
|
oemCustomer = this.offsiteDistribution(hostAbilityId, oemList, yieldOrder, BsWorkCenterEntity.LIMIT_TYPE_MUST); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
// 寻找最合适的作业中心
|
|
|
|
|
log.info("自动分派,流程卡号:{},寻找最合适的作业中心或班组", yieldOrder.getCardNo()); |
|
|
|
|
workCenter = this.inPlantDistribution(hostAbilityId, workCenterMap, yieldOrder, BsWorkCenterEntity.LIMIT_TYPE_NORMAL); |
|
|
|
|
oemCustomer = this.offsiteDistribution(hostAbilityId, oemList, yieldOrder, BsWorkCenterEntity.LIMIT_TYPE_NORMAL); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
log.info("自动分派,流程卡号:{},作业中心:{},外协商:{}", yieldOrder.getCardNo(), workCenter, oemCustomer); |
|
|
|
|
// factor等于null代表是整体,有值时代表是单工序,true转厂内,false转厂外
|
|
|
|
|
if (factor == null) { |
|
|
|
|
if (workCenter != null && oemCustomer == null) { |
|
|
|
|
log.info("自动分派,流程卡号:{},分派到厂内", yieldOrder.getCardNo()); |
|
|
|
|
//只有厂内有工艺能力
|
|
|
|
|
dispatchCraftList = this.bindWorkCenter(workCenter.getId(), workCenterMap, hostAbilityId, craftAbilityMap, craftKeys, yieldOrder, null); |
|
|
|
|
} else if (oemCustomer != null && workCenter == null) { |
|
|
|
|
log.info("自动分派,流程卡号:{},分派到外协", yieldOrder.getCardNo()); |
|
|
|
|
//只有厂外有工艺能力
|
|
|
|
|
dispatchCraftList = this.bindOem(oemCustomer, hostAbilityId, craftAbilityMap, craftKeys, yieldOrder, null); |
|
|
|
|
} else if (workCenter != null && oemCustomer != null) { |
|
|
|
|
log.info("自动分派,流程卡号:{},分派到厂内或外协", yieldOrder.getCardNo()); |
|
|
|
|
//场内外共有工艺能力
|
|
|
|
|
if (workCenter.getLimitType().equals(WorkCenter.LIMIT_TYPE_MUST)) { |
|
|
|
|
log.info("自动分派,流程卡号:{},必须厂内2", yieldOrder.getCardNo()); |
|
|
|
|
dispatchCraftList = this.bindWorkCenter(workCenter.getId(), workCenterMap, hostAbilityId, craftAbilityMap, craftKeys, yieldOrder, null); |
|
|
|
|
} else if (oemCustomer.getLimitType().equals(WorkCenter.LIMIT_TYPE_MUST)) { |
|
|
|
|
log.info("自动分派,流程卡号:{},必须外协2", yieldOrder.getCardNo()); |
|
|
|
|
dispatchCraftList = this.bindOem(oemCustomer, hostAbilityId, craftAbilityMap, craftKeys, yieldOrder, null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -212,6 +224,7 @@ public class YieldOrderCraftServiceImpl extends BaseServiceImpl<YieldOrderCraftM |
|
|
|
|
|
|
|
|
|
// 厂内优先
|
|
|
|
|
if (workCenter.getLimitType().equals(WorkCenter.LIMIT_TYPE_PRIOR)) { |
|
|
|
|
log.info("自动分派,流程卡号:{},优先厂内", yieldOrder.getCardNo()); |
|
|
|
|
dispatchCraftList = this.bindWorkCenter(workCenter.getId(), workCenterMap, hostAbilityId, craftAbilityMap, craftKeys, yieldOrder, null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -222,6 +235,7 @@ public class YieldOrderCraftServiceImpl extends BaseServiceImpl<YieldOrderCraftM |
|
|
|
|
|
|
|
|
|
//外协优先
|
|
|
|
|
if (oemCustomer.getLimitType().equals(WorkCenter.LIMIT_TYPE_PRIOR)) { |
|
|
|
|
log.info("自动分派,流程卡号:{},优先外协", yieldOrder.getCardNo()); |
|
|
|
|
dispatchCraftList = this.bindOem(oemCustomer, hostAbilityId, craftAbilityMap, craftKeys, yieldOrder, null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -250,6 +264,7 @@ public class YieldOrderCraftServiceImpl extends BaseServiceImpl<YieldOrderCraftM |
|
|
|
|
if (totalNum > 0) { |
|
|
|
|
rate = Double.valueOf(facTotalNum) / Double.valueOf(totalNum) * 100; |
|
|
|
|
} |
|
|
|
|
log.info("自动分派,流程卡号:{},分派总量:{},厂内分派比列:{}", yieldOrder.getCardNo(), totalNum, rate); |
|
|
|
|
|
|
|
|
|
// 如果厂内占比大于已经设置的比列,则直接分派外协
|
|
|
|
|
if (rate <= Double.parseDouble(craftAbility.getInRate())) { |
|
|
|
|
@ -399,6 +414,7 @@ public class YieldOrderCraftServiceImpl extends BaseServiceImpl<YieldOrderCraftM |
|
|
|
|
private List<YieldOrderCraft> bindWorkCenter(Long workCenterId, Map<Long, WorkCenter> workCenterMap, Long craftAbilityId, |
|
|
|
|
Map<Long, List<YieldOrderCraft>> craftAbilityMap, Set<Long> craftKeys, |
|
|
|
|
YieldOrder yieldOrder, Boolean factor) throws Exception { |
|
|
|
|
log.info("自动分派,流程卡号:{},分给厂内,作业中心为:{}", yieldOrder.getCardNo(), workCenterId); |
|
|
|
|
List<YieldOrderCraft> orderCrafts = new ArrayList<>(); |
|
|
|
|
// 开始循环生产订单中组合的工艺能力key集合, 主工艺能力之前的全部分配到此作业中心
|
|
|
|
|
for (Long craftId : craftKeys) { |
|
|
|
|
@ -590,7 +606,7 @@ public class YieldOrderCraftServiceImpl extends BaseServiceImpl<YieldOrderCraftM |
|
|
|
|
*/ |
|
|
|
|
private List<YieldOrderCraft> bindOem(Oem oemCustomer, Long craftAbilityId, Map<Long, |
|
|
|
|
List<YieldOrderCraft>> craftAbilityMap, Set<Long> keys, YieldOrder yieldOrder, Boolean factor) throws Exception { |
|
|
|
|
|
|
|
|
|
log.info("自动分派,流程卡号:{},分给外协,外协商为:{}", yieldOrder.getCardNo(), JSONObject.toJSONString(oemCustomer)); |
|
|
|
|
List<YieldOrderCraft> rtnList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
OemCraftAbilityEntity oemAbility = null; |
|
|
|
|
|