Browse Source

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

dev
yinzuomei 5 years ago
parent
commit
5cb26abf59
  1. 48
      epmet-auth/pom.xml
  2. 32
      epmet-auth/src/main/java/com/epmet/controller/GovWebController.java
  3. 25
      epmet-auth/src/main/java/com/epmet/controller/LoginController.java
  4. 11
      epmet-auth/src/main/java/com/epmet/controller/SsoController.java
  5. 6
      epmet-auth/src/main/java/com/epmet/dto/form/SsoEnteOrgFormDTO.java
  6. 42
      epmet-auth/src/main/java/com/epmet/dto/form/SsoWorkLoginFormDTO.java
  7. 5
      epmet-auth/src/main/java/com/epmet/service/SsoService.java
  8. 28
      epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java
  9. 20
      epmet-auth/src/main/resources/bootstrap.yml
  10. 2
      epmet-auth/src/main/resources/logback-spring.xml
  11. 2
      epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/DemoApp.java
  12. 10
      epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/AbstractApiService.java
  13. 64
      epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/jcet/JcetApiService.java
  14. 7
      epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/pyld/PyldApiService.java
  15. 2
      epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/result/jcet/JcetCUserInfoResultDTO.java
  16. 25
      epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/result/jcet/JcetGUserInfoResultDTO.java
  17. 11
      epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/properties/ThirdplatProps.java
  18. 84
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/ApplicationFailedEventListener.java
  19. 13
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/ApplicationReadyEventListener.java
  20. 3
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/BaseRequestLogAspect.java
  21. 2
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/StrConstant.java
  22. 7
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/ThreadLocalConstant.java
  23. 132
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java
  24. 6
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java
  25. 251
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/RSASignature.java
  26. 14
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/user/UserAnalysisController.java
  27. 7
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/user/UserAnalysisService.java
  28. 53
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/user/impl/UserAnalysisServiceImpl.java
  29. 8
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/SubCommunityAvgResultDTO.java
  30. 6
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencyScoreDao.java
  31. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CommunityScoreDao.java
  32. 1
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/DeptScoreDao.java
  33. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.java
  34. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.java
  35. 1
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexServiceAblityOrgMonthlyDao.java
  36. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java
  37. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateCommunityServiceImpl.java
  38. 38
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateDistrictServiceImpl.java
  39. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java
  40. 102
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java
  41. 71
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml
  42. 7
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CommunityScoreDao.xml
  43. 22
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/DeptScoreDao.xml
  44. 30
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml
  45. 8
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml
  46. 24
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexServiceAblityOrgMonthlyDao.xml
  47. 26
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml
  48. 2
      epmet-module/epmet-ext/epmet-ext-client/src/main/java/com/epmet/dto/result/AgencyNodeDTO.java
  49. 3
      epmet-module/gov-grid/gov-grid-server/src/main/java/com/epmet/controller/ResiGroupController.java
  50. 2
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/CommonGridAndPageFormDTO.java
  51. 13
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java
  52. 42
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java
  53. 12
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/invitation/service/impl/GroupInvitationServiceImpl.java
  54. 14
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/service/impl/ResiGroupMemberServiceImpl.java
  55. 5
      epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/advice/controller/AdviceController.java
  56. 4
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/warmhearted/controller/ResiWarmheartedApplyController.java
  57. 5
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/warmhearted/service/ResiWarmheartedApplyService.java
  58. 86
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/warmhearted/service/impl/ResiWarmheartedApplyServiceImpl.java
  59. 152
      epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/util/RSASignature.java
  60. 2
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/SubmitAdviceFormDTO.java
  61. 9
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserAdviceController.java
  62. 5
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/RegisterRelationDao.java
  63. 91
      epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBaseInfoRedis.java
  64. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GridLatestServiceImpl.java
  65. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBadgeServiceImpl.java
  66. 1
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBaseInfoServiceImpl.java
  67. 28
      epmet-user/epmet-user-server/src/main/resources/mapper/RegisterRelationDao.xml

48
epmet-auth/pom.xml

@ -200,9 +200,15 @@
</dingTalk.robot.secret>
<!--第三方平台,酒城e通-->
<thirdplat.jcet.domain>http://101.206.141.251:21006</thirdplat.jcet.domain>
<thirdplat.jcet.appkey>soXDEoM1</thirdplat.jcet.appkey>
<thirdplat.jcet.appsecret>V7ea0KnlYt7eSyzc</thirdplat.jcet.appsecret>
<thirdplat.jcet.c.domain>http://101.206.141.251:21006</thirdplat.jcet.c.domain>
<thirdplat.jcet.c.appkey>soXDEoM1</thirdplat.jcet.c.appkey>
<thirdplat.jcet.c.appsecret>V7ea0KnlYt7eSyzc</thirdplat.jcet.c.appsecret>
<thirdplat.jcet.g.domain>http://101.206.141.219:21006</thirdplat.jcet.g.domain>
<thirdplat.jcet.g.appkey>xSMONWwP</thirdplat.jcet.g.appkey>
<thirdplat.jcet.g.appsecret>UUCnxLyXiB4eBF4p</thirdplat.jcet.g.appsecret>
<epmet.third.urlprefix>https://epmet-cloud.elinkservice.cn</epmet.third.urlprefix>
</properties>
</profile>
<profile>
@ -249,9 +255,15 @@
</dingTalk.robot.secret>
<!--第三方平台,酒城e通-->
<thirdplat.jcet.domain>http://101.206.141.251:21006</thirdplat.jcet.domain>
<thirdplat.jcet.appkey>soXDEoM1</thirdplat.jcet.appkey>
<thirdplat.jcet.appsecret>V7ea0KnlYt7eSyzc</thirdplat.jcet.appsecret>
<thirdplat.jcet.c.domain>http://101.206.141.251:21006</thirdplat.jcet.c.domain>
<thirdplat.jcet.c.appkey>soXDEoM1</thirdplat.jcet.c.appkey>
<thirdplat.jcet.c.appsecret>V7ea0KnlYt7eSyzc</thirdplat.jcet.c.appsecret>
<thirdplat.jcet.g.domain>http://101.206.141.219:21006</thirdplat.jcet.g.domain>
<thirdplat.jcet.g.appkey>xSMONWwP</thirdplat.jcet.g.appkey>
<thirdplat.jcet.g.appsecret>UUCnxLyXiB4eBF4p</thirdplat.jcet.g.appsecret>
<epmet.third.urlprefix>https://epmet-cloud.elinkservice.cn</epmet.third.urlprefix>
</properties>
</profile>
<profile>
@ -293,9 +305,15 @@
</dingTalk.robot.secret>
<!--第三方平台,酒城e通-->
<thirdplat.jcet.domain>http://101.206.141.251:21006</thirdplat.jcet.domain>
<thirdplat.jcet.appkey>soXDEoM1</thirdplat.jcet.appkey>
<thirdplat.jcet.appsecret>V7ea0KnlYt7eSyzc</thirdplat.jcet.appsecret>
<thirdplat.jcet.c.domain>http://101.206.141.251:21006</thirdplat.jcet.c.domain>
<thirdplat.jcet.c.appkey>soXDEoM1</thirdplat.jcet.c.appkey>
<thirdplat.jcet.c.appsecret>V7ea0KnlYt7eSyzc</thirdplat.jcet.c.appsecret>
<thirdplat.jcet.g.domain>http://101.206.141.219:21006</thirdplat.jcet.g.domain>
<thirdplat.jcet.g.appkey>xSMONWwP</thirdplat.jcet.g.appkey>
<thirdplat.jcet.g.appsecret>UUCnxLyXiB4eBF4p</thirdplat.jcet.g.appsecret>
<epmet.third.urlprefix>https://epmet-cloud.elinkservice.cn</epmet.third.urlprefix>
</properties>
</profile>
@ -341,9 +359,15 @@
</dingTalk.robot.secret>
<!--第三方平台,酒城e通-->
<thirdplat.jcet.domain>https://jcytc.lzjczl.com:21009</thirdplat.jcet.domain>
<thirdplat.jcet.appkey>2cy0a9lA</thirdplat.jcet.appkey>
<thirdplat.jcet.appsecret>6hU3PQgxLcXr27SE</thirdplat.jcet.appsecret>
<thirdplat.jcet.c.domain>https://jcytc.lzjczl.com:21009</thirdplat.jcet.c.domain>
<thirdplat.jcet.c.appkey>2cy0a9lA</thirdplat.jcet.c.appkey>
<thirdplat.jcet.c.appsecret>6hU3PQgxLcXr27SE</thirdplat.jcet.c.appsecret>
<thirdplat.jcet.g.domain>http://101.206.141.219:21006</thirdplat.jcet.g.domain>
<thirdplat.jcet.g.appkey>xSMONWwP</thirdplat.jcet.g.appkey>
<thirdplat.jcet.g.appsecret>UUCnxLyXiB4eBF4p</thirdplat.jcet.g.appsecret>
<epmet.third.urlprefix>https://epmet-cloud.elinkservice.cn</epmet.third.urlprefix>
</properties>
</profile>
</profiles>

32
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<UserTokenResultDTO> 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<UserTokenResultDTO>().ok(govWebService.login(formDTO));
}
/**
* desc: 获取前端密码加密 公钥
*
* @return com.epmet.commons.tools.utils.Result
* @author LiuJanJun
* @date 2021/3/8 5:07 下午
*/
@PostMapping("getKey")
public Result<String> getPubKey() {
return new Result().ok(publicKey);
}
}

