Browse Source

Merge branch 'dev_bugfix_ljj' of http://git.elinkit.com.cn:7070/r/epmet-cloud into develop

 Conflicts:
	epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java
	epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java
	epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/ThirdOpenFeignClient.java
dev_shibei_match
jianjun 4 years ago
parent
commit
9713c18a78
  1. 22
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
  2. 2
      epmet-gateway/src/main/resources/bootstrap.yml
  3. 2
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/ListStaffResultDTO.java
  4. 2
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/form/StaffDetailV2FormDTO.java
  5. 36
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java
  6. 7
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java
  7. 46
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java
  8. 15
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java
  9. 14
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetmessage/InfoProfileDao.xml
  10. 5
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/CustomerStaffDao.xml
  11. 12
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerStaffAgencyDao.xml
  12. 3
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/SubAgencyIndexRankResultDTO.java
  13. 16
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/IndexServiceImpl.java
  14. 10
      epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexAgencyScoreDao.xml
  15. 4
      epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexAgencySubScoreDao.xml
  16. 14
      epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCommunityScoreDao.xml
  17. 4
      epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCommunitySubScoreDao.xml
  18. 14
      epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexGridScoreDao.xml
  19. 4
      epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexGridSubScoreDao.xml
  20. 51
      epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml
  21. 6
      epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataYearlyDao.xml
  22. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/ProjectExtractServiceImpl.java
  23. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryGridDailyServiceImpl.java
  24. 138
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryOrgDailyServiceImpl.java
  25. 26
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectOrgDailyServiceImpl.java
  26. 91
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectMainDailyDao.xml
  27. 12
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectCategoryOrgDailyDao.xml
  28. 2
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectOrgDailyDao.xml
  29. 125
      epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/controller/WxController.java
  30. 10
      epmet-module/epmet-message/epmet-message-server/src/main/resources/db/migration/V0.3.17__alter_info_table_ucase.sql
  31. 6
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/constant/ThirdPlatformActions.java
  32. 19
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/ThirdPlatformActionsResultDTO.java
  33. 18
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/privateepmet/GetAccessTokenResultDTO.java
  34. 21
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/ThirdOpenFeignClient.java
  35. 12
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/ThirdOpenFeignClientFallback.java
  36. 5
      epmet-module/epmet-third/epmet-third-server/pom.xml
  37. 246
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/ApiService.java
  38. 18
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/DemoApiService.java
  39. 49
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/LuzhouGridPlatformApiService.java
  40. 169
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/PingyinPrivateEpmetApiService.java
  41. 50
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PrivateEpmetController.java
  42. 30
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/TestConttroller.java
  43. 10
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformActionDao.java
  44. 10
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformCustomerRegisterDao.java
  45. 19
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/ThirdPlatformCache.java
  46. 3
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ComponentVerifyTicketService.java
  47. 19
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PrivateEpmetService.java
  48. 10
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ThirdPlatformService.java
  49. 203
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java
  50. 71
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PrivateEpmetServiceImpl.java
  51. 6
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ThirdPlatformServiceImpl.java
  52. 17
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ThirdplatformActionDao.xml
  53. 14
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ThirdplatformCustomerRegisterDao.xml
  54. 17
      epmet-module/gov-grid/gov-grid-server/src/main/java/com/epmet/service/impl/PartyBranchManageServiceImpl.java
  55. 2
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyFormDTO.java
  56. 12
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddDepartmentFormDTO.java
  57. 15
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddGridFormDTO.java
  58. 2
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditAgencyFormDTO.java
  59. 12
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditDepartmentFormDTO.java
  60. 15
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditGridFormDTO.java
  61. 4
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/MineResultDTO.java
  62. 10
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java
  63. 4
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java
  64. 2
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java
  65. 7
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerStaffAgencyServiceImpl.java
  66. 8
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java
  67. 88
      epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffAgencyDao.xml
  68. 2
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartyMemberConfirmServiceImpl.java
  69. 15
      epmet-openapi/epmet-openapi-sdk/pom.xml
  70. 133
      epmet-openapi/epmet-openapi-sdk/src/main/java/com/epmet/openapi/sdk/encrypt/Md5Util.java
  71. 109
      epmet-openapi/epmet-openapi-sdk/src/main/java/com/epmet/openapi/sdk/sign/OpenApiSignUtils.java
  72. 1
      epmet-openapi/pom.xml

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

@ -441,6 +441,28 @@ public class RedisKeys {
return rootPrefix.concat("thirdplatform:accesstoken:").concat(platformId);
}
/**
* @Description 第三方平台信息key
* @param platformId
* @return java.lang.String
* @author wxz
* @date 2021.08.31 14:44:35
*/
public static String getThirdPlatformInfoKey(String platformId) {
return rootPrefix.concat("thirdplatform:info:").concat(platformId);
}
/**
* @Description 第三方平台操作urlkey
* @param platformId
* @return java.lang.String
* @author wxz
* @date 2021.08.31 15:15:15
*/
public static String getThirdPlatformActionUrlKey(String platformId) {
return rootPrefix.concat("thirdplatform:actions:").concat(platformId);
}
/**
* @return 设置组员已读未读标识
* @param source :act notice

2
epmet-gateway/src/main/resources/bootstrap.yml

@ -484,6 +484,7 @@ epmet:
- /message/template/**
- /data/aggregator/project/projectdistribution
- /data/aggregator/epmetuser/open-staffdetail
- /data/aggregator/epmetuser/gridmemberpatrollist
- /data/aggregator/pub/**
#stats external包下 公共的类只外部暴露方法 纯外部使用的 暴漏整个
- /data/stats/statsuser/gm-uploadevent
@ -497,6 +498,7 @@ epmet:
- /data/stats/project/**
- /data/stats/basereport/**
- /data/stats/governance/**
- /third/private-epmet/push-component-access-token
# 对外开放接口认证白名单

2
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/ListStaffResultDTO.java

@ -31,5 +31,7 @@ public class ListStaffResultDTO implements Serializable {
private String orgName = "";
//职责名称列表
private List<String> roles;
//工作人员添加入口类型(组织:agency;部门:dept;网格:gridId)
private String orgType = "";
}

2
epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/form/StaffDetailV2FormDTO.java

@ -15,6 +15,8 @@ import java.util.List;
public class StaffDetailV2FormDTO implements Serializable {
private static final long serialVersionUID = -1974456701949979946L;
//工作人员所属组织
private String agencyId = "";
//工作人员用户id
private String staffId = "";
//工作人员姓名

36
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java

@ -1,5 +1,6 @@
package com.epmet.dataaggre.service.datastats.impl;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
@ -1488,27 +1489,22 @@ public class DataStatsServiceImpl implements DataStatsService {
formDTO.setDateId(format.format(yesterday));
}
String startDate = null;
String actulStartDate = null;
String endDate = null;
String endDate = formDTO.getDateId();
Date dateIdDate = DateUtils.parse(formDTO.getDateId(), DateUtils.DATE_PATTERN_YYYYMMDD);
boolean isYesterday = DateUtils.getBeforeNDay(1,DateUtils.DATE_PATTERN_YYYYMMDD).equals(formDTO.getDateId());
switch (formDTO.getType()){
case "yesterday":
startDate = DateUtils.getBeforeNDay(formDTO.getDateId(),1);
startDate = formDTO.getDateId();
endDate = formDTO.getDateId();
actulStartDate = formDTO.getDateId();
break;
case "thisWeek":
actulStartDate = DateUtils.getWeekStart(formDTO.getDateId());
startDate = DateUtils.getBeforeNDay(actulStartDate,1);
DateUtils.format(DateUtils.addDateDays(yesterday, -1),DateUtils.DATE_PATTERN_YYYYMMDD);
startDate = DateUtils.getWeekStart(formDTO.getDateId());
if (!isYesterday){
endDate = DateUtils.getWeekEnd(formDTO.getDateId());
}
break;
case "thisMonth":
actulStartDate = DateUtils.format(DateUtils.getMonthStart(dateIdDate),DateUtils.DATE_PATTERN_YYYYMMDD);
startDate = DateUtils.getBeforeNDay(actulStartDate,1);
startDate = DateUtils.format(DateUtils.getMonthStart(dateIdDate),DateUtils.DATE_PATTERN_YYYYMMDD);
if (!isYesterday) {
endDate = DateUtils.format(DateUtils.getMonthEnd(dateIdDate), DateUtils.DATE_PATTERN_YYYYMMDD);
}
@ -1517,7 +1513,9 @@ public class DataStatsServiceImpl implements DataStatsService {
log.warn("===========");
}
formDTO.setStartDateId(startDate);
String breforeStartDate = DateUtils.getBeforeNDay(formDTO.getStartDateId(),1);
formDTO.setEndDateId(endDate);
log.info("getSubWorkFact do select param:{}", JSON.toJSONString(formDTO));
List<WorkFactResultDTO> result = new ArrayList<>();
//如果是社区 则下级是网格 查询网格的数据
if (OrgLevelEnum.COMMUNITY.getCode().equals(formDTO.getAgencyLevel())){
@ -1528,22 +1526,22 @@ public class DataStatsServiceImpl implements DataStatsService {
}
List<String> gridIdList = subAgencyList.stream().map(ScreenCustomerGridDTO::getGridId).collect(Collectors.toList());
//查询组织的话题转议题数据
List<SubGridFormDTO.Topic> toIssueStart = dataStatsDao.getSubGridTopicShiftIssue(gridIdList, formDTO.getStartDateId());
List<SubGridFormDTO.Topic> toIssueStart = dataStatsDao.getSubGridTopicShiftIssue(gridIdList, breforeStartDate);
List<SubGridFormDTO.Topic> toIssueEnd = dataStatsDao.getSubGridTopicShiftIssue(gridIdList, formDTO.getEndDateId());
Map<String, Integer> toIssueStartMap = toIssueStart.stream().collect(Collectors.toMap(SubGridFormDTO.Topic::getGridId, SubGridFormDTO.Topic::getShiftedIssueTotal, (o1, o2) -> o1));
Map<String, Integer> toIssueEndMap = toIssueEnd.stream().collect(Collectors.toMap(SubGridFormDTO.Topic::getGridId, SubGridFormDTO.Topic::getShiftedIssueTotal, (o1, o2) -> o1));
//查询组织的议题转项目数据
List<SubGridIssueResultDTO> toProjectStart = dataStatsDao.getSubGridIssue(gridIdList, formDTO.getStartDateId());
List<SubGridIssueResultDTO> toProjectStart = dataStatsDao.getSubGridIssue(gridIdList, breforeStartDate);
List<SubGridIssueResultDTO> toProjectEnd = dataStatsDao.getSubGridIssue(gridIdList, formDTO.getEndDateId());
Map<String, Integer> toProjectStartMap = toProjectStart.stream().collect(Collectors.toMap(SubGridIssueResultDTO::getGridId, SubGridIssueResultDTO::getShiftProjectTotal, (o1, o2) -> o1));
Map<String, Integer> toProjectEndMap = toProjectEnd.stream().collect(Collectors.toMap(SubGridIssueResultDTO::getGridId, SubGridIssueResultDTO::getShiftProjectTotal, (o1, o2) -> o1));
//查询组织已关闭的项目数据
List<SubGridProjectResultDTO> closeProjectStart = dataStatsDao.getSubGridProject(gridIdList, formDTO.getStartDateId());
List<SubGridProjectResultDTO> closeProjectStart = dataStatsDao.getSubGridProject(gridIdList, breforeStartDate);
List<SubGridProjectResultDTO> closeProjectEnd = dataStatsDao.getSubGridProject(gridIdList, formDTO.getEndDateId());
Map<String, Integer> closeProjectStartMap = closeProjectStart.stream().collect(Collectors.toMap(SubGridProjectResultDTO::getGridId, SubGridProjectResultDTO::getClosedProjectTotal, (o1, o2) -> o1));
Map<String, Integer> closeProjectEndMap = closeProjectEnd.stream().collect(Collectors.toMap(SubGridProjectResultDTO::getGridId, SubGridProjectResultDTO::getClosedProjectTotal, (o1, o2) -> o1));
//巡查次数和时间
List<PatrolDailySumResult> patrolList = statsStaffPatrolRecordDailyService.getPatrolSumList(gridIdList,actulStartDate,formDTO.getEndDateId());
List<PatrolDailySumResult> patrolList = statsStaffPatrolRecordDailyService.getPatrolSumList(gridIdList,formDTO.getStartDateId(),formDTO.getEndDateId());
Map<String, PatrolDailySumResult> patrolListMap = patrolList.stream().collect(Collectors.toMap(PatrolDailySumResult::getFullAgencyId, o -> o, (o1, o2) -> o1));
subAgencyList.forEach(agency->{
@ -1568,23 +1566,23 @@ public class DataStatsServiceImpl implements DataStatsService {
List<String> agencyList = subAgencyList.stream().map(ScreenCustomerAgencyDTO::getAgencyId).collect(Collectors.toList());
//查询组织的话题转议题数据
List<SubAgencyFormDTO.Topic> toIssueStart = dataStatsDao.getSubAgencyTopicShiftIssue(agencyList, formDTO.getStartDateId());
List<SubAgencyFormDTO.Topic> toIssueStart = dataStatsDao.getSubAgencyTopicShiftIssue(agencyList, breforeStartDate);
List<SubAgencyFormDTO.Topic> toIssueEnd = dataStatsDao.getSubAgencyTopicShiftIssue(agencyList, formDTO.getEndDateId());
Map<String, Integer> toIssueStartMap = toIssueStart.stream().collect(Collectors.toMap(SubAgencyFormDTO.Topic::getAgencyId, SubAgencyFormDTO.Topic::getShiftedIssueTotal, (o1, o2) -> o1));
Map<String, Integer> toIssueEndMap = toIssueEnd.stream().collect(Collectors.toMap(SubAgencyFormDTO.Topic::getAgencyId, SubAgencyFormDTO.Topic::getShiftedIssueTotal, (o1, o2) -> o1));
//查询组织的议题转项目数据
List<SubAgencyIssueResultDTO> toProjectStart = dataStatsDao.getSubAgencyIssue(agencyList, formDTO.getStartDateId());
List<SubAgencyIssueResultDTO> toProjectStart = dataStatsDao.getSubAgencyIssue(agencyList, breforeStartDate);
List<SubAgencyIssueResultDTO> toProjectEnd = dataStatsDao.getSubAgencyIssue(agencyList, formDTO.getEndDateId());
Map<String, Integer> toProjectStartMap = toProjectStart.stream().collect(Collectors.toMap(SubAgencyIssueResultDTO::getAgencyId, SubAgencyIssueResultDTO::getShiftProjectTotal, (o1, o2) -> o1));
Map<String, Integer> toProjectEndMap = toProjectEnd.stream().collect(Collectors.toMap(SubAgencyIssueResultDTO::getAgencyId, SubAgencyIssueResultDTO::getShiftProjectTotal, (o1, o2) -> o1));
//查询组织已关闭的项目数据
List<SubAgencyProjectResultDTO> closeProjectStart = dataStatsDao.getSubAgencyProject(agencyList, formDTO.getStartDateId());
List<SubAgencyProjectResultDTO> closeProjectStart = dataStatsDao.getSubAgencyProject(agencyList, breforeStartDate);
List<SubAgencyProjectResultDTO> closeProjectEnd = dataStatsDao.getSubAgencyProject(agencyList, formDTO.getEndDateId());
Map<String, Integer> closeProjectStartMap = closeProjectStart.stream().collect(Collectors.toMap(SubAgencyProjectResultDTO::getAgencyId, SubAgencyProjectResultDTO::getClosedProjectTotal, (o1, o2) -> o1));
Map<String, Integer> closeProjectEndMap = closeProjectEnd.stream().collect(Collectors.toMap(SubAgencyProjectResultDTO::getAgencyId, SubAgencyProjectResultDTO::getClosedProjectTotal, (o1, o2) -> o1));
//巡查次数和时间
List<String> agencyFullIds = subAgencyList.stream().map(o -> o.getPids().concat(StrConstant.COLON).concat(o.getAgencyId())).collect(Collectors.toList());
List<PatrolDailySumResult> patrolList = statsStaffPatrolRecordDailyService.getPatrolSumList(agencyFullIds,actulStartDate,formDTO.getEndDateId());
List<PatrolDailySumResult> patrolList = statsStaffPatrolRecordDailyService.getPatrolSumList(agencyFullIds,breforeStartDate,formDTO.getEndDateId());
Map<String, PatrolDailySumResult> patrolListMap = patrolList.stream().collect(Collectors.toMap(PatrolDailySumResult::getFullAgencyId, o -> o, (o1, o2) -> o1));
subAgencyList.forEach(agency->{
@ -1602,7 +1600,9 @@ public class DataStatsServiceImpl implements DataStatsService {
});
}
List<WorkFactResultDTO> newResult = result.stream().sorted(Comparator.comparing(o -> o.getTopicToIssueTotal() + o.getIssueToProjectTotal() + o.getClosedProjectTotal() + o.getPatrolTotal())).collect(Collectors.toList());
List<WorkFactResultDTO> newResult = result.stream().sorted(Comparator.comparing(o -> o.getTopicToIssueTotal() + o.getIssueToProjectTotal() + o.getClosedProjectTotal() + o.getPatrolTotal()))
.collect(Collectors.toList());
Collections.reverse(newResult);
return newResult;
}

7
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java

@ -98,6 +98,13 @@ public interface EpmetUserService {
*/
UserEventLogoResultDTO mentionMeEvent(String userId);
/**
* @Param formDTO
* @Description 对外接口--网格员排名-巡查记录
* @author sun
*/
List<GridMemberPatrolListResultDTO> gridMemberPatrolList(GridMemberPatrolListFormDTO formDTO);
/**
* @Param formDTO
* @Description 通讯录姓名检索工作人员

46
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java

@ -75,10 +75,10 @@ public class EpmetUserServiceImpl implements EpmetUserService {
private ResiUserBadgeDao resiUserBadgeDao;
@Autowired
private GovProjectService govProjectService;
@Resource
private GovStaffRoleDao govStaffRoleDao;
@Autowired
private DataStatsService dataStatsService;
@Resource
private GovStaffRoleDao govStaffRoleDao;
/**
* @Description 根据UserIds查询
@ -442,6 +442,47 @@ public class EpmetUserServiceImpl implements EpmetUserService {
return resultDTO;
}
/**
* @Param formDTO
* @Description 对外接口--网格员排名-巡查记录
* @author sun
*/
@Override
public List<GridMemberPatrolListResultDTO> gridMemberPatrolList(GridMemberPatrolListFormDTO formDTO) {
//1.查询当前组织及下级所有网格员维度对应最大dated数据【例查询2021年8月数据,则是查询8月对应的最大daeId那天的网格员数据】
List<GridMemberPatrolListResultDTO> resultList = dataStatsService.getGirdMemberPatrol(formDTO);
if (CollectionUtils.isEmpty(resultList)) {
return new ArrayList<>();
}
//2.按维度汇总当前组织及下级网格员巡查数据
//【如果查询当前月或本年度数据,则需要排除最大dateId的数据,因为上边查的统计数据只有t-1的,巡查数据是t的,避免多计算了当天的巡查项目数和时长数】
formDTO.setDateId(resultList.get(0).getDateId());
List<StaffListResultDTO> patrolList = staffPatrolRecordDao.gridMemberPatrol(formDTO);
//3.以统计数据为准封装结果数据
resultList.forEach(re -> patrolList.stream().filter(l -> re.getStaffId().equals(l.getStaffId())).forEach(s -> {
re.setReportProjectCount(s.getReportProjectCount());
re.setPatrolTotalTime((s.getTimeNum() > NumConstant.ZERO ? s.getTimeNum() / 60 : 0));
}));
//4.按排序字段排序并返回
Collections.sort(resultList, new Comparator<GridMemberPatrolListResultDTO>() {
@Override
public int compare(GridMemberPatrolListResultDTO o1, GridMemberPatrolListResultDTO o2) {
if ("patrolTime".equals(formDTO.getSort())) {
return o2.getPatrolTotalTime().compareTo(o1.getPatrolTotalTime());
} else if ("dealEvent".equals(formDTO.getSort())) {
return o2.getEventCount().compareTo(o1.getEventCount());
} else {
return o2.getReportProjectCount().compareTo(o1.getReportProjectCount());
}
}
});
return resultList;
}
/**
* @Param formDTO
* @Description 通讯录姓名检索工作人员
@ -647,6 +688,7 @@ public class EpmetUserServiceImpl implements EpmetUserService {
List<String> list = staffRoleDao.selectByStaffId(staffId);
//汇总数据
result = ConvertUtils.sourceToTarget(dto, StaffDetailV2FormDTO.class);
result.setStaffId(dto.getUserId());
result.setName(dto.getRealName());
result.setGender(dto.getGender().toString());
result.setRoles(list);

15
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java

@ -1,7 +1,6 @@
package com.epmet.dataaggre.service.govorg.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
@ -12,11 +11,6 @@ import com.epmet.dataaggre.dao.govorg.*;
import com.epmet.dataaggre.dto.epmetuser.result.ListStaffResultDTO;
import com.epmet.dataaggre.dto.epmetuser.result.StaffRoleListResultDTO;
import com.epmet.dataaggre.dto.govorg.*;
import com.epmet.dataaggre.dto.govorg.form.*;
import com.epmet.dataaggre.dto.govorg.CustomerAgencyDTO;
import com.epmet.dataaggre.dto.govorg.CustomerDepartmentDTO;
import com.epmet.dataaggre.dto.govorg.CustomerGridDTO;
import com.epmet.dataaggre.dto.govorg.CustomerStaffAgencyDTO;
import com.epmet.dataaggre.dto.govorg.form.NextAreaCodeFormDTO;
import com.epmet.dataaggre.dto.govorg.form.OrgStaffListFormDTO;
import com.epmet.dataaggre.dto.govorg.form.StaffDetailV2FormDTO;
@ -38,6 +32,7 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author zxc
@ -401,6 +396,13 @@ public class GovOrgServiceImpl implements GovOrgService {
//2.分页查询工作人员基础信息、角色信息【组织人员单位领导角色人员在前;部门人员部门领导角色人员在前;网格人员网格长角色人员在前】
List<ListStaffResultDTO> staffList = epmetUserService.getStaffInfoList(formDTO);
//3.查询工作人员注册组织关系信息
List<String> staffIdList = staffList.stream().map(ListStaffResultDTO::getStaffId).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(staffIdList)){
List<StaffOrgNameResultDTO> list = customerAgencyDao.selelctStaffOrg(staffIdList);
staffList.forEach(re -> list.stream().filter(l -> re.getStaffId().equals(l.getStaffId())).forEach(s -> re.setOrgType(s.getOrgType())));
}
//3.封装数据并返回
resultDTO.setStaffCount(staffIds.size());
resultDTO.setStaffList((null == staffList ? new ArrayList<>() : staffList));
@ -429,6 +431,7 @@ public class GovOrgServiceImpl implements GovOrgService {
}
//3.封装数据并返回
result.setAgencyId(list.get(0).getAgencyId());
result.setOrgId(list.get(0).getOrgId());
result.setOrgName(list.get(0).getOrgName());
result.setOrgType(list.get(0).getOrgType());

14
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetmessage/InfoProfileDao.xml

@ -75,9 +75,9 @@
SELECT
ir.INFO_ID,
ip.content,
ii.CREATED_TIME,
ip.CREATED_TIME,
ir.READ_FLAG,
ii.publish_staff_id,
ip.publish_staff_id,
ip.first_att_id,
ia.ATTACHMENT_NAME AS name,
ia.ATTACHMENT_FORMAT AS format,
@ -91,18 +91,20 @@
end) as duration
FROM
info_receivers ir
INNER JOIN info ii ON ( ir.INFO_ID = ii.ID )
INNER JOIN info_profile ip ON ( ii.ID = ip.INFO_ID AND ip.DEL_FLAG = '0' )
<if test="null != content and content !=''">
INNER JOIN info ii ON ( ir.INFO_ID = ii.ID )
</if>
INNER JOIN info_profile ip ON ( ir.INFO_ID = ip.INFO_ID AND ip.DEL_FLAG = '0' )
LEFT JOIN info_att ia on ( ip.first_att_id = ia.id AND ia.DEL_FLAG = '0' )
WHERE
ir.DEL_FLAG = '0'
AND ii.DEL_FLAG = '0'
AND ir.STAFF_ID = #{userId}
<if test="null != content and content !=''">
AND ii.DEL_FLAG = '0'
and ii.content like concat('%',trim(#{content}),'%')
</if>
ORDER BY
ii.CREATED_TIME DESC
ip.CREATED_TIME DESC
</select>
<select id="selectInfoDetail" parameterType="java.lang.String" resultType="com.epmet.dataaggre.dto.message.result.InfoDetailResDTO">

5
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/CustomerStaffDao.xml

@ -60,6 +60,7 @@
<!-- 里边的sql,尽管有去重,一个人有多个角色时,在里边sql查询出来的是一个人两条数据,is_first一个是0一个是1,所以外层需要在按人分组 -->
SELECT DISTINCT<!-- 没有这个去重会改变最终的结果顺序,至于为什么还不清楚 -->
sr.staff_id,
cs.created_time,
case when gsr.role_key =
<choose>
<when test="orgType != null and orgType == 'agency' ">
@ -74,6 +75,7 @@
</choose>
then 1 else 0 end is_first<!-- 有单位领导角色的人赋值为1,没有的赋值为0 -->
FROM staff_role sr
INNER JOIN customer_staff cs ON sr.staff_id = cs.user_id
INNER JOIN gov_staff_role gsr ON sr.role_id = gsr.id AND gsr.customer_id = #{customerId}
WHERE
sr.del_flag = '0'
@ -96,10 +98,9 @@
'grid_manager'
</otherwise>
</choose>
, sr.created_time DESC<!-- 标注有点位领导角色的人不参与排序也就是默认拍在前边 -->
) t
GROUP BY t.staff_id
ORDER BY t.is_first <![CDATA[<>]]> 1
ORDER BY t.is_first <![CDATA[<>]]> 1, t.created_time desc<!-- 标注有单位领导角色的人不参与排序也就是默认拍在前边,再按创建时间降序 -->
LIMIT #{pageNo}, #{pageSize}
</select>

12
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerStaffAgencyDao.xml

@ -77,14 +77,16 @@
</when>
<otherwise>
SELECT
user_id
csa.user_id
FROM
customer_staff_agency
customer_staff_agency csa
INNER JOIN staff_org_relation sor ON csa.user_id = sor.staff_id
WHERE
del_flag = '0'
AND agency_id = #{orgId}
csa.del_flag = '0'
AND sor.org_type = 'agency'
AND csa.agency_id = #{orgId}
ORDER BY
created_time ASC
csa.created_time ASC
</otherwise>
</choose>
</select>

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

@ -27,16 +27,19 @@ public class SubAgencyIndexRankResultDTO implements Serializable {
* 党建能力
*/
private Double governAbility = 0.0;
private Double originGovernAbility = 0.0;
/**
* 治理能力
*/
private Double partyDevAbility = 0.0;
private Double originPartyDevAbility = 0.0;
/**
* 服务能力
*/
private Double serviceAbility = 0.0;
private Double originServiceAbility = 0.0;
private String orgId;
private String orgType;

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

