Browse Source

Merge remote-tracking branch 'remotes/origin/dev_wx_msg' into dev_temp

dev_shibei_match
jianjun 5 years ago
parent
commit
02911783e4
  1. 2
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/BaseRequestLogAspect.java
  2. 4
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/AppClientConstant.java
  3. 3
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/NumConstant.java
  4. 3
      epmet-gateway/pom.xml
  5. 1
      epmet-gateway/src/main/resources/bootstrap.yml
  6. 43
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/project/dto/form/DifficultyRankFormDTO.java
  7. 59
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/project/dto/result/ProjectDifficultRankResultDTO.java
  8. 34
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/project/dto/result/ProjectNextAgencyResultDTO.java
  9. 5
      epmet-module/data-report/data-report-server/pom.xml
  10. 34
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/project/ProjectController.java
  11. 19
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/project/ProjectDao.java
  12. 22
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/project/ProjectService.java
  13. 111
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/project/impl/ProjectServiceImpl.java
  14. 41
      epmet-module/data-report/data-report-server/src/main/resources/mapper/project/ProjectDao.xml
  15. 3
      epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenDifficultyDataDao.xml
  16. 25
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/result/OrgResponseTimeResultDTO.java
  17. 114
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/project/ProjectOrgRelationDTO.java
  18. 3
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/project/result/ProjectOrgPeriodResultDTO.java
  19. 27
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/DifficultyIfExistedResultDTO.java
  20. 11
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java
  21. 29
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginProjectOrgPeriodDailyDao.java
  22. 12
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/project/ProjectDao.java
  23. 33
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/project/ProjectProcessDao.java
  24. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenDifficultyDataEntity.java
  25. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollCommunityServiceImpl.java
  26. 12
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollDistrictServiceImpl.java
  27. 12
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollStreetServiceImpl.java
  28. 6
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java
  29. 12
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/FactOriginProjectLogDailyService.java
  30. 12
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/ProjectExtractService.java
  31. 41
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginProjectLogDailyServiceImpl.java
  32. 1
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginProjectMainDailyServiceImpl.java
  33. 33
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/ProjectExtractServiceImpl.java
  34. 20
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenGrassrootsGovernDataAbsorptionServiceImpl.java
  35. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenDifficultyDataService.java
  36. 14
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenDifficultyDataServiceImpl.java
  37. 26
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/ProjectProcessService.java
  38. 11
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/ProjectService.java
  39. 112
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/impl/ProjectProcessServiceImpl.java
  40. 20
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/impl/ProjectServiceImpl.java
  41. 4
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectMainDailyDao.xml
  42. 62
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectOrgPeriodDailyDao.xml
  43. 2
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenDifficultyDataDao.xml
  44. 41
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/project/ProjectDao.xml
  45. 90
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/project/ProjectProcessDao.xml
  46. 35
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/CostDayFormDTO.java
  47. 41
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/TimestampIntervalFormDTO.java
  48. 47
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/WorkMinuteFormDTO.java
  49. 37
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/CostDayResultDTO.java
  50. 36
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java
  51. 35
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java
  52. 29
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/constant/ProjectConstant.java
  53. 44
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/WorkDayController.java
  54. 32
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/WorkDayService.java
  55. 347
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/WorkDayServiceImpl.java
  56. 1
      epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/CalenderDao.xml
  57. 2
      epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/constant/ModuleConstant.java
  58. 29
      epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/controller/OpenUpController.java
  59. 20
      epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/service/OpenUpService.java
  60. 30
      epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/service/impl/OpenUpServiceImpl.java
  61. 3
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/constant/ActMessageConstant.java
  62. 18
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActServiceImpl.java
  63. 38
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActUserServiceImpl.java
  64. 21
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/ProjectSendMessageService.java
  65. 35
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/ProjectSendMessageServiceImpl.java
  66. 43
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/ProjectSendMessageTask.java
  67. 7
      epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/WxMsgTemplateSubscribeStatus.java
  68. 7
      epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/UserMessageDTO.java
  69. 9
      epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/WxmpMsgSendRecordDTO.java
  70. 2
      epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/WxmpTemplateMsgSubscribeStatusDTO.java
  71. 32
      epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/ActivationSubscribeFormDTO.java
  72. 5
      epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/UserMessageFormDTO.java
  73. 24
      epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/WxMsgAuthInfoFormDTO.java
  74. 16
      epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/WxSubscribeMessageFormDTO.java
  75. 72
      epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/WxmpMessagePushFormDTO.java
  76. 5
      epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/result/WxMsgAuthInfoResultDTO.java
  77. 29
      epmet-module/epmet-message/epmet-message-server/pom.xml
  78. 49
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/config/AsyncConfig.java
  79. 11
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/constant/ExtConstant.java
  80. 18
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/constant/WxmpMessageConstant.java
  81. 76
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/WxmpMessageController.java
  82. 69
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/WxmpMessageExtController.java
  83. 36
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/WxmpResiUserSubscribeDao.java
  84. 21
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/WxmpTemplateMsgSubscribeStatusDao.java
  85. 33
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/WxmpWorkUserSubscribeDao.java
  86. 5
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/UserMessageEntity.java
  87. 10
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/WxmpMsgSendRecordEntity.java
  88. 8
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/WxmpTemplateMsgSubscribeStatusEntity.java
  89. 5
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/excel/UserMessageExcel.java
  90. 8
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/excel/WxmpMsgSendRecordExcel.java
  91. 25
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/properties/ThreadProperties.java
  92. 4
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/redis/WxmpMessageRedis.java
  93. 20
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/WxmpMessageExtService.java
  94. 16
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/WxmpMessageService.java
  95. 83
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/WxmpMessageExtServiceImpl.java
  96. 494
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/WxmpMessageServiceImpl.java
  97. 2
      epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/WxmpMsgSendRecordServiceImpl.java
  98. 10
      epmet-module/epmet-message/epmet-message-server/src/main/resources/bootstrap.yml
  99. 98
      epmet-module/epmet-message/epmet-message-server/src/main/resources/db/migration/V0.3.12.2__wxmp_message_template.sql
  100. 1
      epmet-module/epmet-message/epmet-message-server/src/main/resources/db/migration/V0.3.12.3__sub_status_add_column.sql

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

@ -142,7 +142,7 @@ public abstract class BaseRequestLogAspect {
*/
private Result handlerRuntimeException(RuntimeException ex) {
Result result=new Result().error();
result.setInternalMsg(ex.getMessage());
//result.setInternalMsg(ex.getMessage());
return result;
}

4
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/AppClientConstant.java

@ -50,4 +50,8 @@ public interface AppClientConstant {
* 事务流水号每次请求串起来的多个服务拥有相同的流水号,便于日志追踪
*/
String TRANSACTION_SERIAL_KEY = "Transaction-Serial";
/**
* app类型-工作端
*/
String APP_WORK = "work";
}

3
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/NumConstant.java

@ -26,10 +26,11 @@ public interface NumConstant {
int TEN = 10;
int ELEVEN = 11;
int TWELVE = 12;
int SEVENTEEN = 17;
int FIFTEEN = 15;
int FOURTEEN=14;
int TWENTY = 20;
int TWENTY_FOUR = 24;
int THIRTY = 30;
int THIRTY_ONE = 31;
int FORTY = 40;

3
epmet-gateway/pom.xml

@ -288,10 +288,11 @@
<!-- <gateway.routes.gov-issue-server.uri>http://localhost:8101</gateway.routes.gov-issue-server.uri>-->
<gateway.routes.gov-issue-server.uri>lb://gov-issue-server</gateway.routes.gov-issue-server.uri>
<!-- 23、政府工作端项目管理 -->
<!-- <gateway.routes.gov-project-server.uri>http://localhost:8102</gateway.routes.gov-project-server.uri>-->
<!-- <gateway.routes.gov-project-server.uri>http://localhost:8102</gateway.routes.gov-project-server.uri>-->
<gateway.routes.gov-project-server.uri>lb://gov-project-server</gateway.routes.gov-project-server.uri>
<!-- 24、公共服务 -->
<gateway.routes.common-service-server.uri>lb://common-service-server</gateway.routes.common-service-server.uri>
<!-- <gateway.routes.common-service-server.uri>http://localhost:8103</gateway.routes.common-service-server.uri>-->
<!-- 25、党建园地 -->
<gateway.routes.resi-home-server.uri>lb://resi-home-server</gateway.routes.resi-home-server.uri>
<!-- <gateway.routes.resi-home-server.uri>http://localhost:8104</gateway.routes.resi-home-server.uri>-->

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

@ -445,6 +445,7 @@ epmet:
- /data/stats/**
- /epmet/ext/**
- /epmetuser/customerstaff/customerlist
- /message/template/**
swaggerUrls:

43
epmet-module/data-report/data-report-client/src/main/java/com/epmet/project/dto/form/DifficultyRankFormDTO.java

@ -0,0 +1,43 @@
package com.epmet.project.dto.form;
import lombok.Data;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 数据改版-难点堵点项目排行--接口入参
* @Author jiangyy
*/
@Data
public class DifficultyRankFormDTO implements Serializable {
private static final long serialVersionUID = -2880432640584616651L;
public interface DifficultyRankInternalGroup {}
/**
* 组织Id
*/
@NotBlank(message = "组织ID不能为空",groups = {DifficultyRankInternalGroup.class})
private String agencyId;
/**
* 状态: 待处理: pending; 结案closed
*/
private String status;
/**
* 排序类型 耗时最长timelongest涉及部门最多mostdepts处理次数mosthandled
*/
@NotBlank(message = "排序类型不能为空", groups = {DifficultyRankInternalGroup.class})
private String type;
/**
* 获取数据个数 默认前10
*/
private Integer topNum = 10;
@Min(value = 1, groups = {DifficultyRankInternalGroup.class})
private Integer pageNo;
/**
* 组织类型: 网格grid 组织agency
*/
private String orgType;
}

59
epmet-module/data-report/data-report-client/src/main/java/com/epmet/project/dto/result/ProjectDifficultRankResultDTO.java

@ -0,0 +1,59 @@
package com.epmet.project.dto.result;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* @Description 难点赌点-耗时最长|涉及部门最多|处理次数 返参DTO
* @NEI https://nei.netease.com/interface/detail/res/?pid=57068&id=321614
* @ClassName DifficultProjectResultDTO
* @Auth jiangyy
* @Date 2020-08-20 13:43
*/
@Data
public class ProjectDifficultRankResultDTO implements Serializable {
private static final long serialVersionUID = -7338625142484943434L;
/**
* 项目id
* */
private String projectId;
/**
* 项目标题
* */
private String title;
/**
* 状态: 待处理: pending; 结案closed
* */
private String statusCode;
/**
* 社区-网格名
* */
private String gridName;
/**
* 图片列表
* */
private List<String> imgUrlList;
/**
* 耗时单位分钟
* */
private Integer totalHours;
/**
* 涉及多少个部门
* */
private Integer reOrg;
/**
* 处理次数
* */
private Integer handledCount;
}

34
epmet-module/data-report/data-report-client/src/main/java/com/epmet/project/dto/result/ProjectNextAgencyResultDTO.java

@ -0,0 +1,34 @@
package com.epmet.project.dto.result;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @Description 难点赌点-当前登录人员本级一级下一级组织机构/网格 返参DTO
* @NEI https://nei.netease.com/interface/detail/res/?pid=57068&id=321614
* @ClassName DifficultProjectResultDTO
* @Auth jiangyy
* @Date 2020-08-20 13:43
*/
@Data
public class ProjectNextAgencyResultDTO implements Serializable {
private static final long serialVersionUID = -7338625142484943434L;
/**
* 组织id
* */
private String orgId;
/**
* 组织名称
* */
private String orgName;
/**
* 网格grid 组织agency
* */
private String orgType;
}

5
epmet-module/data-report/data-report-server/pom.xml

@ -14,6 +14,11 @@
<modelVersion>4.0.0</modelVersion>
<dependencies>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>gov-org-client</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>data-report-client</artifactId>

34
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/project/ProjectController.java

@ -1,13 +1,14 @@
package com.epmet.module.project.controller;
package com.epmet.datareport.controller.project;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.datareport.service.project.ProjectService;
import com.epmet.dto.form.ProcessListFormDTO;
import com.epmet.module.project.service.ProjectService;
import com.epmet.project.constant.ProjectConstant;
import com.epmet.project.dto.form.DifficultyRankFormDTO;
import com.epmet.project.dto.form.ProjectIncrTrendFormDTO;
import com.epmet.project.dto.result.*;
import org.springframework.beans.factory.annotation.Autowired;
@ -91,4 +92,33 @@ public class ProjectController {
return new Result<ProjectDetailResultDTO>().ok(projectService.projectDetail(processListFormDTO));
}
/**
* @param param
* @return
* @Description 难点赌点-耗时最长|涉及部门最多|处理次数 返回该组织下所有的难点堵点的 数据
* @NEI https://nei.netease.com/interface/detail/res/?pid=57068&id=321614
* @author jiangyy
* @date 2020.10.19 16:38
**/
@PostMapping("difficultyrank")
public Result<List<ProjectDifficultRankResultDTO>> difficultyRank(@RequestBody DifficultyRankFormDTO param){
ValidatorUtils.validateEntity(param, DifficultyRankFormDTO.DifficultyRankInternalGroup.class);
return new Result<List<ProjectDifficultRankResultDTO>>().ok(projectService.getDifficultyRank(param));
}
/**
* @Description 难点赌点-耗时最长|涉及部门最多|处理次数
* @NEI https://nei.netease.com/interface/detail/res/?pid=57068&id=321614
* @param tokenDto
* @return
* @author jiangyy
* @date 2020.10.19 16:38
**/
@PostMapping("mynextagency")
public Result<List<ProjectNextAgencyResultDTO>> myNextAgency(@LoginUser TokenDto tokenDto){
return new Result<List<ProjectNextAgencyResultDTO>>().ok(projectService.getMyNextAgency(tokenDto));
}
}

19
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/project/ProjectDao.java

@ -1,6 +1,7 @@
package com.epmet.datareport.dao.project;
import com.epmet.project.dto.FactAgencyProjectDailyDTO;
import com.epmet.project.dto.form.DifficultyRankFormDTO;
import com.epmet.project.dto.result.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -55,4 +56,22 @@ public interface ProjectDao {
* @Description 查询机关月统计近十二个月数据
**/
List<ProjectIncrTrendResultDTO> selectIncrTrendMonthly(@Param("agencyId") String agencyId);
/**
* @Description 查询难点赌点-耗时最长|涉及部门最多|处理次数
* @param
* @return
* @author jiangyy
* @date 2020.10.19 16:38
**/
List<ProjectDifficultRankResultDTO> difficultyRank(DifficultyRankFormDTO difficultyRankFormDTO);
/**
* @Description 查询难点堵点的图片list
* @param
* @return
* @author jiangyy
* @date 2020.10.20 10:13
**/
List<String> getDifficultyImgList(String eventId);
}

22
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/project/ProjectService.java

@ -1,6 +1,7 @@
package com.epmet.module.project.service;
package com.epmet.datareport.service.project;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.project.dto.form.DifficultyRankFormDTO;
import com.epmet.dto.form.ProcessListFormDTO;
import com.epmet.project.dto.form.ProjectIncrTrendFormDTO;
import com.epmet.project.dto.result.*;
@ -50,4 +51,23 @@ public interface ProjectService {
* @date 2020/10/23 10:33 上午
*/
ProjectDetailResultDTO projectDetail( ProcessListFormDTO processListFormDTO);
/**
* @Description 难点赌点-耗时最长|涉及部门最多|处理次数
* @NEI https://nei.netease.com/interface/detail/res/?pid=57068&id=321614
* @param param
* @return
* @author jiangyy
* @date 2020.10.19 16:38
**/
List<ProjectDifficultRankResultDTO> getDifficultyRank(DifficultyRankFormDTO param);
/**
* @Description 难点赌点-获取组织下拉框
* @NEI https://nei.netease.com/interface/detail/res/?pid=57068&id=321614
* @return
* @author jiangyy
* @date 2020.10.19 16:38
**/
List<ProjectNextAgencyResultDTO> getMyNextAgency(TokenDto tokenDto);
}

111
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/project/impl/ProjectServiceImpl.java

@ -1,25 +1,32 @@
package com.epmet.datareport.service.project.impl;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.constant.NumConstant;
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.DateUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.DataSourceConstant;
import com.epmet.datareport.dao.project.ProjectDao;
import com.epmet.datareport.service.evaluationindex.screen.ScreenDifficultyDataService;
import com.epmet.datareport.service.project.ProjectService;
import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.dto.form.LoginUserDetailsFormDTO;
import com.epmet.dto.form.ProcessListFormDTO;
import com.epmet.dto.result.LoginUserDetailsResultDTO;
import com.epmet.dto.result.ProcessAndCurrentDeptResultDTO;
import com.epmet.dto.form.SubAgencyFormDTO;
import com.epmet.dto.result.*;
import com.epmet.evaluationindex.screen.dto.result.DepartmentNameListResultDTO;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.feign.GovProjectOpenFeignClient;
import com.epmet.module.project.service.ProjectService;
import com.epmet.project.constant.ProjectConstant;
import com.epmet.project.dto.FactAgencyProjectDailyDTO;
import com.epmet.project.dto.form.DifficultyRankFormDTO;
import com.epmet.project.dto.form.ProjectIncrTrendFormDTO;
import com.epmet.project.dto.result.ProjectDetailResultDTO;
import com.epmet.project.dto.result.*;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -47,6 +54,9 @@ public class ProjectServiceImpl implements ProjectService {
@Autowired
private ScreenDifficultyDataService screenDifficultyDataService;
@Autowired
private GovOrgOpenFeignClient govOrgOpenFeignClient;
/**
* @Author sun
* @Description 数据-项目-获取汇总数据
@ -219,4 +229,99 @@ public class ProjectServiceImpl implements ProjectService {
return agencyId;
}
/**
* @author jiangyy
* @Description 获取userId
*/
private String getLoginUserUserId(TokenDto tokenDto) {
LoginUserDetailsFormDTO dto = new LoginUserDetailsFormDTO();
BeanUtils.copyProperties(tokenDto, dto);
LoginUserDetailsResultDTO data = epmetUserOpenFeignClient.getLoginUserDetails(dto).getData();
String userId = data.getUserId();
if (null == userId || "".equals(userId)) {
throw new RenException(ProjectConstant.GET_AGENCYID);
}
return userId;
}
/**
* @Description 难点赌点-获取组织下拉框
* @NEI https://nei.netease.com/interface/detail/res/?pid=57068&id=321614
* @return
* @author jiangyy
* @date 2020.10.19 16:38
**/
@Override
public List<ProjectNextAgencyResultDTO> getMyNextAgency(TokenDto tokenDto) {
List<ProjectNextAgencyResultDTO> resultList = new ArrayList<>();
//1、根据token获取本级agencyId、获取userId
String agencyId = getLoginUserDetails(tokenDto);
String userId=getLoginUserUserId(tokenDto);
//2、获取本级组织机构
Result<CustomerAgencyDTO> customerAgencyDTO = govOrgOpenFeignClient.getAgencyById(agencyId);
ProjectNextAgencyResultDTO angencyDto = new ProjectNextAgencyResultDTO();
angencyDto.setOrgId(agencyId);
angencyDto.setOrgName(customerAgencyDTO.getData().getOrganizationName());
angencyDto.setOrgType(customerAgencyDTO.getData().getLevel());
resultList.add(angencyDto);
//3、获取下一级组织机构\网格
if ("community".equals(customerAgencyDTO.getData().getLevel())) {
//取下级网格
Result<List<GridByStaffResultDTO>> gridListResult = govOrgOpenFeignClient.listGridsbystaffid(userId);
List<GridByStaffResultDTO> gridList = gridListResult.getData();
for (int i = 0; i < gridList.size(); i++) {
ProjectNextAgencyResultDTO subAgencyDto = new ProjectNextAgencyResultDTO();
subAgencyDto.setOrgId(gridList.get(i).getGridId());
subAgencyDto.setOrgName(gridList.get(i).getGridName());
subAgencyDto.setOrgType("grid");
resultList.add(subAgencyDto);
}
} else {
//取下级组织机构
SubAgencyFormDTO form = new SubAgencyFormDTO();
form.setAgencyId(agencyId);
form.setAgencyNum(100);
Result<SubAgencyResultDTO> SubAgencyResultDTO = govOrgOpenFeignClient.subAgencyList(form);
List<SubListResultDTO> subAgencyList = SubAgencyResultDTO.getData().getAgencyList();
for(int i=0;i<subAgencyList.size();i++){
ProjectNextAgencyResultDTO subAgencyDto = new ProjectNextAgencyResultDTO();
subAgencyDto.setOrgId(subAgencyList.get(i).getAgencyId());
subAgencyDto.setOrgName(subAgencyList.get(i).getAgencyName());
subAgencyDto.setOrgType(subAgencyList.get(i).getAgencyLevel());
resultList.add(subAgencyDto);
}
}
if(null == resultList) return new ArrayList<>();
return resultList;
}
/**
* @Description 难点赌点-耗时最长|涉及部门最多|处理次数
* @NEI https://nei.netease.com/interface/detail/res/?pid=57068&id=321614
* @param param
* @return
* @author jiangyy
* @date 2020.10.19 16:38
**/
@DataSource(value = DataSourceConstant.EVALUATION_INDEX,datasourceNameFromArg = true)
@Override
public List<ProjectDifficultRankResultDTO> getDifficultyRank(DifficultyRankFormDTO param) {
PageHelper.startPage(null == param.getPageNo() ? NumConstant.ONE:param.getPageNo(),param.getTopNum());
List<ProjectDifficultRankResultDTO> result = projectDao.difficultyRank(param);
for (int i = 0; i < result.size (); i ++){
List<String> imgUrlList ;
imgUrlList = projectDao.getDifficultyImgList(result.get(i).getProjectId()) ;
result.get(i).setImgUrlList(imgUrlList);
}
if(null == result) return new ArrayList<>();
return result;
}
}

41
epmet-module/data-report/data-report-server/src/main/resources/mapper/project/ProjectDao.xml

@ -234,4 +234,45 @@
)a ORDER BY a.month_id DESC,a.type ASC
</select>
<!-- 查询难点赌点-耗时最长|涉及部门最多|处理次数 -->
<select id="difficultyRank" resultType="com.epmet.project.dto.result.ProjectDifficultRankResultDTO">
SELECT
diff.EVENT_ID AS projectId,
diff.EVENT_CONTENT AS title,
diff.EVENT_STATUS_CODE AS statusCode,
diff.EVENT_SOURCE AS gridName,
diff.EVENT_IMG_URL AS imgUrl,
floor(diff.EVENT_COST_TIME/60) AS totalHours,
diff.EVENT_RE_ORG AS reOrg,
diff.EVENT_HANDLED_COUNT AS handledCount
FROM
screen_difficulty_data diff
WHERE
diff.DEL_FLAG = '0'
<choose>
<when test="orgType != null and orgType == 'grid'">
AND diff.ORG_ID = #{agencyId,jdbcType=VARCHAR}
</when>
<otherwise>
AND diff.ALL_PARENT_IDS LIKE CONCAT('%',#{agencyId},'%')
</otherwise>
</choose>
<if test="status!= null and status != ''">
AND diff.EVENT_STATUS_CODE = #{status}
</if>
ORDER BY
CASE #{type} WHEN 'timelongest' THEN diff.EVENT_COST_TIME
WHEN 'mosthandled' THEN diff.EVENT_HANDLED_COUNT
ELSE diff.EVENT_RE_ORG END
DESC
</select>
<!-- 查询难点赌点-耗时最长|涉及部门最多|处理次数 -->
<select id="getDifficultyImgList" resultType="string">
select EVENT_IMG_URL
FROM
screen_difficulty_img_data
WHERE EVENT_ID = #{eventId}
ORDER BY SORT
</select>
</mapper>

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

@ -10,7 +10,6 @@
diff.EVENT_CONTENT AS title,
diff.EVENT_STATUS_CODE AS STATUS,
ROUND(diff.EVENT_COST_TIME/60,0) AS totalHours,
DATE_FORMAT( eve.EVENT_CREATE_TIME, '%Y-%m-%d %H:%i' ) AS createDateTime,
diff.EVENT_SOURCE AS gridName,
diff.EVENT_IMG_URL AS imgUrl,
diff.EVENT_CATEGORY_NAME AS categoryName,
@ -18,8 +17,6 @@
diff.EVENT_RE_ORG AS handleCount
FROM
screen_difficulty_data diff
LEFT JOIN screen_event_data eve ON diff.EVENT_ID = eve.EVENT_ID
AND eve.DEL_FLAG = '0'
WHERE
diff.DEL_FLAG = '0'
AND diff.ALL_PARENT_IDS LIKE CONCAT('%',#{agencyId},'%')

25
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/result/OrgResponseTimeResultDTO.java

@ -1,25 +0,0 @@
package com.epmet.dto.extract.result;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @Description 各机关响应时间
* @ClassName OrgResponseTimeResultDTO
* @Auth wangc
* @Date 2020-09-21 02:03
*/
@Data
public class OrgResponseTimeResultDTO implements Serializable {
private static final long serialVersionUID = 6017440139236985959L;
private String agencyId;
private BigDecimal responseTime;
private BigDecimal projectTotal;
private BigDecimal distinctProjectTotal;
}

114
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/project/ProjectOrgRelationDTO.java

@ -0,0 +1,114 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dto.project;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 项目机关历时关系表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-10-19
*/
@Data
public class ProjectOrgRelationDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
private String id;
/**
* 关联PROJECT_STAFF由此ID可以关联出PROJECT_IDCUSTOMER_IDPROCESS_ID
*/
private String projectStaffId;
/**
* 流转到的日期 同CREATED_TIME
*/
private Date informedDate;
/**
* 流转走或结案的日期
*/
private Date handledDate;
/**
* 节点耗时从流转到自己到流转走共耗时单位分钟如果项目还没有结案且该项目在这个组织下一直滞留这一项为空
* 8*60的倍数
*/
private Integer totalPeriod;
/**
* 第一次响应时间
*/
private Date firstDealtDate;
/**
* 首次响应时长单位分钟
* 8*60的倍数
*/
private Integer firstReplyPeriod;
/**
* 来源动作return(回退)transfer(流转)closed(结案)response(响应)created(立项时第一个流转到的)
*/
private String sourceOperation;
/**
* 处理动作return(回退)transfer(流转)closed(结案)response(响应)
*/
private String operation;
/**
* 删除标识
*/
private String delFlag;
/**
* 乐观锁
*/
private Integer revision;
/**
*
*/
private Date createdTime;
/**
*
*/
private String createdBy;
/**
*
*/
private Date updatedTime;
/**
*
*/
private String updatedBy;
}

3
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/project/result/ProjectOrgPeriodResultDTO.java

@ -7,7 +7,6 @@ import java.util.Date;
/**
* @Description 从数据库中查询出的 项目 - 机关网格部门机关的响应时长
* FIXME 查询的全都是已经结案的项目如果查询流转中的项目需要修改逻辑较为复杂
* @ClassName ProjectOrgPeriodResultDTO
* @Auth wangc
* @Date 2020-09-16 15:28
@ -92,4 +91,6 @@ public class ProjectOrgPeriodResultDTO implements Serializable {
private String isResolved;
private String projectStaffId;
}

27
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/DifficultyIfExistedResultDTO.java

@ -1,27 +0,0 @@
package com.epmet.dto.screen.result;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @Description 判断难点赌点是否有数据的返回DTO
* @ClassName DifficultyIfExistedResultDTO
* @Auth wangc
* @Date 2020-09-28 10:45
*/
@Data
public class DifficultyIfExistedResultDTO implements Serializable {
private static final long serialVersionUID = -2278401165059196896L;
/**
* 是否有数据 true false
*/
private boolean ifExisted = false;
/**
* 已经结案的项目Id集合
*/
private List<String> closedIds;
}

11
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java

@ -7,7 +7,6 @@ import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.DataSourceConstant;
import com.epmet.constant.IndexCalConstant;
import com.epmet.dao.evaluationindex.indexcal.GridScoreDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexGovrnAblityGridMonthlyDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexPartyAblityGridMonthlyDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexServiceAblityGridMonthlyDao;
@ -21,6 +20,7 @@ import com.epmet.dto.AgencySubTreeDto;
import com.epmet.dto.extract.form.ExtractOriginFormDTO;
import com.epmet.dto.extract.form.ExtractScreenFormDTO;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.dto.screen.form.ScreenCentralZoneDataFormDTO;
import com.epmet.dto.stats.form.CustomerIdAndDateIdFormDTO;
import com.epmet.entity.evaluationindex.indexcoll.FactIndexGovrnAblityGridMonthlyEntity;
import com.epmet.entity.evaluationindex.indexcoll.FactIndexPartyAblityGridMonthlyEntity;
@ -34,7 +34,6 @@ import com.epmet.entity.stats.DimDateEntity;
import com.epmet.entity.stats.DimMonthEntity;
import com.epmet.service.StatsDemoService;
import com.epmet.service.evaluationindex.extract.dataToIndex.*;
import com.epmet.service.evaluationindex.extract.todata.FactOriginProjectLogDailyService;
import com.epmet.service.evaluationindex.extract.todata.FactOriginTopicMainDailyService;
import com.epmet.service.evaluationindex.extract.toscreen.*;
import com.epmet.service.evaluationindex.indexcal.*;
@ -742,4 +741,12 @@ public class DemoController {
return new Result();
}
@Autowired
private ScreenGrassrootsGovernDataAbsorptionService wc;
@PostMapping("wc")
public Result wc(@RequestBody ScreenCentralZoneDataFormDTO param){
wc.difficultyDataHub(param);
return new Result();
}
}