25
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);
}
}
/**

11
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.form.SsoLoginOperFormDTO;
import com.epmet.dto.result.SsoLoginResultDTO;
import com.epmet.dto.result.UserTokenResultDTO;
@ -37,9 +38,9 @@ public class SsoController {
* @date 2021/1/18 下午4:59
*/
@PostMapping("resi/login")
public Result<SsoLoginResultDTO> ssoLogin(@RequestBody SsoLoginFormDTO formDTO) {
public Result<SsoLoginResultDTO> ssoResiLogin(@RequestBody SsoLoginFormDTO formDTO){
ValidatorUtils.validateEntity(formDTO, SsoLoginFormDTO.SsoLoginForm.class);
return new Result<SsoLoginResultDTO>().ok(ssoService.ssoLogin(formDTO));
return new Result<SsoLoginResultDTO>().ok(ssoService.ssoResiLogin(formDTO));
}
/**
@ -58,7 +59,7 @@ public class SsoController {
public Result<ThirdPlatUserInfo> testssoLogin() {
ThirdPlatUserInfo userInfoByTicket = null;
try {
userInfoByTicket = jcetApiService.getUserInfoByTicket("ssoTicket-vYtMRuXAQZri3wpA2vyq5D8n3Q9oO7ui");
userInfoByTicket = jcetApiService.getCUserInfoByTicket("ssoTicket-vYtMRuXAQZri3wpA2vyq5D8n3Q9oO7ui");
} catch (Exception e) {
e.printStackTrace();
}
@ -71,8 +72,8 @@ public class SsoController {
* @Description 1ticket自动登录获取内部token
**/
@PostMapping("work/login")
public Result<UserTokenResultDTO> ssoWorkLogin(@RequestBody SsoLoginFormDTO formDTO){
ValidatorUtils.validateEntity(formDTO, SsoLoginFormDTO.SsoLoginForm.class);
public Result<UserTokenResultDTO> ssoWorkLogin(@RequestBody SsoWorkLoginFormDTO formDTO){
ValidatorUtils.validateEntity(formDTO, SsoWorkLoginFormDTO.SsoLoginForm.class);
return new Result<UserTokenResultDTO>().ok(ssoService.ssoWorkLogin(formDTO));
}

6
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;
/**
* 手机号

42
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;
}

5
epmet-auth/src/main/java/com/epmet/service/SsoService.java

@ -3,6 +3,7 @@ package com.epmet.service;
import com.epmet.dto.form.SsoEnteOrgFormDTO;
import com.epmet.dto.form.SsoLoginFormDTO;
import com.epmet.dto.form.SsoLoginOperFormDTO;
import com.epmet.dto.form.SsoWorkLoginFormDTO;
import com.epmet.dto.result.SsoLoginResultDTO;
import com.epmet.dto.result.UserTokenResultDTO;
@ -18,14 +19,14 @@ public interface SsoService {
* @author zxc
* @date 2021/1/18 下午4:59
*/
SsoLoginResultDTO ssoLogin(SsoLoginFormDTO formDTO);
SsoLoginResultDTO ssoResiLogin(SsoLoginFormDTO formDTO);
/**
* @param formDTO
* @Author sun
* @Description 1ticket自动登录获取内部token
**/
UserTokenResultDTO ssoWorkLogin(SsoLoginFormDTO formDTO);
UserTokenResultDTO ssoWorkLogin(SsoWorkLoginFormDTO formDTO);
/**
* @param formDTO

28
epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java

@ -30,6 +30,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;
@ -74,6 +75,9 @@ public class SsoServiceImpl implements SsoService {
@Autowired
private EpmetUserFeignClient epmetUserFeignClient;
@Value("${epmet.third.urlPrefix}")
private String epmetThirdUrlPrefix;
/**
* @Description 0入口得到token
* @Param formDTO
@ -81,8 +85,9 @@ 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 = "";
Result<ThirdplatApiserviceResultDTO> apiServiceResult = operCrmOpenFeignClient.getApiServiceByCustomerId(new ApiServiceFormDTO(customerId));
@ -97,7 +102,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());
}
@ -139,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) {
@ -229,7 +234,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);
@ -255,10 +260,11 @@ public class SsoServiceImpl implements SsoService {
* @Description 1ticket自动登录获取内部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<ThirdplatApiserviceResultDTO> apiServiceResult = operCrmOpenFeignClient.getApiServiceByCustomerId(new ApiServiceFormDTO(customerId));
@ -271,7 +277,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());
}
@ -353,7 +359,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("");
@ -479,21 +485,21 @@ public class SsoServiceImpl implements SsoService {
//2.客户Id换取第三方apiService,根据ticket换取华为Id
Result<ThirdplatApiserviceResultDTO> 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 {
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());
}
if (null == userInfo){
throw new RenException(EpmetErrorCode.THIRD_PLAT_REQUEST_ERROR.getCode(),
"【SSO登录】调用第三方平台查询用户信息失败,用户信息为空");
"【SSO enterOrg】调用第三方平台查询用户信息失败,用户信息为空");
}
//3、记录staff_wechat,并记录用户激活状态,激活时间

20
epmet-auth/src/main/resources/bootstrap.yml

@ -136,12 +136,24 @@ shutdown:
# 调用第三方平台相关参数
thirdplat:
jcet:
domain: @thirdplat.jcet.domain@
appkey: @thirdplat.jcet.appkey@
appsecret: @thirdplat.jcet.appsecret@
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@
pyld:
domain: https://epmet-ext9.elinkservice.cn/platform
appId: 7a5aec009ba4eba8e254ee64fe3775e1
appKey: 14faef9af508d1c253b720ea5a43f9de
appSecret: 38e7c2604c8dd33c445705d25eebbfc12a2f7ed8a87111e9e10a40312d3a1595
epmet:
login:
publicKey: MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKjgDaHWqWgquoatbC4zzQCgqE8C425VIOyzJVVgH1HUYCHpuNUnGCv3HBAl2RsziWQqQgd1xxl0C3a5J4J69o8CAwEAAQ==
privateKey: MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEAqOANodapaCq6hq1sLjPNAKCoTwLjblUg7LMlVWAfUdRgIem41ScYK/ccECXZGzOJZCpCB3XHGXQLdrkngnr2jwIDAQABAkAyYaWvgrtHuHetdk+v+QRQC54q9FGluP/5nfilX+f4IUf8j92o/ZohTtmJn9qcDiAP4wxCLIsfy4IW3psST78BAiEA0A/E0WvtI7spWnjfw+wMDhdVMIbIJvDbj/cqMwRZInUCIQDPyO2sbXpwDjmAvyn0jpGJJxU5POWYdI37rTf9fScMcwIhAMkWNHbjBHKANVuHb10ACjakPmWEHnXkW5AspdBg53TxAiARPbzq99KXBbcjxbj3f/T3inSqYTEz60f0wDTLJd1dnQIhAIFe6Jd1TduIxGk1PDh/b/3q0jNGgVXkFnUBnKWDaL9N
# third服务的相关配置
third:
urlPrefix: @epmet.third.urlprefix@

2
epmet-auth/src/main/resources/logback-spring.xml

@ -139,7 +139,7 @@
</appender>
<!-- 开发、测试环境 -->
<springProfile name="dev,test">
<springProfile name="local,dev,test">
<logger name="org.springframework.web" level="INFO"/>
<logger name="org.springboot.sample" level="INFO"/>
<logger name="com.epmet" level="INFO"/>

2
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;

10
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 解析请求结果

64
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;
@ -16,20 +17,20 @@ import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
@Service
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();
}
/**
@ -38,8 +39,7 @@ public class JcetApiService extends AbstractApiService {
* @author wxz
* @date 2021.01.19 10:26
*/
@Override
public ThirdPlatUserInfo getUserInfoByTicket(String ticket) throws UnsupportedEncodingException {
public ThirdPlatUserInfo getCUserInfoByTicket(String ticket) throws UnsupportedEncodingException {
logger.info("【请求酒城e通第三方平台】getUserInfoByTicket()接口开始>>>>>>>>>>>>");
logger.info("【请求酒城e通第三方平台】getUserInfoByTicket()接口入参 ticket:{}", ticket);
@ -47,12 +47,12 @@ public class JcetApiService extends AbstractApiService {
SsoTicketFormDTO ssoTicket = new SsoTicketFormDTO();
ssoTicket.setSsoTicket(ticket);
String domain = jcetThirdplatProps.getDomain();
String domain = jcetThirdplatCendProps.getDomain();
Result<String> result = HttpClientManager.getInstance().sendPost(
domain.concat(JcetConstants.URL_GET_USER_BY_TICKET),
domain.startsWith("https://"),
JSON.toJSONString(ssoTicket),
getHeaders(ssoTicket));
getHeaders(JSON.toJSONString(ssoTicket).getBytes("utf-8").length, jcetThirdplatCendProps.getAppkey(), jcetThirdplatCendProps.getAppsecret()));
try {
logger.info("【请求酒城e通第三方平台】getUserInfoByTicket()接口返回:{}", result.getData());
@ -61,7 +61,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());
@ -70,6 +70,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<String, Object> params = new HashMap<>();
params.put("ssoToken",token);
String domain = jcetThirdplatGendProps.getDomain();
Result<String> 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获取用户信息
@ -98,19 +130,17 @@ public class JcetApiService extends AbstractApiService {
/**
* 获取请求所需要的头信息
*
* @param contentObject
* @return
* @throws UnsupportedEncodingException
*/
private Map<String, Object> getHeaders(Object contentObject) throws UnsupportedEncodingException {
int bodyLength = JSON.toJSONString(contentObject).getBytes(StandardCharsets.UTF_8).length;
private Map<String, Object> getHeaders(int bodyLength, String appKey, String appSecret) throws UnsupportedEncodingException {
Map<String, Object> 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_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));
return headers;
}

7
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);

2
epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/result/jcet/JcetUserInfoResultDTO.java → 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;
/**
* 用户名称

25
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;
}

11
epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/properties/ThirdplatProps.java

@ -6,10 +6,13 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
@Data
@ConfigurationProperties(prefix = "thirdplat")
public class ThirdplatProps {
/**
* 泸州 酒城e通
*/
private JcetThirdplatProps jcet;
// C端
private JcetThirdplatProps jcetCend;
// G端
private JcetThirdplatProps jcetGend;
/**
* 平阴联动指挥平台
*/

84
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.
* <p>
* https://www.renren.io
* <p>
* 版权所有侵权必究
*/
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<ApplicationFailedEvent> {
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);
}
}
}

13
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/CustomerApplicationRunner.java → 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<ApplicationReadyEvent> {
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 {
}
}
}

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

@ -1,6 +1,7 @@
package com.epmet.commons.tools.aspect;
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;
@ -12,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;
/**
* 日志切面
@ -61,6 +63,7 @@ public abstract class BaseRequestLogAspect {
try {
Object[] args = point.getArgs();
ThreadLocalConstant.requestParam.set(Arrays.toString(point.getArgs()));
log.info(">>>>>>>>请求信息>>>>>>>>:事务流水号:{},url:{} ,method:{},请求参数:{}", transactionSerial, requestURI, method, objectsToString(args));
result = point.proceed();
resultInfoLog(transactionSerial, getExecPeriod(startTime), result);

2
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/StrConstant.java

@ -81,4 +81,6 @@ public interface StrConstant {
String MIN="MIN";
String MAX="MAX";
String SPECIAL_CUSTOMER = "150282ed25c14ff0785e7e06283b6283";
}

7
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<String> sqlFilter = new ThreadLocal();
/**
* 用于本次的获取请求参数
*/
public static final ThreadLocal<String> requestParam = new ThreadLocal();
}

132
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(<generated>)\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(<generated>)\n" +
" at com.epmet.controller.ResiVolunteerController.authenticate(ResiVolunteerController.java:59)\n" +
" at com.epmet.controller.ResiVolunteerController$$FastClassBySpringCGLIB$$e023fb55.invoke(<generated>)\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(<generated>)\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);
}
@ -274,7 +204,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;
}
}

6
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java

@ -349,7 +349,7 @@ public class HttpClientManager {
}
}
public Result<String> sendGet(String url, boolean isHttps, Map<String, Object> params, Map<String,String> headerMap) {
public Result<String> sendGet(String url, boolean isHttps, Map<String, Object> params, Map<String, Object> headerMap) {
try {
URIBuilder builder = new URIBuilder(url);
@ -364,7 +364,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);

251
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");
}
}
}

14
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/user/UserAnalysisController.java

