From 47568e5f5dde220acd6ca4eb4eb6c1bbcd5ddf1b Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Thu, 18 Aug 2022 11:31:37 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E3=80=90=E6=8A=A5=E8=A1=A8=E3=80=91pc?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E5=8D=95=E6=8A=A5=E8=A1=A8=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD-=E4=BC=98=E5=8C=96=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E7=9A=84=E6=96=87=E4=BB=B6=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dtos/result/JiMuReportBriefResultDTO.java | 17 ++++ .../feigns/JiMuReportOpenFeignClient.java | 8 ++ .../JiMuReportOpenFeignClientFallback.java | 7 ++ .../impl/IcCustomerReportServiceImpl.java | 77 +++++++++++++------ 4 files changed, 87 insertions(+), 22 deletions(-) create mode 100644 epmet-commons/epmet-commons-feignclient/src/main/java/com/epmet/commons/feignclient/dtos/result/JiMuReportBriefResultDTO.java diff --git a/epmet-commons/epmet-commons-feignclient/src/main/java/com/epmet/commons/feignclient/dtos/result/JiMuReportBriefResultDTO.java b/epmet-commons/epmet-commons-feignclient/src/main/java/com/epmet/commons/feignclient/dtos/result/JiMuReportBriefResultDTO.java new file mode 100644 index 0000000000..be5f3df667 --- /dev/null +++ b/epmet-commons/epmet-commons-feignclient/src/main/java/com/epmet/commons/feignclient/dtos/result/JiMuReportBriefResultDTO.java @@ -0,0 +1,17 @@ +package com.epmet.commons.feignclient.dtos.result; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 报表简要信息result dto + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class JiMuReportBriefResultDTO { + private String id; + private String code; + private String name; +} diff --git a/epmet-commons/epmet-commons-feignclient/src/main/java/com/epmet/commons/feignclient/feigns/JiMuReportOpenFeignClient.java b/epmet-commons/epmet-commons-feignclient/src/main/java/com/epmet/commons/feignclient/feigns/JiMuReportOpenFeignClient.java index 08b07c0dab..009c68c2c8 100644 --- a/epmet-commons/epmet-commons-feignclient/src/main/java/com/epmet/commons/feignclient/feigns/JiMuReportOpenFeignClient.java +++ b/epmet-commons/epmet-commons-feignclient/src/main/java/com/epmet/commons/feignclient/feigns/JiMuReportOpenFeignClient.java @@ -3,6 +3,7 @@ package com.epmet.commons.feignclient.feigns; import com.epmet.commons.feignclient.dtos.JiMuPage; import com.epmet.commons.feignclient.dtos.JiMuResult; import com.epmet.commons.feignclient.dtos.form.JimuReportExportRequestDTO; +import com.epmet.commons.feignclient.dtos.result.JiMuReportBriefResultDTO; import com.epmet.commons.feignclient.dtos.result.JiMuReportDetailResultDTO; import com.epmet.commons.feignclient.dtos.result.JimuReportDbDataResultDTO; import com.epmet.commons.feignclient.dtos.result.JimuReportFieldTreeResultDTO; @@ -44,4 +45,11 @@ public interface JiMuReportOpenFeignClient { @PostMapping("jmreport/exportAllExcelStream") Response exportAllExcelStream(JimuReportExportRequestDTO param); + + /** + * 报表简要信息 + * @return + */ + @GetMapping("jmreport/get/{report-id}") + JiMuResult getReportBrief(@PathVariable("report-id") String reportId); } diff --git a/epmet-commons/epmet-commons-feignclient/src/main/java/com/epmet/commons/feignclient/feigns/fallback/JiMuReportOpenFeignClientFallback.java b/epmet-commons/epmet-commons-feignclient/src/main/java/com/epmet/commons/feignclient/feigns/fallback/JiMuReportOpenFeignClientFallback.java index b1c793d560..9158a6858c 100644 --- a/epmet-commons/epmet-commons-feignclient/src/main/java/com/epmet/commons/feignclient/feigns/fallback/JiMuReportOpenFeignClientFallback.java +++ b/epmet-commons/epmet-commons-feignclient/src/main/java/com/epmet/commons/feignclient/feigns/fallback/JiMuReportOpenFeignClientFallback.java @@ -3,6 +3,7 @@ package com.epmet.commons.feignclient.feigns.fallback; import com.epmet.commons.feignclient.dtos.JiMuPage; import com.epmet.commons.feignclient.dtos.JiMuResult; import com.epmet.commons.feignclient.dtos.form.JimuReportExportRequestDTO; +import com.epmet.commons.feignclient.dtos.result.JiMuReportBriefResultDTO; import com.epmet.commons.feignclient.dtos.result.JiMuReportDetailResultDTO; import com.epmet.commons.feignclient.dtos.result.JimuReportDbDataResultDTO; import com.epmet.commons.feignclient.dtos.result.JimuReportFieldTreeResultDTO; @@ -48,4 +49,10 @@ public class JiMuReportOpenFeignClientFallback implements JiMuReportOpenFeignCli JiMuResult rst = new JiMuResult<>(false, "请求失败", 200, null,null); return rst; } + + @Override + public JiMuResult getReportBrief(String reportID) { + JiMuResult rst = new JiMuResult<>(false, "请求失败", 200, null,null); + return rst; + } } diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java index f88fd01ee9..27450721d8 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java @@ -9,10 +9,7 @@ import com.epmet.commons.feignclient.dtos.JiMuPage; import com.epmet.commons.feignclient.dtos.JiMuResult; import com.epmet.commons.feignclient.dtos.form.JiMuReportFormDTO; import com.epmet.commons.feignclient.dtos.form.JimuReportExportRequestDTO; -import com.epmet.commons.feignclient.dtos.result.JiMuReportDetailResultDTO; -import com.epmet.commons.feignclient.dtos.result.JiMuReportResultDTO; -import com.epmet.commons.feignclient.dtos.result.JimuReportDbDataResultDTO; -import com.epmet.commons.feignclient.dtos.result.JimuReportFieldTreeResultDTO; +import com.epmet.commons.feignclient.dtos.result.*; import com.epmet.commons.feignclient.feigns.JiMuReportOpenFeignClient; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.*; @@ -280,14 +277,18 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl>> fResult = jiMuReportOpenFeignClient.fieldTree(reportId); String datasourceId = fResult.getResult().get(0).get(0).getDbId(); - // 根据数据源ID查询数据源信息 + // 报表数据源信息 JiMuResult dbData = jiMuReportOpenFeignClient.loadDbData(datasourceId); JimuReportDbDataResultDTO.ReportDB reportDb = dbData.getResult().getReportDb(); + // 报表简要信息 + JiMuResult reportBriefResult = jiMuReportOpenFeignClient.getReportBrief(reportId); + JiMuReportBriefResultDTO reportBrief = reportBriefResult.getResult(); + // api的url String apiUrl = reportDb.getApiUrl(); // api方法 @@ -296,29 +297,34 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl ids = listIds(bizId, paramKey, apiUrl, isHttps, idFieldName); + HashMap idAndNames = listBizObjectIdAndName(bizId, paramKey, apiUrl, isHttps, idFieldName, nameFieldName); // 3. 然后以这一列作为查询条件,循环,继续调用该接口,得到单条数据,每一条数据都下载一个excel,最后将其打包为一个压缩包下载 Path storePath = makeTemporaryDownloadDir(reportId); // 4.生成压缩文件 - Path zipFile = downloadAndComppress(storePath, reportId, reportDb.getDbChName(), paramKey, ids); + Path zipFile = downloadAndComppress(storePath, reportId, reportBrief.getName(), paramKey, idAndNames); // 5.下载 try (FileInputStream fis = new FileInputStream(zipFile.toFile())) { @@ -342,10 +348,9 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl ids) { + private Path downloadAndComppress(Path storePath, String reportId, String reportName, String paramKey, HashMap idAndNames) { // 请求头 Map headers = new HashMap<>(); headers.put(Constant.AUTHORIZATION_HEADER, EpmetRequestHolder.getHeader(Constant.AUTHORIZATION_HEADER)); @@ -360,7 +365,7 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl files = new ArrayList<>(); + HashMap files = new HashMap<>(); String currentTimeStr = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss")); @@ -373,13 +378,15 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl> idParts = ListUtils.partition(ids, 100); + ArrayList idList = new ArrayList<>(); + idList.addAll(idAndNames.keySet()); + List> idParts = ListUtils.partition(idList, 100); // 1. 循环下载所有id对应的excel CountDownLatch cdl = new CountDownLatch(idParts.size()); for (List idPart : idParts) { CompletableFuture.runAsync(() -> { - downloadXlsByBatchByBizId(reportId, idPart, param, xlsxStorePath, files, cdl); + downloadXlsByBatchByBizId(reportId, idPart, idAndNames, param, xlsxStorePath, files, cdl); }, executorService); } @@ -397,9 +404,17 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl bizObjNameAndCount = new HashMap<>(32); + for (Map.Entry entry : files.entrySet()) { + String bizObjectId = entry.getKey(); + File file = entry.getValue(); + + String bizObjName = idAndNames.get(bizObjectId); + + bizObjName = getBizObjName(bizObjNameAndCount, bizObjName); + try (final FileInputStream fis = new FileInputStream(file.getAbsolutePath())) { - zos.putNextEntry(new ZipEntry(reportName + "_" + currentTimeStr + "/" + file.getName())); + zos.putNextEntry(new ZipEntry(String.format("%s_%s/%s_%s.xlsx", reportName, currentTimeStr, reportName, bizObjName))); final byte[] buffer = new byte[10240]; for (int len; (len = fis.read(buffer)) > 0; ) { zos.write(buffer, 0, len); @@ -421,6 +436,22 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl bizObjNameAndCount, String bizObjName) { + Integer nameCount = bizObjNameAndCount.get(bizObjName); + if (nameCount == null) { + nameCount = 1; + bizObjNameAndCount.put(bizObjName, nameCount); + } else { + bizObjNameAndCount.put(bizObjName, ++nameCount); + } + + if (nameCount > 1) { + bizObjName = String.format("%s(%d)", bizObjName, nameCount); + } + + return bizObjName; + } + /** * 批量下载xlsx * @param reportId @@ -429,7 +460,7 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl bizIds, JimuReportExportRequestDTO param, Path xlsxStorePath, ArrayList files, + public void downloadXlsByBatchByBizId(String reportId, List bizIds, Map idAndNames, JimuReportExportRequestDTO param, Path xlsxStorePath, Map files, CountDownLatch cdl) { for (String id : bizIds) { @@ -456,7 +487,7 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl listIds(String id, String paramKey, String apiUrl, boolean isHttps, String idFieldName) { + public HashMap listBizObjectIdAndName(String id, String paramKey, String apiUrl, boolean isHttps, String idFieldName, String nameFieldName) { apiUrl = apiUrl.replace("'${id}'", id == null ? "" : id); apiUrl = apiUrl.replace("'${paramKey}'", paramKey); @@ -526,7 +557,7 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl ids = new ArrayList<>(); + HashMap idAndNames = new HashMap<>(); if (data instanceof JSONObject) { // 这种可能是pageData的 @@ -539,8 +570,10 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl it = array.listIterator(); it.hasNext(); ) { JSONObject e = (JSONObject) it.next(); - ids.add(e.getString(idFieldName)); + String idValue = e.getString(idFieldName); + String nameValue = e.getString(nameFieldName); + idAndNames.put(idValue, nameValue); } - return ids; + return idAndNames; } } \ No newline at end of file From c47157141f9a24f838df8da3dd611fd4ff502c0c Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Thu, 18 Aug 2022 12:55:04 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E3=80=90=E6=8A=A5=E8=A1=A8=E3=80=91pc?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E5=8D=95=E6=8A=A5=E8=A1=A8=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD-=E7=94=B1=E4=BA=8E=E7=A7=AF=E6=9C=A8?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=8C=E5=8F=96=E6=B6=88=E5=A4=9A=E7=BA=BF?= =?UTF-8?q?=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/IcCustomerReportServiceImpl.java | 76 ++++++++++++------- 1 file changed, 47 insertions(+), 29 deletions(-) diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java index 27450721d8..4f6277d886 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java @@ -55,8 +55,6 @@ import java.nio.file.Path; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -279,20 +277,29 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl>> fResult = jiMuReportOpenFeignClient.fieldTree(reportId); + if (fResult == null || !fResult.isSuccess()) { + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "根据报表id未找到字段列表,报表ID:" + reportId, "根据报表id未找到字段列表,报表ID:" + reportId); + } String datasourceId = fResult.getResult().get(0).get(0).getDbId(); // 报表数据源信息 JiMuResult dbData = jiMuReportOpenFeignClient.loadDbData(datasourceId); + if (fResult == null || !fResult.isSuccess()) { + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "根据报表id未找到数据源,报表ID:" + reportId, "根据报表id未找到数据源,报表ID:" + reportId); + } JimuReportDbDataResultDTO.ReportDB reportDb = dbData.getResult().getReportDb(); // 报表简要信息 JiMuResult reportBriefResult = jiMuReportOpenFeignClient.getReportBrief(reportId); + if (fResult == null || !fResult.isSuccess()) { + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "根据报表id未找到报表信息,报表ID:" + reportId, "根据报表id未找到报表信息,报表ID:" + reportId); + } JiMuReportBriefResultDTO reportBrief = reportBriefResult.getResult(); // api的url String apiUrl = reportDb.getApiUrl(); // api方法 - //String apiMethod = reportDb.getApiMethod(); + String apiMethod = reportDb.getApiMethod(); // 是否是集合 //String isList = reportDb.getIsList(); // 返回的列表中,哪个字段是ID @@ -318,13 +325,13 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl idAndNames = listBizObjectIdAndName(bizId, paramKey, apiUrl, isHttps, idFieldName, nameFieldName); + HashMap idAndNames = listBizObjectIdAndName(bizId, paramKey, apiUrl, isHttps, idFieldName, nameFieldName, apiMethod); // 3. 然后以这一列作为查询条件,循环,继续调用该接口,得到单条数据,每一条数据都下载一个excel,最后将其打包为一个压缩包下载 Path storePath = makeTemporaryDownloadDir(reportId); // 4.生成压缩文件 - Path zipFile = downloadAndComppress(storePath, reportId, reportBrief.getName(), paramKey, idAndNames); + Path zipFile = downloadAndCompress(storePath, reportId, reportBrief.getName(), paramKey, idAndNames); // 5.下载 try (FileInputStream fis = new FileInputStream(zipFile.toFile())) { @@ -350,7 +357,7 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl idAndNames) { + private Path downloadAndCompress(Path storePath, String reportId, String reportName, String paramKey, HashMap idAndNames) { // 请求头 Map headers = new HashMap<>(); headers.put(Constant.AUTHORIZATION_HEADER, EpmetRequestHolder.getHeader(Constant.AUTHORIZATION_HEADER)); @@ -382,21 +389,22 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl> idParts = ListUtils.partition(idList, 100); - // 1. 循环下载所有id对应的excel - CountDownLatch cdl = new CountDownLatch(idParts.size()); + // 1. 循环下载所有id对应的excel(积木报表的导出接口有并发问题,多线程会导出空表,暂时不用多线程了) + //CountDownLatch cdl = new CountDownLatch(idParts.size()); for (List idPart : idParts) { - CompletableFuture.runAsync(() -> { - downloadXlsByBatchByBizId(reportId, idPart, idAndNames, param, xlsxStorePath, files, cdl); - }, executorService); + downloadXlsByBatchByBizId(reportId, idPart, idAndNames, param, xlsxStorePath, files); + //CompletableFuture.runAsync(() -> { + // downloadXlsByBatchByBizId(reportId, idPart, idAndNames, param, xlsxStorePath, files, cdl); + //}, executorService); } // 等待多线程执行完成,再执行打包 - try { - cdl.await(); - } catch (InterruptedException e) { - log.error(ExceptionUtils.getErrorStackTrace(e)); - throw new EpmetException("【报表批量导出】CountDownLatch等待被中断"); - } + //try { + // cdl.await(); + //} catch (InterruptedException e) { + // log.error(ExceptionUtils.getErrorStackTrace(e)); + // throw new EpmetException("【报表批量导出】CountDownLatch等待被中断"); + //} // 2,打包 Path zipFile = storePath.resolve(reportName + "_" + currentTimeStr + ".zip"); @@ -409,11 +417,9 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl 0; ) { @@ -436,7 +442,13 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl bizObjNameAndCount, String bizObjName) { + /** + * 为业务对象名称编号,解决重名对象问题 + * @param bizObjNameAndCount 业务对象名称/出现次数map + * @param bizObjName 原始业务对象名 + * @return + */ + public String getNumberedObjName(HashMap bizObjNameAndCount, String bizObjName) { Integer nameCount = bizObjNameAndCount.get(bizObjName); if (nameCount == null) { nameCount = 1; @@ -460,8 +472,7 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl bizIds, Map idAndNames, JimuReportExportRequestDTO param, Path xlsxStorePath, Map files, - CountDownLatch cdl) { + public void downloadXlsByBatchByBizId(String reportId, List bizIds, Map idAndNames, JimuReportExportRequestDTO param, Path xlsxStorePath, Map files) { for (String id : bizIds) { try { @@ -495,7 +506,7 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl listBizObjectIdAndName(String id, String paramKey, String apiUrl, boolean isHttps, String idFieldName, String nameFieldName) { + public HashMap listBizObjectIdAndName(String id, String paramKey, String apiUrl, boolean isHttps, String idFieldName, String nameFieldName, String apiMethod) { apiUrl = apiUrl.replace("'${id}'", id == null ? "" : id); apiUrl = apiUrl.replace("'${paramKey}'", paramKey); Map headers = new HashMap<>(); headers.put(Constant.AUTHORIZATION_HEADER, EpmetRequestHolder.getHeader(Constant.AUTHORIZATION_HEADER)); - Result stringResult = HttpClientManager.getInstance().sendPost(apiUrl, isHttps, "{\"id\":" + id + "}", headers); + + Result stringResult; + // 请求方法0-get,1-post + if (NumConstant.ONE_STR.equals(apiMethod)) { + stringResult = HttpClientManager.getInstance().sendPost(apiUrl, isHttps, "{\"id\":\"" + (id == null ? "" : id) + "\"}", headers); + } else { + stringResult = HttpClientManager.getInstance().sendGet(apiUrl, isHttps, null, headers); + } JSONObject dataJsonObject = JSON.parseObject(stringResult.getData()); Object data = dataJsonObject.get("data"); - JSONArray array = new JSONArray(); + JSONArray array; HashMap idAndNames = new HashMap<>(); if (data instanceof JSONObject) { From 6167d22a66a10684afa75840bb17cfb9028222cf Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Thu, 18 Aug 2022 12:58:40 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E3=80=90=E6=8A=A5=E8=A1=A8=E3=80=91pc?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E5=8D=95=E6=8A=A5=E8=A1=A8=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD-=E7=94=B1=E4=BA=8E=E7=A7=AF=E6=9C=A8?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=8C=E5=8F=96=E6=B6=88=E5=A4=9A=E7=BA=BF?= =?UTF-8?q?=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/IcCustomerReportServiceImpl.java | 76 +++++++------------ 1 file changed, 29 insertions(+), 47 deletions(-) diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java index 4f6277d886..27450721d8 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java @@ -55,6 +55,8 @@ import java.nio.file.Path; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -277,29 +279,20 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl>> fResult = jiMuReportOpenFeignClient.fieldTree(reportId); - if (fResult == null || !fResult.isSuccess()) { - throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "根据报表id未找到字段列表,报表ID:" + reportId, "根据报表id未找到字段列表,报表ID:" + reportId); - } String datasourceId = fResult.getResult().get(0).get(0).getDbId(); // 报表数据源信息 JiMuResult dbData = jiMuReportOpenFeignClient.loadDbData(datasourceId); - if (fResult == null || !fResult.isSuccess()) { - throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "根据报表id未找到数据源,报表ID:" + reportId, "根据报表id未找到数据源,报表ID:" + reportId); - } JimuReportDbDataResultDTO.ReportDB reportDb = dbData.getResult().getReportDb(); // 报表简要信息 JiMuResult reportBriefResult = jiMuReportOpenFeignClient.getReportBrief(reportId); - if (fResult == null || !fResult.isSuccess()) { - throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "根据报表id未找到报表信息,报表ID:" + reportId, "根据报表id未找到报表信息,报表ID:" + reportId); - } JiMuReportBriefResultDTO reportBrief = reportBriefResult.getResult(); // api的url String apiUrl = reportDb.getApiUrl(); // api方法 - String apiMethod = reportDb.getApiMethod(); + //String apiMethod = reportDb.getApiMethod(); // 是否是集合 //String isList = reportDb.getIsList(); // 返回的列表中,哪个字段是ID @@ -325,13 +318,13 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl idAndNames = listBizObjectIdAndName(bizId, paramKey, apiUrl, isHttps, idFieldName, nameFieldName, apiMethod); + HashMap idAndNames = listBizObjectIdAndName(bizId, paramKey, apiUrl, isHttps, idFieldName, nameFieldName); // 3. 然后以这一列作为查询条件,循环,继续调用该接口,得到单条数据,每一条数据都下载一个excel,最后将其打包为一个压缩包下载 Path storePath = makeTemporaryDownloadDir(reportId); // 4.生成压缩文件 - Path zipFile = downloadAndCompress(storePath, reportId, reportBrief.getName(), paramKey, idAndNames); + Path zipFile = downloadAndComppress(storePath, reportId, reportBrief.getName(), paramKey, idAndNames); // 5.下载 try (FileInputStream fis = new FileInputStream(zipFile.toFile())) { @@ -357,7 +350,7 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl idAndNames) { + private Path downloadAndComppress(Path storePath, String reportId, String reportName, String paramKey, HashMap idAndNames) { // 请求头 Map headers = new HashMap<>(); headers.put(Constant.AUTHORIZATION_HEADER, EpmetRequestHolder.getHeader(Constant.AUTHORIZATION_HEADER)); @@ -389,22 +382,21 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl> idParts = ListUtils.partition(idList, 100); - // 1. 循环下载所有id对应的excel(积木报表的导出接口有并发问题,多线程会导出空表,暂时不用多线程了) - //CountDownLatch cdl = new CountDownLatch(idParts.size()); + // 1. 循环下载所有id对应的excel + CountDownLatch cdl = new CountDownLatch(idParts.size()); for (List idPart : idParts) { - downloadXlsByBatchByBizId(reportId, idPart, idAndNames, param, xlsxStorePath, files); - //CompletableFuture.runAsync(() -> { - // downloadXlsByBatchByBizId(reportId, idPart, idAndNames, param, xlsxStorePath, files, cdl); - //}, executorService); + CompletableFuture.runAsync(() -> { + downloadXlsByBatchByBizId(reportId, idPart, idAndNames, param, xlsxStorePath, files, cdl); + }, executorService); } // 等待多线程执行完成,再执行打包 - //try { - // cdl.await(); - //} catch (InterruptedException e) { - // log.error(ExceptionUtils.getErrorStackTrace(e)); - // throw new EpmetException("【报表批量导出】CountDownLatch等待被中断"); - //} + try { + cdl.await(); + } catch (InterruptedException e) { + log.error(ExceptionUtils.getErrorStackTrace(e)); + throw new EpmetException("【报表批量导出】CountDownLatch等待被中断"); + } // 2,打包 Path zipFile = storePath.resolve(reportName + "_" + currentTimeStr + ".zip"); @@ -417,9 +409,11 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl 0; ) { @@ -442,13 +436,7 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl bizObjNameAndCount, String bizObjName) { + public String getBizObjName(HashMap bizObjNameAndCount, String bizObjName) { Integer nameCount = bizObjNameAndCount.get(bizObjName); if (nameCount == null) { nameCount = 1; @@ -472,7 +460,8 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl bizIds, Map idAndNames, JimuReportExportRequestDTO param, Path xlsxStorePath, Map files) { + public void downloadXlsByBatchByBizId(String reportId, List bizIds, Map idAndNames, JimuReportExportRequestDTO param, Path xlsxStorePath, Map files, + CountDownLatch cdl) { for (String id : bizIds) { try { @@ -506,7 +495,7 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl listBizObjectIdAndName(String id, String paramKey, String apiUrl, boolean isHttps, String idFieldName, String nameFieldName, String apiMethod) { + public HashMap listBizObjectIdAndName(String id, String paramKey, String apiUrl, boolean isHttps, String idFieldName, String nameFieldName) { apiUrl = apiUrl.replace("'${id}'", id == null ? "" : id); apiUrl = apiUrl.replace("'${paramKey}'", paramKey); Map headers = new HashMap<>(); headers.put(Constant.AUTHORIZATION_HEADER, EpmetRequestHolder.getHeader(Constant.AUTHORIZATION_HEADER)); - - Result stringResult; - // 请求方法0-get,1-post - if (NumConstant.ONE_STR.equals(apiMethod)) { - stringResult = HttpClientManager.getInstance().sendPost(apiUrl, isHttps, "{\"id\":\"" + (id == null ? "" : id) + "\"}", headers); - } else { - stringResult = HttpClientManager.getInstance().sendGet(apiUrl, isHttps, null, headers); - } + Result stringResult = HttpClientManager.getInstance().sendPost(apiUrl, isHttps, "{\"id\":" + id + "}", headers); JSONObject dataJsonObject = JSON.parseObject(stringResult.getData()); Object data = dataJsonObject.get("data"); - JSONArray array; + JSONArray array = new JSONArray(); HashMap idAndNames = new HashMap<>(); if (data instanceof JSONObject) { From 9d8f2da056eb3baea5d1548cecdfaad2a0527c20 Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Thu, 18 Aug 2022 13:01:38 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E3=80=90=E6=8A=A5=E8=A1=A8=E3=80=91pc?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E5=8D=95=E6=8A=A5=E8=A1=A8=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD-=E7=94=B1=E4=BA=8E=E7=A7=AF=E6=9C=A8?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=8C=E5=8F=96=E6=B6=88=E5=A4=9A=E7=BA=BF?= =?UTF-8?q?=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/IcCustomerReportServiceImpl.java | 76 ++++++++++++------- 1 file changed, 47 insertions(+), 29 deletions(-) diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java index 27450721d8..4f6277d886 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java @@ -55,8 +55,6 @@ import java.nio.file.Path; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -279,20 +277,29 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl>> fResult = jiMuReportOpenFeignClient.fieldTree(reportId); + if (fResult == null || !fResult.isSuccess()) { + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "根据报表id未找到字段列表,报表ID:" + reportId, "根据报表id未找到字段列表,报表ID:" + reportId); + } String datasourceId = fResult.getResult().get(0).get(0).getDbId(); // 报表数据源信息 JiMuResult dbData = jiMuReportOpenFeignClient.loadDbData(datasourceId); + if (fResult == null || !fResult.isSuccess()) { + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "根据报表id未找到数据源,报表ID:" + reportId, "根据报表id未找到数据源,报表ID:" + reportId); + } JimuReportDbDataResultDTO.ReportDB reportDb = dbData.getResult().getReportDb(); // 报表简要信息 JiMuResult reportBriefResult = jiMuReportOpenFeignClient.getReportBrief(reportId); + if (fResult == null || !fResult.isSuccess()) { + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "根据报表id未找到报表信息,报表ID:" + reportId, "根据报表id未找到报表信息,报表ID:" + reportId); + } JiMuReportBriefResultDTO reportBrief = reportBriefResult.getResult(); // api的url String apiUrl = reportDb.getApiUrl(); // api方法 - //String apiMethod = reportDb.getApiMethod(); + String apiMethod = reportDb.getApiMethod(); // 是否是集合 //String isList = reportDb.getIsList(); // 返回的列表中,哪个字段是ID @@ -318,13 +325,13 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl idAndNames = listBizObjectIdAndName(bizId, paramKey, apiUrl, isHttps, idFieldName, nameFieldName); + HashMap idAndNames = listBizObjectIdAndName(bizId, paramKey, apiUrl, isHttps, idFieldName, nameFieldName, apiMethod); // 3. 然后以这一列作为查询条件,循环,继续调用该接口,得到单条数据,每一条数据都下载一个excel,最后将其打包为一个压缩包下载 Path storePath = makeTemporaryDownloadDir(reportId); // 4.生成压缩文件 - Path zipFile = downloadAndComppress(storePath, reportId, reportBrief.getName(), paramKey, idAndNames); + Path zipFile = downloadAndCompress(storePath, reportId, reportBrief.getName(), paramKey, idAndNames); // 5.下载 try (FileInputStream fis = new FileInputStream(zipFile.toFile())) { @@ -350,7 +357,7 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl idAndNames) { + private Path downloadAndCompress(Path storePath, String reportId, String reportName, String paramKey, HashMap idAndNames) { // 请求头 Map headers = new HashMap<>(); headers.put(Constant.AUTHORIZATION_HEADER, EpmetRequestHolder.getHeader(Constant.AUTHORIZATION_HEADER)); @@ -382,21 +389,22 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl> idParts = ListUtils.partition(idList, 100); - // 1. 循环下载所有id对应的excel - CountDownLatch cdl = new CountDownLatch(idParts.size()); + // 1. 循环下载所有id对应的excel(积木报表的导出接口有并发问题,多线程会导出空表,暂时不用多线程了) + //CountDownLatch cdl = new CountDownLatch(idParts.size()); for (List idPart : idParts) { - CompletableFuture.runAsync(() -> { - downloadXlsByBatchByBizId(reportId, idPart, idAndNames, param, xlsxStorePath, files, cdl); - }, executorService); + downloadXlsByBatchByBizId(reportId, idPart, idAndNames, param, xlsxStorePath, files); + //CompletableFuture.runAsync(() -> { + // downloadXlsByBatchByBizId(reportId, idPart, idAndNames, param, xlsxStorePath, files, cdl); + //}, executorService); } // 等待多线程执行完成,再执行打包 - try { - cdl.await(); - } catch (InterruptedException e) { - log.error(ExceptionUtils.getErrorStackTrace(e)); - throw new EpmetException("【报表批量导出】CountDownLatch等待被中断"); - } + //try { + // cdl.await(); + //} catch (InterruptedException e) { + // log.error(ExceptionUtils.getErrorStackTrace(e)); + // throw new EpmetException("【报表批量导出】CountDownLatch等待被中断"); + //} // 2,打包 Path zipFile = storePath.resolve(reportName + "_" + currentTimeStr + ".zip"); @@ -409,11 +417,9 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl 0; ) { @@ -436,7 +442,13 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl bizObjNameAndCount, String bizObjName) { + /** + * 为业务对象名称编号,解决重名对象问题 + * @param bizObjNameAndCount 业务对象名称/出现次数map + * @param bizObjName 原始业务对象名 + * @return + */ + public String getNumberedObjName(HashMap bizObjNameAndCount, String bizObjName) { Integer nameCount = bizObjNameAndCount.get(bizObjName); if (nameCount == null) { nameCount = 1; @@ -460,8 +472,7 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl bizIds, Map idAndNames, JimuReportExportRequestDTO param, Path xlsxStorePath, Map files, - CountDownLatch cdl) { + public void downloadXlsByBatchByBizId(String reportId, List bizIds, Map idAndNames, JimuReportExportRequestDTO param, Path xlsxStorePath, Map files) { for (String id : bizIds) { try { @@ -495,7 +506,7 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl listBizObjectIdAndName(String id, String paramKey, String apiUrl, boolean isHttps, String idFieldName, String nameFieldName) { + public HashMap listBizObjectIdAndName(String id, String paramKey, String apiUrl, boolean isHttps, String idFieldName, String nameFieldName, String apiMethod) { apiUrl = apiUrl.replace("'${id}'", id == null ? "" : id); apiUrl = apiUrl.replace("'${paramKey}'", paramKey); Map headers = new HashMap<>(); headers.put(Constant.AUTHORIZATION_HEADER, EpmetRequestHolder.getHeader(Constant.AUTHORIZATION_HEADER)); - Result stringResult = HttpClientManager.getInstance().sendPost(apiUrl, isHttps, "{\"id\":" + id + "}", headers); + + Result stringResult; + // 请求方法0-get,1-post + if (NumConstant.ONE_STR.equals(apiMethod)) { + stringResult = HttpClientManager.getInstance().sendPost(apiUrl, isHttps, "{\"id\":\"" + (id == null ? "" : id) + "\"}", headers); + } else { + stringResult = HttpClientManager.getInstance().sendGet(apiUrl, isHttps, null, headers); + } JSONObject dataJsonObject = JSON.parseObject(stringResult.getData()); Object data = dataJsonObject.get("data"); - JSONArray array = new JSONArray(); + JSONArray array; HashMap idAndNames = new HashMap<>(); if (data instanceof JSONObject) { From 8ccafc581a4ca9d887746e6341a6140b7e096558 Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Thu, 18 Aug 2022 16:35:35 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E3=80=90=E6=8A=A5=E8=A1=A8=E3=80=91?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89excel=E6=89=B9=E9=87=8F=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=8E=BB=E6=8E=89@NoRepeatSubmit=E6=B3=A8=E8=A7=A3?= =?UTF-8?q?=EF=BC=8C=E8=A7=A3=E5=86=B3=E6=89=B9=E9=87=8F=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E6=8A=A5=E8=A1=A8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/epmet/controller/IcResiUserController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java index 3e268bf8d9..7604ebc5c7 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java @@ -560,7 +560,7 @@ public class IcResiUserController implements ResultDataResolver { * @remark 用于报表调用的接口 试试 */ @ReportRequest - @NoRepeatSubmit + //@NoRepeatSubmit @RequestMapping(value = "/exportExcelCustomData") public Map exportExcelCustomData(@LoginUser TokenDto tokenDto, @RequestParam("templateId") String templateId, @RequestBody ExportResiUserFormDTO pageFormDTO) throws Exception { From b6da810145afa2eee428a71e991312a4968c3946 Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Thu, 18 Aug 2022 16:37:21 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E3=80=90=E6=8A=A5=E8=A1=A8=E3=80=91?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89excel=E6=89=B9=E9=87=8F=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=8E=BB=E6=8E=89@NoRepeatSubmit=E6=B3=A8=E8=A7=A3?= =?UTF-8?q?=EF=BC=8C=E8=A7=A3=E5=86=B3=E6=89=B9=E9=87=8F=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E6=8A=A5=E8=A1=A8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/epmet/controller/IcResiUserController.java | 1 - 1 file changed, 1 deletion(-) diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java index 40e661a63b..c574eb3dcd 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java @@ -559,7 +559,6 @@ public class IcResiUserController implements ResultDataResolver { * @remark 用于报表调用的接口 试试 */ @ReportRequest - @NoRepeatSubmit @RequestMapping(value = "/exportExcelCustomData") public Map exportExcelCustomData(@LoginUser TokenDto tokenDto, @RequestParam("templateId") String templateId, @RequestBody ExportResiUserFormDTO pageFormDTO) throws Exception { From 0dfe9fb8b3113def4fbc392550b20034ea5339aa Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Thu, 18 Aug 2022 16:40:05 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E3=80=90=E6=8A=A5=E8=A1=A8=E3=80=91?= =?UTF-8?q?=E5=8F=88=E8=A6=81=E7=94=A8=E5=A4=9A=E7=BA=BF=E7=A8=8B=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/IcCustomerReportServiceImpl.java | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java index 4f6277d886..f9a1707342 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java @@ -55,6 +55,8 @@ import java.nio.file.Path; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -390,21 +392,20 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl> idParts = ListUtils.partition(idList, 100); // 1. 循环下载所有id对应的excel(积木报表的导出接口有并发问题,多线程会导出空表,暂时不用多线程了) - //CountDownLatch cdl = new CountDownLatch(idParts.size()); + CountDownLatch cdl = new CountDownLatch(idParts.size()); for (List idPart : idParts) { - downloadXlsByBatchByBizId(reportId, idPart, idAndNames, param, xlsxStorePath, files); - //CompletableFuture.runAsync(() -> { - // downloadXlsByBatchByBizId(reportId, idPart, idAndNames, param, xlsxStorePath, files, cdl); - //}, executorService); + CompletableFuture.runAsync(() -> { + downloadXlsByBatchByBizId(reportId, idPart, param, xlsxStorePath, files, cdl); + }, executorService); } // 等待多线程执行完成,再执行打包 - //try { - // cdl.await(); - //} catch (InterruptedException e) { - // log.error(ExceptionUtils.getErrorStackTrace(e)); - // throw new EpmetException("【报表批量导出】CountDownLatch等待被中断"); - //} + try { + cdl.await(); + } catch (InterruptedException e) { + log.error(ExceptionUtils.getErrorStackTrace(e)); + throw new EpmetException("【报表批量导出】CountDownLatch等待被中断"); + } // 2,打包 Path zipFile = storePath.resolve(reportName + "_" + currentTimeStr + ".zip"); @@ -472,7 +473,8 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl bizIds, Map idAndNames, JimuReportExportRequestDTO param, Path xlsxStorePath, Map files) { + public void downloadXlsByBatchByBizId(String reportId, List bizIds, JimuReportExportRequestDTO param, + Path xlsxStorePath, Map files, CountDownLatch cdl) { for (String id : bizIds) { try { @@ -506,7 +508,7 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl Date: Thu, 18 Aug 2022 16:59:09 +0800 Subject: [PATCH 8/9] =?UTF-8?q?=E3=80=90=E6=8A=A5=E8=A1=A8=E3=80=91?= =?UTF-8?q?=E5=A4=9A=E7=BA=BF=E7=A8=8B=E5=AF=BC=E5=87=BA=E4=B8=8D=E7=9D=A1?= =?UTF-8?q?=E7=9C=A0=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/IcCustomerReportServiceImpl.java | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java index f9a1707342..2775448c20 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java @@ -476,18 +476,6 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl bizIds, JimuReportExportRequestDTO param, Path xlsxStorePath, Map files, CountDownLatch cdl) { for (String id : bizIds) { - - try { - Thread.sleep(200l); - } catch (InterruptedException e) { - final String errorMsg = ExceptionUtils.getErrorStackTrace(e); - log.error("【报表批量导出】循环导出-请求jmreport,等待过程中睡眠发生意外:{}", errorMsg); - } - - //if (!Arrays.asList("1501821697823608834","1501821694665297922","1501821695114088450","1501821695177003009","1501821695269277697","1501821695344775169","1501821695579656193","1501821695676125186","1501821695755816962","1501821695843897346","1501821695978115074","1501821696108138497","1501821696179441665","1501821696229773313","1501821696284299266","1501821696334630913","1501821696393351170","1501821696452071426","1501821696502403073","1501821696582094849","1501821696645009409","1501821696758255617","1501821696871501826","1501821696917639169","1501821696955387906","1501821696993136641","1501821697135742977","1501821697181880321","1501821697232211969","1501821697274155009").contains(id)) { - // continue; - //} - param.getQueryParam().setId(id); final Response response = jiMuReportOpenFeignClient.exportAllExcelStream(param); // 取出文件后缀 From 068265f814114a04134c157986fb1489db07436c Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Thu, 18 Aug 2022 22:05:11 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E3=80=90=E6=8C=87=E6=8C=A5=E8=B0=83?= =?UTF-8?q?=E5=BA=A6=E3=80=91=E6=A0=B8=E9=85=B8=E6=A3=80=E6=B5=8B&?= =?UTF-8?q?=E7=96=AB=E8=8B=97=E6=8E=A5=E7=A7=8D=EF=BC=8C=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E7=9A=84=E6=95=B0=E6=8D=AE=EF=BC=8C=E8=80=8C?= =?UTF-8?q?=E4=B8=8D=E6=98=AF=E7=AE=A1=E7=90=86=E5=B9=B3=E5=8F=B0=E5=85=AC?= =?UTF-8?q?=E5=85=B1=E6=9C=8D=E5=8A=A1=E5=9B=BE=E5=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/enums/CoveragePlaceTypeEnum.java | 4 +- .../IcPointNucleicMonitoringDao.java | 17 +++ .../IcPointVaccinesInoculationDao.java | 17 +++ .../IcPointNucleicMonitoringEntity.java | 77 +++++++++++++ .../IcPointVaccinesInoculationEntity.java | 102 ++++++++++++++++++ .../service/epmetuser/EpmetUserService.java | 10 ++ .../epmetuser/impl/EpmetUserServiceImpl.java | 48 +++++++++ .../service/impl/CoverageServiceImpl.java | 22 ++++ 8 files changed, 296 insertions(+), 1 deletion(-) create mode 100644 epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/IcPointNucleicMonitoringDao.java create mode 100644 epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/IcPointVaccinesInoculationDao.java create mode 100644 epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/entity/epmetuser/IcPointNucleicMonitoringEntity.java create mode 100644 epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/entity/epmetuser/IcPointVaccinesInoculationEntity.java diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/CoveragePlaceTypeEnum.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/CoveragePlaceTypeEnum.java index 6f71e122b0..d15036075b 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/CoveragePlaceTypeEnum.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/CoveragePlaceTypeEnum.java @@ -18,7 +18,9 @@ public enum CoveragePlaceTypeEnum { VOLUNTEER("volunteer", "志愿者"), GROUP_RENT("group_rent", "群租房"), EVENT("event", "城市管理事件"), - ZHZL_RQ("zhzl_rq", "综合治理人群"); + ZHZL_RQ("zhzl_rq", "综合治理人群"), + NUCLEIC_POINT("nucleic_point", "核酸检测点"), + VACCINE_POINT("vaccine_point", "疫苗接种点"); private final String code; private final String name; diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/IcPointNucleicMonitoringDao.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/IcPointNucleicMonitoringDao.java new file mode 100644 index 0000000000..599243a856 --- /dev/null +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/IcPointNucleicMonitoringDao.java @@ -0,0 +1,17 @@ +package com.epmet.dataaggre.dao.epmetuser; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dataaggre.entity.epmetuser.IcPointNucleicMonitoringEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 核酸监测点 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-06-20 + */ +@Mapper +public interface IcPointNucleicMonitoringDao extends BaseDao { + + +} diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/IcPointVaccinesInoculationDao.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/IcPointVaccinesInoculationDao.java new file mode 100644 index 0000000000..a3bfafee1a --- /dev/null +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/IcPointVaccinesInoculationDao.java @@ -0,0 +1,17 @@ +package com.epmet.dataaggre.dao.epmetuser; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dataaggre.entity.epmetuser.IcPointVaccinesInoculationEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 疫苗接种点 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-06-20 + */ +@Mapper +public interface IcPointVaccinesInoculationDao extends BaseDao { + + +} diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/entity/epmetuser/IcPointNucleicMonitoringEntity.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/entity/epmetuser/IcPointNucleicMonitoringEntity.java new file mode 100644 index 0000000000..b19ab6b721 --- /dev/null +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/entity/epmetuser/IcPointNucleicMonitoringEntity.java @@ -0,0 +1,77 @@ +package com.epmet.dataaggre.entity.epmetuser; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 核酸监测点 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-06-20 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("ic_point_nucleic_monitoring") +public class IcPointNucleicMonitoringEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户ID + */ + private String customerId; + + /** + * 所属组织ID + */ + private String orgId; + + /** + * 所属组织名称 + */ + private String orgName; + + /** + * 组织ID上级 + */ + private String pid; + + /** + * 组织ID所有上级 + */ + private String pids; + + /** + * 核酸监测点名称 + */ + private String name; + + /** + * 服务时间 + */ + private String serveTime; + + /** + * 咨询电话 + */ + private String mobile; + + /** + * 监测点地址 + */ + private String address; + + /** + * 经度 + */ + private String longitude; + + /** + * 纬度 + */ + private String latitude; + +} diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/entity/epmetuser/IcPointVaccinesInoculationEntity.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/entity/epmetuser/IcPointVaccinesInoculationEntity.java new file mode 100644 index 0000000000..3e60c7660e --- /dev/null +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/entity/epmetuser/IcPointVaccinesInoculationEntity.java @@ -0,0 +1,102 @@ +package com.epmet.dataaggre.entity.epmetuser; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 疫苗接种点 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-06-20 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("ic_point_vaccines_inoculation") +public class IcPointVaccinesInoculationEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户ID + */ + private String customerId; + + /** + * 所属组织ID + */ + private String orgId; + + /** + * 所属组织名称 + */ + private String orgName; + + /** + * 组织ID上级 + */ + private String pid; + + /** + * 组织ID所有上级 + */ + private String pids; + + /** + * 疫苗接种点名称 + */ + private String name; + + /** + * 接种日期 + */ + private String inoculationDate; + + /** + * 接种上午开始时间 + */ + private String moStartTime; + + /** + * 接种上午结束时间 + */ + private String moEndTime; + + /** + * 接种下午开始时间 + */ + private String afStartTime; + + /** + * 接种下午结束时间 + */ + private String afEndTime; + + /** + * 暂无疫苗(1:是;2:否) + */ + private String noAvailableVaccines; + + /** + * 咨询电话 + */ + private String mobile; + + /** + * 接种点地址 + */ + private String address; + + /** + * 经度 + */ + private String longitude; + + /** + * 纬度 + */ + private String latitude; + +} diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java index 068b1176cd..901087a7ba 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java @@ -15,6 +15,8 @@ import com.epmet.dataaggre.dto.govorg.result.GridStaffResultDTO; import com.epmet.dataaggre.dto.govorg.result.MemberProjectInfoResultDTO; import com.epmet.dataaggre.dto.govproject.result.ProjectAnalysisResultDTO; import com.epmet.dataaggre.entity.epmetuser.CustomerStaffEntity; +import com.epmet.dataaggre.entity.epmetuser.IcPointNucleicMonitoringEntity; +import com.epmet.dataaggre.entity.epmetuser.IcPointVaccinesInoculationEntity; import com.epmet.dataaggre.entity.epmetuser.IcResiUserEntity; import com.epmet.dto.IcResiUserDTO; import com.epmet.dto.UserBaseInfoDTO; @@ -240,4 +242,12 @@ public interface EpmetUserService { List listVolunteers(String customerId, String agencyId, String staffOrgIds, String search, String resiCategory); List getNowResiUser(NowStatsDataFormDTO formDTO); + + Integer countVaccinePoint(String customerId, String agencyId, String staffOrgIds, String search); + + Integer countNucleicPoint(String customerId, String agencyId, String staffOrgIds, String search); + + List listVaccinePoints(String customerId, String agencyId, String staffOrgIds, String search); + + List listNucleicPoints(String customerId, String agencyId,String staffOrgIds, String search); } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java index 26c5ef1b3a..d9dd1269ea 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java @@ -94,6 +94,10 @@ public class EpmetUserServiceImpl implements EpmetUserService { private CustomerFootBarService customerFootBarService; @Resource private RegisterRelationDao registerRelationDao; + @Resource + private IcPointVaccinesInoculationDao pointVaccinesInoculationDao; + @Resource + private IcPointNucleicMonitoringDao pointNucleicMonitoringDao; /** * @Description 根据UserIds查询 @@ -923,4 +927,48 @@ public class EpmetUserServiceImpl implements EpmetUserService { List list = registerRelationDao.selectNowResiUser(formDTO); return list; } + + @Override + public Integer countVaccinePoint(String customerId, String agencyId, String staffOrgIds, String search) { + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.eq(IcPointVaccinesInoculationEntity::getCustomerId, customerId); + query.and(w -> w.likeRight(IcPointVaccinesInoculationEntity::getPids, staffOrgIds) + .or() + .eq(IcPointVaccinesInoculationEntity::getOrgId, agencyId)); + query.like(StringUtils.isNotBlank(search), IcPointVaccinesInoculationEntity::getName, search); + return pointVaccinesInoculationDao.selectCount(query); + } + + @Override + public Integer countNucleicPoint(String customerId, String agencyId, String staffOrgIds, String search) { + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.eq(IcPointNucleicMonitoringEntity::getCustomerId, customerId); + query.and(w -> w.likeRight(IcPointNucleicMonitoringEntity::getPids, staffOrgIds) + .or() + .eq(IcPointNucleicMonitoringEntity::getOrgId, agencyId)); + query.like(StringUtils.isNotBlank(search), IcPointNucleicMonitoringEntity::getName, search); + return pointNucleicMonitoringDao.selectCount(query); + } + + @Override + public List listVaccinePoints(String customerId, String agencyId, String staffOrgIds, String search) { + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.eq(IcPointVaccinesInoculationEntity::getCustomerId, customerId); + query.and(w -> w.likeRight(IcPointVaccinesInoculationEntity::getPids, staffOrgIds) + .or() + .eq(IcPointVaccinesInoculationEntity::getOrgId, agencyId)); + query.like(StringUtils.isNotBlank(search), IcPointVaccinesInoculationEntity::getName, search); + return pointVaccinesInoculationDao.selectList(query); + } + + @Override + public List listNucleicPoints(String customerId, String agencyId, String staffOrgIds, String search) { + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.eq(IcPointNucleicMonitoringEntity::getCustomerId, customerId); + query.and(w -> w.likeRight(IcPointNucleicMonitoringEntity::getPids, staffOrgIds) + .or() + .eq(IcPointNucleicMonitoringEntity::getOrgId, agencyId)); + query.like(StringUtils.isNotBlank(search), IcPointNucleicMonitoringEntity::getName, search); + return pointNucleicMonitoringDao.selectList(query); + } } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/impl/CoverageServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/impl/CoverageServiceImpl.java index 19b7c71d7e..ff931888c3 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/impl/CoverageServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/impl/CoverageServiceImpl.java @@ -30,6 +30,8 @@ import com.epmet.dataaggre.dto.govorg.form.DataListLeftSubTotalFormDTO; import com.epmet.dataaggre.dto.govorg.form.SearchDetailFormDTO; import com.epmet.dataaggre.dto.govorg.result.*; import com.epmet.dataaggre.dto.resigroup.result.OrgInfoCommonDTO; +import com.epmet.dataaggre.entity.epmetuser.IcPointNucleicMonitoringEntity; +import com.epmet.dataaggre.entity.epmetuser.IcPointVaccinesInoculationEntity; import com.epmet.dataaggre.entity.epmetuser.IcResiUserEntity; import com.epmet.dataaggre.entity.govorg.*; import com.epmet.dataaggre.entity.govproject.IcEventEntity; @@ -628,6 +630,12 @@ public class CoverageServiceImpl implements CoverageService { // 志愿者 String[] parts = categoryKey.split("_"); return epmetUserService.countVolunteers(customerId, agencyId, staffOrgIds, search, parts[1]); + } else if (CoveragePlaceTypeEnum.VACCINE_POINT.getCode().equals(placeType)) { + // 疫苗接种点 + return epmetUserService.countVaccinePoint(customerId, agencyId, staffOrgIds, search); + } else if (CoveragePlaceTypeEnum.NUCLEIC_POINT.getCode().equals(placeType)) { + // 核酸检测点 + return epmetUserService.countNucleicPoint(customerId, agencyId, staffOrgIds, search); } return 0; @@ -805,6 +813,20 @@ public class CoverageServiceImpl implements CoverageService { coordinates[1], coordinates[0]); }).collect(Collectors.toList()); + } else if (CoveragePlaceTypeEnum.VACCINE_POINT.getCode().equals(placeType)) { + // 疫苗接种点 + List vps = epmetUserService.listVaccinePoints(customerId, agencyId, staffOrgIds, search); + return vps.stream() + .map(vp -> new CoverageAnalisisDataListResultDTO(vp.getId(), categoryKey, isPage ? categoryDict.getCategoryName() : null, + placeType, vp.getName(), vp.getLatitude(), vp.getLongitude())) + .collect(Collectors.toList()); + } else if (CoveragePlaceTypeEnum.NUCLEIC_POINT.getCode().equals(placeType)) { + // 核酸检测点 + List nps = epmetUserService.listNucleicPoints(customerId, agencyId, staffOrgIds, search); + return nps.stream() + .map(np -> new CoverageAnalisisDataListResultDTO(np.getId(), categoryKey, isPage ? categoryDict.getCategoryName() : null, + placeType, np.getName(), np.getLatitude(), np.getLongitude())) + .collect(Collectors.toList()); } return new ArrayList<>(); }