|
|
|
@ -18,6 +18,8 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
@ -690,7 +692,7 @@ public class RoutingManagementServiceImpl extends ServiceImpl<RoutingManagementM |
|
|
|
PartInformationEntity part = partInformationMapper.selectOne(new QueryWrapper<PartInformationEntity>().eq("site", data.getSite()).eq("sourceBu", data.getBuNo()).eq("part_no", data.getPartNo())); |
|
|
|
|
|
|
|
// 根据商品组1查标准工序 |
|
|
|
List<RoutingComponentVo> operations = routingManagementMapper.getStandardRoutingOperationByProductGroupId(data.getSite(), data.getBuNo(), part.getOtherGroup1()); |
|
|
|
List<RoutingComponentVo> operations = routingManagementMapper.getStandardRoutingOperationByProductGroupId(data.getSite(), data.getBuNo(), part.getProductGroupId1()); |
|
|
|
|
|
|
|
// 获得物料维护的属性 |
|
|
|
PartSubPropertiesValueData valueData = new PartSubPropertiesValueData(); |
|
|
|
@ -700,50 +702,138 @@ public class RoutingManagementServiceImpl extends ServiceImpl<RoutingManagementM |
|
|
|
valueData.setPartNo(data.getPartNo()); |
|
|
|
List<PartSubPropertiesValueData> partItems = partInformationMapper.getItemModal(valueData); |
|
|
|
|
|
|
|
// 获取的商品组的condition |
|
|
|
List<PgPtmConditionEntity> conditionList = routingManagementMapper.getPtmCondition(data.getSite(), data.getBuNo(), part.getOtherGroup1()); |
|
|
|
for (PgPtmConditionEntity conditionData : conditionList) { |
|
|
|
// 查维护的属性集 |
|
|
|
List<PtmConditionItemEntity> conditionItems = routingManagementMapper.getConditionItemList(data.getSite(), data.getBuNo(), conditionData.getConditionId()); |
|
|
|
// 如果属性集合大小不等则直接跳过 |
|
|
|
if (partItems.size() != conditionItems.size()) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
// 比较属性编码和属性值是否一致 |
|
|
|
boolean b = partItems.stream().allMatch( |
|
|
|
partItem -> conditionItems.stream().anyMatch( |
|
|
|
conditionItem -> |
|
|
|
Objects.equals(partItem.getPropertiesItemNo(), conditionItem.getItemNo()) && |
|
|
|
Objects.equals(partItem.getTextValue(), conditionItem.getTextValue()) && |
|
|
|
Objects.equals(partItem.getNumValue(), conditionItem.getNumValue()) |
|
|
|
) |
|
|
|
); |
|
|
|
if (b) { |
|
|
|
// 获取该condition下维护的工序 |
|
|
|
List<RoutingComponentVo> conditionOperations = routingManagementMapper.getConditionOperationsInfo(conditionData.getConditionId()); |
|
|
|
|
|
|
|
// 创建一个映射,键为 operationNo,值为对应的 RoutingComponentVo 对象 |
|
|
|
Map<Integer, RoutingComponentVo> conditionOperationsMap = conditionOperations.stream() |
|
|
|
.collect(Collectors.toMap(RoutingComponentVo::getOperationNo, vo -> vo)); |
|
|
|
|
|
|
|
// 赋值 labor_run_factor mach_run_factor labor_cycle_time mach_cycle_time |
|
|
|
for (RoutingComponentVo operation : operations) { |
|
|
|
// 检查 conditionOperationsMap 中是否存在相同的 operationNo |
|
|
|
if (conditionOperationsMap.containsKey(operation.getOperationNo())) { |
|
|
|
// 获取 conditionOperations 中具有相同 operationNo 的 RoutingComponentVo 对象 |
|
|
|
RoutingComponentVo conditionOperation = conditionOperationsMap.get(operation.getOperationNo()); |
|
|
|
|
|
|
|
// 更新 operations 中的对象属性 |
|
|
|
operation.setMachRunFactor(conditionOperation.getMachRunFactor()); |
|
|
|
operation.setLaborRunFactor(conditionOperation.getLaborRunFactor()); |
|
|
|
operation.setMachCycleTime(conditionOperation.getMachCycleTime()); |
|
|
|
operation.setLaborCycleTime(conditionOperation.getLaborCycleTime()); |
|
|
|
operation.setConditionDesc(conditionData.getConditionDesc()); |
|
|
|
if (!operations.isEmpty()) { |
|
|
|
for (RoutingComponentVo operation : operations) { |
|
|
|
// 获取各个值 |
|
|
|
int scale = 6; // 保留的小数位数 |
|
|
|
BigDecimal machCycleTime = BigDecimal.ZERO; // 机器处理时间 |
|
|
|
BigDecimal refSpeed = operation.getRefSpeed(); // 速度 |
|
|
|
BigDecimal refTime = operation.getRefTime(); // 时间 |
|
|
|
BigDecimal refEfficiency = operation.getRefEfficiency().multiply(BigDecimal.valueOf(0.01)); // 效率 |
|
|
|
BigDecimal refDailyProduction = operation.getRefDailyProduction(); // 日产量 |
|
|
|
// 判断工序 |
|
|
|
if ("一复".equals(operation.getOperationName()) || "熟化".equals(operation.getOperationName()) || "RFID前道检品".equals(operation.getOperationName())) { |
|
|
|
// 1 /(速度 x 时间 x 效率), 保留四位小数,四舍五入 |
|
|
|
machCycleTime = BigDecimal.ONE.divide(refSpeed.multiply(refTime).multiply(refEfficiency), scale, RoundingMode.HALF_UP); |
|
|
|
} else if ("印刷".equals(operation.getOperationName()) || "RFID-蚀刻".equals(operation.getOperationName()) || "RFID-分切".equals(operation.getOperationName())) { |
|
|
|
// 1 /(速度 x 时间 x 效率)/ Printing lanes , 保留四位小数,四舍五入 |
|
|
|
List<PartSubPropertiesValueData> collect = partItems.stream().filter(a -> "Printing lanes".equals(a.getItemDesc())).collect(Collectors.toList()); |
|
|
|
if (!collect.isEmpty()) { |
|
|
|
// Printing lanes 属性的值 |
|
|
|
BigDecimal numValue = BigDecimal.valueOf(collect.get(0).getNumValue()); |
|
|
|
// 速度 x 时间 x 效率 |
|
|
|
BigDecimal product = refSpeed.multiply(refTime).multiply(refEfficiency); |
|
|
|
// 1 / 速度 x 时间 x 效率 |
|
|
|
BigDecimal intermediateResult = BigDecimal.ONE.divide(product, scale, RoundingMode.HALF_UP); |
|
|
|
// 最终结果 |
|
|
|
machCycleTime = intermediateResult.divide(numValue, scale, RoundingMode.HALF_UP); |
|
|
|
} |
|
|
|
} else if ("RFID绑定-TAL".equals(operation.getOperationName()) || "RFID绑定-Paris".equals(operation.getOperationName()) |
|
|
|
|| "Encoding(编码)".equals(operation.getOperationName()) || "CLS编码打印".equals(operation.getOperationName()) || operation.getOperationName().contains("后道检品")) { |
|
|
|
// 1 / (UPH x 效率) x 1000, UPH-TAL、UPH-Paris、Converting-UPH |
|
|
|
List<PartSubPropertiesValueData> collect = new ArrayList<>(); |
|
|
|
if ("RFID绑定-TAL".equals(operation.getOperationName())) { |
|
|
|
collect = partItems.stream().filter(a -> "UPH-TAL".equals(a.getItemDesc())).collect(Collectors.toList()); |
|
|
|
} else if ("RFID绑定-Paris".equals(operation.getOperationName())) { |
|
|
|
collect = partItems.stream().filter(a -> "UPH-Paris".equals(a.getItemDesc())).collect(Collectors.toList()); |
|
|
|
} else if ("Encoding(编码)".equals(operation.getOperationName()) || "CLS编码打印".equals(operation.getOperationName()) || operation.getOperationName().contains("后道检品")) { |
|
|
|
collect = partItems.stream().filter(a -> "Converting-UPH".equals(a.getItemDesc())).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
if (!collect.isEmpty()) { |
|
|
|
// UPH 属性的值 |
|
|
|
BigDecimal numValue = BigDecimal.valueOf(collect.get(0).getNumValue()); |
|
|
|
// 1/ (UPH x 效率) |
|
|
|
BigDecimal product = BigDecimal.ONE.divide(numValue.multiply(refEfficiency), scale, RoundingMode.HALF_UP); |
|
|
|
// 最终结果 |
|
|
|
machCycleTime = product.multiply(BigDecimal.valueOf(1000)); |
|
|
|
} |
|
|
|
} else if ("RFID绑定-MLI".equals(operation.getOperationName()) || operation.getOperationName().contains("RFID复合模切检测") |
|
|
|
|| operation.getOperationName().contains("RFID自动贴标") || operation.getOperationName().contains("Voyantic在线检测")) { |
|
|
|
// 1 / 速度 x 时间 x 效率 x (1000/pitch) x 列数 x 1000 |
|
|
|
List<PartSubPropertiesValueData> collect1; |
|
|
|
List<PartSubPropertiesValueData> collect2 = new ArrayList<>(); |
|
|
|
collect1 = partItems.stream().filter(a -> "CL60k-Pitch".equals(a.getItemDesc())).collect(Collectors.toList()); |
|
|
|
if ("RFID绑定-MLI".equals(operation.getOperationName())) { |
|
|
|
collect1 = partItems.stream().filter(a -> "Bonding Pitch".equals(a.getItemDesc())).collect(Collectors.toList()); |
|
|
|
collect2 = partItems.stream().filter(a -> "绑定列数".equals(a.getItemDesc())).collect(Collectors.toList()); |
|
|
|
} else if (operation.getOperationName().contains("RFID复合模切检测")) { |
|
|
|
// 复合列数 |
|
|
|
collect2 = partItems.stream().filter(a -> "复合列数".equals(a.getItemDesc())).collect(Collectors.toList()); |
|
|
|
} else if (operation.getOperationName().contains("RFID自动贴标")) { |
|
|
|
// 贴标列数 |
|
|
|
collect2 = partItems.stream().filter(a -> "贴标列数".equals(a.getItemDesc())).collect(Collectors.toList()); |
|
|
|
} else if (operation.getOperationName().contains("Voyantic在线检测")) { |
|
|
|
// 检测列数 |
|
|
|
collect2 = partItems.stream().filter(a -> "检测列数".equals(a.getItemDesc())).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
if (!collect1.isEmpty() && !collect2.isEmpty()) { |
|
|
|
// 1000/pitch |
|
|
|
BigDecimal numValue1 = BigDecimal.valueOf(1000).divide(BigDecimal.valueOf(collect1.get(0).getNumValue()), scale, RoundingMode.HALF_UP); |
|
|
|
// 列数 属性的值 |
|
|
|
BigDecimal numValue2 = BigDecimal.valueOf(collect2.get(0).getNumValue()); |
|
|
|
// 1 / (速度 x 时间 x 效率 x (1000/pitch) x 列数) |
|
|
|
BigDecimal product = BigDecimal.ONE.divide(refSpeed.multiply(refTime).multiply(refEfficiency).multiply(numValue1).multiply(numValue2), scale, RoundingMode.HALF_UP); |
|
|
|
// 最终结果 |
|
|
|
machCycleTime = product.multiply(BigDecimal.valueOf(1000)); |
|
|
|
} |
|
|
|
} else if ("Packaging".equals(operation.getOperationName())) { |
|
|
|
// 1 / (日产量 / 8小时 / 17) x 1000 |
|
|
|
// 日产量 / 8小时 / 17 |
|
|
|
BigDecimal product = BigDecimal.ONE.divide(refDailyProduction.divide(BigDecimal.valueOf(8), scale, RoundingMode.HALF_UP).divide(BigDecimal.valueOf(17), scale, RoundingMode.HALF_UP).multiply(refEfficiency), scale, RoundingMode.HALF_UP); |
|
|
|
// 最终结果 |
|
|
|
machCycleTime = product.multiply(BigDecimal.valueOf(1000)); |
|
|
|
} |
|
|
|
break; |
|
|
|
operation.setMachCycleTime(machCycleTime); // 机器处理时间 |
|
|
|
operation.setLaborCycleTime(machCycleTime); // 人工处理时间 |
|
|
|
operation.setMachRunFactor(BigDecimal.ONE.divide(machCycleTime, 4, RoundingMode.HALF_UP)); // 机器单位产出 |
|
|
|
operation.setLaborRunFactor(BigDecimal.ONE.divide(machCycleTime, 4, RoundingMode.HALF_UP)); // 人工单位产出 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// // 获取的商品组的condition |
|
|
|
// List<PgPtmConditionEntity> conditionList = routingManagementMapper.getPtmCondition(data.getSite(), data.getBuNo(), part.getProductGroupId1()); |
|
|
|
// for (PgPtmConditionEntity conditionData : conditionList) { |
|
|
|
// // 查维护的属性集 |
|
|
|
// List<PtmConditionItemEntity> conditionItems = routingManagementMapper.getConditionItemList(data.getSite(), data.getBuNo(), conditionData.getConditionId()); |
|
|
|
// // 如果属性集合大小不等则直接跳过 |
|
|
|
// if (partItems.size() != conditionItems.size()) { |
|
|
|
// continue; |
|
|
|
// } |
|
|
|
// // 比较属性编码和属性值是否一致 |
|
|
|
// boolean b = partItems.stream().allMatch( |
|
|
|
// partItem -> conditionItems.stream().anyMatch( |
|
|
|
// conditionItem -> |
|
|
|
// Objects.equals(partItem.getPropertiesItemNo(), conditionItem.getItemNo()) && |
|
|
|
// Objects.equals(partItem.getTextValue(), conditionItem.getTextValue()) && |
|
|
|
// Objects.equals(partItem.getNumValue(), conditionItem.getNumValue()) |
|
|
|
// ) |
|
|
|
// ); |
|
|
|
// if (b) { |
|
|
|
// // 获取该condition下维护的工序 |
|
|
|
// List<RoutingComponentVo> conditionOperations = routingManagementMapper.getConditionOperationsInfo(conditionData.getConditionId()); |
|
|
|
// |
|
|
|
// // 创建一个映射,键为 operationNo,值为对应的 RoutingComponentVo 对象 |
|
|
|
// Map<Integer, RoutingComponentVo> conditionOperationsMap = conditionOperations.stream() |
|
|
|
// .collect(Collectors.toMap(RoutingComponentVo::getOperationNo, vo -> vo)); |
|
|
|
// |
|
|
|
// // 赋值 labor_run_factor mach_run_factor labor_cycle_time mach_cycle_time |
|
|
|
// for (RoutingComponentVo operation : operations) { |
|
|
|
// // 检查 conditionOperationsMap 中是否存在相同的 operationNo |
|
|
|
// if (conditionOperationsMap.containsKey(operation.getOperationNo())) { |
|
|
|
// // 获取 conditionOperations 中具有相同 operationNo 的 RoutingComponentVo 对象 |
|
|
|
// RoutingComponentVo conditionOperation = conditionOperationsMap.get(operation.getOperationNo()); |
|
|
|
// |
|
|
|
// // 更新 operations 中的对象属性 |
|
|
|
// operation.setMachRunFactor(conditionOperation.getMachRunFactor()); |
|
|
|
// operation.setLaborRunFactor(conditionOperation.getLaborRunFactor()); |
|
|
|
// operation.setMachCycleTime(conditionOperation.getMachCycleTime()); |
|
|
|
// operation.setLaborCycleTime(conditionOperation.getLaborCycleTime()); |
|
|
|
// operation.setConditionDesc(conditionData.getConditionDesc()); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// break; |
|
|
|
// } |
|
|
|
// } |
|
|
|
return operations; |
|
|
|
} |
|
|
|
|
|
|
|
|