|
|
|
@ -113,7 +113,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void scheduling() { |
|
|
|
public void scheduling() { |
|
|
|
//查询待排产订单,状态是3
|
|
|
|
//查询待排产订单,状态是3
|
|
|
|
List<YieldOrderEntity> list = yieldOrderService.list(Wrappers.<YieldOrderEntity>lambdaQuery().eq(BaseEntity::getStatus, YieldOrderConst.STATUS_APS).isNotNull(YieldOrderEntity::getWorkCenterId)); |
|
|
|
List<YieldOrderEntity> list = yieldOrderService.list(Wrappers.<YieldOrderEntity>lambdaQuery().eq(BaseEntity::getStatus, YieldOrderConst.STATUS_APS).isNotNull(YieldOrderEntity::getWorkCenterId).isNotNull(YieldOrderEntity::getReleaseDate)); |
|
|
|
log.info("待排产订单数量为:" + list.size()); |
|
|
|
log.info("待排产订单数量为:" + list.size()); |
|
|
|
if (CollectionUtils.isNotEmpty(list)) { |
|
|
|
if (CollectionUtils.isNotEmpty(list)) { |
|
|
|
//校验已排产订单
|
|
|
|
//校验已排产订单
|
|
|
|
@ -144,7 +144,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
list1 -> { |
|
|
|
list1 -> { |
|
|
|
// 排序逻辑:优先级升序 → CR值降序 → 数量降序 → 时间升序
|
|
|
|
// 排序逻辑:优先级升序 → CR值降序 → 数量降序 → 时间升序
|
|
|
|
list1.sort(Comparator.comparingInt(YieldOrderEntity::getPriorityAps).reversed() |
|
|
|
list1.sort(Comparator.comparingInt(YieldOrderEntity::getPriorityAps).reversed() |
|
|
|
//.thenComparing((e1, e2) -> e2.getCrValue().compareTo(e1.getCrValue()))
|
|
|
|
.thenComparing((e1, e2) -> e2.getCrValue().compareTo(e1.getCrValue())) |
|
|
|
.thenComparingInt(YieldOrderEntity::getYpQty).reversed() |
|
|
|
.thenComparingInt(YieldOrderEntity::getYpQty).reversed() |
|
|
|
.thenComparing(YieldOrderEntity::getReleaseDate)); |
|
|
|
.thenComparing(YieldOrderEntity::getReleaseDate)); |
|
|
|
return list1; |
|
|
|
return list1; |
|
|
|
@ -468,6 +468,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
public void allocateResources(List<YieldOrderEntity> list,Map<String, PersonAbilityEntity> personAbilityMap,Map<Long, String> mainProducerMap,Map<String,List<WorkPlanEntity>> planMap) { |
|
|
|
public void allocateResources(List<YieldOrderEntity> list,Map<String, PersonAbilityEntity> personAbilityMap,Map<Long, String> mainProducerMap,Map<String,List<WorkPlanEntity>> planMap) { |
|
|
|
List<WorkOrderEntity> workOrderList = new ArrayList<>(); |
|
|
|
List<WorkOrderEntity> workOrderList = new ArrayList<>(); |
|
|
|
for (YieldOrderEntity order : list) { |
|
|
|
for (YieldOrderEntity order : list) { |
|
|
|
|
|
|
|
try { |
|
|
|
//是否可以排产
|
|
|
|
//是否可以排产
|
|
|
|
Boolean isSchecuding = true; |
|
|
|
Boolean isSchecuding = true; |
|
|
|
List<WorkPlanEntity> workPlanList = new ArrayList<>(); |
|
|
|
List<WorkPlanEntity> workPlanList = new ArrayList<>(); |
|
|
|
@ -575,9 +576,9 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
equipResource.setRestCapacity(equipResource.getRestCapacity().subtract(capacity)); |
|
|
|
equipResource.setRestCapacity(equipResource.getRestCapacity().subtract(capacity)); |
|
|
|
equipResource.setIsUsed("1"); |
|
|
|
equipResource.setIsUsed("1"); |
|
|
|
//如果剩余产能占总产能不足20%,则修改为已占用
|
|
|
|
//如果剩余产能占总产能不足20%,则修改为已占用
|
|
|
|
// if(equipResource.getRestCapacity().divide(equipResource.getTotalCapacity(),2,RoundingMode.HALF_UP).compareTo(BigDecimal.valueOf(0.2)) < 0){
|
|
|
|
// if(equipResource.getRestCapacity().divide(equipResource.getTotalCapacity(),2,RoundingMode.HALF_UP).compareTo(BigDecimal.valueOf(0.2)) < 0){
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//同一个设备可能有多个工艺能力,同一时间只能做一个工艺能力的零件,所以需要把当前设备所有工艺能力的剩余产能都更新调
|
|
|
|
//同一个设备可能有多个工艺能力,同一时间只能做一个工艺能力的零件,所以需要把当前设备所有工艺能力的剩余产能都更新调
|
|
|
|
LambdaUpdateWrapper<EquipResourceEntity> equipWrapper = new LambdaUpdateWrapper<>(); |
|
|
|
LambdaUpdateWrapper<EquipResourceEntity> equipWrapper = new LambdaUpdateWrapper<>(); |
|
|
|
equipWrapper.eq(EquipResourceEntity::getEquipCode,equipResource.getEquipCode()); |
|
|
|
equipWrapper.eq(EquipResourceEntity::getEquipCode,equipResource.getEquipCode()); |
|
|
|
@ -625,13 +626,26 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
BigDecimal totalTime = new BigDecimal(0); |
|
|
|
BigDecimal totalTime = new BigDecimal(0); |
|
|
|
PersonAbilityEntity ability = personAbilityMap.get(craft.getWorkCenterId() + "-" + craft.getPpsId() + "-" + craft.getCaId()); |
|
|
|
PersonAbilityEntity ability = personAbilityMap.get(craft.getWorkCenterId() + "-" + craft.getPpsId() + "-" + craft.getCaId()); |
|
|
|
//由于客户提供的数据不全,先判断有没有对应的能力,如果没有先不计算时间
|
|
|
|
//由于客户提供的数据不全,先判断有没有对应的能力,如果没有先不计算时间
|
|
|
|
/* if(ability != null){ |
|
|
|
List<Integer> caIds = Arrays.asList(10,21); |
|
|
|
totalTime = totalTime.add(BigDecimal.valueOf(order.getYpQty()).multiply(personAbilityMap.get(craft.getWorkCenterId() + "-" + craft.getPpsId() + "-" + craft.getCaId()).getStandardTime()).add(personAbilityMap.get(craft.getWorkCenterId() + "-" + craft.getPpsId() + "-" + craft.getCaId()).getPrepareTime())); |
|
|
|
|
|
|
|
}*/ |
|
|
|
|
|
|
|
//镀后检验和镀后接收先按半小时计算
|
|
|
|
//镀后检验和镀后接收先按半小时计算
|
|
|
|
if(ability != null){ |
|
|
|
if(ability != null){ |
|
|
|
|
|
|
|
if(caIds.contains(craft.getCaId())){ |
|
|
|
|
|
|
|
totalTime = BigDecimal.valueOf(30); |
|
|
|
|
|
|
|
workPlan.setStartTime(prevProcessEnd); |
|
|
|
|
|
|
|
workPlan.setEndTime(prevProcessEnd.plusMinutes(30)); |
|
|
|
|
|
|
|
if(craft.getCaId() == 10){ |
|
|
|
|
|
|
|
workPlan.setMakeTeam(Long.valueOf(64)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(craft.getCaId() == 21){ |
|
|
|
|
|
|
|
workPlan.setMakeTeam(Long.valueOf(65)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
totalTime = totalTime.add(BigDecimal.valueOf(order.getYpQty()).multiply(personAbilityMap.get(craft.getWorkCenterId() + "-" + craft.getPpsId() + "-" + craft.getCaId()).getStandardTime()).add(personAbilityMap.get(craft.getWorkCenterId() + "-" + craft.getPpsId() + "-" + craft.getCaId()).getPrepareTime())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//通过加锁的方式保证每次查询到的人力资源都是最新的
|
|
|
|
//通过加锁的方式保证每次查询到的人力资源都是最新的
|
|
|
|
Long craftId = craft.getCaId(); |
|
|
|
/*Long craftId = craft.getCaId(); |
|
|
|
Lock craftLock = getCraftLock(craftId); |
|
|
|
Lock craftLock = getCraftLock(craftId); |
|
|
|
craftLock.lock(); // 加本地锁,同一工艺ID串行执行
|
|
|
|
craftLock.lock(); // 加本地锁,同一工艺ID串行执行
|
|
|
|
try{ |
|
|
|
try{ |
|
|
|
@ -640,7 +654,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
//如果personResourceList不为空,说明是镀后检验或者镀后验收这类跨作业中心的工艺
|
|
|
|
//如果personResourceList不为空,说明是镀后检验或者镀后验收这类跨作业中心的工艺
|
|
|
|
if(CollectionUtils.isNotEmpty(personResourceList)){ |
|
|
|
if(CollectionUtils.isNotEmpty(personResourceList)){ |
|
|
|
//剔除掉personResourceList中isUsed=1之前的数据,isUsed=1说明这些时间被占用了
|
|
|
|
//剔除掉personResourceList中isUsed=1之前的数据,isUsed=1说明这些时间被占用了
|
|
|
|
/* int isUsedIndex = -1; |
|
|
|
*//* int isUsedIndex = -1;
|
|
|
|
for(int m=0;m<personResourceList.size();m++){ |
|
|
|
for(int m=0;m<personResourceList.size();m++){ |
|
|
|
if("1".equals(personResourceList.get(m).getIsUsed())){ |
|
|
|
if("1".equals(personResourceList.get(m).getIsUsed())){ |
|
|
|
isUsedIndex = m; |
|
|
|
isUsedIndex = m; |
|
|
|
@ -648,7 +662,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
} |
|
|
|
} |
|
|
|
if(isUsedIndex != -1){ |
|
|
|
if(isUsedIndex != -1){ |
|
|
|
personResourceList = personResourceList.subList(isUsedIndex + 1, personResourceList.size()); |
|
|
|
personResourceList = personResourceList.subList(isUsedIndex + 1, personResourceList.size()); |
|
|
|
}*/ |
|
|
|
}*//*
|
|
|
|
|
|
|
|
|
|
|
|
//计算加工时间占几个人力片段
|
|
|
|
//计算加工时间占几个人力片段
|
|
|
|
//int period = totalTime.divide(BigDecimal.valueOf(30),0, RoundingMode.CEILING).intValue();
|
|
|
|
//int period = totalTime.divide(BigDecimal.valueOf(30),0, RoundingMode.CEILING).intValue();
|
|
|
|
@ -662,7 +676,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
//占用时间段
|
|
|
|
//占用时间段
|
|
|
|
/*LocalDateTime startTime = LocalDateTime.now(); |
|
|
|
*//*LocalDateTime startTime = LocalDateTime.now();
|
|
|
|
LocalDateTime endTime = LocalDateTime.now(); |
|
|
|
LocalDateTime endTime = LocalDateTime.now(); |
|
|
|
StringBuilder personResourceIds = new StringBuilder(); |
|
|
|
StringBuilder personResourceIds = new StringBuilder(); |
|
|
|
for(int j=0;j<period;j++){ |
|
|
|
for(int j=0;j<period;j++){ |
|
|
|
@ -682,7 +696,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
personResourceIds.append(personResource.getId()); |
|
|
|
personResourceIds.append(personResource.getId()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}*/ |
|
|
|
}*//*
|
|
|
|
PersonResourceEntity personResource = personResourceList.get(0); |
|
|
|
PersonResourceEntity personResource = personResourceList.get(0); |
|
|
|
personResource.setIsUsed("1"); |
|
|
|
personResource.setIsUsed("1"); |
|
|
|
personResourceService.updateById(personResource); |
|
|
|
personResourceService.updateById(personResource); |
|
|
|
@ -695,7 +709,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
} |
|
|
|
} |
|
|
|
}finally { |
|
|
|
}finally { |
|
|
|
craftLock.unlock(); // 释放本地锁
|
|
|
|
craftLock.unlock(); // 释放本地锁
|
|
|
|
} |
|
|
|
}*/ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
workPlan.setWoId(order.getId()); |
|
|
|
workPlan.setWoId(order.getId()); |
|
|
|
@ -765,6 +779,10 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
yieldOrderService.updateById(order); |
|
|
|
yieldOrderService.updateById(order); |
|
|
|
workOrderList.add(workOrder); |
|
|
|
workOrderList.add(workOrder); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
log.error("报错订单是:"+order.getId()+",报错信息是:"+e.getMessage()); |
|
|
|
|
|
|
|
throw new RuntimeException(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if(CollectionUtils.isNotEmpty(workOrderList)){ |
|
|
|
if(CollectionUtils.isNotEmpty(workOrderList)){ |
|
|
|
@ -976,7 +994,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
//还原人力资源
|
|
|
|
//还原人力资源
|
|
|
|
if(workPlan.getPersonResourceIds() != null){ |
|
|
|
/*if(workPlan.getPersonResourceIds() != null){ |
|
|
|
List<PersonResourceEntity> personResourceList = personResourceService.list(Wrappers.<PersonResourceEntity>lambdaQuery().in(BaseEntity::getId,workPlan.getPersonResourceIds().split(","))); |
|
|
|
List<PersonResourceEntity> personResourceList = personResourceService.list(Wrappers.<PersonResourceEntity>lambdaQuery().in(BaseEntity::getId,workPlan.getPersonResourceIds().split(","))); |
|
|
|
if(CollectionUtils.isNotEmpty(personResourceList)){ |
|
|
|
if(CollectionUtils.isNotEmpty(personResourceList)){ |
|
|
|
personResourceList.forEach(item ->{ |
|
|
|
personResourceList.forEach(item ->{ |
|
|
|
@ -984,7 +1002,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
personResourceService.updateById(item); |
|
|
|
personResourceService.updateById(item); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
|
|
workPlanService.deleteLogic(Arrays.asList(workPlan.getId())); |
|
|
|
workPlanService.deleteLogic(Arrays.asList(workPlan.getId())); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -1074,6 +1092,9 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
List<WorkPlanEntity> workPlanList = new ArrayList<>(); |
|
|
|
List<WorkPlanEntity> workPlanList = new ArrayList<>(); |
|
|
|
//获取相关工序
|
|
|
|
//获取相关工序
|
|
|
|
YieldOrderCraftEntity craft = yieldOrderCraftService.getOne(Wrappers.<YieldOrderCraftEntity>lambdaQuery().eq(YieldOrderCraftEntity::getYoId,order.getId()).eq(YieldOrderCraftEntity::getCaId,equipAbility.getCraftId())); |
|
|
|
YieldOrderCraftEntity craft = yieldOrderCraftService.getOne(Wrappers.<YieldOrderCraftEntity>lambdaQuery().eq(YieldOrderCraftEntity::getYoId,order.getId()).eq(YieldOrderCraftEntity::getCaId,equipAbility.getCraftId())); |
|
|
|
|
|
|
|
if(craft == null){ |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
//计算订单总产能
|
|
|
|
//计算订单总产能
|
|
|
|
BigDecimal sumCapacity = order.getYpArea().multiply(BigDecimal.valueOf(100)).multiply(BigDecimal.valueOf(order.getYpQty())); |
|
|
|
BigDecimal sumCapacity = order.getYpArea().multiply(BigDecimal.valueOf(100)).multiply(BigDecimal.valueOf(order.getYpQty())); |
|
|
|
//计算需要占用几个时间段
|
|
|
|
//计算需要占用几个时间段
|
|
|
|
|