@ -1,5 +1,7 @@
package com.epmet.datareport.controller.user;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.user.UserIncrTrendFormDTO;
@ -50,9 +52,9 @@ public class UserAnalysisController {
* @Date 2020/6/22 13:30
**/
@PostMapping("subagency")
public Result<List<UserSubAgencyResultDTO>> subAgency(@RequestBody UserSubAgencyFormDTO formDTO) {
public Result<List<UserSubAgencyResultDTO>> subAgency(@LoginUser TokenDto tokenDto, @RequestBody UserSubAgencyFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO,UserSubAgencyFormDTO.AddUserInternalGroup.class);
List<UserSubAgencyResultDTO> userSubAgencyResultDTO = userService.subAgency(formDTO);
List<UserSubAgencyResultDTO> userSubAgencyResultDTO = userService.subAgency(tokenDto, formDTO);
return new Result<List<UserSubAgencyResultDTO>>().ok(userSubAgencyResultDTO);
}
@ -64,9 +66,9 @@ public class UserAnalysisController {
* @Date 2020/6/22 13:33
**/
@PostMapping("subgrid")
public Result<List<UserSubGridResultDTO>> subGrid(@RequestBody UserSubGridFormDTO formDTO) {
public Result<List<UserSubGridResultDTO>> subGrid(@LoginUser TokenDto tokenDto, @RequestBody UserSubGridFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, UserSubGridFormDTO.AddUserInternalGroup.class);
List<UserSubGridResultDTO> userSubGridResultDTO = userService.subGrid(formDTO);
List<UserSubGridResultDTO> userSubGridResultDTO = userService.subGrid(tokenDto, formDTO);
return new Result<List<UserSubGridResultDTO>>().ok(userSubGridResultDTO);
}
@ -78,9 +80,9 @@ public class UserAnalysisController {
* @Date 2020/6/22 13:36
**/
@PostMapping("incrtrend")
public Result<List<UserIncrTrendResultDTO>> incrTrend(@RequestBody UserIncrTrendFormDTO formDTO) {
public Result<List<UserIncrTrendResultDTO>> incrTrend(@LoginUser TokenDto tokenDto, @RequestBody UserIncrTrendFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, UserIncrTrendFormDTO.AddUserInternalGroup.class);
List<UserIncrTrendResultDTO> userIncrTrendResultDTO = userService.incrTrendV2(formDTO);
List<UserIncrTrendResultDTO> userIncrTrendResultDTO = userService.incrTrendV2(tokenDto, formDTO);
return new Result<List<UserIncrTrendResultDTO>>().ok(userIncrTrendResultDTO);
}

7
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/user/UserAnalysisService.java

@ -1,6 +1,7 @@
package com.epmet.datareport.service.user;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.dto.form.user.UserIncrTrendFormDTO;
import com.epmet.dto.form.user.UserSubAgencyFormDTO;
import com.epmet.dto.form.user.UserSubGridFormDTO;
@ -32,7 +33,7 @@ public interface UserAnalysisService {
* @description 直属机关柱状图查询
* @Date 2020/6/22 13:42
**/
List<UserSubAgencyResultDTO> subAgency(UserSubAgencyFormDTO formDTO);
List<UserSubAgencyResultDTO> subAgency(TokenDto tokenDto, UserSubAgencyFormDTO formDTO);
/**
* @param formDTO
@ -41,7 +42,7 @@ public interface UserAnalysisService {
* @description 直属网格柱状图查询
* @Date 2020/6/22 13:42
**/
List<UserSubGridResultDTO> subGrid(UserSubGridFormDTO formDTO);
List<UserSubGridResultDTO> subGrid(TokenDto tokenDto, UserSubGridFormDTO formDTO);
/**
* @param formDTO
@ -60,7 +61,7 @@ public interface UserAnalysisService {
* @description 按日按月查询注册用户数参与用户数增量折线图
* @Date 2020/6/22 13:42
**/
List<UserIncrTrendResultDTO> incrTrendV2(UserIncrTrendFormDTO formDTO);
List<UserIncrTrendResultDTO> incrTrendV2(TokenDto tokenDto, UserIncrTrendFormDTO formDTO);
/**
* @return com.epmet.dto.result.user.UserAgencyInfoResultDTO

53
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/user/impl/UserAnalysisServiceImpl.java

@ -2,7 +2,9 @@ package com.epmet.datareport.service.user.impl;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.security.user.LoginUserUtil;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.Result;
@ -74,6 +76,7 @@ public class UserAnalysisServiceImpl implements UserAnalysisService {
logger.info(String.format("用户%s的所属机关id为%s",loginUserDetailsFormDTO.getUserId(),result.getData().getAgencyId()));
return result.getData().getAgencyId();
}
/**
* @param formDTO
* @return com.epmet.user.result.UserSummaryInfoResultDTO
@ -120,11 +123,11 @@ public class UserAnalysisServiceImpl implements UserAnalysisService {
* @Date 2020/6/22 13:42
**/
@Override
public List<UserSubAgencyResultDTO> subAgency(UserSubAgencyFormDTO formDTO) {
public List<UserSubAgencyResultDTO> subAgency(TokenDto tokenDto, UserSubAgencyFormDTO formDTO) {
//获取用户所属机关id
String myAgencyId = this.getMyAgency();
//初始化横坐标(用户所机关的下级机关列表)
List<UserSubAgencyResultDTO> dimList = this.initUserSubAgencyResultDTO(myAgencyId);
List<UserSubAgencyResultDTO> dimList = this.initUserSubAgencyResultDTO(tokenDto.getCustomerId(), myAgencyId);
if(CollectionUtils.isEmpty(dimList)){
logger.info(String.format("当前机关(agencyId=%s)下没有下级机关",myAgencyId));
return new ArrayList<>();
@ -199,7 +202,7 @@ public class UserAnalysisServiceImpl implements UserAnalysisService {
return dimList;
}
private List<UserSubAgencyResultDTO> initUserSubAgencyResultDTO(String myAgencyId) {
private List<UserSubAgencyResultDTO> initUserSubAgencyResultDTO(String customerId, String myAgencyId) {
List<UserSubAgencyResultDTO> list=new ArrayList<>();
List<DimAgencyDTO> dimAgencyDTOS=userAnalysisDao.selectSubAgencyList(myAgencyId);
for(DimAgencyDTO agencyDTO:dimAgencyDTOS){
@ -208,7 +211,11 @@ public class UserAnalysisServiceImpl implements UserAnalysisService {
resi.setAgencyId(agencyDTO.getId());
resi.setName(agencyDTO.getAgencyName());
resi.setValue(NumConstant.ZERO);
resi.setType(UserAnalysisConstant.REGISTERED_RESI);
if (StrConstant.SPECIAL_CUSTOMER.equals(customerId)) {
resi.setType("学员");
} else {
resi.setType(UserAnalysisConstant.REGISTERED_RESI);
}
resi.setTotal(NumConstant.ZERO);
list.add(resi);
//热心居民
@ -216,7 +223,11 @@ public class UserAnalysisServiceImpl implements UserAnalysisService {
warm.setAgencyId(agencyDTO.getId());
warm.setName(agencyDTO.getAgencyName());
warm.setValue(NumConstant.ZERO);
warm.setType(UserAnalysisConstant.WARMHEARTED);
if (StrConstant.SPECIAL_CUSTOMER.equals(customerId)) {
warm.setType("组长");
} else {
warm.setType(UserAnalysisConstant.WARMHEARTED);
}
warm.setTotal(NumConstant.ZERO);
list.add(warm);
//党员
@ -239,11 +250,11 @@ public class UserAnalysisServiceImpl implements UserAnalysisService {
* @Date 2020/6/22 13:42
**/
@Override
public List<UserSubGridResultDTO> subGrid(UserSubGridFormDTO formDTO) {
public List<UserSubGridResultDTO> subGrid(TokenDto tokenDto, UserSubGridFormDTO formDTO) {
//获取用户所属机关id
String myAgencyId = this.getMyAgency();
//初始化横坐标(用户所机关的直属网格)
List<UserSubGridResultDTO> dimList = this.initUserSubGridResultDTO(myAgencyId);
List<UserSubGridResultDTO> dimList = this.initUserSubGridResultDTO(tokenDto.getCustomerId(), myAgencyId);
if(CollectionUtils.isEmpty(dimList)){
logger.info(String.format("当前机关(agencyId=%s)下没有网格",myAgencyId));
return new ArrayList<>();
@ -315,7 +326,7 @@ public class UserAnalysisServiceImpl implements UserAnalysisService {
return dimList;
}
private List<UserSubGridResultDTO> initUserSubGridResultDTO(String myAgencyId) {
private List<UserSubGridResultDTO> initUserSubGridResultDTO(String customerId, String myAgencyId) {
List<UserSubGridResultDTO> list=new ArrayList<>();
List<DimGridDTO> gridList=userAnalysisDao.selectSubGridList(myAgencyId);
for(DimGridDTO grid:gridList){
@ -324,7 +335,11 @@ public class UserAnalysisServiceImpl implements UserAnalysisService {
resi.setGridId(grid.getId());
resi.setName(grid.getGridName());
resi.setValue(NumConstant.ZERO);
resi.setType(UserAnalysisConstant.REGISTERED_RESI);
if (StrConstant.SPECIAL_CUSTOMER.equals(customerId)) {
resi.setType("学员");
} else {
resi.setType(UserAnalysisConstant.REGISTERED_RESI);
}
resi.setTotal(NumConstant.ZERO);
list.add(resi);
//热心居民
@ -332,7 +347,11 @@ public class UserAnalysisServiceImpl implements UserAnalysisService {
warm.setGridId(grid.getId());
warm.setName(grid.getGridName());
warm.setValue(NumConstant.ZERO);
warm.setType(UserAnalysisConstant.WARMHEARTED);
if (StrConstant.SPECIAL_CUSTOMER.equals(customerId)) {
warm.setType("组长");
} else {
warm.setType(UserAnalysisConstant.WARMHEARTED);
}
warm.setTotal(NumConstant.ZERO);
list.add(warm);
//党员
@ -411,7 +430,7 @@ public class UserAnalysisServiceImpl implements UserAnalysisService {
}
@Override
public List<UserIncrTrendResultDTO> incrTrendV2(UserIncrTrendFormDTO formDTO) {
public List<UserIncrTrendResultDTO> incrTrendV2(TokenDto tokenDto, UserIncrTrendFormDTO formDTO) {
//获取用户所属机关id
String myAgencyId = this.getMyAgency();
List<UserIncrTrendResultDTO> resultList=new ArrayList<>();
@ -443,14 +462,22 @@ public class UserAnalysisServiceImpl implements UserAnalysisService {
UserIncrTrendResultDTO reg=new UserIncrTrendResultDTO();
reg.setDateOrMonthId(userIncrTrendResDTO.getDateIdOrMonthId());
reg.setDate(date);
reg.setType(UserAnalysisConstant.REGISTERED_RESI);
if (StrConstant.SPECIAL_CUSTOMER.equals(tokenDto.getCustomerId())) {
reg.setType("学员");
} else {
reg.setType(UserAnalysisConstant.REGISTERED_RESI);
}
reg.setValue(userIncrTrendResDTO.getRegIncr());
resultList.add(reg);
UserIncrTrendResultDTO warm=new UserIncrTrendResultDTO();
warm.setDateOrMonthId(userIncrTrendResDTO.getDateIdOrMonthId());
warm.setDate(date);
warm.setType(UserAnalysisConstant.WARMHEARTED);
if (StrConstant.SPECIAL_CUSTOMER.equals(tokenDto.getCustomerId())) {
warm.setType("组长");
} else {
warm.setType(UserAnalysisConstant.WARMHEARTED);
}
warm.setValue(userIncrTrendResDTO.getWarmIncr());
resultList.add(warm);

8
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;
}

6
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencyScoreDao.java

@ -70,7 +70,8 @@ public interface AgencyScoreDao extends BaseDao<AgencyScoreEntity> {
* @author zxc
* @date 2021/1/15 下午4:23
*/
List<AgencyScoreDTO> selectAgencyScoreInfoExistsSub(@Param("areaCode") String areaCode,@Param("areaCodeLength") Integer areaCodeLength, @Param("monthId")String monthId, @Param("dataType")String dataType);
List<AgencyScoreDTO> selectAgencyScoreInfoExistsSub(@Param("areaCode") String areaCode, @Param("monthId")String monthId, @Param("dataType")String dataType,@Param("customerId")String customerId);
List<AgencyScoreDTO> selectAgencyScoreInfoExistsSubSelf(@Param("areaCode") String areaCode, @Param("monthId")String monthId, @Param("dataType")String dataType,@Param("customerId")String customerId);
/**
* @Description 区下级街道得分平均值
@ -90,7 +91,8 @@ public interface AgencyScoreDao extends BaseDao<AgencyScoreEntity> {
* @author zxc
* @date 2021/1/18 上午9:09
*/
List<SubAgencyScoreAvgResultDTO> selectAgencyScoreAvgExistsSub(@Param("monthId")String monthId, @Param("indexCode")String indexCode,@Param("dataType")String dataType,@Param("areaCode")String areaCode,@Param("areaCodeLength")Integer areaCodeLength);
List<SubAgencyScoreAvgResultDTO> selectAgencyScoreAvgExistsSub(@Param("monthId")String monthId, @Param("indexCode")String indexCode,@Param("areaCode")String areaCode);
List<SubAgencyScoreAvgResultDTO> selectAgencyScoreAvgByOrgIds(@Param("monthId")String monthId, @Param("indexCode")String indexCode,@Param("orgIds")List<String> orgIds);
/**

2
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<FactIndexCommunityScoreEntity
* @author zxc
* @date 2021/1/15 下午2:18
*/
List<FactIndexCommunityScoreDTO> selectCommunityInfoExistsSub(@Param("areaCode") String areaCode,@Param("monthId")String monthId);
List<FactIndexCommunityScoreDTO> selectCommunityInfoExistsSub(@Param("areaCode") String areaCode,@Param("monthId")String monthId,@Param("customerId")String customerId);
/**
* 根据入参查询 查询社区相关信息

1
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<DeptScoreEntity> {
* @date 2021/1/18 上午9:31
*/
List<SubAgencyScoreAvgResultDTO> selectGovernDeptScoreAvgExistsSub(@Param("areaCode")String areaCode, @Param("monthId")String monthId, @Param("indexCode")String indexCode);
List<SubAgencyScoreAvgResultDTO> selectGovernDeptScoreAvgExistsSubNotSelf(@Param("areaCode")String areaCode, @Param("monthId")String monthId, @Param("indexCode")String indexCode);
/**
* @return int

10
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.java

@ -75,7 +75,15 @@ public interface FactIndexGovrnAblityOrgMonthlyDao extends BaseDao<FactIndexGovr
* @date 2021/1/15 下午1:27
*/
List<Map<String,Object>> selectCommunityGovernAbilityExistsSub(@Param("monthId")String monthId,@Param("areaCode")String areaCode);
List<Map<String,Object>> selectCommunityGovernAbilityExistsSubNotSelf(@Param("monthId")String monthId,@Param("areaCode")String areaCode);
List<Map<String,Object>> selectCommunityGovernAbilityExistsSubNotSelf(@Param("monthId")String monthId,@Param("areaCode")String areaCode,@Param("level")String level);
/**
* @Description 孔村单独查询
* @Param monthId
* @Param areaCode
* @author zxc
* @date 2021/3/11 下午5:21
*/
List<Map<String,Object>> selectCommunityGovernAbilityIsKongCun(@Param("monthId")String monthId,@Param("areaCode")String areaCode);
/**
* 根据组织类型删除数据

4
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<FactIndexPart
* @author zxc
* @date 2021/1/15 下午3:31
*/
List<Map<String,Object>> selectPublishArticleCountMapExistSub(@Param("monthId")String monthId,@Param("areaCode")String areaCode,@Param("areaCodeLength")Integer areaCodeLength);
List<Map<String,Object>> selectPublishArticleCountMapExistSubNotSelf(@Param("monthId")String monthId,@Param("areaCode")String areaCode,@Param("areaCodeLength")Integer areaCodeLength);
List<Map<String,Object>> selectPublishArticleCountMapExistSubStreet(@Param("monthId")String monthId,@Param("areaCode")String areaCode);
List<Map<String,Object>> selectPublishArticleCountMapExistSubNotSelf(@Param("monthId")String monthId,@Param("areaCode")String areaCode);
/**
* @Description 查询社区下的发文数 Map根据areaCode

1
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<FactIndexSe
* @date 2021/1/15 下午1:53
*/
List<Map<String,Object>> selectActivityCountMapExistsSub(@Param("monthId")String monthId,@Param("areaCode")String areaCode);
List<Map<String,Object>> selectActivityCountMapIsKongCun(@Param("monthId")String monthId,@Param("areaCode")String areaCode);
List<Map<String,Object>> selectActivityCountMapExistsSubNotSelf(@Param("monthId")String monthId,@Param("areaCode")String areaCode);
/**

10
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java

@ -95,6 +95,8 @@ public interface ScreenCustomerAgencyDao extends BaseDao<ScreenCustomerAgencyEnt
* @date 2020/9/8 3:36 下午
*/
String selectPid(@Param("agencyId") String agencyId);
String selectParentId(@Param("agencyId") String agencyId);
String selectAgencyId(@Param("areaCode") String areaCode);
/**
* 返回当前客户下未匹配到的 街道区县级 组织信息
@ -194,4 +196,12 @@ public interface ScreenCustomerAgencyDao extends BaseDao<ScreenCustomerAgencyEnt
List<ScreenProjectOrgDailyDTO> selectAgencyByCustomer(@Param("customerId")String customerId);
List<ScreenProjectOrgDailyDTO> selectAgencyByAreaCode(String areaCode);
/**
* @Description 根据areaCode查询下级组织
* @Param areaCode
* @author zxc
* @date 2021/3/9 上午9:41
*/
List<ScreenProjectOrgDailyDTO> selectAgencyByParentAreaCode(@Param("areaCode") String areaCode);
}

5
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<Map<String, Object>> communityGovernAbility = factIndexGovrnAblityOrgMonthlyDao.selectCommunityGovernAbilityExistsSubNotSelf(form.getMonthId(),form.getCustomerAreaCode());
List<Map<String, Object>> communityGovernAbility = factIndexGovrnAblityOrgMonthlyDao.selectCommunityGovernAbilityExistsSubNotSelf(form.getMonthId(),form.getCustomerAreaCode(), ScreenConstant.COMMUNITY);
if (CollectionUtils.isEmpty(communityGovernAbility)){
log.warn(IndexCalConstant.COMMUNITY_GOVERN_ABILITY_NULL);
}else{
@ -819,7 +820,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
String customerId = form.getCustomerId();
String monthId = form.getMonthId();
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(form.getCustomerId(), IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode());
List<FactIndexCommunityScoreDTO> factIndexCommunityScoreEntities = factIndexCommunityScoreDao.selectCommunityInfoExistsSub(form.getCustomerAreaCode(),form.getMonthId());
List<FactIndexCommunityScoreDTO> factIndexCommunityScoreEntities = factIndexCommunityScoreDao.selectCommunityInfoExistsSub(form.getCustomerAreaCode(),form.getMonthId(),form.getCustomerId());
detailListByParentCode.forEach(detail -> {
factIndexCommunityScoreEntities.forEach(community -> {
if (detail.getIndexCode().equals(community.getIndexCode())) {

38
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;
@ -225,6 +226,7 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
indexDetailList.forEach(detail -> {
if (IndexCodeEnum.QU_XIA_JI_JIE_DDJNLHZPJZ.getCode().equals(detail.getIndexCode())) {
List<SubAgencyScoreAvgResultDTO> subGridPartyAvgScore = agencyScoreDao.selectAgencyScoreAvg(customerId, monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),IndexCalConstant.STREET_LEVEL);
log.info("subGridPartyAvgScore:::"+subGridPartyAvgScore.toString());
if (CollectionUtils.isEmpty(subGridPartyAvgScore)) {
log.warn(IndexCalConstant.DISTRICT_PARTY_AVG_NULL);
} else if (subGridPartyAvgScore.size() > NumConstant.ZERO) {
@ -247,6 +249,7 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
} else {
// 区名义发文数量
List<Map<String, Object>> publishArticleCountList = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCountMap(customerId, monthId,IndexCalConstant.DISTRICT_LEVEL);
log.info("publishArticleCountList:::"+publishArticleCountList.toString());
if (CollectionUtils.isEmpty(publishArticleCountList)) {
log.warn(IndexCalConstant.DISTRICT_PUBLISH_ARTICLE_LIST_NULL);
} else {
@ -301,6 +304,7 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
detailListByParentCode.forEach(detail -> {
if (IndexCodeEnum.SUO_YOU_JIE_DAO_ZLNLPJZ.getCode().equals(detail.getIndexCode())) {
List<SubAgencyScoreAvgResultDTO> districtGovernAvgList = agencyScoreDao.selectAgencyScoreAvg(customerId, monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),IndexCalConstant.STREET_LEVEL);
log.info("districtGovernAvgList:::"+districtGovernAvgList.toString());
for (int i = 0; i < districtGovernAvgList.size(); i++) {
if (districtGovernAvgList.get(i).getAgencyId().equals(NumConstant.ZERO_STR)){
districtGovernAvgList.remove(districtGovernAvgList.get(i));
@ -327,6 +331,7 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
}
} else if (IndexCodeEnum.SUO_YOU_ZHI_SHU_BMZLNLPJZ.getCode().equals(detail.getIndexCode())){
List<SubAgencyScoreAvgResultDTO> deptScoreAvgList = deptScoreDao.selectGovernDeptScoreAvg(customerId, monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
log.info("deptScoreAvgList:::"+deptScoreAvgList.toString());
for (int i = 0; i < deptScoreAvgList.size(); i++) {
if (deptScoreAvgList.get(i).getAgencyId().equals(NumConstant.ZERO_STR)){
deptScoreAvgList.remove(deptScoreAvgList.get(i));
@ -381,6 +386,7 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
String indexCode = detail.getIndexCode();
if (IndexCodeEnum.QU_XIA_SHU_JIE_DFWNLHZPJZ.getCode().equals(indexCode)) {
List<SubAgencyScoreAvgResultDTO> subStreetAvgList = agencyScoreDao.selectAgencyScoreAvg(customerId, monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode(),IndexCalConstant.STREET_LEVEL);
log.info("subStreetAvgList:::"+subStreetAvgList.toString());
for (int i = 0; i < subStreetAvgList.size(); i++) {
if (subStreetAvgList.get(i).getAgencyId().equals(NumConstant.ZERO_STR)){
subStreetAvgList.remove(subStreetAvgList.get(i));
@ -430,6 +436,7 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
public Boolean districtRelate(String customerId, String monthId) {
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode());
List<AgencyScoreDTO> agencyScoreList = agencyScoreDao.selectAgencyScoreInfo(customerId, monthId, IndexCalConstant.DISTRICT_LEVEL);
log.info("agencyScoreList:::"+agencyScoreList.toString());
detailListByParentCode.forEach(detail -> {
agencyScoreList.forEach(community -> {
if (detail.getIndexCode().equals(community.getIndexCode())) {
@ -607,7 +614,8 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
//党建能力平均值
indexDetailList.forEach(detail -> {
if (IndexCodeEnum.QU_XIA_JI_JIE_DDJNLHZPJZ.getCode().equals(detail.getIndexCode())) {
List<SubAgencyScoreAvgResultDTO> subGridPartyAvgScore = agencyScoreDao.selectAgencyScoreAvgExistsSub(monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),IndexCalConstant.STREET_LEVEL,form.getCustomerAreaCode(),NumConstant.SIX);
List<SubAgencyScoreAvgResultDTO> 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);
} else if (subGridPartyAvgScore.size() > NumConstant.ZERO) {
@ -620,6 +628,10 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
pid.put(c.getParentId(), customerAgencyDao.selectPid(c.getParentId()));
SampleValue s = new SampleValue(c.getParentId(), c.getScore());
index1SampleValues.add(s);
}else {
pid.put(c.getAgencyId(), customerAgencyDao.selectPid(c.getAgencyId()));
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
}
});
BigDecimalScoreCalculator sc = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation()));
@ -629,7 +641,8 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
}
} else {
// 区名义发文数量
List<Map<String, Object>> publishArticleCountList = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCountMapExistSub(monthId,form.getCustomerAreaCode(),NumConstant.SIX);
List<Map<String, Object>> publishArticleCountList = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCountMapExistSubNotSelf(monthId,form.getCustomerAreaCode());
log.info("publishArticleCountList:::"+publishArticleCountList.toString());
if (CollectionUtils.isEmpty(publishArticleCountList)) {
log.warn(IndexCalConstant.DISTRICT_PUBLISH_ARTICLE_LIST_NULL);
} else {
@ -684,7 +697,8 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
Map<String, String> pid = new HashMap<>();
detailListByParentCode.forEach(detail -> {
if (IndexCodeEnum.SUO_YOU_JIE_DAO_ZLNLPJZ.getCode().equals(detail.getIndexCode())) {
List<SubAgencyScoreAvgResultDTO> districtGovernAvgList = agencyScoreDao.selectAgencyScoreAvgExistsSub(monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),IndexCalConstant.STREET_LEVEL,form.getCustomerAreaCode(),NumConstant.SIX);
List<SubAgencyScoreAvgResultDTO> districtGovernAvgList = agencyScoreDao.selectAgencyScoreAvgExistsSub(monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),form.getCustomerAreaCode());
log.info("districtGovernAvgList:::"+districtGovernAvgList.toString());
for (int i = 0; i < districtGovernAvgList.size(); i++) {
if (districtGovernAvgList.get(i).getAgencyId().equals(NumConstant.ZERO_STR)){
districtGovernAvgList.remove(districtGovernAvgList.get(i));
@ -702,6 +716,10 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
pid.put(c.getParentId(), customerAgencyDao.selectPid(c.getParentId()));
SampleValue s = new SampleValue(c.getParentId(), c.getScore());
index1SampleValues.add(s);
}else {
pid.put(c.getAgencyId(), customerAgencyDao.selectPid(c.getAgencyId()));
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
}
});
BigDecimalScoreCalculator sc = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation()));
@ -710,7 +728,8 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
});
}
} else if (IndexCodeEnum.SUO_YOU_ZHI_SHU_BMZLNLPJZ.getCode().equals(detail.getIndexCode())){
List<SubAgencyScoreAvgResultDTO> deptScoreAvgList = deptScoreDao.selectGovernDeptScoreAvgExistsSub(monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),form.getCustomerAreaCode());
List<SubAgencyScoreAvgResultDTO> deptScoreAvgList = deptScoreDao.selectGovernDeptScoreAvgExistsSubNotSelf(monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),form.getCustomerAreaCode());
log.info("deptScoreAvgList:::"+deptScoreAvgList.toString());
for (int i = 0; i < deptScoreAvgList.size(); i++) {
if (deptScoreAvgList.get(i).getAgencyId().equals(NumConstant.ZERO_STR)){
deptScoreAvgList.remove(deptScoreAvgList.get(i));
@ -765,7 +784,8 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
detailListByParentCode.forEach(detail -> {
String indexCode = detail.getIndexCode();
if (IndexCodeEnum.QU_XIA_SHU_JIE_DFWNLHZPJZ.getCode().equals(indexCode)) {
List<SubAgencyScoreAvgResultDTO> subStreetAvgList = agencyScoreDao.selectAgencyScoreAvgExistsSub(monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode(),IndexCalConstant.STREET_LEVEL,form.getCustomerAreaCode(),NumConstant.SIX);
List<SubAgencyScoreAvgResultDTO> 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)){
subStreetAvgList.remove(subStreetAvgList.get(i));
@ -784,6 +804,10 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
pid.put(c.getParentId(), customerAgencyDao.selectPid(c.getParentId()));
SampleValue s = new SampleValue(c.getParentId(), c.getScore());
index1SampleValues.add(s);
}else {
pid.put(c.getAgencyId(), customerAgencyDao.selectPid(c.getAgencyId()));
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
}
});
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), IndexCodeEnum.isAvgIndex(detail.getIndexCode()), sc1);
@ -815,7 +839,8 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
String customerId = form.getCustomerId();
String monthId = form.getMonthId();
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode());
List<AgencyScoreDTO> agencyScoreList = agencyScoreDao.selectAgencyScoreInfoExistsSub(form.getCustomerAreaCode(),NumConstant.SIX,monthId, IndexCalConstant.DISTRICT_LEVEL);
List<AgencyScoreDTO> agencyScoreList = agencyScoreDao.selectAgencyScoreInfoExistsSubSelf(form.getCustomerAreaCode(),monthId, IndexCalConstant.DISTRICT_LEVEL,form.getCustomerId());
log.info("agencyScoreList:::"+agencyScoreList.toString());
detailListByParentCode.forEach(detail -> {
agencyScoreList.forEach(community -> {
if (detail.getIndexCode().equals(community.getIndexCode())) {
@ -843,6 +868,7 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
});
result.add(score);
});
log.info("result:::"+result.toString());
if (!CollectionUtils.isEmpty(result)){
agencyScoreDao.insertStreetRecord(result);
}

2
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);

102
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;
@ -20,10 +17,12 @@ import com.epmet.dao.evaluationindex.indexcoll.FactIndexGovrnAblityOrgMonthlyDao
import com.epmet.dao.evaluationindex.indexcoll.FactIndexPartyAblityOrgMonthlyDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexServiceAblityOrgMonthlyDao;
import com.epmet.dao.evaluationindex.screen.IndexGroupDetailDao;
import com.epmet.dao.evaluationindex.screen.ScreenCustomerAgencyDao;
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;
@ -49,6 +48,7 @@ import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
/**
@ -80,6 +80,8 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
private IndexGroupDetailDao indexGroupDetailDao;
@Autowired
private AgencySelfSubScoreDao agencySelfSubScoreDao;
@Autowired
private ScreenCustomerAgencyDao customerAgencyDao;
/**
* @param form
@ -613,7 +615,8 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
//下属所有社区的党建能力平均值
detailListByParentCode.forEach(detail -> {
if (IndexCodeEnum.JIE_DAO_XIA_SHU_SYSQDJNLHZPJZ.getCode().equals(detail.getIndexCode())) {
List<SubCommunityAvgResultDTO> subCommPartyAvgScore = communityScoreDao.selectSubCommAvgScoreExistSubNotSelf(monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),form.getCustomerAreaCode());
List<SubCommunityAvgResultDTO> dispose = communityScoreDao.selectSubCommAvgScoreExistSubNotSelf(monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),form.getCustomerAreaCode());
List<SubCommunityAvgResultDTO> subCommPartyAvgScore = disposeSubAvg(dispose, form);
if (CollectionUtils.isEmpty(subCommPartyAvgScore)) {
log.warn(IndexCalConstant.COMMUNITY_PARTY_AVG_NULL);
} else if (subCommPartyAvgScore.size() > NumConstant.ZERO) {
@ -623,6 +626,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
partition.forEach(publish -> {
List<SampleValue> index1SampleValues = new ArrayList<>();
publish.forEach(c -> {
c.setParentId(customerAgencyDao.selectAgencyId(form.getCustomerAreaCode()));
pid.put(c.getAgencyId(),c.getParentId());
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
@ -634,7 +638,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
}
} else {
// 街道名义发文数量
List<Map<String, Object>> mapList = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCountMapExistSubNotSelf(monthId,form.getCustomerAreaCode(),NumConstant.NINE);
List<Map<String, Object>> mapList = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCountMapExistSubStreet(monthId,form.getCustomerAreaCode());
if (CollectionUtils.isEmpty(mapList)) {
log.warn(IndexCalConstant.STREET_PUBLISH_ARTICLE_LIST_NULL);
} else {
@ -688,7 +692,8 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
Map<String, String> pid = new HashMap<>();
detailListByParentCode.forEach(detail -> {
if (IndexCodeEnum.JIE_DAO_XIA_SHU_SYSQZLNLHZ.getCode().equals(detail.getIndexCode())) {
List<SubCommunityAvgResultDTO> subGridGovernAvg = communityScoreDao.selectSubCommAvgScoreExistSubNotSelf(monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),form.getCustomerAreaCode());
List<SubCommunityAvgResultDTO> dispose = communityScoreDao.selectSubCommAvgScoreExistSubNotSelf(monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),form.getCustomerAreaCode());
List<SubCommunityAvgResultDTO> subGridGovernAvg = disposeSubAvg(dispose,form);
if (CollectionUtils.isEmpty(subGridGovernAvg)){
log.warn("查询街道下属所有社区治理能力汇总为空");
}else if (subGridGovernAvg.size() > NumConstant.ZERO) {
@ -697,6 +702,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
governAvg.forEach(avg -> {
List<SampleValue> index1SampleValues = new ArrayList<>();
avg.forEach(c -> {
c.setParentId(customerAgencyDao.selectAgencyId(form.getCustomerAreaCode()));
pid.put(c.getAgencyId(),c.getParentId());
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
@ -708,7 +714,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
}
} else {
// 治理能力的六个五级指标
List<Map<String, Object>> communityGovernAbility = factIndexGovrnAblityOrgMonthlyDao.selectCommunityGovernAbilityExistsSubNotSelf(monthId,form.getCustomerAreaCode());
List<Map<String, Object>> communityGovernAbility = disposeFiveLevel(form);
if (CollectionUtils.isEmpty(communityGovernAbility)){
log.warn(IndexCalConstant.STREET_GOVERN_ABILITY_NULL);
}else{
@ -762,7 +768,8 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
detailListByParentCode.forEach(detail -> {
String indexCode = detail.getIndexCode();
if (IndexCodeEnum.JIE_DAO_XIA_SHU_SQFWNLDFPYZ.getCode().equals(indexCode)) {
List<SubCommunityAvgResultDTO> subCommServiceAvg = communityScoreDao.selectSubCommAvgScoreExistSubNotSelf(monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode(),form.getCustomerAreaCode());
List<SubCommunityAvgResultDTO> dispose = communityScoreDao.selectSubCommAvgScoreExistSubNotSelf(monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode(),form.getCustomerAreaCode());
List<SubCommunityAvgResultDTO> subCommServiceAvg = disposeSubAvg(dispose,form);
if (CollectionUtils.isEmpty(subCommServiceAvg)) {
log.warn("查询街道下属社区服务能力得分平均值为空");
} else if (subCommServiceAvg.size() > NumConstant.ZERO) {
@ -772,6 +779,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
BigDecimalScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation()));
List<SampleValue> index1SampleValues = new ArrayList<>();
serviceAvg.forEach(c -> {
c.setParentId(customerAgencyDao.selectAgencyId(form.getCustomerAreaCode()));
pid.put(c.getAgencyId(),c.getParentId());
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
@ -781,7 +789,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
});
}
} else {
List<Map<String, Object>> communityActivityCountList = factIndexServiceAblityOrgMonthlyDao.selectActivityCountMapExistsSubNotSelf(monthId,form.getCustomerAreaCode());
List<Map<String, Object>> communityActivityCountList = disposeActivityCount(form);
if (CollectionUtils.isEmpty(communityActivityCountList)) {
log.warn(IndexCalConstant.STREET_SERVICE_ABILITY_NULL);
}else{
@ -826,7 +834,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
String customerId = form.getCustomerId();
String monthId = form.getMonthId();
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode());
List<AgencyScoreDTO> agencyScoreList = agencyScoreDao.selectAgencyScoreInfoExistsSub(form.getCustomerAreaCode(), NumConstant.NINE, monthId, IndexCalConstant.STREET_LEVEL);
List<AgencyScoreDTO> agencyScoreList = agencyScoreDao.selectAgencyScoreInfoExistsSub(form.getCustomerAreaCode(), monthId, IndexCalConstant.STREET_LEVEL,form.getCustomerId());
detailListByParentCode.forEach(detail -> {
agencyScoreList.forEach(community -> {
if (detail.getIndexCode().equals(community.getIndexCode())) {
@ -860,4 +868,76 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
return true;
}
public List<SubCommunityAvgResultDTO> disposeSubAvg(List<SubCommunityAvgResultDTO> avgScore, CalculateCommonFormDTO formDTO){
List<ScreenProjectOrgDailyDTO> orgIds = customerAgencyDao.selectAgencyByParentAreaCode(formDTO.getCustomerAreaCode());
List<SubCommunityAvgResultDTO> 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<Boolean, List<SubCommunityAvgResultDTO>> groupByStatus = avgScore.stream().collect(Collectors.groupingBy(SubCommunityAvgResultDTO::getScoreStatus));
List<SubCommunityAvgResultDTO> subAvgResultDTOS = groupByStatus.get(false);
if (!CollectionUtils.isEmpty(subAvgResultDTOS)){
AtomicReference<BigDecimal> 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<Map<String, Object>> disposeFiveLevel(CalculateCommonFormDTO formDTO){
List<Map<String, Object>> result = new ArrayList<>();
List<Map<String, Object>> communityGovernAbility = factIndexGovrnAblityOrgMonthlyDao.selectCommunityGovernAbilityExistsSubNotSelf(formDTO.getMonthId(),formDTO.getCustomerAreaCode(), ScreenConstant.STREET);
List<Map<String, Object>> 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<Map<String, Object>> disposeActivityCount(CalculateCommonFormDTO formDTO){
List<Map<String, Object>> result = new ArrayList<>();
List<Map<String, Object>> ActivityCountList = factIndexServiceAblityOrgMonthlyDao.selectActivityCountMapExistsSub(formDTO.getMonthId(),formDTO.getCustomerAreaCode());
List<Map<String, Object>> 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;
}
}

71
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml

@ -142,9 +142,11 @@
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"
AND fias.customer_id = #{customerId}
AND (fias.INDEX_CODE = "zhilinengli"
OR fias.INDEX_CODE = "dangjiannengli"
OR fias.INDEX_CODE = "fuwunengli")
@ -152,24 +154,71 @@
<!-- 区下级街道得分平均值 存在下级客户 -->
<select id="selectAgencyScoreAvgExistsSub" resultType="com.epmet.dto.indexcal.SubAgencyScoreAvgResultDTO">
SELECT a2.pid AS parentId,a.monthId,a.quarterId,a.yearId,ROUND(AVG( a.score ),6) AS score,a.customerId,a.parentId AS agencyId FROM
(SELECT
fics.agency_id AS agencyId,
fics.month_id AS monthId,
fics.quarter_id AS quarterId,
fics.year_id AS yearId,
ROUND(AVG( fics.score ),6) AS score,
fics.customer_id AS customerId,
(SELECT AGENCY_ID FROM screen_customer_agency WHERE AREA_CODE = #{areaCode}) AS parentId
FROM
fact_index_agency_score fics
WHERE
fics.del_flag = '0'
AND fics.month_id = #{monthId}
AND fics.index_code = #{indexCode}
AND fics.agency_id IN (SELECT AGENCY_ID FROM screen_customer_agency WHERE PARENT_AREA_CODE = #{areaCode})
GROUP BY agencyId) a
LEFT JOIN screen_customer_agency a2 ON a2.AGENCY_ID = a.parentId
GROUP BY a2.AGENCY_ID
</select>
<select id="selectAgencyScoreAvgByOrgIds" resultType="com.epmet.dto.indexcal.SubAgencyScoreAvgResultDTO">
SELECT
fics.agency_id,
fics.month_id,
fics.quarter_id,
fics.year_id,
fics.agency_id AS agencyId,
fics.month_id AS monthId,
fics.quarter_id AS quarterId,
fics.year_id AS yearId,
ROUND(AVG( fics.score ),6) AS score,
fics.customer_id,
PARENT_AGENCY_ID AS parentId
fics.customer_id AS customerId,
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
WHERE
fics.del_flag = '0'
AND sca.level = 'district'
AND sca.AREA_CODE LIKE CONCAT(#{areaCode},'%')
AND fics.month_id = #{monthId}
AND fics.index_code = #{indexCode}
AND fics.DATA_TYPE = #{dataType}
GROUP BY fics.parent_agency_id
AND (
<foreach collection="orgIds" item="org" separator=" or ">
fics.agency_id = #{org}
</foreach>
)
</select>
<select id="selectAgencyScoreInfoExistsSubSelf" resultType="com.epmet.dto.indexcal.AgencyScoreDTO">
SELECT
fias.CUSTOMER_ID,
fias.AGENCY_ID,
fias.MONTH_ID,
fias.QUARTER_ID,
fias.YEAR_ID,
fias.SCORE,
fias.INDEX_CODE,
fias.PARENT_AGENCY_ID
FROM
fact_index_agency_score fias
LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = fias.AGENCY_ID
WHERE
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"
OR fias.INDEX_CODE = "fuwunengli")
</select>
</mapper>

7
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 LIKE CONCAT(#{areaCode},'%')
AND sca.AREA_CODE != #{areaCode}
AND sca.`LEVEL` = 'community'
AND fics.month_id = #{monthId}
AND fics.index_code = #{indexCode}
GROUP BY fics.parent_agency_id
GROUP BY parentId
</select>
</mapper>

22
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/DeptScoreDao.xml

@ -38,6 +38,7 @@
WHERE
fidc.del_flag = '0'
AND fidc.IS_TOTAL = '0'
AND sca.level = 'district'
AND fidc.customer_id = #{customerId}
AND fidc.month_id = #{monthId}
AND fidc.index_code = #{indexCode}
@ -172,4 +173,25 @@
AND fidc.index_code = #{indexCode}
GROUP BY fidc.agency_id
</select>
<select id="selectGovernDeptScoreAvgExistsSubNotSelf" resultType="com.epmet.dto.indexcal.SubAgencyScoreAvgResultDTO">
SELECT
fidc.agency_id,
fidc.month_id,
fidc.quarter_id,
fidc.year_id,
AVG( fidc.score ) AS score,
fidc.customer_id,
sca.pid AS parentId
FROM
fact_index_dept_score fidc
LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = fidc.AGENCY_ID
WHERE
fidc.del_flag = '0'
AND fidc.IS_TOTAL = '0'
AND sca.AREA_CODE LIKE CONCAT(#{areaCode},'%')
AND sca.AREA_CODE != #{areaCode}
AND fidc.month_id = #{monthId}
AND fidc.index_code = #{indexCode}
GROUP BY fidc.agency_id
</select>
</mapper>

30
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml

@ -193,7 +193,37 @@
WHERE
gm.del_flag = '0'
AND gm.month_id = #{monthId}
AND gm.DATA_TYPE = #{level}
AND sca.AREA_CODE LIKE CONCAT(#{areaCode},'%')
AND sca.AREA_CODE != #{areaCode}
AND gm.PARENT_ID = '0'
</select>
<!-- 孔村单独查询 -->
<select id="selectCommunityGovernAbilityIsKongCun" resultType="java.util.Map">
SELECT
gm.AGENCY_ID,
gm.PARENT_ID,
gm.MONTH_ID,
gm.QUARTER_ID,
gm.YEAR_ID,
ROUND(SUM(gm.TRANSFERED_COUNT),6) AS TRANSFERED_COUNT,
ROUND(SUM(gm.CLOSED_PROJECT_COUNT),6) AS CLOSED_PROJECT_COUNT,
ROUND(AVG(gm.RESP_PROJECT_RATIO),6) AS RESP_PROJECT_RATIO,
ROUND(AVG(gm.OVERDUE_PROJECT_RATIO),6) AS OVERDUE_PROJECT_RATIO,
ROUND(AVG(gm.CLOSED_PROJECT_RATIO),6) AS CLOSED_PROJECT_RATIO,
ROUND(AVG(gm.SATISFACTION_RATIO),6) AS SATISFACTION_RATIO,
ROUND(AVG(gm.HANDLE_PROJECT_RATIO),6) AS HANDLE_PROJECT_RATIO
FROM
fact_index_govrn_ablity_org_monthly gm
LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = gm.AGENCY_ID
LEFT JOIN screen_customer_agency a2 ON a2.AGENCY_ID = gm.PARENT_ID
WHERE
gm.del_flag = '0'
AND gm.month_id = #{monthId}
AND gm.DATA_TYPE = 'street'
AND sca.AREA_CODE LIKE CONCAT(#{areaCode},'%')
AND sca.AREA_CODE != #{areaCode}
AND gm.PARENT_ID != '0'
</select>
</mapper>

8
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityOrgMonthlyDao.xml

@ -132,7 +132,7 @@
</select>
<!-- 查询社区下的发文数 Map 存在下级客户 -->
<select id="selectPublishArticleCountMapExistSub" resultType="java.util.Map">
<select id="selectPublishArticleCountMapExistSubStreet" resultType="java.util.Map">
SELECT
pm.AGENCY_ID,
pm.PARENT_ID,
@ -146,7 +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.PARENT_AREA_CODE = #{areaCode}
AND pm.month_id = #{monthId}
</select>
<select id="selectPublishArticleCountMapExistSubNotSelf" resultType="java.util.Map">
@ -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}
</select>
<select id="selectPublishArticleCountMapbyAreaCodeNotSelf" resultType="java.util.Map">
@ -182,6 +181,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}
</select>

24
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexServiceAblityOrgMonthlyDao.xml

@ -127,8 +127,11 @@
LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = sm.AGENCY_ID
WHERE
sm.del_flag = '0'
AND sm.DATA_TYPE = 'street'
AND sca.AREA_CODE LIKE CONCAT(#{areaCode},'%')
AND sca.AREA_CODE != #{areaCode}
AND sm.month_id = #{monthId}
AND sm.PARENT_ID = '0'
</select>
<select id="selectActivityCountMapExistsSubNotSelf" resultType="java.util.Map">
SELECT
@ -144,8 +147,29 @@
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}
</select>
<select id="selectActivityCountMapIsKongCun" resultType="java.util.Map">
SELECT
sm.AGENCY_ID,
sm.PARENT_ID,
sm.MONTH_ID,
sm.QUARTER_ID,
sm.YEAR_ID,
ROUND(SUM(sm.ACTIVITY_COUNT),6) AS ACTIVITY_COUNT,
sm.CUSTOMER_ID
FROM
fact_index_service_ablity_org_monthly sm
LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = sm.AGENCY_ID
WHERE
sm.del_flag = '0'
AND sm.DATA_TYPE = 'street'
AND sca.AREA_CODE LIKE CONCAT(#{areaCode},'%')
AND sca.AREA_CODE != #{areaCode}
AND sm.month_id = #{monthId}
AND sm.PARENT_ID != '0'
</select>
</mapper>

26
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml

@ -390,4 +390,30 @@
WHERE DEL_FLAG = 0
and sca.AREA_CODE like CONCAT(#{areaCode},'%')
</select>
<!-- 根据areaCode查询下级组织 -->
<select id="selectAgencyByParentAreaCode" resultType="com.epmet.dto.screen.ScreenProjectOrgDailyDTO">
SELECT
sca.CUSTOMER_ID,
sca.AGENCY_ID AS orgId,
sca.PID,
sca.PIDS,
sca.`LEVEL` AS orgType,
sca.AREA_CODE
FROM screen_customer_agency sca
WHERE DEL_FLAG = 0
and sca.PARENT_AREA_CODE = #{areaCode}
</select>
<select id="selectParentId" resultType="java.lang.String">
select sca.AGENCY_ID from screen_customer_agency sca
where sca.AREA_CODE=
(
select m.PARENT_AREA_CODE from screen_customer_agency m
where m.AGENCY_ID=#{agencyId}
)
</select>
<select id="selectAgencyId" resultType="java.lang.String">
select sca.AGENCY_ID from screen_customer_agency sca
where sca.AREA_CODE= #{areaCode}
</select>
</mapper>

2
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;
}

3
epmet-module/gov-grid/gov-grid-server/src/main/java/com/epmet/controller/ResiGroupController.java

@ -140,8 +140,9 @@ public class ResiGroupController {
*/
@PostMapping("edit-auditing-list")
@RequirePermission(requirePermission = RequirePermissionEnum.WORK_GRASSROOTS_GROUP_EDIT_AUDITINGLIST)
public Result<List<ApplyingGroupResultDTO>> getEditAuditingList(@RequestBody CommonGridAndPageFormDTO param){
public Result<List<ApplyingGroupResultDTO>> getEditAuditingList(@LoginUser TokenDto tokenDto, @RequestBody CommonGridAndPageFormDTO param){
ValidatorUtils.validateEntity(param, CommonGridAndPageFormDTO.GridPageGroup.class);
param.setCustomerId(tokenDto.getCustomerId());
return groupOpenFeignClient.govEditAuditingList(param);
}

2
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/CommonGridAndPageFormDTO.java

@ -37,4 +37,6 @@ public class CommonGridAndPageFormDTO implements Serializable {
@Min(1)
private Integer pageSize;
private String customerId;
}

13
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java

@ -19,6 +19,7 @@ package com.epmet.modules.group.controller;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
@ -405,7 +406,17 @@ public class ResiGroupController {
*/
@PostMapping("gov-edit-auditing-list")
public Result<List<ApplyingGroupResultDTO>> govEditAuditingList(@RequestBody CommonGridAndPageFormDTO param){
return new Result<List<ApplyingGroupResultDTO>>().ok(resiGroupService.getEditAuditingList(param));
List<ApplyingGroupResultDTO> list = resiGroupService.getEditAuditingList(param);
if (StrConstant.SPECIAL_CUSTOMER.equals(param.getCustomerId())) {
list.forEach(item -> {
if (item.getMessageText().contains("热心居民")) {
item.setMessageText(item.getMessageText().replace("热心居民", "组长"));
} else if (item.getMessageText().contains("居民")) {
item.setMessageText(item.getMessageText().replace("居民", "学员"));
}
});
}
return new Result<List<ApplyingGroupResultDTO>>().ok(list);
}
/**

42
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java

@ -21,10 +21,7 @@ import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.AppClientConstant;
import com.epmet.commons.tools.constant.EpmetRoleKeyConstant;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.*;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
@ -384,7 +381,11 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou
applyCreateGroupFormDTO.getGridId());
if (!NumConstant.ONE_STR.equals(userRoleDTO.getPartymemberFlag()) && !NumConstant.ONE_STR.equals(userRoleDTO.getWarmHeartedFlag())) {
logger.info(String.format("创建小组异常:%s",EpmetErrorCode.CANNOT_CREATE_GROUP.getMsg()));
throw new RenException(EpmetErrorCode.CANNOT_CREATE_GROUP.getCode());
if (StrConstant.SPECIAL_CUSTOMER.equals(applyCreateGroupFormDTO.getCustomerId())) {
throw new RenException(8002, "只有组长才能创建小组");
} else {
throw new RenException(EpmetErrorCode.CANNOT_CREATE_GROUP.getCode());
}
}
String roleName = "";
if(NumConstant.ONE_STR.equals(userRoleDTO.getPartymemberFlag())){
@ -495,7 +496,12 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou
Result<UserResiInfoResultDTO> result = epmetUserFeignClient.getUserResiInfoDTO(resiUserInfoFormDTO);
if (!result.success() || null == result.getData() || StringUtils.isBlank(result.getData().getRegMobile())) {
logger.info(String.format("加入小组界面初始化查询成功,当前用户非注册居民,epmet-user-server接口入参%s,返回%s",JSON.toJSONString(resiUserInfoFormDTO),JSON.toJSONString(result)));
throw new RenException(EpmetErrorCode.CANNOT_JOIN_GROUP.getCode());
if (StrConstant.SPECIAL_CUSTOMER.equals(initApplyGroupFormDTO.getCustomerId())) {
throw new RenException(8001, "只有注册学员才可以加入小组");
} else {
throw new RenException(EpmetErrorCode.CANNOT_JOIN_GROUP.getCode());
}
}
}
@ -526,7 +532,11 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou
initApplyCreatedGroupFormDTO.getGridId());
if (!NumConstant.ONE_STR.equals(userRoleDTO.getPartymemberFlag()) && !NumConstant.ONE_STR.equals(userRoleDTO.getWarmHeartedFlag())) {
logger.info(String.format("创建小组界面初始化查询成功,用户角色列表%s",JSON.toJSONString(userRoleDTO)));
throw new RenException(EpmetErrorCode.CANNOT_CREATE_GROUP.getCode());
if (StrConstant.SPECIAL_CUSTOMER.equals(initApplyCreatedGroupFormDTO.getCustomerId())) {
throw new RenException(8002, "只有组长才能创建小组");
} else {
throw new RenException(EpmetErrorCode.CANNOT_CREATE_GROUP.getCode());
}
}
}
@ -849,7 +859,17 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou
throw new RenException(ModuleConstant.PAGE_INDEX_NOT_NULL);
}
params.setPageNo((params.getPageNo() - NumConstant.ONE) * params.getPageSize());
return new Result<List<ApplyingGroupResultDTO>>().ok(baseDao.getApplyingGroupsByCustIdAndGridId(params));
List<ApplyingGroupResultDTO> list = baseDao.getApplyingGroupsByCustIdAndGridId(params);
if (StrConstant.SPECIAL_CUSTOMER.equals(params.getCustomerId())) {
list.forEach(item -> {
if (item.getMessageText().contains("热心居民")) {
item.setMessageText(item.getMessageText().replace("热心居民", "组长"));
} else if (item.getMessageText().contains("居民")) {
item.setMessageText(item.getMessageText().replace("居民", "学员"));
}
});
}
return new Result<List<ApplyingGroupResultDTO>>().ok(list);
}
/**
@ -1234,7 +1254,11 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou
}
}
if (!isWarmhearted && !isPartymember) {
throw new RenException(EpmetErrorCode.CANNOT_CREATE_GROUP.getCode(), "只有党员和热心居民才能创建和编辑小组");
if (StrConstant.SPECIAL_CUSTOMER.equals(customerId)) {
throw new RenException(8002, "只有组长才能创建小组");
} else {
throw new RenException(EpmetErrorCode.CANNOT_CREATE_GROUP.getCode());
}
}
String roleName = "";
if (isPartymember) {

12
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/invitation/service/impl/GroupInvitationServiceImpl.java

@ -387,7 +387,11 @@ public class GroupInvitationServiceImpl extends BaseServiceImpl<GroupInvitationD
//4、校验是否已经注册居民
if(null==result.getData().getUserRoleList()||result.getData().getUserRoleList().size()==0){
logger.warn(String.format("用户通过邀请链接入组失败,返回角色列表为空错误编码%s,错误提示%s",EpmetErrorCode.CANNOT_JOIN_GROUP.getCode(),EpmetErrorCode.CANNOT_JOIN_GROUP.getMsg()));
throw new RenException(EpmetErrorCode.CANNOT_JOIN_GROUP.getCode());
if (StrConstant.SPECIAL_CUSTOMER.equals(resiGroupDTO.getCustomerId())) {
throw new RenException(8001, "只有注册学员才可以加入小组");
} else {
throw new RenException(EpmetErrorCode.CANNOT_JOIN_GROUP.getCode());
}
}
UserRoleDTO userRoleDTO=this.getUserRoleDTO(result.getData().getUserRoleList());
//5、新增一条邀请入群、直接审核通过的入群记录
@ -481,7 +485,11 @@ public class GroupInvitationServiceImpl extends BaseServiceImpl<GroupInvitationD
//4、校验是否已经注册居民
if(null==result.getData().getUserRoleList()||result.getData().getUserRoleList().size()==0){
logger.warn(String.format("用户通过扫码入组失败,返回角色列表为空错误编码%s,错误提示%s",EpmetErrorCode.CANNOT_JOIN_GROUP.getCode(),EpmetErrorCode.CANNOT_JOIN_GROUP.getMsg()));
throw new RenException(EpmetErrorCode.CANNOT_JOIN_GROUP.getCode());
if (StrConstant.SPECIAL_CUSTOMER.equals(resiGroupDTO.getCustomerId())) {
throw new RenException(8001, "只有注册学员才可以加入小组");
} else {
throw new RenException(EpmetErrorCode.CANNOT_JOIN_GROUP.getCode());
}
}
//2020.11.17 sun 新增扫描或邀请进组是否需要审核的逻辑 start
GroupMemeberOperationDTO groupMemeberOperation = new GroupMemeberOperationDTO();

14
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/service/impl/ResiGroupMemberServiceImpl.java

@ -226,7 +226,11 @@ public class ResiGroupMemberServiceImpl extends BaseServiceImpl<ResiGroupMemberD
resiGroupDTO.getGridId());
if (NumConstant.ZERO_STR.equals(userRoleDTO.getRegisteredResiFlag())) {
logger.error(String.format("居民端用户【%s】申请加入小组【%s】失败,%s", applyJoinGroupFormDTO.getUserId(), applyJoinGroupFormDTO.getGroupId(), EpmetErrorCode.CANNOT_JOIN_GROUP.getMsg()));
throw new RenException(EpmetErrorCode.CANNOT_JOIN_GROUP.getCode());
if (StrConstant.SPECIAL_CUSTOMER.equals(resiGroupDTO.getCustomerId())) {
throw new RenException(8001, "只有注册学员才可以加入小组");
} else {
throw new RenException(EpmetErrorCode.CANNOT_JOIN_GROUP.getCode());
}
}
}
//查看用户最新一条成员处理记录,避免重复申请
@ -279,7 +283,13 @@ public class ResiGroupMemberServiceImpl extends BaseServiceImpl<ResiGroupMemberD
} else {
currentUserName = resultUserInfo.getData().getShowName();
}
String messageContent = String.format(UserMessageConstant.APPLY_JOIN_GROUP, currentUserName, resiGroupDTO.getGroupName());
String messageContent = "";
if (StrConstant.SPECIAL_CUSTOMER.equals(resiGroupDTO.getCustomerId())) {
messageContent = String.format("学员%s申请加入小组【%s】,请审核", currentUserName, resiGroupDTO.getGroupName());
} else {
messageContent = String.format(UserMessageConstant.APPLY_JOIN_GROUP, currentUserName, resiGroupDTO.getGroupName());
}
userMessage.setMessageContent(messageContent);
userMessage.setReadFlag(ReadFlagConstant.UN_READ);
userMessage.setTitle(UserMessageConstant.GROUP_TITLE);

5
epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/advice/controller/AdviceController.java

@ -1,6 +1,5 @@
package com.epmet.modules.advice.controller;
import com.epmet.commons.tools.security.user.LoginUserUtil;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.MyAdviceListFormDTO;
@ -14,7 +13,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/**
* @description: 用户建议controller
@ -27,9 +25,6 @@ public class AdviceController {
@Autowired
private AdviceService adviceService;
@Autowired
private LoginUserUtil loginUserUtil;
/**
* @Description 提交建议
* @param dto

4
epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/warmhearted/controller/ResiWarmheartedApplyController.java

@ -138,7 +138,7 @@ public class ResiWarmheartedApplyController {
@PostMapping("approve")
public Result approve(@LoginUser TokenDto tokenDTO, @RequestBody ResiWarmAuditApproveFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO);
return resiWarmheartedApplyService.approve(formDTO);
return resiWarmheartedApplyService.approve(tokenDTO, formDTO);
}
/**
@ -160,7 +160,7 @@ public class ResiWarmheartedApplyController {
@PostMapping("getdetail")
public Result<ResiWarmAuditResultDTO> getDetail(@LoginUser TokenDto tokenDTO, @RequestBody ResiWarmGetDetailFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO);
return resiWarmheartedApplyService.getDetail(formDTO);
return resiWarmheartedApplyService.getDetail(tokenDTO, formDTO);
}
/**

5
epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/warmhearted/service/ResiWarmheartedApplyService.java

@ -19,6 +19,7 @@ package com.epmet.modules.warmhearted.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.modules.warmhearted.entity.ResiWarmheartedApplyEntity;
import com.epmet.resi.partymember.dto.warmhearted.ResiWarmheartedApplyDTO;
@ -140,7 +141,7 @@ public interface ResiWarmheartedApplyService extends BaseService<ResiWarmhearted
* @return void
* @author sun
*/
Result approve(ResiWarmAuditApproveFormDTO formDTO);
Result approve(TokenDto tokenDTO, ResiWarmAuditApproveFormDTO formDTO);
/**
* 政府端-热心居民申请-审核驳回
@ -158,7 +159,7 @@ public interface ResiWarmheartedApplyService extends BaseService<ResiWarmhearted
* @return void
* @author sun
*/
Result<ResiWarmAuditResultDTO> getDetail(ResiWarmGetDetailFormDTO formDTO);
Result<ResiWarmAuditResultDTO> getDetail(TokenDto tokenDTO, ResiWarmGetDetailFormDTO formDTO);
/**
* @param gridIdList

86
epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/warmhearted/service/impl/ResiWarmheartedApplyServiceImpl.java

@ -20,13 +20,11 @@ package com.epmet.modules.warmhearted.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.AppClientConstant;
import com.epmet.commons.tools.constant.EpmetRoleKeyConstant;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.*;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.PartyMemberConstant;
@ -155,8 +153,13 @@ public class ResiWarmheartedApplyServiceImpl extends BaseServiceImpl<ResiWarmhea
userResiInfoFormDTO.setUserId(formDTO.getUserId());
Result<UserResiInfoResultDTO> result1 = epmetUserFeignClient.getUserResiInfoDTO(userResiInfoFormDTO);
if (!result1.success() || null == result1.getData()) {
result.setCode(EpmetErrorCode.CANNOT_AUDIT_WARM.getCode());
result.setMsg(EpmetErrorCode.CANNOT_AUDIT_WARM.getMsg());
if (StrConstant.SPECIAL_CUSTOMER.equals(formDTO.getCustomerId())) {
result.setCode(8201);
result.setMsg("请完善学员信息");
} else {
result.setCode(EpmetErrorCode.CANNOT_AUDIT_WARM.getCode());
result.setMsg(EpmetErrorCode.CANNOT_AUDIT_WARM.getMsg());
}
return result;
}
//1:热心居民申请行为记录表新增数据
@ -200,7 +203,12 @@ public class ResiWarmheartedApplyServiceImpl extends BaseServiceImpl<ResiWarmhea
throw new RenException(ResiWarmheartedVisitConstant.SELECT_USERINFO_EXCEPTION);
}
String showName = resultUserInfo.getData().getShowName();
String messageContent = String.format(ResiWarmUserMessageConstant.RESIWARM_APPLY_MSG, showName);
String messageContent = "";
if (StrConstant.SPECIAL_CUSTOMER.equals(formDTO.getCustomerId())) {
messageContent = String.format("%s申请成为组长,请审核。", showName);
} else {
messageContent = String.format(ResiWarmUserMessageConstant.RESIWARM_APPLY_MSG, showName);
}
formDTO.setMessageText(messageContent);
//1:将申请记录存入热心居民申请表中
saveResiWarmApply(formDTO);
@ -212,7 +220,11 @@ public class ResiWarmheartedApplyServiceImpl extends BaseServiceImpl<ResiWarmhea
throw new RenException(ResiWarmheartedVisitConstant.SAVE_MSG_EXCEPTION);
}
result.setCode(NumConstant.ZERO);
result.setMsg(ResiWarmheartedVisitConstant.RESI_WARM_SUBMIT);
if (StrConstant.SPECIAL_CUSTOMER.equals(formDTO.getCustomerId())) {
result.setMsg("组长信息已提交成功,请等待后台审核。");
} else {
result.setMsg(ResiWarmheartedVisitConstant.RESI_WARM_SUBMIT);
}
}
return result;
}
@ -270,7 +282,11 @@ public class ResiWarmheartedApplyServiceImpl extends BaseServiceImpl<ResiWarmhea
msgDTO.setGridId(formDTO.getGridId());
msgDTO.setUserId(staff.getUserId());
msgDTO.setApp(AppClientConstant.APP_GOV);
msgDTO.setTitle(ResiWarmUserMessageConstant.GROUP_TITLE);
if (StrConstant.SPECIAL_CUSTOMER.equals(formDTO.getCustomerId())) {
msgDTO.setTitle("您有一条组长申请消息");
} else {
msgDTO.setTitle(ResiWarmUserMessageConstant.GROUP_TITLE);
}
msgDTO.setMessageContent(formDTO.getMessageText());
msgDTO.setReadFlag(ReadFlagConstant.UN_READ);
msgList.add(msgDTO);
@ -280,7 +296,11 @@ public class ResiWarmheartedApplyServiceImpl extends BaseServiceImpl<ResiWarmhea
subscribeDTO.setGridId(formDTO.getGridId());
subscribeDTO.setUserId(staff.getUserId());
subscribeDTO.setCustomerId(formDTO.getCustomerId());
subscribeDTO.setBehaviorType(ResiWarmUserMessageConstant.WX_WARMHEARTED_BEHAVIOR);
if (StrConstant.SPECIAL_CUSTOMER.equals(formDTO.getCustomerId())) {
subscribeDTO.setBehaviorType("组长申请消息");
} else {
subscribeDTO.setBehaviorType(ResiWarmUserMessageConstant.WX_WARMHEARTED_BEHAVIOR);
}
subscribeDTO.setMessageContent(formDTO.getMessageText());
subscribeDTO.setMessageTime(new Date());
subscribeList.add(subscribeDTO);
@ -384,7 +404,7 @@ public class ResiWarmheartedApplyServiceImpl extends BaseServiceImpl<ResiWarmhea
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Result approve(ResiWarmAuditApproveFormDTO formDTO) {
public Result approve(TokenDto tokenDTO, ResiWarmAuditApproveFormDTO formDTO) {
Result result = new Result();
//0:先校验数据是否是未审核状态,防止接口测试调用多次
ResiWarmheartedApplyEntity entity = baseDao.selectById(formDTO.getApplyId());
@ -399,7 +419,11 @@ public class ResiWarmheartedApplyServiceImpl extends BaseServiceImpl<ResiWarmhea
//2:审核通过的添加热心居民的角色
if (num < NumConstant.ONE) {
logger.error(String.format("政府端-热心居民申请-审核通过错误,applyId=%s,错误提示:%s",ResiWarmheartedVisitConstant.UPDATE_EXCEPTION));
throw new RenException(ResiWarmheartedVisitConstant.UPDATE_EXCEPTION);
if (StrConstant.SPECIAL_CUSTOMER.equals(tokenDTO.getCustomerId())) {
throw new RenException("组长申请数据更新失败,组长角色添加失败");
} else {
throw new RenException(ResiWarmheartedVisitConstant.UPDATE_EXCEPTION);
}
}
//查询需要添加热心居民角色的userId
UserRoleDTO dto = new UserRoleDTO();
@ -413,7 +437,11 @@ public class ResiWarmheartedApplyServiceImpl extends BaseServiceImpl<ResiWarmhea
dto.setGridId(entity.getGridId());
result = epmetUserFeignClient.saveUserRole(dto);
//3:为申请人发送审核通过消息提示
result = auditMessage(entity, ResiWarmUserMessageConstant.AUDIT_APPROVE_MSG);
if (StrConstant.SPECIAL_CUSTOMER.equals(entity.getCustomerId())) {
result = auditMessage(entity, "您申请的%s组长已审核通过,请查看。");
} else {
result = auditMessage(entity, ResiWarmUserMessageConstant.AUDIT_APPROVE_MSG);
}
//5:更新这个人注册热心居民的网格下的所在的组的热心居民数信息
ResiIdentityFormDTO identityParam = new ResiIdentityFormDTO();
identityParam.setUserId(entity.getUserId());
@ -434,7 +462,11 @@ public class ResiWarmheartedApplyServiceImpl extends BaseServiceImpl<ResiWarmhea
userMessageFormDTO.setGridId(formDTO.getGridId());
userMessageFormDTO.setUserId(formDTO.getUserId());
userMessageFormDTO.setApp(AppClientConstant.APP_RESI);
userMessageFormDTO.setTitle(ResiWarmUserMessageConstant.GROUP_TITLE);
if (StrConstant.SPECIAL_CUSTOMER.equals(formDTO.getCustomerId())) {
userMessageFormDTO.setTitle("您有一条组长申请消息");
} else {
userMessageFormDTO.setTitle(ResiWarmUserMessageConstant.GROUP_TITLE);
}
//调用gov-org服务查询网格信息
CustomerGridFormDTO customerGridFormDTO = new CustomerGridFormDTO();
customerGridFormDTO.setGridId(formDTO.getGridId());
@ -453,7 +485,11 @@ public class ResiWarmheartedApplyServiceImpl extends BaseServiceImpl<ResiWarmhea
wxSubscribeMessageFormDTO.setUserId(formDTO.getUserId());
wxSubscribeMessageFormDTO.setGridId(formDTO.getGridId());
wxSubscribeMessageFormDTO.setClientType(AppClientConstant.APP_RESI);
wxSubscribeMessageFormDTO.setBehaviorType(ResiWarmUserMessageConstant.WX_WARMHEARTED_BEHAVIOR);
if (StrConstant.SPECIAL_CUSTOMER.equals(formDTO.getCustomerId())) {
wxSubscribeMessageFormDTO.setBehaviorType("组长申请消息");
} else {
wxSubscribeMessageFormDTO.setBehaviorType(ResiWarmUserMessageConstant.WX_WARMHEARTED_BEHAVIOR);
}
wxSubscribeMessageFormDTO.setMessageContent(messageContent);
wxSubscribeMessageFormDTO.setMessageTime(new Date());
List<WxSubscribeMessageFormDTO> msgList = new ArrayList<>();
@ -487,7 +523,11 @@ public class ResiWarmheartedApplyServiceImpl extends BaseServiceImpl<ResiWarmhea
baseDao.updateById(entity);
//2:为申请人发送审核驳回消息提示
//查询申请信息
auditMessage(entity, ResiWarmUserMessageConstant.AUDIT_REJECT_MSG);
if (StrConstant.SPECIAL_CUSTOMER.equals(entity.getCustomerId())) {
auditMessage(entity, "您申请的%s组长,已被驳回,原因:%s");
} else {
auditMessage(entity, ResiWarmUserMessageConstant.AUDIT_REJECT_MSG);
}
return result;
}
@ -499,12 +539,16 @@ public class ResiWarmheartedApplyServiceImpl extends BaseServiceImpl<ResiWarmhea
* @author sun
*/
@Override
public Result<ResiWarmAuditResultDTO> getDetail(ResiWarmGetDetailFormDTO formDTO) {
public Result<ResiWarmAuditResultDTO> getDetail(TokenDto tokenDTO, ResiWarmGetDetailFormDTO formDTO) {
Result<ResiWarmAuditResultDTO> result = new Result<>();
//1:根据申请Id查询热心居民申请审核详情
ResiWarmheartedApplyEntity entity = baseDao.selectById(formDTO.getApplyId());
if (null == entity) {
result.error(ResiWarmheartedVisitConstant.SELECT_EXCEPTION);
if (StrConstant.SPECIAL_CUSTOMER.equals(tokenDTO.getCustomerId())) {
result.error("根据申请Id未查询到组长申请详情信息");
} else {
result.error(ResiWarmheartedVisitConstant.SELECT_EXCEPTION);
}
return result;
}
//2:修改申请数据状态为已读
@ -518,7 +562,11 @@ public class ResiWarmheartedApplyServiceImpl extends BaseServiceImpl<ResiWarmhea
userResiInfoFormDTO.setUserId(entity.getUserId());
Result<UserResiInfoResultDTO> resultUserInfo = epmetUserFeignClient.getUserResiInfoDTO(userResiInfoFormDTO);
if (!resultUserInfo.success() || null == resultUserInfo.getData()) {
result.error(ResiWarmheartedVisitConstant.SELECT_EXCEPTION);
if (StrConstant.SPECIAL_CUSTOMER.equals(tokenDTO.getCustomerId())) {
result.error("根据申请Id未查询到组长申请详情信息");
} else {
result.error(ResiWarmheartedVisitConstant.SELECT_EXCEPTION);
}
return result;
}
UserResiInfoResultDTO userInfo = resultUserInfo.getData();

152
epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/util/RSASignature.java

@ -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;
}
}

2
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/SubmitAdviceFormDTO.java

@ -3,6 +3,7 @@ package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.util.List;
@ -36,6 +37,7 @@ public class SubmitAdviceFormDTO implements Serializable {
/**
* 电话号码可为空 *不为空需校验
*/
@Pattern(regexp = "^1[3456789]\\d{9}$", message = "请输入正确的手机号")
private String phone;
/**

9
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserAdviceController.java

@ -25,8 +25,8 @@ import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.AssertUtils;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.dto.UserAdviceDTO;
import com.epmet.dto.form.AdviceListFormDTO;
import com.epmet.dto.form.MyAdviceListFormDTO;
@ -47,7 +47,6 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
/**
@ -181,11 +180,7 @@ public class UserAdviceController {
@PostMapping("submitadvice")
public Result submitAdvice(@RequestBody SubmitAdviceFormDTO dto){
ValidatorUtils.validateEntity(dto);
if (StringUtils.isNotBlank(dto.getPhone())){
if (!Pattern.matches("^1[3456789]\\d{9}$",dto.getPhone())){
throw new RenException("手机号格式错误");
}
}else {
if (StringUtils.isBlank(dto.getPhone())) {
dto.setPhone("*");
}
userAdviceService.submitAdvice(dto,loginUserUtil.getLoginUserId());

5
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<RegisterRelationEntity> {
* @date 2020.07.23 15:31
**/
RegisterRelationEntity selectRegisteredGridIdByUserId(@Param("userId") String userId);
RegisterRelationEntity selectRegisteredGridIdByUserIdAndCustomerId(@Param("userId") String userId, @Param("customerId")String customerId);
}

91
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<String,Object> 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<BelongGridNameResultDTO> 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<UserWechatEntity> 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

2
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GridLatestServiceImpl.java

@ -210,7 +210,7 @@ public class GridLatestServiceImpl extends BaseServiceImpl<GridLatestDao, GridLa
}
allData.forEach(info -> {
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());
}

2
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());
}

1
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBaseInfoServiceImpl.java

@ -366,6 +366,7 @@ public class UserBaseInfoServiceImpl extends BaseServiceImpl<UserBaseInfoDao, Us
logger.error("com.epmet.service.impl.UserBaseInfoServiceImpl.extUserInfo,查询不到用户最近访问的网格,用户Id:{}",param.getUserId());
return result;
}
result.setCustomerId(currentGrid.getCustomerId());
result.setGridId(currentGrid.getGridId());
UserRoleFormDTO roleParam = new UserRoleFormDTO();
roleParam.setGridId(currentGrid.getGridId());

28
epmet-user/epmet-user-server/src/main/resources/mapper/RegisterRelationDao.xml

@ -33,6 +33,7 @@
<!-- 查询用户的首次注册网格Id -->
<select id="selectRegisteredGridIdByUserId" resultType="com.epmet.entity.RegisterRelationEntity">
SELECT
DISTINCT
GRID_ID,
CUSTOMER_ID
FROM
@ -43,6 +44,33 @@
user_id = #{userId}
AND
first_register = '1'
ORDER BY
CREATED_TIME desc
LIMIT 1
</select>
<!-- 查询用户的首次注册网格Id -->
<select id="selectRegisteredGridIdByUserIdAndCustomerId" resultType="com.epmet.entity.RegisterRelationEntity">
SELECT
DISTINCT
GRID_ID,
CUSTOMER_ID
FROM
register_relation
WHERE
del_flag = '0'
AND
user_id = #{userId}
AND
customer_id = #{customerId}
AND
first_register = '1'
ORDER BY
CREATED_TIME desc
LIMIT 1
</select>
</mapper>
Loading…
Cancel
Save