From 2ec73d7dc22564535b9e80e946c88fd1b0ddcf12 Mon Sep 17 00:00:00 2001 From: wxz Date: Thu, 25 Feb 2021 17:08:29 +0800 Subject: [PATCH 01/38] =?UTF-8?q?=E3=80=90=E9=85=92=E5=9F=8Ee=E9=80=9A?= =?UTF-8?q?=E5=B1=85=E6=B0=91=E7=99=BB=E5=BD=95=E3=80=91=E5=B0=86yml?= =?UTF-8?q?=E7=9A=84=E7=A7=98=E9=92=A5=E7=9B=B8=E5=85=B3=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E5=88=86=E6=88=902=E4=BB=BD=EF=BC=8Cc=E7=AB=AF=E5=92=8Cg?= =?UTF-8?q?=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- epmet-auth/pom.xml | 36 ++++++++++++------- epmet-auth/src/main/resources/bootstrap.yml | 12 ++++--- .../com/epmet/commons/thirdplat/DemoApp.java | 2 +- .../apiservice/jcet/JcetApiService.java | 18 +++++----- .../thirdplat/properties/ThirdplatProps.java | 6 +++- 5 files changed, 48 insertions(+), 26 deletions(-) diff --git a/epmet-auth/pom.xml b/epmet-auth/pom.xml index 5015feb391..74e4e92ab9 100644 --- a/epmet-auth/pom.xml +++ b/epmet-auth/pom.xml @@ -200,9 +200,13 @@ - http://101.206.141.251:21006 - soXDEoM1 - V7ea0KnlYt7eSyzc + http://101.206.141.251:21006 + soXDEoM1 + V7ea0KnlYt7eSyzc + + http://101.206.141.219:21006 + xSMONWwP + UUCnxLyXiB4eBF4p @@ -249,9 +253,13 @@ - http://101.206.141.251:21006 - soXDEoM1 - V7ea0KnlYt7eSyzc + http://101.206.141.251:21006 + soXDEoM1 + V7ea0KnlYt7eSyzc + + http://101.206.141.219:21006 + xSMONWwP + UUCnxLyXiB4eBF4p @@ -293,9 +301,13 @@ - http://101.206.141.251:21006 - soXDEoM1 - V7ea0KnlYt7eSyzc + http://101.206.141.251:21006 + soXDEoM1 + V7ea0KnlYt7eSyzc + + http://101.206.141.219:21006 + xSMONWwP + UUCnxLyXiB4eBF4p @@ -341,9 +353,9 @@ - https://jcytc.lzjczl.com:21009 - 2cy0a9lA - 6hU3PQgxLcXr27SE + https://jcytc.lzjczl.com:21009 + 2cy0a9lA + 6hU3PQgxLcXr27SE diff --git a/epmet-auth/src/main/resources/bootstrap.yml b/epmet-auth/src/main/resources/bootstrap.yml index 6efee6a635..35d3f0e1f7 100644 --- a/epmet-auth/src/main/resources/bootstrap.yml +++ b/epmet-auth/src/main/resources/bootstrap.yml @@ -135,7 +135,11 @@ shutdown: # 调用第三方平台相关参数 thirdplat: - jcet: - domain: @thirdplat.jcet.domain@ - appkey: @thirdplat.jcet.appkey@ - appsecret: @thirdplat.jcet.appsecret@ \ No newline at end of file + jcetCend: + domain: @thirdplat.jcet.c.domain@ + appkey: @thirdplat.jcet.c.appkey@ + appsecret: @thirdplat.jcet.c.appsecret@ + jcetGend: + domain: @thirdplat.jcet.g.domain@ + appkey: @thirdplat.jcet.g.appkey@ + appsecret: @thirdplat.jcet.g.appsecret@ \ No newline at end of file diff --git a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/DemoApp.java b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/DemoApp.java index 43b27e385b..1b874efc82 100644 --- a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/DemoApp.java +++ b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/DemoApp.java @@ -20,7 +20,7 @@ public class DemoApp { //ssoToken.setSsoToken("wxz"); SsoTicketFormDTO ssoTicket = new SsoTicketFormDTO(); - ssoTicket.setSsoTicket("wxz"); + ssoTicket.setSsoTicket("ssoTicket-jGOAW66udmRtUWBKgs3q7k1w7prGxd5I"); int bodyLength = JSON.toJSONString(ssoTicket).getBytes("utf-8").length; diff --git a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/jcet/JcetApiService.java b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/jcet/JcetApiService.java index c5f0753f47..b158a61b6e 100644 --- a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/jcet/JcetApiService.java +++ b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/jcet/JcetApiService.java @@ -22,11 +22,13 @@ public class JcetApiService extends AbstractApiService { Logger logger = LoggerFactory.getLogger(getClass()); - private JcetThirdplatProps jcetThirdplatProps; + private JcetThirdplatProps jcetThirdplatCendProps; + private JcetThirdplatProps jcetThirdplatGendProps; public JcetApiService(ThirdplatProps props) { this.thirdplatProps = props; - jcetThirdplatProps = props.getJcet(); + jcetThirdplatCendProps = props.getJcetCend(); + jcetThirdplatGendProps = props.getJcetGend(); } /** @@ -43,12 +45,12 @@ public class JcetApiService extends AbstractApiService { SsoTicketFormDTO ssoTicket = new SsoTicketFormDTO(); ssoTicket.setSsoTicket(ticket); - String domain = jcetThirdplatProps.getDomain(); + String domain = jcetThirdplatCendProps.getDomain(); Result result = HttpClientManager.getInstance().sendPost( domain.concat(JcetConstants.URL_GET_USER_BY_TICKET), domain.startsWith("https://"), JSON.toJSONString(ssoTicket), - getHeaders(ssoTicket)); + getHeaders(ssoTicket, jcetThirdplatCendProps.getAppkey(), jcetThirdplatCendProps.getAppsecret())); try { logger.info("【请求酒城e通第三方平台】getUserInfoByTicket()接口返回:{}", result.getData()); @@ -98,15 +100,15 @@ public class JcetApiService extends AbstractApiService { * @return * @throws UnsupportedEncodingException */ - private Map getHeaders(Object contentObject) throws UnsupportedEncodingException { + private Map getHeaders(Object contentObject, String appKey, String appSecret) throws UnsupportedEncodingException { int bodyLength = JSON.toJSONString(contentObject).getBytes("utf-8").length; Map headers = new HashMap(); long timestamp = System.currentTimeMillis(); headers.put(JcetConstants.PLAT_HEADER_OPEN_TIMESTAMP, String.valueOf(timestamp)); - headers.put(JcetConstants.PLAT_HEADER_OPEN_APP_ID, jcetThirdplatProps.getAppkey()); - String encryptContent = jcetThirdplatProps.getAppkey() + timestamp + bodyLength; - headers.put(JcetConstants.PLAT_HEADER_OPEN_SIGN, SignUtils.generate(encryptContent, jcetThirdplatProps.getAppsecret())); + headers.put(JcetConstants.PLAT_HEADER_OPEN_APP_ID, appKey); + String encryptContent = appKey + timestamp + bodyLength; + headers.put(JcetConstants.PLAT_HEADER_OPEN_SIGN, SignUtils.generate(encryptContent, appSecret)); return headers; } diff --git a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/properties/ThirdplatProps.java b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/properties/ThirdplatProps.java index 07c4919bd9..6ce8c89f9b 100644 --- a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/properties/ThirdplatProps.java +++ b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/properties/ThirdplatProps.java @@ -7,6 +7,10 @@ import org.springframework.boot.context.properties.ConfigurationProperties; @ConfigurationProperties(prefix = "thirdplat") public class ThirdplatProps { - private JcetThirdplatProps jcet; + // C端 + private JcetThirdplatProps jcetCend; + + // G端 + private JcetThirdplatProps jcetGend; } From 95d13b3d5f75a1824076536f44b09b48cbd59278 Mon Sep 17 00:00:00 2001 From: wxz Date: Fri, 26 Feb 2021 01:49:56 +0800 Subject: [PATCH 02/38] =?UTF-8?q?=E5=A2=9E=E5=8A=A0G=E7=AB=AFssotoken?= =?UTF-8?q?=E7=99=BB=E5=BD=95=20=E4=BF=AE=E6=94=B9G=E7=AB=AF=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/controller/SsoController.java | 7 +-- .../epmet/dto/form/SsoWorkLoginFormDTO.java | 42 +++++++++++++++++ .../java/com/epmet/service/SsoService.java | 3 +- .../epmet/service/impl/SsoServiceImpl.java | 10 +++-- .../apiservice/AbstractApiService.java | 10 ++++- .../apiservice/jcet/JcetApiService.java | 45 ++++++++++++++++--- ...ltDTO.java => JcetCUserInfoResultDTO.java} | 2 +- .../result/jcet/JcetGUserInfoResultDTO.java | 25 +++++++++++ 8 files changed, 127 insertions(+), 17 deletions(-) create mode 100644 epmet-auth/src/main/java/com/epmet/dto/form/SsoWorkLoginFormDTO.java rename epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/result/jcet/{JcetUserInfoResultDTO.java => JcetCUserInfoResultDTO.java} (91%) create mode 100644 epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/result/jcet/JcetGUserInfoResultDTO.java diff --git a/epmet-auth/src/main/java/com/epmet/controller/SsoController.java b/epmet-auth/src/main/java/com/epmet/controller/SsoController.java index 86fc44aa18..2f5f480bf0 100644 --- a/epmet-auth/src/main/java/com/epmet/controller/SsoController.java +++ b/epmet-auth/src/main/java/com/epmet/controller/SsoController.java @@ -6,6 +6,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.form.SsoEnteOrgFormDTO; import com.epmet.dto.form.SsoLoginFormDTO; +import com.epmet.dto.form.SsoWorkLoginFormDTO; import com.epmet.dto.result.SsoLoginResultDTO; import com.epmet.dto.result.UserTokenResultDTO; import com.epmet.service.SsoService; @@ -45,7 +46,7 @@ public class SsoController { public Result testssoLogin(){ ThirdPlatUserInfo userInfoByTicket = null; try { - userInfoByTicket = jcetApiService.getUserInfoByTicket("ssoTicket-vYtMRuXAQZri3wpA2vyq5D8n3Q9oO7ui"); + userInfoByTicket = jcetApiService.getCUserInfoByTicket("ssoTicket-vYtMRuXAQZri3wpA2vyq5D8n3Q9oO7ui"); } catch (Exception e) { e.printStackTrace(); } @@ -58,8 +59,8 @@ public class SsoController { * @Description 1、ticket自动登录获取内部token **/ @PostMapping("work/login") - public Result ssoWorkLogin(@RequestBody SsoLoginFormDTO formDTO){ - ValidatorUtils.validateEntity(formDTO, SsoLoginFormDTO.SsoLoginForm.class); + public Result ssoWorkLogin(@RequestBody SsoWorkLoginFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO, SsoWorkLoginFormDTO.SsoLoginForm.class); return new Result().ok(ssoService.ssoWorkLogin(formDTO)); } diff --git a/epmet-auth/src/main/java/com/epmet/dto/form/SsoWorkLoginFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/SsoWorkLoginFormDTO.java new file mode 100644 index 0000000000..32ff9aa00b --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/dto/form/SsoWorkLoginFormDTO.java @@ -0,0 +1,42 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2021/1/18 下午4:43 + */ +@Data +public class SsoWorkLoginFormDTO implements Serializable { + + private static final long serialVersionUID = -6543952487970013031L; + + public interface SsoLoginForm{} + + /** + * sso票据,有效期为300秒 + */ + @NotBlank(message = "ssotoken不能为空",groups = SsoLoginForm.class) + private String token; + + /** + * 三方平台应用AppId + */ + @NotBlank(message = "三方平台应用AppId不能为空",groups = SsoLoginForm.class) + private String appId; + + /** + * app类型 resi;居民段,gov:工作端 + */ + @NotBlank(message = "app不能为空",groups = SsoLoginForm.class) + private String app; + + /** + * app;居民段,app:工作端 + */ + @NotBlank(message = "client不能为空",groups = SsoLoginForm.class) + private String client; +} diff --git a/epmet-auth/src/main/java/com/epmet/service/SsoService.java b/epmet-auth/src/main/java/com/epmet/service/SsoService.java index a2986482ab..b1f10e5622 100644 --- a/epmet-auth/src/main/java/com/epmet/service/SsoService.java +++ b/epmet-auth/src/main/java/com/epmet/service/SsoService.java @@ -2,6 +2,7 @@ package com.epmet.service; import com.epmet.dto.form.SsoEnteOrgFormDTO; import com.epmet.dto.form.SsoLoginFormDTO; +import com.epmet.dto.form.SsoWorkLoginFormDTO; import com.epmet.dto.result.SsoLoginResultDTO; import com.epmet.dto.result.UserTokenResultDTO; @@ -24,7 +25,7 @@ public interface SsoService { * @Author sun * @Description 1、ticket自动登录获取内部token **/ - UserTokenResultDTO ssoWorkLogin(SsoLoginFormDTO formDTO); + UserTokenResultDTO ssoWorkLogin(SsoWorkLoginFormDTO formDTO); /** * @param formDTO diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java index 67d00ea4e6..16cb78efe4 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java @@ -75,6 +75,7 @@ public class SsoServiceImpl implements SsoService { @Override public SsoLoginResultDTO ssoLogin(SsoLoginFormDTO formDTO) { String customerId = getCustomerId(formDTO.getAppId()); + //String customerId = "3a4f923665a7a07701bcb311aac9a156"; String userId = ""; Result apiServiceResult = operCrmOpenFeignClient.getApiServiceByCustomerId(new ApiServiceFormDTO(customerId)); @@ -89,7 +90,7 @@ public class SsoServiceImpl implements SsoService { ThirdPlatUserInfo userInfo; try { AbstractApiService apiService = (AbstractApiService) SpringContextUtils.getBean(apiServiceResult.getData().getApiServiceName()); - userInfo = apiService.getUserInfoByTicket(formDTO.getTicket()); + userInfo = apiService.getCUserInfoByTicket(formDTO.getTicket()); } catch (Exception e) { throw new RenException(e.getMessage()); } @@ -199,10 +200,11 @@ public class SsoServiceImpl implements SsoService { * @Description 1、ticket自动登录获取内部token **/ @Override - public UserTokenResultDTO ssoWorkLogin(SsoLoginFormDTO formDTO) { + public UserTokenResultDTO ssoWorkLogin(SsoWorkLoginFormDTO formDTO) { //1.根据appId查询客户id String customerId = getCustomerId(formDTO.getAppId()); + //String customerId = "3a4f923665a7a07701bcb311aac9a156"; //2.客户Id换取第三方apiService,根据ticket换取华为Id Result apiServiceResult = operCrmOpenFeignClient.getApiServiceByCustomerId(new ApiServiceFormDTO(customerId)); @@ -215,7 +217,7 @@ public class SsoServiceImpl implements SsoService { ThirdPlatUserInfo userInfo; try { AbstractApiService apiService = (AbstractApiService) SpringContextUtils.getBean(apiServiceResult.getData().getApiServiceName()); - userInfo = apiService.getUserInfoByTicket(formDTO.getTicket()); + userInfo = apiService.getGUserInfoBySSOToken(formDTO.getToken()); } catch (Exception e) { throw new RenException(e.getMessage()); } @@ -431,7 +433,7 @@ public class SsoServiceImpl implements SsoService { ThirdPlatUserInfo userInfo; try { AbstractApiService apiService = (AbstractApiService) SpringContextUtils.getBean(apiServiceResult.getData().getApiServiceName()); - userInfo = apiService.getUserInfoByTicket(formDTO.getTicket()); + userInfo = apiService.getGUserInfoBySSOToken(formDTO.getTicket()); } catch (Exception e) { throw new RenException(e.getMessage()); } diff --git a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/AbstractApiService.java b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/AbstractApiService.java index fbf0f7781e..c1f3cfcbc7 100644 --- a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/AbstractApiService.java +++ b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/AbstractApiService.java @@ -19,7 +19,15 @@ public abstract class AbstractApiService { * @return * @throws Exception */ - public abstract ThirdPlatUserInfo getUserInfoByTicket(String ticket) throws Exception; + public abstract ThirdPlatUserInfo getCUserInfoByTicket(String ticket) throws Exception; + + /** + * G端用户token获取用户信息 + * @param token + * @return + * @throws Exception + */ + public abstract ThirdPlatUserInfo getGUserInfoBySSOToken(String token) throws Exception; /** * @Description 解析请求结果 diff --git a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/jcet/JcetApiService.java b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/jcet/JcetApiService.java index b158a61b6e..5dbe5bdce0 100644 --- a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/jcet/JcetApiService.java +++ b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/jcet/JcetApiService.java @@ -5,7 +5,8 @@ import com.epmet.commons.thirdplat.apiservice.AbstractApiService; import com.epmet.commons.thirdplat.bean.ThirdPlatUserInfo; import com.epmet.commons.thirdplat.constants.JcetConstants; import com.epmet.commons.thirdplat.dto.form.jcet.SsoTicketFormDTO; -import com.epmet.commons.thirdplat.dto.result.jcet.JcetUserInfoResultDTO; +import com.epmet.commons.thirdplat.dto.result.jcet.JcetCUserInfoResultDTO; +import com.epmet.commons.thirdplat.dto.result.jcet.JcetGUserInfoResultDTO; import com.epmet.commons.thirdplat.encrypt.SignUtils; import com.epmet.commons.thirdplat.properties.JcetThirdplatProps; import com.epmet.commons.thirdplat.properties.ThirdplatProps; @@ -37,7 +38,7 @@ public class JcetApiService extends AbstractApiService { * @author wxz * @date 2021.01.19 10:26 */ - public ThirdPlatUserInfo getUserInfoByTicket(String ticket) throws UnsupportedEncodingException { + public ThirdPlatUserInfo getCUserInfoByTicket(String ticket) throws UnsupportedEncodingException { logger.info("【请求酒城e通第三方平台】getUserInfoByTicket()接口开始>>>>>>>>>>>>"); logger.info("【请求酒城e通第三方平台】getUserInfoByTicket()接口入参 ticket:{}", ticket); @@ -50,7 +51,7 @@ public class JcetApiService extends AbstractApiService { domain.concat(JcetConstants.URL_GET_USER_BY_TICKET), domain.startsWith("https://"), JSON.toJSONString(ssoTicket), - getHeaders(ssoTicket, jcetThirdplatCendProps.getAppkey(), jcetThirdplatCendProps.getAppsecret())); + getHeaders(JSON.toJSONString(ssoTicket).getBytes("utf-8").length, jcetThirdplatCendProps.getAppkey(), jcetThirdplatCendProps.getAppsecret())); try { logger.info("【请求酒城e通第三方平台】getUserInfoByTicket()接口返回:{}", result.getData()); @@ -59,7 +60,7 @@ public class JcetApiService extends AbstractApiService { } logger.info("【请求酒城e通第三方平台】getUserInfoByTicket()接口结束<<<<<<<<<<<<"); - JcetUserInfoResultDTO resultDTO = parseResult(result, JcetUserInfoResultDTO.class); + JcetCUserInfoResultDTO resultDTO = parseResult(result, JcetCUserInfoResultDTO.class); ThirdPlatUserInfo userInfo = new ThirdPlatUserInfo(); userInfo.setOpenId(resultDTO.getId()); @@ -68,6 +69,38 @@ public class JcetApiService extends AbstractApiService { return userInfo; } + @Override + public ThirdPlatUserInfo getGUserInfoBySSOToken(String token) throws Exception { + + logger.info("【请求酒城e通第三方平台】getGUserInfoBySSOToken()接口开始>>>>>>>>>>>>"); + logger.info("【请求酒城e通第三方平台】getGUserInfoBySSOToken()接口入参 ticket:{}", token); + + HashMap params = new HashMap<>(); + params.put("ssoToken",token); + + String domain = jcetThirdplatGendProps.getDomain(); + Result result = HttpClientManager.getInstance().sendGet( + domain.concat(JcetConstants.URL_GET_USER_BY_TOKEN), + domain.startsWith("https://"), + params, + getHeaders(0, jcetThirdplatGendProps.getAppkey(), jcetThirdplatGendProps.getAppsecret())); + + try { + logger.info("【请求酒城e通第三方平台】getUserInfoByTicket()接口返回:{}", result.getData()); + } catch (Exception e) { + //e.printStackTrace(); + } + logger.info("【请求酒城e通第三方平台】getUserInfoByTicket()接口结束<<<<<<<<<<<<"); + + JcetGUserInfoResultDTO resultDTO = parseResult(result, JcetGUserInfoResultDTO.class); + + ThirdPlatUserInfo userInfo = new ThirdPlatUserInfo(); + userInfo.setOpenId(resultDTO.getUid()); + userInfo.setName(resultDTO.getName()); + userInfo.setMobile(resultDTO.getMobile()); + return userInfo; + } + /** * @return * @Description 通过token获取用户信息 @@ -96,12 +129,10 @@ public class JcetApiService extends AbstractApiService { /** * 获取请求所需要的头信息 * - * @param contentObject * @return * @throws UnsupportedEncodingException */ - private Map getHeaders(Object contentObject, String appKey, String appSecret) throws UnsupportedEncodingException { - int bodyLength = JSON.toJSONString(contentObject).getBytes("utf-8").length; + private Map getHeaders(int bodyLength, String appKey, String appSecret) throws UnsupportedEncodingException { Map headers = new HashMap(); long timestamp = System.currentTimeMillis(); diff --git a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/result/jcet/JcetUserInfoResultDTO.java b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/result/jcet/JcetCUserInfoResultDTO.java similarity index 91% rename from epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/result/jcet/JcetUserInfoResultDTO.java rename to epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/result/jcet/JcetCUserInfoResultDTO.java index 8c025e5b9b..765126025d 100644 --- a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/result/jcet/JcetUserInfoResultDTO.java +++ b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/result/jcet/JcetCUserInfoResultDTO.java @@ -3,7 +3,7 @@ package com.epmet.commons.thirdplat.dto.result.jcet; import lombok.Data; @Data -public class JcetUserInfoResultDTO { +public class JcetCUserInfoResultDTO { private String id; /** * 用户名称 diff --git a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/result/jcet/JcetGUserInfoResultDTO.java b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/result/jcet/JcetGUserInfoResultDTO.java new file mode 100644 index 0000000000..24f2faf27c --- /dev/null +++ b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/result/jcet/JcetGUserInfoResultDTO.java @@ -0,0 +1,25 @@ +package com.epmet.commons.thirdplat.dto.result.jcet; + +import lombok.Data; + +@Data +public class JcetGUserInfoResultDTO { + private String uid; + /** + * 手机号码 + */ + private String mobile; + /** + * 姓名 + */ + private String name; + /** + * 账号 + */ + private String account; + + /** + * 用户编码 + */ + private String code; +} From 0b74d92a5935043f785985a4acba4af8ea6f6991 Mon Sep 17 00:00:00 2001 From: jianjun Date: Fri, 26 Feb 2021 11:00:10 +0800 Subject: [PATCH 03/38] =?UTF-8?q?HttpClientManager=20header=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=B8=BAobject?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apiservice/jcet/JcetApiService.java | 7 ++++--- .../commons/tools/utils/HttpClientManager.java | 16 ++++++++++------ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/jcet/JcetApiService.java b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/jcet/JcetApiService.java index 5dbe5bdce0..c2e631ae16 100644 --- a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/jcet/JcetApiService.java +++ b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/jcet/JcetApiService.java @@ -38,6 +38,7 @@ public class JcetApiService extends AbstractApiService { * @author wxz * @date 2021.01.19 10:26 */ + @Override public ThirdPlatUserInfo getCUserInfoByTicket(String ticket) throws UnsupportedEncodingException { logger.info("【请求酒城e通第三方平台】getUserInfoByTicket()接口开始>>>>>>>>>>>>"); @@ -132,11 +133,11 @@ public class JcetApiService extends AbstractApiService { * @return * @throws UnsupportedEncodingException */ - private Map getHeaders(int bodyLength, String appKey, String appSecret) throws UnsupportedEncodingException { + private Map getHeaders(int bodyLength, String appKey, String appSecret) throws UnsupportedEncodingException { - Map headers = new HashMap(); + Map headers = new HashMap(); long timestamp = System.currentTimeMillis(); - headers.put(JcetConstants.PLAT_HEADER_OPEN_TIMESTAMP, String.valueOf(timestamp)); + headers.put(JcetConstants.PLAT_HEADER_OPEN_TIMESTAMP, timestamp); headers.put(JcetConstants.PLAT_HEADER_OPEN_APP_ID, appKey); String encryptContent = appKey + timestamp + bodyLength; headers.put(JcetConstants.PLAT_HEADER_OPEN_SIGN, SignUtils.generate(encryptContent, appSecret)); diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java index 0c83bfdede..463e0b4c6d 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java @@ -188,15 +188,17 @@ public class HttpClientManager { } - public Result sendPost(String url, boolean isHttps, String jsonStrParam,Map headerMap) { + public Result sendPost(String url, boolean isHttps, String jsonStrParam, Map headerMap) { try { HttpPost httppost = new HttpPost(url); httppost.setConfig(requestConfig); httppost.addHeader(HEADER_CONTENT_TYPE, HEADER_APPLICATION_JSON); - if (null != headerMap){ - headerMap.forEach((k,v) -> { - httppost.addHeader(k,v); + if (null != headerMap) { + headerMap.forEach((k, v) -> { + if (StringUtils.isNotBlank(k)) { + httppost.addHeader(k, v == null ? null : v.toString()); + } }); } if (StringUtils.isNotEmpty(jsonStrParam)) { @@ -348,7 +350,7 @@ public class HttpClientManager { } } - public Result sendGet(String url, boolean isHttps, Map params, Map headerMap) { + public Result sendGet(String url, boolean isHttps, Map params, Map headerMap) { try { URIBuilder builder = new URIBuilder(url); @@ -363,7 +365,9 @@ public class HttpClientManager { httpGet.setConfig(requestConfig); if (null != headerMap){ headerMap.forEach((k,v) -> { - httpGet.addHeader(k,v); + if (StringUtils.isNotBlank(k)) { + httpGet.addHeader(k, v == null ? null : v.toString()); + } }); } return execute(httpGet, isHttps); From 24001e55abf3e40ef943db9fbd39c5502ee842a5 Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Fri, 26 Feb 2021 14:50:19 +0800 Subject: [PATCH 04/38] =?UTF-8?q?h5=E5=B7=A5=E4=BD=9C=E7=AB=AF=E7=99=BB?= =?UTF-8?q?=E9=99=86=E6=8E=A5=E5=8F=A3=E5=85=A5=E5=8F=82=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/epmet/dto/form/SsoEnteOrgFormDTO.java | 6 +++--- .../main/java/com/epmet/service/impl/SsoServiceImpl.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/epmet-auth/src/main/java/com/epmet/dto/form/SsoEnteOrgFormDTO.java b/epmet-auth/src/main/java/com/epmet/dto/form/SsoEnteOrgFormDTO.java index 4706061267..d74deaf828 100644 --- a/epmet-auth/src/main/java/com/epmet/dto/form/SsoEnteOrgFormDTO.java +++ b/epmet-auth/src/main/java/com/epmet/dto/form/SsoEnteOrgFormDTO.java @@ -15,10 +15,10 @@ public class SsoEnteOrgFormDTO implements Serializable { public interface AddUserInternalGroup {} public interface AddUserShowGroup extends CustomerClientShowGroup {} /** - * wxCode + * sso票据,有效期为300秒 */ - @NotBlank(message = "ticket不能为空",groups = {AddUserInternalGroup.class}) - private String ticket; + @NotBlank(message = "ssotoken不能为空",groups = SsoWorkLoginFormDTO.SsoLoginForm.class) + private String token; /** * 手机号 diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java index 16cb78efe4..8da49ca303 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java @@ -433,7 +433,7 @@ public class SsoServiceImpl implements SsoService { ThirdPlatUserInfo userInfo; try { AbstractApiService apiService = (AbstractApiService) SpringContextUtils.getBean(apiServiceResult.getData().getApiServiceName()); - userInfo = apiService.getGUserInfoBySSOToken(formDTO.getTicket()); + userInfo = apiService.getGUserInfoBySSOToken(formDTO.getToken()); } catch (Exception e) { throw new RenException(e.getMessage()); } From c64a35837cd774f6cde12ec6d3c10661410c5c3b Mon Sep 17 00:00:00 2001 From: wxz Date: Fri, 26 Feb 2021 14:59:22 +0800 Subject: [PATCH 05/38] =?UTF-8?q?=E4=BF=AE=E6=94=B9sso=E5=B1=85=E6=B0=91?= =?UTF-8?q?=E7=AB=AF=E7=99=BB=E5=BD=95=E6=8E=A5=E5=8F=A3=E7=9A=84=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/epmet/controller/SsoController.java | 4 ++-- .../src/main/java/com/epmet/service/SsoService.java | 2 +- .../main/java/com/epmet/service/impl/SsoServiceImpl.java | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/epmet-auth/src/main/java/com/epmet/controller/SsoController.java b/epmet-auth/src/main/java/com/epmet/controller/SsoController.java index 2f5f480bf0..e7ee68d696 100644 --- a/epmet-auth/src/main/java/com/epmet/controller/SsoController.java +++ b/epmet-auth/src/main/java/com/epmet/controller/SsoController.java @@ -37,9 +37,9 @@ public class SsoController { * @date 2021/1/18 下午4:59 */ @PostMapping("resi/login") - public Result ssoLogin(@RequestBody SsoLoginFormDTO formDTO){ + public Result ssoResiLogin(@RequestBody SsoLoginFormDTO formDTO){ ValidatorUtils.validateEntity(formDTO, SsoLoginFormDTO.SsoLoginForm.class); - return new Result().ok(ssoService.ssoLogin(formDTO)); + return new Result().ok(ssoService.ssoResiLogin(formDTO)); } @PostMapping("test") diff --git a/epmet-auth/src/main/java/com/epmet/service/SsoService.java b/epmet-auth/src/main/java/com/epmet/service/SsoService.java index b1f10e5622..bb4c712ea8 100644 --- a/epmet-auth/src/main/java/com/epmet/service/SsoService.java +++ b/epmet-auth/src/main/java/com/epmet/service/SsoService.java @@ -18,7 +18,7 @@ public interface SsoService { * @author zxc * @date 2021/1/18 下午4:59 */ - SsoLoginResultDTO ssoLogin(SsoLoginFormDTO formDTO); + SsoLoginResultDTO ssoResiLogin(SsoLoginFormDTO formDTO); /** * @param formDTO diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java index 16cb78efe4..b91e1981d6 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java @@ -73,7 +73,7 @@ public class SsoServiceImpl implements SsoService { * @date 2021/1/18 下午4:59 */ @Override - public SsoLoginResultDTO ssoLogin(SsoLoginFormDTO formDTO) { + public SsoLoginResultDTO ssoResiLogin(SsoLoginFormDTO formDTO) { String customerId = getCustomerId(formDTO.getAppId()); //String customerId = "3a4f923665a7a07701bcb311aac9a156"; String userId = ""; @@ -425,10 +425,10 @@ public class SsoServiceImpl implements SsoService { //2.客户Id换取第三方apiService,根据ticket换取华为Id Result apiServiceResult = operCrmOpenFeignClient.getApiServiceByCustomerId(new ApiServiceFormDTO(formDTO.getCustomerId())); if (!apiServiceResult.success()) { - throw new RenException("【SSO登录】调用OperCrm获取ApiService接口失败:", apiServiceResult.getInternalMsg()); + throw new RenException("【SSO enterOrg】调用OperCrm获取ApiService接口失败:", apiServiceResult.getInternalMsg()); } if (apiServiceResult.getData() == null || StringUtils.isBlank(apiServiceResult.getData().getApiServiceName())) { - throw new RenException("【SSO登录】调用OperCrm获取ApiService,查询到的结果为空:", apiServiceResult.toString()); + throw new RenException("【SSO enterOrg】调用OperCrm获取ApiService,查询到的结果为空:", apiServiceResult.toString()); } ThirdPlatUserInfo userInfo; try { @@ -439,7 +439,7 @@ public class SsoServiceImpl implements SsoService { } if (null == userInfo){ throw new RenException(EpmetErrorCode.THIRD_PLAT_REQUEST_ERROR.getCode(), - "【SSO登录】调用第三方平台查询用户信息失败,用户信息为空"); + "【SSO enterOrg】调用第三方平台查询用户信息失败,用户信息为空"); } //3、记录staff_wechat,并记录用户激活状态,激活时间 From bf2e8786dca09eb69ab4acf86b497dd3857603a0 Mon Sep 17 00:00:00 2001 From: wxz Date: Fri, 26 Feb 2021 15:48:52 +0800 Subject: [PATCH 06/38] =?UTF-8?q?=E3=80=90sso=E7=99=BB=E5=BD=95=E3=80=91?= =?UTF-8?q?=E4=BF=AE=E6=94=B9third=E6=9C=8D=E5=8A=A1=E7=9A=84=E5=9C=B0?= =?UTF-8?q?=E5=9D=80=E7=9A=84=E5=86=99=E6=B3=95=EF=BC=8C=E7=94=B1=E7=A1=AC?= =?UTF-8?q?=E7=BC=96=E7=A0=81=E6=94=B9=E4=B8=BA=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- epmet-auth/pom.xml | 8 ++++++++ .../main/java/com/epmet/service/impl/SsoServiceImpl.java | 6 +++++- epmet-auth/src/main/resources/bootstrap.yml | 7 ++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/epmet-auth/pom.xml b/epmet-auth/pom.xml index 74e4e92ab9..eaa22e7557 100644 --- a/epmet-auth/pom.xml +++ b/epmet-auth/pom.xml @@ -207,6 +207,8 @@ http://101.206.141.219:21006 xSMONWwP UUCnxLyXiB4eBF4p + + https://epmet-cloud.elinkservice.cn @@ -260,6 +262,8 @@ http://101.206.141.219:21006 xSMONWwP UUCnxLyXiB4eBF4p + + https://epmet-cloud.elinkservice.cn @@ -308,6 +312,8 @@ http://101.206.141.219:21006 xSMONWwP UUCnxLyXiB4eBF4p + + https://epmet-cloud.elinkservice.cn @@ -356,6 +362,8 @@ https://jcytc.lzjczl.com:21009 2cy0a9lA 6hU3PQgxLcXr27SE + + https://epmet-cloud.elinkservice.cn diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java index bfee9177ba..fa58ce86fa 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java @@ -26,6 +26,7 @@ import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -66,6 +67,9 @@ public class SsoServiceImpl implements SsoService { @Autowired private CpUserDetailRedis cpUserDetailRedis; + @Value("${epmet.third.urlPrefix}") + private String epmetThirdUrlPrefix; + /** * @Description 0、入口:得到token * @Param formDTO @@ -174,7 +178,7 @@ public class SsoServiceImpl implements SsoService { */ public String getCustomerId(String appId){ JSONObject jsonObject = new JSONObject(); - String customerMsgUrl = "https://epmet-cloud.elinkservice.cn/api/third/customermp/getcustomermsg/"; + String customerMsgUrl = epmetThirdUrlPrefix + "/api/third/customermp/getcustomermsg/"; String data = HttpClientManager.getInstance().sendPostByJSON(customerMsgUrl + appId, JSON.toJSONString(jsonObject)).getData(); log.info("调用third服务,根据appId查询客户信息:httpclient->url:" + customerMsgUrl + ",结果->" + data); JSONObject toResult = JSON.parseObject(data); diff --git a/epmet-auth/src/main/resources/bootstrap.yml b/epmet-auth/src/main/resources/bootstrap.yml index 35d3f0e1f7..02f3a33105 100644 --- a/epmet-auth/src/main/resources/bootstrap.yml +++ b/epmet-auth/src/main/resources/bootstrap.yml @@ -142,4 +142,9 @@ thirdplat: jcetGend: domain: @thirdplat.jcet.g.domain@ appkey: @thirdplat.jcet.g.appkey@ - appsecret: @thirdplat.jcet.g.appsecret@ \ No newline at end of file + appsecret: @thirdplat.jcet.g.appsecret@ + +epmet: +# third服务的相关配置 + third: + urlPrefix: @epmet.third.urlprefix@ \ No newline at end of file From 1082d4127f538201470a9cc839b51eb4582cc130 Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Wed, 3 Mar 2021 10:38:07 +0800 Subject: [PATCH 07/38] =?UTF-8?q?h5=E5=B7=A5=E4=BD=9C=E7=AB=AF=E7=99=BB?= =?UTF-8?q?=E9=99=86=E8=B0=83=E6=95=B4token=E7=BC=93=E5=AD=98=E5=AD=98?= =?UTF-8?q?=E5=82=A8=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/epmet/service/impl/SsoServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java index fa58ce86fa..aba56b4a49 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java @@ -303,7 +303,7 @@ public class SsoServiceImpl implements SsoService { int expire = jwtTokenProperties.getExpire(); GovTokenDto govTokenDto = new GovTokenDto(); govTokenDto.setApp(LoginConstant.APP_GOV); - govTokenDto.setClient(LoginConstant.CLIENT_WXMP); + govTokenDto.setClient(LoginConstant.CLIENT_APP); govTokenDto.setUserId(staffLatestAgency.getStaffId()); govTokenDto.setOpenId(userInfo.getOpenId()); govTokenDto.setSessionKey(""); From a516d6c965ddebc90106dbd39718995c5975d6d7 Mon Sep 17 00:00:00 2001 From: jianjun Date: Mon, 8 Mar 2021 14:46:38 +0800 Subject: [PATCH 08/38] =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=8F=90=E9=86=92?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20=E8=AF=B7=E6=B1=82=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E5=8F=8A=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/logback-spring.xml | 2 +- .../tools/aspect/BaseRequestLogAspect.java | 3 + .../tools/constant/ThreadLocalConstant.java | 7 +- .../tools/filter/LogMsgSendFilter.java | 130 ++++-------------- 4 files changed, 39 insertions(+), 103 deletions(-) diff --git a/epmet-auth/src/main/resources/logback-spring.xml b/epmet-auth/src/main/resources/logback-spring.xml index 734c4114a1..0152e72505 100644 --- a/epmet-auth/src/main/resources/logback-spring.xml +++ b/epmet-auth/src/main/resources/logback-spring.xml @@ -139,7 +139,7 @@ - + diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/BaseRequestLogAspect.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/BaseRequestLogAspect.java index ff877a04be..02c3d8f18a 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/BaseRequestLogAspect.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/BaseRequestLogAspect.java @@ -1,6 +1,8 @@ package com.epmet.commons.tools.aspect; +import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.constant.AppClientConstant; +import com.epmet.commons.tools.constant.ThreadLocalConstant; import com.epmet.commons.tools.exception.*; import com.epmet.commons.tools.utils.Result; import org.apache.commons.lang3.StringUtils; @@ -61,6 +63,7 @@ public abstract class BaseRequestLogAspect { try { Object[] args = point.getArgs(); + ThreadLocalConstant.requestParam.set(JSON.toJSONString(args)); log.info(">>>>>>>>请求信息>>>>>>>>:事务流水号:{},url:{} ,method:{},请求参数:{}", transactionSerial, requestURI, method, objectsToString(args)); result = point.proceed(); resultInfoLog(transactionSerial, getExecPeriod(startTime), result); 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 2dad0d6dba..6a2b304cfa 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/ThreadLocalConstant.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/ThreadLocalConstant.java @@ -1,7 +1,5 @@ package com.epmet.commons.tools.constant; -import com.epmet.commons.tools.dto.form.LoginUserInfoResultDTO; - /** * ThreadLocal常亮 */ @@ -16,4 +14,9 @@ public class ThreadLocalConstant { * 用于向DataFilterInterceptor传递权限过滤的sql片段(需要在Controller相关的AOP中进行清理,防止变量残留) */ public static final ThreadLocal sqlFilter = new ThreadLocal(); + + /** + * 用于本次的获取请求参数 + */ + public static final ThreadLocal requestParam = new ThreadLocal(); } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java index 4e2f0d16ab..df8121e059 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java @@ -6,6 +6,7 @@ import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.classic.spi.IThrowableProxy; import ch.qos.logback.classic.spi.StackTraceElementProxy; import ch.qos.logback.core.spi.FilterReply; +import com.epmet.commons.tools.constant.ThreadLocalConstant; import com.epmet.commons.tools.dto.form.DingTalkTextMsg; import com.epmet.commons.tools.enums.EnvEnum; import com.epmet.commons.tools.utils.DingdingMsgSender; @@ -15,9 +16,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.cloud.commons.util.InetUtils; import org.springframework.core.env.Environment; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import javax.servlet.http.HttpServletRequest; import java.text.SimpleDateFormat; -import java.util.Arrays; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -64,14 +68,26 @@ public class LogMsgSendFilter extends LevelFilter { stringBuilder.append("IP地址:" + serverIp); stringBuilder.append("\n"); } + stringBuilder.append("故障时间:" + formatLongTime2Str(event.getTimeStamp())); stringBuilder.append("\n"); stringBuilder.append("TraceId:" + Thread.currentThread().getName()); stringBuilder.append("\n"); + + HttpServletRequest request = getRequest(); + if (request != null) { + String requestURI = request.getRequestURI(); + stringBuilder.append("请求路径:" + requestURI); + stringBuilder.append("\n"); + + stringBuilder.append("请求参数:" + ThreadLocalConstant.requestParam.get()); + stringBuilder.append("\n"); + } + String formattedMessage = event.getFormattedMessage(); IThrowableProxy throwableProxy = event.getThrowableProxy(); if (throwableProxy == null && formattedMessage.length() > 1000) { - formattedMessage = formattedMessage.substring(0, getCharacterPosition(formattedMessage, baseProjectPackage, 5)); + formattedMessage = formattedMessage.substring(0, getCharacterPosition(formattedMessage, baseProjectPackage, 5)); } stringBuilder.append("告警信息:" + formattedMessage); stringBuilder.append("\n"); @@ -159,105 +175,19 @@ public class LogMsgSendFilter extends LevelFilter { } } - public static void main(String[] args) { - String msg = "<<<<<<<<异常响应<<<<<<<<:事务流水号:na1597027822634, 执行时长:59ms, 响应数据:{\"code\":8102,\"internalMsg\":\"验证码错误\",\"msg\":\"验证码错误\"}, 异常信息:验证码错误, 堆栈信息:com.epmet.commons.tools.exception.RenException: \n" + - " at com.epmet.service.impl.VolunteerInfoServiceImpl.authenticate(VolunteerInfoServiceImpl.java:91)\n" + - " at com.epmet.service.impl.VolunteerInfoServiceImpl$$FastClassBySpringCGLIB$$7babb2e8.invoke()\n" + - " at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)\n" + - " at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:750)\n" + - " at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)\n" + - " at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:295)\n" + - " at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)\n" + - " at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)\n" + - " at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689)\n" + - " at com.epmet.service.impl.VolunteerInfoServiceImpl$$EnhancerBySpringCGLIB$$f78b4778.authenticate()\n" + - " at com.epmet.controller.ResiVolunteerController.authenticate(ResiVolunteerController.java:59)\n" + - " at com.epmet.controller.ResiVolunteerController$$FastClassBySpringCGLIB$$e023fb55.invoke()\n" + - " at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)\n" + - " at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:750)\n" + - " at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)\n" + - " at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:56)\n" + - " at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)\n" + - " at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:88)\n" + - " at com.epmet.commons.tools.aspect.BaseRequestLogAspect.proceed(BaseRequestLogAspect.java:66)\n" + - " at com.epmet.aspect.RequestLogAspect.proceed(RequestLogAspect.java:26)\n" + - " at sun.reflect.GeneratedMethodAccessor195.invoke(Unknown Source)\n" + - " at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n" + - " at java.lang.reflect.Method.invoke(Method.java:498)\n" + - " at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644)\n" + - " at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:633)\n" + - " at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70)\n" + - " at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)\n" + - " at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93)\n" + - " at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)\n" + - " at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689)\n" + - " at com.epmet.controller.ResiVolunteerController$$EnhancerBySpringCGLIB$$1c0751c0.authenticate()\n" + - " at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n" + - " at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n" + - " at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n" + - " at java.lang.reflect.Method.invoke(Method.java:498)\n" + - " at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)\n" + - " at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)\n" + - " at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105)\n" + - " at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:893)\n" + - " at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:798)\n" + - " at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)\n" + - " at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)\n" + - " at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)\n" + - " at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)\n" + - " at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)\n" + - " at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)\n" + - " at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)\n" + - " at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)\n" + - " at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)\n" + - " at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n" + - " at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)\n" + - " at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n" + - " at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n" + - " at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:88)\n" + - " at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)\n" + - " at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n" + - " at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n" + - " at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)\n" + - " at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)\n" + - " at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n" + - " at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n" + - " at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)\n" + - " at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)\n" + - " at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n" + - " at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n" + - " at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:94)\n" + - " at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)\n" + - " at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n" + - " at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n" + - " at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:114)\n" + - " at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:104)\n" + - " at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)\n" + - " at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n" + - " at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n" + - " at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)\n" + - " at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)\n" + - " at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)\n" + - " at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)\n" + - " at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)\n" + - " at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)\n" + - " at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:526)\n" + - " at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)\n" + - " at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)\n" + - " at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)\n" + - " at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)\n" + - " at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:367)\n" + - " at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)\n" + - " at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:860)\n" + - " at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1591)\n" + - " at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)\n" + - " at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)\n" + - " at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)\n" + - " at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)\n" + - " at java.lang.Thread.run(Thread.java:745)"; + /** + * 获取Request对象 + * + * @return + */ + private HttpServletRequest getRequest() { + RequestAttributes ra = RequestContextHolder.getRequestAttributes(); + ServletRequestAttributes sra = (ServletRequestAttributes) ra; + if (sra == null){ + return null; + } + return sra.getRequest(); - String substring = msg.substring(0, getCharacterPosition(msg, "com.epme1t", 5)); - System.out.println(substring); } From 607e6a1e67a9d7de7ba1e72053d5f6bed9c3369f Mon Sep 17 00:00:00 2001 From: jianjun Date: Mon, 8 Mar 2021 18:17:53 +0800 Subject: [PATCH 09/38] =?UTF-8?q?=E5=89=8D=E7=AB=AF=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E5=8A=A0=E5=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/controller/GovWebController.java | 32 ++- epmet-auth/src/main/resources/bootstrap.yml | 6 + .../commons/tools/utils/RSASignature.java | 251 ++++++++++++++++++ .../scan/common/util/RSASignature.java | 152 ----------- 4 files changed, 287 insertions(+), 154 deletions(-) create mode 100644 epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/RSASignature.java delete mode 100644 epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/util/RSASignature.java 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 e096c6a65a..d0afcf3c32 100644 --- a/epmet-auth/src/main/java/com/epmet/controller/GovWebController.java +++ b/epmet-auth/src/main/java/com/epmet/controller/GovWebController.java @@ -1,19 +1,22 @@ package com.epmet.controller; +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.GovWebLoginFormDTO; import com.epmet.dto.result.UserTokenResultDTO; import com.epmet.service.GovWebService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; + /** - * @Description PC工作端-登陆服务 * @author sun + * @Description PC工作端-登陆服务 */ @RestController @RequestMapping("govweb") @@ -21,7 +24,10 @@ public class GovWebController { @Autowired private GovWebService govWebService; - + @Value("${epmet.login.publicKey}") + private String publicKey; + @Value("${epmet.login.privateKey}") + private String privateKey; /** * @param formDTO @@ -32,8 +38,30 @@ public class GovWebController { @PostMapping("login") public Result workLogin(@RequestBody GovWebLoginFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO); + + try { + if (formDTO.getPassword().length() > 50) { + String newPassword = RSASignature.decryptByPrivateKey(formDTO.getPassword(), privateKey); + formDTO.setPassword(newPassword); + } + + } catch (Exception e) { + e.printStackTrace(); + } return new Result().ok(govWebService.login(formDTO)); } + /** + * desc: 获取前端密码加密 公钥 + * + * @return com.epmet.commons.tools.utils.Result + * @author LiuJanJun + * @date 2021/3/8 5:07 下午 + */ + @PostMapping("getKey") + public Result getResiWxPhone() { + return new Result().ok(publicKey); + } + } diff --git a/epmet-auth/src/main/resources/bootstrap.yml b/epmet-auth/src/main/resources/bootstrap.yml index 25b9a31702..b2068e7118 100644 --- a/epmet-auth/src/main/resources/bootstrap.yml +++ b/epmet-auth/src/main/resources/bootstrap.yml @@ -145,3 +145,9 @@ thirdplat: appId: 7a5aec009ba4eba8e254ee64fe3775e1 appKey: 14faef9af508d1c253b720ea5a43f9de appSecret: 38e7c2604c8dd33c445705d25eebbfc12a2f7ed8a87111e9e10a40312d3a1595 + +epmet: + login: + publicKey: MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKjgDaHWqWgquoatbC4zzQCgqE8C425VIOyzJVVgH1HUYCHpuNUnGCv3HBAl2RsziWQqQgd1xxl0C3a5J4J69o8CAwEAAQ== + privateKey: MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEAqOANodapaCq6hq1sLjPNAKCoTwLjblUg7LMlVWAfUdRgIem41ScYK/ccECXZGzOJZCpCB3XHGXQLdrkngnr2jwIDAQABAkAyYaWvgrtHuHetdk+v+QRQC54q9FGluP/5nfilX+f4IUf8j92o/ZohTtmJn9qcDiAP4wxCLIsfy4IW3psST78BAiEA0A/E0WvtI7spWnjfw+wMDhdVMIbIJvDbj/cqMwRZInUCIQDPyO2sbXpwDjmAvyn0jpGJJxU5POWYdI37rTf9fScMcwIhAMkWNHbjBHKANVuHb10ACjakPmWEHnXkW5AspdBg53TxAiARPbzq99KXBbcjxbj3f/T3inSqYTEz60f0wDTLJd1dnQIhAIFe6Jd1TduIxGk1PDh/b/3q0jNGgVXkFnUBnKWDaL9N + diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/RSASignature.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/RSASignature.java new file mode 100644 index 0000000000..ac051e7093 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/RSASignature.java @@ -0,0 +1,251 @@ +package com.epmet.commons.tools.utils; + +import javax.crypto.Cipher; +import java.security.*; +import java.security.spec.PKCS8EncodedKeySpec; +import java.security.spec.X509EncodedKeySpec; +import java.util.Base64; + +/** + * @author jianjun liu + * @date 2020-06-05 16:48 + **/ + +public class RSASignature { + + + //非对称密钥算法 + private static final String KEY_ALGORITHM = "RSA"; + //密钥长度,在512到65536位之间,建议不要太长,否则速度很慢,生成的加密数据很长 + private static final int KEY_SIZE = 512; + //字符编码 + private static final String CHARSET = "UTF-8"; + + /** + * 生成密钥对 + * + * @return KeyPair 密钥对 + */ + public static KeyPair getKeyPair() throws Exception { + return getKeyPair(null); + } + + /** + * 生成密钥对 + * + * @param password 生成密钥对的密码 + * @return + * @throws Exception + */ + public static KeyPair getKeyPair(String password) throws Exception { + //实例化密钥生成器 + KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(KEY_ALGORITHM); + //初始化密钥生成器 + if (password == null) { + keyPairGenerator.initialize(KEY_SIZE); + } else { + SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG"); + secureRandom.setSeed(password.getBytes(CHARSET)); + keyPairGenerator.initialize(KEY_SIZE, secureRandom); + } + //生成密钥对 + return keyPairGenerator.generateKeyPair(); + } + + /** + * 取得私钥 + * + * @param keyPair 密钥对 + * @return byte[] 私钥 + */ + public static byte[] getPrivateKeyBytes(KeyPair keyPair) { + return keyPair.getPrivate().getEncoded(); + } + + /** + * 取得Base64编码的私钥 + * + * @param keyPair 密钥对 + * @return String Base64编码的私钥 + */ + public static String getPrivateKey(KeyPair keyPair) { + return Base64.getEncoder().encodeToString(getPrivateKeyBytes(keyPair)); + } + + /** + * 取得公钥 + * + * @param keyPair 密钥对 + * @return byte[] 公钥 + */ + public static byte[] getPublicKeyBytes(KeyPair keyPair) { + return keyPair.getPublic().getEncoded(); + } + + /** + * 取得Base64编码的公钥 + * + * @param keyPair 密钥对 + * @return String Base64编码的公钥 + */ + public static String getPublicKey(KeyPair keyPair) { + return Base64.getEncoder().encodeToString(getPublicKeyBytes(keyPair)); + } + + /** + * 私钥加密 + * + * @param data 待加密数据 + * @param privateKey 私钥字节数组 + * @return byte[] 加密数据 + */ + public static byte[] encryptByPrivateKey(byte[] data, byte[] privateKey) throws Exception { + //实例化密钥工厂 + KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM); + //生成私钥 + PrivateKey key = keyFactory.generatePrivate(new PKCS8EncodedKeySpec(privateKey)); + //数据加密 + Cipher cipher = Cipher.getInstance(KEY_ALGORITHM); + cipher.init(Cipher.ENCRYPT_MODE, key); + return cipher.doFinal(data); + } + + /** + * 私钥加密 + * + * @param data 待加密数据 + * @param privateKey Base64编码的私钥 + * @return String Base64编码的加密数据 + */ + public static String encryptByPrivateKey(String data, String privateKey) throws Exception { + byte[] key = Base64.getDecoder().decode(privateKey); + return Base64.getEncoder().encodeToString(encryptByPrivateKey(data.getBytes(CHARSET), key)); + } + + /** + * 公钥加密 + * + * @param data 待加密数据 + * @param publicKey 公钥字节数组 + * @return byte[] 加密数据 + */ + public static byte[] encryptByPublicKey(byte[] data, byte[] publicKey) throws Exception { + //实例化密钥工厂 + KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM); + //生成公钥 + PublicKey key = keyFactory.generatePublic(new X509EncodedKeySpec(publicKey)); + //数据加密 + Cipher cipher = Cipher.getInstance(KEY_ALGORITHM); + cipher.init(Cipher.ENCRYPT_MODE, key); + return cipher.doFinal(data); + } + + /** + * 公钥加密 + * + * @param data 待加密数据 + * @param publicKey Base64编码的公钥 + * @return String Base64编码的加密数据 + */ + public static String encryptByPublicKey(String data, String publicKey) throws Exception { + byte[] key = Base64.getDecoder().decode(publicKey); + return Base64.getEncoder().encodeToString(encryptByPublicKey(data.getBytes(CHARSET), key)); + } + + /** + * 私钥解密 + * + * @param data 待解密数据 + * @param privateKey 私钥字节数组 + * @return byte[] 解密数据 + */ + public static byte[] decryptByPrivateKey(byte[] data, byte[] privateKey) throws Exception { + //实例化密钥工厂 + KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM); + //生成私钥 + PrivateKey key = keyFactory.generatePrivate(new PKCS8EncodedKeySpec(privateKey)); + //数据解密 + Cipher cipher = Cipher.getInstance(KEY_ALGORITHM); + cipher.init(Cipher.DECRYPT_MODE, key); + return cipher.doFinal(data); + } + + /** + * 私钥解密 + * + * @param data Base64编码的待解密数据 + * @param privateKey Base64编码的私钥 + * @return String 解密数据 + */ + public static String decryptByPrivateKey(String data, String privateKey) throws Exception { + byte[] key = Base64.getDecoder().decode(privateKey); + return new String(decryptByPrivateKey(Base64.getDecoder().decode(data), key), CHARSET); + } + + /** + * 公钥解密 + * + * @param data 待解密数据 + * @param publicKey 公钥字节数组 + * @return byte[] 解密数据 + */ + public static byte[] decryptByPublicKey(byte[] data, byte[] publicKey) throws Exception { + //实例化密钥工厂 + KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM); + //产生公钥 + PublicKey key = keyFactory.generatePublic(new X509EncodedKeySpec(publicKey)); + //数据解密 + Cipher cipher = Cipher.getInstance(KEY_ALGORITHM); + cipher.init(Cipher.DECRYPT_MODE, key); + return cipher.doFinal(data); + } + + /** + * 公钥解密 + * + * @param data Base64编码的待解密数据 + * @param publicKey Base64编码的公钥 + * @return String 解密数据 + */ + public static String decryptByPublicKey(String data, String publicKey) throws Exception { + byte[] key = Base64.getDecoder().decode(publicKey); + return new String(decryptByPublicKey(Base64.getDecoder().decode(data), key), CHARSET); + } + + /** + * 测试加解密方法 + * + * @param args + * @throws Exception + */ + public static void main(String[] args) throws Exception { + //生成密钥对,一般生成之后可以放到配置文件中 + KeyPair keyPair = RSASignature.getKeyPair(); + //公钥 + String publicKey = RSASignature.getPublicKey(keyPair); + //私钥 + String privateKey = RSASignature.getPrivateKey(keyPair); + + System.out.println("公钥:\n" + publicKey); + System.out.println("私钥:\n" + privateKey); + + String data = "RSA 加解密测试!"; + { + System.out.println("\n===========私钥加密,公钥解密=============="); + String s1 = RSASignature.encryptByPrivateKey(data, privateKey); + System.out.println("加密后的数据:" + s1); + String s2 = RSASignature.decryptByPublicKey(s1, publicKey); + System.out.println("解密后的数据:" + s2 + "\n\n"); + } + + { + System.out.println("\n===========公钥加密,私钥解密=============="); + String s1 = RSASignature.encryptByPublicKey(data, publicKey); + System.out.println("加密后的数据:" + s1); + String s2 = RSASignature.decryptByPrivateKey(s1, privateKey); + System.out.println("解密后的数据:" + s2 + "\n\n"); + } + + } + +} diff --git a/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/util/RSASignature.java b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/util/RSASignature.java deleted file mode 100644 index c79906908d..0000000000 --- a/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/util/RSASignature.java +++ /dev/null @@ -1,152 +0,0 @@ -package com.epmet.openapi.scan.common.util; - -import org.apache.commons.codec.binary.Base64; -import org.bouncycastle.util.encoders.UrlBase64; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.crypto.Cipher; -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.security.KeyFactory; -import java.security.PrivateKey; -import java.security.PublicKey; -import java.security.Signature; -import java.security.cert.Certificate; -import java.security.cert.CertificateFactory; -import java.security.spec.PKCS8EncodedKeySpec; -import java.security.spec.X509EncodedKeySpec; - -/** - * @author jianjun liu - * @date 2020-06-05 16:48 - **/ - -public class RSASignature { - private static final Logger LOGGER = LoggerFactory.getLogger(RSASignature.class); - public static final String KEY_ALGORITHM = "RSA"; - public static final String SIGNATURE_ALGORITHM = "SHA1WithRSA"; - public static final String ENCODING = "utf-8"; - public static final String X509 = "X.509"; - - /** - * 获取私钥 - * - * @param key - * @return - * @throws Exception - */ - public static PrivateKey getPrivateKey(String key) throws Exception { - byte[] keyBytes = Base64.decodeBase64(key.getBytes(ENCODING)); - PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(keyBytes); - KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM); - PrivateKey privateKey = keyFactory.generatePrivate(keySpec); - return privateKey; - } - - /** - * 获取公钥 - * - * @param key - * @return - * @throws Exception - */ - public static PublicKey getPublicKey(String key) throws Exception { - byte[] keyBytes = Base64.decodeBase64(key.getBytes(ENCODING)); - CertificateFactory certificateFactory = CertificateFactory.getInstance(X509); - InputStream in = new ByteArrayInputStream(keyBytes); - Certificate certificate = certificateFactory.generateCertificate(in); - PublicKey publicKey = certificate.getPublicKey(); - return publicKey; - } - - /** - * 使用公钥对明文进行加密,返回BASE64编码的字符串 - * - * @param publicKey - * @param plainText - * @return - */ - public static String encrypt(String publicKey, String plainText) { - try { - KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM); - byte[] encodedKey = Base64.decodeBase64(publicKey.getBytes(ENCODING)); - PublicKey pubKey = keyFactory.generatePublic(new X509EncodedKeySpec(encodedKey)); - Cipher cipher = Cipher.getInstance(KEY_ALGORITHM); - cipher.init(Cipher.ENCRYPT_MODE, pubKey); - byte[] enBytes = cipher.doFinal(plainText.getBytes()); - return new String(Base64.encodeBase64(enBytes)); - } catch (Exception e) { - LOGGER.error("rsa encrypt exception: {}", e.getMessage(), e); - } - return null; - } - - /** - * 使用私钥对明文密文进行解密 - * - * @param privateKey - * @param enStr - * @return - */ - public static String decrypt(String privateKey, String enStr) { - try { - PrivateKey priKey = getPrivateKey(privateKey); - Cipher cipher = Cipher.getInstance(KEY_ALGORITHM); - cipher.init(Cipher.DECRYPT_MODE, priKey); - byte[] deBytes = cipher.doFinal(Base64.decodeBase64(enStr)); - return new String(deBytes); - } catch (Exception e) { - LOGGER.error("rsa decrypt exception: {}", e.getMessage(), e); - } - return null; - } - - /** - * RSA私钥签名 - * - * @param content 待签名数据 - * @param privateKey 私钥 - * @return 签名值 - */ - public static String signByPrivateKey(String content, String privateKey) { - try { - PrivateKey priKey = getPrivateKey(privateKey); - Signature signature = Signature.getInstance(SIGNATURE_ALGORITHM); - signature.initSign(priKey); - signature.update(content.getBytes(ENCODING)); - byte[] signed = signature.sign(); - return new String(UrlBase64.encode(signed), ENCODING); - } catch (Exception e) { - LOGGER.error("sign error, content: {}", content, e); - } - return null; - } - - /** - * 公钥验签 - * - * @param content - * @param sign - * @param publicKey - * @return - */ - public static boolean verifySignByPublicKey(String content, String sign, String publicKey) { - try { - KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM); - byte[] encodedKey = Base64.decodeBase64(publicKey.getBytes(ENCODING)); - PublicKey pubKey = keyFactory.generatePublic(new X509EncodedKeySpec(encodedKey)); - - Signature signature = Signature.getInstance(SIGNATURE_ALGORITHM); - signature.initVerify(pubKey); - signature.update(content.getBytes(ENCODING)); - - return signature.verify(UrlBase64.decode(sign.getBytes(ENCODING))); - - } catch (Exception e) { - LOGGER.error("verify sign error, content: {}, sign: {}", content, sign, e); - } - return false; - } - -} From d086ecef931fe921b0ef1ea47d0718aa8672c3ac Mon Sep 17 00:00:00 2001 From: wxz Date: Tue, 9 Mar 2021 10:30:41 +0800 Subject: [PATCH 10/38] =?UTF-8?q?=E8=A7=A3=E5=86=B3sso=E7=AC=AC=E4=B8=89?= =?UTF-8?q?=E6=96=B9=E5=B9=B3=E5=8F=B0=E5=90=88=E5=B9=B6=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/epmet/service/impl/SsoServiceImpl.java | 2 +- .../commons/thirdplat/apiservice/jcet/JcetApiService.java | 3 ++- .../commons/thirdplat/apiservice/pyld/PyldApiService.java | 7 ++++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java index 860719988d..3f77b56af1 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java @@ -144,7 +144,7 @@ public class SsoServiceImpl implements SsoService { ThirdPlatformEnum platformEnum = ThirdPlatformEnum.getEnum(formDTO.getPlatform()); String apiService = platformEnum.getApiService(); AbstractApiService apiServiceImpl = (AbstractApiService) SpringContextUtils.getBean(apiService); - thirdUser = apiServiceImpl.getUserInfoByTicket(formDTO.getThirdToken()); + thirdUser = apiServiceImpl.getGUserInfoBySSOToken(formDTO.getThirdToken()); } catch (RenException e) { throw new RenException(e.getCode(), e.getMessage()); } catch (Exception e) { diff --git a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/jcet/JcetApiService.java b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/jcet/JcetApiService.java index e12d008941..f499156947 100644 --- a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/jcet/JcetApiService.java +++ b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/jcet/JcetApiService.java @@ -14,6 +14,7 @@ import com.epmet.commons.tools.utils.HttpClientManager; import com.epmet.commons.tools.utils.Result; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; import java.io.UnsupportedEncodingException; import java.util.HashMap; @@ -38,7 +39,7 @@ public class JcetApiService extends AbstractApiService { * @author wxz * @date 2021.01.19 10:26 */ - public ThirdPlatUserInfo getUserInfoByTicket(String ticket) throws UnsupportedEncodingException { + public ThirdPlatUserInfo getCUserInfoByTicket(String ticket) throws UnsupportedEncodingException { logger.info("【请求酒城e通第三方平台】getUserInfoByTicket()接口开始>>>>>>>>>>>>"); logger.info("【请求酒城e通第三方平台】getUserInfoByTicket()接口入参 ticket:{}", ticket); diff --git a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/pyld/PyldApiService.java b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/pyld/PyldApiService.java index 958fd8b1bb..b5307c2951 100644 --- a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/pyld/PyldApiService.java +++ b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/pyld/PyldApiService.java @@ -40,6 +40,11 @@ public class PyldApiService extends AbstractApiService { pyldThirdplatProps = props.getPyld(); } + @Override + public ThirdPlatUserInfo getCUserInfoByTicket(String ticket) throws Exception { + return null; + } + /** * @return * @Description 通过第三方平台ticket获取用户信息 @@ -47,7 +52,7 @@ public class PyldApiService extends AbstractApiService { * @date 2021.01.19 10:26 */ @Override - public ThirdPlatUserInfo getUserInfoByTicket(String platformToken) { + public ThirdPlatUserInfo getGUserInfoBySSOToken(String platformToken) { logger.info("【请求平阴联动指挥平台第三方平台】getUserInfoByTicket()接口开始>>>>>>>>>>>>"); logger.info("【请求平阴联动指挥平台第三方平台】getUserInfoByTicket()接口入参 platformToken:{}", platformToken); From 3b9297b7482a00c75f4eacc95c8e1b56d0166dd9 Mon Sep 17 00:00:00 2001 From: jianjun Date: Tue, 9 Mar 2021 11:03:35 +0800 Subject: [PATCH 11/38] =?UTF-8?q?=E9=80=9A=E7=9F=A5=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApplicationFailedEventListener.java | 84 +++++++++++++++++++ ...ava => ApplicationReadyEventListener.java} | 13 ++- 2 files changed, 90 insertions(+), 7 deletions(-) create mode 100644 epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/ApplicationFailedEventListener.java rename epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/{CustomerApplicationRunner.java => ApplicationReadyEventListener.java} (90%) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/ApplicationFailedEventListener.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/ApplicationFailedEventListener.java new file mode 100644 index 0000000000..5c219ab095 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/ApplicationFailedEventListener.java @@ -0,0 +1,84 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + *

