From 3858d98907f8529608eb342ecdbb1ee3d501fbb8 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Fri, 4 Mar 2022 15:48:31 +0800 Subject: [PATCH 01/39] error --- .../com/epmet/commons/tools/utils/YuShanSysApiService.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/YuShanSysApiService.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/YuShanSysApiService.java index 1a714fdffd..e1cb5be523 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/YuShanSysApiService.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/YuShanSysApiService.java @@ -8,7 +8,6 @@ import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.enums.EnvEnum; import com.epmet.commons.tools.enums.ExternalApiEnum; import com.epmet.commons.tools.enums.ExternalServerEnum; -import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import lombok.extern.slf4j.Slf4j; @@ -72,8 +71,7 @@ public class YuShanSysApiService { } } } catch (Exception e) { - log.warn("updateUserPoints exception 入参:{}", JSON.toJSONString(formDTO)); - throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), e.getMessage()); + log.error("updateUserPoints exception 入参:{},异常:{}", JSON.toJSONString(formDTO),e); } } } From 8cbccfd1ab03193d71071b1e9016530cb987be7b Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Fri, 4 Mar 2022 16:32:38 +0800 Subject: [PATCH 02/39] =?UTF-8?q?=E7=9D=A1=E4=B8=80=E7=A7=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/commons/tools/utils/YuShanSysApiService.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/YuShanSysApiService.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/YuShanSysApiService.java index e1cb5be523..317038eab6 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/YuShanSysApiService.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/YuShanSysApiService.java @@ -36,6 +36,12 @@ public class YuShanSysApiService { */ @Async public void updateUserPoints(String customerId, List paramList) { + try { + Thread.sleep(1000l); + } catch (InterruptedException e) { + log.error("调用榆山街道发放积分睡眠发生异常,{}",e); + e.printStackTrace(); + } if (StringUtils.isBlank(customerId) || CollectionUtils.isEmpty(paramList)) { throw new RenException("参数错误"); } From 51be3af9fe34e4fa8ee4ee05babbedc7d9236487 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Fri, 4 Mar 2022 17:00:15 +0800 Subject: [PATCH 03/39] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E6=B3=A8=E8=A7=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commons/tools/utils/YuShanSysApiService.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/YuShanSysApiService.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/YuShanSysApiService.java index 317038eab6..8139dc34be 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/YuShanSysApiService.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/YuShanSysApiService.java @@ -8,11 +8,9 @@ import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.enums.EnvEnum; import com.epmet.commons.tools.enums.ExternalApiEnum; import com.epmet.commons.tools.enums.ExternalServerEnum; -import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; -import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -34,16 +32,17 @@ public class YuShanSysApiService { * * @return */ - @Async + // @Async public void updateUserPoints(String customerId, List paramList) { - try { + /*try { Thread.sleep(1000l); } catch (InterruptedException e) { log.error("调用榆山街道发放积分睡眠发生异常,{}",e); e.printStackTrace(); - } + }*/ if (StringUtils.isBlank(customerId) || CollectionUtils.isEmpty(paramList)) { - throw new RenException("参数错误"); + log.warn("updateUserPoints 参数错误"); + return; } if (!SpecialCustomerOrgConstant.PING_YIN_CUSTOMER_ID.equals(customerId)) { return; @@ -71,13 +70,13 @@ public class YuShanSysApiService { // formDTO.setMobile("13205302682"); Result res = HttpClientManager.getInstance().sendPostByJSON(apiPath, JSON.toJSONString(formDTO)); Result result = JSON.parseObject(res.getData(), Result.class); - log.info(String.format("updateUserPoints 入参:%s;返参:%s", JSON.toJSONString(formDTO),JSON.toJSONString(result))); + log.info(String.format("updateUserPoints 入参:%s;返参:%s", JSON.toJSONString(formDTO), JSON.toJSONString(result))); if (!result.success()) { log.warn("updateUserPoints failed:{}", JSON.toJSONString(result)); } } } catch (Exception e) { - log.error("updateUserPoints exception 入参:{},异常:{}", JSON.toJSONString(formDTO),e); + log.error("updateUserPoints exception 入参:{},异常:{}", JSON.toJSONString(formDTO), e); } } } From 327c3fcec8a9d11afbe0bb33a2883c2c9d5e6597 Mon Sep 17 00:00:00 2001 From: jianjun Date: Fri, 4 Mar 2022 17:10:27 +0800 Subject: [PATCH 04/39] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/model/ImportNeighborHoodInfoListener.java | 1 - .../java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java | 2 -- 2 files changed, 3 deletions(-) diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportNeighborHoodInfoListener.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportNeighborHoodInfoListener.java index 791e3b6741..2e326c20f0 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportNeighborHoodInfoListener.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportNeighborHoodInfoListener.java @@ -79,7 +79,6 @@ public class ImportNeighborHoodInfoListener extends AnalysisEventListener importTask) { - log.info("neighborhoodImport start====="); executorService.submit(() -> { // importNeighbor(formDTO,file,importTask); log.info("neighborhoodImport thread start====="); @@ -250,7 +249,6 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl Date: Fri, 4 Mar 2022 17:13:38 +0800 Subject: [PATCH 05/39] =?UTF-8?q?=E5=8E=BB=E6=8E=89Async?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/BuildingServiceImpl.java | 52 ++++++++++--------- .../epmet/service/impl/HouseServiceImpl.java | 52 ++++++++++--------- 2 files changed, 56 insertions(+), 48 deletions(-) diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java index 091ef5dd1e..f598fae562 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java @@ -58,6 +58,7 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.InputStream; import java.util.*; +import java.util.concurrent.ExecutorService; import java.util.function.Function; import java.util.stream.Collectors; @@ -95,6 +96,8 @@ public class BuildingServiceImpl implements BuildingService { private IcNeighborHoodService neighborHoodService; @Autowired private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient; + @Autowired + private ExecutorService executorService; @Override @Transactional(rollbackFor = Exception.class) @@ -403,33 +406,34 @@ public class BuildingServiceImpl implements BuildingService { * @date 2022/2/13 10:15 上午 */ @Override - @Async public Result buildingImportExcel(ImportInfoFormDTO formDTO, MultipartFile file,Result importTask) throws IOException { - ExcelReader excelReader = null; - try { - InputStream inputStream = null; + executorService.submit(() -> { + ExcelReader excelReader = null; try { - inputStream = file.getInputStream(); - } catch (IOException e) { - return new Result().error("读取文件失败"); - } - excelReader = EasyExcel.read(inputStream).build(); - // 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener - ReadSheet readSheet = EasyExcel.readSheet(0).head(BuildingInfoModel.class) - .registerReadListener(new ImportBuildingInfoListener(formDTO,icHouseRedis,icBuildingDao,neighborHoodService,epmetCommonServiceOpenFeignClient,importTask.getData().getTaskId())) - .build(); - excelReader.read(readSheet); - } catch (Exception e){ - ImportTaskCommonFormDTO input = new ImportTaskCommonFormDTO(); - input.setOperatorId(formDTO.getUserId()); - input.setTaskId(importTask.getData().getTaskId()); - input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); - epmetCommonServiceOpenFeignClient.finishImportTask(input); - } finally { - if (excelReader != null) { - excelReader.finish(); + InputStream inputStream = null; + try { + inputStream = file.getInputStream(); + } catch (IOException e) { + log.error("读取文件失败"); + } + excelReader = EasyExcel.read(inputStream).build(); + // 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener + ReadSheet readSheet = EasyExcel.readSheet(0).head(BuildingInfoModel.class) + .registerReadListener(new ImportBuildingInfoListener(formDTO,icHouseRedis,icBuildingDao,neighborHoodService,epmetCommonServiceOpenFeignClient,importTask.getData().getTaskId())) + .build(); + excelReader.read(readSheet); + } catch (Exception e){ + ImportTaskCommonFormDTO input = new ImportTaskCommonFormDTO(); + input.setOperatorId(formDTO.getUserId()); + input.setTaskId(importTask.getData().getTaskId()); + input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); + epmetCommonServiceOpenFeignClient.finishImportTask(input); + } finally { + if (excelReader != null) { + excelReader.finish(); + } } - } + }); return new Result<>(); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java index 6130bd49c1..84f46de18a 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java @@ -65,6 +65,7 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.InputStream; import java.util.*; +import java.util.concurrent.ExecutorService; import java.util.stream.Collectors; @Slf4j @@ -97,6 +98,8 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { private IcNeighborHoodService neighborHoodService; @Autowired private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient; + @Autowired + private ExecutorService executorService; @@ -351,34 +354,35 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { return result; } - @Async @Override public Result dispose(MultipartFile file, ImportInfoFormDTO formDTO, Result importTask) { - ExcelReader excelReader = null; - try { - InputStream inputStream = null; + executorService.submit(() -> { + ExcelReader excelReader = null; try { - inputStream = file.getInputStream(); - } catch (IOException e) { - return new Result().error("读取文件失败"); - } - excelReader = EasyExcel.read(inputStream).build(); - // 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener - ReadSheet readSheet = EasyExcel.readSheet(0).head(HouseInfoModel.class) - .registerReadListener(new ImportHouseInfoListener(formDTO,icBuildingDao,icHouseRedis,neighborHoodService,icHouseService,epmetCommonServiceOpenFeignClient,importTask.getData().getTaskId())) - .build(); - excelReader.read(readSheet); - } catch (Exception e){ - ImportTaskCommonFormDTO input = new ImportTaskCommonFormDTO(); - input.setOperatorId(formDTO.getUserId()); - input.setTaskId(importTask.getData().getTaskId()); - input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); - epmetCommonServiceOpenFeignClient.finishImportTask(input); - } finally { - if (excelReader != null) { - excelReader.finish(); + InputStream inputStream = null; + try { + inputStream = file.getInputStream(); + } catch (IOException e) { + log.error("读取文件失败"); + } + excelReader = EasyExcel.read(inputStream).build(); + // 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener + ReadSheet readSheet = EasyExcel.readSheet(0).head(HouseInfoModel.class) + .registerReadListener(new ImportHouseInfoListener(formDTO,icBuildingDao,icHouseRedis,neighborHoodService,icHouseService,epmetCommonServiceOpenFeignClient,importTask.getData().getTaskId())) + .build(); + excelReader.read(readSheet); + } catch (Exception e){ + ImportTaskCommonFormDTO input = new ImportTaskCommonFormDTO(); + input.setOperatorId(formDTO.getUserId()); + input.setTaskId(importTask.getData().getTaskId()); + input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); + epmetCommonServiceOpenFeignClient.finishImportTask(input); + } finally { + if (excelReader != null) { + excelReader.finish(); + } } - } + }); return new Result(); } } From cf0c1ca254dafda46ddde03b6ef9f40dea2a1cd7 Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Fri, 4 Mar 2022 21:05:16 +0800 Subject: [PATCH 06/39] =?UTF-8?q?=E5=B1=85=E6=B0=91=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=EF=BC=9A=E5=A2=9E=E5=8A=A0=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/epmet/controller/IcResiUserController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 0c3adbb8fa..d3009cf3a2 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 @@ -470,8 +470,8 @@ public class IcResiUserController implements ResultDataResolver { try { // 睡眠2秒钟,等待主线程先结束,主线程会清空request对象的headers,等他执行了清空之后,我们这边再手动setHeader进去 - Thread.sleep(2000l); - System.out.println("请求头:" + headers); + Thread.sleep(3000l); + log.info("请求头:" + headers); } catch (InterruptedException e) { String errorMsg = ExceptionUtils.getErrorStackTrace(e); log.error("【上传居民信息】失败,睡眠2s发生中断:{}", errorMsg); From e22fb90726b4abe87d14f7e05642db8042a5baf6 Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Fri, 4 Mar 2022 21:06:21 +0800 Subject: [PATCH 07/39] =?UTF-8?q?=E5=B1=85=E6=B0=91=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=EF=BC=9A=E5=A2=9E=E5=8A=A0=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= 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 d3009cf3a2..b7f737098f 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 @@ -471,7 +471,7 @@ public class IcResiUserController implements ResultDataResolver { try { // 睡眠2秒钟,等待主线程先结束,主线程会清空request对象的headers,等他执行了清空之后,我们这边再手动setHeader进去 Thread.sleep(3000l); - log.info("请求头:" + headers); + log.info("【上传居民信息】子线程请求头:" + headers); } catch (InterruptedException e) { String errorMsg = ExceptionUtils.getErrorStackTrace(e); log.error("【上传居民信息】失败,睡眠2s发生中断:{}", errorMsg); From e03798ac3e68f315d45b577a3ca35751f7353e82 Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Fri, 4 Mar 2022 22:37:21 +0800 Subject: [PATCH 08/39] =?UTF-8?q?=E8=B0=83=E8=AF=95=EF=BC=9A=E5=B1=85?= =?UTF-8?q?=E6=B0=91=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/feign/ResultDataResolver.java | 6 +++++- .../impl/IcResiUserImportServiceImpl.java | 18 +++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/ResultDataResolver.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/ResultDataResolver.java index 8a9bc6ad80..c7da43dc5b 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/ResultDataResolver.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/ResultDataResolver.java @@ -1,5 +1,6 @@ package com.epmet.commons.tools.feign; +import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.RenException; @@ -13,6 +14,8 @@ import org.slf4j.LoggerFactory; */ public interface ResultDataResolver { + Logger logger = LoggerFactory.getLogger(ResultDataResolver.class); + /** * @Description 获取Result种的data,如果失败(返回result为null或者result.success为false),那么返回null * @return data数据 @@ -20,7 +23,6 @@ public interface ResultDataResolver { * @date 2021.06.07 22:45 */ default R getResultDataOrReturnNull(Result result, String targetServiceName) { - Logger logger = LoggerFactory.getLogger(ResultDataResolver.class); if (result == null) { logger.error("调用{}服务发生错误,返回Result为null", targetServiceName); return null; @@ -56,6 +58,8 @@ public interface ResultDataResolver { }*/ if (!result.success()) { + String j = JSON.toJSONString(result); + logger.info("远程调用出错,返回结果:{}", j); // 如果不通过参数指定code,则默认使用8000服务器开小差 Integer finalErrorCode = errorCode == null ? EpmetErrorCode.SERVER_ERROR.getCode() : errorCode; diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java index 414a077729..0a0e184d18 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java @@ -221,15 +221,17 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res String loginUserApp = loginUserUtil.getLoginUserApp(); String loginUserClient = loginUserUtil.getLoginUserClient(); - LoginUserDetailsFormDTO userForm = new LoginUserDetailsFormDTO(); - userForm.setApp(loginUserApp); - userForm.setClient(loginUserClient); - userForm.setUserId(loginUserId); +// LoginUserDetailsFormDTO userForm = new LoginUserDetailsFormDTO(); +// userForm.setApp(loginUserApp); +// userForm.setClient(loginUserClient); +// userForm.setUserId(loginUserId); String currUserAgencyId = userService.getLoginUserDetails( - loginUserUtil.getLoginUserApp(), - loginUserUtil.getLoginUserClient(), - loginUserUtil.getLoginUserId()).getAgencyId(); + loginUserApp, + loginUserClient, + loginUserId).getAgencyId(); + + log.info("userId:{}, app:{}, client:{}, currUserAgencyId:{}", loginUserId, loginUserApp, loginUserClient, currUserAgencyId); CustomerAgencyDTO agencyInfo = getResultDataOrThrowsException(govOrgOpenFeignClient.getAgencyById(currUserAgencyId), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null, null); String customerId = agencyInfo.getCustomerId(); @@ -991,6 +993,8 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res List options = null; + log.info("optionsUrl:{}, currUserAgencyId:{}", pureUri, currUserAgencyId); + switch (pureUri) { case "/epmetuser/icresidemanddict/demandoption": options = getResultDataOrThrowsException(epmetUserOpenFeignClient.getDemandOptions(), ServiceConstant.EPMET_USER_SERVER, From 054ba84f1d5f02b859f800a5321516ab22827a09 Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Fri, 4 Mar 2022 22:58:34 +0800 Subject: [PATCH 09/39] =?UTF-8?q?=E8=B0=83=E8=AF=95=EF=BC=9A=E5=B1=85?= =?UTF-8?q?=E6=B0=91=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/service/impl/IcResiUserImportServiceImpl.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java index 0a0e184d18..56b049bf3b 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java @@ -221,7 +221,9 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res String loginUserApp = loginUserUtil.getLoginUserApp(); String loginUserClient = loginUserUtil.getLoginUserClient(); -// LoginUserDetailsFormDTO userForm = new LoginUserDetailsFormDTO(); + log.info("userId:{}, app:{}, client:{}", loginUserId, loginUserApp, loginUserClient); + + // LoginUserDetailsFormDTO userForm = new LoginUserDetailsFormDTO(); // userForm.setApp(loginUserApp); // userForm.setClient(loginUserClient); // userForm.setUserId(loginUserId); @@ -231,7 +233,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res loginUserClient, loginUserId).getAgencyId(); - log.info("userId:{}, app:{}, client:{}, currUserAgencyId:{}", loginUserId, loginUserApp, loginUserClient, currUserAgencyId); + log.info("currUserAgencyId:{}", currUserAgencyId); CustomerAgencyDTO agencyInfo = getResultDataOrThrowsException(govOrgOpenFeignClient.getAgencyById(currUserAgencyId), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null, null); String customerId = agencyInfo.getCustomerId(); From 7791c3285c6e44e0376a8029c67c7a4778f0e344 Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Fri, 4 Mar 2022 23:20:38 +0800 Subject: [PATCH 10/39] =?UTF-8?q?=E8=B0=83=E8=AF=95=EF=BC=9A=E5=B1=85?= =?UTF-8?q?=E6=B0=91=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/controller/IcResiUserController.java | 6 +++++- .../service/impl/IcResiUserImportServiceImpl.java | 12 ++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) 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 b7f737098f..9fd05b7f72 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 @@ -88,6 +88,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.*; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; import java.util.stream.Collectors; @@ -130,6 +131,8 @@ public class IcResiUserController implements ResultDataResolver { private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; @Autowired private LoginUserUtil loginUserUtil; + @Autowired + private ExecutorService executorService; /** * 模板枚举 @@ -466,7 +469,8 @@ public class IcResiUserController implements ResultDataResolver { HashMap headers = getHeadersFromRequest(request); // 三.异步执行导入 - CompletableFuture.runAsync(() -> { + + executorService.execute(() -> { try { // 睡眠2秒钟,等待主线程先结束,主线程会清空request对象的headers,等他执行了清空之后,我们这边再手动setHeader进去 diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java index 56b049bf3b..c88815c47b 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java @@ -220,8 +220,9 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res String loginUserId = loginUserUtil.getLoginUserId(); String loginUserApp = loginUserUtil.getLoginUserApp(); String loginUserClient = loginUserUtil.getLoginUserClient(); + String loginUserCustomerId = loginUserUtil.getLoginUserCustomerId(); - log.info("userId:{}, app:{}, client:{}", loginUserId, loginUserApp, loginUserClient); + log.info("userId:{}, app:{}, client:{}, customerId:{}", loginUserId, loginUserApp, loginUserClient, loginUserCustomerId); // LoginUserDetailsFormDTO userForm = new LoginUserDetailsFormDTO(); // userForm.setApp(loginUserApp); @@ -420,6 +421,13 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res String currUserAgencyId, Map checkBoxOptionColumnIdxAndLabel, String currUserAgencyPids, String currentUserId, String tableName) { + String loginUserId = loginUserUtil.getLoginUserId(); + String loginUserApp = loginUserUtil.getLoginUserApp(); + String loginUserClient = loginUserUtil.getLoginUserClient(); + String loginUserCustomerId = loginUserUtil.getLoginUserCustomerId(); + + log.info("persistIcResiBaseInfo:: userId:{}, app:{}, client:{}, customerId:{}", loginUserId, loginUserApp, loginUserClient, loginUserCustomerId); + // 遍历每一行,将行内容转化为 for (Map row : dataRows) { @@ -475,7 +483,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res columnAndValues.put("AGENCY_ID", currUserAgencyId); columnAndValues.put("PIDS", currUserAgencyPids); - columnAndValues.put("CUSTOMER_ID", loginUserUtil.getLoginUserCustomerId()); + columnAndValues.put("CUSTOMER_ID", loginUserCustomerId); columnAndValues.put("UPDATED_BY", currentUserId); From 90c1ab458e226b2ebd6bb9791290e2916417ae4c Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Sat, 5 Mar 2022 00:03:13 +0800 Subject: [PATCH 11/39] =?UTF-8?q?=E8=B0=83=E8=AF=95=EF=BC=9A=E5=B1=85?= =?UTF-8?q?=E6=B0=91=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/IcResiUserImportServiceImpl.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java index c88815c47b..6568f35cdb 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java @@ -222,7 +222,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res String loginUserClient = loginUserUtil.getLoginUserClient(); String loginUserCustomerId = loginUserUtil.getLoginUserCustomerId(); - log.info("userId:{}, app:{}, client:{}, customerId:{}", loginUserId, loginUserApp, loginUserClient, loginUserCustomerId); + log.info("importIcResiInfoFromExcel:: userId:{}, app:{}, client:{}, customerId:{}", loginUserId, loginUserApp, loginUserClient, loginUserCustomerId); // LoginUserDetailsFormDTO userForm = new LoginUserDetailsFormDTO(); // userForm.setApp(loginUserApp); @@ -234,7 +234,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res loginUserClient, loginUserId).getAgencyId(); - log.info("currUserAgencyId:{}", currUserAgencyId); + log.info("importIcResiInfoFromExcel:: currUserAgencyId:{}", currUserAgencyId); CustomerAgencyDTO agencyInfo = getResultDataOrThrowsException(govOrgOpenFeignClient.getAgencyById(currUserAgencyId), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null, null); String customerId = agencyInfo.getCustomerId(); @@ -369,6 +369,13 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res private void importIcResiBaseInfoFromExcel(List formItemList, String excelPathName, int sheetNo, int headRowNumber, String currUserAgencyId, String currUserAgencyPids, String currentUserId, String tableName, String customerId) { + String loginUserId = loginUserUtil.getLoginUserId(); + String loginUserApp = loginUserUtil.getLoginUserApp(); + String loginUserClient = loginUserUtil.getLoginUserClient(); + String loginUserCustomerId = loginUserUtil.getLoginUserCustomerId(); + + log.info("importIcResiBaseInfoFromExcel:: userId:{}, app:{}, client:{}, customerId:{}", loginUserId, loginUserApp, loginUserClient, loginUserCustomerId); + IcResiImportDynamicExcelListener readListener = new IcResiImportDynamicExcelListener(this, customerId, currentUserId, currUserAgencyId, currUserAgencyPids, true, tableName, formItemList, headRowNumber); EasyExcel.read(new File(excelPathName)).registerReadListener(readListener).headRowNumber(headRowNumber).sheet(sheetNo).doRead(); From f128557851e39e7319451ec128c49e4d6e8b9650 Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Sat, 5 Mar 2022 00:34:16 +0800 Subject: [PATCH 12/39] =?UTF-8?q?=E8=B0=83=E8=AF=95=EF=BC=9A=E5=B1=85?= =?UTF-8?q?=E6=B0=91=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/IcResiUserImportServiceImpl.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java index 6568f35cdb..cd6000ef0a 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java @@ -243,6 +243,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res initImportThreadLocal(customerId); // 上传主表信息 + log.info("======开始导入基础信息======="); importIcResiBaseInfoFromExcel(formItemList,excelPathName, IcResiUserTableEnum.IC_RESI_USER.getSheetNo(), IcResiUserTableEnum.IC_RESI_USER.getHeadRowNo(), currUserAgencyId, agencyInfo.getPids(), loginUserId, IcResiUserTableEnum.IC_RESI_USER.getTableName(), customerId); @@ -254,6 +255,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res } try { + log.info("======开始导入附加表:{}=======", sheet.getTableComment()); importIcResiExtraInfoFromExcel(formItemList, excelPathName, sheet, currUserAgencyId, loginUserId, customerId); } catch (Exception e) { String errorMsg = ExceptionUtils.getErrorStackTrace(e); @@ -560,6 +562,13 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res LinkedHashMap columnAndValues = new LinkedHashMap<>(); + String loginUserId = loginUserUtil.getLoginUserId(); + String loginUserApp = loginUserUtil.getLoginUserApp(); + String loginUserClient = loginUserUtil.getLoginUserClient(); + String loginUserCustomerId = loginUserUtil.getLoginUserCustomerId(); + + log.info("persistIcResiBaseInfo:: userId:{}, app:{}, client:{}, customerId:{}", loginUserId, loginUserApp, loginUserClient, loginUserCustomerId); + // 遍历每一行,将行内容转化为 for (Map row : dataRows) { @@ -586,7 +595,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res String icResiId = existResiInfoMap.get("ID"); columnAndValues.put("IC_RESI_USER", icResiId); - columnAndValues.put("CUSTOMER_ID", loginUserUtil.getLoginUserCustomerId()); + columnAndValues.put("CUSTOMER_ID", loginUserCustomerId); columnAndValues.put("UPDATED_BY", currentUserId); // 移除excel中存在,但是数据库表中不存在的无效列,方式sql语法错误 From df768ceddce4f2d85f91e14dbba1ee40a86ed96f Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Sat, 5 Mar 2022 01:17:43 +0800 Subject: [PATCH 13/39] =?UTF-8?q?=E8=B0=83=E8=AF=95=EF=BC=9A=E5=B1=85?= =?UTF-8?q?=E6=B0=91=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handler/IcResiImportDynamicExcelListener.java | 11 +++++++++++ .../service/impl/IcResiUserImportServiceImpl.java | 11 ++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/IcResiImportDynamicExcelListener.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/IcResiImportDynamicExcelListener.java index 427e70f0a3..b390d10a39 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/IcResiImportDynamicExcelListener.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/IcResiImportDynamicExcelListener.java @@ -122,12 +122,18 @@ public class IcResiImportDynamicExcelListener extends AnalysisEventListener> headers = icResiUserImportService.mergeMultiLevelHeadLabels(headList); + icResiUserImportService.printLog("invokeHeadMap_1_" + isPrimary); + // 清洗表头数据,通过items剔除,并且得到options abandonedHeaders = icResiUserImportService.removeAndGetOptionsFromHeaders(headers, formItemList); + icResiUserImportService.printLog("invokeHeadMap_2_" + isPrimary); + // 交换表头信息,以label连起来的string作为key,列号的列表作为value HashMap> combinedHeaders = icResiUserImportService.exchangeKeyAndValueOfHeaders(headers); + icResiUserImportService.printLog("invokeHeadMap_3_" + isPrimary); + // 得到客户配置item数据。<"兴趣爱好:兴趣特长", item对象> Map customizedLabelCompbinedItemsMap = formItemList.stream().collect( Collectors.toMap(formItem -> { @@ -141,7 +147,11 @@ public class IcResiImportDynamicExcelListener extends AnalysisEventListener formItem) ); + icResiUserImportService.printLog("invokeHeadMap_4_" + isPrimary); + itemIdAndColumnWrapper = icResiUserImportService.convertExcelHeaders2DBColumnWrappers(customizedLabelCompbinedItemsMap, combinedHeaders); + + icResiUserImportService.printLog("invokeHeadMap_5_" + isPrimary); } /** @@ -172,6 +182,7 @@ public class IcResiImportDynamicExcelListener extends AnalysisEventListener row : dataRows) { @@ -1838,4 +1838,13 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res importTaskId, processStatus, operatorId, resultDesc, resultDescPath); } } + + public void printLog(String positionPrefix) { + String loginUserId = loginUserUtil.getLoginUserId(); + String loginUserApp = loginUserUtil.getLoginUserApp(); + String loginUserClient = loginUserUtil.getLoginUserClient(); + String loginUserCustomerId = loginUserUtil.getLoginUserCustomerId(); + + log.info("{}:: userId:{}, app:{}, client:{}, customerId:{}", positionPrefix, loginUserId, loginUserApp, loginUserClient, loginUserCustomerId); + } } From 8d4657f60e3115ba852a6bf1c136adc87b50bf0c Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Sat, 5 Mar 2022 17:37:03 +0800 Subject: [PATCH 14/39] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E5=BC=82=E6=AD=A5=E6=83=85=E5=86=B5=E4=B8=8B=EF=BC=8C=E4=B8=BB?= =?UTF-8?q?=E7=BA=BF=E7=A8=8B=E7=BB=93=E6=9D=9F=EF=BC=8C=E5=AD=90=E7=BA=BF?= =?UTF-8?q?=E7=A8=8Brequest=20header=E8=A2=AB=E6=B8=85=E7=A9=BA=E7=9A=84bu?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/constant/ThreadLocalConstant.java | 7 ++ .../feign/EpmetBaseRequestInterceptor.java | 32 +++++- .../commons/tools/filter/GlobalFilter.java | 1 + .../controller/IcResiUserController.java | 89 +++++---------- .../com/epmet/enums/IcResiUserTableEnum.java | 2 +- .../impl/IcResiUserImportServiceImpl.java | 102 ++++++++---------- 6 files changed, 110 insertions(+), 123 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/ThreadLocalConstant.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/ThreadLocalConstant.java index 6a2b304cfa..9061c2e8d3 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/ThreadLocalConstant.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/ThreadLocalConstant.java @@ -1,5 +1,7 @@ package com.epmet.commons.tools.constant; +import java.util.Map; + /** * ThreadLocal常亮 */ @@ -19,4 +21,9 @@ public class ThreadLocalConstant { * 用于本次的获取请求参数 */ public static final ThreadLocal requestParam = new ThreadLocal(); + + /** + * 可被子线程继承的,追加的request headers + */ + public static final InheritableThreadLocal> inheritableAdditionalHeaders = new InheritableThreadLocal<>(); } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/EpmetBaseRequestInterceptor.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/EpmetBaseRequestInterceptor.java index 7fb9822290..f687696494 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/EpmetBaseRequestInterceptor.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/EpmetBaseRequestInterceptor.java @@ -1,5 +1,6 @@ package com.epmet.commons.tools.feign; +import com.epmet.commons.tools.constant.ThreadLocalConstant; import feign.RequestInterceptor; import feign.RequestTemplate; import org.springframework.web.context.request.RequestAttributes; @@ -8,17 +9,38 @@ import org.springframework.web.context.request.ServletRequestAttributes; import javax.servlet.http.HttpServletRequest; import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; public class EpmetBaseRequestInterceptor implements RequestInterceptor { @Override public void apply(RequestTemplate template) { - RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); - if (requestAttributes == null) { - return; + // 自定义追加的request header,可被子线程继承拷贝 + Map inheritableAdditionalHeaders = ThreadLocalConstant.inheritableAdditionalHeaders.get(); + Map requestHeaders = getHeadersFromRequest(); + + if (requestHeaders != null && requestHeaders.size() > 0) { + for (Map.Entry kv : requestHeaders.entrySet()) { + template.header(kv.getKey(), kv.getValue()); + } + } + + if (inheritableAdditionalHeaders != null && inheritableAdditionalHeaders.size() > 0) { + for (Map.Entry kv : inheritableAdditionalHeaders.entrySet()) { + template.header(kv.getKey(), kv.getValue()); + } } + } + + /** + * 从header里面获取headers + */ + public HashMap getHeadersFromRequest() { + HashMap headers = new HashMap<>(); + RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); HttpServletRequest request = ((ServletRequestAttributes) requestAttributes).getRequest(); Enumeration headerNames = request.getHeaderNames(); if (headerNames != null) { @@ -27,9 +49,11 @@ public class EpmetBaseRequestInterceptor implements RequestInterceptor { Enumeration values = request.getHeaders(name); while (values.hasMoreElements()) { String value = values.nextElement(); - template.header(name, value); + headers.put(name, value); } } } + + return headers; } } \ No newline at end of file diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/GlobalFilter.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/GlobalFilter.java index fe3dc8a3e9..4aa7beab20 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/GlobalFilter.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/GlobalFilter.java @@ -25,6 +25,7 @@ public class GlobalFilter implements Filter { ThreadLocalConstant.sqlFilter.remove(); ThreadLocalConstant.requirePermissionTl.remove(); ThreadLocalConstant.requestParam.remove(); + ThreadLocalConstant.inheritableAdditionalHeaders.remove(); } } } \ No newline at end of file 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 9fd05b7f72..e09f7427c5 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 @@ -27,6 +27,7 @@ import com.epmet.commons.tools.aop.NoRepeatSubmit; import com.epmet.commons.tools.constant.Constant; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; +import com.epmet.commons.tools.constant.ThreadLocalConstant; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.dto.result.OptionDataResultDTO; import com.epmet.commons.tools.enums.IcFormCodeEnum; @@ -34,6 +35,7 @@ import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.feign.EpmetBaseRequestInterceptor; import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.redis.RedisKeys; @@ -58,6 +60,7 @@ import com.epmet.feign.OperCustomizeOpenFeignClient; import com.epmet.feign.OssFeignClient; import com.epmet.service.IcResiUserImportService; import com.epmet.service.IcResiUserService; +import feign.RequestInterceptor; import jodd.io.FileUtil; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.FileUtils; @@ -71,7 +74,6 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; -import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.support.StandardMultipartHttpServletRequest; @@ -132,7 +134,7 @@ public class IcResiUserController implements ResultDataResolver { @Autowired private LoginUserUtil loginUserUtil; @Autowired - private ExecutorService executorService; + private RequestInterceptor requestInterceptor; /** * 模板枚举 @@ -358,6 +360,7 @@ public class IcResiUserController implements ResultDataResolver { //表数据写入 //通过枚举获取相关表并按照sheetNo排序 List resiTableList = Arrays.stream(IcResiUserTableEnum.values()) + .filter((v) -> v.getSheetNo() != null) .sorted(Comparator.comparing(IcResiUserTableEnum::getSheetNo)) .collect(Collectors.toList()); List> resiResultList = null; @@ -464,27 +467,14 @@ public class IcResiUserController implements ResultDataResolver { throw new RenException("上传失败"); } - HttpServletRequest request = ((StandardMultipartHttpServletRequest)multipartRequest).getRequest(); + HashMap headers = ((EpmetBaseRequestInterceptor) requestInterceptor).getHeadersFromRequest(); - HashMap headers = getHeadersFromRequest(request); + ThreadLocalConstant.inheritableAdditionalHeaders.set(headers); // 三.异步执行导入 - - executorService.execute(() -> { + new Thread(() -> { try { - // 睡眠2秒钟,等待主线程先结束,主线程会清空request对象的headers,等他执行了清空之后,我们这边再手动setHeader进去 - Thread.sleep(3000l); - log.info("【上传居民信息】子线程请求头:" + headers); - } catch (InterruptedException e) { - String errorMsg = ExceptionUtils.getErrorStackTrace(e); - log.error("【上传居民信息】失败,睡眠2s发生中断:{}", errorMsg); - return; - } - - try { - setHeaders2Request(request, headers); - List formItemList = icResiUserService.listFormItems(customerId,IcFormCodeEnum.RESI_BASE_INFO.getCode()); icResiUserImportService.importIcResiInfoFromExcel(importTaskId, formItemList, importTempFileSavePath.toString(), response, IC_RESI_UPLOAD_DIR); } catch (Throwable e) { @@ -502,56 +492,29 @@ public class IcResiUserController implements ResultDataResolver { log.error("【导入居民信息失败】清理上传的文件失败:{}", ExceptionUtils.getErrorStackTrace(e)); } - // 清理request对象 - RequestContextHolder.resetRequestAttributes(); + // 清理tl对象 + ThreadLocalConstant.inheritableAdditionalHeaders.remove(); } - }); + }).start(); return new Result(); } - private HashMap getHeadersFromRequest(HttpServletRequest request) { - HashMap headers = new HashMap<>(); - Enumeration headerNames = request.getHeaderNames(); - if (headerNames != null) { - while (headerNames.hasMoreElements()) { - String name = headerNames.nextElement(); - Enumeration values = request.getHeaders(name); - while (values.hasMoreElements()) { - String value = values.nextElement(); - headers.put(name, value); - } - } - } - return headers; - } - - private void setHeaders2Request(HttpServletRequest request, HashMap headers) { - for (Map.Entry kv : headers.entrySet()) { - setParam2Header(request, kv.getKey(), kv.getValue()); - } - } - - private void setParam2Header(HttpServletRequest requestFacade, String key, String value){ - Class requestFacadeClass = requestFacade.getClass(); - try { - Field requestField = requestFacadeClass.getDeclaredField("request"); - requestField.setAccessible(true); - Object requestObject = requestField.get(requestFacade); - - Field coyoteRequestField = requestObject.getClass().getDeclaredField("coyoteRequest"); - coyoteRequestField.setAccessible(true); - Object coyoteRequestObject = coyoteRequestField.get(requestObject); - - Field headers = coyoteRequestObject.getClass().getDeclaredField("headers"); - headers.setAccessible(true); - MimeHeaders o2 = (MimeHeaders)headers.get(coyoteRequestObject); - o2.addValue(key).setString(value); - } catch (Exception e) { - e.printStackTrace(); - log.error("为子线程设置请求头出错"); - } - } +// private HashMap getHeadersFromRequest(HttpServletRequest request) { +// HashMap headers = new HashMap<>(); +// Enumeration headerNames = request.getHeaderNames(); +// if (headerNames != null) { +// while (headerNames.hasMoreElements()) { +// String name = headerNames.nextElement(); +// Enumeration values = request.getHeaders(name); +// while (values.hasMoreElements()) { +// String value = values.nextElement(); +// headers.put(name, value); +// } +// } +// } +// return headers; +// } @PostMapping("test") public Result>> test(@LoginUser TokenDto tokenDto, @RequestBody DynamicQueryFormDTO formDTO) { diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/enums/IcResiUserTableEnum.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/enums/IcResiUserTableEnum.java index 5bb46b6369..0490c50c5c 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/enums/IcResiUserTableEnum.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/enums/IcResiUserTableEnum.java @@ -89,7 +89,7 @@ public enum IcResiUserTableEnum { return tableComment; } - public int getSheetNo() { + public Integer getSheetNo() { return sheetNo; } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java index d0416409c8..7972ddbeef 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java @@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.epmet.bean.ResiImportCategoryData; import com.epmet.bean.ResiImportResiCategoryChangedCache; import com.epmet.bean.ResiImportChangedData; +import com.epmet.commons.tools.constant.AppClientConstant; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.constant.ThreadLocalConstant; @@ -23,7 +24,6 @@ import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; -import com.epmet.commons.tools.security.user.LoginUserUtil; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.constants.ImportTaskConstants; @@ -103,10 +103,6 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res */ Cache>> itemIdAndOptionsCache = CacheBuilder.newBuilder().maximumSize(500).build(); - - @Autowired - private LoginUserUtil loginUserUtil; - @Autowired private EpmetUserOpenFeignClient epmetUserOpenFeignClient; @@ -217,22 +213,11 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res @Override public void importIcResiInfoFromExcel(String importTaskId, List formItemList, String excelPathName, HttpServletResponse response, Path importTempPath) { - String loginUserId = loginUserUtil.getLoginUserId(); - String loginUserApp = loginUserUtil.getLoginUserApp(); - String loginUserClient = loginUserUtil.getLoginUserClient(); - String loginUserCustomerId = loginUserUtil.getLoginUserCustomerId(); - - log.info("importIcResiInfoFromExcel:: userId:{}, app:{}, client:{}, customerId:{}", loginUserId, loginUserApp, loginUserClient, loginUserCustomerId); + String app = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.APP); + String client = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.CLIENT); + String loginUserId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.USER_ID.toLowerCase()); - // LoginUserDetailsFormDTO userForm = new LoginUserDetailsFormDTO(); -// userForm.setApp(loginUserApp); -// userForm.setClient(loginUserClient); -// userForm.setUserId(loginUserId); - - String currUserAgencyId = userService.getLoginUserDetails( - loginUserApp, - loginUserClient, - loginUserId).getAgencyId(); + String currUserAgencyId = userService.getLoginUserDetails(app, client, loginUserId).getAgencyId(); log.info("importIcResiInfoFromExcel:: currUserAgencyId:{}", currUserAgencyId); @@ -331,7 +316,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res */ private void initImportThreadLocal(String customerId) { // 生成importTag,用于标记唯一一次导入操作,导入完成之后,用来删除redis里面临时的key - String operatorId = loginUserUtil.getLoginUserId(); + String operatorId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.USER_ID.toLowerCase()); String importTag = operatorId + System.currentTimeMillis(); // 错误信息 @@ -371,10 +356,10 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res private void importIcResiBaseInfoFromExcel(List formItemList, String excelPathName, int sheetNo, int headRowNumber, String currUserAgencyId, String currUserAgencyPids, String currentUserId, String tableName, String customerId) { - String loginUserId = loginUserUtil.getLoginUserId(); - String loginUserApp = loginUserUtil.getLoginUserApp(); - String loginUserClient = loginUserUtil.getLoginUserClient(); - String loginUserCustomerId = loginUserUtil.getLoginUserCustomerId(); + String loginUserApp = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.APP); + String loginUserClient = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.CLIENT); + String loginUserId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.USER_ID.toLowerCase()); + String loginUserCustomerId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.CUSTOMER_ID.toLowerCase()); log.info("importIcResiBaseInfoFromExcel:: userId:{}, app:{}, client:{}, customerId:{}", loginUserId, loginUserApp, loginUserClient, loginUserCustomerId); @@ -430,10 +415,10 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res String currUserAgencyId, Map checkBoxOptionColumnIdxAndLabel, String currUserAgencyPids, String currentUserId, String tableName) { - String loginUserId = loginUserUtil.getLoginUserId(); - String loginUserApp = loginUserUtil.getLoginUserApp(); - String loginUserClient = loginUserUtil.getLoginUserClient(); - String loginUserCustomerId = loginUserUtil.getLoginUserCustomerId(); + String loginUserApp = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.APP); + String loginUserClient = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.CLIENT); + String loginUserId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.USER_ID.toLowerCase()); + String loginUserCustomerId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.USER_ID.toLowerCase()); log.info("persistIcResiBaseInfo:: userId:{}, app:{}, client:{}, customerId:{}", loginUserId, loginUserApp, loginUserClient, loginUserCustomerId); @@ -562,10 +547,10 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res LinkedHashMap columnAndValues = new LinkedHashMap<>(); - String loginUserId = loginUserUtil.getLoginUserId(); - String loginUserApp = loginUserUtil.getLoginUserApp(); - String loginUserClient = loginUserUtil.getLoginUserClient(); - String loginUserCustomerId = loginUserUtil.getLoginUserCustomerId(); + String loginUserApp = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.APP); + String loginUserClient = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.CLIENT); + String loginUserId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.USER_ID.toLowerCase()); + String loginUserCustomerId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.CUSTOMER_ID.toLowerCase()); log.info("persistIcResiExtraInfo:: userId:{}, app:{}, client:{}, customerId:{}", loginUserId, loginUserApp, loginUserClient, loginUserCustomerId); @@ -1297,7 +1282,10 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res Date now = new Date(); - CustomerStaffInfoCacheResult operator = CustomerStaffRedis.getStaffInfo(loginUserUtil.getLoginUserCustomerId(), loginUserUtil.getLoginUserId()); + String customerId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.CUSTOMER_ID.toLowerCase()); + String userId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.USER_ID.toLowerCase()); + + CustomerStaffInfoCacheResult operator = CustomerStaffRedis.getStaffInfo(customerId, userId); for (Map.Entry entry : categoryChangedResis.entrySet()) { String resiId = entry.getKey(); @@ -1326,7 +1314,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res } // 生成changeRecord并存入 - IcUserChangeRecordEntity changeRecord = fillChangeRecord(loginUserUtil.getLoginUserCustomerId(), resiId, resiInfoMap.get("NAME"), null, loginUserUtil.getLoginUserId(), + IcUserChangeRecordEntity changeRecord = fillChangeRecord(customerId, resiId, resiInfoMap.get("NAME"), null, userId, operator.getRealName() , descBefore, descAfter, "category", "类别", "", now); icUserChangeRecordDao.insert(changeRecord); @@ -1346,7 +1334,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res String unitId = newData.getUnitId(); String homeId = newData.getHomeId(); - IcUserChangeDetailedEntity newDetail = fillChangeDetail(loginUserUtil.getLoginUserCustomerId(), resiId, changeRecord.getId(), agencyId, + IcUserChangeDetailedEntity newDetail = fillChangeDetail(customerId, resiId, changeRecord.getId(), agencyId, gridId, villageId, buildId, unitId, homeId, "category", "类别", columnEntry.getKey(), 1, resiInfoMap.get("PIDS")); @@ -1391,7 +1379,10 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res Set newResiKeys = redisUtils.keys(RedisKeys.icResiImportTypeKey(newlyOrChangedResi.get().getImportTag(), "add").concat("*")); - CustomerStaffInfoCacheResult operator = CustomerStaffRedis.getStaffInfo(loginUserUtil.getLoginUserCustomerId(), loginUserUtil.getLoginUserId()); + String customerId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.CUSTOMER_ID.toLowerCase()); + String userId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.USER_ID.toLowerCase()); + + CustomerStaffInfoCacheResult operator = CustomerStaffRedis.getStaffInfo(customerId, userId); for (String resiKey : newResiKeys) { Map newResiInfoMap = redisUtils.hGetAll(resiKey); @@ -1400,14 +1391,14 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res IcResiUserEntity resiInfo = icResiUserDao.selectById(newResiInfoObj.getResiId()); // 插入changeRecord - IcUserChangeRecordEntity changeRecord = fillChangeRecord(loginUserUtil.getLoginUserCustomerId(), newResiInfoObj.getResiId(), resiInfo.getName(), null, - loginUserUtil.getLoginUserId(), operator.getRealName(), "-", "-", + IcUserChangeRecordEntity changeRecord = fillChangeRecord(customerId, newResiInfoObj.getResiId(), resiInfo.getName(), null, + userId, operator.getRealName(), "-", "-", "add", "新增", "", now); icUserChangeRecordDao.insert(changeRecord); // 插入changeDetail for (Map.Entry mainTableColumn : newResiInfoObj.getCategories().entrySet()) { - IcUserChangeDetailedEntity changedetail = fillChangeDetail(loginUserUtil.getLoginUserCustomerId(), newResiInfoObj.getResiId(), changeRecord.getId(), newResiInfoObj.getAgencyId(), + IcUserChangeDetailedEntity changedetail = fillChangeDetail(customerId, newResiInfoObj.getResiId(), changeRecord.getId(), newResiInfoObj.getAgencyId(), newResiInfoObj.getGridId(), newResiInfoObj.getVillageId(), newResiInfoObj.getBuildId(), newResiInfoObj.getUnitId(), newResiInfoObj.getHomeId(), "add", "新增", mainTableColumn.getKey(), 1, resiInfo.getPids()); @@ -1426,8 +1417,9 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res */ public void saveTransferedResiRecord(Map transferedResis) { Date now = new Date(); - String customerId = loginUserUtil.getLoginUserCustomerId(); - CustomerStaffInfoCacheResult operator = CustomerStaffRedis.getStaffInfo(customerId, loginUserUtil.getLoginUserId()); + String loginUserId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.USER_ID.toLowerCase()); + String loginUserCustomerId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.CUSTOMER_ID.toLowerCase()); + CustomerStaffInfoCacheResult operator = CustomerStaffRedis.getStaffInfo(loginUserCustomerId, loginUserId); for (Map.Entry resi : transferedResis.entrySet()) { @@ -1460,7 +1452,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res String newHomeId = newData.getHomeId(); IcResiUserOrgMsgFormDTO oldOrgFormDTO = new IcResiUserOrgMsgFormDTO(); - oldOrgFormDTO.setCustomerId(customerId); + oldOrgFormDTO.setCustomerId(loginUserCustomerId); oldOrgFormDTO.setAgencyId(oldAgencyId); oldOrgFormDTO.setGridId(oldGridId); oldOrgFormDTO.setNeighborHoodId(oldvillageId); @@ -1470,7 +1462,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res Result oldOrgInfoRst = govOrgOpenFeignClient.icResiUserOrgMsg(oldOrgFormDTO); IcResiUserOrgMsgFormDTO newOrgInfo = new IcResiUserOrgMsgFormDTO(); - newOrgInfo.setCustomerId(customerId); + newOrgInfo.setCustomerId(loginUserCustomerId); newOrgInfo.setAgencyId(newAgencyId); newOrgInfo.setGridId(newGridId); newOrgInfo.setNeighborHoodId(newvillageId); @@ -1540,13 +1532,13 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res } // 保存 transferRecord - IcUserTransferRecordEntity transferRecord = fillTransferRecord(resiId, resiName, operator, customerId, - oldAgencyId, oldGridId, oldvillageId, oldBuildId, oldUnitId, oldHomeId, customerId, + IcUserTransferRecordEntity transferRecord = fillTransferRecord(resiId, resiName, operator, loginUserCustomerId, + oldAgencyId, oldGridId, oldvillageId, oldBuildId, oldUnitId, oldHomeId, loginUserCustomerId, newAgencyId, newGridId, newvillageId, newBuildId, newUnitId, newHomeId, oldOrg, newOrg); icUserTransferRecordDao.insert(transferRecord); // 保存 调动changeRecord - IcUserChangeRecordEntity transferChangeRecord = fillChangeRecord(customerId, resiId, resiName, transferRecord.getId(), operator.getStaffId(), + IcUserChangeRecordEntity transferChangeRecord = fillChangeRecord(loginUserCustomerId, resiId, resiName, transferRecord.getId(), operator.getStaffId(), operator.getRealName(), sbBefore.toString(), sbAfter.toString(), "transfer", "调动", "", now); icUserChangeRecordDao.insert(transferChangeRecord); @@ -1580,7 +1572,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res String categoryDescAfter = sbAfter.toString(); if (!StringUtils.isAllBlank(categoryDescBefore, categoryDescAfter)) { - IcUserChangeRecordEntity categoryChangeRecord = fillChangeRecord(customerId, resiId, resiName, transferRecord.getId(), operator.getStaffId(), + IcUserChangeRecordEntity categoryChangeRecord = fillChangeRecord(loginUserCustomerId, resiId, resiName, transferRecord.getId(), operator.getStaffId(), operator.getRealName(), categoryDescBefore, categoryDescAfter , "category", "类别", "", now); icUserChangeRecordDao.insert(categoryChangeRecord); } @@ -1593,7 +1585,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res // 之前是这个类型,那这个类型需要-1 String oldValue = oldCategories.getValue(); if ("1".equals(oldValue)) { - IcUserChangeDetailedEntity changeDetail = fillChangeDetail(customerId, resiId, transferChangeRecord.getId(), oldAgencyId, + IcUserChangeDetailedEntity changeDetail = fillChangeDetail(loginUserCustomerId, resiId, transferChangeRecord.getId(), oldAgencyId, oldGridId, oldvillageId, oldBuildId, oldUnitId, oldHomeId, transferChangeRecord.getType(), transferChangeRecord.getTypeName(), key, -1, pids); icUserChangeDetailedDao.insert(changeDetail); @@ -1607,7 +1599,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res // 现在是这个类型,这个类型要+1 if ("1".equals(newValue)) { - IcUserChangeDetailedEntity changeDetail = fillChangeDetail(customerId, resiId, transferChangeRecord.getId(), newAgencyId, + IcUserChangeDetailedEntity changeDetail = fillChangeDetail(loginUserCustomerId, resiId, transferChangeRecord.getId(), newAgencyId, newGridId, newvillageId, newBuildId, newUnitId, newHomeId, transferChangeRecord.getType(), transferChangeRecord.getTypeName(), key, 1, pids); icUserChangeDetailedDao.insert(changeDetail); @@ -1840,11 +1832,11 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res } public void printLog(String positionPrefix) { - String loginUserId = loginUserUtil.getLoginUserId(); - String loginUserApp = loginUserUtil.getLoginUserApp(); - String loginUserClient = loginUserUtil.getLoginUserClient(); - String loginUserCustomerId = loginUserUtil.getLoginUserCustomerId(); + String app = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.APP); + String client = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.CLIENT); + String loginUserId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.USER_ID.toLowerCase()); + String loginUserCustomerId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.CUSTOMER_ID.toLowerCase()); - log.info("{}:: userId:{}, app:{}, client:{}, customerId:{}", positionPrefix, loginUserId, loginUserApp, loginUserClient, loginUserCustomerId); + log.info("{}:: userId:{}, app:{}, client:{}, customerId:{}", positionPrefix, loginUserId, app, client, loginUserCustomerId); } } From 21d6090c7bfbef506b840f4477884f030534ee7e Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Sun, 6 Mar 2022 00:23:32 +0800 Subject: [PATCH 15/39] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feign/EpmetBaseRequestInterceptor.java | 6 +++++ .../tools/feign/ResultDataResolver.java | 26 +++++++++---------- .../impl/IcResiUserImportServiceImpl.java | 15 +++++------ 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/EpmetBaseRequestInterceptor.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/EpmetBaseRequestInterceptor.java index f687696494..7c6c0cd82d 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/EpmetBaseRequestInterceptor.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/EpmetBaseRequestInterceptor.java @@ -3,6 +3,8 @@ package com.epmet.commons.tools.feign; import com.epmet.commons.tools.constant.ThreadLocalConstant; import feign.RequestInterceptor; import feign.RequestTemplate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; @@ -15,12 +17,16 @@ import java.util.Map; public class EpmetBaseRequestInterceptor implements RequestInterceptor { + private static final Logger log = LoggerFactory.getLogger(EpmetBaseRequestInterceptor.class); + @Override public void apply(RequestTemplate template) { // 自定义追加的request header,可被子线程继承拷贝 Map inheritableAdditionalHeaders = ThreadLocalConstant.inheritableAdditionalHeaders.get(); Map requestHeaders = getHeadersFromRequest(); + log.info("EpmetBaseRequestInterceptor#apply#inheritableAdditionalHeaders:{}", inheritableAdditionalHeaders.toString()); + if (requestHeaders != null && requestHeaders.size() > 0) { for (Map.Entry kv : requestHeaders.entrySet()) { template.header(kv.getKey(), kv.getValue()); diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/ResultDataResolver.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/ResultDataResolver.java index c7da43dc5b..07c2df6679 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/ResultDataResolver.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/ResultDataResolver.java @@ -51,24 +51,24 @@ public interface ResultDataResolver { // 考虑到:上游服务抛出的异常代码和错误消息并不一定适用于当前服务,并且上有服务的错误消息弹出之后可能给用户造成困扰, // 因此,当前服务抛出异常的时候,不再继承上游服务返回的错误码和错误消息 - /*if (!result.success()) { + if (!result.success()) { Integer finalErrorCode = errorCode == null ? result.getCode() : errorCode; String finalErrorInternalMsg = StringUtils.isBlank(errorInternalMsg) ? result.getInternalMsg() : errorInternalMsg; throw new RenException(finalErrorCode, finalErrorInternalMsg, showMsg, RenException.MessageMode.CODE_INTERNAL_EXTERNAL); - }*/ - - if (!result.success()) { - String j = JSON.toJSONString(result); - logger.info("远程调用出错,返回结果:{}", j); - - // 如果不通过参数指定code,则默认使用8000服务器开小差 - Integer finalErrorCode = errorCode == null ? EpmetErrorCode.SERVER_ERROR.getCode() : errorCode; - String finalErrorInternalMsg = StringUtils.isBlank(errorInternalMsg) ? "" : errorInternalMsg; - String finalShowMsg = StringUtils.isBlank(showMsg) ? "" : showMsg; - - throw new EpmetException(finalErrorCode, finalErrorInternalMsg, finalShowMsg); } +// if (!result.success()) { +// String j = JSON.toJSONString(result); +// logger.info("远程调用出错,返回结果:{}", j); +// +// // 如果不通过参数指定code,则默认使用8000服务器开小差 +// Integer finalErrorCode = errorCode == null ? EpmetErrorCode.SERVER_ERROR.getCode() : errorCode; +// String finalErrorInternalMsg = StringUtils.isBlank(errorInternalMsg) ? "" : errorInternalMsg; +// String finalShowMsg = StringUtils.isBlank(showMsg) ? "" : showMsg; +// +// throw new EpmetException(finalErrorCode, finalErrorInternalMsg, finalShowMsg); +// } + return result.getData(); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java index 7972ddbeef..62b7dbf697 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java @@ -415,12 +415,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res String currUserAgencyId, Map checkBoxOptionColumnIdxAndLabel, String currUserAgencyPids, String currentUserId, String tableName) { - String loginUserApp = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.APP); - String loginUserClient = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.CLIENT); - String loginUserId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.USER_ID.toLowerCase()); - String loginUserCustomerId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.USER_ID.toLowerCase()); - - log.info("persistIcResiBaseInfo:: userId:{}, app:{}, client:{}, customerId:{}", loginUserId, loginUserApp, loginUserClient, loginUserCustomerId); + this.printLog("persistIcResiBaseInfo"); // 遍历每一行,将行内容转化为 for (Map row : dataRows) { @@ -477,7 +472,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res columnAndValues.put("AGENCY_ID", currUserAgencyId); columnAndValues.put("PIDS", currUserAgencyPids); - columnAndValues.put("CUSTOMER_ID", loginUserCustomerId); + columnAndValues.put("CUSTOMER_ID", ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.CUSTOMER_ID.toLowerCase())); columnAndValues.put("UPDATED_BY", currentUserId); @@ -1005,7 +1000,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res List options = null; log.info("optionsUrl:{}, currUserAgencyId:{}", pureUri, currUserAgencyId); - + this.printLog("listRemoteOptions"); switch (pureUri) { case "/epmetuser/icresidemanddict/demandoption": options = getResultDataOrThrowsException(epmetUserOpenFeignClient.getDemandOptions(), ServiceConstant.EPMET_USER_SERVER, @@ -1045,6 +1040,10 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res nform.setAgencyId(currUserAgencyId); } nform.setGridId(gridId); + + this.printLog("listRemoteOptions#neighborhoodoption"); + log.info("neighborhoodoption:{},{}", currUserAgencyId, gridId); + options = getResultDataOrThrowsException(govOrgOpenFeignClient.getNeighborHoodOptions(nform), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null, null); break; case "/sys/dict/data/education": From 532904489a8298958b5d57c20d7b18447459ffaa Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Sun, 6 Mar 2022 00:38:50 +0800 Subject: [PATCH 16/39] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/commons/tools/feign/EpmetBaseRequestInterceptor.java | 2 +- epmet-user/epmet-user-server/deploy/docker-compose-prod.yml | 2 +- epmet-user/epmet-user-server/pom.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/EpmetBaseRequestInterceptor.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/EpmetBaseRequestInterceptor.java index 7c6c0cd82d..cb2936ce50 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/EpmetBaseRequestInterceptor.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/EpmetBaseRequestInterceptor.java @@ -25,7 +25,7 @@ public class EpmetBaseRequestInterceptor implements RequestInterceptor { Map inheritableAdditionalHeaders = ThreadLocalConstant.inheritableAdditionalHeaders.get(); Map requestHeaders = getHeadersFromRequest(); - log.info("EpmetBaseRequestInterceptor#apply#inheritableAdditionalHeaders:{}", inheritableAdditionalHeaders.toString()); + log.info("EpmetBaseRequestInterceptor#apply#inheritableAdditionalHeaders:"+inheritableAdditionalHeaders); if (requestHeaders != null && requestHeaders.size() > 0) { for (Map.Entry kv : requestHeaders.entrySet()) { diff --git a/epmet-user/epmet-user-server/deploy/docker-compose-prod.yml b/epmet-user/epmet-user-server/deploy/docker-compose-prod.yml index bc63091248..43808623b4 100644 --- a/epmet-user/epmet-user-server/deploy/docker-compose-prod.yml +++ b/epmet-user/epmet-user-server/deploy/docker-compose-prod.yml @@ -2,7 +2,7 @@ version: "3.7" services: epmet-user-server: container_name: epmet-user-server-prod - image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-master/epmet-user-server:0.3.218 + image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-master/epmet-user-server:0.3.219 ports: - "8087:8087" network_mode: host # 不会创建新的网络 diff --git a/epmet-user/epmet-user-server/pom.xml b/epmet-user/epmet-user-server/pom.xml index 0189ee8ce0..ea68bf40e5 100644 --- a/epmet-user/epmet-user-server/pom.xml +++ b/epmet-user/epmet-user-server/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - 0.3.218 + 0.3.219 com.epmet epmet-user From 429555293f2298b3f8ff713283c91ca2cd817f99 Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Sun, 6 Mar 2022 00:40:42 +0800 Subject: [PATCH 17/39] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- epmet-user/epmet-user-server/deploy/docker-compose-prod.yml | 2 +- epmet-user/epmet-user-server/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/epmet-user/epmet-user-server/deploy/docker-compose-prod.yml b/epmet-user/epmet-user-server/deploy/docker-compose-prod.yml index 43808623b4..bc63091248 100644 --- a/epmet-user/epmet-user-server/deploy/docker-compose-prod.yml +++ b/epmet-user/epmet-user-server/deploy/docker-compose-prod.yml @@ -2,7 +2,7 @@ version: "3.7" services: epmet-user-server: container_name: epmet-user-server-prod - image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-master/epmet-user-server:0.3.219 + image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-master/epmet-user-server:0.3.218 ports: - "8087:8087" network_mode: host # 不会创建新的网络 diff --git a/epmet-user/epmet-user-server/pom.xml b/epmet-user/epmet-user-server/pom.xml index ea68bf40e5..0189ee8ce0 100644 --- a/epmet-user/epmet-user-server/pom.xml +++ b/epmet-user/epmet-user-server/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - 0.3.219 + 0.3.218 com.epmet epmet-user From c9ae0d499f04dd94bc5a97e1ebe6c05bd8d0adfc Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Sun, 6 Mar 2022 01:19:48 +0800 Subject: [PATCH 18/39] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LoginUserHandlerMethodArgumentResolver.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/resolver/LoginUserHandlerMethodArgumentResolver.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/resolver/LoginUserHandlerMethodArgumentResolver.java index 79ee2d538a..6f7afa97ba 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/resolver/LoginUserHandlerMethodArgumentResolver.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/resolver/LoginUserHandlerMethodArgumentResolver.java @@ -34,6 +34,8 @@ import org.springframework.web.servlet.HandlerMapping; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; +import java.util.Enumeration; +import java.util.Iterator; import java.util.Map; /** @@ -80,6 +82,16 @@ public class LoginUserHandlerMethodArgumentResolver implements HandlerMethodArgu logger.info("【LoginUserHandlerMethodArgumentResolver】请求uri:{}", requestURI); + // todo delete + Iterator headerNames = request.getHeaderNames(); + if (headerNames != null) { + while (headerNames.hasNext()) { + String name = headerNames.next(); + String[] headerValues = request.getHeaderValues(name); + logger.info("LoginUserHandlerMethodArgumentResolver#resolveArgument:"+headerValues); + } + } + //app-client-userId String redisKey = request.getHeader(Constant.APP_USER_KEY); if (StringUtils.isEmpty(redisKey)) { From 66f22172e86f2412b9ef2c790398a39364620d08 Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Sun, 6 Mar 2022 01:32:27 +0800 Subject: [PATCH 19/39] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resolver/LoginUserHandlerMethodArgumentResolver.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/resolver/LoginUserHandlerMethodArgumentResolver.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/resolver/LoginUserHandlerMethodArgumentResolver.java index 6f7afa97ba..cdfc906740 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/resolver/LoginUserHandlerMethodArgumentResolver.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/security/resolver/LoginUserHandlerMethodArgumentResolver.java @@ -35,6 +35,7 @@ import org.springframework.web.servlet.HandlerMapping; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import java.util.Enumeration; +import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -85,11 +86,15 @@ public class LoginUserHandlerMethodArgumentResolver implements HandlerMethodArgu // todo delete Iterator headerNames = request.getHeaderNames(); if (headerNames != null) { + HashMap hm = new HashMap<>(); while (headerNames.hasNext()) { String name = headerNames.next(); String[] headerValues = request.getHeaderValues(name); - logger.info("LoginUserHandlerMethodArgumentResolver#resolveArgument:"+headerValues); + hm.put(name, String.join(",", headerValues)); } + + logger.info("LoginUserHandlerMethodArgumentResolver#resolveArgument:"+hm); + } //app-client-userId From 5ca90bfc074cb5788bf827bc7db318cec196902b Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Sun, 6 Mar 2022 22:36:09 +0800 Subject: [PATCH 20/39] =?UTF-8?q?=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/feign/EpmetBaseRequestInterceptor.java | 2 +- .../tools/feign/FeignHystrixConcurrencyStrategy.java | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/EpmetBaseRequestInterceptor.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/EpmetBaseRequestInterceptor.java index cb2936ce50..d19a1145d2 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/EpmetBaseRequestInterceptor.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/EpmetBaseRequestInterceptor.java @@ -22,7 +22,7 @@ public class EpmetBaseRequestInterceptor implements RequestInterceptor { @Override public void apply(RequestTemplate template) { // 自定义追加的request header,可被子线程继承拷贝 - Map inheritableAdditionalHeaders = ThreadLocalConstant.inheritableAdditionalHeaders.get(); + Map inheritableAdditionalHeaders = FeignHystrixConcurrencyStrategy.hystrixAdditionHeaders.get(); Map requestHeaders = getHeadersFromRequest(); log.info("EpmetBaseRequestInterceptor#apply#inheritableAdditionalHeaders:"+inheritableAdditionalHeaders); diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/FeignHystrixConcurrencyStrategy.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/FeignHystrixConcurrencyStrategy.java index 5fef2a246d..0d2998ccd3 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/FeignHystrixConcurrencyStrategy.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/FeignHystrixConcurrencyStrategy.java @@ -1,5 +1,6 @@ package com.epmet.commons.tools.feign; +import com.epmet.commons.tools.constant.ThreadLocalConstant; import com.netflix.hystrix.HystrixThreadPoolKey; import com.netflix.hystrix.HystrixThreadPoolProperties; import com.netflix.hystrix.strategy.HystrixPlugins; @@ -17,6 +18,7 @@ import org.springframework.stereotype.Component; import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.RequestContextHolder; +import java.util.Map; import java.util.concurrent.BlockingQueue; import java.util.concurrent.Callable; import java.util.concurrent.ThreadPoolExecutor; @@ -35,6 +37,7 @@ import java.util.concurrent.TimeUnit; @Component public class FeignHystrixConcurrencyStrategy extends HystrixConcurrencyStrategy { + public static final ThreadLocal> hystrixAdditionHeaders = new ThreadLocal<>(); private static final Logger log = LoggerFactory.getLogger(FeignHystrixConcurrencyStrategy.class); private HystrixConcurrencyStrategy delegate; @@ -74,8 +77,9 @@ public class FeignHystrixConcurrencyStrategy extends HystrixConcurrencyStrategy @Override public Callable wrapCallable(Callable callable) { + Map inheritableAdditionalHeaders = ThreadLocalConstant.inheritableAdditionalHeaders.get(); RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); - return new WrappedCallable<>(callable, requestAttributes); + return new WrappedCallable<>(callable, requestAttributes, inheritableAdditionalHeaders); } @Override @@ -105,15 +109,18 @@ public class FeignHystrixConcurrencyStrategy extends HystrixConcurrencyStrategy static class WrappedCallable implements Callable { private final Callable target; private final RequestAttributes requestAttributes; + private final Map inheritableAdditionalHeaders; - public WrappedCallable(Callable target, RequestAttributes requestAttributes) { + public WrappedCallable(Callable target, RequestAttributes requestAttributes, Map inheritableAdditionalHeaders) { this.target = target; this.requestAttributes = requestAttributes; + this.inheritableAdditionalHeaders = inheritableAdditionalHeaders; } @Override public T call() throws Exception { try { + hystrixAdditionHeaders.set(inheritableAdditionalHeaders); RequestContextHolder.setRequestAttributes(requestAttributes); return target.call(); } finally { From 9c41853fae66cb48de7daa00e542dc6b01eb414c Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Mon, 7 Mar 2022 09:43:43 +0800 Subject: [PATCH 21/39] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=88=BF=E5=B1=8B?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/epmet/redis/IcHouseRedis.java | 6 ++++++ .../main/java/com/epmet/service/impl/HouseServiceImpl.java | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/IcHouseRedis.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/IcHouseRedis.java index 2329e467d6..01792daf8c 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/IcHouseRedis.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/redis/IcHouseRedis.java @@ -24,6 +24,7 @@ import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.dao.IcHouseDao; import com.epmet.dto.result.HouseInfoDTO; import com.epmet.dto.result.ImportResultDTO; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Component; @@ -38,6 +39,7 @@ import java.util.Map; * @since v1.0.0 2021-10-27 */ @Component +@Slf4j public class IcHouseRedis { @Autowired private RedisUtils redisUtils; @@ -79,6 +81,10 @@ public class IcHouseRedis { return ConvertUtils.mapToEntity(map,HouseInfoDTO.class); } HouseInfoDTO houseInfo = icHouseDao.queryHouseInfoByHouseId(houseId); + if(null == houseInfo){ + log.info("Database does not exist this house info, id = {}", houseId); + return null; + } Map result = BeanUtil.beanToMap(houseInfo, false, true); setHouseInfo(houseId,result,houseInfo.getCustomerId()); return houseInfo; diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java index 4c809cb812..b4b8185482 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java @@ -325,7 +325,10 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { } List result = new ArrayList<>(); houseIdList.forEach(h -> { - result.add(icHouseRedis.getHouseInfo(h,customerId)); + HouseInfoDTO houseInfo = icHouseRedis.getHouseInfo(h, customerId); + if (null != houseInfo){ + result.add(houseInfo); + } }); return result; } From 61a0679cd993690b54bce70aca39c513293af242 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Mon, 7 Mar 2022 14:07:57 +0800 Subject: [PATCH 22/39] =?UTF-8?q?=E5=8A=A0=E4=BA=86=E4=B8=AA=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E5=92=8C=E5=A4=87=E6=B3=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/IcHouseDao.xml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml index 08adc876d0..5d81fe75b7 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/IcHouseDao.xml @@ -304,6 +304,8 @@ and ih.id !=#{houseId} + + + diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/ScreenExtractTaskService.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/ScreenExtractTaskService.java index 25a4244301..90716be4c4 100644 --- a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/ScreenExtractTaskService.java +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/ScreenExtractTaskService.java @@ -19,4 +19,7 @@ public interface ScreenExtractTaskService { * @Date 2020/9/28 10:49 **/ Result screenExtractMonthly(String params); + + + Result dateCheckDaily(String params); } diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/ScreenExtractTaskServiceImpl.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/ScreenExtractTaskServiceImpl.java index 698a3ec7b3..dea86b3965 100644 --- a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/ScreenExtractTaskServiceImpl.java +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/ScreenExtractTaskServiceImpl.java @@ -47,4 +47,13 @@ public class ScreenExtractTaskServiceImpl implements ScreenExtractTaskService { } return dataStatisticalOpenFeignClient.extractMonthlyAll(extractScreenFormDTO); } + + @Override + public Result dateCheckDaily(String params) { + ExtractOriginFormDTO extractOriginFormDTO = new ExtractOriginFormDTO(); + if (StringUtils.isNotBlank(params)) { + extractOriginFormDTO = JSON.parseObject(params, ExtractOriginFormDTO.class); + } + return dataStatisticalOpenFeignClient.dataCheck(extractOriginFormDTO); + } } diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/DataCheckDailyTask.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/DataCheckDailyTask.java new file mode 100644 index 0000000000..e94d4c68c7 --- /dev/null +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/DataCheckDailyTask.java @@ -0,0 +1,33 @@ +package com.epmet.task; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.service.ScreenExtractTaskService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + + +/** + * @author Administrator + */ +@Component("dataCheckDailyTask") +public class DataCheckDailyTask implements ITask{ + + @Autowired + private ScreenExtractTaskService screenExtractTaskService; + + private Logger logger = LoggerFactory.getLogger(getClass()); + + + @Override + public void run(String params) { + logger.info("DataCheckDailyTask定时任务正在执行,参数为:{}", params); + Result result = screenExtractTaskService.dateCheckDaily(params); + if (result.success()){ + logger.info("DataCheckDailyTask定时任务执行成功"); + }else { + logger.error("DataCheckDailyTask定时任务执行失败:" + result.getMsg()); + } + } +} From bd2101d5010d7d0b74118e1ab3c20405c2a1cac4 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Tue, 8 Mar 2022 09:04:43 +0800 Subject: [PATCH 31/39] =?UTF-8?q?=E5=B0=8F=E5=8C=BA=EF=BC=8C=E6=A5=BC?= =?UTF-8?q?=E5=AE=87=EF=BC=8C=E6=88=BF=E5=B1=8B=E5=AF=BC=E5=85=A5=E5=BE=AE?= =?UTF-8?q?=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/controller/BuildingController.java | 14 +++++++++++++- .../java/com/epmet/controller/HouseController.java | 13 ++++++++++++- .../epmet/controller/IcNeighborHoodController.java | 14 +++++++++++++- .../java/com/epmet/service/BuildingService.java | 3 ++- .../main/java/com/epmet/service/HouseService.java | 3 ++- .../com/epmet/service/IcNeighborHoodService.java | 3 ++- .../epmet/service/impl/BuildingServiceImpl.java | 8 +------- .../com/epmet/service/impl/HouseServiceImpl.java | 8 +------- .../service/impl/IcNeighborHoodServiceImpl.java | 11 ++--------- 9 files changed, 48 insertions(+), 29 deletions(-) diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java index 349df657f4..394448e623 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java @@ -53,6 +53,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.io.InputStream; import java.util.*; import java.util.stream.Collectors; @@ -224,7 +225,18 @@ public class BuildingController { if (!importTask.success()){ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"","存在进行中的导入"); } - buildingService.buildingImportExcel(formDTO,file,importTask); + InputStream inputStream = null; + try { + inputStream = file.getInputStream(); + }catch (Exception e){ + ImportTaskCommonFormDTO input = new ImportTaskCommonFormDTO(); + input.setOperatorId(formDTO.getUserId()); + input.setTaskId(importTask.getData().getTaskId()); + input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); + epmetCommonServiceOpenFeignClient.finishImportTask(input); + log.error("读取文件失败"); + } + buildingService.buildingImportExcel(formDTO, inputStream, importTask); return new Result(); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java index ea54959b86..40e37a1db5 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java @@ -274,7 +274,18 @@ public class HouseController implements ResultDataResolver { if (!importTask.success()){ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"","存在进行中的导入"); } - houseService.dispose(file,formDTO,importTask); + InputStream inputStream = null; + try { + inputStream = file.getInputStream(); + }catch (Exception e){ + ImportTaskCommonFormDTO input = new ImportTaskCommonFormDTO(); + input.setOperatorId(formDTO.getUserId()); + input.setTaskId(importTask.getData().getTaskId()); + input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); + epmetCommonServiceOpenFeignClient.finishImportTask(input); + log.error("读取文件失败"); + } + houseService.dispose(inputStream,formDTO,importTask); return new Result<>(); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java index 107b6c612e..dadab70ce5 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcNeighborHoodController.java @@ -44,6 +44,7 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import java.io.IOException; +import java.io.InputStream; import java.util.List; import java.util.Map; @@ -148,8 +149,19 @@ public class IcNeighborHoodController { if (!importTask.success()){ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"","存在进行中的导入"); } + InputStream inputStream = null; + try { + inputStream = file.getInputStream(); + }catch (Exception e){ + ImportTaskCommonFormDTO input = new ImportTaskCommonFormDTO(); + input.setOperatorId(formDTO.getUserId()); + input.setTaskId(importTask.getData().getTaskId()); + input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); + epmetCommonServiceOpenFeignClient.finishImportTask(input); + log.error("读取文件失败"); + } log.info("插入任务结果"+ JSON.toJSONString(importTask.getData())); - icNeighborHoodService.neighborhoodImport(formDTO,file,importTask); + icNeighborHoodService.neighborhoodImport(formDTO,inputStream,importTask); return new Result(); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java index a5d84c4d7d..0ba2aeb492 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java @@ -31,6 +31,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.io.InputStream; import java.util.List; /** @@ -75,6 +76,6 @@ public interface BuildingService { * @author zxc * @date 2022/2/13 10:18 上午 */ - Result buildingImportExcel(ImportInfoFormDTO formDTO, MultipartFile file,Result importTask) throws IOException; + Result buildingImportExcel(ImportInfoFormDTO formDTO, InputStream inputStream, Result importTask) throws IOException; } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java index c7a065024e..6000e27c05 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/HouseService.java @@ -28,6 +28,7 @@ import com.epmet.excel.IcHouseExcel; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; +import java.io.InputStream; import java.util.List; import java.util.Set; @@ -67,5 +68,5 @@ public interface HouseService { List queryListHouseInfo(Set houseIds, String customerId); - Result dispose(MultipartFile file, ImportInfoFormDTO formDTO, Result importTask); + Result dispose(InputStream inputStream, ImportInfoFormDTO formDTO, Result importTask); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java index 1d6193834f..1f32607a65 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java @@ -31,6 +31,7 @@ import com.epmet.entity.IcPropertyManagementEntity; import org.springframework.web.multipart.MultipartFile; import java.io.IOException; +import java.io.InputStream; import java.util.Collection; import java.util.List; import java.util.Map; @@ -129,7 +130,7 @@ public interface IcNeighborHoodService extends BaseService * @author zxc * @date 2022/2/12 11:11 上午 */ - Result neighborhoodImport(ImportInfoFormDTO formDTO, MultipartFile file,Result importTask) throws IOException; + Result neighborhoodImport(ImportInfoFormDTO formDTO, InputStream inputStream, Result importTask) throws IOException; /** * 获取导入小区,楼栋,单元ID diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java index f598fae562..28baadf38f 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java @@ -406,16 +406,10 @@ public class BuildingServiceImpl implements BuildingService { * @date 2022/2/13 10:15 上午 */ @Override - public Result buildingImportExcel(ImportInfoFormDTO formDTO, MultipartFile file,Result importTask) throws IOException { + public Result buildingImportExcel(ImportInfoFormDTO formDTO, InputStream inputStream,Result importTask) throws IOException { executorService.submit(() -> { ExcelReader excelReader = null; try { - InputStream inputStream = null; - try { - inputStream = file.getInputStream(); - } catch (IOException e) { - log.error("读取文件失败"); - } excelReader = EasyExcel.read(inputStream).build(); // 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener ReadSheet readSheet = EasyExcel.readSheet(0).head(BuildingInfoModel.class) diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java index 84f46de18a..dfcf158272 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java @@ -355,16 +355,10 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { } @Override - public Result dispose(MultipartFile file, ImportInfoFormDTO formDTO, Result importTask) { + public Result dispose(InputStream inputStream, ImportInfoFormDTO formDTO, Result importTask) { executorService.submit(() -> { ExcelReader excelReader = null; try { - InputStream inputStream = null; - try { - inputStream = file.getInputStream(); - } catch (IOException e) { - log.error("读取文件失败"); - } excelReader = EasyExcel.read(inputStream).build(); // 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener ReadSheet readSheet = EasyExcel.readSheet(0).head(HouseInfoModel.class) diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java index 3064679e2c..f2b50748eb 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java @@ -226,24 +226,17 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl importTask) { + public Result neighborhoodImport(ImportInfoFormDTO formDTO, InputStream inputStream,Result importTask) { executorService.submit(() -> { // importNeighbor(formDTO,file,importTask); log.info("neighborhoodImport thread start====="); ExcelReader excelReader = null; try { - InputStream inputStream = null; - try { - inputStream = file.getInputStream(); - } catch (IOException e) { - throw new EpmetException("读取文件失败"); - } - excelReader = EasyExcel.read(inputStream).build(); // 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener ReadSheet readSheet = EasyExcel.readSheet(0).head(NeighborHoodInfoModel.class) From 931338532b83d164d0a2a3691a7b456ae259a7b9 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Tue, 8 Mar 2022 09:17:45 +0800 Subject: [PATCH 32/39] =?UTF-8?q?=E7=A4=BE=E5=8C=BA=E8=87=AA=E7=BB=84?= =?UTF-8?q?=E7=BB=87=EF=BC=8C=E5=85=9A=E5=91=98=E9=A3=8E=E9=87=87=E5=BE=AE?= =?UTF-8?q?=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/commons/tools/utils/ExcelPoiUtils.java | 2 +- .../IcCommunitySelfOrganizationController.java | 16 +++++++++++++++- .../IcCommunitySelfOrganizationService.java | 3 ++- .../IcCommunitySelfOrganizationServiceImpl.java | 5 +++-- .../controller/IcPartymemberStyleController.java | 14 +++++++++++++- .../service/IcPartymemberStyleService.java | 3 ++- .../impl/IcPartymemberStyleServiceImpl.java | 5 +++-- 7 files changed, 39 insertions(+), 9 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ExcelPoiUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ExcelPoiUtils.java index 3ea8472867..ee92fbeb26 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ExcelPoiUtils.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ExcelPoiUtils.java @@ -255,7 +255,7 @@ public class ExcelPoiUtils { * @param * @return */ - private static ExcelImportResult importExcelMore(InputStream inputStream,Integer titleRows, Integer headerRows, Class pojoClass) throws IOException { + public static ExcelImportResult importExcelMore(InputStream inputStream,Integer titleRows, Integer headerRows, Class pojoClass) throws IOException { if (inputStream == null) { return null; } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcCommunitySelfOrganizationController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcCommunitySelfOrganizationController.java index bbea13e834..0c8c8f6dc8 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcCommunitySelfOrganizationController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcCommunitySelfOrganizationController.java @@ -42,6 +42,7 @@ import com.epmet.excel.IcCommunitySelfOrganizationExcel; import com.epmet.excel.ImportCommunitySelfOrganizationSon; import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.service.IcCommunitySelfOrganizationService; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.io.FilenameUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -50,6 +51,7 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; +import java.io.InputStream; import java.util.List; import java.util.Map; @@ -62,6 +64,7 @@ import java.util.Map; */ @RestController @RequestMapping("iccommunityselforganization") +@Slf4j public class IcCommunitySelfOrganizationController { @Autowired @@ -161,8 +164,19 @@ public class IcCommunitySelfOrganizationController { if (!result.success()) { throw new RenException(result.getInternalMsg()); } + InputStream inputStream = null; + try { + inputStream = file.getInputStream(); + }catch (Exception e){ + ImportTaskCommonFormDTO input = new ImportTaskCommonFormDTO(); + input.setOperatorId(tokenDto.getUserId()); + input.setTaskId(result.getData().getTaskId()); + input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); + commonServiceOpenFeignClient.finishImportTask(input); + log.error("读取文件失败"); + } //2.执行导入程序 - icCommunitySelfOrganizationService.importCommunitySelfOrganization(tokenDto, response, file, result.getData().getTaskId()); + icCommunitySelfOrganizationService.importCommunitySelfOrganization(tokenDto, response, inputStream, result.getData().getTaskId()); return new Result(); } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcCommunitySelfOrganizationService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcCommunitySelfOrganizationService.java index ab97e36e84..79f1e0a477 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcCommunitySelfOrganizationService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcCommunitySelfOrganizationService.java @@ -33,6 +33,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.io.InputStream; import java.util.List; import java.util.Map; @@ -157,7 +158,7 @@ public interface IcCommunitySelfOrganizationService extends BaseService queryListById(List communityOrgIds); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java index 7dd0c6343e..366d472088 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java @@ -66,6 +66,7 @@ import org.springframework.web.multipart.commons.CommonsMultipartFile; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.io.InputStream; import java.io.OutputStream; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -478,13 +479,13 @@ public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl fileList = new ArrayList<>(); CommunitySelfOrgImportExcel excel = null; //1.读取Excel数据 - ExcelImportResult testExcelImportResult = ExcelPoiUtils.importExcelMore(file, 0, 2, ImportCommunitySelfOrganization.class); + ExcelImportResult testExcelImportResult = ExcelPoiUtils.importExcelMore(inputStream,0,2,ImportCommunitySelfOrganization.class); //2.存在错误行数据时存入错误数据集合中 for (ImportCommunitySelfOrganization entity : testExcelImportResult.getFailList()) { //打印失败的行 和失败的信息 diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/IcPartymemberStyleController.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/IcPartymemberStyleController.java index b99c297700..064a85c98f 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/IcPartymemberStyleController.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/IcPartymemberStyleController.java @@ -48,6 +48,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.io.InputStream; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -143,8 +144,19 @@ public class IcPartymemberStyleController { if (!result.success()) { throw new RenException(result.getInternalMsg()); } + InputStream inputStream = null; + try { + inputStream = file.getInputStream(); + }catch (Exception e){ + ImportTaskCommonFormDTO input = new ImportTaskCommonFormDTO(); + input.setOperatorId(tokenDto.getUserId()); + input.setTaskId(result.getData().getTaskId()); + input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); + commonServiceOpenFeignClient.finishImportTask(input); + log.error("读取文件失败"); + } //2.执行导入程序 - icPartymemberStyleService.importData(tokenDto, response, file, result.getData().getTaskId()); + icPartymemberStyleService.importData(tokenDto, response, inputStream, result.getData().getTaskId()); return new Result(); } diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/IcPartymemberStyleService.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/IcPartymemberStyleService.java index 533cb59262..4a9ec6ba5c 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/IcPartymemberStyleService.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/IcPartymemberStyleService.java @@ -29,6 +29,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.io.InputStream; import java.util.List; import java.util.Map; @@ -108,7 +109,7 @@ public interface IcPartymemberStyleService extends BaseService fileList = new ArrayList<>(); PartyMemberImportExcel excel = null; - ExcelImportResult importResult = ExcelPoiUtils.importExcelMore(file, 0, 1, IcPartymemberStyleImportExcel.class); + ExcelImportResult importResult = ExcelPoiUtils.importExcelMore(inputStream, 0, 1, IcPartymemberStyleImportExcel.class); List failList = importResult.getFailList(); //存放错误数据行号 From a0ab64e5e05ace1a007dec996356b345755eb6f5 Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Tue, 8 Mar 2022 10:02:49 +0800 Subject: [PATCH 33/39] =?UTF-8?q?job=20RequestAttributes=E4=B8=BA=E7=A9=BA?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/commons/tools/feign/EpmetBaseRequestInterceptor.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/EpmetBaseRequestInterceptor.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/EpmetBaseRequestInterceptor.java index d19a1145d2..2b07b4b5ab 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/EpmetBaseRequestInterceptor.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/EpmetBaseRequestInterceptor.java @@ -47,6 +47,9 @@ public class EpmetBaseRequestInterceptor implements RequestInterceptor { HashMap headers = new HashMap<>(); RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); + if (requestAttributes == null) { + return null; + } HttpServletRequest request = ((ServletRequestAttributes) requestAttributes).getRequest(); Enumeration headerNames = request.getHeaderNames(); if (headerNames != null) { From e416692ca5f6a00200a3cfedd717b007eeed0786 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Tue, 8 Mar 2022 11:14:52 +0800 Subject: [PATCH 34/39] =?UTF-8?q?=E9=83=A8=E7=BD=B2=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E5=8F=91=E5=88=B0"=E5=BC=80=E5=8F=91?= =?UTF-8?q?=E6=B5=8B=E8=AF=95-=E6=8A=A5=E8=AD=A6=E7=BE=A4"=E9=87=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/aspect/ApplicationFailedEventListener.java | 3 ++- .../tools/aspect/ApplicationReadyEventListener.java | 3 ++- .../commons/tools/constant/DingDingRobotConstant.java | 10 ++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/ApplicationFailedEventListener.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/ApplicationFailedEventListener.java index 5c219ab095..4ed9e4c711 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/ApplicationFailedEventListener.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/ApplicationFailedEventListener.java @@ -13,6 +13,7 @@ import com.dingtalk.api.DefaultDingTalkClient; import com.dingtalk.api.DingTalkClient; import com.dingtalk.api.request.OapiRobotSendRequest; import com.dingtalk.api.response.OapiRobotSendResponse; +import com.epmet.commons.tools.constant.DingDingRobotConstant; import com.epmet.commons.tools.enums.EnvEnum; import com.epmet.commons.tools.utils.SpringContextUtils; import com.taobao.api.ApiException; @@ -56,7 +57,7 @@ public class ApplicationFailedEventListener implements ApplicationListener Date: Tue, 8 Mar 2022 16:06:37 +0800 Subject: [PATCH 35/39] =?UTF-8?q?=E5=8A=A0=E7=82=B9=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/epmet/controller/IcResiUserController.java | 1 + .../java/com/epmet/mq/listener/ICWarnStatsEventListener.java | 5 ++++- 2 files changed, 5 insertions(+), 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 e09f7427c5..df529b42a1 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 @@ -232,6 +232,7 @@ public class IcResiUserController implements ResultDataResolver { //推送MQ事件 IcResiUserAddMQMsg mqMsg = new IcResiUserAddMQMsg(); mqMsg.setCustomerId(tokenDto.getCustomerId()); + log.info("customer id is {}",tokenDto.getCustomerId()); mqMsg.setIcResiUser(resiUserId); SystemMsgFormDTO form = new SystemMsgFormDTO(); form.setMessageType(SystemMessageType.IC_RESI_USER_EDIT); diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/mq/listener/ICWarnStatsEventListener.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/mq/listener/ICWarnStatsEventListener.java index d0ff2a10e9..9901fe8215 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/mq/listener/ICWarnStatsEventListener.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/mq/listener/ICWarnStatsEventListener.java @@ -10,6 +10,7 @@ import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.utils.SpringContextUtils; import com.epmet.service.StatsResiWarnService; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext; import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus; @@ -27,6 +28,7 @@ import java.util.concurrent.TimeUnit; * @author wxz * @date 2021.10.13 15:21:48 */ +@Slf4j public class ICWarnStatsEventListener implements MessageListenerConcurrently { private Logger logger = LoggerFactory.getLogger(getClass()); @@ -53,13 +55,14 @@ public class ICWarnStatsEventListener implements MessageListenerConcurrently { // msg即为消息体 // tags为SystemMessageType.java中的项,为具体的操作,此处拿到tags,判断是创建还是变更,来做响应的后续操作即可 String msg = new String(messageExt.getBody()); + log.info("msg is {}",msg); String topic = messageExt.getTopic(); String tags = messageExt.getTags(); String pendingMsgLabel = messageExt.getUserProperty(MQUserPropertys.BLOCKED_MSG_LABEL); logger.info("【开放数据事件监听器】-居民信息变动-收到消息内容:{},操作:{}", msg, tags); IcResiUserAddMQMsg obj = JSON.parseObject(msg, IcResiUserAddMQMsg.class); - + log.info("obj is {}",JSON.toJSONString(obj)); DistributedLock distributedLock = null; RLock lock = null; try { From d5c71e2084dd7855c76bc96c2420064b5de4f498 Mon Sep 17 00:00:00 2001 From: jianjun Date: Tue, 8 Mar 2022 16:39:52 +0800 Subject: [PATCH 36/39] =?UTF-8?q?=E5=BE=AA=E7=8E=AF=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...cCommunitySelfOrganizationServiceImpl.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java index 366d472088..792f917e51 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java @@ -30,11 +30,13 @@ import com.epmet.constant.IcCommunitySelfOrganizationConstant; import com.epmet.constant.UserDemandConstant; import com.epmet.constants.ImportTaskConstants; import com.epmet.dao.IcCommunitySelfOrganizationDao; +import com.epmet.dao.IcUserDemandRecDao; import com.epmet.dto.IcCommunitySelfOrganizationDTO; import com.epmet.dto.form.*; import com.epmet.dto.form.demand.ServiceQueryFormDTO; import com.epmet.dto.result.CommunitySelfOrganizationListDTO; import com.epmet.dto.result.CommunitySelfOrganizationListResultDTO; +import com.epmet.dto.result.ServicePointDTO; import com.epmet.dto.result.UploadImgResultDTO; import com.epmet.dto.result.demand.OptionDTO; import com.epmet.entity.IcCommunitySelfOrganizationEntity; @@ -45,7 +47,6 @@ import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.feign.OssFeignClient; import com.epmet.service.IcCommunitySelfOrganizationPersonnelService; import com.epmet.service.IcCommunitySelfOrganizationService; -import com.epmet.service.IcUserDemandRecService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import lombok.extern.slf4j.Slf4j; @@ -68,8 +69,6 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.text.ParseException; -import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; @@ -91,7 +90,7 @@ public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl pointMap = icUserDemandRecService.getServicePoint(tokenDto.getCustomerId(), UserDemandConstant.COMMUNITY_ORG); + List servicePointList = icUserDemandRecDao.getServicePoint(tokenDto.getCustomerId(), UserDemandConstant.COMMUNITY_ORG); + Map pointMap = new HashMap<>(); + if (CollectionUtils.isNotEmpty(servicePointList)){ + pointMap = servicePointList.stream().collect(Collectors.toMap(ServicePointDTO::getServerId, ServicePointDTO::getPoint)); + } formDTO.setAgencyId(staffInfo.getAgencyId()); formDTO.setCustomerId(tokenDto.getCustomerId()); final int[] i = {(formDTO.getPageNo() - NumConstant.ONE) * formDTO.getPageSize() + NumConstant.ONE}; @@ -316,11 +319,11 @@ public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl objectPageInfo = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.selectCommunitySelfOrganizationList(formDTO)); result.setTotal(Integer.valueOf(String.valueOf(objectPageInfo.getTotal()))); if (CollectionUtils.isNotEmpty(objectPageInfo.getList())){ - objectPageInfo.getList().forEach(l -> { + for (CommunitySelfOrganizationListDTO l : objectPageInfo.getList()) { l.setSort(i[NumConstant.ZERO]); i[NumConstant.ZERO]++; - l.setScore(null == pointMap.get(l.getOrgId())?NumConstant.ZERO:pointMap.get(l.getOrgId())); - }); + l.setScore(null == pointMap.get(l.getOrgId()) ? NumConstant.ZERO : pointMap.get(l.getOrgId())); + } result.setList(objectPageInfo.getList()); } return result; @@ -329,10 +332,10 @@ public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl sort = new AtomicReference<>(NumConstant.ONE); - resultDTOs.forEach(r -> { + for (CommunitySelfOrganizationListDTO r : resultDTOs) { r.setSort(sort.getAndSet(sort.get() + NumConstant.ONE)); - r.setScore(null == pointMap.get(r.getOrgId())?NumConstant.ZERO:pointMap.get(r.getOrgId())); - }); + r.setScore(null == pointMap.get(r.getOrgId()) ? NumConstant.ZERO : pointMap.get(r.getOrgId())); + } result.setList(resultDTOs); } return result; From 8dc4023e10927c4e4a5a2d498b0a43491c8778bc Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Tue, 8 Mar 2022 17:11:05 +0800 Subject: [PATCH 37/39] =?UTF-8?q?EnableAsync=E6=8C=AA=E5=88=B0=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/epmet/EpmetHeartApplication.java | 2 ++ .../service/impl/IcCommunitySelfOrganizationServiceImpl.java | 1 - .../src/main/java/com/epmet/ResiPartyMemberApplication.java | 2 ++ .../partymember/service/impl/IcPartymemberStyleServiceImpl.java | 1 - 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/EpmetHeartApplication.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/EpmetHeartApplication.java index c7969a259b..38a41f919e 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/EpmetHeartApplication.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/EpmetHeartApplication.java @@ -13,6 +13,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.scheduling.annotation.EnableAsync; /** * 模块 @@ -24,6 +25,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @EnableDiscoveryClient @EnableFeignClients @ServletComponentScan +@EnableAsync public class EpmetHeartApplication { public static void main(String[] args) { diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java index 792f917e51..56c49c53c1 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java @@ -84,7 +84,6 @@ import static com.epmet.commons.tools.utils.DateUtils.DATE_PATTERN; */ @Service @Slf4j -@EnableAsync public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl implements IcCommunitySelfOrganizationService { @Autowired diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/ResiPartyMemberApplication.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/ResiPartyMemberApplication.java index 57a43e6f1f..2ddef94968 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/ResiPartyMemberApplication.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/ResiPartyMemberApplication.java @@ -13,6 +13,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.scheduling.annotation.EnableAsync; /** * 模块 @@ -24,6 +25,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @EnableDiscoveryClient @EnableFeignClients @ServletComponentScan +@EnableAsync public class ResiPartyMemberApplication { public static void main(String[] args) { diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/IcPartymemberStyleServiceImpl.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/IcPartymemberStyleServiceImpl.java index 5b293262be..3c5871637c 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/IcPartymemberStyleServiceImpl.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/IcPartymemberStyleServiceImpl.java @@ -95,7 +95,6 @@ import java.util.stream.Collectors; */ @Slf4j @Service -@EnableAsync public class IcPartymemberStyleServiceImpl extends BaseServiceImpl implements IcPartymemberStyleService { @Resource From 75ca49624c38343e2b37104459decd3ae0ff98d5 Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Tue, 8 Mar 2022 17:27:41 +0800 Subject: [PATCH 38/39] =?UTF-8?q?=E5=B9=B3=E9=98=B4=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=95=B0=E6=8D=AE=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/constant/DingDingRobotConstant.java | 3 ++ .../epmet/dto/screen/result/DataCheckDTO.java | 6 ++- .../screen/impl/ProjectDataServiceImpl.java | 31 ++++++++----- .../screen/ScreenProjectDataDao.xml | 43 ++++++++++++------- 4 files changed, 56 insertions(+), 27 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/DingDingRobotConstant.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/DingDingRobotConstant.java index 08c5708cf6..eb09819172 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/DingDingRobotConstant.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/DingDingRobotConstant.java @@ -12,4 +12,7 @@ public interface DingDingRobotConstant { */ String V3_ROBOT_URL="https://oapi.dingtalk.com/robot/send?access_token=75e9ab857536f3018baa09009646876edbd263d07521a1a22eedfc3852623614"; String V3_ROBOT_SECRET="SECdc8d3fb6780faa919f38fd43783f76d111255036c3b5bdcbc086dff023ee84d5"; + + String SELF_ROBOT_URL="https://oapi.dingtalk.com/robot/send?access_token=ffd7c972b0525e249283df1a16b65a8b9d0012601f3a458dfc588c2eac497bb5"; + String SELF_ROBOT_SECRET=null; } diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/DataCheckDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/DataCheckDTO.java index 005d23246f..a19dfbc1a2 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/DataCheckDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/DataCheckDTO.java @@ -16,10 +16,14 @@ public class DataCheckDTO implements Serializable { * 客户ID */ private String customerId; + /** + * 客户ID + */ + private String agencyId; /** * 客户名 */ - private String customerName; + private String agencyName; /** * 日期 */ diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ProjectDataServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ProjectDataServiceImpl.java index 6d98d21115..1b1a5d5755 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ProjectDataServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ProjectDataServiceImpl.java @@ -18,12 +18,14 @@ package com.epmet.service.evaluationindex.screen.impl; import com.alibaba.fastjson.JSON; +import com.dingtalk.api.DefaultDingTalkClient; +import com.dingtalk.api.DingTalkClient; import com.dingtalk.api.request.OapiRobotSendRequest; +import com.dingtalk.api.response.OapiRobotSendResponse; import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.DingDingRobotConstant; import com.epmet.commons.tools.utils.DateUtils; -import com.epmet.commons.tools.utils.HttpClientManager; import com.epmet.constant.DataSourceConstant; import com.epmet.dao.evaluationindex.screen.ScreenProjectDataDao; import com.epmet.dto.extract.form.ExtractOriginFormDTO; @@ -31,6 +33,7 @@ import com.epmet.dto.screen.result.DataCheckDTO; import com.epmet.entity.evaluationindex.screen.ScreenProjectDataEntity; import com.epmet.service.evaluationindex.screen.ProjectDataService; import com.epmet.util.DimIdGenerator; +import com.taobao.api.ApiException; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -69,25 +72,31 @@ public class ProjectDataServiceImpl extends BaseServiceImpl list = baseDao.getCheckResult(formDTO); + //群机器人 + String url = DingDingRobotConstant.SELF_ROBOT_URL; + DingTalkClient client = new DefaultDingTalkClient(url); if (CollectionUtils.isNotEmpty(list)) { //发送钉钉消息 - //EPMETV3群机器人 - String secret = DingDingRobotConstant.V3_ROBOT_SECRET; - String url = DingDingRobotConstant.V3_ROBOT_URL; - for (DataCheckDTO dto : list) { OapiRobotSendRequest request = new OapiRobotSendRequest(); request.setMsgtype("markdown"); OapiRobotSendRequest.Markdown markdown = new OapiRobotSendRequest.Markdown(); - markdown.setTitle("平阴三个街道项目日统计数据上报比对结果"); - markdown.setText("客户ID:" + dto.getCustomerId() +"\n\n"+ - "> 客户名称:" + dto.getCustomerName() +"\n\n"+ - "> 日期:" + dto.getDateId() + "\n\n"+ - "> 上报项目数:" + dto.getReportCount() + "\n\n"+ + markdown.setTitle("数据异常"); + markdown.setText("数据异常:" + "\n\n" + + "> 所属客户ID:" + dto.getCustomerId() + "\n\n" + + "> 组织ID:" + dto.getAgencyId() + "\n\n" + + "> 组织名称:" + dto.getAgencyName() + "\n\n" + + "> 日期:" + dto.getDateId() + "\n\n" + + "> 上报项目数:" + dto.getReportCount() + "\n\n" + "> 表中项目数:" + dto.getCount()); request.setMarkdown(markdown); log.info("robot需要发送的内容为:"+markdown.getText()); - HttpClientManager.getInstance().sendDingMsg(JSON.toJSONString(request),url,secret); + try { + OapiRobotSendResponse execute = client.execute(request); + log.info("=====通知结果===>" + JSON.toJSONString(execute)); + } catch (ApiException e) { + log.error("sendDingMarkDownMsg exception", e); + } } } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectDataDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectDataDao.xml index fd9d29f527..95c907ce97 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectDataDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectDataDao.xml @@ -395,16 +395,28 @@ From 65d9931686a46b885df65015258b87ab5a89f8b0 Mon Sep 17 00:00:00 2001 From: jianjun Date: Wed, 9 Mar 2022 09:19:45 +0800 Subject: [PATCH 39/39] =?UTF-8?q?=E5=85=B3=E9=97=AD=E7=9B=91=E6=8E=A7?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gov-issue-server/src/main/resources/bootstrap.yml | 4 ++-- .../gov-project-server/src/main/resources/bootstrap.yml | 4 ++-- .../resi-group-server/src/main/resources/bootstrap.yml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/resources/bootstrap.yml b/epmet-module/gov-issue/gov-issue-server/src/main/resources/bootstrap.yml index af7dee2c58..06f9b57041 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/resources/bootstrap.yml +++ b/epmet-module/gov-issue/gov-issue-server/src/main/resources/bootstrap.yml @@ -30,12 +30,12 @@ spring: password: @spring.datasource.druid.password@ #监控页面 stat-view-servlet: - enabled: true + enabled: false #loginUsername: admin #loginPassword: admin allow: web-stat-filter: - enabled: true + enabled: false filters: stat,log4j2 cloud: nacos: diff --git a/epmet-module/gov-project/gov-project-server/src/main/resources/bootstrap.yml b/epmet-module/gov-project/gov-project-server/src/main/resources/bootstrap.yml index 15aa1dcbfb..22a2f25dc9 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/resources/bootstrap.yml +++ b/epmet-module/gov-project/gov-project-server/src/main/resources/bootstrap.yml @@ -30,12 +30,12 @@ spring: password: @spring.datasource.druid.password@ #监控页面 stat-view-servlet: - enabled: true + enabled: false #loginUsername: admin #loginPassword: admin allow: web-stat-filter: - enabled: true + enabled: false filters: stat,wall,log4j2 # 数据迁移工具flyway flyway: diff --git a/epmet-module/resi-group/resi-group-server/src/main/resources/bootstrap.yml b/epmet-module/resi-group/resi-group-server/src/main/resources/bootstrap.yml index e9a8edafd3..b782d086dc 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/resources/bootstrap.yml +++ b/epmet-module/resi-group/resi-group-server/src/main/resources/bootstrap.yml @@ -33,12 +33,12 @@ spring: password: @spring.datasource.druid.password@ #监控页面 stat-view-servlet: - enabled: true + enabled: false #loginUsername: admin #loginPassword: admin allow: web-stat-filter: - enabled: true + enabled: false filters: stat,wall,log4j2 # 数据迁移工具flyway flyway: