|
|
|
|
@ -528,23 +528,25 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
} else { |
|
|
|
|
if ("设备".equals(mainProducerMap.get(craft.getPpsId()))) { |
|
|
|
|
String glassCodeStr = null; |
|
|
|
|
Map<String, Object> sameFurnaceMap = new HashMap<>(); |
|
|
|
|
Map<String, Object> sameMap = new HashMap<>(); |
|
|
|
|
//同炉同槽
|
|
|
|
|
if(order.getYieldType() == YieldOrderEnum.YIELD_TYPE_1.getCode()){ |
|
|
|
|
//热表同槽
|
|
|
|
|
Boolean isSameTrough = sameTrough(order, craft, localDateTime, workPlanList); |
|
|
|
|
sameMap = sameTrough(order, craft, localDateTime, workPlanList, prevProcessEnd); |
|
|
|
|
//同槽就不需要继续匹配了
|
|
|
|
|
if (isSameTrough) { |
|
|
|
|
if (sameMap.get("isSameTrough").toString() == "true") { |
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm"); |
|
|
|
|
prevProcessEnd = LocalDateTime.parse(sameMap.get("prevProcessEnd").toString(), formatter); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
//烧结同炉
|
|
|
|
|
if (sintMap.containsKey(craft.getPpsId())) { |
|
|
|
|
sameFurnaceMap = sameFurnace(order, craft, workPlanList, localDateTime, glassCodeStr, sintMap, part, processMap, prevProcessEnd); |
|
|
|
|
sameMap = sameFurnace(order, craft, workPlanList, localDateTime, glassCodeStr, sintMap, part, processMap, prevProcessEnd); |
|
|
|
|
//同炉的话就不用走下面的匹配了,直接下一工序
|
|
|
|
|
if (sameFurnaceMap.get("isSameFurnace").toString() == "true") { |
|
|
|
|
if (sameMap.get("isSameFurnace").toString() == "true") { |
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm"); |
|
|
|
|
prevProcessEnd = LocalDateTime.parse(sameFurnaceMap.get("prevProcessEnd").toString(), formatter); |
|
|
|
|
prevProcessEnd = LocalDateTime.parse(sameMap.get("prevProcessEnd").toString(), formatter); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -688,8 +690,8 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
//更新剩余产能
|
|
|
|
|
equipResource.setRestCapacity(equipResource.getRestCapacity().subtract(capacity)); |
|
|
|
|
equipResource.setIsUsed("1"); |
|
|
|
|
if (order.getYieldType() != YieldOrderEnum.YIELD_TYPE_1.getCode() && sameFurnaceMap.get("glassCode") != null) { |
|
|
|
|
equipResource.setGlassCode(sameFurnaceMap.get("glassCode").toString()); |
|
|
|
|
if (order.getYieldType() != YieldOrderEnum.YIELD_TYPE_1.getCode() && sameMap.get("glassCode") != null) { |
|
|
|
|
equipResource.setGlassCode(sameMap.get("glassCode").toString()); |
|
|
|
|
} |
|
|
|
|
equipResourceService.updateById(equipResource); |
|
|
|
|
//同一个设备可能有多个工艺能力,同一时间只能做一个工艺能力的零件,所以需要把当前设备所有工艺能力的剩余产能都更新调
|
|
|
|
|
@ -703,8 +705,8 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
for(EquipResourceEntity otherResource : otherResourceList){ |
|
|
|
|
otherResource.setRestCapacity(otherResource.getTotalCapacity().multiply(rate).setScale(0, RoundingMode.FLOOR)); |
|
|
|
|
otherResource.setIsUsed("1"); |
|
|
|
|
if (order.getYieldType() != YieldOrderEnum.YIELD_TYPE_1.getCode() && sameFurnaceMap.get("glassCode") != null) { |
|
|
|
|
otherResource.setGlassCode(sameFurnaceMap.get("glassCode").toString()); |
|
|
|
|
if (order.getYieldType() != YieldOrderEnum.YIELD_TYPE_1.getCode() && sameMap.get("glassCode") != null) { |
|
|
|
|
otherResource.setGlassCode(sameMap.get("glassCode").toString()); |
|
|
|
|
} |
|
|
|
|
equipResourceService.updateById(otherResource); |
|
|
|
|
} |
|
|
|
|
@ -809,13 +811,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
wrapper.eq(PersonResourceEntity::getTeamId,craft.getMakeTeam()); |
|
|
|
|
} |
|
|
|
|
wrapper.orderByAsc(PersonResourceEntity::getDateTime,PersonResourceEntity::getStartTime); |
|
|
|
|
List<PersonResourceEntity> personResourceList = personResourceService.list(Wrappers.<PersonResourceEntity>lambdaQuery() |
|
|
|
|
.eq(PersonResourceEntity::getWorkCenterId, craft.getWorkCenterId()) |
|
|
|
|
.eq(PersonResourceEntity::getProcessId, craft.getPpsId()) |
|
|
|
|
.eq(PersonResourceEntity::getCraftId, craft.getCaId()) |
|
|
|
|
.le(PersonResourceEntity::getStartTime, prevProcessEnd) |
|
|
|
|
.orderByAsc(PersonResourceEntity::getDateTime,PersonResourceEntity::getStartTime) |
|
|
|
|
.eq(PersonResourceEntity::getTeamId,craft.getMakeTeam())); |
|
|
|
|
List<PersonResourceEntity> personResourceList = personResourceService.list(wrapper); |
|
|
|
|
if (CollectionUtils.isNotEmpty(personResourceList)) { |
|
|
|
|
workPlan.setMakeTeam(personResourceList.get(0).getTeamId()); |
|
|
|
|
} |
|
|
|
|
@ -1417,13 +1413,17 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Boolean sameTrough(YieldOrderEntity order, YieldOrderCraftEntity craft, LocalDateTime dateTime, List<WorkPlanEntity> workPlanList) { |
|
|
|
|
public Map<String, Object> sameTrough(YieldOrderEntity order, |
|
|
|
|
YieldOrderCraftEntity craft, |
|
|
|
|
LocalDateTime dateTime, |
|
|
|
|
List<WorkPlanEntity> workPlanList, |
|
|
|
|
LocalDateTime prevProcessEnd) { |
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
Boolean isSameTrough = false; |
|
|
|
|
SameTroughEntity sameTrough = sameTroughService.getOne(Wrappers.<SameTroughEntity>lambdaQuery() |
|
|
|
|
.eq(SameTroughEntity::getWorkCenterId, craft.getWorkCenterId()) |
|
|
|
|
.eq(SameTroughEntity::getCraftId, craft.getCaId()) |
|
|
|
|
.eq(SameTroughEntity::getProcessId, craft.getPpsId())); |
|
|
|
|
if (sameTrough != null) { |
|
|
|
|
LambdaQueryWrapper<WorkPlanEntity> wrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
wrapper.eq(WorkPlanEntity::getWorkCenterId, craft.getWorkCenterId()) |
|
|
|
|
.eq(WorkPlanEntity::getCaId, craft.getCaId()) |
|
|
|
|
@ -1435,11 +1435,88 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
} |
|
|
|
|
wrapper.orderByAsc(WorkPlanEntity::getPlanStartTime); |
|
|
|
|
//查询是否有已经排产的计划
|
|
|
|
|
List<WorkPlanEntity> workPlanOldList = workPlanService.list(Wrappers.<WorkPlanEntity>lambdaQuery() |
|
|
|
|
.eq(WorkPlanEntity::getWorkCenterId, craft.getWorkCenterId()) |
|
|
|
|
.eq(WorkPlanEntity::getCaId, craft.getCaId()) |
|
|
|
|
.eq(WorkPlanEntity::getPpsId, craft.getPpsId()) |
|
|
|
|
.ge(WorkPlanEntity::getPlanStartTime, dateTime).orderByAsc(WorkPlanEntity::getPlanStartTime)); |
|
|
|
|
List<WorkPlanEntity> workPlanOldList = workPlanService.list(wrapper); |
|
|
|
|
//如果没有查询到非同槽条件,默认同槽
|
|
|
|
|
if(sameTrough == null){ |
|
|
|
|
if (CollectionUtils.isNotEmpty(workPlanOldList)) { |
|
|
|
|
//总生产量
|
|
|
|
|
BigDecimal sumCapacity = order.getYpArea().multiply(BigDecimal.valueOf(order.getYpQty())); |
|
|
|
|
for (WorkPlanEntity entry : workPlanOldList) { |
|
|
|
|
List<Long> resourceList = new ArrayList<>(); |
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
|
//判断剩余产能是否满足总产能
|
|
|
|
|
if (sumCapacity.compareTo(equipResource.getRestCapacity()) > 0) { |
|
|
|
|
resourceList.clear(); |
|
|
|
|
break; |
|
|
|
|
} else { |
|
|
|
|
resourceList.add(resourceId); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
List<WorkPlanEntity> processPlanList = new ArrayList<>(); |
|
|
|
|
for(Long resourceId : resourceList){ |
|
|
|
|
EquipResourceEntity equipResource = equipResourceService.getById(resourceId); |
|
|
|
|
//生成车间订单
|
|
|
|
|
WorkPlanEntity workPlan = new WorkPlanEntity(); |
|
|
|
|
workPlan.setPlanStartTime(equipResource.getStartTime()); |
|
|
|
|
if ("0".equals(equipResource.getEquipType())) { |
|
|
|
|
workPlan.setPlanEndTime(equipResource.getStartTime().plusMinutes(equipResource.getStandardTime().setScale(0, RoundingMode.CEILING).longValue())); |
|
|
|
|
} else { |
|
|
|
|
workPlan.setPlanEndTime(equipResource.getEndTime()); |
|
|
|
|
} |
|
|
|
|
workPlan.setWorkQty(0); |
|
|
|
|
workPlan.setCaId(craft.getCaId()); |
|
|
|
|
workPlan.setPpsId(craft.getPpsId()); |
|
|
|
|
workPlan.setMakeTeam(equipResource.getTeamId()); |
|
|
|
|
workPlan.setWorkCenterId(craft.getWorkCenterId()); |
|
|
|
|
workPlan.setOrders(craft.getProcessNo()); |
|
|
|
|
workPlan.setWoId(order.getId()); |
|
|
|
|
workPlan.setOem("0"); |
|
|
|
|
workPlan.setTestQty(0); |
|
|
|
|
workPlan.setQualifiedQty(0); |
|
|
|
|
workPlan.setUnqualifiedQty(0); |
|
|
|
|
workPlan.setScrapQty(0); |
|
|
|
|
workPlan.setHourQuota((double)ChronoUnit.MINUTES.between(workPlan.getPlanStartTime(), workPlan.getPlanEndTime())); |
|
|
|
|
workPlan.setEquipCode(equipResource.getEquipCode()); |
|
|
|
|
workPlan.setEquipName(equipResource.getEquipName()); |
|
|
|
|
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); |
|
|
|
|
prevProcessEnd = workPlan.getPlanEndTime(); |
|
|
|
|
//排完了跳出循环
|
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}else if(sameTrough != null) { |
|
|
|
|
if (CollectionUtils.isNotEmpty(workPlanOldList)) { |
|
|
|
|
//总生产量
|
|
|
|
|
BigDecimal sumCapacity = order.getYpArea().multiply(BigDecimal.valueOf(order.getYpQty())); |
|
|
|
|
@ -1466,7 +1543,6 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
resourceList.add(resourceId); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
//如果产能满足,再判断是否满足同槽条件
|
|
|
|
|
if (isEnough) { |
|
|
|
|
@ -1579,6 +1655,9 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
workPlan.setEquipResourceId(equipResourceId); |
|
|
|
|
workPlan.setHourQuota(hourQuota); |
|
|
|
|
workPlanList.add(workPlan); |
|
|
|
|
prevProcessEnd = workPlan.getPlanEndTime(); |
|
|
|
|
//排完了跳出循环
|
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -1588,7 +1667,9 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return isSameTrough; |
|
|
|
|
map.put("isSameTrough", isSameTrough); |
|
|
|
|
map.put("prevProcessEnd" , prevProcessEnd); |
|
|
|
|
return map; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Map<String, Object> sameFurnace(YieldOrderEntity order, |
|
|
|
|
|