|
@@ -204,7 +204,12 @@ public class TrialSummaryController {
|
|
|
if (records.size() <= 0) {
|
|
|
throw new ServiceException("未获取到该报告时间段范围内的试验自检记录信息,操作失败");
|
|
|
}
|
|
|
- List<Long> recordIds = records.stream().map(TrialSelfInspectionRecord::getId).collect(Collectors.toList());
|
|
|
+ List<Long> recordIds = new ArrayList<>();
|
|
|
+ Map<Long, Integer> sortMap = new HashMap<>();
|
|
|
+ for (int i = 0; i < records.size(); i++) {
|
|
|
+ sortMap.put(records.get(i).getId(), i);
|
|
|
+ recordIds.add(records.get(i).getId());
|
|
|
+ }
|
|
|
|
|
|
String sql_2 = "SELECT * FROM m_trial_summary_excel_tab_reflection WHERE excel_id = ? AND class_id = ?";
|
|
|
List<TrialSummaryExcelTabReflection> excelTabReflections = jdbcTemplate.query(sql_2,
|
|
@@ -232,96 +237,107 @@ public class TrialSummaryController {
|
|
|
tabDataList = new ArrayList<>();
|
|
|
}
|
|
|
} else {
|
|
|
- String sql_3 = "SELECT " + String.join(",", elementKeys) + " FROM " + tabName + " WHERE p_key_id = " + tabPkeyId + " AND group_id in(" + StringUtils.join(recordIds, ",") + ")";
|
|
|
+ String sql_3 = "SELECT " + String.join(",", elementKeys) + " ,group_id FROM " + tabName + " WHERE p_key_id = " + tabPkeyId + " AND group_id in(" + StringUtils.join(recordIds, ",") + ")";
|
|
|
tabDataList = jdbcTemplate.queryForList(sql_3);
|
|
|
}
|
|
|
if (tabDataList.isEmpty()) {
|
|
|
continue;
|
|
|
}
|
|
|
-
|
|
|
+ Map<String, List<Map<String, Object>>> dataGroupMap = tabDataList.stream().collect(Collectors.groupingBy(data -> data.get("group_id") + ""));
|
|
|
+ List<String> list = tabDataList.stream().map(data -> data.get("group_id") + "").sorted((o1, o2) -> {
|
|
|
+ int i = sortMap.get(Long.parseLong(o1));
|
|
|
+ int j = sortMap.get(Long.parseLong(o2));
|
|
|
+ return Integer.compare(i, j);
|
|
|
+ }).collect(Collectors.toList());
|
|
|
for (String elementKey : elementKeys) {
|
|
|
- for (Map<String, Object> stringObjectMap : tabDataList) {
|
|
|
- stringObjectMap.entrySet().removeIf(obj -> obj.getValue() == null || obj.getValue().equals(""));
|
|
|
- Object tabData = stringObjectMap.getOrDefault(elementKey, null);
|
|
|
- if (ObjectUtil.isEmpty(tabData)) {
|
|
|
+ for (String key : list) {
|
|
|
+ List<Map<String, Object>> dataList = dataGroupMap.get(key);
|
|
|
+ if (dataList == null || dataList.isEmpty()) {
|
|
|
continue;
|
|
|
}
|
|
|
-
|
|
|
- String tabDataStr = (String) tabData;
|
|
|
- //跨行
|
|
|
- if (tabDataStr.contains("☆")) {
|
|
|
- String[] split = tabDataStr.split("☆");
|
|
|
- for (String valueRow : split) {
|
|
|
- String[] splitValues = valueRow.split(Pattern.quote("_^_"));
|
|
|
- String valueInput = splitValues[0];
|
|
|
- /*String indexKey = splitValues[1];*/
|
|
|
- String keyName = elementKey + "__" + tabPkeyId;
|
|
|
-
|
|
|
- if (map.containsKey(keyName)) {
|
|
|
- String existingValue = (String) map.get(keyName);
|
|
|
- map.put(keyName, existingValue + "@@@###" + valueInput);
|
|
|
- } else {
|
|
|
- map.put(keyName, valueInput);
|
|
|
- }
|
|
|
+ for (Map<String, Object> stringObjectMap : dataList) {
|
|
|
+ stringObjectMap.entrySet().removeIf(obj -> obj.getValue() == null || obj.getValue().equals(""));
|
|
|
+ Object tabData = stringObjectMap.getOrDefault(elementKey, null);
|
|
|
+ if (ObjectUtil.isEmpty(tabData)) {
|
|
|
+ continue;
|
|
|
}
|
|
|
|
|
|
- } else {
|
|
|
- //非跨行
|
|
|
- if (tabDataStr.contains(".000Z]") && tabDataStr.contains("T")) {
|
|
|
- String[] splitValues = tabDataStr.split(Pattern.quote("_^_"));
|
|
|
- String valueInput = splitValues[0];
|
|
|
- /*String indexKey = splitValues[1];*/
|
|
|
- String keyName = elementKey + "__" + tabPkeyId;
|
|
|
-
|
|
|
- //范围日期
|
|
|
- String[] split = valueInput.split(",");
|
|
|
- String date_1 = split[0].trim();
|
|
|
- String date_2 = split[1].trim();
|
|
|
- LocalDateTime startTime = LocalDateTime.parse(date_1, DateTimeFormatter.ISO_DATE_TIME);
|
|
|
- LocalDateTime endTime = LocalDateTime.parse(date_2, DateTimeFormatter.ISO_DATE_TIME);
|
|
|
- ZonedDateTime startZonedTime = startTime.atZone(ZoneId.of("UTC"));
|
|
|
- ZonedDateTime endZonedTime = endTime.atZone(ZoneId.of("UTC"));
|
|
|
- String time_1 = startZonedTime.format(DateTimeFormatter.ISO_DATE_TIME);
|
|
|
- String time_2 = endZonedTime.format(DateTimeFormatter.ISO_DATE_TIME);
|
|
|
-
|
|
|
- if (map.containsKey(keyName)) {
|
|
|
- String existingValue = (String) map.get(keyName);
|
|
|
- map.put(keyName, existingValue + "@@@###" + time_1 + "~" + time_2);
|
|
|
- } else {
|
|
|
- map.put(keyName, time_1 + "~" + time_2);
|
|
|
+ String tabDataStr = (String) tabData;
|
|
|
+ //跨行
|
|
|
+ if (tabDataStr.contains("☆")) {
|
|
|
+ String[] split = tabDataStr.split("☆");
|
|
|
+ for (String valueRow : split) {
|
|
|
+ String[] splitValues = valueRow.split(Pattern.quote("_^_"));
|
|
|
+ String valueInput = splitValues[0];
|
|
|
+ /*String indexKey = splitValues[1];*/
|
|
|
+ String keyName = elementKey + "__" + tabPkeyId;
|
|
|
+
|
|
|
+ if (map.containsKey(keyName)) {
|
|
|
+ String existingValue = (String) map.get(keyName);
|
|
|
+ map.put(keyName, existingValue + "@@@###" + valueInput);
|
|
|
+ } else {
|
|
|
+ map.put(keyName, valueInput);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- } else if (tabDataStr.contains(".000Z") && tabDataStr.contains("T")) {
|
|
|
- String[] splitValues = tabDataStr.split(Pattern.quote("_^_"));
|
|
|
- String valueInput = splitValues[0];
|
|
|
- /*String indexKey = splitValues[1];*/
|
|
|
- String keyName = elementKey + "__" + tabPkeyId;
|
|
|
+ } else {
|
|
|
+ //非跨行
|
|
|
+ if (tabDataStr.contains(".000Z]") && tabDataStr.contains("T")) {
|
|
|
+ String[] splitValues = tabDataStr.split(Pattern.quote("_^_"));
|
|
|
+ String valueInput = splitValues[0];
|
|
|
+ /*String indexKey = splitValues[1];*/
|
|
|
+ String keyName = elementKey + "__" + tabPkeyId;
|
|
|
+
|
|
|
+ //范围日期
|
|
|
+ String[] split = valueInput.split(",");
|
|
|
+ String date_1 = split[0].trim();
|
|
|
+ String date_2 = split[1].trim();
|
|
|
+ LocalDateTime startTime = LocalDateTime.parse(date_1, DateTimeFormatter.ISO_DATE_TIME);
|
|
|
+ LocalDateTime endTime = LocalDateTime.parse(date_2, DateTimeFormatter.ISO_DATE_TIME);
|
|
|
+ ZonedDateTime startZonedTime = startTime.atZone(ZoneId.of("UTC"));
|
|
|
+ ZonedDateTime endZonedTime = endTime.atZone(ZoneId.of("UTC"));
|
|
|
+ String time_1 = startZonedTime.format(DateTimeFormatter.ISO_DATE_TIME);
|
|
|
+ String time_2 = endZonedTime.format(DateTimeFormatter.ISO_DATE_TIME);
|
|
|
+
|
|
|
+ if (map.containsKey(keyName)) {
|
|
|
+ String existingValue = (String) map.get(keyName);
|
|
|
+ map.put(keyName, existingValue + "@@@###" + time_1 + "~" + time_2);
|
|
|
+ } else {
|
|
|
+ map.put(keyName, time_1 + "~" + time_2);
|
|
|
+ }
|
|
|
|
|
|
- //单日期
|
|
|
- LocalDateTime time = LocalDateTime.parse(valueInput, DateTimeFormatter.ISO_DATE_TIME);
|
|
|
- ZonedDateTime zonedDateTime = time.atZone(ZoneId.of("UTC"));
|
|
|
- String timeStr = zonedDateTime.format(DateTimeFormatter.ISO_DATE_TIME);
|
|
|
+ } else if (tabDataStr.contains(".000Z") && tabDataStr.contains("T")) {
|
|
|
+ String[] splitValues = tabDataStr.split(Pattern.quote("_^_"));
|
|
|
+ String valueInput = splitValues[0];
|
|
|
+ /*String indexKey = splitValues[1];*/
|
|
|
+ String keyName = elementKey + "__" + tabPkeyId;
|
|
|
+
|
|
|
+ //单日期
|
|
|
+ LocalDateTime time = LocalDateTime.parse(valueInput, DateTimeFormatter.ISO_DATE_TIME);
|
|
|
+ ZonedDateTime zonedDateTime = time.atZone(ZoneId.of("UTC"));
|
|
|
+ String timeStr = zonedDateTime.format(DateTimeFormatter.ISO_DATE_TIME);
|
|
|
+
|
|
|
+ if (map.containsKey(keyName)) {
|
|
|
+ String existingValue = (String) map.get(keyName);
|
|
|
+ map.put(keyName, existingValue + "@@@###" + timeStr);
|
|
|
+ } else {
|
|
|
+ map.put(keyName, timeStr);
|
|
|
+ }
|
|
|
|
|
|
- if (map.containsKey(keyName)) {
|
|
|
- String existingValue = (String) map.get(keyName);
|
|
|
- map.put(keyName, existingValue + "@@@###" + timeStr);
|
|
|
} else {
|
|
|
- map.put(keyName, timeStr);
|
|
|
- }
|
|
|
+ String[] splitValues = tabDataStr.split(Pattern.quote("_^_"));
|
|
|
+ String valueInput = splitValues[0];
|
|
|
+ /*String indexKey = splitValues[1];*/
|
|
|
+ String keyName = elementKey + "__" + tabPkeyId;
|
|
|
+
|
|
|
+ if (map.containsKey(keyName)) {
|
|
|
+ String existingValue = (String) map.get(keyName);
|
|
|
+ map.put(keyName, existingValue + "@@@###" + valueInput);
|
|
|
+ } else {
|
|
|
+ map.put(keyName, valueInput);
|
|
|
+ }
|
|
|
|
|
|
- } else {
|
|
|
- String[] splitValues = tabDataStr.split(Pattern.quote("_^_"));
|
|
|
- String valueInput = splitValues[0];
|
|
|
- /*String indexKey = splitValues[1];*/
|
|
|
- String keyName = elementKey + "__" + tabPkeyId;
|
|
|
-
|
|
|
- if (map.containsKey(keyName)) {
|
|
|
- String existingValue = (String) map.get(keyName);
|
|
|
- map.put(keyName, existingValue + "@@@###" + valueInput);
|
|
|
- } else {
|
|
|
- map.put(keyName, valueInput);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
}
|