|
|
|
|
@ -61,6 +61,7 @@ import org.springblade.scheduling.scheduling.vo.SameTroughVO; |
|
|
|
|
import org.springblade.scheduling.scheduling.vo.WorkPlanVO; |
|
|
|
|
import org.springblade.wms.feign.StGlassCakeOutClient; |
|
|
|
|
import org.springblade.wms.pojo.dto.StGlassCakeOutDTO; |
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
@ -582,6 +583,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
//匹配设备资源
|
|
|
|
|
//获取下一个整数点
|
|
|
|
|
LocalDateTime dateTime = getNextIntegerTime(prevProcessEnd); |
|
|
|
|
List<WorkPlanEntity> processPlanList = new ArrayList<>(); |
|
|
|
|
for (Map.Entry<Integer, List<EquipAbilityEntity>> entry : equipAbilityMap.entrySet()) { |
|
|
|
|
int partType = entry.getValue().get(0).getPartType(); |
|
|
|
|
//根据时间点获取所有设备资源
|
|
|
|
|
@ -701,8 +703,8 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
workPlan.setHourQuota((double)ChronoUnit.MINUTES.between(workPlan.getPlanStartTime(), workPlan.getPlanEndTime())); |
|
|
|
|
workPlan.setEquipCode(equipResource.getEquipCode()); |
|
|
|
|
workPlan.setEquipName(equipResource.getEquipName()); |
|
|
|
|
workPlan.setEquipResourceId(equipResource.getId()); |
|
|
|
|
workPlanList.add(workPlan); |
|
|
|
|
workPlan.setEquipResourceId(equipResource.getId().toString()); |
|
|
|
|
processPlanList.add(workPlan); |
|
|
|
|
//更新剩余产能
|
|
|
|
|
equipResource.setRestCapacity(equipResource.getRestCapacity().subtract(capacity)); |
|
|
|
|
equipResource.setIsUsed("1"); |
|
|
|
|
@ -749,6 +751,21 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
if(CollectionUtils.isNotEmpty(processPlanList)){ |
|
|
|
|
WorkPlanEntity workPlan = new WorkPlanEntity(); |
|
|
|
|
BeanUtils.copyProperties(processPlanList.get(0),workPlan); |
|
|
|
|
workPlan.setPlanStartTime(processPlanList.get(0).getPlanStartTime()); |
|
|
|
|
workPlan.setPlanEndTime(processPlanList.get(processPlanList.size()-1).getPlanEndTime()); |
|
|
|
|
String equipCode = processPlanList.stream().map(WorkPlanEntity::getEquipCode).collect(Collectors.joining(",")); |
|
|
|
|
String equipName = processPlanList.stream().map(WorkPlanEntity::getEquipName).collect(Collectors.joining(",")); |
|
|
|
|
String equipResourceId = processPlanList.stream().map(WorkPlanEntity::getEquipResourceId).map(String::valueOf).collect(Collectors.joining(",")); |
|
|
|
|
Double hourQuota = processPlanList.stream().mapToDouble(WorkPlanEntity::getHourQuota).sum(); |
|
|
|
|
workPlan.setEquipCode(equipCode); |
|
|
|
|
workPlan.setEquipName(equipName); |
|
|
|
|
workPlan.setEquipResourceId(equipResourceId); |
|
|
|
|
workPlan.setHourQuota(hourQuota); |
|
|
|
|
workPlanList.add(workPlan); |
|
|
|
|
} |
|
|
|
|
if (!isSchecuding) { |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
@ -807,7 +824,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
.eq(PersonResourceEntity::getProcessId, craft.getPpsId()) |
|
|
|
|
.eq(PersonResourceEntity::getCraftId, craft.getCaId()) |
|
|
|
|
.le(PersonResourceEntity::getStartTime, prevProcessEnd) |
|
|
|
|
.ge(PersonResourceEntity::getEndTime, prevProcessEnd)); |
|
|
|
|
.orderByAsc(PersonResourceEntity::getDateTime,PersonResourceEntity::getStartTime)); |
|
|
|
|
if (CollectionUtils.isNotEmpty(personResourceList)) { |
|
|
|
|
workPlan.setMakeTeam(personResourceList.get(0).getTeamId()); |
|
|
|
|
} |
|
|
|
|
@ -1334,7 +1351,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
workPlan.setHourQuota((double)ChronoUnit.MINUTES.between(workPlan.getPlanStartTime(), workPlan.getPlanEndTime())); |
|
|
|
|
workPlan.setEquipCode(equipResource.getEquipCode()); |
|
|
|
|
workPlan.setEquipName(equipResource.getEquipName()); |
|
|
|
|
workPlan.setEquipResourceId(equipResource.getId()); |
|
|
|
|
workPlan.setEquipResourceId(equipResource.getId().toString()); |
|
|
|
|
workPlanList.add(workPlan); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
@ -1425,16 +1442,17 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
if (CollectionUtils.isNotEmpty(workPlanOldList)) { |
|
|
|
|
//总生产量
|
|
|
|
|
BigDecimal sumCapacity = order.getYpArea().multiply(BigDecimal.valueOf(order.getYpQty())); |
|
|
|
|
//可能有多个订单符合要求,按照车间订单、时间分组排序
|
|
|
|
|
Map<Long, List<WorkPlanEntity>> workPlanMap = workPlanOldList.stream().collect(Collectors.groupingBy(WorkPlanEntity::getWoId)); |
|
|
|
|
for (Map.Entry<Long, List<WorkPlanEntity>> entry : workPlanMap.entrySet()) { |
|
|
|
|
Long woId = entry.getKey(); |
|
|
|
|
List<WorkPlanEntity> planList = entry.getValue(); |
|
|
|
|
for (WorkPlanEntity entry : workPlanOldList) { |
|
|
|
|
Long woId = entry.getWoId(); |
|
|
|
|
Boolean isEnough = true; |
|
|
|
|
List<Long> resourceList = new ArrayList<>(); |
|
|
|
|
for (WorkPlanEntity workPlan : planList) { |
|
|
|
|
if (workPlan.getEquipResourceId() != null) { |
|
|
|
|
EquipResourceEntity equipResource = equipResourceService.getById(workPlan.getEquipResourceId()); |
|
|
|
|
if (StringUtils.isNotEmpty(entry.getEquipResourceId())) { |
|
|
|
|
List<Long> resourceIdList = Arrays.stream(entry.getEquipResourceId().split(",")) |
|
|
|
|
.map(String::trim) |
|
|
|
|
.map(Long::valueOf) |
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
for(Long resourceId : resourceIdList){ |
|
|
|
|
EquipResourceEntity equipResource = equipResourceService.getById(resourceId); |
|
|
|
|
if(equipResource == null){ |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
@ -1444,9 +1462,10 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
resourceList.clear(); |
|
|
|
|
break; |
|
|
|
|
} else { |
|
|
|
|
resourceList.add(workPlan.getEquipResourceId()); |
|
|
|
|
resourceList.add(resourceId); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
//如果产能满足,再判断是否满足同槽条件
|
|
|
|
|
if (isEnough) { |
|
|
|
|
@ -1512,6 +1531,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
if (isSameTrough2) { |
|
|
|
|
List<WorkPlanEntity> processPlanList = new ArrayList<>(); |
|
|
|
|
for(Long resourceId : resourceList){ |
|
|
|
|
EquipResourceEntity equipResource = equipResourceService.getById(resourceId); |
|
|
|
|
//生成车间订单
|
|
|
|
|
@ -1537,13 +1557,28 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
workPlan.setHourQuota((double)ChronoUnit.MINUTES.between(workPlan.getPlanStartTime(), workPlan.getPlanEndTime())); |
|
|
|
|
workPlan.setEquipCode(equipResource.getEquipCode()); |
|
|
|
|
workPlan.setEquipName(equipResource.getEquipName()); |
|
|
|
|
workPlan.setEquipResourceId(equipResource.getId()); |
|
|
|
|
workPlanList.add(workPlan); |
|
|
|
|
workPlan.setEquipResourceId(equipResource.getId().toString()); |
|
|
|
|
processPlanList.add(workPlan); |
|
|
|
|
|
|
|
|
|
equipResource.setRestCapacity(equipResource.getRestCapacity().subtract(sumCapacity)); |
|
|
|
|
equipResourceService.updateById(equipResource); |
|
|
|
|
isSameTrough = true; |
|
|
|
|
} |
|
|
|
|
if(CollectionUtils.isNotEmpty(processPlanList)){ |
|
|
|
|
WorkPlanEntity workPlan = new WorkPlanEntity(); |
|
|
|
|
BeanUtils.copyProperties(processPlanList.get(0),workPlan); |
|
|
|
|
workPlan.setPlanStartTime(processPlanList.get(0).getPlanStartTime()); |
|
|
|
|
workPlan.setPlanEndTime(processPlanList.get(processPlanList.size()-1).getPlanEndTime()); |
|
|
|
|
String equipCode = processPlanList.stream().map(WorkPlanEntity::getEquipCode).collect(Collectors.joining(",")); |
|
|
|
|
String equipName = processPlanList.stream().map(WorkPlanEntity::getEquipName).collect(Collectors.joining(",")); |
|
|
|
|
String equipResourceId = processPlanList.stream().map(WorkPlanEntity::getEquipResourceId).map(String::valueOf).collect(Collectors.joining(",")); |
|
|
|
|
Double hourQuota = processPlanList.stream().mapToDouble(WorkPlanEntity::getHourQuota).sum(); |
|
|
|
|
workPlan.setEquipCode(equipCode); |
|
|
|
|
workPlan.setEquipName(equipName); |
|
|
|
|
workPlan.setEquipResourceId(equipResourceId); |
|
|
|
|
workPlan.setHourQuota(hourQuota); |
|
|
|
|
workPlanList.add(workPlan); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -1656,7 +1691,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
workPlan.setHourQuota((double)ChronoUnit.MINUTES.between(workPlan.getPlanStartTime(), workPlan.getPlanEndTime())); |
|
|
|
|
workPlan.setEquipCode(equipResource.getEquipCode()); |
|
|
|
|
workPlan.setEquipName(equipResource.getEquipName()); |
|
|
|
|
workPlan.setEquipResourceId(equipResource.getId()); |
|
|
|
|
workPlan.setEquipResourceId(equipResource.getId().toString()); |
|
|
|
|
workPlanList.add(workPlan); |
|
|
|
|
|
|
|
|
|
equipResource.setRestCapacity(equipResource.getRestCapacity().subtract(sumCapacity)); |
|
|
|
|
|