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 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..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 @@ -1,24 +1,55 @@ 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; import javax.servlet.http.HttpServletRequest; import java.util.Enumeration; +import java.util.HashMap; +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 = FeignHystrixConcurrencyStrategy.hystrixAdditionHeaders.get(); + Map requestHeaders = getHeadersFromRequest(); + + log.info("EpmetBaseRequestInterceptor#apply#inheritableAdditionalHeaders:"+inheritableAdditionalHeaders); + + 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(); if (requestAttributes == null) { - return; + return null; } - HttpServletRequest request = ((ServletRequestAttributes) requestAttributes).getRequest(); Enumeration headerNames = request.getHeaderNames(); if (headerNames != null) { @@ -27,9 +58,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/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 { 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..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 @@ -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; @@ -49,22 +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()) { - - // 如果不通过参数指定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-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-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..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 @@ -34,6 +34,9 @@ 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; /** @@ -80,6 +83,20 @@ public class LoginUserHandlerMethodArgumentResolver implements HandlerMethodArgu logger.info("【LoginUserHandlerMethodArgumentResolver】请求uri:{}", requestURI); + // 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); + hm.put(name, String.join(",", headerValues)); + } + + logger.info("LoginUserHandlerMethodArgumentResolver#resolveArgument:"+hm); + + } + //app-client-userId String redisKey = request.getHeader(Constant.APP_USER_KEY); if (StringUtils.isEmpty(redisKey)) { 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-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..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,12 +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.EpmetErrorCode; -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; @@ -35,10 +32,17 @@ public class YuShanSysApiService { * * @return */ - @Async + // @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("参数错误"); + log.warn("updateUserPoints 参数错误"); + return; } if (!SpecialCustomerOrgConstant.PING_YIN_CUSTOMER_ID.equals(customerId)) { return; @@ -66,14 +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.warn("updateUserPoints exception 入参:{}", JSON.toJSONString(formDTO)); - throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), e.getMessage()); + log.error("updateUserPoints exception 入参:{},异常:{}", JSON.toJSONString(formDTO), e); } } } diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/DataSourceConstant.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/DataSourceConstant.java index 1ae7002dc4..543b3865b3 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/DataSourceConstant.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/DataSourceConstant.java @@ -12,6 +12,7 @@ public interface DataSourceConstant { String RESI_GROUP = "resiGroup"; String EPMET_USER = "epmetuser"; String EVALUATION_INDEX = "evaluationIndex"; + String EVALUATION_INDEX_READ = "evaluationIndexRead"; String PARTY_MEMBER = "partyMember"; String EPMET_HEART="epmetHeart"; String EPMET_POINT = "epmetPoint"; 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 new file mode 100644 index 0000000000..a19dfbc1a2 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/DataCheckDTO.java @@ -0,0 +1,39 @@ +package com.epmet.dto.screen.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description + * @Author zhaoqifeng + * @Date 2022/3/7 15:56 + */ +@Data +public class DataCheckDTO implements Serializable { + private static final long serialVersionUID = -5836567756526658928L; + /** + * 客户ID + */ + private String customerId; + /** + * 客户ID + */ + private String agencyId; + /** + * 客户名 + */ + private String agencyName; + /** + * 日期 + */ + private String dateId; + /** + * 上报项目数 + */ + private String reportCount; + /** + * 项目数 + */ + private String count; +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java index c729dea005..595977d64c 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java @@ -365,4 +365,7 @@ public interface DataStatisticalOpenFeignClient { @PostMapping("/data/stats/ic/user/category-analysis-daily") Result statUserCategoryDaily(@RequestBody IcUserCategoryAnalysisDailyFormDTO formDTO); + + @PostMapping("/data/stats/screenextract/data_check") + Result dataCheck(@RequestBody ExtractOriginFormDTO formDTO); } diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java index a65ced89f8..43e2a3445c 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java @@ -346,4 +346,9 @@ public class DataStatisticalOpenFeignClientFallBack implements DataStatisticalOp public Result statUserCategoryDaily(IcUserCategoryAnalysisDailyFormDTO formDTO) { return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "statUserCategoryDaily", formDTO); } + + @Override + public Result dataCheck(ExtractOriginFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "dataCheck", formDTO); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/pom.xml b/epmet-module/data-statistical/data-statistical-server/pom.xml index d142521099..de703b486f 100644 --- a/epmet-module/data-statistical/data-statistical-server/pom.xml +++ b/epmet-module/data-statistical/data-statistical-server/pom.xml @@ -242,6 +242,12 @@ epmet_evaluation_index_user EpmEt-db-UsEr + + + + root + root + @@ -374,6 +380,12 @@ epmet_evaluation_index_user EpmEt-db-UsEr + + + + root + root + @@ -506,6 +518,12 @@ epmet elink@833066 + + + + epmet + elink@833066 + @@ -634,6 +652,12 @@ epmet_evaluation_index_user EpmEt-db-UsEr + + + + epmet_cloud_viewer + EpmEtclOUdvIEwEr@w + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenExtractDailyController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenExtractDailyController.java index 756ecc2d8a..466774ecc5 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenExtractDailyController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenExtractDailyController.java @@ -5,6 +5,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.dto.extract.form.ExtractOriginFormDTO; import com.epmet.dto.extract.form.ExtractScreenFormDTO; import com.epmet.service.evaluationindex.extract.toscreen.ScreenExtractService; +import com.epmet.service.evaluationindex.screen.ProjectDataService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; @@ -12,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import javax.annotation.Resource; import java.util.concurrent.ExecutorService; /** @@ -26,6 +28,8 @@ public class ScreenExtractDailyController { private ScreenExtractService screenExtractService; @Autowired private ExecutorService executorService; + @Resource + private ProjectDataService projectDataService; /** * @param extractOriginFormDTO @@ -59,4 +63,19 @@ public class ScreenExtractDailyController { return new Result(); } + + /** + * 平阴三个街道上报统计数据正确性校验 + * + * @Param formDTO + * @Return {@link Result} + * @Author zhaoqifeng + * @Date 2022/3/7 15:43 + */ + @PostMapping("data_check") + public Result dataCheck(@RequestBody ExtractOriginFormDTO formDTO) { + projectDataService.dataCheck(formDTO); + return new Result(); + } + } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenProjectDataDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenProjectDataDao.java index 701348e39a..bf82610651 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenProjectDataDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenProjectDataDao.java @@ -18,7 +18,9 @@ package com.epmet.dao.evaluationindex.screen; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.extract.form.ExtractOriginFormDTO; import com.epmet.dto.screen.ScreenProjectDataDTO; +import com.epmet.dto.screen.result.DataCheckDTO; import com.epmet.dto.screen.result.GridAndOrgCategoryCountResultDTO; import com.epmet.entity.evaluationindex.screen.ScreenProjectDataEntity; import org.apache.ibatis.annotations.Mapper; @@ -111,4 +113,13 @@ public interface ScreenProjectDataDao extends BaseDao { @Param("customerId") String customerId, @Param("subCount")Integer subCount, @Param("allAgencies") List allAgencies); + /** + * 获取数据比对结果 + * + * @Param formDTO + * @Return {@link List< DataCheckDTO>} + * @Author zhaoqifeng + * @Date 2022/3/7 16:00 + */ + List getCheckResult(ExtractOriginFormDTO formDTO); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ProjectDataService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ProjectDataService.java new file mode 100644 index 0000000000..ac348125ab --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ProjectDataService.java @@ -0,0 +1,42 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.evaluationindex.screen; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.dto.extract.form.ExtractOriginFormDTO; +import com.epmet.entity.evaluationindex.screen.ScreenProjectDataEntity; + +/** + * 中央区-项目数据 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2021-02-23 + */ +public interface ProjectDataService extends BaseService { + + /** + * 平阴三个街道上报统计数据正确性校验 + * + * @Param formDTO + * @Return + * @Author zhaoqifeng + * @Date 2022/3/7 15:44 + */ + void dataCheck(ExtractOriginFormDTO formDTO); + +} 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 new file mode 100644 index 0000000000..1b1a5d5755 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ProjectDataServiceImpl.java @@ -0,0 +1,103 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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.constant.DataSourceConstant; +import com.epmet.dao.evaluationindex.screen.ScreenProjectDataDao; +import com.epmet.dto.extract.form.ExtractOriginFormDTO; +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; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.List; + +/** + * 中央区-项目数据 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2021-02-23 + */ +@Slf4j +@Service +@DataSource(value = DataSourceConstant.EVALUATION_INDEX_READ) +public class ProjectDataServiceImpl extends BaseServiceImpl implements ProjectDataService { + + /** + * 平阴三个街道上报统计数据正确性校验 + * + * @param formDTO + * @Param formDTO + * @Return + * @Author zhaoqifeng + * @Date 2022/3/7 15:44 + */ + @Override + public void dataCheck(ExtractOriginFormDTO formDTO) { + if (StringUtils.isNotBlank(formDTO.getStartDate()) && StringUtils.isNotBlank(formDTO.getEndDate())) { + formDTO.setDateId(null); + } else { + if (StringUtils.isBlank(formDTO.getDateId())){ + formDTO.setDateId(DimIdGenerator.getDateDimId(DateUtils.addDateDays(new Date(), -1))); + } + } + List list = baseDao.getCheckResult(formDTO); + //群机器人 + String url = DingDingRobotConstant.SELF_ROBOT_URL; + DingTalkClient client = new DefaultDingTalkClient(url); + if (CollectionUtils.isNotEmpty(list)) { + //发送钉钉消息 + for (DataCheckDTO dto : list) { + OapiRobotSendRequest request = new OapiRobotSendRequest(); + request.setMsgtype("markdown"); + OapiRobotSendRequest.Markdown markdown = new OapiRobotSendRequest.Markdown(); + 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()); + 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/bootstrap.yml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml index 8374e06c4f..b159668ec9 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml @@ -193,6 +193,11 @@ dynamic: url: @datasource.druid.operCustomize.url@ username: @datasource.druid.operCustomize.username@ password: @datasource.druid.operCustomize.password@ + evaluationIndexRead: + driver-class-name: com.mysql.cj.jdbc.Driver + url: @datasource.druid.evaluationIndex1.url@ + username: @datasource.druid.evaluationIndex1.username@ + password: @datasource.druid.evaluationIndex1.password@ thread: # 线程池配置 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 7a192fa70d..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 @@ -393,4 +393,69 @@ GROUP BY categoryCode + 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/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..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 @@ -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; @@ -66,9 +67,8 @@ 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; import java.util.*; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; @@ -84,13 +84,12 @@ import static com.epmet.commons.tools.utils.DateUtils.DATE_PATTERN; */ @Service @Slf4j -@EnableAsync public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl implements IcCommunitySelfOrganizationService { @Autowired private IcCommunitySelfOrganizationPersonnelService personnelService; @Autowired - private IcUserDemandRecService icUserDemandRecService; + private IcUserDemandRecDao icUserDemandRecDao; @Autowired private OssFeignClient ossFeignClient; @Autowired @@ -306,7 +305,11 @@ 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}; @@ -315,11 +318,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; @@ -328,10 +331,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; @@ -478,13 +481,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/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()); + } + } +} 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-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 bcc96a106f..acdd00b556 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..fe5722451e 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 @@ -40,10 +40,12 @@ import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.service.IcNeighborHoodService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; 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 +150,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/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 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/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 499f1a750b..681fbc6458 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 @@ -29,6 +29,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; @@ -76,5 +77,5 @@ public interface HouseService { */ void allDelete(NeighborHoodManageDelFormDTO formDTO); - 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 091ef5dd1e..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 @@ -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,28 @@ 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; + public Result buildingImportExcel(ImportInfoFormDTO formDTO, InputStream inputStream,Result importTask) throws IOException { + 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(); + 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 a0e6407d0c..b1ea2f0fc0 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 @@ -70,6 +70,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 @@ -102,6 +103,8 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { private IcNeighborHoodService neighborHoodService; @Autowired private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient; + @Autowired + private ExecutorService executorService; @Autowired private EpmetUserOpenFeignClient epmetUserOpenFeignClient; @@ -353,39 +356,37 @@ 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; } - @Async @Override - public Result dispose(MultipartFile file, ImportInfoFormDTO formDTO, Result importTask) { - ExcelReader excelReader = null; - try { - InputStream inputStream = null; + public Result dispose(InputStream inputStream, ImportInfoFormDTO formDTO, Result importTask) { + 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(); + 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(); } 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 d68ba40e01..f32ef3e285 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 @@ -71,6 +71,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.http.entity.ContentType; import org.apache.poi.ss.usermodel.Workbook; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; @@ -226,31 +227,23 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl importTask) { - log.info("neighborhoodImport start====="); - executorService.submit(() -> { + @Async + 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) .registerReadListener(new ImportNeighborHoodInfoListener(formDTO,icHouseRedis,icBuildingDao,this,propertyManagementDao,epmetCommonServiceOpenFeignClient,importTask.getData().getTaskId())) .build(); - log.info("neighborhoodImport build readSheet num:{}",readSheet.getSheetNo()); excelReader.read(readSheet); } catch (Exception e){ log.error("neighborhoodImport import exception", e); @@ -266,7 +259,7 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl(); } 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 40984e17f1..4a53158d3e 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 @@ -123,7 +123,9 @@ a.BUILDING_UNIT_ID as unitNumKey, a.HOUSE_TYPE as houseTypeKey, a.PURPOSE as purposeKey, - a.RENT_FLAG as rentFlagKey + a.RENT_FLAG as rentFlagKey, + c.AGENCY_ID as agencyId, + c.GRID_ID as gridId from ic_house a LEFT JOIN ic_building b on a.BUILDING_ID = b.ID and b.DEL_FLAG = '0' LEFT JOIN ic_neighbor_hood c on a.NEIGHBOR_HOOD_ID = c.ID and c.DEL_FLAG = '0' @@ -304,6 +306,8 @@ and ih.id !=#{houseId} + +