diff --git a/epmet-auth-client/pom.xml b/epmet-auth-client/pom.xml index 1aee53c24e..d84ead3ff5 100644 --- a/epmet-auth-client/pom.xml +++ b/epmet-auth-client/pom.xml @@ -11,4 +11,11 @@ epmet-auth-client + + + com.epmet + epmet-commons-tools + 2.0.0 + + \ No newline at end of file diff --git a/epmet-auth-client/src/main/java/com/epmet/auth/dto/result/BlockChainStaffAuthResultDTO.java b/epmet-auth-client/src/main/java/com/epmet/auth/dto/result/BlockChainStaffAuthResultDTO.java new file mode 100644 index 0000000000..2a1ca0dfcc --- /dev/null +++ b/epmet-auth-client/src/main/java/com/epmet/auth/dto/result/BlockChainStaffAuthResultDTO.java @@ -0,0 +1,25 @@ +package com.epmet.auth.dto.result; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @ClassName BlockChainStaffAuthResultDTO + * @Description 区块链用户认证结果 + * @Author wangxianzhang + * @Date 2022/1/20 10:41 上午 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class BlockChainStaffAuthResultDTO { + + private String userId; + private String realName; + private String phone; + private String headUrl; + private String agencyId; + private String agencyName; + +} diff --git a/epmet-auth/src/main/java/com/epmet/controller/GovLoginController.java b/epmet-auth/src/main/java/com/epmet/controller/GovLoginController.java index 386e162c02..8745418f90 100644 --- a/epmet-auth/src/main/java/com/epmet/controller/GovLoginController.java +++ b/epmet-auth/src/main/java/com/epmet/controller/GovLoginController.java @@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.HashMap; import java.util.List; /** diff --git a/epmet-auth/src/main/java/com/epmet/controller/GovWebController.java b/epmet-auth/src/main/java/com/epmet/controller/GovWebController.java index 8a85cb9da4..9320b5f140 100644 --- a/epmet-auth/src/main/java/com/epmet/controller/GovWebController.java +++ b/epmet-auth/src/main/java/com/epmet/controller/GovWebController.java @@ -1,8 +1,10 @@ package com.epmet.controller; +import com.epmet.auth.dto.result.BlockChainStaffAuthResultDTO; import com.epmet.commons.tools.utils.RSASignature; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.form.BcStaffAuthenticationFormDTO; import com.epmet.dto.form.GovWebLoginFormDTO; import com.epmet.dto.result.UserTokenResultDTO; import com.epmet.service.GovWebService; @@ -13,6 +15,8 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.HashMap; + /** * @author sun @@ -63,5 +67,21 @@ public class GovWebController { return new Result().ok(publicKey); } + /** + * 区块链web 系统身份认证 + * @param input + * @return + */ + @PostMapping("/blockchain/authentication") + public Result blockChainGetStaffInfoByPwd(@RequestBody BcStaffAuthenticationFormDTO input) { + ValidatorUtils.validateEntity(input); + String customerId = input.getCustomerId(); + String mobile = input.getMobile(); + String password = input.getPassword(); + + BlockChainStaffAuthResultDTO r = govWebService.blockChainStaffAuthenticationByPwd(customerId, mobile, password); + + return new Result().ok(r); + } } diff --git a/epmet-auth/src/main/java/com/epmet/dto/form/BcStaffAuthenticationFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/BcStaffAuthenticationFormDTO.java new file mode 100644 index 0000000000..202f8073c9 --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/dto/form/BcStaffAuthenticationFormDTO.java @@ -0,0 +1,24 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * @ClassName BcAdminLoginFormDTO + * @Description 区块链管理系统staff身份认证 + * @Author wangxianzhang + * @Date 2022/1/17 10:11 下午 + */ +@Data +public class BcStaffAuthenticationFormDTO { + + @NotBlank(message = "客户ID必填") + private String customerId; + + @NotBlank(message = "手机号必填") + private String mobile; + + @NotBlank(message = "密码必填") + private String password; +} diff --git a/epmet-auth/src/main/java/com/epmet/service/GovWebService.java b/epmet-auth/src/main/java/com/epmet/service/GovWebService.java index 30f8d8ae4c..10d86c20b4 100644 --- a/epmet-auth/src/main/java/com/epmet/service/GovWebService.java +++ b/epmet-auth/src/main/java/com/epmet/service/GovWebService.java @@ -1,5 +1,6 @@ package com.epmet.service; +import com.epmet.auth.dto.result.BlockChainStaffAuthResultDTO; import com.epmet.dto.form.GovWebLoginFormDTO; import com.epmet.dto.result.UserTokenResultDTO; @@ -16,4 +17,12 @@ public interface GovWebService { * @Description PC工作端-工作人员登录 **/ UserTokenResultDTO login(GovWebLoginFormDTO formDTO); + + /** + * 区块链系统通过用户密码认证身份 + * @param mobile + * @param password + * @return + */ + BlockChainStaffAuthResultDTO blockChainStaffAuthenticationByPwd(String customerId, String mobile, String password); } diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java index 86569434c2..8d78665550 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/GovLoginServiceImpl.java @@ -5,8 +5,10 @@ import com.epmet.common.token.constant.LoginConstant; import com.epmet.commons.tools.constant.AppClientConstant; import com.epmet.commons.tools.constant.ServiceConstant; 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.ResultDataResolver; import com.epmet.commons.tools.security.dto.GovTokenDto; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.password.PasswordUtils; @@ -46,7 +48,7 @@ import java.util.stream.Collectors; * @Date 2020/4/20 10:56 */ @Service -public class GovLoginServiceImpl implements GovLoginService { +public class GovLoginServiceImpl implements GovLoginService, ResultDataResolver { private static final Logger logger = LoggerFactory.getLogger(GovLoginServiceImpl.class); private static final String SEND_SMS_CODE_ERROR = "发送短信验证码异常,手机号[%s],code[%s],msg[%s]"; @Autowired diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/GovWebServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/GovWebServiceImpl.java index 9d455af694..d6edfb8657 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/GovWebServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/GovWebServiceImpl.java @@ -1,13 +1,21 @@ package com.epmet.service.impl; +import com.epmet.auth.dto.result.BlockChainStaffAuthResultDTO; import com.epmet.common.token.constant.LoginConstant; +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.feign.ResultDataResolver; +import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.security.dto.GovTokenDto; import com.epmet.commons.tools.security.password.PasswordUtils; import com.epmet.commons.tools.utils.CpUserDetailRedis; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.CustomerStaffDTO; +import com.epmet.dto.form.CustomerStaffFormDTO; import com.epmet.dto.form.GovWebLoginFormDTO; import com.epmet.dto.form.GovWebOperLoginFormDTO; import com.epmet.dto.result.GovWebOperLoginResultDTO; @@ -32,7 +40,7 @@ import java.util.Map; */ @Slf4j @Service -public class GovWebServiceImpl implements GovWebService { +public class GovWebServiceImpl implements GovWebService, ResultDataResolver { private static final Logger logger = LoggerFactory.getLogger(GovWebServiceImpl.class); @Autowired @@ -131,5 +139,36 @@ public class GovWebServiceImpl implements GovWebService { return token; } + @Override + public BlockChainStaffAuthResultDTO blockChainStaffAuthenticationByPwd(String customerId, String mobile, String password) { + + GovWebOperLoginFormDTO form = new GovWebOperLoginFormDTO(); + form.setCustomerId(customerId); + form.setMobile(mobile); + + // 用户认证 + GovWebOperLoginResultDTO staff = getResultDataOrThrowsException(epmetUserFeignClient.getStaffIdAndPwd(form), ServiceConstant.EPMET_USER_SERVER, + EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), + String.format("【区块链用户认证】根据手机号%s和指定客户ID:%s认证用户失败", mobile, customerId), + "认证失败"); + + if (staff == null) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), + String.format("【区块链用户认证】根据手机号%s和指定客户ID:%s认证用户失败", mobile, customerId)); + } + + if (!PasswordUtils.matches(password, staff.getPassWord())) { + // 密码不匹配 + throw new EpmetException(EpmetErrorCode.ERR10004.getCode(), String.format("【区块链用户认证】密码不匹配,手机号:%s", mobile)); + } + + // 用户基础信息 + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(customerId, staff.getUserId()); + + BlockChainStaffAuthResultDTO r = new BlockChainStaffAuthResultDTO(staff.getUserId(), staffInfo.getRealName(), + staffInfo.getMobile(), staffInfo.getHeadPhoto(), staffInfo.getAgencyId(), staffInfo.getAgencyName()); + + return r; + } } diff --git a/epmet-commons/epmet-commons-tools/pom.xml b/epmet-commons/epmet-commons-tools/pom.xml index 31e2276fc4..cafd5f7023 100644 --- a/epmet-commons/epmet-commons-tools/pom.xml +++ b/epmet-commons/epmet-commons-tools/pom.xml @@ -161,6 +161,11 @@ 2.6.0 compile + + com.alibaba + transmittable-thread-local + 2.12.4 + diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/AsyncConfig.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/AsyncConfig.java index 2778f3c9ef..f094348322 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/AsyncConfig.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/config/AsyncConfig.java @@ -1,5 +1,6 @@ package com.epmet.commons.tools.config; +import com.alibaba.ttl.threadpool.TtlExecutors; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; @@ -69,7 +70,7 @@ public class AsyncConfig { @Bean public ExecutorService executorService() { ThreadPoolTaskExecutor executor = (ThreadPoolTaskExecutor) executor(); - return executor.getThreadPoolExecutor(); + return TtlExecutors.getTtlExecutorService(executor.getThreadPoolExecutor()); } /** 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 67d96e4dd4..50234e0ce6 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 @@ -22,4 +22,7 @@ public interface DingDingRobotConstant { * 开发测试-报警群的服务监控助理机器人 */ String DEPLOY_ROBOT="https://oapi.dingtalk.com/robot/send?access_token=5dfbde0c814a43d72e3e7f02385db87df1fc8231cff30728d8df1d1b58a00998"; + + String SELF_ROBOT_URL="https://oapi.dingtalk.com/robot/send?access_token=ffd7c972b0525e249283df1a16b65a8b9d0012601f3a458dfc588c2eac497bb5"; + String SELF_ROBOT_SECRET=null; } 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 9061c2e8d3..40d69ebcf4 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 @@ -22,8 +22,4 @@ 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/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java index 7992a0049a..4614beb5ba 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java @@ -250,6 +250,7 @@ public enum EpmetErrorCode { ORG_ADD_FAILED(8919,"添加失败"), ORG_EDIT_FAILED(8920,"编辑失败"), ORG_DEL_FAILED(8921,"删除失败"), + NEIGHBORHOOD_DEL_FAILED(8922,""), //通用错误码 start 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 2b07b4b5ab..2cfa8ea3ad 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,6 +1,6 @@ package com.epmet.commons.tools.feign; -import com.epmet.commons.tools.constant.ThreadLocalConstant; +import com.epmet.commons.tools.utils.EpmetRequestHolder; import feign.RequestInterceptor; import feign.RequestTemplate; import org.slf4j.Logger; @@ -21,23 +21,17 @@ public class EpmetBaseRequestInterceptor implements RequestInterceptor { @Override public void apply(RequestTemplate template) { - // 自定义追加的request header,可被子线程继承拷贝 - Map inheritableAdditionalHeaders = FeignHystrixConcurrencyStrategy.hystrixAdditionHeaders.get(); - Map requestHeaders = getHeadersFromRequest(); + Map requestHeaders = EpmetRequestHolder.getAllHeaders(); - log.info("EpmetBaseRequestInterceptor#apply#inheritableAdditionalHeaders:"+inheritableAdditionalHeaders); +// Map requestHeaders = getHeadersFromRequest(); + + log.info("EpmetBaseRequestInterceptor#apply#inheritableAdditionalHeaders:" + requestHeaders); 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()); - } - } } /** 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 0d2998ccd3..2a63841ac9 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,6 +1,6 @@ package com.epmet.commons.tools.feign; -import com.epmet.commons.tools.constant.ThreadLocalConstant; +import com.alibaba.ttl.TtlRunnable; import com.netflix.hystrix.HystrixThreadPoolKey; import com.netflix.hystrix.HystrixThreadPoolProperties; import com.netflix.hystrix.strategy.HystrixPlugins; @@ -12,17 +12,15 @@ import com.netflix.hystrix.strategy.executionhook.HystrixCommandExecutionHook; import com.netflix.hystrix.strategy.metrics.HystrixMetricsPublisher; import com.netflix.hystrix.strategy.properties.HystrixPropertiesStrategy; import com.netflix.hystrix.strategy.properties.HystrixProperty; +import com.netflix.hystrix.util.PlatformSpecific; import org.slf4j.Logger; import org.slf4j.LoggerFactory; 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; -import java.util.concurrent.TimeUnit; +import java.util.concurrent.*; +import java.util.concurrent.atomic.AtomicInteger; /** * 自定义Feign的隔离策略 @@ -37,7 +35,6 @@ 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; @@ -77,23 +74,57 @@ 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, inheritableAdditionalHeaders); + return new WrappedCallable<>(callable, requestAttributes); } @Override public ThreadPoolExecutor getThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixProperty corePoolSize, HystrixProperty maximumPoolSize, HystrixProperty keepAliveTime, TimeUnit unit, BlockingQueue workQueue) { - return this.delegate.getThreadPool(threadPoolKey, corePoolSize, maximumPoolSize, keepAliveTime, - unit, workQueue); +// return this.delegate.getThreadPool(threadPoolKey, corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue); + + final ThreadFactory threadFactory = getThreadFactory(threadPoolKey); + + final int dynamicCoreSize = corePoolSize.get(); + final int dynamicMaximumSize = maximumPoolSize.get(); + + if (dynamicCoreSize > dynamicMaximumSize) { + log.error("Epmet Hystrix ThreadPool configuration at startup for : " + threadPoolKey.name() + " is trying to set coreSize = " + + dynamicCoreSize + " and maximumSize = " + dynamicMaximumSize + ". Maximum size will be set to " + + dynamicCoreSize + ", the coreSize value, since it must be equal to or greater than the coreSize value"); + return new WrappedThreadPoolExecutor(dynamicCoreSize, dynamicCoreSize, keepAliveTime.get(), unit, workQueue, threadFactory); + } else { + return new WrappedThreadPoolExecutor(dynamicCoreSize, dynamicMaximumSize, keepAliveTime.get(), unit, workQueue, threadFactory); + } } @Override public ThreadPoolExecutor getThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolProperties threadPoolProperties) { - return this.delegate.getThreadPool(threadPoolKey, threadPoolProperties); +// return this.delegate.getThreadPool(threadPoolKey, threadPoolProperties); + + final ThreadFactory threadFactory = getThreadFactory(threadPoolKey); + + final boolean allowMaximumSizeToDivergeFromCoreSize = threadPoolProperties.getAllowMaximumSizeToDivergeFromCoreSize().get(); + final int dynamicCoreSize = threadPoolProperties.coreSize().get(); + final int keepAliveTime = threadPoolProperties.keepAliveTimeMinutes().get(); + final int maxQueueSize = threadPoolProperties.maxQueueSize().get(); + final BlockingQueue workQueue = getBlockingQueue(maxQueueSize); + + if (allowMaximumSizeToDivergeFromCoreSize) { + final int dynamicMaximumSize = threadPoolProperties.maximumSize().get(); + if (dynamicCoreSize > dynamicMaximumSize) { + log.error("Epmet Hystrix ThreadPool configuration at startup for : " + threadPoolKey.name() + " is trying to set coreSize = " + + dynamicCoreSize + " and maximumSize = " + dynamicMaximumSize + ". Maximum size will be set to " + + dynamicCoreSize + ", the coreSize value, since it must be equal to or greater than the coreSize value"); + return new WrappedThreadPoolExecutor(dynamicCoreSize, dynamicCoreSize, keepAliveTime, TimeUnit.MINUTES, workQueue, threadFactory); + } else { + return new WrappedThreadPoolExecutor(dynamicCoreSize, dynamicMaximumSize, keepAliveTime, TimeUnit.MINUTES, workQueue, threadFactory); + } + } else { + return new WrappedThreadPoolExecutor(dynamicCoreSize, dynamicCoreSize, keepAliveTime, TimeUnit.MINUTES, workQueue, threadFactory); + } } @Override @@ -106,21 +137,41 @@ public class FeignHystrixConcurrencyStrategy extends HystrixConcurrencyStrategy return this.delegate.getRequestVariable(rv); } + /** + * 从父类复制过来的 + * @param threadPoolKey + * @return + */ + private ThreadFactory getThreadFactory(final HystrixThreadPoolKey threadPoolKey) { + if (!PlatformSpecific.isAppEngineStandardEnvironment()) { + return new ThreadFactory() { + private final AtomicInteger threadNumber = new AtomicInteger(0); + + @Override + public Thread newThread(Runnable r) { + Thread thread = new Thread(r, "hystrix-" + threadPoolKey.name() + "-" + threadNumber.incrementAndGet()); + thread.setDaemon(true); + return thread; + } + + }; + } else { + return PlatformSpecific.getAppEngineThreadFactory(); + } + } + static class WrappedCallable implements Callable { private final Callable target; private final RequestAttributes requestAttributes; - private final Map inheritableAdditionalHeaders; - public WrappedCallable(Callable target, RequestAttributes requestAttributes, Map inheritableAdditionalHeaders) { + public WrappedCallable(Callable target, RequestAttributes requestAttributes) { 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 { @@ -128,4 +179,25 @@ public class FeignHystrixConcurrencyStrategy extends HystrixConcurrencyStrategy } } } + + /** + * 自定义线程池类,使用Ttl包装过,解决异步环境下线程上下文透传问题 + */ + static class WrappedThreadPoolExecutor extends ThreadPoolExecutor { + private static final RejectedExecutionHandler defaultHandler = new AbortPolicy(); + + public WrappedThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, + BlockingQueue workQueue) { + super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue); + } + public WrappedThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, + BlockingQueue workQueue, ThreadFactory threadFactory) { + super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory, defaultHandler); + } + + @Override + public void execute(Runnable command) { + super.execute(TtlRunnable.get(command)); + } + } } 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 4aa7beab20..d27a5dbe0f 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 @@ -1,10 +1,16 @@ package com.epmet.commons.tools.filter; import com.epmet.commons.tools.constant.ThreadLocalConstant; +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.commons.tools.utils.EpmetRequestHolder; +import lombok.extern.slf4j.Slf4j; import javax.servlet.*; import javax.servlet.annotation.WebFilter; +import javax.servlet.http.HttpServletRequest; import java.io.IOException; +import java.util.Enumeration; +import java.util.HashMap; /** * @Description 全局过滤器,可在请求结束的时候清除线程变量残留 @@ -12,20 +18,59 @@ import java.io.IOException; * @date 2021.07.19 10:19:24 */ @WebFilter(value = "/*") +@Slf4j public class GlobalFilter implements Filter { @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { try { + // 获取request中的header,放入RequestHeaderHolder,用于异步环境下的上下文透传 + HashMap headerMap = getHeadersFromRequest((HttpServletRequest) servletRequest); + EpmetRequestHolder.addHeaders(headerMap); + filterChain.doFilter(servletRequest, servletResponse); } catch (Throwable e) { throw e; } finally { // 清除线程变量残留 - ThreadLocalConstant.sqlFilter.remove(); - ThreadLocalConstant.requirePermissionTl.remove(); - ThreadLocalConstant.requestParam.remove(); - ThreadLocalConstant.inheritableAdditionalHeaders.remove(); + clear(ThreadLocalConstant.sqlFilter, "sqlFilter"); + clear(ThreadLocalConstant.requirePermissionTl, "requirePermissionTl"); + clear(ThreadLocalConstant.requestParam, "requestParam"); + EpmetRequestHolder.clearAllHeaders(); + System.out.println("清理完成"); + } + } + + /** + * 从header里面获取headers + */ + public 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; + } + + /** + * 清空threadlocal + * @param tl + * @param tag + */ + public void clear(ThreadLocal tl, String tag) { + try { + tl.remove(); + } catch (Throwable t) { + String errorMsg = ExceptionUtils.getThrowableErrorStackTrace(t); + log.error("【GlobalFilter】清空ThreadLocal失败,{}, {}", tag, errorMsg); } } } \ No newline at end of file diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/EpmetRequestHolder.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/EpmetRequestHolder.java new file mode 100644 index 0000000000..80849ebfc3 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/EpmetRequestHolder.java @@ -0,0 +1,67 @@ +package com.epmet.commons.tools.utils; + +import com.alibaba.ttl.TransmittableThreadLocal; +import org.apache.commons.lang3.StringUtils; + +import java.util.HashMap; +import java.util.Map; + +/** + * 请求header holder,可用于异步环境下request header的透传。详情结合 alibaba transmitable-thread-local + */ +public class EpmetRequestHolder { + + public static final TransmittableThreadLocal> requestHeaderTtl = new TransmittableThreadLocal<>(); + + /** + * 存储 + * @param headerName + * @param headerValue + */ + public static void addHeader(String headerName, String headerValue) { + if (StringUtils.isBlank(headerName)) { + return; + } + before(); + requestHeaderTtl.get().put(headerName, headerValue); + } + + public static void addHeaders(Map headers) { + if (headers == null) { + return; + } + before(); + requestHeaderTtl.get().putAll(headers); + } + + private static void before() { + if (requestHeaderTtl.get() == null) { + requestHeaderTtl.set(new HashMap<>()); + } + } + + /** + * 获取 + * @param headerName + * @return + */ + public static String getHeader(String headerName) { + return requestHeaderTtl.get().get(headerName); + } + + /** + * 获取所有 + * @return + */ + public static Map getAllHeaders() { + return requestHeaderTtl.get(); + } + + /** + * 清空内容 + */ + public static void clearAllHeaders() { + requestHeaderTtl.remove(); + } + +} diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/result/GridInfoResultDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/result/GridInfoResultDTO.java index 45618fbff5..a4e155231f 100644 --- a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/result/GridInfoResultDTO.java +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/result/GridInfoResultDTO.java @@ -37,5 +37,6 @@ public class GridInfoResultDTO implements Serializable { */ private String gridId = ""; private String gridName = ""; + private String pids = ""; } \ No newline at end of file diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/GridLivelyDetailExcel.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/GridLivelyDetailExcel.java new file mode 100644 index 0000000000..ce6d2b5365 --- /dev/null +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/GridLivelyDetailExcel.java @@ -0,0 +1,81 @@ +/** + * 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.dataaggre.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import cn.afterturn.easypoi.excel.annotation.ExcelIgnore; +import lombok.Data; + +import java.util.LinkedList; +import java.util.List; + +/** + * @Description 网格活跃度文件导出-活跃网格sheet-接口返参 + * @Author sun + */ +@Data +public class GridLivelyDetailExcel { + + LinkedList livelyExcelList; + List livelyGrid; + List ordinaryGrid; + List lazyGrid; + + //活跃网格 + @Data + public static class LivelyGrid { + @ExcelIgnore + private String agencyId; + @Excel(name = "所属组织", width = 20, mergeVertical = true) + private String agencyName; + @ExcelIgnore + private String gridId; + @Excel(name = "活跃网格名称",width = 20) + private String gridName; + @Excel(name = "活跃天数",width = 20) + private Integer datyNum; + } + //正常网格 + @Data + public static class OrdinaryGrid { + @ExcelIgnore + private String agencyId; + @Excel(name = "所属组织", width = 20, mergeVertical = true) + private String agencyName; + @ExcelIgnore + private String gridId; + @Excel(name = "正常运行网格名称", width = 20) + private String gridName; + @Excel(name = "活跃天数", width = 20) + private Integer datyNum; + } + //僵尸网格 + @Data + public static class LazyGrid { + @ExcelIgnore + private String agencyId; + @Excel(name = "所属组织", width = 20, mergeVertical = true) + private String agencyName; + @ExcelIgnore + private String gridId; + @Excel(name = "僵尸网格名称",width = 20) + private String gridName; + @Excel(name = "活跃天数",width = 20) + private Integer datyNum; + } +} diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/GridLivelyExcel.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/GridLivelyExcel.java index 331511dbe6..39740aa2a2 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/GridLivelyExcel.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/GridLivelyExcel.java @@ -18,7 +18,7 @@ package com.epmet.dataaggre.excel; import cn.afterturn.easypoi.excel.annotation.Excel; -import com.alibaba.excel.annotation.ExcelIgnore; +import cn.afterturn.easypoi.excel.annotation.ExcelIgnore; import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.write.style.ColumnWidth; import lombok.Data; @@ -66,7 +66,7 @@ public class GridLivelyExcel { //正常运行网格数占比 - @Excel(name = "正常运行网格数占比",width = 15) + @Excel(name = "正常运行网格数占比",width = 20) @ExcelProperty("正常运行网格数占比") @ColumnWidth(15) private String gridOrdinaryRatio; diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java index 7acb871048..dc63adc141 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java @@ -2,9 +2,7 @@ package com.epmet.dataaggre.service.govorg.impl; import cn.afterturn.easypoi.excel.ExcelExportUtil; import cn.afterturn.easypoi.excel.entity.ExportParams; -import com.alibaba.excel.EasyExcel; -import com.alibaba.excel.ExcelWriter; -import com.alibaba.excel.write.metadata.WriteSheet; +import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; import com.alibaba.fastjson.JSON; import com.dingtalk.api.request.OapiRobotSendRequest; import com.epmet.commons.dynamic.datasource.annotation.DataSource; @@ -16,10 +14,10 @@ import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.redis.common.CustomerOrgRedis; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; +import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; import com.epmet.commons.tools.security.dto.TokenDto; -import com.epmet.commons.tools.utils.ConvertUtils; -import com.epmet.commons.tools.utils.ExcelUtils; import com.epmet.commons.tools.utils.HttpClientManager; import com.epmet.commons.tools.utils.Result; import com.epmet.dataaggre.constant.DataSourceConstant; @@ -31,6 +29,7 @@ import com.epmet.dataaggre.dto.govorg.form.*; import com.epmet.dataaggre.dto.govorg.result.*; import com.epmet.dataaggre.dto.resigroup.result.OrgInfoCommonDTO; import com.epmet.dataaggre.entity.govorg.CustomerAgencyEntity; +import com.epmet.dataaggre.excel.GridLivelyDetailExcel; import com.epmet.dataaggre.excel.GridLivelyExcel; import com.epmet.dataaggre.service.commonservice.AreaCodeService; import com.epmet.dataaggre.service.datastats.DataStatsService; @@ -51,6 +50,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.multipart.commons.CommonsMultipartFile; +import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.OutputStream; @@ -677,13 +677,131 @@ public class GovOrgServiceImpl implements GovOrgService { return subList; } + private GridLivelyDetailExcel gridActiveList(GridLivelyFormDTO formDTO) { + GridLivelyDetailExcel result = new GridLivelyDetailExcel(); + LinkedList livelyExcelList = new LinkedList<>(); + List livelyGrid = new ArrayList<>(); + List ordinaryGrid = new ArrayList<>(); + List lazyGrid = new ArrayList<>(); + //用于存放存在例行工作或上报事件的网格Id,供后边寻找活跃度为0的僵尸网格使用 + Set gridSet = new HashSet<>(); + //0.查询当前组织的直属下级组织列表及组织下的网格总数 + LinkedList subList = customerAgencyDao.subAgencyListAndGridSumNum(formDTO.getAgencyId()); + //1.查询当前组织下所有网格列表 + List gridList = customerGridDao.selectAgencyGridList(formDTO.getAgencyId()); + Map gridMap = gridList.stream().collect(Collectors.toMap(GridInfoResultDTO :: getGridId, v -> v, (v1, v2) -> v1)); + //2.查询直属下级组织下网格在查询时间段内存在例行工作次数的网格,一天一条 + List workList = epmetUserService.getGridDateRoutineWorkList(formDTO); + //3.查询直属下级组织下网格在查询时间段内存在上报事件(直接立项)数的网格,一天一条 + List projectList = dataStatsService.getGridDateProjectIncrList(formDTO); + //4.汇总数据,一个网格一天只记录一条数据,这条数据可能是例行工作的也可能是上报事件的,也可能某一天两个数都有,但只记录一条 + Set map = workList.stream().map(o -> o.getGridId() + o.getDateId()).collect(Collectors.toSet()); + projectList.stream().filter(pro -> !map.contains(pro.getGridId() + pro.getDateId())).forEach(p -> workList.add(p)); + //5.按组织封装数据 + //计算百分比使用,保留小数点后两位 + NumberFormat numberFormat = NumberFormat.getInstance(); + numberFormat.setMaximumFractionDigits(NumConstant.TWO); + subList.forEach(sub -> { + //5-1.组装存在活跃度的数据【网格活跃天数大于0的】 + Map hash = new HashMap<>(); + workList.forEach(w -> { + if (w.getPids().contains(sub.getAgencyId())) { + if (hash.containsKey(w.getGridId())) { + hash.put(w.getGridId(), hash.get(w.getGridId()) + NumConstant.ONE); + } else { + hash.put(w.getGridId(), NumConstant.ONE); + } + } + }); + //活跃网格数、普通网格数、僵尸网格数 + int gridLivelyNum = 0; + int gridOrdinaryNum = 0; + for (Map.Entry ma : hash.entrySet()){ + gridSet.add(ma.getKey()); + if (ma.getValue() >= NumConstant.FIVE) {//活跃网格 + gridLivelyNum++; + GridLivelyDetailExcel.LivelyGrid lively = new GridLivelyDetailExcel.LivelyGrid(); + lively.setAgencyId(sub.getAgencyId()); + lively.setAgencyName(sub.getAgencyName()); + lively.setGridId(ma.getKey()); + lively.setGridName(null!=gridMap.get(ma.getKey())?gridMap.get(ma.getKey()).getGridName():""); + lively.setDatyNum(ma.getValue()); + livelyGrid.add(lively); + } else if (ma.getValue() >= NumConstant.TWO && ma.getValue() < NumConstant.FIVE) {//正常网格 + gridOrdinaryNum++; + GridLivelyDetailExcel.OrdinaryGrid ordinary = new GridLivelyDetailExcel.OrdinaryGrid(); + ordinary.setAgencyId(sub.getAgencyId()); + ordinary.setAgencyName(sub.getAgencyName()); + ordinary.setGridId(ma.getKey()); + ordinary.setGridName(null!=gridMap.get(ma.getKey())?gridMap.get(ma.getKey()).getGridName():""); + ordinary.setDatyNum(ma.getValue()); + ordinaryGrid.add(ordinary); + }else if (ma.getValue() < NumConstant.TWO) {//部分僵尸网格[这是活跃天数为1的,还有部分活跃天数为0的] + GridLivelyDetailExcel.LazyGrid lazy = new GridLivelyDetailExcel.LazyGrid(); + lazy.setAgencyId(sub.getAgencyId()); + lazy.setAgencyName(sub.getAgencyName()); + lazy.setGridId(ma.getKey()); + lazy.setGridName(null!=gridMap.get(ma.getKey())?gridMap.get(ma.getKey()).getGridName():""); + lazy.setDatyNum(ma.getValue()); + lazyGrid.add(lazy); + } + } + GridLivelyExcel gridLively = new GridLivelyExcel(); + gridLively.setAgencyId(sub.getAgencyId()); + gridLively.setAgencyName(sub.getAgencyName()); + gridLively.setGridSumNum(sub.getGridSumNum()); + gridLively.setGridLivelyNum(gridLivelyNum); + gridLively.setGridLivelyRatio((sub.getGridSumNum() == 0 || gridLivelyNum > sub.getGridSumNum()) ? "0%" : numberFormat.format(((float) gridLivelyNum / (float) sub.getGridSumNum()) * 100) + "%"); + gridLively.setGridOrdinaryNum(gridOrdinaryNum); + gridLively.setGridOrdinaryRatio((sub.getGridSumNum() == 0 || gridOrdinaryNum > sub.getGridSumNum()) ? "0%" : numberFormat.format(((float) gridOrdinaryNum / (float) sub.getGridSumNum()) * 100) + "%"); + int gridLazyNum = sub.getGridSumNum() - gridLivelyNum - gridOrdinaryNum; + gridLively.setGridLazyNum(gridLazyNum < 0 ? 0 : gridLazyNum); + gridLively.setGridLazyRatio((sub.getGridSumNum() == 0 || gridLazyNum < 0) ? "0%" : numberFormat.format(((float) gridLazyNum / (float) sub.getGridSumNum()) * 100) + "%"); + livelyExcelList.add(gridLively); + + //5-2.组装不存在活跃度的数据【网格活跃天数为0的】 + gridList.forEach(g->{ + if(g.getPids().contains(sub.getAgencyId())&&!gridSet.contains(g.getGridId())){ + GridLivelyDetailExcel.LazyGrid lazy = new GridLivelyDetailExcel.LazyGrid(); + lazy.setAgencyId(sub.getAgencyId()); + lazy.setAgencyName(sub.getAgencyName()); + lazy.setGridId(g.getGridId()); + lazy.setGridName(null!=gridMap.get(g.getGridId())?gridMap.get(g.getGridId()).getGridName():""); + lazy.setDatyNum(NumConstant.ZERO); + lazyGrid.add(lazy); + } + }); + }); + //5-3.网格运行情况合计 + if (!CollectionUtils.isEmpty(livelyExcelList)){ + GridLivelyExcel gridLively = new GridLivelyExcel(); + gridLively.setAgencyName("合计"); + gridLively.setGridSumNum(livelyExcelList.stream().mapToInt(GridLivelyExcel::getGridSumNum).sum()); + gridLively.setGridLivelyNum(livelyExcelList.stream().mapToInt(GridLivelyExcel::getGridLivelyNum).sum()); + gridLively.setGridLivelyRatio((gridLively.getGridSumNum() == 0 || gridLively.getGridLivelyNum() > gridLively.getGridSumNum()) ? "0%" : numberFormat.format(((float) gridLively.getGridLivelyNum() / (float) gridLively.getGridSumNum()) * 100) + "%"); + gridLively.setGridOrdinaryNum(livelyExcelList.stream().mapToInt(GridLivelyExcel::getGridOrdinaryNum).sum()); + gridLively.setGridOrdinaryRatio((gridLively.getGridSumNum() == 0 || gridLively.getGridOrdinaryNum() > gridLively.getGridSumNum()) ? "0%" : numberFormat.format(((float) gridLively.getGridOrdinaryNum() / (float) gridLively.getGridSumNum()) * 100) + "%"); + gridLively.setGridLazyNum(livelyExcelList.stream().mapToInt(GridLivelyExcel::getGridLazyNum).sum()); + gridLively.setGridLazyRatio((gridLively.getGridSumNum() == 0 || gridLively.getGridLazyNum() > gridLively.getGridSumNum()) ? "0%" : numberFormat.format(((float) gridLively.getGridLazyNum() / (float) gridLively.getGridSumNum()) * 100) + "%"); + livelyExcelList.add(gridLively); + } + + //6.封装并返回 + result.setLivelyExcelList(livelyExcelList); + result.setLivelyGrid(livelyGrid); + result.setOrdinaryGrid(ordinaryGrid); + result.setLazyGrid(lazyGrid); + return result; + } + /** * @Author sun * @Description 查询组织的直属下级组织下网格活跃度统计--文件导出 **/ @Override public void grdiLivelyExport(HttpServletResponse response, GridLivelyFormDTO formDTO) { - ExcelWriter excelWriter = null; + //easyExcel导出 + /*ExcelWriter excelWriter = null; try { excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel("网格活跃度统计表.xlsx", response)).build(); WriteSheet writeSheet = EasyExcel.writerSheet(excelSheetName(formDTO)).build(); @@ -696,9 +814,81 @@ public class GovOrgServiceImpl implements GovOrgService { if (excelWriter != null) { excelWriter.finish(); } + }*/ + //easyPoi导出 + //1.获取当前组织缓存信息 + AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(formDTO.getAgencyId()); + if (null == agencyInfo) { + throw new RenException(String.format("获取组织缓存信息失败%s", formDTO.getAgencyId())); + } + //2.查询网格活跃度数据 + GridLivelyDetailExcel resultDTO = gridActiveList(formDTO); + if(null==resultDTO||CollectionUtils.isEmpty(resultDTO.getLivelyExcelList())){ + log.warn(String.format("网格员活跃度统计数据为空,入参【%s】", JSON.toJSONString(formDTO))); + return; + } + //3.生成多sheet页excel文件并写入数据导出文件 + List> headerList = getHeaderList(formDTO,agencyInfo,resultDTO); + try { + Workbook workbook = ExcelExportUtil.exportExcel(headerList, ExcelType.XSSF); + response.setCharacterEncoding("UTF-8"); + response.setHeader("content-Type", "application/vnd.ms-excel"); + String fileName = excelTitleName(formDTO.getStartTime(), formDTO.getEndTime(), agencyInfo.getOrganizationName()+"网格活跃度统计.xls"); + response.setHeader("Content-Disposition", "attachment;filename=" +fileName); + ServletOutputStream out = response.getOutputStream(); + workbook.write(out); + out.flush(); + out.close(); + } catch (IOException e) { + log.error("网格活跃度导出失败", e); } } + private List> getHeaderList(GridLivelyFormDTO formDTO, AgencyInfoCache agencyInfo,GridLivelyDetailExcel resultDTO) { + List> headerList = new ArrayList<>(); + String titleName = excelTitleName(formDTO.getStartTime(), formDTO.getEndTime(), agencyInfo.getOrganizationName()+"网格活跃度统计表"); + headerList.add(getHaderMap(resultDTO.getLivelyExcelList(), titleName, "各街镇网格运行情况", GridLivelyExcel.class)); + titleName = excelTitleName(formDTO.getStartTime(), formDTO.getEndTime(), agencyInfo.getOrganizationName()+"活跃网格明细"); + headerList.add(getHaderMap(resultDTO.getLivelyGrid(), titleName, "活跃网格统计", GridLivelyDetailExcel.LivelyGrid.class)); + titleName = excelTitleName(formDTO.getStartTime(), formDTO.getEndTime(), agencyInfo.getOrganizationName()+"正常运行网格明细"); + headerList.add(getHaderMap(resultDTO.getOrdinaryGrid(), titleName, "正常运行网格统计", GridLivelyDetailExcel.OrdinaryGrid.class)); + titleName = excelTitleName(formDTO.getStartTime(), formDTO.getEndTime(), agencyInfo.getOrganizationName()+"僵尸网格明细"); + headerList.add(getHaderMap(resultDTO.getLazyGrid(), titleName, "僵尸网格统计", GridLivelyDetailExcel.LazyGrid.class)); + return headerList; + } + + /** + * @Author sun + * data 业务数据集合 + * title sheet页主标题 + * name sheet页名称 + * cl sheet页列头对应实体类 + * @Description 生成多sheet页excel文件模板数据 + **/ + private Map getHaderMap(Collection data, String title, String name, Class cl){ + Map map = new HashMap<>(); + map.put("data",data); + ExportParams param1 = new ExportParams(title, name); + map.put("title", param1); + map.put("entity", cl); + return map; + } + /** + * @Author sun + * @Description excel文件sheet页主标题拼接 + **/ + private String excelTitleName(String startTime, String endTime, String name){ + StringBuilder titleName = new StringBuilder(); + SimpleDateFormat format1 = new SimpleDateFormat("yyyyMMdd"); + SimpleDateFormat format2 = new SimpleDateFormat("yyyy年MM月dd日"); + try{ + titleName.append("(").append(format2.format(format1.parse(startTime))).append("至").append(format2.format(format1.parse(endTime))).append(")").append(name); + } catch (Exception e) { + e.printStackTrace(); + } + return titleName.toString(); + } + private String excelSheetName(GridLivelyFormDTO formDTO){ StringBuilder name = new StringBuilder(); SimpleDateFormat format1 = new SimpleDateFormat("yyyyMMdd"); @@ -717,25 +907,38 @@ public class GovOrgServiceImpl implements GovOrgService { **/ @Override public void pcworkRecordListExportSendMsg(GridLivelyFormDTO formDTO) { - List data = ConvertUtils.sourceToTarget(grdiLively(formDTO), GridLivelyExcel.class); + /*List data = ConvertUtils.sourceToTarget(grdiLively(formDTO), GridLivelyExcel.class); if(CollectionUtils.isEmpty(data)){ log.warn(String.format("网格员活跃度统计数据查询为空,入参【%s】", JSON.toJSONString(formDTO))); return; } ExportParams exportParams = new ExportParams(); - String sheetName = excelSheetName(formDTO); exportParams.setSheetName(sheetName); Workbook workbook = ExcelExportUtil.exportExcel(exportParams, - GridLivelyExcel.class, data); - + GridLivelyExcel.class, data);*/ + //1.获取当前组织缓存信息 + AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(formDTO.getAgencyId()); + if (null == agencyInfo) { + throw new RenException(String.format("获取组织缓存信息失败%s", formDTO.getAgencyId())); + } + //2.查询网格活跃度数据 + GridLivelyDetailExcel resultDTO = gridActiveList(formDTO); + if (null == resultDTO || CollectionUtils.isEmpty(resultDTO.getLivelyExcelList())) { + log.warn(String.format("网格员活跃度统计数据为空,入参【%s】", JSON.toJSONString(formDTO))); + return; + } + //3.生成多sheet页excel文件并写入数据导出文件 + List> headerList = getHeaderList(formDTO,agencyInfo,resultDTO); // 文件名 - String resultDescFileName = sheetName.concat(".xls"); + String sheetName = excelSheetName(formDTO); + String resultDescFileName = sheetName.concat(".xlsx"); FileItemFactory factory = new DiskFileItemFactory(16, null); FileItem fileItem = factory.createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), true, resultDescFileName); OutputStream os = null; Result uploadResult = null; try { + Workbook workbook = ExcelExportUtil.exportExcel(headerList, ExcelType.XSSF); os = fileItem.getOutputStream(); workbook.write(os); uploadResult = ossFeignClient.uploadImportTaskDescFile(new CommonsMultipartFile(fileItem)); @@ -772,6 +975,7 @@ public class GovOrgServiceImpl implements GovOrgService { //小雷哥手机号:18660295251, OapiRobotSendRequest.At at = new OapiRobotSendRequest.At(); at.setAtMobiles(Arrays.asList("18660295251")); + // at.setAtMobiles(Arrays.asList("15764229697")); at.setIsAtAll(false); dingTalkTextMsg.setAt(at); diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govproject/impl/GovProjectServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govproject/impl/GovProjectServiceImpl.java index 6cd219c759..8619a74875 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govproject/impl/GovProjectServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govproject/impl/GovProjectServiceImpl.java @@ -11,6 +11,7 @@ import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.redis.common.CustomerOrgRedis; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; +import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; import com.epmet.commons.tools.redis.common.bean.GridInfoCache; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/datastats/DatsStatsDao.xml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/datastats/DatsStatsDao.xml index 26f74c4124..891e6f2cf4 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/datastats/DatsStatsDao.xml +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/datastats/DatsStatsDao.xml @@ -1033,7 +1033,13 @@ AND date_id #{endTime} - GROUP BY date_id, agency_id + + + GROUP BY date_id, agency_id + + + GROUP BY date_id, grid_id + ORDER BY date_id ASC @@ -1041,7 +1047,13 @@ AND date_id =]]> #{startTime} AND date_id #{endTime} - GROUP BY date_id, agency_id + + + GROUP BY date_id, agency_id + + + GROUP BY date_id, grid_id + ORDER BY date_id DESC diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerGridDao.xml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerGridDao.xml index 60350c7a1e..adc659eae6 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerGridDao.xml +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerGridDao.xml @@ -6,12 +6,14 @@ diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java index 71417dbb2e..ef5df1e3fe 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java @@ -67,6 +67,12 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.Optional; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/BlockChainProcessProjectFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/BlockChainProcessProjectFormDTO.java index 4d6dfb09d0..0b2e2749cb 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/BlockChainProcessProjectFormDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/BlockChainProcessProjectFormDTO.java @@ -13,6 +13,12 @@ import java.util.List; public class BlockChainProcessProjectFormDTO implements Serializable { private static final long serialVersionUID = -7316616101790749793L; + + /** + * 项目基础信息 + */ + private BlockChainProjectFormDTO project; + @NotNull(message = "处理进展信息不能为空") private BlockChainProjectProcessFormDTO process; diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/BlockChainProjectServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/BlockChainProjectServiceImpl.java index 36db95499d..c648097ab2 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/BlockChainProjectServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/BlockChainProjectServiceImpl.java @@ -182,15 +182,20 @@ public class BlockChainProjectServiceImpl implements BlockChainProjectService, R @Override public void blockChainProcessProject(BlockChainProcessProjectFormDTO input) { + BlockChainProjectFormDTO project = input.getProject(); BlockChainProjectProcessFormDTO process = input.getProcess(); List assignedStaffs = input.getAssignedStaffs(); BlockChainProjectProcessAssignedStaffFormDTO handledStaff = input.getHandledStaff(); - fill(null, process, assignedStaffs, handledStaff); + fill(project, process, assignedStaffs, handledStaff); String processString = JSON.toJSONString(process); blockChainProducer.sendMsg(BlockChainProducer.TOPIC_PROJECT, BlockChainProducer.TAG_SEND_PROCESS, processString); - + + if (project != null) { + blockChainProducer.sendMsg(BlockChainProducer.TOPIC_PROJECT, BlockChainProducer.TAG_SEND_PROJECT, JSON.toJSONString(project)); + } + if (assignedStaffs != null && assignedStaffs.size() > 0) { String assignedStaffsString = JSON.toJSONString(assignedStaffs); blockChainProducer.sendMsg(BlockChainProducer.TOPIC_PROJECT, BlockChainProducer.TAG_SEND_ASSIGNED_STAFFS, assignedStaffsString); diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/NeighborHoodManageDelFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/NeighborHoodManageDelFormDTO.java new file mode 100644 index 0000000000..22d913ee32 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/NeighborHoodManageDelFormDTO.java @@ -0,0 +1,30 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.List; + +/** + * @Author zxc + * @DateTime 2022/3/1 4:35 下午 + * @DESC + */ +@Data +public class NeighborHoodManageDelFormDTO implements Serializable { + + private static final long serialVersionUID = 405799151478155056L; + + public interface NeighborHoodManageDelForm{} + + @NotNull(message = "ids不能为空" , groups = NeighborHoodManageDelForm.class) + private List ids; + + /** + * 小区:neighborHood,楼栋:building,房屋:house + */ + @NotBlank(message = "type不能为空" , groups = NeighborHoodManageDelForm.class) + private String type; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/NeighborHoodManageDelResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/NeighborHoodManageDelResultDTO.java new file mode 100644 index 0000000000..bec9a06639 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/NeighborHoodManageDelResultDTO.java @@ -0,0 +1,22 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2022/3/2 10:05 上午 + * @DESC + */ +@Data +public class NeighborHoodManageDelResultDTO implements Serializable { + + private static final long serialVersionUID = -4248802585738319974L; + + private String neighborHoodId; + private String buildingId; + private String houseId; + + private String name; +} diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/CustomerGridConstant.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/CustomerGridConstant.java index bfe1fbe93c..409ec696db 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/CustomerGridConstant.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/CustomerGridConstant.java @@ -19,4 +19,5 @@ public interface CustomerGridConstant { String NEIGHBORHOOD = "neighborHood"; String BUILDING = "building"; + String HOUSE = "house"; } 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 40e37a1db5..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 @@ -289,4 +289,17 @@ public class HouseController implements ResultDataResolver { return new Result<>(); } + /** + * Desc 小区管理中批量删除 + * @param formDTO + * @author zxc + * @date 2022/3/1 4:57 下午 + */ + @PostMapping("delete") + public Result allDelete(@RequestBody NeighborHoodManageDelFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO, NeighborHoodManageDelFormDTO.NeighborHoodManageDelForm.class); + houseService.allDelete(formDTO); + 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 dadab70ce5..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,6 +40,7 @@ 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; diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java index a394aaaef5..28c0014f19 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/IcHouseDao.java @@ -20,6 +20,7 @@ package com.epmet.dao; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.result.HouseInfoDTO; +import com.epmet.dto.result.NeighborHoodManageDelResultDTO; import com.epmet.entity.IcHouseEntity; import com.epmet.excel.IcHouseExcel; import org.apache.ibatis.annotations.Mapper; @@ -74,4 +75,29 @@ public interface IcHouseDao extends BaseDao { @Param("buildingUnitId")String buildingUnitId, @Param("doorName")String doorName, @Param("houseId")String houseId); + + /** + * Desc: 根据小区IDs查询小区下是否有存在楼栋的 + * @param ids + * @author zxc + * @date 2022/3/2 9:51 上午 + */ + List selectExistBuildingByNeighborHoodIds(@Param("ids")List ids); + + /** + * Desc: 根据楼栋IDs查询楼栋下是否有存在房屋的 + * @param ids + * @author zxc + * @date 2022/3/2 9:53 上午 + */ + List selectExistHouseByBuildingIds(@Param("ids")List ids); + + /** + * Desc: 根据房屋ID查询名字 + * @param ids + * @author zxc + * @date 2022/3/2 11:00 上午 + */ + List selectHouseNames(@Param("ids")List ids); + } \ No newline at end of file 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 6000e27c05..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 @@ -21,6 +21,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.IcHouseFormDTO; import com.epmet.dto.form.ImportInfoFormDTO; import com.epmet.dto.form.ListIcNeighborHoodFormDTO; +import com.epmet.dto.form.NeighborHoodManageDelFormDTO; import com.epmet.dto.result.HouseInfoDTO; import com.epmet.dto.result.IcNeighborHoodResultDTO; import com.epmet.dto.result.ImportTaskCommonResultDTO; @@ -68,5 +69,13 @@ public interface HouseService { List queryListHouseInfo(Set houseIds, String customerId); + /** + * Desc 小区管理中批量删除 + * @param formDTO + * @author zxc + * @date 2022/3/1 4:57 下午 + */ + void allDelete(NeighborHoodManageDelFormDTO formDTO); + 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/impl/HouseServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java index f45b43d17a..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 @@ -18,6 +18,8 @@ import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; +import com.epmet.constant.CustomerGridConstant; +import com.epmet.commons.tools.utils.Result; import com.epmet.constants.ImportTaskConstants; import com.epmet.dao.IcBuildingDao; import com.epmet.dao.IcBuildingUnitDao; @@ -31,15 +33,18 @@ import com.epmet.dto.form.IcHouseFormDTO; import com.epmet.dto.form.ImportInfoFormDTO; import com.epmet.dto.form.ImportTaskCommonFormDTO; import com.epmet.dto.form.ListIcNeighborHoodFormDTO; +import com.epmet.dto.form.NeighborHoodManageDelFormDTO; import com.epmet.dto.result.HouseInfoDTO; import com.epmet.dto.result.IcNeighborHoodResultDTO; import com.epmet.dto.result.ImportTaskCommonResultDTO; +import com.epmet.dto.result.NeighborHoodManageDelResultDTO; import com.epmet.entity.IcHouseEntity; import com.epmet.enums.HousePurposeEnums; import com.epmet.enums.HouseRentFlagEnums; import com.epmet.enums.HouseTypeEnums; import com.epmet.excel.IcHouseExcel; import com.epmet.feign.EpmetCommonServiceOpenFeignClient; +import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.model.HouseInfoModel; import com.epmet.model.ImportHouseInfoListener; @@ -101,6 +106,8 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { @Autowired private ExecutorService executorService; + @Autowired + private EpmetUserOpenFeignClient epmetUserOpenFeignClient; @Override @@ -382,4 +389,84 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { }); return new Result(); } + + /** + * Desc 小区管理中批量删除 + * @param formDTO + * @author zxc + * @date 2022/3/1 4:57 下午 + */ + @Override + public void allDelete(NeighborHoodManageDelFormDTO formDTO) { + if (CollectionUtils.isEmpty(formDTO.getIds())){ + return; + } + List ids = formDTO.getIds(); + if (formDTO.getType().equals(CustomerGridConstant.NEIGHBORHOOD)){ + List exists = icHouseDao.selectExistBuildingByNeighborHoodIds(ids); + if (!CollectionUtils.isEmpty(exists)){ + exists.forEach(e -> { + for (int i = NumConstant.ZERO; i < ids.size(); i++) { + if (ids.get(i).equals(e.getNeighborHoodId())){ + ids.remove(i); + continue; + } + } + }); + } + if (!CollectionUtils.isEmpty(ids)){ + icNeighborHoodDao.deleteBatchIds(ids); + } + if (!CollectionUtils.isEmpty(exists)){ + String collect = exists.stream().map(m -> m.getName()).collect(Collectors.joining(",")); + EpmetErrorCode.NEIGHBORHOOD_DEL_FAILED.setMsg(String.format("%s内包含楼宇信息,暂无法删除",collect)); + throw new EpmetException(EpmetErrorCode.NEIGHBORHOOD_DEL_FAILED.getCode()); + } + }else if (formDTO.getType().equals(CustomerGridConstant.BUILDING)){ + List exists = icHouseDao.selectExistHouseByBuildingIds(ids); + if (!CollectionUtils.isEmpty(exists)){ + exists.forEach(e -> { + for (int i = NumConstant.ZERO; i < ids.size(); i++) { + if (ids.get(i).equals(e.getBuildingId())){ + ids.remove(i); + continue; + } + } + }); + } + if (!CollectionUtils.isEmpty(ids)){ + icBuildingDao.deleteBatchIds(ids); + } + if (!CollectionUtils.isEmpty(exists)){ + String collect = exists.stream().map(m -> m.getName()).collect(Collectors.joining(",")); + EpmetErrorCode.NEIGHBORHOOD_DEL_FAILED.setMsg(String.format("%s内包含房屋信息,暂无法删除",collect)); + throw new EpmetException(EpmetErrorCode.NEIGHBORHOOD_DEL_FAILED.getCode()); + } + }else if (formDTO.getType().equals(CustomerGridConstant.HOUSE)){ + Result> existUsers = epmetUserOpenFeignClient.getExistUserByHouseIds(ids); + if (!existUsers.success()){ + throw new EpmetException("根据房屋IDs查询房屋下是否有存在居民失败..."); + } + List exists = existUsers.getData(); + if (!CollectionUtils.isEmpty(exists)){ + exists.forEach(e -> { + for (int i = NumConstant.ZERO; i < ids.size(); i++) { + if (ids.get(i).equals(e)){ + ids.remove(i); + continue; + } + } + }); + } + if (!CollectionUtils.isEmpty(ids)){ + icHouseDao.deleteBatchIds(ids); + } + if (!CollectionUtils.isEmpty(exists)){ + List list = icHouseDao.selectHouseNames(exists); + String collect = list.stream().collect(Collectors.joining(",")); + EpmetErrorCode.NEIGHBORHOOD_DEL_FAILED.setMsg(String.format("%s内包含居民信息,暂无法删除",collect)); + throw new EpmetException(EpmetErrorCode.NEIGHBORHOOD_DEL_FAILED.getCode()); + } + } + } } 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 f2b50748eb..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; @@ -231,8 +232,9 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl importTask) { - executorService.submit(() -> { +// executorService.submit(() -> { // importNeighbor(formDTO,file,importTask); log.info("neighborhoodImport thread start====="); ExcelReader excelReader = null; @@ -257,7 +259,7 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl(); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml index 2cd7210dc5..a85367052d 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml @@ -709,15 +709,6 @@ agency.DEL_FLAG = '0' AND agency.ID = #{agencyId} - + UPDATE customer_agency 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 4403d39f0e..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 @@ -333,4 +333,47 @@ ih.DEL_FLAG = '0' AND ih.ID = #{houseId} + + + + + + + + + diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/BlockChainUploadServiceImpl.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/BlockChainUploadServiceImpl.java index 18f4d39d4a..d28f2c11a1 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/BlockChainUploadServiceImpl.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/BlockChainUploadServiceImpl.java @@ -134,9 +134,10 @@ public class BlockChainUploadServiceImpl implements BlockChainUploadService { } Result result; - if (project == null) { - // 处理 + if (!"created".equals(processEntity.getOperation())) { + // 处理。如果是结案,则会有project对象,因为要传递结案状态给区块链,其他状态则project==null BlockChainProcessProjectFormDTO processForm = new BlockChainProcessProjectFormDTO(); + processForm.setProject(project); processForm.setProcess(process); processForm.setAssignedStaffs(assignedStaffs); processForm.setHandledStaff(handledStaff); diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java index 6a591d9e8d..80ceb02393 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java @@ -599,7 +599,7 @@ public class ProjectServiceImpl extends BaseServiceImpl> getCategoryList(@RequestBody IcResiCategoryStatsConfigDTO dto); - + /** + * 获取居民类别配置表ic_resi_category_stats_config,根据token里的客户id查询,可根据状态筛选:显示:show;隐藏:hidden; + * @param formDTO + * @return + */ @PostMapping("/oper/customize/resicategorystatsconfig/resicategorystatslistshowd") Result> resiCategoryStatsListShowd(@RequestBody IcResiCategoryStatsConfigFormDTO formDTO); + /** + * 查询ic_resi_category_warn_config,返回预警的类别 + * @param customerId + * @return + */ @PostMapping("/oper/customize/resicategorystatsconfig/resicategorywarnlist") Result> resiCategoryWarnList(@RequestParam String customerId); diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/ResiCategoryStatsConfigController.java b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/ResiCategoryStatsConfigController.java index f43e75bf97..3c2004e714 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/ResiCategoryStatsConfigController.java +++ b/epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/ResiCategoryStatsConfigController.java @@ -128,6 +128,12 @@ public class ResiCategoryStatsConfigController { return new Result().ok(resiCategoryStatsConfigService.info(formDTO.getId(),tokenDTO.getCustomerId())); } + /** + * 获取居民类别配置表ic_resi_category_stats_config,根据token里的客户id查询,可根据状态筛选:显示:show;隐藏:hidden; + * @param tokenDTO + * @param formDTO + * @return + */ @PostMapping("resicategorystatslistshowd") public Result> resiCategoryStatsListShowd(@LoginUser TokenDto tokenDTO,@RequestBody IcResiCategoryStatsConfigFormDTO formDTO){ //获取预警配置列表 @@ -145,6 +151,11 @@ public class ResiCategoryStatsConfigController { return new Result>().ok(ConvertUtils.sourceToTarget(statsConfigEntityList, IcResiCategoryStatsConfigDTO.class)); } + /** + * 查询ic_resi_category_warn_config,返回预警的类别 + * @param customerId + * @return + */ @PostMapping("resicategorywarnlist") public Result> resiCategoryWarnList(@RequestParam String customerId){ //获取预警配置列表 diff --git a/epmet-module/resi-guide/resi-guide-server/pom.xml b/epmet-module/resi-guide/resi-guide-server/pom.xml index 9c057ecb24..f1ca66e4fe 100644 --- a/epmet-module/resi-guide/resi-guide-server/pom.xml +++ b/epmet-module/resi-guide/resi-guide-server/pom.xml @@ -141,6 +141,15 @@ true + + true + 5 + 8 + 10 + 60 + resi-guide- + callerRunsPolicy + false @@ -181,6 +190,15 @@ false + + true + 5 + 8 + 10 + 60 + epmet-guide- + callerRunsPolicy + false @@ -221,6 +239,15 @@ true + + true + 5 + 8 + 10 + 60 + epmet-guide- + callerRunsPolicy + true @@ -259,6 +286,15 @@ true + + true + 5 + 8 + 10 + 60 + epmet-guide- + callerRunsPolicy + true diff --git a/epmet-module/resi-guide/resi-guide-server/src/main/resources/bootstrap.yml b/epmet-module/resi-guide/resi-guide-server/src/main/resources/bootstrap.yml index 8084eeeec5..c8bfca6ee6 100644 --- a/epmet-module/resi-guide/resi-guide-server/src/main/resources/bootstrap.yml +++ b/epmet-module/resi-guide/resi-guide-server/src/main/resources/bootstrap.yml @@ -133,3 +133,14 @@ shutdown: graceful: enable: true #是否开启优雅停机 waitTimeSecs: 30 # 优雅停机等待时间,超过30秒,发出告警 + +thread: + # 线程池配置 + threadPool: + enableCustomize: @thread.threadPool.enable-customize@ + corePoolSize: @thread.threadPool.core-pool-size@ + maxPoolSize: @thread.threadPool.max-pool-size@ + queueCapacity: @thread.threadPool.queue-capacity@ + keepAliveSeconds: @thread.threadPool.keep-alive-seconds@ + threadNamePrefix: @thread.threadPool.thread-name-prefix@ + rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@ \ No newline at end of file diff --git a/epmet-module/resi-hall/resi-hall-server/pom.xml b/epmet-module/resi-hall/resi-hall-server/pom.xml index e1d8cb9996..bffb6788ab 100644 --- a/epmet-module/resi-hall/resi-hall-server/pom.xml +++ b/epmet-module/resi-hall/resi-hall-server/pom.xml @@ -105,6 +105,15 @@ true + + true + 5 + 8 + 10 + 60 + resi-hall + callerRunsPolicy + false @@ -139,6 +148,15 @@ false + + true + 5 + 8 + 10 + 60 + resi-hall + callerRunsPolicy + false @@ -173,6 +191,15 @@ true + + true + 5 + 8 + 10 + 60 + resi-hall + callerRunsPolicy + true @@ -204,6 +231,15 @@ true + + true + 5 + 8 + 10 + 60 + resi-hall + callerRunsPolicy + true diff --git a/epmet-module/resi-hall/resi-hall-server/src/main/resources/bootstrap.yml b/epmet-module/resi-hall/resi-hall-server/src/main/resources/bootstrap.yml index 33e54c75af..35219270ce 100644 --- a/epmet-module/resi-hall/resi-hall-server/src/main/resources/bootstrap.yml +++ b/epmet-module/resi-hall/resi-hall-server/src/main/resources/bootstrap.yml @@ -88,3 +88,14 @@ shutdown: graceful: enable: true #是否开启优雅停机 waitTimeSecs: 30 # 优雅停机等待时间,超过30秒,发出告警 + +thread: + # 线程池配置 + threadPool: + enableCustomize: @thread.threadPool.enable-customize@ + corePoolSize: @thread.threadPool.core-pool-size@ + maxPoolSize: @thread.threadPool.max-pool-size@ + queueCapacity: @thread.threadPool.queue-capacity@ + keepAliveSeconds: @thread.threadPool.keep-alive-seconds@ + threadNamePrefix: @thread.threadPool.thread-name-prefix@ + rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@ \ No newline at end of file diff --git a/epmet-module/resi-home/resi-home-server/pom.xml b/epmet-module/resi-home/resi-home-server/pom.xml index d5972d3f1e..08c3603b30 100644 --- a/epmet-module/resi-home/resi-home-server/pom.xml +++ b/epmet-module/resi-home/resi-home-server/pom.xml @@ -129,6 +129,15 @@ true + + true + 5 + 8 + 10 + 60 + resi-home + callerRunsPolicy + https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 @@ -162,6 +171,15 @@ false + + true + 5 + 8 + 10 + 60 + resi-home + callerRunsPolicy + https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 @@ -195,6 +213,15 @@ true + + true + 5 + 8 + 10 + 60 + resi-home + callerRunsPolicy + https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 @@ -226,6 +253,15 @@ true + + true + 5 + 8 + 10 + 60 + resi-home + callerRunsPolicy + https://oapi.dingtalk.com/robot/send?access_token=a5f66c3374b1642fe2142dbf56d5997e280172d4e8f2b546c9423a68c82ece6c diff --git a/epmet-module/resi-home/resi-home-server/src/main/resources/bootstrap.yml b/epmet-module/resi-home/resi-home-server/src/main/resources/bootstrap.yml index a0fecfc66f..7315ad7080 100644 --- a/epmet-module/resi-home/resi-home-server/src/main/resources/bootstrap.yml +++ b/epmet-module/resi-home/resi-home-server/src/main/resources/bootstrap.yml @@ -87,3 +87,14 @@ shutdown: graceful: enable: true #是否开启优雅停机 waitTimeSecs: 30 # 优雅停机等待时间,超过30秒,发出告警 + +thread: + # 线程池配置 + threadPool: + enableCustomize: @thread.threadPool.enable-customize@ + corePoolSize: @thread.threadPool.core-pool-size@ + maxPoolSize: @thread.threadPool.max-pool-size@ + queueCapacity: @thread.threadPool.queue-capacity@ + keepAliveSeconds: @thread.threadPool.keep-alive-seconds@ + threadNamePrefix: @thread.threadPool.thread-name-prefix@ + rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@ \ No newline at end of file diff --git a/epmet-module/resi-mine/resi-mine-server/pom.xml b/epmet-module/resi-mine/resi-mine-server/pom.xml index ef177cadf2..b2ebcfe1b7 100644 --- a/epmet-module/resi-mine/resi-mine-server/pom.xml +++ b/epmet-module/resi-mine/resi-mine-server/pom.xml @@ -148,6 +148,15 @@ true + + true + 5 + 8 + 10 + 60 + resi-mine + callerRunsPolicy + https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 @@ -180,6 +189,15 @@ false + + true + 5 + 8 + 10 + 60 + resi-mine + callerRunsPolicy + https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 @@ -212,6 +230,15 @@ true + + true + 5 + 8 + 10 + 60 + resi-mine + callerRunsPolicy + https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 @@ -242,6 +269,15 @@ true + + true + 5 + 8 + 10 + 60 + resi-mine + callerRunsPolicy + https://oapi.dingtalk.com/robot/send?access_token=a5f66c3374b1642fe2142dbf56d5997e280172d4e8f2b546c9423a68c82ece6c diff --git a/epmet-module/resi-mine/resi-mine-server/src/main/resources/bootstrap.yml b/epmet-module/resi-mine/resi-mine-server/src/main/resources/bootstrap.yml index 68fb8924c1..60f5366ff8 100644 --- a/epmet-module/resi-mine/resi-mine-server/src/main/resources/bootstrap.yml +++ b/epmet-module/resi-mine/resi-mine-server/src/main/resources/bootstrap.yml @@ -111,3 +111,14 @@ shutdown: graceful: enable: true #是否开启优雅停机 waitTimeSecs: 30 # 优雅停机等待时间,超过30秒,发出告警 + +thread: + # 线程池配置 + threadPool: + enableCustomize: @thread.threadPool.enable-customize@ + corePoolSize: @thread.threadPool.core-pool-size@ + maxPoolSize: @thread.threadPool.max-pool-size@ + queueCapacity: @thread.threadPool.queue-capacity@ + keepAliveSeconds: @thread.threadPool.keep-alive-seconds@ + threadNamePrefix: @thread.threadPool.thread-name-prefix@ + rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@ \ No newline at end of file diff --git a/epmet-module/resi-partymember/resi-partymember-server/pom.xml b/epmet-module/resi-partymember/resi-partymember-server/pom.xml index ca41c090c5..bae2ec09fb 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/pom.xml +++ b/epmet-module/resi-partymember/resi-partymember-server/pom.xml @@ -69,12 +69,6 @@ 2.0.0 compile - - com.epmet - epmet-user-client - 2.0.0 - compile - info.debatty java-string-similarity @@ -164,6 +158,15 @@ true + + true + 5 + 8 + 10 + 60 + resi-partymember- + callerRunsPolicy + false @@ -205,6 +208,15 @@ false + + true + 5 + 8 + 10 + 60 + resi-partymember- + callerRunsPolicy + false @@ -246,6 +258,15 @@ true + + true + 5 + 8 + 10 + 60 + resi-partymember- + callerRunsPolicy + true @@ -285,6 +306,15 @@ true + + true + 5 + 8 + 10 + 60 + resi-partymember- + callerRunsPolicy + true diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/bootstrap.yml b/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/bootstrap.yml index 211b221914..ee185fa822 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/bootstrap.yml +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/bootstrap.yml @@ -132,3 +132,14 @@ shutdown: graceful: enable: true #是否开启优雅停机 waitTimeSecs: 30 # 优雅停机等待时间,超过30秒,发出告警 + +thread: + # 线程池配置 + threadPool: + enableCustomize: @thread.threadPool.enable-customize@ + corePoolSize: @thread.threadPool.core-pool-size@ + maxPoolSize: @thread.threadPool.max-pool-size@ + queueCapacity: @thread.threadPool.queue-capacity@ + keepAliveSeconds: @thread.threadPool.keep-alive-seconds@ + threadNamePrefix: @thread.threadPool.thread-name-prefix@ + rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@ \ No newline at end of file diff --git a/epmet-module/resi-voice/resi-voice-server/pom.xml b/epmet-module/resi-voice/resi-voice-server/pom.xml index a3dd4affa4..ae4858bceb 100644 --- a/epmet-module/resi-voice/resi-voice-server/pom.xml +++ b/epmet-module/resi-voice/resi-voice-server/pom.xml @@ -105,6 +105,14 @@ true + + true + 5 + 8 + 10 + 60 + resi-voice + callerRunsPolicy @@ -139,6 +147,15 @@ false + + true + 5 + 8 + 10 + 60 + resi-voice + callerRunsPolicy + https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 @@ -172,6 +189,15 @@ true + + true + 5 + 8 + 10 + 60 + resi-voice + callerRunsPolicy + https://oapi.dingtalk.com/robot/send?access_token=e894e5690f9d6a527722974c71548ff6c0fe29bd956589a09e21b16442a35ed4 @@ -206,6 +232,14 @@ true + + true + 5 + 8 + 10 + 60 + resi-voice + callerRunsPolicy diff --git a/epmet-module/resi-voice/resi-voice-server/src/main/resources/bootstrap.yml b/epmet-module/resi-voice/resi-voice-server/src/main/resources/bootstrap.yml index 156a3bf5d7..dc2eaa3898 100644 --- a/epmet-module/resi-voice/resi-voice-server/src/main/resources/bootstrap.yml +++ b/epmet-module/resi-voice/resi-voice-server/src/main/resources/bootstrap.yml @@ -79,3 +79,14 @@ shutdown: graceful: enable: true #是否开启优雅停机 waitTimeSecs: 30 # 优雅停机等待时间,超过30秒,发出告警 + +thread: + # 线程池配置 + threadPool: + enableCustomize: @thread.threadPool.enable-customize@ + corePoolSize: @thread.threadPool.core-pool-size@ + maxPoolSize: @thread.threadPool.max-pool-size@ + queueCapacity: @thread.threadPool.queue-capacity@ + keepAliveSeconds: @thread.threadPool.keep-alive-seconds@ + threadNamePrefix: @thread.threadPool.thread-name-prefix@ + rejectedExecutionHandler: @thread.threadPool.rejected-execution-handler@ \ No newline at end of file diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DelIcResiUserFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DelIcResiUserFormDTO.java index 558bb88b7f..98526ad993 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DelIcResiUserFormDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/DelIcResiUserFormDTO.java @@ -4,7 +4,9 @@ import com.epmet.commons.tools.enums.IcFormCodeEnum; import lombok.Data; import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; import java.io.Serializable; +import java.util.List; /** * @Description 删除居民 @@ -18,10 +20,14 @@ public class DelIcResiUserFormDTO implements Serializable { public interface IdGroup { } - @NotBlank(message = "icResiUserId不能为空", groups = IdGroup.class) private String icResiUserId; + + @NotNull(message = "userIds不能为空", groups = IdGroup.class) + private List userIds; + @NotBlank(message = "token获取的customerId不能为空", groups = IdGroup.class) private String customerId; + private String formCode= IcFormCodeEnum.RESI_BASE_INFO.getCode(); } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PersonWarnRightListFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PersonWarnRightListFormDTO.java index 977390e31a..9be92d4233 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PersonWarnRightListFormDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PersonWarnRightListFormDTO.java @@ -22,4 +22,6 @@ public class PersonWarnRightListFormDTO implements Serializable { @NotNull(message = "pageSize不能为空",groups = PersonWarnRightListForm.class) private Integer pageSize; + + private String categoryCode; } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/IcStatsResiWarnBuildingResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/IcStatsResiWarnBuildingResultDTO.java index 3d4253f721..f4c317274a 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/IcStatsResiWarnBuildingResultDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/IcStatsResiWarnBuildingResultDTO.java @@ -20,7 +20,6 @@ package com.epmet.dto.result; import lombok.Data; import java.io.Serializable; -import java.util.Date; import java.util.List; @@ -38,21 +37,52 @@ public class IcStatsResiWarnBuildingResultDTO implements Serializable { /** * 预警配置ID + * ic_resi_category_warn_config.id */ private String configId; + /** + * ic_resi_category_warn_config.label + * 类别名 + */ private String label; + /** + * 排序 + */ private Integer sort; + + /** + * 等级1阈值 + */ private Integer level1; private Integer levelCount1; + + /** + * 等级2阈值 + */ private Integer level2; private Integer levelCount2; + + /** + * 等级3阈值 + */ private Integer level3; private Integer levelCount3; + /** + * 管理平台分类图标 + */ private String managementIcon; + + /** + * 数据平台分类图标 + */ private String dataIcon; + + /** + * 房屋显示分类图标 + */ private String houseShowIcon; private Integer count; diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/PersonWarnRightListResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/PersonWarnRightListResultDTO.java index c98b26cbec..a2739c6857 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/PersonWarnRightListResultDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/PersonWarnRightListResultDTO.java @@ -35,6 +35,9 @@ public class PersonWarnRightListResultDTO implements Serializable { */ private List type; + @JsonIgnore + private String sortString; + /** * 所属网格 */ diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java index d1d176cbe9..0ed71a07f0 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java @@ -25,7 +25,7 @@ import java.util.Set; * @author yinzuomei@elink-cn.com * @date 2020/6/4 13:09 */ -// @FeignClient(name = ServiceConstant.EPMET_USER_SERVER, fallbackFactory = EpmetUserOpenFeignClientFallbackFactory.class, url = "localhost:8087") + // @FeignClient(name = ServiceConstant.EPMET_USER_SERVER, fallbackFactory = EpmetUserOpenFeignClientFallbackFactory.class, url = "localhost:8087") @FeignClient(name = ServiceConstant.EPMET_USER_SERVER, fallbackFactory = EpmetUserOpenFeignClientFallbackFactory.class) public interface EpmetUserOpenFeignClient { @@ -712,4 +712,13 @@ public interface EpmetUserOpenFeignClient { @PostMapping("/epmetuser/statsresiwarn/list2") Result> getPersonCategoryList(@RequestBody StatsResiListFormDTO formDTO); + /** + * Desc: 根据房屋IDs查询房屋下是否有存在居民的 + * @param ids + * @author zxc + * @date 2022/3/2 10:32 上午 + */ + @PostMapping("/epmetuser/icresiuser/getexistuserbyhouseids") + Result> getExistUserByHouseIds(@RequestBody List ids); + } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java index bde8bf2e8c..0f9f38ea5c 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java @@ -527,4 +527,9 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien public Result> getPersonCategoryList(StatsResiListFormDTO formDTO) { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getPersonCategoryList", formDTO); } + + @Override + public Result> getExistUserByHouseIds(List ids) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getExistUserByHouseIds", ids); + } } diff --git a/epmet-user/epmet-user-server/deploy/docker-compose-dev.yml b/epmet-user/epmet-user-server/deploy/docker-compose-dev.yml index b5421e4e4e..e1e35559ff 100644 --- a/epmet-user/epmet-user-server/deploy/docker-compose-dev.yml +++ b/epmet-user/epmet-user-server/deploy/docker-compose-dev.yml @@ -9,7 +9,7 @@ services: volumes: - "/opt/epmet-cloud-logs/dev:/logs" environment: - RUN_INSTRUCT: "java -Xms32m -Xmx512m -jar ./epmet-user.jar" + RUN_INSTRUCT: "java -Xms256m -Xmx512m -jar ./epmet-user.jar" restart: "unless-stopped" deploy: resources: 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 df529b42a1..324567a120 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 @@ -35,7 +35,6 @@ 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; @@ -43,10 +42,7 @@ import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.user.LoginUserUtil; -import com.epmet.commons.tools.utils.ExcelUtils; -import com.epmet.commons.tools.utils.HttpClientManager; -import com.epmet.commons.tools.utils.IpUtils; -import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.utils.*; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.constant.SystemMessageType; import com.epmet.constants.ImportTaskConstants; @@ -67,7 +63,6 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.tomcat.util.http.MimeHeaders; import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpHeaders; @@ -75,7 +70,6 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.multipart.support.StandardMultipartHttpServletRequest; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -83,13 +77,11 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.lang.reflect.Field; import java.net.URLEncoder; import java.nio.file.Files; 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; @@ -135,6 +127,8 @@ public class IcResiUserController implements ResultDataResolver { private LoginUserUtil loginUserUtil; @Autowired private RequestInterceptor requestInterceptor; + @Autowired + private ExecutorService executorService; /** * 模板枚举 @@ -189,15 +183,19 @@ public class IcResiUserController implements ResultDataResolver { public Result delete(@LoginUser TokenDto tokenDto, @RequestBody DelIcResiUserFormDTO formDTO) { formDTO.setCustomerId(tokenDto.getCustomerId()); ValidatorUtils.validateEntity(formDTO, DelIcResiUserFormDTO.IdGroup.class); - icResiUserService.delete(formDTO); - //推送MQ事件 - IcResiUserAddMQMsg mqMsg = new IcResiUserAddMQMsg(); - mqMsg.setCustomerId(tokenDto.getCustomerId()); - mqMsg.setIcResiUser(formDTO.getIcResiUserId()); - SystemMsgFormDTO form = new SystemMsgFormDTO(); - form.setMessageType(SystemMessageType.IC_RESI_USER_DEL); - form.setContent(mqMsg); - epmetMessageOpenFeignClient.sendSystemMsgByMQ(form); + formDTO.getUserIds().forEach(userId -> { + formDTO.setIcResiUserId(userId); + icResiUserService.delete(formDTO); + //推送MQ事件 + IcResiUserAddMQMsg mqMsg = new IcResiUserAddMQMsg(); + mqMsg.setCustomerId(tokenDto.getCustomerId()); + mqMsg.setIcResiUser(userId); + SystemMsgFormDTO form = new SystemMsgFormDTO(); + form.setMessageType(SystemMessageType.IC_RESI_USER_DEL); + form.setContent(mqMsg); + epmetMessageOpenFeignClient.sendSystemMsgByMQ(form); + }); + return new Result(); } @@ -468,12 +466,8 @@ public class IcResiUserController implements ResultDataResolver { throw new RenException("上传失败"); } - HashMap headers = ((EpmetBaseRequestInterceptor) requestInterceptor).getHeadersFromRequest(); - - ThreadLocalConstant.inheritableAdditionalHeaders.set(headers); - // 三.异步执行导入 - new Thread(() -> { + executorService.execute(() -> { try { List formItemList = icResiUserService.listFormItems(customerId,IcFormCodeEnum.RESI_BASE_INFO.getCode()); @@ -492,31 +486,12 @@ public class IcResiUserController implements ResultDataResolver { } catch (IOException e) { log.error("【导入居民信息失败】清理上传的文件失败:{}", ExceptionUtils.getErrorStackTrace(e)); } - - // 清理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; -// } - @PostMapping("test") public Result>> test(@LoginUser TokenDto tokenDto, @RequestBody DynamicQueryFormDTO formDTO) { formDTO.setCustomerId("45687aa479955f9d06204d415238f7cc"); @@ -748,4 +723,33 @@ public class IcResiUserController implements ResultDataResolver { ValidatorUtils.validateEntity(formDTO, PersonWarnRightListFormDTO.PersonWarnRightListForm.class); return new Result().ok(icResiUserService.personWarnRightList(formDTO,tokenDto)); } + + /** + * Desc: 根据房屋IDs查询房屋下是否有存在居民的 + * @param ids + * @author zxc + * @date 2022/3/2 10:32 上午 + */ + @PostMapping("getexistuserbyhouseids") + public Result> getExistUserByHouseIds(@RequestBody List ids){ + return new Result>().ok(icResiUserService.getExistUserByHouseIds(ids)); + } + +// public static ThreadLocal tl = new ThreadLocal(); + + @PostMapping("test-async") + public Result testAsync(HttpServletRequest request){ +// tl.set("wxz"); + executorService.submit(() -> { + try { + Thread.sleep(500l); + System.out.println("["+Thread.currentThread().getId() + "]:" + EpmetRequestHolder.getHeader("app")); + System.out.println("---"); + } catch (InterruptedException e) { + e.printStackTrace(); + } +// icResiUserImportService.testAsync(); + }); + return new Result(); + } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StatsResiWarnController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StatsResiWarnController.java index 33855a2b2c..3d18050f66 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StatsResiWarnController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/StatsResiWarnController.java @@ -17,19 +17,15 @@ package com.epmet.controller; -import com.epmet.common.token.annotation.Login; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; -import com.epmet.dto.form.CategoryCountListFormDTO; import com.epmet.dto.form.StatsResiListFormDTO; import com.epmet.dto.form.StatsResiWarnCountFormDTO; import com.epmet.dto.form.StatsResiWarnFormDTO; -import com.epmet.dto.result.CategoryCountListResultDTO; import com.epmet.dto.result.IcStatsResiResultDTO; import com.epmet.dto.result.IcStatsResiWarnBuildingResultDTO; -import com.epmet.dto.result.IcStatsResiWarnUserResultDTO; import com.epmet.service.IcStatsResiWarnService; import com.epmet.service.StatsResiWarnService; import org.springframework.beans.factory.annotation.Autowired; @@ -80,6 +76,12 @@ public class StatsResiWarnController { return new Result>().ok(statsResiWarnService.list2(formDTO)); } + /** + * 可视化分析-人员预警,各类别楼栋数量展示 + * @param tokenDto + * @param formDTO 只有agencyId + * @return + */ @PostMapping("buildingwarnlist") public Result buildingWarnList(@LoginUser TokenDto tokenDto,@RequestBody StatsResiWarnFormDTO formDTO){ ValidatorUtils.validateEntity(formDTO, StatsResiWarnFormDTO.ListSelectedBuilding.class); @@ -89,6 +91,13 @@ public class StatsResiWarnController { return new Result().ok(icStatsResiWarnBuildingResultDTOS); } + + /** + * 可视化分析-人员预警,楼栋列表展示 + * @param tokenDto + * @param formDTO + * @return + */ @PostMapping("userwarnlist") public Result userWarnList(@LoginUser TokenDto tokenDto,@RequestBody StatsResiWarnFormDTO formDTO){ ValidatorUtils.validateEntity(formDTO, StatsResiWarnFormDTO.ListSelectedUser.class); diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java index 35abe08623..a4f5508b51 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java @@ -245,7 +245,7 @@ public interface IcResiUserDao extends BaseDao { List icUserCustomerIds(); - List> getIcUserList(@Param("customerId") String customerId, @Param("columns")List columns); + List> getIcUserList(@Param("customerId") String customerId); /** * desc: 获取数据分析列中的 各类居民数据 @@ -261,4 +261,14 @@ public interface IcResiUserDao extends BaseDao { */ Map getDataAnalyseCount(@Param("customerId") String customerId, @Param("tableName") String tableName, @Param("columnList") List columnList, @Param("id") String id, @Param("level") String level); + List> getIcUserList(@Param("customerId") String customerId, @Param("columns")List columns); + + /** + * Desc: 根据房屋IDs查询房屋下是否有存在居民的 + * @param ids + * @author zxc + * @date 2022/3/2 10:32 上午 + */ + List getExistUserByHouseIds(@Param("ids") List ids); + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserImportService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserImportService.java index 7358dcd961..05fb431c32 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserImportService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserImportService.java @@ -32,4 +32,6 @@ public interface IcResiUserImportService { * @param resultDescPath 结果描述文件,excel等文件,有错误的话需要传入,成功则不需要 */ void finishImportTask(String importTaskId, String operatorId, String processStatus, String resultDesc, String resultDescPath); + + Object testAsync(); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java index dc2c2a76d5..59ec56519b 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserService.java @@ -209,4 +209,11 @@ public interface IcResiUserService extends BaseService { */ PersonWarnRightListResultDTO personWarnRightList(PersonWarnRightListFormDTO formDTO, TokenDto tokenDto); + /** + * Desc: 根据房屋IDs查询房屋下是否有存在居民的 + * @param ids + * @author zxc + * @date 2022/3/2 10:32 上午 + */ + List getExistUserByHouseIds(List ids); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StatsResiWarnService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StatsResiWarnService.java index f0c4e5f5f5..7c5477b61b 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StatsResiWarnService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/StatsResiWarnService.java @@ -17,12 +17,9 @@ package com.epmet.service; -import com.epmet.dto.form.CategoryCountListFormDTO; import com.epmet.dto.form.StatsResiListFormDTO; -import com.epmet.dto.result.CategoryCountListResultDTO; import com.epmet.dto.result.IcStatsResiResultDTO; import com.epmet.dto.result.IcStatsResiWarnBuildingResultDTO; -import com.epmet.dto.result.IcStatsResiWarnUserResultDTO; import java.util.List; import java.util.Map; @@ -35,8 +32,23 @@ import java.util.Map; */ public interface StatsResiWarnService{ + /** + * 可视化分析-人员预警,各类别楼栋数量展示 + * @param customerId + * @param agencyID + * @return + */ List buildingwWarnList(String customerId,String agencyID); + /** + * 可视化分析-人员预警,楼栋列表展示 + * @param customerId + * @param configId + * @param buildingIdList + * @param pageNo + * @param pageSize + * @return + */ Map userWarnList(String customerId, String configId, List buildingIdList, Integer pageNo, Integer pageSize); List list(String customerId,String id, String level); 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 c636d91b43..59be4a9fb4 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 @@ -24,7 +24,9 @@ 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.EpmetRequestHolder; import com.epmet.commons.tools.utils.Result; import com.epmet.constants.ImportTaskConstants; import com.epmet.dao.IcResiUserDao; @@ -213,9 +215,9 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res @Override public void importIcResiInfoFromExcel(String importTaskId, List formItemList, String excelPathName, HttpServletResponse response, Path importTempPath) { - 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 app = EpmetRequestHolder.getHeader(AppClientConstant.APP); + String client = EpmetRequestHolder.getHeader(AppClientConstant.CLIENT); + String loginUserId = EpmetRequestHolder.getHeader(AppClientConstant.USER_ID.toLowerCase()); String currUserAgencyId = userService.getLoginUserDetails(app, client, loginUserId).getAgencyId(); @@ -316,7 +318,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res */ private void initImportThreadLocal(String customerId) { // 生成importTag,用于标记唯一一次导入操作,导入完成之后,用来删除redis里面临时的key - String operatorId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.USER_ID.toLowerCase()); + String operatorId = EpmetRequestHolder.getHeader(AppClientConstant.USER_ID.toLowerCase()); String importTag = operatorId + System.currentTimeMillis(); // 错误信息 @@ -356,10 +358,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 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()); + String loginUserApp = EpmetRequestHolder.getHeader(AppClientConstant.APP); + String loginUserClient = EpmetRequestHolder.getHeader(AppClientConstant.CLIENT); + String loginUserId = EpmetRequestHolder.getHeader(AppClientConstant.USER_ID.toLowerCase()); + String loginUserCustomerId = EpmetRequestHolder.getHeader(AppClientConstant.CUSTOMER_ID.toLowerCase()); log.info("importIcResiBaseInfoFromExcel:: userId:{}, app:{}, client:{}, customerId:{}", loginUserId, loginUserApp, loginUserClient, loginUserCustomerId); @@ -472,7 +474,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res columnAndValues.put("AGENCY_ID", currUserAgencyId); columnAndValues.put("PIDS", currUserAgencyPids); - columnAndValues.put("CUSTOMER_ID", ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.CUSTOMER_ID.toLowerCase())); + columnAndValues.put("CUSTOMER_ID", EpmetRequestHolder.getHeader(AppClientConstant.CUSTOMER_ID.toLowerCase())); columnAndValues.put("UPDATED_BY", currentUserId); @@ -542,10 +544,10 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res LinkedHashMap columnAndValues = new LinkedHashMap<>(); - 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()); + String loginUserApp = EpmetRequestHolder.getHeader(AppClientConstant.APP); + String loginUserClient = EpmetRequestHolder.getHeader(AppClientConstant.CLIENT); + String loginUserId = EpmetRequestHolder.getHeader(AppClientConstant.USER_ID.toLowerCase()); + String loginUserCustomerId = EpmetRequestHolder.getHeader(AppClientConstant.CUSTOMER_ID.toLowerCase()); log.info("persistIcResiExtraInfo:: userId:{}, app:{}, client:{}, customerId:{}", loginUserId, loginUserApp, loginUserClient, loginUserCustomerId); @@ -1281,8 +1283,8 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res Date now = new Date(); - String customerId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.CUSTOMER_ID.toLowerCase()); - String userId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.USER_ID.toLowerCase()); + String userId = EpmetRequestHolder.getHeader(AppClientConstant.USER_ID.toLowerCase()); + String customerId = EpmetRequestHolder.getHeader(AppClientConstant.CUSTOMER_ID.toLowerCase()); CustomerStaffInfoCacheResult operator = CustomerStaffRedis.getStaffInfo(customerId, userId); @@ -1378,8 +1380,8 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res Set newResiKeys = redisUtils.keys(RedisKeys.icResiImportTypeKey(newlyOrChangedResi.get().getImportTag(), "add").concat("*")); - String customerId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.CUSTOMER_ID.toLowerCase()); - String userId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.USER_ID.toLowerCase()); + String userId = EpmetRequestHolder.getHeader(AppClientConstant.USER_ID.toLowerCase()); + String customerId = EpmetRequestHolder.getHeader(AppClientConstant.CUSTOMER_ID.toLowerCase()); CustomerStaffInfoCacheResult operator = CustomerStaffRedis.getStaffInfo(customerId, userId); @@ -1416,8 +1418,10 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res */ public void saveTransferedResiRecord(Map transferedResis) { Date now = new Date(); - String loginUserId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.USER_ID.toLowerCase()); - String loginUserCustomerId = ThreadLocalConstant.inheritableAdditionalHeaders.get().get(AppClientConstant.CUSTOMER_ID.toLowerCase()); + + String loginUserId = EpmetRequestHolder.getHeader(AppClientConstant.USER_ID.toLowerCase()); + String loginUserCustomerId = EpmetRequestHolder.getHeader(AppClientConstant.CUSTOMER_ID.toLowerCase()); + CustomerStaffInfoCacheResult operator = CustomerStaffRedis.getStaffInfo(loginUserCustomerId, loginUserId); for (Map.Entry resi : transferedResis.entrySet()) { @@ -1831,11 +1835,18 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res } public void printLog(String positionPrefix) { - 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()); + String app = EpmetRequestHolder.getHeader(AppClientConstant.APP); + String client = EpmetRequestHolder.getHeader(AppClientConstant.CLIENT); + String loginUserId = EpmetRequestHolder.getHeader(AppClientConstant.USER_ID.toLowerCase()); + String loginUserCustomerId = EpmetRequestHolder.getHeader(AppClientConstant.CUSTOMER_ID.toLowerCase()); log.info("{}:: userId:{}, app:{}, client:{}, customerId:{}", positionPrefix, loginUserId, app, client, loginUserCustomerId); } + + @Override + public Object testAsync() { + IcNeighborHoodDTO nform = new IcNeighborHoodDTO(); + govOrgOpenFeignClient.getNeighborHoodOptions(nform); + return null; + } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java index 6350f94c54..341932bd52 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java @@ -1183,8 +1183,19 @@ public class IcResiUserServiceImpl extends BaseServiceImpl configList = configListResult.getData(); - PageInfo> pageInfo = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.selectResiUsers(configList.stream().map(m -> m.getColumnName()).collect(Collectors.toList()), staffInfo.getAgencyId())); + List configListOrigin = configListResult.getData(); + List configList = new ArrayList<>(); + if (StringUtils.isNotBlank(formDTO.getCategoryCode())){ + for (CustomerCategoryShowAndWarnListResultDTO c : configListOrigin) { + if (c.getColumnName().equals(formDTO.getCategoryCode())){ + configList.add(c); + } + } + }else { + configList = configListOrigin; + } + List finalConfigList = configList; + PageInfo> pageInfo = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.selectResiUsers(finalConfigList.stream().map(m -> m.getColumnName()).collect(Collectors.toList()), staffInfo.getAgencyId())); List> list = pageInfo.getList(); if (CollectionUtils.isEmpty(list)) { return result; @@ -1197,10 +1208,28 @@ public class IcResiUserServiceImpl extends BaseServiceImpl houseInfos = houseInfosResult.getData(); userList.forEach(u -> houseInfos.stream().filter(h -> h.getHomeId().equals(u.getHomeId())).forEach(h -> u.setFamily(h.getAllName()))); - result.setList(userList); + // 类型+网格+家庭 排序 + userList.forEach(u -> { + String types = u.getType().stream().map(String::valueOf).collect(Collectors.joining("、")); + String s = types + u.getGridName() + u.getFamily(); + u.setSortString(s); + }); + List finalResult = userList.stream().sorted(Comparator.comparing(PersonWarnRightListResultDTO.PersonWarnRightList::getSortString)).collect(Collectors.toList()); + result.setList(finalResult); return result; } + /** + * Desc: 根据房屋IDs查询房屋下是否有存在居民的 + * @param ids + * @author zxc + * @date 2022/3/2 10:32 上午 + */ + @Override + public List getExistUserByHouseIds(List ids) { + return baseDao.getExistUserByHouseIds(ids); + } + /** * @Description 居民分类 和 网格名 处理 * @param list diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/PatrolRoutineWorkServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/PatrolRoutineWorkServiceImpl.java index df3d1c3418..7964281361 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/PatrolRoutineWorkServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/PatrolRoutineWorkServiceImpl.java @@ -97,9 +97,9 @@ public class PatrolRoutineWorkServiceImpl extends BaseServiceImpl buildingwWarnList(String customerId,String agencyID) { List result = new ArrayList<>(); diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml index ff945fede7..8122ec6bf9 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml @@ -628,4 +628,17 @@ ) + + +