@ -57,9 +57,6 @@ public class IndexServiceImpl implements IndexService {
if (null == yearAverageIndexResultDTO){
return new YearAverageIndexResultDTO();
}
yearAverageIndexResultDTO.setPartyDevAbility(getRound(yearAverageIndexResultDTO.getPartyDevAbility()));
yearAverageIndexResultDTO.setGovernAbility(getRound(yearAverageIndexResultDTO.getGovernAbility()));
yearAverageIndexResultDTO.setServiceAbility(getRound(yearAverageIndexResultDTO.getServiceAbility()));
yearAverageIndexResultDTO.setYearAverageIndex(getRound(yearAverageIndexResultDTO.getPartyDevAbility() + yearAverageIndexResultDTO.getGovernAbility() + yearAverageIndexResultDTO.getServiceAbility()));
return yearAverageIndexResultDTO;
}
@ -86,10 +83,6 @@ public class IndexServiceImpl implements IndexService {
if (null == pieChartDTO) {
return new MonthPieChartResultDTO();
}
// 处理小数四舍五入
pieChartDTO.setPartyDevAbility(getRound(pieChartDTO.getPartyDevAbility()));
pieChartDTO.setGovernAbility(getRound(pieChartDTO.getGovernAbility()));
pieChartDTO.setServiceAbility(getRound(pieChartDTO.getServiceAbility()));
return pieChartDTO;
}
@ -154,9 +147,6 @@ public class IndexServiceImpl implements IndexService {
}
// 处理小数四舍五入
monthBarchartResults.forEach(barchart -> {
barchart.setPartyDevAbility(getRound(barchart.getPartyDevAbility()));
barchart.setGovernAbility(getRound(barchart.getGovernAbility()));
barchart.setServiceAbility(getRound(barchart.getServiceAbility()));
barchart.setIndexTotal(getRound(barchart.getPartyDevAbility() + barchart.getGovernAbility() + barchart.getServiceAbility()));
//四舍五入,保留小数点后两位
barchart.setServiceAblityWeight(barchart.getServiceAblityWeight().setScale(NumConstant.TWO,BigDecimal.ROUND_HALF_UP));
@ -443,9 +433,6 @@ public class IndexServiceImpl implements IndexService {
// 小数四舍五入
streetList.forEach(indexRank -> {
indexRank.setOrgType("street");
indexRank.setPartyDevAbility(getRound(indexRank.getPartyDevAbility()));
indexRank.setGovernAbility(getRound(indexRank.getGovernAbility()));
indexRank.setServiceAbility(getRound(indexRank.getServiceAbility()));
indexRank.setTotalIndex(getRound(indexRank.getPartyDevAbility() + indexRank.getGovernAbility() + indexRank.getServiceAbility()));
});
return streetList;
@ -455,9 +442,6 @@ public class IndexServiceImpl implements IndexService {
// 小数四舍五入
gridList.forEach(indexRank -> {
indexRank.setOrgType("grid");
indexRank.setPartyDevAbility(getRound(indexRank.getPartyDevAbility()));
indexRank.setGovernAbility(getRound(indexRank.getGovernAbility()));
indexRank.setServiceAbility(getRound(indexRank.getServiceAbility()));
indexRank.setTotalIndex(getRound(indexRank.getPartyDevAbility() + indexRank.getGovernAbility() + indexRank.getServiceAbility()));
});
return gridList;

10
epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexAgencyScoreDao.xml

@ -6,7 +6,7 @@
<select id="selectAgencyAblityWeightScoreIndex" resultType="com.epmet.evaluationindex.screen.dto.result.AblityIndexResultDTO$ScoreListResultDTO">
SELECT
fact.month_id AS "monthId",
ROUND(fact.score*fact.WEIGHT, 1) AS "indexTotal",
ROUND(ROUND(fact.score,1)*fact.WEIGHT, 1) AS "indexTotal",
fact.index_code AS "indexCode"
FROM
fact_index_agency_score fact
@ -24,7 +24,7 @@
<select id="selectAgencyWeightScoreList" resultType="com.epmet.evaluationindex.screen.dto.result.ScoreListResultDTO">
SELECT
fact.index_code AS "indexCode",
ROUND(fact.score*fact.WEIGHT, 1) AS "indexTotal",
ROUND(ROUND(fact.score,1)*fact.WEIGHT, 1) AS "indexTotal",
ROUND(fact.score,1) AS "indexTotalOriginScore",
fact.WEIGHT AS "indexTotalSupWeight",
ROUND(self.self_score*fact.WEIGHT, 1) AS "agencyScore",
@ -50,11 +50,11 @@
<select id="selectAgencyMonthWeightScoreList" resultType="com.epmet.evaluationindex.screen.dto.result.MonthScoreListResultDTO$ScoreListResultDTO">
SELECT
fact.month_id AS "monthId",
ROUND(fact.score*fact.WEIGHT, 1) AS "indexTotal",
ROUND(ROUND(fact.score,1)*fact.WEIGHT, 1) AS "indexTotal",
ROUND(fact.score,1) AS "indexTotalOriginScore",
fact.WEIGHT AS "indexTotalSupWeight",
ROUND(self.self_score*fact.WEIGHT, 1) AS "agencyScore",
ROUND(self.sub_score*fact.WEIGHT, 1) AS "subAgencyScore",
ROUND(ROUND(self.self_score,1)*fact.WEIGHT, 1) AS "agencyScore",
ROUND(ROUND(self.sub_score,1)*fact.WEIGHT, 1) AS "subAgencyScore",
fact.index_code AS "indexCode",
self.SELF_WEIGHT AS "selfWeight",
self.SUB_WEIGHT AS "subWeight"

4
epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexAgencySubScoreDao.xml

@ -7,10 +7,10 @@
SELECT
fact.index_code AS "key",
IF(fact.origin_value='',0,IFNULL(fact.origin_value,0)) AS "value",
fact.score AS score,
round(fact.score,1) AS score,
dict.index_name AS "name",
round(fact.WEIGHT,2) AS weight,
(fact.SCORE * fact.WEIGHT) AS weightedScore
round(round(fact.SCORE,1) * fact.WEIGHT,1) AS weightedScore
FROM
fact_index_agency_sub_score fact
LEFT JOIN index_dict dict ON fact.index_code = dict.index_code

14
epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCommunityScoreDao.xml

@ -6,7 +6,7 @@
<select id="selectCommunityAblityWeightScore" resultType="com.epmet.evaluationindex.screen.dto.result.AblityIndexResultDTO$ScoreListResultDTO">
SELECT
fact.month_id AS "monthId",
ROUND(fact.score*fact.WEIGHT, 1) AS "indexTotal",
ROUND(ROUND(fact.score,1)*fact.WEIGHT, 1) AS "indexTotal",
fact.index_code AS "indexCode"
FROM
fact_index_community_score fact
@ -24,13 +24,13 @@
<select id="selectCommunityWeightScoreList" resultType="com.epmet.evaluationindex.screen.dto.result.ScoreListResultDTO">
SELECT
fact.index_code AS "indexCode",
ROUND(fact.score*fact.WEIGHT, 1) AS "indexTotal",
ROUND(ROUND(fact.score,1)*fact.WEIGHT, 1) AS "indexTotal",
ROUND(fact.score,1) AS "indexTotalOriginScore",
fact.WEIGHT AS "indexTotalSupWeight",
ROUND(self.self_score*fact.WEIGHT, 1) AS "agencyScore",
ROUND(ROUND(self.self_score,1)*fact.WEIGHT, 1) AS "agencyScore",
ROUND(self.self_score, 1) AS selfOriginScore,
self.SELF_WEIGHT AS agencyWeight,
ROUND(self.sub_score*fact.WEIGHT, 1) AS "subAgencyScore",
ROUND(ROUND(self.sub_score,1)*fact.WEIGHT, 1) AS "subAgencyScore",
ROUND(self.sub_score, 1) AS subOriginScore,
self.SUB_WEIGHT AS subAgencyWeight
FROM
@ -50,11 +50,11 @@
<select id="selectCommunityMonthWeightScoreList" resultType="com.epmet.evaluationindex.screen.dto.result.MonthScoreListResultDTO$ScoreListResultDTO">
SELECT
fact.month_id AS "monthId",
ROUND(fact.score*fact.WEIGHT, 1) AS "indexTotal",
ROUND(ROUND(fact.score,1)*fact.WEIGHT, 1) AS "indexTotal",
ROUND(fact.score,1) AS "indexTotalOriginScore",
fact.WEIGHT AS "indexTotalSupWeight",
ROUND(self.self_score*fact.WEIGHT, 1) AS "agencyScore",
ROUND(self.sub_score*fact.WEIGHT, 1) AS "subAgencyScore",
ROUND(ROUND(self.self_score,1)*fact.WEIGHT, 1) AS "agencyScore",
ROUND(ROUND(self.sub_score,1)*fact.WEIGHT, 1) AS "subAgencyScore",
fact.index_code AS "indexCode",
self.SELF_WEIGHT AS "selfWeight",
self.SUB_WEIGHT AS "subWeight"

4
epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCommunitySubScoreDao.xml

@ -8,9 +8,9 @@
fact.index_code AS "key",
IF(fact.origin_value='',0,IFNULL(fact.origin_value,0)) AS "value",
dict.index_name AS "name",
fact.score AS score,
round(fact.score,1) AS score,
round(fact.WEIGHT,2) AS weight,
(fact.SCORE * fact.WEIGHT) AS weightedScore
round(round(fact.SCORE,1) * fact.WEIGHT,1) AS weightedScore
FROM
fact_index_community_sub_score fact
LEFT JOIN index_dict dict ON fact.index_code = dict.index_code

14
epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexGridScoreDao.xml

@ -6,7 +6,7 @@
<select id="selectGridAblityWeightScore" resultType="com.epmet.evaluationindex.screen.dto.result.AblityIndexResultDTO$ScoreListResultDTO">
SELECT
fact.month_id AS "monthId",
ROUND(fact.score*fact.WEIGHT, 1) AS "indexTotal",
ROUND(ROUND(fact.score,1)*fact.WEIGHT, 1) AS "indexTotal",
fact.index_code AS "indexCode"
FROM
fact_index_grid_score fact
@ -24,13 +24,13 @@
<select id="selectGridWeightScoreList" resultType="com.epmet.evaluationindex.screen.dto.result.ScoreListResultDTO">
SELECT
fact.index_code AS "indexCode",
ROUND(fact.score*fact.WEIGHT, 1) AS "indexTotal",
ROUND(ROUND(fact.score,1)*fact.WEIGHT, 1) AS "indexTotal",
ROUND(fact.score,1) AS "indexTotalOriginScore",
fact.WEIGHT AS "indexTotalSupWeight",
ROUND(self.self_score*fact.WEIGHT, 1) AS "agencyScore",
ROUND(ROUND(self.self_score,1)*fact.WEIGHT, 1) AS "agencyScore",
ROUND(self.self_score, 1) AS selfOriginScore,
self.SELF_WEIGHT AS agencyWeight,
ROUND(self.sub_score*fact.WEIGHT, 1) AS "subAgencyScore",
ROUND(ROUND(self.sub_score,1)*fact.WEIGHT, 1) AS "subAgencyScore",
ROUND(self.sub_score, 1) AS subOriginScore,
self.SUB_WEIGHT AS subAgencyWeight
FROM
@ -51,11 +51,11 @@
<select id="selectGridMonthWeightScoreList" resultType="com.epmet.evaluationindex.screen.dto.result.MonthScoreListResultDTO$ScoreListResultDTO">
SELECT
fact.month_id AS "monthId",
ROUND(fact.score*fact.WEIGHT, 1) AS "indexTotal",
ROUND(ROUND(fact.score,1)*fact.WEIGHT, 1) AS "indexTotal",
ROUND(fact.score,1) AS "indexTotalOriginScore",
fact.WEIGHT AS "indexTotalSupWeight",
ROUND(self.self_score*fact.WEIGHT, 1) AS "agencyScore",
ROUND(self.sub_score*fact.WEIGHT, 1) AS "subAgencyScore",
ROUND(ROUND(self.self_score,1)*fact.WEIGHT, 1) AS "agencyScore",
ROUND(ROUND(self.sub_score,1)*fact.WEIGHT, 1) AS "subAgencyScore",
fact.index_code AS "indexCode",
self.SELF_WEIGHT AS "selfWeight",
self.SUB_WEIGHT AS "subWeight"

4
epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexGridSubScoreDao.xml

@ -8,9 +8,9 @@
fact.index_code AS "key",
IF(fact.origin_value='',0,IFNULL(fact.origin_value,0)) AS "value",
dict.index_name AS "name",
fact.score AS score,
round(fact.score,1) AS score,
round(fact.WEIGHT,2) AS weight,
(fact.SCORE * fact.WEIGHT) AS weightedScore
round(round(fact.SCORE,1) * fact.WEIGHT,1) AS weightedScore
FROM
fact_index_grid_sub_score fact
LEFT JOIN index_dict dict ON fact.index_code = dict.index_code

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

@ -6,9 +6,9 @@
<!-- 2、月度指数分析-饼状图 -->
<select id="selectMonthPieChart" resultType="com.epmet.evaluationindex.screen.dto.result.MonthPieChartResultDTO">
SELECT
service_ablity * SERVICE_ABLITY_WEIGHT AS serviceAbility,
party_dev_ablity * PARTY_DEV_WEIGHT AS partyDevAbility,
govern_ablity * GOVERN_ABLITY_WEIGHT AS governAbility,
ROUND((ROUND(service_ablity,1) * SERVICE_ABLITY_WEIGHT),1) AS serviceAbility,
ROUND((ROUND(party_dev_ablity,1) * PARTY_DEV_WEIGHT),1) AS partyDevAbility,
ROUND((ROUND(govern_ablity,1) * GOVERN_ABLITY_WEIGHT),1) AS governAbility,
ROUND(service_ablity,1) serviceOriginScore,
ROUND(party_dev_ablity,1) partyOriginScore,
ROUND(govern_ablity,1) governOriginScore,
@ -38,9 +38,9 @@
<select id="selectMonthBarchart" resultType="com.epmet.evaluationindex.screen.dto.result.MonthBarchartResult">
SELECT
month_id AS monthId,
service_ablity * SERVICE_ABLITY_WEIGHT AS serviceAbility,
party_dev_ablity * PARTY_DEV_WEIGHT AS partyDevAbility,
govern_ablity * GOVERN_ABLITY_WEIGHT AS governAbility,
ROUND((ROUND(service_ablity,1) * SERVICE_ABLITY_WEIGHT),1) AS serviceAbility,
ROUND((ROUND(party_dev_ablity,1) * PARTY_DEV_WEIGHT),1) AS partyDevAbility,
ROUND((ROUND(govern_ablity,1) * GOVERN_ABLITY_WEIGHT),1) AS governAbility,
ROUND(service_ablity,1) serviceOriginScore,
ROUND(party_dev_ablity,1) partyOriginScore,
ROUND(govern_ablity,1) governOriginScore,
@ -88,9 +88,9 @@
resultType="com.epmet.evaluationindex.screen.dto.result.AnNingSubAgencyIndexRankResultDTO">
SELECT
score.org_name AS `NAME`,
score.service_ablity * score.SERVICE_ABLITY_WEIGHT AS serviceAbility,
score.party_dev_ablity * score.PARTY_DEV_WEIGHT AS partyDevAbility,
score.govern_ablity * score.GOVERN_ABLITY_WEIGHT AS governAbility,
ROUND(ROUND(score.service_ablity,1) * score.SERVICE_ABLITY_WEIGHT, 1) AS serviceAbility,
ROUND(ROUND(score.party_dev_ablity,1) * score.PARTY_DEV_WEIGHT, 1) AS partyDevAbility,
ROUND(ROUND(score.govern_ablity,1) * score.GOVERN_ABLITY_WEIGHT, 1) AS governAbility,
score.PARTY_DEV_WEIGHT AS partyWeight,
score.GOVERN_ABLITY_WEIGHT AS governWeight,
score.SERVICE_ABLITY_WEIGHT AS serviceWeight,
@ -156,13 +156,13 @@
org_id AS "orgId",
org_name AS "orgName",
<if test="indexCode != null and indexCode != '' and indexCode == 'dangjiannengli'">
round((party_dev_ablity * party_dev_weight),1) AS "score"
round(round(party_dev_ablity,1) * party_dev_weight,1) AS "score"
</if>
<if test="indexCode != null and indexCode != '' and indexCode == 'zhilinengli'">
round((govern_ablity * govern_ablity_weight),1) AS "score"
round(round(govern_ablity,1) * govern_ablity_weight,1) AS "score"
</if>
<if test="indexCode != null and indexCode != '' and indexCode == 'fuwunengli'">
round((service_ablity * service_ablity_weight),1) AS "score"
round(round(service_ablity,1) * service_ablity_weight,1) AS "score"
</if>
FROM
screen_index_data_monthly
@ -201,13 +201,13 @@
<select id="selectMonthData" resultType="com.epmet.evaluationindex.screen.dto.result.IndexScoreResultDTO">
SELECT
score.index_total AS "total",
(score.party_dev_ablity * score.party_dev_weight) AS "party",
(ROUND(score.party_dev_ablity,1) * score.party_dev_weight) AS "party",
ROUND(score.party_dev_ablity,1) partyOriginScore,
score.party_dev_weight AS "partyDevAbilityWeight",
(score.govern_ablity * score.govern_ablity_weight) AS "govern",
(ROUND(score.govern_ablity,1) * score.govern_ablity_weight) AS "govern",
ROUND(score.govern_ablity,1) governOriginScore,
score.govern_ablity_weight AS "governAbilityWeight",
(score.service_ablity * score.service_ablity_weight) AS "service",
(ROUND(score.service_ablity,1) * score.service_ablity_weight) AS "service",
ROUND(score.service_ablity,1) serviceOriginScore,
score.service_ablity_weight AS "serviceAbilityWeight"
FROM
@ -360,9 +360,12 @@
<select id="selectSubStreetByAreaCode" parameterType="map" resultType="com.epmet.evaluationindex.screen.dto.result.SubAgencyIndexRankResultDTO">
SELECT
sca.AGENCY_NAME AS NAME,
sy.govern_ablity * sy.GOVERN_ABLITY_WEIGHT AS governAbility,
sy.party_dev_ablity * sy.PARTY_DEV_WEIGHT AS partyDevAbility,
sy.service_ablity * sy.SERVICE_ABLITY_WEIGHT AS serviceAbility,
ROUND((ROUND(sy.govern_ablity,1) * sy.GOVERN_ABLITY_WEIGHT),1) AS governAbility,
ROUND((ROUND(sy.party_dev_ablity,1) * sy.PARTY_DEV_WEIGHT),1) AS partyDevAbility,
ROUND((ROUND(sy.service_ablity,1) * sy.SERVICE_ABLITY_WEIGHT),1) AS serviceAbility,
ROUND(sy.govern_ablity,1) AS originGovernAbility,
ROUND(sy.party_dev_ablity,1) AS originPartyDevAbility,
ROUND(sy.service_ablity,1) AS originServiceAbility,
sy.ORG_ID as orgId,
sca.area_code as areaCode
FROM screen_customer_agency sca
@ -382,9 +385,9 @@
<select id="selectSubGridByAreaCode" parameterType="map" resultType="com.epmet.evaluationindex.screen.dto.result.SubAgencyIndexRankResultDTO">
SELECT
scg.GRID_NAME AS NAME,
sy.govern_ablity * sy.GOVERN_ABLITY_WEIGHT AS governAbility,
sy.party_dev_ablity * sy.PARTY_DEV_WEIGHT AS partyDevAbility,
sy.service_ablity * sy.SERVICE_ABLITY_WEIGHT AS serviceAbility,
ROUND((ROUND(sy.govern_ablity,1) * sy.GOVERN_ABLITY_WEIGHT),1) AS governAbility,
ROUND((ROUND(sy.party_dev_ablity,1) * sy.PARTY_DEV_WEIGHT),1) AS partyDevAbility,
ROUND((ROUND(sy.service_ablity,1) * sy.SERVICE_ABLITY_WEIGHT),1) AS serviceAbility,
sy.ORG_ID as orgId,
scg.area_code as areaCode
FROM screen_customer_grid scg
@ -406,9 +409,9 @@
resultType="com.epmet.evaluationindex.screen.dto.result.AnNingSubAgencyIndexRankResultDTO">
SELECT
score.org_name AS `NAME`,
score.service_ablity * score.SERVICE_ABLITY_WEIGHT AS serviceAbility,
score.party_dev_ablity * score.PARTY_DEV_WEIGHT AS partyDevAbility,
score.govern_ablity * score.GOVERN_ABLITY_WEIGHT AS governAbility,
ROUND(ROUND(score.service_ablity,1)*score.SERVICE_ABLITY_WEIGHT, 1)AS serviceAbility,
ROUND(ROUND(score.party_dev_ablity,1) * score.PARTY_DEV_WEIGHT, 1) AS partyDevAbility,
ROUND(ROUND(score.govern_ablity,1) * score.GOVERN_ABLITY_WEIGHT, 1) AS governAbility,
score.PARTY_DEV_WEIGHT AS partyWeight,
score.GOVERN_ABLITY_WEIGHT AS governWeight,
score.SERVICE_ABLITY_WEIGHT AS serviceWeight,

6
epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataYearlyDao.xml

@ -6,9 +6,9 @@
<!-- 1、年度平均指数 -->
<select id="selectYearAverageIndex" resultType="com.epmet.evaluationindex.screen.dto.result.YearAverageIndexResultDTO">
SELECT
service_ablity AS serviceAbility,
party_dev_ablity AS partyDevAbility,
govern_ablity AS governAbility,
ROUND(service_ablity,1) AS serviceAbility,
ROUND(party_dev_ablity,1) AS partyDevAbility,
ROUND(govern_ablity,1) AS governAbility,
year_id as yearId
FROM
screen_index_data_yearly

9
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/ProjectExtractServiceImpl.java

@ -35,6 +35,7 @@ import com.epmet.service.project.ProjectService;
import com.epmet.service.stats.DimCustomerService;
import com.epmet.service.topic.TopicService;
import com.epmet.util.DimIdGenerator;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@ -478,9 +479,11 @@ public class ProjectExtractServiceImpl implements ProjectExtractService {
formattingData.add(dest);
});
if(!CollectionUtils.isEmpty(formattingData)) {
factOriginProjectOrgPeriodDailyDao.deleteByProjectIds(null,param.getCustomerId());
factOriginProjectOrgPeriodDailyDao.insertBatch(formattingData);
if (!CollectionUtils.isEmpty(formattingData)) {
factOriginProjectOrgPeriodDailyDao.deleteByProjectIds(null, param.getCustomerId());
Lists.partition(formattingData, NumConstant.ONE_HUNDRED)
.forEach(part -> factOriginProjectOrgPeriodDailyDao.insertBatch(part));
}
}

9
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryGridDailyServiceImpl.java

@ -147,8 +147,17 @@ public class ScreenProjectCategoryGridDailyServiceImpl extends BaseServiceImpl<S
listDTO.forEach(dto->{
dto.setDateId(dateId);
});
del(customerId,dateId);
boolean insertRes=insertBatch(ConvertUtils.sourceToTarget(listDTO, ScreenProjectCategoryGridDailyEntity.class));
log.info("insertRes is {}",insertRes);
}
@Transactional(rollbackFor = Exception.class)
public void del(String customerId,String dateId){
Integer num = NumConstant.ZERO;
do {
num = baseDao.deleteByDateIdAndCustomerId(customerId, dateId);
}while (num > NumConstant.ZERO && num == NumConstant.ONE_THOUSAND);
}
}

138
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryOrgDailyServiceImpl.java

@ -17,6 +17,7 @@
package com.epmet.service.evaluationindex.screen.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
@ -242,6 +243,9 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc
*/
public void disposeOneCustomerSub(String level, Boolean isGrid, String customerId, String dateId,List<CustomerAgencyInfoResultDTO> agencyIdList){
List<ScreenProjectCategoryOrgDailyEntity> result = new ArrayList<>();
Map<String, List<CustomerAgencyInfoResultDTO>> groupByLevel = agencyIdList.stream().collect(Collectors.groupingBy(CustomerAgencyInfoResultDTO::getLevel));
List<String> orgIds = groupByLevel.get(level).stream().map(m -> m.getAgencyId()).collect(Collectors.toList());
del(customerId,dateId,orgIds);
if (isGrid){
// 是社区级别
List<CategoryProjectResultDTO> categoryInfos = gridDailyDao.selectCategoryInfo(customerId, dateId,null,null);
@ -274,11 +278,8 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc
result = ConvertUtils.sourceToTarget(categoryProjectResultDTOS,ScreenProjectCategoryOrgDailyEntity.class);
}
// 组织项目分类 项目数
List<String> orgIds = new ArrayList<>();
Map<String, List<CustomerAgencyInfoResultDTO>> groupByLevel = agencyIdList.stream().collect(Collectors.groupingBy(CustomerAgencyInfoResultDTO::getLevel));
List<CustomerAgencyInfoResultDTO> levelAgencyInfo = groupByLevel.get(level);
if (!CollectionUtils.isEmpty(levelAgencyInfo)){
orgIds = levelAgencyInfo.stream().map(m -> m.getAgencyId()).collect(Collectors.toList());
List<ScreenProjectCategoryGridDailyDTO> screenProjectCategory = factOriginProjectCategoryDailyService.selectListProjectCategoryByOrg(orgIds,customerId);
if (!CollectionUtils.isEmpty(result)){
if (!CollectionUtils.isEmpty(screenProjectCategory)){
@ -306,7 +307,7 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc
result.forEach(r -> {r.setOrgType(level);r.setDateId(dateId);});
}
}
deleteAndInsert(customerId,dateId,result,orgIds);
insert(result);
}
/**
@ -357,7 +358,16 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc
*/
private void disposeMoreCustomerSub(String level,Boolean isGrid,String customerId, String dateId, List<CustomerRelationEntity> relationInfo,List<CustomerAgencyInfoResultDTO> agencyIdList){
List<ScreenProjectCategoryOrgDailyEntity> result = new ArrayList<>();
List<String> orgIds = new ArrayList<>();
Map<String, List<CustomerAgencyInfoResultDTO>> groupByLevel = agencyIdList.stream().collect(Collectors.groupingBy(CustomerAgencyInfoResultDTO::getLevel));
List<String> orgIds = groupByLevel.get(level).stream().map(m -> m.getAgencyId()).collect(Collectors.toList());
if (ScreenConstant.DISTRICT.equals(level)){
// 添加此 锦水、孔村、榆山 orgId,删除时使用
orgIds.add(PingYinConstant.JIN_SHUI_AGENCY_ID);
orgIds.add(PingYinConstant.KONG_CUN_AGENCY_ID);
orgIds.add(PingYinConstant.YU_SHAN_AGENCY_ID);
}
log.info("groupByLevel:{}"+JSON.toJSONString(groupByLevel)+"orgIds:{}"+JSON.toJSONString(orgIds));
del(customerId,dateId,orgIds);
if (isGrid){
// community级别走这
List<CategoryProjectResultDTO> categoryInfos = gridDailyDao.selectCategoryInfo(customerId, dateId,null,null);
@ -367,6 +377,7 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc
}else {
// 根据客户ID,时间,组织级别查询 分类标签
List<CategoryProjectResultDTO> categoryProjectResultDTOS = baseDao.selectOrgCategoryInfo(customerId, dateId, level);
log.info("分类标签:{}"+JSON.toJSONString(categoryProjectResultDTOS));
List<ScreenCustomerGridDTO> belongGridInfos = gridService.selectBelongGridInfo(customerId, level);
if (!CollectionUtils.isEmpty(belongGridInfos)){
// 存在直属网格
@ -395,60 +406,98 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc
* 在保存一份子客户自己agencyId的
*/
if (ScreenConstant.DISTRICT.equals(level)){
// 这时的result集合要清空,因为被上边使用 【result = ConvertUtils.sourceToTarget(categoryProjectResultDTOS,ScreenProjectCategoryOrgDailyEntity.class);】
result.clear();
// 查询 平阴的agencyId
ScreenCustomerAgencyEntity entity = agencyService.selectTopAgency(customerId);
// 子级客户ID
List<String> customerIds = relationInfo.stream().map(m -> m.getCustomerId()).collect(Collectors.toList());
// 子客户单独存一份【三个街道的】
List<CategoryProjectResultDTO> sonCustomerList = new ArrayList<>();
// 父客户存在的分类
List<CategoryProjectResultDTO> categoryProjectExists = baseDao.selectOrgCategoryMoreCustomerInfo(customerIds, dateId, level, customerId, true);
// 内部客户进行分组
Map<String, List<CategoryProjectResultDTO>> groupByCategoryCode = categoryProjectResultDTOS.stream().collect(Collectors.groupingBy(CategoryProjectResultDTO::getCategoryCode));
// 这时的result集合要清空,因为被上边使用 【result = ConvertUtils.sourceToTarget(categoryProjectResultDTOS,ScreenProjectCategoryOrgDailyEntity.class);】
result.clear();
List<ScreenProjectCategoryOrgDailyEntity> finalResult = result;
groupByCategoryCode.forEach((code, list) -> {
ScreenProjectCategoryOrgDailyEntity e = new ScreenProjectCategoryOrgDailyEntity();
e.setCustomerId(customerId);
e.setCategoryOriginCustomerId(customerId);
e.setCategoryCode(code);
e.setOrgId(entity.getAgencyId());
e.setProjectTotal(CollectionUtils.isEmpty(list) ? NumConstant.ZERO : list.stream().collect(Collectors.summingInt(CategoryProjectResultDTO::getProjectTotal)));
e.setPid(entity.getPid());
e.setPids(StringUtils.isEmpty(entity.getPids()) ? NumConstant.ZERO_STR : entity.getPids());
// 因为根据categoryCode分组,所以level都一样,取第一条的
e.setLevel(list.get(NumConstant.ZERO).getLevel());
finalResult.add(e);
});
log.info("父客户存在的分类{}"+ JSON.toJSONString(categoryProjectExists));
// 父客户不存在的分类
List<CategoryProjectResultDTO> categoryProjectNotExists = baseDao.selectOrgCategoryMoreCustomerInfo(customerIds, dateId, level, customerId, false);
log.info("父客户不存在的分类{}"+ JSON.toJSONString(categoryProjectNotExists));
if (!CollectionUtils.isEmpty(categoryProjectExists)){
sonCustomerList.addAll(categoryProjectExists);
}
if (!CollectionUtils.isEmpty(categoryProjectNotExists)){
sonCustomerList.addAll(categoryProjectNotExists);
}
if (!CollectionUtils.isEmpty(sonCustomerList)){
List<ScreenProjectCategoryOrgDailyEntity> finalSonResult = result;
sonCustomerList.forEach(s -> {
ScreenProjectCategoryOrgDailyEntity e = ConvertUtils.sourceToTarget(s, ScreenProjectCategoryOrgDailyEntity.class);
e.setOrgType(ScreenConstant.STREET);
e.setDateId(dateId);
e.setPid(entity.getPid());
e.setCustomerId(customerId);
finalSonResult.add(e);
});
}
// 内部客户与外部客户 相同的分类累加
if (!CollectionUtils.isEmpty(categoryProjectExists)){
finalResult.forEach(f -> {
categoryProjectResultDTOS.forEach(f -> {
categoryProjectExists.forEach(c -> {
if (f.getCategoryCode().equals(c.getCategoryCode())){
f.setProjectTotal(f.getProjectTotal() + c.getProjectTotal());
c.setStatus(true);
}
});
});
}
// 父客户不存在的分类
List<CategoryProjectResultDTO> categoryProjectNotExists = baseDao.selectOrgCategoryMoreCustomerInfo(customerIds, dateId, level, customerId, false);
List<ScreenProjectCategoryOrgDailyEntity> finalResult = result;
categoryProjectResultDTOS.forEach(c -> {
ScreenProjectCategoryOrgDailyEntity e = ConvertUtils.sourceToTarget(c, ScreenProjectCategoryOrgDailyEntity.class);
e.setCustomerId(customerId);
e.setCategoryOriginCustomerId(customerId);
e.setOrgId(entity.getAgencyId());
e.setPid(entity.getPid());
e.setPids(StringUtils.isEmpty(entity.getPids()) ? NumConstant.ZERO_STR : entity.getPids());
finalResult.add(e);
});
log.info("组合后的数据{}:"+JSON.toJSONString(finalResult));
// 父客户存在分类,但是父客户没有使用过此分类
Map<Boolean, List<CategoryProjectResultDTO>> groupByStatus = categoryProjectExists.stream().collect(Collectors.groupingBy(CategoryProjectResultDTO::getStatus));
List<CategoryProjectResultDTO> twoResult = new ArrayList<>();
if (!CollectionUtils.isEmpty(groupByStatus.get(false))){
twoResult.addAll(groupByStatus.get(false));
}
if (!CollectionUtils.isEmpty(categoryProjectNotExists)){
List<ScreenProjectCategoryOrgDailyEntity> entities = ConvertUtils.sourceToTarget(categoryProjectNotExists, ScreenProjectCategoryOrgDailyEntity.class);
result.addAll(entities);
twoResult.addAll(categoryProjectNotExists);
}
if (!CollectionUtils.isEmpty(twoResult)){
Map<String, List<CategoryProjectResultDTO>> groupOrigin = twoResult.stream().collect(Collectors.groupingBy(CategoryProjectResultDTO::getCategoryOriginCustomerId));
List<ScreenProjectCategoryOrgDailyEntity> finalResult1 = result;
groupOrigin.forEach((originCustomerId, list) -> {
// 父客户存在但是未使用的分类 + 父客户不存在的分类,根据categoryCode分组
Map<String, List<CategoryProjectResultDTO>> sonGroupByCode = list.stream().collect(Collectors.groupingBy(CategoryProjectResultDTO::getCategoryCode));
sonGroupByCode.forEach((code,list2) -> {
ScreenProjectCategoryOrgDailyEntity e = new ScreenProjectCategoryOrgDailyEntity();
e.setCustomerId(customerId);
e.setCategoryOriginCustomerId(originCustomerId);
e.setCategoryCode(code);
e.setOrgId(entity.getAgencyId());
e.setProjectTotal(CollectionUtils.isEmpty(list2) ? NumConstant.ZERO : list2.stream().collect(Collectors.summingInt(CategoryProjectResultDTO::getProjectTotal)));
e.setPid(entity.getPid());
e.setPids(StringUtils.isEmpty(entity.getPids()) ? NumConstant.ZERO_STR : entity.getPids());
// 因为根据categoryCode分组,所以level都一样,取第一条的
e.setLevel(list2.get(NumConstant.ZERO).getLevel());
finalResult1.add(e);
});
});
}
// 添加此 锦水、孔村、榆山 orgId,删除时使用
orgIds.add(PingYinConstant.JIN_SHUI_AGENCY_ID);
orgIds.add(PingYinConstant.KONG_CUN_AGENCY_ID);
orgIds.add(PingYinConstant.YU_SHAN_AGENCY_ID);
}
}
// 目前不考虑计算子客户组织直接创建的项目,只算内部客户
Map<String, List<CustomerAgencyInfoResultDTO>> groupByLevel = agencyIdList.stream().collect(Collectors.groupingBy(CustomerAgencyInfoResultDTO::getLevel));
List<CustomerAgencyInfoResultDTO> levelAgencyInfo = groupByLevel.get(level);
if (!CollectionUtils.isEmpty(levelAgencyInfo)) {
List<String> orgIdss = levelAgencyInfo.stream().map(m -> m.getAgencyId()).collect(Collectors.toList());
orgIds.addAll(orgIdss);
// 查询客户下,组织直接立项的,各项目分类下的项目数量【筛选组织创建的项目,fact_origin_project_main_daily表gridId为空】
List<ScreenProjectCategoryGridDailyDTO> screenProjectCategory = factOriginProjectCategoryDailyService.selectListProjectCategoryByOrg(orgIds, customerId);
log.info("直接立项的统计:"+screenProjectCategory);
if (!CollectionUtils.isEmpty(result)) {
if (!CollectionUtils.isEmpty(screenProjectCategory)) {
result.forEach(r -> {
@ -485,21 +534,30 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc
});
}
}
deleteAndInsert(customerId,dateId,result,orgIds);
log.info("插入总结果:{}"+JSON.toJSONString(result));
insert(result);
}
/**
* @Description 删除和新增
* @Description 新增
* @Param customerId
* @Param dateId
* @author zxc
* @date 2021/3/23 上午10:52
*/
@Transactional(rollbackFor = Exception.class)
public void deleteAndInsert(String customerId, String dateId, List<ScreenProjectCategoryOrgDailyEntity> needInsert,List<String> orgIds){
public void insert(List<ScreenProjectCategoryOrgDailyEntity> needInsert){
if (CollectionUtils.isEmpty(needInsert)){
return;
}
List<List<ScreenProjectCategoryOrgDailyEntity>> partition = ListUtils.partition(needInsert, NumConstant.ONE_HUNDRED);
partition.forEach(p -> {
insertBatch(p);
});
}
@Transactional(rollbackFor = Exception.class)
public void del(String customerId, String dateId,List<String> orgIds){
if (CollectionUtils.isEmpty(orgIds)){
return;
}
@ -507,10 +565,6 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl<Sc
do {
row = baseDao.deleteAppointData(customerId, dateId,orgIds);
}while (row > NumConstant.ZERO && row == NumConstant.ONE_THOUSAND);
List<List<ScreenProjectCategoryOrgDailyEntity>> partition = ListUtils.partition(needInsert, NumConstant.ONE_HUNDRED);
partition.forEach(p -> {
insertBatch(p);
});
}
}

26
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectOrgDailyServiceImpl.java

@ -184,44 +184,30 @@ public class ScreenProjectOrgDailyServiceImpl extends BaseServiceImpl<ScreenProj
log.warn(String.format(PingYinConstants.AGENCY_INFO_IS_ZERO,customerId));
return;
}
del(customerId, dateId);
List<ProjectOrgDailyResultDTO> projectOrgDaily = baseDao.selectOrgProjectByAgency(agencyInfos, dateId);
if (CollectionUtils.isEmpty(projectOrgDaily)){
log.info(String.format(PingYinConstants.SELECT_GRID_INFO_BY_ORG_IS_NULL,customerId));
return;
}
log.info(projectOrgDaily.toString());
List<ScreenProjectOrgDailyDTO> createProjects = disposeCreateProject(agencyInfos, dateId);
agencyInfos = disposeCreateProject(agencyInfos, dateId);
agencyInfos.forEach(a -> {
a.setDateId(dateId);
projectOrgDaily.forEach(p -> {
if (a.getAreaCode().equals(p.getAreaCode())){
a.setResolvedRatio(getRatio(p.getResolvedNum(),p.getProjectTotal()));
a.setBadRatio(getRatio(p.getBadTotal(),p.getEvaluateTotal()));
a.setGoodRatio(getRatio(p.getGoodTotal(),p.getEvaluateTotal()));
a.setBadTotal(p.getBadTotal());
a.setEvaluateTotal(p.getEvaluateTotal());
a.setGoodTotal(p.getGoodTotal());
a.setProjectTotal(p.getProjectTotal());
a.setResolvedNum(p.getResolvedNum());
}
});
});
agencyInfos.forEach(a -> {
createProjects.forEach(p -> {
if (a.getOrgId().equals(p.getOrgId())){
a.setBadTotal(p.getBadTotal() + a.getBadTotal());
a.setEvaluateTotal(p.getEvaluateTotal() + a.getEvaluateTotal());
a.setGoodTotal(p.getGoodTotal() + a.getGoodTotal());
a.setProjectTotal(p.getProjectTotal() + a.getProjectTotal());
a.setResolvedNum(p.getResolvedNum() + a.getResolvedNum());
a.setResolvedRatio(getRatio(a.getResolvedNum(),a.getProjectTotal()));
a.setBadRatio(getRatio(a.getBadTotal(),a.getEvaluateTotal()));
a.setGoodRatio(getRatio(a.getGoodTotal(),a.getEvaluateTotal()));
a.setResolvedRatio(getRatio(p.getResolvedNum(),p.getProjectTotal()));
a.setBadRatio(getRatio(p.getBadTotal(),p.getEvaluateTotal()));
a.setGoodRatio(getRatio(p.getGoodTotal(),p.getEvaluateTotal()));
}
});
});
log.info(agencyInfos.toString());
del(customerId, dateId);
insert(agencyInfos,customerId,dateId);
}
@ -239,6 +225,7 @@ public class ScreenProjectOrgDailyServiceImpl extends BaseServiceImpl<ScreenProj
log.warn(String.format(PingYinConstants.AGENCY_INFO_IS_ZERO,customerId));
return;
}
del(customerId, dateId);
List<ProjectOrgDailyResultDTO> projectOrgDaily = baseDao.selectOrgProject(agencyInfos, dateId);
if (CollectionUtils.isEmpty(projectOrgDaily)){
log.info(String.format(PingYinConstants.SELECT_GRID_INFO_BY_ORG_IS_NULL,customerId));
@ -278,7 +265,6 @@ public class ScreenProjectOrgDailyServiceImpl extends BaseServiceImpl<ScreenProj
});
});
log.info(agencyInfos.toString());
del(customerId, dateId);
insert(agencyInfos,customerId,dateId);
}

