diff --git a/epmet-commons/epmet-commons-rocketmq/pom.xml b/epmet-commons/epmet-commons-rocketmq/pom.xml new file mode 100644 index 0000000000..41ee2e97e1 --- /dev/null +++ b/epmet-commons/epmet-commons-rocketmq/pom.xml @@ -0,0 +1,21 @@ + + + + epmet-commons + com.epmet + 2.0.0 + + 4.0.0 + + epmet-commons-rocketmq + + + + org.apache.rocketmq + rocketmq-spring-boot-starter + 2.1.1 + + + \ No newline at end of file diff --git a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/ConsomerGroupConstants.java b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/ConsomerGroupConstants.java new file mode 100644 index 0000000000..0bcf7d4aa6 --- /dev/null +++ b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/ConsomerGroupConstants.java @@ -0,0 +1,21 @@ +package com.epmet.commons.rocketmq.constants; + +/** + * 消费者组常量 + */ +public interface ConsomerGroupConstants { + + /** + * 初始化客户角色消费者组 + */ + String INIT_CUSTOMER_ROLES_GROUP = "init_customer_roles_group"; + /** + * 初始化客户自定义消费者组 + */ + String INIT_CUSTOMER_CUSTOMIZE_GROUP = "init_customer_customize_group"; + /** + * 初始化客户组织机构信息分组 + */ + String INIT_CUSTOMER_ORG_GROUP = "init_customer_org_group"; + +} diff --git a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/TopicConstants.java b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/TopicConstants.java new file mode 100644 index 0000000000..d95a829b8f --- /dev/null +++ b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/constants/TopicConstants.java @@ -0,0 +1,5 @@ +package com.epmet.commons.rocketmq.constants; + +public interface TopicConstants { + String INIT_CUSTOMER = "init_customer_topic"; +} diff --git a/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/InitCustomerMQMsg.java b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/InitCustomerMQMsg.java new file mode 100644 index 0000000000..104d77581c --- /dev/null +++ b/epmet-commons/epmet-commons-rocketmq/src/main/java/com/epmet/commons/rocketmq/messages/InitCustomerMQMsg.java @@ -0,0 +1,148 @@ +package com.epmet.commons.rocketmq.messages; + +public class InitCustomerMQMsg { + + private String customerId; + + private InitCustomerAgency agency; + + private InitCustomerStaff staff; + + public static class InitCustomerStaff { + private String agencyId; + private Integer gender; + private String mobile; + private String name; + private String workType; + + public String getAgencyId() { + return agencyId; + } + + public void setAgencyId(String agencyId) { + this.agencyId = agencyId; + } + + public Integer getGender() { + return gender; + } + + public void setGender(Integer gender) { + this.gender = gender; + } + + public String getMobile() { + return mobile; + } + + public void setMobile(String mobile) { + this.mobile = mobile; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getWorkType() { + return workType; + } + + public void setWorkType(String workType) { + this.workType = workType; + } + } + + public static class InitCustomerAgency { + private String agencyId; + private String organizationName; + private String level; + private String areaCode; + private String province; + private String city; + private String district; + + public String getAgencyId() { + return agencyId; + } + + public void setAgencyId(String agencyId) { + this.agencyId = agencyId; + } + + public String getOrganizationName() { + return organizationName; + } + + public void setOrganizationName(String organizationName) { + this.organizationName = organizationName; + } + + public String getLevel() { + return level; + } + + public void setLevel(String level) { + this.level = level; + } + + public String getAreaCode() { + return areaCode; + } + + public void setAreaCode(String areaCode) { + this.areaCode = areaCode; + } + + public String getProvince() { + return province; + } + + public void setProvince(String province) { + this.province = province; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getDistrict() { + return district; + } + + public void setDistrict(String district) { + this.district = district; + } + } + + public String getCustomerId() { + return customerId; + } + + public void setCustomerId(String customerId) { + this.customerId = customerId; + } + + public InitCustomerAgency getAgency() { + return agency; + } + + public void setAgency(InitCustomerAgency agency) { + this.agency = agency; + } + + public InitCustomerStaff getStaff() { + return staff; + } + + public void setStaff(InitCustomerStaff staff) { + this.staff = staff; + } +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java index 07c1cc403b..6dfc185e18 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java @@ -20,6 +20,7 @@ public enum EpmetErrorCode { ERR10006(10006, "登录超时,请重新登录"), ERR10007(10007, "当前帐号已在别处登录"), ERR10019(10019, "验证码不正确"), + SYSTEM_MQ_MSG_SEND_FAIL(10020, "MQ消息发送失败"), ERR401(401, "未授权"), INTERNAL_VALIDATE_ERROR(7000, "内部数据校验异常"), SERVER_ERROR(8000, "服务器开小差了..."), diff --git a/epmet-commons/pom.xml b/epmet-commons/pom.xml index d4b8e270b4..0bf8dd9c9f 100644 --- a/epmet-commons/pom.xml +++ b/epmet-commons/pom.xml @@ -23,6 +23,7 @@ epmet-commons-tools-wx-mp epmet-commons-service-call epmet-commons-extapp-auth + epmet-commons-rocketmq diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/AdvanceBranchRankResultDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/AdvanceBranchRankResultDTO.java index 60545c7fc4..216214d05c 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/AdvanceBranchRankResultDTO.java +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/AdvanceBranchRankResultDTO.java @@ -50,4 +50,9 @@ public class AdvanceBranchRankResultDTO implements Serializable { * */ private Integer projectNum; + /** + * 当前name的上级组织名称 2021-01-11新增 + */ + private String parentAgencyName; + } diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/GovernCapacityRankResultDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/GovernCapacityRankResultDTO.java index 0f6b481e1c..bf6ae28829 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/GovernCapacityRankResultDTO.java +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/GovernCapacityRankResultDTO.java @@ -39,4 +39,9 @@ public class GovernCapacityRankResultDTO implements Serializable { * 满意率 * */ private String satisfactionRatio; + + /** + * 当前agencyName的上一级组织名称 + */ + private String parentAgencyName; } diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/GovernCapacityResultDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/GovernCapacityResultDTO.java index f51fe26255..95ab00a382 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/GovernCapacityResultDTO.java +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/GovernCapacityResultDTO.java @@ -39,4 +39,9 @@ public class GovernCapacityResultDTO implements Serializable { * 满意率 * */ private BigDecimal satisfactionRatio; + + /** + * 当前agencyName的上一级组织名称 + */ + private String parentAgencyName; } diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/OrgRankDataResultDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/OrgRankDataResultDTO.java index 9aff92593f..a52b035475 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/OrgRankDataResultDTO.java +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/OrgRankDataResultDTO.java @@ -51,4 +51,9 @@ public class OrgRankDataResultDTO implements Serializable { * */ private Integer projectNum; + /** + * 当前name的上级组织名称 2021-01-11新增 + */ + private String parentAgencyName; + } diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/PublicPartiRankResultDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/PublicPartiRankResultDTO.java index 6d4eba5f4b..53209c640a 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/PublicPartiRankResultDTO.java +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/PublicPartiRankResultDTO.java @@ -25,4 +25,6 @@ public class PublicPartiRankResultDTO implements Serializable { private Integer issueNum; private Integer projectNum; + + private String parentAgencyName; } diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/GrassRootsGovernServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/GrassRootsGovernServiceImpl.java index 7afd0f4362..e33e7c9334 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/GrassRootsGovernServiceImpl.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/GrassRootsGovernServiceImpl.java @@ -181,6 +181,7 @@ public class GrassRootsGovernServiceImpl implements GrassRootsGovernService { rank.setResolvedRatio(convertPercentStr(o.getResolvedRatio(),NumConstant.ONE)); rank.setResponseRatio(convertPercentStr(o.getResponseRatio(),NumConstant.ONE)); rank.setSatisfactionRatio(convertPercentStr(o.getSatisfactionRatio(),NumConstant.ONE)); + rank.setParentAgencyName(o.getParentAgencyName()); result.add(rank); }); return result; diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCpcBaseDataDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCpcBaseDataDao.xml index 573c7501fa..06e501b713 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCpcBaseDataDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCpcBaseDataDao.xml @@ -10,7 +10,8 @@ SUM( AGE_LEVEL_3 ) + SUM( AGE_LEVEL_4 ) AS between31And50Count, SUM( AGE_LEVEL_5 ) AS between51And60Count, SUM( AGE_LEVEL_6 ) AS above61Count, - SUM( PARTY_MEMBER_COUNT) AS partyTotal + SUM( PARTY_MEMBER_COUNT) AS partyMemberCount, + SUM( AGE_LEVEL_1 ) + SUM( AGE_LEVEL_2 )+SUM( AGE_LEVEL_3 ) + SUM( AGE_LEVEL_4 )+SUM( AGE_LEVEL_5 )+SUM( AGE_LEVEL_6 ) as partyTotal FROM screen_cpc_base_data WHERE diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenGovernRankDataDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenGovernRankDataDao.xml index 7976de7ff1..a1766981cc 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenGovernRankDataDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenGovernRankDataDao.xml @@ -6,19 +6,23 @@ \ No newline at end of file diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenOrgRankDataDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenOrgRankDataDao.xml index 310320029e..bc1fa8f0aa 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenOrgRankDataDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenOrgRankDataDao.xml @@ -6,28 +6,31 @@ diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenPartyLinkMassesDataDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenPartyLinkMassesDataDao.xml index 7a59c7f16d..7f4520f8ff 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenPartyLinkMassesDataDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenPartyLinkMassesDataDao.xml @@ -15,5 +15,8 @@ WHERE md.del_flag = '0' AND md.parent_id = #{agencyId} + + AND md.ORG_TYPE = + CASE WHEN sca.LEVEL = 'community' THEN 'grid' ELSE 'agency' END \ No newline at end of file diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenPublicPartiTotalDataDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenPublicPartiTotalDataDao.xml index 1a94210725..277e6c17dc 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenPublicPartiTotalDataDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenPublicPartiTotalDataDao.xml @@ -6,24 +6,29 @@ \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java index a22a573819..755705a6ce 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java @@ -20,7 +20,6 @@ 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; @@ -47,7 +46,6 @@ import org.springframework.web.bind.annotation.*; import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.List; -import java.util.Map; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; @@ -664,12 +662,21 @@ public class DemoController { @Autowired private PublicPartiTotalDataExtractService publicPartiTotalDataExtractService; @PostMapping("insertScreenPioneerData") - public Result insertScreenPioneerData(@RequestParam("customerId") String customerId, @RequestParam("dateId") String dateId) { + public Result insertScreenPioneerData(@RequestParam("customerId") String customerId, @RequestParam("dateId") String dateId,@RequestParam("type") String type) { if (StringUtils.isNotBlank(customerId) && StringUtils.isNotBlank(dateId)) { - pioneerDataExtractService.extractGridPioneerData(customerId, dateId); - pioneerDataExtractService.extractCommunityPioneerData(customerId, dateId); - pioneerDataExtractService.extractExceptCommunityPioneerData(customerId, dateId); - } else { + if ("grid".equals(type)) { + pioneerDataExtractService.extractGridPioneerData(customerId, dateId); + } else if ("community".equals(type)) { + pioneerDataExtractService.extractCommunityPioneerData(customerId, dateId); + } else if ("exceptcommunity".equals(type)) { + pioneerDataExtractService.extractExceptCommunityPioneerData(customerId, dateId); + } else { + pioneerDataExtractService.extractGridPioneerData(customerId, dateId); + pioneerDataExtractService.extractCommunityPioneerData(customerId, dateId); + pioneerDataExtractService.extractExceptCommunityPioneerData(customerId, dateId); + } + } + /*else { QueryWrapper customerEntityQueryWrapper = new QueryWrapper<>(); List customerEntityList = dimCustomerDao.selectList(customerEntityQueryWrapper); for (DimCustomerEntity customerEntity : customerEntityList) { @@ -677,8 +684,8 @@ public class DemoController { pioneerDataExtractService.extractCommunityPioneerData(customerEntity.getId(), "20200926"); pioneerDataExtractService.extractExceptCommunityPioneerData(customerEntity.getId(), "20200926"); } - } - return new Result(); + }*/ + return new Result().ok("调用成功"); } @PostMapping("extractPublicPartiTotalData") diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactOriginExtractController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactOriginExtractController.java index 2abcd81edd..9542bdc580 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactOriginExtractController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactOriginExtractController.java @@ -1,5 +1,7 @@ package com.epmet.controller; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.extract.form.ExtractOriginFormDTO; @@ -11,6 +13,8 @@ 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; + /** * 原始数据清洗 @@ -114,7 +118,15 @@ public class FactOriginExtractController { **/ @PostMapping("groupdatacleaning") public Result groupDataCleaning(@RequestBody ExtractOriginFormDTO param) { - groupExtractService.extractGroupData(param); + if(StringUtils.isNotBlank(param.getStartDate()) && StringUtils.isNotBlank(param.getEndDate())){ + List finalDaysBetween = DateUtils.getDaysBetween(param.getStartDate(), param.getEndDate()); + ExtractOriginFormDTO paramNew = ConvertUtils.sourceToTarget(param, ExtractOriginFormDTO.class); + for (int i = 0; i < finalDaysBetween.size(); i++) { + String dateDimId = finalDaysBetween.get(i); + paramNew.setDateId(dateDimId); + groupExtractService.extractGroupData(paramNew); + } + }else groupExtractService.extractGroupData(param); return new Result(); } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginGroupMainDailyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginGroupMainDailyDao.java index 12e6151f3f..911d8b7993 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginGroupMainDailyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginGroupMainDailyDao.java @@ -18,13 +18,11 @@ package com.epmet.dao.evaluationindex.extract; import com.epmet.commons.mybatis.dao.BaseDao; -import com.epmet.dto.extract.form.ScreenPartyLinkMassesDataFormDTO; -import com.epmet.dto.extract.result.OrgStatisticsResultDTO; -import com.epmet.dto.extract.result.PartyCreateGroupCountResultDTO; import com.epmet.dto.extract.FactOriginGroupMainDailyDTO; import com.epmet.dto.extract.form.GridHeartedFormDTO; import com.epmet.dto.extract.form.ScreenPartyLinkMassesDataFormDTO; import com.epmet.dto.extract.result.GridGroupUserCountResultDTO; +import com.epmet.dto.extract.result.OrgStatisticsResultDTO; import com.epmet.dto.extract.result.PartyCreateGroupCountResultDTO; import com.epmet.dto.group.result.ExtractGroupMemberActionRecordResultDTO; import com.epmet.entity.evaluationindex.extract.FactOriginGroupMainDailyEntity; @@ -164,12 +162,11 @@ public interface FactOriginGroupMainDailyDao extends BaseDao selectPartyCreateGroupInfo(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("gridIds") List gridIds); + List selectPartyCreateGroupInfo(@Param("customerId") String customerId, @Param("gridIds") List gridIds); /** * desc: 获取所有网格的组中成员人数 去重 @@ -202,4 +199,4 @@ public interface FactOriginGroupMainDailyDao extends BaseDao selectOrgGroupCount(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("level") String level); -} \ No newline at end of file +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/FactOriginGroupMainDailyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/FactOriginGroupMainDailyService.java index c9a74e31b8..730acde2c8 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/FactOriginGroupMainDailyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/FactOriginGroupMainDailyService.java @@ -68,12 +68,11 @@ public interface FactOriginGroupMainDailyService extends BaseService selectPartyCreateGroupInfo(String customerId, String monthId, List gridIds); + List selectPartyCreateGroupInfo(String customerId, List gridIds); /** * desc: 获取客户下每个网格小组内的 去重人数 @@ -106,4 +105,4 @@ public interface FactOriginGroupMainDailyService extends BaseService */ List getOrgGroupCount(String customerId, String monthId, String level); -} \ No newline at end of file +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginGroupMainDailyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginGroupMainDailyServiceImpl.java index ab3efce8b4..94fadea5fe 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginGroupMainDailyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginGroupMainDailyServiceImpl.java @@ -21,8 +21,8 @@ import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.dao.evaluationindex.extract.FactOriginGroupMainDailyDao; import com.epmet.dto.extract.FactOriginGroupMainDailyDTO; import com.epmet.dto.extract.form.ScreenPartyLinkMassesDataFormDTO; -import com.epmet.dto.extract.result.OrgStatisticsResultDTO; import com.epmet.dto.extract.result.GridGroupUserCountResultDTO; +import com.epmet.dto.extract.result.OrgStatisticsResultDTO; import com.epmet.dto.group.result.ExtractGroupMemberActionRecordResultDTO; import com.epmet.entity.evaluationindex.extract.FactOriginGroupMainDailyEntity; import com.epmet.service.evaluationindex.extract.todata.FactOriginGroupMainDailyService; @@ -85,19 +85,21 @@ public class FactOriginGroupMainDailyServiceImpl extends BaseServiceImpl originGroupData, List memberList,List missing) { - if (isFirst) { - //isFirst - baseDao.deleteBatchMemberByCustomerId(customerId,null,null); - } else { - if(StringUtils.isNotBlank(dateId)){ - baseDao.deleteBatchMemberByCustomerId(customerId,dateId,"date"); + if(!CollectionUtils.isEmpty(originGroupData)) { + if (isFirst) { + //isFirst + baseDao.deleteBatchMemberByCustomerId(customerId, null, null); + } else { + if (StringUtils.isNotBlank(dateId)) { + baseDao.deleteBatchMemberByCustomerId(customerId, dateId, "date"); + } } - } - //删除要插入的组主表数据 - baseDao.deleteBatchByGroupId(customerId,originGroupData.stream().map(FactOriginGroupMainDailyDTO :: getId).distinct().collect(Collectors.toList())); + //删除要插入的组主表数据 + baseDao.deleteBatchByGroupId(customerId, originGroupData.stream().map(FactOriginGroupMainDailyDTO::getId).distinct().collect(Collectors.toList())); - baseDao.insertBatchMain(originGroupData); - baseDao.insertBatchMembers(memberList); + baseDao.insertBatchMain(originGroupData); + baseDao.insertBatchMembers(memberList); + } if(!CollectionUtils.isEmpty(missing)){ baseDao.deleteBatchByGroupId(customerId,missing); baseDao.deleteMemberByGroupList(customerId,missing); @@ -106,16 +108,15 @@ public class FactOriginGroupMainDailyServiceImpl extends BaseServiceImpl selectPartyCreateGroupInfo(String customerId, String monthId, List gridIds) { + public List selectPartyCreateGroupInfo(String customerId, List gridIds) { if (!CollectionUtils.isEmpty(gridIds)) { - return baseDao.selectPartyCreateGroupInfo(customerId, monthId, gridIds); + return baseDao.selectPartyCreateGroupInfo(customerId, gridIds); } return new ArrayList<>(); } @@ -135,4 +136,4 @@ public class FactOriginGroupMainDailyServiceImpl extends BaseServiceImpl originGroupData = groupDataService.extractGroupData( count <= NumConstant.ZERO, param.getCustomerId(), param.getDateId()); - + log.info("extractGroupData extractGroupData:result:{},param:{}", JSON.toJSONString(originGroupData), JSON.toJSONString(param)); List memberList = new LinkedList<>(); if (!CollectionUtils.isEmpty(originGroupData)) { - List gridList = dimGridService.getGridAttributes(param.getCustomerId(),originGroupData.stream().map(FactOriginGroupMainDailyDTO::getGridId).distinct().collect(Collectors.toList())); + List gridList = dimGridService.getGridAttributes(param.getCustomerId(),null); if (!CollectionUtils.isEmpty(gridList)) { Map gridMap = @@ -160,7 +161,7 @@ public class GroupExtractServiceImpl implements GroupExtractService { factOriginGroupMainDailyService.insertExtractedData( - count <= NumConstant.ZERO ? true : false, + count <= NumConstant.ZERO, param.getCustomerId(), param.getDateId(), originGroupData, diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/IssueExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/IssueExtractServiceImpl.java index 20169ae538..b7b4532f4f 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/IssueExtractServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/IssueExtractServiceImpl.java @@ -22,6 +22,7 @@ import com.epmet.service.evaluationindex.extract.todata.IssueExtractService; import com.epmet.service.topic.TopicService; import com.epmet.service.user.UserService; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -129,7 +130,11 @@ public class IssueExtractServiceImpl implements IssueExtractService { agencyInfoList.forEach(pid -> { if (r.getAgencyId().equals(pid.getAgencyId())){ r.setPid(pid.getPid()); - r.setPids(pid.getPids().concat(":").concat(r.getAgencyId())); + if (StringUtils.isNotBlank(pid.getPids())) { + r.setPids(pid.getPids().concat(":").concat(r.getAgencyId())); + } else { + r.setPids(r.getAgencyId()); + } } }); }); @@ -231,7 +236,11 @@ public class IssueExtractServiceImpl implements IssueExtractService { agencyInfoList.forEach(agency -> { if (r.getAgencyId().equals(agency.getAgencyId())){ r.setPid(agency.getPid()); - r.setPids(agency.getPids().concat(":").concat(r.getAgencyId())); + if(StringUtils.isNotBlank(agency.getPids())){ + r.setPids(agency.getPids().concat(":").concat(r.getAgencyId())); + }else{ + r.setPids(r.getAgencyId()); + } } }); }); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PartyBaseInfoServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PartyBaseInfoServiceImpl.java index f0999a4605..a7435b914e 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PartyBaseInfoServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PartyBaseInfoServiceImpl.java @@ -129,7 +129,8 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService { form.setAgeLevel4(party.stream().collect(Collectors.summingInt(PartyBaseInfoFormDTO::getAgeLevel4))); form.setAgeLevel5(party.stream().collect(Collectors.summingInt(PartyBaseInfoFormDTO::getAgeLevel5))); form.setAgeLevel6(party.stream().collect(Collectors.summingInt(PartyBaseInfoFormDTO::getAgeLevel6))); - form.setPartyMemberCount(party.stream().collect(Collectors.summingInt(PartyBaseInfoFormDTO::getPartyMemberCount))); +// form.setPartyMemberCount(party.stream().collect(Collectors.summingInt(PartyBaseInfoFormDTO::getPartyMemberCount))); + form.setPartyMemberCount(calPartyMemberCount(form)); form.setResiTotal(party.stream().collect(Collectors.summingInt(PartyBaseInfoFormDTO::getResiTotal))); form.setRegisterUserCount(party.stream().collect(Collectors.summingInt(PartyBaseInfoFormDTO::getRegisterUserCount))); result.add(form); @@ -175,6 +176,7 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService { form.setAgeLevel4(disposeAgeArea(partyInfos,NumConstant.FORTY_ONE,NumConstant.FIFTY)); form.setAgeLevel5(disposeAgeArea(partyInfos,NumConstant.FIFTY_ONE,NumConstant.SIXTY)); form.setAgeLevel6(disposeAge(partyInfos,NumConstant.SIXTY,true)); + form.setPartyMemberCount(calPartyMemberCount(form)); form.setCustomerId(customerId); form.setDataEndTime(dateId); form.setParentId(partyInfos.get(NumConstant.ZERO).getAgencyId()); @@ -183,7 +185,7 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService { if (gridId.equals(user.getOrgId())){ form.setResiTotal(user.getResiTotal()); form.setRegisterUserCount(user.getRegisterUserCount()); - form.setPartyMemberCount(user.getPartyMemberCount()); +// form.setPartyMemberCount(user.getPartyMemberCount()); } }); } @@ -210,7 +212,8 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService { form.setAgeLevel4(partyInfoList.stream().collect(Collectors.summingInt(PartyInfoResultDTO::getAgeLevel4))); form.setAgeLevel5(partyInfoList.stream().collect(Collectors.summingInt(PartyInfoResultDTO::getAgeLevel5))); form.setAgeLevel6(partyInfoList.stream().collect(Collectors.summingInt(PartyInfoResultDTO::getAgeLevel6))); - form.setPartyMemberCount(partyInfoList.stream().collect(Collectors.summingInt(PartyInfoResultDTO::getPartyMemberCount))); +// form.setPartyMemberCount(partyInfoList.stream().collect(Collectors.summingInt(PartyInfoResultDTO::getPartyMemberCount))); + form.setPartyMemberCount(calPartyMemberCount(form)); form.setResiTotal(partyInfoList.stream().collect(Collectors.summingInt(PartyInfoResultDTO::getResiTotal))); form.setRegisterUserCount(partyInfoList.stream().collect(Collectors.summingInt(PartyInfoResultDTO::getRegisterUserCount))); result.add(form); @@ -361,6 +364,7 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService { form.setAgeLevel3(disposeAgeArea(partyInfos,NumConstant.THIRTY_ONE,NumConstant.FORTY)); form.setAgeLevel4(disposeAgeArea(partyInfos,NumConstant.FORTY_ONE,NumConstant.FIFTY)); form.setAgeLevel5(disposeAgeArea(partyInfos,NumConstant.FIFTY_ONE,NumConstant.SIXTY)); + form.setPartyMemberCount(calPartyMemberCount(form)); form.setAgeLevel6(disposeAge(partyInfos,NumConstant.SIXTY,true)); form.setCustomerId(customerId); form.setDataEndTime(dateId); @@ -370,7 +374,7 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService { if (gridId.equals(user.getOrgId())){ form.setResiTotal(user.getResiTotal()); form.setRegisterUserCount(user.getRegisterUserCount()); - form.setPartyMemberCount(user.getPartyMemberCount()); +// form.setPartyMemberCount(user.getPartyMemberCount()); } }); } @@ -379,4 +383,9 @@ public class PartyBaseInfoServiceImpl implements PartyBaseInfoService { } return new GridPartyDTO(orgIds, result); } + + public Integer calPartyMemberCount(PartyBaseInfoFormDTO form){ + Integer result = form.getAgeLevel1() + form.getAgeLevel2() + form.getAgeLevel3() + form.getAgeLevel4() + form.getAgeLevel5() + form.getAgeLevel6(); + return result; + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PartyGuideServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PartyGuideServiceImpl.java index 74f7b84d27..2e31f8ae4a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PartyGuideServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PartyGuideServiceImpl.java @@ -1,11 +1,9 @@ package com.epmet.service.evaluationindex.extract.toscreen.impl; -import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.constant.ScreenConstant; import com.epmet.dto.extract.form.ExtractScreenFormDTO; -import com.epmet.dto.extract.form.ScreenExtractFormDTO; import com.epmet.dto.extract.form.ScreenPartyBranchDataFormDTO; import com.epmet.dto.extract.form.ScreenPartyLinkMassesDataFormDTO; import com.epmet.dto.extract.result.*; @@ -185,22 +183,22 @@ public class PartyGuideServiceImpl implements PartyGuideService { // 判断当前级别agency是否为空 if (!CollectionUtils.isEmpty(agencyIdList)){ // 获取agencyIds - List orgIds = agencyIdList.stream().map(m -> m.getAgencyId()).collect(Collectors.toList()); - if (isGrid == true){ + List orgIds = agencyIdList.stream().map(CustomerAgencyInfoResultDTO::getAgencyId).collect(Collectors.toList()); + if (isGrid) { agencyIdList.forEach(agency -> { // 计算社区级别的下级(实际就是网格) - GridPartyGuideDTO gridPartyGuideDTO = communityLevelSubGrid(customerId, monthId, agency); + GridPartyGuideDTO gridPartyGuideDTO = communityLevelSubGrid(customerId, agency); orgIds.addAll(gridPartyGuideDTO.getOrgIds()); result.addAll(gridPartyGuideDTO.getResult()); }); // 根据agencyId分组,计算各个社区的 Map> groupByAgency = result.stream().collect(Collectors.groupingBy(ScreenPartyLinkMassesDataFormDTO::getParentId)); - groupByAgency.forEach((agencyId,gridList) -> { + groupByAgency.forEach((agencyId, gridList) -> { ScreenPartyLinkMassesDataFormDTO form = new ScreenPartyLinkMassesDataFormDTO(); List orgNameAgencyList = agencyService.selectOrgNameAgency(orgIds); if (!CollectionUtils.isEmpty(orgNameAgencyList)){ orgNameAgencyList.forEach(name -> { - if (agencyId.equals(name.getAgencyId())){ + if (agencyId.equals(name.getAgencyId())) { form.setOrgName(name.getAgencyName()); form.setParentId(name.getParentId()); } @@ -210,8 +208,8 @@ public class PartyGuideServiceImpl implements PartyGuideService { form.setCustomerId(customerId); form.setDataEndTime(monthId); form.setOrgType(ScreenConstant.AGENCY); - form.setCreateGroupTotal(gridList.stream().collect(Collectors.summingInt(ScreenPartyLinkMassesDataFormDTO::getCreateGroupTotal))); - form.setGroupUserTotal(gridList.stream().collect(Collectors.summingInt(ScreenPartyLinkMassesDataFormDTO::getGroupUserTotal))); + form.setCreateGroupTotal(gridList.stream().mapToInt(ScreenPartyLinkMassesDataFormDTO::getCreateGroupTotal).sum()); + form.setGroupUserTotal(gridList.stream().mapToInt(ScreenPartyLinkMassesDataFormDTO::getGroupUserTotal).sum()); result.add(form); }); delAndInsertLink(result,customerId,monthId,orgIds); @@ -227,15 +225,15 @@ public class PartyGuideServiceImpl implements PartyGuideService { } }); // 不为空 存在直属网格 - if (!CollectionUtils.isEmpty(disGridIds)){ + if (!CollectionUtils.isEmpty(disGridIds)) { List gridResult = new ArrayList<>(); // 查询党员创建组,组内成员数 - List partyLinkMassesDataList = groupMainService.selectPartyCreateGroupInfo(customerId, monthId, disGridIds); - List orgNameList = agencyService.selectOrgNameGrid(partyLinkMassesDataList.stream().map(m -> m.getOrgId()).collect(Collectors.toList())); - if (!CollectionUtils.isEmpty(partyLinkMassesDataList)){ + List partyLinkMassesDataList = groupMainService.selectPartyCreateGroupInfo(customerId, disGridIds); + List orgNameList = agencyService.selectOrgNameGrid(partyLinkMassesDataList.stream().map(ScreenPartyLinkMassesDataFormDTO::getOrgId).collect(Collectors.toList())); + if (!CollectionUtils.isEmpty(partyLinkMassesDataList)) { partyLinkMassesDataList.forEach(party -> { orgNameList.forEach(org -> { - if (party.getOrgId().equals(org.getGridId())){ + if (party.getOrgId().equals(org.getGridId())) { party.setOrgName(org.getGridName()); } }); @@ -246,10 +244,10 @@ public class PartyGuideServiceImpl implements PartyGuideService { delAndInsertLink(gridResult,customerId,monthId,disGridIds); } // 查询直属网格的信息 + 下级机关的信息 = agency的机关信息 - List screenPartyLinkMassesDataGrid = groupMainService.selectPartyCreateGroupInfo(customerId, monthId, disGridIds); + List screenPartyLinkMassesDataGrid = groupMainService.selectPartyCreateGroupInfo(customerId, disGridIds); List screenPartyLinkMassesDataList = linkMassesDataService.selectPartyLinkMassesInfo(customerId, monthId, agencyId); screenPartyLinkMassesDataList.addAll(screenPartyLinkMassesDataGrid); - if (!CollectionUtils.isEmpty(screenPartyLinkMassesDataList)){ + if (!CollectionUtils.isEmpty(screenPartyLinkMassesDataList)) { ScreenPartyLinkMassesDataFormDTO form = new ScreenPartyLinkMassesDataFormDTO(); form.setOrgId(agencyId); form.setOrgType(ScreenConstant.AGENCY); @@ -257,8 +255,8 @@ public class PartyGuideServiceImpl implements PartyGuideService { form.setCustomerId(customerId); form.setDataEndTime(monthId); form.setParentId(screenPartyLinkMassesDataList.get(NumConstant.ZERO).getParentId()); - form.setGroupUserTotal(screenPartyLinkMassesDataList.stream().collect(Collectors.summingInt(ScreenPartyLinkMassesDataFormDTO::getGroupUserTotal))); - form.setCreateGroupTotal(screenPartyLinkMassesDataList.stream().collect(Collectors.summingInt(ScreenPartyLinkMassesDataFormDTO::getCreateGroupTotal))); + form.setGroupUserTotal(screenPartyLinkMassesDataList.stream().mapToInt(ScreenPartyLinkMassesDataFormDTO::getGroupUserTotal).sum()); + form.setCreateGroupTotal(screenPartyLinkMassesDataList.stream().mapToInt(ScreenPartyLinkMassesDataFormDTO::getCreateGroupTotal).sum()); result.add(form); } }); @@ -431,24 +429,23 @@ public class PartyGuideServiceImpl implements PartyGuideService { } /** - * @Description 社区级别的处理 + * @Description 社区级别的处理 * @Param customerId - * @Param monthId * @Param agency * @author zxc * @date 2020/9/25 10:06 上午 */ - public GridPartyGuideDTO communityLevelSubGrid(String customerId, String monthId, CustomerAgencyInfoResultDTO agency){ + public GridPartyGuideDTO communityLevelSubGrid(String customerId, CustomerAgencyInfoResultDTO agency) { String agencyId = agency.getAgencyId(); // 获取下级所有agencyId【根据agencyMap中的level判断下级orgId是否是gridId】(此处直接作为gridId) Map agencyMap = agencyService.selectAllSubAgencyId(agencyId, customerId); List gridIds = (List) agencyMap.get(agencyId); - List partyLinkMassesDataList = groupMainService.selectPartyCreateGroupInfo(customerId, monthId, gridIds); + List partyLinkMassesDataList = groupMainService.selectPartyCreateGroupInfo(customerId, gridIds); List orgIds = partyLinkMassesDataList.stream().map(m -> m.getOrgId()).collect(Collectors.toList()); List orgNameList = agencyService.selectOrgNameGrid(orgIds); partyLinkMassesDataList.forEach(party -> { orgNameList.forEach(orgName -> { - if (party.getOrgId().equals(orgName.getGridId())){ + if (party.getOrgId().equals(orgName.getGridId())) { party.setOrgName(orgName.getGridName()); } }); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PioneerDataExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PioneerDataExtractServiceImpl.java index f41366eb13..234e5ed149 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PioneerDataExtractServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PioneerDataExtractServiceImpl.java @@ -66,56 +66,65 @@ public class PioneerDataExtractServiceImpl implements PioneerDataExtractService //何为参与: 议题的表决行为次数总计 //1、党员参与议事 entity.setIssueTotal(calPartyPartiIssueTotal(customerId,gridId,null,null,NumConstant.ONE_STR)); + log.info("extractGridPioneerData 当前网格id=" + gridId + ";党员参与议事issueTotal="+entity.getIssueTotal()); if(entity.getIssueTotal()==0){ entity.setIssueRatio(BigDecimal.ZERO); }else{ //2、党员参与议事占比 int issueTotal=calPartyPartiIssueTotal(customerId,gridId,null,null,null); - BigDecimal issueRatio=new BigDecimal(entity.getIssueTotal()/issueTotal).multiply(new BigDecimal(NumConstant.ONE_HUNDRED)); + log.info("extractGridPioneerData 当前网格id=" + gridId + ";参与议事总数issueTotal=" + issueTotal); + BigDecimal issueRatio = new BigDecimal((double) entity.getIssueTotal() / issueTotal).multiply(new BigDecimal(NumConstant.ONE_HUNDRED)); + log.info("extractGridPioneerData 当前网格id=" + gridId + ";issueRatio=" + issueRatio); entity.setIssueRatio(issueRatio.setScale(NumConstant.SIX,RoundingMode.HALF_UP)); } //3、党员发布话题: entity.setTopicTotal(getTopicTotal(customerId, gridId, null)); + log.info("extractGridPioneerData 当前网格id=" + gridId + ";党员发布话题topicTotal"+entity.getTopicTotal()); //4、党员发布话题占比: 网格内注册党员发布的话题总数占 网格内话题总数的 比率 if (entity.getTopicTotal() == NumConstant.ZERO) { entity.setTopicRatio(BigDecimal.ZERO); } else { //当前网格内所有话题总数 int gridTopicTotal = getGridOrCommunityTopicTotal(customerId, gridId, null); + log.info("extractGridPioneerData 当前网格id=" + gridId + ";当前网格内所有话题总数gridTopicTotal="+gridTopicTotal); if(gridTopicTotal == NumConstant.ZERO){ entity.setTopicRatio(BigDecimal.ZERO); }else{ - BigDecimal topicRatio=new BigDecimal(entity.getTopicTotal() / gridTopicTotal).multiply(new BigDecimal(NumConstant.ONE_HUNDRED)); + BigDecimal topicRatio = new BigDecimal((double) entity.getTopicTotal() / gridTopicTotal).multiply(new BigDecimal(NumConstant.ONE_HUNDRED)); + log.info("extractGridPioneerData 当前网格id=" + gridId + ";党员发布话题占比topicRatio="+topicRatio); entity.setTopicRatio(topicRatio.setScale(NumConstant.SIX, RoundingMode.HALF_UP)); } } //当前网格内所有议题总数 int gridIssueTotal = getGridOrCommunityIssueTotal(customerId, gridId, null); + log.info("extractGridPioneerData 当前网格id=" + gridId + ";当前网格内所有议题总数=" + gridIssueTotal); if (gridIssueTotal != NumConstant.ZERO) { //5、党员发布议题 entity.setPublishIssueTotal(getParyPublishIssueTotal(customerId, gridId, null)); + log.info("extractGridPioneerData 当前网格id=" + gridId + ";党员发布议题publishIssueTotal"+entity.getPublishIssueTotal()); //6、党员发布议题占比 : 占网格内所有议题的比率 if (entity.getPublishIssueTotal() == NumConstant.ZERO) { entity.setPublishIssueRatio(BigDecimal.ZERO); }else{ - BigDecimal publishIssueRatio=new BigDecimal(entity.getPublishIssueTotal() / gridIssueTotal).multiply(new BigDecimal(NumConstant.ONE_HUNDRED)); + BigDecimal publishIssueRatio=new BigDecimal((double)entity.getPublishIssueTotal() / gridIssueTotal).multiply(new BigDecimal(NumConstant.ONE_HUNDRED)); entity.setPublishIssueRatio(publishIssueRatio.setScale(NumConstant.SIX, RoundingMode.HALF_UP)); } //7、议题转项目数 entity.setShiftProjectTotal(getGridOrCommunityShiftProjectTotal(customerId, gridId, null)); + log.info("extractGridPioneerData 当前网格id=" + gridId +";议题转项目数shiftProjectTotal="+entity.getShiftProjectTotal()); //8、议题转项目占比 : 占网格内议题总数的比率 if(entity.getShiftProjectTotal() == NumConstant.ZERO){ entity.setShiftProjectRatio(BigDecimal.ZERO); }else{ - BigDecimal shiftProjectRatio=new BigDecimal(entity.getShiftProjectTotal() / gridIssueTotal).multiply(new BigDecimal(NumConstant.ONE_HUNDRED)); + BigDecimal shiftProjectRatio = new BigDecimal((double) entity.getShiftProjectTotal() / gridIssueTotal).multiply(new BigDecimal(NumConstant.ONE_HUNDRED)); entity.setShiftProjectRatio(shiftProjectRatio.setScale(NumConstant.SIX, RoundingMode.HALF_UP)); } }else{ -// log.info("当前网格内所有议题总数="+gridIssueTotal); + log.info("extractGridPioneerData 当前网格id="+gridId+";当前网格内所有议题总数 gridIssueTotal =0 "); entity.setPublishIssueTotal(NumConstant.ZERO); entity.setPublishIssueRatio(BigDecimal.ZERO); entity.setShiftProjectTotal(NumConstant.ZERO); @@ -125,15 +134,17 @@ public class PioneerDataExtractServiceImpl implements PioneerDataExtractService // 9、已解决项目 entity.setResolvedProjectTotal(getGridOrCommunityClosedProjectTotal(customerId, gridId, null, DimObjectStatusConstant.RESOLVED)); + log.info("extractGridPioneerData 当前网格id="+gridId+";已解决项目resolvedProjectTotal="+entity.getResolvedProjectTotal()); if (entity.getResolvedProjectTotal() == NumConstant.ZERO) { entity.setResolvedProjectRatio(BigDecimal.ZERO); } else { // 10、占总结项目 int closedProjectTotal = getGridOrCommunityClosedProjectTotal(customerId, gridId, null, null); + log.info("extractGridPioneerData 当前网格id="+gridId+";总结项目closedProjectTotal="+closedProjectTotal); if(closedProjectTotal == NumConstant.ZERO){ entity.setResolvedProjectRatio(BigDecimal.ZERO); }else { - BigDecimal resolvedProjectRatio=new BigDecimal(entity.getResolvedProjectTotal() / closedProjectTotal).multiply(new BigDecimal(NumConstant.ONE_HUNDRED)); + BigDecimal resolvedProjectRatio = new BigDecimal((double) entity.getResolvedProjectTotal() / closedProjectTotal).multiply(new BigDecimal(NumConstant.ONE_HUNDRED)); entity.setResolvedProjectRatio(resolvedProjectRatio.setScale(NumConstant.SIX, RoundingMode.HALF_UP)); } } @@ -172,42 +183,49 @@ public class PioneerDataExtractServiceImpl implements PioneerDataExtractService String communityId = entity.getOrgId(); //1、党员参与议事 entity.setIssueTotal(calPartyPartiIssueTotal(customerId,null,communityId,null,NumConstant.ONE_STR)); + log.info("extractCommunityPioneerData 当前communityId="+communityId+";党员参与议事issueTotal="+entity.getIssueTotal()); if(entity.getIssueTotal()==0){ entity.setIssueRatio(BigDecimal.ZERO); }else{ //2、党员参与议事占比 int issueTotal=calPartyPartiIssueTotal(customerId,null,communityId,null,null); - entity.setIssueRatio(new BigDecimal(entity.getIssueTotal()/issueTotal).setScale(NumConstant.SIX,RoundingMode.HALF_UP)); + log.info("extractCommunityPioneerData 当前communityId="+communityId+";参与议事总数issueTotal="+issueTotal); + entity.setIssueRatio(new BigDecimal((double)entity.getIssueTotal()/issueTotal).multiply(new BigDecimal(NumConstant.ONE_HUNDRED)).setScale(NumConstant.SIX,RoundingMode.HALF_UP)); } //3、党员发布话题: entity.setTopicTotal(getTopicTotal(customerId, null, communityId)); + log.info("extractCommunityPioneerData 当前communityId="+communityId+";党员发布话题topicTotal="+entity.getTopicTotal()); //4、党员发布话题占比: 社区内注册党员发布的话题总数占 社区内话题总数的 比率 if (entity.getTopicTotal() == NumConstant.ZERO) { entity.setTopicRatio(BigDecimal.ZERO); } else { //当前社区内所有话题总数 int communityTopicTotal = getGridOrCommunityTopicTotal(customerId, null, communityId); - entity.setTopicRatio(communityTopicTotal == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(entity.getTopicTotal() / communityTopicTotal).setScale(NumConstant.SIX, RoundingMode.HALF_UP)); + log.info("extractCommunityPioneerData 当前communityId="+communityId+";当前社区内所有话题总数communityTopicTotal="+communityTopicTotal); + entity.setTopicRatio(communityTopicTotal == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal((double)entity.getTopicTotal() / communityTopicTotal).multiply(new BigDecimal(NumConstant.ONE_HUNDRED)).setScale(NumConstant.SIX, RoundingMode.HALF_UP)); } //当前社区内所有议题总数 int communityIssueTotal = getGridOrCommunityIssueTotal(customerId, null, communityId); + log.info("extractCommunityPioneerData 当前communityId="+communityId+";当前社区内所有议题总数communityIssueTotal="+communityIssueTotal); if (communityIssueTotal != NumConstant.ZERO) { //5、党员发布议题 entity.setPublishIssueTotal(getParyPublishIssueTotal(customerId, null, communityId)); + log.info("extractCommunityPioneerData 当前communityId="+communityId+";党员发布议题publishIssueTotal="+entity.getPublishIssueTotal()); //6、党员发布议题占比 : 占社区内所有议题的比率 if (entity.getPublishIssueTotal() == NumConstant.ZERO) { entity.setPublishIssueRatio(BigDecimal.ZERO); } - entity.setPublishIssueRatio(communityIssueTotal == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(entity.getPublishIssueTotal() / communityIssueTotal).setScale(NumConstant.SIX, RoundingMode.HALF_UP)); + entity.setPublishIssueRatio(communityIssueTotal == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal((double)entity.getPublishIssueTotal() / communityIssueTotal).multiply(new BigDecimal(NumConstant.ONE_HUNDRED)).setScale(NumConstant.SIX, RoundingMode.HALF_UP)); //7、议题转项目数 entity.setShiftProjectTotal(getGridOrCommunityShiftProjectTotal(customerId, null, communityId)); + log.info("extractCommunityPioneerData 当前communityId="+communityId+";议题转项目数shiftProjectTotal="+entity.getShiftProjectTotal()); //8、议题转项目占比 : 占社区内议题总数的比率 - entity.setShiftProjectRatio(entity.getShiftProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(entity.getShiftProjectTotal() / communityIssueTotal).setScale(NumConstant.SIX, RoundingMode.HALF_UP)); + entity.setShiftProjectRatio(entity.getShiftProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal((double)entity.getShiftProjectTotal() / communityIssueTotal).multiply(new BigDecimal(NumConstant.ONE_HUNDRED)).setScale(NumConstant.SIX, RoundingMode.HALF_UP)); }else{ -// log.info("当前社区内所有议题总数="+communityIssueTotal); + log.info("extractCommunityPioneerData 当前communityId="+communityId+"communityIssueTotal =0"); entity.setPublishIssueTotal(NumConstant.ZERO); entity.setPublishIssueRatio(BigDecimal.ZERO); entity.setShiftProjectTotal(NumConstant.ZERO); @@ -217,12 +235,14 @@ public class PioneerDataExtractServiceImpl implements PioneerDataExtractService // 9、已解决项目 entity.setResolvedProjectTotal(getGridOrCommunityClosedProjectTotal(customerId, null, communityId, DimObjectStatusConstant.RESOLVED)); + log.info("extractCommunityPioneerData 当前communityId="+communityId+";已解决项目resolvedProjectTotal="+entity.getResolvedProjectTotal()); if (entity.getResolvedProjectTotal() == NumConstant.ZERO) { entity.setResolvedProjectRatio(BigDecimal.ZERO); } else { // 10、占总结项目 int closedProjectTotal = getGridOrCommunityClosedProjectTotal(customerId, null, communityId, null); - entity.setResolvedProjectRatio(closedProjectTotal == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(entity.getResolvedProjectTotal() / closedProjectTotal).setScale(NumConstant.SIX, RoundingMode.HALF_UP)); + log.info("extractCommunityPioneerData 当前communityId="+communityId+";总结项目closedProjectTotal="+closedProjectTotal); + entity.setResolvedProjectRatio(closedProjectTotal == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal((double)entity.getResolvedProjectTotal() / closedProjectTotal).multiply(new BigDecimal(NumConstant.ONE_HUNDRED)).setScale(NumConstant.SIX, RoundingMode.HALF_UP)); } }); screenPioneerDataService.delAndSavePioneerData(customerId, OrgTypeConstant.AGENCY, IndexCalConstant.DELETE_SIZE, communityList); @@ -243,44 +263,52 @@ public class PioneerDataExtractServiceImpl implements PioneerDataExtractService } else { entity.setAgencyPath(entity.getAgencyPids().concat(StrConstant.COLON).concat(entity.getOrgId())); } + log.info("extractExceptCommunityPioneerData 当前orgId="+entity.getOrgId()+";agencyPath="+entity.getAgencyPath()); //1、党员参与议事 entity.setIssueTotal(calPartyPartiIssueTotal(customerId,null,null,entity.getAgencyPath(),NumConstant.ONE_STR)); + log.info("extractExceptCommunityPioneerData 党员参与议事issueTotal="+entity.getIssueTotal()); if(entity.getIssueTotal()==0){ entity.setIssueRatio(BigDecimal.ZERO); }else{ //2、党员参与议事占比 int issueTotal=calPartyPartiIssueTotal(customerId,null,null,entity.getAgencyPath(),null); - entity.setIssueRatio(new BigDecimal(entity.getIssueTotal()/issueTotal).setScale(NumConstant.SIX,RoundingMode.HALF_UP)); + log.info("extractExceptCommunityPioneerData 平台参与议事issueTotal="+issueTotal); + entity.setIssueRatio(new BigDecimal((double)entity.getIssueTotal()/issueTotal).multiply(new BigDecimal(NumConstant.ONE_HUNDRED)).setScale(NumConstant.SIX,RoundingMode.HALF_UP)); } //3、党员发布话题: entity.setTopicTotal(getAgencyTopicTotal(customerId, entity.getAgencyPath(),NumConstant.ONE_STR)); + log.info("extractExceptCommunityPioneerData 党员发布话题topicTotal="+entity.getTopicTotal()); //4、党员发布话题占比: 组织内注册党员发布的话题总数占 组织内话题总数的 比率 if (entity.getTopicTotal() == NumConstant.ZERO) { entity.setTopicRatio(BigDecimal.ZERO); } else { //当前组织内所有话题总数 int agencyTopicTotal = getAgencyTopicTotal(customerId, entity.getAgencyPath(),null); - entity.setTopicRatio(agencyTopicTotal == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(entity.getTopicTotal() / agencyTopicTotal).setScale(NumConstant.SIX, RoundingMode.HALF_UP)); + log.info("extractExceptCommunityPioneerData 当前组织内所有话题总数agencyTopicTotal="+agencyTopicTotal); + entity.setTopicRatio(agencyTopicTotal == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal((double)entity.getTopicTotal() / agencyTopicTotal).multiply(new BigDecimal(NumConstant.ONE_HUNDRED)).setScale(NumConstant.SIX, RoundingMode.HALF_UP)); } //当前组织内所有议题总数 int agencyIssueTotal = getAgencyIssueTotal(customerId, entity.getAgencyPath()); + log.info("extractExceptCommunityPioneerData 当前组织内所有议题总数agencyIssueTotal="+agencyIssueTotal); if (agencyIssueTotal != NumConstant.ZERO) { //5、党员发布议题 entity.setPublishIssueTotal(getAgencyParyPublishIssueTotal(customerId, entity.getAgencyPath())); + log.info("extractExceptCommunityPioneerData 党员发布议题publishIssueTotal="+entity.getPublishIssueTotal()); //6、党员发布议题占比 : 占社区内所有议题的比率 if (entity.getPublishIssueTotal() == NumConstant.ZERO) { entity.setPublishIssueRatio(BigDecimal.ZERO); } - entity.setPublishIssueRatio(agencyIssueTotal == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(entity.getPublishIssueTotal() / agencyIssueTotal).setScale(NumConstant.SIX, RoundingMode.HALF_UP)); + entity.setPublishIssueRatio(agencyIssueTotal == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal((double)entity.getPublishIssueTotal() / agencyIssueTotal).multiply(new BigDecimal(NumConstant.ONE_HUNDRED)).setScale(NumConstant.SIX, RoundingMode.HALF_UP)); //7、议题转项目数 entity.setShiftProjectTotal(getAgencyShiftProjectTotal(customerId, entity.getAgencyPath())); + log.info("extractExceptCommunityPioneerData 议题转项目数shiftProjectTotal="+entity.getShiftProjectTotal()); //8、议题转项目占比 : 占网格内议题总数的比率 - entity.setShiftProjectRatio(entity.getShiftProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(entity.getShiftProjectTotal() / agencyIssueTotal).setScale(NumConstant.SIX, RoundingMode.HALF_UP)); + entity.setShiftProjectRatio(entity.getShiftProjectTotal() == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal((double)entity.getShiftProjectTotal() / agencyIssueTotal).multiply(new BigDecimal(NumConstant.ONE_HUNDRED)).setScale(NumConstant.SIX, RoundingMode.HALF_UP)); }else{ -// log.info("当前组织内所有议题总数="+agencyIssueTotal); + log.info("extractExceptCommunityPioneerData 当前组织内所有议题总数agencyIssueTotal=0"); entity.setPublishIssueTotal(NumConstant.ZERO); entity.setPublishIssueRatio(BigDecimal.ZERO); entity.setShiftProjectTotal(NumConstant.ZERO); @@ -290,12 +318,14 @@ public class PioneerDataExtractServiceImpl implements PioneerDataExtractService // 9、已解决项目 entity.setResolvedProjectTotal(getAgencyClosedProjectTotal(customerId, entity.getAgencyPath(), DimObjectStatusConstant.RESOLVED)); + log.info("extractExceptCommunityPioneerData 已解决项目resolvedProjectTotal="+entity.getResolvedProjectTotal()); if (entity.getResolvedProjectTotal() == NumConstant.ZERO) { entity.setResolvedProjectRatio(BigDecimal.ZERO); } else { // 10、占总结项目 int closedProjectTotal = getAgencyClosedProjectTotal(customerId, entity.getAgencyPath(), null); - entity.setResolvedProjectRatio(closedProjectTotal == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal(entity.getResolvedProjectTotal() / closedProjectTotal).setScale(NumConstant.SIX, RoundingMode.HALF_UP)); + log.info("extractExceptCommunityPioneerData 总结项目closedProjectTotal="+closedProjectTotal); + entity.setResolvedProjectRatio(closedProjectTotal == NumConstant.ZERO ? BigDecimal.ZERO : new BigDecimal((double)entity.getResolvedProjectTotal() / closedProjectTotal).multiply(new BigDecimal(NumConstant.ONE_HUNDRED)).setScale(NumConstant.SIX, RoundingMode.HALF_UP)); } }); screenPioneerDataService.delAndSavePioneerData(customerId, OrgTypeConstant.AGENCY, IndexCalConstant.DELETE_SIZE, agencyList); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimGridServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimGridServiceImpl.java index 5062b8e94f..a08e0af4ba 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimGridServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimGridServiceImpl.java @@ -186,7 +186,7 @@ public class DimGridServiceImpl extends BaseServiceImpl getGridAttributes(String customerId,List gridIds) { - if(CollectionUtils.isEmpty(gridIds)) return Collections.EMPTY_LIST; + return baseDao.selectGridAttributes(customerId,gridIds); } } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginGroupMainDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginGroupMainDailyDao.xml index 2717a8cb5e..db5dc8b583 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginGroupMainDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginGroupMainDailyDao.xml @@ -97,7 +97,7 @@ - + DELETE FROM fact_origin_group_main_daily @@ -287,8 +287,8 @@ WHERE DEL_FLAG = '0' AND CUSTOMER_ID = #{customerId} - AND MONTH_ID = #{monthId} AND GROUP_STATE = 'approved' + AND IS_OWNER_PARTY = 1 AND ( @@ -338,4 +338,4 @@ AND f.GROUP_STATE = 'approved' GROUP BY f.AGENCY_ID - \ No newline at end of file + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/group/GroupDataDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/group/GroupDataDao.xml index f47b266eba..9b6da626dc 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/group/GroupDataDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/group/GroupDataDao.xml @@ -186,7 +186,7 @@ oper.UPDATED_TIME AS joinDate, IF(groupp.CREATED_BY = oper.CUSTOMER_USER_ID,'leader','member') AS leaderFlag, groupp.CREATED_BY AS groupOwnerId, - 'join' AS actionCode + IF(groupp.CREATED_BY = oper.CUSTOMER_USER_ID,'join','create') AS actionCode FROM RESI_GROUP groupp diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimGridDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimGridDao.xml index b83e517441..d7a33deb51 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimGridDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimGridDao.xml @@ -104,11 +104,14 @@ dg.DEL_FLAG = '0' AND da.DEL_FLAG = '0' AND da.CUSTOMER_ID = #{customerId} - AND - ( - - dg.id = #{gridId} - - ) + + AND + ( + + dg.id = #{gridId} + + ) + + \ No newline at end of file diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SystemMessageSendApproach.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SystemMessageSendApproach.java new file mode 100644 index 0000000000..7406175d87 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SystemMessageSendApproach.java @@ -0,0 +1,7 @@ +package com.epmet.constant; + +public interface SystemMessageSendApproach { + + String MQ = "mq"; + +} diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SystemMessageType.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SystemMessageType.java new file mode 100644 index 0000000000..382b96e275 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/constant/SystemMessageType.java @@ -0,0 +1,13 @@ +package com.epmet.constant; + +/** + * 系统消息类型 + */ +public interface SystemMessageType { + + /** + * 初始化客户 + */ + String INIT_CUSTOMER = "init_customer"; + +} diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/SystemMsgFormDTO.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/SystemMsgFormDTO.java new file mode 100644 index 0000000000..c0fc9308b8 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/dto/form/SystemMsgFormDTO.java @@ -0,0 +1,15 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Data +public class SystemMsgFormDTO { + + @NotNull(message = "消息类型不能为空") + private String messageType; + + @NotNull(message = "消息内容不能为空") + private Object content; +} diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/EpmetMessageOpenFeignClient.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/EpmetMessageOpenFeignClient.java index 39f6d76f21..ff085c7bc0 100644 --- a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/EpmetMessageOpenFeignClient.java +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/EpmetMessageOpenFeignClient.java @@ -5,6 +5,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.dto.SysSmsDTO; import com.epmet.dto.form.ProjectSendMsgFormDTO; import com.epmet.dto.form.SendVerificationCodeFormDTO; +import com.epmet.dto.form.SystemMsgFormDTO; import com.epmet.dto.form.UserMessageFormDTO; import com.epmet.dto.form.WxSubscribeMessageFormDTO; import com.epmet.dto.form.WxSubscribeUpdateFormDTO; @@ -96,4 +97,13 @@ public interface EpmetMessageOpenFeignClient { **/ @PostMapping(value = "message/wxmpmessage/sendwxsubscribeupdate", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) Result sendWxSubscribeUpdate(List msgList); + + /** + * @Description 通过mq发送系统消息 + * @return + * @author wxz + * @date 2021.01.06 15:16 + */ + @PostMapping("/message/system/send-by-mq") + Result sendSystemMsgByMQ(@RequestBody SystemMsgFormDTO form); } diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/fallback/EpmetMessageOpenFeignClientFallback.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/fallback/EpmetMessageOpenFeignClientFallback.java index 9f1ae0083f..a77d9152db 100644 --- a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/fallback/EpmetMessageOpenFeignClientFallback.java +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/feign/fallback/EpmetMessageOpenFeignClientFallback.java @@ -6,6 +6,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.dto.SysSmsDTO; import com.epmet.dto.form.ProjectSendMsgFormDTO; import com.epmet.dto.form.SendVerificationCodeFormDTO; +import com.epmet.dto.form.SystemMsgFormDTO; import com.epmet.dto.form.UserMessageFormDTO; import com.epmet.dto.form.WxSubscribeMessageFormDTO; import com.epmet.dto.form.WxSubscribeUpdateFormDTO; @@ -63,4 +64,9 @@ public class EpmetMessageOpenFeignClientFallback implements EpmetMessageOpenFeig public Result sendWxSubscribeUpdate(List msgList) { return ModuleUtils.feignConError(ServiceConstant.EPMET_MESSAGE_SERVER, "sendWxSubscribeUpdate", msgList); } + + @Override + public Result sendSystemMsgByMQ(SystemMsgFormDTO form) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_MESSAGE_SERVER, "sendSystemMsgByMQ", form); + } } diff --git a/epmet-module/epmet-message/epmet-message-server/pom.xml b/epmet-module/epmet-message/epmet-message-server/pom.xml index 778985212f..ccfcf76ec3 100644 --- a/epmet-module/epmet-message/epmet-message-server/pom.xml +++ b/epmet-module/epmet-message/epmet-message-server/pom.xml @@ -118,6 +118,13 @@ oper-crm-client 2.0.0 + + + + com.epmet + epmet-commons-rocketmq + 2.0.0 + @@ -184,6 +191,10 @@ SEC080aac67ff78e79fdaba132aa51e3fb3f6060dec99492feaac82cabf9f8b6a19 + + + 192.168.1.130:9876;192.168.1.132:9876 + epmet_message @@ -228,6 +239,10 @@ SEC080aac67ff78e79fdaba132aa51e3fb3f6060dec99492feaac82cabf9f8b6a19 + + + 192.168.1.130:9876;192.168.1.132:9876 + epmet_message @@ -272,6 +287,10 @@ SEC080aac67ff78e79fdaba132aa51e3fb3f6060dec99492feaac82cabf9f8b6a19 + + + 192.168.10.161:9876 + epmet_message @@ -313,6 +332,10 @@ SEC95f4f40b533ad379ea6a6d1af6dd37029383cfe1b7cd96dfac2678be2c1c3ed1 + + + 192.168.11.187:9876;192.168.11.184:9876 + epmet_message diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/SystemMessageController.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/SystemMessageController.java new file mode 100644 index 0000000000..7a31e91785 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/controller/SystemMessageController.java @@ -0,0 +1,27 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.form.SystemMsgFormDTO; +import com.epmet.service.SystemMessageService; +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; + +@RestController +@RequestMapping("system") +public class SystemMessageController { + + @Autowired + private SystemMessageService systemMessageService; + + @PostMapping("send-by-mq") + public Result sendSystemMsgByMQ(@RequestBody SystemMsgFormDTO form) { + ValidatorUtils.validateEntity(form); + systemMessageService.sendMQMessage(form.getMessageType(), form.getContent()); + return new Result(); + } + +} diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/SystemMessageDao.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/SystemMessageDao.java new file mode 100644 index 0000000000..7770c58547 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/dao/SystemMessageDao.java @@ -0,0 +1,33 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.SystemMessageEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 系统消息表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-01-06 + */ +@Mapper +public interface SystemMessageDao extends BaseDao { + +} \ No newline at end of file diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/SystemMessageEntity.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/SystemMessageEntity.java new file mode 100644 index 0000000000..effdb2d59b --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/entity/SystemMessageEntity.java @@ -0,0 +1,57 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.omg.CORBA.StringHolder; + +import java.util.Date; + +/** + * 系统消息表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-01-06 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("system_message") +public class SystemMessageEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 消息类型 + */ + private String msgType; + + /** + * 发送途径 + */ + private String sendApproach; + + /** + * 消息内容 + */ + private String content; + +} diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/SystemMessageService.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/SystemMessageService.java new file mode 100644 index 0000000000..2985b550c9 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/SystemMessageService.java @@ -0,0 +1,7 @@ +package com.epmet.service; + +public interface SystemMessageService { + + void sendMQMessage(String messageType, Object content); + +} diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/SystemMessageServiceImpl.java b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/SystemMessageServiceImpl.java new file mode 100644 index 0000000000..64a067af56 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-server/src/main/java/com/epmet/service/impl/SystemMessageServiceImpl.java @@ -0,0 +1,70 @@ +package com.epmet.service.impl; + +import com.alibaba.fastjson.JSON; +import com.epmet.commons.rocketmq.constants.TopicConstants; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.constant.SystemMessageSendApproach; +import com.epmet.constant.SystemMessageType; +import com.epmet.dao.SystemMessageDao; +import com.epmet.entity.SystemMessageEntity; +import com.epmet.service.SystemMessageService; +import org.apache.rocketmq.common.message.Message; +import org.apache.rocketmq.remoting.common.RemotingHelper; +import org.apache.rocketmq.spring.core.RocketMQTemplate; +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; + +@Service +public class SystemMessageServiceImpl implements SystemMessageService { + + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Autowired + private SystemMessageDao systemMessageDao; + + @Autowired + private RocketMQTemplate rocketMQTemplate; + + @Transactional(rollbackFor = Exception.class) + @Override + public void sendMQMessage(String messageType, Object content) { + String contentStr = JSON.toJSONString(content); + //存储消息到表 + SystemMessageEntity systemMessageEntity = new SystemMessageEntity(); + systemMessageEntity.setMsgType(messageType); + systemMessageEntity.setSendApproach(SystemMessageSendApproach.MQ); + systemMessageEntity.setContent(contentStr); + systemMessageDao.insert(systemMessageEntity); + + //发送mq消息 + try { + Message meMessage = new Message(getTopicByMsgType(messageType), contentStr.getBytes(RemotingHelper.DEFAULT_CHARSET)); + rocketMQTemplate.getProducer().send(meMessage); + } catch (Exception e) { + String errorStackTrace = ExceptionUtils.getErrorStackTrace(e); + logger.error("发送系统消息失败,堆栈信息:{}", errorStackTrace); + throw new RenException(EpmetErrorCode.SYSTEM_MQ_MSG_SEND_FAIL.getCode()); + } + } + + /** + * @Description 根据消息类型获取topic + * @return + * @author wxz + * @date 2021.01.06 13:42 + */ + private String getTopicByMsgType(String msgType) { + String topic = null; + switch (msgType) { + case SystemMessageType.INIT_CUSTOMER: + topic = TopicConstants.INIT_CUSTOMER; + break; + } + return topic; + } +} diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/resources/bootstrap.yml b/epmet-module/epmet-message/epmet-message-server/src/main/resources/bootstrap.yml index fc82a1608a..0639ecbfd2 100644 --- a/epmet-module/epmet-message/epmet-message-server/src/main/resources/bootstrap.yml +++ b/epmet-module/epmet-message/epmet-message-server/src/main/resources/bootstrap.yml @@ -137,4 +137,9 @@ dingTalk: shutdown: graceful: enable: true #是否开启优雅停机 - waitTimeSecs: 30 # 优雅停机等待时间,超过30秒,发出告警 \ No newline at end of file + waitTimeSecs: 30 # 优雅停机等待时间,超过30秒,发出告警 + +rocketmq: + name-server: @rocketmq.nameserver@ + producer: + group: @rocketmq.producer.group@ \ No newline at end of file diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/SystemMessageDao.xml b/epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/SystemMessageDao.xml new file mode 100644 index 0000000000..a5ce6d9da5 --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-server/src/main/resources/mapper/SystemMessageDao.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AddTemplateFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AddTemplateFormDTO.java index edb391eb73..16491eb32e 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AddTemplateFormDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AddTemplateFormDTO.java @@ -48,4 +48,9 @@ public class AddTemplateFormDTO implements Serializable { * 关键字名称 */ private List nameList; + + /** + * 是否同步到所有客户 + */ + private Boolean isSync = true; } diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/DelPersonalTempFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/DelPersonalTempFormDTO.java new file mode 100644 index 0000000000..9c49eeeccf --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/DelPersonalTempFormDTO.java @@ -0,0 +1,31 @@ +package com.epmet.dto.form; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2021/1/11 14:53 + */ +@NoArgsConstructor +@Data +public class DelPersonalTempFormDTO implements Serializable { + + private static final long serialVersionUID = -1445036628319660147L; + /** + * 客户ID + */ + private String customerId; + /** + * 所属端 居民端resi 工作端work + */ + private String clientType; + /** + * 模板id + */ + private List tempIdList; +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/InitAllFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/InitAllFormDTO.java new file mode 100644 index 0000000000..ed476cc3b6 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/InitAllFormDTO.java @@ -0,0 +1,26 @@ +package com.epmet.dto.form; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2021/1/11 14:47 + */ +@NoArgsConstructor +@Data +public class InitAllFormDTO implements Serializable { + + private static final long serialVersionUID = 5198153778356904936L; + /** + * 测试号APPID + */ + private String appId; + /** + * 模板ID + */ + private String tempId; +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/InitFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/InitFormDTO.java index ab154a196a..196128aff2 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/InitFormDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/InitFormDTO.java @@ -36,4 +36,9 @@ public class InitFormDTO implements Serializable { * 工作端需要同步的模板id数组 */ private List workTempIdList; + + /** + * 1 已同步,0 未同步 + */ + private String sync; } diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/TemplateDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/TemplateDTO.java index 0229316e01..1fccf69f2d 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/TemplateDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/TemplateDTO.java @@ -17,9 +17,14 @@ public class TemplateDTO implements Serializable { */ private String id; /** - * 模板ID + * 公共模板ID */ private String tmplId; + private String personalId; + /** + * 客户模板ID + */ + private String personalTempId; /** * 标题 */ diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/SubscribeController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/SubscribeController.java index 47d3b6d653..63a31e73b2 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/SubscribeController.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/SubscribeController.java @@ -146,4 +146,30 @@ public class SubscribeController { CustomerTempResultDTO result = subscribeService.getCustomerTemplate(formDTO); return new Result().ok(result); } + + /** + * 同步单一模板到所有客户 + * @author zhaoqifeng + * @date 2021/1/11 14:49 + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + */ + @PostMapping("initall") + public Result initAll(@RequestBody InitAllFormDTO formDTO) { + subscribeService.initAll(formDTO); + return new Result(); + } + + /** + * 删除客户模板 + * @author zhaoqifeng + * @date 2021/1/11 14:54 + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + */ + @PostMapping("delpersonaltemp") + public Result delPersonalTemp(@RequestBody DelPersonalTempFormDTO formDTO) { + subscribeService.delPersonalTemp(formDTO); + return new Result(); + } } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PersonalTemplateDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PersonalTemplateDao.java index 93fe3d2d95..054712bea0 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PersonalTemplateDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PersonalTemplateDao.java @@ -105,4 +105,6 @@ public interface PersonalTemplateDao extends BaseDao { List selectListByKey(@Param("appId") String appId, @Param("tid") String tid, @Param("keyIds") String keyIds); List selectTemplateListV2(TemplateListV2FormDTO formDTO); + + PersonalTemplateDTO getTempByPid(); } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PersonalTemplateService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PersonalTemplateService.java index 1f3540a90f..a586844667 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PersonalTemplateService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PersonalTemplateService.java @@ -156,4 +156,14 @@ public interface PersonalTemplateService extends BaseService getListByKey(String appId, String tid, String keyIds); List templateListV2(TemplateListV2FormDTO formDTO); + + /** + * 获取个人模板 + * @author zhaoqifeng + * @date 2021/1/11 15:32 + * @param customerId + * @param pid + * @return com.epmet.dto.PersonalTemplateDTO + */ + PersonalTemplateDTO getTempByPid(String customerId, String pid); } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/SubscribeService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/SubscribeService.java index c56d17487a..6790a2aa15 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/SubscribeService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/SubscribeService.java @@ -102,4 +102,22 @@ public interface SubscribeService { */ CustomerTempResultDTO getCustomerTemplate(InitFormDTO formDTO); + /** + * 同步单一模板到所有客户 + * @author zhaoqifeng + * @date 2021/1/11 14:49 + * @param formDTO + * @return void + */ + void initAll(InitAllFormDTO formDTO); + + /** + * 删除客户模板 + * @author zhaoqifeng + * @date 2021/1/11 14:54 + * @param formDTO + * @return void + */ + void delPersonalTemp(DelPersonalTempFormDTO formDTO); + } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PersonalTemplateServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PersonalTemplateServiceImpl.java index 65e2f87e51..96e257c141 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PersonalTemplateServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PersonalTemplateServiceImpl.java @@ -165,4 +165,18 @@ public class PersonalTemplateServiceImpl extends BaseServiceImpl templateListV2(TemplateListV2FormDTO formDTO) { return baseDao.selectTemplateListV2(formDTO); } + + /** + * 获取个人模板 + * + * @param customerId + * @param pid + * @return com.epmet.dto.PersonalTemplateDTO + * @author zhaoqifeng + * @date 2021/1/11 15:32 + */ + @Override + public PersonalTemplateDTO getTempByPid(String customerId, String pid) { + return baseDao.selectSetTemp(customerId, pid); + } } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/SubscribeServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/SubscribeServiceImpl.java index 6d212b75ee..b51c32632e 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/SubscribeServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/SubscribeServiceImpl.java @@ -199,44 +199,46 @@ public class SubscribeServiceImpl implements SubscribeService { personalTemplateDTO.setKeyWords(keywords); personalTemplateDTO.setType(formDTO.getType()); personalTemplateService.save(personalTemplateDTO); - //获取客户列表 - List customerList = paCustomerService.getCustomerListByTestId(authInfo.getCustomerId()); - List customerNames = new ArrayList<>(); - if (null != customerList && customerList.size() > NumConstant.ZERO) { - for (PaCustomerDTO paCustomerDTO : customerList) { - //获取小程序调用令牌 - AuthorizationInfoDTO authDTO = authorizationInfoDao.getAuthInfoByCustomer(paCustomerDTO.getId(), authInfo.getClientType()); - if (null == authDTO) { - log.error("客户[" + paCustomerDTO.getCustomerName() + "]未授权"); - customerNames.add(paCustomerDTO.getCustomerName()); - continue; - } - WxResult wxResult1 = wxMaSubscribeService.addTemplate(authDTO.getAuthorizerAccessToken(), request); - if (!wxResult1.success()) { - log.error("客户[" + paCustomerDTO.getCustomerName() + "]添加模板失败,原因:" + wxResult1.getErrorCode() + wxResult1.getErrorMsg()); - customerNames.add(paCustomerDTO.getCustomerName()); - continue; + if (formDTO.getIsSync()) { + //获取客户列表 + List customerList = paCustomerService.getCustomerListByTestId(authInfo.getCustomerId()); + List customerNames = new ArrayList<>(); + if (null != customerList && customerList.size() > NumConstant.ZERO) { + for (PaCustomerDTO paCustomerDTO : customerList) { + //获取小程序调用令牌 + AuthorizationInfoDTO authDTO = authorizationInfoDao.getAuthInfoByCustomer(paCustomerDTO.getId(), authInfo.getClientType()); + if (null == authDTO) { + log.error("客户[" + paCustomerDTO.getCustomerName() + "]未授权"); + customerNames.add(paCustomerDTO.getCustomerName()); + continue; + } + WxResult wxResult1 = wxMaSubscribeService.addTemplate(authDTO.getAuthorizerAccessToken(), request); + if (!wxResult1.success()) { + log.error("客户[" + paCustomerDTO.getCustomerName() + "]添加模板失败,原因:" + wxResult1.getErrorCode() + wxResult1.getErrorMsg()); + customerNames.add(paCustomerDTO.getCustomerName()); + continue; + } + String tmplId = wxResult1.getData(); + PersonalTemplateDTO templateDTO = new PersonalTemplateDTO(); + templateDTO.setCustomerId(paCustomerDTO.getId()); + templateDTO.setClientType(authInfo.getClientType()); + templateDTO.setAppId(authDTO.getAuthorizerAppid()); + templateDTO.setPid(priTmplId); + templateDTO.setPriTmplId(tmplId); + templateDTO.setTid(formDTO.getTid()); + templateDTO.setKeyIds(keyIds); + templateDTO.setTitle(formDTO.getTitle()); + templateDTO.setSceneDesc(formDTO.getSceneDesc()); + templateDTO.setKeyWords(keywords); + templateDTO.setType(formDTO.getType()); + personalTemplateService.save(templateDTO); } - String tmplId = wxResult1.getData(); - PersonalTemplateDTO templateDTO = new PersonalTemplateDTO(); - templateDTO.setCustomerId(paCustomerDTO.getId()); - templateDTO.setClientType(authInfo.getClientType()); - templateDTO.setAppId(authDTO.getAuthorizerAppid()); - templateDTO.setPid(priTmplId); - templateDTO.setPriTmplId(tmplId); - templateDTO.setTid(formDTO.getTid()); - templateDTO.setKeyIds(keyIds); - templateDTO.setTitle(formDTO.getTitle()); - templateDTO.setSceneDesc(formDTO.getSceneDesc()); - templateDTO.setKeyWords(keywords); - templateDTO.setType(formDTO.getType()); - personalTemplateService.save(templateDTO); } - } - if (customerNames.size() > NumConstant.ZERO) { - String names = String.join(",", customerNames); - throw new RenException("客户[" + names + "]添加模板失败"); + if (customerNames.size() > NumConstant.ZERO) { + String names = String.join(",", customerNames); + throw new RenException("客户[" + names + "]添加模板失败"); + } } } @@ -348,7 +350,6 @@ public class SubscribeServiceImpl implements SubscribeService { log.error("居民端同步失败:" + wxResult.getErrorCode() + wxResult.getErrorMsg()); } }); - resultDTO.setResiList(resiList); AuthorizationInfoDTO workAuthDTO = authorizationInfoDao.getAuthInfoByCustomer(formDTO.getCustomerId(), "work"); if (null == workAuthDTO) { @@ -371,10 +372,100 @@ public class SubscribeServiceImpl implements SubscribeService { log.error("工作端同步失败:" + wxResult.getErrorCode() + wxResult.getErrorMsg()); } }); + +// resultDTO.setResiList(resiList.stream().filter(item -> formDTO.getSync().equals(item.getState())).collect(Collectors.toList())); +// resultDTO.setWorkList(workList.stream().filter(item -> formDTO.getSync().equals(item.getState())).collect(Collectors.toList())); + resultDTO.setResiList(resiList); resultDTO.setWorkList(workList); return resultDTO; } + /** + * 同步单一模板到所有客户 + * + * @param formDTO + * @return void + * @author zhaoqifeng + * @date 2021/1/11 14:49 + */ + @Override + public void initAll(InitAllFormDTO formDTO) { + AuthorizationInfoDTO authInfo = authorizationInfoDao.selectInfoByAppId(formDTO.getAppId()); + PersonalTemplateDTO publicDTO = personalTemplateService.getTempByPid(authInfo.getCustomerId(), formDTO.getTempId()); + + //获取客户列表 + List customerList = paCustomerService.getCustomerListByTestId(authInfo.getCustomerId()); + List customerNames = new ArrayList<>(); + if (null != customerList && customerList.size() > NumConstant.ZERO) { + for (PaCustomerDTO paCustomerDTO : customerList) { + PersonalTemplateDTO personalTemplateDTO = personalTemplateService.getTempByPid(paCustomerDTO.getId(), publicDTO.getPriTmplId()); + if (null == personalTemplateDTO) { + //获取小程序调用令牌 + AuthorizationInfoDTO authDTO = authorizationInfoDao.getAuthInfoByCustomer(paCustomerDTO.getId(), authInfo.getClientType()); + + List keyIds = Arrays.asList(publicDTO.getKeyIds().split(",")); + List keyIdList = keyIds.stream().map(Integer::parseInt).collect(Collectors.toList()); + WxAddTemplateReq request = new WxAddTemplateReq(); + request.setTid(publicDTO.getTid()); + request.setKidList(keyIdList); + request.setSceneDesc(publicDTO.getSceneDesc()); + WxResult wxResult = wxMaSubscribeService.addTemplate(authInfo.getAuthorizerAccessToken(), request); + if (null == authDTO) { + log.error("客户[" + paCustomerDTO.getCustomerName() + "]未授权"); + customerNames.add(paCustomerDTO.getCustomerName()); + continue; + } + + String tmplId = wxResult.getData(); + PersonalTemplateDTO templateDTO = new PersonalTemplateDTO(); + templateDTO.setCustomerId(paCustomerDTO.getId()); + templateDTO.setClientType(authInfo.getClientType()); + templateDTO.setAppId(authDTO.getAuthorizerAppid()); + templateDTO.setPid(publicDTO.getPriTmplId()); + templateDTO.setPriTmplId(tmplId); + templateDTO.setTid(publicDTO.getTid()); + templateDTO.setKeyIds(publicDTO.getKeyIds()); + templateDTO.setTitle(publicDTO.getTitle()); + templateDTO.setSceneDesc(publicDTO.getSceneDesc()); + templateDTO.setKeyWords(publicDTO.getKeyWords()); + templateDTO.setType(publicDTO.getType()); + personalTemplateService.save(templateDTO); + } + } + } + + if (customerNames.size() > NumConstant.ZERO) { + String names = String.join(",", customerNames); + log.error("客户[" + names + "]添加模板失败"); + } + } + + /** + * 删除客户模板 + * + * @param formDTO + * @return void + * @author zhaoqifeng + * @date 2021/1/11 14:54 + */ + @Override + public void delPersonalTemp(DelPersonalTempFormDTO formDTO) { + AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(formDTO.getCustomerId(), formDTO.getClientType()); + if (null == authInfo) { + throw new RenException("未授权或token已过期"); + } + formDTO.getTempIdList().forEach(tempId -> { + PersonalTemplateDTO dto = personalTemplateService.get(tempId); + WxDelTemplateReq request = new WxDelTemplateReq(); + request.setPriTmplId(dto.getPriTmplId()); + WxResult wxResult = wxMaSubscribeService.delTemplate(authInfo.getAuthorizerAccessToken(), request); + if (!wxResult.success()) { + throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg()); + } + personalTemplateService.deleteById(dto.getId()); + }); + } + private WxGetCategoryResult getCategoryResult(String accessToken) { WxResult wxResult = wxMaSubscribeService.getCategory(accessToken); diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PersonalTemplateDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PersonalTemplateDao.xml index 26c12ac4ec..644cda2bc6 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PersonalTemplateDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PersonalTemplateDao.xml @@ -39,7 +39,17 @@ + + \ No newline at end of file diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java index b31f94ddff..494fce4e3f 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.java @@ -469,4 +469,12 @@ public interface EpmetUserOpenFeignClient { @PostMapping(value = "epmetuser/staffrole/specificrolesstaffs", consumes = MediaType.APPLICATION_JSON_VALUE) Result> specificRolesStaffs(RolesUsersListFormDTO rolesUsersListFormDTO); + + /** + * 为客户初始化政府端工作人员角色 + * @param customerId + * @return + */ + @PostMapping("/epmetuser/staffrole/initrolesforcustomer/{customerId}") + Result initGovStaffRolesForCustomer(@PathVariable String customerId); } diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java index 69371a19cd..7137d3ad1d 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java @@ -331,4 +331,9 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien public Result> specificRolesStaffs(RolesUsersListFormDTO rolesUsersListFormDTO) { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "specificRolesStaffs", rolesUsersListFormDTO); } + + @Override + public Result initGovStaffRolesForCustomer(String customerId) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "initGovStaffRolesForCustomer", customerId); + } } diff --git a/epmet-user/epmet-user-server/pom.xml b/epmet-user/epmet-user-server/pom.xml index 67888acc41..847367216c 100644 --- a/epmet-user/epmet-user-server/pom.xml +++ b/epmet-user/epmet-user-server/pom.xml @@ -112,6 +112,12 @@ 2.0.0 compile + + + com.epmet + epmet-commons-rocketmq + 2.0.0 + diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GovStaffRoleDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GovStaffRoleDao.java index f7875d63d5..5992dfb720 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GovStaffRoleDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GovStaffRoleDao.java @@ -77,4 +77,6 @@ public interface GovStaffRoleDao extends BaseDao { int updateSortById(@Param("roleId") String roleId, @Param("sort") int sort); List listRolesByRoleKey(@Param("roleKey") String roleKey); + + Integer countRolesByCustomerId(@Param("customerId") String customerId); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/mq/listener/InitCustomerRolesListener.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/mq/listener/InitCustomerRolesListener.java new file mode 100644 index 0000000000..a50da7561e --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/mq/listener/InitCustomerRolesListener.java @@ -0,0 +1,39 @@ +//package com.epmet.mq.listener; +// +//import com.alibaba.fastjson.JSON; +//import com.epmet.commons.rocketmq.constants.ConsomerGroupConstants; +//import com.epmet.commons.rocketmq.constants.TopicConstants; +//import com.epmet.commons.rocketmq.messages.InitCustomerMQMsg; +//import com.epmet.service.GovStaffRoleService; +//import org.apache.rocketmq.common.message.MessageExt; +//import org.apache.rocketmq.spring.annotation.MessageModel; +//import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; +//import org.apache.rocketmq.spring.core.RocketMQListener; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.stereotype.Component; +// +///** +// * 监听初始化客户动作,为客户初始化角色列表 +// */ +//@RocketMQMessageListener(topic = TopicConstants.INIT_CUSTOMER, +// consumerGroup = ConsomerGroupConstants.INIT_CUSTOMER_ROLES_GROUP, +// messageModel = MessageModel.CLUSTERING, +// selectorExpression = "*") +//@Component +//public class InitCustomerRolesListener implements RocketMQListener { +// +// private Logger logger = LoggerFactory.getLogger(getClass()); +// +// @Autowired +// private GovStaffRoleService govStaffRoleService; +// +// @Override +// public void onMessage(MessageExt messageExt) { +// String msg = new String(messageExt.getBody()); +// logger.info("初始化客户-初始化角色列表-收到消息内容:{}", msg); +// InitCustomerMQMsg msgObj = JSON.parseObject(msg, InitCustomerMQMsg.class); +// govStaffRoleService.initGovStaffRolesForCustomer(msgObj.getCustomerId()); +// } +//} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GovStaffRoleServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GovStaffRoleServiceImpl.java index 726be2370d..16c6a375e2 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GovStaffRoleServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GovStaffRoleServiceImpl.java @@ -39,6 +39,8 @@ import com.epmet.feign.GovAccessFeignClient; import com.epmet.redis.GovStaffRoleRedis; import com.epmet.service.GovStaffRoleService; 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.transaction.annotation.Transactional; @@ -57,6 +59,8 @@ import java.util.Map; @Service public class GovStaffRoleServiceImpl extends BaseServiceImpl implements GovStaffRoleService { + private Logger logger = LoggerFactory.getLogger(getClass()); + @Autowired private GovStaffRoleRedis govStaffRoleRedis; @@ -140,8 +144,13 @@ public class GovStaffRoleServiceImpl extends BaseServiceImpl 0) { + logger.info("为客户初始化角色列表-该客户【客户ID:%s】已存在角色信息,无需再次初始化。", customerId); + return; + } // 增加角色列表 List validRoles = govStaffRoleTemplateDao.listValidateRoles(); diff --git a/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml b/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml index e05a958192..68f5492ae8 100644 --- a/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml +++ b/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml @@ -146,6 +146,9 @@ dingTalk: webHook: @dingTalk.robot.webHook@ secret: @dingTalk.robot.secret@ +rocketmq: + name-server: 192.168.1.130:9876;192.168.1.132:9876 + # 停机选项 shutdown: graceful: diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/GovStaffRoleDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/GovStaffRoleDao.xml index 40539c565f..87a5fc01e7 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/GovStaffRoleDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/GovStaffRoleDao.xml @@ -111,4 +111,10 @@ where gsr.ROLE_KEY = #{roleKey} and gsr.DEL_FLAG=0 + + \ No newline at end of file