Browse Source

Merge branches 'dev' and 'dev_wx_msg' of http://git.elinkit.com.cn:7070/r/epmet-cloud into dev_wx_msg

master
sunyuchao 5 years ago
parent
commit
0eedb6d7e5
  1. 1
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/BaseRequestLogAspect.java
  2. 79
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/distributedlock/DistributedLock.java
  3. 12
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/distributedlock/LockConstants.java
  4. 10
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
  5. 73
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/IpUtils.java
  6. 10
      epmet-gateway/src/main/java/com/epmet/auth/AuthProcessor.java
  7. 10
      epmet-gateway/src/main/java/com/epmet/auth/ExternalAuthProcessor.java
  8. 18
      epmet-gateway/src/main/java/com/epmet/auth/InternalAuthProcessor.java
  9. 1
      epmet-gateway/src/main/java/com/epmet/constant/AuthTypeConstant.java
  10. 25
      epmet-gateway/src/main/java/com/epmet/filter/CpAuthGatewayFilterFactory.java
  11. 24
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/BranchCountFormDTO.java
  12. 22
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/AnNingSubAgencyIndexRankResultDTO.java
  13. 36
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/BranchCountResultDTO.java
  14. 2
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/DepartmentNameListResultDTO.java
  15. 52
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/SubBranchCountResultDTO.java
  16. 16
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/DistributionController.java
  17. 8
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java
  18. 9
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenCustomerGridDao.java
  19. 8
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/DistributionService.java
  20. 10
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/AgencyServiceImpl.java
  21. 44
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/DistributionServiceImpl.java
  22. 15
      epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerAgencyDao.xml
  23. 41
      epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerGridDao.xml
  24. 3
      epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml
  25. 13
      epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenPartyLinkMassesDataDao.xml
  26. 23
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java
  27. 48
      epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/RedissonTest.java
  28. 21
      epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/zxc/ZxcDTO.java
  29. 16
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AddToTemplateFormDTO.java
  30. 16
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/DeleteTemplateFormDTO.java
  31. 34
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/TemplateDraftListResultDTO.java
  32. 39
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeController.java
  33. 27
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeService.java
  34. 71
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java
  35. 15
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java
  36. 18
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxAddToTemplateReq.java
  37. 18
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxDeleteTemplateReq.java
  38. 51
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxTemplateDraftListResult.java
  39. 29
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/WxMaCodeService.java
  40. 83
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaCodeServiceImpl.java
  41. 24
      epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/CustomerFootBarController.java
  42. 35
      epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/CustomerFootBarServiceImpl.java
  43. 2
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartyMemberConfirmServiceImpl.java
  44. 1
      epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partymember/PartymemberInfoDao.xml

1
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/BaseRequestLogAspect.java

