|
|
|
|
@ -625,10 +625,11 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
BigDecimal totalTime = new BigDecimal(0); |
|
|
|
|
PersonAbilityEntity ability = personAbilityMap.get(craft.getWorkCenterId() + "-" + craft.getPpsId() + "-" + craft.getCaId()); |
|
|
|
|
//由于客户提供的数据不全,先判断有没有对应的能力,如果没有先不计算时间
|
|
|
|
|
if(ability != null){ |
|
|
|
|
/* if(ability != null){ |
|
|
|
|
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(totalTime.compareTo(new BigDecimal(0)) > 0){ |
|
|
|
|
}*/ |
|
|
|
|
//镀后检验和镀后接收先按半小时计算
|
|
|
|
|
if(ability != null){ |
|
|
|
|
//通过加锁的方式保证每次查询到的人力资源都是最新的
|
|
|
|
|
Long craftId = craft.getCaId(); |
|
|
|
|
Lock craftLock = getCraftLock(craftId); |
|
|
|
|
@ -648,15 +649,20 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
if(isUsedIndex != -1){ |
|
|
|
|
personResourceList = personResourceList.subList(isUsedIndex + 1, personResourceList.size()); |
|
|
|
|
} |
|
|
|
|
//如果size=0,说明最近3天的资源都排满了,就不需要排了
|
|
|
|
|
if(personResourceList.size() == 0){ |
|
|
|
|
|
|
|
|
|
//计算加工时间占几个人力片段
|
|
|
|
|
//int period = totalTime.divide(BigDecimal.valueOf(30),0, RoundingMode.CEILING).intValue();
|
|
|
|
|
//1.如果size=0,说明最近3天的资源都排满了,就不需要排了
|
|
|
|
|
if(personResourceList.size() == 0){ |
|
|
|
|
//还原已占用资源
|
|
|
|
|
restoreResource(workPlanList); |
|
|
|
|
order.setErrorInfo("最近3天人力资源已占满,需下次排产"); |
|
|
|
|
yieldOrderService.updateById(order); |
|
|
|
|
isSchecuding = false; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
//计算加工时间占几个人力片段
|
|
|
|
|
int period = totalTime.divide(BigDecimal.valueOf(30),0, RoundingMode.CEILING).intValue(); |
|
|
|
|
//占用时间段
|
|
|
|
|
LocalDateTime startTime = LocalDateTime.now(); |
|
|
|
|
/*LocalDateTime startTime = LocalDateTime.now(); |
|
|
|
|
LocalDateTime endTime = LocalDateTime.now(); |
|
|
|
|
StringBuilder personResourceIds = new StringBuilder(); |
|
|
|
|
for(int j=0;j<period;j++){ |
|
|
|
|
@ -676,13 +682,16 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
personResourceIds.append(personResource.getId()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
workPlan.setPersonResourceIds(personResourceIds.toString()); |
|
|
|
|
workPlan.setStartTime(startTime); |
|
|
|
|
workPlan.setEndTime(endTime); |
|
|
|
|
}*/ |
|
|
|
|
PersonResourceEntity personResource = personResourceList.get(0); |
|
|
|
|
personResource.setIsUsed("1"); |
|
|
|
|
personResourceService.updateById(personResource); |
|
|
|
|
workPlan.setPersonResourceIds(personResource.getId().toString()); |
|
|
|
|
workPlan.setStartTime(personResource.getStartTime()); |
|
|
|
|
workPlan.setEndTime(personResource.getEndTime()); |
|
|
|
|
workPlan.setMakeTeam(personResourceList.get(0).getTeamId()); |
|
|
|
|
|
|
|
|
|
prevProcessEnd = endTime; |
|
|
|
|
prevProcessEnd = personResource.getEndTime(); |
|
|
|
|
} |
|
|
|
|
}finally { |
|
|
|
|
craftLock.unlock(); // 释放本地锁
|
|
|
|
|
@ -726,8 +735,8 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
workOrder.setBatchNo(order.getBatchNo()); |
|
|
|
|
workOrder.setYoId(order.getId()); |
|
|
|
|
workOrder.setMakeQty(order.getYpQty()); |
|
|
|
|
workOrder.setPlanStartDate(workPlanList.get(0).getStartTime().truncatedTo(ChronoUnit.DAYS).toString().substring(0,10)); |
|
|
|
|
workOrder.setPlanEndDate(workPlanList.get(workPlanList.size()-1).getEndTime().truncatedTo(ChronoUnit.DAYS).toString().substring(0,10)); |
|
|
|
|
workOrder.setPlanStartDate(workPlanList.get(0).getStartTime() == null ? null :workPlanList.get(0).getStartTime().truncatedTo(ChronoUnit.DAYS).toString().substring(0,10)); |
|
|
|
|
workOrder.setPlanEndDate(workPlanList.get(workPlanList.size()-1).getEndTime() == null ? null : workPlanList.get(workPlanList.size()-1).getEndTime().truncatedTo(ChronoUnit.DAYS).toString().substring(0,10)); |
|
|
|
|
workOrder.setInventoryQty(0); |
|
|
|
|
workOrder.setRunStatus(2); |
|
|
|
|
workOrder.setPickingStatus(0); |
|
|
|
|
@ -752,6 +761,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
this.updateById(workOrder); |
|
|
|
|
//更新订单状态为已排产
|
|
|
|
|
order.setStatus(4); |
|
|
|
|
order.setErrorInfo(null); |
|
|
|
|
yieldOrderService.updateById(order); |
|
|
|
|
workOrderList.add(workOrder); |
|
|
|
|
} |
|
|
|
|
@ -958,7 +968,11 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
EquipResourceEntity equipResource = equipResourceService.getById(workPlan.getEquipResourceId()); |
|
|
|
|
equipResource.setIsUsed("0"); |
|
|
|
|
equipResource.setRestCapacity(equipResource.getRestCapacity().add(workPlan.getHourQuota())); |
|
|
|
|
equipResourceService.updateById(equipResource); |
|
|
|
|
LambdaUpdateWrapper<EquipResourceEntity> updateWrapper = new LambdaUpdateWrapper<>(); |
|
|
|
|
updateWrapper.eq(EquipResourceEntity::getEquipCode,equipResource.getEquipCode()); |
|
|
|
|
updateWrapper.eq(EquipResourceEntity::getDateTime,equipResource.getDateTime()); |
|
|
|
|
updateWrapper.eq(EquipResourceEntity::getPeriod,equipResource.getPeriod()); |
|
|
|
|
equipResourceService.update(equipResource,updateWrapper); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
//还原人力资源
|
|
|
|
|
@ -1132,4 +1146,34 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void restoreResource(List<WorkPlanEntity> list){ |
|
|
|
|
for(WorkPlanEntity workPlan : list){ |
|
|
|
|
//还原设备资源
|
|
|
|
|
if(workPlan.getEquipResourceId() != null){ |
|
|
|
|
EquipResourceEntity equipResource = equipResourceService.getById(workPlan.getEquipResourceId()); |
|
|
|
|
equipResource.setIsUsed("0"); |
|
|
|
|
equipResource.setRestCapacity(equipResource.getRestCapacity().add(workPlan.getHourQuota())); |
|
|
|
|
LambdaUpdateWrapper<EquipResourceEntity> updateWrapper = new LambdaUpdateWrapper<>(); |
|
|
|
|
updateWrapper.eq(EquipResourceEntity::getEquipCode,equipResource.getEquipCode()); |
|
|
|
|
updateWrapper.eq(EquipResourceEntity::getDateTime,equipResource.getDateTime()); |
|
|
|
|
updateWrapper.eq(EquipResourceEntity::getPeriod,equipResource.getPeriod()); |
|
|
|
|
equipResourceService.update(equipResource,updateWrapper); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
//还原人力资源
|
|
|
|
|
if(workPlan.getPersonResourceIds() != null){ |
|
|
|
|
List<PersonResourceEntity> personResourceList = personResourceService.list(Wrappers.<PersonResourceEntity>lambdaQuery().in(BaseEntity::getId,workPlan.getPersonResourceIds().split(","))); |
|
|
|
|
if(CollectionUtils.isNotEmpty(personResourceList)){ |
|
|
|
|
personResourceList.forEach(item ->{ |
|
|
|
|
item.setIsUsed("0"); |
|
|
|
|
personResourceService.updateById(item); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(workPlan.getId() != null){ |
|
|
|
|
workPlanService.deleteLogic(Arrays.asList(workPlan.getId())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|