29
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginProjectOrgPeriodDailyDao.java

@ -18,12 +18,10 @@
package com.epmet.dao.evaluationindex.extract;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.extract.result.OrgResponseTimeResultDTO;
import com.epmet.dto.extract.result.OrgStatisticsResultDTO;
import com.epmet.entity.evaluationindex.extract.FactOriginProjectOrgPeriodDailyEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.PostMapping;
import java.util.List;
@ -45,15 +43,6 @@ public interface FactOriginProjectOrgPeriodDailyDao extends BaseDao<FactOriginPr
**/
int selectIfExisted(@Param("customerId") String customerId);
/**
* @Description 在插入之前先删除所有与这个项目相关的历时信息
* @param list
* @return
* @author wangc
* @date 2020.09.17 14:43
**/
void deleteByProjectId(@Param("projectId") String projectId);
/**
* 获取项目响应度
* @author zhaoqifeng
@ -85,24 +74,6 @@ public interface FactOriginProjectOrgPeriodDailyDao extends BaseDao<FactOriginPr
**/
void insertBatch(@Param("list") List<FactOriginProjectOrgPeriodDailyEntity> list);
/**
* @Description 查找网格部门对项目的办结系数
* @param customerId
* @return
* @author wangc
* @date 2020.09.21 02:13
**/
List<OrgResponseTimeResultDTO> selectSubOrgResponseCoefficient(@Param("customerId") String customerId,@Param("dimId") String dimId, @Param("dateType") String dateType);
/**
* @Description 查找机关对项目的办结系数
* @param customerId
* @return
* @author wangc
* @date 2020.09.21 02:13
**/
List<OrgResponseTimeResultDTO> selectAgencyResponseCoefficient(@Param("customerId") String customerId,@Param("dimId") String dimId, @Param("dateType") String dateType);
/**
* 部门处理效率统计
* @author zhaoqifeng

12
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/project/ProjectDao.java

@ -21,7 +21,6 @@ import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.ProjectDTO;
import com.epmet.dto.project.ProjectAgencyDTO;
import com.epmet.dto.project.ProjectGridDTO;
import com.epmet.dto.project.ProjectInfoDTO;
import com.epmet.entity.project.ProjectEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -103,4 +102,15 @@ public interface ProjectDao extends BaseDao<ProjectEntity> {
* @return java.lang.String
*/
String selectParameterValueByKey(@Param("customerId") String customerId);
/**
* @Description 得到超过阈值滞留的项目Id集合
* 规定只要项目的任何一个负责人(被流转到的自始至终不管有没有处理)超过了自定义或默认的滞留时间就算难点赌点
* @param customerId
* @param exclude
* @return java.util.List<java.lang.String>
* @author wangc
* @date 2020.11.06 14:14
*/
List<String> selectOvertimeProjectIds(@Param("customerId") String customerId,@Param("exclude") List<String> exclude,@Param("value") Integer value);
}

33
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/project/ProjectProcessDao.java

@ -20,6 +20,7 @@ package com.epmet.dao.project;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.project.FinishOrgDTO;
import com.epmet.dto.project.ProcessInfoDTO;
import com.epmet.dto.project.ProjectOrgRelationDTO;
import com.epmet.dto.project.result.ProjectLatestOperationResultDTO;
import com.epmet.dto.project.result.ProjectOrgPeriodResultDTO;
import com.epmet.dto.project.result.ProjectOrgRelationWhenResponseResultDTO;
@ -28,6 +29,7 @@ import com.epmet.entity.project.ProjectProcessEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
@ -106,6 +108,15 @@ public interface ProjectProcessDao extends BaseDao<ProjectProcessEntity> {
**/
List<ProjectOrgPeriodResultDTO> selectProjectOrgPeriod(@Param("customerId") String customerId,@Param("projectStatus")String projectStatus,@Param("dateId") String dateId);
/**
* @Description 根据项目业务改造在数据抽取时直接查询出项目节点的耗时
* @param
* @return java.util.List<com.epmet.dto.project.result.ProjectOrgPeriodResultDTO>
* @author wangc
* @date 2020.10.23 11:13
*/
List<ProjectOrgPeriodResultDTO> selectProjectOrgPeriodDirectly(@Param("customerId") String customerId,@Param("projectStatus")String projectStatus,@Param("dateId") String dateId);
/**
* @Description 查询项目-机关各个节点的响应列表
* @param projects
@ -115,6 +126,15 @@ public interface ProjectProcessDao extends BaseDao<ProjectProcessEntity> {
**/
List<ProjectOrgRelationWhenResponseResultDTO> selectResponseTrace(@Param("projects") List<String> projects);
/**
* @Description 查询项目的节点
* @param projects
* @return java.util.List<com.epmet.dto.project.result.ProjectOrgRelationWhenResponseResultDTO>
* @author wangc
* @date 2020.10.23 17:02
*/
List<ProjectOrgRelationWhenResponseResultDTO> selectProjectProcess(@Param("projects") List<String> projects);
/**
* 获取办结组织
* @author zhaoqifeng
@ -132,5 +152,16 @@ public interface ProjectProcessDao extends BaseDao<ProjectProcessEntity> {
* @author wangc
* @date 2020.09.28 14:45
*/
List<ProjectLatestOperationResultDTO> selectLatestOperation(@Param("list") List<String> list);
List<ProjectLatestOperationResultDTO> selectLatestOperation(@Param("list") List<String> list,@Param("customerId") String customerId);
/**
* @Description 查找项目标题
* @param list
* @return java.util.List<com.epmet.dto.project.result.ProjectLatestOperationResultDTO>
* @author wangc
* @date 2020.09.28 14:45
*/
List<ProjectLatestOperationResultDTO> selectProjectTitle(@Param("list") List<String> list,@Param("customerId") String customerId);
}

5
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenDifficultyDataEntity.java