@ -12,7 +12,6 @@ import org.springframework.dao.DuplicateKeyException;
import javax.servlet.http.HttpServletRequest;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.UUID;
/**
* 日志切面

79
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/distributedlock/DistributedLock.java

@ -0,0 +1,79 @@
package com.epmet.commons.tools.distributedlock;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.RedisKeys;
import org.apache.commons.lang3.StringUtils;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
/**
* @Author zxc
* @DateTime 2020/10/28 9:05 上午
*/
@Component
public class DistributedLock {
@Autowired
private RedissonClient redissonClient;
/**
* @Description 抢锁🔒 每个锁持有十分钟
* @Param name
* @author zxc
* @date 2020/10/28 2:52 下午
*/
public RLock getLock(String name){
RLock lock = null;
if (StringUtils.isNotBlank(name)) {
lock = redissonClient.getLock(name);
// 持续时间为 -1 时,直到其明确释放锁才会释放【宕机就完蛋了】,
lock.lock(10,TimeUnit.MINUTES);
}
return lock;
}
/**
* @Description
* @Param name 锁名
* @Param leaseTime 持锁时间 单位min
* @Param waitTime 获取锁最长等待时间 单位min
* @author zxc
* @date 2020/10/29 9:04 上午
*/
public RLock getLock(String name,Long leaseTime,Long waitTime){
RLock lock = null;
if (StringUtils.isNotBlank(name) && leaseTime > 0 && waitTime > 0 ){
lock = redissonClient.getLock(name);
Boolean lockStatus;
try {
lockStatus = lock.tryLock(waitTime,leaseTime,TimeUnit.MINUTES);
if (!lockStatus){
throw new RenException("获取锁🔒失败了......");
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
return lock;
}
/**
* @Description 释放锁🔒
* @Param rLock
* @author zxc
* @date 2020/10/28 2:52 下午
*/
public void unLock(RLock rLock){
if (null != rLock){
if (rLock.isHeldByCurrentThread()){
rLock.unlock();
}
}
}
}

12
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/distributedlock/LockConstants.java

@ -0,0 +1,12 @@
package com.epmet.commons.tools.distributedlock;
/**
* @Author zxc
* @DateTime 2020/10/28 9:23 上午
*/
public interface LockConstants {
String TEST_LOCK_NAME = "testLock";
String STATS_LOCK_NAME = "stats";
}

10
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java

@ -337,6 +337,16 @@ public class RedisKeys {
return rootPrefix.concat("stats:calflag");
}
/**
* footbar缓存key
* @param customerId
* @param appType
* @return
*/
public static String getCustomerFootbarKey(String customerId, String appType) {
return rootPrefix.concat("footbar").concat(":").concat(customerId).concat(":").concat(appType);
}
/**
* 插入大屏指标数据分布式锁 key
*/

73
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/IpUtils.java

@ -8,12 +8,17 @@
package com.epmet.commons.tools.utils;
import com.epmet.commons.tools.constant.StrConstant;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpHeaders;
import org.springframework.http.server.reactive.ServerHttpRequest;
import javax.servlet.http.HttpServletRequest;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Optional;
import java.util.regex.Pattern;
/**
@ -24,43 +29,87 @@ import java.util.regex.Pattern;
*/
public class IpUtils {
private static Logger logger = LoggerFactory.getLogger(IpUtils.class);
public static final String LOCALHOST = "127.0.0.1";
private static final String LOCALHOST = "127.0.0.1";
public static final String ANYHOST = "0.0.0.0";
private static final String ANYHOST = "0.0.0.0";
private static final String IP_UNKNOWN = "unknown";
private static final Pattern IP_PATTERN = Pattern.compile("\\d{1,3}(\\.\\d{1,3}){3,5}$");
public static String getIpAddr(HttpServletRequest request) {
String ip = null;
try {
ip = request.getHeader("x-forwarded-for");
logger.debug("x-forwarded-for:"+ip);
if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
logger.debug("x-forwarded-for:" + ip);
if (StringUtils.isEmpty(ip) || IP_UNKNOWN.equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (StringUtils.isEmpty(ip) || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
if (StringUtils.isEmpty(ip) || ip.length() == 0 || IP_UNKNOWN.equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
if (StringUtils.isEmpty(ip) || IP_UNKNOWN.equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_CLIENT_IP");
}
if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
if (StringUtils.isEmpty(ip) || IP_UNKNOWN.equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
if (StringUtils.isEmpty(ip) || IP_UNKNOWN.equalsIgnoreCase(ip)) {
ip = request.getHeader("X-Real-IP");
}
if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
if (StringUtils.isEmpty(ip) || IP_UNKNOWN.equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
//对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割
if (ip != null) { //"***.***.***.***".length() = 15
if (ip.indexOf(",") > 0) {
ip = ip.substring(0, ip.indexOf(","));
if (ip.indexOf(StrConstant.COMMA) > 0) {
ip = ip.split(StrConstant.COMMA)[0];
;
}
}
} catch (Exception e) {
logger.error("IpUtils getIpAddr ERROR ", e);
}
return ip;
}
public static String getClientIp(ServerHttpRequest request) {
String ip = null;
try {
HttpHeaders headers = request.getHeaders();
String ipAddress = headers.getFirst("x-forwarded-for");
if (ipAddress == null || ipAddress.length() == 0 || IP_UNKNOWN.equalsIgnoreCase(ipAddress)) {
ipAddress = headers.getFirst("Proxy-Client-IP");
}
if (ipAddress == null || ipAddress.length() == 0 || IP_UNKNOWN.equalsIgnoreCase(ipAddress)) {
ipAddress = headers.getFirst("WL-Proxy-Client-IP");
}
if (ipAddress == null || ipAddress.length() == 0 || IP_UNKNOWN.equalsIgnoreCase(ipAddress)) {
ipAddress = Optional.ofNullable(request.getRemoteAddress())
.map(address -> address.getAddress().getHostAddress())
.orElse("");
if (LOCALHOST.equals(ipAddress)) {
// 根据网卡取本机配置的IP
try {
InetAddress inet = InetAddress.getLocalHost();
ipAddress = inet.getHostAddress();
} catch (UnknownHostException e) {
// ignore
}
}
}
// 对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割
if (ip != null) { //"***.***.***.***".length() = 15
if (ip.indexOf(StrConstant.COMMA) > 0) {
ip = ip.substring(0, ip.indexOf(StrConstant.COMMA));
}
}
return ipAddress;
} catch (Exception e) {
logger.error("IpUtils ERROR ", e);
logger.error("IpUtils getIpAddr ERROR ", e);
}
return ip;

10
epmet-gateway/src/main/java/com/epmet/auth/AuthProcessor.java

@ -13,14 +13,6 @@ import java.nio.charset.StandardCharsets;
public abstract class AuthProcessor {
abstract Mono<Void> auth(ServerWebExchange exchange, GatewayFilterChain chain);
protected Mono<Void> response(ServerWebExchange exchange, Object object) {
String json = JSON.toJSONString(object);
DataBuffer buffer = exchange.getResponse().bufferFactory().wrap(json.getBytes(StandardCharsets.UTF_8));
exchange.getResponse().getHeaders().setContentType(MediaType.APPLICATION_JSON_UTF8);
exchange.getResponse().setStatusCode(HttpStatus.OK);
return exchange.getResponse().writeWith(Flux.just(buffer));
}
abstract ServerWebExchange auth(ServerWebExchange exchange, GatewayFilterChain chain);
}

10
epmet-gateway/src/main/java/com/epmet/auth/ExternalAuthProcessor.java

@ -50,7 +50,7 @@ public class ExternalAuthProcessor extends AuthProcessor {
private CpProperty cpProperty;
@Override
public Mono<Void> auth(ServerWebExchange exchange, GatewayFilterChain chain) {
public ServerWebExchange auth(ServerWebExchange exchange, GatewayFilterChain chain) {
ServerHttpRequest request = exchange.getRequest();
// 只有在外部应用urls中的url才会允许外部应用访问,否则不允许访问
@ -92,12 +92,14 @@ public class ExternalAuthProcessor extends AuthProcessor {
throw new RenException(EpmetErrorCode.OPER_EXTERNAL_APP_AUTH_ERROR.getCode(), "未知的外部认证类型");
}
} catch (RenException e) {
return response(exchange, new Result<>().error(e.getCode(), e.getMsg()));
//return response(exchange, new Result<>().error(e.getCode(), e.getMsg()));
throw new RenException(e.getCode(),e.getMsg());
} catch (Exception e) {
logger.error("外部应用请求认证发生未知错误:" + ExceptionUtils.getErrorStackTrace(e));
return response(exchange, new Result<>().error("外部应用请求认证发生未知错误"));
//return response(exchange, new Result<>().error("外部应用请求认证发生未知错误"));
throw new RenException("外部应用请求认证发生未知错误");
}
return chain.filter(exchange);
return exchange;
}
}

18
epmet-gateway/src/main/java/com/epmet/auth/InternalAuthProcessor.java

@ -8,7 +8,6 @@ import com.epmet.commons.tools.security.dto.BaseTokenDto;
import com.epmet.commons.tools.security.dto.GovTokenDto;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.CpUserDetailRedis;
import com.epmet.commons.tools.utils.Result;
import com.epmet.filter.CpProperty;
import com.epmet.jwt.JwtTokenUtils;
import io.jsonwebtoken.Claims;
@ -22,7 +21,6 @@ import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.stereotype.Component;
import org.springframework.util.AntPathMatcher;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
/**
* 内部认证处理器
@ -44,11 +42,10 @@ public class InternalAuthProcessor extends AuthProcessor {
private CpProperty cpProperty;
@Override
public Mono<Void> auth(ServerWebExchange exchange, GatewayFilterChain chain) {
public ServerWebExchange auth(ServerWebExchange exchange, GatewayFilterChain chain) {
ServerHttpRequest request = exchange.getRequest();
String requestUri = request.getPath().pathWithinApplication().value();
logger.info("CpAuthGatewayFilterFactory当前requestUri=[" + requestUri + "]CpAuthGatewayFilterFactory拦截成功");
String token = getTokenFromRequest(request);
//BaseTokenDto baseTokenDto = StringUtils.isNotBlank(token) ? getBaseTokenDto(token, jwtTokenUtils) : null;
BaseTokenDto baseTokenDto;
@ -56,7 +53,8 @@ public class InternalAuthProcessor extends AuthProcessor {
try{
baseTokenDto = getBaseTokenDto(token, jwtTokenUtils);
}catch(RenException e){
return response(exchange,new Result<>().error(e.getCode(),e.getMsg()));
//return response(exchange,new Result<>().error(e.getCode(),e.getMsg()));
throw new RenException(e.getCode(), e.getMsg());
}
}else{
baseTokenDto = null;
@ -92,12 +90,14 @@ public class InternalAuthProcessor extends AuthProcessor {
if (needAuth(requestUri)) {
// 校验token
if (StringUtils.isBlank(token)) {
return response(exchange, new Result<>().error(EpmetErrorCode.ERR10005.getCode(), EpmetErrorCode.ERR10005.getMsg()));
//return response(exchange, new Result<>().error(EpmetErrorCode.ERR10005.getCode(), EpmetErrorCode.ERR10005.getMsg()));
throw new RenException(EpmetErrorCode.ERR10005.getCode(), EpmetErrorCode.ERR10005.getMsg());
}
try {
validateTokenDto(baseTokenDto, token);
} catch (RenException e) {
return response(exchange, new Result<>().error(e.getCode(), e.getMsg()));
//return response(exchange, new Result<>().error(e.getCode(), e.getMsg()));
throw new RenException(e.getCode(), e.getMsg());
}
}
@ -119,10 +119,10 @@ public class InternalAuthProcessor extends AuthProcessor {
exchange.getRequest().mutate().header(AppClientConstant.CUSTOMER_ID, customerId);
}
ServerHttpRequest build = exchange.getRequest().mutate().build();
return chain.filter(exchange.mutate().request(build).build());
return exchange.mutate().request(build).build();
}
return chain.filter(exchange);
return exchange;
}
/**

1
epmet-gateway/src/main/java/com/epmet/constant/AuthTypeConstant.java

@ -1,6 +1,7 @@
package com.epmet.constant;
public class AuthTypeConstant {
public static final String AUTH_TYPE_ALL = "all";
public static final String AUTH_TYPE_INTERNAL = "internal";
public static final String AUTH_TYPE_EXTERNAL = "external";
public static final String AUTH_TYPE_NO_NEED = "no_need";

25
epmet-gateway/src/main/java/com/epmet/filter/CpAuthGatewayFilterFactory.java

@ -5,9 +5,8 @@ import com.alibaba.fastjson.JSON;
import com.epmet.auth.ExternalAuthProcessor;
import com.epmet.auth.InternalAuthProcessor;
import com.epmet.commons.tools.constant.AppClientConstant;
import com.epmet.commons.tools.constant.Constant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.IpUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.AuthTypeConstant;
import com.epmet.constant.TokenHeaderKeyConstant;
@ -23,7 +22,6 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.stereotype.Component;
import org.springframework.util.AntPathMatcher;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@ -71,13 +69,21 @@ public class CpAuthGatewayFilterFactory extends AbstractGatewayFilterFactory<CpA
ServerHttpRequest request = exchange.getRequest();
String authType = getAuthType(request);
String requestUri = request.getPath().pathWithinApplication().value();
logger.info("CpAuthGatewayFilterFactory当前requestUri=[" + requestUri + "],CpAuthGatewayFilterFactory拦截成功,客户端Id:{}", IpUtils.getClientIp(request));
try {
switch (authType) {
case AuthTypeConstant.AUTH_TYPE_ALL:
externalAuthProcessor.auth(exchange, chain);
internalAuthProcessor.auth(exchange, chain);
break;
case AuthTypeConstant.AUTH_TYPE_EXTERNAL:
return externalAuthProcessor.auth(exchange, chain);
externalAuthProcessor.auth(exchange, chain);
break;
case AuthTypeConstant.AUTH_TYPE_INTERNAL:
return internalAuthProcessor.auth(exchange, chain);
internalAuthProcessor.auth(exchange, chain);
break;
}
} catch (RenException e) {
return response(exchange, new Result<>().error(e.getCode(), e.getMessage()));
@ -105,7 +111,14 @@ public class CpAuthGatewayFilterFactory extends AbstractGatewayFilterFactory<CpA
// }
//}
if (StringUtils.isNotBlank(request.getHeaders().getFirst(TokenHeaderKeyConstant.ACCESS_TOKEN_HEADER_KEY))) {
boolean needExternal = StringUtils.isNotBlank(request.getHeaders().getFirst(TokenHeaderKeyConstant.ACCESS_TOKEN_HEADER_KEY));
boolean needInternal = StringUtils.isNotBlank(request.getHeaders().getFirst(TokenHeaderKeyConstant.AUTHORIZATION_TOKEN_HEADER_KEY));
if (needExternal && needInternal) {
return AuthTypeConstant.AUTH_TYPE_ALL;
}
if (needExternal) {
// url对外部应用开放,并且头里面有AccessToken,那么走外部应用认证
return AuthTypeConstant.AUTH_TYPE_EXTERNAL;
}

24
epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/BranchCountFormDTO.java

@ -0,0 +1,24 @@
package com.epmet.evaluationindex.screen.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2020/10/27 11:08 上午
*/
@Data
public class BranchCountFormDTO implements Serializable {
private static final long serialVersionUID = -4869326660700557193L;
public interface BranchCount{}
/**
* 机关ID
*/
@NotBlank(message = "机关ID不能为空",groups = {BranchCount.class})
private String agencyId;
}

22
epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/AnNingSubAgencyIndexRankResultDTO.java

@ -1,5 +1,6 @@
package com.epmet.evaluationindex.screen.dto.result;
import com.epmet.commons.tools.constant.NumConstant;
import lombok.Data;
import java.io.Serializable;
@ -38,6 +39,21 @@ public class AnNingSubAgencyIndexRankResultDTO implements Serializable {
*/
private Double serviceAbility = 0.0;
/**
* 党建能力权重
*/
private Double partyWeight;
/**
* 治理能力权重
*/
private Double governWeight;
/**
* 服务能力权重
*/
private Double serviceWeight;
/**
* 组织id或者网格id
*/
@ -47,4 +63,10 @@ public class AnNingSubAgencyIndexRankResultDTO implements Serializable {
* 组织类型
*/
private String orgType = "";
public AnNingSubAgencyIndexRankResultDTO() {
this.partyWeight = NumConstant.ZERO_DOT_ZERO;
this.governWeight = NumConstant.ZERO_DOT_ZERO;
this.serviceWeight = NumConstant.ZERO_DOT_ZERO;
}
}

36
epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/BranchCountResultDTO.java

@ -0,0 +1,36 @@
package com.epmet.evaluationindex.screen.dto.result;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* @Author zxc
* @DateTime 2020/10/27 11:03 上午
*/
@Data
public class BranchCountResultDTO implements Serializable {
private static final long serialVersionUID = -5915969126291502360L;
private String agencyId;
/**
* 机关名称
*/
private String name;
@JsonIgnore
private String level;
private List<SubBranchCountResultDTO> partyDistribution;
public BranchCountResultDTO() {
this.agencyId = "";
this.name = "";
this.partyDistribution = new ArrayList<>();
}
}

2
epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/DepartmentNameListResultDTO.java

@ -2,6 +2,7 @@ package com.epmet.evaluationindex.screen.dto.result;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.List;
@ -12,6 +13,7 @@ import java.util.List;
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class DepartmentNameListResultDTO implements Serializable {
private static final long serialVersionUID = -801407836277197080L;

52
epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/SubBranchCountResultDTO.java

@ -0,0 +1,52 @@
package com.epmet.evaluationindex.screen.dto.result;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2020/10/27 5:22 下午
*/
@Data
public class SubBranchCountResultDTO implements Serializable {
private static final long serialVersionUID = -4174988002147169566L;
private String subId;
/**
* 机关名称
*/
private String name;
/**
* 中心点位
*/
private String centerMark;
/**
* 社区下的党支部数
*/
private Integer totalNum;
/**
* 坐标区域
*/
private String areaMarks;
@JsonIgnore
private String allParentIds;
@JsonIgnore
private String subAgencyId;
public SubBranchCountResultDTO() {
this.subId = "";
this.name = "";
this.centerMark = "";
this.totalNum = 0;
this.areaMarks = "";
this.subAgencyId = "";
}
}

16
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/DistributionController.java

@ -39,7 +39,19 @@ public class DistributionController {
}
/**
* @Description 2用户分布 只显示 screen_customer_biz_org 表中存在的orgId的数据
* @Description 查询机关下的党支部
* @Param branchCountFormDTO
* @author zxc
* @date 2020/10/27 11:11 上午
*/
@PostMapping("branchcount")
public Result<BranchCountResultDTO> branchCount(@RequestBody BranchCountFormDTO branchCountFormDTO){
ValidatorUtils.validateEntity(branchCountFormDTO, BranchCountFormDTO.BranchCount.class);
return new Result<BranchCountResultDTO>().ok(distributionService.branchCount(branchCountFormDTO));
}
/**
* @Description 2用户分布 只显示 is_display = 1 的数据
* @param userFormDTO
* @author zxc
* @date 2020/8/18 11:10 上午
@ -51,7 +63,7 @@ public class DistributionController {
}
/**
* @Description 3党员分布 只显示 screen_customer_biz_org 表中存在的orgId的数据
* @Description 3党员分布 只显示 is_display = 1 的数据
* @param parymemberFormDTO
* @author zxc
* @date 2020/8/18 11:20 上午

8
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java

@ -104,4 +104,12 @@ public interface ScreenCustomerAgencyDao {
* @date 2020/10/23 3:54 下午
*/
CompartmentResultDTO getAgencyInfoByAegncyId(@Param("agencyId") String agencyId);
/**
* @Description 查询组织的下级组织ID
* @Param agencyId
* @author zxc
* @date 2020/10/28 10:33 上午
*/
List<SubBranchCountResultDTO> selectSubAgencyId(@Param("agencyId") String agencyId);
}

9
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenCustomerGridDao.java

@ -48,6 +48,15 @@ public interface ScreenCustomerGridDao {
*/
List<BranchResultDTO> selectBranch(@Param("agencyId")String agencyId);
/**
* @Description 查询机关下的党支部
* @Param branchCountFormDTO
* @author zxc
* @date 2020/10/27 11:11 上午
*/
BranchCountResultDTO selectAgencyInfo(@Param("agencyId")String agencyId);
List<SubBranchCountResultDTO> selectBranchCount(@Param("agencyId")String agencyId);
/**
* @Description 查询子级用户分布网格级别
* @param parentId

8
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/DistributionService.java

@ -21,6 +21,14 @@ public interface DistributionService {
*/
List<BranchResultDTO> branch(BranchFormDTO formDTO);
/**
* @Description 查询机关下的党支部
* @Param branchCountFormDTO
* @author zxc
* @date 2020/10/27 11:11 上午
*/
BranchCountResultDTO branchCount(BranchCountFormDTO branchCountFormDTO);
/**
* @Description 2用户分布
* @param userFormDTO

10
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/AgencyServiceImpl.java

@ -138,12 +138,7 @@ public class AgencyServiceImpl implements AgencyService {
});
sub.setChildren(treeResultDTOS);
}else {
List<TreeResultDTO> subAgency = new ArrayList<>();
if (sub.getPids().contains(ScreenConstant.COMMA)){
subAgency = getDepartmentList(sub.getPids() + ScreenConstant.COMMA + sub.getValue());
}else {
subAgency = getDepartmentList(sub.getPids() + ScreenConstant.COLON + sub.getValue());
}
List<TreeResultDTO> subAgency = getDepartmentList(sub.getPids() + ScreenConstant.COMMA + sub.getValue());
sub.setChildren(subAgency);
}
});
@ -176,6 +171,9 @@ public class AgencyServiceImpl implements AgencyService {
subAgency = getDepartmentListByBiz(sub.getPids() + ScreenConstant.COMMA + sub.getValue());
}else {
subAgency = getDepartmentListByBiz(sub.getPids() + ScreenConstant.COLON + sub.getValue());
if (null == subAgency){
subAgency = getDepartmentListByBiz(sub.getPids() + ScreenConstant.COMMA + sub.getValue());
}
}
sub.setChildren(subAgency);
}

44
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/DistributionServiceImpl.java

@ -11,12 +11,16 @@ import com.epmet.datareport.service.evaluationindex.screen.DistributionService;
import com.epmet.evaluationindex.screen.constant.ScreenConstant;
import com.epmet.evaluationindex.screen.dto.form.*;
import com.epmet.evaluationindex.screen.dto.result.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 中央区相关各指标查询
@ -24,6 +28,7 @@ import java.util.List;
* @author yinzuomei@elink-cn.com
* @date 2020/8/18 10:19
*/
@Slf4j
@Service
@DataSource(DataSourceConstant.EVALUATION_INDEX)
public class DistributionServiceImpl implements DistributionService {
@ -50,6 +55,45 @@ public class DistributionServiceImpl implements DistributionService {
return branchResultDTOS;
}
/**
* @Description 查询机关下的党支部
* @Param branchCountFormDTO
* @author zxc
* @date 2020/10/27 11:11 上午
*/
@DataSource(value = DataSourceConstant.EVALUATION_INDEX,datasourceNameFromArg = true)
@Override
public BranchCountResultDTO branchCount(BranchCountFormDTO branchCountFormDTO) {
BranchCountResultDTO branchCountResultDTO = screenCustomerGridDao.selectAgencyInfo(branchCountFormDTO.getAgencyId());
if (null == branchCountResultDTO){
return new BranchCountResultDTO();
}
if (branchCountResultDTO.getLevel().equals(ScreenConstant.COMMUNITY)){
return new BranchCountResultDTO();
}
List<SubBranchCountResultDTO> agencyIds = screenCustomerAgencyDao.selectSubAgencyId(branchCountFormDTO.getAgencyId());
List<SubBranchCountResultDTO> subList = screenCustomerGridDao.selectBranchCount(branchCountFormDTO.getAgencyId());
if (!CollectionUtils.isEmpty(subList)){
subList.forEach(sub -> {
agencyIds.forEach(agencyId -> {
if (sub.getAllParentIds().contains(agencyId.getSubId())){
sub.setSubAgencyId(agencyId.getSubId());
}
});
});
}
Map<String, List<SubBranchCountResultDTO>> groupBySubAgency = subList.stream().collect(Collectors.groupingBy(sub -> sub.getSubAgencyId()));
agencyIds.forEach(a -> {
groupBySubAgency.forEach((agencyId,value) -> {
if (a.getSubId().equals(agencyId)){
a.setTotalNum(value.stream().collect(Collectors.summingInt(v -> v.getTotalNum())));
}
});
});
branchCountResultDTO.setPartyDistribution(CollectionUtils.isEmpty(agencyIds) ? new ArrayList<>() : agencyIds);
return branchCountResultDTO;
}
/**
* @Description 2用户分布
* @param userFormDTO

15
epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerAgencyDao.xml

@ -197,4 +197,19 @@
del_flag = 0
AND agency_id = #{agencyId}
</select>
<!-- 查询组织的下级组织ID -->
<select id="selectSubAgencyId" resultType="com.epmet.evaluationindex.screen.dto.result.SubBranchCountResultDTO">
SELECT
AGENCY_ID AS subId,
AGENCY_NAME AS name,
IFNULL(CENTER_MARK,'') AS centerMark ,
IFNULL(AREA_MARKS,'') AS areaMarks
FROM
screen_customer_agency
WHERE
DEL_FLAG = 0
AND IS_DISPLAY = 1
AND pid = #{agencyId}
</select>
</mapper>

41
epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerGridDao.xml

@ -26,10 +26,10 @@
scg.party_mark AS partyMark
FROM
screen_customer_grid scg
LEFT JOIN screen_customer_biz_org bo ON bo.ORG_ID = scg.PARENT_AGENCY_ID
LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = scg.PARENT_AGENCY_ID AND sca.IS_DISPLAY = 1
WHERE
scg.del_flag = 0
AND bo.BIZ_TYPE = 'community'
AND sca.DEL_FLAG = 0
AND scg.all_parent_ids LIKE concat('%', #{agencyId}, '%')
</select>
@ -84,4 +84,41 @@
ORDER BY
created_time DESC
</select>
<!-- 查询机关下的党支部 -->
<select id="selectAgencyInfo" resultType="com.epmet.evaluationindex.screen.dto.result.BranchCountResultDTO">
SELECT
AGENCY_ID,
AGENCY_NAME AS name,
IFNULL(PARTY_MARK,''),
IFNULL(CENTER_MARK,''),
level
FROM
screen_customer_agency
WHERE
DEL_FLAG = 0
AND IS_DISPLAY = 1
AND AGENCY_ID = #{agencyId}
</select>
<select id="selectBranchCount" resultType="com.epmet.evaluationindex.screen.dto.result.SubBranchCountResultDTO">
SELECT
COUNT( scg.ID ) AS totalNum,
sca.AGENCY_ID AS subId,
IFNULL(sca.CENTER_MARK,'') AS centerMark,
sca.AGENCY_NAME AS name,
IFNULL(sca.AREA_MARKS,'') AS areaMarks,
scg.ALL_PARENT_IDS,
sca.PID
FROM
screen_customer_grid scg
LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = scg.PARENT_AGENCY_ID
WHERE
scg.DEL_FLAG = 0
AND sca.DEL_FLAG = 0
AND sca.IS_DISPLAY = 1
AND scg.all_parent_ids LIKE concat('%', #{agencyId}, '%')
GROUP BY scg.PARENT_AGENCY_ID
</select>
</mapper>

3
epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml

@ -69,6 +69,9 @@
service_ablity * SERVICE_ABLITY_WEIGHT AS serviceAbility,
party_dev_ablity * PARTY_DEV_WEIGHT AS partyDevAbility,
govern_ablity * GOVERN_ABLITY_WEIGHT AS governAbility,
PARTY_DEV_WEIGHT AS partyWeight,
GOVERN_ABLITY_WEIGHT AS governWeight,
SERVICE_ABLITY_WEIGHT AS serviceWeight,
ORG_ID orgId,
ORG_TYPE orgType
FROM

13
epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenPartyLinkMassesDataDao.xml

@ -6,13 +6,14 @@
<!-- 查询党员联系群众 -->
<select id="selectContactMassLineChart" resultType="com.epmet.evaluationindex.screen.dto.result.ContactMassLineChartResult">
SELECT
org_name AS orgName,
create_group_total AS groupTotal,
group_user_total AS userTotal
md.org_name AS orgName,
md.create_group_total AS groupTotal,
md.group_user_total AS userTotal
FROM
screen_party_link_masses_data
screen_party_link_masses_data md
left join screen_customer_agency sca on sca.agency_id = md.parent_id and is_display = 1
WHERE
del_flag = '0'
AND parent_id = #{agencyId}
md.del_flag = '0'
AND md.parent_id = #{agencyId}
</select>
</mapper>

23
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java

@ -3,7 +3,8 @@ package com.epmet.service.evaluationindex.indexcoll.impl;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.distributedlock.DistributedLock;
import com.epmet.commons.tools.distributedlock.LockConstants;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.constant.DataSourceConstant;
import com.epmet.constant.OrgTypeConstant;
@ -29,7 +30,6 @@ import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -89,7 +89,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
@Autowired
private ScreenCustomerAgencyDao screenCustomerAgencyDao;
@Autowired
private RedissonClient redissonClient;
private DistributedLock distributedLock;
@Override
@Transactional(rollbackFor = Exception.class)
@ -216,15 +216,9 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
if (NumConstant.SIX != monthId.length()) {
throw new RuntimeException("入参monthId格式不正确:monthId =" + monthId);
}
RLock lock = redissonClient.getLock(RedisKeys.getScreenIndexDataLockKey());
RLock lock = distributedLock.getLock(LockConstants.STATS_LOCK_NAME);
try {
AtomicInteger tryTimes = new AtomicInteger(0);
boolean lockFlag = false;
do {
lockFlag = lock.tryLock(1, 10, TimeUnit.MINUTES);
} while (!lockFlag && tryTimes.addAndGet(1) < 3);
if (!lockFlag) {
log.error("插入大屏指数方法获取锁失败");
if (null==lock) {
return;
}
allParentIds.cleanUp();
@ -250,13 +244,8 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
// 根据年,汇总今年各项得到,计算平均值后 插入年表 screen_index_data_yearly
this.insertIndexDataYear(monthId, customerId);
allParentIds.invalidateAll();
} catch (InterruptedException inter) {
log.error("插入计算指标数据异常", inter);
} finally {
//判断是否是当前线程 持有锁
if (lock.isHeldByCurrentThread()) {
lock.unlock();
}
distributedLock.unLock(lock);
}
}

48
epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/RedissonTest.java

@ -1,6 +1,10 @@
package com.epmet.stats.test;
import com.alibaba.fastjson.JSON;
import com.epmet.DataStatsApplication;
import com.epmet.commons.tools.distributedlock.DistributedLock;
import com.epmet.commons.tools.distributedlock.LockConstants;
import com.epmet.stats.test.zxc.ZxcDTO;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -10,6 +14,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
/**
@ -22,8 +29,43 @@ public class RedissonTest {
@Autowired
private RedissonClient redissonClient;
@Autowired
private DistributedLock distributedLock;
@Test
public void lock(){
long start = System.currentTimeMillis();
RLock lock = distributedLock.getLock(LockConstants.TEST_LOCK_NAME);
if (null==lock){
System.out.println("shibai");
}
try {
List<ZxcDTO> list = new ArrayList<>();
for (int i = 0; i < 50000; i++) {
ZxcDTO zxcDTO = new ZxcDTO();
zxcDTO.setA(UUID.randomUUID().toString());
zxcDTO.setB(UUID.randomUUID().toString());
zxcDTO.setC(UUID.randomUUID().toString());
zxcDTO.setD(UUID.randomUUID().toString());
zxcDTO.setE(UUID.randomUUID().toString());
zxcDTO.setF(i);
zxcDTO.setG(i+1);
zxcDTO.setH(i+2);
list.add(zxcDTO);
}
// log.info(JSON.toJSONString(list));
}finally {
// distributedLock.unLock(lock);
}
long end = System.currentTimeMillis();
log.info((end-start)+"hs");
}
/*@Test
public void lockTest() {
//获取一个名为 lockName 的锁实例
RLock lock = redissonClient.getLock("lockName");
@ -38,10 +80,10 @@ public class RedissonTest {
//lock.lock();
//异步方式
/* RFuture<Void> future = lock.lockAsync();
*//* RFuture<Void> future = lock.lockAsync();
if (future.isSuccess()){
//todo something
}*/
}*//*
if (bs) {
// 业务代码
System.out.println("进入业务代码: " + 123);
@ -56,6 +98,6 @@ public class RedissonTest {
lock.unlock();
}
}
}
}*/
}

21
epmet-module/data-statistical/data-statistical-server/src/test/java/com/epmet/stats/test/zxc/ZxcDTO.java

@ -0,0 +1,21 @@
package com.epmet.stats.test.zxc;
import lombok.Data;
/**
* @Author zxc
* @DateTime 2020/10/28 3:15 下午
*/
@Data
public class ZxcDTO {
private String a;
private String b;
private String c;
private String d;
private String e;
private Integer f;
private Integer g;
private Integer h;
}

16
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AddToTemplateFormDTO.java

@ -0,0 +1,16 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
/**
* @author zhaoqifeng
* @dscription
* @date 2020/10/28 9:55
*/
@Data
public class AddToTemplateFormDTO implements Serializable {
private static final long serialVersionUID = -7759275805971446460L;
private String draftId;
}

16
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/DeleteTemplateFormDTO.java

@ -0,0 +1,16 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
/**
* @author zhaoqifeng
* @dscription
* @date 2020/10/28 9:57
*/
@Data
public class DeleteTemplateFormDTO implements Serializable {
private static final long serialVersionUID = -6516706760708801090L;
private String templateId;
}

34
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/TemplateDraftListResultDTO.java

@ -0,0 +1,34 @@
package com.epmet.dto.result;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @author zhaoqifeng
* @dscription
* @date 2020/10/28 9:52
*/
@NoArgsConstructor
@Data
public class TemplateDraftListResultDTO implements Serializable {
private static final long serialVersionUID = 8249448254837721428L;
/**
* 开发者上传草稿时间戳
*/
private String createTime;
/**
* 版本号开发者自定义字段
*/
private String userVersion;
/**
* 版本描述 开发者自定义字段
*/
private String userDesc;
/**
* 草稿 id
*/
private String draftId;
}

39
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeController.java

@ -251,5 +251,44 @@ public class CodeController {
return new Result<>();
}
/**
* 获取代码草稿列表
* @author zhaoqifeng
* @date 2020/10/28 9:59
* @param
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.result.TemplateDraftListResultDTO>>
*/
@PostMapping("gettemplatedraftlist")
public Result<List<TemplateDraftListResultDTO>> getTemplateDraftList() {
List<TemplateDraftListResultDTO> list = codeService.getTemplateDraftList();
return new Result<List<TemplateDraftListResultDTO>>().ok(list);
}
/**
* 将草稿添加到代码模板库
* @author zhaoqifeng
* @date 2020/10/28 10:00
* @param formDTO
* @return com.epmet.commons.tools.utils.Result
*/
@PostMapping("addtotemplate")
public Result addToTemplate(@RequestBody AddToTemplateFormDTO formDTO) {
codeService.addToTemplate(formDTO);
return new Result<>();
}
/**
* 删除指定代码模板
* @author zhaoqifeng
* @date 2020/10/28 10:03
* @param formDTO
* @return com.epmet.commons.tools.utils.Result
*/
@PostMapping("deletetemplate")
public Result deleteTemplate(@RequestBody DeleteTemplateFormDTO formDTO) {
codeService.deleteTemplate(formDTO);
return new Result<>();
}
}

27
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/CodeService.java

@ -217,4 +217,31 @@ public interface CodeService {
*/
void revertCodeRelease(CodeCommonFormDTO formDTO);
/**
* 获取代码草稿列表
* @author zhaoqifeng
* @date 2020/10/28 10:02
* @param
* @return java.util.List<com.epmet.dto.result.TemplateDraftListResultDTO>
*/
List<TemplateDraftListResultDTO> getTemplateDraftList();
/**
* 将草稿添加到代码模板库
* @author zhaoqifeng
* @date 2020/10/28 10:02
* @param formDTO
* @return void
*/
void addToTemplate(AddToTemplateFormDTO formDTO);
/**
* 删除指定代码模板
* @author zhaoqifeng
* @date 2020/10/28 10:03
* @param formDTO
* @return void
*/
void deleteTemplate(DeleteTemplateFormDTO formDTO);
}

71
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java

@ -741,6 +741,77 @@ public class CodeServiceImpl implements CodeService {
codeCustomerService.deleteById(codeCustomerDTO.getId());
}
/**
* 获取代码草稿列表
*
* @return java.util.List<com.epmet.dto.result.TemplateDraftListResultDTO>
* @author zhaoqifeng
* @date 2020/10/28 10:02
*/
@Override
public List<TemplateDraftListResultDTO> getTemplateDraftList() {
List<TemplateDraftListResultDTO> resultList = new ArrayList<>();
//获取COMPONENT_ACCESS_TOKEN
String accessToken = componentAccessTokenDao.getComponentAccessToken();
//调用微信API获取模板列表
WxResult<WxTemplateDraftListResult> wxResult = wxMaCodeService.getTemplateDraftList(accessToken);
if (!wxResult.success()) {
throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg());
}
if (null == wxResult.getData() || wxResult.getData().getDraftList().size() == NumConstant.ZERO) {
return resultList;
}
wxResult.getData().getDraftList().forEach(temp -> {
TemplateDraftListResultDTO dto = new TemplateDraftListResultDTO();
dto.setDraftId(temp.getDraftId());
dto.setUserVersion(temp.getUserVersion());
dto.setUserDesc(temp.getUserDesc());
dto.setCreateTime(DateUtils.formatTimestamp(temp.getCreateTime(), DateUtils.DATE_TIME_PATTERN));
resultList.add(dto);
});
return resultList;
}
/**
* 将草稿添加到代码模板库
*
* @param formDTO
* @return void
* @author zhaoqifeng
* @date 2020/10/28 10:02
*/
@Override
public void addToTemplate(AddToTemplateFormDTO formDTO) {
//获取COMPONENT_ACCESS_TOKEN
String accessToken = componentAccessTokenDao.getComponentAccessToken();
WxAddToTemplateReq request = new WxAddToTemplateReq();
request.setDraftId(formDTO.getDraftId());
WxResult result = wxMaCodeService.addToTemplate(accessToken, request);
if (!result.success()) {
throw new RenException(result.getErrorCode(), result.getErrorMsg());
}
}
/**
* 删除指定代码模板
*
* @param formDTO
* @return void
* @author zhaoqifeng
* @date 2020/10/28 10:03
*/
@Override
public void deleteTemplate(DeleteTemplateFormDTO formDTO) {
//获取COMPONENT_ACCESS_TOKEN
String accessToken = componentAccessTokenDao.getComponentAccessToken();
WxDeleteTemplateReq request = new WxDeleteTemplateReq();
request.setTemplateId(formDTO.getTemplateId());
WxResult result = wxMaCodeService.deleteTemplate(accessToken, request);
if (!result.success()) {
throw new RenException(result.getErrorCode(), result.getErrorMsg());
}
}
private void saveOperation(String customerId, String clientType, String codeId, String version, String operation, String describe) {
CodeOperationHistoryDTO operationDTO = new CodeOperationHistoryDTO();
operationDTO.setCustomerId(customerId);

15
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java

@ -185,4 +185,19 @@ public interface WxMaCodeConstant {
* 加急审核申请
*/
String SPEED_UP_AUDIT_URL = "https://api.weixin.qq.com/wxa/speedupaudit";
/**
* 获取代码草稿列表
*/
String GET_TEMPLATE_DRAFT_LIST_URL = "https://api.weixin.qq.com/wxa/gettemplatedraftlist";
/**
* 将草稿添加到代码模板库
*/
String ADD_TO_TEMPLATE_URL = "https://api.weixin.qq.com/wxa/addtotemplate";
/**
* 获取代码草稿列表
*/
String DELETE_TEMPLATE_URL = "https://api.weixin.qq.com/wxa/deletetemplate";
}

18
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxAddToTemplateReq.java

@ -0,0 +1,18 @@
package com.epmet.wxapi.param;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import java.io.Serializable;
/**
* @author zhaoqifeng
* @dscription
* @date 2020/10/28 10:20
*/
@Data
public class WxAddToTemplateReq implements Serializable {
private static final long serialVersionUID = -4667328954236033227L;
@SerializedName("draft_id")
private String draftId;
}

18
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxDeleteTemplateReq.java

@ -0,0 +1,18 @@
package com.epmet.wxapi.param;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import java.io.Serializable;
/**
* @author zhaoqifeng
* @dscription
* @date 2020/10/28 10:21
*/
@Data
public class WxDeleteTemplateReq implements Serializable {
private static final long serialVersionUID = 3099244896895201612L;
@SerializedName("template_id")
private String templateId;
}

51
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxTemplateDraftListResult.java

@ -0,0 +1,51 @@
package com.epmet.wxapi.result;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.List;
/**
* @author zhaoqifeng
* @dscription
* @date 2020/10/28 10:12
*/
@NoArgsConstructor
@Data
public class WxTemplateDraftListResult implements Serializable {
private static final long serialVersionUID = -7316579770340890368L;
/**
* 错误码
*/
private Integer errcode;
/**
* 错误信息
*/
private String errmsg;
@SerializedName("draft_list")
private List<DraftListBean> draftList;
public boolean success(){
return errcode == 0;
}
@NoArgsConstructor
@Data
public static class DraftListBean {
/**
* create_time
*/
@SerializedName("create_time")
private Long createTime;
@SerializedName("user_version")
private String userVersion;
@SerializedName("user_desc")
private String userDesc;
@SerializedName("draft_id")
private String draftId;
}
}

29
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/WxMaCodeService.java

@ -202,4 +202,33 @@ public interface WxMaCodeService {
* @return com.epmet.wxapi.result.WxResult
*/
WxResult revertCodeRelease(String accessToken);
/**
* 获取代码草稿列表
* @author zhaoqifeng
* @date 2020/10/28 10:18
* @param accessToken
* @return com.epmet.wxapi.result.WxResult<com.epmet.wxapi.result.WxTemplateDraftListResult>
*/
WxResult<WxTemplateDraftListResult> getTemplateDraftList(String accessToken);
/**
* 将草稿添加到代码模板库
* @author zhaoqifeng
* @date 2020/10/28 10:23
* @param accessToken
* @param request
* @return com.epmet.wxapi.result.WxResult
*/
WxResult addToTemplate(String accessToken, WxAddToTemplateReq request);
/**
* 删除指定代码模板
* @author zhaoqifeng
* @date 2020/10/28 10:23
* @param accessToken
* @param request
* @return com.epmet.wxapi.result.WxResult
*/
WxResult deleteTemplate(String accessToken, WxDeleteTemplateReq request);
}

83
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaCodeServiceImpl.java

@ -387,6 +387,89 @@ public class WxMaCodeServiceImpl implements WxMaCodeService {
return result;
}
/**
* 获取代码草稿列表
*
* @param accessToken
* @return com.epmet.wxapi.result.WxResult<com.epmet.wxapi.result.WxTemplateDraftListResult>
* @author zhaoqifeng
* @date 2020/10/28 10:18
*/
@Override
public WxResult<WxTemplateDraftListResult> getTemplateDraftList(String accessToken) {
WxResult<WxTemplateDraftListResult> result = new WxResult<>();
String url = WxMaCodeConstant.GET_TEMPLATE_DRAFT_LIST_URL + "?" + "access_token=" + accessToken;
Result<String> templateListResult = HttpClientManager.getInstance().sendGet(url, null);
if (!templateListResult.success()) {
result.setErrorCode(templateListResult.getCode());
result.setErrorMsg(templateListResult.getMsg());
return result;
}
Gson gson = new Gson();
WxTemplateDraftListResult templateList = gson.fromJson(templateListResult.getData(), WxTemplateDraftListResult.class);
result.setErrorCode(templateList.getErrcode());
result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(templateList.getErrcode()));
result.setData(templateList);
WxTemplateDraftListResult draftListResult = JSONObject.parseObject(templateListResult.getData(), WxTemplateDraftListResult.class);
if (!draftListResult.success()) {
result.setErrorCode(draftListResult.getErrcode());
result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(draftListResult.getErrcode()));
return result;
}
result.ok(draftListResult);
return result;
}
/**
* 将草稿添加到代码模板库
*
* @param accessToken
* @param request
* @return com.epmet.wxapi.result.WxResult
* @author zhaoqifeng
* @date 2020/10/28 10:23
*/
@Override
public WxResult addToTemplate(String accessToken, WxAddToTemplateReq request) {
WxResult result = new WxResult();
String url = WxMaCodeConstant.ADD_TO_TEMPLATE_URL + "?" + "access_token=" + accessToken;
Result<String> submitResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request));
if (!submitResult.success()) {
result.setErrorCode(submitResult.getCode());
result.setErrorMsg(submitResult.getMsg());
return result;
}
JSONObject jsonObject = JSONObject.parseObject(submitResult.getData());
result.setErrorCode(jsonObject.getInteger(ERR_CODE));
result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(jsonObject.getInteger(ERR_CODE)));
return result;
}
/**
* 删除指定代码模板
*
* @param accessToken
* @param request
* @return com.epmet.wxapi.result.WxResult
* @author zhaoqifeng
* @date 2020/10/28 10:23
*/
@Override
public WxResult deleteTemplate(String accessToken, WxDeleteTemplateReq request) {
WxResult result = new WxResult();
String url = WxMaCodeConstant.DELETE_TEMPLATE_URL + "?" + "access_token=" + accessToken;
Result<String> submitResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request));
if (!submitResult.success()) {
result.setErrorCode(submitResult.getCode());
result.setErrorMsg(submitResult.getMsg());
return result;
}
JSONObject jsonObject = JSONObject.parseObject(submitResult.getData());
result.setErrorCode(jsonObject.getInteger(ERR_CODE));
result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(jsonObject.getInteger(ERR_CODE)));
return result;
}
private String toJson(Object object) {
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.setPrettyPrinting();

24
epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/controller/CustomerFootBarController.java

@ -18,6 +18,8 @@
package com.epmet.controller;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.utils.ExcelUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.AssertUtils;
@ -31,8 +33,12 @@ import com.epmet.dto.result.CustomerFootBarResultDTO;
import com.epmet.entity.CustomerFootBarEntity;
import com.epmet.excel.CustomerFootBarExcel;
import com.epmet.service.CustomerFootBarService;
import com.epmet.service.impl.CustomerFunctionDetailServiceImpl;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
@ -51,9 +57,14 @@ import java.util.Map;
@RequestMapping("customerfootbar")
public class CustomerFootBarController {
private Logger logger = LogManager.getLogger(CustomerFootBarController.class);
@Autowired
private CustomerFootBarService customerFootBarService;
@Autowired
private RedisUtils redisUtils;
@GetMapping("page")
public Result<PageData<CustomerFootBarDTO>> page(@RequestParam Map<String, Object> params){
PageData<CustomerFootBarDTO> page = customerFootBarService.page(params);
@ -107,6 +118,13 @@ public class CustomerFootBarController {
String customerId = formDTO.getCustomerId();
String appType = formDTO.getAppType();
// 优先查询缓存
List<CustomerFootBarDTO> bars = (List<CustomerFootBarDTO>)redisUtils.get(RedisKeys.getCustomerFootbarKey(customerId, appType));
if (bars != null) {
new Result<List<CustomerFootBarDTO>>().ok(bars);
}
// 查询db
List<CustomerFootBarEntity> footbars = customerFootBarService.listCustomerFootBars(customerId, appType);
List<CustomerFootBarDTO> barDTOS = new LinkedList<>();
footbars.forEach(barEntity -> {
@ -117,6 +135,12 @@ public class CustomerFootBarController {
barDTO.setDefaultBarName(defaultFootBarEntity.getBarName());
barDTOS.add(barDTO);
});
try {
redisUtils.set(RedisKeys.getCustomerFootbarKey(customerId, appType), barDTOS);
} catch (Exception e) {
logger.error("将客户footbar放入缓存失败,customerId:{}, appType:{}", customerId, appType);
}
return new Result<List<CustomerFootBarDTO>>().ok(barDTOS);
}

35
epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/CustomerFootBarServiceImpl.java

@ -23,6 +23,8 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.dao.CustomerFootBarDao;
@ -36,10 +38,12 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
* APP底部菜单栏信息
@ -53,6 +57,9 @@ public class CustomerFootBarServiceImpl extends BaseServiceImpl<CustomerFootBarD
@Autowired
private CustomerFootBarRedis customerFootBarRedis;
@Autowired
private RedisUtils redisUtils;
@Override
public PageData<CustomerFootBarDTO> page(Map<String, Object> params) {
IPage<CustomerFootBarEntity> page = baseDao.selectPage(
@ -160,6 +167,7 @@ public class CustomerFootBarServiceImpl extends BaseServiceImpl<CustomerFootBarD
}
}
@Transactional
@Override
public void updateFootBar(CustomerFootBarFormDTO form) {
validateBeforeUpdate(form);
@ -174,6 +182,9 @@ public class CustomerFootBarServiceImpl extends BaseServiceImpl<CustomerFootBarD
entity.setIconPath(form.getIconPath());
baseDao.updateById(entity);
// 删除缓存中的footbar。若缓存删除失败,则事务回滚,db中的不应该成功
redisUtils.delete(RedisKeys.getCustomerFootbarKey(entity.getCustomerId(), entity.getAppType()));
}
@Override
@ -197,6 +208,18 @@ public class CustomerFootBarServiceImpl extends BaseServiceImpl<CustomerFootBarD
for (CustomerFootBarFormDTO.OrderIndexDTO idx : orderList) {
baseDao.updateOrder(idx.getId(), idx.getOrderIndex());
}
if (!CollectionUtils.isEmpty(orderList)) {
String footbarId = orderList.get(0).getId();
CustomerFootBarEntity footBarEntity = baseDao.selectById(footbarId);
Optional.of(footBarEntity).ifPresent(c -> {
// 删除缓存中的footbar。若缓存删除失败,则事务回滚,db中的不应该成功
redisUtils.delete(RedisKeys.getCustomerFootbarKey(c.getCustomerId(), c.getAppType()));
});
}
}
@Override
@ -204,9 +227,17 @@ public class CustomerFootBarServiceImpl extends BaseServiceImpl<CustomerFootBarD
return baseDao.getByAppTypeAndBarKeyOfCustomer(customerId, appType, barKey);
}
@Transactional
@Override
public void updateDisplayStatus(String id, Boolean display) {
baseDao.updateDisplayStatus(id, display);
CustomerFootBarEntity footBarEntity = baseDao.selectById(id);
Optional.of(footBarEntity).ifPresent(c -> {
// 删除缓存中的footbar。若缓存删除失败,则事务回滚,db中的不应该成功
redisUtils.delete(RedisKeys.getCustomerFootbarKey(c.getCustomerId(), c.getAppType()));
});
}
@Transactional
@ -230,10 +261,14 @@ public class CustomerFootBarServiceImpl extends BaseServiceImpl<CustomerFootBarD
}
}
@Transactional
@Override
public void deleteFootBar(String id) {
CustomerFootBarEntity defaultFootbar = baseDao.selectById(id);
baseDao.physicsDeleteByAppTypeAndBarKey(defaultFootbar.getAppType(), defaultFootbar.getBarKey());
// 删除缓存中的footbar。若缓存删除失败,则事务回滚,db中的不应该成功
redisUtils.delete(RedisKeys.getCustomerFootbarKey(defaultFootbar.getCustomerId(), defaultFootbar.getAppType()));
}
/**

2
epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartyMemberConfirmServiceImpl.java

@ -98,7 +98,7 @@ public class PartyMemberConfirmServiceImpl implements PartyMemberConfirmService
// 获取党员认证信息,判断是否提交认证
PartymemberInfoDTO partyMemberInfoParam = new PartymemberInfoDTO();
partyMemberInfoParam.setCustomerId(fromDto.getCustomerId());
partyMemberInfoParam.setGridId(fromDto.getGridId());
//partyMemberInfoParam.setGridId(fromDto.getGridId());
partyMemberInfoParam.setUserId(fromDto.getUserId());
PartymemberInfoDTO partyMemberInfoResult = partymemberInfoService.getPartyMemberInfo(partyMemberInfoParam);
// 若已提交,获取提交的党员信息

1
epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partymember/PartymemberInfoDao.xml

@ -38,7 +38,6 @@
AND pcm.DEL_FLAG = 0
WHERE
pi.CUSTOMER_ID = #{customerId}
AND pi.GRID_ID = #{gridId}
AND pi.USER_ID = #{userId}
AND pi.CONFIRM_RESULT = 'auto_confirm_failed'
AND pi.DEL_FLAG = 0

Loading…
Cancel
Save