Browse Source

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

 Conflicts:
	epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java
	epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java
	epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/VolunteerInfoService.java
	epmet-module/epmet-job/epmet-job-server/pom.xml
	epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/VolunteerServiceImpl.java
master
wangxianzhang 4 years ago
parent
commit
8a8c3cd218
  1. 6
      epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govproject/ProjectDao.xml
  2. 1
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java
  3. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactOriginExtractController.java
  4. 48
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/DimLastSyncRecordDao.java
  5. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/project/ProjectDao.java
  6. 51
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/DimLastSyncRecordEntity.java
  7. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenCustomerDeptEntity.java
  8. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenCustomerGridEntity.java
  9. 35
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/ProjectExtractServiceImpl.java
  10. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerAgencyService.java
  11. 8
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerDeptService.java
  12. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerGridService.java
  13. 108
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerAgencyServiceImpl.java
  14. 43
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerDeptServiceImpl.java
  15. 64
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerGridServiceImpl.java
  16. 138
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/EIDimServiceImpl.java
  17. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/ProjectService.java
  18. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/project/impl/ProjectServiceImpl.java
  19. 15
      epmet-module/data-statistical/data-statistical-server/src/main/resources/db/migration/V0.0.27__create_indexdimsyncrecord.sql
  20. 31
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/DimLastSyncRecordDao.xml
  21. 6
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerDepartmentDao.xml
  22. 1
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml
  23. 5
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/StatsCustomerAgencyDao.xml
  24. 3
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/project/ProjectDao.xml
  25. 8
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java
  26. 5
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java
  27. 14
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiVolunteerController.java
  28. 9
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcPartyUnitService.java
  29. 7
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/VolunteerInfoService.java
  30. 2
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyActivityServiceImpl.java
  31. 21
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyUnitServiceImpl.java
  32. 7
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java
  33. 6
      epmet-module/epmet-job/epmet-job-server/pom.xml
  34. 3
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/feign/GovIssueFeignClient.java
  35. 5
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/feign/impl/GovIssueFeignClientFallBack.java
  36. 3
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/IssueVotingDailyStatisticalTaskService.java
  37. 5
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/IssueVotingDailyStatisticalTaskServiceImpl.java
  38. 9
      epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/DailyStatisticalVoteTask.java
  39. 5
      epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/PolyLineDTO.java
  40. 26
      epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/DailyStatisticalVoteJob.java
  41. 5
      epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/ResiBuzzLeftPieChartFormDTO.java
  42. 70
      epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/result/DailyStatisticalVoteJobResultDTO.java
  43. 2
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueManageController.java
  44. 6
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueVoteStatisticalDailyController.java
  45. 2
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueDao.java
  46. 21
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueVoteDetailDao.java
  47. 9
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueVoteStatisticalDailyDao.java
  48. 5
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/redis/IssueVoteDetailRedis.java
  49. 9
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueVoteStatisticalDailyService.java
  50. 2
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java
  51. 81
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueVoteStatisticalDailyServiceImpl.java
  52. 61
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueVoteStatisticalServiceImpl.java
  53. 5
      epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueDao.xml
  54. 39
      epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueVoteDetailDao.xml
  55. 9
      epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueVoteStatisticalDailyDao.xml
  56. 2
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java
  57. 242
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/VolunteerServiceImpl.java

6
epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govproject/ProjectDao.xml