@ -80,6 +80,11 @@ public class ScreenDifficultyDataEntity extends BaseEpmetEntity {
*/
private String eventContent;
/**
* 事件标题
*/
private String eventTitle;
/**
* 事件耗时 单位分钟
*/

10
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollCommunityServiceImpl.java

@ -135,14 +135,14 @@ public class IndexCollCommunityServiceImpl implements IndexCollCommunityService
}
List<String> agencies = agencyList.stream().map(DimAgencyDTO :: getId).distinct().collect(Collectors.toList());
List<String> agencies = agencyList.stream().map(DimAgencyDTO::getId).distinct().collect(Collectors.toList());
//办结数
Map<String, Integer> agencyHandleCount = factOriginProjectLogDailyService.getProjectHandledAgency(agencies,customerId,dimId.getMonthId(),"month");
Map<String, Integer> agencyHandleCount = factOriginProjectLogDailyService.getProjectHandledAgency(agencies, customerId, dimId.getMonthId());
//办结率
Map<String, BigDecimal> handlingRatioMap = factOriginProjectLogDailyService.getHandlingRatio(agencies,customerId,dimId.getMonthId(),"month");
Map<String, BigDecimal> handlingRatioMap = factOriginProjectLogDailyService.getHandlingRatio(agencies, customerId, dimId.getMonthId());
//处理效率
Map<String,BigDecimal> efficiencyMap = factOriginProjectLogDailyService.getAgencyWorkPieceRatio(customerId,dimId.getMonthId(),"month");
list.forEach(entity ->{
Map<String, BigDecimal> efficiencyMap = factOriginProjectLogDailyService.getAgencyWorkPieceRatio(customerId, dimId.getMonthId());
list.forEach(entity -> {
//办结数
entity.setClosedProjectCount(Optional.ofNullable(agencyHandleCount.get(entity.getAgencyId())).orElse(NumConstant.ZERO));
//办结率

12
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollDistrictServiceImpl.java

@ -128,16 +128,16 @@ public class IndexCollDistrictServiceImpl implements IndexCollDistrictService {
}));
}
List<String> agencies = agencyList.stream().map(DimAgencyDTO :: getId).distinct().collect(Collectors.toList());
List<String> agencies = agencyList.stream().map(DimAgencyDTO::getId).distinct().collect(Collectors.toList());
//办结数
Map<String, Integer> agencyHandleCount = factOriginProjectLogDailyService.getProjectHandledAgency(agencies,customerId,dimId.getMonthId(),"month");
Map<String, Integer> agencyHandleCount = factOriginProjectLogDailyService.getProjectHandledAgency(agencies, customerId, dimId.getMonthId());
//办结率
Map<String, BigDecimal> handlingRatioMap = factOriginProjectLogDailyService.getHandlingRatio(agencies,customerId,dimId.getMonthId(),"month");
Map<String, BigDecimal> handlingRatioMap = factOriginProjectLogDailyService.getHandlingRatio(agencies, customerId, dimId.getMonthId());
//处理效率
Map<String,BigDecimal> efficiencyMap = factOriginProjectLogDailyService.getAgencyWorkPieceRatio(customerId,dimId.getMonthId(),"month");
list.forEach(entity ->{
Map<String, BigDecimal> efficiencyMap = factOriginProjectLogDailyService.getAgencyWorkPieceRatio(customerId, dimId.getMonthId());
list.forEach(entity -> {
//办结数
entity.setClosedProjectCount(agencyHandleCount.get(entity.getAgencyId()) == null? NumConstant.ZERO : agencyHandleCount.get(entity.getAgencyId()));
entity.setClosedProjectCount(agencyHandleCount.get(entity.getAgencyId()) == null ? NumConstant.ZERO : agencyHandleCount.get(entity.getAgencyId()));
//办结率
entity.setClosedProjectRatio(Optional.ofNullable(handlingRatioMap.get(entity.getAgencyId())).orElse(BigDecimal.ZERO));
//办结效率

12
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexCollStreetServiceImpl.java

@ -126,16 +126,16 @@ public class IndexCollStreetServiceImpl implements IndexCollStreetService {
}));
}
List<String> agencies = agencyList.stream().map(DimAgencyDTO :: getId).distinct().collect(Collectors.toList());
List<String> agencies = agencyList.stream().map(DimAgencyDTO::getId).distinct().collect(Collectors.toList());
//办结数
Map<String, Integer> agencyHandleCount = factOriginProjectLogDailyService.getProjectHandledAgency(agencies,customerId,dimId.getMonthId(),"month");
Map<String, Integer> agencyHandleCount = factOriginProjectLogDailyService.getProjectHandledAgency(agencies, customerId, dimId.getMonthId());
//办结率
Map<String, BigDecimal> handlingRatioMap = factOriginProjectLogDailyService.getHandlingRatio(agencies,customerId,dimId.getMonthId(),"month");
Map<String, BigDecimal> handlingRatioMap = factOriginProjectLogDailyService.getHandlingRatio(agencies, customerId, dimId.getMonthId());
//处理效率
Map<String,BigDecimal> efficiencyMap = factOriginProjectLogDailyService.getAgencyWorkPieceRatio(customerId,dimId.getMonthId(),"month");
list.forEach(entity ->{
Map<String, BigDecimal> efficiencyMap = factOriginProjectLogDailyService.getAgencyWorkPieceRatio(customerId, dimId.getMonthId());
list.forEach(entity -> {
//办结数
entity.setClosedProjectCount(agencyHandleCount.get(entity.getAgencyId()) == null? NumConstant.ZERO : agencyHandleCount.get(entity.getAgencyId()));
entity.setClosedProjectCount(agencyHandleCount.get(entity.getAgencyId()) == null ? NumConstant.ZERO : agencyHandleCount.get(entity.getAgencyId()));
//办结率
entity.setClosedProjectRatio(Optional.ofNullable(handlingRatioMap.get(entity.getAgencyId())).orElse(BigDecimal.ZERO));
//办结效率

6
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java

@ -2,11 +2,9 @@ package com.epmet.service.evaluationindex.extract.dataToIndex.impl;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.dto.extract.form.ExtractIndexFormDTO;
import com.epmet.service.evaluationindex.extract.dataToIndex.*;
import com.epmet.service.stats.DimCustomerService;
import com.epmet.util.DimIdGenerator;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@ -16,7 +14,6 @@ import org.springframework.util.CollectionUtils;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.*;
@ -107,16 +104,19 @@ public class IndexOriginExtractServiceImpl implements IndexOriginExtractService
log.error("抽取【网格服务能力数据】发生异常,参数:" + JSON.toJSONString(param), e);
}
try{
//dimAgency
indexCollStreetService.saveStreetAbility(customerId, monthId);
}catch (Exception e){
log.error("抽取【街道治理能力-街道党建能力-服务能力】发生异常,参数:" + JSON.toJSONString(param), e);
}
try{
//dimAgency
indexCollCommunityService.saveCommunityAbility(customerId, monthId);
}catch (Exception e){
log.error("抽取【社区治理能力-社区党建能力-服务能力】发生异常,参数:" + JSON.toJSONString(param), e);
}
try{
//dimAgency
indexCollDistrictService.saveDistrictAbility(customerId, monthId);
}catch (Exception e){
log.error("抽取【全区治理能力-全区党建能力-服务能力】发生异常,参数:" + JSON.toJSONString(param), e);

12
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/FactOriginProjectLogDailyService.java

@ -168,13 +168,13 @@ public interface FactOriginProjectLogDailyService extends BaseService<FactOrigin
List<OrgStatisticsResultDTO> getDepTransferCount(String customerId, String monthId, String level);
/**
* @Description 查询各机关办结(办结的含义指每个项目的结点中最高的机关)了多少项目
* @param agencies
* @return
* @Description 查询各机关办结(办结的含义指每个项目的结点中最高的机关)了多少项目
* @author wangc
* @date 2020.09.20 23:46
**/
Map<String,Integer> getProjectHandledAgency(List<String> agencies, String customerId, String dimId,String dateType);
Map<String, Integer> getProjectHandledAgency(List<String> agencies, String customerId, String dimId);
/**
* @Description 办结率
@ -184,8 +184,8 @@ public interface FactOriginProjectLogDailyService extends BaseService<FactOrigin
* @return
* @author wangc
* @date 2020.09.23 10:06
**/
Map<String,BigDecimal> getHandlingRatio(List<String> agencies, String customerId,String dimId,String dateType);
**/
Map<String, BigDecimal> getHandlingRatio(List<String> agencies, String customerId, String dimId);
/**
* @Description 计算机关办结项目效率
@ -193,8 +193,8 @@ public interface FactOriginProjectLogDailyService extends BaseService<FactOrigin
* @return
* @author wangc
* @date 2020.09.21 02:16
**/
Map<String, BigDecimal> getAgencyWorkPieceRatio( String customerId,String dimId,String dateType);
**/
Map<String, BigDecimal> getAgencyWorkPieceRatio(String customerId, String dimId);
/**
* 网格项目响应度

12
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/ProjectExtractService.java

@ -2,6 +2,9 @@ package com.epmet.service.evaluationindex.extract.todata;
import com.epmet.dto.extract.form.ExtractOriginFormDTO;
import com.epmet.dto.project.result.ProjectOrgPeriodResultDTO;
import java.util.List;
/**
* @author zhaoqifeng
@ -29,4 +32,13 @@ public interface ProjectExtractService {
* @date 2020.09.17 14:05
**/
void extractProjectPeriodData(ExtractOriginFormDTO param);
/**
* @Description 项目节点耗时数据补齐
* @param
* @return java.util.List<com.epmet.dto.project.result.ProjectOrgPeriodResultDTO>
* @author wangc
* @date 2020.10.26 10:18
*/
void projectProcessCostTimeDataCompensation();
}

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

@ -38,7 +38,6 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.naming.LinkLoopException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
@ -171,43 +170,43 @@ public class FactOriginProjectLogDailyServiceImpl extends BaseServiceImpl<FactOr
}
/**
* @Description 查询各机关办结的项目数
* @param agencies
* @return
* @Description 查询各机关办结的项目数
* @author wangc
* @date 2020.09.20 23:46
**/
@Override
public Map<String, Integer> getProjectHandledAgency(List<String> agencies, String customerId,String dimId, String dateType) {
public Map<String, Integer> getProjectHandledAgency(List<String> agencies, String customerId, String dimId) {
Map<String, Integer> result = new HashMap<>();
List<ProjectParticipatedAgencyResultDTO> countList = baseDao.selectAgencyHandledProjectCount(agencies,customerId,dimId);
if(!CollectionUtils.isEmpty(countList)){
result = countList.stream().collect(Collectors.toMap(ProjectParticipatedAgencyResultDTO::getAgencyId,ProjectParticipatedAgencyResultDTO::getCount));
List<ProjectParticipatedAgencyResultDTO> countList = baseDao.selectAgencyHandledProjectCount(agencies, customerId, dimId);
if (!CollectionUtils.isEmpty(countList)) {
result = countList.stream().collect(Collectors.toMap(ProjectParticipatedAgencyResultDTO::getAgencyId, ProjectParticipatedAgencyResultDTO::getCount));
}
return result;
}
/**
* @Description 办结率
* @param agencies
* @param dimId
* @param dateType - 日期维度类型 month date week quarter year
* @return
* @Description 办结率
* @author wangc
* @date 2020.09.23 10:06
**/
@Override
public Map<String, BigDecimal> getHandlingRatio(List<String> agencies, String customerId,String dimId, String dateType) {
public Map<String, BigDecimal> getHandlingRatio(List<String> agencies, String customerId, String dimId) {
//计算方式:“评价周期内被吹哨且办结(无论是哪一级办结)的项目数”/“评价周期内被吹哨的所有项目数”
Map<String,BigDecimal> result = new HashMap<>();
List<ProjectParticipatedAgencyResultDTO> projectAgencyCount = baseDao.selectWhistledAgencyClosedProjectCount(agencies,customerId,dimId);
if(!CollectionUtils.isEmpty(projectAgencyCount)){
Map<String,Integer> whistledAndHandledProjectTotalMap = projectAgencyCount.stream().collect(Collectors.toMap(ProjectParticipatedAgencyResultDTO::getAgencyId,ProjectParticipatedAgencyResultDTO::getCount));
List<ProjectParticipatedAgencyResultDTO> whistledProjectTotal = baseDao.selectAgencyWhistledCount(agencies,customerId,dimId);
Map<String,Integer> whistledProjectTotalMap = whistledProjectTotal.stream().collect(Collectors.toMap(ProjectParticipatedAgencyResultDTO::getAgencyId,ProjectParticipatedAgencyResultDTO::getCount));
whistledAndHandledProjectTotalMap.forEach((agencyId,count) -> {
Map<String, BigDecimal> result = new HashMap<>();
List<ProjectParticipatedAgencyResultDTO> projectAgencyCount = baseDao.selectWhistledAgencyClosedProjectCount(agencies, customerId, dimId);
if (!CollectionUtils.isEmpty(projectAgencyCount)) {
Map<String, Integer> whistledAndHandledProjectTotalMap = projectAgencyCount.stream().collect(Collectors.toMap(ProjectParticipatedAgencyResultDTO::getAgencyId, ProjectParticipatedAgencyResultDTO::getCount));
List<ProjectParticipatedAgencyResultDTO> whistledProjectTotal = baseDao.selectAgencyWhistledCount(agencies, customerId, dimId);
Map<String, Integer> whistledProjectTotalMap = whistledProjectTotal.stream().collect(Collectors.toMap(ProjectParticipatedAgencyResultDTO::getAgencyId, ProjectParticipatedAgencyResultDTO::getCount));
whistledAndHandledProjectTotalMap.forEach((agencyId, count) -> {
//分母 被吹哨项目数
Integer denominator = whistledProjectTotalMap.get(agencyId);
if(null == denominator || NumConstant.ZERO == denominator){
@ -222,22 +221,22 @@ public class FactOriginProjectLogDailyServiceImpl extends BaseServiceImpl<FactOr
}
/**
* @Description 计算机关办结项目效率
* @param
* @return
* @Description 计算机关办结项目效率
* @author wangc
* @date 2020.09.21 02:16
**/
@Override
public Map<String, BigDecimal> getAgencyWorkPieceRatio(String customerId,String dimId, String dateType) {
public Map<String, BigDecimal> getAgencyWorkPieceRatio(String customerId, String dimId) {
//计算方法 : 评价周期内办结项目的平均处理时长的倒数
//1.评价周期内结案了的项目
List<ProjectParticipatedAgencyResultDTO> projectsHandledByAgency = baseDao.selectProjectIdHandledByAgency(customerId,dimId);
Map<String,BigDecimal> efficiencyMap = new HashMap<>();
if(!CollectionUtils.isEmpty(projectsHandledByAgency)){
Map<String,List<String>> agencyProjectsMap = new HashMap<>();
List<ProjectParticipatedAgencyResultDTO> projectsHandledByAgency = baseDao.selectProjectIdHandledByAgency(customerId, dimId);
Map<String, BigDecimal> efficiencyMap = new HashMap<>();
if (!CollectionUtils.isEmpty(projectsHandledByAgency)) {
Map<String, List<String>> agencyProjectsMap = new HashMap<>();
projectsHandledByAgency.forEach(o -> {
String agencyId = o.getAgencyId();

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

@ -244,6 +244,7 @@ public class FactOriginProjectMainDailyServiceImpl extends BaseServiceImpl<FactO
*/
@Override
public List<ScreenDifficultyDataEntity> getDifficultyBaseInfo(String customerId, List<String> list) {
if(CollectionUtils.isEmpty(list)) return null;
return baseDao.selectDifficultyBaseInfo(customerId,list);
}

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

@ -16,6 +16,7 @@ import com.epmet.dto.issue.IssueDTO;
import com.epmet.dto.party.PartyMemberDTO;
import com.epmet.dto.project.FinishOrgDTO;
import com.epmet.dto.project.ProcessInfoDTO;
import com.epmet.dto.project.ProjectOrgRelationDTO;
import com.epmet.dto.project.result.ProjectOrgPeriodResultDTO;
import com.epmet.dto.result.WorkDayResultDTO;
import com.epmet.dto.topic.ResiTopicDTO;
@ -31,6 +32,7 @@ import com.epmet.service.evaluationindex.extract.todata.ProjectExtractService;
import com.epmet.service.partymember.PartyMemberService;
import com.epmet.service.project.ProjectProcessService;
import com.epmet.service.project.ProjectService;
import com.epmet.service.stats.DimCustomerService;
import com.epmet.service.topic.TopicService;
import com.epmet.util.DimIdGenerator;
import lombok.extern.slf4j.Slf4j;
@ -40,10 +42,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.*;
import java.util.stream.Collector;
import java.util.stream.Collectors;
/**
@ -73,6 +73,8 @@ public class ProjectExtractServiceImpl implements ProjectExtractService {
private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient;
@Autowired
private FactOriginProjectOrgPeriodDailyDao factOriginProjectOrgPeriodDailyDao;
@Autowired
private DimCustomerService dimCustomerService;
private final static String ONE_DAY = "<1";
@ -398,7 +400,7 @@ public class ProjectExtractServiceImpl implements ProjectExtractService {
param.setDateId(DateUtils.getBeforeNDay(NumConstant.ONE));
}
List<ProjectOrgPeriodResultDTO> extractData =
projectProcessService.getProjectPeriod(isFirst, param.getCustomerId(), param.getDateId());
projectProcessService.getProjectPeriodDirectly(isFirst, param.getCustomerId(), param.getDateId());
List<FactOriginProjectOrgPeriodDailyEntity> formattingData = new LinkedList<>();
extractData.forEach(original -> {
FactOriginProjectOrgPeriodDailyEntity dest
@ -447,6 +449,27 @@ public class ProjectExtractServiceImpl implements ProjectExtractService {
}
}
/**
* @Description 项目节点耗时数据补齐
* @param
* @return java.util.List<com.epmet.dto.project.result.ProjectOrgPeriodResultDTO>
* @author wangc
* @date 2020.10.26 10:18
*/
@Override
public void projectProcessCostTimeDataCompensation() {
List<String> customers = dimCustomerService.getAllCustomerId();
if(CollectionUtils.isEmpty(customers)) return ;
customers.forEach(local -> {
// projectProcessService.getProjectPeriod(true, local,null);
});
System.out.println("-------------EndPointHere----------------");
}
/**
* 工作日计算

20
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenGrassrootsGovernDataAbsorptionServiceImpl.java

@ -6,7 +6,6 @@ import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.dto.org.GridInfoDTO;
import com.epmet.dto.screen.form.ProjectSourceMapFormDTO;
import com.epmet.dto.screen.form.ScreenCentralZoneDataFormDTO;
import com.epmet.dto.screen.result.DifficultyIfExistedResultDTO;
import com.epmet.entity.evaluationindex.screen.ScreenDifficultyDataEntity;
import com.epmet.entity.evaluationindex.screen.ScreenDifficultyImgDataEntity;
import com.epmet.entity.evaluationindex.screen.ScreenPartyUserRankDataEntity;
@ -18,6 +17,7 @@ import com.epmet.service.evaluationindex.screen.ScreenPartyUserRankDataService;
import com.epmet.service.org.CustomerGridService;
import com.epmet.service.point.UserPointService;
import com.epmet.service.project.ProjectProcessService;
import com.epmet.service.project.ProjectService;
import com.epmet.service.topic.TopicService;
import com.epmet.service.user.UserService;
import lombok.extern.slf4j.Slf4j;
@ -63,6 +63,8 @@ public class ScreenGrassrootsGovernDataAbsorptionServiceImpl implements ScreenGr
private ProjectProcessService projectProcessService;
@Autowired
private TopicService topicService;
@Autowired
private ProjectService projectService;
/**
* @Description 用户积分党员分值数据中转站
* @param param
@ -135,15 +137,20 @@ public class ScreenGrassrootsGovernDataAbsorptionServiceImpl implements ScreenGr
**/
@Override
public void difficultyDataHub(ScreenCentralZoneDataFormDTO param) {
//验证是否存在
DifficultyIfExistedResultDTO existedMap = screenDifficultyDataService.selectExistedInfo(param.getCustomerId());
//查询难点赌点中有无已结案的项目,若有则保留
List<String> existed = screenDifficultyDataService.selectExistedInfo(param.getCustomerId());
//查询数据
List<ScreenDifficultyDataEntity> difficulties = factOriginProjectMainDailyService.getDifficultyBaseInfo(param.getCustomerId(),existedMap.getClosedIds());
List<ScreenDifficultyDataEntity> difficulties = factOriginProjectMainDailyService.getDifficultyBaseInfo(param.getCustomerId(),projectService.getOvertimeProjectByParameter(param.getCustomerId(),existed));
if(CollectionUtils.isEmpty(difficulties)) return;
List<String> projectIds = difficulties.stream().map(ScreenDifficultyDataEntity :: getEventId).distinct().collect(Collectors.toList());
//最近一次操作
Map<String,String> latestOperationMap = projectProcessService.selectLatestOperation(projectIds,param.getCustomerId());
Map<String,String> latestOperationMap = projectProcessService.getLatestOperation(projectIds,param.getCustomerId());
//标题
Map<String,String> titleMap = projectProcessService.getProjectTitle(projectIds,param.getCustomerId());
boolean isOperationNull = CollectionUtils.isEmpty(latestOperationMap) ? true : false;
boolean isTitleNull = CollectionUtils.isEmpty(titleMap) ? true : false;
//图片
List<ProjectSourceMapFormDTO> projectSourceMap = factOriginProjectMainDailyService.getNewProject(param.getCustomerId(),projectIds);
@ -163,6 +170,9 @@ public class ScreenGrassrootsGovernDataAbsorptionServiceImpl implements ScreenGr
if(!isOperationNull){
diff.setLatestOperateDesc(latestOperationMap.get(diff.getEventId()));
}
if(!isTitleNull){
diff.setEventTitle(titleMap.get(diff.getEventId()));
}
diff.setDataEndTime(DateUtils.getBeforeNDay(NumConstant.ONE));
});
List<ScreenDifficultyImgDataEntity> imgList = new LinkedList<>();

3
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenDifficultyDataService.java

@ -18,7 +18,6 @@
package com.epmet.service.evaluationindex.screen;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.dto.screen.result.DifficultyIfExistedResultDTO;
import com.epmet.entity.evaluationindex.screen.ScreenDifficultyDataEntity;
import com.epmet.entity.evaluationindex.screen.ScreenDifficultyImgDataEntity;
@ -39,7 +38,7 @@ public interface ScreenDifficultyDataService extends BaseService<ScreenDifficult
* @author wangc
* @date 2020.09.28 10:53
*/
DifficultyIfExistedResultDTO selectExistedInfo(String customerId);
List<String> selectExistedInfo(String customerId);
/**

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

@ -24,7 +24,6 @@ import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.constant.DataSourceConstant;
import com.epmet.dao.evaluationindex.screen.ScreenDifficultyDataDao;
import com.epmet.dto.screen.result.DifficultyIfExistedResultDTO;
import com.epmet.entity.evaluationindex.screen.ScreenDifficultyDataEntity;
import com.epmet.entity.evaluationindex.screen.ScreenDifficultyImgDataEntity;
import com.epmet.service.evaluationindex.screen.ScreenDifficultyDataService;
@ -47,16 +46,9 @@ public class ScreenDifficultyDataServiceImpl extends BaseServiceImpl<ScreenDiffi
@Override
public DifficultyIfExistedResultDTO selectExistedInfo(String customerId) {
int count = baseDao.selectCountByCustomerId(customerId);
DifficultyIfExistedResultDTO existedMap = new DifficultyIfExistedResultDTO();
if (count <= NumConstant.ZERO) {
existedMap.setIfExisted(true);
} else {
existedMap.setClosedIds(baseDao.selectClosedProjectId(customerId));
}
return existedMap;
public List<String> selectExistedInfo(String customerId) {
if (baseDao.selectCountByCustomerId(customerId) > NumConstant.ZERO) return baseDao.selectClosedProjectId(customerId);
return null;
}
@Override

26
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/ProjectProcessService.java

@ -93,16 +93,18 @@ public interface ProjectProcessService extends BaseService<ProjectProcessEntity>
*/
List<ProjectProcessEntity> getClosedProjectList(String customerId, String date);
/**
* @Description 查询各机关项目节点历时
* @param isFirst 是否首次
* @Description 直接从项目业务改造获取项目节点耗时信息
* @param isFirst
* @param customerId
* @param date
* @return
* @return java.util.List<com.epmet.dto.project.result.ProjectOrgPeriodResultDTO>
* @author wangc
* @date 2020.09.18 13:38
**/
List<ProjectOrgPeriodResultDTO> getProjectPeriod(Boolean isFirst,String customerId,String date);
* @date 2020.10.23 09:10
*/
List<ProjectOrgPeriodResultDTO> getProjectPeriodDirectly(Boolean isFirst,String customerId, String date);
/**
* 获取办结组织
@ -122,6 +124,16 @@ public interface ProjectProcessService extends BaseService<ProjectProcessEntity>
* @author wangc
* @date 2020.09.28 14:44
*/
Map<String,String> selectLatestOperation(List<String> list, String customerId);
Map<String,String> getLatestOperation(List<String> list, String customerId);
/**
* @Description 获取项目标题
* @param list
* @param customerId
* @return java.util.Map<java.lang.String,java.lang.String>
* @author wangc
* @date 2020.10.27 14:34
*/
Map<String,String> getProjectTitle(List<String>list ,String customerId);
}

11
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/ProjectService.java

@ -99,4 +99,15 @@ public interface ProjectService extends BaseService<ProjectEntity> {
* @return java.lang.String
*/
String getParameterValueByKey(String customerId);
/**
* @Description 得到超过阈值滞留的项目Id集合
* 规定只要项目的任何一个负责人(被流转到的自始至终不管有没有处理)超过了自定义或默认的滞留时间就算难点赌点
* @param customerId
* @param exclude
* @return java.util.List<java.lang.String>
* @author wangc
* @date 2020.11.06 14:14
*/
List<String> getOvertimeProjectByParameter(String customerId,List<String> exclude);
}

112
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/impl/ProjectProcessServiceImpl.java

@ -20,11 +20,13 @@ package com.epmet.service.project.impl;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.constant.DataSourceConstant;
import com.epmet.dao.project.ProjectProcessDao;
import com.epmet.dto.form.CommonStaffIdFormDTO;
import com.epmet.dto.project.FinishOrgDTO;
import com.epmet.dto.project.ProcessInfoDTO;
import com.epmet.dto.project.ProjectOrgRelationDTO;
import com.epmet.dto.project.result.ProjectLatestOperationResultDTO;
import com.epmet.dto.project.result.ProjectOrgPeriodResultDTO;
import com.epmet.dto.project.result.ProjectOrgRelationWhenResponseResultDTO;
@ -86,43 +88,24 @@ public class ProjectProcessServiceImpl extends BaseServiceImpl<ProjectProcessDao
return baseDao.selectClosedProjectList(customerId, date);
}
/**
* @Description 查询各机关项目节点历时
* @param isFirst 是否首次
* @Description 直接从项目业务改造获取项目节点耗时信息
* @param isFirst
* @param customerId
* @param date
* @return
* @return java.util.List<com.epmet.dto.project.result.ProjectOrgPeriodResultDTO>
* @author wangc
* @date 2020.09.18 13:38
**/
* @date 2020.10.23 09:10
*/
@Override
public List<ProjectOrgPeriodResultDTO> getProjectPeriod(Boolean isFirst,String customerId, String date) {
List<ProjectOrgPeriodResultDTO> projectNodePeriodPerOrgList;
public List<ProjectOrgPeriodResultDTO> getProjectPeriodDirectly(Boolean isFirst, String customerId, String date) {
if(isFirst){
projectNodePeriodPerOrgList = baseDao.selectProjectOrgPeriod(customerId,null,null);
return baseDao.selectProjectOrgPeriodDirectly(customerId,null,null);
}else{
projectNodePeriodPerOrgList = baseDao.selectProjectOrgPeriod(customerId,null,date);
}
if(!CollectionUtils.isEmpty(projectNodePeriodPerOrgList)){
Map<String,List<ProjectOrgPeriodResultDTO>> processMap
= projectNodePeriodPerOrgList.stream().collect(Collectors.groupingBy(ProjectOrgPeriodResultDTO :: getProcessId));
List<String> projects =
projectNodePeriodPerOrgList.stream().map(ProjectOrgPeriodResultDTO::getProjectId).distinct().collect(Collectors.toList());
if(!projects.isEmpty()){
List<ProjectOrgRelationWhenResponseResultDTO> responseList = baseDao.selectResponseTrace(projects);
Map<String,List<ProjectOrgRelationWhenResponseResultDTO>> sorted =
responseList.stream().collect(Collectors.groupingBy(ProjectOrgRelationWhenResponseResultDTO::getProjectId));
skipLevelGrouping(processMap,sorted);
List<ProjectOrgPeriodResultDTO> result = new LinkedList<>();
processMap.values().forEach(list -> {list.forEach(obj -> {result.add(obj);});});
return result;
}
return baseDao.selectProjectOrgPeriodDirectly(customerId,null,date);
}
return new ArrayList<>();
}
@Override
@ -139,74 +122,31 @@ public class ProjectProcessServiceImpl extends BaseServiceImpl<ProjectProcessDao
* @date 2020.09.28 14:44
*/
@Override
public Map<String, String> selectLatestOperation(List<String> list, String customerId) {
List<ProjectLatestOperationResultDTO> operations = baseDao.selectLatestOperation(list);
public Map<String, String> getLatestOperation(List<String> list, String customerId) {
List<ProjectLatestOperationResultDTO> operations = baseDao.selectLatestOperation(list,customerId);
if(CollectionUtils.isEmpty(operations)){
return Collections.EMPTY_MAP;
}else{
return operations.stream().collect(Collectors.toMap(ProjectLatestOperationResultDTO :: getProjectId,ProjectLatestOperationResultDTO :: getOperationName));
}
}
/**
* @Description 跨级分组 eg -> transfer ; response response transfer ; return ; response close.
* @param dest - Map<String,List<ProjectOrgPeriodResultDTO>> 需要填充的数据
* @param fillFactor - Map<String,List<ProjectOrgRelationWhenResponseResultDTO>> 填充因子
* @return
* @Description 获取项目标题
* @param list
* @param customerId
* @return java.util.Map<java.lang.String,java.lang.String>
* @author wangc
* @date 2020.09.18 15:27
**/
private void skipLevelGrouping(Map<String,List<ProjectOrgPeriodResultDTO>> dest,Map<String,List<ProjectOrgRelationWhenResponseResultDTO>> fillFactor){
for(String projectId : fillFactor.keySet()){
List<ProjectOrgRelationWhenResponseResultDTO> projectTraceUnit = fillFactor.get(projectId);
if(!projectTraceUnit.isEmpty()){
Map<String,List<ProjectOrgRelationWhenResponseResultDTO>> staffResponseTrace =
projectTraceUnit.stream().collect(Collectors.groupingBy(ProjectOrgRelationWhenResponseResultDTO::getStaffId));
if(!CollectionUtils.isEmpty(staffResponseTrace)){
staffResponseTrace.keySet().forEach( staffId -> {
if(!CollectionUtils.isEmpty(staffResponseTrace.get(staffId))){
List<ProjectOrgRelationWhenResponseResultDTO> staffResponseTraceUnit
= staffResponseTrace.get(staffId);
int lastEndCount = NumConstant.ONE_NEG;
for(int index = NumConstant.ZERO; index < staffResponseTraceUnit.size(); index ++){
if(StringUtils.equalsAny(staffResponseTraceUnit.get(index).getOperation(),
"transfer","return","close")){
replaceFirstResponseDate(dest,index,staffResponseTraceUnit,true);
lastEndCount = index;
}else{
if(lastEndCount == NumConstant.ONE_NEG) continue;
if(index - NumConstant.ONE == lastEndCount){
replaceFirstResponseDate(dest,index,staffResponseTraceUnit,false);
}else{continue;}
}
}
}
});
}
}
}
}
private void replaceFirstResponseDate(Map<String,List<ProjectOrgPeriodResultDTO>> dest, int index, List<ProjectOrgRelationWhenResponseResultDTO> staffResponseTraceUnit, boolean ifResponsed){
List<ProjectOrgPeriodResultDTO> processSingleList =
dest.get(staffResponseTraceUnit.get(index).getProcessId());
if(!CollectionUtils.isEmpty(processSingleList)){
//ProjectOrgPeriodResultDTO element = processSingleList.get(NumConstant.ZERO);
ProjectOrgPeriodResultDTO element = processSingleList.stream().filter(node ->
StringUtils.equals(node.getStaffId(),staffResponseTraceUnit.get(index).getStaffId())).findFirst().get();
if(!ifResponsed && null == element.getHandledDate()){
log.warn("com.epmet.service.project.impl.ProjectProcessServiceImpl.skipLevelGrouping::已流出节点没有办结日期,节点ID{}",element.getProcessId() );
}
element.setPeriodTillReplyFirstly(ifResponsed ? staffResponseTraceUnit.get(index).getCreatedTime() :element.getHandledDate());
* @date 2020.10.27 14:34
*/
@Override
public Map<String, String> getProjectTitle(List<String> list, String customerId) {
List<ProjectLatestOperationResultDTO> titles = baseDao.selectProjectTitle(list,customerId);
if(CollectionUtils.isEmpty(titles)){
return Collections.EMPTY_MAP;
}else{
return titles.stream().collect(Collectors.toMap(ProjectLatestOperationResultDTO :: getProjectId,ProjectLatestOperationResultDTO :: getOperationName));
}
}
}

20
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/impl/ProjectServiceImpl.java

@ -19,15 +19,15 @@ package com.epmet.service.project.impl;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.constant.DataSourceConstant;
import com.epmet.dao.project.ProjectDao;
import com.epmet.dto.ProjectDTO;
import com.epmet.dto.project.ProjectAgencyDTO;
import com.epmet.dto.project.ProjectGridDTO;
import com.epmet.dto.project.ProjectInfoDTO;
import com.epmet.entity.project.ProjectEntity;
import com.epmet.service.project.ProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.List;
@ -82,4 +82,20 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit
return baseDao.selectParameterValueByKey(customerId);
}
/**
* @Description 得到超过阈值滞留的项目Id集合
* 规定只要项目的任何一个负责人(被流转到的自始至终不管有没有处理)超过了自定义或默认的滞留时间就算难点赌点
* @param customerId
* @param exclude
* @return java.util.List<java.lang.String>
* @author wangc
* @date 2020.11.06 14:14
*/
@Override
public List<String> getOvertimeProjectByParameter(String customerId, List<String> exclude) {
String parameter = baseDao.selectParameterValueByKey(customerId);
if(StringUtils.isBlank(parameter)) parameter = baseDao.selectParameterValueByKey("default");
return baseDao.selectOvertimeProjectIds(customerId, exclude, StringUtils.isBlank(parameter) ? NumConstant.FIVE : Integer.parseInt(parameter));
}
}

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

@ -406,8 +406,8 @@
project.DEL_FLAG = '0'
AND project.CUSTOMER_ID = #{customerId}
<if test="null != list and list.size() != 0">
<foreach collection="list" item="projectId" open="AND " separator=" AND " >
project.ID <![CDATA[<>]]> #{projectId}
<foreach collection="list" item="projectId" open="AND " separator=" OR " >
project.ID = #{projectId}
</foreach>
</if>
</select>

62
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginProjectOrgPeriodDailyDao.xml

@ -119,69 +119,7 @@
</foreach>
</insert>
<!-- 查找网格、部门对项目的办结系数 -->
<select id="selectSubOrgResponseCoefficient" resultType="com.epmet.dto.extract.result.OrgResponseTimeResultDTO">
SELECT
PID AS agencyId,
SUM(timestampdiff(MINUTE , INFORMED_DATE ,IFNULL(HANDLED_DATE,NOW()))) AS responseTime,
COUNT(ID) projectTotal,
COUNT(DISTINCT PROJECT_ID) distinctProjectTotal
FROM
fact_origin_project_org_period_daily
WHERE
DEL_FLAG = '0'
AND
CUSTOMER_ID = #{customerId}
AND
(ORG_TYPE = 'grid' OR ORG_TYPE = 'dept')
AND
IS_RESOLVED = 'resolved'
<if test='null != dimId and "" != dimId'>
<choose>
<when test='"month" == dateType'>
AND DATE_FORMAT(IFNULL(HANDLED_DATE,NOW()),'%Y%m') = #{dimId}
</when>
<otherwise>
AND DATE_FORMAT(IFNULL(HANDLED_DATE,NOW()),'%Y%m%d') = #{dimId}
</otherwise>
</choose>
</if>
GROUP BY PID
</select>
<!-- 查找机关对项目的办结系数 -->
<select id="selectAgencyResponseCoefficient" resultType="com.epmet.dto.extract.result.OrgResponseTimeResultDTO">
SELECT
ORG_ID AS agencyId,
SUM(timestampdiff(MINUTE , INFORMED_DATE ,IFNULL(HANDLED_DATE,NOW()))) AS responseTime,
COUNT(ID) projectTotal,
COUNT(PROJECT_ID) distinctProjectTotal
FROM
fact_origin_project_org_period_daily
WHERE
DEL_FLAG = '0'
AND
CUSTOMER_ID = #{customerId}
AND
ORG_TYPE = 'agency'
AND
IS_RESOLVED = 'resolved'
<if test='null != dimId and "" != dimId'>
<choose>
<when test='"month" == dateType'>
AND DATE_FORMAT(IFNULL(HANDLED_DATE,NOW()),'%Y%m') = #{dimId}
</when>
<otherwise>
AND DATE_FORMAT(IFNULL(HANDLED_DATE,NOW()),'%Y%m%d') = #{dimId}
</otherwise>
</choose>
</if>
GROUP BY ORG_ID
</select>
<select id="selectDeptHandle" resultType="com.epmet.dto.extract.result.OrgStatisticsResultDTO">
SELECT
fp.ORG_ID,

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

@ -137,6 +137,7 @@
EVENT_IMG_URL,
EVENT_SOURCE,
EVENT_CONTENT,
EVENT_TITLE,
EVENT_COST_TIME,
EVENT_RE_ORG,
EVENT_HANDLED_COUNT,
@ -166,6 +167,7 @@
#{item.eventImgUrl},
#{item.eventSource},
#{item.eventContent},
#{item.eventTitle},
#{item.eventCostTime},
#{item.eventReOrg},
#{item.eventHandledCount},

41
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/project/ProjectDao.xml

@ -106,4 +106,45 @@
and PARAMETER_KEY ='detention_days'
</select>
<select id="selectOvertimeProjectIds" resultType="string">
SELECT
DISTINCT
project.ID
FROM
project project
WHERE
project.del_flag = '0'
AND project.customer_id = #{customerId}
<if test="null != exclude and exclude.size() > 0">
<foreach collection="exclude" item="id" open="AND ( " separator=" OR " close=" ) ">
project.ID <![CDATA[ <> ]]> #{id}
</foreach>
</if>
AND EXISTS (
SELECT
stff.ID
FROM
project_staff stff
LEFT JOIN project_org_relation period ON stff.ID = period.PROJECT_STAFF_ID
AND period.DEL_FLAG = '0'
WHERE
stff.DEL_FLAG = '0'
AND stff.CUSTOMER_ID = #{customerId}
AND project.ID = stff.PROJECT_ID
AND ABS(
TIMESTAMPDIFF(
DAY,
period.INFORMED_DATE,
IF
(
period.HANDLED_DATE IS NULL,
IF
( project.`STATUS` = 'closed', project.UPDATED_TIME, NOW( ) ),
period.HANDLED_DATE
)
)
) > #{value}
)
</select>
</mapper>

90
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/project/ProjectProcessDao.xml

@ -98,6 +98,7 @@
<!-- 查询项目-机关各个节点历时详情 -->
<select id="selectProjectOrgPeriod" resultType="com.epmet.dto.project.result.ProjectOrgPeriodResultDTO">
SELECT
staff.ID AS projectStaffId,
project.CUSTOMER_ID,
process.ID AS processId,
process.PROJECT_ID,
@ -107,7 +108,7 @@
staff.ORG_ID,
staff.DEPARTMENT_ID,
staff.GRID_ID,
staff.CREATED_BY AS staffId,
staff.STAFF_ID AS staffId,
staff.ORG_ID_PATH,
IF(staff.IS_HANDLE='handle',timestampdiff(MINUTE , staff.CREATED_TIME , staff.UPDATED_TIME),0) AS TOTAL_PERIOD,
@ -119,7 +120,9 @@
FROM PROJECT_STAFF staff
LEFT JOIN PROJECT project ON staff.PROJECT_ID = project.ID AND project.DEL_FLAG = '0'
LEFT JOIN PROJECT_PROCESS process ON staff.PROCESS_ID = process.ID AND process.DEL_FLAG = '0'
LEFT JOIN PROJECT_PROCESS selfAction ON staff.PROJECT_ID = selfAction.PROJECT_ID AND selfAction.DEL_FLAG = '0' AND staff.UPDATED_TIME = selfAction.CREATED_TIME AND staff.STAFF_ID = selfAction.STAFF_ID
LEFT JOIN PROJECT_PROCESS selfAction ON staff.PROJECT_ID = selfAction.PROJECT_ID AND selfAction.DEL_FLAG = '0'
AND ABS(TIMESTAMPDIFF(SECOND,staff.UPDATED_TIME,selfAction.CREATED_TIME)) <![CDATA[ <= ]]> 30
AND staff.STAFF_ID = selfAction.STAFF_ID
WHERE staff.DEL_FLAG = '0'
AND project.CUSTOMER_ID = #{customerId}
@ -137,6 +140,45 @@
ORDER BY process.PROJECT_ID,staff.CREATED_TIME ASC
</select>
<select id="selectProjectOrgPeriodDirectly" resultType="com.epmet.dto.project.result.ProjectOrgPeriodResultDTO">
SELECT
staff.CUSTOMER_ID,
staff.PROCESS_ID,
staff.PROJECT_ID,
relation.SOURCE_OPERATION AS lastAction,
relation.OPERATION,
staff.DEPARTMENT_NAME,
staff.ORG_ID,
staff.DEPARTMENT_ID,
staff.GRID_ID,
staff.ORG_ID_PATH,
staff.STAFF_ID,
relation.TOTAL_PERIOD,
relation.INFORMED_DATE,
IF(staff.IS_HANDLE='handle','resolved','unresolved') AS isResolved,
relation.HANDLED_DATE,
relation.FIRST_DEALT_DATE AS periodTillReplyFirstly
FROM PROJECT_STAFF staff
INNER JOIN PROJECT_ORG_RELATION relation ON staff.ID = relation.PROJECT_STAFF_ID AND relation.DEL_FLAG = '0'
WHERE staff.DEL_FLAG = '0'
AND staff.CUSTOMER_ID = #{customerId}
<if test='null != projectStatus and "" != projectStatus'>
AND project.STATUS = #{projectStatus}
</if>
<if test='null != dateId and "" != dateId'>
AND (
DATE_FORMAT(relation.UPDATED_TIME , '%Y%m%d') = #{dateId}
)
</if>
ORDER BY staff.PROJECT_ID,staff.CREATED_TIME ASC
</select>
<!-- 查询项目-机关各个节点的响应列表 -->
<select id="selectResponseTrace" resultType="com.epmet.dto.project.result.ProjectOrgRelationWhenResponseResultDTO">
SELECT
@ -159,8 +201,32 @@
SELECT * FROM PROJECT_PROCESS WHERE DEL_FLAG = '0' AND PROJECT_ID = process.PROJECT_ID AND OPERATION = 'response'
AND STAFF_ID = process.STAFF_ID AND DEPARTMENT_NAME = process.DEPARTMENT_NAME
)
ORDER BY process.STAFF_ID , process.CREATED_TIME ASC
ORDER BY process.PROJECT_ID , process.STAFF_ID , process.CREATED_TIME ASC
</select>
<!-- 查询项目的节点 -->
<select id="selectProjectProcess" resultType="com.epmet.dto.project.result.ProjectOrgRelationWhenResponseResultDTO">
SELECT
ID AS processId,
PROJECT_ID,
STAFF_ID,
OPERATION,
CREATED_TIME
FROM
PROJECT_PROCESS
WHERE
DEL_FLAG = '0'
AND
PROJECT_ID
IN(
SELECT DISTINCT ID
)
<foreach collection="projects" item="id" open="AND (" close=")" separator=" OR ">
PROJECT_ID = #{id}
</foreach>
ORDER BY PROJECT_ID,STAFF_ID,CREATED_TIME ASC
</select>
<select id="selectFinishOrg" resultType="com.epmet.dto.project.FinishOrgDTO">
SELECT
a.GRID_ID,
@ -207,6 +273,7 @@
project_process process
WHERE
process.DEL_FLAG = '0'
AND process.CUSTOMER_ID = #{customerId}
<if test="null != list and list.size() > 0">
<foreach collection="list" item="projectId" open="AND (" separator=" OR " close=" )">
process.PROJECT_ID = #{projectId}
@ -239,4 +306,21 @@
AND DATE_FORMAT(pp.CREATED_TIME,'%Y%m%d') = #{date}
</if>
</select>
<!-- 查找项目标题 -->
<select id="selectProjectTitle" resultType="com.epmet.dto.project.result.ProjectLatestOperationResultDTO">
SELECT
ID AS projectId,
TITLE AS operationName
FROM
project
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
<if test="null != list and list.size() > 0">
<foreach collection="list" item="projectId" open="AND (" separator=" OR " close=" )">
ID = #{projectId}
</foreach>
</if>
</select>
</mapper>

35
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/CostDayFormDTO.java

@ -0,0 +1,35 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* @author zhaoqifeng
* @dscription
* @date 2020/10/21 17:34
*/
@Data
public class CostDayFormDTO implements Serializable {
private static final long serialVersionUID = -1002961480112906533L;
/**
* 项目ID
*/
private String id;
/**
* 工作人员ID
*/
private String staffId;
/**
* 起始日期
*/
private Date startDate;
/**
* 终止日期
*/
private Date endDate;
}

41
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/TimestampIntervalFormDTO.java

@ -0,0 +1,41 @@
package com.epmet.dto.form;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
/**
* @Description 时间区间
* @ClassName TimestampIntervalFormDTO
* @Auth wangc
* @Date 2020-10-21 15:55
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TimestampIntervalFormDTO implements Serializable {
private static final long serialVersionUID = 8404199047657424778L;
/***
* 可以是任意的标志Id用来区分多组传参的返回值
*/
@NotNull(message = "时间区间标识Id不能为空",groups = WorkMinuteFormDTO.WorkTimeGroup.class)
private String id;
/**
* 区间左段点
*/
@NotNull(message = "开始时间不能为空",groups = WorkMinuteFormDTO.WorkTimeGroup.class)
private Date left;
/***
* 去边右段点
*/
private Date right;
}

47
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/WorkMinuteFormDTO.java

@ -0,0 +1,47 @@
package com.epmet.dto.form;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import javax.validation.Valid;
import java.io.Serializable;
import java.util.List;
/**
* @Description 计算经历的多少分钟(只计算工作日)
* @ClassName WorkMinuteFromDTO
* @Auth wangc
* @Date 2020-10-21 15:48
*/
@Data
public class WorkMinuteFormDTO implements Serializable {
private static final long serialVersionUID = -7777345488803895645L;
public interface WorkTimeGroup extends CustomerClientShowGroup{}
/**
* 是否使用自定义起止时间 default - 24小时制计 custom - 使用自定义但是一定要传递起止时间(目前只支持在同一天)
*/
private String ifCustom;
/**
* 是否精准计算 默认不精准计算 Imprecise - 不精准 precise - 精准
*/
private String ifPrecise;
/***
* 每天的计算起始时间
* HH:mm:ss
*/
private String startTemplate;
/***
* 每天的计算截止时间
* HH:mm:ss
*/
private String endTemplate;
@Valid
private List<TimestampIntervalFormDTO> timeList;
}

37
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/CostDayResultDTO.java

@ -0,0 +1,37 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* @author zhaoqifeng
* @dscription
* @date 2020/10/21 17:53
*/
@Data
public class CostDayResultDTO implements Serializable {
private static final long serialVersionUID = -1575208332115510050L;
/**
* 项目ID
*/
private String id;
/**
* 工作人员ID
*/
private String staffId;
/**
* 已滞留工作日
*/
private Integer detentionDays;
/**
* 起始日期
*/
private Date startDate;
}

36
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java

@ -2,9 +2,12 @@ package com.epmet.feign;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.CostDayFormDTO;
import com.epmet.dto.form.ExternalAppAuthFormDTO;
import com.epmet.dto.form.GetJwtAccessTokenFormDTO;
import com.epmet.dto.form.WorkDayFormDTO;
import com.epmet.dto.result.CostDayResultDTO;
import com.epmet.dto.form.WorkMinuteFormDTO;
import com.epmet.dto.result.AppIdInfoResultDTO;
import com.epmet.dto.result.ExternalAppAuthResultDTO;
import com.epmet.dto.result.WorkDayResultDTO;
@ -14,6 +17,7 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
import java.util.Map;
/**
* 本服务对外开放的API,其他服务通过引用此client调用该服务
@ -22,7 +26,7 @@ import java.util.List;
* @date 2020/6/4 10:28
*/
@FeignClient(name = ServiceConstant.EPMET_COMMON_SERVICE, fallback = EpmetCommonServiceOpenFeignClientFallback.class)
//@FeignClient(name = ServiceConstant.EPMET_COMMON_SERVICE, fallback = EpmetCommonServiceOpenFeignClientFallback.class, url = "localhost:8103")
//@FeignClient(name = ServiceConstant.EPMET_COMMON_SERVICE, fallback = EpmetCommonServiceOpenFeignClientFallback.class, url = "http://localhost:8103")
public interface EpmetCommonServiceOpenFeignClient {
/**
* @param formDTO
@ -67,4 +71,34 @@ public interface EpmetCommonServiceOpenFeignClient {
@PostMapping("/commonservice/externalapp/appidinfo")
Result<AppIdInfoResultDTO> appIdInfo(@RequestBody String appId);
/**
* 工作日计算
* @author zhaoqifeng
* @date 2020/10/22 9:25
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.result.CostDayResultDTO>>
*/
@PostMapping("commonservice/workday/workdays")
Result<List<CostDayResultDTO>> costWorkDays(@RequestBody List<CostDayFormDTO> formDTO);
/**
* 日历天计算
* @author zhaoqifeng
* @date 2020/10/22 9:25
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.result.CostDayResultDTO>>
*/
@PostMapping("commonservice/workday/calendardays")
Result<List<CostDayResultDTO>> costCalendarDays(@RequestBody List<CostDayFormDTO> formDTO);
/**
* @Description 计算经历的多少分钟(只计算工作日)
* @param param
* @return com.epmet.commons.tools.utils.Result<java.util.Map<java.lang.String,java.lang.Integer>>
* @author wangc
* @date 2020.10.21 16:34
*/
@PostMapping("commonservice/workday/workminutes")
Result<Map<String,Integer>> workMinutes(@RequestBody WorkMinuteFormDTO param);
}

35
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java

@ -3,9 +3,12 @@ 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.CostDayFormDTO;
import com.epmet.dto.form.ExternalAppAuthFormDTO;
import com.epmet.dto.form.GetJwtAccessTokenFormDTO;
import com.epmet.dto.form.WorkDayFormDTO;
import com.epmet.dto.form.WorkMinuteFormDTO;
import com.epmet.dto.result.CostDayResultDTO;
import com.epmet.dto.result.AppIdInfoResultDTO;
import com.epmet.dto.result.ExternalAppAuthResultDTO;
import com.epmet.dto.result.WorkDayResultDTO;
@ -13,6 +16,7 @@ import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
/**
* 本服务对外开放的API,其他服务通过引用此client调用该服务
@ -51,4 +55,35 @@ public class EpmetCommonServiceOpenFeignClientFallback implements EpmetCommonSer
public Result getAccessToken(GetJwtAccessTokenFormDTO form) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "getAccessToken", form);
}
/**
* 工作日计算
*
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<java.util.List < com.epmet.dto.result.CostDayResultDTO>>
* @author zhaoqifeng
* @date 2020/10/22 9:25
*/
@Override
public Result<List<CostDayResultDTO>> costWorkDays(List<CostDayFormDTO> formDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "costWorkDays", formDTO);
}
/**
* 日历天计算
*
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<java.util.List < com.epmet.dto.result.CostDayResultDTO>>
* @author zhaoqifeng
* @date 2020/10/22 9:25
*/
@Override
public Result<List<CostDayResultDTO>> costCalendarDays(List<CostDayFormDTO> formDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "costCalendarDays", formDTO);
}
@Override
public Result<Map<String, Integer>> workMinutes(WorkMinuteFormDTO param) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "workMinutes", param);
}
}

29
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/constant/ProjectConstant.java

@ -8,4 +8,33 @@ public interface ProjectConstant {
* 时间已存在
*/
/**
* 日期类型 工作日
*/
String DAY_TYPE_WORK = "1";
/**
* 日期类型 周末
*/
String DAY_TYPE_WEEKEND = "2";
/**
* 日期类型 假日
*/
String DAY_TYPE_HOLIDAY = "3";
/***
* 计算方式 使用自定应
*/
String CALCULATION_TYPE_CUSTOM = "custom";
/**
* 计算方式 使用默认24小时制
*/
String CALCULATION_TYPE_DEFAULT = "default";
/**
* 精准计算
*/
String PRECISE_CALCULATION = "precise";
}

44
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/WorkDayController.java

@ -1,7 +1,10 @@
package com.epmet.controller;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.CostDayFormDTO;
import com.epmet.dto.form.WorkDayFormDTO;
import com.epmet.dto.result.CostDayResultDTO;
import com.epmet.dto.form.WorkMinuteFormDTO;
import com.epmet.dto.result.WorkDayResultDTO;
import com.epmet.service.WorkDayService;
import org.springframework.beans.factory.annotation.Autowired;
@ -11,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/**
* @Description 工作日计算
@ -36,5 +40,45 @@ public class WorkDayController {
List<WorkDayResultDTO> list = workDayService.detentionDays(formDTO);
return new Result<List<WorkDayResultDTO>>().ok(list);
}
/**
* 工作日计算
* @author zhaoqifeng
* @date 2020/10/22 9:23
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.result.CostDayResultDTO>>
*/
@PostMapping("workdays")
public Result<List<CostDayResultDTO>> costWorkDays(@RequestBody List<CostDayFormDTO> formDTO) {
List<CostDayResultDTO> list = workDayService.costWorkDays(formDTO);
return new Result<List<CostDayResultDTO>>().ok(list);
}
/**
* 日历天计算
* @author zhaoqifeng
* @date 2020/10/22 9:23
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.result.CostDayResultDTO>>
*/
@PostMapping("calendardays")
public Result<List<CostDayResultDTO>> costCalendarDays(@RequestBody List<CostDayFormDTO> formDTO) {
List<CostDayResultDTO> list = workDayService.costCalendarDays(formDTO);
return new Result<List<CostDayResultDTO>>().ok(list);
}
/**
* @Description 计算经历的多少分钟(只计算工作日)
* @param param
* @return com.epmet.commons.tools.utils.Result<java.util.Map<java.lang.String,java.lang.Integer>>
* @author wangc
* @date 2020.10.21 16:34
*/
@PostMapping("workminutes")
public Result<Map<String,Integer>> workMinutes(@RequestBody WorkMinuteFormDTO param){
return new Result<Map<String,Integer>>().ok(workDayService.workMinutes(param));
}
}

32
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/WorkDayService.java

@ -1,9 +1,14 @@
package com.epmet.service;
import com.epmet.dto.form.CostDayFormDTO;
import com.epmet.dto.form.WorkDayFormDTO;
import com.epmet.dto.result.CostDayResultDTO;
import com.epmet.dto.form.WorkMinuteFormDTO;
import com.epmet.dto.result.WorkDayResultDTO;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
@ -13,4 +18,31 @@ import java.util.Set;
*/
public interface WorkDayService {
List<WorkDayResultDTO> detentionDays(List<WorkDayFormDTO> formDTO);
/**
* 工作日计算
* @author zhaoqifeng
* @date 2020/10/21 17:56
* @param formDTO
* @return java.util.List<com.epmet.dto.result.CostDayResultDTO>
*/
List<CostDayResultDTO> costWorkDays(List<CostDayFormDTO> formDTO);
/**
* 日历日计算
* @author zhaoqifeng
* @date 2020/10/21 17:56
* @param formDTO
* @return java.util.List<com.epmet.dto.result.CostDayResultDTO>
*/
List<CostDayResultDTO> costCalendarDays(List<CostDayFormDTO> formDTO);
/**
* @Description 计算经历的多少分钟(只计算工作日)
* @param param
* @return java.util.Map<java.lang.String,java.lang.Integer>
* @author wangc
* @date 2020.10.21 16:14
*/
Map<String,Integer> workMinutes(WorkMinuteFormDTO param);
}

347
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/WorkDayServiceImpl.java

@ -1,17 +1,30 @@
package com.epmet.service.impl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.constant.ProjectConstant;
import com.epmet.dao.CalenderDao;
import com.epmet.dto.form.CostDayFormDTO;
import com.epmet.dto.form.TimestampIntervalFormDTO;
import com.epmet.dto.form.WorkDayFormDTO;
import com.epmet.dto.result.CostDayResultDTO;
import com.epmet.dto.form.WorkMinuteFormDTO;
import com.epmet.dto.result.WorkDayResultDTO;
import com.epmet.entity.CalenderEntity;
import com.epmet.service.WorkDayService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.*;
/**
@ -25,6 +38,8 @@ public class WorkDayServiceImpl implements WorkDayService {
@Autowired
private CalenderDao calenderDao;
private static SimpleDateFormat format = new SimpleDateFormat(DateUtils.DATE_PATTERN);
private static SimpleDateFormat formatMinute = new SimpleDateFormat(DateUtils.DATE_TIME_PATTERN);
@Override
public List<WorkDayResultDTO> detentionDays(List<WorkDayFormDTO> workDayFormDTO) {
List<WorkDayResultDTO> list = new ArrayList<>();
@ -44,6 +59,95 @@ public class WorkDayServiceImpl implements WorkDayService {
return list;
}
/**
* 工作日计算
*
* @param formDTO
* @return java.util.List<com.epmet.dto.result.CostDayResultDTO>
* @author zhaoqifeng
* @date 2020/10/21 17:56
*/
@Override
public List<CostDayResultDTO> costWorkDays(List<CostDayFormDTO> formDTO) {
List<CostDayResultDTO> list = new ArrayList<>();
if (formDTO.isEmpty()) {
throw new RenException("起始时间、终止时间不能为空");
}
for (CostDayFormDTO form : formDTO) {
CostDayResultDTO result = new CostDayResultDTO();
result.setId(form.getId());
result.setStaffId(form.getStaffId());
result.setDetentionDays(this.getWorkDays(form.getStartDate(), form.getEndDate()));
result.setStartDate(form.getStartDate());
list.add(result);
}
return list;
}
/**
* 日历日计算
*
* @param formDTO
* @return java.util.List<com.epmet.dto.result.CostDayResultDTO>
* @author zhaoqifeng
* @date 2020/10/21 17:56
*/
@Override
public List<CostDayResultDTO> costCalendarDays(List<CostDayFormDTO> formDTO) {
List<CostDayResultDTO> list = new ArrayList<>();
if (formDTO.isEmpty()) {
throw new RenException("起始时间、终止时间不能为空");
}
for (CostDayFormDTO form : formDTO) {
CostDayResultDTO result = new CostDayResultDTO();
result.setId(form.getId());
result.setStaffId(form.getStaffId());
result.setDetentionDays(this.getCalendarDays(form.getStartDate(), form.getEndDate()));
result.setStartDate(form.getStartDate());
list.add(result);
}
return list;
}
/**
* @Description 计算经历的多少分钟(只计算工作日)
* @param param
* @return java.util.Map<java.lang.String,java.lang.Integer>
* @author wangc
* @date 2020.10.21 16:14
*/
@Override
public Map<String,Integer> workMinutes(WorkMinuteFormDTO param) {
List<TimestampIntervalFormDTO> params = param.getTimeList();
if(CollectionUtils.isEmpty(params)) return null;
Map<String,Integer> result = new LinkedHashMap<>();
//默认非精准计算
if(StringUtils.isBlank(param.getIfPrecise()) || !StringUtils.equals(ProjectConstant.PRECISE_CALCULATION,param.getIfPrecise())){
params.forEach(local -> {
result.put(local.getId(),calculateImpreciseDetentionMinutes(local.getLeft(),local.getRight()));
});
return result;
}
//精准计算
if(StringUtils.isBlank(param.getIfCustom()) || !StringUtils.equals(ProjectConstant.CALCULATION_TYPE_CUSTOM,param.getIfCustom())){
//默认
params.forEach(local -> {
result.put(local.getId(),calculateDetentionMinutes(local.getLeft(),local.getRight()));
});
}else{
//自定义
params.forEach(local -> {
try {
result.put(local.getId(), calculateDetentionMinutesWithStartEnd(local.getLeft(), local.getRight(), param.getStartTemplate(), param.getEndTemplate()));
}catch (Exception e){
throw new RenException(e.getMessage());
}
});
}
return result;
}
//公式: 当前日期 - 被吹日期 - 期间的节假日
private String caculateDetentionDays(String startDateStr, String endDateStr) {
if (startDateStr.equals(endDateStr)) {
@ -77,6 +181,249 @@ public class WorkDayServiceImpl implements WorkDayService {
return "-1";
}
/***
* @Description 计算两个日期之间的非准确时间差(只包括工作日)单位分钟 不足一天按照一天计算
* @param left
* @param right
* @return java.lang.Integer
* @author wangc
* @date 2020.10.21 17:09
*/
private Integer calculateImpreciseDetentionMinutes(Date left, Date right){
if(null == left){ logger.error("计算工作日,传入的开始日期为空!");return null;}
//给右区间赋值,默认当前时间
if(null == right || right.compareTo(left) < NumConstant.ZERO) right = new Date();
List<CalenderEntity> list = calenderDao.selectByStartAndEnd(format.format(left),format.format(right));
if(!CollectionUtils.isEmpty(list)){
//集合中只有一个元素,说明两个时间在同一天
if(list.size() == NumConstant.ONE){
return NumConstant.EIGHT * NumConstant.SIXTY;
}
//集合中有两个元素,说明两个时间是相连的
//集合中有两个元素以上,说明两个时间存在跨度
else{
int costMin = NumConstant.ZERO;
if(NumConstant.TWO == list.size()) return costMin;
for(int index = NumConstant.ZERO ; index < list.size() ; index++)
if(StringUtils.equals(ProjectConstant.DAY_TYPE_WORK,list.get(index).getType()))
costMin += NumConstant.TWENTY_FOUR * NumConstant.SIXTY;
return costMin;
}
}
logger.warn("计算工作日,没有找到开始日期和结束日期,可能数据库中没有存储对应时段的数据,开始时间:{},结束时间:{}",left,right);
return null;
}
/**
* @Description 计算两个日期之间的时间差(只包括工作日)单位分钟
* @param left
* @param right
* @return java.lang.Integer
* @author wangc
* @date 2020.10.21 14:00
*/
private Integer calculateDetentionMinutes(Date left ,Date right){
if(null == left){ logger.error("计算工作日,传入的开始日期为空!");return null;}
//给右区间赋值,默认当前时间
if(null == right || right.compareTo(left) < NumConstant.ZERO) right = new Date();
List<CalenderEntity> list = calenderDao.selectByStartAndEnd(format.format(left),format.format(right));
if(!CollectionUtils.isEmpty(list)){
//集合中只有一个元素,说明两个时间在同一天
if(list.size() == NumConstant.ONE){
if(ProjectConstant.DAY_TYPE_WORK.equals(list.get(NumConstant.ZERO).getType()))
return (int)((right.getTime() - left.getTime())/NumConstant.ONE_THOUSAND/NumConstant.SIXTY);
else {
logger.warn("计算工作日,传入的起始时间都在同一天且是在节假日,开始时间:{},结束时间:{},节日类型:{}(1工作日、2周末、3、节假日)",left,right);
return NumConstant.ZERO;
}
}
//集合中有两个元素,说明两个时间是相连的
//集合中有两个元素以上,说明两个时间存在跨度
else{
String leftType = list.get(NumConstant.ZERO).getType();
String rightType = list.get(list.size() - NumConstant.ONE).getType();
int costMin = NumConstant.ZERO;
if(ProjectConstant.DAY_TYPE_WORK.equals(leftType)){
LocalDateTime localDateTime = LocalDateTime.ofInstant(left.toInstant(), ZoneId.systemDefault());
//获取第第二天零点时刻的实例
LocalDateTime tomorrowTime = LocalDateTime.ofInstant(left.toInstant(), ZoneId.systemDefault())
.plusDays(NumConstant.ONE).withHour(NumConstant.ZERO).withMinute(NumConstant.ZERO).withSecond(NumConstant.ZERO).withNano(NumConstant.ZERO);
//ChronoUnit日期枚举类,between方法计算两个时间对象之间的时间量
costMin += ChronoUnit.SECONDS.between(localDateTime, tomorrowTime)/NumConstant.SIXTY;
}
if(ProjectConstant.DAY_TYPE_WORK.equals(rightType)){
LocalDateTime localDateTime = LocalDateTime.ofInstant(right.toInstant(), ZoneId.systemDefault());
//获取第第二天零点时刻的实例
LocalDateTime initialTime = LocalDateTime.ofInstant(right.toInstant(), ZoneId.systemDefault())
.withHour(NumConstant.ZERO).withMinute(NumConstant.ZERO).withSecond(NumConstant.ZERO).withNano(NumConstant.ZERO);
//ChronoUnit日期枚举类,between方法计算两个时间对象之间的时间量
costMin += ChronoUnit.SECONDS.between(localDateTime, initialTime)/NumConstant.SIXTY;
}
if(NumConstant.TWO == list.size()) return costMin;
for(int index = NumConstant.ONE ; index < list.size() - NumConstant.ONE ; index++)
if(StringUtils.equals(ProjectConstant.DAY_TYPE_WORK,list.get(index).getType()))
costMin += NumConstant.TWENTY_FOUR * NumConstant.SIXTY;
return costMin;
}
}
logger.warn("计算工作日,没有找到开始日期和结束日期,可能数据库中没有存储对应时段的数据,开始时间:{},结束时间:{}",left,right);
return null;
}
/***
* @Description 根据可配置的工作起始时间计算两个日期之间的差
* @param left
* @param right
* @param start 格式为 HH:mm:ss
* @param end 格式为 HH:mm:ss
* @return java.lang.Integer
* @author wangc
* @date 2020.10.20 18:05
*/
private Integer calculateDetentionMinutesWithStartEnd(Date left ,Date right, String start, String end)throws Exception{
if(null == left){ logger.error("计算工作日,传入的开始日期为空!");return null;}
if(null == start || null == end){start = "9:00:00"; end = "17:00:00";}
//给右区间赋值,默认当前时间
if(null == right || right.compareTo(left) < NumConstant.ZERO) right = new Date();
//自定义起始时间
String standardStartDateStr = format.format(left).concat(" ").concat(start);
//自定义截至时间
String standardEndDateStr = format.format(right).concat(" ").concat(end);
Date standardStartDate = formatMinute.parse(standardStartDateStr);
Date standardEndDate = formatMinute.parse(standardEndDateStr);
if(standardEndDate.compareTo(standardStartDate) < NumConstant.ZERO){ logger.error("计算工作日,自定义截止日期小于自定义起始日期!");return null;}
//单位时间内规定起止时间的时间差
Integer delta_T = (int)(standardEndDate.getTime() - formatMinute.parse(format.format(right).concat(" ").concat(start)).getTime())/NumConstant.ONE_THOUSAND/NumConstant.SIXTY;
List<CalenderEntity> list = calenderDao.selectByStartAndEnd(format.format(left),format.format(right));
if(!CollectionUtils.isEmpty(list)){
//集合中只有一个元素,说明两个时间在同一天
if(list.size() == NumConstant.ONE){
if(ProjectConstant.DAY_TYPE_WORK.equals(list.get(NumConstant.ZERO).getType())){
//开始时间早于当天规定开始时间
if(left.before(standardStartDate)){
if(right.before(standardStartDate)){
//结束时间早于当天规定开始时间
logger.warn("计算工作日,开始时间与结数时间均早于当天规定的起止计算时间,开始时间:{},结束时间:{},当天开始时间:{}",left,right,standardStartDate);
return NumConstant.ZERO;
}else if(right.before(standardEndDate)){
return (int)(right.getTime() - standardStartDate.getTime())/NumConstant.ONE_THOUSAND/NumConstant.SIXTY;
}else{
//结束时间晚于当天规定截止时间
return delta_T;
}
}else if(left.before(standardEndDate)){
//开始时间在当天规定起止时间之间
if(right.before(standardEndDate)){
return (int)(right.getTime() - left.getTime())/NumConstant.ONE_THOUSAND/NumConstant.SIXTY;
}else{
return (int)(standardEndDate.getTime() - left.getTime())/NumConstant.ONE_THOUSAND/NumConstant.SIXTY;
}
}else{
logger.warn("计算工作日,开始时间与结数时间晚于当天规定的截止计算时间,开始时间:{},结束时间:{},当天截止时间:{}",left,right,standardEndDate);
return NumConstant.ZERO;
}
}else {
logger.warn("计算工作日,传入的起始时间都在同一天且是在节假日,开始时间:{},结束时间:{},节日类型:{}(1工作日、2周末、3、节假日)",left,right);
return NumConstant.ZERO;
}
}
//集合中有两个元素,说明两个时间是相连的
//集合中有两个元素以上,说明两个时间存在跨度
else{
String leftType = list.get(NumConstant.ZERO).getType();
String rightType = list.get(list.size() - NumConstant.ONE).getType();
int costMin = NumConstant.ZERO;
if(ProjectConstant.DAY_TYPE_WORK.equals(leftType)){
if(left.before(standardStartDate)){
costMin += delta_T;
}else if(left.before(standardEndDate)){
costMin += (formatMinute.parse(format.format(left).concat(" ").concat(end)).getTime() - left.getTime())/NumConstant.ONE_THOUSAND/NumConstant.SIXTY;
}else{
}
}
if(ProjectConstant.DAY_TYPE_WORK.equals(rightType)){
Date leftStandardStartDate = formatMinute.parse(format.format(right).concat(" ").concat(end));
if(right.before(leftStandardStartDate)){
}else if(right.before(standardEndDate)){
costMin += (left.getTime() - leftStandardStartDate.getTime())/NumConstant.ONE_THOUSAND/NumConstant.SIXTY;
}else{
costMin += delta_T;
}
}
if(NumConstant.TWO == list.size()) return costMin;
for(int index = NumConstant.ONE ; index < list.size() - NumConstant.ONE ; index++)
if(StringUtils.equals(ProjectConstant.DAY_TYPE_WORK,list.get(index).getType()))
costMin += delta_T * NumConstant.SIXTY;
return costMin;
}
}
logger.warn("计算工作日,没有找到开始日期和结束日期,可能数据库中没有存储对应时段的数据,开始时间:{},结束时间:{}",left,right);
return null;
}
private Integer getWorkDays(Date start, Date end) {
String startDateStr = DateUtils.format(start, DateUtils.DATE_PATTERN_YYYYMMDD);
String endDateStr = DateUtils.format(end, DateUtils.DATE_PATTERN_YYYYMMDD);
if (startDateStr.equals(endDateStr)) {
logger.info(String.format("%s-%s起止时间一致,返回<1,",startDateStr,endDateStr));
return 0;
}
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
try {
Date startDate = simpleDateFormat.parse(startDateStr);
Date endDate = simpleDateFormat.parse(endDateStr);
long day = (endDate.getTime() - startDate.getTime()) / (24 * 60 * 60 * 1000);
logger.info(String.format("当前日期[%s]-被吹日期[%s]=%s", endDateStr, startDateStr, day));
List<CalenderEntity> list = calenderDao.selectByStartAndEnd(startDateStr, endDateStr);
long totalHoliday = 0;
for (CalenderEntity calenderEntity : list) {
if (!"1".equals(calenderEntity.getType())) {
totalHoliday += 1;
}
}
logger.info(String.format("期间的节假日[%s-%s]=%s", endDateStr, startDateStr, totalHoliday));
long detentionDay = day - totalHoliday;
logger.info(String.format("当前日期[%s]-被吹日期[%s]-期间的节假日[%s]=%s", endDateStr, startDateStr, totalHoliday, detentionDay));
return (int)detentionDay;
} catch (Exception e) {
e.printStackTrace();
}
return -1;
}
private Integer getCalendarDays(Date start, Date end) {
String startDateStr = DateUtils.format(start, DateUtils.DATE_PATTERN_YYYYMMDD);
String endDateStr = DateUtils.format(end, DateUtils.DATE_PATTERN_YYYYMMDD);
if (startDateStr.equals(endDateStr)) {
logger.info(String.format("%s-%s起止时间一致,返回<1,",startDateStr,endDateStr));
return 0;
}
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
try {
Date startDate = simpleDateFormat.parse(startDateStr);
Date endDate = simpleDateFormat.parse(endDateStr);
long day = (endDate.getTime() - startDate.getTime()) / (24 * 60 * 60 * 1000);
return (int)day;
} catch (Exception e) {
e.printStackTrace();
}
return -1;
}
}

1
epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/CalenderDao.xml

@ -61,4 +61,5 @@
AND QUERY_DATE BETWEEN #{begin}
AND #{end}
</select>
</mapper>

2
epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/constant/ModuleConstant.java

@ -14,4 +14,6 @@ public interface ModuleConstant {
String ERROR_EPMET_USER = "调用epmet_user服务查询网格下的所有工作人员失败";
String ERROR_AGENCY = "调用gov_org服务查询组织基本信息失败";
}

29
epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/controller/OpenUpController.java

@ -11,8 +11,10 @@ import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.service.OpenUpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
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;
import java.util.List;
@ -100,5 +102,28 @@ public class OpenUpController {
return govOrgOpenFeignClient.staffPermissionExt(commonStaffIdFormDTO.getStaffId());
}
/**
* @Description 对外接口-根据组织Id获取组织信息
* @author sun
**/
@PostMapping("agencyinfo")
Result<AgencyInfoResultDTO> agencyInfo(@RequestBody AgencyInfoFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, AgencyInfoFormDTO.StaffIdGroup.class);
if (!"agency".equals(formDTO.getOrgType()) && !"grid".equals(formDTO.getOrgType())) {
return new Result<AgencyInfoResultDTO>().error("参数错误,orgType值类型错误!");
}
return new Result<AgencyInfoResultDTO>().ok(openUpService.agencyInfo(formDTO));
}
/**
* @Description 外挂-获取当前组织及部门网格数据递归查询所有下级数据
* @author sun
**/
@PostMapping("organizetree")
Result<OrganizeTreeResultDTO> organizeTree(@RequestBody OrganizeTreeFormDTO formDTO){
ValidatorUtils.validateEntity(formDTO, OrganizeTreeFormDTO.StaffIdGroup.class);
return new Result<OrganizeTreeResultDTO>().ok(openUpService.organizeTree(formDTO));
}
}

20
epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/service/OpenUpService.java

@ -1,11 +1,7 @@
package com.epmet.service;
import com.epmet.dto.form.StaffSinAgencyFormDTO;
import com.epmet.dto.form.StaffSinDeptFormDTO;
import com.epmet.dto.form.StaffSinGridFormDTO;
import com.epmet.dto.result.StaffSinAgencyResultDTO;
import com.epmet.dto.result.StaffSinDeptResultDTO;
import com.epmet.dto.result.StaffSinGridResultDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import java.util.List;
@ -38,4 +34,16 @@ public interface OpenUpService {
* @date 2020/8/17 9:59 上午
*/
List<StaffSinAgencyResultDTO> staffSinAgency(StaffSinAgencyFormDTO formDTO);
/**
* @Description 对外接口-根据组织Id获取组织信息
* @author sun
**/
AgencyInfoResultDTO agencyInfo(AgencyInfoFormDTO formDTO);
/**
* @Description 外挂-获取当前组织及部门网格数据递归查询所有下级数据
* @author sun
**/
OrganizeTreeResultDTO organizeTree(OrganizeTreeFormDTO formDTO);
}

30
epmet-module/epmet-ext/epmet-ext-server/src/main/java/com/epmet/service/impl/OpenUpServiceImpl.java

@ -6,9 +6,7 @@ import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.ModuleConstant;
import com.epmet.dto.form.*;
import com.epmet.dto.result.StaffSinAgencyResultDTO;
import com.epmet.dto.result.StaffSinDeptResultDTO;
import com.epmet.dto.result.StaffSinGridResultDTO;
import com.epmet.dto.result.*;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.service.OpenUpService;
@ -123,4 +121,30 @@ public class OpenUpServiceImpl implements OpenUpService {
return staffInfoList.getData();
}
/**
* @Description 对外接口-根据组织Id获取组织信息
* @author sun
**/
@Override
public AgencyInfoResultDTO agencyInfo(AgencyInfoFormDTO formDTO) {
Result<AgencyInfoResultDTO> result = govOrgOpenFeignClient.agencyInfo(formDTO);
if (!result.success()){
throw new RenException(result.getInternalMsg());
}
return result.getData();
}
/**
* @Description 外挂-获取当前组织及部门网格数据递归查询所有下级数据
* @author sun
**/
@Override
public OrganizeTreeResultDTO organizeTree(OrganizeTreeFormDTO formDTO) {
Result<OrganizeTreeResultDTO> result = govOrgOpenFeignClient.organizeTree(formDTO.getAgencyId());
if (!result.success()){
throw new RenException(result.getInternalMsg());
}
return result.getData();
}
}

3
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/constant/ActMessageConstant.java

@ -8,6 +8,7 @@ package com.epmet.constant;
*/
public interface ActMessageConstant {
String TITLE="您有一条活动消息";
String WXMP_TITLE="活动消息";
/**
* 报名审核成功给居民端用户发送消息
*/
@ -29,5 +30,5 @@ public interface ActMessageConstant {
/**
* 工作端-重新发布活动通知待审核+已经审核通过的用户
*/
String RE_PUBLISH_ACT="您好,您参与的%s活动,%s,请注意查看";
String RE_PUBLISH_ACT="您参与的%s活动,%s,请注意查看";
}

18
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActServiceImpl.java

@ -24,6 +24,7 @@ import com.epmet.constant.ReadFlagConstant;
import com.epmet.dao.*;
import com.epmet.dto.*;
import com.epmet.dto.form.UserMessageFormDTO;
import com.epmet.dto.form.WxSubscribeMessageFormDTO;
import com.epmet.dto.form.work.*;
import com.epmet.dto.result.ActSponsorResultDTO;
import com.epmet.dto.result.work.*;
@ -31,6 +32,7 @@ import com.epmet.entity.*;
import com.epmet.feign.EpmetMessageOpenFeignClient;
import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.service.*;
import com.epmet.utils.ModuleConstant;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -680,6 +682,7 @@ public class WorkActServiceImpl implements WorkActService {
List<String> userIdList=actUserRelationDao.selectUserIdList(formDTO.getActId(),ActConstant.ACT_USER_STATUS_PASSED);
if(null!=userIdList&&userIdList.size()>0){
List<UserMessageFormDTO> userMessageFormDTOS=new ArrayList<>();
List<WxSubscribeMessageFormDTO> msgList = new ArrayList<>();
for(String userId:userIdList){
UserMessageFormDTO userMessageFormDTO = new UserMessageFormDTO();
userMessageFormDTO.setCustomerId(actInfoDTO.getCustomerId());
@ -692,11 +695,26 @@ public class WorkActServiceImpl implements WorkActService {
actInfoDTO.getTitle(),
formDTO.getCancelReason()));
userMessageFormDTOS.add(userMessageFormDTO);
//2020.10.26 添加发送微信订阅消息功能 sun
WxSubscribeMessageFormDTO dto = new WxSubscribeMessageFormDTO();
dto.setCustomerId(actInfoDTO.getCustomerId());
dto.setClientType(AppClientConstant.APP_RESI);
dto.setUserId(userId);
dto.setBehaviorType(ActMessageConstant.WXMP_TITLE);
dto.setMessageContent(String.format(ActMessageConstant.ACT_CANCELED, actInfoDTO.getTitle(), formDTO.getCancelReason()));
dto.setMessageTime(new Date());
dto.setGridId("*");
msgList.add(dto);
}
Result sendMessageRes= epmetMessageOpenFeignClient.saveUserMessageList(userMessageFormDTOS);
if(sendMessageRes.success()){
logger.info("给审核通过的用户发送消息成功");
}
logger.info("取消活动,开始推送微信订阅消息");
Result wxmpMsg = epmetMessageOpenFeignClient.sendWxSubscribeMessage(msgList);
if (wxmpMsg.success()) {
logger.info("给审核通过的用户推送微信订阅消息成功");
}
}
}

38
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActUserServiceImpl.java

@ -19,6 +19,7 @@ import com.epmet.dto.ActUserLogDTO;
import com.epmet.dto.ActUserRelationDTO;
import com.epmet.dto.HeartUserInfoDTO;
import com.epmet.dto.form.UserMessageFormDTO;
import com.epmet.dto.form.WxSubscribeMessageFormDTO;
import com.epmet.dto.form.work.AactUserDetailFormDTO;
import com.epmet.dto.form.work.ActIdFormDTO;
import com.epmet.dto.form.work.AuditUserFormDTO;
@ -464,6 +465,8 @@ public class WorkActUserServiceImpl implements WorkActUserService {
actUserLogDao.insert(actUserLogEntity);
//给居民发消息
this.saveUserMessage(actUserRelationEntity,ActConstant.ACT_USER_STATUS_PASSED,actInfo);
//给居民发送微信订阅消息 sun
this.saveWxmpMessage(actUserRelationEntity,ActConstant.ACT_USER_STATUS_PASSED,actInfo);
}
/**
@ -511,6 +514,8 @@ public class WorkActUserServiceImpl implements WorkActUserService {
actUserLogDao.insert(actUserLogEntity);
//给居民发消息
this.saveUserMessage(actUserRelationEntity,ActConstant.ACT_USER_STATUS_REFUSED,actInfo);
//给居民发送微信订阅消息 sun
this.saveWxmpMessage(actUserRelationEntity,ActConstant.ACT_USER_STATUS_REFUSED,actInfo);
}
/**
@ -645,6 +650,39 @@ public class WorkActUserServiceImpl implements WorkActUserService {
}
}
/**
* @param actUserRelationEntity type actInfo
* @author sun
* @description 报名审核--给报名申请人发送微信订阅消息
**/
private void saveWxmpMessage(ActUserRelationEntity actUserRelationEntity, String type, ActInfoEntity actInfo) {
List<WxSubscribeMessageFormDTO> list = new ArrayList<>();
try {
WxSubscribeMessageFormDTO msg = new WxSubscribeMessageFormDTO();
msg.setCustomerId(actInfo.getCustomerId());
msg.setClientType(AppClientConstant.APP_RESI);
msg.setUserId(actUserRelationEntity.getUserId());
msg.setBehaviorType(ActMessageConstant.WXMP_TITLE);
msg.setMessageTime(new Date());
msg.setGridId("*");
if (ActConstant.ACT_USER_STATUS_PASSED.equals(type)) {
msg.setMessageContent(String.format(ActMessageConstant.AUDIT_PASSED, actInfo.getTitle()));
} else if (ActConstant.ACT_USER_STATUS_REFUSED.equals(type)) {
msg.setMessageContent(String.format(ActMessageConstant.AUDIT_REFUSED, actInfo.getTitle(), actUserRelationEntity.getFailureReason()));
}
list.add(msg);
logger.info("活动报名审核,开始推送微信订阅消息");
Result result = epmetMessageOpenFeignClient.sendWxSubscribeMessage(list);
if (result.success()) {
logger.info("审核成功,已成功发送微信订阅消息");
} else {
logger.error("审核成功,发送微信订阅消息失败" + JSON.toJSONString(result));
}
} catch (Exception e) {
logger.error("审核结果,发送微信订阅消息异常", e.getMessage());
}
}
/**
* @return com.epmet.dto.result.work.HistoricalActInfo
* @param userId

21
epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/ProjectSendMessageService.java

@ -0,0 +1,21 @@
package com.epmet.service;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.ProjectDTO;
import com.epmet.dto.extract.form.ExtractOriginFormDTO;
/**
* @author zhaoqifeng
* @dscription
* @date 2020/10/26 15:19
*/
public interface ProjectSendMessageService {
/**
* 滞留提醒
* @author zhaoqifeng
* @date 2020/10/26 15:21
* @param formDTO
* @return com.epmet.commons.tools.utils.Result
*/
Result projectSendMessage(ExtractOriginFormDTO formDTO);
}

35
epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/ProjectSendMessageServiceImpl.java

@ -0,0 +1,35 @@
package com.epmet.service.impl;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.ProjectDTO;
import com.epmet.dto.extract.form.ExtractOriginFormDTO;
import com.epmet.feign.GovProjectOpenFeignClient;
import com.epmet.service.ProjectSendMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author zhaoqifeng
* @dscription
* @date 2020/10/26 15:22
*/
@Service
public class ProjectSendMessageServiceImpl implements ProjectSendMessageService {
@Autowired
private GovProjectOpenFeignClient govProjectOpenFeignClient;
/**
* 滞留提醒
*
* @param formDTO
* @return com.epmet.commons.tools.utils.Result
* @author zhaoqifeng
* @date 2020/10/26 15:21
*/
@Override
public Result projectSendMessage(ExtractOriginFormDTO formDTO) {
ProjectDTO projectDTO = new ProjectDTO();
projectDTO.setCustomerId(formDTO.getCustomerId());
return govProjectOpenFeignClient.sendMessageJob(projectDTO);
}
}

43
epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/ProjectSendMessageTask.java

@ -0,0 +1,43 @@
package com.epmet.task;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.extract.form.ExtractOriginFormDTO;
import com.epmet.service.ProjectSendMessageService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @author zhaoqifeng
* @dscription
* @date 2020/10/26 15:26
*/
@Component("projectSendMessageTask")
public class ProjectSendMessageTask implements ITask {
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private ProjectSendMessageService projectSendMessageService;
/**
* 执行定时任务接口
*
* @param params 参数多参数使用JSON数据
*/
@Override
public void run(String params) {
logger.info("ProjectSendMessageTask定时任务正在执行,参数为:{}", params);
ExtractOriginFormDTO formDTO = new ExtractOriginFormDTO();
if (StringUtils.isNotBlank(params)) {
formDTO = JSON.parseObject(params, ExtractOriginFormDTO.class);
}
Result result = projectSendMessageService.projectSendMessage(formDTO);
if (result.success()) {
logger.info("ProjectSendMessageTask定时任务执行成功");
} else {
logger.error("ProjectSendMessageTask定时任务执行失败:" + result.getMsg());
}
}
}

7
epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/WxMsgTemplateSubscribeStatus.java

@ -0,0 +1,7 @@
package com.epmet.constant;
public interface WxMsgTemplateSubscribeStatus {
//wx订阅状态 订阅状态(订阅:subscribe 取消订阅:unsubscribe)
String SUBSCRIBE = "subscribe";
String UNSUBSCRIBE = "unsubscribe";
}

7
epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/UserMessageDTO.java

@ -59,6 +59,11 @@ public class UserMessageDTO implements Serializable {
*/
private String app;
/**
* 调用者
*/
private String referer;
/**
* 消息标题
*/
@ -104,4 +109,4 @@ public class UserMessageDTO implements Serializable {
*/
private Date updatedTime;
}
}

9
epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/WxmpMsgSendRecordDTO.java

@ -42,6 +42,10 @@ public class WxmpMsgSendRecordDTO implements Serializable {
* 客户Id 客户Id
*/
private String customerId;
/**
* 网格Id居民端跟网格有关的则有值工作端以及一些居民端和网格没关的存*
*/
private String gridId;
/**
* 所属端类型 居民端:resi 工作端:work
@ -93,6 +97,11 @@ public class WxmpMsgSendRecordDTO implements Serializable {
*/
private String reason;
/**
* 调用方
*/
private String referer;
/**
* 删除标识
*/

2
epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/WxmpTemplateMsgSubscribeStatusDTO.java

@ -103,4 +103,6 @@ public class WxmpTemplateMsgSubscribeStatusDTO implements Serializable {
*/
private Date updatedTime;
private Date templateId;
}

32
epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/ActivationSubscribeFormDTO.java

@ -0,0 +1,32 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* @Description 居民端工作端-重新激活授权页-接口入参
* @author sun
*/
@Data
public class ActivationSubscribeFormDTO {
@NotBlank(message = "客户id不能为空", groups = { UpdateWxSubscribeInfoGroup.class })
private String customerId;
@NotBlank(message = "客户端类型不能为空", groups = { UpdateWxSubscribeInfoGroup.class })
private String clientType;
@NotBlank(message = "模板ID不能为空", groups = { UpdateWxSubscribeInfoGroup.class })
private String templateId;
@NotBlank(message = "'是否总是允许'选项不能为空", groups = { UpdateWxSubscribeInfoGroup.class })
private String alwaysVisit;
/**
* token中用户Id
*/
private String userId;
/**
* 用户对应的openId(居民端一对一工作端一对多)
*/
private String openId;
public interface UpdateWxSubscribeInfoGroup {}
}

5
epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/UserMessageFormDTO.java

@ -56,4 +56,9 @@ public class UserMessageFormDTO implements Serializable {
*/
@NotBlank(message = "readFlag不能为空")
private String readFlag;
/**
* 调用者
*/
private String referer;
}

24
epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/WxMsgAuthInfoFormDTO.java

@ -8,17 +8,35 @@ import javax.validation.constraints.NotBlank;
public class WxMsgAuthInfoFormDTO {
public interface SaveSysAuthInfoGroup {}
public interface GetAuthInfoGroup {}
public interface SaveWxSubscribeInfoGroup {}
@NotBlank(message = "客户id不能为空", groups = { SaveSysAuthInfoGroup.class })
@NotBlank(message = "客户id不能为空", groups = { SaveSysAuthInfoGroup.class, GetAuthInfoGroup.class, SaveWxSubscribeInfoGroup.class })
private String customerId;
@NotBlank(message = "客户端类型不能为空", groups = { SaveSysAuthInfoGroup.class })
@NotBlank(message = "客户端类型不能为空", groups = { SaveSysAuthInfoGroup.class, GetAuthInfoGroup.class, SaveWxSubscribeInfoGroup.class })
private String clientType;
@NotBlank(message = "是否总是字段不能为空", groups = { SaveSysAuthInfoGroup.class })
@NotBlank(message = "'是否总是允许'选项不能为空", groups = { SaveSysAuthInfoGroup.class })
private String alwaysVisit;
@NotBlank(message = "是否去订阅字段不能为空", groups = { SaveSysAuthInfoGroup.class })
private String subscribeStatus;
@NotBlank(message = "模板ID不能为空", groups = { SaveWxSubscribeInfoGroup.class, GetAuthInfoGroup.class, SaveSysAuthInfoGroup.class })
private String templateId;
@NotBlank(message = "微信'是否总是允许'选项不能为空", groups = { SaveWxSubscribeInfoGroup.class })
private String wxAlwaysVisit;
@NotBlank(message = "微信'是否订阅字段不能为空'", groups = { SaveWxSubscribeInfoGroup.class })
private String wxSubscribeStatus;
@NotBlank(message = "动作类型不能为空", groups = { SaveWxSubscribeInfoGroup.class })
private String behaviorType;
}

16
epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/WxSubscribeMessageFormDTO.java

@ -48,4 +48,20 @@ public class WxSubscribeMessageFormDTO implements Serializable {
@NotBlank(message = "消息内容不能为空")
private String messageContent;
/**
* 消息时间
*/
@NotNull(message = "消息时间不能为空")
private Date messageTime;
/**
* 网格id-居民端用
*/
private String gridId;
/**
* 调用方
*/
private String referer;
}

72
epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/WxmpMessagePushFormDTO.java

@ -0,0 +1,72 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
/**
* @description: 微信订阅消息FormDTO
* @author: liushaowen
* @date: 2020/10/21 14:29
*/
@Data
public class WxmpMessagePushFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 客户id
*/
@NotBlank(message = "客户id不能为空")
private String customerId;
/**
* 客户端类型 居民端:resi 工作端:work
*/
@NotBlank(message = "客户端类型不能为空")
private String app;
/**
* 接收者用户 userId
*/
@NotBlank(message = "接收用户id不能为空")
private String userId;
/**
* 行为类型(存title字段的中间值) 入组申请党员认证等
*/
@NotBlank(message = "行为类型不能为空")
private String title;
/**
* 消息内容
*/
@NotBlank(message = "消息内容不能为空")
private String messageContent;
/**
* 网格id-居民端用
*/
@NotBlank(message = "网格id不能为空")
private String gridId;
/**
* 已读标记
*/
@NotBlank(message = "已读标记不能为空")
private String readFlag;
/**
* 调用方
*/
@NotBlank(message = "调用方不能为空")
private String referer;
/**
* 推送微信订阅Flag
*/
@NotBlank(message = "是否推送订阅Flag不能为空")
private String pushWxmpFlag;
}

5
epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/result/WxMsgAuthInfoResultDTO.java

@ -38,4 +38,9 @@ public class WxMsgAuthInfoResultDTO {
* wx订阅状态 订阅状态(订阅:subscribe 取消订阅:unsubscribe)
*/
private String wxSubscribeStatus;
/**
* 微信openId
*/
private String wxOpenId;
}

29
epmet-module/epmet-message/epmet-message-server/pom.xml

@ -25,6 +25,11 @@
<artifactId>epmet-message-client</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-user-client</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-admin-client</artifactId>
@ -160,6 +165,12 @@
<nacos.ip/>
<spring.flyway.enabled>false</spring.flyway.enabled>
<!--线程池配置-->
<thread.pool.core-pool-size>5</thread.pool.core-pool-size>
<thread.pool.max-pool-size>8</thread.pool.max-pool-size>
<thread.pool.queue-capacity>10</thread.pool.queue-capacity>
<thread.pool.keep-alive>30</thread.pool.keep-alive>
</properties>
</profile>
<profile>
@ -192,6 +203,12 @@
<nacos.ip/>
<spring.flyway.enabled>false</spring.flyway.enabled>
<!--线程池配置-->
<thread.pool.core-pool-size>5</thread.pool.core-pool-size>
<thread.pool.max-pool-size>8</thread.pool.max-pool-size>
<thread.pool.queue-capacity>10</thread.pool.queue-capacity>
<thread.pool.keep-alive>30</thread.pool.keep-alive>
</properties>
</profile>
<profile>
@ -224,6 +241,12 @@
<nacos.ip/>
<spring.flyway.enabled>true</spring.flyway.enabled>
<!--线程池配置-->
<thread.pool.core-pool-size>5</thread.pool.core-pool-size>
<thread.pool.max-pool-size>8</thread.pool.max-pool-size>
<thread.pool.queue-capacity>10</thread.pool.queue-capacity>
<thread.pool.keep-alive>30</thread.pool.keep-alive>
</properties>
</profile>
<profile>
@ -253,6 +276,12 @@
<nacos.ip/>
<spring.flyway.enabled>true</spring.flyway.enabled>
<!--线程池配置-->
<thread.pool.core-pool-size>5</thread.pool.core-pool-size>
<thread.pool.max-pool-size>8</thread.pool.max-pool-size>
<thread.pool.queue-capacity>10</thread.pool.queue-capacity>
<thread.pool.keep-alive>30</thread.pool.keep-alive>
</properties>
</profile>
</profiles>

49
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/config/AsyncConfig.java

@ -0,0 +1,49 @@
package com.epmet.config;
import com.epmet.properties.ThreadProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
/**
* 线程池配置类
*/
@Configuration
@EnableConfigurationProperties(ThreadProperties.class)
@EnableAsync
public class AsyncConfig {
@Autowired
private ThreadProperties threadProperties;
@Bean
public Executor executor() {
ThreadProperties.ThreadPoolProperties threadPoolProps = threadProperties.getThreadPool();
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(threadPoolProps.getCorePoolSize());
executor.setMaxPoolSize(threadPoolProps.getMaxPoolSize());
executor.setQueueCapacity(threadPoolProps.getQueueCapacity());
executor.setThreadNamePrefix("epmet-message-");
// rejection-policy:当pool已经达到max size的时候,如何处理新任务
// CALLER_RUNS:不在新线程中执行任务,而是由调用者所在的线程来执行
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); //对拒绝task的处理策略
executor.setKeepAliveSeconds(threadPoolProps.getKeepAlive());
executor.initialize();
return executor;
}
@Bean
public ExecutorService executorService() {
ThreadPoolTaskExecutor executor = (ThreadPoolTaskExecutor) executor();
return executor.getThreadPoolExecutor();
}
}

11
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/constant/ExtConstant.java

@ -0,0 +1,11 @@
package com.epmet.constant;
public interface ExtConstant {
String APP_RESI = "resi";
String APP_WORK = "work";
String APP_GOV = "gov";
String PUSH_WXMP = "1";
}

18
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/constant/WxmpMessageConstant.java

@ -22,7 +22,9 @@ public interface WxmpMessageConstant {
String RESI = "resi";
String WORK = "work";
String GOV_REDIS = "work";
String GOV_DB = "gov";
String ACCESS_TOKEN = "access_token";
@ -30,17 +32,21 @@ public interface WxmpMessageConstant {
String TEMPLATE_ID = "template_id";
String TEMPLATE_TYPE = "1832";
String PAGE = "page";
String TITLE = "title";
String PAGE_URL = "/subpages/mine/pages/message/skip";
String TITLE = "thing5";
int TITLE_LIMIT = 20;
String MESSAGE_CONTENT = "message_content";
String MESSAGE_CONTENT = "thing4";
int MESSAGE_CONTENT_LIMIT = 20;
String MESSAGE_TIME = "message_time";
String MESSAGE_TIME = "date2";
String DATA = "data";
@ -50,10 +56,6 @@ public interface WxmpMessageConstant {
String ERROR = "error";
String PAGE_RESI = "";
String PAGE_WORK = "";
String STATE_DEV = "developer";
String STATE_TEST = "trial";

76
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/WxmpMessageController.java

@ -17,14 +17,19 @@
package com.epmet.controller;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.security.user.LoginUserUtil;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.ActivationSubscribeFormDTO;
import com.epmet.dto.form.GetTemplateListFormDTO;
import com.epmet.dto.form.WxMsgAuthInfoFormDTO;
import com.epmet.dto.form.WxSubscribeMessageFormDTO;
import com.epmet.dto.result.GetTemplateListResultDTO;
import com.epmet.dto.result.WxMsgAuthInfoResultDTO;
import com.epmet.service.WxmpMessageService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@ -32,6 +37,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.concurrent.ExecutorService;
/**
@ -44,12 +50,17 @@ import java.util.List;
@RequestMapping("wxmpmessage")
public class WxmpMessageController {
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private WxmpMessageService wxmpMessageService;
@Autowired
private LoginUserUtil loginUserUtil;
@Autowired
private ExecutorService executorService;
/**
* @Description 保存系统自身的弹框授权信息
* @return com.epmet.commons.tools.utils.Result
@ -64,17 +75,28 @@ public class WxmpMessageController {
String clientType = form.getClientType();
String customerId = form.getCustomerId();
String subscribeStatus = form.getSubscribeStatus();
String templateId = form.getTemplateId();
wxmpMessageService.saveSysAuthorizeInfo(customerId, clientType, alwaysVisit, subscribeStatus, loginUserUtil.getLoginUserId());
wxmpMessageService.saveSysAuthorizeInfo(customerId, clientType, alwaysVisit, subscribeStatus, loginUserUtil.getLoginUserId(), templateId);
return new Result();
}
@PostMapping("sendwxsubscribemessage")
public Result sendWxSubscribeMessage(@RequestBody List<WxSubscribeMessageFormDTO> msgList){
for (WxSubscribeMessageFormDTO wxSubscribeMessageFormDTO : msgList) {
ValidatorUtils.validateEntity(wxSubscribeMessageFormDTO);
}
wxmpMessageService.sendWxSubscribeMessage(msgList);
executorService.execute(() -> {
try {
long startTs = System.currentTimeMillis();
wxmpMessageService.sendWxSubscribeMessage(msgList);
long endTs = System.currentTimeMillis();
logger.info("异步发送消息成功,执行时长:{}", endTs - startTs);
} catch (Exception e) {
logger.error("异步发送消息失败,错误信息:{}", ExceptionUtils.getErrorStackTrace(e));
}
});
return new Result();
}
@ -89,4 +111,52 @@ public class WxmpMessageController {
return new Result<List<GetTemplateListResultDTO>>().ok(wxmpMessageService.templateList(formDTO));
}
}
/**
* @Description 查询用户授权信息
* @return
* @author wxz
* @date 2020.10.21 18:15
*/
@PostMapping("get-authorizeinfo")
public Result getAuthorizationInfo(@RequestBody WxMsgAuthInfoFormDTO form) {
ValidatorUtils.validateEntity(form, WxMsgAuthInfoFormDTO.GetAuthInfoGroup.class);
WxMsgAuthInfoResultDTO authorizationInfo = wxmpMessageService.getAuthorizationInfo(
form.getCustomerId(), form.getClientType(),
loginUserUtil.getLoginUserId(), form.getTemplateId());
return new Result().ok(authorizationInfo);
}
/**
* 保存微信订阅的授权信息
* @param form
* @return
*/
@PostMapping("save-wxsubscribe")
public Result saveWxSubscribe(@RequestBody WxMsgAuthInfoFormDTO form) {
ValidatorUtils.validateEntity(form, WxMsgAuthInfoFormDTO.SaveWxSubscribeInfoGroup.class);
String customerId = form.getCustomerId();
String clientType = form.getClientType();
String templateId = form.getTemplateId();
String wxAlwaysVisit = form.getWxAlwaysVisit();
String wxSubscribeStatus = form.getWxSubscribeStatus();
String behaviorType = form.getBehaviorType();
wxmpMessageService.saveWxSubscribe(customerId, clientType, templateId, wxAlwaysVisit, wxSubscribeStatus, behaviorType, loginUserUtil.getLoginUserId());
return new Result();
}
/**
* @return
* @Description 居民端工作端-重新激活授权页
* @author sun
*/
@PostMapping("activationsubscribe")
public Result activationSubscribe(@RequestBody ActivationSubscribeFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, ActivationSubscribeFormDTO.UpdateWxSubscribeInfoGroup.class);
formDTO.setUserId(loginUserUtil.getLoginUserId());
wxmpMessageService.activationSubscribe(formDTO);
return new Result();
}
}

69
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/WxmpMessageExtController.java

@ -0,0 +1,69 @@
package com.epmet.controller;
import com.epmet.commons.tools.constant.AppClientConstant;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.WxmpMessagePushFormDTO;
import com.epmet.dto.form.WxmpTemplateListFormDTO;
import com.epmet.dto.result.WxmpTemplateListResultDTO;
import com.epmet.service.WxmpMessageExtService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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;
import java.util.List;
import java.util.concurrent.ExecutorService;
/**
* @description: 外部调用微信订阅controller
* @author: liushaowen
* @date: 2020/11/2 14:51
*/
@RestController
@RequestMapping("template")
public class WxmpMessageExtController {
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private WxmpMessageExtService wxmpMessageExtService;
@Autowired
private ExecutorService executorService;
@PostMapping("msgpush")
public Result wxmpMsgPush(@RequestBody List<WxmpMessagePushFormDTO> dtos){
for (WxmpMessagePushFormDTO dto : dtos) {
ValidatorUtils.validateEntity(dto);
}
executorService.execute(() -> {
try {
long startTs = System.currentTimeMillis();
wxmpMessageExtService.pushWxmpMessage(dtos);
long endTs = System.currentTimeMillis();
logger.info("异步发送消息成功,执行时长:{}", endTs - startTs);
} catch (Exception e) {
logger.error("异步发送消息失败,错误信息:{}", ExceptionUtils.getErrorStackTrace(e));
}
});
return new Result();
}
/**
* @return
* @Description (外挂)消息-获取订阅消息模板列表
* @author sun
*/
@PostMapping("wxmptemplatelist")
public Result<List<WxmpTemplateListResultDTO>> wxmpTemplateList(@RequestBody WxmpTemplateListFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, WxmpTemplateListFormDTO.AddUserInternalGroup.class);
if (!AppClientConstant.APP_RESI.equals(formDTO.getClientType()) && !AppClientConstant.APP_WORK.equals(formDTO.getClientType())) {
return new Result<List<WxmpTemplateListResultDTO>>().error("参数错误,clientType值类型错误!");
}
return new Result<List<WxmpTemplateListResultDTO>>().ok(wxmpMessageExtService.wxmpTemplateList(formDTO));
}
}

36
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/WxmpResiUserSubscribeDao.java

@ -36,11 +36,12 @@ public interface WxmpResiUserSubscribeDao extends BaseDao<WxmpResiUserSubscribeE
* @param openId
* @param templateId
* @param customerId
* @param userId
* @return java.lang.Integer
* @Author liushaowen
* @Date 2020/10/22 9:30
*/
Integer getResiSubscribeInfo(@Param("openId") String openId, @Param("templateId") String templateId, @Param("customerId") String customerId);
Integer getResiSubscribeInfo(@Param("openId") String openId, @Param("templateId") String templateId, @Param("customerId") String customerId,@Param("userId") String userId);
/**
* @Description 减少订阅条数
@ -52,7 +53,7 @@ public interface WxmpResiUserSubscribeDao extends BaseDao<WxmpResiUserSubscribeE
* @Author liushaowen
* @Date 2020/10/22 9:38
*/
int decreaseResiSubscribeCount(@Param("openId") String openId, @Param("templateId") String templateId, @Param("customerId") String customerId,@Param("num") int i);
int decreaseResiSubscribeCount(@Param("openId") String openId, @Param("templateId") String templateId, @Param("customerId") String customerId,@Param("num") int i,@Param("userId") String userId);
/**
* @Description 清空订阅条数修改订阅状态
@ -63,15 +64,24 @@ public interface WxmpResiUserSubscribeDao extends BaseDao<WxmpResiUserSubscribeE
* @Author liushaowen
* @Date 2020/10/22 13:23
*/
int clearResiSubscribeCount(@Param("openId") String openId, @Param("templateId") String templateId, @Param("customerId") String customerId);
/**
* @Description 获取模板id
* @param openId
* @param templateId
* @param customerId
* @return java.lang.Integer
* @Author liushaowen
* @Date 2020/10/23 10:53
*/
String getResiSubscribeTemplateId(@Param("openId") String openId, @Param("templateId") String templateId, @Param("customerId") String customerId);
int clearResiSubscribeCount(@Param("openId") String openId,
@Param("templateId") String templateId,
@Param("customerId") String customerId,
@Param("userId") String userId);
WxmpResiUserSubscribeEntity getWxResiSubscribe(@Param("userId") String userId,
@Param("customerId") String customerId,
@Param("templateId") String templateId,
@Param("openId") String openId);
void incrSubscribeCount(@Param("incr") int incr,
@Param("userId") String userId,
@Param("customerId") String customerId,
@Param("templateId")String templateId,
@Param("resiOpenId") String resiOpenId);
void unSubscribe(@Param("userId") String userId,
@Param("customerId") String customerId,
@Param("templateId") String templateId,
@Param("resiOpenId") String resiOpenId);
}

21
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/WxmpTemplateMsgSubscribeStatusDao.java

@ -18,6 +18,7 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.form.ActivationSubscribeFormDTO;
import com.epmet.dto.result.WxMsgAuthInfoResultDTO;
import com.epmet.entity.WxmpTemplateMsgSubscribeStatusEntity;
import org.apache.ibatis.annotations.Mapper;
@ -33,10 +34,22 @@ import org.apache.ibatis.annotations.Param;
public interface WxmpTemplateMsgSubscribeStatusDao extends BaseDao<WxmpTemplateMsgSubscribeStatusEntity> {
WxMsgAuthInfoResultDTO getUserSubscribeStatusDTO(@Param("userId") String userId,
@Param("customerId") String customerId,
@Param("clientType") String clientType);
@Param("customerId") String customerId,
@Param("clientType") String clientType,
@Param("templateId") String templateId,
@Param("openId") String openId);
WxmpTemplateMsgSubscribeStatusEntity getUserSubscribeStatusEntity(@Param("userId") String userId,
@Param("customerId") String customerId,
@Param("clientType") String clientType);
@Param("customerId") String customerId,
@Param("clientType") String clientType,
@Param("templateId") String templateId,
@Param("openId") String openId);
/**
* @return
* @Description 更新用户授权信息
*
* @author sun
*/
int updateUserSubscribe(ActivationSubscribeFormDTO formDTO);
}

33
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/WxmpWorkUserSubscribeDao.java

@ -36,11 +36,12 @@ public interface WxmpWorkUserSubscribeDao extends BaseDao<WxmpWorkUserSubscribeE
* @param openId
* @param templateId
* @param customerId
* @param userId
* @return java.lang.Integer
* @Author liushaowen
* @Date 2020/10/22 9:31
*/
Integer getWorkSubscribeInfo(@Param("openId") String openId, @Param("templateId") String templateId, @Param("customerId") String customerId);
Integer getWorkSubscribeInfo(@Param("openId") String openId, @Param("templateId") String templateId, @Param("customerId") String customerId,@Param("userId") String userId);
/**
* @Description 减少订阅条数
@ -52,7 +53,7 @@ public interface WxmpWorkUserSubscribeDao extends BaseDao<WxmpWorkUserSubscribeE
* @Author liushaowen
* @Date 2020/10/22 9:38
*/
int decreaseWorkSubscribeCount(@Param("openId") String openId, @Param("templateId") String templateId, @Param("customerId") String customerId, @Param("num") int i);
int decreaseWorkSubscribeCount(@Param("openId") String openId, @Param("templateId") String templateId, @Param("customerId") String customerId, @Param("num") int decr,@Param("userId") String userId);
/**
* @Description 清空订阅数修改订阅状态
@ -63,16 +64,22 @@ public interface WxmpWorkUserSubscribeDao extends BaseDao<WxmpWorkUserSubscribeE
* @Author liushaowen
* @Date 2020/10/22 13:22
*/
int clearWorkSubscribeCount(@Param("openId") String openId, @Param("templateId") String templateId, @Param("customerId") String customerId);
int clearWorkSubscribeCount(@Param("openId") String openId, @Param("templateId") String templateId, @Param("customerId") String customerId,@Param("userId") String userId);
/**
* @Description 获取模板id
* @param openId
* @param templateId
* @param customerId
* @return java.lang.String
* @Author liushaowen
* @Date 2020/10/23 10:54
*/
String getWorkSubscribeTemplateId(@Param("openId") String openId, @Param("templateId") String templateId, @Param("customerId") String customerId);
WxmpWorkUserSubscribeEntity getWxWorkSubscribe(@Param("userId") String userId,
@Param("customerId") String customerId,
@Param("templateId") String templateId,
@Param("openId") String openId
);
void incrSubscribeCount(@Param("incr") int incr,
@Param("userId") String userId,
@Param("customerId") String customerId,
@Param("templateId") String templateId,
@Param("openId") String workOpenId);
void unSubscribe(@Param("userId") String userId,
@Param("customerId")String customerId,
@Param("templateId")String templateId,
@Param("workOpenId")String workOpenId);
}

5
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/UserMessageEntity.java

@ -70,4 +70,9 @@ public class UserMessageEntity extends BaseEpmetEntity {
*/
private String readFlag;
/**
* 调用者
*/
private String referer;
}

10
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/WxmpMsgSendRecordEntity.java

@ -43,6 +43,11 @@ public class WxmpMsgSendRecordEntity extends BaseEpmetEntity {
*/
private String customerId;
/**
* 网格Id居民端跟网格有关的则有值工作端以及一些居民端和网格没关的存*
*/
private String gridId;
/**
* 所属端类型 居民端:resi 工作端:work
*/
@ -93,4 +98,9 @@ public class WxmpMsgSendRecordEntity extends BaseEpmetEntity {
*/
private String reason;
/**
* 调用方
*/
private String referer;
}

8
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/WxmpTemplateMsgSubscribeStatusEntity.java

@ -73,4 +73,12 @@ public class WxmpTemplateMsgSubscribeStatusEntity extends BaseEpmetEntity {
*/
private String wxSubscribeStatus;
/**模板id*/
private String templateId;
/**
* 微信openId
*/
private String wxOpenId;
}

5
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/excel/UserMessageExcel.java

@ -49,6 +49,9 @@ public class UserMessageExcel {
@Excel(name = "消息标题")
private String title;
@Excel(name = "调用者")
private String referer;
@Excel(name = "消息通知内容")
private String messageContent;
@ -74,4 +77,4 @@ public class UserMessageExcel {
private Date updatedTime;
}
}

8
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/excel/WxmpMsgSendRecordExcel.java

@ -37,6 +37,9 @@ public class WxmpMsgSendRecordExcel {
@Excel(name = "客户Id 客户Id")
private String customerId;
@Excel(name = "网格Id")
private String gridId;
@Excel(name = "所属端类型 居民端:resi 工作端:work")
private String clientType;
@ -67,6 +70,9 @@ public class WxmpMsgSendRecordExcel {
@Excel(name = "发送失败的原因")
private String reason;
@Excel(name = "调用者")
private String referer;
@Excel(name = "删除标识")
private Integer delFlag;
@ -86,4 +92,4 @@ public class WxmpMsgSendRecordExcel {
private Date updatedTime;
}
}

25
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/properties/ThreadProperties.java

@ -0,0 +1,25 @@
package com.epmet.properties;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* 线程池属性类
*/
@ConfigurationProperties(prefix = "thread")
@Data
public class ThreadProperties {
private ThreadPoolProperties threadPool;
@Data
public static class ThreadPoolProperties {
private int corePoolSize;
private int maxPoolSize;
private int queueCapacity;
private int keepAlive;
public ThreadPoolProperties() {
}
}
}

4
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/redis/WxmpMessageRedis.java

@ -2,6 +2,8 @@ package com.epmet.redis;
import com.epmet.commons.tools.redis.RedisUtils;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -15,6 +17,7 @@ import java.util.Map;
@Slf4j
@Component
public class WxmpMessageRedis {
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private RedisUtils redisUtils;
@ -24,6 +27,7 @@ public class WxmpMessageRedis {
* @author zxc
*/
public Map<String,Object> getAuthorizerRefreshToken(String key){
logger.info("发送微信订阅消息,获取accesstoken的key值:" + key);
Map<String, Object> result = redisUtils.hGetAll("epmet:wechartthird:authorizerrefreshtoken:" + key);
return result;
}

20
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/WxmpMessageExtService.java

@ -0,0 +1,20 @@
package com.epmet.service;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.WxmpMessagePushFormDTO;
import com.epmet.dto.form.WxmpTemplateListFormDTO;
import com.epmet.dto.result.WxmpTemplateListResultDTO;
import java.util.List;
public interface WxmpMessageExtService {
Result pushWxmpMessage(List<WxmpMessagePushFormDTO> dto);
/**
* @return
* @Description 消息-获取订阅消息模板列表
* @author sun
*/
List<WxmpTemplateListResultDTO> wxmpTemplateList(WxmpTemplateListFormDTO formDTO);
}

16
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/WxmpMessageService.java

@ -17,9 +17,11 @@
package com.epmet.service;
import com.epmet.dto.form.ActivationSubscribeFormDTO;
import com.epmet.dto.form.GetTemplateListFormDTO;
import com.epmet.dto.form.WxSubscribeMessageFormDTO;
import com.epmet.dto.result.GetTemplateListResultDTO;
import com.epmet.dto.result.WxMsgAuthInfoResultDTO;
import java.util.List;
@ -31,7 +33,12 @@ import java.util.List;
*/
public interface WxmpMessageService {
void saveSysAuthorizeInfo(String customerId, String clientType, String alwaysVisit, String subscribeStatus, String userId);
void saveSysAuthorizeInfo(String customerId, String clientType, String alwaysVisit, String subscribeStatus, String userId, String templateId);
WxMsgAuthInfoResultDTO getAuthorizationInfo(String customerId, String clientType, String loginUserId, String templateId);
void saveWxSubscribe(String customerId, String clientType, String templateId, String wxAlwaysVisit, String wxSubscribeStatus,
String behaviorType, String userId);
/**
* @Description 发送订阅消息
@ -48,4 +55,11 @@ public interface WxmpMessageService {
* @author sun
*/
List<GetTemplateListResultDTO> templateList(GetTemplateListFormDTO formDTO);
/**
* @return
* @Description 居民端工作端-重新激活授权页
* @author sun
*/
void activationSubscribe(ActivationSubscribeFormDTO formDTO);
}

83
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/WxmpMessageExtServiceImpl.java

@ -0,0 +1,83 @@
package com.epmet.service.impl;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.ExtConstant;
import com.epmet.dto.form.*;
import com.epmet.dto.result.CustomerTemplateListResultDTO;
import com.epmet.dto.result.WxmpTemplateListResultDTO;
import com.epmet.service.UserMessageService;
import com.epmet.service.WxmpMessageExtService;
import com.epmet.service.WxmpMessageService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* @description:
* @author: liushaowen
* @date: 2020/11/2 14:54
*/
@Service
public class WxmpMessageExtServiceImpl implements WxmpMessageExtService {
@Autowired
private WxmpMessageService wxmpMessageService;
@Autowired
private UserMessageService userMessageService;
@Autowired
private WxmpMessageServiceImpl wxmpMessageServiceImpl;
@Override
public Result pushWxmpMessage(List<WxmpMessagePushFormDTO> dtos) {
List<WxSubscribeMessageFormDTO> wxmpMsgList = new ArrayList<>();
List<UserMessageFormDTO> userMsgList = new ArrayList<>();
for (WxmpMessagePushFormDTO dto : dtos) {
//站内信
UserMessageFormDTO userMessageFormDTO = new UserMessageFormDTO();
BeanUtils.copyProperties(dto,userMessageFormDTO);
userMessageFormDTO.setTitle("您有一条"+dto.getTitle());
userMsgList.add(userMessageFormDTO);
//如果推送微信订阅flag为"1",推送微信订阅
if (ExtConstant.PUSH_WXMP.equals(dto.getPushWxmpFlag())){
WxSubscribeMessageFormDTO wxSubscribeMessageFormDTO = new WxSubscribeMessageFormDTO();
BeanUtils.copyProperties(dto,wxSubscribeMessageFormDTO);
//设置ClientType
if (ExtConstant.APP_RESI.equals(dto.getApp())){
wxSubscribeMessageFormDTO.setClientType(ExtConstant.APP_RESI);
}
if (ExtConstant.APP_GOV.equals(dto.getApp())){
wxSubscribeMessageFormDTO.setClientType(ExtConstant.APP_WORK);
}
wxSubscribeMessageFormDTO.setBehaviorType(dto.getTitle());
wxSubscribeMessageFormDTO.setMessageTime(new Date());
wxmpMsgList.add(wxSubscribeMessageFormDTO);
}
}
wxmpMessageService.sendWxSubscribeMessage(wxmpMsgList);
return userMessageService.saveUserMessageList(userMsgList);
}
/**
* @return
* @Description 消息-获取订阅消息模板列表
* @author sun
*/
@Override
public List<WxmpTemplateListResultDTO> wxmpTemplateList(WxmpTemplateListFormDTO formDTO) {
List<WxmpTemplateListResultDTO> resultList = new ArrayList<>();
CustomerTemplateListFormDTO dto = ConvertUtils.sourceToTarget(formDTO, CustomerTemplateListFormDTO.class);
List<CustomerTemplateListResultDTO> list = wxmpMessageServiceImpl.customerTemplateList(dto);
list.forEach(l->{
if(formDTO.getClientType().equals(l.getClientType())){
WxmpTemplateListResultDTO result = ConvertUtils.sourceToTarget(l, WxmpTemplateListResultDTO.class);
resultList.add(result);
}
});
return resultList;
}
}

494
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/WxmpMessageServiceImpl.java

@ -19,25 +19,22 @@ package com.epmet.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.epmet.commons.tools.constant.AppClientConstant;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.enums.EnvEnum;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.exception.ValidateException;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.constant.WxMsgTemplateSubscribeStatus;
import com.epmet.constant.WxmpMessageConstant;
import com.epmet.dao.WxmpResiUserSubscribeDao;
import com.epmet.dao.WxmpTemplateMsgSubscribeStatusDao;
import com.epmet.dao.WxmpUserSubscribeRecordDao;
import com.epmet.dao.WxmpWorkUserSubscribeDao;
import com.epmet.dto.form.GetTemplateListFormDTO;
import com.epmet.dto.form.StaffBasicInfoFormDTO;
import com.epmet.dto.form.UserBasicInfoFormDTO;
import com.epmet.dto.form.WxSubscribeMessageFormDTO;
import com.epmet.dto.result.GetTemplateListResultDTO;
import com.epmet.entity.WxmpMsgSendRecordEntity;
import com.epmet.entity.WxmpTemplateMsgSubscribeStatusEntity;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.entity.*;
import com.epmet.exception.WxSubscribeException;
import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.redis.WxmpMessageRedis;
@ -48,11 +45,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -85,6 +82,9 @@ public class WxmpMessageServiceImpl implements WxmpMessageService {
@Autowired
private WxmpMsgSendRecordService wxmpMsgSendRecordService;
@Autowired
private WxmpUserSubscribeRecordDao subscribeRecordDao;
/**
* @return void
* @Description 保存系统授权信息
@ -92,8 +92,18 @@ public class WxmpMessageServiceImpl implements WxmpMessageService {
* @date 2020.10.21 17:29
*/
@Override
public void saveSysAuthorizeInfo(String customerId, String clientType, String alwaysVisit, String subscribeStatus, String userId) {
WxmpTemplateMsgSubscribeStatusEntity userSubscribeStatusEntity = msgSubscribeStatusDao.getUserSubscribeStatusEntity(userId, customerId, clientType);
public void saveSysAuthorizeInfo(String customerId, String clientType, String alwaysVisit, String subscribeStatus, String userId, String templateId) {
String openId = null;
switch (clientType) {
case AppClientConstant.APP_GOV:
openId = getWorkOpenId(userId);
break;
case AppClientConstant.APP_RESI:
openId = getResiOpenId(userId);
break;
}
WxmpTemplateMsgSubscribeStatusEntity userSubscribeStatusEntity = msgSubscribeStatusDao.getUserSubscribeStatusEntity(userId, customerId, clientType, templateId, openId);
if (userSubscribeStatusEntity != null) {
userSubscribeStatusEntity.setAlwaysVisit(alwaysVisit);
userSubscribeStatusEntity.setSubscribeStatus(subscribeStatus);
@ -104,7 +114,9 @@ public class WxmpMessageServiceImpl implements WxmpMessageService {
userSubscribeStatusEntity = new WxmpTemplateMsgSubscribeStatusEntity();
userSubscribeStatusEntity.setCustomerId(customerId);
userSubscribeStatusEntity.setClientType(clientType);
userSubscribeStatusEntity.setTemplateId(templateId);
userSubscribeStatusEntity.setAlwaysVisit(alwaysVisit);
userSubscribeStatusEntity.setWxOpenId(openId);
userSubscribeStatusEntity.setSubscribeStatus(subscribeStatus);
userSubscribeStatusEntity.setUserId(userId);
msgSubscribeStatusDao.insert(userSubscribeStatusEntity);
@ -120,7 +132,17 @@ public class WxmpMessageServiceImpl implements WxmpMessageService {
@Override
public void sendWxSubscribeMessage(List<WxSubscribeMessageFormDTO> msgList) {
logger.info("待发送订阅消息数量:{}", msgList.size());
if (!(msgList.size() > NumConstant.ZERO)) {
throw new RenException("待发送消息不能为空");
}
int succecssCount = 0;
// 获取templateId
CustomerTemplateListFormDTO customerTemplateListFormDTO = new CustomerTemplateListFormDTO();
customerTemplateListFormDTO.setCustomerId(msgList.get(0).getCustomerId());
customerTemplateListFormDTO.setPublicId(WxmpMessageConstant.TEMPLATE_TYPE);
List<CustomerTemplateListResultDTO> customerTemplateListResultDTOS = customerTemplateList(customerTemplateListFormDTO);
// 获取AccessToken
Map<String,String> accessTokenMap = getAccessToken(msgList.get(0).getCustomerId());
for (WxSubscribeMessageFormDTO msg : msgList) {
try {
String userId = msg.getUserId();
@ -133,51 +155,54 @@ public class WxmpMessageServiceImpl implements WxmpMessageService {
if (WxmpMessageConstant.RESI.equals(clientType)) {
UserBasicInfoFormDTO userBasicInfoFormDTO = new UserBasicInfoFormDTO();
userBasicInfoFormDTO.setUserId(userId);
openId = epmetUserOpenFeignClient.getUserBasicInfo(userBasicInfoFormDTO).getData().getOpenId();
} else if (WxmpMessageConstant.WORK.equals(clientType)) {
Result<UserBasicInfo> userBasicInfo = epmetUserOpenFeignClient.getUserBasicInfo(userBasicInfoFormDTO);
if (userBasicInfo.getCode() != 0){
throw new Exception(userBasicInfo.getInternalMsg());
}else {
openId = userBasicInfo.getData().getOpenId();
}
} else if (WxmpMessageConstant.GOV_DB.equals(clientType)) {
StaffBasicInfoFormDTO staffBasicInfoFormDTO = new StaffBasicInfoFormDTO();
staffBasicInfoFormDTO.setStaffId(userId);
openId = epmetUserOpenFeignClient.getStaffBasicInfo(staffBasicInfoFormDTO).getData().getOpenId();
Result<StaffBasicInfo> staffBasicInfo = epmetUserOpenFeignClient.getStaffBasicInfo(staffBasicInfoFormDTO);;
if (staffBasicInfo.getCode() != 0){
throw new Exception(staffBasicInfo.getInternalMsg());
}else {
openId = staffBasicInfo.getData().getOpenId();
}
} else {
throw new WxSubscribeException("clientType有误", "", openId);
}
} catch (Exception e) {
throw new WxSubscribeException("连接User服务失败", "", "");
e.printStackTrace();
throw new WxSubscribeException("获取openId失败:" + e.getMessage(), "", "");
}
if (StringUtils.isBlank(openId)) {
throw new WxSubscribeException("openId获取失败", "", "");
throw new WxSubscribeException("该userId未查询到关联的openId", "", "");
}
//获取accessToken
StringBuilder key = new StringBuilder(msg.getCustomerId()).append(":").append(msg.getClientType());
Map<String, Object> authorizerRefreshToken = new HashMap<>();
try {
authorizerRefreshToken = wxmpMessageRedis.getAuthorizerRefreshToken(key.toString());
} catch (Exception e) {
throw new WxSubscribeException("连接缓存服务器失败", "", openId);
}
String accessToken = (String) authorizerRefreshToken.get(WxmpMessageConstant.AUTHORIZER_ACCESS_TOKEN);
if (StringUtils.isBlank(accessToken)) {
throw new WxSubscribeException("accessToken获取失败", "", openId);
}
//获取模板id
if (WxmpMessageConstant.RESI.equals(clientType)) {
templateId = wxmpResiUserSubscribeDao.getResiSubscribeTemplateId(openId, templateId, customerId);
} else if (WxmpMessageConstant.WORK.equals(clientType)) {
templateId = wxmpWorkUserSubscribeDao.getWorkSubscribeTemplateId(openId, templateId, customerId);
if (customerTemplateListResultDTOS.size() > NumConstant.ZERO) {
for (CustomerTemplateListResultDTO customerTemplateListResultDTO : customerTemplateListResultDTOS) {
if (WxmpMessageConstant.GOV_REDIS.equals(customerTemplateListResultDTO.getClientType())) {
customerTemplateListResultDTO.setClientType(WxmpMessageConstant.GOV_DB);
}
if (clientType.equals(customerTemplateListResultDTO.getClientType())) {
templateId = customerTemplateListResultDTO.getTemplateId();
}
}
} else {
throw new WxSubscribeException("获取模板id失败", "", openId);
}
if (StringUtils.isBlank(templateId)) {
throw new WxSubscribeException("获取模板id失败", "", openId);
}
//判断用户是否有次数
Integer count = null;
if (WxmpMessageConstant.RESI.equals(clientType)) {
count = wxmpResiUserSubscribeDao.getResiSubscribeInfo(openId, templateId, customerId);
} else if (WxmpMessageConstant.WORK.equals(clientType)) {
count = wxmpWorkUserSubscribeDao.getWorkSubscribeInfo(openId, templateId, customerId);
count = wxmpResiUserSubscribeDao.getResiSubscribeInfo(openId, templateId, customerId, userId);
} else if (WxmpMessageConstant.GOV_DB.equals(clientType)) {
count = wxmpWorkUserSubscribeDao.getWorkSubscribeInfo(openId, templateId, customerId, userId);
}
if (count == null) {
//用户未订阅
@ -187,6 +212,17 @@ public class WxmpMessageServiceImpl implements WxmpMessageService {
throw new WxSubscribeException("用户可用额度不足", templateId, openId);
}
//获取accessToken
String accessToken = null;
if (WxmpMessageConstant.RESI.equals(clientType)) {
accessToken = accessTokenMap.get("resiToken");
} else if (WxmpMessageConstant.GOV_DB.equals(clientType)) {
accessToken = accessTokenMap.get("govToken");
}
if (StringUtils.isBlank(accessToken)) {
throw new WxSubscribeException("accessToken获取失败"+accessTokenMap.get("errorMsg"), "", openId);
}
//发送消息
JSONObject jsonObject = new JSONObject();
JSONObject data = new JSONObject();
@ -194,16 +230,30 @@ public class WxmpMessageServiceImpl implements WxmpMessageService {
jsonObject.put(WxmpMessageConstant.ACCESS_TOKEN, accessToken);
jsonObject.put(WxmpMessageConstant.TOUSER, openId);
jsonObject.put(WxmpMessageConstant.TEMPLATE_ID, templateId);
data.put(WxmpMessageConstant.TITLE, new JSONObject().put("value", ("您有一条" + msg.getBehaviorType()).substring(0, WxmpMessageConstant.TITLE_LIMIT)));
data.put(WxmpMessageConstant.MESSAGE_CONTENT, new JSONObject().put("value", msg.getMessageContent().substring(0, WxmpMessageConstant.MESSAGE_CONTENT_LIMIT)));
data.put(WxmpMessageConstant.MESSAGE_TIME, new JSONObject().put("value", new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new Date())));
//标题
String title = "您有一条" + msg.getBehaviorType();
JSONObject titleJson = new JSONObject();
titleJson.put("value", title.length() > WxmpMessageConstant.TITLE_LIMIT ? title.substring(0, WxmpMessageConstant.TITLE_LIMIT) : title);
data.put(WxmpMessageConstant.TITLE, titleJson);
//内容
JSONObject contentJson = new JSONObject();
contentJson.put("value", msg.getMessageContent().length() > WxmpMessageConstant.MESSAGE_CONTENT_LIMIT ? msg.getMessageContent().substring(0, WxmpMessageConstant.MESSAGE_CONTENT_LIMIT) : msg.getMessageContent());
data.put(WxmpMessageConstant.MESSAGE_CONTENT, contentJson);
//时间
JSONObject timeJson = new JSONObject();
timeJson.put("value", new SimpleDateFormat("yyyy-MM-dd HH:mm").format(msg.getMessageTime()));
data.put(WxmpMessageConstant.MESSAGE_TIME, timeJson);
jsonObject.put(WxmpMessageConstant.DATA, data);
EnvEnum envEnum = EnvEnum.getCurrentEnv();
//选填项
if (WxmpMessageConstant.RESI.equals(clientType)) {
jsonObject.put(WxmpMessageConstant.PAGE, WxmpMessageConstant.PAGE_RESI);
} else if (WxmpMessageConstant.WORK.equals(clientType)) {
jsonObject.put(WxmpMessageConstant.PAGE, WxmpMessageConstant.PAGE_WORK);
StringBuilder resiPage = new StringBuilder(WxmpMessageConstant.PAGE_URL);
resiPage.append("?customerId=").append(customerId).append("&gridId=").append(msg.getGridId());
jsonObject.put(WxmpMessageConstant.PAGE, resiPage.toString());
} else if (WxmpMessageConstant.GOV_DB.equals(clientType)) {
StringBuilder govPage = new StringBuilder(WxmpMessageConstant.PAGE_URL);
govPage.append("?customerId=").append(customerId).append("&staffId=").append(userId);
jsonObject.put(WxmpMessageConstant.PAGE, govPage.toString());
}
//开发环境
if ("dev".equals(envEnum.getCode())) {
@ -223,9 +273,9 @@ public class WxmpMessageServiceImpl implements WxmpMessageService {
//订阅条数-1
int decrease = 0;
if (WxmpMessageConstant.RESI.equals(clientType)) {
decrease = wxmpResiUserSubscribeDao.decreaseResiSubscribeCount(openId, templateId, customerId, 1);
} else if (WxmpMessageConstant.WORK.equals(clientType)) {
decrease = wxmpWorkUserSubscribeDao.decreaseWorkSubscribeCount(openId, templateId, customerId, 1);
decrease = wxmpResiUserSubscribeDao.decreaseResiSubscribeCount(openId, templateId, customerId, 1,userId);
} else if (WxmpMessageConstant.GOV_DB.equals(clientType)) {
decrease = wxmpWorkUserSubscribeDao.decreaseWorkSubscribeCount(openId, templateId, customerId, 1,userId);
}
if (decrease == 0) {
logger.error("消息{}发送成功但订阅条数-1失败", JSON.toJSONString(msg));
@ -241,9 +291,9 @@ public class WxmpMessageServiceImpl implements WxmpMessageService {
if (errcode.equals(WxmpMessageConstant.USER_REFUSED)) {
int clear = 0;
if (WxmpMessageConstant.RESI.equals(clientType)) {
clear = wxmpResiUserSubscribeDao.clearResiSubscribeCount(openId, templateId, customerId);
} else if (WxmpMessageConstant.WORK.equals(clientType)) {
clear = wxmpWorkUserSubscribeDao.clearWorkSubscribeCount(openId, templateId, customerId);
clear = wxmpResiUserSubscribeDao.clearResiSubscribeCount(openId, templateId, customerId,userId);
} else if (WxmpMessageConstant.GOV_DB.equals(clientType)) {
clear = wxmpWorkUserSubscribeDao.clearWorkSubscribeCount(openId, templateId, customerId,userId);
}
if (clear == 0) {
logger.error("消息{}发送失败且清空订阅条数失败", JSON.toJSONString(msg));
@ -251,9 +301,8 @@ public class WxmpMessageServiceImpl implements WxmpMessageService {
}
//抛出错误
throw new WxSubscribeException(String.valueOf(resultMap.get(WxmpMessageConstant.ERR_MSG)),templateId, openId);
throw new WxSubscribeException(String.valueOf(resultMap.get(WxmpMessageConstant.ERR_MSG)), templateId, openId);
}
succecssCount++;
} catch (Exception e) {
String errMsg = e.getMessage();
@ -284,39 +333,326 @@ public class WxmpMessageServiceImpl implements WxmpMessageService {
wxmpMsgSendRecordEntity.setCustomerId(msg.getCustomerId());
wxmpMsgSendRecordEntity.setClientType(msg.getClientType());
wxmpMsgSendRecordEntity.setTemplateId(templateId);
wxmpMsgSendRecordEntity.setGridId(msg.getGridId() == null ? "" : msg.getGridId());
wxmpMsgSendRecordEntity.setUserId(msg.getUserId());
wxmpMsgSendRecordEntity.setWxOpenId(openId);
wxmpMsgSendRecordEntity.setBehaviorType(msg.getBehaviorType());
wxmpMsgSendRecordEntity.setTitle("您有一条" + msg.getBehaviorType());
wxmpMsgSendRecordEntity.setMessageContent(msg.getMessageContent());
wxmpMsgSendRecordEntity.setMessageTime(new Date());
wxmpMsgSendRecordEntity.setMessageTime(msg.getMessageTime());
wxmpMsgSendRecordEntity.setResult(status);
wxmpMsgSendRecordEntity.setReferer(msg.getReferer());
return wxmpMsgSendRecordEntity;
}
/**
* @return
* @Description 居民端工作端-获取客户小程序模板列表
* @author sun
*/
@Override
public List<GetTemplateListResultDTO> templateList(GetTemplateListFormDTO formDTO) {
GetTemplateListFormDTO dto = ConvertUtils.sourceToTarget(formDTO, GetTemplateListFormDTO.class);
String url = "https://epmet-cloud.elinkservice.cn/api/third/personaltemplate/templatelist";
//String url = "http://localhost:8080/api/third/personaltemplate/templatelist";
String data = HttpClientManager.getInstance().sendPostByJSON(url, JSON.toJSONString(dto)).getData();
logger.info("ThirdLoginServiceImpl.getUserWeChat:httpclient->url:"+url+",结果->"+data);
JSONObject toResult = JSON.parseObject(data);
Result mapToResult = ConvertUtils.mapToEntity(toResult, Result.class);
if (null != toResult.get("code")) {
mapToResult.setCode(((Integer) toResult.get("code")).intValue());
}
if (!mapToResult.success()) {
logger.error("调用epmet_third服务获取小程序消息订阅模板数据失败");
throw new RenException(mapToResult.getCode());
}
List<GetTemplateListResultDTO> resultList = (List<GetTemplateListResultDTO>) mapToResult.getData();
return resultList;
}
//获取AccessToken
private Map<String,String> getAccessToken(String customerId) {
EnvEnum envEnum = EnvEnum.getCurrentEnv();
String resiAccessToken = null;
String govAccessToken = null;
String errorMsg = null;
if (EnvEnum.PROD.getCode().equals(envEnum.getCode())) {
//居民端
StringBuilder resiKey = new StringBuilder(customerId).append(":").append(WxmpMessageConstant.RESI);
Map<String, Object> authorizerRefreshToken = new HashMap<>();
try {
authorizerRefreshToken = wxmpMessageRedis.getAuthorizerRefreshToken(resiKey.toString());
} catch (Exception e) {
errorMsg = e.getMessage();
}
resiAccessToken = (String) authorizerRefreshToken.get(WxmpMessageConstant.AUTHORIZER_ACCESS_TOKEN);
//政府端
StringBuilder govKey = new StringBuilder(customerId).append(":").append(WxmpMessageConstant.GOV_REDIS);
authorizerRefreshToken = new HashMap<>();
try {
authorizerRefreshToken = wxmpMessageRedis.getAuthorizerRefreshToken(resiKey.toString());
} catch (Exception e) {
errorMsg = e.getMessage();
}
govAccessToken = (String) authorizerRefreshToken.get(WxmpMessageConstant.AUTHORIZER_ACCESS_TOKEN);
} else {
String url = "https://epmet-cloud.elinkservice.cn/api/third/pacustomer/tokenlist";
JSONObject postData = new JSONObject();
postData.put("customerId", customerId);
String data = HttpClientManager.getInstance().sendPostByJSON(url, JSON.toJSONString(postData)).getData();
JSONObject toResult = JSON.parseObject(data);
Result mapToResult = ConvertUtils.mapToEntity(toResult, Result.class);
if (null != toResult.get("code")) {
mapToResult.setCode(((Integer) toResult.get("code")).intValue());
}
if (!mapToResult.success()) {
errorMsg = StringUtils.isBlank(mapToResult.getMsg()) ? mapToResult.getInternalMsg() : mapToResult.getMsg();
}
Object CustomerTokensResultDTO = mapToResult.getData();
JSONObject json = JSON.parseObject(CustomerTokensResultDTO.toString());
CustomerTokensResultDTO customerTokensResultDTO = ConvertUtils.mapToEntity(json, CustomerTokensResultDTO.class);
resiAccessToken = customerTokensResultDTO.getResiAuthorizerToken();
govAccessToken = customerTokensResultDTO.getWorkAuthorizerToken();
}
Map resultMap = new HashMap();
resultMap.put("resiToken",resiAccessToken);
resultMap.put("govToken",govAccessToken);
resultMap.put("errorMsg",errorMsg);
return resultMap;
}
/**
* @return
* @Description 居民端工作端-获取客户小程序模板列表
* @author sun
*/
@Override
public List<GetTemplateListResultDTO> templateList(GetTemplateListFormDTO formDTO) {
GetTemplateListFormDTO dto = ConvertUtils.sourceToTarget(formDTO, GetTemplateListFormDTO.class);
String url = "https://epmet-cloud.elinkservice.cn/api/third/personaltemplate/templatelist";
//String url = "http://localhost:8080/api/third/personaltemplate/templatelist";
String data = HttpClientManager.getInstance().sendPostByJSON(url, JSON.toJSONString(dto)).getData();
logger.info("ThirdLoginServiceImpl.getUserWeChat:httpclient->url:" + url + ",结果->" + data);
JSONObject toResult = JSON.parseObject(data);
Result mapToResult = ConvertUtils.mapToEntity(toResult, Result.class);
if (null != toResult.get("code")) {
mapToResult.setCode(((Integer) toResult.get("code")).intValue());
}
if (!mapToResult.success()) {
logger.error("调用epmet_third服务获取小程序消息订阅模板数据失败");
throw new RenException(mapToResult.getCode());
}
List<GetTemplateListResultDTO> resultList = (List<GetTemplateListResultDTO>) mapToResult.getData();
return resultList;
/*List<Object> resultList = (List<Object>) mapToResult.getData();
List<CustomerTemplateListResultDTO> list = new ArrayList<>();
//必须转换
for(Object f:resultList){
JSONObject json = JSON.parseObject(f.toString());
CustomerTemplateListResultDTO ff = ConvertUtils.mapToEntity(json, CustomerTemplateListResultDTO.class);
list.add(ff);
}
return list;*/
}
/**
* @return
* @Description 查询客户两个端小程序对应的站内信模板Id
* @author sun
*/
public List<CustomerTemplateListResultDTO> customerTemplateList(CustomerTemplateListFormDTO formDTO) {
String url = "https://epmet-cloud.elinkservice.cn/api/third/personaltemplate/customertemplatelist";
String data = HttpClientManager.getInstance().sendPostByJSON(url, JSON.toJSONString(formDTO)).getData();
logger.info("ThirdLoginServiceImpl.customerTemplateList:httpclient->url:" + url + ",结果->" + data);
JSONObject toResult = JSON.parseObject(data);
Result mapToResult = ConvertUtils.mapToEntity(toResult, Result.class);
if (null != toResult.get("code")) {
mapToResult.setCode(((Integer) toResult.get("code")).intValue());
}
if (!mapToResult.success()) {
logger.error("调用epmet_third服务获取客户小程序消息订阅模板数据失败");
throw new RenException(mapToResult.getCode());
}
List<Object> resultList = (List<Object>) mapToResult.getData();
List<CustomerTemplateListResultDTO> list = new ArrayList<>();
//必须转换
for (Object f : resultList) {
JSONObject json = JSON.parseObject(f.toString());
CustomerTemplateListResultDTO ff = ConvertUtils.mapToEntity(json, CustomerTemplateListResultDTO.class);
list.add(ff);
}
return list;
}
@Override
public WxMsgAuthInfoResultDTO getAuthorizationInfo(String customerId, String clientType, String loginUserId, String templateId) {
String openId = null;
switch (clientType) {
case AppClientConstant.APP_RESI:
openId = getResiOpenId(loginUserId);
break;
case AppClientConstant.APP_GOV:
openId = getWorkOpenId(loginUserId);
break;
}
return msgSubscribeStatusDao.getUserSubscribeStatusDTO(loginUserId, customerId, clientType, templateId, openId);
}
@Transactional
@Override
public void saveWxSubscribe(String customerId, String clientType, String templateId, String wxAlwaysVisit,
String wxSubscribeStatus, String behaviorType, String userId) {
String openId;
// 1. 用户订阅信息表新增或者更新
if (AppClientConstant.APP_GOV.equals(clientType)) {
// 工作端
openId = getWorkOpenId(userId);
saveWxWorkSubscribe(customerId, templateId, wxSubscribeStatus, userId, openId, wxAlwaysVisit);
} else {
//居民端
openId = getResiOpenId(userId);
saveWxResiSubscribe(customerId, templateId, wxSubscribeStatus, userId, openId, wxAlwaysVisit);
}
// 2.保存行为记录
WxmpUserSubscribeRecordEntity record = new WxmpUserSubscribeRecordEntity();
record.setBehaviorType(behaviorType);
record.setCustomerId(customerId);
record.setTemplateId(templateId);
record.setUserId(userId);
record.setWxAlwaysVisit(wxAlwaysVisit);
record.setWxOpenId(openId);
record.setWxSubscribeStatus(wxSubscribeStatus);
subscribeRecordDao.insert(record);
// 3.更新用户模板订阅状态
WxmpTemplateMsgSubscribeStatusEntity subscribeStatusEntity = msgSubscribeStatusDao.getUserSubscribeStatusEntity(userId, customerId, clientType, templateId, openId);
if (subscribeStatusEntity == null) {
subscribeStatusEntity = new WxmpTemplateMsgSubscribeStatusEntity();
subscribeStatusEntity.setUserId(userId);
subscribeStatusEntity.setWxSubscribeStatus(wxSubscribeStatus);
subscribeStatusEntity.setTemplateId(templateId);
subscribeStatusEntity.setWxAlwaysVisit(wxAlwaysVisit);
subscribeStatusEntity.setCustomerId(customerId);
subscribeStatusEntity.setClientType(clientType);
subscribeStatusEntity.setWxOpenId(openId);
msgSubscribeStatusDao.insert(subscribeStatusEntity);
return;
}
subscribeStatusEntity.setWxAlwaysVisit(wxAlwaysVisit);
subscribeStatusEntity.setWxSubscribeStatus(wxSubscribeStatus);
msgSubscribeStatusDao.updateById(subscribeStatusEntity);
}
/**
* @return void
* @Description 保存居民端微信订阅信息
* @author wxz
* @date 2020.10.22 09:56
*/
private void saveWxResiSubscribe(String customerId, String templateId, String wxSubscribeStatus, String userId,
String openId, String wxAlwaysVisit) {
WxmpResiUserSubscribeEntity wxResiSubscribe = wxmpResiUserSubscribeDao.getWxResiSubscribe(userId, customerId, templateId, openId);
if (wxResiSubscribe == null) {
WxmpResiUserSubscribeEntity insert = new WxmpResiUserSubscribeEntity();
insert.setCount(WxMsgTemplateSubscribeStatus.SUBSCRIBE.equals(wxSubscribeStatus) ? 1 : 0);
insert.setCustomerId(customerId);
insert.setTemplateId(templateId);
insert.setUserId(userId);
insert.setWxOpenId(openId);
insert.setWxSubscribeStatus(wxSubscribeStatus);
wxmpResiUserSubscribeDao.insert(insert);
return;
}
if (WxMsgTemplateSubscribeStatus.SUBSCRIBE.equals(wxSubscribeStatus)) {
wxmpResiUserSubscribeDao.incrSubscribeCount(1, userId, customerId, templateId, openId);
} else if (WxMsgTemplateSubscribeStatus.UNSUBSCRIBE.equals(wxSubscribeStatus) && "yes".equals(wxAlwaysVisit)) {
// 总是+取消
wxmpResiUserSubscribeDao.unSubscribe(userId, customerId, templateId, openId);
wxmpResiUserSubscribeDao.clearResiSubscribeCount(openId, templateId, customerId, userId);
} else {
// 取消
wxmpResiUserSubscribeDao.unSubscribe(userId, customerId, templateId, openId);
}
}
/**
* @return void
* @Description 保存工作端订阅信息
* @author wxz
* @date 2020.10.22 14:21
*/
private void saveWxWorkSubscribe(String customerId, String templateId, String wxSubscribeStatus, String userId,
String openId, String wxAlwaysVisit) {
WxmpWorkUserSubscribeEntity wxWorkSubscribe = wxmpWorkUserSubscribeDao.getWxWorkSubscribe(userId, customerId, templateId, openId);
if (wxWorkSubscribe == null) {
WxmpWorkUserSubscribeEntity insert = new WxmpWorkUserSubscribeEntity();
insert.setCount(WxMsgTemplateSubscribeStatus.SUBSCRIBE.equals(wxSubscribeStatus) ? 1 : 0);
insert.setCustomerId(customerId);
insert.setTemplateId(templateId);
insert.setUserId(userId);
insert.setWxOpenId(openId);
insert.setWxSubscribeStatus(wxSubscribeStatus);
wxmpWorkUserSubscribeDao.insert(insert);
return;
}
if (WxMsgTemplateSubscribeStatus.SUBSCRIBE.equals(wxSubscribeStatus)) {
wxmpWorkUserSubscribeDao.incrSubscribeCount(1, userId, customerId, templateId, openId);
} else if (WxMsgTemplateSubscribeStatus.UNSUBSCRIBE.equals(wxSubscribeStatus) && "yes".equals(wxAlwaysVisit)) {
// 取消订阅+总是
wxmpWorkUserSubscribeDao.unSubscribe(userId, customerId, templateId, openId);
wxmpWorkUserSubscribeDao.clearWorkSubscribeCount(openId, templateId, customerId, userId);
} else {
// 取消订阅+不总是
wxmpWorkUserSubscribeDao.unSubscribe(userId, customerId, templateId, openId);
}
}
/**
* @return string
* @Description 根据UserId查询居民OpenId
* @author wxz
* @date 2020.10.22 13:35
*/
public String getResiOpenId(String userId) {
UserBasicInfoFormDTO bif = new UserBasicInfoFormDTO();
bif.setUserId(userId);
Result<UserBasicInfo> result = epmetUserOpenFeignClient.getUserBasicInfo(bif);
if (!result.success()) {
throw new RenException(String.format("查询居民OpenId失败,userId:%s,错误信息:%s", userId, result.getInternalMsg()));
}
UserBasicInfo userBasicInfo = result.getData();
if (userBasicInfo == null) {
throw new RenException(String.format("根据userId:%s,没有查询到居民OpenId", userId));
}
return userBasicInfo.getOpenId();
}
/**
* @return java.lang.String
* @Description 查询工作人员openId
* @author wxz
* @date 2020.10.22 14:46
*/
public String getWorkOpenId(String userId) {
StaffBasicInfoFormDTO form = new StaffBasicInfoFormDTO();
form.setStaffId(userId);
Result<StaffBasicInfo> result = epmetUserOpenFeignClient.getStaffBasicInfo(form);
if (!result.success()) {
throw new RenException(String.format("查询工作人员OpenId失败,userId:%s,错误信息:%s", userId, result.getInternalMsg()));
}
StaffBasicInfo staffBasicInfo = result.getData();
if (staffBasicInfo == null) {
throw new RenException(String.format("根据userId:%s,没有查询到工作人员OpenId", userId));
}
return staffBasicInfo.getOpenId();
}
/**
* @return
* @Description 居民端工作端-重新激活授权页
* @author sun
*/
@Override
public void activationSubscribe(ActivationSubscribeFormDTO formDTO) {
//1.根据所属端和用户Id查询对应的openId
String openId = "";
if (AppClientConstant.APP_GOV.equals(formDTO.getClientType())) {
// 工作端
openId = getWorkOpenId(formDTO.getUserId());
} else {
//居民端
openId = getResiOpenId(formDTO.getUserId());
}
formDTO.setOpenId(openId);
//2.更新我们自己授权页用户授权状态
if(msgSubscribeStatusDao.updateUserSubscribe(formDTO)<NumConstant.ONE){
throw new RenException("重新激活订阅操作失败");
}
}
}

2
epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/WxmpMsgSendRecordServiceImpl.java

@ -104,6 +104,6 @@ public class WxmpMsgSendRecordServiceImpl extends BaseServiceImpl<WxmpMsgSendRec
@Override
@Transactional(rollbackFor = Exception.class)
public int saveRecord(WxmpMsgSendRecordEntity entity) {
return baseDao.saveRecord(entity);
return baseDao.insert(entity);
}
}

10
epmet-module/epmet-message/epmet-message-server/src/main/resources/bootstrap.yml

@ -118,4 +118,12 @@ ribbon:
#pageHelper分页插件
pagehelper:
helper-dialect: mysql
reasonable: false #分页合理化配置,例如输入页码为-1,则自动转化为最小页码1
reasonable: false #分页合理化配置,例如输入页码为-1,则自动转化为最小页码1
thread:
# 线程池配置
threadPool:
corePoolSize: @thread.pool.core-pool-size@
maxPoolSize: @thread.pool.max-pool-size@
queueCapacity: @thread.pool.queue-capacity@
keepAlive: @thread.pool.keep-alive@

98
epmet-module/epmet-message/epmet-message-server/src/main/resources/db/migration/V0.3.12.2__wxmp_message_template.sql

@ -0,0 +1,98 @@
CREATE TABLE `wxmp_template_msg_subscribe_status` (
`ID` varchar(64) NOT NULL COMMENT '主键',
`CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户Id ',
`CLIENT_TYPE` varchar(64) NOT NULL COMMENT '所属端类型 居民端:resi 工作端:gov',
`USER_ID` varchar(64) NOT NULL COMMENT '用户Id ',
`TEMPLATE_ID` varchar(64) DEFAULT NULL COMMENT '模板id',
`ALWAYS_VISIT` varchar(32) DEFAULT NULL COMMENT '是否总是访问 是:yes 否:no',
`SUBSCRIBE_STATUS` varchar(32) DEFAULT NULL COMMENT '订阅状态(订阅:subscribe 取消订阅:unsubscribe)',
`WX_ALWAYS_VISIT` varchar(32) DEFAULT NULL COMMENT 'wx是否总是访问 是:yes 否:no',
`WX_SUBSCRIBE_STATUS` varchar(32) DEFAULT NULL COMMENT 'wx订阅状态 (订阅:subscribe 取消订阅:unsubscribe)',
`DEL_FLAG` int(11) NOT NULL COMMENT '删除标识',
`REVISION` int(11) NOT NULL COMMENT '乐观锁',
`CREATED_BY` varchar(32) NOT NULL COMMENT '创建人',
`CREATED_TIME` datetime NOT NULL COMMENT '创建时间',
`UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人',
`UPDATED_TIME` datetime NOT NULL COMMENT '更新时间',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户模板消息订阅授权状态表(记录我们自己和微信的授权页用户勾选的状态)';
CREATE TABLE `wxmp_user_subscribe_record` (
`ID` varchar(64) NOT NULL COMMENT '主键',
`CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户Id ',
`TEMPLATE_ID` varchar(64) NOT NULL COMMENT '消息模板Id ',
`USER_ID` varchar(64) NOT NULL COMMENT '用户Id ',
`WX_OPEN_ID` varchar(64) NOT NULL COMMENT 'openId ',
`BEHAVIOR_TYPE` varchar(128) DEFAULT NULL COMMENT '行为类型 (入组申请、党员认证)等',
`WX_ALWAYS_VISIT` varchar(32) DEFAULT NULL COMMENT 'wx是否总是访问 是:yes 否:no',
`WX_SUBSCRIBE_STATUS` varchar(32) DEFAULT NULL COMMENT 'wx订阅状态(订阅:subscribe 取消订阅:unsubscribe)',
`DEL_FLAG` int(11) NOT NULL COMMENT '删除标识',
`REVISION` int(11) NOT NULL COMMENT '乐观锁',
`CREATED_BY` varchar(32) NOT NULL COMMENT '创建人',
`CREATED_TIME` datetime NOT NULL COMMENT '创建时间',
`UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人',
`UPDATED_TIME` datetime NOT NULL COMMENT '更新时间',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户触发订阅的行为记录表(同时记录微信授权页每次勾选的状态)';
CREATE TABLE `wxmp_resi_user_subscribe` (
`ID` varchar(64) NOT NULL COMMENT '主键',
`CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户Id ',
`TEMPLATE_ID` varchar(64) NOT NULL COMMENT '消息模板Id',
`USER_ID` varchar(64) NOT NULL COMMENT '用户Id',
`WX_OPEN_ID` varchar(64) NOT NULL COMMENT 'openId ',
`WX_SUBSCRIBE_STATUS` varchar(32) DEFAULT NULL COMMENT 'wx订阅状态,只记录用户最后一次操作的勾选状态 (订阅:subscribe 取消订阅:unsubscribe)',
`COUNT` int(11) DEFAULT NULL COMMENT '可用推送次数',
`DEL_FLAG` int(11) NOT NULL COMMENT '删除标识',
`REVISION` int(11) NOT NULL COMMENT '乐观锁',
`CREATED_BY` varchar(32) NOT NULL COMMENT '创建人',
`CREATED_TIME` datetime NOT NULL COMMENT '创建时间',
`UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人',
`UPDATED_TIME` datetime NOT NULL COMMENT '更新时间',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='居民端用户订阅模板消息次数记录表';
CREATE TABLE `wxmp_work_user_subscribe` (
`ID` varchar(64) NOT NULL COMMENT '主键',
`CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户Id ',
`TEMPLATE_ID` varchar(64) NOT NULL COMMENT '消息模板Id ',
`USER_ID` varchar(64) NOT NULL COMMENT '用户Id ',
`WX_OPEN_ID` varchar(64) NOT NULL COMMENT 'openId ',
`WX_SUBSCRIBE_STATUS` varchar(32) DEFAULT NULL COMMENT 'wx订阅状态,只记录用户最后一次操作的勾选状态 (订阅:subscribe 取消订阅:unsubscribe)',
`COUNT` int(11) DEFAULT NULL COMMENT '可用推送次数 ',
`DEL_FLAG` int(11) NOT NULL COMMENT '删除标识',
`REVISION` int(11) NOT NULL COMMENT '乐观锁',
`CREATED_BY` varchar(32) NOT NULL COMMENT '创建人',
`CREATED_TIME` datetime NOT NULL COMMENT '创建时间',
`UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人',
`UPDATED_TIME` datetime NOT NULL COMMENT '更新时间',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='工作端用户订阅模板消息有效次数记录表 ';
CREATE TABLE `wxmp_msg_send_record` (
`ID` varchar(64) NOT NULL COMMENT '主键',
`CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户Id ',
`GRID_ID` varchar(64) NOT NULL COMMENT '网格Id (居民端跟网格有关的则有值,工作端以及一些居民端和网格没关的存*)',
`CLIENT_TYPE` varchar(64) NOT NULL COMMENT '所属端类型 居民端:resi 工作端:gov',
`TEMPLATE_ID` varchar(64) NOT NULL COMMENT '消息模板Id ',
`USER_ID` varchar(64) NOT NULL COMMENT '用户Id',
`WX_OPEN_ID` varchar(64) NOT NULL COMMENT 'openId ',
`BEHAVIOR_TYPE` varchar(128) NOT NULL COMMENT '行为类型(存title字段的中间值) 入组申请、党员认证等',
`TITLE` varchar(128) NOT NULL COMMENT '消息标题 ',
`MESSAGE_CONTENT` varchar(1024) NOT NULL COMMENT '消息内容 ',
`MESSAGE_TIME` datetime NOT NULL COMMENT '消息时间 ',
`RESULT` varchar(32) NOT NULL COMMENT '发送结果(成功:success 失败:error)',
`REASON` varchar(1024) DEFAULT NULL COMMENT '发送失败的原因,成功可以不记录',
`DEL_FLAG` int(11) NOT NULL COMMENT '删除标识',
`REVISION` int(11) NOT NULL COMMENT '乐观锁',
`CREATED_BY` varchar(32) NOT NULL COMMENT '创建人',
`CREATED_TIME` datetime NOT NULL COMMENT '创建时间',
`UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人',
`UPDATED_TIME` datetime NOT NULL COMMENT '更新时间',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='消息发送记录表';

1
epmet-module/epmet-message/epmet-message-server/src/main/resources/db/migration/V0.3.12.3__sub_status_add_column.sql

@ -0,0 +1 @@
alter table wxmp_template_msg_subscribe_status add column WX_OPEN_ID varchar(64) not null ;

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save