|
|
|
@ -1602,51 +1602,53 @@ public class RoutingManagementServiceImpl extends ServiceImpl<RoutingManagementM |
|
|
|
throw new RuntimeException(e.getMessage()); |
|
|
|
} |
|
|
|
|
|
|
|
// 查询PLM数据 |
|
|
|
String[] arr = data.getSiteCon().replace("(", "").replace(")", "").replace("'", "").split(","); |
|
|
|
List<WorkCenterCost> plmWorkCenterCosts = routingManagementMapper.getPLMWorkCenterCosts(arr); |
|
|
|
|
|
|
|
// 转换列表为映射以便于比较 |
|
|
|
Map<String, WorkCenterCost> mapListAll = ifsWorkCenterCosts.stream() |
|
|
|
.collect(Collectors.toMap(WorkCenterCost::getIfsRowId, Function.identity())); |
|
|
|
Map<String, WorkCenterCost> mapList1 = plmWorkCenterCosts.stream() |
|
|
|
.collect(Collectors.toMap(WorkCenterCost::getIfsRowId, Function.identity())); |
|
|
|
|
|
|
|
// 找出需要新增的对象(IFS有而PLM没有的) |
|
|
|
Set<String> keysToAdd = new HashSet<>(mapListAll.keySet()); |
|
|
|
keysToAdd.removeAll(mapList1.keySet()); |
|
|
|
List<WorkCenterCost> toAdd = keysToAdd.stream() |
|
|
|
.map(mapListAll::get) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
// 找出需要更新的对象(ifsRowVersion不同) |
|
|
|
Set<String> commonKeys = new HashSet<>(mapListAll.keySet()); |
|
|
|
commonKeys.retainAll(mapList1.keySet()); |
|
|
|
List<WorkCenterCost> toUpdate = commonKeys.stream() |
|
|
|
.filter(key -> !mapListAll.get(key).getIfsRowVersion().equals(mapList1.get(key).getIfsRowVersion())) |
|
|
|
.map(key -> mapListAll.get(key)) // 选择listAll中的版本进行更新 |
|
|
|
.collect(Collectors.toList()); |
|
|
|
// // 查询PLM数据 |
|
|
|
// String[] arr = data.getSiteCon().replace("(", "").replace(")", "").replace("'", "").split(","); |
|
|
|
// List<WorkCenterCost> plmWorkCenterCosts = routingManagementMapper.getPLMWorkCenterCosts(arr); |
|
|
|
// |
|
|
|
// // 转换列表为映射以便于比较 |
|
|
|
// Map<String, WorkCenterCost> mapListAll = ifsWorkCenterCosts.stream() |
|
|
|
// .collect(Collectors.toMap(WorkCenterCost::getIfsRowId, Function.identity())); |
|
|
|
// Map<String, WorkCenterCost> mapList1 = plmWorkCenterCosts.stream() |
|
|
|
// .collect(Collectors.toMap(WorkCenterCost::getIfsRowId, Function.identity())); |
|
|
|
|
|
|
|
// // 找出需要新增的对象(IFS有而PLM没有的) |
|
|
|
// Set<String> keysToAdd = new HashSet<>(mapListAll.keySet()); |
|
|
|
// keysToAdd.removeAll(mapList1.keySet()); |
|
|
|
// List<WorkCenterCost> toAdd = keysToAdd.stream() |
|
|
|
// .map(mapListAll::get) |
|
|
|
// .collect(Collectors.toList()); |
|
|
|
// |
|
|
|
// // 找出需要更新的对象(ifsRowVersion不同) |
|
|
|
// Set<String> commonKeys = new HashSet<>(mapListAll.keySet()); |
|
|
|
// commonKeys.retainAll(mapList1.keySet()); |
|
|
|
// List<WorkCenterCost> toUpdate = commonKeys.stream() |
|
|
|
// .filter(key -> !mapListAll.get(key).getIfsRowVersion().equals(mapList1.get(key).getIfsRowVersion())) |
|
|
|
// .map(key -> mapListAll.get(key)) // 选择listAll中的版本进行更新 |
|
|
|
// .collect(Collectors.toList()); |
|
|
|
|
|
|
|
// 新增 |
|
|
|
if (!toAdd.isEmpty()) { |
|
|
|
// 删除再新增 |
|
|
|
if (!ifsWorkCenterCosts.isEmpty()) { |
|
|
|
// 清空数据 |
|
|
|
routingManagementMapper.deleteWorkCenterCostAll(); |
|
|
|
// 分批插入 |
|
|
|
int batchSize = 50; // 假设每批100条记录 |
|
|
|
for (int i = 0; i < toAdd.size(); i += batchSize) { |
|
|
|
int end = Math.min(i + batchSize, toAdd.size()); |
|
|
|
List<WorkCenterCost> subList = toAdd.subList(i, end); |
|
|
|
for (int i = 0; i < ifsWorkCenterCosts.size(); i += batchSize) { |
|
|
|
int end = Math.min(i + batchSize, ifsWorkCenterCosts.size()); |
|
|
|
List<WorkCenterCost> subList = ifsWorkCenterCosts.subList(i, end); |
|
|
|
routingManagementMapper.syncSaveWorkCenterCost(subList); |
|
|
|
} |
|
|
|
} |
|
|
|
// 修改 |
|
|
|
if (!toUpdate.isEmpty()) { |
|
|
|
// 分批修改 |
|
|
|
int batchSize = 50; // 假设每批100条记录 |
|
|
|
for (int i = 0; i < toUpdate.size(); i += batchSize) { |
|
|
|
int end = Math.min(i + batchSize, toUpdate.size()); |
|
|
|
List<WorkCenterCost> subList = toUpdate.subList(i, end); |
|
|
|
routingManagementMapper.syncUpdateWorkCenterCost(subList); |
|
|
|
} |
|
|
|
} |
|
|
|
// // 修改 |
|
|
|
// if (!toUpdate.isEmpty()) { |
|
|
|
// // 分批修改 |
|
|
|
// int batchSize = 50; // 假设每批100条记录 |
|
|
|
// for (int i = 0; i < toUpdate.size(); i += batchSize) { |
|
|
|
// int end = Math.min(i + batchSize, toUpdate.size()); |
|
|
|
// List<WorkCenterCost> subList = toUpdate.subList(i, end); |
|
|
|
// routingManagementMapper.syncUpdateWorkCenterCost(subList); |
|
|
|
// } |
|
|
|
// } |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
|