@ -4,7 +4,7 @@
<mapper namespace="com.epmet.dataaggre.dao.govproject.ProjectDao">
<select id="getAllProject" resultType="com.epmet.dataaggre.dto.govproject.result.ProjectInfoDTO">
SELECT
SELECT DISTINCT
p.ID AS projectId,
p.TITLE AS projectTitle,
p.`STATUS` AS projectStatus,
@ -19,12 +19,12 @@
IFNULL( pp.PUBLIC_REPLY, '' ) AS publicReply
FROM
project p
INNER JOIN ( SELECT PROJECT_ID, GRID_ID FROM project_related_personnel WHERE DEL_FLAG = '0' AND SOURCE_TYPE = 'issue' ) prp ON p.ID = prp.PROJECT_ID
LEFT JOIN ( SELECT PROJECT_ID, GRID_ID FROM project_related_personnel WHERE DEL_FLAG = '0' AND SOURCE_TYPE = 'issue' ) prp ON p.ID = prp.PROJECT_ID
INNER JOIN ( SELECT PROJECT_ID, MAX( CREATED_TIME ) AS updateTime FROM project_process ppro GROUP BY PROJECT_ID ) ppro ON p.ID = ppro.PROJECT_ID
INNER JOIN ( SELECT PROJECT_ID, COUNT( DISTINCT DEPARTMENT_NAME ) AS departmentCount FROM project_staff GROUP BY PROJECT_ID ) ps ON ps.PROJECT_ID = p.ID
LEFT JOIN ( SELECT PROJECT_ID, COUNT( ID ) AS processCount FROM project_process WHERE DEL_FLAG = '0' AND OPERATION != 'created' GROUP BY PROJECT_ID ) ppc ON ppc.PROJECT_ID = p.ID
LEFT JOIN project_process pp ON p.ID = pp.PROJECT_ID
AND pp.OPERATION = 'close'
AND pp.OPERATION = 'close' AND pp.DEL_FLAG = '0'
WHERE
p.DEL_FLAG = '0'
AND p.ORG_ID_PATH LIKE concat('%', #{agencyId}, '%')

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

@ -1112,6 +1112,7 @@ public class DemoController {
}else {
screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectGridData(customerId,dateId);
screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectOrgData(customerId,dateId);
result.add(dateId);
redisUtils.hSet(RedisKeys.getBackDoorbizExcuteResult("gridandorgdailynew"),customerId,result,3*24*60*60L);
}
long end = System.currentTimeMillis();

4
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactOriginExtractController.java

@ -7,6 +7,7 @@ import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.extract.form.ExtractOriginFormDTO;
import com.epmet.service.evaluationindex.extract.todata.*;
import com.epmet.service.stats.DimCustomerService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
@ -23,6 +24,7 @@ import java.util.List;
* @author yinzuomei@elink-cn.com
* @date 2020/9/15 11:06
*/
@Slf4j
@RestController
@RequestMapping("factorigin")
public class FactOriginExtractController {
@ -95,6 +97,7 @@ public class FactOriginExtractController {
@PostMapping("project")
public Result projectData(@RequestBody ExtractOriginFormDTO extractOriginFormDTO) {
long start = System.currentTimeMillis();
if (StringUtils.isNotBlank(extractOriginFormDTO.getCustomerId())) {
List<String> daysBetween;
if (StringUtils.isBlank(extractOriginFormDTO.getDateId())) {
@ -115,6 +118,7 @@ public class FactOriginExtractController {
projectExtractService.saveOriginProjectDaily(dto);
});
}
log.info("projectData end,cost:{}",System.currentTimeMillis() - start);
return new Result();
}

48
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/DimLastSyncRecordDao.java

@ -0,0 +1,48 @@
/**
* 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.dao.evaluationindex.screen;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.evaluationindex.screen.DimLastSyncRecordEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
/**
*
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-12-28
*/
@Mapper
public interface DimLastSyncRecordDao extends BaseDao<DimLastSyncRecordEntity> {
/**
* 查询最后一次同步时间
* @return
*/
Date getDimLastSyncEndTime(@Param("subject") String subject);
/**
* 更新最后一次同步时间
* @param subject
* @param statsEndTime
* @return
*/
int updateLastSyncEndTime(@Param("subject") String subject, @Param("statsEndTime") Date statsEndTime);
}

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

@ -200,7 +200,8 @@ public interface ProjectDao extends BaseDao<ProjectEntity> {
* 获取已转项目事件事件
*
* @param customerId
* @param projectId
* @return
*/
List<ResiEventDTO> getEventList(@Param("customerId") String customerId);
List<ResiEventDTO> getEventList(@Param("customerId") String customerId, @Param("projectId") String projectId);
}

51
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/DimLastSyncRecordEntity.java

@ -0,0 +1,51 @@
/**
* 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.entity.evaluationindex.screen;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
*
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-12-28
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("dim_last_sync_record")
public class DimLastSyncRecordEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 主体agency:机关department:部门grid:网格
*/
private String subject;
/**
* 最后一次同步时间
*/
private Date lastSyncTime;
}

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

@ -87,4 +87,9 @@ public class ScreenCustomerDeptEntity extends BaseEpmetEntity {
* desc: 是否参与上级计算yes:参与;no:不参与 add 01.14
*/
private String upToCal;
/**
* desc: 是否显示 1显示 0不显示
*/
private String isDisplay;
}

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

@ -97,4 +97,9 @@ public class ScreenCustomerGridEntity extends BaseEpmetEntity {
* 地区码
*/
private String code;
/**
* desc: 是否显示 1显示 0不显示
*/
private String isDisplay;
}

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

@ -38,6 +38,7 @@ import com.epmet.util.DimIdGenerator;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -127,17 +128,26 @@ public class ProjectExtractServiceImpl implements ProjectExtractService {
//获取项目信息
List<ProjectDTO> projectList = projectService.getProjectInfo(customerId, dateString, projectId);
factOriginProjectMainDailyService.deleteByDate(customerId, dateString,projectId);
List<IssueDTO> issueList = new ArrayList<>();
List<ResiTopicDTO> topicList = new ArrayList<>();
if (!CollectionUtils.isEmpty(projectList)) {
Map<String, ResiEventDTO> projectEventMap = projectService.getEventList(customerId);
Map<String, ResiEventDTO> projectEventMap = projectService.getEventList(customerId, projectId);
//提取议题ID
List<String> issueIds =
projectList.stream().filter(item -> ProjectConstant.ISSUE.equals(item.getOrigin())).map(ProjectDTO::getOriginId).collect(Collectors.toList());
//获取议题信息
List<IssueDTO> issueList = issueService.getIssueInfoByIds(issueIds);
//提取话题ID
List<String> topicIds = issueList.stream().map(IssueDTO::getSourceId).collect(Collectors.toList());
//获取话题信息
List<ResiTopicDTO> topicList = topicService.getTopicByIds(topicIds);
if (CollectionUtils.isNotEmpty(issueIds)) {
//分批次获取
//获取议题信息
List<List<String>> partition = ListUtils.partition(issueIds, NumConstant.FIFTY);
partition.forEach(part -> issueList.addAll(issueService.getIssueInfoByIds(part)));
//提取话题ID
List<String> topicIds = issueList.stream().map(IssueDTO::getSourceId).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(topicIds)) {
//获取话题信息
List<List<String>> topicPart = ListUtils.partition(topicIds, NumConstant.FIFTY);
topicPart.forEach(part -> topicList.addAll(topicService.getTopicByIds(part)));
}
}
//获取网格认证党员
List<PartyMemberDTO> partyMemberList = partyMemberService.getPartyMemberByCustomer(customerId);
//生成DTO
@ -231,7 +241,9 @@ public class ProjectExtractServiceImpl implements ProjectExtractService {
}
//满意度
long start = System.currentTimeMillis();
List<FactOriginProjectMainDailyEntity> satisfaction = projectService.getProjectSatisfaction(customerId, projectId);
log.info("saveOriginProjectDaily 满意度 cost:{}",System.currentTimeMillis()-start);
if (CollectionUtils.isNotEmpty(satisfaction)) {
factOriginProjectMainDailyService.updateBatchById(satisfaction);
}
@ -239,7 +251,9 @@ public class ProjectExtractServiceImpl implements ProjectExtractService {
final List<FactOriginProjectMainDailyEntity> mainList = list;
List<FactOriginProjectLogDailyEntity> logList = new ArrayList<>();
//节点发起人 部门流转退回结案
start = System.currentTimeMillis();
List<ProcessInfoDTO> processList = projectProcessService.getProcessListByCustomer(customerId, dateString, projectId);
log.info("saveOriginProjectDaily 节点发起人 部门流转退回结案 cost:{}",System.currentTimeMillis()-start);
if (!CollectionUtils.isEmpty(processList)) {
logList = processList.stream().map(process -> {
//获取日期相关维度
@ -291,7 +305,9 @@ public class ProjectExtractServiceImpl implements ProjectExtractService {
}).collect(Collectors.toList());
}
//节点发起人 响应
start = System.currentTimeMillis();
List<ProcessInfoDTO> responseList = projectProcessService.getResponseProcessList(customerId, dateString, projectId);
log.info("saveOriginProjectDaily 节点发起人 响应 cost:{}",System.currentTimeMillis()-start);
if (!CollectionUtils.isEmpty(responseList)) {
logList.addAll(responseList.stream().map(process -> {
//获取日期相关维度
@ -337,8 +353,9 @@ public class ProjectExtractServiceImpl implements ProjectExtractService {
}
//项目评论人
start = System.currentTimeMillis();
List<ProcessInfoDTO> satisfactionRecordList = projectProcessService.getSatisfactionRecord(customerId, dateString, projectId);
log.info("saveOriginProjectDaily 项目评论人 cost:{}",System.currentTimeMillis()-start);
satisfactionRecordList.forEach(log -> mainList.stream().filter(project -> log.getProjectId().equals(project.getId())).forEach(main -> {
//进行满意度评价的居民的所属机关的父机机关信息
log.setPid(main.getPid());
@ -367,7 +384,9 @@ public class ProjectExtractServiceImpl implements ProjectExtractService {
//节点接收人
start = System.currentTimeMillis();
List<ProcessInfoDTO> processStaffList = projectProcessService.getProcessStaffByCustomer(customerId, dateString, projectId);
log.info("saveOriginProjectDaily 节点接收人 cost:{}",System.currentTimeMillis()-start);
logList.addAll(processStaffList.stream().map(process -> {
//获取日期相关维度
DimIdGenerator.DimIdBean dimId = DimIdGenerator.getDimIdBean(process.getCreatedTime());

10
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerAgencyService.java

@ -17,6 +17,7 @@
package com.epmet.service.evaluationindex.screen;
import cn.hutool.db.DaoTemplate;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.dto.CustomerAgencyDTO;
import com.epmet.dto.extract.form.PartyBaseInfoFormDTO;
@ -27,6 +28,7 @@ import com.epmet.dto.extract.result.OrgNameResultDTO;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity;
import com.epmet.entity.org.CustomerAgencyEntity;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -61,7 +63,7 @@ public interface ScreenCustomerAgencyService extends BaseService<ScreenCustomerA
ScreenCustomerAgencyEntity getLastUpdatedAgency();
void initAgencies(List<CustomerAgencyEntity> agencies2Add, List<CustomerAgencyEntity> agencies2Update);
void initAgencies(List<CustomerAgencyEntity> agencies2Add, List<CustomerAgencyEntity> agencies2Update, Date statsEndTime);
/**
* @Description 查询下一级机关的ID即以agencyId为pid的agency
@ -164,4 +166,10 @@ public interface ScreenCustomerAgencyService extends BaseService<ScreenCustomerA
*/
String getParentAgencyId(String agencyId);
/**
* 获取上次维度同步时间
* @return
*/
Date getDimLastSyncTime();
}

8
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerDeptService.java

@ -21,6 +21,7 @@ import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity;
import com.epmet.entity.org.CustomerDepartmentEntity;
import java.util.Date;
import java.util.List;
/**
@ -39,6 +40,11 @@ public interface ScreenCustomerDeptService extends BaseService<ScreenCustomerDep
ScreenCustomerDeptEntity getLastUpdateDept();
void addAndUpdateDepartments(List<CustomerDepartmentEntity> depts2Add, List<CustomerDepartmentEntity> depts2Update);
void addAndUpdateDepartments(List<CustomerDepartmentEntity> depts2Add, List<CustomerDepartmentEntity> depts2Update, Date syncEndTime);
/**
* 查询上次同步的截止时间
* @return
*/
Date getLastSyncEndTime();
}

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

@ -27,6 +27,7 @@ import com.epmet.dto.screen.ScreenProjectGridDailyDTO;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerGridEntity;
import com.epmet.entity.org.CustomerGridEntity;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -41,7 +42,7 @@ public interface ScreenCustomerGridService extends BaseService<ScreenCustomerGri
ScreenCustomerGridEntity getLastAddGrid();
ScreenCustomerGridEntity getLastUpdateGrid();
void addAndUpdateGrids(List<CustomerGridEntity> grids2Add, List<CustomerGridEntity> grids2Update);
void addAndUpdateGrids(List<CustomerGridEntity> grids2Add, List<CustomerGridEntity> grids2Update, Date syncEndTime);
/**
* @Description 查询客户下所有网格ID
@ -129,4 +130,10 @@ public interface ScreenCustomerGridService extends BaseService<ScreenCustomerGri
* @Date 2021/10/15 15:50
*/
Map<String, ScreenCustomerGridDTO> getGridList(String customerId);
/**
* 查询上次同步截止时间
* @return
*/
Date getLastSyncEndTime();
}

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

@ -25,6 +25,7 @@ import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.constant.DataSourceConstant;
import com.epmet.constant.OrgSourceTypeConstant;
import com.epmet.constant.ScreenConstant;
import com.epmet.dao.evaluationindex.screen.DimLastSyncRecordDao;
import com.epmet.dao.evaluationindex.screen.ScreenCustomerAgencyDao;
import com.epmet.dao.evaluationindex.screen.ScreenCustomerGridDao;
import com.epmet.dto.CustomerAgencyDTO;
@ -34,6 +35,7 @@ import com.epmet.dto.extract.form.ScreenPartyLinkMassesDataFormDTO;
import com.epmet.dto.extract.result.CustomerAgencyInfoResultDTO;
import com.epmet.dto.extract.result.OrgNameResultDTO;
import com.epmet.dto.screen.result.TreeResultDTO;
import com.epmet.entity.evaluationindex.screen.DimLastSyncRecordEntity;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity;
import com.epmet.entity.org.CustomerAgencyEntity;
import com.epmet.service.evaluationindex.screen.ScreenCustomerAgencyService;
@ -63,6 +65,8 @@ public class ScreenCustomerAgencyServiceImpl extends BaseServiceImpl<ScreenCusto
private ScreenCustomerAgencyDao screenCustomerAgencyDao;
@Autowired
private ScreenCustomerGridDao screenCustomerGridDao;
@Autowired
private DimLastSyncRecordDao dimLastSyncRecordDao;
/**
* @Description 根据agencyId查询所有子级agencyId当机关的级别为 community时所有子级为gridId
@ -116,12 +120,12 @@ public class ScreenCustomerAgencyServiceImpl extends BaseServiceImpl<ScreenCusto
@Transactional(rollbackFor = Exception.class)
@Override
public void initAgencies(List<CustomerAgencyEntity> agencies2Add, List<CustomerAgencyEntity> agencies2Update) {
public void initAgencies(List<CustomerAgencyEntity> agencies2Add, List<CustomerAgencyEntity> agencies2Update, Date statsEndTime) {
String dateEndTime = DateUtils.format(new Date(), DateUtils.DATE_PATTERN_YYYYMMDD);
if (!CollectionUtils.isEmpty(agencies2Add)) {
// 添加
for (CustomerAgencyEntity e : agencies2Add) {
addAgency(e, dateEndTime);
addOrUpdateAgency(e, dateEndTime);
}
}
@ -137,11 +141,11 @@ public class ScreenCustomerAgencyServiceImpl extends BaseServiceImpl<ScreenCusto
exists.setDataEndTime(dateEndTime);
exists.setAreaCode(e.getAreaCode());
//如果没有区划 则默认暂时不显示
if (StringUtils.isEmpty(e.getAreaCode())) {
exists.setIsDisplay(NumConstant.ZERO_STR);
} else {
exists.setIsDisplay(NumConstant.ONE_STR);
}
//if (StringUtils.isEmpty(e.getAreaCode())) {
// exists.setIsDisplay(NumConstant.ZERO_STR);
//} else {
// exists.setIsDisplay(NumConstant.ONE_STR);
//}
exists.setAllParentNames(e.getAllParentName());
exists.setParentAreaCode(e.getParentAreaCode());
exists.setCode(e.getCode());
@ -156,6 +160,19 @@ public class ScreenCustomerAgencyServiceImpl extends BaseServiceImpl<ScreenCusto
}
}
}
// 保存同步记录
Date lastSyncEndTime = dimLastSyncRecordDao.getDimLastSyncEndTime("agency");
if (lastSyncEndTime == null) {
// 首次初始化,没有上次执行记录,插入一条
DimLastSyncRecordEntity insertRecord = new DimLastSyncRecordEntity();
insertRecord.setSubject("agency");
insertRecord.setLastSyncTime(statsEndTime);
dimLastSyncRecordDao.insert(insertRecord);
} else {
// 更新
dimLastSyncRecordDao.updateLastSyncEndTime("agency", statsEndTime);
}
}
/**
@ -231,31 +248,62 @@ public class ScreenCustomerAgencyServiceImpl extends BaseServiceImpl<ScreenCusto
}
/**
* 添加agency
* 添加或者更新agency防止情况业务表中有数据被抽取过来且这条数据已经由其他操作推到维度库了
* @param e
*/
private void addAgency(CustomerAgencyEntity e, String dateEndTime) {
ScreenCustomerAgencyEntity cae = new ScreenCustomerAgencyEntity();
cae.setAgencyId(e.getId());
cae.setAgencyName(e.getOrganizationName());
cae.setAllParentNames(e.getAllParentName());
cae.setAreaCode(e.getAreaCode());
//cae.setAreaMarks(e);
//如果没有区划 则默认暂时不显示
if (StringUtils.isEmpty(e.getAreaCode())) {
cae.setIsDisplay(NumConstant.ZERO_STR);
private void addOrUpdateAgency(CustomerAgencyEntity e, String dateEndTime) {
LambdaQueryWrapper<ScreenCustomerAgencyEntity> query = new LambdaQueryWrapper<>();
query.eq(ScreenCustomerAgencyEntity::getCustomerId, e.getCustomerId());
query.eq(ScreenCustomerAgencyEntity::getAgencyId, e.getId());
ScreenCustomerAgencyEntity existsOne = screenCustomerAgencyDao.selectOne(query);
if (existsOne != null) {
// 已经存在
existsOne.setAgencyId(e.getId());
existsOne.setAgencyName(e.getOrganizationName());
existsOne.setAllParentNames(e.getAllParentName());
existsOne.setAreaCode(e.getAreaCode());
//cae.setAreaMarks(e);
//如果没有区划 则默认暂时不显示
//if (StringUtils.isEmpty(e.getAreaCode())) {
// existsOne.setIsDisplay(NumConstant.ZERO_STR);
//} else {
// existsOne.setIsDisplay(NumConstant.ONE_STR);
//}
existsOne.setCustomerId(e.getCustomerId());
existsOne.setDataEndTime(dateEndTime);
existsOne.setLevel(e.getLevel());
existsOne.setPid(e.getPid());
existsOne.setPids(e.getPids());
//existsOne.setSourceType(OrgSourceTypeConstant.INTERNAL);
existsOne.setParentAreaCode(e.getParentAreaCode());
existsOne.setCode(e.getCode());
screenCustomerAgencyDao.updateById(existsOne);
return;
} else {
cae.setIsDisplay(NumConstant.ONE_STR);
// 不存在,需要添加
ScreenCustomerAgencyEntity cae = new ScreenCustomerAgencyEntity();
cae.setAgencyId(e.getId());
cae.setAgencyName(e.getOrganizationName());
cae.setAllParentNames(e.getAllParentName());
cae.setAreaCode(e.getAreaCode());
//cae.setAreaMarks(e);
//如果没有区划 则默认暂时不显示
if (StringUtils.isEmpty(e.getAreaCode())) {
cae.setIsDisplay(NumConstant.ZERO_STR);
} else {
cae.setIsDisplay(NumConstant.ONE_STR);
}
cae.setCustomerId(e.getCustomerId());
cae.setDataEndTime(dateEndTime);
cae.setLevel(e.getLevel());
cae.setPid(e.getPid());
cae.setPids(e.getPids());
cae.setSourceType(OrgSourceTypeConstant.INTERNAL);
cae.setParentAreaCode(e.getParentAreaCode());
cae.setCode(e.getCode());
screenCustomerAgencyDao.insert(cae);
}
cae.setCustomerId(e.getCustomerId());
cae.setDataEndTime(dateEndTime);
cae.setLevel(e.getLevel());
cae.setPid(e.getPid());
cae.setPids(e.getPids());
cae.setSourceType(OrgSourceTypeConstant.INTERNAL);
cae.setParentAreaCode(e.getParentAreaCode());
cae.setCode(e.getCode());
screenCustomerAgencyDao.insert(cae);
}
/**
@ -355,4 +403,8 @@ public class ScreenCustomerAgencyServiceImpl extends BaseServiceImpl<ScreenCusto
return baseDao.getParentAgencyId(agencyId);
}
@Override
public Date getDimLastSyncTime() {
return dimLastSyncRecordDao.getDimLastSyncEndTime("agency");
}
}

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

@ -20,13 +20,17 @@ package com.epmet.service.evaluationindex.screen.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.DateUtils;
import com.epmet.constant.DataSourceConstant;
import com.epmet.constant.OrgSourceTypeConstant;
import com.epmet.dao.evaluationindex.screen.DimLastSyncRecordDao;
import com.epmet.dao.evaluationindex.screen.ScreenCustomerDeptDao;
import com.epmet.entity.evaluationindex.screen.DimLastSyncRecordEntity;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity;
import com.epmet.entity.org.CustomerDepartmentEntity;
import com.epmet.service.evaluationindex.screen.ScreenCustomerDeptService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -46,6 +50,9 @@ public class ScreenCustomerDeptServiceImpl extends BaseServiceImpl<ScreenCustome
@Autowired
private ScreenCustomerDeptDao screenCustomerDeptDao;
@Autowired
private DimLastSyncRecordDao dimLastSyncRecordDao;
@Override
public ScreenCustomerDeptEntity getLastAddDept() {
@ -64,7 +71,7 @@ public class ScreenCustomerDeptServiceImpl extends BaseServiceImpl<ScreenCustome
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void addAndUpdateDepartments(List<CustomerDepartmentEntity> depts2Add, List<CustomerDepartmentEntity> depts2Update) {
public void addAndUpdateDepartments(List<CustomerDepartmentEntity> depts2Add, List<CustomerDepartmentEntity> depts2Update, Date syncEndTime) {
String dateStr = DateUtils.format(new Date(), "YYYYmmdd");
for (CustomerDepartmentEntity dept : depts2Add) {
ScreenCustomerDeptEntity e = screenCustomerDeptDao.selectByDeptId(dept.getId());
@ -77,7 +84,22 @@ public class ScreenCustomerDeptServiceImpl extends BaseServiceImpl<ScreenCustome
e.setParentAgencyId(dept.getAgencyId());
e.setSourceType(OrgSourceTypeConstant.INTERNAL);
e.setAreaCode(dept.getAreaCode());
//如果没有区划 则默认暂时不显示
if (StringUtils.isEmpty(dept.getAreaCode())) {
e.setIsDisplay(NumConstant.ZERO_STR);
} else {
e.setIsDisplay(NumConstant.ONE_STR);
}
screenCustomerDeptDao.insert(e);
} else {
e.setCustomerId(dept.getCustomerId());
e.setDataEndTime(dateStr);
e.setDeptId(dept.getId());
e.setDeptName(dept.getDepartmentName());
e.setParentAgencyId(dept.getAgencyId());
//e.setSourceType(OrgSourceTypeConstant.INTERNAL);
e.setAreaCode(dept.getAreaCode());
screenCustomerDeptDao.updateById(e);
}
}
@ -100,6 +122,25 @@ public class ScreenCustomerDeptServiceImpl extends BaseServiceImpl<ScreenCustome
}
}
}
// 存储同步记录
LambdaQueryWrapper<DimLastSyncRecordEntity> lastSyncRecordQuery = new LambdaQueryWrapper<>();
lastSyncRecordQuery.eq(DimLastSyncRecordEntity::getSubject, "department");
DimLastSyncRecordEntity syncRecord = dimLastSyncRecordDao.selectOne(lastSyncRecordQuery);
if (syncRecord != null) {
dimLastSyncRecordDao.updateLastSyncEndTime("department", syncEndTime);
} else {
syncRecord = new DimLastSyncRecordEntity();
syncRecord.setSubject("department");
syncRecord.setLastSyncTime(syncEndTime);
dimLastSyncRecordDao.insert(syncRecord);
}
}
@Override
public Date getLastSyncEndTime() {
return dimLastSyncRecordDao.getDimLastSyncEndTime("department");
}
}

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

@ -22,16 +22,19 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
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.commons.tools.utils.DateUtils;
import com.epmet.constant.DataSourceConstant;
import com.epmet.constant.OrgSourceTypeConstant;
import com.epmet.dao.evaluationindex.screen.DimLastSyncRecordDao;
import com.epmet.dao.evaluationindex.screen.ScreenCustomerGridDao;
import com.epmet.dto.extract.form.*;
import com.epmet.dto.extract.result.GridInfoResultDTO;
import com.epmet.dto.indexcollect.form.CustomerBizOrgFormDTO;
import com.epmet.dto.screen.ScreenCustomerGridDTO;
import com.epmet.dto.screen.ScreenProjectGridDailyDTO;
import com.epmet.entity.evaluationindex.screen.DimLastSyncRecordEntity;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerGridEntity;
import com.epmet.entity.org.CustomerGridEntity;
import com.epmet.service.evaluationindex.screen.ScreenCustomerGridService;
@ -57,6 +60,8 @@ public class ScreenCustomerGridServiceImpl extends BaseServiceImpl<ScreenCustome
@Autowired
private ScreenCustomerGridDao screenCustomerGridDao;
@Autowired
private DimLastSyncRecordDao dimLastSyncRecordDao;
@Override
public ScreenCustomerGridEntity getLastAddGrid() {
@ -70,22 +75,39 @@ public class ScreenCustomerGridServiceImpl extends BaseServiceImpl<ScreenCustome
@Transactional(rollbackFor = Exception.class)
@Override
public void addAndUpdateGrids(List<CustomerGridEntity> grids2Add, List<CustomerGridEntity> grids2Update) {
public void addAndUpdateGrids(List<CustomerGridEntity> grids2Add, List<CustomerGridEntity> grids2Update, Date syncEndTime) {
String dateStr = DateUtils.format(new Date(), "YYYYmmdd");
for (CustomerGridEntity grid : grids2Add) {
ScreenCustomerGridEntity screenGrid = screenCustomerGridDao.getByGridId(grid.getId());
if (screenGrid == null) {
ScreenCustomerGridEntity insertOne = new ScreenCustomerGridEntity();
insertOne.setAllParentIds(grid.getPids());
insertOne.setCustomerId(grid.getCustomerId());
insertOne.setDataEndTime(dateStr);
insertOne.setGridId(grid.getId());
insertOne.setGridName(grid.getGridName());
insertOne.setParentAgencyId(grid.getPid());
insertOne.setSourceType(OrgSourceTypeConstant.INTERNAL);
insertOne.setAreaCode(grid.getAreaCode());
insertOne.setCode(grid.getCode());
screenCustomerGridDao.insert(insertOne);
screenGrid = new ScreenCustomerGridEntity();
screenGrid.setAllParentIds(grid.getPids());
screenGrid.setCustomerId(grid.getCustomerId());
screenGrid.setDataEndTime(dateStr);
screenGrid.setGridId(grid.getId());
screenGrid.setGridName(grid.getGridName());
screenGrid.setParentAgencyId(grid.getPid());
screenGrid.setSourceType(OrgSourceTypeConstant.INTERNAL);
screenGrid.setAreaCode(grid.getAreaCode());
screenGrid.setCode(grid.getCode());
//如果没有区划 则默认暂时不显示
if (StringUtils.isEmpty(grid.getAreaCode())) {
screenGrid.setIsDisplay(NumConstant.ZERO_STR);
} else {
screenGrid.setIsDisplay(NumConstant.ONE_STR);
}
screenCustomerGridDao.insert(screenGrid);
} else {
screenGrid.setAllParentIds(grid.getPids());
screenGrid.setCustomerId(grid.getCustomerId());
screenGrid.setDataEndTime(dateStr);
screenGrid.setGridId(grid.getId());
screenGrid.setGridName(grid.getGridName());
screenGrid.setParentAgencyId(grid.getPid());
//screenGrid.setSourceType(OrgSourceTypeConstant.INTERNAL);
screenGrid.setAreaCode(grid.getAreaCode());
screenGrid.setCode(grid.getCode());
screenCustomerGridDao.updateById(screenGrid);
}
}
@ -109,6 +131,19 @@ public class ScreenCustomerGridServiceImpl extends BaseServiceImpl<ScreenCustome
}
}
}
// 保存同步记录
Date lastSyncEndTime = dimLastSyncRecordDao.getDimLastSyncEndTime("grid");
if (lastSyncEndTime == null) {
// 首次初始化,没有上次执行记录,插入一条
DimLastSyncRecordEntity insertRecord = new DimLastSyncRecordEntity();
insertRecord.setSubject("grid");
insertRecord.setLastSyncTime(syncEndTime);
dimLastSyncRecordDao.insert(insertRecord);
} else {
// 更新
dimLastSyncRecordDao.updateLastSyncEndTime("grid", syncEndTime);
}
}
/**
@ -250,4 +285,9 @@ public class ScreenCustomerGridServiceImpl extends BaseServiceImpl<ScreenCustome
List<ScreenCustomerGridEntity> list = baseDao.selectList(wrapper);
return ConvertUtils.sourceToTarget(list, ScreenCustomerGridDTO.class).stream().collect(Collectors.toMap(ScreenCustomerGridDTO::getGridId, Function.identity()));
}
@Override
public Date getLastSyncEndTime() {
return dimLastSyncRecordDao.getDimLastSyncEndTime("grid");
}
}

138
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/EIDimServiceImpl.java

@ -2,9 +2,6 @@ package com.epmet.service.impl;
import com.epmet.dto.screen.ScreenProjectGridDailyDTO;
import com.epmet.dto.screen.form.GridCenterPointForm;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerGridEntity;
import com.epmet.entity.org.CustomerAgencyEntity;
import com.epmet.entity.org.CustomerDepartmentEntity;
import com.epmet.entity.org.CustomerGridEntity;
@ -45,10 +42,11 @@ public class EIDimServiceImpl implements EIDimService {
@Override
public void initAgencies() {
List<CustomerAgencyEntity> agencies2Add = listAgencies2Add();
List<CustomerAgencyEntity> agencies2Update = listAgencies2Update();
Date statsEndTime = new Date();//DateUtils.integrate(new Date(), DateUtils.DATE_PATTERN);
List<CustomerAgencyEntity> agencies2Add = listAgencies2Add(statsEndTime);
List<CustomerAgencyEntity> agencies2Update = listAgencies2Update(statsEndTime);
screenCustomerAgencyService.initAgencies(agencies2Add, agencies2Update);
screenCustomerAgencyService.initAgencies(agencies2Add, agencies2Update, statsEndTime);
}
/**
@ -56,17 +54,9 @@ public class EIDimServiceImpl implements EIDimService {
*
* @return
*/
private List<CustomerAgencyEntity> listAgencies2Update() {
ScreenCustomerAgencyEntity e = screenCustomerAgencyService.getLastUpdatedAgency();
if (e != null) {
// 说明不是第一次初始化
Date startTime = e.getUpdatedTime();
Date endTime = new Date();
return originCustomerAgencyService.listAgenciesByUpdatedTime(startTime, endTime);
}
return new ArrayList<>();
private List<CustomerAgencyEntity> listAgencies2Update(Date endTime) {
Date startTime = screenCustomerAgencyService.getDimLastSyncTime();
return originCustomerAgencyService.listAgenciesByUpdatedTime(startTime, endTime);
}
/**
@ -74,23 +64,17 @@ public class EIDimServiceImpl implements EIDimService {
*
* @return
*/
private List<CustomerAgencyEntity> listAgencies2Add() {
ScreenCustomerAgencyEntity e = screenCustomerAgencyService.getLastAddedAgency();
Date endTime = new Date();
Date startTime = null;
if (e != null) {
startTime = e.getCreatedTime();
}
private List<CustomerAgencyEntity> listAgencies2Add(Date endTime) {
Date startTime = screenCustomerAgencyService.getDimLastSyncTime();
return originCustomerAgencyService.listAgenciesByCreateTime(null, startTime, endTime);
}
@Override
public void initDepartments() {
List<CustomerDepartmentEntity> depts2Add = listDepts2Add();
List<CustomerDepartmentEntity> depts2Update = listDepts2Update();
screenCustomerDeptService.addAndUpdateDepartments(depts2Add, depts2Update);
Date syncEndTime = new Date();//DateUtils.integrate(new Date(), DateUtils.DATE_PATTERN);
List<CustomerDepartmentEntity> depts2Add = listDepts2Add(syncEndTime);
List<CustomerDepartmentEntity> depts2Update = listDepts2Update(syncEndTime);
screenCustomerDeptService.addAndUpdateDepartments(depts2Add, depts2Update, syncEndTime);
}
/**
@ -98,17 +82,19 @@ public class EIDimServiceImpl implements EIDimService {
*
* @return
*/
private List<CustomerDepartmentEntity> listDepts2Update() {
ScreenCustomerDeptEntity lastUpdateDept = screenCustomerDeptService.getLastUpdateDept();
if (lastUpdateDept != null) {
// 不是第一次初始化
Date endTime = new Date();
Date startTime = lastUpdateDept.getUpdatedTime();
return originCustomerDepartmentService.listDepartmentsByUpdatedTime(startTime, endTime);
}
return new ArrayList<>();
private List<CustomerDepartmentEntity> listDepts2Update(Date syncEndTime) {
//ScreenCustomerDeptEntity lastUpdateDept = screenCustomerDeptService.getLastUpdateDept();
//
//if (lastUpdateDept != null) {
// // 不是第一次初始化
// Date endTime = new Date();
// Date startTime = lastUpdateDept.getUpdatedTime();
// return originCustomerDepartmentService.listDepartmentsByUpdatedTime(startTime, endTime);
//}
//return new ArrayList<>();
Date lastSyncEndTime = screenCustomerDeptService.getLastSyncEndTime();
return originCustomerDepartmentService.listDepartmentsByUpdatedTime(lastSyncEndTime, syncEndTime);
}
/**
@ -116,23 +102,25 @@ public class EIDimServiceImpl implements EIDimService {
*
* @return
*/
private List<CustomerDepartmentEntity> listDepts2Add() {
ScreenCustomerDeptEntity lastAddDept = screenCustomerDeptService.getLastAddDept();
Date startTime = null;
Date endTime = new Date();
if (lastAddDept != null) {
startTime = lastAddDept.getCreatedTime();
}
return originCustomerDepartmentService.listDepartmentsByCreatedTime(null, startTime, endTime);
private List<CustomerDepartmentEntity> listDepts2Add(Date syncEndTime) {
//ScreenCustomerDeptEntity lastAddDept = screenCustomerDeptService.getLastAddDept();
//
//Date startTime = null;
//Date endTime = new Date();
//if (lastAddDept != null) {
// startTime = lastAddDept.getCreatedTime();
//}
Date startTime = screenCustomerDeptService.getLastSyncEndTime();
return originCustomerDepartmentService.listDepartmentsByCreatedTime(null, startTime, syncEndTime);
}
@Override
public void initGrids() {
List<CustomerGridEntity> grids2Add = listGrids2Add();
List<CustomerGridEntity> grids2Update = listGrids2Update();
screenCustomerGridService.addAndUpdateGrids(grids2Add, grids2Update);
Date syncEndTime = new Date();//DateUtils.integrate(new Date(), DateUtils.DATE_PATTERN);
List<CustomerGridEntity> grids2Add = listGrids2Add(syncEndTime);
List<CustomerGridEntity> grids2Update = listGrids2Update(syncEndTime);
screenCustomerGridService.addAndUpdateGrids(grids2Add, grids2Update, syncEndTime);
}
@Override
@ -159,26 +147,32 @@ public class EIDimServiceImpl implements EIDimService {
return result;
}
private List<CustomerGridEntity> listGrids2Update() {
ScreenCustomerGridEntity lastUpdateGrid = screenCustomerGridService.getLastUpdateGrid();
if (lastUpdateGrid != null) {
Date endTime = new Date();
Date startTime = lastUpdateGrid.getUpdatedTime();
return customerGridService.listUpdatedGridsByUpdateTime(startTime, endTime);
}
return new ArrayList();
private List<CustomerGridEntity> listGrids2Update(Date syncEndTime) {
//ScreenCustomerGridEntity lastUpdateGrid = screenCustomerGridService.getLastUpdateGrid();
//if (lastUpdateGrid != null) {
// Date endTime = new Date();
// Date startTime = lastUpdateGrid.getUpdatedTime();
// return customerGridService.listUpdatedGridsByUpdateTime(startTime, endTime);
//}
//
//return new ArrayList();
Date lastSyncEndTime = screenCustomerGridService.getLastSyncEndTime();
return customerGridService.listUpdatedGridsByUpdateTime(lastSyncEndTime, syncEndTime);
}
private List<CustomerGridEntity> listGrids2Add() {
ScreenCustomerGridEntity lastAddGrid = screenCustomerGridService.getLastAddGrid();
Date endTime = new Date();
Date startTime = null;
if (lastAddGrid != null) {
startTime = lastAddGrid.getCreatedTime();
}
return customerGridService.listGridsByCreateTime(null, startTime, endTime);
private List<CustomerGridEntity> listGrids2Add(Date syncEndTime) {
//ScreenCustomerGridEntity lastAddGrid = screenCustomerGridService.getLastAddGrid();
//
//Date endTime = new Date();
//Date startTime = null;
//if (lastAddGrid != null) {
// startTime = lastAddGrid.getCreatedTime();
//}
//
//return customerGridService.listGridsByCreateTime(null, startTime, endTime);
Date lastSyncEndTime = screenCustomerGridService.getLastSyncEndTime();
return customerGridService.listGridsByCreateTime(null, lastSyncEndTime, syncEndTime);
}
}

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

@ -202,5 +202,5 @@ public interface ProjectService extends BaseService<ProjectEntity> {
* @param projectId
* @return
*/
Map<String, ResiEventDTO> getEventList(String customerId);
Map<String, ResiEventDTO> getEventList(String customerId, String projectId);
}

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

@ -249,8 +249,8 @@ public class ProjectServiceImpl extends BaseServiceImpl<ProjectDao, ProjectEntit
}
@Override
public Map<String, ResiEventDTO> getEventList(String customerId) {
List<ResiEventDTO> list = baseDao.getEventList(customerId);
public Map<String, ResiEventDTO> getEventList(String customerId, String projectId) {
List<ResiEventDTO> list = baseDao.getEventList(customerId, projectId);
if (org.apache.commons.collections4.CollectionUtils.isEmpty(list)) {
return Collections.emptyMap();
}

15
epmet-module/data-statistical/data-statistical-server/src/main/resources/db/migration/V0.0.27__create_indexdimsyncrecord.sql

@ -0,0 +1,15 @@
create table dim_last_sync_record
(
`ID` varchar(64) primary key comment '主键',
`SUBJECT` varchar(32) not null comment '主体。agency:机关,department:部门,grid:网格',
`LAST_SYNC_TIME` datetime not null comment '最后一次同步时间',
`DEL_FLAG` char(1) NOT NULL DEFAULT '0' COMMENT '删除标识 0未删除;1已删除',
`REVISION` int(11) NOT NULL COMMENT '乐观锁',
`CREATED_BY` varchar(64) NOT NULL COMMENT '创建人',
`CREATED_TIME` datetime NOT NULL COMMENT '创建时间',
`UPDATED_BY` varchar(64) NOT NULL COMMENT '更新人',
`UPDATED_TIME` datetime NOT NULL COMMENT '更新时间'
) default character set utf8mb4 engine InnoDB;
create unique index dim_last_sync_record_SUBJECT_uindex
on dim_last_sync_record (SUBJECT);

31
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/DimLastSyncRecordDao.xml

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.evaluationindex.screen.DimLastSyncRecordDao">
<resultMap type="com.epmet.entity.evaluationindex.screen.DimLastSyncRecordEntity" id="dimLastSyncRecordMap">
<result property="id" column="ID"/>
<result property="subject" column="SUBJECT"/>
<result property="lastSyncTime" column="LAST_SYNC_TIME"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<update id="updateLastSyncEndTime">
update dim_last_sync_record
set LAST_SYNC_TIME = #{statsEndTime}
where SUBJECT = #{subject}
and DEL_FLAG = '0'
</update>
<!--查询最后一次维度同步时间-->
<select id="getDimLastSyncEndTime" resultType="java.util.Date">
select LAST_SYNC_TIME
from dim_last_sync_record
where SUBJECT = #{subject}
and DEL_FLAG = '0'
</select>
</mapper>

6
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerDepartmentDao.xml

@ -44,7 +44,9 @@
from customer_department cd
LEFT JOIN customer_agency ca ON (
cd.AGENCY_ID = ca.id and ca.DEL_FLAG='0')
where cd.UPDATED_TIME > #{startTime}
and cd.UPDATED_TIME <![CDATA[<=]]> #{endTime}
where
cd.CREATED_TIME <![CDATA[<]]> #{startTime}
and cd.UPDATED_TIME >= #{startTime}
and cd.UPDATED_TIME <![CDATA[<]]> #{endTime}
</select>
</mapper>

1
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml

@ -71,6 +71,7 @@
pids
FROM customer_grid
WHERE SYNC_FLAG='1'
AND CREATED_TIME <![CDATA[<]]> #{startTime}
AND UPDATED_TIME >= #{startTime}
AND UPDATED_TIME <![CDATA[<]]> #{endTime}
</select>

5
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/StatsCustomerAgencyDao.xml

@ -102,9 +102,10 @@
district,
PARENT_AREA_CODE as parentAreaCode
from customer_agency
where SYNC_FLAG='1'
where SYNC_FLAG='1'
AND CREATED_TIME <![CDATA[<]]> #{startTime}
AND UPDATED_TIME >= #{startTime}
and UPDATED_TIME <![CDATA[<=]]> #{endTime}
AND UPDATED_TIME <![CDATA[<]]> #{endTime}
</select>
<!-- 查询客户所属区域编码 -->

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

@ -259,6 +259,9 @@
from resi_event_report_org rero
inner join resi_event re on rero.RESI_EVENT_ID = re.id and re.SHIFT_PROJECT = 1 and re.DEL_FLAG = '0'
where rero.del_flag = '0'
<if test="projectId != null and projectId != ''">
AND re.PROJECT_ID = #{projectId}
</if>
and rero.CUSTOMER_ID = #{customerId}
</select>

8
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java

@ -75,4 +75,12 @@ public interface EpmetHeartOpenFeignClient {
*/
@PostMapping("/heart/residemand/autoevaluate")
Result AutoEvaluateDemand(@RequestBody AutoEvaluateDemandFormDTO formDTO);
/**
* 查询志愿者数量
* @param input
* @return
*/
@PostMapping("/heart/resi/volunteer/count")
Result<Integer> getVolunteerCount(@RequestBody VolunteerCommonFormDTO input);
}

5
epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java

@ -71,4 +71,9 @@ public class EpmetHeartOpenFeignClientFallback implements EpmetHeartOpenFeignCli
public Result AutoEvaluateDemand(AutoEvaluateDemandFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_HEART_SERVER, "autoEvaluate",formDTO);
}
@Override
public Result<Integer> getVolunteerCount(VolunteerCommonFormDTO input) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_HEART_SERVER, "getVolunteerCount", input);
}
}

14
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiVolunteerController.java

@ -145,4 +145,18 @@ public class ResiVolunteerController {
List<PageVolunteerInfoResultDTO> l = volunteerInfoService.queryVolunteerPage(customerId, pageNo, pageSize, superiorAgencyId);
return new Result<List<PageVolunteerInfoResultDTO>>().ok(l);
}
/**
* 查询志愿者数量
* @param input
* @return
*/
@PostMapping("count")
public Result<Integer> getVolunteerCount(@RequestBody VolunteerCommonFormDTO input) {
ValidatorUtils.validateEntity(input, VolunteerCommonFormDTO.VolunteerPage.class);
String customerId = input.getCustomerId();
Integer volunteerCount = volunteerInfoService.getVolunteerCount(customerId);
return new Result<Integer>().ok(volunteerCount);
}
}

9
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcPartyUnitService.java

@ -114,6 +114,15 @@ public interface IcPartyUnitService extends BaseService<IcPartyUnitEntity> {
*/
List<OptionDTO> option(IcPartyUnitDTO dto);
/**
* @Description 获取组织以及下级单位列表
* @Param dto
* @Return {@link List< OptionDTO>}
* @Author zhaoqifeng
* @Date 2021/11/22 14:35
*/
List<OptionDTO> options(IcPartyUnitDTO dto);
/**
* 导入数据
* @Param tokenDto

7
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/VolunteerInfoService.java

@ -96,4 +96,11 @@ public interface VolunteerInfoService extends BaseService<VolunteerInfoEntity> {
List<OptionDTO> queryListVolunteer(String customerId,String staffId,String userRealName);
List<PageVolunteerInfoResultDTO> queryVolunteerPage(String customerId, Integer pageNo, Integer pageSize, String superiorAgencyId);
/**
* 查询志愿者数量
* @param customerId
* @return
*/
Integer getVolunteerCount(String customerId);
}

2
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyActivityServiceImpl.java

@ -366,7 +366,7 @@ public class IcPartyActivityServiceImpl extends BaseServiceImpl<IcPartyActivityD
unitDTO.setAgencyId(formDTO.getAgencyId());
if (CollectionUtils.isNotEmpty(dtoList)) {
//获取联建单位
Map<String, String> option = icPartyUnitService.option(unitDTO).stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel));
Map<String, String> option = icPartyUnitService.options(unitDTO).stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel));
//获取服务事项字典
SubCodeFormDTO codeFormDTO = new SubCodeFormDTO();
codeFormDTO.setCustomerId(tokenDto.getCustomerId());

21
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyUnitServiceImpl.java

@ -193,7 +193,7 @@ public class IcPartyUnitServiceImpl extends BaseServiceImpl<IcPartyUnitDao, IcPa
}
insert(entity);
} else {
if (CollectionUtils.isNotEmpty(list) && list.get(0).getId().equals(entity.getId())) {
if (CollectionUtils.isNotEmpty(list) && !list.get(0).getId().equals(entity.getId())) {
throw new EpmetException(EpmetErrorCode.PARTY_UNIT_NAME_EXITED.getCode(), EpmetErrorCode.PARTY_UNIT_NAME_EXITED.getMsg(), EpmetErrorCode.PARTY_UNIT_NAME_EXITED.getMsg());
}
updateById(entity);
@ -261,6 +261,25 @@ public class IcPartyUnitServiceImpl extends BaseServiceImpl<IcPartyUnitDao, IcPa
}).collect(Collectors.toList());
}
@Override
public List<OptionDTO> options(IcPartyUnitDTO dto) {
LambdaQueryWrapper<IcPartyUnitEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.and(wp -> wp.eq(IcPartyUnitEntity::getAgencyId, dto.getAgencyId()).or().
like(IcPartyUnitEntity::getPids, dto.getAgencyId()));
wrapper.orderByDesc(IcPartyUnitEntity::getUpdatedTime);
wrapper.eq(StringUtils.isNotBlank(dto.getServiceMatter()), IcPartyUnitEntity::getServiceMatter, dto.getServiceMatter());
List<IcPartyUnitEntity> list = baseDao.selectList(wrapper);
if (CollectionUtils.isEmpty(list)) {
return Collections.emptyList();
}
return list.stream().map(item -> {
OptionDTO option = new OptionDTO();
option.setValue(item.getId());
option.setLabel(item.getUnitName());
return option;
}).collect(Collectors.toList());
}
/**
* 导入数据
*

7
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java

@ -383,4 +383,11 @@ public class VolunteerInfoServiceImpl extends BaseServiceImpl<VolunteerInfoDao,
return list;
}
@Override
public Integer getVolunteerCount(String customerId) {
LambdaQueryWrapper<VolunteerInfoEntity> query = new LambdaQueryWrapper<>();
query.eq(VolunteerInfoEntity::getCustomerId, customerId);
return baseDao.selectCount(query);
}
}

6
epmet-module/epmet-job/epmet-job-server/pom.xml

@ -96,6 +96,12 @@
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>gov-issue-client</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

3
epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/feign/GovIssueFeignClient.java

@ -2,6 +2,7 @@ package com.epmet.feign;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.DailyStatisticalVoteJob;
import com.epmet.feign.impl.GovIssueFeignClientFallBack;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
@ -22,7 +23,7 @@ public interface GovIssueFeignClient {
* @date 2020.05.20 15:39
**/
@PostMapping(value = "gov/issue/issuevotestatisticaldaily/dailystatisticalvotejob")
Result dailyStatisticalVoteJob();
Result dailyStatisticalVoteJob(DailyStatisticalVoteJob form);
/**
* @Description 将所有表决中的投票数从缓存同步到数据库要进行数据对比若数据一致无需更新

5
epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/feign/impl/GovIssueFeignClientFallBack.java

@ -3,6 +3,7 @@ package com.epmet.feign.impl;
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.DailyStatisticalVoteJob;
import com.epmet.feign.GovIssueFeignClient;
import org.springframework.stereotype.Component;
@ -15,8 +16,8 @@ import org.springframework.stereotype.Component;
@Component
public class GovIssueFeignClientFallBack implements GovIssueFeignClient {
@Override
public Result dailyStatisticalVoteJob() {
return ModuleUtils.feignConError(ServiceConstant.GOV_ISSUE_SERVER, "dailyStatisticalVoteJob");
public Result dailyStatisticalVoteJob(DailyStatisticalVoteJob form) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ISSUE_SERVER, "dailyStatisticalVoteJob",form);
}
@Override

3
epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/IssueVotingDailyStatisticalTaskService.java

@ -2,6 +2,7 @@ package com.epmet.service;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.DailyStatisticalVoteJob;
/**
* @Description 生成议题表决日统计数定时任务
@ -10,6 +11,6 @@ import com.epmet.commons.tools.utils.Result;
*/
public interface IssueVotingDailyStatisticalTaskService {
Result issueVotingDailyStatistical();
Result issueVotingDailyStatistical(DailyStatisticalVoteJob form);
}

5
epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/IssueVotingDailyStatisticalTaskServiceImpl.java

@ -1,6 +1,7 @@
package com.epmet.service.impl;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.DailyStatisticalVoteJob;
import com.epmet.feign.GovIssueFeignClient;
import com.epmet.service.IssueVotingDailyStatisticalTaskService;
import org.springframework.beans.factory.annotation.Autowired;
@ -18,7 +19,7 @@ public class IssueVotingDailyStatisticalTaskServiceImpl implements IssueVotingDa
private GovIssueFeignClient govIssueFeignClient;
@Override
public Result issueVotingDailyStatistical() {
return govIssueFeignClient.dailyStatisticalVoteJob();
public Result issueVotingDailyStatistical(DailyStatisticalVoteJob form) {
return govIssueFeignClient.dailyStatisticalVoteJob(form);
}
}

9
epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/DailyStatisticalVoteTask.java

@ -1,7 +1,10 @@
package com.epmet.task;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.DailyStatisticalVoteJob;
import com.epmet.service.IssueVotingDailyStatisticalTaskService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -24,7 +27,11 @@ public class DailyStatisticalVoteTask implements ITask{
@Override
public void run(String params) {
logger.debug("dailyStatisticalVoteTask定时任务正在执行,参数为:{}", params);
Result result=issueVotingDailyStatisticalTaskService.issueVotingDailyStatistical();
DailyStatisticalVoteJob form = new DailyStatisticalVoteJob();
if (StringUtils.isNotBlank(params)) {
form = JSON.parseObject(params, DailyStatisticalVoteJob.class);
}
Result result=issueVotingDailyStatisticalTaskService.issueVotingDailyStatistical(form);
if(result.success()){
logger.debug("dailyStatisticalVoteTask定时任务正在执行定时任务执行成功");
}else{

5
epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/PolyLineDTO.java

@ -1,5 +1,6 @@
package com.epmet.dto;
import com.epmet.commons.tools.constant.NumConstant;
import lombok.Data;
import java.io.Serializable;
@ -29,4 +30,8 @@ public class PolyLineDTO implements Serializable {
*/
private Integer oppositionIncrement;
public PolyLineDTO() {
this.supportIncrement = NumConstant.ZERO;
this.oppositionIncrement = NumConstant.ZERO;
}
}

26
epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/DailyStatisticalVoteJob.java

@ -0,0 +1,26 @@
package com.epmet.dto.form;
import lombok.Data;
import java.io.Serializable;
/**
* @Author zxc
* @DateTime 2021/12/29 10:56 上午
* @DESC
*/
@Data
public class DailyStatisticalVoteJob implements Serializable {
private static final long serialVersionUID = -3685299478100771134L;
private String customerId;
private String dateId;
private String startDate;
private String endDate;
}

5
epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/ResiBuzzLeftPieChartFormDTO.java

@ -23,4 +23,9 @@ public class ResiBuzzLeftPieChartFormDTO implements Serializable {
* 组织类型agency组织grid网格
*/
private String orgType;
/**
* 表决中voting 已转项目shift_project 已关闭closed全部all
*/
private String status = "all";
}

70
epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/result/DailyStatisticalVoteJobResultDTO.java

@ -0,0 +1,70 @@
package com.epmet.dto.result;
import com.epmet.commons.tools.constant.NumConstant;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* @Author zxc
* @DateTime 2021/12/29 1:52 下午
* @DESC
*/
@Data
public class DailyStatisticalVoteJobResultDTO implements Serializable {
private static final long serialVersionUID = 5266996778036448163L;
private String issueId;
/**
* 统计日期
*/
private Date statisticalDate;
/**
* 到该日的总赞成数
*/
private Integer supportCount;
/**
* 到该日的总反对数
*/
private Integer oppositionCount;
/**
* 到该日的总票数
*/
private Integer totalCount;
/**
* 该日增量
*/
private Integer todayIncrement;
/**
* 该日赞成增量
*/
private Integer supportIncrement;
/**
* 该日反对增量
*/
private Integer oppositionIncrement;
/**
* 应表决数
*/
private Integer votableCount;
public DailyStatisticalVoteJobResultDTO() {
this.supportCount = NumConstant.ZERO;
this.oppositionCount = NumConstant.ZERO;
this.totalCount = NumConstant.ZERO;
this.todayIncrement = NumConstant.ZERO;
this.supportIncrement = NumConstant.ZERO;
this.oppositionIncrement = NumConstant.ZERO;
this.votableCount = NumConstant.ZERO;
}
}

2
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueManageController.java

@ -83,7 +83,7 @@ public class IssueManageController {
* @author zxc
*/
@PostMapping("votingtrend")
@RequirePermission(requirePermission = RequirePermissionEnum.WORK_GRASSROOTS_ISSUE_DETAIL)
// @RequirePermission(requirePermission = RequirePermissionEnum.WORK_GRASSROOTS_ISSUE_DETAIL)
public Result<VotingTrendResultDTO> votingTrend(@RequestBody IssueIdFormDTO issueId){
return new Result<VotingTrendResultDTO>().ok(issueVoteStatisticalService.votingTrend(issueId));
}

6
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueVoteStatisticalDailyController.java

@ -26,6 +26,7 @@ import com.epmet.commons.tools.validator.group.AddGroup;
import com.epmet.commons.tools.validator.group.UpdateGroup;
import com.epmet.commons.tools.validator.group.DefaultGroup;
import com.epmet.dto.IssueVoteStatisticalDailyDTO;
import com.epmet.dto.form.DailyStatisticalVoteJob;
import com.epmet.excel.IssueVoteStatisticalDailyExcel;
import com.epmet.service.IssueVoteStatisticalDailyService;
import org.springframework.beans.factory.annotation.Autowired;
@ -99,8 +100,9 @@ public class IssueVoteStatisticalDailyController {
* @date 2020.05.20 15:39
**/
@PostMapping(value = "dailystatisticalvotejob")
public Result dailyStatisticalVoteJob(){
issueVoteStatisticalDailyService.countVotingDailyStatistic();
public Result dailyStatisticalVoteJob(@RequestBody DailyStatisticalVoteJob form){
// issueVoteStatisticalDailyService.countVotingDailyStatistic();
issueVoteStatisticalDailyService.countVotingDailyStatisticNew(form);
return new Result();
}
}

2
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueDao.java

@ -272,7 +272,7 @@ public interface IssueDao extends BaseDao<IssueEntity> {
* @author zxc
* @date 2021/12/30 9:16 上午
*/
List<String> resiBuzzLeftPieChartIssueIds(@Param("orgId")String orgId,@Param("orgType")String orgType);
List<String> resiBuzzLeftPieChartIssueIds(@Param("orgId")String orgId,@Param("orgType")String orgType,@Param("status")String status);
/**
* @Description 查询组织下每个网格的项目数

21
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueVoteDetailDao.java

@ -19,8 +19,10 @@ package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.IssueVoteDetailDTO;
import com.epmet.dto.PolyLineDTO;
import com.epmet.dto.form.VoteFormDTO;
import com.epmet.dto.form.VoteRedisFormDTO;
import com.epmet.dto.result.DailyStatisticalVoteJobResultDTO;
import com.epmet.dto.result.IssueAttitudeCountResultDTO;
import com.epmet.dto.result.IssueVoteResultDTO;
import com.epmet.dto.result.MyPartIssuesResultDTO;
@ -130,4 +132,23 @@ public interface IssueVoteDetailDao extends BaseDao<IssueVoteDetailEntity> {
* @date 2021/5/12 1:48 下午
*/
List<IssueVoteResultDTO> selectIssueVoteCountBatch(@Param("issueIds")List<String> issueIds);
/**
* @Description 查询客户下的议题表决日增
* @param customerId
* @param dateId 当dateId为空时查询的是累计值
* @author zxc
* @date 2021/12/29 2:02 下午
*/
List<DailyStatisticalVoteJobResultDTO> statisticVote(@Param("customerId")String customerId,@Param("dateId")String dateId);
/**
* @Description 根据议题ID查询折线图一天的数据
* @param issueId
* @param dateId
* @author zxc
* @date 2021/12/29 4:19 下午
*/
PolyLineDTO polyLineData(@Param("issueId")String issueId,@Param("dateId")String dateId);;
}

9
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueVoteStatisticalDailyDao.java

@ -78,4 +78,13 @@ public interface IssueVoteStatisticalDailyDao extends BaseDao<IssueVoteStatistic
* @date 2020.05.20 14:54
**/
void updateBatch(@Param("list") List<IssueVoteStatisticalDailyEntity> list);
/**
* @Description 删除历史数据
* @param customerId
* @param dateId
* @author zxc
* @date 2021/12/29 2:51 下午
*/
Integer delHistoryData(@Param("customerId")String customerId,@Param("dateId")String dateId);
}

5
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/redis/IssueVoteDetailRedis.java

@ -264,6 +264,11 @@ public class IssueVoteDetailRedis {
formDTO.setIssueId(issueId);
formDTO.setGridId(issue.getGridId());
voteCache = issueVoteDetailService.selectIssueVotingDetail(formDTO);
IssueVoteStatisticalDTO dto = ConvertUtils.sourceToTarget(voteCache, IssueVoteStatisticalDTO.class);
dto.setVotableCount(voteCache.getShouldVoteCount());
dto.setSupportCount(voteCache.getSupportAmount());
dto.setOppositionCount(voteCache.getOppositionAmount());
issueVoteStatisticalDao.updateBtIssueId(dto);
}else {
// 状态是关闭,转议题的,直接从结果表查询
voteCache = issueVoteStatisticalDao.selectVoteDetail(issueId);

9
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueVoteStatisticalDailyService.java

@ -20,6 +20,7 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.IssueVoteStatisticalDailyDTO;
import com.epmet.dto.form.DailyStatisticalVoteJob;
import com.epmet.entity.IssueVoteStatisticalDailyEntity;
import java.util.List;
@ -101,4 +102,12 @@ public interface IssueVoteStatisticalDailyService extends BaseService<IssueVoteS
* @date 2020.05.19 09:23
**/
void countVotingDailyStatistic();
/**
* @Description 统计前一天所有有表决动作的议题
* @param
* @author zxc
* @date 2021/12/29 10:31 上午
*/
void countVotingDailyStatisticNew(DailyStatisticalVoteJob form);
}

2
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java

@ -1678,7 +1678,7 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp
// 分类编码长度
Integer length = baseDao.selectOneLevelCategoryLength(tokenDto.getCustomerId());
// List<ResiBuzzLeftPieChartResultDTO> result = baseDao.resiBuzzLeftPieChart(formDTO.getOrgId(), formDTO.getOrgType(), length, tokenDto.getCustomerId());
List<String> issueIds = baseDao.resiBuzzLeftPieChartIssueIds(formDTO.getOrgId(), formDTO.getOrgType());
List<String> issueIds = baseDao.resiBuzzLeftPieChartIssueIds(formDTO.getOrgId(), formDTO.getOrgType(),formDTO.getStatus());
if(CollectionUtils.isEmpty(issueIds)){
return new ArrayList<>();
}

81
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueVoteStatisticalDailyServiceImpl.java

@ -21,18 +21,27 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dao.IssueVoteDetailDao;
import com.epmet.dao.IssueVoteStatisticalDailyDao;
import com.epmet.dto.CustomerDTO;
import com.epmet.dto.IssueVoteStatisticalDailyDTO;
import com.epmet.dto.form.DailyStatisticalVoteJob;
import com.epmet.dto.result.DailyStatisticalVoteJobResultDTO;
import com.epmet.dto.result.IssuesToBeCountedResultDTO;
import com.epmet.entity.IssueVoteStatisticalDailyEntity;
import com.epmet.feign.OperCrmOpenFeignClient;
import com.epmet.redis.IssueVoteStatisticalDailyRedis;
import com.epmet.service.IssueVoteStatisticalDailyService;
import com.epmet.utils.ModuleConstants;
import oracle.sql.NUMBER;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -40,6 +49,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
@ -58,6 +68,9 @@ public class IssueVoteStatisticalDailyServiceImpl extends BaseServiceImpl<IssueV
@Autowired
private IssueVoteDetailDao issueVoteDetailDao;
@Autowired
private OperCrmOpenFeignClient operCrmOpenFeignClient;
protected static final Logger logger = LoggerFactory.getLogger(IssueVoteStatisticalDailyServiceImpl.class);
@Override
@ -303,4 +316,72 @@ public class IssueVoteStatisticalDailyServiceImpl extends BaseServiceImpl<IssueV
}
/**
* @Description 统计前一天所有有表决动作的议题
* @param
* @author zxc
* @date 2021/12/29 10:31 上午
*/
@Override
public void countVotingDailyStatisticNew(DailyStatisticalVoteJob form) {
// 先处理下纬度
List<String> customerIds = new ArrayList<>();
if (StringUtils.isBlank(form.getCustomerId())){
Result<List<CustomerDTO>> allCustomerList = operCrmOpenFeignClient.getAllCustomerList();
if (!allCustomerList.success() || CollectionUtils.isEmpty(allCustomerList.getData())){
throw new EpmetException("查询所有客户失败...");
}
customerIds = allCustomerList.getData().stream().map(m -> m.getId()).collect(Collectors.toList());
}else {
customerIds.add(form.getCustomerId());
}
if (StringUtils.isNotBlank(form.getStartDate()) && StringUtils.isNotBlank(form.getEndDate())){
List<String> daysBetween = DateUtils.getDaysBetween(form.getStartDate(), form.getEndDate());
customerIds.forEach(customerId -> {
daysBetween.forEach(dateId -> {
statisticVote(customerId,dateId);
});
});
}else {
if (StringUtils.isBlank(form.getDateId())){
form.setDateId(LocalDate.now().minusDays(NumConstant.ONE).toString().replace("-", ""));
}
customerIds.forEach(customerId -> {
statisticVote(customerId, form.getDateId());
});
}
}
/**
* @Description 统计 issue_vote_statistical_daily
* 只统计表决日增存在的不存在的不写入查询程序补全
* @param customerId
* @param dateId 格式YYYY-MM-DD
* @author zxc
* @date 2021/12/29 1:46 下午
*/
@Transactional(rollbackFor = Exception.class)
public void statisticVote(String customerId,String dateId){
// 日增
List<DailyStatisticalVoteJobResultDTO> dayAdd = issueVoteDetailDao.statisticVote(customerId, dateId);
if (CollectionUtils.isNotEmpty(dayAdd)){
//累计
List<DailyStatisticalVoteJobResultDTO> allDayAdd = issueVoteDetailDao.statisticVote(customerId, null);
dayAdd.forEach(d -> allDayAdd.stream().filter(a -> a.getIssueId().equals(d.getIssueId())).forEach(a -> {
d.setOppositionCount(a.getOppositionCount());
d.setSupportCount(a.getSupportCount());
d.setTotalCount(a.getTotalCount());
}));
List<IssueVoteStatisticalDailyEntity> needInsert = ConvertUtils.sourceToTarget(dayAdd, IssueVoteStatisticalDailyEntity.class);
Integer delNum;
do {
delNum = baseDao.delHistoryData(customerId, dateId);
} while (delNum != null && delNum > NumConstant.ZERO);
List<List<IssueVoteStatisticalDailyEntity>> partition = ListUtils.partition(needInsert, NumConstant.ONE_HUNDRED);
partition.forEach(p -> {
baseDao.insertBatch(p);
});
}
}
}

61
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueVoteStatisticalServiceImpl.java

@ -27,6 +27,7 @@ import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.IssueConstant;
import com.epmet.dao.IssueDao;
@ -66,6 +67,9 @@ import java.time.ZoneOffset;
import java.util.*;
import java.util.stream.Collectors;
import static com.epmet.commons.tools.utils.DateUtils.DATE_PATTERN;
import static com.epmet.commons.tools.utils.DateUtils.DATE_PATTERN_YYYYMMDD;
/**
* 议题表决统计表
*
@ -205,12 +209,36 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl<IssueVoteSt
votingTrendResultDTO.setRealityVoteCount(voteRedisFormDTO.getSupportAmount() + voteRedisFormDTO.getOppositionAmount());
//DB获取表决 日统计详情
List<PolyLineDTO> polyLineDTOS = issueVoteStatisticalDao.polyLineData(issueId);
PolyLineDTO polyLineDTO = new PolyLineDTO();
polyLineDTO.setVoteDate(LocalDateTime.now().toEpochSecond(ZoneOffset.of(IssueConstant.BEIJING_TIME_ZONE)));
// PolyLineDTO polyLineDTO = new PolyLineDTO();
// polyLineDTO.setVoteDate(LocalDateTime.now().toEpochSecond(ZoneOffset.of(IssueConstant.BEIJING_TIME_ZONE)));
//议题 已转项目 或 已结案 的时间
String date = issueDao.operateTime(issueId.getIssueId());
// String date = issueDao.operateTime(issueId.getIssueId());
IssueEntity issueEntity = issueDao.selectById(issueId.getIssueId());
String startDate = DateUtils.format(issueEntity.getDecidedTime(),DATE_PATTERN);
String endDate = null == issueEntity.getVotingDeadline() ?
DateUtils.format(new Date(),DATE_PATTERN) :
DateUtils.format(issueEntity.getVotingDeadline(),DATE_PATTERN);
List<PolyLineDTO> polyLine = getPolyLine(startDate, endDate);
String today = LocalDate.now().toString();
if (today.equals(endDate)){
PolyLineDTO polyLineDTO = issueVoteDetailDao.polyLineData(issueId.getIssueId(), endDate);
polyLine.get(polyLine.size() - NumConstant.ONE).setSupportIncrement(polyLineDTO.getSupportIncrement());
polyLine.get(polyLine.size() - NumConstant.ONE).setOppositionIncrement(polyLineDTO.getOppositionIncrement());
}
if (CollectionUtils.isEmpty(polyLineDTOS)){
votingTrendResultDTO.setPolyLine(polyLine);
return votingTrendResultDTO;
}
polyLineDTOS.forEach(pd -> {
polyLine.forEach(p -> {
if (pd.getVoteDate().equals(p.getVoteDate())){
p.setOppositionIncrement(pd.getOppositionIncrement());
p.setSupportIncrement(pd.getSupportIncrement());
}
});
});
//今天刚转项目或刚刚关闭,当天数据DB没有,直接从缓存拿
if (polyLineDTOS.size() == NumConstant.ZERO && date.equals(LocalDate.now().toString())) {
/*if (polyLineDTOS.size() == NumConstant.ZERO && date.equals(LocalDate.now().toString())) {
polyLineDTO.setSupportIncrement(voteRedisFormDTO.getSupportAmount());
polyLineDTO.setOppositionIncrement(voteRedisFormDTO.getOppositionAmount());
polyLineDTOS.add(polyLineDTO);
@ -222,18 +250,37 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl<IssueVoteSt
polyLineDTOS.add(polyLineDTO);
}
//从古至今一直在表决中
IssueEntity issueEntity = issueDao.selectById(issueId.getIssueId());
if (issueEntity.getIssueStatus().equals(IssueConstant.ISSUE_VOTING)){
polyLineDTO.setSupportIncrement(voteRedisFormDTO.getSupportAmount());
polyLineDTO.setOppositionIncrement(voteRedisFormDTO.getOppositionAmount());
polyLineDTOS.add(polyLineDTO);
}
}
}*/
//今天之前 “已转项目”或“已关闭”
votingTrendResultDTO.setPolyLine(polyLineDTOS);
votingTrendResultDTO.setPolyLine(polyLine);
return votingTrendResultDTO;
}
public List<PolyLineDTO> getPolyLine(String startTime, String endTime){
List<PolyLineDTO> result = new ArrayList<>();
Date start = DateUtils.parse(startTime, DATE_PATTERN);
Date end = DateUtils.parse(endTime, DATE_PATTERN);
Calendar tempStart = Calendar.getInstance();
tempStart.setTime(start);
Calendar tempEnd = Calendar.getInstance();
tempEnd.setTime(end);
// 日期加1(包含结束)
tempEnd.add(Calendar.DATE, +1);
while (tempStart.before(tempEnd)) {
PolyLineDTO dto = new PolyLineDTO();
dto.setVoteDate(tempStart.getTimeInMillis()/1000);
result.add(dto);
tempStart.add(Calendar.DAY_OF_YEAR, 1);
}
return result;
}
/**
* @param formDTO
* @Description 满意度评价列表已关闭

5
epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueDao.xml

@ -641,7 +641,7 @@
<!-- 查询组织下每个网格的项目数 -->
<select id="getProjectCountByGrid" resultType="com.epmet.dto.result.ProjectDistributionAnalysisRightDTO">
SELECT
GRID_ID,
GRID_ID AS orgId,
COUNT(ID) AS count
FROM issue
WHERE DEL_FLAG = '0'
@ -680,6 +680,9 @@
FROM issue i
INNER JOIN issue_vote_statistical s ON (s.ISSUE_ID = i.ID AND s.DEL_FLAG = '0')
WHERE i.DEL_FLAG = '0'
<if test='status != "all" '>
AND i.ISSUE_STATUS = #{status}
</if>
<if test='orgType == "grid" '>
AND i.GRID_ID = #{orgId}
</if>

39
epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueVoteDetailDao.xml

@ -181,4 +181,43 @@
</foreach>
)
</select>
<!-- 查询客户下的议题表决日增 -->
<select id="statisticVote" resultType="com.epmet.dto.result.DailyStatisticalVoteJobResultDTO">
SELECT
vs.votable_count,
<if test="dateId == null">
(t.oppositionCount + t.supportCount) AS totalCount,
</if>
<if test="dateId != null">
(t.oppositionIncrement + t.supportIncrement) AS todayIncrement,
</if>
t.* FROM
(SELECT
vd.ISSUE_ID,
COUNT(CASE WHEN vd.ATTITUDE = 'opposition' THEN 1 END) AS oppositionCount,
COUNT(CASE WHEN vd.ATTITUDE = 'opposition' THEN 1 END) AS oppositionIncrement,
COUNT(CASE WHEN vd.ATTITUDE = 'support' THEN 1 END) AS supportCount,
COUNT(CASE WHEN vd.ATTITUDE = 'support' THEN 1 END) AS supportIncrement,
str_to_date(#{dateId},'%Y-%m-%d') AS statisticalDate
FROM issue_vote_detail vd
WHERE vd.DEL_FLAG = '0'
AND vd.CUSTOMER_ID = #{customerId}
<if test="dateId != null">
AND DATE_FORMAT(vd.CREATED_TIME,'%Y-%m-%d') = #{dateId}
</if>
GROUP BY vd.ISSUE_ID)t
INNER JOIN issue_vote_statistical vs ON (vs.ISSUE_ID = t.ISSUE_ID AND vs.DEL_FLAG = '0')
</select>
<!-- 根据议题ID查询折线图一天的数据 -->
<select id="polyLineData" resultType="com.epmet.dto.PolyLineDTO">
SELECT
COUNT(CASE WHEN vd.ATTITUDE = 'opposition' THEN 1 END) AS oppositionIncrement,
COUNT(CASE WHEN vd.ATTITUDE = 'support' THEN 1 END) AS supportIncrement
FROM issue_vote_detail vd
WHERE vd.DEL_FLAG = '0'
AND DATE_FORMAT(vd.CREATED_TIME,'%Y-%m-%d') = #{dateId}
AND ISSUE_ID = #{issueId}
</select>
</mapper>

9
epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueVoteStatisticalDailyDao.xml

@ -280,4 +280,13 @@
id = #{item.id}
</foreach>
</update>
<!-- 删除历史数据 -->
<delete id="delHistoryData">
DELETE FROM issue_vote_statistical_daily
WHERE CUSTOMER_ID = #{customerId}
AND STATISTICAL_DATE = #{dateId}
LIMIT 1000
</delete>
</mapper>

2
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java

@ -1136,7 +1136,7 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao
if (o == null){
ExtStaffPermissionResultDTO res = baseDao.selectAgencyAndGridById(rootAgency.getAgencyId());
convert2AgencyTreeResult(result,res.getSubAgencyList(),res.getGridList());
redisUtils.set(orgTreeCacheKey,result, 60 * 60 * 24L);
redisUtils.set(orgTreeCacheKey,result, RedisUtils.MINUTE_THIRTY_EXPIRE);
}else {
result = (AgencyTreeResultDTO) o;
}

242
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/VolunteerServiceImpl.java

@ -2,6 +2,7 @@ package com.epmet.service.impl;
import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.feign.ResultDataResolver;
import com.epmet.dao.IcResiUserDao;
import com.epmet.dao.UserBaseInfoDao;
@ -16,7 +17,6 @@ import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.feign.OperCustomizeOpenFeignClient;
import com.epmet.service.VolunteerService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -24,6 +24,8 @@ import org.springframework.stereotype.Service;
import com.google.common.collect.Lists;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
/**
@ -94,136 +96,156 @@ public class VolunteerServiceImpl implements VolunteerService, ResultDataResolve
* @return
*/
public VolunteerDistributionResultDTO getVolunteerDistribution(String customerId, String agencyId) {
//epmetHeartOpenFeignClient.queryVolunteerPage()
VolunteerDistributionResultDTO r = new VolunteerDistributionResultDTO();
// 1.==========分页查询出所有志愿者列表==========
String vcErrorMsg = "【志愿者分布】查询志愿者总数出错";
VolunteerCommonFormDTO volunteerCountForm = new VolunteerCommonFormDTO();
volunteerCountForm.setCustomerId(customerId);
Integer volunteerCount = getResultDataOrThrowsException(epmetHeartOpenFeignClient.getVolunteerCount(volunteerCountForm),
ServiceConstant.EPMET_HEART_SERVER,
EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),
vcErrorMsg,
vcErrorMsg);
if (volunteerCount == null || volunteerCount == 0) {
// 没得志愿者,直接返回
return r;
}
// 1.分页查询出所有志愿者列表
int pageNo = 1;
// 计算页数
int pageSize = 200;
int pageCount = volunteerCount / pageSize;
int lastPageItems = volunteerCount % pageSize;
pageCount = lastPageItems > 0 ? ++pageCount : pageCount;
// 志愿者epmet user id
// 志愿者epmet user id 集合
List<String> volunteerEpmetUserIds = new ArrayList<>();
// 分页查询志愿者的epmet user id
while (true) {
VolunteerCommonFormDTO volunteerForm = new VolunteerCommonFormDTO();
volunteerForm.setCustomerId(customerId);
volunteerForm.setSuperiorAgencyId(agencyId);
volunteerForm.setPageNo(pageNo);
volunteerForm.setPageSize(pageSize);
String errorMsg = "【志愿者分布】分页查询志愿者列表失败";
List<PageVolunteerInfoResultDTO> volunteerPage = getResultDataOrThrowsException(epmetHeartOpenFeignClient.queryVolunteerPage(volunteerForm),
ServiceConstant.EPMET_HEART_SERVER,
EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),
errorMsg,
errorMsg);
// 将本页userId添加到总集中去
volunteerEpmetUserIds.addAll(volunteerPage.stream().map(v -> v.getUserId()).collect(Collectors.toSet()));
if (volunteerPage.size() < pageSize) {
// 说明是最后一页了
break;
}
List<CompletableFuture<Set<String>>> volsPageFutures = new ArrayList<>();
pageNo++;
}
for (int pageNo = 1 ; pageNo <= pageCount ; pageNo ++) {
int pageNoTemp = pageNo;
CompletableFuture<Set<String>> future = CompletableFuture.supplyAsync(() -> {
return listVolunteersByPage(customerId, agencyId, pageNoTemp, pageSize)
.stream()
.map(v -> v.getUserId())
.collect(Collectors.toSet());
});
VolunteerDistributionResultDTO r = new VolunteerDistributionResultDTO();
volsPageFutures.add(future);
}
// 阻塞,等待子线程返回结果,然后添加到志愿者userId集合中去
for (CompletableFuture<Set<String>> future : volsPageFutures) {
try {
volunteerEpmetUserIds.addAll(future.get());
} catch (InterruptedException e) {
log.error("【志愿者分布】异步获取志愿者userId列表被中断:{}", ExceptionUtils.getErrorStackTrace(e));
} catch (ExecutionException e) {
log.error("【志愿者分布】异步获取志愿者userId列表失败:{}", ExceptionUtils.getErrorStackTrace(e));
}
}
log.info("【志愿者分布】查询到志愿者userId公{}个", volunteerEpmetUserIds.size());
// 2.填充ic居民信息
// 2.==========异步填充ic居民信息==========
List<CompletableFuture<List<VolunteerDistributionResultDTO.Distribution>>> volResiInfoFutures = new ArrayList<>();
// 将所有的userId按100固定分割成多个部分,循环用每个部分去查询,然后填充
List<List<String>> volunteerEpmetUserIdParts = Lists.partition(volunteerEpmetUserIds, 100);
for (List<String> volunteerEpmetUserIdPart : volunteerEpmetUserIdParts) {
List<VolunteerDistributionResultDTO.Distribution> icResiInfos = icResiUserDao.listIcResiInfosByUserIds(volunteerEpmetUserIdPart);
// 填充志愿者类型
for (VolunteerDistributionResultDTO.Distribution icResiInfo : icResiInfos) {
// 将志愿者类型列表字符串,切割放到set中
Set<String> volunteerTypes = new HashSet();
String volunteerCategoriesStr = icResiInfo.getVolunteerCategoriesStr();
if (StringUtils.isNotEmpty(volunteerCategoriesStr)) {
String[] vTypes = volunteerCategoriesStr.split(",");
if (vTypes != null && vTypes.length > 0) {
volunteerTypes.addAll(Arrays.asList(vTypes));
}
icResiInfo.setVolunteerCategories(volunteerTypes);
} else {
icResiInfo.setVolunteerCategories(new HashSet<>());
}
log.info("【志愿者分布】查询ic居民信息,切割后,本组的userId个数:{}", volunteerEpmetUserIdPart.size());
// 填充建筑坐标
String msg = "【志愿者分布】查询楼栋信息失败";
IcBuildingDTO building = getResultDataOrThrowsException(govOrgOpenFeignClient.getBuildingById(icResiInfo.getBuildingId()),
ServiceConstant.GOV_ORG_SERVER,
EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), msg, msg);
CompletableFuture<List<VolunteerDistributionResultDTO.Distribution>> future = CompletableFuture.supplyAsync(() -> {
return listIcResiInfosByUserIds(volunteerEpmetUserIdPart);
});
icResiInfo.setEpmetUserId(icResiInfo.getEpmetUserId());
icResiInfo.setIcResiUserId(icResiInfo.getIcResiUserId());
Optional.of(building).ifPresent(b -> {
icResiInfo.setLongitude(b.getLongitude());
icResiInfo.setLatitude(b.getLatitude());
});
volResiInfoFutures.add(future);
}
// 阻塞的,获取各个子线程计算结果
for (CompletableFuture<List<VolunteerDistributionResultDTO.Distribution>> volResiInfoFuture : volResiInfoFutures) {
try {
List<VolunteerDistributionResultDTO.Distribution> distributions = volResiInfoFuture.get();
r.getDistributions().addAll(distributions);
} catch (InterruptedException e) {
log.error("【志愿者分布】异步获取志愿者的居民信息被中断:{}", ExceptionUtils.getErrorStackTrace(e));
} catch (ExecutionException e) {
log.error("【志愿者分布】异步获取志愿者的居民信息失败:{}", ExceptionUtils.getErrorStackTrace(e));
}
r.getDistributions().addAll(icResiInfos);
}
// 就有代码,稳定之后可以删掉
//for (String volunteerEpmetUserId : volunteerEpmetUserIds) {
//
// VolunteerDistributionResultDTO.Distribution distribution = new VolunteerDistributionResultDTO.Distribution();
//
// ResiUserBaseInfoResultDTO userBaseInfo = userBaseInfoDao.selecUserBaseInfoByUserId(volunteerEpmetUserId);
// if (userBaseInfo == null || StringUtils.isBlank(userBaseInfo.getIdNum())){
// log.warn("getVolunteerDistribution selecUserBaseInfoByUserId return null or idCard is null,volunteerEpmetUserId:{}", volunteerEpmetUserId);
// continue;
// }
// //使用身份证号查询ic resi信息
// IcResiUserDTO icResiUserInfo = icResiUserDao.selectIdByIdCard(customerId, userBaseInfo.getIdNum(), null);
// if (icResiUserInfo == null) {
// continue;
// }
//
// // 查询志愿者类别
// List<String> volunteerCategories = icResiUserDao.selectVolunteerByUserId(icResiUserInfo.getId());
// //if (CollectionUtils.isEmpty(volunteerCategories)) {
// // // 此人没有志愿者信息
// // continue;
// //}
//
// // 将志愿者类型列表字符串,切割放到set中
// Set<String> volunteerTypes = new HashSet();
// for (String vTypesString : volunteerCategories) {
// String[] vTypes = vTypesString.split(",");
// if (vTypes != null && vTypes.length > 0) {
// volunteerTypes.addAll(Arrays.asList(vTypes));
// }
// }
//
//
// String msg = "【志愿者分布】查询楼栋信息失败";
// IcBuildingDTO building = getResultDataOrThrowsException(govOrgOpenFeignClient.getBuildingById(icResiUserInfo.getBuildId()),
// ServiceConstant.GOV_ORG_SERVER,
// EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), msg, msg);
//
// distribution.setVolunteerCategories(volunteerTypes);
// distribution.setEpmetUserId(userBaseInfo.getUserId());
// distribution.setIcResiUserId(icResiUserInfo.getId());
// Optional.of(building).ifPresent(b -> {
// distribution.setLongitude(b.getLongitude());
// distribution.setLatitude(b.getLatitude());
// });
//
// r.getDistributions().add(distribution);
//}
return r;
}
/**
* userId列表批量获取他们对应的志愿者信息
* @param volunteerEpmetUserIdPart
* @return
*/
private List<VolunteerDistributionResultDTO.Distribution> listIcResiInfosByUserIds(List<String> volunteerEpmetUserIdPart) {
List<VolunteerDistributionResultDTO.Distribution> icResiInfos = icResiUserDao.listIcResiInfosByUserIds(volunteerEpmetUserIdPart);
// 填充志愿者类型
for (VolunteerDistributionResultDTO.Distribution icResiInfo : icResiInfos) {
// 将志愿者类型列表字符串,切割放到set中
Set<String> volunteerTypes = new HashSet();
String volunteerCategoriesStr = icResiInfo.getVolunteerCategoriesStr();
if (StringUtils.isNotEmpty(volunteerCategoriesStr)) {
String[] vTypes = volunteerCategoriesStr.split(",");
if (vTypes != null && vTypes.length > 0) {
volunteerTypes.addAll(Arrays.asList(vTypes));
}
icResiInfo.setVolunteerCategories(volunteerTypes);
} else {
icResiInfo.setVolunteerCategories(new HashSet<>());
}
// 填充建筑坐标
String msg = "【志愿者分布】查询楼栋信息失败";
IcBuildingDTO building = getResultDataOrThrowsException(govOrgOpenFeignClient.getBuildingById(icResiInfo.getBuildingId()),
ServiceConstant.GOV_ORG_SERVER,
EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), msg, msg);
icResiInfo.setEpmetUserId(icResiInfo.getEpmetUserId());
icResiInfo.setIcResiUserId(icResiInfo.getIcResiUserId());
Optional.of(building).ifPresent(b -> {
icResiInfo.setLongitude(b.getLongitude());
icResiInfo.setLatitude(b.getLatitude());
});
}
return icResiInfos;
}
/**
* 分页查询志愿者列表
* @param customerId
* @param pageNo
* @param pageSize
* @return
*/
private List<PageVolunteerInfoResultDTO> listVolunteersByPage(String customerId, String agencyId, Integer pageNo, Integer pageSize) {
VolunteerCommonFormDTO volunteerForm = new VolunteerCommonFormDTO();
volunteerForm.setCustomerId(customerId);
volunteerForm.setSuperiorAgencyId(agencyId);
volunteerForm.setPageNo(pageNo);
volunteerForm.setPageSize(pageSize);
String errorMsg = "【志愿者分布】分页查询志愿者列表失败";
return getResultDataOrThrowsException(epmetHeartOpenFeignClient.queryVolunteerPage(volunteerForm),
ServiceConstant.EPMET_HEART_SERVER,
EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),
errorMsg,
errorMsg);
}
}

Loading…
Cancel
Save