From 444409ba734d4457f9109f0b71422b83fed60cd6 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期四, 24 九月 2026 11:14:20 +0800
Subject: [PATCH] refactor(inspect): 重构设备列表查询和报告生成逻辑
---
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java | 574 +++++++++++++++++++++++++++++++++++++++------------------
1 files changed, 391 insertions(+), 183 deletions(-)
diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java
index c9d4bb2..3394113 100644
--- a/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java
@@ -46,6 +46,7 @@
import com.ruoyi.inspect.service.*;
import com.ruoyi.inspect.util.HackLoopTableRenderPolicy;
import com.ruoyi.inspect.util.PreserveReportPicturePlaceholderHandler;
+import com.ruoyi.inspect.util.ReportSignaturePictureUtils;
import com.ruoyi.inspect.vo.InsOrderPlanTaskSwitchVo;
import com.ruoyi.inspect.vo.InsOrderPlanVO;
import com.ruoyi.inspect.vo.InsSampleUserVO;
@@ -74,6 +75,7 @@
import java.nio.file.Paths;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
+import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
@@ -178,8 +180,12 @@
String userName = null;
Integer userId = null;
if (ObjectUtil.isNotEmpty(insOrderPlanDTO.getUserId())) {
- userId = SecurityUtils.getUserId().intValue();
- userName = userMapper.selectById(userId).getName();
+ Integer currentUserId = SecurityUtils.getUserId().intValue();
+ // 绠$悊鍛樺彲浠ユ煡鐪嬪苟澶嶆牳鍏ㄩ儴寰呭鏍镐换鍔★紝鏅�氱敤鎴蜂粛鍙煡鐪嬪垎閰嶇粰鑷繁鐨勪换鍔°��
+ if (!SecurityUtils.isAdmin(currentUserId.longValue())) {
+ userId = currentUserId;
+ userName = userMapper.selectById(userId).getName();
+ }
insOrderPlanDTO.setUserId(null);
}
Integer isCheck = insOrderPlanDTO.getIsCheck();
@@ -269,11 +275,11 @@
// 鏌ヨ璁㈠崟Id
InsOrder order = insOrderMapper.selectFirstSubmit(dto.getId());
if (order == null) {
- return BeanUtil.isEmpty(insProducts) ? null : insProducts;
+ return BeanUtil.isEmpty(insProducts) ? Collections.emptyList() : insProducts;
}
insProducts = mergeDirectTemplateSnapshots(order, dto.getId(), dto.getLaboratory(), insProducts);
if (BeanUtil.isEmpty(insProducts)) {
- return null;
+ return Collections.emptyList();
}
getTemplateThing(order, insProducts, dto.getLaboratory());
return insProducts;
@@ -295,14 +301,6 @@
if (snapshots.isEmpty()) {
return source;
}
- InsSample sample = insSampleMapper.selectById(sampleId);
- boolean directTemplateOrder = source.stream()
- .anyMatch(product -> product.getTemplateRowIndex() != null)
- || isDirectTemplateSample(order, sample);
- if (!directTemplateOrder) {
- return source;
- }
-
Map<Integer, List<InsProduct>> productsByTemplate = source.stream()
.filter(product -> product.getTemplateId() != null)
.collect(Collectors.groupingBy(InsProduct::getTemplateId, LinkedHashMap::new, Collectors.toList()));
@@ -745,18 +743,9 @@
} catch (Exception ignored) {
thing = compressedThing;
}
- JSONArray cellData = JSON.parseObject(thing).getJSONArray("data").getJSONObject(0).getJSONArray("celldata");
+ JSONObject sheet = JSON.parseObject(thing).getJSONArray("data").getJSONObject(0);
+ JSONArray cellData = sheet.getJSONArray("celldata");
NavigableMap<Integer, List<String>> result = new TreeMap<>();
- Integer inspectionResultColumn = null;
- for (Object item : cellData) {
- JSONObject cell = JSON.parseObject(JSON.toJSONString(item));
- Integer column = cell.getInteger("c");
- JSONObject value = cell.getJSONObject("v");
- String displayValue = value == null ? null : value.getString("v");
- if (inspectionResultColumn == null && "妫�楠岀粨鏋�".equals(StringUtils.trim(displayValue))) {
- inspectionResultColumn = column;
- }
- }
for (Object item : cellData) {
JSONObject cell = JSON.parseObject(JSON.toJSONString(item));
JSONObject value = cell.getJSONObject("v");
@@ -767,16 +756,119 @@
Integer row = cell.getInteger("r");
Integer column = cell.getInteger("c");
if (row != null && column != null) {
- // 鈥滃鍑哄�尖�濇爣鍦ㄦ娴嬮」鐩爣棰樺崟鍏冩牸鏃讹紝鐪熸瀵煎嚭鐨勫�兼槸鍚屼竴琛屸�滄楠岀粨鏋溾�濆垪鐨勫崟鍏冩牸銆�
- String coordinate = row + "-" + column;
- String resultCoordinate = row + "-" + inspectionResultColumn;
- if (inspectionResultColumn != null && !Objects.equals(column, inspectionResultColumn)) {
- coordinate = resultCoordinate;
- }
+ // 鎵规敞鍗曞厓鏍煎彲鑳芥í鍚戝悎骞讹紝鍙充晶缁撴灉鍗曞厓鏍间篃鍙兘绾靛悜鍚堝苟锛涙渶缁堣鍙栫粨鏋滃尯鍩熺殑宸︿笂瑙掑瓨鍌ㄥ潗鏍囥��
+ String coordinate = getRightAdjacentCoordinate(sheet, row, column);
result.computeIfAbsent(row, ignored -> new ArrayList<>()).add(coordinate);
}
}
return result;
+ }
+
+ /**
+ * 杩斿洖鎸囧畾鍗曞厓鏍硷紙鎴栧叾鎵�鍦ㄥ悎骞跺尯鍩燂級鍙充晶绱ч偦鍒楃殑涓嬫爣銆�
+ * Luckysheet 鐨勫悎骞朵俊鎭�氬父淇濆瓨鍦� config.merge锛涢儴鍒嗗巻鍙叉ā鏉垮彧鍦ㄥ崟鍏冩牸 v.mc 涓繚鐣欙紝
+ * 鍥犳涓ょ缁撴瀯閮借鍏煎銆�
+ */
+ private int getRightAdjacentColumn(JSONObject sheet, int row, int column) {
+ int rightEdge = column;
+ JSONObject config = sheet == null ? null : sheet.getJSONObject("config");
+ JSONObject merges = config == null ? null : config.getJSONObject("merge");
+ if (merges != null) {
+ for (Object rawMerge : merges.values()) {
+ rightEdge = extendMergedRightEdge(rightEdge, row, column, rawMerge);
+ }
+ }
+
+ JSONArray cellData = sheet == null ? null : sheet.getJSONArray("celldata");
+ if (cellData != null) {
+ for (Object rawCell : cellData) {
+ JSONObject cell = JSON.parseObject(JSON.toJSONString(rawCell));
+ JSONObject value = cell == null ? null : cell.getJSONObject("v");
+ JSONObject merge = value == null ? null : value.getJSONObject("mc");
+ rightEdge = extendMergedRightEdge(rightEdge, row, column, merge);
+ }
+ }
+ return rightEdge + 1;
+ }
+
+ private String getRightAdjacentCoordinate(JSONObject sheet, int row, int column) {
+ int adjacentColumn = getRightAdjacentColumn(sheet, row, column);
+ int[] anchor = findMergedAnchor(sheet, row, adjacentColumn);
+ return anchor[0] + "-" + anchor[1];
+ }
+
+ /**
+ * Luckysheet 鍙湪鍚堝苟鍖哄煙宸︿笂瑙掍繚瀛樺疄闄呭�笺�傝嫢鐩爣鍗曞厓鏍间綅浜庡悎骞跺尯鍩熷唴閮紝
+ * 灏嗗叾杞崲涓鸿鍖哄煙鐨勫乏涓婅鍧愭爣锛涙湭鍚堝苟鍒欒繑鍥炲師鍧愭爣銆�
+ */
+ private int[] findMergedAnchor(JSONObject sheet, int row, int column) {
+ JSONObject config = sheet == null ? null : sheet.getJSONObject("config");
+ JSONObject merges = config == null ? null : config.getJSONObject("merge");
+ if (merges != null) {
+ for (Object rawMerge : merges.values()) {
+ int[] anchor = findMergedAnchor(row, column, rawMerge);
+ if (anchor != null) {
+ return anchor;
+ }
+ }
+ }
+
+ JSONArray cellData = sheet == null ? null : sheet.getJSONArray("celldata");
+ if (cellData != null) {
+ for (Object rawCell : cellData) {
+ JSONObject cell = JSON.parseObject(JSON.toJSONString(rawCell));
+ JSONObject value = cell == null ? null : cell.getJSONObject("v");
+ int[] anchor = findMergedAnchor(row, column,
+ value == null ? null : value.getJSONObject("mc"));
+ if (anchor != null) {
+ return anchor;
+ }
+ }
+ }
+ return new int[]{row, column};
+ }
+
+ private int[] findMergedAnchor(int row, int column, Object rawMerge) {
+ if (rawMerge == null) {
+ return null;
+ }
+ JSONObject merge = rawMerge instanceof JSONObject
+ ? (JSONObject) rawMerge : JSON.parseObject(JSON.toJSONString(rawMerge));
+ Integer startRow = merge.getInteger("r");
+ Integer startColumn = merge.getInteger("c");
+ Integer rowSpan = merge.getInteger("rs");
+ Integer columnSpan = merge.getInteger("cs");
+ if (startRow == null || startColumn == null || rowSpan == null || columnSpan == null
+ || rowSpan < 1 || columnSpan < 1) {
+ return null;
+ }
+ if (row >= startRow && row < startRow + rowSpan
+ && column >= startColumn && column < startColumn + columnSpan) {
+ return new int[]{startRow, startColumn};
+ }
+ return null;
+ }
+
+ private int extendMergedRightEdge(int currentRightEdge, int row, int column, Object rawMerge) {
+ if (rawMerge == null) {
+ return currentRightEdge;
+ }
+ JSONObject merge = rawMerge instanceof JSONObject
+ ? (JSONObject) rawMerge : JSON.parseObject(JSON.toJSONString(rawMerge));
+ Integer startRow = merge.getInteger("r");
+ Integer startColumn = merge.getInteger("c");
+ Integer rowSpan = merge.getInteger("rs");
+ Integer columnSpan = merge.getInteger("cs");
+ if (startRow == null || startColumn == null || rowSpan == null || columnSpan == null
+ || rowSpan < 1 || columnSpan < 1) {
+ return currentRightEdge;
+ }
+ int endRow = startRow + rowSpan - 1;
+ int endColumn = startColumn + columnSpan - 1;
+ if (row >= startRow && row <= endRow && column >= startColumn && column <= endColumn) {
+ return Math.max(currentRightEdge, endColumn);
+ }
+ return currentRightEdge;
}
/**
@@ -794,7 +886,7 @@
}
/**
- * 鐩寸粦妯℃澘璁㈠崟鍙牎楠屾ā鏉夸腑鏍囪涓衡�滃鍑哄�尖�濈殑鍗曞厓鏍硷紝涓嶄娇鐢ㄦ楠岄」鐘舵�佹垨 last_value 鍒ゅ畾銆�
+ * 鐩寸粦妯℃澘璁㈠崟鍙牎楠屾瘡涓�滃鍑哄�尖�濇壒娉ㄦ墍鍦ㄥ尯鍩熷彸渚х揣閭诲崟鍏冩牸锛屼笉浣跨敤妫�楠岄」鐘舵�佹垨 last_value 鍒ゅ畾銆�
*/
private List<String> getMissingTemplateExportValues(Integer orderId) {
List<InsOrderStandardTemplate> snapshots = insOrderStandardTemplateService.list(
@@ -820,12 +912,12 @@
JSONObject recordValues = StrUtil.isBlank(snapshot.getRecordValues())
? new JSONObject() : JSON.parseObject(snapshot.getRecordValues());
- // 淇濆瓨鏃跺悓鏍峰彧鍙栨ā鏉夸腑鐨勭涓�涓鍑哄�硷紝鎻愪氦鏍¢獙涓庝繚瀛樺彛寰勪繚鎸佷竴鑷淬��
- String coordinate = coordinates.get(0);
- JSONObject cell = recordValues.getJSONObject(coordinate);
- Object value = cell == null ? null : cell.get("v");
- if (value == null || StringUtils.isBlank(String.valueOf(value))) {
- missing.add(templateName + "锛�" + coordinate + "锛�");
+ for (String coordinate : coordinates) {
+ JSONObject cell = recordValues.getJSONObject(coordinate);
+ Object value = cell == null ? null : cell.get("v");
+ if (value == null || StringUtils.isBlank(String.valueOf(value))) {
+ missing.add(templateName + "锛�" + coordinate + "锛�");
+ }
}
}
return missing;
@@ -1119,13 +1211,12 @@
.last("FOR UPDATE"));
boolean isInspectionReport = Objects.equals(INSPECTION_REPORT, reportType);
registerInsResults = isInspectionReport && Boolean.TRUE.equals(registerInsResults);
- // 1. 鍒ゆ柇鏄惁鏈夐噸澶嶇紪鍙�, 鏈夐噸澶嶇紪鍙峰仛鎻愰啋
+ // 1. 濮旀墭缂栧彿鍏ㄥ眬鍞竴锛屾彁浜ゅ鏍告椂鍐嶆鏍¢獙锛岄槻姝㈠苟鍙戞垨鍘嗗彶鏁版嵁缁曡繃鐢熸垚鏍¢獙銆�
Long codeCount = insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery()
- .ne(InsOrder::getState, -1)
- .ne(InsOrder::getIfsInventoryId, order.getIfsInventoryId())
+ .ne(InsOrder::getId, orderId)
.eq(InsOrder::getEntrustCode, order.getEntrustCode()));
if (codeCount > 0) {
- throw new ErrorException("褰撳墠缂栧彿鏈夐噸澶�, 璇峰厛鍘讳慨鏀归噸澶嶇紪鍙�");
+ throw new ErrorException("鏍峰搧/濮旀墭鍗曞凡瀛樺湪锛岃纭鏍峰搧缂栧彿");
}
// 2. 鍒ゆ柇璇ヨ鍗曟槸鍚︽槸绗竴娆$敓浜�(鍚庣画鎶ュ憡鐢熸垚鍙彇绗竴娆℃彁浜ゆ椂闂�)
@@ -1532,6 +1623,10 @@
refreshed.setRecordValues(templateRecordValuesMap.get(templateId));
refreshed.setTemperature(templateTemperatureMap.get(templateId));
refreshed.setHumidity(templateHumidityMap.get(templateId));
+ // 鍒锋柊妯℃澘缁撴瀯鏃跺繀椤讳繚鐣欐楠岄樁娈靛~鍐欑殑涓氬姟鏁版嵁锛岄伩鍏嶈繘鍏ュ鏍稿悗鍥炴樉涓虹┖銆�
+ refreshed.setDetectionTime(oldSnapshot == null ? null : oldSnapshot.getDetectionTime());
+ refreshed.setDetectionPlace(oldSnapshot == null ? null : oldSnapshot.getDetectionPlace());
+ refreshed.setInsResult(oldSnapshot == null ? null : oldSnapshot.getInsResult());
Integer templateSort = templateSortMap.get(templateId);
refreshed.setSort(templateSort == null ? nextTemplateSort++ : templateSort);
refreshedSnapshots.add(refreshed);
@@ -1586,12 +1681,13 @@
InsReport existingReport = insReportMapper.selectOne(Wrappers.<InsReport>lambdaQuery()
.eq(InsReport::getInsOrderId, orderId)
.last("limit 1"));
+ boolean directTemplateOrder = isDirectTemplateOrder(orderId);
if (currentState != null && Objects.equals(currentState.getInsState(), 5)
- && existingReport != null && StringUtils.isNotBlank(existingReport.getUrl())) {
+ && existingReport != null && StringUtils.isNotBlank(existingReport.getUrl())
+ && (!directTemplateOrder || StringUtils.isNotBlank(existingReport.getInspectionUrl()))) {
// 闃叉澶嶆牳椤甸潰閲嶅鐐瑰嚮鎴栫綉缁滈噸璇曢噸澶嶇敓鎴愭姤鍛娿�侀噸澶嶅彂璧锋姤鍛婂鎵广��
return 1;
}
- boolean directTemplateOrder = isDirectTemplateOrder(orderId);
if (directTemplateOrder && Objects.equals(type, 1)
&& !Objects.equals(dto.getInsResult(), 0) && !Objects.equals(dto.getInsResult(), 1)) {
throw new ErrorException("璇烽�夋嫨妫�楠屽崟缁撹");
@@ -1640,15 +1736,22 @@
.eq(InsOrder::getId, orderId)
.set(InsOrder::getInsState, 5));
- // 妫�楠屼汉鍛樻彁浜ゅ鏍告椂涓嶅啀鐢熸垚鎶ュ憡锛涗粎鍦ㄥ叏閮ㄨ瘯楠屽澶嶆牳閫氳繃鍚庣敓鎴愭娴嬫姤鍛娿��
+ // 妫�楠屼汉鍛樻彁浜ゅ鏍告椂涓嶇敓鎴愭姤鍛婏紱鍏ㄩ儴璇曢獙瀹ゅ鏍搁�氳繃鍚庣敓鎴愭姤鍛娿��
if (report == null || StringUtils.isBlank(report.getUrl())) {
this.generateReport(orderId, DETECTION_REPORT, writeUserId);
- report = insReportMapper.selectOne(Wrappers.<InsReport>lambdaQuery()
- .eq(InsReport::getInsOrderId, orderId)
- .last("limit 1"));
}
+ // 鐩寸粦妯℃澘璁㈠崟鍚屾椂鐢熸垚妫�楠屾姤鍛婏紝涓や唤鏂囦欢鍏辩敤鍚屼竴鏉″鎵硅褰曘��
+ if (directTemplateOrder && (report == null || StringUtils.isBlank(report.getInspectionUrl()))) {
+ this.generateReport(orderId, INSPECTION_REPORT, writeUserId);
+ }
+ report = insReportMapper.selectOne(Wrappers.<InsReport>lambdaQuery()
+ .eq(InsReport::getInsOrderId, orderId)
+ .last("limit 1"));
if (report == null || StringUtils.isBlank(report.getUrl())) {
throw new ErrorException("妫�娴嬫姤鍛婄敓鎴愬け璐�");
+ }
+ if (directTemplateOrder && StringUtils.isBlank(report.getInspectionUrl())) {
+ throw new ErrorException("妫�楠屾姤鍛婄敓鎴愬け璐�");
}
if (report.getTempUrlPdf() == null) {
String tempUrlPdf = this.wordToPdfTemp(report.getUrl().replace("/word", wordUrl));
@@ -1798,6 +1901,101 @@
throw new ErrorException("鎵句笉鍒板綋鍓嶆楠屼换鍔$殑妫�楠屼汉锛屾棤娉曠敓鎴愭娴嬫姤鍛�");
}
return inspector.getUserId();
+ }
+
+ /**
+ * 閲嶆柊鐢熸垚灏氭湭鎵瑰噯鐨勭郴缁熸姤鍛婏紝骞舵仮澶嶅凡瀛樺湪鐨勭紪鍒躲�佸鏍哥鍚嶃��
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void regenerateReport(Integer reportId, Integer createOrderUser) {
+ if (reportId == null) {
+ throw new ErrorException("鎶ュ憡涓嶈兘涓虹┖");
+ }
+ InsReport accessibleReport = insReportMapper.selectDownloadableReport(reportId, createOrderUser);
+ if (accessibleReport == null) {
+ throw new ErrorException("鎶ュ憡涓嶅瓨鍦ㄣ�佸皻鏈敓鎴愭垨鏃犳潈鎿嶄綔");
+ }
+ // 鏁版嵁搴撹閿侀伩鍏嶅悓涓�鎶ュ憡琚浜哄悓鏃堕噸鏂扮敓鎴愬苟瑕嗙洊銆�
+ InsReport report = insReportMapper.selectOne(Wrappers.<InsReport>lambdaQuery()
+ .eq(InsReport::getId, reportId)
+ .last("FOR UPDATE"));
+ if (report == null) {
+ throw new ErrorException("鎶ュ憡涓嶅瓨鍦�");
+ }
+ if (Objects.equals(report.getIsRatify(), 1)) {
+ throw new ErrorException("宸叉壒鍑嗘姤鍛婁笉鑳介噸鏂扮敓鎴�");
+ }
+ if (StringUtils.isNotBlank(report.getUrlS())) {
+ throw new ErrorException("褰撳墠鎶ュ憡宸叉墜鍔ㄤ笂浼狅紝璇峰厛杩樺師涓虹郴缁熸姤鍛婂悗鍐嶉噸鏂扮敓鎴�");
+ }
+ if (report.getInsOrderId() == null) {
+ throw new ErrorException("鎶ュ憡鏈叧鑱旀楠屽崟锛屾棤娉曢噸鏂扮敓鎴�");
+ }
+
+ Integer reportType = report.getReportType() == null ? DETECTION_REPORT : report.getReportType();
+ Integer writeUserId = report.getWriteUserId() == null
+ ? SecurityUtils.getUserId().intValue() : report.getWriteUserId();
+ boolean directTemplateOrder = isDirectTemplateOrder(report.getInsOrderId());
+ if (directTemplateOrder) {
+ generateReport(report.getInsOrderId(), DETECTION_REPORT, writeUserId);
+ generateReport(report.getInsOrderId(), INSPECTION_REPORT, writeUserId);
+ } else {
+ generateReport(report.getInsOrderId(), reportType, writeUserId);
+ }
+
+ InsReport regenerated = insReportMapper.selectById(reportId);
+ if (regenerated == null || StringUtils.isBlank(regenerated.getUrl())) {
+ throw new ErrorException("鎶ュ憡閲嶆柊鐢熸垚澶辫触");
+ }
+ if (directTemplateOrder && StringUtils.isBlank(regenerated.getInspectionUrl())) {
+ throw new ErrorException("妫�楠屾姤鍛婇噸鏂扮敓鎴愬け璐�");
+ }
+ String reportPath = regenerated.getUrl().replace("/word", wordUrl);
+ Map<String, Object> marks = buildExistingReportMarks(report);
+ if (!marks.isEmpty()) {
+ insReportService.wordInsertUrl(marks, reportPath);
+ if (StringUtils.isNotBlank(regenerated.getInspectionUrl())) {
+ insReportService.wordInsertUrl(marks,
+ regenerated.getInspectionUrl().replace("/word", wordUrl));
+ }
+ }
+ String tempPdfName = wordToPdfTemp(reportPath);
+ if (StringUtils.isBlank(tempPdfName)) {
+ throw new ErrorException("鎶ュ憡棰勮鏂囦欢鐢熸垚澶辫触");
+ }
+ // generateReport 浼氬啓鍏ュ綋鍓嶆椂闂达紱閲嶆柊鐢熸垚涓嶅簲鏀瑰彉鍘熷鎵硅褰曟椂闂淬��
+ insReportMapper.update(null, Wrappers.<InsReport>lambdaUpdate()
+ .eq(InsReport::getId, reportId)
+ .set(InsReport::getWriteTime, report.getWriteTime())
+ .set(InsReport::getTempUrlPdf, "/word/" + tempPdfName));
+ }
+
+ private Map<String, Object> buildExistingReportMarks(InsReport report) {
+ Map<String, Object> marks = new HashMap<>();
+ boolean submitted = Objects.equals(report.getState(), 1)
+ || report.getIsExamine() != null
+ || report.getExamineTime() != null;
+ if (submitted) {
+ User writer = getReportSigner(report.getWriteUserId(), "缂栧埗浜�");
+ marks.put("writeUrl", ReportSignaturePictureUtils.create(imgUrl, writer.getSignatureUrl()));
+ marks.put("writeDateUrl", Pictures.ofStream(DateImageUtil.createDateImage(report.getWriteTime())).create());
+ marks.put("insUrl", ReportSignaturePictureUtils.create(imgUrl, writer.getSignatureUrl()));
+ }
+ if (Objects.equals(report.getIsExamine(), 1)) {
+ User examiner = getReportSigner(report.getExamineUserId(), "瀹℃牳浜�");
+ marks.put("examineUrl", ReportSignaturePictureUtils.create(imgUrl, examiner.getSignatureUrl()));
+ marks.put("examineDateUrl", Pictures.ofStream(DateImageUtil.createDateImage(report.getExamineTime())).create());
+ }
+ return marks;
+ }
+
+ private User getReportSigner(Integer userId, String roleName) {
+ User user = userId == null ? null : userMapper.selectById(userId);
+ if (user == null || StringUtils.isBlank(user.getSignatureUrl())) {
+ throw new ErrorException("鎵句笉鍒�" + roleName + "鐨勭鍚�");
+ }
+ return user;
}
/**
@@ -2331,13 +2529,18 @@
enterFactoryReport.setLotBatchNo(ifsInventoryQuantity.getUpdateBatchNo());
// 妫�娴嬩緷鎹�
- Set<String> standardMethod = new HashSet<>();
+ Set<String> standardMethod = new LinkedHashSet<>();
StringBuilder standardMethod2 = new StringBuilder();
- standardMethod.add(baseMapper.getStandardMethodCode(insSample.getStandardMethodListId()));
+ String reportStandardMethod = baseMapper.getStandardMethodReportText(insSample.getStandardMethodListId());
+ if (StringUtils.isNotBlank(reportStandardMethod)) {
+ standardMethod.add(reportStandardMethod);
+ }
for (String s : standardMethod) {
standardMethod2.append("銆�").append(s);
}
- standardMethod2.replace(0, 1, "");
+ if (standardMethod2.length() > 0) {
+ standardMethod2.deleteCharAt(0);
+ }
// 鏍峰搧绫诲瀷
String orderType = iSysDictTypeService.selectLabelByDict(DictDataConstants.CHECK_TYPE, insOrder.getOrderType());
@@ -3009,8 +3212,7 @@
insReport.setReportType(reportType);
boolean showResult = Objects.equals(reportType, INSPECTION_REPORT);
List<Map<String, Object>> tables = new ArrayList<>();
- Set<String> standardMethod = new HashSet<>();
- Set<String> deviceSet = new HashSet<>();
+ Set<String> standardMethod = new LinkedHashSet<>();
Set<String> models = new HashSet<>();
// 鏌ヨ妫�楠岄」鏁伴噺
AtomicInteger productSize = new AtomicInteger();
@@ -3022,25 +3224,16 @@
/*鍩虹鎶ュ憡(鏍规嵁缁樺埗鐨勫師濮嬭褰曟ā鐗堝舰鎴�)*/
samples.forEach(a -> {
models.add(a.getModel());
- String standardMethodCode = baseMapper.getStandardMethodCode(a.getStandardMethodListId());
- if (StrUtil.isNotBlank(a.getSpecialStandardMethod())) {
- standardMethodCode = standardMethodCode + "+" + a.getSpecialStandardMethod();
- }
- standardMethod.add(standardMethodCode);
- for (InsProduct b : a.getInsProduct()) {
- if (b.getInsProductResult() != null) {
- List<JSONObject> jsonObjects = JSON.parseArray(b.getInsProductResult().getEquipValue(), JSONObject.class);
- for (JSONObject jsonObject : jsonObjects) {
- if (!"".equals(jsonObject.get("v") + "")) {
- List<String> v = StrUtil.split(jsonObject.get("v") + "", "锛�");
- deviceSet.addAll(v);
- }
- }
+ String standardMethodCode = baseMapper.getStandardMethodReportText(a.getStandardMethodListId());
+ if (StrUtil.isNotBlank(standardMethodCode)) {
+ if (StrUtil.isNotBlank(a.getSpecialStandardMethod())) {
+ standardMethodCode = standardMethodCode + "+" + a.getSpecialStandardMethod();
}
+ standardMethod.add(standardMethodCode);
}
- // 鏂扮増妫�娴嬫姤鍛婄洿鎺ヤ娇鐢ㄥ浐瀹氬洓鍒楃粨鏋滆锛屼笉鍐嶆瀯閫犳棫鐗堝彲鍙樺垪 TableRenderData銆�
- // 妫�楠屾姤鍛婁粛娌跨敤涓嬫柟鍘熸湁鐨勫ぇ琛ㄦ牸閫昏緫銆�
- if (!showResult) {
+ // 鐩寸粦妯℃澘鐨勬娴嬫姤鍛娿�佹楠屾姤鍛婇兘浣跨敤鏂扮増鍥哄畾缁撴灉琛岋紝涓嶅啀杩涘叆鏃х増妫�楠岄」琛ㄦ牸閫昏緫銆�
+ // 鐩寸粦妯℃澘涓殑鎵胯浇璁板綍娌℃湁鏃ф楠岄」瀛楁锛岃繘鍏ユ棫閫昏緫浼氬湪鏍煎紡鍖栨椂浜х敓绌烘寚閽堛��
+ if (!showResult || directTemplateOrder) {
return;
}
// 鏀舵牱鏃ユ湡
@@ -3067,28 +3260,6 @@
}
max = a.getQuantity();
- // 瀛e害妫�楠岄渶瑕佽繘鍘傛楠岀殑璁惧
- // 鏌ヨ鏄惁鏈夎繘鍘傛楠�
- InsOrder order = insOrderMapper.selectOne(Wrappers.<InsOrder>lambdaQuery()
- .eq(InsOrder::getIfsInventoryId, insOrder.getIfsInventoryId())
- .ne(InsOrder::getState, -1)
- .eq(InsOrder::getOrderType, InsOrderTypeConstants.ENTER_THE_FACTORY)
- .ne(InsOrder::getId, insOrder.getId())
- .last("limit 1"));
- if (order != null) {
- List<SampleProductDto> sampleProductDtos = insSampleMapper.selectSampleProductListByOrderId(order.getId());
- for (InsProduct b : sampleProductDtos.get(0).getInsProduct()) {
- if (b.getInsProductResult() != null) {
- List<JSONObject> jsonObjects = JSON.parseArray(b.getInsProductResult().getEquipValue(), JSONObject.class);
- for (JSONObject jsonObject : jsonObjects) {
- if (!"".equals(jsonObject.get("v") + "")) {
- List<String> v = StrUtil.split(jsonObject.get("v") + "", "锛�");
- deviceSet.addAll(v);
- }
- }
- }
- }
- }
if (StringUtils.isBlank(insOrder.getSampleView())) {
insOrder.setSampleView(insOrder.getSample());
}
@@ -3244,20 +3415,13 @@
tables.forEach(table -> {
table.put("tableSize", tables.size() + 1);
});
- // 鏂拌鍗曟寜妯℃澘閫夋嫨璁惧锛涙棫璁㈠崟娌℃湁妯℃澘璁惧鍏崇郴鏃跺洖閫�鍒拌鍗曠骇璁惧璁板綍銆�
- Set<String> reportDeviceNumbers = insOrderTemplateDeviceMapper
- .selectManagementNumbersByOrderId(orderId).stream()
- .filter(StringUtils::isNotBlank)
+ // 鎶ュ憡鍙睍绀烘楠屽崟鍚勬ā鏉块�夋嫨鐨勮澶囷紝骞舵寜璁惧ID鍘婚噸銆�
+ Set<Integer> reportDeviceIds = insOrderTemplateDeviceMapper
+ .selectDeviceIdsByOrderId(orderId).stream()
+ .filter(Objects::nonNull)
.collect(Collectors.toCollection(LinkedHashSet::new));
- if (reportDeviceNumbers.isEmpty()) {
- reportDeviceNumbers.addAll(insOrderDeviceRecordMapper.selectDeviceNumber(orderId).stream()
- .map(InsOrderDeviceRecordDto::getManagementNumber)
- .filter(StringUtils::isNotBlank)
- .collect(Collectors.toList()));
- }
- reportDeviceNumbers.addAll(deviceSet);
- List<Map<String, String>> deviceList = reportDeviceNumbers.isEmpty()
- ? new ArrayList<>() : insOrderMapper.selectDeviceList(reportDeviceNumbers);
+ List<Map<String, String>> deviceList = reportDeviceIds.isEmpty()
+ ? new ArrayList<>() : insOrderMapper.selectDeviceListByIds(reportDeviceIds);
if (CollectionUtils.isNotEmpty(deviceList)) {
int count = 1;
for (Map<String, String> stringMap : deviceList) {
@@ -3358,26 +3522,18 @@
sendTime = reportInventory.getDeclareDate();
}
- // 妫�娴嬫棩鏈燂細棣栨淇濆瓨妯℃澘鍊兼椂闂�-棣栨鎻愪氦鏃堕棿
+ // 妫�娴嬫棩鏈燂細姹囨�绘楠屽崟鍚勬ā鏉垮~鍐欑殑妫�娴嬫椂闂达紝鏃ユ湡鐩稿悓鏄剧ず涓�涓紝鍚﹀垯鏄剧ず鏈�鏃╄嚦鏈�鏅氥��
LocalDateTime now = LocalDateTime.now();
- // 鎻愪氦鏃堕棿
- LocalDateTime submitTime = LocalDateTime.now();
- // 鍒ゆ柇鏄惁鏈夋彁浜ゆ椂闂�
- if (insOrder.getFirstSubmitDate() != null) {
- submitTime = insOrder.getFirstSubmitDate();
- }
-
- LocalDateTime firstInspectDate = insOrder.getFirstInspectDate();
- // 瀛楁涓婄嚎鍓嶇殑鍘嗗彶璁㈠崟娌跨敤鍘熸潵鐨勪笅鍙戞椂闂达紝閬垮厤鏀瑰彉鏃㈡湁鎶ュ憡鍙e緞銆�
- if (firstInspectDate == null) {
- firstInspectDate = insOrder.getSendTime();
- }
-
- String insTime = firstInspectDate.format(DateTimeFormatter.ofPattern("yyyy骞碝M鏈坉d鏃�")) + "-"
- + submitTime.format(DateTimeFormatter.ofPattern("yyyy骞碝M鏈坉d鏃�"));
-
- String insTimeEn = monthNames[firstInspectDate.getMonthValue() - 1] + " " + firstInspectDate.format(DateTimeFormatter.ofPattern("dd, yyyy")) + "-"
- + monthNames[submitTime.getMonthValue() - 1] + " " + submitTime.format(DateTimeFormatter.ofPattern("dd, yyyy"));
+ List<InsOrderStandardTemplate> templateSnapshots = insOrderStandardTemplateService.list(
+ Wrappers.<InsOrderStandardTemplate>lambdaQuery()
+ .eq(InsOrderStandardTemplate::getInsOrderId, orderId)
+ .orderByAsc(InsOrderStandardTemplate::getSort, InsOrderStandardTemplate::getId));
+ List<LocalDate> detectionDates = templateSnapshots.stream()
+ .map(InsOrderStandardTemplate::getDetectionTime)
+ .filter(Objects::nonNull)
+ .collect(Collectors.toList());
+ String insTime = formatReportTestDate(detectionDates);
+ String insTimeEn = formatReportTestDateEn(detectionDates, monthNames);
// 妫�楠岀幆澧冿細浼樺厛姹囨�诲悇妯℃澘濉啓鐨勬俯婀垮害锛屾姤鍛婂睍绀哄叏閮ㄦā鏉跨殑鏈�灏忓�煎埌鏈�澶у�笺��
String environment = buildReportEnvironment(orderId, insOrder);
@@ -3415,10 +3571,6 @@
batchNo = defaultReportText(reportInventory.getUpdateBatchNo(), reportInventory.getLotBatchNo());
}
// 鏂拌仛鐩寸粦妯℃澘璁㈠崟锛氭姤鍛婁俊鎭彇濮旀墭淇℃伅鍜岃鍗曟ā鏉垮揩鐓э紝涓嶅啀鍙栬兘鍔涜寖鍥存爣鍑嗘柟娉曘��
- List<InsOrderStandardTemplate> templateSnapshots = insOrderStandardTemplateService.list(
- Wrappers.<InsOrderStandardTemplate>lambdaQuery()
- .eq(InsOrderStandardTemplate::getInsOrderId, orderId)
- .orderByAsc(InsOrderStandardTemplate::getSort, InsOrderStandardTemplate::getId));
boolean newJuTemplateOrder = !templateSnapshots.isEmpty() && directTemplateOrder;
if (newJuTemplateOrder) {
productName = defaultReportText(insOrder.getSampleView(), insOrder.getSample());
@@ -3431,11 +3583,8 @@
productionDate = insOrder.getProductionDate().format(DateTimeFormatter.ofPattern("yyyy骞碝M鏈坉d鏃�"));
}
batchNo = defaultReportText(insOrder.getProductionBatch(), "/");
- standardMethodText = templateSnapshots.stream()
- .map(InsOrderStandardTemplate::getRemark)
- .filter(StringUtils::isNotBlank)
- .distinct()
- .collect(Collectors.joining("锛�"));
+ standardMethodText = defaultReportText(
+ baseMapper.getStandardMethodReportTextByCode(insOrder.getSample()), insOrder.getSample());
}
boolean containsOrganicChlorine = detectionResultRows.stream()
.map(row -> row.get("itemName"))
@@ -3445,8 +3594,9 @@
? "寰簱浠戞硶锛屾湁鏈烘隘鍚噺灏忎簬0.005%鏃讹紝浠ユ湭妫�鍑烘姤鍑恒��"
: defaultReportText(insOrder.getRemark(), "/");
- // 妫�娴嬫姤鍛婂拰妫�楠屾姤鍛婄粺涓�浣跨敤鏂扮増鎶ュ憡妯℃澘
- String templateName = "/static/detection-report-template-v2.docx";
+ String templateName = showResult
+ ? "/static/inspection-report-template-v2.docx"
+ : "/static/detection-report-template-v2.docx";
InputStream inputStream = this.getClass().getResourceAsStream(templateName);
if (inputStream == null) {
throw new RuntimeException("鎵句笉鍒版姤鍛婃ā鏉�: " + templateName);
@@ -3533,7 +3683,7 @@
put("resultNote", finalResultRemark);
}});
try {
- String name = insReport.getCode().replace("/", "") + (showResult ? ".docx" : "-C.docx");
+ String name = insReport.getCode().replace("/", "") + (showResult ? "-J.docx" : "-C.docx");
Files.createDirectories(Paths.get(wordUrl));
template.writeAndClose(Files.newOutputStream(Paths.get(wordUrl, name)));
insReport.setUrl("/word/" + name);
@@ -3550,6 +3700,22 @@
InsReport existing = insReportMapper.selectOne(Wrappers.<InsReport>lambdaQuery()
.eq(InsReport::getInsOrderId, report.getInsOrderId())
.last("limit 1"));
+ if (Objects.equals(report.getReportType(), INSPECTION_REPORT)) {
+ String inspectionUrl = report.getUrl();
+ if (existing == null) {
+ report.setReportType(DETECTION_REPORT);
+ report.setUrl(null);
+ report.setInspectionUrl(inspectionUrl);
+ insReportMapper.insert(report);
+ } else {
+ insReportMapper.update(null, Wrappers.<InsReport>lambdaUpdate()
+ .eq(InsReport::getId, existing.getId())
+ .set(InsReport::getInspectionUrl, inspectionUrl)
+ .set(InsReport::getWriteUserId, report.getWriteUserId())
+ .set(InsReport::getWriteTime, report.getWriteTime()));
+ }
+ return;
+ }
if (existing == null) {
insReportMapper.insert(report);
return;
@@ -3591,6 +3757,7 @@
row.put("itemName", itemName);
row.put("unit", defaultReportText(product.getUnit(), "/"));
row.put("result", defaultReportText(product.getLastValue(), "/"));
+ row.put("inspectionConclusion", formatInspectionConclusion(product.getInsResult()));
rows.add(row);
}
}
@@ -3598,7 +3765,7 @@
}
/**
- * 鏂拌仛鐩寸粦妯℃澘璁㈠崟锛氫竴涓ā鏉块〉绛惧湪鎶ュ憡涓彧瀵瑰簲涓�鏉℃娴嬮」鐩��
+ * 鏂拌仛鐩寸粦妯℃澘璁㈠崟锛氭ā鏉夸腑姣忎竴涓�滃鍑哄�尖�濇壒娉ㄩ兘瀵瑰簲鎶ュ憡涓殑涓�鏉℃娴嬮」鐩��
*/
private List<Map<String, String>> buildTemplateDetectionResultRows(Integer orderId) {
List<InsOrderStandardTemplate> snapshots = insOrderStandardTemplateService.list(
@@ -3608,27 +3775,30 @@
List<Map<String, String>> rows = new ArrayList<>();
int sequence = 1;
for (InsOrderStandardTemplate snapshot : snapshots) {
- TemplateExportCell exportCell = getFirstTemplateExportCell(snapshot.getThing());
+ List<TemplateExportCell> exportCells = getTemplateExportCells(snapshot.getThing());
JSONObject recordValues = StrUtil.isBlank(snapshot.getRecordValues())
? new JSONObject() : JSON.parseObject(snapshot.getRecordValues());
- String result = readTemplateCellText(recordValues, exportCell.resultCoordinate, exportCell.templateValues);
- if (StringUtils.isBlank(result)) {
- throw new ErrorException("妯℃澘鈥�" + defaultReportText(snapshot.getName(), "妯℃澘ID " + snapshot.getTemplateId())
- + "鈥濈殑瀵煎嚭鍊间笉鑳戒负绌�");
- }
- String unit = exportCell.unitCoordinate == null ? null
- : readTemplateCellText(recordValues, exportCell.unitCoordinate, exportCell.templateValues);
- String itemName = exportCell.itemCoordinate == null ? null
- : readTemplateCellText(recordValues, exportCell.itemCoordinate, exportCell.templateValues);
+ for (TemplateExportCell exportCell : exportCells) {
+ String result = readTemplateCellText(recordValues, exportCell.resultCoordinate, exportCell.templateValues);
+ if (StringUtils.isBlank(result)) {
+ throw new ErrorException("妯℃澘鈥�" + defaultReportText(snapshot.getName(), "妯℃澘ID " + snapshot.getTemplateId())
+ + "鈥濈殑瀵煎嚭鍊间笉鑳戒负绌猴紙" + exportCell.resultCoordinate + "锛�");
+ }
+ String unit = exportCell.unitCoordinate == null ? null
+ : readTemplateCellText(recordValues, exportCell.unitCoordinate, exportCell.templateValues);
+ String itemName = exportCell.itemCoordinate == null ? null
+ : readTemplateCellText(recordValues, exportCell.itemCoordinate, exportCell.templateValues);
- Map<String, String> row = new LinkedHashMap<>();
- row.put("seq", String.valueOf(sequence++));
- String reportItemName = defaultReportText(itemName,
- defaultReportText(snapshot.getName(), "妯℃澘ID " + snapshot.getTemplateId()));
- row.put("itemName", formatExportItemName(reportItemName));
- row.put("unit", defaultReportText(unit, "/"));
- row.put("result", result);
- rows.add(row);
+ Map<String, String> row = new LinkedHashMap<>();
+ row.put("seq", String.valueOf(sequence++));
+ String reportItemName = defaultReportText(itemName,
+ defaultReportText(snapshot.getName(), "妯℃澘ID " + snapshot.getTemplateId()));
+ row.put("itemName", formatExportItemName(reportItemName));
+ row.put("unit", defaultReportText(unit, "/"));
+ row.put("result", result);
+ row.put("inspectionConclusion", formatInspectionConclusion(snapshot.getInsResult()));
+ rows.add(row);
+ }
}
if (rows.isEmpty()) {
throw new ErrorException("褰撳墠璁㈠崟鏈壘鍒板彲鐢熸垚鎶ュ憡鐨勫師濮嬭褰曟ā鏉�");
@@ -3636,7 +3806,17 @@
return rows;
}
- private TemplateExportCell getFirstTemplateExportCell(String compressedThing) {
+ private static String formatInspectionConclusion(Integer insResult) {
+ if (Objects.equals(insResult, 1)) {
+ return "鍚堟牸";
+ }
+ if (Objects.equals(insResult, 0)) {
+ return "涓嶅悎鏍�";
+ }
+ return "/";
+ }
+
+ private List<TemplateExportCell> getTemplateExportCells(String compressedThing) {
if (StrUtil.isBlank(compressedThing)) {
throw new ErrorException("鍘熷璁板綍妯℃澘涓虹┖");
}
@@ -3646,9 +3826,8 @@
} catch (Exception ignored) {
thing = compressedThing;
}
- JSONArray cellData = JSON.parseObject(thing).getJSONArray("data").getJSONObject(0).getJSONArray("celldata");
- Integer resultColumn = null;
- Integer itemColumn = null;
+ JSONObject sheet = JSON.parseObject(thing).getJSONArray("data").getJSONObject(0);
+ JSONArray cellData = sheet.getJSONArray("celldata");
Integer unitColumn = null;
List<int[]> exportCells = new ArrayList<>();
Map<String, String> templateValues = new HashMap<>();
@@ -3662,13 +3841,6 @@
}
String displayValue = value.get("v") == null ? null : String.valueOf(value.get("v"));
templateValues.put(row + "-" + column, displayValue);
- if (resultColumn == null && "妫�楠岀粨鏋�".equals(StringUtils.trim(displayValue))) {
- resultColumn = column;
- }
- if (itemColumn == null && ("妫�娴嬮」鐩�".equals(StringUtils.trim(displayValue))
- || "妫�楠岄」鐩�".equals(StringUtils.trim(displayValue)))) {
- itemColumn = column;
- }
if (unitColumn == null && "鍗曚綅".equals(StringUtils.trim(displayValue))) {
unitColumn = column;
}
@@ -3681,17 +3853,16 @@
throw new ErrorException("妯℃澘蹇呴』鑷冲皯閰嶇疆涓�涓鍑哄�兼壒娉�");
}
exportCells.sort(Comparator.comparingInt((int[] cell) -> cell[0]).thenComparingInt(cell -> cell[1]));
- int[] firstExport = exportCells.get(0);
- int resultColumnForRow = resultColumn == null ? firstExport[1] : resultColumn;
- // 閫氬父鈥滃鍑哄�尖�濇壒娉ㄩ厤缃湪椤圭洰鍚嶇О鍗曞厓鏍硷紱鑻ラ厤缃湪缁撴灉鍗曞厓鏍硷紝鍒欏洖鍒扳�滄娴嬮」鐩�濆垪鍙栧悕绉般��
- Integer itemColumnForRow = !Objects.equals(firstExport[1], resultColumnForRow)
- ? firstExport[1] : itemColumn;
- TemplateExportCell result = new TemplateExportCell();
- result.resultCoordinate = firstExport[0] + "-" + resultColumnForRow;
- result.itemCoordinate = itemColumnForRow == null ? null : firstExport[0] + "-" + itemColumnForRow;
- result.unitCoordinate = unitColumn == null ? null : firstExport[0] + "-" + unitColumn;
- result.templateValues = templateValues;
- return result;
+ List<TemplateExportCell> results = new ArrayList<>();
+ for (int[] exportCell : exportCells) {
+ TemplateExportCell result = new TemplateExportCell();
+ result.resultCoordinate = getRightAdjacentCoordinate(sheet, exportCell[0], exportCell[1]);
+ result.itemCoordinate = exportCell[0] + "-" + exportCell[1];
+ result.unitCoordinate = unitColumn == null ? null : exportCell[0] + "-" + unitColumn;
+ result.templateValues = templateValues;
+ results.add(result);
+ }
+ return results;
}
private String readTemplateCellText(JSONObject recordValues, String coordinate, Map<String, String> templateValues) {
@@ -3716,16 +3887,26 @@
if (CollectionUtils.isEmpty(deviceList)) {
return "/";
}
- Set<String> lines = new LinkedHashSet<>();
- int sequence = 1;
+ Set<String> equipmentItems = new LinkedHashSet<>();
for (Map<String, String> device : deviceList) {
String name = getMapText(device, "deviceName", "device_name");
String managementNumber = getMapText(device, "managementNumber", "management_number");
- String line = sequence++ + ". " + defaultReportText(name, "/");
- if (StringUtils.isNotBlank(managementNumber)) {
- line += "锛�" + managementNumber;
+ if (StringUtils.isBlank(name) || "/".equals(name.trim())) {
+ continue;
}
- lines.add(line);
+ String number = StringUtils.isBlank(managementNumber) || "/".equals(managementNumber.trim())
+ ? "鍑哄巶缂栧彿" : managementNumber.trim();
+ String item = name.trim() + "锛�" + number;
+ equipmentItems.add(item);
+ }
+ if (equipmentItems.isEmpty()) {
+ return "/";
+ }
+ List<String> items = new ArrayList<>(equipmentItems);
+ List<String> lines = new ArrayList<>();
+ for (int i = 0; i < items.size(); i++) {
+ String punctuation = i == items.size() - 1 ? "銆�" : "锛�";
+ lines.add((i + 1) + ". " + items.get(i) + punctuation);
}
return String.join("\n", lines);
}
@@ -3746,7 +3927,7 @@
.collect(Collectors.toList());
String temperature = formatConditionRange(temperatures, order.getTemperature(), "鈩�");
- String humidity = formatConditionRange(humidities, order.getHumidity(), "%");
+ String humidity = formatConditionRange(humidities, order.getHumidity(), "%RH");
return Stream.of(temperature, humidity)
.filter(StringUtils::isNotBlank)
.collect(Collectors.joining(" "));
@@ -3817,6 +3998,33 @@
return value;
}
return StringUtils.isNotBlank(fallback) ? fallback : "/";
+ }
+
+ private static String formatReportTestDate(List<LocalDate> detectionDates) {
+ if (CollectionUtils.isEmpty(detectionDates)) {
+ return "/";
+ }
+ LocalDate startDate = Collections.min(detectionDates);
+ LocalDate endDate = Collections.max(detectionDates);
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy骞碝M鏈坉d鏃�");
+ if (startDate.equals(endDate)) {
+ return startDate.format(formatter);
+ }
+ return startDate.format(formatter) + "鑷�" + endDate.format(formatter);
+ }
+
+ private static String formatReportTestDateEn(List<LocalDate> detectionDates, String[] monthNames) {
+ if (CollectionUtils.isEmpty(detectionDates)) {
+ return "/";
+ }
+ LocalDate startDate = Collections.min(detectionDates);
+ LocalDate endDate = Collections.max(detectionDates);
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd, yyyy");
+ String startText = monthNames[startDate.getMonthValue() - 1] + " " + startDate.format(formatter);
+ if (startDate.equals(endDate)) {
+ return startText;
+ }
+ return startText + "-" + monthNames[endDate.getMonthValue() - 1] + " " + endDate.format(formatter);
}
/**
@@ -5134,7 +5342,7 @@
}
}
// 鍒ゆ柇鏄惁鏄暟瀛楃被鍨�
- if (sampleProductDto2.getInspectionValueType().equals("1")) {
+ if ("1".equals(sampleProductDto2.getInspectionValueType())) {
// 鎶婃楠屽唴瀹瑰鏋滄纭寲鐐瑰拰鐒︾儳鏃堕棿鎶� . 鍒囧壊鎴� :
String lastValue = sampleProductDto2.getLastValue();
if (sampleProductDto2.getInspectionItem().contains("姝g~鍖栫偣") || sampleProductDto2.getInspectionItem().contains("鐒︾儳鏃堕棿")) {
--
Gitblit v1.9.3