|
|
|
@ -1,6 +1,7 @@ |
|
|
|
package org.springblade.desk.order.service.impl; |
|
|
|
package org.springblade.desk.order.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
|
|
|
import com.alibaba.nacos.common.utils.CollectionUtils; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
@ -218,68 +219,60 @@ public class YieldOrderCraftServiceImpl extends BaseServiceImpl<YieldOrderCraftM |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//如果匹配到了作业单位,则直接停止
|
|
|
|
//如果匹配到了作业单位,则直接停止
|
|
|
|
if (dispatchCraftList != null && dispatchCraftList.size() > 0) { |
|
|
|
if (CollectionUtils.isEmpty(dispatchCraftList)) { |
|
|
|
return; |
|
|
|
// 厂内优先
|
|
|
|
} |
|
|
|
if (workCenter.getLimitType().equals(WorkCenter.LIMIT_TYPE_PRIOR)) { |
|
|
|
|
|
|
|
log.info("自动分派,流程卡号:{},优先厂内", yieldOrder.getCardNo()); |
|
|
|
// 厂内优先
|
|
|
|
dispatchCraftList = this.bindWorkCenter(workCenter.getId(), workCenterMap, hostAbilityId, craftAbilityMap, craftKeys, yieldOrder, null); |
|
|
|
if (workCenter.getLimitType().equals(WorkCenter.LIMIT_TYPE_PRIOR)) { |
|
|
|
} |
|
|
|
log.info("自动分派,流程卡号:{},优先厂内", yieldOrder.getCardNo()); |
|
|
|
|
|
|
|
dispatchCraftList = this.bindWorkCenter(workCenter.getId(), workCenterMap, hostAbilityId, craftAbilityMap, craftKeys, yieldOrder, null); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//如果匹配到了作业单位,则直接停止
|
|
|
|
|
|
|
|
if (dispatchCraftList != null && dispatchCraftList.size() > 0) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//外协优先
|
|
|
|
|
|
|
|
if (oemCustomer.getLimitType().equals(WorkCenter.LIMIT_TYPE_PRIOR)) { |
|
|
|
|
|
|
|
log.info("自动分派,流程卡号:{},优先外协", yieldOrder.getCardNo()); |
|
|
|
|
|
|
|
dispatchCraftList = this.bindOem(oemCustomer, hostAbilityId, craftAbilityMap, craftKeys, yieldOrder, null); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//如果匹配到了作业单位,则直接停止
|
|
|
|
//如果匹配到了作业单位,则直接停止
|
|
|
|
if (dispatchCraftList != null && dispatchCraftList.size() > 0) { |
|
|
|
if (CollectionUtils.isEmpty(dispatchCraftList)) { |
|
|
|
return; |
|
|
|
//外协优先
|
|
|
|
} |
|
|
|
if (oemCustomer.getLimitType().equals(WorkCenter.LIMIT_TYPE_PRIOR)) { |
|
|
|
|
|
|
|
log.info("自动分派,流程卡号:{},优先外协", yieldOrder.getCardNo()); |
|
|
|
|
|
|
|
dispatchCraftList = this.bindOem(oemCustomer, hostAbilityId, craftAbilityMap, craftKeys, yieldOrder, null); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 开始根据分派比例分派
|
|
|
|
//如果匹配到了作业单位,则直接停止
|
|
|
|
Long facTotalNum = 0L; |
|
|
|
if (CollectionUtils.isEmpty(dispatchCraftList)) { |
|
|
|
YieldOrderAssignCount facCapacity = dailyAssignService.queryCount(hostAbilityId, BsAssignEntity.IN_FACTORY); |
|
|
|
// 开始根据分派比例分派
|
|
|
|
if (facCapacity != null) { |
|
|
|
Long facTotalNum = 0L; |
|
|
|
facTotalNum = facCapacity.getTotalNum(); |
|
|
|
YieldOrderAssignCount facCapacity = dailyAssignService.queryCount(hostAbilityId, BsAssignEntity.IN_FACTORY); |
|
|
|
} |
|
|
|
if (facCapacity != null) { |
|
|
|
// 获取厂外已经分派的总量
|
|
|
|
facTotalNum = facCapacity.getTotalNum(); |
|
|
|
Long oemTotalNum = 0L; |
|
|
|
} |
|
|
|
YieldOrderAssignCount oemCapacity = dailyAssignService.queryCount(hostAbilityId, BsAssignEntity.OUTSOURCE); |
|
|
|
// 获取厂外已经分派的总量
|
|
|
|
if (oemCapacity != null) { |
|
|
|
Long oemTotalNum = 0L; |
|
|
|
oemTotalNum = oemCapacity.getTotalNum(); |
|
|
|
YieldOrderAssignCount oemCapacity = dailyAssignService.queryCount(hostAbilityId, BsAssignEntity.OUTSOURCE); |
|
|
|
} |
|
|
|
if (oemCapacity != null) { |
|
|
|
|
|
|
|
oemTotalNum = oemCapacity.getTotalNum(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//日分派总量
|
|
|
|
//日分派总量
|
|
|
|
Long totalNum = facTotalNum + oemTotalNum; |
|
|
|
Long totalNum = facTotalNum + oemTotalNum; |
|
|
|
// 厂内分派比列
|
|
|
|
// 厂内分派比列
|
|
|
|
Double rate = 0D; |
|
|
|
Double rate = 0D; |
|
|
|
if (totalNum > 0) { |
|
|
|
if (totalNum > 0) { |
|
|
|
rate = Double.valueOf(facTotalNum) / Double.valueOf(totalNum) * 100; |
|
|
|
rate = Double.valueOf(facTotalNum) / Double.valueOf(totalNum) * 100; |
|
|
|
} |
|
|
|
} |
|
|
|
log.info("自动分派,流程卡号:{},分派总量:{},厂内分派比列:{}", yieldOrder.getCardNo(), totalNum, rate); |
|
|
|
log.info("自动分派,流程卡号:{},分派总量:{},厂内分派比列:{}", yieldOrder.getCardNo(), totalNum, rate); |
|
|
|
|
|
|
|
|
|
|
|
// 如果厂内占比大于已经设置的比列,则直接分派外协
|
|
|
|
// 如果厂内占比大于已经设置的比列,则直接分派外协
|
|
|
|
if (rate <= Double.parseDouble(craftAbility.getInRate())) { |
|
|
|
if (rate <= Double.parseDouble(craftAbility.getInRate())) { |
|
|
|
log.info("{}自动分派按照比例分派给厂内:{},分派比例:{} 应分比例:{}", yieldOrder.getCardNo(), workCenter.getWcName(), rate, craftAbility.getInRate()); |
|
|
|
log.info("{}自动分派按照比例分派给厂内:{},分派比例:{} 应分比例:{}", yieldOrder.getCardNo(), workCenter.getWcName(), rate, craftAbility.getInRate()); |
|
|
|
dispatchCraftList = this.bindWorkCenter(workCenter.getId(), workCenterMap, hostAbilityId, craftAbilityMap, craftKeys, yieldOrder, null); |
|
|
|
dispatchCraftList = this.bindWorkCenter(workCenter.getId(), workCenterMap, hostAbilityId, craftAbilityMap, craftKeys, yieldOrder, null); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//如果匹配到了作业单位,则直接停止
|
|
|
|
//如果匹配到了作业单位,则直接停止
|
|
|
|
if (dispatchCraftList != null && !dispatchCraftList.isEmpty()) { |
|
|
|
if (CollectionUtils.isEmpty(dispatchCraftList)) { |
|
|
|
return; |
|
|
|
// 外协
|
|
|
|
|
|
|
|
log.info("{}自动分派按照比例分派给外协:{},分派比例:{} 应分比例:{}", yieldOrder.getCardNo(), oemCustomer.getOcName(), rate, craftAbility.getInRate()); |
|
|
|
|
|
|
|
dispatchCraftList = this.bindOem(oemCustomer, hostAbilityId, craftAbilityMap, craftKeys, yieldOrder, null); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 外协
|
|
|
|
|
|
|
|
log.info("{}自动分派按照比例分派给外协:{},分派比例:{} 应分比例:{}", yieldOrder.getCardNo(), oemCustomer.getOcName(), rate, craftAbility.getInRate()); |
|
|
|
|
|
|
|
dispatchCraftList = this.bindOem(oemCustomer, hostAbilityId, craftAbilityMap, craftKeys, yieldOrder, null); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (Boolean.TRUE.equals(factor)) { |
|
|
|
if (Boolean.TRUE.equals(factor)) { |
|
|
|
@ -295,7 +288,7 @@ public class YieldOrderCraftServiceImpl extends BaseServiceImpl<YieldOrderCraftM |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (dispatchCraftList == null || dispatchCraftList.size() == 0) { |
|
|
|
if (dispatchCraftList == null || dispatchCraftList.isEmpty()) { |
|
|
|
throw new ServiceException("自动分派失败,未找到合适的班组或者供应商!"); |
|
|
|
throw new ServiceException("自动分派失败,未找到合适的班组或者供应商!"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|