91
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectMainDailyDao.xml

@ -623,66 +623,57 @@
<!-- 组织查询项目总数 -->
<select id="selectProjectTotalByOrg" resultType="com.epmet.dto.pingyin.result.ProjectTotalResultDTO">
SELECT
m.AGENCY_ID AS orgId,
IFNULL(COUNT(m.ID),0) AS projectTotal
FROM fact_origin_project_main_daily m
WHERE m.DEL_FLAG = 0
AND m.GRID_ID = ''
AND (
<foreach collection="orgIds" item="orgId" separator=" OR ">
m.AGENCY_ID = #{orgId}
</foreach>
)
<if test="dateId != null and dateId != '' ">
AND m.DATE_ID <![CDATA[ <= ]]> #{dateId}
</if>
<if test="monthId != null and monthId != '' ">
AND m.MONTH_ID <![CDATA[ <= ]]> #{monthId}
</if>
GROUP BY m.AGENCY_ID
<foreach collection="orgIds" item="orgId" separator=" UNION ALL ">
SELECT
#{orgId} AS orgId,
IFNULL(COUNT(m.ID),0) AS projectTotal
FROM fact_origin_project_main_daily m
WHERE m.DEL_FLAG = 0
AND m.GRID_ID = ''
AND m.PIDS LIKE CONCAT('%',#{orgId},'%')
<if test="dateId != null and dateId != '' ">
AND m.DATE_ID <![CDATA[ <= ]]> #{dateId}
</if>
<if test="monthId != null and monthId != '' ">
AND m.MONTH_ID <![CDATA[ <= ]]> #{monthId}
</if>
</foreach>
</select>
<!-- 组织查询已解决项目数 -->
<select id="selectResolvedNumByOrg" resultType="com.epmet.dto.pingyin.result.ResolvedNumResultDTO">
SELECT
AGENCY_ID AS orgId,
IFNULL(COUNT(ID),0) AS resolvedNum
FROM fact_origin_project_main_daily
WHERE DEL_FLAG = 0
AND DATE_ID <![CDATA[ <= ]]> #{dateId}
AND PROJECT_STATUS = 'closed'
AND IS_RESOLVED = 'resolved'
AND (
<foreach collection="orgIds" item="orgId" separator=" OR ">
AGENCY_ID = #{orgId}
</foreach>
)
AND GRID_ID = ''
GROUP BY AGENCY_ID
<foreach collection="orgIds" item="orgId" separator=" UNION ALL ">
SELECT
#{orgId} AS orgId,
IFNULL(COUNT(ID),0) AS resolvedNum
FROM fact_origin_project_main_daily
WHERE DEL_FLAG = 0
AND DATE_ID <![CDATA[ <= ]]> #{dateId}
AND PIDS LIKE CONCAT('%',#{orgId},'%')
AND PROJECT_STATUS = 'closed'
AND IS_RESOLVED = 'resolved'
AND GRID_ID = ''
</foreach>
</select>
<!-- 组织 查询 满意度评价次数 -->
<select id="selectEvaluateCountByOrg" resultType="com.epmet.dto.pingyin.result.EvaluateTotalResultDTO">
SELECT
ORG_ID,
IFNULL(COUNT(PROJECT_ID),0) AS evaluateCount
FROM fact_origin_project_log_daily
WHERE DEL_FLAG = 0
AND ORG_TYPE = 'agency'
AND DATE_ID <![CDATA[ <= ]]> #{dateId}
AND (
<foreach collection="orgIds" item="orgId" separator=" OR ">
org_id = #{orgId}
<foreach collection="orgIds" item="orgId" separator=" UNION ALL ">
SELECT
#{orgId} as orgId,
IFNULL(COUNT(PROJECT_ID),0) AS evaluateCount
FROM fact_origin_project_log_daily
WHERE DEL_FLAG = 0
AND ORG_TYPE = 'agency'
AND DATE_ID <![CDATA[ <= ]]> #{dateId}
AND PIDS LIKE CONCAT('%',#{orgId},'%')
AND IS_ACTIVE = 1
AND (
<foreach collection="activeCodes" item="code" separator=" OR ">
ACTION_CODE = #{code}
</foreach>
)
AND IS_ACTIVE = 1
AND (
<foreach collection="activeCodes" item="code" separator=" OR ">
ACTION_CODE = #{code}
)
</foreach>
)
GROUP BY ORG_ID
</select>
<!-- 组织查询本月新增项目数 -->

12
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectCategoryOrgDailyDao.xml

@ -47,7 +47,7 @@
<!-- 查询组织分类信息【多客户】 -->
<select id="selectOrgCategoryMoreCustomerInfo" resultType="com.epmet.dto.screen.result.CategoryProjectResultDTO">
SELECT
IF(od.pid = '0', od.ORG_ID,od.pid) AS orgId,
od.ORG_ID AS orgId,
IFNULL(sca.PID,'0') AS pid,
IFNULL(sca.PIDS,'0') AS pids,
#{customerId} as customerId,
@ -64,7 +64,7 @@
od.DATE_ID
FROM screen_project_category_org_daily od
LEFT JOIN customer_project_category_dict cd ON (cd.CATEGORY_CODE = od.CATEGORY_CODE AND cd.CUSTOMER_ID = od.CUSTOMER_ID)
LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = od.PID
LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = od.ORG_ID
WHERE 1=1
AND od.DEL_FLAG = '0'
AND (
@ -74,13 +74,14 @@
)
<if test="existsStatus == true">
AND cd.EPMET_CATEGORY_CODE IS NOT NULL
AND cd.EPMET_CATEGORY_CODE != ''
</if>
<if test="existsStatus == false">
AND cd.EPMET_CATEGORY_CODE IS NULL
AND (cd.EPMET_CATEGORY_CODE IS NULL OR cd.EPMET_CATEGORY_CODE = '')
</if>
AND od.pid = '0'
AND od.date_id = #{dateId}
GROUP BY od.CATEGORY_CODE,od.pid
GROUP BY categoryCode,od.ORG_ID
</select>
<!-- 查询内部客户组织的项目分类 -->
@ -131,6 +132,7 @@
</foreach>
)
AND cd.EPMET_CATEGORY_CODE IS NOT NULL
AND cd.EPMET_CATEGORY_CODE != ''
AND od.pid = '0'
AND od.date_id = #{dateId}
GROUP BY od.CATEGORY_CODE,od.pid
@ -155,7 +157,7 @@
#{customer}
</foreach>
)
AND cd.EPMET_CATEGORY_CODE IS NULL
AND (cd.EPMET_CATEGORY_CODE IS NULL OR cd.EPMET_CATEGORY_CODE = '')
AND od.pid = '0'
AND od.date_id = #{dateId}
GROUP BY od.CATEGORY_CODE,od.pid

2
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectOrgDailyDao.xml

@ -138,7 +138,7 @@
FROM screen_project_grid_daily g
LEFT JOIN screen_customer_grid cg ON cg.GRID_ID = g.GRID_ID
WHERE g.DEL_FLAG = 0
AND cg.PARENT_AGENCY_ID = #{a.orgId}
AND cg.ALL_PARENT_IDS LIKE CONCAT('%',#{a.orgId},'%')
AND g.DATE_ID <![CDATA[ = ]]> #{dateId}
</foreach>
</select>

125
epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/controller/WxController.java

@ -0,0 +1,125 @@
package com.epmet.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
/**
* desc:微信配置测试
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-03-08
*/
@RestController
@RequestMapping("wechat")
public class WxController {
private static Logger log = LoggerFactory.getLogger(WxController.class);
@RequestMapping("check")
public void doGet(HttpServletRequest request, HttpServletResponse response) {
log.debug("weixin get...");
// 微信加密签名,signature结合了开发者填写的token参数和请求中的timestamp参数、nonce参数。
String signature = request.getParameter("signature");
// 时间戳
String timestamp = request.getParameter("timestamp");
// 随机数
String nonce = request.getParameter("nonce");
// 随机字符串
String echostr = request.getParameter("echostr");
// 通过检验signature对请求进行校验,若校验成功则原样返回echostr,表示接入成功,否则接入失败
PrintWriter out = null;
try {
out = response.getWriter();
if (WxController.checkSignature(signature, timestamp, nonce)) {
log.debug("weixin get success....");
out.print(echostr);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (out != null)
out.close();
}
}
/**
* 与接口配置信息中的Token要一致
*/
private static String token = "o2opri3hschiwit";
/**
* 验证签名
*
* @param signature
* @param timestamp
* @param nonce
* @return
*/
public static boolean checkSignature(String signature, String timestamp, String nonce) {
String[] arr = new String[]{token, timestamp, nonce};
// 将token、timestamp、nonce三个参数进行字典序排序
Arrays.sort(arr);
StringBuilder content = new StringBuilder();
for (int i = 0; i < arr.length; i++) {
content.append(arr[i]);
}
MessageDigest md = null;
String tmpStr = null;
try {
md = MessageDigest.getInstance("SHA-1");
// 将三个参数字符串拼接成一个字符串进行sha1加密
byte[] digest = md.digest(content.toString().getBytes());
tmpStr = byteToStr(digest);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
content = null;
// 将sha1加密后的字符串可与signature对比,标识该请求来源于微信
return tmpStr != null ? tmpStr.equals(signature.toUpperCase()) : false;
}
/**
* 将字节数组转换为十六进制字符串
*
* @param byteArray
* @return
*/
private static String byteToStr(byte[] byteArray) {
String strDigest = "";
for (int i = 0; i < byteArray.length; i++) {
strDigest += byteToHexStr(byteArray[i]);
}
return strDigest;
}
/**
* 将字节转换为十六进制字符串
*
* @param mByte
* @return
*/
private static String byteToHexStr(byte mByte) {
char[] Digit = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
char[] tempArr = new char[2];
tempArr[0] = Digit[(mByte >>> 4) & 0X0F];
tempArr[1] = Digit[mByte & 0X0F];
String s = new String(tempArr);
return s;
}
}

10
epmet-module/epmet-message/epmet-message-server/src/main/resources/db/migration/V0.3.17__alter_info_table_ucase.sql

@ -0,0 +1,10 @@
alter table info_profile change column publish_staff_id PUBLISH_STAFF_ID varchar(64) not null comment '发布人id';
alter table info_profile change column content CONTENT varchar(512) not null comment '内容概要,取前100字';
alter table info_profile change column first_att_id FIRST_ATT_ID varchar(64) comment '默认附件表的第一个条用于展示';
alter table info_profile change column total_receiver TOTAL_RECEIVER int(11) not null comment '应读人数';
alter table info_profile change column read_total READ_TOTAL int(11) not null default '0' comment '已读人数,插入是为0';
alter table info change column publish_staff_id PUBLISH_STAFF_ID varchar(64)not null comment '发布人id';
alter table info change column content CONTENT varchar(1024) not null comment '内容,这里存储全部的内容。';
alter table info_group_receivers change column info_receiver_group_id INFO_RECEIVER_GROUP_ID varchar(64) not null comment '群组id';

6
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/constant/ThirdPlatformActions.java

@ -19,4 +19,10 @@ public interface ThirdPlatformActions {
*/
String UPLOAD_FILE = "UPLOAD_FILE";
/** 推送 微信component access token */
String PUSH_COMPONENT_ACCESS_TOKEN = "PUSH_COMPONENT_ACCESS_TOKEN";
/** 推送 微信 authorizer access token */
String PUSH_AUTHORIZER_ACCESS_TOKEN = "PUSH_AUTHORIZER_ACCESS_TOKEN";
}

19
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/ThirdPlatformActionsResultDTO.java

@ -0,0 +1,19 @@
package com.epmet.dto.result;
import lombok.Data;
/**
* @Description 第三方平台及其支持的action result
* @author wxz
* @date 2021.08.30 17:06:42
*/
@Data
public class ThirdPlatformActionsResultDTO {
private String platformId;
private String platformKey;
private String platformName;
private String actionKey;
private String apiUrl;
}

18
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/privateepmet/GetAccessTokenResultDTO.java

@ -0,0 +1,18 @@
package com.epmet.dto.result.privateepmet;
import lombok.Data;
/**
* @Description 获取accesstoken结果
* @author wxz
* @date 2021.08.30 17:40:25
*/
@Data
public class GetAccessTokenResultDTO {
// token
private String accessToken;
// 有效时长
private Long expireTime;
}

21
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/ThirdOpenFeignClient.java

@ -2,6 +2,8 @@ package com.epmet.feign;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.AuthorizerAccessTokenFormDTO;
import com.epmet.dto.form.ComponentAccessTokenFormDTO;
import com.epmet.dto.form.SaveOrUpdateCustSelPlatformFormDTO;
import com.epmet.dto.form.ThirdPlatformFormDTO;
import com.epmet.dto.result.ThirdplatformResultDTO;
@ -36,4 +38,23 @@ public interface ThirdOpenFeignClient {
@PostMapping("/third/thirdplatform/customer/list-available-platforms-by-action")
Result<List<ThirdplatformResultDTO>> listAvailablePlatformsByCustomerAndAction(@RequestBody ThirdPlatformFormDTO input);
/**
* @Description 私有化平台接收component-access推送
* @param input
* @return com.epmet.commons.tools.utils.Result
* @author wxz
* @date 2021.08.30 16:40:17
*/
@PostMapping("/third/private-epmet/push-component-access-token")
Result pushComponentAccessToken(@RequestBody ComponentAccessTokenFormDTO input);
/**
* @Description 接收推送AuthorizerTokens
* @param input
* @return com.epmet.commons.tools.utils.Result
* @author wxz
* @date 2021.08.30 16:36:02
*/
@PostMapping("/third/private-epmet/push-authorizer-tokens")
Result pushAuthorizerTokens(@RequestBody AuthorizerAccessTokenFormDTO input);
}

12
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/ThirdOpenFeignClientFallback.java

@ -3,6 +3,8 @@ package com.epmet.feign.fallback;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.ModuleUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.AuthorizerAccessTokenFormDTO;
import com.epmet.dto.form.ComponentAccessTokenFormDTO;
import com.epmet.dto.form.SaveOrUpdateCustSelPlatformFormDTO;
import com.epmet.dto.form.ThirdPlatformFormDTO;
import com.epmet.dto.result.ThirdplatformResultDTO;
@ -22,4 +24,14 @@ public class ThirdOpenFeignClientFallback implements ThirdOpenFeignClient {
public Result<List<ThirdplatformResultDTO>> listAvailablePlatformsByCustomerAndAction(ThirdPlatformFormDTO input) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_THIRD_SERVER, "listAvailablePlatformsByCustomerAndAction", input);
}
@Override
public Result pushComponentAccessToken(ComponentAccessTokenFormDTO input) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_THIRD_SERVER, "pushComponentAccessToken", input);
}
@Override
public Result pushAuthorizerTokens(AuthorizerAccessTokenFormDTO input) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_THIRD_SERVER, "pushAuthorizerTokens", input);
}
}

