|
|
|
@ -5126,115 +5126,133 @@ public class QcServiceImpl implements QcService { |
|
|
|
throw new RuntimeException("数据采集失败(未获取到检验单信息)!"); |
|
|
|
} |
|
|
|
|
|
|
|
List<SubDetailValues> subDetailList = new LinkedList<>(); |
|
|
|
List<SysOssEntity> fileList = new ArrayList<>(); |
|
|
|
for (EquipmentDataAcquisitionData acquisitionData : noList) { |
|
|
|
// 查检验项目的过滤条件 |
|
|
|
SubDetailValues values = new SubDetailValues(); |
|
|
|
values.setSite(acquisitionData.getSite()); |
|
|
|
values.setBuNo(acquisitionData.getBuNo()); |
|
|
|
values.setItemNo(acquisitionData.getItemNo()); |
|
|
|
String collectionDataContent = qcMapper.getItemCollectionDataContent(values); |
|
|
|
// 临时对象 |
|
|
|
EquipmentDataAcquisitionData tempAcquisitionData = new EquipmentDataAcquisitionData(); |
|
|
|
BeanUtils.copyProperties(acquisitionData,tempAcquisitionData); |
|
|
|
tempAcquisitionData.setCollectionDataContent(collectionDataContent); |
|
|
|
// 循环数据采集来源 |
|
|
|
int type = 0; |
|
|
|
for (int i = 0; i < acquisitionData.getCollectionSource().split(",").length; i++) { |
|
|
|
// 数据采集来源 |
|
|
|
tempAcquisitionData.setCollectionSource(acquisitionData.getCollectionSource().split(",")[i]); |
|
|
|
// 数据采集方式 |
|
|
|
if (tempAcquisitionData.getCollectionSource().startsWith("value")) { // 如果采集来源是以"value"开头则采集方式使用文件数据采集(file) |
|
|
|
if (tempAcquisitionData.getCollectionMethod().contains("plc")) { |
|
|
|
tempAcquisitionData.setCollectionMethod("plc"); |
|
|
|
} else if (tempAcquisitionData.getCollectionMethod().contains("RS232")) { |
|
|
|
tempAcquisitionData.setCollectionMethod("RS232"); |
|
|
|
} else { |
|
|
|
tempAcquisitionData.setCollectionMethod("file"); |
|
|
|
} |
|
|
|
} else if ("photo_value1".equals(tempAcquisitionData.getCollectionSource())){ // // 如果采集来源是"photo_value1"开头则采集方式使用文件数据采集(image) |
|
|
|
tempAcquisitionData.setCollectionMethod("image"); |
|
|
|
} else if ("file_value1".equals(tempAcquisitionData.getCollectionSource())){ // // 如果采集来源是"file_value1"开头则采集方式使用文件数据采集(fileUrl) |
|
|
|
tempAcquisitionData.setCollectionMethod("fileUrl"); |
|
|
|
} |
|
|
|
// 设备号 |
|
|
|
tempAcquisitionData.setEquipmentNo(acquisitionData.getEquipmentNo()); |
|
|
|
if ("file".equals(tempAcquisitionData.getCollectionMethod()) || "plc".equals(tempAcquisitionData.getCollectionMethod()) || "RS232".equals(tempAcquisitionData.getCollectionMethod())) { |
|
|
|
// 文件数据采集 |
|
|
|
if (tempAcquisitionData.getCollectionSource().startsWith("value")) { |
|
|
|
tempAcquisitionData.setSubDetailValueType(type); |
|
|
|
type++; |
|
|
|
} |
|
|
|
List<SubDetailValues> dataList = qcMapper.dataAcquisition(tempAcquisitionData); |
|
|
|
subDetailList.addAll(dataList); |
|
|
|
} else if ("image".equals(tempAcquisitionData.getCollectionMethod()) || "fileUrl".equals(tempAcquisitionData.getCollectionMethod())) { |
|
|
|
// 图片采集 |
|
|
|
List<SysOssEntity> dataList2 = qcMapper.dataAcquisition2(tempAcquisitionData); |
|
|
|
List<SysOssEntity> collect = dataList2.stream().map(a -> { |
|
|
|
a.setFileName(a.getUrl().split("\\$")[1]); |
|
|
|
a.setNewFileName(a.getUrl().split("\\\\")[a.getUrl().split("\\\\").length-1]); |
|
|
|
return a; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
fileList.addAll(collect); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (subDetailList.isEmpty()) { |
|
|
|
throw new RuntimeException("未采集到数据信息!"); |
|
|
|
} |
|
|
|
|
|
|
|
// 整合实测值A和实测值B |
|
|
|
List<SubDetailValues> groupCannotBeEmpty = subDetailList.stream() |
|
|
|
.collect(Collectors.groupingBy(a -> new AbstractMap.SimpleEntry<>(a.getItemNo(), a.getNum()))) |
|
|
|
.values().stream() |
|
|
|
.map(userList -> userList.stream() |
|
|
|
.reduce((u1, u2) -> { |
|
|
|
SubDetailValues result = new SubDetailValues(data.getSite(), data.getBuNo(), data.getInspectionNo(), u1.getItemNo(), u1.getNum(), |
|
|
|
u1.getSubDetailValue() != null ? u1.getSubDetailValue() : u2.getSubDetailValue(), |
|
|
|
u1.getSubDetailValueB() != null ? u1.getSubDetailValueB() : u2.getSubDetailValueB(), |
|
|
|
u1.getSubDetailValueC() != null ? u1.getSubDetailValueC() : u2.getSubDetailValueC(), |
|
|
|
u1.getSubDetailValueD() != null ? u1.getSubDetailValueD() : u2.getSubDetailValueD(), |
|
|
|
u1.getSubDetailValueE() != null ? u1.getSubDetailValueE() : u2.getSubDetailValueE()); |
|
|
|
return result; |
|
|
|
}) |
|
|
|
.orElseThrow(() -> new IllegalStateException("Group cannot be empty"))) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
// 分批插入 |
|
|
|
int batchSize = 150; // 假设每批200条记录 |
|
|
|
for (int i = 0; i < groupCannotBeEmpty.size(); i += batchSize) { |
|
|
|
int end = Math.min(i + batchSize, groupCannotBeEmpty.size()); |
|
|
|
List<SubDetailValues> subList = groupCannotBeEmpty.subList(i, end); |
|
|
|
// 新增数据采集信息 |
|
|
|
if ("iqc".equals(data.getFlag())) { |
|
|
|
qcMapper.saveIQCSubDetailed(subList); |
|
|
|
} else if ("ipqc".equals(data.getFlag())) { |
|
|
|
qcMapper.saveIPQCSubDetailed(subList); |
|
|
|
} else if ("fqc".equals(data.getFlag())) { |
|
|
|
qcMapper.saveFQCSubDetailed(subList); |
|
|
|
} else if ("fai".equals(data.getFlag())) { |
|
|
|
qcMapper.saveFAISubDetailed(subList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 新增图片采集信息 |
|
|
|
if (!fileList.isEmpty()) { |
|
|
|
int batchSize2 = 150; |
|
|
|
for (int i = 0; i < fileList.size(); i += batchSize2) { |
|
|
|
int end = Math.min(i + batchSize2, fileList.size()); |
|
|
|
List<SysOssEntity> subFileList = fileList.subList(i, end); |
|
|
|
qcMapper.saveFileList(subFileList); |
|
|
|
// 调用存储过程 |
|
|
|
List<Object> params = new ArrayList<>(); |
|
|
|
params.add(acquisitionData.getSite()); |
|
|
|
params.add(acquisitionData.getBuNo()); |
|
|
|
params.add(acquisitionData.getInspectionNo()); |
|
|
|
params.add(acquisitionData.getItemNo()); |
|
|
|
params.add(data.getFlag()); |
|
|
|
//执行方法 |
|
|
|
List<Map<String, Object>> resultList = procedureDao.getProcedureData("Get_inspection_detail", params); |
|
|
|
//判断是否检验成功 |
|
|
|
String code = String.valueOf(resultList.get(0).get("code")); |
|
|
|
if ("400".equalsIgnoreCase(code)) { |
|
|
|
String msg = String.valueOf(resultList.get(0).get("message")); |
|
|
|
throw new XJException(msg, Integer.parseInt(code)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 修改数据采集方式为 "RS232" 的 inspectionNo |
|
|
|
List<SubDetailValues> rsList = subDetailList.stream().filter(a -> "RS232".equals(a.getCollectionMethod())).collect(Collectors.toList()); |
|
|
|
if (!rsList.isEmpty()) { |
|
|
|
for (SubDetailValues detailValues : rsList) { |
|
|
|
qcMapper.updateEquipmentDataDetailInspectionNo(detailValues); |
|
|
|
} |
|
|
|
} |
|
|
|
// List<SubDetailValues> subDetailList = new LinkedList<>(); |
|
|
|
// List<SysOssEntity> fileList = new ArrayList<>(); |
|
|
|
// for (EquipmentDataAcquisitionData acquisitionData : noList) { |
|
|
|
// // 查检验项目的过滤条件 |
|
|
|
// SubDetailValues values = new SubDetailValues(); |
|
|
|
// values.setSite(acquisitionData.getSite()); |
|
|
|
// values.setBuNo(acquisitionData.getBuNo()); |
|
|
|
// values.setItemNo(acquisitionData.getItemNo()); |
|
|
|
// String collectionDataContent = qcMapper.getItemCollectionDataContent(values); |
|
|
|
// // 临时对象 |
|
|
|
// EquipmentDataAcquisitionData tempAcquisitionData = new EquipmentDataAcquisitionData(); |
|
|
|
// BeanUtils.copyProperties(acquisitionData,tempAcquisitionData); |
|
|
|
// tempAcquisitionData.setCollectionDataContent(collectionDataContent); |
|
|
|
// // 循环数据采集来源 |
|
|
|
// int type = 0; |
|
|
|
// for (int i = 0; i < acquisitionData.getCollectionSource().split(",").length; i++) { |
|
|
|
// // 数据采集来源 |
|
|
|
// tempAcquisitionData.setCollectionSource(acquisitionData.getCollectionSource().split(",")[i]); |
|
|
|
// // 数据采集方式 |
|
|
|
// if (tempAcquisitionData.getCollectionSource().startsWith("value")) { // 如果采集来源是以"value"开头则采集方式使用文件数据采集(file) |
|
|
|
// if (tempAcquisitionData.getCollectionMethod().contains("plc")) { |
|
|
|
// tempAcquisitionData.setCollectionMethod("plc"); |
|
|
|
// } else if (tempAcquisitionData.getCollectionMethod().contains("RS232")) { |
|
|
|
// tempAcquisitionData.setCollectionMethod("RS232"); |
|
|
|
// } else { |
|
|
|
// tempAcquisitionData.setCollectionMethod("file"); |
|
|
|
// } |
|
|
|
// } else if ("photo_value1".equals(tempAcquisitionData.getCollectionSource())){ // // 如果采集来源是"photo_value1"开头则采集方式使用文件数据采集(image) |
|
|
|
// tempAcquisitionData.setCollectionMethod("image"); |
|
|
|
// } else if ("file_value1".equals(tempAcquisitionData.getCollectionSource())){ // // 如果采集来源是"file_value1"开头则采集方式使用文件数据采集(fileUrl) |
|
|
|
// tempAcquisitionData.setCollectionMethod("fileUrl"); |
|
|
|
// } |
|
|
|
// // 设备号 |
|
|
|
// tempAcquisitionData.setEquipmentNo(acquisitionData.getEquipmentNo()); |
|
|
|
// if ("file".equals(tempAcquisitionData.getCollectionMethod()) || "plc".equals(tempAcquisitionData.getCollectionMethod()) || "RS232".equals(tempAcquisitionData.getCollectionMethod())) { |
|
|
|
// // 文件数据采集 |
|
|
|
// if (tempAcquisitionData.getCollectionSource().startsWith("value")) { |
|
|
|
// tempAcquisitionData.setSubDetailValueType(type); |
|
|
|
// type++; |
|
|
|
// } |
|
|
|
// List<SubDetailValues> dataList = qcMapper.dataAcquisition(tempAcquisitionData); |
|
|
|
// subDetailList.addAll(dataList); |
|
|
|
// } else if ("image".equals(tempAcquisitionData.getCollectionMethod()) || "fileUrl".equals(tempAcquisitionData.getCollectionMethod())) { |
|
|
|
// // 图片采集 |
|
|
|
// List<SysOssEntity> dataList2 = qcMapper.dataAcquisition2(tempAcquisitionData); |
|
|
|
// List<SysOssEntity> collect = dataList2.stream().map(a -> { |
|
|
|
// a.setFileName(a.getUrl().split("\\$")[1]); |
|
|
|
// a.setNewFileName(a.getUrl().split("\\\\")[a.getUrl().split("\\\\").length-1]); |
|
|
|
// return a; |
|
|
|
// }).collect(Collectors.toList()); |
|
|
|
// fileList.addAll(collect); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
// if (subDetailList.isEmpty()) { |
|
|
|
// throw new RuntimeException("未采集到数据信息!"); |
|
|
|
// } |
|
|
|
// |
|
|
|
// // 整合实测值A和实测值B |
|
|
|
// List<SubDetailValues> groupCannotBeEmpty = subDetailList.stream() |
|
|
|
// .collect(Collectors.groupingBy(a -> new AbstractMap.SimpleEntry<>(a.getItemNo(), a.getNum()))) |
|
|
|
// .values().stream() |
|
|
|
// .map(userList -> userList.stream() |
|
|
|
// .reduce((u1, u2) -> { |
|
|
|
// SubDetailValues result = new SubDetailValues(data.getSite(), data.getBuNo(), data.getInspectionNo(), u1.getItemNo(), u1.getNum(), |
|
|
|
// u1.getSubDetailValue() != null ? u1.getSubDetailValue() : u2.getSubDetailValue(), |
|
|
|
// u1.getSubDetailValueB() != null ? u1.getSubDetailValueB() : u2.getSubDetailValueB(), |
|
|
|
// u1.getSubDetailValueC() != null ? u1.getSubDetailValueC() : u2.getSubDetailValueC(), |
|
|
|
// u1.getSubDetailValueD() != null ? u1.getSubDetailValueD() : u2.getSubDetailValueD(), |
|
|
|
// u1.getSubDetailValueE() != null ? u1.getSubDetailValueE() : u2.getSubDetailValueE()); |
|
|
|
// return result; |
|
|
|
// }) |
|
|
|
// .orElseThrow(() -> new IllegalStateException("Group cannot be empty"))) |
|
|
|
// .collect(Collectors.toList()); |
|
|
|
// |
|
|
|
// // 分批插入 |
|
|
|
// int batchSize = 150; // 假设每批200条记录 |
|
|
|
// for (int i = 0; i < groupCannotBeEmpty.size(); i += batchSize) { |
|
|
|
// int end = Math.min(i + batchSize, groupCannotBeEmpty.size()); |
|
|
|
// List<SubDetailValues> subList = groupCannotBeEmpty.subList(i, end); |
|
|
|
// // 新增数据采集信息 |
|
|
|
// if ("iqc".equals(data.getFlag())) { |
|
|
|
// qcMapper.saveIQCSubDetailed(subList); |
|
|
|
// } else if ("ipqc".equals(data.getFlag())) { |
|
|
|
// qcMapper.saveIPQCSubDetailed(subList); |
|
|
|
// } else if ("fqc".equals(data.getFlag())) { |
|
|
|
// qcMapper.saveFQCSubDetailed(subList); |
|
|
|
// } else if ("fai".equals(data.getFlag())) { |
|
|
|
// qcMapper.saveFAISubDetailed(subList); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// |
|
|
|
// // 新增图片采集信息 |
|
|
|
// if (!fileList.isEmpty()) { |
|
|
|
// int batchSize2 = 150; |
|
|
|
// for (int i = 0; i < fileList.size(); i += batchSize2) { |
|
|
|
// int end = Math.min(i + batchSize2, fileList.size()); |
|
|
|
// List<SysOssEntity> subFileList = fileList.subList(i, end); |
|
|
|
// qcMapper.saveFileList(subFileList); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// |
|
|
|
// // 修改数据采集方式为 "RS232" 的 inspectionNo |
|
|
|
// List<SubDetailValues> rsList = subDetailList.stream().filter(a -> "RS232".equals(a.getCollectionMethod())).collect(Collectors.toList()); |
|
|
|
// if (!rsList.isEmpty()) { |
|
|
|
// for (SubDetailValues detailValues : rsList) { |
|
|
|
// qcMapper.updateEquipmentDataDetailInspectionNo(detailValues); |
|
|
|
// } |
|
|
|
// } |
|
|
|
|
|
|
|
// 判断是否合格 |
|
|
|
// 获取检验单使用的模板中的项目 |
|
|
|
@ -5318,116 +5336,135 @@ public class QcServiceImpl implements QcService { |
|
|
|
if (noList.isEmpty()) { |
|
|
|
throw new RuntimeException("数据采集失败(未获取到检验单信息)!"); |
|
|
|
} |
|
|
|
List<SubDetailValues> subDetailList = new LinkedList<>(); |
|
|
|
List<SysOssEntity> fileList = new ArrayList<>(); |
|
|
|
for (EquipmentDataAcquisitionData acquisitionData : noList) { |
|
|
|
// 查检验项目的过滤条件 |
|
|
|
SubDetailValues values = new SubDetailValues(); |
|
|
|
values.setSite(acquisitionData.getSite()); |
|
|
|
values.setBuNo(acquisitionData.getBuNo()); |
|
|
|
values.setItemNo(acquisitionData.getItemNo()); |
|
|
|
String collectionDataContent = qcMapper.getItemCollectionDataContent(values); |
|
|
|
// 临时对象 |
|
|
|
EquipmentDataAcquisitionData tempAcquisitionData = new EquipmentDataAcquisitionData(); |
|
|
|
BeanUtils.copyProperties(acquisitionData,tempAcquisitionData); |
|
|
|
tempAcquisitionData.setCollectionDataContent(collectionDataContent); |
|
|
|
// 循环数据采集来源 |
|
|
|
int type = 0; |
|
|
|
for (int i = 0; i < acquisitionData.getCollectionSource().split(",").length; i++) { |
|
|
|
// 数据采集来源 |
|
|
|
tempAcquisitionData.setCollectionSource(acquisitionData.getCollectionSource().split(",")[i]); |
|
|
|
// 数据采集方式 |
|
|
|
if (tempAcquisitionData.getCollectionSource().startsWith("value")) { // 如果采集来源是以"value"开头则采集方式使用文件数据采集(file) |
|
|
|
if (tempAcquisitionData.getCollectionMethod().contains("plc")) { |
|
|
|
tempAcquisitionData.setCollectionMethod("plc"); |
|
|
|
} else if (tempAcquisitionData.getCollectionMethod().contains("RS232")) { |
|
|
|
tempAcquisitionData.setCollectionMethod("RS232"); |
|
|
|
} else { |
|
|
|
tempAcquisitionData.setCollectionMethod("file"); |
|
|
|
} |
|
|
|
} else if ("photo_value1".equals(tempAcquisitionData.getCollectionSource())){ // // 如果采集来源是"photo_value1"开头则采集方式使用文件数据采集(image) |
|
|
|
tempAcquisitionData.setCollectionMethod("image"); |
|
|
|
} else if ("file_value1".equals(tempAcquisitionData.getCollectionSource())){ // // 如果采集来源是"file_value1"开头则采集方式使用文件数据采集(fileUrl) |
|
|
|
tempAcquisitionData.setCollectionMethod("fileUrl"); |
|
|
|
} |
|
|
|
// 设备号 |
|
|
|
tempAcquisitionData.setEquipmentNo(acquisitionData.getEquipmentNo()); |
|
|
|
if ("file".equals(tempAcquisitionData.getCollectionMethod()) || "plc".equals(tempAcquisitionData.getCollectionMethod()) || "RS232".equals(tempAcquisitionData.getCollectionMethod())) { |
|
|
|
// 文件数据采集 |
|
|
|
if (tempAcquisitionData.getCollectionSource().startsWith("value")) { |
|
|
|
tempAcquisitionData.setSubDetailValueType(type); |
|
|
|
type++; |
|
|
|
} |
|
|
|
List<SubDetailValues> dataList = qcMapper.dataAcquisition(tempAcquisitionData); |
|
|
|
subDetailList.addAll(dataList); |
|
|
|
} else if ("image".equals(tempAcquisitionData.getCollectionMethod()) || "fileUrl".equals(tempAcquisitionData.getCollectionMethod())) { |
|
|
|
// 图片采集 |
|
|
|
List<SysOssEntity> dataList2 = qcMapper.dataAcquisition2(tempAcquisitionData); |
|
|
|
List<SysOssEntity> collect = dataList2.stream().map(a -> { |
|
|
|
a.setFileName(a.getUrl().split("\\$")[1]); |
|
|
|
a.setNewFileName(a.getUrl().split("\\\\")[a.getUrl().split("\\\\").length-1]); |
|
|
|
return a; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
fileList.addAll(collect); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (subDetailList.isEmpty() && fileList.isEmpty()) { |
|
|
|
throw new RuntimeException("未采集到数据信息!"); |
|
|
|
} |
|
|
|
|
|
|
|
// 整合实测值A和实测值B |
|
|
|
List<SubDetailValues> groupCannotBeEmpty = subDetailList.stream() |
|
|
|
.collect(Collectors.groupingBy(a -> new AbstractMap.SimpleEntry<>(a.getItemNo(), a.getNum()))) |
|
|
|
.values().stream() |
|
|
|
.map(userList -> userList.stream() |
|
|
|
.reduce((u1, u2) -> { |
|
|
|
SubDetailValues result = new SubDetailValues(data.getSite(), data.getBuNo(), data.getInspectionNo(), u1.getItemNo(), u1.getNum(), |
|
|
|
u1.getSubDetailValue() != null ? u1.getSubDetailValue() : u2.getSubDetailValue(), |
|
|
|
u1.getSubDetailValueB() != null ? u1.getSubDetailValueB() : u2.getSubDetailValueB(), |
|
|
|
u1.getSubDetailValueC() != null ? u1.getSubDetailValueC() : u2.getSubDetailValueC(), |
|
|
|
u1.getSubDetailValueD() != null ? u1.getSubDetailValueD() : u2.getSubDetailValueD(), |
|
|
|
u1.getSubDetailValueE() != null ? u1.getSubDetailValueE() : u2.getSubDetailValueE()); |
|
|
|
return result; |
|
|
|
}) |
|
|
|
.orElseThrow(() -> new IllegalStateException("Group cannot be empty"))) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
// 分批插入 |
|
|
|
int batchSize = 150; // 假设每批150条记录 |
|
|
|
for (int i = 0; i < groupCannotBeEmpty.size(); i += batchSize) { |
|
|
|
int end = Math.min(i + batchSize, groupCannotBeEmpty.size()); |
|
|
|
List<SubDetailValues> subList = groupCannotBeEmpty.subList(i, end); |
|
|
|
// 新增数据采集信息 |
|
|
|
if ("iqc".equals(data.getFlag())) { |
|
|
|
qcMapper.saveIQCSubDetailed(subList); |
|
|
|
} else if ("ipqc".equals(data.getFlag())) { |
|
|
|
qcMapper.saveIPQCSubDetailed(subList); |
|
|
|
} else if ("fqc".equals(data.getFlag())) { |
|
|
|
qcMapper.saveFQCSubDetailed(subList); |
|
|
|
} else if ("fai".equals(data.getFlag())) { |
|
|
|
qcMapper.saveFAISubDetailed(subList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 新增图片采集信息 |
|
|
|
if (!fileList.isEmpty()) { |
|
|
|
int batchSize2 = 150; |
|
|
|
for (int i = 0; i < fileList.size(); i += batchSize2) { |
|
|
|
int end = Math.min(i + batchSize2, fileList.size()); |
|
|
|
List<SysOssEntity> subFileList = fileList.subList(i, end); |
|
|
|
qcMapper.saveFileList(subFileList); |
|
|
|
for (EquipmentDataAcquisitionData acquisitionData : noList) { |
|
|
|
// 调用存储过程 |
|
|
|
List<Object> params = new ArrayList<>(); |
|
|
|
params.add(acquisitionData.getSite()); |
|
|
|
params.add(acquisitionData.getBuNo()); |
|
|
|
params.add(acquisitionData.getInspectionNo()); |
|
|
|
params.add(acquisitionData.getItemNo()); |
|
|
|
params.add(data.getFlag()); |
|
|
|
//执行方法 |
|
|
|
List<Map<String, Object>> resultList = procedureDao.getProcedureData("Get_inspection_detail", params); |
|
|
|
//判断是否检验成功 |
|
|
|
String code = String.valueOf(resultList.get(0).get("code")); |
|
|
|
if ("400".equalsIgnoreCase(code)) { |
|
|
|
String msg = String.valueOf(resultList.get(0).get("message")); |
|
|
|
throw new XJException(msg, Integer.parseInt(code)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 修改数据采集方式为 "RS232" 的 inspectionNo |
|
|
|
List<SubDetailValues> rsList = subDetailList.stream().filter(a -> "RS232".equals(a.getCollectionMethod())).collect(Collectors.toList()); |
|
|
|
if (!rsList.isEmpty()) { |
|
|
|
for (SubDetailValues detailValues : rsList) { |
|
|
|
qcMapper.updateEquipmentDataDetailInspectionNo(detailValues); |
|
|
|
} |
|
|
|
} |
|
|
|
// List<SubDetailValues> subDetailList = new LinkedList<>(); |
|
|
|
// List<SysOssEntity> fileList = new ArrayList<>(); |
|
|
|
// for (EquipmentDataAcquisitionData acquisitionData : noList) { |
|
|
|
// // 查检验项目的过滤条件 |
|
|
|
// SubDetailValues values = new SubDetailValues(); |
|
|
|
// values.setSite(acquisitionData.getSite()); |
|
|
|
// values.setBuNo(acquisitionData.getBuNo()); |
|
|
|
// values.setItemNo(acquisitionData.getItemNo()); |
|
|
|
// String collectionDataContent = qcMapper.getItemCollectionDataContent(values); |
|
|
|
// // 临时对象 |
|
|
|
// EquipmentDataAcquisitionData tempAcquisitionData = new EquipmentDataAcquisitionData(); |
|
|
|
// BeanUtils.copyProperties(acquisitionData,tempAcquisitionData); |
|
|
|
// tempAcquisitionData.setCollectionDataContent(collectionDataContent); |
|
|
|
// // 循环数据采集来源 |
|
|
|
// int type = 0; |
|
|
|
// for (int i = 0; i < acquisitionData.getCollectionSource().split(",").length; i++) { |
|
|
|
// // 数据采集来源 |
|
|
|
// tempAcquisitionData.setCollectionSource(acquisitionData.getCollectionSource().split(",")[i]); |
|
|
|
// // 数据采集方式 |
|
|
|
// if (tempAcquisitionData.getCollectionSource().startsWith("value")) { // 如果采集来源是以"value"开头则采集方式使用文件数据采集(file) |
|
|
|
// if (tempAcquisitionData.getCollectionMethod().contains("plc")) { |
|
|
|
// tempAcquisitionData.setCollectionMethod("plc"); |
|
|
|
// } else if (tempAcquisitionData.getCollectionMethod().contains("RS232")) { |
|
|
|
// tempAcquisitionData.setCollectionMethod("RS232"); |
|
|
|
// } else { |
|
|
|
// tempAcquisitionData.setCollectionMethod("file"); |
|
|
|
// } |
|
|
|
// } else if ("photo_value1".equals(tempAcquisitionData.getCollectionSource())){ // // 如果采集来源是"photo_value1"开头则采集方式使用文件数据采集(image) |
|
|
|
// tempAcquisitionData.setCollectionMethod("image"); |
|
|
|
// } else if ("file_value1".equals(tempAcquisitionData.getCollectionSource())){ // // 如果采集来源是"file_value1"开头则采集方式使用文件数据采集(fileUrl) |
|
|
|
// tempAcquisitionData.setCollectionMethod("fileUrl"); |
|
|
|
// } |
|
|
|
// // 设备号 |
|
|
|
// tempAcquisitionData.setEquipmentNo(acquisitionData.getEquipmentNo()); |
|
|
|
// if ("file".equals(tempAcquisitionData.getCollectionMethod()) || "plc".equals(tempAcquisitionData.getCollectionMethod()) || "RS232".equals(tempAcquisitionData.getCollectionMethod())) { |
|
|
|
// // 文件数据采集 |
|
|
|
// if (tempAcquisitionData.getCollectionSource().startsWith("value")) { |
|
|
|
// tempAcquisitionData.setSubDetailValueType(type); |
|
|
|
// type++; |
|
|
|
// } |
|
|
|
// List<SubDetailValues> dataList = qcMapper.dataAcquisition(tempAcquisitionData); |
|
|
|
// subDetailList.addAll(dataList); |
|
|
|
// } else if ("image".equals(tempAcquisitionData.getCollectionMethod()) || "fileUrl".equals(tempAcquisitionData.getCollectionMethod())) { |
|
|
|
// // 图片采集 |
|
|
|
// List<SysOssEntity> dataList2 = qcMapper.dataAcquisition2(tempAcquisitionData); |
|
|
|
// List<SysOssEntity> collect = dataList2.stream().map(a -> { |
|
|
|
// a.setFileName(a.getUrl().split("\\$")[1]); |
|
|
|
// a.setNewFileName(a.getUrl().split("\\\\")[a.getUrl().split("\\\\").length-1]); |
|
|
|
// return a; |
|
|
|
// }).collect(Collectors.toList()); |
|
|
|
// fileList.addAll(collect); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// } |
|
|
|
// |
|
|
|
// if (subDetailList.isEmpty() && fileList.isEmpty()) { |
|
|
|
// throw new RuntimeException("未采集到数据信息!"); |
|
|
|
// } |
|
|
|
// |
|
|
|
// // 整合实测值A和实测值B |
|
|
|
// List<SubDetailValues> groupCannotBeEmpty = subDetailList.stream() |
|
|
|
// .collect(Collectors.groupingBy(a -> new AbstractMap.SimpleEntry<>(a.getItemNo(), a.getNum()))) |
|
|
|
// .values().stream() |
|
|
|
// .map(userList -> userList.stream() |
|
|
|
// .reduce((u1, u2) -> { |
|
|
|
// SubDetailValues result = new SubDetailValues(data.getSite(), data.getBuNo(), data.getInspectionNo(), u1.getItemNo(), u1.getNum(), |
|
|
|
// u1.getSubDetailValue() != null ? u1.getSubDetailValue() : u2.getSubDetailValue(), |
|
|
|
// u1.getSubDetailValueB() != null ? u1.getSubDetailValueB() : u2.getSubDetailValueB(), |
|
|
|
// u1.getSubDetailValueC() != null ? u1.getSubDetailValueC() : u2.getSubDetailValueC(), |
|
|
|
// u1.getSubDetailValueD() != null ? u1.getSubDetailValueD() : u2.getSubDetailValueD(), |
|
|
|
// u1.getSubDetailValueE() != null ? u1.getSubDetailValueE() : u2.getSubDetailValueE()); |
|
|
|
// return result; |
|
|
|
// }) |
|
|
|
// .orElseThrow(() -> new IllegalStateException("Group cannot be empty"))) |
|
|
|
// .collect(Collectors.toList()); |
|
|
|
// |
|
|
|
// // 分批插入 |
|
|
|
// int batchSize = 150; // 假设每批150条记录 |
|
|
|
// for (int i = 0; i < groupCannotBeEmpty.size(); i += batchSize) { |
|
|
|
// int end = Math.min(i + batchSize, groupCannotBeEmpty.size()); |
|
|
|
// List<SubDetailValues> subList = groupCannotBeEmpty.subList(i, end); |
|
|
|
// // 新增数据采集信息 |
|
|
|
// if ("iqc".equals(data.getFlag())) { |
|
|
|
// qcMapper.saveIQCSubDetailed(subList); |
|
|
|
// } else if ("ipqc".equals(data.getFlag())) { |
|
|
|
// qcMapper.saveIPQCSubDetailed(subList); |
|
|
|
// } else if ("fqc".equals(data.getFlag())) { |
|
|
|
// qcMapper.saveFQCSubDetailed(subList); |
|
|
|
// } else if ("fai".equals(data.getFlag())) { |
|
|
|
// qcMapper.saveFAISubDetailed(subList); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// |
|
|
|
// // 新增图片采集信息 |
|
|
|
// if (!fileList.isEmpty()) { |
|
|
|
// int batchSize2 = 150; |
|
|
|
// for (int i = 0; i < fileList.size(); i += batchSize2) { |
|
|
|
// int end = Math.min(i + batchSize2, fileList.size()); |
|
|
|
// List<SysOssEntity> subFileList = fileList.subList(i, end); |
|
|
|
// qcMapper.saveFileList(subFileList); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// |
|
|
|
// // 修改数据采集方式为 "RS232" 的 inspectionNo |
|
|
|
// List<SubDetailValues> rsList = subDetailList.stream().filter(a -> "RS232".equals(a.getCollectionMethod())).collect(Collectors.toList()); |
|
|
|
// if (!rsList.isEmpty()) { |
|
|
|
// for (SubDetailValues detailValues : rsList) { |
|
|
|
// qcMapper.updateEquipmentDataDetailInspectionNo(detailValues); |
|
|
|
// } |
|
|
|
// } |
|
|
|
|
|
|
|
QcInspectionStandardData templateDetail = new QcInspectionStandardData(); |
|
|
|
templateDetail.setSite(data.getSite()); |
|
|
|
|