+ * https://www.renren.io + *

+ * 版权所有,侵权必究! + */ + +package com.epmet.commons.tools.aspect; + +import com.alibaba.fastjson.JSON; +import com.dingtalk.api.DefaultDingTalkClient; +import com.dingtalk.api.DingTalkClient; +import com.dingtalk.api.request.OapiRobotSendRequest; +import com.dingtalk.api.response.OapiRobotSendResponse; +import com.epmet.commons.tools.enums.EnvEnum; +import com.epmet.commons.tools.utils.SpringContextUtils; +import com.taobao.api.ApiException; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.event.ApplicationFailedEvent; +import org.springframework.cloud.commons.util.InetUtils; +import org.springframework.context.ApplicationListener; +import org.springframework.stereotype.Component; + +/** + * 应用 启动健康检查 通知类 + * CustomerApplicationRunner + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Component +public class ApplicationFailedEventListener implements ApplicationListener { + private static Logger logger = LogManager.getLogger(ApplicationFailedEventListener.class); + @Value("${spring.application.name}") + private String appName; + @Value("${server.version}") + private String version; + + @Override + public void onApplicationEvent(ApplicationFailedEvent applicationFailedEvent) { + Throwable exception = applicationFailedEvent.getException(); + EnvEnum currentEnv = EnvEnum.getCurrentEnv(); + logger.info(currentEnv); + if (!EnvEnum.DEV.getCode().equals(currentEnv.getCode()) && !EnvEnum.LOCAL.getCode().equals(currentEnv.getCode())) { + sendDingMarkDownMsg(exception); + } + } + + + private String getServerIp() { + InetUtils inetUtils = SpringContextUtils.getBean(InetUtils.class); + return inetUtils.findFirstNonLoopbackHostInfo().getIpAddress(); + } + + private void sendDingMarkDownMsg(Throwable exception) { + DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/robot/send?access_token=ffd7c972b0525e249283df1a16b65a8b9d0012601f3a458dfc588c2eac497bb5"); + OapiRobotSendRequest request = new OapiRobotSendRequest(); + request.setMsgtype("markdown"); + OapiRobotSendRequest.Markdown markdown = new OapiRobotSendRequest.Markdown(); + markdown.setTitle("部署失败通知"); + + markdown.setText("部署失败通知 \n" + + "> 服务:" + appName + "\n\n" + + "> 版本:" + version + "\n\n" + + "> 环境:" + EnvEnum.getCurrentEnv().getName() + "\n\n" + + "> IP: " + getServerIp() + "\n\n" + + "> 异常:" + exception.getMessage() + "\n\n" + ); + request.setMarkdown(markdown); + OapiRobotSendRequest.At at = new OapiRobotSendRequest.At(); + at.setIsAtAll(true); + request.setAt(at); + try { + OapiRobotSendResponse execute = client.execute(request); + logger.info("=====通知结果===>" + JSON.toJSONString(execute)); + } catch (ApiException e) { + logger.error("sendDingMarkDownMsg exception", e); + } + } + +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/CustomerApplicationRunner.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/ApplicationReadyEventListener.java similarity index 90% rename from epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/CustomerApplicationRunner.java rename to epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/ApplicationReadyEventListener.java index 4537414335..901163e7ac 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/CustomerApplicationRunner.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/ApplicationReadyEventListener.java @@ -22,10 +22,9 @@ import com.taobao.api.ApiException; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.ApplicationArguments; -import org.springframework.boot.ApplicationRunner; +import org.springframework.boot.context.event.ApplicationReadyEvent; import org.springframework.cloud.commons.util.InetUtils; -import org.springframework.core.annotation.Order; +import org.springframework.context.ApplicationListener; import org.springframework.stereotype.Component; /** @@ -36,16 +35,15 @@ import org.springframework.stereotype.Component; * @since 1.0.0 */ @Component -@Order(value = 99) -public class CustomerApplicationRunner implements ApplicationRunner { - private static Logger logger = LogManager.getLogger(CustomerApplicationRunner.class); +public class ApplicationReadyEventListener implements ApplicationListener { + private static Logger logger = LogManager.getLogger(ApplicationReadyEventListener.class); @Value("${spring.application.name}") private String appName; @Value("${server.version}") private String version; @Override - public void run(ApplicationArguments args) { + public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) { EnvEnum currentEnv = EnvEnum.getCurrentEnv(); logger.info(currentEnv); if (!EnvEnum.DEV.getCode().equals(currentEnv.getCode()) && !EnvEnum.LOCAL.getCode().equals(currentEnv.getCode())) { @@ -107,4 +105,5 @@ public class CustomerApplicationRunner implements ApplicationRunner { } } + } From df3fe4cbaa0e5d83c5df80c37dd3a6c5b42cd721 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Tue, 9 Mar 2021 12:53:22 +0800 Subject: [PATCH 12/38] =?UTF-8?q?=E5=B9=B3=E9=98=B4=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=8A=BD=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../indexcal/AgencyScoreDao.java | 2 + .../indexcal/DeptScoreDao.java | 1 + .../screen/ScreenCustomerAgencyDao.java | 8 +++ .../IndexCalculateDistrictServiceImpl.java | 19 ++++--- .../indexcal/AgencyScoreDao.xml | 50 ++++++++++++++++++- .../evaluationindex/indexcal/DeptScoreDao.xml | 21 ++++++++ .../FactIndexPartyAblityOrgMonthlyDao.xml | 3 +- .../screen/ScreenCustomerAgencyDao.xml | 14 ++++++ 8 files changed, 109 insertions(+), 9 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencyScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencyScoreDao.java index 5e0d0585be..bc00d9e97b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencyScoreDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencyScoreDao.java @@ -71,6 +71,7 @@ public interface AgencyScoreDao extends BaseDao { * @date 2021/1/15 下午4:23 */ List selectAgencyScoreInfoExistsSub(@Param("areaCode") String areaCode,@Param("areaCodeLength") Integer areaCodeLength, @Param("monthId")String monthId, @Param("dataType")String dataType); + List selectAgencyScoreInfoExistsSubSelf(@Param("areaCode") String areaCode, @Param("monthId")String monthId, @Param("dataType")String dataType); /** * @Description 区下级街道得分平均值 @@ -91,6 +92,7 @@ public interface AgencyScoreDao extends BaseDao { * @date 2021/1/18 上午9:09 */ List selectAgencyScoreAvgExistsSub(@Param("monthId")String monthId, @Param("indexCode")String indexCode,@Param("dataType")String dataType,@Param("areaCode")String areaCode,@Param("areaCodeLength")Integer areaCodeLength); + List selectAgencyScoreAvgByOrgIds(@Param("monthId")String monthId, @Param("indexCode")String indexCode,@Param("orgIds")List orgIds); /** diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/DeptScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/DeptScoreDao.java index a22317c371..cc35dbb875 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/DeptScoreDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/DeptScoreDao.java @@ -77,6 +77,7 @@ public interface DeptScoreDao extends BaseDao { * @date 2021/1/18 上午9:31 */ List selectGovernDeptScoreAvgExistsSub(@Param("areaCode")String areaCode, @Param("monthId")String monthId, @Param("indexCode")String indexCode); + List selectGovernDeptScoreAvgExistsSubNotSelf(@Param("areaCode")String areaCode, @Param("monthId")String monthId, @Param("indexCode")String indexCode); /** * @return int diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java index f61e21f2ad..44eeb11fa6 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java @@ -194,4 +194,12 @@ public interface ScreenCustomerAgencyDao extends BaseDao selectAgencyByCustomer(@Param("customerId")String customerId); List selectAgencyByAreaCode(String areaCode); + + /** + * @Description 根据areaCode查询下级组织 + * @Param areaCode + * @author zxc + * @date 2021/3/9 上午9:41 + */ + List selectAgencyByParentAreaCode(@Param("areaCode") String areaCode); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateDistrictServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateDistrictServiceImpl.java index 592c114fd4..5ea39f0d4c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateDistrictServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateDistrictServiceImpl.java @@ -23,6 +23,7 @@ import com.epmet.dto.indexcal.AgencyCalResultDTO; import com.epmet.dto.indexcal.AgencyScoreDTO; import com.epmet.dto.indexcal.CalculateCommonFormDTO; import com.epmet.dto.indexcal.SubAgencyScoreAvgResultDTO; +import com.epmet.dto.screen.ScreenProjectOrgDailyDTO; import com.epmet.dto.screen.result.MaxAndMinBigDecimalResultDTO; import com.epmet.entity.evaluationindex.indexcal.AgencySelfSubScoreEntity; import com.epmet.entity.evaluationindex.indexcal.AgencySubScoreEntity; @@ -604,10 +605,11 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict } List indexInputVOS = new ArrayList<>(); Map pid = new HashMap<>(); + List orgInfos = customerAgencyDao.selectAgencyByParentAreaCode(form.getCustomerAreaCode()); //党建能力平均值 indexDetailList.forEach(detail -> { if (IndexCodeEnum.QU_XIA_JI_JIE_DDJNLHZPJZ.getCode().equals(detail.getIndexCode())) { - List subGridPartyAvgScore = agencyScoreDao.selectAgencyScoreAvgExistsSub(monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),IndexCalConstant.STREET_LEVEL,form.getCustomerAreaCode(),NumConstant.SIX); + List subGridPartyAvgScore = agencyScoreDao.selectAgencyScoreAvgByOrgIds(monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),orgInfos.stream().map(o -> o.getOrgId()).collect(Collectors.toList())); if (CollectionUtils.isEmpty(subGridPartyAvgScore)) { log.warn(IndexCalConstant.DISTRICT_PARTY_AVG_NULL); } else if (subGridPartyAvgScore.size() > NumConstant.ZERO) { @@ -629,7 +631,7 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict } } else { // 区名义发文数量 - List> publishArticleCountList = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCountMapExistSub(monthId,form.getCustomerAreaCode(),NumConstant.SIX); + List> publishArticleCountList = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCountMapExistSubNotSelf(monthId,form.getCustomerAreaCode(),NumConstant.SIX); if (CollectionUtils.isEmpty(publishArticleCountList)) { log.warn(IndexCalConstant.DISTRICT_PUBLISH_ARTICLE_LIST_NULL); } else { @@ -682,9 +684,12 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict } List indexInputVOS = new ArrayList<>(); Map pid = new HashMap<>(); + List orgInfos = customerAgencyDao.selectAgencyByParentAreaCode(form.getCustomerAreaCode()); detailListByParentCode.forEach(detail -> { if (IndexCodeEnum.SUO_YOU_JIE_DAO_ZLNLPJZ.getCode().equals(detail.getIndexCode())) { - List districtGovernAvgList = agencyScoreDao.selectAgencyScoreAvgExistsSub(monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),IndexCalConstant.STREET_LEVEL,form.getCustomerAreaCode(),NumConstant.SIX); +// List districtGovernAvgList = agencyScoreDao.selectAgencyScoreAvgExistsSub(monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),IndexCalConstant.STREET_LEVEL,form.getCustomerAreaCode(),NumConstant.SIX); + List districtGovernAvgList = agencyScoreDao.selectAgencyScoreAvgByOrgIds(monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),orgInfos.stream().map(m -> m.getOrgId()).collect(Collectors.toList())); + log.info(districtGovernAvgList.toString()); for (int i = 0; i < districtGovernAvgList.size(); i++) { if (districtGovernAvgList.get(i).getAgencyId().equals(NumConstant.ZERO_STR)){ districtGovernAvgList.remove(districtGovernAvgList.get(i)); @@ -710,7 +715,7 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict }); } } else if (IndexCodeEnum.SUO_YOU_ZHI_SHU_BMZLNLPJZ.getCode().equals(detail.getIndexCode())){ - List deptScoreAvgList = deptScoreDao.selectGovernDeptScoreAvgExistsSub(monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),form.getCustomerAreaCode()); + List deptScoreAvgList = deptScoreDao.selectGovernDeptScoreAvgExistsSubNotSelf(monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),form.getCustomerAreaCode()); for (int i = 0; i < deptScoreAvgList.size(); i++) { if (deptScoreAvgList.get(i).getAgencyId().equals(NumConstant.ZERO_STR)){ deptScoreAvgList.remove(deptScoreAvgList.get(i)); @@ -762,10 +767,12 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict } List indexInputVOS = new ArrayList<>(); Map pid = new HashMap<>(); + List orgInfos = customerAgencyDao.selectAgencyByParentAreaCode(form.getCustomerAreaCode()); detailListByParentCode.forEach(detail -> { String indexCode = detail.getIndexCode(); if (IndexCodeEnum.QU_XIA_SHU_JIE_DFWNLHZPJZ.getCode().equals(indexCode)) { - List subStreetAvgList = agencyScoreDao.selectAgencyScoreAvgExistsSub(monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode(),IndexCalConstant.STREET_LEVEL,form.getCustomerAreaCode(),NumConstant.SIX); +// List subStreetAvgList = agencyScoreDao.selectAgencyScoreAvgExistsSub(monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode(),IndexCalConstant.STREET_LEVEL,form.getCustomerAreaCode(),NumConstant.SIX); + List subStreetAvgList = agencyScoreDao.selectAgencyScoreAvgByOrgIds(monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode(),orgInfos.stream().map(m -> m.getOrgId()).collect(Collectors.toList())); for (int i = 0; i < subStreetAvgList.size(); i++) { if (subStreetAvgList.get(i).getAgencyId().equals(NumConstant.ZERO_STR)){ subStreetAvgList.remove(subStreetAvgList.get(i)); @@ -815,7 +822,7 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict String customerId = form.getCustomerId(); String monthId = form.getMonthId(); List detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode()); - List agencyScoreList = agencyScoreDao.selectAgencyScoreInfoExistsSub(form.getCustomerAreaCode(),NumConstant.SIX,monthId, IndexCalConstant.DISTRICT_LEVEL); + List agencyScoreList = agencyScoreDao.selectAgencyScoreInfoExistsSubSelf(form.getCustomerAreaCode(),monthId, IndexCalConstant.DISTRICT_LEVEL); detailListByParentCode.forEach(detail -> { agencyScoreList.forEach(community -> { if (detail.getIndexCode().equals(community.getIndexCode())) { diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml index 6ba1ac05cf..c082758802 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml @@ -142,6 +142,7 @@ WHERE fias.del_flag = 0 AND sca.AREA_CODE LIKE CONCAT(#{areaCode},'%') + AND sca.AREA_CODE != #{areaCode} AND fias.MONTH_ID = #{monthId} AND fias.data_type = #{dataType} AND fias.IS_TOTAL = "0" @@ -159,7 +160,7 @@ fics.year_id, ROUND(AVG( fics.score ),6) AS score, fics.customer_id, - PARENT_AGENCY_ID AS parentId + fics.PARENT_AGENCY_ID AS parentId FROM fact_index_agency_score fics LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = fics.PARENT_AGENCY_ID @@ -172,4 +173,51 @@ AND fics.DATA_TYPE = #{dataType} GROUP BY fics.parent_agency_id + + + + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/DeptScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/DeptScoreDao.xml index d5f2e9b8a0..f0dc795c8e 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/DeptScoreDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/DeptScoreDao.xml @@ -172,4 +172,25 @@ AND fidc.index_code = #{indexCode} GROUP BY fidc.agency_id + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml index 9ce69d1128..c0f9e6e261 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml @@ -163,8 +163,7 @@ LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = pm.AGENCY_ID WHERE pm.del_flag = '0' - AND sca.AREA_CODE LIKE CONCAT(#{areaCode},'%') - AND sca.AREA_CODE != #{areaCode} + AND sca.AREA_CODE = #{areaCode} AND pm.month_id = #{monthId} + + + From 797011a8ef7b8b9c00ed649b3d5deb3f7ad2d797 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Tue, 9 Mar 2021 13:25:11 +0800 Subject: [PATCH 13/38] =?UTF-8?q?sql=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml index 9c3497f29e..5552a9df4b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml @@ -402,6 +402,6 @@ sca.AREA_CODE FROM screen_customer_agency sca WHERE DEL_FLAG = 0 - and sca.PARENT_AREA_CODE like #{areaCode} + and sca.PARENT_AREA_CODE = #{areaCode} From b89490cf08e0fc41192d52b01503f5f9aedc8155 Mon Sep 17 00:00:00 2001 From: jianjun Date: Tue, 9 Mar 2021 13:33:49 +0800 Subject: [PATCH 14/38] test --- .../java/com/epmet/commons/tools/filter/LogMsgSendFilter.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java index 4e2f0d16ab..79d0b59f6e 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java @@ -17,7 +17,6 @@ import org.springframework.cloud.commons.util.InetUtils; import org.springframework.core.env.Environment; import java.text.SimpleDateFormat; -import java.util.Arrays; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -274,7 +273,7 @@ public class LogMsgSendFilter extends LevelFilter { } return slashMatcher.start(); } catch (Exception e) { - logger.warn("getCharacterPosition no matche"); + logger.warn("getCharacterPosition no matche", e); return 0; } } From bd23c5c5ded97aa5f817634f43a7dd92ffdc3ccc Mon Sep 17 00:00:00 2001 From: jianjun Date: Tue, 9 Mar 2021 13:43:56 +0800 Subject: [PATCH 15/38] test --- .../com/epmet/controller/LoginController.java | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/epmet-auth/src/main/java/com/epmet/controller/LoginController.java b/epmet-auth/src/main/java/com/epmet/controller/LoginController.java index 45c8950d9c..f70495eb51 100644 --- a/epmet-auth/src/main/java/com/epmet/controller/LoginController.java +++ b/epmet-auth/src/main/java/com/epmet/controller/LoginController.java @@ -12,6 +12,7 @@ import com.epmet.dto.form.ResiWxPhoneFormDTO; import com.epmet.dto.result.UserTokenResultDTO; import com.epmet.service.CaptchaService; import com.epmet.service.LoginService; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -28,6 +29,7 @@ import java.io.IOException; * @Author yinzuomei * @Date 2020/3/14 13:58 */ +@Slf4j @RestController @RequestMapping("login") public class LoginController { @@ -47,15 +49,20 @@ public class LoginController { **/ @GetMapping("captcha") public void captcha(HttpServletResponse response, String uuid) throws IOException { - //uuid不能为空 - AssertUtils.isBlank(uuid, ErrorCode.IDENTIFIER_NOT_NULL); - //生成图片验证码 - BufferedImage image = captchaService.create(uuid); - response.setHeader("Cache-Control", "no-store, no-cache"); - response.setContentType("image/jpeg"); - ServletOutputStream out = response.getOutputStream(); - ImageIO.write(image, "jpg", out); - out.close(); + try { + //uuid不能为空 + AssertUtils.isBlank(uuid, ErrorCode.IDENTIFIER_NOT_NULL); + //生成图片验证码 + BufferedImage image = captchaService.create(uuid); + response.reset(); + response.setHeader("Cache-Control", "no-store, no-cache"); + response.setContentType("image/jpeg"); + ServletOutputStream out = response.getOutputStream(); + ImageIO.write(image, "jpg", out); + out.close(); + } catch (IOException e) { + log.error("获取登陆验证码异常", e); + } } /** From cc2b5b3a6dbda3c3fe09a8b04b6eaf6e664b3e81 Mon Sep 17 00:00:00 2001 From: jianjun Date: Tue, 9 Mar 2021 13:49:34 +0800 Subject: [PATCH 16/38] =?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/commons/tools/aspect/BaseRequestLogAspect.java | 1 + 1 file changed, 1 insertion(+) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/BaseRequestLogAspect.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/BaseRequestLogAspect.java index ff877a04be..5eaada034e 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/BaseRequestLogAspect.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/BaseRequestLogAspect.java @@ -61,6 +61,7 @@ public abstract class BaseRequestLogAspect { try { Object[] args = point.getArgs(); + ThreadLocalConstant.requestParam.set(objectsToString(args)); log.info(">>>>>>>>请求信息>>>>>>>>:事务流水号:{},url:{} ,method:{},请求参数:{}", transactionSerial, requestURI, method, objectsToString(args)); result = point.proceed(); resultInfoLog(transactionSerial, getExecPeriod(startTime), result); From ff1d9694224c3ecb4ee249ccce693c55105862ec Mon Sep 17 00:00:00 2001 From: jianjun Date: Tue, 9 Mar 2021 14:05:59 +0800 Subject: [PATCH 17/38] =?UTF-8?q?=E5=8F=82=E6=95=B0=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/commons/tools/aspect/BaseRequestLogAspect.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/BaseRequestLogAspect.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/BaseRequestLogAspect.java index 02c3d8f18a..4b3496ee36 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/BaseRequestLogAspect.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/BaseRequestLogAspect.java @@ -1,6 +1,5 @@ package com.epmet.commons.tools.aspect; -import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.constant.AppClientConstant; import com.epmet.commons.tools.constant.ThreadLocalConstant; import com.epmet.commons.tools.exception.*; @@ -14,6 +13,7 @@ import org.springframework.dao.DuplicateKeyException; import javax.servlet.http.HttpServletRequest; import java.time.Duration; import java.time.LocalDateTime; +import java.util.Arrays; /** * 日志切面 @@ -63,7 +63,7 @@ public abstract class BaseRequestLogAspect { try { Object[] args = point.getArgs(); - ThreadLocalConstant.requestParam.set(JSON.toJSONString(args)); + ThreadLocalConstant.requestParam.set(Arrays.toString(point.getArgs())); log.info(">>>>>>>>请求信息>>>>>>>>:事务流水号:{},url:{} ,method:{},请求参数:{}", transactionSerial, requestURI, method, objectsToString(args)); result = point.proceed(); resultInfoLog(transactionSerial, getExecPeriod(startTime), result); From d7bf8d2eb9cc7b56228d9d4428c9c4b322da34c2 Mon Sep 17 00:00:00 2001 From: jianjun Date: Tue, 9 Mar 2021 14:13:12 +0800 Subject: [PATCH 18/38] =?UTF-8?q?=E8=8E=B7=E5=8F=96pubkey?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/epmet/controller/GovWebController.java | 2 +- .../main/java/com/epmet/commons/tools/utils/RSASignature.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 d0afcf3c32..8a85cb9da4 100644 --- a/epmet-auth/src/main/java/com/epmet/controller/GovWebController.java +++ b/epmet-auth/src/main/java/com/epmet/controller/GovWebController.java @@ -59,7 +59,7 @@ public class GovWebController { * @date 2021/3/8 5:07 下午 */ @PostMapping("getKey") - public Result getResiWxPhone() { + public Result getPubKey() { return new Result().ok(publicKey); } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/RSASignature.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/RSASignature.java index ac051e7093..6de665f7eb 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/RSASignature.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/RSASignature.java @@ -237,7 +237,7 @@ public class RSASignature { String s2 = RSASignature.decryptByPublicKey(s1, publicKey); System.out.println("解密后的数据:" + s2 + "\n\n"); } - + //===== { System.out.println("\n===========公钥加密,私钥解密=============="); String s1 = RSASignature.encryptByPublicKey(data, publicKey); From e83a8c8386feb5242d8a282fa3680b8215523576 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Tue, 9 Mar 2021 14:47:18 +0800 Subject: [PATCH 19/38] =?UTF-8?q?=E5=B9=B3=E9=98=B4=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=8A=BD=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../indexcoll/FactIndexPartyAblityOrgMonthlyDao.java | 4 ++-- .../indexcal/impl/IndexCalculateDistrictServiceImpl.java | 2 +- .../indexcal/impl/IndexCalculateStreetServiceImpl.java | 2 +- .../indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml | 3 ++- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.java index 99c0efaa60..dd3774be45 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.java @@ -85,8 +85,8 @@ public interface FactIndexPartyAblityOrgMonthlyDao extends BaseDao> selectPublishArticleCountMapExistSub(@Param("monthId")String monthId,@Param("areaCode")String areaCode,@Param("areaCodeLength")Integer areaCodeLength); - List> selectPublishArticleCountMapExistSubNotSelf(@Param("monthId")String monthId,@Param("areaCode")String areaCode,@Param("areaCodeLength")Integer areaCodeLength); + List> selectPublishArticleCountMapExistSubStreet(@Param("monthId")String monthId,@Param("areaCode")String areaCode); + List> selectPublishArticleCountMapExistSubNotSelf(@Param("monthId")String monthId,@Param("areaCode")String areaCode); /** * @Description 查询社区下的发文数 Map【根据areaCode】 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateDistrictServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateDistrictServiceImpl.java index 5ea39f0d4c..b679cd8c99 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateDistrictServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateDistrictServiceImpl.java @@ -631,7 +631,7 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict } } else { // 区名义发文数量 - List> publishArticleCountList = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCountMapExistSubNotSelf(monthId,form.getCustomerAreaCode(),NumConstant.SIX); + List> publishArticleCountList = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCountMapExistSubNotSelf(monthId,form.getCustomerAreaCode()); if (CollectionUtils.isEmpty(publishArticleCountList)) { log.warn(IndexCalConstant.DISTRICT_PUBLISH_ARTICLE_LIST_NULL); } else { diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java index 9343575dc3..539667b0a3 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java @@ -634,7 +634,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ } } else { // 街道名义发文数量 - List> mapList = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCountMapExistSubNotSelf(monthId,form.getCustomerAreaCode(),NumConstant.NINE); + List> mapList = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCountMapExistSubStreet(monthId,form.getCustomerAreaCode()); if (CollectionUtils.isEmpty(mapList)) { log.warn(IndexCalConstant.STREET_PUBLISH_ARTICLE_LIST_NULL); } else { diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml index c0f9e6e261..457443543b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml @@ -132,7 +132,7 @@ - SELECT pm.AGENCY_ID, pm.PARENT_ID, @@ -147,6 +147,7 @@ WHERE pm.del_flag = '0' AND sca.AREA_CODE LIKE CONCAT(#{areaCode},'%') + AND sca.AREA_CODE != #{areaCode} AND pm.month_id = #{monthId} + From e4e3166c1a61e2352f4e84869a255d7079b2d2e4 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Wed, 10 Mar 2021 09:42:03 +0800 Subject: [PATCH 27/38] =?UTF-8?q?=E5=B9=B3=E9=98=B4=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml index c082758802..f42c0de60c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml @@ -195,7 +195,6 @@ fics.agency_id = #{org} ) - GROUP BY AGENCY_ID + From f9852f088b20bb1fa0ed44f3904ba9491eb415d6 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Wed, 10 Mar 2021 14:36:49 +0800 Subject: [PATCH 31/38] =?UTF-8?q?=E5=B9=B3=E9=98=B4=E6=95=B0=E6=8D=AE-?= =?UTF-8?q?=E7=A4=BE=E5=8C=BA=E7=BA=A7=E5=88=AB=E5=8F=91=E6=96=87=E6=95=B0?= =?UTF-8?q?=E9=87=8Fsql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml index 457443543b..911b62e8c6 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml @@ -182,6 +182,7 @@ WHERE fm.del_flag = '0' AND fm.month_id = #{monthId} + AND fm.DATA_TYPE = 'community' AND sca.AREA_CODE LIKE CONCAT(#{areaCode},'%') AND sca.AREA_CODE != #{areaCode} From 510dec45eac48fb225a46411d6f692b9d4319cd2 Mon Sep 17 00:00:00 2001 From: jianjun Date: Wed, 10 Mar 2021 16:50:06 +0800 Subject: [PATCH 32/38] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E7=94=9F=E4=BA=A7?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=20jcet=20g=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- epmet-auth/pom.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/epmet-auth/pom.xml b/epmet-auth/pom.xml index eaa22e7557..5af5eae312 100644 --- a/epmet-auth/pom.xml +++ b/epmet-auth/pom.xml @@ -363,6 +363,10 @@ 2cy0a9lA 6hU3PQgxLcXr27SE + http://101.206.141.219:21006 + xSMONWwP + UUCnxLyXiB4eBF4p + https://epmet-cloud.elinkservice.cn From 9693fd1f7743e6d7d7afb516b4d58dbca5385770 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Wed, 10 Mar 2021 16:55:10 +0800 Subject: [PATCH 33/38] =?UTF-8?q?=E5=B9=B3=E9=98=B4=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml | 1 + .../indexcoll/FactIndexServiceAblityOrgMonthlyDao.xml | 1 + 2 files changed, 2 insertions(+) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml index 19cfc84047..d189ad2ee6 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml @@ -193,6 +193,7 @@ WHERE gm.del_flag = '0' AND gm.month_id = #{monthId} + AND gm.DATA_TYPE = 'community' AND sca.AREA_CODE LIKE CONCAT(#{areaCode},'%') AND sca.AREA_CODE != #{areaCode} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexServiceAblityOrgMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexServiceAblityOrgMonthlyDao.xml index 0e35707bce..e35e4de6f8 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexServiceAblityOrgMonthlyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexServiceAblityOrgMonthlyDao.xml @@ -144,6 +144,7 @@ LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = sm.AGENCY_ID WHERE sm.del_flag = '0' + AND sm.DATA_TYPE = 'community' AND sca.AREA_CODE LIKE CONCAT(#{areaCode},'%') AND sca.AREA_CODE != #{areaCode} AND sm.month_id = #{monthId} From 7df97b77db21ff926c13ecff2c6fa45ed969149a Mon Sep 17 00:00:00 2001 From: wangchao Date: Wed, 10 Mar 2021 17:15:24 +0800 Subject: [PATCH 34/38] =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=9F=A5=E8=AF=A2=EF=BC=8C=E4=BF=9D=E8=AF=81?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E7=94=A8=E6=88=B7=E6=9C=80=E5=A4=9A=E5=8F=AA?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E4=B8=80=E6=9D=A1=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/dao/RegisterRelationDao.java | 5 +- .../com/epmet/redis/UserBaseInfoRedis.java | 91 +++++++++++++++++++ .../service/impl/GridLatestServiceImpl.java | 2 +- .../service/impl/UserBadgeServiceImpl.java | 2 +- .../resources/mapper/RegisterRelationDao.xml | 28 ++++++ 5 files changed, 125 insertions(+), 3 deletions(-) diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/RegisterRelationDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/RegisterRelationDao.java index 4570711923..a19881ce9a 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/RegisterRelationDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/RegisterRelationDao.java @@ -18,11 +18,11 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; -import com.epmet.dto.RegisterRelationDTO; import com.epmet.entity.RegisterRelationEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; + import java.util.List; /** @@ -44,4 +44,7 @@ public interface RegisterRelationDao extends BaseDao { * @date 2020.07.23 15:31 **/ RegisterRelationEntity selectRegisteredGridIdByUserId(@Param("userId") String userId); + + + RegisterRelationEntity selectRegisteredGridIdByUserIdAndCustomerId(@Param("userId") String userId, @Param("customerId")String customerId); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBaseInfoRedis.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBaseInfoRedis.java index ec6d1eb485..315341ae84 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBaseInfoRedis.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBaseInfoRedis.java @@ -190,6 +190,97 @@ public class UserBaseInfoRedis { return null; } + + /** + * @Description 缓存中获取用户基本信息 + * @param userId + * @return + * @author wangc + * @date 2020.07.23 14:58 + **/ + public UserBaseInfoResultDTO getUserInfo(String userId,String customerId){ + if(StringUtils.isNotBlank(userId)){ + //获取居民缓存key + Map map = redisUtils.hGetAll(UserRedisKeys.getResiUserKey(userId)); + if(null != map && !map.isEmpty()) { + //缓存中有数据,直接返回 + return BeanUtil.mapToBean(map, UserBaseInfoResultDTO.class, true); + } + //缓存中没有数据,先查数据库,放入缓存后再返回 + UserBaseInfoResultDTO baseInfo = userBaseInfoDao.selectListByUserIdList(userId); + + if(null != baseInfo && StringUtils.isNotBlank(baseInfo.getId())){ + + //如果没有首次注册网格,则没有网格名称(xx机关-xx网格)、显示昵称(xx网格-x先生/女士) + RegisterRelationEntity relation = registerRelationDao.selectRegisteredGridIdByUserIdAndCustomerId(userId,customerId); + if(null != relation && StringUtils.isNotBlank(relation.getGridId())){ + baseInfo.setCustomerId(relation.getCustomerId()); + BelongGridNameFormDTO gridParam = new BelongGridNameFormDTO(); + gridParam.setGridId(relation.getGridId()); + baseInfo.setRegisteredGridId(relation.getGridId()); + Result gridResult = + govOrgOpenFeignClient.getGridNameByGridId(gridParam); + if(gridResult.success() && null != gridResult.getData() + && StringUtils.isNotBlank(gridResult.getData().getBelongsGridName())){ + String gridFullName = gridResult.getData().getBelongsGridName(); + baseInfo.setRegisteredGridName(gridFullName); + StringBuffer buffer = new StringBuffer(gridFullName.split(ModuleConstant.DASH)[NumConstant.ONE]).append(ModuleConstant.DASH).append(baseInfo.getSurname()); + switch (baseInfo.getGender()) { + case NumConstant.ONE_STR: + buffer.append(ModuleConstant.RESI_USER_NICKNAME_SUFFIX_MALE); + break; + case NumConstant.TWO_STR: + buffer.append(ModuleConstant.RESI_USER_NICKNAME_SUFFIX_FEMALE); + break; + default: + buffer.append(ModuleConstant.RESI_USER_NICKNAME_SUFFIX_GENDER_UNKNOWN); + } + baseInfo.setShowName(buffer.toString()); + } + } + else{ + //如果没有居民注册记录,说明当前用户是陌生人,需要从陌生人网格访问列表中查询所属的客户Id + LatestGridInfoResultDTO gridLatest = + gridLatestDao.selectLatestGridInfoByUserId(userId); + if(null != gridLatest){ + baseInfo.setCustomerId(gridLatest.getCustomerId()); + } + } + set(baseInfo); + return baseInfo; + }else{ + //如果没有,说明这里是陌生人 + //陌生人不放入缓存,也不更新用户基础信息表 + baseInfo = new UserBaseInfoResultDTO(); + baseInfo.setUserId(userId); + List wechatInfo = userWechatDao.selectByUserId(userId); + if(null != wechatInfo && !wechatInfo.isEmpty()){ + baseInfo.setNickname(wechatInfo.get(NumConstant.ZERO).getNickname()); + if(StringUtils.isBlank(baseInfo.getNickname())){ + baseInfo.setNickname(ModuleConstant.EMPTY_STR); + } + }else{ + return null; + } + RegisterRelationEntity relation = registerRelationDao.selectRegisteredGridIdByUserId(userId); + if(null != relation && StringUtils.isNotBlank(relation.getGridId())){ + baseInfo.setCustomerId(relation.getCustomerId()); + }else{ + LatestGridInfoResultDTO gridLatest = + gridLatestDao.selectLatestGridInfoByUserId(userId); + if(null != gridLatest){ + baseInfo.setCustomerId(gridLatest.getCustomerId()); + } + } + } + + return baseInfo; + + } + + return null; + } + /** * @Description 更新缓存 * @param entity diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GridLatestServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GridLatestServiceImpl.java index 46bd30dfff..c18e91c05d 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GridLatestServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GridLatestServiceImpl.java @@ -210,7 +210,7 @@ public class GridLatestServiceImpl extends BaseServiceImpl { if(StringUtils.isNotBlank(info.getUserId())){ - UserBaseInfoResultDTO cache = userBaseInfoRedis.getUserInfo(info.getUserId()); + UserBaseInfoResultDTO cache = userBaseInfoRedis.getUserInfo(info.getUserId(),customerUserFormDTO.getCustomerId()); if(null != cache) { info.setRegisteredGrid(StringUtils.isBlank(cache.getRegisteredGridName()) ? ModuleConstant.EMPTY_STR : cache.getRegisteredGridName()); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java index 02e3c8c875..391ad95b7c 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java @@ -342,7 +342,7 @@ public class UserBadgeServiceImpl implements UserBadgeService { //居民端 CertificationDetailResultDTO resiResult = userBadgeDao.selectBadgeAuthRecord(tokenDto.getUserId(), certificationDetailFormDTO.getBadgeId(),certificationDetailFormDTO.getRecordId()); if(null == resiResult){ - UserBaseInfoResultDTO userInfo = userBaseInfoRedis.getUserInfo(tokenDto.getUserId()); + UserBaseInfoResultDTO userInfo = userBaseInfoRedis.getUserInfo(tokenDto.getUserId(),certificationDetailFormDTO.getCustomerId()); resiResult = ConvertUtils.sourceToTarget(userInfo,CertificationDetailResultDTO.class); if(null != resiResult) resiResult.setIdcard(userInfo.getIdNum()); } diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/RegisterRelationDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/RegisterRelationDao.xml index 44dbb58269..403e3fcc8e 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/RegisterRelationDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/RegisterRelationDao.xml @@ -33,6 +33,7 @@ + + + + \ No newline at end of file From 7193a584bd243e60a2c027d996e763c0d0fcffba Mon Sep 17 00:00:00 2001 From: wangchao Date: Wed, 10 Mar 2021 18:01:57 +0800 Subject: [PATCH 35/38] =?UTF-8?q?extUserInfo=20=E8=BF=94=E5=9B=9E=E5=8A=A0?= =?UTF-8?q?=E4=B8=8AcustomerId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/service/impl/UserBaseInfoServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBaseInfoServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBaseInfoServiceImpl.java index 2072097574..f76628b60d 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBaseInfoServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBaseInfoServiceImpl.java @@ -366,6 +366,7 @@ public class UserBaseInfoServiceImpl extends BaseServiceImpl Date: Thu, 11 Mar 2021 13:13:11 +0800 Subject: [PATCH 36/38] =?UTF-8?q?/epmet/ext/staff/permissionv2=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../indexcal/impl/IndexCalculateServiceImpl.java | 2 +- .../src/main/java/com/epmet/dto/result/AgencyNodeDTO.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java index d080e31712..01d7f5d581 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java @@ -157,7 +157,7 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { log.error("indexCalculate calStreetAll exception", e); } - //计算区直属 + //计算部门相关 start = System.currentTimeMillis(); try { flag = deptScoreService.calculateDeptCorreLation(formDTO); diff --git a/epmet-module/epmet-ext/epmet-ext-client/src/main/java/com/epmet/dto/result/AgencyNodeDTO.java b/epmet-module/epmet-ext/epmet-ext-client/src/main/java/com/epmet/dto/result/AgencyNodeDTO.java index 54ad61602e..3d27d589ab 100644 --- a/epmet-module/epmet-ext/epmet-ext-client/src/main/java/com/epmet/dto/result/AgencyNodeDTO.java +++ b/epmet-module/epmet-ext/epmet-ext-client/src/main/java/com/epmet/dto/result/AgencyNodeDTO.java @@ -56,5 +56,5 @@ public class AgencyNodeDTO implements Serializable { * */ private String areaCode; - private String parentCode; + private String parentAreaCode; } From 741c6e8eaf71308cf09da1ea9ec958705afed9c2 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Fri, 12 Mar 2021 09:28:44 +0800 Subject: [PATCH 37/38] =?UTF-8?q?=E5=B9=B3=E9=98=B4=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../indexcal/SubCommunityAvgResultDTO.java | 8 +- .../indexcal/AgencyScoreDao.java | 6 +- .../indexcal/CommunityScoreDao.java | 2 +- .../FactIndexGovrnAblityOrgMonthlyDao.java | 8 ++ .../FactIndexServiceAblityOrgMonthlyDao.java | 1 + .../IndexCalculateCommunityServiceImpl.java | 2 +- .../IndexCalculateDistrictServiceImpl.java | 29 +----- .../impl/IndexCalculateStreetServiceImpl.java | 89 +++++++++++++++++-- .../indexcal/AgencyScoreDao.xml | 40 +++++---- .../indexcal/CommunityScoreDao.xml | 9 +- .../FactIndexGovrnAblityOrgMonthlyDao.xml | 31 ++++++- .../FactIndexPartyAblityOrgMonthlyDao.xml | 3 +- .../FactIndexServiceAblityOrgMonthlyDao.xml | 23 +++++ 13 files changed, 188 insertions(+), 63 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/SubCommunityAvgResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/SubCommunityAvgResultDTO.java index 06b06109f1..a2c167eaeb 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/SubCommunityAvgResultDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/SubCommunityAvgResultDTO.java @@ -1,5 +1,6 @@ package com.epmet.dto.indexcal; +import com.epmet.commons.tools.constant.NumConstant; import lombok.Data; import java.io.Serializable; @@ -47,5 +48,10 @@ public class SubCommunityAvgResultDTO implements Serializable { /** * 分数 */ - private BigDecimal score; + private BigDecimal score = NumConstant.ZERO_DECIMAL; + + /** + * 赋值状态 + */ + private Boolean scoreStatus = false; } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencyScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencyScoreDao.java index bc00d9e97b..2593996a1b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencyScoreDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencyScoreDao.java @@ -70,8 +70,8 @@ public interface AgencyScoreDao extends BaseDao { * @author zxc * @date 2021/1/15 下午4:23 */ - List selectAgencyScoreInfoExistsSub(@Param("areaCode") String areaCode,@Param("areaCodeLength") Integer areaCodeLength, @Param("monthId")String monthId, @Param("dataType")String dataType); - List selectAgencyScoreInfoExistsSubSelf(@Param("areaCode") String areaCode, @Param("monthId")String monthId, @Param("dataType")String dataType); + List selectAgencyScoreInfoExistsSub(@Param("areaCode") String areaCode, @Param("monthId")String monthId, @Param("dataType")String dataType,@Param("customerId")String customerId); + List selectAgencyScoreInfoExistsSubSelf(@Param("areaCode") String areaCode, @Param("monthId")String monthId, @Param("dataType")String dataType,@Param("customerId")String customerId); /** * @Description 区下级街道得分平均值 @@ -91,7 +91,7 @@ public interface AgencyScoreDao extends BaseDao { * @author zxc * @date 2021/1/18 上午9:09 */ - List selectAgencyScoreAvgExistsSub(@Param("monthId")String monthId, @Param("indexCode")String indexCode,@Param("dataType")String dataType,@Param("areaCode")String areaCode,@Param("areaCodeLength")Integer areaCodeLength); + List selectAgencyScoreAvgExistsSub(@Param("monthId")String monthId, @Param("indexCode")String indexCode,@Param("areaCode")String areaCode); List selectAgencyScoreAvgByOrgIds(@Param("monthId")String monthId, @Param("indexCode")String indexCode,@Param("orgIds")List orgIds); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CommunityScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CommunityScoreDao.java index d88c05e053..104f53bb42 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CommunityScoreDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CommunityScoreDao.java @@ -68,7 +68,7 @@ public interface CommunityScoreDao extends BaseDao selectCommunityInfoExistsSub(@Param("areaCode") String areaCode,@Param("monthId")String monthId); + List selectCommunityInfoExistsSub(@Param("areaCode") String areaCode,@Param("monthId")String monthId,@Param("customerId")String customerId); /** * 根据入参查询 查询社区相关信息 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.java index 72888053f3..4188e5f96f 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.java @@ -76,6 +76,14 @@ public interface FactIndexGovrnAblityOrgMonthlyDao extends BaseDao> selectCommunityGovernAbilityExistsSub(@Param("monthId")String monthId,@Param("areaCode")String areaCode); List> selectCommunityGovernAbilityExistsSubNotSelf(@Param("monthId")String monthId,@Param("areaCode")String areaCode); + /** + * @Description 孔村单独查询 + * @Param monthId + * @Param areaCode + * @author zxc + * @date 2021/3/11 下午5:21 + */ + List> selectCommunityGovernAbilityIsKongCun(@Param("monthId")String monthId,@Param("areaCode")String areaCode); /** * 根据组织类型删除数据 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexServiceAblityOrgMonthlyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexServiceAblityOrgMonthlyDao.java index 5bcd057058..28917bf72b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexServiceAblityOrgMonthlyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexServiceAblityOrgMonthlyDao.java @@ -87,6 +87,7 @@ public interface FactIndexServiceAblityOrgMonthlyDao extends BaseDao> selectActivityCountMapExistsSub(@Param("monthId")String monthId,@Param("areaCode")String areaCode); + List> selectActivityCountMapIsKongCun(@Param("monthId")String monthId,@Param("areaCode")String areaCode); List> selectActivityCountMapExistsSubNotSelf(@Param("monthId")String monthId,@Param("areaCode")String areaCode); /** diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateCommunityServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateCommunityServiceImpl.java index 38d14d8667..0d084096ec 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateCommunityServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateCommunityServiceImpl.java @@ -819,7 +819,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni String customerId = form.getCustomerId(); String monthId = form.getMonthId(); List detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(form.getCustomerId(), IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode()); - List factIndexCommunityScoreEntities = factIndexCommunityScoreDao.selectCommunityInfoExistsSub(form.getCustomerAreaCode(),form.getMonthId()); + List factIndexCommunityScoreEntities = factIndexCommunityScoreDao.selectCommunityInfoExistsSub(form.getCustomerAreaCode(),form.getMonthId(),form.getCustomerId()); detailListByParentCode.forEach(detail -> { factIndexCommunityScoreEntities.forEach(community -> { if (detail.getIndexCode().equals(community.getIndexCode())) { diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateDistrictServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateDistrictServiceImpl.java index f8d6c6d3f7..9c3328f6ca 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateDistrictServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateDistrictServiceImpl.java @@ -611,16 +611,10 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict } List indexInputVOS = new ArrayList<>(); Map pid = new HashMap<>(); - List orgInfos = customerAgencyDao.selectAgencyByParentAreaCode(form.getCustomerAreaCode()); - log.info("orgInfos:::"+orgInfos.toString()); //党建能力平均值 indexDetailList.forEach(detail -> { if (IndexCodeEnum.QU_XIA_JI_JIE_DDJNLHZPJZ.getCode().equals(detail.getIndexCode())) { - List subGridPartyAvgScore = agencyScoreDao.selectAgencyScoreAvgByOrgIds(monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),orgInfos.stream().map(o -> o.getOrgId()).collect(Collectors.toList())); - // 暂时的 - subGridPartyAvgScore.forEach(s -> { - s.setParentId(customerAgencyDao.selectParentId(s.getAgencyId())); - }); + List subGridPartyAvgScore = agencyScoreDao.selectAgencyScoreAvgExistsSub(monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),form.getCustomerAreaCode()); log.info("subGridPartyAvgScore:::"+subGridPartyAvgScore.toString()); if (CollectionUtils.isEmpty(subGridPartyAvgScore)) { log.warn(IndexCalConstant.DISTRICT_PARTY_AVG_NULL); @@ -701,18 +695,10 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict } List indexInputVOS = new ArrayList<>(); Map pid = new HashMap<>(); - List orgInfos = customerAgencyDao.selectAgencyByParentAreaCode(form.getCustomerAreaCode()); - log.info("orgInfos:::"+orgInfos.toString()); detailListByParentCode.forEach(detail -> { if (IndexCodeEnum.SUO_YOU_JIE_DAO_ZLNLPJZ.getCode().equals(detail.getIndexCode())) { -// List districtGovernAvgList = agencyScoreDao.selectAgencyScoreAvgExistsSub(monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),IndexCalConstant.STREET_LEVEL,form.getCustomerAreaCode(),NumConstant.SIX); - List districtGovernAvgList = agencyScoreDao.selectAgencyScoreAvgByOrgIds(monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),orgInfos.stream().map(m -> m.getOrgId()).collect(Collectors.toList())); - // 暂时的 - districtGovernAvgList.forEach(s -> { - s.setParentId(customerAgencyDao.selectParentId(s.getAgencyId())); - }); + List districtGovernAvgList = agencyScoreDao.selectAgencyScoreAvgExistsSub(monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),form.getCustomerAreaCode()); log.info("districtGovernAvgList:::"+districtGovernAvgList.toString()); - log.info(districtGovernAvgList.toString()); for (int i = 0; i < districtGovernAvgList.size(); i++) { if (districtGovernAvgList.get(i).getAgencyId().equals(NumConstant.ZERO_STR)){ districtGovernAvgList.remove(districtGovernAvgList.get(i)); @@ -795,17 +781,10 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict } List indexInputVOS = new ArrayList<>(); Map pid = new HashMap<>(); - List orgInfos = customerAgencyDao.selectAgencyByParentAreaCode(form.getCustomerAreaCode()); - log.info("orgInfos"+orgInfos.toString()); detailListByParentCode.forEach(detail -> { String indexCode = detail.getIndexCode(); if (IndexCodeEnum.QU_XIA_SHU_JIE_DFWNLHZPJZ.getCode().equals(indexCode)) { -// List subStreetAvgList = agencyScoreDao.selectAgencyScoreAvgExistsSub(monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode(),IndexCalConstant.STREET_LEVEL,form.getCustomerAreaCode(),NumConstant.SIX); - List subStreetAvgList = agencyScoreDao.selectAgencyScoreAvgByOrgIds(monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode(),orgInfos.stream().map(m -> m.getOrgId()).collect(Collectors.toList())); - // 暂时的 - subStreetAvgList.forEach(s -> { - s.setParentId(customerAgencyDao.selectParentId(s.getAgencyId())); - }); + List subStreetAvgList = agencyScoreDao.selectAgencyScoreAvgExistsSub(monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode(),form.getCustomerAreaCode()); log.info("subStreetAvgList:::"+subStreetAvgList.toString()); for (int i = 0; i < subStreetAvgList.size(); i++) { if (subStreetAvgList.get(i).getAgencyId().equals(NumConstant.ZERO_STR)){ @@ -860,7 +839,7 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict String customerId = form.getCustomerId(); String monthId = form.getMonthId(); List detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode()); - List agencyScoreList = agencyScoreDao.selectAgencyScoreInfoExistsSubSelf(form.getCustomerAreaCode(),monthId, IndexCalConstant.DISTRICT_LEVEL); + List agencyScoreList = agencyScoreDao.selectAgencyScoreInfoExistsSubSelf(form.getCustomerAreaCode(),monthId, IndexCalConstant.DISTRICT_LEVEL,form.getCustomerId()); log.info("agencyScoreList:::"+agencyScoreList.toString()); detailListByParentCode.forEach(detail -> { agencyScoreList.forEach(community -> { diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java index 2b27420d2a..000b41921c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java @@ -25,6 +25,7 @@ import com.epmet.dto.indexcal.AgencyCalResultDTO; import com.epmet.dto.indexcal.AgencyScoreDTO; import com.epmet.dto.indexcal.CalculateCommonFormDTO; import com.epmet.dto.indexcal.SubCommunityAvgResultDTO; +import com.epmet.dto.screen.ScreenProjectOrgDailyDTO; import com.epmet.dto.screen.result.MaxAndMinBigDecimalResultDTO; import com.epmet.entity.evaluationindex.indexcal.AgencySelfSubScoreEntity; import com.epmet.entity.evaluationindex.indexcal.AgencySubScoreEntity; @@ -50,6 +51,7 @@ import org.springframework.util.CollectionUtils; import java.math.BigDecimal; import java.util.*; +import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; /** @@ -616,7 +618,8 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ //下属所有社区的党建能力平均值 detailListByParentCode.forEach(detail -> { if (IndexCodeEnum.JIE_DAO_XIA_SHU_SYSQDJNLHZPJZ.getCode().equals(detail.getIndexCode())) { - List subCommPartyAvgScore = communityScoreDao.selectSubCommAvgScoreExistSubNotSelf(monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),form.getCustomerAreaCode()); + List dispose = communityScoreDao.selectSubCommAvgScoreExistSubNotSelf(monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),form.getCustomerAreaCode()); + List subCommPartyAvgScore = disposeSubAvg(dispose, form); if (CollectionUtils.isEmpty(subCommPartyAvgScore)) { log.warn(IndexCalConstant.COMMUNITY_PARTY_AVG_NULL); } else if (subCommPartyAvgScore.size() > NumConstant.ZERO) { @@ -692,7 +695,8 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ Map pid = new HashMap<>(); detailListByParentCode.forEach(detail -> { if (IndexCodeEnum.JIE_DAO_XIA_SHU_SYSQZLNLHZ.getCode().equals(detail.getIndexCode())) { - List subGridGovernAvg = communityScoreDao.selectSubCommAvgScoreExistSubNotSelf(monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),form.getCustomerAreaCode()); + List dispose = communityScoreDao.selectSubCommAvgScoreExistSubNotSelf(monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),form.getCustomerAreaCode()); + List subGridGovernAvg = disposeSubAvg(dispose,form); if (CollectionUtils.isEmpty(subGridGovernAvg)){ log.warn("查询街道下属所有社区治理能力汇总为空"); }else if (subGridGovernAvg.size() > NumConstant.ZERO) { @@ -713,7 +717,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ } } else { // 治理能力的六个五级指标 - List> communityGovernAbility = factIndexGovrnAblityOrgMonthlyDao.selectCommunityGovernAbilityExistsSubNotSelf(monthId,form.getCustomerAreaCode()); + List> communityGovernAbility = disposeFiveLevel(form); if (CollectionUtils.isEmpty(communityGovernAbility)){ log.warn(IndexCalConstant.STREET_GOVERN_ABILITY_NULL); }else{ @@ -767,7 +771,8 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ detailListByParentCode.forEach(detail -> { String indexCode = detail.getIndexCode(); if (IndexCodeEnum.JIE_DAO_XIA_SHU_SQFWNLDFPYZ.getCode().equals(indexCode)) { - List subCommServiceAvg = communityScoreDao.selectSubCommAvgScoreExistSubNotSelf(monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode(),form.getCustomerAreaCode()); + List dispose = communityScoreDao.selectSubCommAvgScoreExistSubNotSelf(monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode(),form.getCustomerAreaCode()); + List subCommServiceAvg = disposeSubAvg(dispose,form); if (CollectionUtils.isEmpty(subCommServiceAvg)) { log.warn("查询街道下属社区服务能力得分平均值为空"); } else if (subCommServiceAvg.size() > NumConstant.ZERO) { @@ -787,7 +792,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ }); } } else { - List> communityActivityCountList = factIndexServiceAblityOrgMonthlyDao.selectActivityCountMapExistsSubNotSelf(monthId,form.getCustomerAreaCode()); + List> communityActivityCountList = disposeActivityCount(form); if (CollectionUtils.isEmpty(communityActivityCountList)) { log.warn(IndexCalConstant.STREET_SERVICE_ABILITY_NULL); }else{ @@ -832,7 +837,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ String customerId = form.getCustomerId(); String monthId = form.getMonthId(); List detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode()); - List agencyScoreList = agencyScoreDao.selectAgencyScoreInfoExistsSub(form.getCustomerAreaCode(), NumConstant.NINE, monthId, IndexCalConstant.STREET_LEVEL); + List agencyScoreList = agencyScoreDao.selectAgencyScoreInfoExistsSub(form.getCustomerAreaCode(), monthId, IndexCalConstant.STREET_LEVEL,form.getCustomerId()); detailListByParentCode.forEach(detail -> { agencyScoreList.forEach(community -> { if (detail.getIndexCode().equals(community.getIndexCode())) { @@ -866,4 +871,76 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ return true; } + public List disposeSubAvg(List avgScore, CalculateCommonFormDTO formDTO){ + List orgIds = customerAgencyDao.selectAgencyByParentAreaCode(formDTO.getCustomerAreaCode()); + List subAvgScores = new ArrayList<>(); + orgIds.forEach(org -> { + SubCommunityAvgResultDTO s = new SubCommunityAvgResultDTO(); + s.setAgencyId(org.getOrgId()); + subAvgScores.add(s); + }); + subAvgScores.forEach(subScore -> { + if (!CollectionUtils.isEmpty(avgScore)){ + avgScore.forEach(avg -> { + if (subScore.getAgencyId().equals(avg.getParentId())){ + subScore.setScore(avg.getScore()); + avg.setScoreStatus(true); + } + }); + } + }); + Map> groupByStatus = avgScore.stream().collect(Collectors.groupingBy(SubCommunityAvgResultDTO::getScoreStatus)); + List subAvgResultDTOS = groupByStatus.get(false); + if (!CollectionUtils.isEmpty(subAvgResultDTOS)){ + AtomicReference finalScore = new AtomicReference<>(new BigDecimal(NumConstant.ZERO)); + subAvgResultDTOS.forEach(sub -> { + finalScore.set(finalScore.get().add(sub.getScore())); + }); + BigDecimal divide = finalScore.get().divide(new BigDecimal(subAvgResultDTOS.size())); + subAvgScores.forEach(s -> { + if (s.getAgencyId().equals("1234085031077498881")){ + s.setScore(divide); + } + }); + } + return subAvgScores; + } + + public List> disposeFiveLevel(CalculateCommonFormDTO formDTO){ + List> result = new ArrayList<>(); + List> communityGovernAbility = factIndexGovrnAblityOrgMonthlyDao.selectCommunityGovernAbilityExistsSubNotSelf(formDTO.getMonthId(),formDTO.getCustomerAreaCode()); + List> kongCunGovernAbility = factIndexGovrnAblityOrgMonthlyDao.selectCommunityGovernAbilityIsKongCun(formDTO.getMonthId(),formDTO.getCustomerAreaCode()); + if (!CollectionUtils.isEmpty(kongCunGovernAbility)){ + kongCunGovernAbility.forEach(k -> { + k.put("AGENCY_ID",k.get("PARENT_ID")); + k.put("PARENT_ID",NumConstant.ZERO_STR); + }); + } + if (!CollectionUtils.isEmpty(communityGovernAbility)){ + result.addAll(communityGovernAbility); + } + if (!CollectionUtils.isEmpty(kongCunGovernAbility)){ + result.addAll(kongCunGovernAbility); + } + return result; + } + + public List> disposeActivityCount(CalculateCommonFormDTO formDTO){ + List> result = new ArrayList<>(); + List> ActivityCountList = factIndexServiceAblityOrgMonthlyDao.selectActivityCountMapExistsSub(formDTO.getMonthId(),formDTO.getCustomerAreaCode()); + List> kongCunActivityCountList = factIndexServiceAblityOrgMonthlyDao.selectActivityCountMapIsKongCun(formDTO.getMonthId(),formDTO.getCustomerAreaCode()); + if (!CollectionUtils.isEmpty(kongCunActivityCountList)){ + kongCunActivityCountList.forEach(k -> { + k.put("AGENCY_ID",k.get("PARENT_ID")); + k.put("PARENT_ID",NumConstant.ZERO_STR); + }); + } + if (!CollectionUtils.isEmpty(ActivityCountList)){ + result.addAll(ActivityCountList); + } + if (!CollectionUtils.isEmpty(kongCunActivityCountList)){ + result.addAll(kongCunActivityCountList); + } + return result; + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml index f42c0de60c..f776956bf0 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml @@ -146,6 +146,7 @@ AND fias.MONTH_ID = #{monthId} AND fias.data_type = #{dataType} AND fias.IS_TOTAL = "0" + AND fias.customer_id = #{customerId} AND (fias.INDEX_CODE = "zhilinengli" OR fias.INDEX_CODE = "dangjiannengli" OR fias.INDEX_CODE = "fuwunengli") @@ -153,25 +154,25 @@ @@ -214,6 +215,7 @@ fias.del_flag = 0 AND sca.AREA_CODE = #{areaCode} AND fias.MONTH_ID = #{monthId} + AND fias.customer_id = #{customerId} AND fias.IS_TOTAL = "0" AND (fias.INDEX_CODE = "zhilinengli" OR fias.INDEX_CODE = "dangjiannengli" diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CommunityScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CommunityScoreDao.xml index 5690d1a665..28eda4f99c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CommunityScoreDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CommunityScoreDao.xml @@ -142,6 +142,7 @@ AND sca.AREA_CODE LIKE CONCAT(#{areaCode},'%') AND cs.MONTH_ID = #{monthId} AND cs.IS_TOTAL = "0" + AND cs.customer_id = #{customerId} AND (cs.INDEX_CODE = "dangjiannengli" OR cs.INDEX_CODE = "zhilinengli" OR cs.INDEX_CODE = "fuwunengli") @@ -179,14 +180,14 @@ sca.pid AS parentId FROM fact_index_community_score fics - LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = fics.PARENT_AGENCY_ID + LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = fics.AGENCY_ID WHERE fics.del_flag = '0' AND sca.DEL_FLAG = 0 - AND sca.AREA_CODE IN - (SELECT AREA_CODE FROM screen_customer_agency WHERE DEL_FLAG = '0' AND PARENT_AREA_CODE = #{areaCode}) + AND sca.AREA_CODE LIKE CONCAT(#{areaCode},'%') + AND sca.`LEVEL` = 'community' AND fics.month_id = #{monthId} AND fics.index_code = #{indexCode} - GROUP BY fics.parent_agency_id + GROUP BY parentId diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml index d189ad2ee6..1217c43131 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml @@ -193,8 +193,37 @@ WHERE gm.del_flag = '0' AND gm.month_id = #{monthId} - AND gm.DATA_TYPE = 'community' + AND gm.DATA_TYPE = 'street' AND sca.AREA_CODE LIKE CONCAT(#{areaCode},'%') AND sca.AREA_CODE != #{areaCode} + AND gm.PARENT_ID = '0' + + + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml index 911b62e8c6..eeddf7a408 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml @@ -146,8 +146,7 @@ LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = pm.AGENCY_ID WHERE pm.del_flag = '0' - AND sca.AREA_CODE LIKE CONCAT(#{areaCode},'%') - AND sca.AREA_CODE != #{areaCode} + AND sca.PARENT_AREA_CODE = #{areaCode} AND pm.month_id = #{monthId} + From 4a3ca383ccd4649752d47d9b30e71253f6b117c3 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Fri, 12 Mar 2021 09:49:43 +0800 Subject: [PATCH 38/38] =?UTF-8?q?=E5=B9=B3=E9=98=B4=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../indexcoll/FactIndexGovrnAblityOrgMonthlyDao.java | 2 +- .../indexcal/impl/IndexCalculateCommunityServiceImpl.java | 3 ++- .../indexcal/impl/IndexCalculateStreetServiceImpl.java | 7 ++----- .../indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.java index 4188e5f96f..24f48eef4f 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.java @@ -75,7 +75,7 @@ public interface FactIndexGovrnAblityOrgMonthlyDao extends BaseDao> selectCommunityGovernAbilityExistsSub(@Param("monthId")String monthId,@Param("areaCode")String areaCode); - List> selectCommunityGovernAbilityExistsSubNotSelf(@Param("monthId")String monthId,@Param("areaCode")String areaCode); + List> selectCommunityGovernAbilityExistsSubNotSelf(@Param("monthId")String monthId,@Param("areaCode")String areaCode,@Param("level")String level); /** * @Description 孔村单独查询 * @Param monthId diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateCommunityServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateCommunityServiceImpl.java index 0d084096ec..693f02c50d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateCommunityServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateCommunityServiceImpl.java @@ -11,6 +11,7 @@ import com.epmet.commons.tools.utils.DateUtils; import com.epmet.constant.DataSourceConstant; import com.epmet.constant.IndexCalConstant; import com.epmet.constant.ProjectConstant; +import com.epmet.constant.ScreenConstant; import com.epmet.dao.evaluationindex.indexcal.CommunityScoreDao; import com.epmet.dao.evaluationindex.indexcal.CommunitySelfSubScoreDao; import com.epmet.dao.evaluationindex.indexcal.CommunitySubScoreDao; @@ -702,7 +703,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni } } else { // 治理能力的六个五级指标 - List> communityGovernAbility = factIndexGovrnAblityOrgMonthlyDao.selectCommunityGovernAbilityExistsSubNotSelf(form.getMonthId(),form.getCustomerAreaCode()); + List> communityGovernAbility = factIndexGovrnAblityOrgMonthlyDao.selectCommunityGovernAbilityExistsSubNotSelf(form.getMonthId(),form.getCustomerAreaCode(), ScreenConstant.COMMUNITY); if (CollectionUtils.isEmpty(communityGovernAbility)){ log.warn(IndexCalConstant.COMMUNITY_GOVERN_ABILITY_NULL); }else{ diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java index 000b41921c..552efefa9d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java @@ -8,10 +8,7 @@ import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.DateUtils; -import com.epmet.constant.DataSourceConstant; -import com.epmet.constant.IndexCalConstant; -import com.epmet.constant.OrgTypeConstant; -import com.epmet.constant.ProjectConstant; +import com.epmet.constant.*; import com.epmet.dao.evaluationindex.indexcal.AgencyScoreDao; import com.epmet.dao.evaluationindex.indexcal.AgencySelfSubScoreDao; import com.epmet.dao.evaluationindex.indexcal.AgencySubScoreDao; @@ -908,7 +905,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ public List> disposeFiveLevel(CalculateCommonFormDTO formDTO){ List> result = new ArrayList<>(); - List> communityGovernAbility = factIndexGovrnAblityOrgMonthlyDao.selectCommunityGovernAbilityExistsSubNotSelf(formDTO.getMonthId(),formDTO.getCustomerAreaCode()); + List> communityGovernAbility = factIndexGovrnAblityOrgMonthlyDao.selectCommunityGovernAbilityExistsSubNotSelf(formDTO.getMonthId(),formDTO.getCustomerAreaCode(), ScreenConstant.STREET); List> kongCunGovernAbility = factIndexGovrnAblityOrgMonthlyDao.selectCommunityGovernAbilityIsKongCun(formDTO.getMonthId(),formDTO.getCustomerAreaCode()); if (!CollectionUtils.isEmpty(kongCunGovernAbility)){ kongCunGovernAbility.forEach(k -> { diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml index 1217c43131..3dbe2956ed 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml @@ -193,7 +193,7 @@ WHERE gm.del_flag = '0' AND gm.month_id = #{monthId} - AND gm.DATA_TYPE = 'street' + AND gm.DATA_TYPE = #{level} AND sca.AREA_CODE LIKE CONCAT(#{areaCode},'%') AND sca.AREA_CODE != #{areaCode} AND gm.PARENT_ID = '0'