5
epmet-module/epmet-third/epmet-third-server/pom.xml

@ -21,6 +21,11 @@
</properties>
<dependencies>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-openapi-sdk</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-third-client</artifactId>

246
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/ApiService.java

@ -1,7 +1,8 @@
package com.epmet.apiservice;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSON;
import com.epmet.apiservice.result.LZGridPlatformBaseResult;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.utils.HttpClientManager;
@ -10,19 +11,21 @@ import com.epmet.commons.tools.utils.SpringContextUtils;
import com.epmet.dao.ThirdplatformActionDao;
import com.epmet.dao.ThirdplatformCustomerRegisterDao;
import com.epmet.dao.ThirdplatformDao;
import com.epmet.dto.form.ProjectApplyAssistFormDTO;
import com.epmet.dto.form.TPFDemoFormDTO;
import com.epmet.dto.form.UploadFileFormDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.ProjectAssistResult;
import com.epmet.dto.result.UploadFileResultDTO;
import com.epmet.entity.ThirdplatformActionEntity;
import com.epmet.entity.ThirdplatformCustomerRegisterEntity;
import com.epmet.entity.ThirdplatformEntity;
import com.epmet.redis.ThirdPlatformCache;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate;
import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@ -32,7 +35,7 @@ import java.util.concurrent.TimeUnit;
* 此抽象类中定义方法的具体返回类型所有子类都要统一使用在具体实现中做转换若是不需要返回返回null即可
*/
@Slf4j
public abstract class ApiService {
public abstract class ApiService<R> {
/**
* 重试次数
*/
@ -61,13 +64,13 @@ public abstract class ApiService {
* @param headers
* @return
*/
public String sendGetRequest(String platformId, String action, Map<String, Object> params, Map<String, Object> headers) {
public R sendGetRequest(String platformId, String action, Map<String, Object> params, Map<String, Object> headers) {
// 1.获取token
String accessToken = getAccessToken(platformId);
//2.获取url
ThirdplatformEntity thirdplatform = SpringContextUtils.getBean(ThirdplatformDao.class).selectById(platformId);
ThirdplatformActionEntity actionEntity = SpringContextUtils.getBean(ThirdplatformActionDao.class)
.getByPlatformIdAndActionKey(platformId, action);
ThirdPlatformCache thirdPlatformInfo = getThirdPlatformInfo(platformId);
String actionUrl = getThirdPlatformActionUrl(platformId, action);
if (headers == null) {
headers = new HashMap<>();
@ -76,8 +79,8 @@ public abstract class ApiService {
// 填充access token到头当中
headers.put("X-Access-Token", accessToken);
log.info("apiService sendGetRequest param:{},headers:{}",params,headers);
Result<String> result = HttpClientManager.getInstance().sendGet(thirdplatform.getBaseUrl().concat(actionEntity.getApiUrl()),
thirdplatform.getBaseUrl().startsWith("https://"),
Result<String> result = HttpClientManager.getInstance().sendGet(thirdPlatformInfo.getBaseUrl().concat(actionUrl),
thirdPlatformInfo.getBaseUrl().startsWith("https://"),
params,
headers);
log.info("apiService sendGetRequest result:{}",JSON.toJSONString(result));
@ -87,37 +90,51 @@ public abstract class ApiService {
if (result.success()) {
throw new RenException("请求第三方平台,获取AccessToken失败。");
}
LZGridPlatformBaseResult platformResult = JSON.parseObject(result.getData(), LZGridPlatformBaseResult.class);
judgeResultSuccess(platformResult);
return result.getData();
return parsePlatformResponseResult(result.getData(), String.class);
}
/**
* @Description
accesstoken header名称如果不需要AccessToken与getAccessToken()方法共同返回null即可
* @return java.lang.String
* @author wxz
* @date 2021.08.30 14:06:26
*/
public abstract String getAccessTokenHeaderName();
/**
* 发送post请求
* @param platformId
* @param action
* @param jsonString
* @param headers
* @return
* @return 平台对应返回值的Result类
*/
public String sendPostRequest(String platformId, String action, String jsonString, Map<String, Object> headers) {
public R sendPostRequest(String platformId, String action, String jsonString, Map<String, Object> headers, Map<String, String> urlParams) {
// 1.获取token
String accessToken = getAccessToken(platformId);
//2.获取url
ThirdplatformEntity thirdplatform = SpringContextUtils.getBean(ThirdplatformDao.class).selectById(platformId);
ThirdplatformActionEntity actionEntity = SpringContextUtils.getBean(ThirdplatformActionDao.class)
.getByPlatformIdAndActionKey(platformId, action);
ThirdPlatformCache platformFromCache = getThirdPlatformInfo(platformId);
String actionUrl = getThirdPlatformActionUrl(platformId, action);
if (headers == null) {
headers = new HashMap<>();
}
// 填充access token到头当中
headers.put("X-Access-Token", accessToken);
if (StringUtils.isNotBlank(accessToken)) {
//headers.put("X-Access-Token", accessToken);
String accessTokenHeaderName = getAccessTokenHeaderName();
if (StringUtils.isBlank(accessTokenHeaderName)) {
throw new RenException("没有指定AccessToken的Header名字");
}
headers.put(accessTokenHeaderName, accessToken);
}
log.info("apiService sendPostRequest param:{},headers:{}",jsonString,headers);
Result<String> result = HttpClientManager.getInstance().sendPost(thirdplatform.getBaseUrl().concat(actionEntity.getApiUrl()),
thirdplatform.getBaseUrl().startsWith("https://"),
String urlParmsStr = this.convertQueryParams2String(urlParams);
Result<String> result = HttpClientManager.getInstance().sendPost(platformFromCache.getBaseUrl().concat(actionUrl).concat(urlParmsStr),
platformFromCache.getBaseUrl().startsWith("https://"),
jsonString,
headers);
log.info("apiService sendPostRequest result:{}",JSON.toJSONString(result));
@ -128,12 +145,10 @@ public abstract class ApiService {
throw new RenException("请求第三方平台,发送Post请求失败。错误信息:" + result.getMsg());
}
LZGridPlatformBaseResult platformResult = JSON.parseObject(result.getData(), LZGridPlatformBaseResult.class);
judgeResultSuccess(platformResult);
return result.getData();
return parsePlatformResponseResult(result.getData(), String.class);
}
public String sendPostRequestToUploadFile(String platformId, String action, File file, String fileName) {
public R sendPostRequestToUploadFile(String platformId, String action, File file, String fileName) {
// 1.获取token
String accessToken = getAccessToken(platformId);
//2.获取url
@ -159,8 +174,6 @@ public abstract class ApiService {
throw new RenException("请求第三方平台,发送Post请求失败。错误信息:" + result.getMsg());
}
LZGridPlatformBaseResult platformResult = JSON.parseObject(result.getData(), LZGridPlatformBaseResult.class);
// token过期重试逻辑,先不加
//if ("402".equals(platformResult.getCode())) {
// // 如果token过期
@ -168,8 +181,37 @@ public abstract class ApiService {
// getAccessToken(platformId);
// return sendPostRequest(platformId, action, jsonString, headers);
//}
judgeResultSuccess(platformResult);
return result.getData();
return parsePlatformResponseResult(result.getData(), String.class);
}
/**
* @Description 将url参数拼接为字符串
* @param queryParams
* @return java.lang.String
* @author wxz
* @date 2021.08.31 14:08:17
*/
protected String convertQueryParams2String(Map<String, String> queryParams) {
try {
if (queryParams == null || queryParams.size() == 0) {
return "";
}
StringBuilder sb = new StringBuilder("");
queryParams.entrySet().forEach(entry -> {
String key = entry.getKey();
String value = entry.getValue();
sb.append("&").append(key).append("=").append(value);
});
String result = sb.toString();
if (result.startsWith("&")) {
result = result.substring(1);
return "?".concat(result);
}
return "";
} catch (Exception e) {
log.warn("gateway中将url参数转化为String失败,程序继续执行,错误信息:".concat(ExceptionUtils.getErrorStackTrace(e)));
return "";
}
}
/**
@ -202,6 +244,36 @@ public abstract class ApiService {
stringRedisTemplate.opsForValue().set(RedisKeys.getThirdPlatformAccessTokenKey(platformId), accessToken, expire, timeUnit);
}
/**
* @Description 将第三方平台信息存入缓存
* @param cache
* @return void
* @author wxz
* @date 2021.08.31 14:55:48
*/
protected void addPlatformToCache(ThirdPlatformCache cache) {
RedisTemplate<String, String> stringRedisTemplate = SpringContextUtils.getBean("redisTemplate", RedisTemplate.class);
Map<String, Object> stringObjectMap = BeanUtil.beanToMap(cache);
stringRedisTemplate.opsForHash().putAll(RedisKeys.getThirdPlatformInfoKey(cache.getPlatformId()), stringObjectMap);
}
/**
* @Description 从缓存中取第三方平台信息
* @param thirdPlatformKey
* @return com.epmet.redis.ThirdPlatformCache
* @author wxz
* @date 2021.08.31 14:55:28
*/
protected ThirdPlatformCache getPlatformFromCache(String thirdPlatformKey) {
HashOperations<String, String, Object> hashOperations = SpringContextUtils.getBean("redisTemplate", RedisTemplate.class).opsForHash();
Map<String, Object> entries = hashOperations.entries(RedisKeys.getThirdPlatformInfoKey(thirdPlatformKey));
if (entries.size() == 0) {
return null;
}
ThirdPlatformCache thirdPlatformCache = BeanUtil.mapToBean(entries, ThirdPlatformCache.class, true);
return thirdPlatformCache;
}
/**
* @Description 从缓存中取token
* @return
@ -210,7 +282,87 @@ public abstract class ApiService {
*/
protected String getAccessTokenFromCache(String platformId) {
RedisTemplate<String, String> stringRedisTemplate = SpringContextUtils.getBean("redisTemplate", RedisTemplate.class);
return stringRedisTemplate.opsForValue().get(platformId);
return stringRedisTemplate.opsForValue().get(RedisKeys.getThirdPlatformAccessTokenKey(platformId));
}
/**
* @Description 从缓存查询第三方平台操作url
* @param platformId
* @param action
* @return java.lang.String
* @author wxz
* @date 2021.08.31 15:18:06
*/
protected String getThirdPlatformActionUrlFromCache(String platformId, String action) {
HashOperations<String, String, String> ops = SpringContextUtils.getBean("redisTemplate", RedisTemplate.class).opsForHash();
String url = ops.get(RedisKeys.getThirdPlatformActionUrlKey(platformId), action);
return url;
}
/**
* @Description 将第三方平台操作url添加至缓存
* @param platformId
* @param map
* @return java.lang.String
* @author wxz
* @date 2021.08.31 15:20:45
*/
protected void addThirdPlatformActionUrlsToCache(String platformId, Map<String, Object> map) {
String redisKey = RedisKeys.getThirdPlatformActionUrlKey(platformId);
RedisTemplate redisTemplate = SpringContextUtils.getBean("redisTemplate", RedisTemplate.class);
HashOperations<String, String, Object> ops = redisTemplate.opsForHash();
ops.putAll(redisKey, map);
}
/**
* @Description 从缓存里面读取平台信息如果缓存中没有从db读取放入缓存
* @param platformId 平台id
* @return com.epmet.redis.ThirdPlatformCache
* @author wxz
* @date 2021.08.31 15:02:19
*/
protected ThirdPlatformCache getThirdPlatformInfo(String platformId) {
ThirdPlatformCache platform = getPlatformFromCache(platformId);
if (platform == null) {
platform = new ThirdPlatformCache();
ThirdplatformEntity platformEntity = SpringContextUtils.getBean(ThirdplatformDao.class).selectById(platformId);
platform.setPlatformId(platformEntity.getId());
platform.setApiService(platformEntity.getApiService());
platform.setBaseUrl(platformEntity.getBaseUrl());
platform.setPlatformKey(platformEntity.getPlatformKey());
platform.setPlatformName(platformEntity.getPlatformName());
platform.setPlatformSecret(platformEntity.getPlatformSecret());
addPlatformToCache(platform);
}
return platform;
}
/**
* @Description 获取第三放平台操作url优先读取缓存没有则读取db
* @param platformId
* @param actionKey
* @return java.util.Map<java.lang.String,java.lang.String>
* @author wxz
* @date 2021.08.31 15:21:39
*/
protected String getThirdPlatformActionUrl(String platformId, String actionKey) {
String url = getThirdPlatformActionUrlFromCache(platformId, actionKey);
if (StringUtils.isBlank(url)) {
List<ThirdplatformActionEntity> actions = SpringContextUtils.getBean(ThirdplatformActionDao.class)
.listPlatformActions(platformId);
Map<String, Object> map = new HashMap<>(actions.size());
// 将action:url映射至map
for (ThirdplatformActionEntity a : actions) {
map.put(a.getActionKey(), a.getApiUrl());
if (actionKey.equals(a.getActionKey())) {
url = a.getApiUrl();
}
}
addThirdPlatformActionUrlsToCache(platformId, map);
}
return url;
}
/**
@ -246,16 +398,38 @@ public abstract class ApiService {
}
/**
* @Description 判断第三方平台返回结果成功失败如果失败则抛出异常
* @return
* @Description 解析第三方平台返回结果
* @param resultString
* @param clazz R的泛型对象T的clazz
* @return R 泛型不同平台的Result DTO类型
* @author wxz
* @date 2021.03.22 10:32
*/
public abstract void judgeResultSuccess(LZGridPlatformBaseResult result);
* @date 2021.08.31 13:36:11
*/
public abstract <T> R parsePlatformResponseResult(String resultString, Class<T> clazz);
public UploadFileResultDTO uploadFile(UploadFileFormDTO formDTO) {
return null;
}
/**
* @Description 推送ComponentAccessToken
* @param form
* @return void 保持空实现让子类去实现
* @author wxz
* @date 2021.08.30 17:15:01
*/
public void pushComponentAccessToken(ComponentAccessTokenFormDTO form, String platformId, String platformKey) {}
/**
* @description 推送小程序token
*
* @param form
* @param platformId
* @param platformKey
* @return
* @author wxz
* @date 2021.08.31 20:26:51
*/
public void pushAuthorizerAccessToken(AuthorizerAccessTokenFormDTO form, String platformId, String platformKey) {};
}

18
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/DemoApiService.java

@ -14,10 +14,15 @@ import org.springframework.stereotype.Component;
* demo api service
*/
@Component(value = "demoApiService")
public class DemoApiService extends ApiService {
public class DemoApiService extends ApiService<String> {
Logger logger = LoggerFactory.getLogger(DemoApiService.class);
@Override
public String getAccessTokenHeaderName() {
return null;
}
@Override
public String getAccessToken(String platformId) {
return null;
@ -29,8 +34,15 @@ public class DemoApiService extends ApiService {
return null;
}
/**
* @Description 解析平台返回结果
* @param resultString 平台返回结果string
* @return java.lang.String
* @author wxz
* @date 2021.08.30 22:43:24
*/
@Override
public void judgeResultSuccess(LZGridPlatformBaseResult result) {
public <T> String parsePlatformResponseResult(String resultString, Class<T> clazz) {
return null;
}
}

49
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/LuzhouGridPlatformApiService.java

@ -31,7 +31,12 @@ import java.util.concurrent.TimeUnit;
*/
@Slf4j
@Component("luzhouGridPlatformApiService")
public class LuzhouGridPlatformApiService extends ApiService {
public class LuzhouGridPlatformApiService extends ApiService<LZGridPlatformBaseResult> {
@Override
public String getAccessTokenHeaderName() {
return "X-Access-Token";
}
@Override
public String getAccessToken(String platformId) {
@ -58,11 +63,8 @@ public class LuzhouGridPlatformApiService extends ApiService {
throw new RenException("请求第三方平台,获取AccessToken失败。");
}
LZGridPlatformBaseResult<String> platformResult = JSON.parseObject(result.getData(), LZGridPlatformBaseResult.class);
judgeResultSuccess(platformResult);
token = platformResult.getResult();
addAccessTokenToCache(platformId, token, (long)(3600*1.8*1000), TimeUnit.MILLISECONDS);
LZGridPlatformBaseResult<String> lzGridPlatformBaseResult = parsePlatformResponseResult(result.getData(), String.class);
addAccessTokenToCache(platformId, lzGridPlatformBaseResult.getResult(), (long)(3600*1.8*1000), TimeUnit.MILLISECONDS);
}
return token;
}
@ -83,30 +85,24 @@ public class LuzhouGridPlatformApiService extends ApiService {
// 正式调用第三方平台
String argsStr = JSON.toJSONString(formDTO);
String result = sendPostRequest(platformId, ThirdPlatformActions.PROJECT_ASSIST, argsStr, null);
LZGridPlatformBaseResult<String> result = sendPostRequest(platformId, ThirdPlatformActions.PROJECT_ASSIST, argsStr, null, null);
// 开发阶段临时写死
//String result = "{\"eventId\":\"test-task-id\"}";
ProjectAssistResult projectAssistResult = new ProjectAssistResult();
if (!StringUtils.isBlank(result)) {
// 此处要经过一系列业务处理,将第三方平台返回的数据进行解析,等处理最后转换成ProjectAssistResult类型,返回。ProjectAssistResult这个类型是
// 所有apiService的projectAssist方法返回值的统一类型,是我们的epmet-cloud所需要的数据的实体,
// 所有apiService都要想办法转化成这个类型。
LZGridPlatformBaseResult<String> lzResult = JSON.parseObject(result, LZGridPlatformBaseResult.class);
// 此处设置为第三方系统返回的唯一id
projectAssistResult.setTaskId(lzResult.getResult());
}
// 此处设置为第三方系统返回的唯一id
projectAssistResult.setTaskId(result.getResult());
log.info("projectAssist 泸州网格化平台项目协助发送成功");
return projectAssistResult;
}
@Override
public void judgeResultSuccess(LZGridPlatformBaseResult result) {
//LZGridPlatformBaseResult;
if (!"200".equalsIgnoreCase(result.getCode())) {
throw new RenException("泸州网格化平台:返回失败结果,错误码:" + result.getCode());
public <T> LZGridPlatformBaseResult<T> parsePlatformResponseResult(String resultString, Class<T> clazz) {
LZGridPlatformBaseResult<T> baseResult = JSON.parseObject(resultString, LZGridPlatformBaseResult.class);
if (!"200".equalsIgnoreCase(baseResult.getCode())) {
throw new RenException("泸州网格化平台:返回失败结果,错误码:" + baseResult.getCode());
}
return baseResult;
}
@Override
@ -118,16 +114,9 @@ public class LuzhouGridPlatformApiService extends ApiService {
// 正式调用第三方平台
File file = new File(formDTO.getFile().getOriginalFilename());
FileUtils.copyInputStreamToFile(formDTO.getFile().getInputStream(), file);
String result = sendPostRequestToUploadFile(platformId, ThirdPlatformActions.UPLOAD_FILE, file, fileName);
if (!StringUtils.isBlank(result)) {
// 此处要经过一系列业务处理,将第三方平台返回的数据进行解析,等处理最后转换成ProjectAssistResult类型,返回。ProjectAssistResult这个类型是
// 所有apiService的projectAssist方法返回值的统一类型,是我们的epmet-cloud所需要的数据的实体,
// 所有apiService都要想办法转化成这个类型。
LZGridPlatformBaseResult lzResult = JSON.parseObject(result, LZGridPlatformBaseResult.class);
// 此处设置为第三方系统返回的唯一id
resultDTO.setUrl((String) lzResult.getResult());
}
LZGridPlatformBaseResult<String> baseResult = sendPostRequestToUploadFile(platformId, ThirdPlatformActions.UPLOAD_FILE, file, fileName);
// 此处设置为第三方系统返回的唯一id
resultDTO.setUrl(baseResult.getResult());
System.out.println("泸州网格化平台项目文件上传成功");
} catch (Exception e) {
throw new RenException("上传失败");

169
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/PingyinPrivateEpmetApiService.java

@ -0,0 +1,169 @@
package com.epmet.apiservice.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.epmet.apiservice.ApiService;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.feign.ResultDataResolver;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.ThirdPlatformActions;
import com.epmet.dto.form.AuthorizerAccessTokenFormDTO;
import com.epmet.dto.form.ComponentAccessTokenFormDTO;
import com.epmet.dto.result.privateepmet.GetAccessTokenResultDTO;
import com.epmet.openapi.sdk.sign.OpenApiSignUtils;
import com.epmet.redis.ThirdPlatformCache;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
@Component("pingyinPrivateEpmetApiService")
@Slf4j
public class PingyinPrivateEpmetApiService extends ApiService<Result> implements ResultDataResolver {
// 认证方式
private String authType = "take_token";
@Override
public String getAccessTokenHeaderName() {
return "AccessToken";
}
@Override
public String getAccessToken(String platformId) {
String accessTokenFromCache = super.getAccessTokenFromCache(platformId);
if (StringUtils.isBlank(accessTokenFromCache)) {
ThirdPlatformCache thirdPlatformInfo = super.getThirdPlatformInfo(platformId);
String apiUrl = getThirdPlatformActionUrl(platformId, ThirdPlatformActions.GET_ACCESS_TOKEN);
String baseUrl = thirdPlatformInfo.getBaseUrl();
String platformKey = thirdPlatformInfo.getPlatformKey();
String platformSecret = thirdPlatformInfo.getPlatformSecret();
String uuid = UUID.randomUUID().toString();
long currentTimeMillis = System.currentTimeMillis();
try {
String sign = createSign(platformKey, platformSecret, uuid, currentTimeMillis, authType, null);
log.info("【调用平阴私有化平台获取AccessToken】参数列表:sign:{}, app_id:{}, auth_type:{}, nonce:{}, timestamp:{}", sign, platformKey, platformSecret, uuid, currentTimeMillis);
String urlParams = super.convertQueryParams2String(constructCommonUrlParamsMap(platformKey, authType, uuid, currentTimeMillis, sign));
String requestUrl = baseUrl.concat(apiUrl).concat(urlParams);
Result<String> stringResult = HttpClientManager.getInstance().sendPostByHttps(requestUrl, "{}");
String remoteResultString = getResultDataOrThrowsException(stringResult, "【调用平阴私有化平台获取AccessToken】", EpmetErrorCode.SERVER_ERROR.getCode(), null);
Result<GetAccessTokenResultDTO> remoteResult = parsePlatformResponseResult(remoteResultString, GetAccessTokenResultDTO.class);
log.info("【调用平阴私有化平台获取AccessToken】结果:{}", remoteResultString);
accessTokenFromCache = remoteResult.getData().getAccessToken();
//(15 * 60 * 1000)为提前获取token。对方token有效期2小时,我们设置有效期为1小时45分钟,留15分钟容错时间,防止时间差
long expire = remoteResult.getData().getExpireTime() - System.currentTimeMillis() - (15 * 60 * 1000);
super.addAccessTokenToCache(platformId, accessTokenFromCache, expire, TimeUnit.MILLISECONDS);
} catch (Exception e) {
throw new RenException(ExceptionUtils.getErrorStackTrace(e));
}
}
return accessTokenFromCache;
}
/**
* @Description 创建签名
* @param platformKey
* @param platformSecret
* @param nonce
* @param timeMillis
* @param authType
* @return java.lang.String
* @author wxz
* @date 2021.08.31 15:37:58
*/
private String createSign(String platformKey, String platformSecret, String nonce, Long timeMillis, String authType, Map<String, String> requestBodyMap) {
HashMap<String, String> contentMap = new HashMap<>();
contentMap.put("app_id", platformKey);
contentMap.put("auth_type", authType);
contentMap.put("nonce", nonce);
contentMap.put("timestamp", String.valueOf(timeMillis));
if (requestBodyMap != null && requestBodyMap.size() > 0) {
contentMap.putAll(requestBodyMap);
}
String sign;
try {
sign = OpenApiSignUtils.createSign(contentMap, platformSecret);
} catch (Exception e) {
String detail = ExceptionUtils.getErrorStackTrace(e);
log.error(detail);
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), "【平阴私有化平台apService】创建签名失败");
}
return sign;
}
/**
* @Description 构造url参数map
* @param platformKey
* @param authType
* @param nonce
* @param timeMillis
* @param sign
* @return java.util.Map<java.lang.String,java.lang.String>
* @author wxz
* @date 2021.08.31 14:19:41
*/
private Map<String, String> constructCommonUrlParamsMap(String platformKey, String authType, String nonce, Long timeMillis, String sign) {
HashMap<String, String> map = new HashMap<>();
map.put("app_id", platformKey);
map.put("auth_type", authType);
map.put("nonce", nonce);
map.put("timestamp", String.valueOf(timeMillis));
map.put("sign", sign);
return map;
}
@Override
public <T> Result<T> parsePlatformResponseResult(String resultString, Class<T> clazz) {
Result<T> result;
try {
result = JSON.parseObject(resultString, new TypeReference<Result<T>>(clazz){});
} catch (Exception e) {
String errorStackTrace = ExceptionUtils.getErrorStackTrace(e);
log.error(errorStackTrace);
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), "【调用平阴私有化服务器,解析返回结果失败】");
}
if (!result.success()) {
throw new RenException(String.format("【请求平阴私有化平台】失败,返回结果string:%s", resultString));
}
return result;
}
@Override
public void pushComponentAccessToken(ComponentAccessTokenFormDTO form, String platformId, String platformKey) {
ThirdPlatformCache thirdPlatformInfo = getThirdPlatformInfo(platformId);
String nonce = UUID.randomUUID().toString();
long timeMillis = System.currentTimeMillis();
Map<String, String> bodyMap = null;
try {
bodyMap = ConvertUtils.entityToMap(form);
} catch (Exception e) {
String detail = ExceptionUtils.getErrorStackTrace(e);
log.error(detail);
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), "【推送ComponentAccessToken】requestBody转化为map失败");
}
String sign = createSign(platformKey, thirdPlatformInfo.getPlatformSecret(), nonce, timeMillis, authType, bodyMap);
Map<String, String> urlParams = constructCommonUrlParamsMap(platformKey, authType, nonce, timeMillis, sign);
String jsonString = JSON.toJSONString(form);
Result result = super.sendPostRequest(platformId, ThirdPlatformActions.PUSH_COMPONENT_ACCESS_TOKEN, jsonString, null, urlParams);
getResultDataOrThrowsException(result, "【平阴私有化平台】推送ComponentAccessToken", EpmetErrorCode.SERVER_ERROR.getCode(), null);
}
@Override
public void pushAuthorizerAccessToken(AuthorizerAccessTokenFormDTO form, String platformId, String platformKey) {
}
}

50
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PrivateEpmetController.java

@ -0,0 +1,50 @@
package com.epmet.controller;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.AuthorizerAccessTokenFormDTO;
import com.epmet.dto.form.ComponentAccessTokenFormDTO;
import com.epmet.service.PrivateEpmetService;
import org.springframework.beans.factory.annotation.Autowired;
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 私有化平台相关controller
* @author wxz
* @date 2021.08.30 15:18:51
*/
@RestController
@RequestMapping("/private-epmet")
public class PrivateEpmetController {
@Autowired
private PrivateEpmetService privateEpmetService;
/**
* @Description 接收推送component access
* @param input
* @return com.epmet.commons.tools.utils.Result
* @author wxz
* @date 2021.08.30 15:18:57
*/
@PostMapping("push-component-access-token")
public Result pushComponentAccessToken(@RequestBody ComponentAccessTokenFormDTO input) {
privateEpmetService.pushComponentAccessToken(input);
return new Result();
}
/**
* @Description 接收推送AuthorizerTokens
* @param input
* @return com.epmet.commons.tools.utils.Result
* @author wxz
* @date 2021.08.30 16:36:02
*/
@PostMapping("push-authorizer-tokens")
public Result pushAuthorizerTokens(@RequestBody AuthorizerAccessTokenFormDTO input) {
privateEpmetService.pushAuthorizerTokens(input);
return new Result();
}
}

30
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/TestConttroller.java

@ -0,0 +1,30 @@
package com.epmet.controller;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.ComponentAccessTokenFormDTO;
import com.epmet.service.ComponentVerifyTicketService;
import com.epmet.service.PrivateEpmetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
@RestController
@RequestMapping("test")
public class TestConttroller {
@Autowired
private ComponentVerifyTicketService componentVerifyTicketService;
@PostMapping("push-component-access-token")
public Result testPushComponentAccessToken() {
ComponentAccessTokenFormDTO form = new ComponentAccessTokenFormDTO();
form.setComponentAccessToken("token...");
form.setExpiresInTime(new Date());
componentVerifyTicketService.pushComponentAccessToken2PrivateEpmetPlatforms(form);
return new Result();
}
}

10
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformActionDao.java

@ -22,6 +22,8 @@ import com.epmet.entity.ThirdplatformActionEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
*
*
@ -38,4 +40,12 @@ public interface ThirdplatformActionDao extends BaseDao<ThirdplatformActionEntit
* @date 2021.03.16 13:35
*/
ThirdplatformActionEntity getByPlatformIdAndActionKey(@Param("platformId") String platformId, @Param("action") String action);
/**
* @Description 列出平台的操作列表
* @param platformId
* @return com.epmet.entity.ThirdplatformActionEntity
* @author wxz
* @date 2021.08.31 15:23:14
*/
List<ThirdplatformActionEntity> listPlatformActions(@Param("platformId") String platformId);
}

10
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformCustomerRegisterDao.java

@ -19,6 +19,7 @@ package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.form.PlatformUnregisterFormDTO;
import com.epmet.dto.result.ThirdPlatformActionsResultDTO;
import com.epmet.entity.ThirdplatformCustomerRegisterEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -55,4 +56,13 @@ public interface ThirdplatformCustomerRegisterDao extends BaseDao<ThirdplatformC
* @Date 10:15 2021-04-09
**/
void unregisterPlatformCustomer(PlatformUnregisterFormDTO formDTO);
/**
* @Description 已知操作的key查询哪些app可以做此操作
* @param actionKey 操作key
* @return java.util.List<com.epmet.dto.result.ThirdPlatformActionsResultDTO>
* @author wxz
* @date 2021.08.30 17:07:32
*/
List<ThirdPlatformActionsResultDTO> listPlatformsByActionKey(@Param("actionKey") String actionKey);
}

19
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/ThirdPlatformCache.java

@ -0,0 +1,19 @@
package com.epmet.redis;
import lombok.Data;
/**
* @Description 第三方平台缓存对象
* @author wxz
* @date 2021.08.31 14:41:49
*/
@Data
public class ThirdPlatformCache {
//String platformKey, String platformSecret, String platformName, String apiService, String baseUrl
private String platformId;
private String platformKey;
private String platformSecret;
private String platformName;
private String apiService;
private String baseUrl;
}

3
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ComponentVerifyTicketService.java

@ -2,6 +2,7 @@ package com.epmet.service;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.dto.form.AuthCodeAndTimeFromDTO;
import com.epmet.dto.form.ComponentAccessTokenFormDTO;
import org.springframework.web.bind.annotation.RequestBody;
import javax.servlet.http.HttpServletRequest;
@ -48,4 +49,6 @@ public interface ComponentVerifyTicketService {
*/
void redirectUri(TokenDto tokenDto, @RequestBody AuthCodeAndTimeFromDTO fromDTO);
public void pushComponentAccessToken2PrivateEpmetPlatforms(ComponentAccessTokenFormDTO input);
}

19
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PrivateEpmetService.java

@ -0,0 +1,19 @@
package com.epmet.service;
import com.epmet.dto.form.AuthorizerAccessTokenFormDTO;
import com.epmet.dto.form.ComponentAccessTokenFormDTO;
public interface PrivateEpmetService {
void pushAuthorizerTokens(AuthorizerAccessTokenFormDTO input);
/**
* @Description 推送component access token
* @param input
* @return void
* @author wxz
* @date 2021.08.30 16:17:48
*/
void pushComponentAccessToken(ComponentAccessTokenFormDTO input);
void pushVerifyTicket(String ticket);
}

10
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ThirdPlatformService.java

@ -5,6 +5,7 @@ import com.epmet.dto.form.CustomerFormDTO;
import com.epmet.dto.form.ThirdPlatformFormDTO;
import com.epmet.dto.form.PlatformRegisterFormDTO;
import com.epmet.dto.form.PlatformUnregisterFormDTO;
import com.epmet.dto.result.ThirdPlatformActionsResultDTO;
import com.epmet.dto.result.ThirdplatformResultDTO;
import java.util.List;
@ -100,4 +101,13 @@ public interface ThirdPlatformService {
* @Date 10:15 2021-04-09
**/
void registerThirdPlatformCustomer(PlatformRegisterFormDTO formDTO);
/**
* @Description 已知操作的key查询哪些app可以做此操作
* @param actionKey
* @return java.util.List<com.epmet.dto.result.ThirdplatformResultDTO>
* @author wxz
* @date 2021.08.30 16:59:13
*/
List<ThirdPlatformActionsResultDTO> listPlatformsByActionKey(String actionKey);
}

203
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java

@ -4,12 +4,15 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.client.config.utils.IOUtils;
import com.dingtalk.api.request.OapiRobotSendRequest;
import com.epmet.apiservice.ApiService;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.constant.ModuleConstant;
import com.epmet.constant.ThirdPlatformActions;
import com.epmet.constant.ThirdRedisKeyConstant;
import com.epmet.constant.ThirdRunTimeInfoConstant;
import com.epmet.dao.*;
@ -21,7 +24,9 @@ import com.epmet.feign.OperCrmOpenFeignClient;
import com.epmet.mpaes.WXBizMsgCrypt;
import com.epmet.mpaes.WXXmlToMapUtil;
import com.epmet.redis.RedisThird;
import com.epmet.service.ApiServiceSelector;
import com.epmet.service.ComponentVerifyTicketService;
import com.epmet.service.ThirdPlatformService;
import com.epmet.wxapi.constant.WxMaCodeConstant;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@ -47,7 +52,7 @@ import static com.epmet.constant.ThirdRunTimeInfoConstant.*;
*/
@Slf4j
@Service
public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketService {
public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketService, ApiServiceSelector {
@Autowired
private RedisThird redisThird;
@ -94,6 +99,9 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
@Autowired
private PaCustomerDao paCustomerDao;
@Autowired
private ThirdPlatformService thirdPlatformService;
@Value("${third.platform.appId}")
private String componentAppId;
@Value("${third.platform.appSecret}")
@ -104,8 +112,8 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
private String token;
/**
* @Description 获得授权事件的票据
* @param
* @Description 获得授权事件的票据
* @author zxc
*/
@Transactional(rollbackFor = Exception.class)
@ -123,23 +131,23 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
String nonce = request.getParameter(ModuleConstant.NONCE);
String encryptType = request.getParameter(ModuleConstant.ENCRYPT_TYPE);
String signature = request.getParameter(ModuleConstant.SIGNATURE);
log.info(String.format(ThirdRunTimeInfoConstant.VERIFY_TICKET,msgSignature,timeStamp,nonce,encryptType,signature));
log.info(String.format(ThirdRunTimeInfoConstant.VERIFY_TICKET, msgSignature, timeStamp, nonce, encryptType, signature));
// 从请求中读取整个post数据
InputStream inputStream;
String postData = null;
inputStream = request.getInputStream();
postData= IOUtils.toString(inputStream,ModuleConstant.UTF8);
WXBizMsgCrypt wxBizMsgCrypt = new WXBizMsgCrypt(token,aesKey,componentAppId);
postData = IOUtils.toString(inputStream, ModuleConstant.UTF8);
WXBizMsgCrypt wxBizMsgCrypt = new WXBizMsgCrypt(token, aesKey, componentAppId);
String msg = wxBizMsgCrypt.decryptMsg(msgSignature, timeStamp, nonce, postData);
log.info(String.format(ThirdRunTimeInfoConstant.MSG,msg));
log.info(String.format(ThirdRunTimeInfoConstant.MSG, msg));
// 将xml转为map
Map<String, String> result = WXXmlToMapUtil.xmlToMap(msg);
String infotype = result.get(ModuleConstant.INFO_TYPE);
log.info(String.format(ThirdRunTimeInfoConstant.INFO_TYPE,infotype));
switch (infotype){
log.info(String.format(ThirdRunTimeInfoConstant.INFO_TYPE, infotype));
switch (infotype) {
case ModuleConstant.TICKET_UNDERLINE_KEY: //接收票据 【component_verify_ticket】
String ComponentVerifyTicket = result.get(ModuleConstant.TICKET_KEY);
log.info(String.format(COMPONENT_VERIFY_TICKET,ComponentVerifyTicket));
log.info(String.format(COMPONENT_VERIFY_TICKET, ComponentVerifyTicket));
// 缓存 ticket
redisThird.setComponentVerifyTicket(ComponentVerifyTicket);
// 存数据库
@ -149,7 +157,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
//先逻辑删
ticketDao.deleteOldComponentVerifyTicket();
ticketDao.insertComponentVerifyTicket(ticketFormDTO);
log.info(ModuleConstant.TICKET_UNDERLINE_KEY+":"+ComponentVerifyTicket);
log.info(ModuleConstant.TICKET_UNDERLINE_KEY + ":" + ComponentVerifyTicket);
break;
case ModuleConstant.AUTHORIZED: //授权成功
this.disposeAuthResult(result);
@ -173,7 +181,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
}
log.info(ThirdRunTimeInfoConstant.END_TICKET);
Integer tokenCount = componentAccessTokenDao.selectAccessTokenCount();
if (tokenCount == NumConstant.ZERO){
if (tokenCount == NumConstant.ZERO) {
String accessTokenCountFlag = ModuleConstant.ACCOUNT_TOKEN_FLAG_ONE;
this.getComponentAccessToken(accessTokenCountFlag);
}
@ -181,14 +189,14 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
}
/**
* @Description 授权结果插入
* @param result
* @Description 授权结果插入
* @author zxc
*/
@Transactional(rollbackFor = Exception.class)
public void disposeAuthResult(Map<String,String> result){
public void disposeAuthResult(Map<String, String> result) {
Map tempMap = result;
Map<String,Object> data = tempMap;
Map<String, Object> data = tempMap;
AuthResultRecordFormDTO authResultRecord = ConvertUtils.mapToEntity(data, AuthResultRecordFormDTO.class);
authResultRecord.setWechatCreateTime(this.sToDate(result.get(ModuleConstant.CREATE_TIME)));
if (result.containsKey(ModuleConstant.AUTHORIZATION_CODE_EXPIRED_TIME)) {
@ -199,9 +207,9 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
}
/**
* @Description 定时获取 (令牌component_access_token) 第三方与微信交互使用的component_access_token
* 每十分钟执行一次,判断是否有马上超时的15分钟以内算马上超时
* @param accessTokenCountFlag 表里的 component_access_token的数量
* @Description 定时获取 (令牌component_access_token) 第三方与微信交互使用的component_access_token
* 每十分钟执行一次,判断是否有马上超时的15分钟以内算马上超时
* @author zxc
*/
@Transactional(rollbackFor = Exception.class)
@ -218,7 +226,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
jsonObject.put(ModuleConstant.COMPONENT_APPID, componentAppId);
jsonObject.put(ModuleConstant.COMPONENT_APPSECRET, appSecret);
jsonObject.put(ModuleConstant.TICKET_UNDERLINE_KEY, componentVerifyTicket);
log.info(String.format(ThirdRunTimeInfoConstant.COMPONENT_ACCESS_TOKEN,componentVerifyTicket));
log.info(String.format(ThirdRunTimeInfoConstant.COMPONENT_ACCESS_TOKEN, componentVerifyTicket));
String post = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_COMPONENT_TOKEN_URL, JSON.toJSONString(jsonObject)).getData();
Map hashMap = JSON.parseObject(post, Map.class);
if (!hashMap.containsKey(ModuleConstant.ERR_MSG)) {
@ -236,6 +244,13 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
componentAccessTokenDao.insertComponentAccessToken(formDTO);
//存缓存
redisThird.setComponentAccessToken(componentAccessToken);
//推送到私有化平台们
try {
pushComponentAccessToken2PrivateEpmetPlatforms(formDTO);
} catch (Exception e) {
String detail = ExceptionUtils.getErrorStackTrace(e);
log.error(detail);
}
} else {
throw new RenException(ThirdRunTimeInfoConstant.FAILURE_ACCESS_TOKEN);
}
@ -245,8 +260,29 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
}
/**
* @Description 获取预授权码
* @param input
* @return void
* @Description 推送component access token到私有化平台
* @author wxz
* @date 2021.08.30 17:12:15
*/
public void pushComponentAccessToken2PrivateEpmetPlatforms(ComponentAccessTokenFormDTO input) {
List<ThirdPlatformActionsResultDTO> platforms = thirdPlatformService.listPlatformsByActionKey(ThirdPlatformActions.PUSH_COMPONENT_ACCESS_TOKEN);
platforms.stream().forEach(p -> {
log.info("推送component-access-token到私有化平台:platformId:{}, platformKey:{}, platformName:{}, apiUrl:{}", p.getPlatformId(), p.getPlatformKey(), p.getPlatformName(), p.getApiUrl());
ApiService apiService = selectApiService(p.getPlatformId());
try {
apiService.pushComponentAccessToken(input, p.getPlatformId(), p.getPlatformKey());
} catch (Exception e) {
String detail = ExceptionUtils.getErrorStackTrace(e);
log.error(detail);
}
});
}
/**
* @param
* @Description 获取预授权码
* @author zxc
*/
@Transactional(rollbackFor = Exception.class)
@ -258,7 +294,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
JSONObject jsonObject = new JSONObject();
jsonObject.put(ModuleConstant.COMPONENT_APPID, componentAppId);
String post = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_CREATE_PREAUTHCODE_URL + accessToken, JSON.toJSONString(jsonObject)).getData();
log.info(String.format(POST_RESULT,post));
log.info(String.format(POST_RESULT, post));
Map hashMap = JSON.parseObject(post, Map.class);
if (!hashMap.containsKey(ModuleConstant.ERR_MSG)) {
preAuthCode = hashMap.get(ModuleConstant.PRE_AUTH_CODE).toString();
@ -283,11 +319,11 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
}
/**
* @Description 使用授权码获取授权信息 请求参数component_access_tokencomponent_appidauthorization_code
* @Description 使用授权码获取授权信息 请求参数component_access_tokencomponent_appidauthorization_code
* @author zxc
*/
@Transactional(rollbackFor = Exception.class)
public AuthorizationInfoResultDTO authInfoByAuthCode(String authCode,String customerId,String clientType) {
public AuthorizationInfoResultDTO authInfoByAuthCode(String authCode, String customerId, String clientType) {
log.info(START_GET_AUTH_INFO);
AuthorizationInfoResultDTO authorizationInfoResultDTO = new AuthorizationInfoResultDTO();
// 获取令牌【component_access_token】
@ -297,11 +333,11 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
jsonObject.put(ModuleConstant.COMPONENT_APPID, componentAppId);
jsonObject.put(ModuleConstant.AUTHORIZATION_CODE, authCode);
String authInfo = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_QUERY_AUTH_URL + accessToken, JSON.toJSONString(jsonObject)).getData();
HashMap<String,Map> hashMap = JSON.parseObject(authInfo, HashMap.class);
HashMap<String, Map> hashMap = JSON.parseObject(authInfo, HashMap.class);
Map map = hashMap.get(ModuleConstant.AUTHORIZATION_INFO);
authorizationInfoResultDTO = ConvertUtils.mapToEntity(map, AuthorizationInfoResultDTO.class);
String authAppId = authorizationInfoResultDTO.getAuthorizer_appid();
log.info("授权信息:"+map);
log.info("授权信息:" + map);
String expiresIn = authorizationInfoResultDTO.getExpires_in().toString();
Date expiresInTime = this.countExpirationTime(expiresIn);
//授权信息分为两张表,基础信息authorization_info,授权列表func_info
@ -314,14 +350,14 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
authInfoDTO.setCustomerId(customerId);
authInfoDTO.setClientType(clientType);
List<Map> func_info = authorizationInfoResultDTO.getFunc_info();
log.info("权限列表信息:"+func_info);
log.info("权限列表信息:" + func_info);
String funcInfo = JSON.toJSONString(func_info);
authInfoDTO.setFuncInfo(funcInfo);
//先逻辑删除,在插入
authorizationInfoDao.updateOldAuthorizationInfo(authAppId);
authorizationInfoDao.insertAuthorizationInfo(authInfoDTO);
// 授权信息放入缓存
redisThird.setAuthInfo(authorizationInfoResultDTO,customerId,clientType);
redisThird.setAuthInfo(authorizationInfoResultDTO, customerId, clientType);
//authorizer_refresh_token 放入缓存
redisThird.setAuthorizerRefreshToken(authInfoDTO);
log.info(END_GET_AUTH_INFO);
@ -329,8 +365,8 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
}
/**
* @Description 获取/刷新接口调用令牌
* @param
* @Description 获取/刷新接口调用令牌
* @author zxc
*/
@Transactional(rollbackFor = Exception.class)
@ -338,7 +374,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
public void refreshToken() {
//查询 即将过期的 authorizer_access_token
List<WillOverDueResultDTO> willOverDueResultDTOS = authorizationInfoDao.checkWillOverDue();
if (willOverDueResultDTOS.size() != NumConstant.ZERO && null != willOverDueResultDTOS){
if (willOverDueResultDTOS.size() != NumConstant.ZERO && null != willOverDueResultDTOS) {
log.info("查询到即将过期的authorizer_access_token");
willOverDueResultDTOS.forEach(willOverDueDTO -> {
String authAppId = willOverDueDTO.getAuthAppId();
@ -346,10 +382,10 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
String clientType = willOverDueDTO.getClientType();
JSONObject jsonObject = new JSONObject();
//授权方AppId
jsonObject.put(ModuleConstant.AUTHORIZER_APPID,authAppId);
jsonObject.put(ModuleConstant.AUTHORIZER_APPID, authAppId);
//第三方平台AppId
jsonObject.put(ModuleConstant.COMPONENT_APPID,componentAppId);
jsonObject.put(ModuleConstant.AUTHORIZER_REFRESH_TOKEN,willOverDueDTO.getAuthorizerRefreshToken());
jsonObject.put(ModuleConstant.COMPONENT_APPID, componentAppId);
jsonObject.put(ModuleConstant.AUTHORIZER_REFRESH_TOKEN, willOverDueDTO.getAuthorizerRefreshToken());
String componentAccessToken = redisThird.getComponentAccessToken();
String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_AUTHORIZER_TOKEN_URL + componentAccessToken, JSON.toJSONString(jsonObject)).getData();
Map map = JSON.parseObject(data, HashMap.class);
@ -368,7 +404,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
formDTO.setAuthAppid(authAppId);
formDTO.setClientType(clientType);
AuthorizationInfoFormDTO authorizationInfo = new AuthorizationInfoFormDTO();
BeanUtils.copyProperties(formDTO,authorizationInfo);
BeanUtils.copyProperties(formDTO, authorizationInfo);
authorizationInfo.setAuthorizerAppid(authAppId);
//先逻辑删除,在插入
authorizationInfoDao.deleteOldAuthorizerAccessToken(customerId, clientType);
@ -380,7 +416,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
resultDTO.setAuthorizer_refresh_token(authorizerRefreshToken);
resultDTO.setAuthorizer_appid(authAppId);
resultDTO.setExpires_in(7200);
redisThird.setAuthInfo(resultDTO,customerId,clientType);
redisThird.setAuthInfo(resultDTO, customerId, clientType);
}
});
log.info("更新authorizer_access_token成功");
@ -389,13 +425,13 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
}
/**
* @Description 授权回调URL,回调时并获取授权信息
* @param
* @Description 授权回调URL, 回调时并获取授权信息
* @author zxc
*/
@Transactional(rollbackFor = Exception.class)
@Override
public void redirectUri(TokenDto tokenDto, @RequestBody AuthCodeAndTimeFromDTO authCodeAndTime){
public void redirectUri(TokenDto tokenDto, @RequestBody AuthCodeAndTimeFromDTO authCodeAndTime) {
log.info("开始执行回调URL");
String authCode = authCodeAndTime.getAuthCode();
String clientType = authCodeAndTime.getClientType();
@ -413,7 +449,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
formDTO.setClientType(clientType);
formDTO.setCustomerId(customerId);
log.info(ThirdRunTimeInfoConstant.BEGIN_DELETE_INSERT_AUTH_CODE);
authCodeDao.deleteCustomerAuthCode(customerId,clientType);
authCodeDao.deleteCustomerAuthCode(customerId, clientType);
authCodeDao.insertRedirectAuthCode(formDTO);
//authCode存缓存
redisThird.setAuthCode(formDTO);
@ -423,12 +459,12 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
List<FixationAppIdResultDTO> fixationAppIdResultDTOS = fixationAppIdDao.selectFixationInfos();
String finalCustomerId = customerId;//
fixationAppIdResultDTOS.forEach(fixationAppId -> {
if (fixationAppId.getAppId().equals(authAppId)){
if (fixationAppId.getAppId().equals(authAppId)) {
// TODO 是城阳项目或者党群e事通
// crm表中的customerId【原customerId】
String masterCustomerId = fixationAppId.getMasterCustomerId();
formDTO.setCustomerId(masterCustomerId);
authCodeDao.deleteCustomerAuthCode(finalCustomerId,clientType);
authCodeDao.deleteCustomerAuthCode(finalCustomerId, clientType);
authCodeDao.insertRedirectAuthCode(formDTO);
//authCode存缓存
redisThird.setAuthCode(formDTO);
@ -447,37 +483,37 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
//替换 新customerId为旧customerId
customerId = formDTO.getCustomerId();
// 2. 创建开放平台账号并绑定 或者 直接绑定开放平台
this.createAndBindOpenAccount(customerId,authAppId,clientType);
this.createAndBindOpenAccount(customerId, authAppId, clientType);
// 3. 更新 customer_mp 表授权状态和AuthAppId
this.updateCustomerMpAppId(customerId,authAppId,clientType);
authCodeDao.updateAppId(customerId,clientType,authAppId);
this.updateCustomerMpAppId(customerId, authAppId, clientType);
authCodeDao.updateAppId(customerId, clientType, authAppId);
// 4. 保存授权方账户信息
this.saveAuthAccountInfo(customerId,authAppId,clientType);
this.saveAuthAccountInfo(customerId, authAppId, clientType);
// 5. 校验客户居民端、工作端小程序是否全部授权,全部授权完成的推送钉钉消息 sun
this.checkAuthorization(customerId);
log.info("回调结束");
}
/**
* @Description 获取授权方的帐号基本信息并保存
* @param customerId
* @param authAppId
* @Description 获取授权方的帐号基本信息并保存
* @author zxc
*/
@Transactional(rollbackFor = Exception.class)
public void saveAuthAccountInfo(String customerId, String authAppId,String clientType) {
public void saveAuthAccountInfo(String customerId, String authAppId, String clientType) {
log.info("开始执行保存授权账户基本信息");
JSONObject jsonObject = new JSONObject();
jsonObject.put(ModuleConstant.COMPONENT_APP_ID,componentAppId);
jsonObject.put(ModuleConstant.AUTHORIZER_APP_ID,authAppId);
jsonObject.put(ModuleConstant.COMPONENT_APP_ID, componentAppId);
jsonObject.put(ModuleConstant.AUTHORIZER_APP_ID, authAppId);
String componentAccessToken = redisThird.getComponentAccessToken();
String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_GET_AUTHORIZER_INFO + componentAccessToken , JSON.toJSONString(jsonObject)).getData();
Map<String,Map> map = JSON.parseObject(data, Map.class);
String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_GET_AUTHORIZER_INFO + componentAccessToken, JSON.toJSONString(jsonObject)).getData();
Map<String, Map> map = JSON.parseObject(data, Map.class);
Map authorizerInfo = map.get(ModuleConstant.AUTHORIZER_INFO);
log.info("授权信息:"+authorizerInfo);
log.info("授权信息:" + authorizerInfo);
// 存在 “miniprograminfo” 字段为小程序,不存在为公众号
boolean keyExist = authorizerInfo.containsKey(ModuleConstant.MINI_PROGRAM_INFO);
if (keyExist == true){
if (keyExist == true) {
log.info("授权方为小程序 并 开始插入信息");
MiniInfoFormDTO miniInfoFormDTO = ConvertUtils.mapToEntity(authorizerInfo, MiniInfoFormDTO.class);
miniInfoFormDTO.setCustomerId(customerId);
@ -498,22 +534,22 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
businessInfoForm.setPrimaryId(primaryId);
businessInfoList.add(businessInfoForm);
});
businessInfoDao.deleteBusinessInfo(customerId,clientType);
businessInfoDao.deleteBusinessInfo(customerId, clientType);
businessInfoDao.insertBusinessInfo(businessInfoList);
//todo 小程序配置的合法域名信息插入
Map miniProgramInfo = (Map) authorizerInfo.get(ModuleConstant.MINI_PROGRAM_INFO);
List<MiniNetworkInfoFormDTO> networkInfoList = new ArrayList<>();
Map networkInfo = (Map) miniProgramInfo.get(ModuleConstant.NETWORK);
networkInfo.forEach((key,value) -> {
networkInfo.forEach((key, value) -> {
MiniNetworkInfoFormDTO miniNetworkInfoForm = new MiniNetworkInfoFormDTO();
miniNetworkInfoForm .setCustomerId(customerId);
miniNetworkInfoForm.setCustomerId(customerId);
miniNetworkInfoForm.setClientType(clientType);
miniNetworkInfoForm.setNetworkType(key.toString());
miniNetworkInfoForm.setUrl(value.toString());
miniNetworkInfoForm.setPrimaryId(primaryId);
networkInfoList.add(miniNetworkInfoForm);
});
miniNetworkInfoDao.deleteNetworkInfo(customerId,clientType);
miniNetworkInfoDao.deleteNetworkInfo(customerId, clientType);
miniNetworkInfoDao.insertNetworkInfo(networkInfoList);
//todo 小程序配置的类目信息插入
List<MiniCategoryInfoFormDTO> categoryInfoList = new ArrayList<>();
@ -533,7 +569,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
miniCategoryInfoDao.deleteCategoryInfo(customerId, clientType);
miniCategoryInfoDao.insertCategoryInfo(categoryInfoList);
}
}else {
} else {
log.info("授权方为公众号 并 开始插入信息");
PaInfoFormDTO paInfoFormDTO = ConvertUtils.mapToEntity(authorizerInfo, PaInfoFormDTO.class);
//公众号基本信息插入
@ -551,7 +587,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
businessInfoForm.setPrimaryId(primaryId);
businessInfoList.add(businessInfoForm);
});
businessInfoDao.deleteBusinessInfo(customerId,clientType);
businessInfoDao.deleteBusinessInfo(customerId, clientType);
businessInfoDao.insertBusinessInfo(businessInfoList);
}
log.info("保存授权方基本信息结束");
@ -559,12 +595,12 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
}
/**
* @Description 回填 customer_mp appId , 更改授权状态
* @param
* @Description 回填 customer_mp appId , 更改授权状态
* @author zxc
*/
@Transactional(rollbackFor = Exception.class)
public void updateCustomerMpAppId(String customerId,String authAppId,String clientType){
public void updateCustomerMpAppId(String customerId, String authAppId, String clientType) {
log.info("==========回填customer_mp开始==========");
Integer checkBindCount = customerMpDao.checkBind(authAppId, clientType);
if (checkBindCount == NumConstant.ZERO) {
@ -578,14 +614,14 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
log.info("==========回填customer_mp结束==========");
}
public void createAndBindOpenAccount(String customerId,String authAppId,String clientType){
public void createAndBindOpenAccount(String customerId, String authAppId, String clientType) {
log.info(ThirdRunTimeInfoConstant.BEGIN_CREATE_OPEN);
Map<String, Object> authorizerRefreshToken = redisThird.getAuthorizerRefreshToken(customerId + ThirdRedisKeyConstant.COLON + clientType);
String authorizerAccessToken = authorizerRefreshToken.get("authorizerAccessToken").toString();
JSONObject bindInfoForm = new JSONObject();
bindInfoForm.put(ModuleConstant.LOW_APP_ID,authAppId);
bindInfoForm.put(ModuleConstant.LOW_APP_ID, authAppId);
String bindResult = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_OPEN_GET + authorizerAccessToken, JSON.toJSONString(bindInfoForm)).getData();
Map<String,Object> bindInfo = JSON.parseObject(bindResult, Map.class);
Map<String, Object> bindInfo = JSON.parseObject(bindResult, Map.class);
boolean bindStatus = bindInfo.containsKey(ModuleConstant.OPEN_APP_ID);
if (bindStatus != true) {
Integer authCount = customerMpDao.selectAuthCount(customerId);
@ -663,11 +699,11 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
}
/**
* @Description 转换过期时间
* @param expiresIn
* @Description 转换过期时间
* @author zxc
*/
public Date countExpirationTime(String expiresIn){
public Date countExpirationTime(String expiresIn) {
expiresIn = expiresIn + "000";
Date date = new Date();
long l = date.getTime() + Long.valueOf(expiresIn);
@ -676,21 +712,21 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
}
/**
* @Description 查询客户Id
* @param tokenDto
* @Description 查询客户Id
* @author zxc
*/
public String getLoginUserCustomerId(TokenDto tokenDto){
public String getLoginUserCustomerId(TokenDto tokenDto) {
PaCustomerUserAgencyDTO result = paCustomerUserAgencyDao.selectCustomerIdByUserId(tokenDto.getUserId());
return result.getCustomerId();
}
/**
* @Description 时间戳秒级转换 Date
* @param t
* @Description 时间戳秒级转换 Date
* @author zxc
*/
public Date sToDate(String t){
public Date sToDate(String t) {
Long aLong = Long.valueOf(t + "000");
Date date = new Date();
date.setTime(aLong);
@ -699,24 +735,24 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
/**
* @author sun
* @Description 校验客户两哥小程序是否完成授权
* @Description 校验客户两哥小程序是否完成授权
*/
private void checkAuthorization(String customerId){
private void checkAuthorization(String customerId) {
List<CustomerMpDTO> list = customerMpDao.selectByCustomerId(customerId);
AtomicBoolean bl = new AtomicBoolean(false);
list.forEach(mp->{
if(mp.getAuthorizationFlag()!=NumConstant.ONE){
list.forEach(mp -> {
if (mp.getAuthorizationFlag() != NumConstant.ONE) {
bl.set(true);
}
});
if(!bl.get()){
if (!bl.get()) {
dDingNews(customerId);
}
}
/**
* @author sun
* @Description 发送钉钉消息通知运营人员有新客户完成授权
* @Description 发送钉钉消息通知运营人员有新客户完成授权
*/
private String dDingNews(String customerId) {
//1.查询客户及管理员信息,用于发送消息使用
@ -739,8 +775,29 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
"> 管理员称谓: " + result.getAppellation() + "\n\n" +
"> 联系方式: " + result.getPhone() + "\n");
request.setMarkdown(markdown);
HttpClientManager.getInstance().sendDingMsg(JSON.toJSONString(request),url,secret);
HttpClientManager.getInstance().sendDingMsg(JSON.toJSONString(request), url, secret);
return null;
}
/**
* @Description 推送AuthorizerAccessToken到私有化平台们
* @param form
* @return void
* @author wxz
* @date 2021.08.31 17:22:04
*/
public void pushAuthorizerAccessToken2PrivateEpmets(AuthorizerAccessTokenFormDTO form) {
List<ThirdPlatformActionsResultDTO> platforms = thirdPlatformService.listPlatformsByActionKey(ThirdPlatformActions.PUSH_AUTHORIZER_ACCESS_TOKEN);
platforms.stream().forEach(p -> {
log.info("推送authorizer-access-token到私有化平台:platformId:{}, platformKey:{}, platformName:{}, apiUrl:{}", p.getPlatformId(), p.getPlatformKey(), p.getPlatformName(), p.getApiUrl());
ApiService apiService = selectApiService(p.getPlatformId());
try {
apiService.pushAuthorizerAccessToken(form, p.getPlatformId(), p.getPlatformKey());
} catch (Exception e) {
String detail = ExceptionUtils.getErrorStackTrace(e);
log.error(detail);
}
});
}
}

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

@ -0,0 +1,71 @@
package com.epmet.service.impl;
import com.epmet.constant.ThirdRunTimeInfoConstant;
import com.epmet.dao.AuthorizationInfoDao;
import com.epmet.dao.ComponentAccessTokenDao;
import com.epmet.dao.ComponentVerifyTicketDao;
import com.epmet.dto.form.AuthorizationInfoFormDTO;
import com.epmet.dto.form.AuthorizerAccessTokenFormDTO;
import com.epmet.dto.form.ComponentAccessTokenFormDTO;
import com.epmet.dto.result.AuthorizationInfoResultDTO;
import com.epmet.redis.RedisThird;
import com.epmet.service.PrivateEpmetService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@Slf4j
public class PrivateEpmetServiceImpl implements PrivateEpmetService {
@Autowired
private ComponentVerifyTicketDao componentVerifyTicketDao;
@Autowired
private AuthorizationInfoDao authorizationInfoDao;
@Autowired
private ComponentAccessTokenDao componentAccessTokenDao;
@Autowired
private RedisThird redisThird;
@Transactional(rollbackFor = RuntimeException.class)
@Override
public void pushAuthorizerTokens(AuthorizerAccessTokenFormDTO input) {
System.out.println("收到AuthorizerAccessTokenFormDTO:" + input);
//AuthorizationInfoFormDTO authorizationInfo = new AuthorizationInfoFormDTO();
//BeanUtils.copyProperties(input,authorizationInfo);
//authorizationInfo.setAuthorizerAppid(input.getAuthAppid());
////先逻辑删除,在插入
//authorizationInfoDao.deleteOldAuthorizerAccessToken(input.getCustomerId(), input.getClientType());
//authorizationInfoDao.insertAuthorizerAccessToken(input);
////缓存 refreshAuthorizerAccessToken
//redisThird.setAuthorizerRefreshToken(authorizationInfo);
//AuthorizationInfoResultDTO resultDTO = new AuthorizationInfoResultDTO();
//resultDTO.setAuthorizer_access_token(input.getAuthorizerAccessToken());
//resultDTO.setAuthorizer_refresh_token(input.getAuthorizerRefreshToken());
//resultDTO.setAuthorizer_appid(input.getAuthAppid());
//resultDTO.setExpires_in(7200);
//redisThird.setAuthInfo(resultDTO,input.getCustomerId(),input.getClientType());
}
@Override
@Transactional(rollbackFor = RuntimeException.class)
public void pushComponentAccessToken(ComponentAccessTokenFormDTO componentAccessToken) {
System.out.println("收到componentAccessToken:" + componentAccessToken);
//先逻辑删,在插入
//componentAccessTokenDao.deleteOldComponentAccessToken();
//componentAccessTokenDao.insertComponentAccessToken(componentAccessToken);
////存缓存
//redisThird.setComponentAccessToken(componentAccessToken.getComponentAccessToken());
}
@Override
public void pushVerifyTicket(String ticket) {
}
}

6
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ThirdPlatformServiceImpl.java

@ -12,6 +12,7 @@ import com.epmet.dto.form.CustomerFormDTO;
import com.epmet.dto.form.ThirdPlatformFormDTO;
import com.epmet.dto.form.PlatformRegisterFormDTO;
import com.epmet.dto.form.PlatformUnregisterFormDTO;
import com.epmet.dto.result.ThirdPlatformActionsResultDTO;
import com.epmet.dto.result.ThirdplatformResultDTO;
import com.epmet.entity.ThirdplatformCustomerActionEntity;
import com.epmet.entity.ThirdplatformCustomerRegisterEntity;
@ -160,4 +161,9 @@ public class ThirdPlatformServiceImpl implements ThirdPlatformService {
thirdplatformCustomerRegisterDao.batchInsertThirdplatformCustomerRegister(entityList);
}
}
@Override
public List<ThirdPlatformActionsResultDTO> listPlatformsByActionKey(String actionKey) {
return thirdplatformCustomerRegisterDao.listPlatformsByActionKey(actionKey);
}
}

17
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ThirdplatformActionDao.xml

@ -30,6 +30,23 @@
from thirdplatform_action ta
where ta.PLATFORM_ID = #{platformId}
and ACTION_KEY = #{action}
and ta.DEL_FLAG=0
</select>
<select id="listPlatformActions" resultType="com.epmet.entity.ThirdplatformActionEntity">
select id,
platform_id,
action_key,
api_url,
del_flag,
revision,
created_by,
created_time,
updated_by,
updated_time
from thirdplatform_action ta
where ta.PLATFORM_ID = #{platformId}
and ta.DEL_FLAG=0
</select>

14
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ThirdplatformCustomerRegisterDao.xml

@ -36,6 +36,20 @@
and DEL_FLAG = 0
</select>
<!--已知操作的key,查询哪些app可以做此操作-->
<select id="listPlatformsByActionKey" resultType="com.epmet.dto.result.ThirdPlatformActionsResultDTO">
select thirdplatform_action.PLATFORM_ID,
thirdplatform.PLATFORM_KEY,
thirdplatform.PLATFORM_NAME,
thirdplatform_action.ACTION_KEY,
thirdplatform_action.API_URL
from thirdplatform
inner join thirdplatform_action
on (thirdplatform.ID = thirdplatform_action.PLATFORM_ID and thirdplatform_action.DEL_FLAG = 0)
and thirdplatform_action.ACTION_KEY = #{actionKey}
and thirdplatform.DEL_FLAG = 0
</select>
<insert id="batchInsertThirdplatformCustomerRegister" parameterType="map">
insert into thirdplatform_customer_register
(

17
epmet-module/gov-grid/gov-grid-server/src/main/java/com/epmet/service/impl/PartyBranchManageServiceImpl.java

@ -137,17 +137,14 @@ public class PartyBranchManageServiceImpl implements PartyBranchManageService {
CustomerPartyBranchDTO customerPartyBranch = customerPartyBranchResult.getData();
PartyMemberBaseInfoAddFormDTO partyMemberBaseInfoAddFormDTO = this.getPartyMemberBaseInfoAddFormDTO(formDTO, customerPartyBranch);
Result<String> result = resiPartyMemberOpenFeignClient.addPartyMemberBaseInfo(partyMemberBaseInfoAddFormDTO);
if (!result.success() || StringUtils.isBlank(result.getData())) {
throw new RenException(result.getCode(), result.getMsg());
}
//3、党支部总人数+1
if (result.success() && StringUtils.isNotBlank(result.getData())) {
//党支部总人数+1
customerPartyBranch.setTotalPartyMember(customerPartyBranch.getTotalPartyMember() + 1);
Result<String> updatePartyBranchResult = govOrgOpenFeignClient.updatePartyBranch(customerPartyBranch);
if (updatePartyBranchResult.success()) {
logger.info(String.format("党支部(%s)总人数+1", formDTO.getPartyBranchId()));
}
} else {
logger.error("添加党员异常");
throw new RenException(result.getCode());
customerPartyBranch.setTotalPartyMember(customerPartyBranch.getTotalPartyMember() + 1);
Result<String> updatePartyBranchResult = govOrgOpenFeignClient.updatePartyBranch(customerPartyBranch);
if (updatePartyBranchResult.success()) {
logger.info(String.format("党支部(%s)总人数+1", formDTO.getPartyBranchId()));
}
return result.getData();
}

2
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyFormDTO.java

@ -45,7 +45,7 @@ public class AddAgencyFormDTO implements Serializable {
* 机构组织名称
*/
@NotBlank(message = "组织名称不能为空")
@Length(max=50,message = "机构名称不能超过50个字")
@Length(max=20,message = "机构名称不能超过20个字")
private String agencyName;
/**

12
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddDepartmentFormDTO.java

@ -16,6 +16,7 @@ package com.epmet.dto.form;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
@ -31,20 +32,21 @@ import java.io.Serializable;
public class AddDepartmentFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 所属组织机构IDcustomer_agency.id
*/
@NotBlank(message = "组织机构Id不能为空")
@NotBlank(message = "组织机构Id不能为空",groups = AddDepartmentFormDTO.AddDept.class)
private String agencyId;
/**
* 部门名称
*/
@NotBlank(message = "部门名称不能为空")
@Length(max=120,message = "部门名称不能超过120个字")
@NotBlank(message = "部门名称不能为空",groups = AddDepartmentFormDTO.AddDept.class)
@Length(max=20,message = "部门名称不能超过20个字",groups = AddDepartmentFormDTO.AddDept.class)
private String departmentName;
public interface AddDept extends CustomerClientShowGroup {
}
/**
* 部门职责
*/

15
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddGridFormDTO.java

@ -1,7 +1,10 @@
package com.epmet.dto.form;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
@ -12,16 +15,20 @@ import java.io.Serializable;
public class AddGridFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 新建网格名称
*/
@NotBlank(message = "网格名称不能为空")
@Length(max=20,message = "网格名称不能超过20个字",groups = AddGridFormDTO.AddGrid.class)
private String gridName;
/**
* 机构id
*/
private String agencyId;
/**
* 新建网格名称
*/
private String gridName;
public interface AddGrid extends CustomerClientShowGroup {
}
/**
* 管辖区域

2
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditAgencyFormDTO.java

@ -50,7 +50,7 @@ public class EditAgencyFormDTO implements Serializable {
* 机关组织名称
*/
@NotBlank(message = "机关组织名称不能为空")
@Length(max=50,message = "机构名称不能超过50个字",groups = DefaultUserShowGroup.class)
@Length(max=20,message = "机构名称不能超过20个字",groups = DefaultUserShowGroup.class)
private String agencyName;
/**

12
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditDepartmentFormDTO.java

@ -17,6 +17,7 @@
package com.epmet.dto.form;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
@ -33,20 +34,21 @@ import java.io.Serializable;
public class EditDepartmentFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 部门Id
*/
@NotBlank(message = "部门ID不能为空")
@NotBlank(message = "部门ID不能为空",groups = EditDepartmentFormDTO.EditDept.class)
private String departmentId;
/**
* 部门名称
*/
@NotBlank(message = "部门名称不能为空")
@Length(max=120,message = "部门名称不能超过120个字")
@NotBlank(message = "部门名称不能为空",groups = EditDepartmentFormDTO.EditDept.class)
@Length(max=20,message = "部门名称不能超过20个字",groups = EditDepartmentFormDTO.EditDept.class)
private String departmentName;
public interface EditDept extends CustomerClientShowGroup {
}
/**
* 部门职责
*/

15
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditGridFormDTO.java

@ -1,7 +1,10 @@
package com.epmet.dto.form;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
@ -12,6 +15,12 @@ import java.io.Serializable;
public class EditGridFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 网格名称
*/
@NotBlank(message = "网格名称不能为空")
@Length(max=20,message = "网格名称不能超过20个字",groups = EditGridFormDTO.EditGrid.class)
private String gridName;
/**
* gridId 网格id
@ -23,10 +32,8 @@ public class EditGridFormDTO implements Serializable {
*/
private String agencyId;
/**
* 网格名称
*/
private String gridName;
public interface EditGrid extends CustomerClientShowGroup {
}
/**
* 管理区域

4
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/MineResultDTO.java

@ -59,4 +59,8 @@ public class MineResultDTO implements Serializable {
* 根组织
*/
private String rootAgencyId;
/**
* 根组织名
*/
private String rootAgencyName;
}

10
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java

@ -302,4 +302,14 @@ public class CustomerAgencyController {
public Result<String> getAreaCodeSwitch(@PathVariable("customerId")String customerId){
return new Result<String>().ok(customerOrgParameterService.getAreaCodeSwitch(customerId));
}
/**
* @Description 通讯录查询当前人员所属组织组织下部门/网格树
* @author sun
**/
@PostMapping("orgtree")
Result<ExtStaffPermissionResultDTO> orgTree(@LoginUser TokenDto tokenDto){
return new Result<ExtStaffPermissionResultDTO>().ok(customerAgencyService.staffPermissionExt(tokenDto.getUserId()));
}
}

4
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java

@ -52,7 +52,7 @@ public class DepartmentController {
@PostMapping("adddepartment")
@RequirePermission(requirePermission = RequirePermissionEnum.ORG_DEPARTMENT_CREATE)
public Result<AddDepartmentResultDTO> addDepartment(@LoginUser TokenDto tokenDTO, @RequestBody AddDepartmentFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO);
ValidatorUtils.validateEntity(formDTO, AddDepartmentFormDTO.AddDept.class);
return departmentService.addDepartment(formDTO);
}
@ -65,7 +65,7 @@ public class DepartmentController {
@PostMapping("editdepartment")
@RequirePermission(requirePermission = RequirePermissionEnum.ORG_DEPARTMENT_UPDATE)
public Result editDepartment(@LoginUser TokenDto tokenDTO, @RequestBody EditDepartmentFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO);
ValidatorUtils.validateEntity(formDTO, EditDepartmentFormDTO.EditDept.class);
return departmentService.editDepartment(formDTO);
}

2
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java

@ -46,6 +46,7 @@ public class GridController {
@PostMapping("addgrid")
@RequirePermission(requirePermission = RequirePermissionEnum.ORG_GRID_CREATE)
public Result<AddGridResultDTO> addGrid(@LoginUser TokenDto tokenDto, @RequestBody AddGridFormDTO addGridFormDTO){
ValidatorUtils.validateEntity(addGridFormDTO, AddGridFormDTO.AddGrid.class);
return customerGridService.addGrid(tokenDto,addGridFormDTO);
}
@ -56,6 +57,7 @@ public class GridController {
@PostMapping("editgrid")
@RequirePermission(requirePermission = RequirePermissionEnum.ORG_GRID_UPDATE)
public Result editGrid(@LoginUser TokenDto tokenDto, @RequestBody EditGridFormDTO editGridFormDTO){
ValidatorUtils.validateEntity(editGridFormDTO, EditGridFormDTO.EditGrid.class);
return customerGridService.editGrid(tokenDto,editGridFormDTO);
}

7
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerStaffAgencyServiceImpl.java

@ -39,6 +39,7 @@ import com.epmet.service.CustomerDepartmentService;
import com.epmet.service.CustomerGridService;
import com.epmet.service.CustomerStaffAgencyService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -241,9 +242,9 @@ public class CustomerStaffAgencyServiceImpl extends BaseServiceImpl<CustomerStaf
*/
@Override
public Set<String> queryOrgStaffs(OrgStaffFormDTO formDTO) {
Set<String> agencyUserIds=customerStaffAgencyDao.selectAgencyStaffs(formDTO.getCustomerId(),formDTO.getAgencyIds());
Set<String> deptUserIds=customerStaffAgencyDao.selectDeptStaffs(formDTO.getCustomerId(),formDTO.getDeptIds());
Set<String> gridUserIds=customerStaffAgencyDao.selectGridStaffs(formDTO.getCustomerId(),formDTO.getGridIds());
Set<String> agencyUserIds= CollectionUtils.isNotEmpty(formDTO.getAgencyIds())?customerStaffAgencyDao.selectAgencyStaffs(formDTO.getCustomerId(),formDTO.getAgencyIds()):new HashSet<>();
Set<String> deptUserIds=CollectionUtils.isNotEmpty(formDTO.getDeptIds())?customerStaffAgencyDao.selectDeptStaffs(formDTO.getCustomerId(),formDTO.getDeptIds()):new HashSet<>();
Set<String> gridUserIds=CollectionUtils.isNotEmpty(formDTO.getGridIds())?customerStaffAgencyDao.selectGridStaffs(formDTO.getCustomerId(),formDTO.getGridIds()):new HashSet<>();
Set<String> result=new LinkedHashSet<String>();
result.addAll(agencyUserIds);
result.addAll(deptUserIds);

8
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java

@ -234,9 +234,13 @@ public class StaffServiceImpl implements StaffService {
//获取根组织
CustomerAgencyDTO agency = customerAgencyService.get(customerStaffAgency.getAgencyId());
if (StringUtils.isNotBlank(agency.getPids())) {
result.setRootAgencyId(agency.getPids().split(StrConstant.COLON)[0]);
String rootAgencyId = agency.getPids().split(StrConstant.COLON)[0];
CustomerAgencyDTO rootAgency = customerAgencyService.get(rootAgencyId);
result.setRootAgencyId(rootAgencyId);
result.setRootAgencyName(rootAgency.getOrganizationName());
} else {
result.setRootAgencyId(customerStaffAgency.getAgencyId());
result.setRootAgencyName(agency.getOrganizationName());
}
//2021.08.27 zhaoqf end
return result;
@ -438,6 +442,8 @@ public class StaffServiceImpl implements StaffService {
staffTransferRecordDTO.setRemarks(fromDTO.getRemarks());
staffTransferRecordService.save(staffTransferRecordDTO);
//8.更改注册关系
CustomerAgencyDTO agencyDTO = customerAgencyService.get(agencyId);
staffOrgRelation.setPids(agencyDTO.getPids());
staffOrgRelation.setOrgId(fromDTO.getOrgId());
staffOrgRelation.setOrgType(fromDTO.getOrgType());
staffOrgRelation.setUpdatedBy(null);

88
epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffAgencyDao.xml

@ -41,58 +41,62 @@
<!-- 查询当前网格所属机构下的不在此网格的工作人员Id -->
<select id="getSelectableStaffsForGrid" parameterType="string" resultType="string">
SELECT
agency.USER_ID
FROM
CUSTOMER_STAFF_AGENCY agency
WHERE
agency.DEL_FLAG = '0'
AND agency.AGENCY_ID = (
SELECT
PID
agency.user_id
FROM
CUSTOMER_GRID
customer_staff_agency agency
INNER JOIN staff_org_relation sor ON agency.user_id = sor.staff_id AND sor.org_type = 'agency'
WHERE
DEL_FLAG = '0'
AND ID = #{gridId})
AND agency.USER_ID NOT IN (
SELECT
USER_ID
FROM
CUSTOMER_STAFF_GRID
WHERE
DEL_FLAG = '0'
AND
GRID_ID = #{gridId} )
agency.del_flag = '0'
AND agency.agency_id = (
SELECT
pid
FROM
customer_grid
WHERE
del_flag = '0'
AND id = #{gridId}
)
AND agency.user_id NOT IN (
SELECT
user_id
FROM
customer_staff_grid
WHERE
del_flag = '0'
AND
grid_id = #{gridId}
)
</select>
<!-- 查询当前部门所属机构下的不在此部门的工作人员Id -->
<select id="getSelectableStaffsForDept" parameterType="string" resultType="string">
SELECT
agency.USER_ID
agency.user_id
FROM
CUSTOMER_STAFF_AGENCY agency
customer_staff_agency agency
INNER JOIN staff_org_relation sor ON agency.user_id = sor.staff_id AND sor.org_type = 'agency'
WHERE
agency.DEL_FLAG = '0'
AND agency.AGENCY_ID = (
SELECT
AGENCY_ID
FROM
CUSTOMER_DEPARTMENT
WHERE
DEL_FLAG = '0'
AND ID = #{departmentId})
AND agency.USER_ID NOT IN (
SELECT
USER_ID
FROM
CUSTOMER_STAFF_DEPARTMENT
WHERE
DEL_FLAG = '0'
AND
DEPARTMENT_ID = #{departmentId} )
agency.del_flag = '0'
AND agency.agency_id = (
SELECT
agency_id
FROM
customer_department
WHERE
del_flag = '0'
AND id = #{departmentId}
)
AND agency.user_id NOT IN (
SELECT
user_id
FROM
customer_staff_department
WHERE
del_flag = '0'
AND
department_id = #{departmentId}
)
</select>
<select id="selectAgencyStaffList" resultType="com.epmet.dto.result.StaffListResultDTO">

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

@ -193,7 +193,7 @@ public class PartyMemberConfirmServiceImpl implements PartyMemberConfirmService
PartymemberInfoEntity.class);
PartymemberInfoDTO info = partymemberInfoService.getPartyMemberInfoByUser(partyMemberInfoDTO.getCustomerId(), partyMemberInfoDTO.getUserId());
if (null != info) {
partyMemberInfoDTO.setId(info.getId());
partyMemberInfoEntity.setId(info.getId());
}
if (confirmAutoDTO == null || !confirmAutoDTO.getComparisonResults()) {
log.info("submit confirmAutoDTO return null or false:{}",JSON.toJSONString(confirmAutoDTO));

15
epmet-openapi/epmet-openapi-sdk/pom.xml

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>epmet-openapi</artifactId>
<groupId>com.epmet</groupId>
<version>2.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>epmet-openapi-sdk</artifactId>
</project>

133
epmet-openapi/epmet-openapi-sdk/src/main/java/com/epmet/openapi/sdk/encrypt/Md5Util.java

@ -0,0 +1,133 @@
package com.epmet.openapi.sdk.encrypt;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class Md5Util {
/**
* 加密盐
*/
public static final String SALT = "EPMET_UMD_SALT";
public static String md5(String string) throws Exception {
if (string == null || string.trim().length() == 0) {
return null;
}
return getMD5(string.getBytes("GBK"));
}
private static final char hexDigits[] = { // 用来将字节转换成 16 进制表示的字符
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
private static String getMD5(byte[] source) throws Exception {
String s = null;
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(source);
byte tmp[] = md.digest(); // MD5 的计算结果是一个 128 位的长整数,
// 用字节表示就是 16 个字节
char str[] = new char[16 * 2]; // 每个字节用 16 进制表示的话,使用两个字符,
// 所以表示成 16 进制需要 32 个字符
int k = 0; // 表示转换结果中对应的字符位置
for (int i = 0; i < 16; i++) { // 从第一个字节开始,对 MD5 的每一个字节
// 转换成 16 进制字符的转换
byte byte0 = tmp[i]; // 取第 i 个字节
str[k++] = hexDigits[byte0 >>> 4 & 0xf]; // 取字节中高 4 位的数字转换,
// >>> 为逻辑右移,将符号位一起右移
str[k++] = hexDigits[byte0 & 0xf]; // 取字节中低 4 位的数字转换
}
s = new String(str); // 换后的结果转换为字符串
return s;
}
private static String byteArrayToHexString(byte b[]) {
StringBuffer resultSb = new StringBuffer();
for (int i = 0; i < b.length; i++)
resultSb.append(byteToHexString(b[i]));
return resultSb.toString();
}
private static String byteToHexString(byte b) {
int n = b;
if (n < 0)
n += 256;
int d1 = n / 16;
int d2 = n % 16;
return hexDigits[d1] + "" + hexDigits[d2];
}
public static String MD5Encode(String origin, String charsetname) throws Exception {
String resultString = null;
resultString = new String(origin);
MessageDigest md = MessageDigest.getInstance("MD5");
if (charsetname == null || "".equals(charsetname))
resultString = byteArrayToHexString(md.digest(resultString
.getBytes()));
else
resultString = byteArrayToHexString(md.digest(resultString
.getBytes(charsetname)));
return resultString;
}
public static void main(String[] args) {
for (int i = 0; i < 5; i++) {
String uuid = "03a1dcd8cb1811eabac1c03fd56f7847";
System.out.println(get12Char(uuid));
}
}
/**
* 获取短字符
*
* @param str
* @return 大写
*/
public static String get12Char(String str) {
String arr[] = ShortText(str);
String rst = (arr[0] + arr[1]).toUpperCase();
return rst.substring(0, 4) + rst.substring(4, 8) + rst.substring(8, 12);
}
private static String[] ShortText(String string) {
String[] chars = new String[]{ // 要使用生成URL的字符
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n",
"o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z",
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B",
"C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N",
"O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
String hex = "";
MessageDigest md = null;
try {
md = MessageDigest.getInstance("MD5");
hex = byteArrayToHexString(md.digest(SALT.concat(string)
.getBytes("utf-8")));
} catch (Exception e) {
e.printStackTrace();
}
int hexLen = hex.length();
int subHexLen = hexLen / 8;
String[] ShortStr = new String[4];
for (int i = 0; i < subHexLen; i++) {
String outChars = "";
int j = i + 1;
String subHex = hex.substring(i * 8, j * 8);
long idx = Long.valueOf("3FFFFFFF", 16) & Long.valueOf(subHex, 16);
for (int k = 0; k < 6; k++) {
int index = (int) (Long.valueOf("0000003D", 16) & idx);
outChars += chars[index];
idx = idx >> 5;
}
ShortStr[i] = outChars;
}
return ShortStr;
}
}

109
epmet-openapi/epmet-openapi-sdk/src/main/java/com/epmet/openapi/sdk/sign/OpenApiSignUtils.java

@ -0,0 +1,109 @@
package com.epmet.openapi.sdk.sign;
import com.epmet.openapi.sdk.encrypt.Md5Util;
import java.util.*;
/**
* OpenApi签名工具
*/
public class OpenApiSignUtils {
/**
* @Description 创建签名
* @return
* @author wxz
* @date 2021.03.22 16:47
*/
public static String createSign(Map<String, String> contentMap, String signKey) throws Exception {
String str2beSigned = mapToSignStr(contentMap);
str2beSigned = str2beSigned.concat("&sign_key=").concat(signKey);
return Md5Util.md5(str2beSigned);
}
/**
* @Description 验签
* @return
* @author wxz
* @date 2021.03.22 16:51
*/
public static boolean checkSign(Map<String, String> contentMap, String signKey) throws Exception {
String newSign = createSign(contentMap, signKey);
return newSign.equals(contentMap.get("sign"));
}
/**
* @Description map转化为签名明文
* @return
* @author wxz
* @date 2021.03.22 16:47
*/
public static String mapToSignStr(Map<String, String> map) {
Set<String> keySet = map.keySet();
String[] keyArray = (String[])keySet.toArray(new String[keySet.size()]);
Arrays.sort(keyArray);
StringBuilder sb = new StringBuilder();
for(int i = 0; i < keyArray.length; ++i) {
String key = keyArray[i];
String val = (String)map.get(key);
if (val != null && val.trim().length() > 0 && !"sign".equals(key)) {
if (!sb.toString().isEmpty()) {
sb.append("&");
}
sb.append(key).append("=").append((String)map.get(key));
}
}
return sb.toString();
}
public static void main(String[] args) throws Exception {
generateGetAccessTokenSign();
System.out.println("==============");
generateGetOrgDetailSign();
}
private static void generateGetAccessTokenSign() throws Exception {
long now = System.currentTimeMillis();
System.out.println(now);
String uuid = UUID.randomUUID().toString().replace("-", "");
HashMap<String, String> content = new HashMap<>();
content.put("app_id", "7d98b8af2d05752b4225709c4cfd4bd0");
content.put("timestamp", String.valueOf(now));
content.put("nonce", uuid);
content.put("auth_type", "take_token");
String secret = "3209ee9f41704482be1a1fb5873a25376f2899191ca846119d44168316bc3e44";
String sign = createSign(content, secret);
System.out.println("时间戳:" + now);
System.out.println("随机数:" + uuid);
System.out.println("签名:" + sign);
}
private static void generateGetOrgDetailSign() throws Exception {
long now = System.currentTimeMillis();
String uuid = UUID.randomUUID().toString().replace("-", "");;
System.out.println("时间戳:" + now);
System.out.println("随机数:" + uuid);
HashMap<String, String> content = new HashMap<>();
//content.put("orgId", "aaa");
//content.put("test", null);
content.put("gridId", "12128e0f614f1c00a058ea9a107033b2");
content.put("app_id", "7d98b8af2d05752b4225709c4cfd4bd0");
content.put("timestamp", String.valueOf(now));
content.put("nonce", uuid);
content.put("auth_type", "take_token");
String secret = "3209ee9f41704482be1a1fb5873a25376f2899191ca846119d44168316bc3e44";
String sign = createSign(content, secret);
System.out.println("签名:" + sign);
}
}

1
epmet-openapi/pom.xml

@ -13,6 +13,7 @@
<artifactId>epmet-openapi</artifactId>
<modules>
<module>epmet-openapi-scan</module>
<module>epmet-openapi-sdk</module>
</modules>
</project>
Loading…
Cancel
Save