From 08ddfad4530a014094c06fe68b8c2d9a0753403a Mon Sep 17 00:00:00 2001
From: linwei <872216696@qq.com>
Date: Wed, 05 Aug 2026 14:09:29 +0800
Subject: [PATCH] fix(gd): 修复线索事件查询中的SQL语法错误
---
drone-service/drone-gd/src/main/java/org/sxkj/gd/workorder/utils/GdPatrolReportWordUtil.java | 70 ++++++++++++++++++++++++++++++++---
1 files changed, 64 insertions(+), 6 deletions(-)
diff --git a/drone-service/drone-gd/src/main/java/org/sxkj/gd/workorder/utils/GdPatrolReportWordUtil.java b/drone-service/drone-gd/src/main/java/org/sxkj/gd/workorder/utils/GdPatrolReportWordUtil.java
index 62aecde..419c0c3 100644
--- a/drone-service/drone-gd/src/main/java/org/sxkj/gd/workorder/utils/GdPatrolReportWordUtil.java
+++ b/drone-service/drone-gd/src/main/java/org/sxkj/gd/workorder/utils/GdPatrolReportWordUtil.java
@@ -38,6 +38,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springblade.core.tool.utils.StringUtil;
+import org.sxkj.gd.utils.GdGeoAddressUtil;
import org.sxkj.gd.workorder.entity.GdPatrolTaskEntity;
import org.sxkj.gd.workorder.entity.GdTaskResultEntity;
@@ -101,9 +102,13 @@
CompletableFuture<Map<String, byte[]>> qrCodeFuture = CompletableFuture.supplyAsync(
() -> preloadQrCodes(results), RESOURCE_EXECUTOR
);
- CompletableFuture.allOf(imageFuture, qrCodeFuture).join();
+ CompletableFuture<Map<String, String>> addressFuture = CompletableFuture.supplyAsync(
+ () -> preloadAddresses(results), RESOURCE_EXECUTOR
+ );
+ CompletableFuture.allOf(imageFuture, qrCodeFuture, addressFuture).join();
Map<String, byte[]> imageCache = imageFuture.get();
Map<String, byte[]> qrCodeCache = qrCodeFuture.get();
+ Map<String, String> addressCache = addressFuture.get();
createTitle(document, title);
createSectionHeader(document, "一、任务详情");
@@ -111,7 +116,7 @@
int resultCount = results.size();
createSectionHeader(document, "二、巡查结果(" + resultCount + "件)");
- addResultDetails(document, results, imageCache, qrCodeCache);
+ addResultDetails(document, results, imageCache, qrCodeCache, addressCache);
document.write(fos);
return reportFile;
@@ -124,8 +129,8 @@
return File.createTempFile(safePrefix, ".docx");
}
- private static String buildSafeFilePrefix(String text) {
- String baseName = StringUtil.isBlank(text) ? "gd_patrol_report" : "gd_patrol_report_" + text;
+ private static String buildSafeFilePrefix(String taskNo) {
+ String baseName = StringUtil.isBlank(taskNo) ? "gd_patrol_report" : taskNo;
String safeName = baseName.replaceAll("[^a-zA-Z0-9_-]", "_");
if (safeName.length() < 3) {
safeName = "gd_patrol_report";
@@ -163,7 +168,8 @@
private static void addResultDetails(XWPFDocument document,
List<GdTaskResultEntity> results,
Map<String, byte[]> imageCache,
- Map<String, byte[]> qrCodeCache)
+ Map<String, byte[]> qrCodeCache,
+ Map<String, String> addressCache)
throws IOException, InvalidFormatException {
if (results == null || results.isEmpty()) {
addDetailItem(document, "/");
@@ -209,7 +215,8 @@
currentRow++;
setTableCellWithBoldAndCenter(resultTable, currentRow, 1, "成果地址");
- setTableCellWithSpacing(resultTable, currentRow, 2, "/");
+ String address = getAddressFromCache(result, addressCache);
+ setTableCellWithSpacing(resultTable, currentRow, 2, formatString(address));
currentRow++;
setTableCellWithBoldAndCenter(resultTable, currentRow, 1, "成果定位");
@@ -554,6 +561,39 @@
return qrCodeCache;
}
+ private static Map<String, String> preloadAddresses(List<GdTaskResultEntity> results) {
+ if (results == null || results.isEmpty()) {
+ return Collections.emptyMap();
+ }
+ List<GdTaskResultEntity> needAddressResults = results.stream()
+ .filter(result -> result.getLongitude() != null && result.getLatitude() != null)
+ .collect(Collectors.toList());
+ if (needAddressResults.isEmpty()) {
+ return Collections.emptyMap();
+ }
+
+ Map<String, String> addressCache = new ConcurrentHashMap<>();
+ List<CompletableFuture<Void>> futures = needAddressResults.stream()
+ .map(result -> CompletableFuture.runAsync(() -> {
+ String key = buildCoordinateKey(result.getLongitude(), result.getLatitude());
+ if (StringUtil.isBlank(key) || addressCache.containsKey(key)) {
+ return;
+ }
+ String address = GdGeoAddressUtil.getFormattedAddress(result.getLongitude(), result.getLatitude());
+ if (!StringUtil.isBlank(address)) {
+ addressCache.put(key, address);
+ }
+ }, RESOURCE_EXECUTOR))
+ .collect(Collectors.toList());
+
+ try {
+ CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
+ } catch (Exception e) {
+ logger.error("等待成果地址获取完成时发生异常", e);
+ }
+ return addressCache;
+ }
+
private static byte[] downloadImage(String urlString) throws IOException {
URL url = new URL(urlString);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
@@ -628,6 +668,24 @@
return String.format(Locale.CHINA, "%.6f", coordinate);
}
+ private static String getAddressFromCache(GdTaskResultEntity result, Map<String, String> addressCache) {
+ if (result == null || addressCache == null || addressCache.isEmpty()) {
+ return null;
+ }
+ String key = buildCoordinateKey(result.getLongitude(), result.getLatitude());
+ if (StringUtil.isBlank(key)) {
+ return null;
+ }
+ return addressCache.get(key);
+ }
+
+ private static String buildCoordinateKey(Double longitude, Double latitude) {
+ if (longitude == null || latitude == null) {
+ return "";
+ }
+ return formatCoordinateValue(longitude) + "," + formatCoordinateValue(latitude);
+ }
+
private static int findImageFormat(String url) {
String cleanUrl = url;
int queryIndex = url.indexOf("?");
--
Gitblit v1.9.3