|
|
|
@ -63,6 +63,8 @@ import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.PrintWriter; |
|
|
|
|
|
|
|
import java.io.StringWriter; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.text.ParseException; |
|
|
|
import java.text.ParseException; |
|
|
|
@ -206,7 +208,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
Map<Long, List<SintTempCurveEntity>> sintMap = sintList.stream().collect(Collectors.groupingBy(SintTempCurveEntity::getProcessId)); |
|
|
|
Map<Long, List<SintTempCurveEntity>> sintMap = sintList.stream().collect(Collectors.groupingBy(SintTempCurveEntity::getProcessId)); |
|
|
|
|
|
|
|
|
|
|
|
//计算cr值
|
|
|
|
//计算cr值
|
|
|
|
calculateCr(list); |
|
|
|
//calculateCr(list);
|
|
|
|
//根据作业中心将订单分组,并根据优先级、cr值、订单需求数量、计划下达时间4个维度进行组内排序
|
|
|
|
//根据作业中心将订单分组,并根据优先级、cr值、订单需求数量、计划下达时间4个维度进行组内排序
|
|
|
|
Map<Long, List<YieldOrderEntity>> map = |
|
|
|
Map<Long, List<YieldOrderEntity>> map = |
|
|
|
list.stream() |
|
|
|
list.stream() |
|
|
|
@ -218,7 +220,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; |
|
|
|
@ -226,7 +228,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
) |
|
|
|
) |
|
|
|
)); |
|
|
|
)); |
|
|
|
//处理带有公共前置工序的订单
|
|
|
|
//处理带有公共前置工序的订单
|
|
|
|
Map<String, List<WorkPlanEntity>> planMap = dealCommonCraftOrders(); |
|
|
|
Map<Long, List<WorkPlanEntity>> planMap = dealCommonCraftOrders(); |
|
|
|
//多线程排产
|
|
|
|
//多线程排产
|
|
|
|
ExecutorService threadPool = new ThreadPoolExecutor( |
|
|
|
ExecutorService threadPool = new ThreadPoolExecutor( |
|
|
|
map.size(), map.size(), 0L, TimeUnit.MILLISECONDS, |
|
|
|
map.size(), map.size(), 0L, TimeUnit.MILLISECONDS, |
|
|
|
@ -420,7 +422,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
public void allocateResources(List<YieldOrderEntity> list, |
|
|
|
public void allocateResources(List<YieldOrderEntity> list, |
|
|
|
Map<String, PersonAbilityEntity> personAbilityMap, |
|
|
|
Map<String, PersonAbilityEntity> personAbilityMap, |
|
|
|
Map<Long, String> mainProducerMap, |
|
|
|
Map<Long, String> mainProducerMap, |
|
|
|
Map<String, List<WorkPlanEntity>> planMap, |
|
|
|
Map<Long, List<WorkPlanEntity>> planMap, |
|
|
|
Map<Long, String> processMap, |
|
|
|
Map<Long, String> processMap, |
|
|
|
Map<Long, List<SintTempCurveEntity>> sintMap, |
|
|
|
Map<Long, List<SintTempCurveEntity>> sintMap, |
|
|
|
Map<Long, String> workCenterMap, |
|
|
|
Map<Long, String> workCenterMap, |
|
|
|
@ -471,8 +473,8 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
//上一道工序结束时间
|
|
|
|
//上一道工序结束时间
|
|
|
|
LocalDateTime prevProcessEnd = LocalDateTime.now(); |
|
|
|
LocalDateTime prevProcessEnd = LocalDateTime.now(); |
|
|
|
//判断是否有公共工序已经处理了,如果有则重新定义workPlanList,获取公共工序的最后结束时间和当前时间做比较,取大的作为上一道工序结束时间
|
|
|
|
//判断是否有公共工序已经处理了,如果有则重新定义workPlanList,获取公共工序的最后结束时间和当前时间做比较,取大的作为上一道工序结束时间
|
|
|
|
if (planMap.containsKey(order.getYoCode())) { |
|
|
|
if (planMap.containsKey(order.getId())) { |
|
|
|
workPlanList = planMap.get(order.getYoCode()); |
|
|
|
workPlanList = planMap.get(order.getId()); |
|
|
|
prevProcessEnd = prevProcessEnd.compareTo(workPlanList.get(workPlanList.size() - 1).getPlanEndTime()) > 0 ? prevProcessEnd : workPlanList.get(workPlanList.size() - 1).getPlanEndTime(); |
|
|
|
prevProcessEnd = prevProcessEnd.compareTo(workPlanList.get(workPlanList.size() - 1).getPlanEndTime()) > 0 ? prevProcessEnd : workPlanList.get(workPlanList.size() - 1).getPlanEndTime(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -494,7 +496,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
workPlan.setWoId(order.getId()); |
|
|
|
workPlan.setWoId(order.getId()); |
|
|
|
workPlan.setCaId(craft.getCaId()); |
|
|
|
workPlan.setCaId(craft.getCaId()); |
|
|
|
workPlan.setPpsId(craft.getPpsId()); |
|
|
|
workPlan.setPpsId(craft.getPpsId()); |
|
|
|
workPlan.setWorkQty(order.getYpQty()); |
|
|
|
workPlan.setWorkQty(0); |
|
|
|
workPlan.setHourQuota(totalTime); |
|
|
|
workPlan.setHourQuota(totalTime); |
|
|
|
workPlan.setWorkCenterId(craft.getWorkCenterId()); |
|
|
|
workPlan.setWorkCenterId(craft.getWorkCenterId()); |
|
|
|
workPlan.setOrders(craft.getProcessNo()); |
|
|
|
workPlan.setOrders(craft.getProcessNo()); |
|
|
|
@ -516,7 +518,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
//同炉同槽
|
|
|
|
//同炉同槽
|
|
|
|
if(order.getYieldType() == YieldOrderEnum.YIELD_TYPE_1.getCode()){ |
|
|
|
if(order.getYieldType() == YieldOrderEnum.YIELD_TYPE_1.getCode()){ |
|
|
|
//热表同槽
|
|
|
|
//热表同槽
|
|
|
|
Boolean isSameTrough = sameTrough(order, craft, prevProcessEnd, workPlanList); |
|
|
|
Boolean isSameTrough = sameTrough(order, craft, localDateTime, workPlanList); |
|
|
|
//同槽就不需要继续匹配了
|
|
|
|
//同槽就不需要继续匹配了
|
|
|
|
if (isSameTrough) { |
|
|
|
if (isSameTrough) { |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
@ -554,38 +556,36 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
//获取下一个整数点
|
|
|
|
//获取下一个整数点
|
|
|
|
LocalDateTime dateTime = getNextIntegerTime(prevProcessEnd); |
|
|
|
LocalDateTime dateTime = getNextIntegerTime(prevProcessEnd); |
|
|
|
for (Map.Entry<Integer, List<EquipAbilityEntity>> entry : equipAbilityMap.entrySet()) { |
|
|
|
for (Map.Entry<Integer, List<EquipAbilityEntity>> entry : equipAbilityMap.entrySet()) { |
|
|
|
|
|
|
|
int partType = entry.getValue().get(0).getPartType(); |
|
|
|
//根据时间点获取所有设备资源
|
|
|
|
//根据时间点获取所有设备资源
|
|
|
|
List<EquipResourceEntity> equipResourceList = new ArrayList<>(); |
|
|
|
List<EquipResourceEntity> equipResourceList = new ArrayList<>(); |
|
|
|
if(order.getYieldType() == YieldOrderEnum.YIELD_TYPE_1.getCode()){ |
|
|
|
if(partType == 0){ |
|
|
|
equipResourceList = equipResourceService.list(Wrappers.<EquipResourceEntity>lambdaQuery() |
|
|
|
equipResourceList = equipResourceService.list(Wrappers.<EquipResourceEntity>lambdaQuery() |
|
|
|
.eq(EquipResourceEntity::getCraftId, craft.getCaId()) |
|
|
|
.eq(EquipResourceEntity::getCraftId, craft.getCaId()) |
|
|
|
.eq(EquipResourceEntity::getWorkCenterId, craft.getWorkCenterId()) |
|
|
|
.eq(EquipResourceEntity::getWorkCenterId, craft.getWorkCenterId()) |
|
|
|
.ge(EquipResourceEntity::getStartTime, dateTime) |
|
|
|
.ge(EquipResourceEntity::getStartTime, dateTime) |
|
|
|
.eq(EquipResourceEntity::getIsUsed, 0) |
|
|
|
.eq(EquipResourceEntity::getIsUsed, 0) |
|
|
|
.in(EquipResourceEntity::getEquipOrder, entry.getKey())); |
|
|
|
.in(EquipResourceEntity::getEquipOrder, entry.getKey())); |
|
|
|
}else{ |
|
|
|
}else if(partType == 1){ |
|
|
|
if(order.getYieldType() == YieldOrderEnum.YIELD_TYPE_3.getCode()){ |
|
|
|
equipResourceList = equipResourceService.list(Wrappers.<EquipResourceEntity>lambdaQuery() |
|
|
|
equipResourceList = equipResourceService.list(Wrappers.<EquipResourceEntity>lambdaQuery() |
|
|
|
.eq(EquipResourceEntity::getCraftId, craft.getCaId()) |
|
|
|
.eq(EquipResourceEntity::getCraftId, craft.getCaId()) |
|
|
|
.eq(EquipResourceEntity::getWorkCenterId, craft.getWorkCenterId()) |
|
|
|
.eq(EquipResourceEntity::getWorkCenterId, craft.getWorkCenterId()) |
|
|
|
.eq(EquipResourceEntity::getProcessId,craft.getPpsId()) |
|
|
|
.eq(EquipResourceEntity::getProcessId,craft.getPpsId()) |
|
|
|
.ge(EquipResourceEntity::getStartTime, dateTime) |
|
|
|
.ge(EquipResourceEntity::getStartTime, dateTime) |
|
|
|
.eq(EquipResourceEntity::getIsUsed, 0) |
|
|
|
.eq(EquipResourceEntity::getIsUsed, 0) |
|
|
|
.in(EquipResourceEntity::getEquipOrder, entry.getKey()) |
|
|
|
.in(EquipResourceEntity::getEquipOrder, entry.getKey()) |
|
|
|
.lt(EquipResourceEntity::getStartNum,part.getExternalDiameter()) |
|
|
|
.lt(EquipResourceEntity::getStartNum,part.getBlbDiameter()) |
|
|
|
.ge(EquipResourceEntity::getEndNum,part.getExternalDiameter())); |
|
|
|
.ge(EquipResourceEntity::getEndNum,part.getBlbDiameter())); |
|
|
|
}else if(partType == 2){ |
|
|
|
}else{ |
|
|
|
equipResourceList = equipResourceService.list(Wrappers.<EquipResourceEntity>lambdaQuery() |
|
|
|
equipResourceList = equipResourceService.list(Wrappers.<EquipResourceEntity>lambdaQuery() |
|
|
|
.eq(EquipResourceEntity::getCraftId, craft.getCaId()) |
|
|
|
.eq(EquipResourceEntity::getCraftId, craft.getCaId()) |
|
|
|
.eq(EquipResourceEntity::getWorkCenterId, craft.getWorkCenterId()) |
|
|
|
.eq(EquipResourceEntity::getWorkCenterId, craft.getWorkCenterId()) |
|
|
|
.eq(EquipResourceEntity::getProcessId,craft.getPpsId()) |
|
|
|
.eq(EquipResourceEntity::getProcessId,craft.getPpsId()) |
|
|
|
.ge(EquipResourceEntity::getStartTime, dateTime) |
|
|
|
.ge(EquipResourceEntity::getStartTime, dateTime) |
|
|
|
.eq(EquipResourceEntity::getIsUsed, 0) |
|
|
|
.eq(EquipResourceEntity::getIsUsed, 0) |
|
|
|
.in(EquipResourceEntity::getEquipOrder, entry.getKey()) |
|
|
|
.in(EquipResourceEntity::getEquipOrder, entry.getKey()) |
|
|
|
.lt(EquipResourceEntity::getStartNum,part.getBlbDiameter()) |
|
|
|
.lt(EquipResourceEntity::getStartNum,part.getExternalDiameter()) |
|
|
|
.ge(EquipResourceEntity::getEndNum,part.getBlbDiameter())); |
|
|
|
.ge(EquipResourceEntity::getEndNum,part.getExternalDiameter())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(equipResourceList)) { |
|
|
|
if (CollectionUtils.isEmpty(equipResourceList)) { |
|
|
|
@ -766,6 +766,8 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
totalTime = calPersonHoursByZklgj(order,part); |
|
|
|
totalTime = calPersonHoursByZklgj(order,part); |
|
|
|
}else if("单侧折针".equals(processMap.get(craft.getPpsId())) || "双侧折针".equals(processMap.get(craft.getPpsId()))){ |
|
|
|
}else if("单侧折针".equals(processMap.get(craft.getPpsId())) || "双侧折针".equals(processMap.get(craft.getPpsId()))){ |
|
|
|
totalTime = calPersonHoursByZz(order,part,processMap.get(craft.getPpsId())); |
|
|
|
totalTime = calPersonHoursByZz(order,part,processMap.get(craft.getPpsId())); |
|
|
|
|
|
|
|
}else if("玻璃封接电镀上挂".equals(processMap.get(craft.getPpsId()))){ |
|
|
|
|
|
|
|
totalTime = calPersonHoursByBlfjddsg(order,part); |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
totalTime = calPersonHours(order,craft,part); |
|
|
|
totalTime = calPersonHours(order,craft,part); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -800,7 +802,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
workPlan.setWoId(order.getId()); |
|
|
|
workPlan.setWoId(order.getId()); |
|
|
|
workPlan.setCaId(craft.getCaId()); |
|
|
|
workPlan.setCaId(craft.getCaId()); |
|
|
|
workPlan.setPpsId(craft.getPpsId()); |
|
|
|
workPlan.setPpsId(craft.getPpsId()); |
|
|
|
workPlan.setWorkQty(order.getYpQty()); |
|
|
|
workPlan.setWorkQty(0); |
|
|
|
workPlan.setHourQuota(totalTime); |
|
|
|
workPlan.setHourQuota(totalTime); |
|
|
|
workPlan.setWorkCenterId(craft.getWorkCenterId()); |
|
|
|
workPlan.setWorkCenterId(craft.getWorkCenterId()); |
|
|
|
workPlan.setOrders(craft.getProcessNo()); |
|
|
|
workPlan.setOrders(craft.getProcessNo()); |
|
|
|
@ -904,8 +906,11 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("报错订单是:" + order.getId() + ",报错信息是:" + e.getMessage()); |
|
|
|
StringWriter sw = new StringWriter(); |
|
|
|
throw new RuntimeException(e); |
|
|
|
PrintWriter pw = new PrintWriter(sw); |
|
|
|
|
|
|
|
e.printStackTrace(pw); |
|
|
|
|
|
|
|
log.error("报错订单是:" + order.getId() + ",报错信息是:" + sw.toString()); |
|
|
|
|
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
log.info("当前订单:" + order.getId() + "结束!"); |
|
|
|
log.info("当前订单:" + order.getId() + "结束!"); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -1252,10 +1257,10 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
return batches; |
|
|
|
return batches; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Map<String, List<WorkPlanEntity>> dealCommonCraftOrders() { |
|
|
|
public Map<Long, List<WorkPlanEntity>> dealCommonCraftOrders() { |
|
|
|
log.info("处理前置公共工序开始!"); |
|
|
|
log.info("处理前置公共工序开始!"); |
|
|
|
List<YieldOrderEntity> commonCraftOrderList = yieldOrderService.selectCommonCraftOrderList(); |
|
|
|
List<YieldOrderEntity> commonCraftOrderList = yieldOrderService.selectCommonCraftOrderList(); |
|
|
|
Map<String, List<WorkPlanEntity>> planMap = new HashMap<>(); |
|
|
|
Map<Long, List<WorkPlanEntity>> planMap = new HashMap<>(); |
|
|
|
if (CollectionUtils.isNotEmpty(commonCraftOrderList)) { |
|
|
|
if (CollectionUtils.isNotEmpty(commonCraftOrderList)) { |
|
|
|
//对订单进行排序,每5个相同workCenterId的为一组,实现负载均衡
|
|
|
|
//对订单进行排序,每5个相同workCenterId的为一组,实现负载均衡
|
|
|
|
commonCraftOrderList = sortByWorkcenterIdPer5Group(commonCraftOrderList); |
|
|
|
commonCraftOrderList = sortByWorkcenterIdPer5Group(commonCraftOrderList); |
|
|
|
@ -1263,8 +1268,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
//获取公共工序设备能力,根据工艺能力查询,写死ID是27
|
|
|
|
//获取公共工序设备能力,根据工艺能力查询,写死ID是27
|
|
|
|
EquipAbilityEntity equipAbility = equipAbilityService.getOne(Wrappers.<EquipAbilityEntity>lambdaQuery().eq(EquipAbilityEntity::getCraftId, 27)); |
|
|
|
EquipAbilityEntity equipAbility = equipAbilityService.getOne(Wrappers.<EquipAbilityEntity>lambdaQuery().eq(EquipAbilityEntity::getCraftId, 27)); |
|
|
|
BigDecimal standardProcessAbility = BigDecimal.valueOf(Integer.parseInt(equipAbility.getStandardProcessAbility())); |
|
|
|
BigDecimal standardProcessAbility = BigDecimal.valueOf(Integer.parseInt(equipAbility.getStandardProcessAbility())); |
|
|
|
//获取所有空闲的公共工序资源
|
|
|
|
|
|
|
|
List<EquipResourceEntity> equipResourceList = equipResourceService.selectCommonCraftList(); |
|
|
|
|
|
|
|
for (YieldOrderEntity order : commonCraftOrderList) { |
|
|
|
for (YieldOrderEntity order : commonCraftOrderList) { |
|
|
|
List<WorkPlanEntity> workPlanList = new ArrayList<>(); |
|
|
|
List<WorkPlanEntity> workPlanList = new ArrayList<>(); |
|
|
|
//获取相关工序
|
|
|
|
//获取相关工序
|
|
|
|
@ -1278,6 +1282,8 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
int period = sumCapacity.divide(standardProcessAbility, 0, RoundingMode.CEILING).intValue(); |
|
|
|
int period = sumCapacity.divide(standardProcessAbility, 0, RoundingMode.CEILING).intValue(); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < period; i++) { |
|
|
|
for (int i = 0; i < period; i++) { |
|
|
|
|
|
|
|
//获取所有空闲的公共工序资源
|
|
|
|
|
|
|
|
List<EquipResourceEntity> equipResourceList = equipResourceService.selectCommonCraftList(); |
|
|
|
for (int j = 0; j < equipResourceList.size(); j++) { |
|
|
|
for (int j = 0; j < equipResourceList.size(); j++) { |
|
|
|
if (i == j) { |
|
|
|
if (i == j) { |
|
|
|
EquipResourceEntity equipResource = equipResourceList.get(j); |
|
|
|
EquipResourceEntity equipResource = equipResourceList.get(j); |
|
|
|
@ -1286,7 +1292,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
WorkPlanEntity workPlan = new WorkPlanEntity(); |
|
|
|
WorkPlanEntity workPlan = new WorkPlanEntity(); |
|
|
|
workPlan.setPlanStartTime(equipResource.getStartTime()); |
|
|
|
workPlan.setPlanStartTime(equipResource.getStartTime()); |
|
|
|
workPlan.setPlanEndTime(equipResource.getStartTime().plusMinutes(equipResource.getStandardTime().setScale(0, RoundingMode.CEILING).longValue())); |
|
|
|
workPlan.setPlanEndTime(equipResource.getStartTime().plusMinutes(equipResource.getStandardTime().setScale(0, RoundingMode.CEILING).longValue())); |
|
|
|
workPlan.setWorkQty(order.getYpQty()); |
|
|
|
workPlan.setWorkQty(0); |
|
|
|
workPlan.setCaId(craft.getCaId()); |
|
|
|
workPlan.setCaId(craft.getCaId()); |
|
|
|
workPlan.setPpsId(craft.getPpsId()); |
|
|
|
workPlan.setPpsId(craft.getPpsId()); |
|
|
|
workPlan.setMakeTeam(equipResource.getTeamId()); |
|
|
|
workPlan.setMakeTeam(equipResource.getTeamId()); |
|
|
|
@ -1307,7 +1313,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
planMap.put(order.getYoCode(), workPlanList); |
|
|
|
planMap.put(order.getId(), workPlanList); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -1395,12 +1401,16 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
//可能有多个订单符合要求,按照车间订单、时间分组排序
|
|
|
|
//可能有多个订单符合要求,按照车间订单、时间分组排序
|
|
|
|
Map<Long, List<WorkPlanEntity>> workPlanMap = workPlanOldList.stream().collect(Collectors.groupingBy(WorkPlanEntity::getWoId)); |
|
|
|
Map<Long, List<WorkPlanEntity>> workPlanMap = workPlanOldList.stream().collect(Collectors.groupingBy(WorkPlanEntity::getWoId)); |
|
|
|
for (Map.Entry<Long, List<WorkPlanEntity>> entry : workPlanMap.entrySet()) { |
|
|
|
for (Map.Entry<Long, List<WorkPlanEntity>> entry : workPlanMap.entrySet()) { |
|
|
|
|
|
|
|
Long woId = entry.getKey(); |
|
|
|
List<WorkPlanEntity> planList = entry.getValue(); |
|
|
|
List<WorkPlanEntity> planList = entry.getValue(); |
|
|
|
Boolean isEnough = true; |
|
|
|
Boolean isEnough = true; |
|
|
|
List<Long> resourceList = new ArrayList<>(); |
|
|
|
List<Long> resourceList = new ArrayList<>(); |
|
|
|
for (WorkPlanEntity workPlan : planList) { |
|
|
|
for (WorkPlanEntity workPlan : planList) { |
|
|
|
if (workPlan.getEquipResourceId() != null) { |
|
|
|
if (workPlan.getEquipResourceId() != null) { |
|
|
|
EquipResourceEntity equipResource = equipResourceService.getById(workPlan.getEquipResourceId()); |
|
|
|
EquipResourceEntity equipResource = equipResourceService.getById(workPlan.getEquipResourceId()); |
|
|
|
|
|
|
|
if(equipResource == null){ |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
//判断剩余产能是否满足总产能
|
|
|
|
//判断剩余产能是否满足总产能
|
|
|
|
if (sumCapacity.compareTo(equipResource.getRestCapacity()) > 0) { |
|
|
|
if (sumCapacity.compareTo(equipResource.getRestCapacity()) > 0) { |
|
|
|
isEnough = false; |
|
|
|
isEnough = false; |
|
|
|
@ -1413,7 +1423,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
} |
|
|
|
} |
|
|
|
//如果产能满足,再判断是否满足同槽条件
|
|
|
|
//如果产能满足,再判断是否满足同槽条件
|
|
|
|
if (isEnough) { |
|
|
|
if (isEnough) { |
|
|
|
WorkOrderEntity workOrder = this.getById(workPlanOldList.get(0).getWoId()); |
|
|
|
WorkOrderEntity workOrder = this.getById(woId); |
|
|
|
YieldOrderEntity yieldOrderEntity = yieldOrderService.getById(workOrder.getYoId()); |
|
|
|
YieldOrderEntity yieldOrderEntity = yieldOrderService.getById(workOrder.getYoId()); |
|
|
|
List<YieldOrderCraftEntity> orderCraftList = yieldOrderCraftService.list(Wrappers.<YieldOrderCraftEntity>lambdaQuery() |
|
|
|
List<YieldOrderCraftEntity> orderCraftList = yieldOrderCraftService.list(Wrappers.<YieldOrderCraftEntity>lambdaQuery() |
|
|
|
.eq(YieldOrderCraftEntity::getYoId, yieldOrderEntity.getId()) |
|
|
|
.eq(YieldOrderCraftEntity::getYoId, yieldOrderEntity.getId()) |
|
|
|
@ -1422,93 +1432,95 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
.eq(YieldOrderCraftEntity::getWorkCenterId, craft.getWorkCenterId())); |
|
|
|
.eq(YieldOrderCraftEntity::getWorkCenterId, craft.getWorkCenterId())); |
|
|
|
SameTroughVO voNew = sameTroughService.selectSameTroughInfo(craft.getId()); |
|
|
|
SameTroughVO voNew = sameTroughService.selectSameTroughInfo(craft.getId()); |
|
|
|
SameTroughVO voOld = sameTroughService.selectSameTroughInfo(orderCraftList.get(0).getId()); |
|
|
|
SameTroughVO voOld = sameTroughService.selectSameTroughInfo(orderCraftList.get(0).getId()); |
|
|
|
//根据同槽因素进行比对
|
|
|
|
if(voNew != null && voOld != null){ |
|
|
|
Boolean isSameTrough2 = true; |
|
|
|
//根据同槽因素进行比对
|
|
|
|
//键位
|
|
|
|
Boolean isSameTrough2 = true; |
|
|
|
if ("1".equals(sameTrough.getKeyBinding()) && voNew.getPartCode().equals(voOld.getPartCode()) && StringUtils.isNotEmpty(voNew.getKeyBinding()) && StringUtils.isNotEmpty(voOld.getKeyBinding()) && !voNew.getKeyBinding().equals(voOld.getKeyBinding())) { |
|
|
|
//键位
|
|
|
|
isSameTrough2 = false; |
|
|
|
if ("1".equals(sameTrough.getKeyBinding()) && voNew.getPartCode().equals(voOld.getPartCode()) && StringUtils.isNotEmpty(voNew.getKeyBinding()) && StringUtils.isNotEmpty(voOld.getKeyBinding()) && !voNew.getKeyBinding().equals(voOld.getKeyBinding())) { |
|
|
|
} |
|
|
|
|
|
|
|
//生产厂家
|
|
|
|
|
|
|
|
if ("1".equals(sameTrough.getProducter()) && voNew.getPartCode().equals(voOld.getPartCode()) && StringUtils.isNotEmpty(voNew.getProducter()) && StringUtils.isNotEmpty(voOld.getProducter()) && !voNew.getProducter().equals(voOld.getProducter())) { |
|
|
|
|
|
|
|
isSameTrough2 = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//检验编号
|
|
|
|
|
|
|
|
if ("1".equals(sameTrough.getInspectionCode()) && voNew.getPartCode().equals(voOld.getPartCode()) && StringUtils.isNotEmpty(voNew.getInspectionCode()) && StringUtils.isNotEmpty(voOld.getInspectionCode()) && !voNew.getInspectionCode().equals(voOld.getInspectionCode())) { |
|
|
|
|
|
|
|
isSameTrough2 = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//材料
|
|
|
|
|
|
|
|
if ("1".equals(sameTrough.getMaterial()) && StringUtils.isNotEmpty(voNew.getMaterial()) && StringUtils.isNotEmpty(voOld.getMaterial()) && !voNew.getMaterial().equals(voOld.getMaterial())) { |
|
|
|
|
|
|
|
isSameTrough2 = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//厚度
|
|
|
|
|
|
|
|
if ("1".equals(sameTrough.getThickness()) && StringUtils.isNotEmpty(voNew.getThickness()) && StringUtils.isNotEmpty(voOld.getThickness()) && !voNew.getThickness().equals(voOld.getThickness())) { |
|
|
|
|
|
|
|
isSameTrough2 = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//钝化
|
|
|
|
|
|
|
|
if ("1".equals(sameTrough.getPassivation())) { |
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(voNew.getPlate()) |
|
|
|
|
|
|
|
&& StringUtils.isNotEmpty(voOld.getPlate()) |
|
|
|
|
|
|
|
&& ((voNew.getPlate().contains("不钝化") |
|
|
|
|
|
|
|
&& !voOld.getPlate().contains("不钝化")) |
|
|
|
|
|
|
|
|| (voOld.getPlate().contains("不钝化") |
|
|
|
|
|
|
|
&& !voNew.getPlate().contains("不钝化")))) { |
|
|
|
|
|
|
|
isSameTrough2 = false; |
|
|
|
isSameTrough2 = false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//生产厂家
|
|
|
|
//硬度
|
|
|
|
if ("1".equals(sameTrough.getProducter()) && voNew.getPartCode().equals(voOld.getPartCode()) && StringUtils.isNotEmpty(voNew.getProducter()) && StringUtils.isNotEmpty(voOld.getProducter()) && !voNew.getProducter().equals(voOld.getProducter())) { |
|
|
|
if ("1".equals(sameTrough.getHardness()) && StringUtils.isNotEmpty(voNew.getHardness()) && StringUtils.isNotEmpty(voOld.getHardness()) && !voNew.getHardness().equals(voOld.getHardness())) { |
|
|
|
|
|
|
|
isSameTrough2 = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//生产标识
|
|
|
|
|
|
|
|
if ("1".equals(sameTrough.getProductIdent())) { |
|
|
|
|
|
|
|
List<String> highIdentList = Arrays.asList(new String[]{"JHT", "JI", "JIX", "YH", "CC", "SATA"}); |
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(order.getProductIdent()) && highIdentList.contains(order.getProductIdent())) { |
|
|
|
|
|
|
|
isSameTrough2 = false; |
|
|
|
isSameTrough2 = false; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!(voNew.getPartCode().equals(voOld.getPartCode()) |
|
|
|
//检验编号
|
|
|
|
&& StringUtils.isNotEmpty(voNew.getProductIdent()) |
|
|
|
if ("1".equals(sameTrough.getInspectionCode()) && voNew.getPartCode().equals(voOld.getPartCode()) && StringUtils.isNotEmpty(voNew.getInspectionCode()) && StringUtils.isNotEmpty(voOld.getInspectionCode()) && !voNew.getInspectionCode().equals(voOld.getInspectionCode())) { |
|
|
|
&& StringUtils.isNotEmpty(voOld.getProductIdent()) |
|
|
|
|
|
|
|
&& voNew.getProductIdent().equals(voOld.getProductIdent()))) { |
|
|
|
|
|
|
|
isSameTrough2 = false; |
|
|
|
isSameTrough2 = false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//材料
|
|
|
|
} |
|
|
|
if ("1".equals(sameTrough.getMaterial()) && StringUtils.isNotEmpty(voNew.getMaterial()) && StringUtils.isNotEmpty(voOld.getMaterial()) && !voNew.getMaterial().equals(voOld.getMaterial())) { |
|
|
|
if (isSameTrough2) { |
|
|
|
isSameTrough2 = false; |
|
|
|
for (Long resourceId : resourceList) { |
|
|
|
} |
|
|
|
EquipResourceEntity equipResource = equipResourceService.getById(resourceId); |
|
|
|
//厚度
|
|
|
|
//生成车间订单
|
|
|
|
if ("1".equals(sameTrough.getThickness()) && StringUtils.isNotEmpty(voNew.getThickness()) && StringUtils.isNotEmpty(voOld.getThickness()) && !voNew.getThickness().equals(voOld.getThickness())) { |
|
|
|
WorkPlanEntity workPlan = new WorkPlanEntity(); |
|
|
|
isSameTrough2 = false; |
|
|
|
workPlan.setPlanStartTime(equipResource.getStartTime()); |
|
|
|
} |
|
|
|
if ("0".equals(equipResource.getEquipType())) { |
|
|
|
//钝化
|
|
|
|
workPlan.setPlanEndTime(equipResource.getStartTime().plusMinutes(equipResource.getStandardTime().setScale(0, RoundingMode.CEILING).longValue())); |
|
|
|
if ("1".equals(sameTrough.getPassivation())) { |
|
|
|
} else { |
|
|
|
if (StringUtils.isNotEmpty(voNew.getPlate()) |
|
|
|
workPlan.setPlanEndTime(equipResource.getEndTime()); |
|
|
|
&& StringUtils.isNotEmpty(voOld.getPlate()) |
|
|
|
|
|
|
|
&& ((voNew.getPlate().contains("不钝化") |
|
|
|
|
|
|
|
&& !voOld.getPlate().contains("不钝化")) |
|
|
|
|
|
|
|
|| (voOld.getPlate().contains("不钝化") |
|
|
|
|
|
|
|
&& !voNew.getPlate().contains("不钝化")))) { |
|
|
|
|
|
|
|
isSameTrough2 = false; |
|
|
|
} |
|
|
|
} |
|
|
|
workPlan.setWorkQty(order.getYpQty()); |
|
|
|
|
|
|
|
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()); |
|
|
|
|
|
|
|
workPlanList.add(workPlan); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
equipResource.setRestCapacity(equipResource.getRestCapacity().subtract(sumCapacity)); |
|
|
|
|
|
|
|
equipResourceService.updateById(equipResource); |
|
|
|
|
|
|
|
isSameTrough = true; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//硬度
|
|
|
|
|
|
|
|
if ("1".equals(sameTrough.getHardness()) && StringUtils.isNotEmpty(voNew.getHardness()) && StringUtils.isNotEmpty(voOld.getHardness()) && !voNew.getHardness().equals(voOld.getHardness())) { |
|
|
|
|
|
|
|
isSameTrough2 = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//生产标识
|
|
|
|
|
|
|
|
if ("1".equals(sameTrough.getProductIdent())) { |
|
|
|
|
|
|
|
List<String> highIdentList = Arrays.asList(new String[]{"JHT", "JI", "JIX", "YH", "CC", "SATA"}); |
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(order.getProductIdent()) && highIdentList.contains(order.getProductIdent())) { |
|
|
|
|
|
|
|
isSameTrough2 = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!(voNew.getPartCode().equals(voOld.getPartCode()) |
|
|
|
|
|
|
|
&& StringUtils.isNotEmpty(voNew.getProductIdent()) |
|
|
|
|
|
|
|
&& StringUtils.isNotEmpty(voOld.getProductIdent()) |
|
|
|
|
|
|
|
&& voNew.getProductIdent().equals(voOld.getProductIdent()))) { |
|
|
|
|
|
|
|
isSameTrough2 = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (isSameTrough2) { |
|
|
|
|
|
|
|
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()); |
|
|
|
|
|
|
|
workPlanList.add(workPlan); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
equipResource.setRestCapacity(equipResource.getRestCapacity().subtract(sumCapacity)); |
|
|
|
|
|
|
|
equipResourceService.updateById(equipResource); |
|
|
|
|
|
|
|
isSameTrough = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -1602,7 +1614,7 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
personHours = calPersonHours(order,craft,part); |
|
|
|
personHours = calPersonHours(order,craft,part); |
|
|
|
} |
|
|
|
} |
|
|
|
workPlan.setPlanEndTime(workPlan.getPlanEndTime().plusMinutes(personHours.longValue())); |
|
|
|
workPlan.setPlanEndTime(workPlan.getPlanEndTime().plusMinutes(personHours.longValue())); |
|
|
|
workPlan.setWorkQty(order.getYpQty()); |
|
|
|
workPlan.setWorkQty(0); |
|
|
|
workPlan.setCaId(craft.getCaId()); |
|
|
|
workPlan.setCaId(craft.getCaId()); |
|
|
|
workPlan.setPpsId(craft.getPpsId()); |
|
|
|
workPlan.setPpsId(craft.getPpsId()); |
|
|
|
workPlan.setMakeTeam(equipResource.getTeamId()); |
|
|
|
workPlan.setMakeTeam(equipResource.getTeamId()); |
|
|
|
@ -2172,6 +2184,23 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO |
|
|
|
return Math.ceil(result * order.getYpQty() + 2); |
|
|
|
return Math.ceil(result * order.getYpQty() + 2); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//玻璃封接电镀上挂
|
|
|
|
|
|
|
|
public Double calPersonHoursByBlfjddsg(YieldOrderEntity order,PartEntity part){ |
|
|
|
|
|
|
|
Double result = 0.0; |
|
|
|
|
|
|
|
if (part != null && part.getId() != null) { |
|
|
|
|
|
|
|
List<PartRelationEntity> partRelationList = partRelationService.list(Wrappers.<PartRelationEntity>lambdaQuery().eq(PartRelationEntity::getPartId,part.getId())); |
|
|
|
|
|
|
|
List<Long> childIds = partRelationList.stream().map(PartRelationEntity::getChildPartId).collect(Collectors.toList()); |
|
|
|
|
|
|
|
List<PartEntity> partCz = partService.list(Wrappers.<PartEntity>lambdaQuery().in(BaseEntity::getId,childIds).eq(PartEntity::getSinTerType,DsPartConstant.SIN_TER_TYPE_CZ)); |
|
|
|
|
|
|
|
if (partCz != null && partCz.size() > 0) { |
|
|
|
|
|
|
|
double sumOfQuota = partCz.stream() |
|
|
|
|
|
|
|
.mapToDouble(PartEntity::getQuota) // 调用 getQuota() 方法
|
|
|
|
|
|
|
|
.sum(); |
|
|
|
|
|
|
|
result = (38 + 3 * sumOfQuota) / 60; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return Math.ceil(result * order.getYpQty() + 2); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static List<YieldOrderEntity> mergeYieldOrderList(List<YieldOrderEntity> originalList) { |
|
|
|
public static List<YieldOrderEntity> mergeYieldOrderList(List<YieldOrderEntity> originalList) { |
|
|
|
// 空值校验
|
|
|
|
// 空值校验
|
|
|
|
if (originalList == null || originalList.isEmpty()) { |
|
|
|
if (originalList == null || originalList.isEmpty()) { |
|
|
|
|