|
|
|
|
@ -8,11 +8,13 @@ import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
import org.springblade.common.constant.CommonConstant; |
|
|
|
|
import org.springblade.common.exception.BusinessException; |
|
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
|
import org.springblade.desk.basic.pojo.entity.BsAssignEntity; |
|
|
|
|
import org.springblade.desk.basic.pojo.entity.Oem; |
|
|
|
|
import org.springblade.desk.basic.pojo.entity.OemCraftAbilityEntity; |
|
|
|
|
import org.springblade.desk.basic.pojo.entity.WorkCenter; |
|
|
|
|
import org.springblade.desk.basic.service.IBsAssignService; |
|
|
|
|
import org.springblade.desk.basic.service.IOemCraftAbilityService; |
|
|
|
|
import org.springblade.desk.basic.service.IOemService; |
|
|
|
|
@ -98,7 +100,7 @@ public class YieldOrderCraftServiceImpl extends BaseServiceImpl<YieldOrderCraftM |
|
|
|
|
Long hostAbilityId = craftKeys.iterator().next(); |
|
|
|
|
BsCraftAbilityEntity craftAbility = craftAbilityService.getById(hostAbilityId); |
|
|
|
|
//获取可以做此主工艺能力的作业中心集合
|
|
|
|
|
Map<Long, BsWorkCenterEntity> workCenterMap = workCenterService.selectByAbility(hostAbilityId, yieldOrder.getYpQty(), yieldOrder.getYpArea(), yieldOrder.getPartCode(), yieldOrder.getPrimaryCraft(), yieldOrder.getYieldType(), rxlSpace); |
|
|
|
|
Map<Long, WorkCenter> workCenterMap = workCenterService.selectByAbility(hostAbilityId, yieldOrder.getYpQty(), yieldOrder.getYpArea(), yieldOrder.getPartCode(), yieldOrder.getPrimaryCraft(), yieldOrder.getYieldType(), rxlSpace); |
|
|
|
|
//获取可以做此主工艺能力的外协商集合
|
|
|
|
|
List<Long> oemList = oemService.selectByAbility(hostAbilityId, yieldOrder.getYpQty(), yieldOrder.getYpArea(), yieldOrder.getPartCode(), yieldOrder.getPrimaryCraft(), yieldOrder.getYieldType(), yieldOrder.getPlate(), rxlSpace); |
|
|
|
|
|
|
|
|
|
@ -123,7 +125,7 @@ public class YieldOrderCraftServiceImpl extends BaseServiceImpl<YieldOrderCraftM |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//获取到可以做主工艺能力的最合适的作业中心,并且标记必须、优先、正常
|
|
|
|
|
BsWorkCenterEntity workCenter = null; |
|
|
|
|
WorkCenter workCenter = null; |
|
|
|
|
//获取到可以做主工艺能力的最合适的外协商,并且标记必须、优先、正常
|
|
|
|
|
Oem oemCustomer = null; |
|
|
|
|
//自动分派后的结果集
|
|
|
|
|
@ -180,9 +182,9 @@ public class YieldOrderCraftServiceImpl extends BaseServiceImpl<YieldOrderCraftM |
|
|
|
|
dispatchCraftList = this.bindOem(oemCustomer, hostAbilityId, craftAbilityMap, craftKeys, yieldOrder, null); |
|
|
|
|
} else if (workCenter != null && oemCustomer != null) { |
|
|
|
|
//场内外共有工艺能力
|
|
|
|
|
if (workCenter.getLimitType().equals(BsWorkCenterEntity.LIMIT_TYPE_MUST)) { |
|
|
|
|
if (workCenter.getLimitType().equals(WorkCenter.LIMIT_TYPE_MUST)) { |
|
|
|
|
dispatchCraftList = this.bindWorkCenter(workCenter.getId(), workCenterMap, hostAbilityId, craftAbilityMap, craftKeys, yieldOrder, null); |
|
|
|
|
} else if (oemCustomer.getLimitType().equals(BsWorkCenterEntity.LIMIT_TYPE_MUST)) { |
|
|
|
|
} else if (oemCustomer.getLimitType().equals(WorkCenter.LIMIT_TYPE_MUST)) { |
|
|
|
|
dispatchCraftList = this.bindOem(oemCustomer, hostAbilityId, craftAbilityMap, craftKeys, yieldOrder, null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -192,7 +194,7 @@ public class YieldOrderCraftServiceImpl extends BaseServiceImpl<YieldOrderCraftM |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 厂内优先
|
|
|
|
|
if (workCenter.getLimitType().equals(BsWorkCenterEntity.LIMIT_TYPE_PRIOR)) { |
|
|
|
|
if (workCenter.getLimitType().equals(WorkCenter.LIMIT_TYPE_PRIOR)) { |
|
|
|
|
dispatchCraftList = this.bindWorkCenter(workCenter.getId(), workCenterMap, hostAbilityId, craftAbilityMap, craftKeys, yieldOrder, null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -202,7 +204,7 @@ public class YieldOrderCraftServiceImpl extends BaseServiceImpl<YieldOrderCraftM |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//外协优先
|
|
|
|
|
if (oemCustomer.getLimitType().equals(BsWorkCenterEntity.LIMIT_TYPE_PRIOR)) { |
|
|
|
|
if (oemCustomer.getLimitType().equals(WorkCenter.LIMIT_TYPE_PRIOR)) { |
|
|
|
|
dispatchCraftList = this.bindOem(oemCustomer, hostAbilityId, craftAbilityMap, craftKeys, yieldOrder, null); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -262,11 +264,11 @@ public class YieldOrderCraftServiceImpl extends BaseServiceImpl<YieldOrderCraftM |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (dispatchCraftList == null || dispatchCraftList.size() == 0) { |
|
|
|
|
throw new BusinessException("自动分派失败,未找到合适的班组或者供应商!"); |
|
|
|
|
throw new ServiceException("自动分派失败,未找到合适的班组或者供应商!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 分派成功,保存分派结果
|
|
|
|
|
this.saveBatch(dispatchCraftList); |
|
|
|
|
this.saveOrUpdateBatch(dispatchCraftList); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -279,7 +281,7 @@ public class YieldOrderCraftServiceImpl extends BaseServiceImpl<YieldOrderCraftM |
|
|
|
|
* @Author dxl |
|
|
|
|
* @CreateTime 2023/3/7 18:30 |
|
|
|
|
*/ |
|
|
|
|
private BsWorkCenterEntity inPlantDistribution(Long hostCaId, Map<Long, BsWorkCenterEntity> wcMap, YieldOrder yieldOrder, Integer limitType) { |
|
|
|
|
private WorkCenter inPlantDistribution(Long hostCaId, Map<Long, WorkCenter> wcMap, YieldOrder yieldOrder, Integer limitType) { |
|
|
|
|
//没有工艺能力的对应作业中心,直接分派厂外
|
|
|
|
|
if (wcMap == null || wcMap.size() == 0) { |
|
|
|
|
return null; |
|
|
|
|
@ -290,7 +292,7 @@ public class YieldOrderCraftServiceImpl extends BaseServiceImpl<YieldOrderCraftM |
|
|
|
|
wcList.addAll(wcMap.keySet()); |
|
|
|
|
|
|
|
|
|
//作业中心
|
|
|
|
|
BsWorkCenterEntity workCenter = null; |
|
|
|
|
WorkCenter workCenter = null; |
|
|
|
|
//在规则表中匹配是否存在匹配的条件(查厂内)
|
|
|
|
|
BsAssignEntity assign = this.getRules(yieldOrder, hostCaId, BsAssignEntity.IN_FACTORY); |
|
|
|
|
if (assign != null) { |
|
|
|
|
@ -341,14 +343,14 @@ public class YieldOrderCraftServiceImpl extends BaseServiceImpl<YieldOrderCraftM |
|
|
|
|
* @Author dxl |
|
|
|
|
* @CreateTime 2023/3/7 18:31 |
|
|
|
|
*/ |
|
|
|
|
private BsWorkCenterEntity priorityInPlantDistribution(Long hostCaId, List<Long> wcList, YieldOrder yieldOrder, Integer limitType) { |
|
|
|
|
private WorkCenter priorityInPlantDistribution(Long hostCaId, List<Long> wcList, YieldOrder yieldOrder, Integer limitType) { |
|
|
|
|
//没有工艺能力的对应作业中心,直接分派厂外
|
|
|
|
|
if (wcList == null || wcList.size() == 0) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//作业中心
|
|
|
|
|
BsWorkCenterEntity workCenter = null; |
|
|
|
|
WorkCenter workCenter = null; |
|
|
|
|
//如果找到合适的作业中心直接分派,反之如果未找到合适的作业中心(bool 是true的情况下强制厂内,bool是false是优先厂内,不满足的情况下直接返回空)
|
|
|
|
|
YieldOrderAssignDaily dayAbilityAssignment = dailyAssignService.findMinNum(hostCaId, wcList); |
|
|
|
|
if (Func.isEmpty(dayAbilityAssignment)) { |
|
|
|
|
@ -372,17 +374,17 @@ public class YieldOrderCraftServiceImpl extends BaseServiceImpl<YieldOrderCraftM |
|
|
|
|
* @Author dxl |
|
|
|
|
* @CreateTime 2023/3/8 15:30 |
|
|
|
|
*/ |
|
|
|
|
private List<YieldOrderCraft> bindWorkCenter(Long workCenterId, Map<Long, BsWorkCenterEntity> workCenterMap, Long craftAbilityId, |
|
|
|
|
private List<YieldOrderCraft> bindWorkCenter(Long workCenterId, Map<Long, WorkCenter> workCenterMap, Long craftAbilityId, |
|
|
|
|
Map<Long, List<YieldOrderCraft>> craftAbilityMap, Set<Long> craftKeys, |
|
|
|
|
YieldOrder yieldOrder, Boolean factor) { |
|
|
|
|
YieldOrder yieldOrder, Boolean factor) throws BusinessException { |
|
|
|
|
List<YieldOrderCraft> orderCrafts = new ArrayList<>(); |
|
|
|
|
// 开始循环生产订单中组合的工艺能力key集合, 主工艺能力之前的全部分配到此作业中心
|
|
|
|
|
for (Long craftId : craftKeys) { |
|
|
|
|
//验证工艺能力
|
|
|
|
|
BsWorkCenterEntity workCenter = workCenterMap.get(craftId); |
|
|
|
|
/*WorkCenter workCenter = workCenterService.getOne(Wrappers.<WorkCenter>lambdaQuery().eq(BaseEntity::getId,workCenterId).like(WorkCenter::getCraftAbilityId,craftId)); |
|
|
|
|
if (workCenter == null) { |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
}*/ |
|
|
|
|
orderCrafts.addAll(craftAbilityMap.get(craftId)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -398,8 +400,21 @@ public class YieldOrderCraftServiceImpl extends BaseServiceImpl<YieldOrderCraftM |
|
|
|
|
centerId = teamSetEntity.getWcId(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
BsWorkCenterEntity workCenter = workCenterMap.get(centerId); |
|
|
|
|
WorkCenter workCenter = null; |
|
|
|
|
if(orderCraft.getCaId().equals(craftAbilityId)){ |
|
|
|
|
workCenter = workCenterMap.get(workCenterId); |
|
|
|
|
}else{ |
|
|
|
|
workCenter = workCenterService.getOne(Wrappers.<WorkCenter>lambdaQuery().like(WorkCenter::getCraftAbilityId,orderCraft.getCaId())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(centerId != null){ |
|
|
|
|
orderCraft.setWorkCenterId(centerId); |
|
|
|
|
}else{ |
|
|
|
|
if(workCenter == null){ |
|
|
|
|
throw new BusinessException("工艺" + orderCraft.getCaId() + "未查询到对应作业中心"); |
|
|
|
|
} |
|
|
|
|
orderCraft.setWorkCenterId(workCenter.getId()); |
|
|
|
|
} |
|
|
|
|
orderCraft.setIsOutsource(Boolean.FALSE); |
|
|
|
|
} |
|
|
|
|
//factor等于null代表是整体,有值时代表是单工序
|
|
|
|
|
|