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 aa74cd8e2a..4d717f919e 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 @@ -155,7 +155,8 @@ public enum EpmetErrorCode { EXISTED_SPECIAL_PROJECT(8807, "已经添加过此专题"), CAN_NOT_DEL_SPECIAL_PROJECT(8808, "您没有权限删除此专题"), TAG_NOT_EXIST(8809,"标签不存在"), - + GUIDE_IS_NULL(8810,"指南内容不能为空"), + GUIDE_IS_NOT_YOURS(8811,"只能删除自己创建的指南"), //公众号 865..开头的码 PUBLIC_NOT_EXISTS(8651,"手机号未注册,请先完成信息注册"), SELECT_CUSTOMER_ERROR(8652,"未查询到注册客户信息"), diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java index f16bb16c2b..c0011a3d6a 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java @@ -441,6 +441,28 @@ public class RedisKeys { return rootPrefix.concat("thirdplatform:accesstoken:").concat(platformId); } + /** + * @Description 第三方平台信息key + * @param platformId + * @return java.lang.String + * @author wxz + * @date 2021.08.31 14:44:35 + */ + public static String getThirdPlatformInfoKey(String platformId) { + return rootPrefix.concat("thirdplatform:info:").concat(platformId); + } + + /** + * @Description 第三方平台操作urlkey + * @param platformId + * @return java.lang.String + * @author wxz + * @date 2021.08.31 15:15:15 + */ + public static String getThirdPlatformActionUrlKey(String platformId) { + return rootPrefix.concat("thirdplatform:actions:").concat(platformId); + } + /** * @return 设置组员已读、未读标识 * @param source :act notice @@ -501,4 +523,16 @@ public class RedisKeys { public static String getCustomerStaffInfoKey(String customerId, String staffId) { return rootPrefix.concat("gov:staff:").concat(customerId).concat(StrConstant.COLON).concat(staffId); } + + /** + * @description 网格信息 + * + * @param gridId + * @return + * @author wxz + * @date 2021.09.08 11:03:48 + */ + public static String getGridInfoKey(String gridId) { + return rootPrefix.concat("gov:grid:").concat(gridId); + } } diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/GridInfoCache.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/GridInfoCache.java new file mode 100644 index 0000000000..2900180581 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/common/bean/GridInfoCache.java @@ -0,0 +1,12 @@ +package com.epmet.commons.tools.redis.common.bean; + +import lombok.Data; + +@Data +public class GridInfoCache { + private String gridId; + private String gridNamePath; + private String customerId; + private String pid; + private String pids; +} diff --git a/epmet-gateway/src/main/resources/bootstrap.yml b/epmet-gateway/src/main/resources/bootstrap.yml index aaabe3dcab..3a9e82e496 100644 --- a/epmet-gateway/src/main/resources/bootstrap.yml +++ b/epmet-gateway/src/main/resources/bootstrap.yml @@ -484,6 +484,7 @@ epmet: - /message/template/** - /data/aggregator/project/projectdistribution - /data/aggregator/epmetuser/open-staffdetail + - /data/aggregator/epmetuser/gridmemberpatrollist - /data/aggregator/pub/** #stats external包下 公共的类只外部暴露方法 纯外部使用的 暴漏整个 - /data/stats/statsuser/gm-uploadevent @@ -497,6 +498,7 @@ epmet: - /data/stats/project/** - /data/stats/basereport/** - /data/stats/governance/** + - /third/private-epmet/push-component-access-token # 对外开放接口认证白名单 diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/ListStaffResultDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/ListStaffResultDTO.java index b465f8ec3e..ae926bd6ee 100644 --- a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/ListStaffResultDTO.java +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/ListStaffResultDTO.java @@ -31,5 +31,7 @@ public class ListStaffResultDTO implements Serializable { private String orgName = ""; //职责名称列表 private List roles; + //工作人员添加入口类型(组织:agency;部门:dept;网格:gridId) + private String orgType = ""; } diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/form/OrgStaffListFormDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/form/OrgStaffListFormDTO.java index 7d0ed2f595..391fe968c9 100644 --- a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/form/OrgStaffListFormDTO.java +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/form/OrgStaffListFormDTO.java @@ -45,6 +45,8 @@ public class OrgStaffListFormDTO implements Serializable { private List staffIds; //token中用户Id private String staffId; + //人员是否禁用【未禁用enable,已禁用disabled】 + private String enableFlag = "enable"; public interface OrgStaff extends CustomerClientShowGroup {} } diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/form/StaffDetailV2FormDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/form/StaffDetailV2FormDTO.java index d568099084..a03d93fb71 100644 --- a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/form/StaffDetailV2FormDTO.java +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/govorg/form/StaffDetailV2FormDTO.java @@ -15,6 +15,8 @@ import java.util.List; public class StaffDetailV2FormDTO implements Serializable { private static final long serialVersionUID = -1974456701949979946L; + //工作人员所属组织 + private String agencyId = ""; //工作人员用户id private String staffId = ""; //工作人员姓名 diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java index cfe7943085..1002b8c34a 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java @@ -1,5 +1,6 @@ package com.epmet.dataaggre.service.datastats.impl; + import com.alibaba.fastjson.JSON; import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; @@ -1488,27 +1489,22 @@ public class DataStatsServiceImpl implements DataStatsService { formDTO.setDateId(format.format(yesterday)); } String startDate = null; - String actulStartDate = null; - String endDate = null; + String endDate = formDTO.getDateId(); Date dateIdDate = DateUtils.parse(formDTO.getDateId(), DateUtils.DATE_PATTERN_YYYYMMDD); boolean isYesterday = DateUtils.getBeforeNDay(1,DateUtils.DATE_PATTERN_YYYYMMDD).equals(formDTO.getDateId()); switch (formDTO.getType()){ case "yesterday": - startDate = DateUtils.getBeforeNDay(formDTO.getDateId(),1); + startDate = formDTO.getDateId(); endDate = formDTO.getDateId(); - actulStartDate = formDTO.getDateId(); break; case "thisWeek": - actulStartDate = DateUtils.getWeekStart(formDTO.getDateId()); - startDate = DateUtils.getBeforeNDay(actulStartDate,1); - DateUtils.format(DateUtils.addDateDays(yesterday, -1),DateUtils.DATE_PATTERN_YYYYMMDD); + startDate = DateUtils.getWeekStart(formDTO.getDateId()); if (!isYesterday){ endDate = DateUtils.getWeekEnd(formDTO.getDateId()); } break; case "thisMonth": - actulStartDate = DateUtils.format(DateUtils.getMonthStart(dateIdDate),DateUtils.DATE_PATTERN_YYYYMMDD); - startDate = DateUtils.getBeforeNDay(actulStartDate,1); + startDate = DateUtils.format(DateUtils.getMonthStart(dateIdDate),DateUtils.DATE_PATTERN_YYYYMMDD); if (!isYesterday) { endDate = DateUtils.format(DateUtils.getMonthEnd(dateIdDate), DateUtils.DATE_PATTERN_YYYYMMDD); } @@ -1517,7 +1513,9 @@ public class DataStatsServiceImpl implements DataStatsService { log.warn("==========="); } formDTO.setStartDateId(startDate); + String breforeStartDate = DateUtils.getBeforeNDay(formDTO.getStartDateId(),1); formDTO.setEndDateId(endDate); + log.info("getSubWorkFact do select param:{}", JSON.toJSONString(formDTO)); List result = new ArrayList<>(); //如果是社区 则下级是网格 查询网格的数据 if (OrgLevelEnum.COMMUNITY.getCode().equals(formDTO.getAgencyLevel())){ @@ -1528,22 +1526,22 @@ public class DataStatsServiceImpl implements DataStatsService { } List gridIdList = subAgencyList.stream().map(ScreenCustomerGridDTO::getGridId).collect(Collectors.toList()); //查询组织的话题转议题数据 - List toIssueStart = dataStatsDao.getSubGridTopicShiftIssue(gridIdList, formDTO.getStartDateId()); + List toIssueStart = dataStatsDao.getSubGridTopicShiftIssue(gridIdList, breforeStartDate); List toIssueEnd = dataStatsDao.getSubGridTopicShiftIssue(gridIdList, formDTO.getEndDateId()); Map toIssueStartMap = toIssueStart.stream().collect(Collectors.toMap(SubGridFormDTO.Topic::getGridId, SubGridFormDTO.Topic::getShiftedIssueTotal, (o1, o2) -> o1)); Map toIssueEndMap = toIssueEnd.stream().collect(Collectors.toMap(SubGridFormDTO.Topic::getGridId, SubGridFormDTO.Topic::getShiftedIssueTotal, (o1, o2) -> o1)); //查询组织的议题转项目数据 - List toProjectStart = dataStatsDao.getSubGridIssue(gridIdList, formDTO.getStartDateId()); + List toProjectStart = dataStatsDao.getSubGridIssue(gridIdList, breforeStartDate); List toProjectEnd = dataStatsDao.getSubGridIssue(gridIdList, formDTO.getEndDateId()); Map toProjectStartMap = toProjectStart.stream().collect(Collectors.toMap(SubGridIssueResultDTO::getGridId, SubGridIssueResultDTO::getShiftProjectTotal, (o1, o2) -> o1)); Map toProjectEndMap = toProjectEnd.stream().collect(Collectors.toMap(SubGridIssueResultDTO::getGridId, SubGridIssueResultDTO::getShiftProjectTotal, (o1, o2) -> o1)); //查询组织已关闭的项目数据 - List closeProjectStart = dataStatsDao.getSubGridProject(gridIdList, formDTO.getStartDateId()); + List closeProjectStart = dataStatsDao.getSubGridProject(gridIdList, breforeStartDate); List closeProjectEnd = dataStatsDao.getSubGridProject(gridIdList, formDTO.getEndDateId()); Map closeProjectStartMap = closeProjectStart.stream().collect(Collectors.toMap(SubGridProjectResultDTO::getGridId, SubGridProjectResultDTO::getClosedProjectTotal, (o1, o2) -> o1)); Map closeProjectEndMap = closeProjectEnd.stream().collect(Collectors.toMap(SubGridProjectResultDTO::getGridId, SubGridProjectResultDTO::getClosedProjectTotal, (o1, o2) -> o1)); //巡查次数和时间 - List patrolList = statsStaffPatrolRecordDailyService.getPatrolSumList(gridIdList,actulStartDate,formDTO.getEndDateId()); + List patrolList = statsStaffPatrolRecordDailyService.getPatrolSumList(gridIdList,formDTO.getStartDateId(),formDTO.getEndDateId()); Map patrolListMap = patrolList.stream().collect(Collectors.toMap(PatrolDailySumResult::getFullAgencyId, o -> o, (o1, o2) -> o1)); subAgencyList.forEach(agency->{ @@ -1568,23 +1566,23 @@ public class DataStatsServiceImpl implements DataStatsService { List agencyList = subAgencyList.stream().map(ScreenCustomerAgencyDTO::getAgencyId).collect(Collectors.toList()); //查询组织的话题转议题数据 - List toIssueStart = dataStatsDao.getSubAgencyTopicShiftIssue(agencyList, formDTO.getStartDateId()); + List toIssueStart = dataStatsDao.getSubAgencyTopicShiftIssue(agencyList, breforeStartDate); List toIssueEnd = dataStatsDao.getSubAgencyTopicShiftIssue(agencyList, formDTO.getEndDateId()); Map toIssueStartMap = toIssueStart.stream().collect(Collectors.toMap(SubAgencyFormDTO.Topic::getAgencyId, SubAgencyFormDTO.Topic::getShiftedIssueTotal, (o1, o2) -> o1)); Map toIssueEndMap = toIssueEnd.stream().collect(Collectors.toMap(SubAgencyFormDTO.Topic::getAgencyId, SubAgencyFormDTO.Topic::getShiftedIssueTotal, (o1, o2) -> o1)); //查询组织的议题转项目数据 - List toProjectStart = dataStatsDao.getSubAgencyIssue(agencyList, formDTO.getStartDateId()); + List toProjectStart = dataStatsDao.getSubAgencyIssue(agencyList, breforeStartDate); List toProjectEnd = dataStatsDao.getSubAgencyIssue(agencyList, formDTO.getEndDateId()); Map toProjectStartMap = toProjectStart.stream().collect(Collectors.toMap(SubAgencyIssueResultDTO::getAgencyId, SubAgencyIssueResultDTO::getShiftProjectTotal, (o1, o2) -> o1)); Map toProjectEndMap = toProjectEnd.stream().collect(Collectors.toMap(SubAgencyIssueResultDTO::getAgencyId, SubAgencyIssueResultDTO::getShiftProjectTotal, (o1, o2) -> o1)); //查询组织已关闭的项目数据 - List closeProjectStart = dataStatsDao.getSubAgencyProject(agencyList, formDTO.getStartDateId()); + List closeProjectStart = dataStatsDao.getSubAgencyProject(agencyList, breforeStartDate); List closeProjectEnd = dataStatsDao.getSubAgencyProject(agencyList, formDTO.getEndDateId()); Map closeProjectStartMap = closeProjectStart.stream().collect(Collectors.toMap(SubAgencyProjectResultDTO::getAgencyId, SubAgencyProjectResultDTO::getClosedProjectTotal, (o1, o2) -> o1)); Map closeProjectEndMap = closeProjectEnd.stream().collect(Collectors.toMap(SubAgencyProjectResultDTO::getAgencyId, SubAgencyProjectResultDTO::getClosedProjectTotal, (o1, o2) -> o1)); //巡查次数和时间 List agencyFullIds = subAgencyList.stream().map(o -> o.getPids().concat(StrConstant.COLON).concat(o.getAgencyId())).collect(Collectors.toList()); - List patrolList = statsStaffPatrolRecordDailyService.getPatrolSumList(agencyFullIds,actulStartDate,formDTO.getEndDateId()); + List patrolList = statsStaffPatrolRecordDailyService.getPatrolSumList(agencyFullIds,breforeStartDate,formDTO.getEndDateId()); Map patrolListMap = patrolList.stream().collect(Collectors.toMap(PatrolDailySumResult::getFullAgencyId, o -> o, (o1, o2) -> o1)); subAgencyList.forEach(agency->{ @@ -1602,7 +1600,9 @@ public class DataStatsServiceImpl implements DataStatsService { }); } - List newResult = result.stream().sorted(Comparator.comparing(o -> o.getTopicToIssueTotal() + o.getIssueToProjectTotal() + o.getClosedProjectTotal() + o.getPatrolTotal())).collect(Collectors.toList()); + List newResult = result.stream().sorted(Comparator.comparing(o -> o.getTopicToIssueTotal() + o.getIssueToProjectTotal() + o.getClosedProjectTotal() + o.getPatrolTotal())) + .collect(Collectors.toList()); + Collections.reverse(newResult); return newResult; } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java index 457a99f2d8..7819be0d10 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java @@ -98,6 +98,13 @@ public interface EpmetUserService { */ UserEventLogoResultDTO mentionMeEvent(String userId); + /** + * @Param formDTO + * @Description 对外接口--网格员排名-巡查记录 + * @author sun + */ + List gridMemberPatrolList(GridMemberPatrolListFormDTO formDTO); + /** * @Param formDTO * @Description 通讯录】姓名检索工作人员 diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java index ff11d641ef..73e7a85774 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java @@ -75,10 +75,10 @@ public class EpmetUserServiceImpl implements EpmetUserService { private ResiUserBadgeDao resiUserBadgeDao; @Autowired private GovProjectService govProjectService; - @Resource - private GovStaffRoleDao govStaffRoleDao; @Autowired private DataStatsService dataStatsService; + @Resource + private GovStaffRoleDao govStaffRoleDao; /** * @Description 根据UserIds查询 @@ -442,6 +442,47 @@ public class EpmetUserServiceImpl implements EpmetUserService { return resultDTO; } + /** + * @Param formDTO + * @Description 对外接口--网格员排名-巡查记录 + * @author sun + */ + @Override + public List gridMemberPatrolList(GridMemberPatrolListFormDTO formDTO) { + //1.查询当前组织及下级所有网格员维度对应最大dated数据【例查询2021年8月数据,则是查询8月对应的最大daeId那天的网格员数据】 + List resultList = dataStatsService.getGirdMemberPatrol(formDTO); + if (CollectionUtils.isEmpty(resultList)) { + return new ArrayList<>(); + } + + //2.按维度汇总当前组织及下级网格员巡查数据 + //【如果查询当前月或本年度数据,则需要排除最大dateId的数据,因为上边查的统计数据只有t-1的,巡查数据是t的,避免多计算了当天的巡查项目数和时长数】 + formDTO.setDateId(resultList.get(0).getDateId()); + List patrolList = staffPatrolRecordDao.gridMemberPatrol(formDTO); + + //3.以统计数据为准封装结果数据 + resultList.forEach(re -> patrolList.stream().filter(l -> re.getStaffId().equals(l.getStaffId())).forEach(s -> { + re.setReportProjectCount(s.getReportProjectCount()); + re.setPatrolTotalTime((s.getTimeNum() > NumConstant.ZERO ? s.getTimeNum() / 60 : 0)); + })); + + //4.按排序字段排序并返回 + Collections.sort(resultList, new Comparator() { + @Override + public int compare(GridMemberPatrolListResultDTO o1, GridMemberPatrolListResultDTO o2) { + if ("patrolTime".equals(formDTO.getSort())) { + return o2.getPatrolTotalTime().compareTo(o1.getPatrolTotalTime()); + } else if ("dealEvent".equals(formDTO.getSort())) { + return o2.getEventCount().compareTo(o1.getEventCount()); + } else { + return o2.getReportProjectCount().compareTo(o1.getReportProjectCount()); + } + } + }); + + return resultList; + } + /** * @Param formDTO * @Description 【通讯录】姓名检索工作人员 @@ -647,6 +688,7 @@ public class EpmetUserServiceImpl implements EpmetUserService { List list = staffRoleDao.selectByStaffId(staffId); //汇总数据 result = ConvertUtils.sourceToTarget(dto, StaffDetailV2FormDTO.class); + result.setStaffId(dto.getUserId()); result.setName(dto.getRealName()); result.setGender(dto.getGender().toString()); result.setRoles(list); diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java index 745e68e804..8142f4a728 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java @@ -1,22 +1,18 @@ package com.epmet.dataaggre.service.govorg.impl; import com.alibaba.fastjson.JSON; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.dataaggre.constant.DataSourceConstant; import com.epmet.dataaggre.dao.govorg.*; import com.epmet.dataaggre.dto.epmetuser.result.ListStaffResultDTO; import com.epmet.dataaggre.dto.epmetuser.result.StaffRoleListResultDTO; import com.epmet.dataaggre.dto.govorg.*; -import com.epmet.dataaggre.dto.govorg.form.*; -import com.epmet.dataaggre.dto.govorg.CustomerAgencyDTO; -import com.epmet.dataaggre.dto.govorg.CustomerDepartmentDTO; -import com.epmet.dataaggre.dto.govorg.CustomerGridDTO; -import com.epmet.dataaggre.dto.govorg.CustomerStaffAgencyDTO; import com.epmet.dataaggre.dto.govorg.form.NextAreaCodeFormDTO; import com.epmet.dataaggre.dto.govorg.form.OrgStaffListFormDTO; import com.epmet.dataaggre.dto.govorg.form.StaffDetailV2FormDTO; @@ -34,10 +30,8 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; +import java.util.*; +import java.util.stream.Collectors; /** * @Author zxc @@ -398,9 +392,23 @@ public class GovOrgServiceImpl implements GovOrgService { staffIds.removeIf(s->s.equals(formDTO.getStaffId())); } + //是否具有超级管理员或管理员角色 + CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId()); + Map roleMap = staffInfoCache.getRoleMap(); + if (roleMap.containsKey("root_manager") || roleMap.containsKey("manager")) { + formDTO.setEnableFlag("disabled"); + } + //2.分页查询工作人员基础信息、角色信息【组织人员单位领导角色人员在前;部门人员部门领导角色人员在前;网格人员网格长角色人员在前】 List staffList = epmetUserService.getStaffInfoList(formDTO); + //3.查询工作人员注册组织关系信息 + List staffIdList = staffList.stream().map(ListStaffResultDTO::getStaffId).collect(Collectors.toList()); + if (!CollectionUtils.isEmpty(staffIdList)){ + List list = customerAgencyDao.selelctStaffOrg(staffIdList); + staffList.forEach(re -> list.stream().filter(l -> re.getStaffId().equals(l.getStaffId())).forEach(s -> re.setOrgType(s.getOrgType()))); + } + //3.封装数据并返回 resultDTO.setStaffCount(staffIds.size()); resultDTO.setStaffList((null == staffList ? new ArrayList<>() : staffList)); @@ -429,6 +437,7 @@ public class GovOrgServiceImpl implements GovOrgService { } //3.封装数据并返回 + result.setAgencyId(list.get(0).getAgencyId()); result.setOrgId(list.get(0).getOrgId()); result.setOrgName(list.get(0).getOrgName()); result.setOrgType(list.get(0).getOrgType()); diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetmessage/InfoProfileDao.xml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetmessage/InfoProfileDao.xml index 8c31bdcbb8..f93f3198d7 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetmessage/InfoProfileDao.xml +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetmessage/InfoProfileDao.xml @@ -75,9 +75,9 @@ SELECT ir.INFO_ID, ip.content, - ii.CREATED_TIME, + ip.CREATED_TIME, ir.READ_FLAG, - ii.publish_staff_id, + ip.publish_staff_id, ip.first_att_id, ia.ATTACHMENT_NAME AS name, ia.ATTACHMENT_FORMAT AS format, @@ -91,18 +91,20 @@ end) as duration FROM info_receivers ir - INNER JOIN info ii ON ( ir.INFO_ID = ii.ID ) - INNER JOIN info_profile ip ON ( ii.ID = ip.INFO_ID AND ip.DEL_FLAG = '0' ) + + INNER JOIN info ii ON ( ir.INFO_ID = ii.ID ) + + INNER JOIN info_profile ip ON ( ir.INFO_ID = ip.INFO_ID AND ip.DEL_FLAG = '0' ) LEFT JOIN info_att ia on ( ip.first_att_id = ia.id AND ia.DEL_FLAG = '0' ) WHERE ir.DEL_FLAG = '0' - AND ii.DEL_FLAG = '0' AND ir.STAFF_ID = #{userId} + AND ii.DEL_FLAG = '0' and ii.content like concat('%',trim(#{content}),'%') ORDER BY - ii.CREATED_TIME DESC + ip.CREATED_TIME DESC diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerStaffAgencyDao.xml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerStaffAgencyDao.xml index 65afdbabdd..55c4d7789c 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerStaffAgencyDao.xml +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerStaffAgencyDao.xml @@ -77,14 +77,16 @@ SELECT - user_id + csa.user_id FROM - customer_staff_agency + customer_staff_agency csa + INNER JOIN staff_org_relation sor ON csa.user_id = sor.staff_id WHERE - del_flag = '0' - AND agency_id = #{orgId} + csa.del_flag = '0' + AND sor.org_type = 'agency' + AND csa.agency_id = #{orgId} ORDER BY - created_time ASC + csa.created_time ASC diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/SubAgencyIndexRankResultDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/SubAgencyIndexRankResultDTO.java index af9d6caf5e..ae70697765 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/SubAgencyIndexRankResultDTO.java +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/SubAgencyIndexRankResultDTO.java @@ -27,16 +27,19 @@ public class SubAgencyIndexRankResultDTO implements Serializable { * 党建能力 */ private Double governAbility = 0.0; + private Double originGovernAbility = 0.0; /** * 治理能力 */ private Double partyDevAbility = 0.0; + private Double originPartyDevAbility = 0.0; /** * 服务能力 */ private Double serviceAbility = 0.0; + private Double originServiceAbility = 0.0; private String orgId; private String orgType; diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/IndexServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/IndexServiceImpl.java index 8ccc906405..95446fac0d 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/IndexServiceImpl.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/IndexServiceImpl.java @@ -57,9 +57,6 @@ public class IndexServiceImpl implements IndexService { if (null == yearAverageIndexResultDTO){ return new YearAverageIndexResultDTO(); } - yearAverageIndexResultDTO.setPartyDevAbility(getRound(yearAverageIndexResultDTO.getPartyDevAbility())); - yearAverageIndexResultDTO.setGovernAbility(getRound(yearAverageIndexResultDTO.getGovernAbility())); - yearAverageIndexResultDTO.setServiceAbility(getRound(yearAverageIndexResultDTO.getServiceAbility())); yearAverageIndexResultDTO.setYearAverageIndex(getRound(yearAverageIndexResultDTO.getPartyDevAbility() + yearAverageIndexResultDTO.getGovernAbility() + yearAverageIndexResultDTO.getServiceAbility())); return yearAverageIndexResultDTO; } @@ -86,10 +83,6 @@ public class IndexServiceImpl implements IndexService { if (null == pieChartDTO) { return new MonthPieChartResultDTO(); } - // 处理小数四舍五入 - pieChartDTO.setPartyDevAbility(getRound(pieChartDTO.getPartyDevAbility())); - pieChartDTO.setGovernAbility(getRound(pieChartDTO.getGovernAbility())); - pieChartDTO.setServiceAbility(getRound(pieChartDTO.getServiceAbility())); return pieChartDTO; } @@ -154,9 +147,6 @@ public class IndexServiceImpl implements IndexService { } // 处理小数四舍五入 monthBarchartResults.forEach(barchart -> { - barchart.setPartyDevAbility(getRound(barchart.getPartyDevAbility())); - barchart.setGovernAbility(getRound(barchart.getGovernAbility())); - barchart.setServiceAbility(getRound(barchart.getServiceAbility())); barchart.setIndexTotal(getRound(barchart.getPartyDevAbility() + barchart.getGovernAbility() + barchart.getServiceAbility())); //四舍五入,保留小数点后两位 barchart.setServiceAblityWeight(barchart.getServiceAblityWeight().setScale(NumConstant.TWO,BigDecimal.ROUND_HALF_UP)); @@ -443,9 +433,6 @@ public class IndexServiceImpl implements IndexService { // 小数四舍五入 streetList.forEach(indexRank -> { indexRank.setOrgType("street"); - indexRank.setPartyDevAbility(getRound(indexRank.getPartyDevAbility())); - indexRank.setGovernAbility(getRound(indexRank.getGovernAbility())); - indexRank.setServiceAbility(getRound(indexRank.getServiceAbility())); indexRank.setTotalIndex(getRound(indexRank.getPartyDevAbility() + indexRank.getGovernAbility() + indexRank.getServiceAbility())); }); return streetList; @@ -455,9 +442,6 @@ public class IndexServiceImpl implements IndexService { // 小数四舍五入 gridList.forEach(indexRank -> { indexRank.setOrgType("grid"); - indexRank.setPartyDevAbility(getRound(indexRank.getPartyDevAbility())); - indexRank.setGovernAbility(getRound(indexRank.getGovernAbility())); - indexRank.setServiceAbility(getRound(indexRank.getServiceAbility())); indexRank.setTotalIndex(getRound(indexRank.getPartyDevAbility() + indexRank.getGovernAbility() + indexRank.getServiceAbility())); }); return gridList; diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexAgencyScoreDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexAgencyScoreDao.xml index 5662edfaf7..04fcae2efd 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexAgencyScoreDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexAgencyScoreDao.xml @@ -6,7 +6,7 @@ SELECT fact.index_code AS "indexCode", - ROUND(fact.score*fact.WEIGHT, 1) AS "indexTotal", + ROUND(ROUND(fact.score,1)*fact.WEIGHT, 1) AS "indexTotal", ROUND(fact.score,1) AS "indexTotalOriginScore", fact.WEIGHT AS "indexTotalSupWeight", ROUND(self.self_score*fact.WEIGHT, 1) AS "agencyScore", @@ -50,11 +50,11 @@ SELECT fact.month_id AS "monthId", - ROUND(fact.score*fact.WEIGHT, 1) AS "indexTotal", + ROUND(ROUND(fact.score,1)*fact.WEIGHT, 1) AS "indexTotal", fact.index_code AS "indexCode" FROM fact_index_community_score fact @@ -24,13 +24,13 @@ SELECT fact.month_id AS "monthId", - ROUND(fact.score*fact.WEIGHT, 1) AS "indexTotal", + ROUND(ROUND(fact.score,1)*fact.WEIGHT, 1) AS "indexTotal", ROUND(fact.score,1) AS "indexTotalOriginScore", fact.WEIGHT AS "indexTotalSupWeight", - ROUND(self.self_score*fact.WEIGHT, 1) AS "agencyScore", - ROUND(self.sub_score*fact.WEIGHT, 1) AS "subAgencyScore", + ROUND(ROUND(self.self_score,1)*fact.WEIGHT, 1) AS "agencyScore", + ROUND(ROUND(self.sub_score,1)*fact.WEIGHT, 1) AS "subAgencyScore", fact.index_code AS "indexCode", self.SELF_WEIGHT AS "selfWeight", self.SUB_WEIGHT AS "subWeight" diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCommunitySubScoreDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCommunitySubScoreDao.xml index 37290ed60a..11a9f85a9b 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCommunitySubScoreDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCommunitySubScoreDao.xml @@ -8,9 +8,9 @@ fact.index_code AS "key", IF(fact.origin_value='',0,IFNULL(fact.origin_value,0)) AS "value", dict.index_name AS "name", - fact.score AS score, + round(fact.score,1) AS score, round(fact.WEIGHT,2) AS weight, - (fact.SCORE * fact.WEIGHT) AS weightedScore + round(round(fact.SCORE,1) * fact.WEIGHT,1) AS weightedScore FROM fact_index_community_sub_score fact LEFT JOIN index_dict dict ON fact.index_code = dict.index_code diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexGridScoreDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexGridScoreDao.xml index a177451112..c152cbd144 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexGridScoreDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexGridScoreDao.xml @@ -6,7 +6,7 @@ SELECT fact.index_code AS "indexCode", - ROUND(fact.score*fact.WEIGHT, 1) AS "indexTotal", + ROUND(ROUND(fact.score,1)*fact.WEIGHT, 1) AS "indexTotal", ROUND(fact.score,1) AS "indexTotalOriginScore", fact.WEIGHT AS "indexTotalSupWeight", - ROUND(self.self_score*fact.WEIGHT, 1) AS "agencyScore", + ROUND(ROUND(self.self_score,1)*fact.WEIGHT, 1) AS "agencyScore", ROUND(self.self_score, 1) AS selfOriginScore, self.SELF_WEIGHT AS agencyWeight, - ROUND(self.sub_score*fact.WEIGHT, 1) AS "subAgencyScore", + ROUND(ROUND(self.sub_score,1)*fact.WEIGHT, 1) AS "subAgencyScore", ROUND(self.sub_score, 1) AS subOriginScore, self.SUB_WEIGHT AS subAgencyWeight FROM @@ -51,11 +51,11 @@ SELECT - service_ablity * SERVICE_ABLITY_WEIGHT AS serviceAbility, - party_dev_ablity * PARTY_DEV_WEIGHT AS partyDevAbility, - govern_ablity * GOVERN_ABLITY_WEIGHT AS governAbility, + ROUND((ROUND(service_ablity,1) * SERVICE_ABLITY_WEIGHT),1) AS serviceAbility, + ROUND((ROUND(party_dev_ablity,1) * PARTY_DEV_WEIGHT),1) AS partyDevAbility, + ROUND((ROUND(govern_ablity,1) * GOVERN_ABLITY_WEIGHT),1) AS governAbility, ROUND(service_ablity,1) serviceOriginScore, ROUND(party_dev_ablity,1) partyOriginScore, ROUND(govern_ablity,1) governOriginScore, @@ -38,9 +38,9 @@ SELECT score.index_total AS "total", - (score.party_dev_ablity * score.party_dev_weight) AS "party", + (ROUND(score.party_dev_ablity,1) * score.party_dev_weight) AS "party", ROUND(score.party_dev_ablity,1) partyOriginScore, score.party_dev_weight AS "partyDevAbilityWeight", - (score.govern_ablity * score.govern_ablity_weight) AS "govern", + (ROUND(score.govern_ablity,1) * score.govern_ablity_weight) AS "govern", ROUND(score.govern_ablity,1) governOriginScore, score.govern_ablity_weight AS "governAbilityWeight", - (score.service_ablity * score.service_ablity_weight) AS "service", + (ROUND(score.service_ablity,1) * score.service_ablity_weight) AS "service", ROUND(score.service_ablity,1) serviceOriginScore, score.service_ablity_weight AS "serviceAbilityWeight" FROM @@ -360,9 +360,12 @@ SELECT scg.GRID_NAME AS NAME, - sy.govern_ablity * sy.GOVERN_ABLITY_WEIGHT AS governAbility, - sy.party_dev_ablity * sy.PARTY_DEV_WEIGHT AS partyDevAbility, - sy.service_ablity * sy.SERVICE_ABLITY_WEIGHT AS serviceAbility, + ROUND((ROUND(sy.govern_ablity,1) * sy.GOVERN_ABLITY_WEIGHT),1) AS governAbility, + ROUND((ROUND(sy.party_dev_ablity,1) * sy.PARTY_DEV_WEIGHT),1) AS partyDevAbility, + ROUND((ROUND(sy.service_ablity,1) * sy.SERVICE_ABLITY_WEIGHT),1) AS serviceAbility, sy.ORG_ID as orgId, scg.area_code as areaCode FROM screen_customer_grid scg @@ -406,9 +409,9 @@ resultType="com.epmet.evaluationindex.screen.dto.result.AnNingSubAgencyIndexRankResultDTO"> SELECT score.org_name AS `NAME`, - score.service_ablity * score.SERVICE_ABLITY_WEIGHT AS serviceAbility, - score.party_dev_ablity * score.PARTY_DEV_WEIGHT AS partyDevAbility, - score.govern_ablity * score.GOVERN_ABLITY_WEIGHT AS governAbility, + ROUND(ROUND(score.service_ablity,1)*score.SERVICE_ABLITY_WEIGHT, 1)AS serviceAbility, + ROUND(ROUND(score.party_dev_ablity,1) * score.PARTY_DEV_WEIGHT, 1) AS partyDevAbility, + ROUND(ROUND(score.govern_ablity,1) * score.GOVERN_ABLITY_WEIGHT, 1) AS governAbility, score.PARTY_DEV_WEIGHT AS partyWeight, score.GOVERN_ABLITY_WEIGHT AS governWeight, score.SERVICE_ABLITY_WEIGHT AS serviceWeight, diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataYearlyDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataYearlyDao.xml index 78c494648b..c65c1bd3b0 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataYearlyDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataYearlyDao.xml @@ -6,9 +6,9 @@ - SELECT - m.AGENCY_ID AS orgId, - IFNULL(COUNT(m.ID),0) AS projectTotal - FROM fact_origin_project_main_daily m - WHERE m.DEL_FLAG = 0 - AND m.GRID_ID = '' - AND ( - - m.AGENCY_ID = #{orgId} - - ) - - AND m.DATE_ID #{dateId} - - - AND m.MONTH_ID #{monthId} - - GROUP BY m.AGENCY_ID + + SELECT + #{orgId} AS orgId, + IFNULL(COUNT(m.ID),0) AS projectTotal + FROM fact_origin_project_main_daily m + WHERE m.DEL_FLAG = 0 + AND m.GRID_ID = '' + AND m.PIDS LIKE CONCAT('%',#{orgId},'%') + + AND m.DATE_ID #{dateId} + + + AND m.MONTH_ID #{monthId} + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectCategoryOrgDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectCategoryOrgDailyDao.xml index 72f1a188a1..cdce01974a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectCategoryOrgDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectCategoryOrgDailyDao.xml @@ -47,7 +47,7 @@ @@ -131,6 +132,7 @@ ) AND cd.EPMET_CATEGORY_CODE IS NOT NULL + AND cd.EPMET_CATEGORY_CODE != '' AND od.pid = '0' AND od.date_id = #{dateId} GROUP BY od.CATEGORY_CODE,od.pid @@ -155,7 +157,7 @@ #{customer} ) - AND cd.EPMET_CATEGORY_CODE IS NULL + AND (cd.EPMET_CATEGORY_CODE IS NULL OR cd.EPMET_CATEGORY_CODE = '') AND od.pid = '0' AND od.date_id = #{dateId} GROUP BY od.CATEGORY_CODE,od.pid diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectOrgDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectOrgDailyDao.xml index 0700977462..841526476b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectOrgDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectOrgDailyDao.xml @@ -138,7 +138,7 @@ FROM screen_project_grid_daily g LEFT JOIN screen_customer_grid cg ON cg.GRID_ID = g.GRID_ID WHERE g.DEL_FLAG = 0 - AND cg.PARENT_AGENCY_ID = #{a.orgId} + AND cg.ALL_PARENT_IDS LIKE CONCAT('%',#{a.orgId},'%') AND g.DATE_ID #{dateId} diff --git a/epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/controller/WxController.java b/epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/controller/WxController.java new file mode 100644 index 0000000000..71fc73ef60 --- /dev/null +++ b/epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/controller/WxController.java @@ -0,0 +1,125 @@ + +package com.epmet.controller; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.Arrays; + + +/** + * desc:微信配置测试 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-08 + */ +@RestController +@RequestMapping("wechat") +public class WxController { + private static Logger log = LoggerFactory.getLogger(WxController.class); + + + @RequestMapping("check") + public void doGet(HttpServletRequest request, HttpServletResponse response) { + log.debug("weixin get..."); + // 微信加密签名,signature结合了开发者填写的token参数和请求中的timestamp参数、nonce参数。 + String signature = request.getParameter("signature"); + // 时间戳 + String timestamp = request.getParameter("timestamp"); + // 随机数 + String nonce = request.getParameter("nonce"); + // 随机字符串 + String echostr = request.getParameter("echostr"); + + // 通过检验signature对请求进行校验,若校验成功则原样返回echostr,表示接入成功,否则接入失败 + PrintWriter out = null; + try { + out = response.getWriter(); + if (WxController.checkSignature(signature, timestamp, nonce)) { + log.debug("weixin get success...."); + out.print(echostr); + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (out != null) + out.close(); + } + } + + /** + * 与接口配置信息中的Token要一致 + */ + private static String token = "o2opri3hschiwit"; + + /** + * 验证签名 + * + * @param signature + * @param timestamp + * @param nonce + * @return + */ + public static boolean checkSignature(String signature, String timestamp, String nonce) { + String[] arr = new String[]{token, timestamp, nonce}; + // 将token、timestamp、nonce三个参数进行字典序排序 + Arrays.sort(arr); + StringBuilder content = new StringBuilder(); + for (int i = 0; i < arr.length; i++) { + content.append(arr[i]); + } + MessageDigest md = null; + String tmpStr = null; + + try { + md = MessageDigest.getInstance("SHA-1"); + // 将三个参数字符串拼接成一个字符串进行sha1加密 + byte[] digest = md.digest(content.toString().getBytes()); + tmpStr = byteToStr(digest); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } + + content = null; + // 将sha1加密后的字符串可与signature对比,标识该请求来源于微信 + return tmpStr != null ? tmpStr.equals(signature.toUpperCase()) : false; + } + + /** + * 将字节数组转换为十六进制字符串 + * + * @param byteArray + * @return + */ + private static String byteToStr(byte[] byteArray) { + String strDigest = ""; + for (int i = 0; i < byteArray.length; i++) { + strDigest += byteToHexStr(byteArray[i]); + } + return strDigest; + } + + /** + * 将字节转换为十六进制字符串 + * + * @param mByte + * @return + */ + private static String byteToHexStr(byte mByte) { + char[] Digit = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; + char[] tempArr = new char[2]; + tempArr[0] = Digit[(mByte >>> 4) & 0X0F]; + tempArr[1] = Digit[mByte & 0X0F]; + + String s = new String(tempArr); + return s; + } +} diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/config/ScheduleConfig.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/config/ScheduleConfig.java index 199da6b24d..a20624fa18 100644 --- a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/config/ScheduleConfig.java +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/config/ScheduleConfig.java @@ -46,6 +46,7 @@ public class ScheduleConfig { prop.put("org.quartz.jobStore.misfireThreshold", "12000"); prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_"); prop.put("org.quartz.jobStore.selectWithLockSQL", "SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?"); + prop.put("org.quartz.jobStore.acquireTriggersWithinLock", "true"); //PostgreSQL数据库,需要打开此注释 //prop.put("org.quartz.jobStore.driverDelegateClass", "org.quartz.impl.jdbcjobstore.PostgreSQLDelegate"); diff --git a/epmet-module/epmet-message/epmet-message-server/src/main/resources/db/migration/V0.3.17__alter_info_table_ucase.sql b/epmet-module/epmet-message/epmet-message-server/src/main/resources/db/migration/V0.3.17__alter_info_table_ucase.sql new file mode 100644 index 0000000000..aa545faaac --- /dev/null +++ b/epmet-module/epmet-message/epmet-message-server/src/main/resources/db/migration/V0.3.17__alter_info_table_ucase.sql @@ -0,0 +1,10 @@ +alter table info_profile change column publish_staff_id PUBLISH_STAFF_ID varchar(64) not null comment '发布人id'; +alter table info_profile change column content CONTENT varchar(512) not null comment '内容概要,取前100字'; +alter table info_profile change column first_att_id FIRST_ATT_ID varchar(64) comment '默认附件表的第一个条用于展示'; +alter table info_profile change column total_receiver TOTAL_RECEIVER int(11) not null comment '应读人数'; +alter table info_profile change column read_total READ_TOTAL int(11) not null default '0' comment '已读人数,插入是为0'; + +alter table info change column publish_staff_id PUBLISH_STAFF_ID varchar(64)not null comment '发布人id'; +alter table info change column content CONTENT varchar(1024) not null comment '内容,这里存储全部的内容。'; + +alter table info_group_receivers change column info_receiver_group_id INFO_RECEIVER_GROUP_ID varchar(64) not null comment '群组id'; \ No newline at end of file diff --git a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/AllPartyFormDTO.java b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/AllPartyFormDTO.java new file mode 100644 index 0000000000..ebfea4f918 --- /dev/null +++ b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/AllPartyFormDTO.java @@ -0,0 +1,46 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.constant.NumConstant; +import lombok.Data; + +import javax.validation.constraints.Min; +import java.io.Serializable; +import java.util.List; + +/** + * @Author zxc + * @DateTime 2021/9/6 3:13 下午 + * @DESC + */ +@Data +public class AllPartyFormDTO implements Serializable { + + private static final long serialVersionUID = -600409785611581009L; + + + /** + * 页码 + **/ + private Integer pageNo = NumConstant.ONE; + + /** + * 每页数据条数 + **/ + private Integer pageSize = NumConstant.TEN; + + /** + * 本月 monthly 总排行 all; + * */ + private String type; + + /** + * 认证成功的党员 的用户ID + * */ + private List userIds; + + /** + * 客户ID + */ + private String customerId; + +} diff --git a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/GroupPointFormDTO.java b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/GroupPointFormDTO.java index b727bb5d1b..d1124fe9b8 100644 --- a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/GroupPointFormDTO.java +++ b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/form/GroupPointFormDTO.java @@ -1,6 +1,7 @@ package com.epmet.dto.form; import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import com.sun.webkit.LoadListenerClient; import lombok.Data; import javax.validation.constraints.NotBlank; @@ -17,8 +18,18 @@ public class GroupPointFormDTO implements Serializable { public interface GroupPoint extends CustomerClientShowGroup {} public interface GridRank extends CustomerClientShowGroup {} + public interface GridScopeRank extends CustomerClientShowGroup {} + public interface CustomerScopeRank extends CustomerClientShowGroup {} @NotBlank(message = "小组Id不能为空", groups = {GroupPoint.class, GridRank.class}) private String groupId; - @NotBlank(message = "网格Id不能为空", groups = {GridRank.class}) + @NotBlank(message = "网格Id不能为空", groups = {GridRank.class, GridScopeRank.class}) private String gridId; + @NotBlank(message = "客户Id不能为空", groups = {CustomerScopeRank.class}) + private String customerId; + + /** 页码 */ + private Integer pageNo = 1; + + /** 单页条数 */ + private Integer pageSize = 10; } diff --git a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/AllPartyResultDTO.java b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/AllPartyResultDTO.java new file mode 100644 index 0000000000..a8aabab703 --- /dev/null +++ b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/AllPartyResultDTO.java @@ -0,0 +1,49 @@ +package com.epmet.dto.result; + +import com.epmet.commons.tools.constant.NumConstant; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2021/9/6 3:12 下午 + * @DESC + */ +@Data +public class AllPartyResultDTO implements Serializable { + + private static final long serialVersionUID = -5889648842876122793L; + + /** + * 排序 + **/ + private Integer ranking; + + /** + * 积分 + **/ + private Integer point; + + /** + * 头像 + **/ + private String userHeadPhoto; + + /** + * 名称 + **/ + private String realName; + + /** + * 用户id + **/ + private String userId; + + public AllPartyResultDTO() { + this.point = NumConstant.ZERO; + this.userHeadPhoto = ""; + this.realName = ""; + this.userId = ""; + } +} diff --git a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/GroupPointRankingResultDTO.java b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/GroupPointRankingResultDTO.java index 275a5917ba..b99d4313ac 100644 --- a/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/GroupPointRankingResultDTO.java +++ b/epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/dto/result/GroupPointRankingResultDTO.java @@ -35,4 +35,16 @@ public class GroupPointRankingResultDTO implements Serializable { * 小组ID */ private String groupId; + + /** 头像 */ + private String groupHeadPhoto; + + /** 类型 branch 支部小组;o */ + private String groupType; + + /** 所属网格id */ + private String gridId; + + /** 所属网格名称 */ + private String gridNamePath; } diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/GroupPointController.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/GroupPointController.java index 9fd48f00a1..1ff898d97d 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/GroupPointController.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/GroupPointController.java @@ -1,6 +1,7 @@ package com.epmet.controller; import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; @@ -10,16 +11,20 @@ import com.epmet.dto.result.GroupPointRankingResultDTO; import com.epmet.dto.result.GroupPointRuleResultDTO; import com.epmet.dto.result.PointRankingResultDTO; import com.epmet.resi.group.dto.group.result.GroupPointDetailResultDTO; +import com.epmet.resi.group.enums.SearchScopeTypeEnum; import com.epmet.service.BizPointTotalDetailService; import com.epmet.service.BizPointUserTotalDetailService; import com.epmet.service.PointRuleService; import com.epmet.utils.ModuleConstant; +import com.github.pagehelper.PageInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import javax.validation.constraints.NotBlank; +import java.lang.management.MemoryManagerMXBean; import java.util.List; /** @@ -113,4 +118,42 @@ public class GroupPointController { return new Result().ok(result); } + /** + * @description 【小组排名】- 网格范围内 + * + * @param formDTO + * @return + * @author wxz + * @date 2021.09.07 13:35:45 + */ + @PostMapping("grouppointranking/gridscope") + public Result> listGroupPointRandingInGridScope(@RequestBody GroupPointFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, GroupPointFormDTO.GridScopeRank.class); + String gridId = formDTO.getGridId(); + Integer pageNo = formDTO.getPageNo(); + Integer pageSize = formDTO.getPageSize(); + + PageData page = bizPointTotalDetailService.listGroupPointRandingInGridScope(SearchScopeTypeEnum.GRID, gridId,pageNo, pageSize); + return new Result>().ok(page); + } + + /** + * @description 【小组排名】- 客户范围内 + * + * @param formDTO + * @return + * @author wxz + * @date 2021.09.08 09:18:37 + */ + @PostMapping("grouppointranking/customerscope") + public Result> listGroupPointRandingInCustomerScope(@RequestBody GroupPointFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, GroupPointFormDTO.CustomerScopeRank.class); + String customerId = formDTO.getCustomerId(); + Integer pageNo = formDTO.getPageNo(); + Integer pageSize = formDTO.getPageSize(); + + PageData page = bizPointTotalDetailService.listGroupPointRandingInGridScope(SearchScopeTypeEnum.CUSTOMER, customerId, pageNo, pageSize); + return new Result>().ok(page); + } + } diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/ResiPointController.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/ResiPointController.java index b52a602ede..9f5ee8acf8 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/ResiPointController.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/ResiPointController.java @@ -159,6 +159,18 @@ public class ResiPointController { return new Result>().ok(resultDTOS); } + /** + * @Description 全部党员积分排行 + * @Param formDTO + * @author zxc + * @date 2021/9/6 3:30 下午 + */ + @PostMapping("allparty") + public Result> allParty(@RequestBody AllPartyFormDTO formDTO,@LoginUser TokenDto tokenDto){ + formDTO.setCustomerId(tokenDto.getCustomerId()); + return new Result>().ok(userPointStatisticalDailyService.allParty(formDTO)); + } + /** * @return com.epmet.commons.tools.utils.Result> * @param tokenDto diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/UserPointStatisticalDailyDao.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/UserPointStatisticalDailyDao.java index 63a3e68c1c..2ae8bb24f5 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/UserPointStatisticalDailyDao.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/dao/UserPointStatisticalDailyDao.java @@ -19,6 +19,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.form.ResiAroundPartyPointRankFormDTO; +import com.epmet.dto.result.AllPartyResultDTO; import com.epmet.dto.result.ResiAroundPartyPointRankResultDTO; import com.epmet.dto.result.ResiPointRankResultDTO; import com.epmet.entity.UserPointStatisticalDailyEntity; @@ -73,6 +74,7 @@ public interface UserPointStatisticalDailyDao extends BaseDao selectListGridPartyRankByUsablePoint(ResiAroundPartyPointRankFormDTO formDTO); + List selectListGridPartyNewRankByUsablePoint(ResiAroundPartyPointRankFormDTO formDTO); /** * 身边党员-积分排行 :按网格统计,对本月党员增加的积分 进行排序 @@ -82,4 +84,5 @@ public interface UserPointStatisticalDailyDao extends BaseDao selectListGridPartyRankByMonth(ResiAroundPartyPointRankFormDTO formDTO); + List selectListGridPartyNewRankByMonth(ResiAroundPartyPointRankFormDTO formDTO); } diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/BizPointTotalDetailService.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/BizPointTotalDetailService.java index 8a81ff5ffb..0b64de14bc 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/BizPointTotalDetailService.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/BizPointTotalDetailService.java @@ -24,6 +24,7 @@ import com.epmet.dto.form.GroupPointFormDTO; import com.epmet.resi.group.dto.group.result.GroupPointDetailResultDTO; import com.epmet.dto.result.GroupPointRankingResultDTO; import com.epmet.entity.BizPointTotalDetailEntity; +import com.epmet.resi.group.enums.SearchScopeTypeEnum; import java.util.List; import java.util.Map; @@ -135,4 +136,17 @@ public interface BizPointTotalDetailService extends BaseService listGroupPointRandingInGridScope(SearchScopeTypeEnum searchScopeType, String searchScopeId, Integer pageNo, Integer pageSize); } \ No newline at end of file diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/UserPointStatisticalDailyService.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/UserPointStatisticalDailyService.java index 6630a87891..1a82b5ca14 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/UserPointStatisticalDailyService.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/UserPointStatisticalDailyService.java @@ -20,8 +20,10 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.dto.UserPointStatisticalDailyDTO; +import com.epmet.dto.form.AllPartyFormDTO; import com.epmet.dto.form.ResiAroundPartyPointRankFormDTO; import com.epmet.dto.form.ResiPointRankFormDTO; +import com.epmet.dto.result.AllPartyResultDTO; import com.epmet.dto.result.ResiAroundPartyPointRankResultDTO; import com.epmet.dto.result.ResiPointRankListResultDTO; import com.epmet.entity.UserPointStatisticalDailyEntity; @@ -125,4 +127,12 @@ public interface UserPointStatisticalDailyService extends BaseService listAroundPartyPointRank(ResiAroundPartyPointRankFormDTO formDTO); + + /** + * @Description 全部党员积分排行 + * @Param formDTO + * @author zxc + * @date 2021/9/6 3:30 下午 + */ + List allParty(AllPartyFormDTO formDTO); } diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/BizPointTotalDetailServiceImpl.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/BizPointTotalDetailServiceImpl.java index c1a7dbe14b..29723b68a2 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/BizPointTotalDetailServiceImpl.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/BizPointTotalDetailServiceImpl.java @@ -17,31 +17,48 @@ package com.epmet.service.impl; +import cn.hutool.core.bean.BeanUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.redis.RedisKeys; +import com.epmet.commons.tools.redis.common.bean.GridInfoCache; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dao.BizPointTotalDetailDao; import com.epmet.dto.BizPointTotalDetailDTO; +import com.epmet.dto.CustomerGridDTO; +import com.epmet.dto.form.CustomerGridFormDTO; import com.epmet.dto.form.GroupPointFormDTO; +import com.epmet.feign.GovOrgOpenFeignClient; +import com.epmet.resi.group.dto.group.form.GroupFormDTO; import com.epmet.resi.group.dto.group.form.GroupPointDetailFormDTO; +import com.epmet.resi.group.dto.group.result.GroupDetailResultDTO; import com.epmet.resi.group.dto.group.result.GroupPointDetailResultDTO; import com.epmet.dto.result.GroupPointRankingResultDTO; import com.epmet.entity.BizPointTotalDetailEntity; import com.epmet.resi.group.dto.group.ResiGroupDTO; +import com.epmet.resi.group.enums.SearchScopeTypeEnum; import com.epmet.resi.group.feign.ResiGroupOpenFeignClient; import com.epmet.service.BizPointTotalDetailService; import com.epmet.service.BizPointUserTotalDetailService; import com.epmet.service.UserPointActionLogService; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.HashOperations; +import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -57,7 +74,7 @@ import java.util.stream.Collectors; * @since v1.0.0 2021-04-20 */ @Service -public class BizPointTotalDetailServiceImpl extends BaseServiceImpl implements BizPointTotalDetailService { +public class BizPointTotalDetailServiceImpl extends BaseServiceImpl implements BizPointTotalDetailService, ResultDataResolver { @Autowired private ResiGroupOpenFeignClient resiGroupOpenFeignClient; @@ -65,6 +82,10 @@ public class BizPointTotalDetailServiceImpl extends BaseServiceImpl redisTemplate; + @Autowired + private GovOrgOpenFeignClient govOrgOpenFeignClient; @Override public PageData page(Map params) { @@ -239,4 +260,166 @@ public class BizPointTotalDetailServiceImpl extends BaseServiceImpl listGroupPointRandingInGridScope(SearchScopeTypeEnum searchScopeType, String searchScopeId, Integer pageNo, Integer pageSize) { + + // 1.查询有积分的小组得分排名 + PageInfo entityPageInfo = PageHelper.startPage(pageNo, pageSize).doSelectPageInfo(() -> { + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + if (SearchScopeTypeEnum.CUSTOMER == searchScopeType) { + query.eq(BizPointTotalDetailEntity::getCustomerId, searchScopeId); + } else if (SearchScopeTypeEnum.GRID == searchScopeType) { + query.eq(BizPointTotalDetailEntity::getGridId, searchScopeId); + } + query.eq(BizPointTotalDetailEntity::getBizType, "group"); + query.orderByDesc(BizPointTotalDetailEntity::getTotalPoint); + baseDao.selectList(query); + }); + + List groupList = entityPageInfo.getList(); + + List groupIds = groupList.stream().map(g -> g.getObjectId()).collect(Collectors.toList()); + + // 2.将列表填充基本信息并且转换为dto + List rankingInfoDTOs = convertGroupRankingInfoEntity2DTOs(groupIds, groupList); + + Page page = new Page(pageNo, pageSize); + + // 3.如果不满一页,则填充分数为0的 + if (pageSize > groupIds.size()) { + // 查出网格下已有积分的小组id + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + if (SearchScopeTypeEnum.CUSTOMER == searchScopeType) { + query.eq(BizPointTotalDetailEntity::getCustomerId, searchScopeId); + } else if (SearchScopeTypeEnum.GRID == searchScopeType) { + query.eq(BizPointTotalDetailEntity::getGridId, searchScopeId); + } + query.eq(BizPointTotalDetailEntity::getBizType, "group"); + query.select(BizPointTotalDetailEntity::getObjectId); + List existingGroupIds = baseDao.selectObjs(query).stream().map(obj -> obj.toString()).collect(Collectors.toList()); + + int startRow = page.getStartRow() - existingGroupIds.size(); + // 不足0的从0开始 + startRow = Math.max(startRow, 0); + List gap; + gap = fillGroupPageGap(existingGroupIds, searchScopeType, searchScopeId, startRow, pageSize - groupList.size()); + rankingInfoDTOs.addAll(gap); + } + + // 4.排名填充 + Integer ranking = page.getStartRow() + 1; + for (GroupPointRankingResultDTO g : rankingInfoDTOs) { + GridInfoCache gridInfo = getGridInfo(g.getGridId()); + g.setRanking(String.valueOf(ranking)); + g.setGridId(g.getGridId()); + g.setGridNamePath(gridInfo.getGridNamePath()); + ranking ++; + } + PageData pageData = new PageData<>(rankingInfoDTOs, entityPageInfo.getTotal()); + return pageData; + } + + /** + * @description 获取分页缺口group ranking信息 + * + * @param startRow + * @param rowCount + * @return + * @author wxz + * @date 2021.09.07 16:30:28 + */ + private List fillGroupPageGap(List existingGroupIds, SearchScopeTypeEnum searchScopeType, String searchScopeObjectId, Integer startRow, Integer rowCount) { + GroupFormDTO form = new GroupFormDTO(); + form.setExcludeGroupIds(existingGroupIds); + form.setOrder(GroupFormDTO.OrderTypeEnum.DESC); + form.setSort(GroupFormDTO.SortTypeEnum.CREATE_TIME); + form.setStartRow(startRow); + form.setRowCount(rowCount); + form.setSearchScopeType(searchScopeType); + form.setSearchScopeObjectId(searchScopeObjectId); + + Result> result = resiGroupOpenFeignClient.listGroupDetailsExcludeGroupIds(form); + List groups = getResultDataOrThrowsException(result, ServiceConstant.RESI_GROUP_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【小组排名】查询积分为0的小组列表失败"); + if (CollectionUtils.isEmpty(groups)) { + return new ArrayList<>(); + } + return groups.stream().map(g -> { + GroupPointRankingResultDTO dto = new GroupPointRankingResultDTO(); + dto.setGroupType(g.getGroupType()); + dto.setPoint("0"); + dto.setGroupHeadPhoto(g.getGroupHeadPhoto()); + dto.setGroupName(g.getGroupName()); + dto.setGroupId(g.getGroupId()); + dto.setGridId(g.getGridId()); + return dto; + }).collect(Collectors.toList()); + } + + /** + * @description 将小组排名Entity转化为dto + * + * @param groupList + * @return + * @author wxz + * @date 2021.09.07 15:52:17 + */ + private List convertGroupRankingInfoEntity2DTOs(List groupIds, List groupList) { + if (CollectionUtils.isEmpty(groupIds)) { + return new ArrayList<>(); + } + + // 查询这些小组的基本信息 + Result> listResult = resiGroupOpenFeignClient.listGroupDetailsByGroupIds(groupIds); + List groupInfos = getResultDataOrThrowsException(listResult, ServiceConstant.RESI_GROUP_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), "【小组排行】批量查询小组信息出错"); + + // 将小组基本信息转化为map + HashMap groupMap = new HashMap<>(); + groupInfos.stream().forEach(g -> groupMap.put(g.getGroupId(), g)); + + // 将小组信息填充到排名列表中 + List rankingDTOs = groupList.stream().map(g -> { + GroupDetailResultDTO groupInfo = groupMap.get(g.getObjectId()); + GroupPointRankingResultDTO dto = new GroupPointRankingResultDTO(); + dto.setGroupId(g.getObjectId()); + dto.setGroupName(groupInfo.getGroupName()); + dto.setGroupType(groupInfo.getGroupType()); + dto.setPoint(g.getTotalPoint().toString()); + dto.setGroupHeadPhoto(groupInfo.getGroupHeadPhoto()); + dto.setGridId(g.getGridId()); + return dto; + }).collect(Collectors.toList()); + return rankingDTOs; + } + + /** + * @description 查询网格信息 + * + * @param gridId + * @return + * @author wxz + * @date 2021.09.08 11:17:17 + */ + public GridInfoCache getGridInfo(String gridId) { + HashOperations ope = redisTemplate.opsForHash(); + Map entries = ope.entries(RedisKeys.getGridInfoKey(gridId)); + if (entries.size() != 0) { + return BeanUtil.mapToBean(entries, GridInfoCache.class, true); + } + + CustomerGridFormDTO form = new CustomerGridFormDTO(); + form.setGridId(gridId); + Result result = govOrgOpenFeignClient.getCustomerGridByGridId(form); + if (result == null || !result.success() || result.getData() == null) { + return null; + } + + GridInfoCache cache = new GridInfoCache(); + cache.setCustomerId(result.getData().getCustomerId()); + cache.setGridId(result.getData().getId()); + cache.setGridNamePath(result.getData().getGridName()); + cache.setPid(result.getData().getPid()); + cache.setPids(result.getData().getPids()); + ope.putAll(RedisKeys.getGridInfoKey(gridId), BeanUtil.beanToMap(cache)); + return cache; + } } \ No newline at end of file diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/UserPointStatisticalDailyServiceImpl.java b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/UserPointStatisticalDailyServiceImpl.java index 10ed45500f..c75edbae56 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/UserPointStatisticalDailyServiceImpl.java +++ b/epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/UserPointStatisticalDailyServiceImpl.java @@ -23,11 +23,13 @@ import com.epmet.common.enu.AroundPartyConstant; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dao.UserPointStatisticalDailyDao; import com.epmet.dto.UserPointStatisticalDailyDTO; +import com.epmet.dto.form.AllPartyFormDTO; import com.epmet.dto.form.ResiAroundPartyPointRankFormDTO; import com.epmet.dto.form.ResiPointRankFormDTO; import com.epmet.dto.result.*; @@ -45,6 +47,7 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; import java.util.*; import java.util.stream.Collectors; @@ -292,6 +295,37 @@ public class UserPointStatisticalDailyServiceImpl extends BaseServiceImpl allParty(AllPartyFormDTO formDTO) { + formDTO.setPageNo((formDTO.getPageNo() - NumConstant.ONE) * formDTO.getPageSize()); + Result> partyMemberInfosResult = resiPartyMemberOpenFeignClient.getPartyMemberInfoByCustomerId(formDTO.getCustomerId()); + if (!partyMemberInfosResult.success()){ + throw new RenException("查询客户下的党员失败......"); + } + if (CollectionUtils.isEmpty(partyMemberInfosResult.getData())){ + return new ArrayList<>(); + } + List partyMemberInfos = partyMemberInfosResult.getData(); + List userIds = partyMemberInfos.stream().map(m -> m.getUserId()).collect(Collectors.toList()); + ResiAroundPartyPointRankFormDTO selDto = ConvertUtils.sourceToTarget(formDTO, ResiAroundPartyPointRankFormDTO.class); + selDto.setUserIds(userIds); + List resultDTOS = new ArrayList<>(); + if (AroundPartyConstant.ALL.equals(formDTO.getType())){ + resultDTOS = baseDao.selectListGridPartyNewRankByUsablePoint(selDto); + }else if (AroundPartyConstant.MONTHLY.equals(formDTO.getType())){ + resultDTOS = baseDao.selectListGridPartyNewRankByMonth(selDto); + } + List partyBaseInfo = getPartyBaseInfo(ConvertUtils.sourceToTarget(resultDTOS, ResiAroundPartyPointRankResultDTO.class)); + List result = ConvertUtils.sourceToTarget(partyBaseInfo, AllPartyResultDTO.class); + return result; + } + /** * 获取认证通过的党员的 用户id * diff --git a/epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/UserPointStatisticalDailyDao.xml b/epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/UserPointStatisticalDailyDao.xml index d49ca80396..49179803c7 100644 --- a/epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/UserPointStatisticalDailyDao.xml +++ b/epmet-module/epmet-point/epmet-point-server/src/main/resources/mapper/UserPointStatisticalDailyDao.xml @@ -184,4 +184,47 @@ ORDER BY P.point DESC LIMIT #{pageNo}, #{pageSize} + + + + diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/constant/ThirdPlatformActions.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/constant/ThirdPlatformActions.java index dc17deca39..bd0875b2e2 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/constant/ThirdPlatformActions.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/constant/ThirdPlatformActions.java @@ -19,4 +19,10 @@ public interface ThirdPlatformActions { */ String UPLOAD_FILE = "UPLOAD_FILE"; + /** 推送 微信component access token */ + String PUSH_COMPONENT_ACCESS_TOKEN = "PUSH_COMPONENT_ACCESS_TOKEN"; + + /** 推送 微信 authorizer access token */ + String PUSH_AUTHORIZER_ACCESS_TOKEN = "PUSH_AUTHORIZER_ACCESS_TOKEN"; + } diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/ThirdPlatformActionsResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/ThirdPlatformActionsResultDTO.java new file mode 100644 index 0000000000..a1a81ee406 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/ThirdPlatformActionsResultDTO.java @@ -0,0 +1,19 @@ +package com.epmet.dto.result; + +import lombok.Data; + +/** + * @Description 第三方平台及其支持的action result + * @author wxz + * @date 2021.08.30 17:06:42 +*/ +@Data +public class ThirdPlatformActionsResultDTO { + + private String platformId; + private String platformKey; + private String platformName; + private String actionKey; + private String apiUrl; + +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/privateepmet/GetAccessTokenResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/privateepmet/GetAccessTokenResultDTO.java new file mode 100644 index 0000000000..e2cc8ab4c3 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/privateepmet/GetAccessTokenResultDTO.java @@ -0,0 +1,18 @@ +package com.epmet.dto.result.privateepmet; + +import lombok.Data; + +/** + * @Description 获取accesstoken结果 + * @author wxz + * @date 2021.08.30 17:40:25 +*/ +@Data +public class GetAccessTokenResultDTO { + + // token + private String accessToken; + // 有效时长 + private Long expireTime; + +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/ThirdOpenFeignClient.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/ThirdOpenFeignClient.java index cb194775ff..d4efa88cc9 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/ThirdOpenFeignClient.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/ThirdOpenFeignClient.java @@ -2,6 +2,8 @@ package com.epmet.feign; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.AuthorizerAccessTokenFormDTO; +import com.epmet.dto.form.ComponentAccessTokenFormDTO; import com.epmet.dto.form.SaveOrUpdateCustSelPlatformFormDTO; import com.epmet.dto.form.ThirdPlatformFormDTO; import com.epmet.dto.result.ThirdplatformResultDTO; @@ -36,4 +38,23 @@ public interface ThirdOpenFeignClient { @PostMapping("/third/thirdplatform/customer/list-available-platforms-by-action") Result> listAvailablePlatformsByCustomerAndAction(@RequestBody ThirdPlatformFormDTO input); + /** + * @Description 私有化平台接收component-access推送 + * @param input + * @return com.epmet.commons.tools.utils.Result + * @author wxz + * @date 2021.08.30 16:40:17 + */ + @PostMapping("/third/private-epmet/push-component-access-token") + Result pushComponentAccessToken(@RequestBody ComponentAccessTokenFormDTO input); + + /** + * @Description 接收推送AuthorizerTokens + * @param input + * @return com.epmet.commons.tools.utils.Result + * @author wxz + * @date 2021.08.30 16:36:02 + */ + @PostMapping("/third/private-epmet/push-authorizer-tokens") + Result pushAuthorizerTokens(@RequestBody AuthorizerAccessTokenFormDTO input); } diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/ThirdOpenFeignClientFallback.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/ThirdOpenFeignClientFallback.java index 76098de169..b6929b9883 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/ThirdOpenFeignClientFallback.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/ThirdOpenFeignClientFallback.java @@ -3,6 +3,8 @@ package com.epmet.feign.fallback; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.AuthorizerAccessTokenFormDTO; +import com.epmet.dto.form.ComponentAccessTokenFormDTO; import com.epmet.dto.form.SaveOrUpdateCustSelPlatformFormDTO; import com.epmet.dto.form.ThirdPlatformFormDTO; import com.epmet.dto.result.ThirdplatformResultDTO; @@ -22,4 +24,14 @@ public class ThirdOpenFeignClientFallback implements ThirdOpenFeignClient { public Result> listAvailablePlatformsByCustomerAndAction(ThirdPlatformFormDTO input) { return ModuleUtils.feignConError(ServiceConstant.EPMET_THIRD_SERVER, "listAvailablePlatformsByCustomerAndAction", input); } + + @Override + public Result pushComponentAccessToken(ComponentAccessTokenFormDTO input) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_THIRD_SERVER, "pushComponentAccessToken", input); + } + + @Override + public Result pushAuthorizerTokens(AuthorizerAccessTokenFormDTO input) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_THIRD_SERVER, "pushAuthorizerTokens", input); + } } diff --git a/epmet-module/epmet-third/epmet-third-server/pom.xml b/epmet-module/epmet-third/epmet-third-server/pom.xml index bd811cf03e..a945beb046 100644 --- a/epmet-module/epmet-third/epmet-third-server/pom.xml +++ b/epmet-module/epmet-third/epmet-third-server/pom.xml @@ -21,6 +21,11 @@ + + com.epmet + epmet-openapi-sdk + 2.0.0 + com.epmet epmet-third-client diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/ApiService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/ApiService.java index 36117287e1..a43689e321 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/ApiService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/ApiService.java @@ -1,7 +1,8 @@ package com.epmet.apiservice; +import cn.hutool.core.bean.BeanUtil; import com.alibaba.fastjson.JSON; -import com.epmet.apiservice.result.LZGridPlatformBaseResult; +import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.utils.HttpClientManager; @@ -10,19 +11,21 @@ import com.epmet.commons.tools.utils.SpringContextUtils; import com.epmet.dao.ThirdplatformActionDao; import com.epmet.dao.ThirdplatformCustomerRegisterDao; import com.epmet.dao.ThirdplatformDao; -import com.epmet.dto.form.ProjectApplyAssistFormDTO; -import com.epmet.dto.form.TPFDemoFormDTO; -import com.epmet.dto.form.UploadFileFormDTO; +import com.epmet.dto.form.*; import com.epmet.dto.result.ProjectAssistResult; import com.epmet.dto.result.UploadFileResultDTO; import com.epmet.entity.ThirdplatformActionEntity; import com.epmet.entity.ThirdplatformCustomerRegisterEntity; import com.epmet.entity.ThirdplatformEntity; +import com.epmet.redis.ThirdPlatformCache; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.data.redis.core.HashOperations; import org.springframework.data.redis.core.RedisTemplate; import java.io.File; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; @@ -32,7 +35,7 @@ import java.util.concurrent.TimeUnit; * 此抽象类中定义方法的具体返回类型,所有子类都要统一使用,在具体实现中做转换。若是不需要返回,返回null即可。 */ @Slf4j -public abstract class ApiService { +public abstract class ApiService { /** * 重试次数 */ @@ -61,13 +64,13 @@ public abstract class ApiService { * @param headers * @return */ - public String sendGetRequest(String platformId, String action, Map params, Map headers) { + public R sendGetRequest(String platformId, String action, Map params, Map headers) { // 1.获取token String accessToken = getAccessToken(platformId); //2.获取url - ThirdplatformEntity thirdplatform = SpringContextUtils.getBean(ThirdplatformDao.class).selectById(platformId); - ThirdplatformActionEntity actionEntity = SpringContextUtils.getBean(ThirdplatformActionDao.class) - .getByPlatformIdAndActionKey(platformId, action); + ThirdPlatformCache thirdPlatformInfo = getThirdPlatformInfo(platformId); + String actionUrl = getThirdPlatformActionUrl(platformId, action); + if (headers == null) { headers = new HashMap<>(); @@ -76,8 +79,8 @@ public abstract class ApiService { // 填充access token到头当中 headers.put("X-Access-Token", accessToken); log.info("apiService sendGetRequest param:{},headers:{}",params,headers); - Result result = HttpClientManager.getInstance().sendGet(thirdplatform.getBaseUrl().concat(actionEntity.getApiUrl()), - thirdplatform.getBaseUrl().startsWith("https://"), + Result result = HttpClientManager.getInstance().sendGet(thirdPlatformInfo.getBaseUrl().concat(actionUrl), + thirdPlatformInfo.getBaseUrl().startsWith("https://"), params, headers); log.info("apiService sendGetRequest result:{}",JSON.toJSONString(result)); @@ -87,37 +90,51 @@ public abstract class ApiService { if (result.success()) { throw new RenException("请求第三方平台,获取AccessToken失败。"); } - LZGridPlatformBaseResult platformResult = JSON.parseObject(result.getData(), LZGridPlatformBaseResult.class); - judgeResultSuccess(platformResult); - return result.getData(); + return parsePlatformResponseResult(result.getData(), String.class); } + /** + * @Description + accesstoken header名称。如果不需要AccessToken,与getAccessToken()方法共同返回null即可 + * @return java.lang.String + * @author wxz + * @date 2021.08.30 14:06:26 + */ + public abstract String getAccessTokenHeaderName(); + /** * 发送post请求 * @param platformId * @param action * @param jsonString * @param headers - * @return + * @return 平台对应返回值的Result类 */ - public String sendPostRequest(String platformId, String action, String jsonString, Map headers) { + public R sendPostRequest(String platformId, String action, String jsonString, Map headers, Map urlParams) { // 1.获取token String accessToken = getAccessToken(platformId); //2.获取url - ThirdplatformEntity thirdplatform = SpringContextUtils.getBean(ThirdplatformDao.class).selectById(platformId); - ThirdplatformActionEntity actionEntity = SpringContextUtils.getBean(ThirdplatformActionDao.class) - .getByPlatformIdAndActionKey(platformId, action); + ThirdPlatformCache platformFromCache = getThirdPlatformInfo(platformId); + String actionUrl = getThirdPlatformActionUrl(platformId, action); if (headers == null) { headers = new HashMap<>(); } // 填充access token到头当中 - headers.put("X-Access-Token", accessToken); + if (StringUtils.isNotBlank(accessToken)) { + //headers.put("X-Access-Token", accessToken); + String accessTokenHeaderName = getAccessTokenHeaderName(); + if (StringUtils.isBlank(accessTokenHeaderName)) { + throw new RenException("没有指定AccessToken的Header名字"); + } + headers.put(accessTokenHeaderName, accessToken); + } log.info("apiService sendPostRequest param:{},headers:{}",jsonString,headers); - Result result = HttpClientManager.getInstance().sendPost(thirdplatform.getBaseUrl().concat(actionEntity.getApiUrl()), - thirdplatform.getBaseUrl().startsWith("https://"), + String urlParmsStr = this.convertQueryParams2String(urlParams); + Result result = HttpClientManager.getInstance().sendPost(platformFromCache.getBaseUrl().concat(actionUrl).concat(urlParmsStr), + platformFromCache.getBaseUrl().startsWith("https://"), jsonString, headers); log.info("apiService sendPostRequest result:{}",JSON.toJSONString(result)); @@ -128,12 +145,10 @@ public abstract class ApiService { throw new RenException("请求第三方平台,发送Post请求失败。错误信息:" + result.getMsg()); } - LZGridPlatformBaseResult platformResult = JSON.parseObject(result.getData(), LZGridPlatformBaseResult.class); - judgeResultSuccess(platformResult); - return result.getData(); + return parsePlatformResponseResult(result.getData(), String.class); } - public String sendPostRequestToUploadFile(String platformId, String action, File file, String fileName) { + public R sendPostRequestToUploadFile(String platformId, String action, File file, String fileName) { // 1.获取token String accessToken = getAccessToken(platformId); //2.获取url @@ -159,8 +174,6 @@ public abstract class ApiService { throw new RenException("请求第三方平台,发送Post请求失败。错误信息:" + result.getMsg()); } - LZGridPlatformBaseResult platformResult = JSON.parseObject(result.getData(), LZGridPlatformBaseResult.class); - // token过期重试逻辑,先不加 //if ("402".equals(platformResult.getCode())) { // // 如果token过期 @@ -168,8 +181,37 @@ public abstract class ApiService { // getAccessToken(platformId); // return sendPostRequest(platformId, action, jsonString, headers); //} - judgeResultSuccess(platformResult); - return result.getData(); + return parsePlatformResponseResult(result.getData(), String.class); + } + + /** + * @Description 将url参数拼接为字符串 + * @param queryParams + * @return java.lang.String + * @author wxz + * @date 2021.08.31 14:08:17 + */ + protected String convertQueryParams2String(Map queryParams) { + try { + if (queryParams == null || queryParams.size() == 0) { + return ""; + } + StringBuilder sb = new StringBuilder(""); + queryParams.entrySet().forEach(entry -> { + String key = entry.getKey(); + String value = entry.getValue(); + sb.append("&").append(key).append("=").append(value); + }); + String result = sb.toString(); + if (result.startsWith("&")) { + result = result.substring(1); + return "?".concat(result); + } + return ""; + } catch (Exception e) { + log.warn("gateway中将url参数转化为String失败,程序继续执行,错误信息:".concat(ExceptionUtils.getErrorStackTrace(e))); + return ""; + } } /** @@ -202,6 +244,36 @@ public abstract class ApiService { stringRedisTemplate.opsForValue().set(RedisKeys.getThirdPlatformAccessTokenKey(platformId), accessToken, expire, timeUnit); } + /** + * @Description 将第三方平台信息存入缓存 + * @param cache + * @return void + * @author wxz + * @date 2021.08.31 14:55:48 + */ + protected void addPlatformToCache(ThirdPlatformCache cache) { + RedisTemplate stringRedisTemplate = SpringContextUtils.getBean("redisTemplate", RedisTemplate.class); + Map stringObjectMap = BeanUtil.beanToMap(cache); + stringRedisTemplate.opsForHash().putAll(RedisKeys.getThirdPlatformInfoKey(cache.getPlatformId()), stringObjectMap); + } + + /** + * @Description 从缓存中取第三方平台信息 + * @param thirdPlatformKey + * @return com.epmet.redis.ThirdPlatformCache + * @author wxz + * @date 2021.08.31 14:55:28 + */ + protected ThirdPlatformCache getPlatformFromCache(String thirdPlatformKey) { + HashOperations hashOperations = SpringContextUtils.getBean("redisTemplate", RedisTemplate.class).opsForHash(); + Map entries = hashOperations.entries(RedisKeys.getThirdPlatformInfoKey(thirdPlatformKey)); + if (entries.size() == 0) { + return null; + } + ThirdPlatformCache thirdPlatformCache = BeanUtil.mapToBean(entries, ThirdPlatformCache.class, true); + return thirdPlatformCache; + } + /** * @Description 从缓存中取token * @return @@ -210,7 +282,87 @@ public abstract class ApiService { */ protected String getAccessTokenFromCache(String platformId) { RedisTemplate stringRedisTemplate = SpringContextUtils.getBean("redisTemplate", RedisTemplate.class); - return stringRedisTemplate.opsForValue().get(platformId); + return stringRedisTemplate.opsForValue().get(RedisKeys.getThirdPlatformAccessTokenKey(platformId)); + } + + /** + * @Description 从缓存查询第三方平台操作url + * @param platformId + * @param action + * @return java.lang.String + * @author wxz + * @date 2021.08.31 15:18:06 + */ + protected String getThirdPlatformActionUrlFromCache(String platformId, String action) { + HashOperations ops = SpringContextUtils.getBean("redisTemplate", RedisTemplate.class).opsForHash(); + String url = ops.get(RedisKeys.getThirdPlatformActionUrlKey(platformId), action); + return url; + } + + /** + * @Description 将第三方平台操作url添加至缓存 + * @param platformId + * @param map + * @return java.lang.String + * @author wxz + * @date 2021.08.31 15:20:45 + */ + protected void addThirdPlatformActionUrlsToCache(String platformId, Map map) { + String redisKey = RedisKeys.getThirdPlatformActionUrlKey(platformId); + + RedisTemplate redisTemplate = SpringContextUtils.getBean("redisTemplate", RedisTemplate.class); + HashOperations ops = redisTemplate.opsForHash(); + ops.putAll(redisKey, map); + } + + /** + * @Description 从缓存里面读取平台信息,如果缓存中没有,从db读取,放入缓存 + * @param platformId 平台id + * @return com.epmet.redis.ThirdPlatformCache + * @author wxz + * @date 2021.08.31 15:02:19 + */ + protected ThirdPlatformCache getThirdPlatformInfo(String platformId) { + ThirdPlatformCache platform = getPlatformFromCache(platformId); + if (platform == null) { + platform = new ThirdPlatformCache(); + ThirdplatformEntity platformEntity = SpringContextUtils.getBean(ThirdplatformDao.class).selectById(platformId); + platform.setPlatformId(platformEntity.getId()); + platform.setApiService(platformEntity.getApiService()); + platform.setBaseUrl(platformEntity.getBaseUrl()); + platform.setPlatformKey(platformEntity.getPlatformKey()); + platform.setPlatformName(platformEntity.getPlatformName()); + platform.setPlatformSecret(platformEntity.getPlatformSecret()); + addPlatformToCache(platform); + } + return platform; + } + + /** + * @Description 获取第三放平台操作url。优先读取缓存,没有则读取db + * @param platformId + * @param actionKey + * @return java.util.Map + * @author wxz + * @date 2021.08.31 15:21:39 + */ + protected String getThirdPlatformActionUrl(String platformId, String actionKey) { + String url = getThirdPlatformActionUrlFromCache(platformId, actionKey); + if (StringUtils.isBlank(url)) { + List actions = SpringContextUtils.getBean(ThirdplatformActionDao.class) + .listPlatformActions(platformId); + + Map map = new HashMap<>(actions.size()); + // 将action:url映射至map + for (ThirdplatformActionEntity a : actions) { + map.put(a.getActionKey(), a.getApiUrl()); + if (actionKey.equals(a.getActionKey())) { + url = a.getApiUrl(); + } + } + addThirdPlatformActionUrlsToCache(platformId, map); + } + return url; } /** @@ -246,16 +398,38 @@ public abstract class ApiService { } /** - * @Description 判断第三方平台返回结果成功失败。如果失败,则抛出异常 - * @return + * @Description 解析第三方平台返回结果 + * @param resultString + * @param clazz R的泛型对象T的clazz + * @return R 泛型,不同平台的Result DTO类型 * @author wxz - * @date 2021.03.22 10:32 - */ - public abstract void judgeResultSuccess(LZGridPlatformBaseResult result); + * @date 2021.08.31 13:36:11 + */ + public abstract R parsePlatformResponseResult(String resultString, Class clazz); public UploadFileResultDTO uploadFile(UploadFileFormDTO formDTO) { return null; } + /** + * @Description 推送ComponentAccessToken + * @param form + * @return void 保持空实现,让子类去实现 + * @author wxz + * @date 2021.08.30 17:15:01 + */ + public void pushComponentAccessToken(ComponentAccessTokenFormDTO form, String platformId, String platformKey) {} + + /** + * @description 推送小程序token + * + * @param form + * @param platformId + * @param platformKey + * @return + * @author wxz + * @date 2021.08.31 20:26:51 + */ + public void pushAuthorizerAccessToken(AuthorizerAccessTokenFormDTO form, String platformId, String platformKey) {}; } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/DemoApiService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/DemoApiService.java index 63f718a0d5..ed06d5059a 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/DemoApiService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/DemoApiService.java @@ -14,10 +14,15 @@ import org.springframework.stereotype.Component; * demo api service */ @Component(value = "demoApiService") -public class DemoApiService extends ApiService { +public class DemoApiService extends ApiService { Logger logger = LoggerFactory.getLogger(DemoApiService.class); + @Override + public String getAccessTokenHeaderName() { + return null; + } + @Override public String getAccessToken(String platformId) { return null; @@ -29,8 +34,15 @@ public class DemoApiService extends ApiService { return null; } + /** + * @Description 解析平台返回结果 + * @param resultString 平台返回结果string + * @return java.lang.String + * @author wxz + * @date 2021.08.30 22:43:24 + */ @Override - public void judgeResultSuccess(LZGridPlatformBaseResult result) { - + public String parsePlatformResponseResult(String resultString, Class clazz) { + return null; } } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/LuzhouGridPlatformApiService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/LuzhouGridPlatformApiService.java index abbaad2255..dee2cd8137 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/LuzhouGridPlatformApiService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/LuzhouGridPlatformApiService.java @@ -31,7 +31,12 @@ import java.util.concurrent.TimeUnit; */ @Slf4j @Component("luzhouGridPlatformApiService") -public class LuzhouGridPlatformApiService extends ApiService { +public class LuzhouGridPlatformApiService extends ApiService { + + @Override + public String getAccessTokenHeaderName() { + return "X-Access-Token"; + } @Override public String getAccessToken(String platformId) { @@ -58,11 +63,8 @@ public class LuzhouGridPlatformApiService extends ApiService { throw new RenException("请求第三方平台,获取AccessToken失败。"); } - LZGridPlatformBaseResult platformResult = JSON.parseObject(result.getData(), LZGridPlatformBaseResult.class); - judgeResultSuccess(platformResult); - - token = platformResult.getResult(); - addAccessTokenToCache(platformId, token, (long)(3600*1.8*1000), TimeUnit.MILLISECONDS); + LZGridPlatformBaseResult lzGridPlatformBaseResult = parsePlatformResponseResult(result.getData(), String.class); + addAccessTokenToCache(platformId, lzGridPlatformBaseResult.getResult(), (long)(3600*1.8*1000), TimeUnit.MILLISECONDS); } return token; } @@ -83,30 +85,24 @@ public class LuzhouGridPlatformApiService extends ApiService { // 正式调用第三方平台 String argsStr = JSON.toJSONString(formDTO); - String result = sendPostRequest(platformId, ThirdPlatformActions.PROJECT_ASSIST, argsStr, null); + LZGridPlatformBaseResult result = sendPostRequest(platformId, ThirdPlatformActions.PROJECT_ASSIST, argsStr, null, null); // 开发阶段临时写死 //String result = "{\"eventId\":\"test-task-id\"}"; ProjectAssistResult projectAssistResult = new ProjectAssistResult(); - if (!StringUtils.isBlank(result)) { - // 此处要经过一系列业务处理,将第三方平台返回的数据进行解析,等处理最后转换成ProjectAssistResult类型,返回。ProjectAssistResult这个类型是 - // 所有apiService的projectAssist方法返回值的统一类型,是我们的epmet-cloud所需要的数据的实体, - // 所有apiService都要想办法转化成这个类型。 - LZGridPlatformBaseResult lzResult = JSON.parseObject(result, LZGridPlatformBaseResult.class); - - // 此处设置为第三方系统返回的唯一id - projectAssistResult.setTaskId(lzResult.getResult()); - } + // 此处设置为第三方系统返回的唯一id + projectAssistResult.setTaskId(result.getResult()); log.info("projectAssist 泸州网格化平台项目协助发送成功"); return projectAssistResult; } @Override - public void judgeResultSuccess(LZGridPlatformBaseResult result) { - //LZGridPlatformBaseResult; - if (!"200".equalsIgnoreCase(result.getCode())) { - throw new RenException("泸州网格化平台:返回失败结果,错误码:" + result.getCode()); + public LZGridPlatformBaseResult parsePlatformResponseResult(String resultString, Class clazz) { + LZGridPlatformBaseResult baseResult = JSON.parseObject(resultString, LZGridPlatformBaseResult.class); + if (!"200".equalsIgnoreCase(baseResult.getCode())) { + throw new RenException("泸州网格化平台:返回失败结果,错误码:" + baseResult.getCode()); } + return baseResult; } @Override @@ -118,16 +114,9 @@ public class LuzhouGridPlatformApiService extends ApiService { // 正式调用第三方平台 File file = new File(formDTO.getFile().getOriginalFilename()); FileUtils.copyInputStreamToFile(formDTO.getFile().getInputStream(), file); - String result = sendPostRequestToUploadFile(platformId, ThirdPlatformActions.UPLOAD_FILE, file, fileName); - if (!StringUtils.isBlank(result)) { - // 此处要经过一系列业务处理,将第三方平台返回的数据进行解析,等处理最后转换成ProjectAssistResult类型,返回。ProjectAssistResult这个类型是 - // 所有apiService的projectAssist方法返回值的统一类型,是我们的epmet-cloud所需要的数据的实体, - // 所有apiService都要想办法转化成这个类型。 - LZGridPlatformBaseResult lzResult = JSON.parseObject(result, LZGridPlatformBaseResult.class); - - // 此处设置为第三方系统返回的唯一id - resultDTO.setUrl((String) lzResult.getResult()); - } + LZGridPlatformBaseResult baseResult = sendPostRequestToUploadFile(platformId, ThirdPlatformActions.UPLOAD_FILE, file, fileName); + // 此处设置为第三方系统返回的唯一id + resultDTO.setUrl(baseResult.getResult()); System.out.println("泸州网格化平台项目文件上传成功"); } catch (Exception e) { throw new RenException("上传失败"); diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/PingyinPrivateEpmetApiService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/PingyinPrivateEpmetApiService.java new file mode 100644 index 0000000000..da62386442 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/PingyinPrivateEpmetApiService.java @@ -0,0 +1,169 @@ +package com.epmet.apiservice.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.TypeReference; +import com.epmet.apiservice.ApiService; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.feign.ResultDataResolver; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.HttpClientManager; +import com.epmet.commons.tools.utils.Result; +import com.epmet.constant.ThirdPlatformActions; +import com.epmet.dto.form.AuthorizerAccessTokenFormDTO; +import com.epmet.dto.form.ComponentAccessTokenFormDTO; +import com.epmet.dto.result.privateepmet.GetAccessTokenResultDTO; +import com.epmet.openapi.sdk.sign.OpenApiSignUtils; +import com.epmet.redis.ThirdPlatformCache; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.TimeUnit; + +@Component("pingyinPrivateEpmetApiService") +@Slf4j +public class PingyinPrivateEpmetApiService extends ApiService implements ResultDataResolver { + + // 认证方式 + private String authType = "take_token"; + + @Override + public String getAccessTokenHeaderName() { + return "AccessToken"; + } + + @Override + public String getAccessToken(String platformId) { + String accessTokenFromCache = super.getAccessTokenFromCache(platformId); + if (StringUtils.isBlank(accessTokenFromCache)) { + ThirdPlatformCache thirdPlatformInfo = super.getThirdPlatformInfo(platformId); + String apiUrl = getThirdPlatformActionUrl(platformId, ThirdPlatformActions.GET_ACCESS_TOKEN); + String baseUrl = thirdPlatformInfo.getBaseUrl(); + String platformKey = thirdPlatformInfo.getPlatformKey(); + String platformSecret = thirdPlatformInfo.getPlatformSecret(); + String uuid = UUID.randomUUID().toString(); + long currentTimeMillis = System.currentTimeMillis(); + + try { + String sign = createSign(platformKey, platformSecret, uuid, currentTimeMillis, authType, null); + log.info("【调用平阴私有化平台获取AccessToken】参数列表:sign:{}, app_id:{}, auth_type:{}, nonce:{}, timestamp:{}", sign, platformKey, platformSecret, uuid, currentTimeMillis); + String urlParams = super.convertQueryParams2String(constructCommonUrlParamsMap(platformKey, authType, uuid, currentTimeMillis, sign)); + String requestUrl = baseUrl.concat(apiUrl).concat(urlParams); + Result stringResult = HttpClientManager.getInstance().sendPostByHttps(requestUrl, "{}"); + String remoteResultString = getResultDataOrThrowsException(stringResult, "【调用平阴私有化平台获取AccessToken】", EpmetErrorCode.SERVER_ERROR.getCode(), null); + Result remoteResult = parsePlatformResponseResult(remoteResultString, GetAccessTokenResultDTO.class); + log.info("【调用平阴私有化平台获取AccessToken】结果:{}", remoteResultString); + accessTokenFromCache = remoteResult.getData().getAccessToken(); + //(15 * 60 * 1000)为提前获取token。对方token有效期2小时,我们设置有效期为1小时45分钟,留15分钟容错时间,防止时间差 + long expire = remoteResult.getData().getExpireTime() - System.currentTimeMillis() - (15 * 60 * 1000); + super.addAccessTokenToCache(platformId, accessTokenFromCache, expire, TimeUnit.MILLISECONDS); + } catch (Exception e) { + throw new RenException(ExceptionUtils.getErrorStackTrace(e)); + } + } + return accessTokenFromCache; + } + + /** + * @Description 创建签名 + * @param platformKey + * @param platformSecret + * @param nonce + * @param timeMillis + * @param authType + * @return java.lang.String + * @author wxz + * @date 2021.08.31 15:37:58 + */ + private String createSign(String platformKey, String platformSecret, String nonce, Long timeMillis, String authType, Map requestBodyMap) { + HashMap contentMap = new HashMap<>(); + contentMap.put("app_id", platformKey); + contentMap.put("auth_type", authType); + contentMap.put("nonce", nonce); + contentMap.put("timestamp", String.valueOf(timeMillis)); + + if (requestBodyMap != null && requestBodyMap.size() > 0) { + contentMap.putAll(requestBodyMap); + } + + String sign; + try { + sign = OpenApiSignUtils.createSign(contentMap, platformSecret); + } catch (Exception e) { + String detail = ExceptionUtils.getErrorStackTrace(e); + log.error(detail); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), "【平阴私有化平台apService】创建签名失败"); + } + return sign; + } + + /** + * @Description 构造url参数map + * @param platformKey + * @param authType + * @param nonce + * @param timeMillis + * @param sign + * @return java.util.Map + * @author wxz + * @date 2021.08.31 14:19:41 + */ + private Map constructCommonUrlParamsMap(String platformKey, String authType, String nonce, Long timeMillis, String sign) { + HashMap map = new HashMap<>(); + map.put("app_id", platformKey); + map.put("auth_type", authType); + map.put("nonce", nonce); + map.put("timestamp", String.valueOf(timeMillis)); + map.put("sign", sign); + return map; + } + + @Override + public Result parsePlatformResponseResult(String resultString, Class clazz) { + Result result; + try { + result = JSON.parseObject(resultString, new TypeReference>(clazz){}); + } catch (Exception e) { + String errorStackTrace = ExceptionUtils.getErrorStackTrace(e); + log.error(errorStackTrace); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), "【调用平阴私有化服务器,解析返回结果失败】"); + } + if (!result.success()) { + throw new RenException(String.format("【请求平阴私有化平台】失败,返回结果string:%s", resultString)); + } + return result; + } + + @Override + public void pushComponentAccessToken(ComponentAccessTokenFormDTO form, String platformId, String platformKey) { + ThirdPlatformCache thirdPlatformInfo = getThirdPlatformInfo(platformId); + String nonce = UUID.randomUUID().toString(); + long timeMillis = System.currentTimeMillis(); + + Map bodyMap = null; + try { + bodyMap = ConvertUtils.entityToMap(form); + } catch (Exception e) { + String detail = ExceptionUtils.getErrorStackTrace(e); + log.error(detail); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), "【推送ComponentAccessToken】requestBody转化为map失败"); + } + + String sign = createSign(platformKey, thirdPlatformInfo.getPlatformSecret(), nonce, timeMillis, authType, bodyMap); + Map urlParams = constructCommonUrlParamsMap(platformKey, authType, nonce, timeMillis, sign); + + String jsonString = JSON.toJSONString(form); + Result result = super.sendPostRequest(platformId, ThirdPlatformActions.PUSH_COMPONENT_ACCESS_TOKEN, jsonString, null, urlParams); + getResultDataOrThrowsException(result, "【平阴私有化平台】推送ComponentAccessToken", EpmetErrorCode.SERVER_ERROR.getCode(), null); + } + + @Override + public void pushAuthorizerAccessToken(AuthorizerAccessTokenFormDTO form, String platformId, String platformKey) { + + } +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PrivateEpmetController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PrivateEpmetController.java new file mode 100644 index 0000000000..1135562069 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PrivateEpmetController.java @@ -0,0 +1,50 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.AuthorizerAccessTokenFormDTO; +import com.epmet.dto.form.ComponentAccessTokenFormDTO; +import com.epmet.service.PrivateEpmetService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @Description 私有化平台相关controller + * @author wxz + * @date 2021.08.30 15:18:51 +*/ +@RestController +@RequestMapping("/private-epmet") +public class PrivateEpmetController { + + @Autowired + private PrivateEpmetService privateEpmetService; + + /** + * @Description 接收推送component access + * @param input + * @return com.epmet.commons.tools.utils.Result + * @author wxz + * @date 2021.08.30 15:18:57 + */ + @PostMapping("push-component-access-token") + public Result pushComponentAccessToken(@RequestBody ComponentAccessTokenFormDTO input) { + privateEpmetService.pushComponentAccessToken(input); + return new Result(); + } + + /** + * @Description 接收推送AuthorizerTokens + * @param input + * @return com.epmet.commons.tools.utils.Result + * @author wxz + * @date 2021.08.30 16:36:02 + */ + @PostMapping("push-authorizer-tokens") + public Result pushAuthorizerTokens(@RequestBody AuthorizerAccessTokenFormDTO input) { + privateEpmetService.pushAuthorizerTokens(input); + return new Result(); + } +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/TestConttroller.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/TestConttroller.java new file mode 100644 index 0000000000..f5d81f987d --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/TestConttroller.java @@ -0,0 +1,30 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.ComponentAccessTokenFormDTO; +import com.epmet.service.ComponentVerifyTicketService; +import com.epmet.service.PrivateEpmetService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Date; + +@RestController +@RequestMapping("test") +public class TestConttroller { + + @Autowired + private ComponentVerifyTicketService componentVerifyTicketService; + + @PostMapping("push-component-access-token") + public Result testPushComponentAccessToken() { + ComponentAccessTokenFormDTO form = new ComponentAccessTokenFormDTO(); + form.setComponentAccessToken("token..."); + form.setExpiresInTime(new Date()); + componentVerifyTicketService.pushComponentAccessToken2PrivateEpmetPlatforms(form); + return new Result(); + } + +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformActionDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformActionDao.java index 50de9d3629..405ae52529 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformActionDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformActionDao.java @@ -22,6 +22,8 @@ import com.epmet.entity.ThirdplatformActionEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.List; + /** * * @@ -38,4 +40,12 @@ public interface ThirdplatformActionDao extends BaseDao listPlatformActions(@Param("platformId") String platformId); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformCustomerRegisterDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformCustomerRegisterDao.java index 3dc3001baf..5f1fe6f038 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformCustomerRegisterDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformCustomerRegisterDao.java @@ -19,6 +19,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.form.PlatformUnregisterFormDTO; +import com.epmet.dto.result.ThirdPlatformActionsResultDTO; import com.epmet.entity.ThirdplatformCustomerRegisterEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -55,4 +56,13 @@ public interface ThirdplatformCustomerRegisterDao extends BaseDao + * @author wxz + * @date 2021.08.30 17:07:32 + */ + List listPlatformsByActionKey(@Param("actionKey") String actionKey); } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/ThirdPlatformCache.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/ThirdPlatformCache.java new file mode 100644 index 0000000000..c8c3409bc2 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/ThirdPlatformCache.java @@ -0,0 +1,19 @@ +package com.epmet.redis; + +import lombok.Data; + +/** + * @Description 第三方平台缓存对象 + * @author wxz + * @date 2021.08.31 14:41:49 +*/ +@Data +public class ThirdPlatformCache { + //String platformKey, String platformSecret, String platformName, String apiService, String baseUrl + private String platformId; + private String platformKey; + private String platformSecret; + private String platformName; + private String apiService; + private String baseUrl; +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ComponentVerifyTicketService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ComponentVerifyTicketService.java index 28cfae2fde..8d3ce45cbf 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ComponentVerifyTicketService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ComponentVerifyTicketService.java @@ -2,6 +2,7 @@ package com.epmet.service; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.dto.form.AuthCodeAndTimeFromDTO; +import com.epmet.dto.form.ComponentAccessTokenFormDTO; import org.springframework.web.bind.annotation.RequestBody; import javax.servlet.http.HttpServletRequest; @@ -48,4 +49,6 @@ public interface ComponentVerifyTicketService { */ void redirectUri(TokenDto tokenDto, @RequestBody AuthCodeAndTimeFromDTO fromDTO); + public void pushComponentAccessToken2PrivateEpmetPlatforms(ComponentAccessTokenFormDTO input); + } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PrivateEpmetService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PrivateEpmetService.java new file mode 100644 index 0000000000..3ab6a0b870 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PrivateEpmetService.java @@ -0,0 +1,19 @@ +package com.epmet.service; + +import com.epmet.dto.form.AuthorizerAccessTokenFormDTO; +import com.epmet.dto.form.ComponentAccessTokenFormDTO; + +public interface PrivateEpmetService { + void pushAuthorizerTokens(AuthorizerAccessTokenFormDTO input); + + /** + * @Description 推送component access token + * @param input + * @return void + * @author wxz + * @date 2021.08.30 16:17:48 + */ + void pushComponentAccessToken(ComponentAccessTokenFormDTO input); + + void pushVerifyTicket(String ticket); +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ThirdPlatformService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ThirdPlatformService.java index 570ce04d49..33224b3497 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ThirdPlatformService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ThirdPlatformService.java @@ -5,6 +5,7 @@ import com.epmet.dto.form.CustomerFormDTO; import com.epmet.dto.form.ThirdPlatformFormDTO; import com.epmet.dto.form.PlatformRegisterFormDTO; import com.epmet.dto.form.PlatformUnregisterFormDTO; +import com.epmet.dto.result.ThirdPlatformActionsResultDTO; import com.epmet.dto.result.ThirdplatformResultDTO; import java.util.List; @@ -100,4 +101,13 @@ public interface ThirdPlatformService { * @Date 10:15 2021-04-09 **/ void registerThirdPlatformCustomer(PlatformRegisterFormDTO formDTO); + + /** + * @Description 已知操作的key,查询哪些app可以做此操作 + * @param actionKey + * @return java.util.List + * @author wxz + * @date 2021.08.30 16:59:13 + */ + List listPlatformsByActionKey(String actionKey); } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java index a23d9ac77f..2ac3e225b2 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java @@ -4,12 +4,15 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.alibaba.nacos.client.config.utils.IOUtils; import com.dingtalk.api.request.OapiRobotSendRequest; +import com.epmet.apiservice.ApiService; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.HttpClientManager; import com.epmet.constant.ModuleConstant; +import com.epmet.constant.ThirdPlatformActions; import com.epmet.constant.ThirdRedisKeyConstant; import com.epmet.constant.ThirdRunTimeInfoConstant; import com.epmet.dao.*; @@ -21,7 +24,9 @@ import com.epmet.feign.OperCrmOpenFeignClient; import com.epmet.mpaes.WXBizMsgCrypt; import com.epmet.mpaes.WXXmlToMapUtil; import com.epmet.redis.RedisThird; +import com.epmet.service.ApiServiceSelector; import com.epmet.service.ComponentVerifyTicketService; +import com.epmet.service.ThirdPlatformService; import com.epmet.wxapi.constant.WxMaCodeConstant; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -47,7 +52,7 @@ import static com.epmet.constant.ThirdRunTimeInfoConstant.*; */ @Slf4j @Service -public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketService { +public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketService, ApiServiceSelector { @Autowired private RedisThird redisThird; @@ -94,6 +99,9 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe @Autowired private PaCustomerDao paCustomerDao; + @Autowired + private ThirdPlatformService thirdPlatformService; + @Value("${third.platform.appId}") private String componentAppId; @Value("${third.platform.appSecret}") @@ -104,8 +112,8 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe private String token; /** - * @Description 获得授权事件的票据 * @param + * @Description 获得授权事件的票据 * @author zxc */ @Transactional(rollbackFor = Exception.class) @@ -123,23 +131,23 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe String nonce = request.getParameter(ModuleConstant.NONCE); String encryptType = request.getParameter(ModuleConstant.ENCRYPT_TYPE); String signature = request.getParameter(ModuleConstant.SIGNATURE); - log.info(String.format(ThirdRunTimeInfoConstant.VERIFY_TICKET,msgSignature,timeStamp,nonce,encryptType,signature)); + log.info(String.format(ThirdRunTimeInfoConstant.VERIFY_TICKET, msgSignature, timeStamp, nonce, encryptType, signature)); // 从请求中读取整个post数据 InputStream inputStream; String postData = null; inputStream = request.getInputStream(); - postData= IOUtils.toString(inputStream,ModuleConstant.UTF8); - WXBizMsgCrypt wxBizMsgCrypt = new WXBizMsgCrypt(token,aesKey,componentAppId); + postData = IOUtils.toString(inputStream, ModuleConstant.UTF8); + WXBizMsgCrypt wxBizMsgCrypt = new WXBizMsgCrypt(token, aesKey, componentAppId); String msg = wxBizMsgCrypt.decryptMsg(msgSignature, timeStamp, nonce, postData); - log.info(String.format(ThirdRunTimeInfoConstant.MSG,msg)); + log.info(String.format(ThirdRunTimeInfoConstant.MSG, msg)); // 将xml转为map Map result = WXXmlToMapUtil.xmlToMap(msg); String infotype = result.get(ModuleConstant.INFO_TYPE); - log.info(String.format(ThirdRunTimeInfoConstant.INFO_TYPE,infotype)); - switch (infotype){ + log.info(String.format(ThirdRunTimeInfoConstant.INFO_TYPE, infotype)); + switch (infotype) { case ModuleConstant.TICKET_UNDERLINE_KEY: //接收票据 【component_verify_ticket】 String ComponentVerifyTicket = result.get(ModuleConstant.TICKET_KEY); - log.info(String.format(COMPONENT_VERIFY_TICKET,ComponentVerifyTicket)); + log.info(String.format(COMPONENT_VERIFY_TICKET, ComponentVerifyTicket)); // 缓存 ticket redisThird.setComponentVerifyTicket(ComponentVerifyTicket); // 存数据库 @@ -149,7 +157,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe //先逻辑删 ticketDao.deleteOldComponentVerifyTicket(); ticketDao.insertComponentVerifyTicket(ticketFormDTO); - log.info(ModuleConstant.TICKET_UNDERLINE_KEY+":"+ComponentVerifyTicket); + log.info(ModuleConstant.TICKET_UNDERLINE_KEY + ":" + ComponentVerifyTicket); break; case ModuleConstant.AUTHORIZED: //授权成功 this.disposeAuthResult(result); @@ -173,7 +181,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe } log.info(ThirdRunTimeInfoConstant.END_TICKET); Integer tokenCount = componentAccessTokenDao.selectAccessTokenCount(); - if (tokenCount == NumConstant.ZERO){ + if (tokenCount == NumConstant.ZERO) { String accessTokenCountFlag = ModuleConstant.ACCOUNT_TOKEN_FLAG_ONE; this.getComponentAccessToken(accessTokenCountFlag); } @@ -181,14 +189,14 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe } /** - * @Description 授权结果插入 * @param result + * @Description 授权结果插入 * @author zxc */ @Transactional(rollbackFor = Exception.class) - public void disposeAuthResult(Map result){ + public void disposeAuthResult(Map result) { Map tempMap = result; - Map data = tempMap; + Map data = tempMap; AuthResultRecordFormDTO authResultRecord = ConvertUtils.mapToEntity(data, AuthResultRecordFormDTO.class); authResultRecord.setWechatCreateTime(this.sToDate(result.get(ModuleConstant.CREATE_TIME))); if (result.containsKey(ModuleConstant.AUTHORIZATION_CODE_EXPIRED_TIME)) { @@ -199,9 +207,9 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe } /** - * @Description 定时获取 (令牌,component_access_token) 第三方与微信交互使用的component_access_token - * 每十分钟执行一次,判断是否有马上超时的(15分钟以内算马上超时) * @param accessTokenCountFlag 表里的 component_access_token的数量 + * @Description 定时获取 (令牌,component_access_token) 第三方与微信交互使用的component_access_token + * 每十分钟执行一次,判断是否有马上超时的(15分钟以内算马上超时) * @author zxc */ @Transactional(rollbackFor = Exception.class) @@ -218,7 +226,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe jsonObject.put(ModuleConstant.COMPONENT_APPID, componentAppId); jsonObject.put(ModuleConstant.COMPONENT_APPSECRET, appSecret); jsonObject.put(ModuleConstant.TICKET_UNDERLINE_KEY, componentVerifyTicket); - log.info(String.format(ThirdRunTimeInfoConstant.COMPONENT_ACCESS_TOKEN,componentVerifyTicket)); + log.info(String.format(ThirdRunTimeInfoConstant.COMPONENT_ACCESS_TOKEN, componentVerifyTicket)); String post = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_COMPONENT_TOKEN_URL, JSON.toJSONString(jsonObject)).getData(); Map hashMap = JSON.parseObject(post, Map.class); if (!hashMap.containsKey(ModuleConstant.ERR_MSG)) { @@ -236,6 +244,13 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe componentAccessTokenDao.insertComponentAccessToken(formDTO); //存缓存 redisThird.setComponentAccessToken(componentAccessToken); + //推送到私有化平台们 + try { + pushComponentAccessToken2PrivateEpmetPlatforms(formDTO); + } catch (Exception e) { + String detail = ExceptionUtils.getErrorStackTrace(e); + log.error(detail); + } } else { throw new RenException(ThirdRunTimeInfoConstant.FAILURE_ACCESS_TOKEN); } @@ -245,8 +260,29 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe } /** - * @Description 获取预授权码 + * @param input + * @return void + * @Description 推送component access token到私有化平台 + * @author wxz + * @date 2021.08.30 17:12:15 + */ + public void pushComponentAccessToken2PrivateEpmetPlatforms(ComponentAccessTokenFormDTO input) { + List platforms = thirdPlatformService.listPlatformsByActionKey(ThirdPlatformActions.PUSH_COMPONENT_ACCESS_TOKEN); + platforms.stream().forEach(p -> { + log.info("推送component-access-token到私有化平台:platformId:{}, platformKey:{}, platformName:{}, apiUrl:{}", p.getPlatformId(), p.getPlatformKey(), p.getPlatformName(), p.getApiUrl()); + ApiService apiService = selectApiService(p.getPlatformId()); + try { + apiService.pushComponentAccessToken(input, p.getPlatformId(), p.getPlatformKey()); + } catch (Exception e) { + String detail = ExceptionUtils.getErrorStackTrace(e); + log.error(detail); + } + }); + } + + /** * @param + * @Description 获取预授权码 * @author zxc */ @Transactional(rollbackFor = Exception.class) @@ -258,7 +294,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe JSONObject jsonObject = new JSONObject(); jsonObject.put(ModuleConstant.COMPONENT_APPID, componentAppId); String post = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_CREATE_PREAUTHCODE_URL + accessToken, JSON.toJSONString(jsonObject)).getData(); - log.info(String.format(POST_RESULT,post)); + log.info(String.format(POST_RESULT, post)); Map hashMap = JSON.parseObject(post, Map.class); if (!hashMap.containsKey(ModuleConstant.ERR_MSG)) { preAuthCode = hashMap.get(ModuleConstant.PRE_AUTH_CODE).toString(); @@ -283,11 +319,11 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe } /** - * @Description 使用授权码获取授权信息 请求参数:【component_access_token、component_appid、authorization_code】 + * @Description 使用授权码获取授权信息 请求参数:【component_access_token、component_appid、authorization_code】 * @author zxc */ @Transactional(rollbackFor = Exception.class) - public AuthorizationInfoResultDTO authInfoByAuthCode(String authCode,String customerId,String clientType) { + public AuthorizationInfoResultDTO authInfoByAuthCode(String authCode, String customerId, String clientType) { log.info(START_GET_AUTH_INFO); AuthorizationInfoResultDTO authorizationInfoResultDTO = new AuthorizationInfoResultDTO(); // 获取令牌【component_access_token】 @@ -297,11 +333,11 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe jsonObject.put(ModuleConstant.COMPONENT_APPID, componentAppId); jsonObject.put(ModuleConstant.AUTHORIZATION_CODE, authCode); String authInfo = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_QUERY_AUTH_URL + accessToken, JSON.toJSONString(jsonObject)).getData(); - HashMap hashMap = JSON.parseObject(authInfo, HashMap.class); + HashMap hashMap = JSON.parseObject(authInfo, HashMap.class); Map map = hashMap.get(ModuleConstant.AUTHORIZATION_INFO); authorizationInfoResultDTO = ConvertUtils.mapToEntity(map, AuthorizationInfoResultDTO.class); String authAppId = authorizationInfoResultDTO.getAuthorizer_appid(); - log.info("授权信息:"+map); + log.info("授权信息:" + map); String expiresIn = authorizationInfoResultDTO.getExpires_in().toString(); Date expiresInTime = this.countExpirationTime(expiresIn); //授权信息分为两张表,基础信息authorization_info,授权列表func_info @@ -314,14 +350,14 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe authInfoDTO.setCustomerId(customerId); authInfoDTO.setClientType(clientType); List func_info = authorizationInfoResultDTO.getFunc_info(); - log.info("权限列表信息:"+func_info); + log.info("权限列表信息:" + func_info); String funcInfo = JSON.toJSONString(func_info); authInfoDTO.setFuncInfo(funcInfo); //先逻辑删除,在插入 authorizationInfoDao.updateOldAuthorizationInfo(authAppId); authorizationInfoDao.insertAuthorizationInfo(authInfoDTO); // 授权信息放入缓存 - redisThird.setAuthInfo(authorizationInfoResultDTO,customerId,clientType); + redisThird.setAuthInfo(authorizationInfoResultDTO, customerId, clientType); //authorizer_refresh_token 放入缓存 redisThird.setAuthorizerRefreshToken(authInfoDTO); log.info(END_GET_AUTH_INFO); @@ -329,8 +365,8 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe } /** - * @Description 获取/刷新接口调用令牌 * @param + * @Description 获取/刷新接口调用令牌 * @author zxc */ @Transactional(rollbackFor = Exception.class) @@ -338,7 +374,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe public void refreshToken() { //查询 即将过期的 authorizer_access_token List willOverDueResultDTOS = authorizationInfoDao.checkWillOverDue(); - if (willOverDueResultDTOS.size() != NumConstant.ZERO && null != willOverDueResultDTOS){ + if (willOverDueResultDTOS.size() != NumConstant.ZERO && null != willOverDueResultDTOS) { log.info("查询到即将过期的authorizer_access_token"); willOverDueResultDTOS.forEach(willOverDueDTO -> { String authAppId = willOverDueDTO.getAuthAppId(); @@ -346,10 +382,10 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe String clientType = willOverDueDTO.getClientType(); JSONObject jsonObject = new JSONObject(); //授权方AppId - jsonObject.put(ModuleConstant.AUTHORIZER_APPID,authAppId); + jsonObject.put(ModuleConstant.AUTHORIZER_APPID, authAppId); //第三方平台AppId - jsonObject.put(ModuleConstant.COMPONENT_APPID,componentAppId); - jsonObject.put(ModuleConstant.AUTHORIZER_REFRESH_TOKEN,willOverDueDTO.getAuthorizerRefreshToken()); + jsonObject.put(ModuleConstant.COMPONENT_APPID, componentAppId); + jsonObject.put(ModuleConstant.AUTHORIZER_REFRESH_TOKEN, willOverDueDTO.getAuthorizerRefreshToken()); String componentAccessToken = redisThird.getComponentAccessToken(); String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_AUTHORIZER_TOKEN_URL + componentAccessToken, JSON.toJSONString(jsonObject)).getData(); Map map = JSON.parseObject(data, HashMap.class); @@ -368,7 +404,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe formDTO.setAuthAppid(authAppId); formDTO.setClientType(clientType); AuthorizationInfoFormDTO authorizationInfo = new AuthorizationInfoFormDTO(); - BeanUtils.copyProperties(formDTO,authorizationInfo); + BeanUtils.copyProperties(formDTO, authorizationInfo); authorizationInfo.setAuthorizerAppid(authAppId); //先逻辑删除,在插入 authorizationInfoDao.deleteOldAuthorizerAccessToken(customerId, clientType); @@ -380,7 +416,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe resultDTO.setAuthorizer_refresh_token(authorizerRefreshToken); resultDTO.setAuthorizer_appid(authAppId); resultDTO.setExpires_in(7200); - redisThird.setAuthInfo(resultDTO,customerId,clientType); + redisThird.setAuthInfo(resultDTO, customerId, clientType); } }); log.info("更新authorizer_access_token成功"); @@ -389,13 +425,13 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe } /** - * @Description 授权回调URL,回调时并获取授权信息 * @param + * @Description 授权回调URL, 回调时并获取授权信息 * @author zxc */ @Transactional(rollbackFor = Exception.class) @Override - public void redirectUri(TokenDto tokenDto, @RequestBody AuthCodeAndTimeFromDTO authCodeAndTime){ + public void redirectUri(TokenDto tokenDto, @RequestBody AuthCodeAndTimeFromDTO authCodeAndTime) { log.info("开始执行回调URL"); String authCode = authCodeAndTime.getAuthCode(); String clientType = authCodeAndTime.getClientType(); @@ -413,7 +449,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe formDTO.setClientType(clientType); formDTO.setCustomerId(customerId); log.info(ThirdRunTimeInfoConstant.BEGIN_DELETE_INSERT_AUTH_CODE); - authCodeDao.deleteCustomerAuthCode(customerId,clientType); + authCodeDao.deleteCustomerAuthCode(customerId, clientType); authCodeDao.insertRedirectAuthCode(formDTO); //authCode存缓存 redisThird.setAuthCode(formDTO); @@ -423,12 +459,12 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe List fixationAppIdResultDTOS = fixationAppIdDao.selectFixationInfos(); String finalCustomerId = customerId;// fixationAppIdResultDTOS.forEach(fixationAppId -> { - if (fixationAppId.getAppId().equals(authAppId)){ + if (fixationAppId.getAppId().equals(authAppId)) { // TODO 是城阳项目或者党群e事通 // crm表中的customerId【原customerId】 String masterCustomerId = fixationAppId.getMasterCustomerId(); formDTO.setCustomerId(masterCustomerId); - authCodeDao.deleteCustomerAuthCode(finalCustomerId,clientType); + authCodeDao.deleteCustomerAuthCode(finalCustomerId, clientType); authCodeDao.insertRedirectAuthCode(formDTO); //authCode存缓存 redisThird.setAuthCode(formDTO); @@ -447,37 +483,37 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe //替换 新customerId为旧customerId customerId = formDTO.getCustomerId(); // 2. 创建开放平台账号并绑定 或者 直接绑定开放平台 - this.createAndBindOpenAccount(customerId,authAppId,clientType); + this.createAndBindOpenAccount(customerId, authAppId, clientType); // 3. 更新 customer_mp 表授权状态和AuthAppId - this.updateCustomerMpAppId(customerId,authAppId,clientType); - authCodeDao.updateAppId(customerId,clientType,authAppId); + this.updateCustomerMpAppId(customerId, authAppId, clientType); + authCodeDao.updateAppId(customerId, clientType, authAppId); // 4. 保存授权方账户信息 - this.saveAuthAccountInfo(customerId,authAppId,clientType); + this.saveAuthAccountInfo(customerId, authAppId, clientType); // 5. 校验客户居民端、工作端小程序是否全部授权,全部授权完成的推送钉钉消息 sun this.checkAuthorization(customerId); log.info("回调结束"); } /** - * @Description 获取授权方的帐号基本信息并保存 * @param customerId * @param authAppId + * @Description 获取授权方的帐号基本信息并保存 * @author zxc */ @Transactional(rollbackFor = Exception.class) - public void saveAuthAccountInfo(String customerId, String authAppId,String clientType) { + public void saveAuthAccountInfo(String customerId, String authAppId, String clientType) { log.info("开始执行保存授权账户基本信息"); JSONObject jsonObject = new JSONObject(); - jsonObject.put(ModuleConstant.COMPONENT_APP_ID,componentAppId); - jsonObject.put(ModuleConstant.AUTHORIZER_APP_ID,authAppId); + jsonObject.put(ModuleConstant.COMPONENT_APP_ID, componentAppId); + jsonObject.put(ModuleConstant.AUTHORIZER_APP_ID, authAppId); String componentAccessToken = redisThird.getComponentAccessToken(); - String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_GET_AUTHORIZER_INFO + componentAccessToken , JSON.toJSONString(jsonObject)).getData(); - Map map = JSON.parseObject(data, Map.class); + String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_GET_AUTHORIZER_INFO + componentAccessToken, JSON.toJSONString(jsonObject)).getData(); + Map map = JSON.parseObject(data, Map.class); Map authorizerInfo = map.get(ModuleConstant.AUTHORIZER_INFO); - log.info("授权信息:"+authorizerInfo); + log.info("授权信息:" + authorizerInfo); // 存在 “miniprograminfo” 字段为小程序,不存在为公众号 boolean keyExist = authorizerInfo.containsKey(ModuleConstant.MINI_PROGRAM_INFO); - if (keyExist == true){ + if (keyExist == true) { log.info("授权方为小程序 并 开始插入信息"); MiniInfoFormDTO miniInfoFormDTO = ConvertUtils.mapToEntity(authorizerInfo, MiniInfoFormDTO.class); miniInfoFormDTO.setCustomerId(customerId); @@ -498,22 +534,22 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe businessInfoForm.setPrimaryId(primaryId); businessInfoList.add(businessInfoForm); }); - businessInfoDao.deleteBusinessInfo(customerId,clientType); + businessInfoDao.deleteBusinessInfo(customerId, clientType); businessInfoDao.insertBusinessInfo(businessInfoList); //todo 小程序配置的合法域名信息插入 Map miniProgramInfo = (Map) authorizerInfo.get(ModuleConstant.MINI_PROGRAM_INFO); List networkInfoList = new ArrayList<>(); Map networkInfo = (Map) miniProgramInfo.get(ModuleConstant.NETWORK); - networkInfo.forEach((key,value) -> { + networkInfo.forEach((key, value) -> { MiniNetworkInfoFormDTO miniNetworkInfoForm = new MiniNetworkInfoFormDTO(); - miniNetworkInfoForm .setCustomerId(customerId); + miniNetworkInfoForm.setCustomerId(customerId); miniNetworkInfoForm.setClientType(clientType); miniNetworkInfoForm.setNetworkType(key.toString()); miniNetworkInfoForm.setUrl(value.toString()); miniNetworkInfoForm.setPrimaryId(primaryId); networkInfoList.add(miniNetworkInfoForm); }); - miniNetworkInfoDao.deleteNetworkInfo(customerId,clientType); + miniNetworkInfoDao.deleteNetworkInfo(customerId, clientType); miniNetworkInfoDao.insertNetworkInfo(networkInfoList); //todo 小程序配置的类目信息插入 List categoryInfoList = new ArrayList<>(); @@ -533,7 +569,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe miniCategoryInfoDao.deleteCategoryInfo(customerId, clientType); miniCategoryInfoDao.insertCategoryInfo(categoryInfoList); } - }else { + } else { log.info("授权方为公众号 并 开始插入信息"); PaInfoFormDTO paInfoFormDTO = ConvertUtils.mapToEntity(authorizerInfo, PaInfoFormDTO.class); //公众号基本信息插入 @@ -551,7 +587,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe businessInfoForm.setPrimaryId(primaryId); businessInfoList.add(businessInfoForm); }); - businessInfoDao.deleteBusinessInfo(customerId,clientType); + businessInfoDao.deleteBusinessInfo(customerId, clientType); businessInfoDao.insertBusinessInfo(businessInfoList); } log.info("保存授权方基本信息结束"); @@ -559,12 +595,12 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe } /** - * @Description 回填 customer_mp appId , 更改授权状态 * @param + * @Description 回填 customer_mp appId , 更改授权状态 * @author zxc */ @Transactional(rollbackFor = Exception.class) - public void updateCustomerMpAppId(String customerId,String authAppId,String clientType){ + public void updateCustomerMpAppId(String customerId, String authAppId, String clientType) { log.info("==========回填customer_mp开始=========="); Integer checkBindCount = customerMpDao.checkBind(authAppId, clientType); if (checkBindCount == NumConstant.ZERO) { @@ -578,14 +614,14 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe log.info("==========回填customer_mp结束=========="); } - public void createAndBindOpenAccount(String customerId,String authAppId,String clientType){ + public void createAndBindOpenAccount(String customerId, String authAppId, String clientType) { log.info(ThirdRunTimeInfoConstant.BEGIN_CREATE_OPEN); Map authorizerRefreshToken = redisThird.getAuthorizerRefreshToken(customerId + ThirdRedisKeyConstant.COLON + clientType); String authorizerAccessToken = authorizerRefreshToken.get("authorizerAccessToken").toString(); JSONObject bindInfoForm = new JSONObject(); - bindInfoForm.put(ModuleConstant.LOW_APP_ID,authAppId); + bindInfoForm.put(ModuleConstant.LOW_APP_ID, authAppId); String bindResult = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_OPEN_GET + authorizerAccessToken, JSON.toJSONString(bindInfoForm)).getData(); - Map bindInfo = JSON.parseObject(bindResult, Map.class); + Map bindInfo = JSON.parseObject(bindResult, Map.class); boolean bindStatus = bindInfo.containsKey(ModuleConstant.OPEN_APP_ID); if (bindStatus != true) { Integer authCount = customerMpDao.selectAuthCount(customerId); @@ -663,11 +699,11 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe } /** - * @Description 转换过期时间 * @param expiresIn + * @Description 转换过期时间 * @author zxc */ - public Date countExpirationTime(String expiresIn){ + public Date countExpirationTime(String expiresIn) { expiresIn = expiresIn + "000"; Date date = new Date(); long l = date.getTime() + Long.valueOf(expiresIn); @@ -676,21 +712,21 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe } /** - * @Description 查询客户Id * @param tokenDto + * @Description 查询客户Id * @author zxc */ - public String getLoginUserCustomerId(TokenDto tokenDto){ + public String getLoginUserCustomerId(TokenDto tokenDto) { PaCustomerUserAgencyDTO result = paCustomerUserAgencyDao.selectCustomerIdByUserId(tokenDto.getUserId()); return result.getCustomerId(); } /** - * @Description 时间戳(秒级)转换 Date * @param t + * @Description 时间戳(秒级)转换 Date * @author zxc */ - public Date sToDate(String t){ + public Date sToDate(String t) { Long aLong = Long.valueOf(t + "000"); Date date = new Date(); date.setTime(aLong); @@ -699,24 +735,24 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe /** * @author sun - * @Description 校验客户两哥小程序是否完成授权 + * @Description 校验客户两哥小程序是否完成授权 */ - private void checkAuthorization(String customerId){ + private void checkAuthorization(String customerId) { List list = customerMpDao.selectByCustomerId(customerId); AtomicBoolean bl = new AtomicBoolean(false); - list.forEach(mp->{ - if(mp.getAuthorizationFlag()!=NumConstant.ONE){ + list.forEach(mp -> { + if (mp.getAuthorizationFlag() != NumConstant.ONE) { bl.set(true); } }); - if(!bl.get()){ + if (!bl.get()) { dDingNews(customerId); } } /** * @author sun - * @Description 发送钉钉消息,通知运营人员有新客户完成授权 + * @Description 发送钉钉消息,通知运营人员有新客户完成授权 */ private String dDingNews(String customerId) { //1.查询客户及管理员信息,用于发送消息使用 @@ -739,8 +775,29 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe "> 管理员称谓: " + result.getAppellation() + "\n\n" + "> 联系方式: " + result.getPhone() + "\n"); request.setMarkdown(markdown); - HttpClientManager.getInstance().sendDingMsg(JSON.toJSONString(request),url,secret); + HttpClientManager.getInstance().sendDingMsg(JSON.toJSONString(request), url, secret); return null; } + /** + * @Description 推送AuthorizerAccessToken到私有化平台们 + * @param form + * @return void + * @author wxz + * @date 2021.08.31 17:22:04 + */ + public void pushAuthorizerAccessToken2PrivateEpmets(AuthorizerAccessTokenFormDTO form) { + List platforms = thirdPlatformService.listPlatformsByActionKey(ThirdPlatformActions.PUSH_AUTHORIZER_ACCESS_TOKEN); + platforms.stream().forEach(p -> { + log.info("推送authorizer-access-token到私有化平台:platformId:{}, platformKey:{}, platformName:{}, apiUrl:{}", p.getPlatformId(), p.getPlatformKey(), p.getPlatformName(), p.getApiUrl()); + ApiService apiService = selectApiService(p.getPlatformId()); + try { + apiService.pushAuthorizerAccessToken(form, p.getPlatformId(), p.getPlatformKey()); + } catch (Exception e) { + String detail = ExceptionUtils.getErrorStackTrace(e); + log.error(detail); + } + }); + } + } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PrivateEpmetServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PrivateEpmetServiceImpl.java new file mode 100644 index 0000000000..35cb59cad1 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PrivateEpmetServiceImpl.java @@ -0,0 +1,71 @@ +package com.epmet.service.impl; + +import com.epmet.constant.ThirdRunTimeInfoConstant; +import com.epmet.dao.AuthorizationInfoDao; +import com.epmet.dao.ComponentAccessTokenDao; +import com.epmet.dao.ComponentVerifyTicketDao; +import com.epmet.dto.form.AuthorizationInfoFormDTO; +import com.epmet.dto.form.AuthorizerAccessTokenFormDTO; +import com.epmet.dto.form.ComponentAccessTokenFormDTO; +import com.epmet.dto.result.AuthorizationInfoResultDTO; +import com.epmet.redis.RedisThird; +import com.epmet.service.PrivateEpmetService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Slf4j +public class PrivateEpmetServiceImpl implements PrivateEpmetService { + + @Autowired + private ComponentVerifyTicketDao componentVerifyTicketDao; + + @Autowired + private AuthorizationInfoDao authorizationInfoDao; + + @Autowired + private ComponentAccessTokenDao componentAccessTokenDao; + + @Autowired + private RedisThird redisThird; + + @Transactional(rollbackFor = RuntimeException.class) + @Override + public void pushAuthorizerTokens(AuthorizerAccessTokenFormDTO input) { + System.out.println("收到AuthorizerAccessTokenFormDTO:" + input); + + //AuthorizationInfoFormDTO authorizationInfo = new AuthorizationInfoFormDTO(); + //BeanUtils.copyProperties(input,authorizationInfo); + //authorizationInfo.setAuthorizerAppid(input.getAuthAppid()); + ////先逻辑删除,在插入 + //authorizationInfoDao.deleteOldAuthorizerAccessToken(input.getCustomerId(), input.getClientType()); + //authorizationInfoDao.insertAuthorizerAccessToken(input); + ////缓存 refreshAuthorizerAccessToken + //redisThird.setAuthorizerRefreshToken(authorizationInfo); + //AuthorizationInfoResultDTO resultDTO = new AuthorizationInfoResultDTO(); + //resultDTO.setAuthorizer_access_token(input.getAuthorizerAccessToken()); + //resultDTO.setAuthorizer_refresh_token(input.getAuthorizerRefreshToken()); + //resultDTO.setAuthorizer_appid(input.getAuthAppid()); + //resultDTO.setExpires_in(7200); + //redisThird.setAuthInfo(resultDTO,input.getCustomerId(),input.getClientType()); + } + + @Override + @Transactional(rollbackFor = RuntimeException.class) + public void pushComponentAccessToken(ComponentAccessTokenFormDTO componentAccessToken) { + System.out.println("收到componentAccessToken:" + componentAccessToken); + //先逻辑删,在插入 + //componentAccessTokenDao.deleteOldComponentAccessToken(); + //componentAccessTokenDao.insertComponentAccessToken(componentAccessToken); + ////存缓存 + //redisThird.setComponentAccessToken(componentAccessToken.getComponentAccessToken()); + } + + @Override + public void pushVerifyTicket(String ticket) { + + } +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ThirdPlatformServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ThirdPlatformServiceImpl.java index 3d6393e17e..a3e0930e7a 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ThirdPlatformServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ThirdPlatformServiceImpl.java @@ -12,6 +12,7 @@ import com.epmet.dto.form.CustomerFormDTO; import com.epmet.dto.form.ThirdPlatformFormDTO; import com.epmet.dto.form.PlatformRegisterFormDTO; import com.epmet.dto.form.PlatformUnregisterFormDTO; +import com.epmet.dto.result.ThirdPlatformActionsResultDTO; import com.epmet.dto.result.ThirdplatformResultDTO; import com.epmet.entity.ThirdplatformCustomerActionEntity; import com.epmet.entity.ThirdplatformCustomerRegisterEntity; @@ -160,4 +161,9 @@ public class ThirdPlatformServiceImpl implements ThirdPlatformService { thirdplatformCustomerRegisterDao.batchInsertThirdplatformCustomerRegister(entityList); } } + + @Override + public List listPlatformsByActionKey(String actionKey) { + return thirdplatformCustomerRegisterDao.listPlatformsByActionKey(actionKey); + } } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ThirdplatformActionDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ThirdplatformActionDao.xml index 39de22dca5..954b8a96e6 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ThirdplatformActionDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ThirdplatformActionDao.xml @@ -30,6 +30,23 @@ from thirdplatform_action ta where ta.PLATFORM_ID = #{platformId} and ACTION_KEY = #{action} + and ta.DEL_FLAG=0 + + + diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ThirdplatformCustomerRegisterDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ThirdplatformCustomerRegisterDao.xml index 9ab368a8bc..66d039fc3c 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ThirdplatformCustomerRegisterDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ThirdplatformCustomerRegisterDao.xml @@ -36,6 +36,20 @@ and DEL_FLAG = 0 + + + insert into thirdplatform_customer_register ( diff --git a/epmet-module/gov-grid/gov-grid-server/src/main/java/com/epmet/service/impl/PartyBranchManageServiceImpl.java b/epmet-module/gov-grid/gov-grid-server/src/main/java/com/epmet/service/impl/PartyBranchManageServiceImpl.java index 0cf320e03f..e4e806573a 100644 --- a/epmet-module/gov-grid/gov-grid-server/src/main/java/com/epmet/service/impl/PartyBranchManageServiceImpl.java +++ b/epmet-module/gov-grid/gov-grid-server/src/main/java/com/epmet/service/impl/PartyBranchManageServiceImpl.java @@ -137,17 +137,14 @@ public class PartyBranchManageServiceImpl implements PartyBranchManageService { CustomerPartyBranchDTO customerPartyBranch = customerPartyBranchResult.getData(); PartyMemberBaseInfoAddFormDTO partyMemberBaseInfoAddFormDTO = this.getPartyMemberBaseInfoAddFormDTO(formDTO, customerPartyBranch); Result result = resiPartyMemberOpenFeignClient.addPartyMemberBaseInfo(partyMemberBaseInfoAddFormDTO); + if (!result.success() || StringUtils.isBlank(result.getData())) { + throw new RenException(result.getCode(), result.getMsg()); + } //3、党支部总人数+1 - if (result.success() && StringUtils.isNotBlank(result.getData())) { - //党支部总人数+1 - customerPartyBranch.setTotalPartyMember(customerPartyBranch.getTotalPartyMember() + 1); - Result updatePartyBranchResult = govOrgOpenFeignClient.updatePartyBranch(customerPartyBranch); - if (updatePartyBranchResult.success()) { - logger.info(String.format("党支部(%s)总人数+1", formDTO.getPartyBranchId())); - } - } else { - logger.error("添加党员异常"); - throw new RenException(result.getCode()); + customerPartyBranch.setTotalPartyMember(customerPartyBranch.getTotalPartyMember() + 1); + Result updatePartyBranchResult = govOrgOpenFeignClient.updatePartyBranch(customerPartyBranch); + if (updatePartyBranchResult.success()) { + logger.info(String.format("党支部(%s)总人数+1", formDTO.getPartyBranchId())); } return result.getData(); } diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyFormDTO.java index a177306a68..7a5e6b5537 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyFormDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyFormDTO.java @@ -45,7 +45,7 @@ public class AddAgencyFormDTO implements Serializable { * 机构组织名称 */ @NotBlank(message = "组织名称不能为空") - @Length(max=50,message = "机构名称不能超过50个字") + @Length(max=20,message = "机构名称不能超过20个字") private String agencyName; /** diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddDepartmentFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddDepartmentFormDTO.java index 30f74015ca..5a582535c6 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddDepartmentFormDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddDepartmentFormDTO.java @@ -16,6 +16,7 @@ package com.epmet.dto.form; * along with this program. If not, see . */ +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; import lombok.Data; import org.hibernate.validator.constraints.Length; @@ -31,20 +32,21 @@ import java.io.Serializable; public class AddDepartmentFormDTO implements Serializable { private static final long serialVersionUID = 1L; - /** * 所属组织机构ID(customer_agency.id) */ - @NotBlank(message = "组织机构Id不能为空") + @NotBlank(message = "组织机构Id不能为空",groups = AddDepartmentFormDTO.AddDept.class) private String agencyId; - /** * 部门名称 */ - @NotBlank(message = "部门名称不能为空") - @Length(max=120,message = "部门名称不能超过120个字") + @NotBlank(message = "部门名称不能为空",groups = AddDepartmentFormDTO.AddDept.class) + @Length(max=20,message = "部门名称不能超过20个字",groups = AddDepartmentFormDTO.AddDept.class) private String departmentName; + public interface AddDept extends CustomerClientShowGroup { + } + /** * 部门职责 */ diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddGridFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddGridFormDTO.java index 95df5fca15..a9473e218e 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddGridFormDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddGridFormDTO.java @@ -1,7 +1,10 @@ package com.epmet.dto.form; +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; import lombok.Data; +import org.hibernate.validator.constraints.Length; +import javax.validation.constraints.NotBlank; import java.io.Serializable; /** @@ -12,16 +15,20 @@ import java.io.Serializable; public class AddGridFormDTO implements Serializable { private static final long serialVersionUID = 1L; + /** + * 新建网格名称 + */ + @NotBlank(message = "网格名称不能为空") + @Length(max=20,message = "网格名称不能超过20个字",groups = AddGridFormDTO.AddGrid.class) + private String gridName; /** * 机构id */ private String agencyId; - /** - * 新建网格名称 - */ - private String gridName; + public interface AddGrid extends CustomerClientShowGroup { + } /** * 管辖区域 diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditAgencyFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditAgencyFormDTO.java index 66984fc62e..f279164095 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditAgencyFormDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditAgencyFormDTO.java @@ -50,7 +50,7 @@ public class EditAgencyFormDTO implements Serializable { * 机关组织名称 */ @NotBlank(message = "机关组织名称不能为空") - @Length(max=50,message = "机构名称不能超过50个字",groups = DefaultUserShowGroup.class) + @Length(max=20,message = "机构名称不能超过20个字",groups = DefaultUserShowGroup.class) private String agencyName; /** diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditDepartmentFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditDepartmentFormDTO.java index d87c0081a0..5d59b289f0 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditDepartmentFormDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditDepartmentFormDTO.java @@ -17,6 +17,7 @@ package com.epmet.dto.form; +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; import lombok.Data; import org.hibernate.validator.constraints.Length; @@ -33,20 +34,21 @@ import java.io.Serializable; public class EditDepartmentFormDTO implements Serializable { private static final long serialVersionUID = 1L; - /** * 部门Id */ - @NotBlank(message = "部门ID不能为空") + @NotBlank(message = "部门ID不能为空",groups = EditDepartmentFormDTO.EditDept.class) private String departmentId; - /** * 部门名称 */ - @NotBlank(message = "部门名称不能为空") - @Length(max=120,message = "部门名称不能超过120个字") + @NotBlank(message = "部门名称不能为空",groups = EditDepartmentFormDTO.EditDept.class) + @Length(max=20,message = "部门名称不能超过20个字",groups = EditDepartmentFormDTO.EditDept.class) private String departmentName; + public interface EditDept extends CustomerClientShowGroup { + } + /** * 部门职责 */ diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditGridFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditGridFormDTO.java index b22e5048f9..0ad04c404d 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditGridFormDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditGridFormDTO.java @@ -1,7 +1,10 @@ package com.epmet.dto.form; +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; import lombok.Data; +import org.hibernate.validator.constraints.Length; +import javax.validation.constraints.NotBlank; import java.io.Serializable; /** @@ -12,6 +15,12 @@ import java.io.Serializable; public class EditGridFormDTO implements Serializable { private static final long serialVersionUID = 1L; + /** + * 网格名称 + */ + @NotBlank(message = "网格名称不能为空") + @Length(max=20,message = "网格名称不能超过20个字",groups = EditGridFormDTO.EditGrid.class) + private String gridName; /** * gridId 网格id @@ -23,10 +32,8 @@ public class EditGridFormDTO implements Serializable { */ private String agencyId; - /** - * 网格名称 - */ - private String gridName; + public interface EditGrid extends CustomerClientShowGroup { + } /** * 管理区域 diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/OrgFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/OrgFormDTO.java new file mode 100644 index 0000000000..6975477321 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/OrgFormDTO.java @@ -0,0 +1,17 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description + * @Author zhaoqifeng + * @Date 2021/9/7 15:41 + */ +@Data +public class OrgFormDTO implements Serializable { + private static final long serialVersionUID = -5975063766883885089L; + private String orgId; + private String orgType; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/MineResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/MineResultDTO.java index 69e4ff630d..01b1630ebc 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/MineResultDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/MineResultDTO.java @@ -59,4 +59,8 @@ public class MineResultDTO implements Serializable { * 根组织 */ private String rootAgencyId; + /** + * 根组织名 + */ + private String rootAgencyName; } diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java index e6af374fe2..7e7de0e4b2 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/GovOrgOpenFeignClient.java @@ -417,4 +417,14 @@ public interface GovOrgOpenFeignClient { */ @PostMapping("/gov/org/customerstaffagency/queryOrgStaffs") Result> queryOrgStaffs(@RequestBody OrgStaffFormDTO formDTO); + + /** + * @Description 根据组织或网格或吧部门获取组织信息 + * @Param formDTO + * @Return {@link Result} + * @Author zhaoqifeng + * @Date 2021/9/7 15:27 + */ + @PostMapping("/gov/org/customeragency/getAgencyInfo") + Result getAgencyInfo(@RequestBody OrgFormDTO formDTO); } diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java index b517c20344..38f5df4626 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/feign/fallback/GovOrgOpenFeignClientFallback.java @@ -248,6 +248,19 @@ public class GovOrgOpenFeignClientFallback implements GovOrgOpenFeignClient { return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "queryOrgStaffs", formDTO); } + /** + * @param formDTO + * @Description 根据组织或网格或吧部门获取组织信息 + * @Param formDTO + * @Return {@link Result} + * @Author zhaoqifeng + * @Date 2021/9/7 15:27 + */ + @Override + public Result getAgencyInfo(OrgFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getAgencyInfo", formDTO); + } + @Override public Result selectPidsByGridId(String gridId) { return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "selectPidsByGridId", gridId); diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java index bb6308fd11..70c254ee26 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java @@ -302,4 +302,26 @@ public class CustomerAgencyController { public Result getAreaCodeSwitch(@PathVariable("customerId")String customerId){ return new Result().ok(customerOrgParameterService.getAreaCodeSwitch(customerId)); } + + /** + * @Description 【通讯录】查询当前人员所属组织、组织下部门/网格树 + * @author sun + **/ + @PostMapping("orgtree") + Result orgTree(@LoginUser TokenDto tokenDto){ + return new Result().ok(customerAgencyService.staffPermissionExt(tokenDto.getUserId())); + } + + /** + * @Description 根据组织或网格或吧部门获取组织信息 + * @Param formDTO + * @Return {@link Result} + * @Author zhaoqifeng + * @Date 2021/9/7 15:27 + */ + @PostMapping("getAgencyInfo") + public Result getAgencyInfo(@RequestBody OrgFormDTO formDTO) { + return new Result().ok(customerAgencyService.getAgencyInfo(formDTO)); + } + } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java index e0d76fc5b4..186cae52b6 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java @@ -52,7 +52,7 @@ public class DepartmentController { @PostMapping("adddepartment") @RequirePermission(requirePermission = RequirePermissionEnum.ORG_DEPARTMENT_CREATE) public Result addDepartment(@LoginUser TokenDto tokenDTO, @RequestBody AddDepartmentFormDTO formDTO) { - ValidatorUtils.validateEntity(formDTO); + ValidatorUtils.validateEntity(formDTO, AddDepartmentFormDTO.AddDept.class); return departmentService.addDepartment(formDTO); } @@ -65,7 +65,7 @@ public class DepartmentController { @PostMapping("editdepartment") @RequirePermission(requirePermission = RequirePermissionEnum.ORG_DEPARTMENT_UPDATE) public Result editDepartment(@LoginUser TokenDto tokenDTO, @RequestBody EditDepartmentFormDTO formDTO) { - ValidatorUtils.validateEntity(formDTO); + ValidatorUtils.validateEntity(formDTO, EditDepartmentFormDTO.EditDept.class); return departmentService.editDepartment(formDTO); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java index 4940768e7d..daf3c835cc 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java @@ -46,6 +46,7 @@ public class GridController { @PostMapping("addgrid") @RequirePermission(requirePermission = RequirePermissionEnum.ORG_GRID_CREATE) public Result addGrid(@LoginUser TokenDto tokenDto, @RequestBody AddGridFormDTO addGridFormDTO){ + ValidatorUtils.validateEntity(addGridFormDTO, AddGridFormDTO.AddGrid.class); return customerGridService.addGrid(tokenDto,addGridFormDTO); } @@ -56,6 +57,7 @@ public class GridController { @PostMapping("editgrid") @RequirePermission(requirePermission = RequirePermissionEnum.ORG_GRID_UPDATE) public Result editGrid(@LoginUser TokenDto tokenDto, @RequestBody EditGridFormDTO editGridFormDTO){ + ValidatorUtils.validateEntity(editGridFormDTO, EditGridFormDTO.EditGrid.class); return customerGridService.editGrid(tokenDto,editGridFormDTO); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java index fda2f4d09e..aaa691f239 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java @@ -236,4 +236,13 @@ public interface CustomerAgencyService extends BaseService OrganizeTreeResultDTO organizeTree(String agencyId); void checkAgencyName(String agencyName,String customerId,String agencyId,String parentAgencyId); + + /** + * 根据组织或网格或吧部门获取组织信息 + * @Param formDTO + * @Return {@link OrgResultDTO} + * @Author zhaoqifeng + * @Date 2021/9/7 15:28 + */ + OrgResultDTO getAgencyInfo(OrgFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java index 38c0fc85b0..554d263173 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java @@ -1075,4 +1075,18 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl queryOrgStaffs(OrgStaffFormDTO formDTO) { - Set agencyUserIds=customerStaffAgencyDao.selectAgencyStaffs(formDTO.getCustomerId(),formDTO.getAgencyIds()); - Set deptUserIds=customerStaffAgencyDao.selectDeptStaffs(formDTO.getCustomerId(),formDTO.getDeptIds()); - Set gridUserIds=customerStaffAgencyDao.selectGridStaffs(formDTO.getCustomerId(),formDTO.getGridIds()); + Set agencyUserIds= CollectionUtils.isNotEmpty(formDTO.getAgencyIds())?customerStaffAgencyDao.selectAgencyStaffs(formDTO.getCustomerId(),formDTO.getAgencyIds()):new HashSet<>(); + Set deptUserIds=CollectionUtils.isNotEmpty(formDTO.getDeptIds())?customerStaffAgencyDao.selectDeptStaffs(formDTO.getCustomerId(),formDTO.getDeptIds()):new HashSet<>(); + Set gridUserIds=CollectionUtils.isNotEmpty(formDTO.getGridIds())?customerStaffAgencyDao.selectGridStaffs(formDTO.getCustomerId(),formDTO.getGridIds()):new HashSet<>(); Set result=new LinkedHashSet(); result.addAll(agencyUserIds); result.addAll(deptUserIds); diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java index ceab225169..9d6504d673 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java @@ -234,9 +234,13 @@ public class StaffServiceImpl implements StaffService { //获取根组织 CustomerAgencyDTO agency = customerAgencyService.get(customerStaffAgency.getAgencyId()); if (StringUtils.isNotBlank(agency.getPids())) { - result.setRootAgencyId(agency.getPids().split(StrConstant.COLON)[0]); + String rootAgencyId = agency.getPids().split(StrConstant.COLON)[0]; + CustomerAgencyDTO rootAgency = customerAgencyService.get(rootAgencyId); + result.setRootAgencyId(rootAgencyId); + result.setRootAgencyName(rootAgency.getOrganizationName()); } else { result.setRootAgencyId(customerStaffAgency.getAgencyId()); + result.setRootAgencyName(agency.getOrganizationName()); } //2021.08.27 zhaoqf end return result; @@ -438,6 +442,8 @@ public class StaffServiceImpl implements StaffService { staffTransferRecordDTO.setRemarks(fromDTO.getRemarks()); staffTransferRecordService.save(staffTransferRecordDTO); //8.更改注册关系 + CustomerAgencyDTO agencyDTO = customerAgencyService.get(agencyId); + staffOrgRelation.setPids(agencyDTO.getPids()); staffOrgRelation.setOrgId(fromDTO.getOrgId()); staffOrgRelation.setOrgType(fromDTO.getOrgType()); staffOrgRelation.setUpdatedBy(null); diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffAgencyDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffAgencyDao.xml index c62306039f..5f471060b6 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffAgencyDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerStaffAgencyDao.xml @@ -41,58 +41,62 @@ + SELECT + g.ID AS "guideId", + g.TITLE AS "title", + gc.CATEGORY_NAME AS categoryName, + g.CREATED_BY AS createdId, + g.UPDATED_TIME AS updatedTime, + FROM + guide g + INNER JOIN guide_category gc ON g.CATEGORY_ID = gc.ID + WHERE g.DEL_FLAG = 0 + + AND g.PIDS LIKE CONCAT( '%', #{agencyId}, '%' ) + + + AND g.TITLE LIKE CONCAT( '%', #{guideTitle}, '%' ) + + + AND g.CATEGORY_ID = #{categoryId} + + + + + + \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/GuideExternalLinkDao.xml b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/GuideExternalLinkDao.xml new file mode 100644 index 0000000000..e570f994b4 --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/GuideExternalLinkDao.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/GuideModuleDao.xml b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/GuideModuleDao.xml new file mode 100644 index 0000000000..3d329b642d --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/GuideModuleDao.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/GuideModuleDictDao.xml b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/GuideModuleDictDao.xml new file mode 100644 index 0000000000..be18e67c5d --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/GuideModuleDictDao.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/GuideModuleDictDefaultDao.xml b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/GuideModuleDictDefaultDao.xml new file mode 100644 index 0000000000..89cc9ac2e3 --- /dev/null +++ b/epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/GuideModuleDictDefaultDao.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/constant/ActConstant.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/constant/ActConstant.java new file mode 100644 index 0000000000..30f06ebaf6 --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/constant/ActConstant.java @@ -0,0 +1,17 @@ +package com.epmet.resi.group.constant; + +/** + * @Author zxc + * @DateTime 2021/9/3 4:39 下午 + * @DESC + */ +public interface ActConstant { + + /** + * 类型【组织活动次数:orgAct,应参加活动次数:joinAct,活动签到次数:signAct】 + */ + String ORG_ACT = "orgAct"; + String JOIN_ACT = "joinAct"; + String SIGN_ACT = "signAct"; + +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/ActCommentAttachmentDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/ActCommentAttachmentDTO.java new file mode 100644 index 0000000000..5326d3783d --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/ActCommentAttachmentDTO.java @@ -0,0 +1,126 @@ +/** + * 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.resi.group.dto.act; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 活动评论附件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-06 + */ +@Data +public class ActCommentAttachmentDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 客户ID + */ + private String customerId; + + /** + * 活动Id[group_act_info.id] + */ + private String groupActId; + + /** + * 评论Id + */ + private String actCommentId; + + /** + * 文件名 + */ + private String fileName; + + /** + * 附件名(uuid随机生成) + */ + private String attachmentName; + + /** + * 文件大小,单位b + */ + private Integer attachmentSize; + + /** + * 文件格式(JPG、PNG、PDF、JPEG、BMP、MP4、WMA、M4A、MP3、DOC、DOCX、XLS) + */ + private String attachmentFormat; + + /** + * 附件类型((图片 - image、 视频 - video、 语音 - voice、 文档 - doc)) + */ + private String attachmentType; + + /** + * 附件地址 + */ + private String attachmentUrl; + + /** + * 排序字段 + */ + private Integer sort; + + /** + * 语音或视频时长,秒 + */ + private Integer duration; + + /** + * 删除标记 0:未删除,1:已删除 + */ + private String delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/OrganizationalLifeLineChartDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/OrganizationalLifeLineChartDTO.java new file mode 100644 index 0000000000..ad5dca0bba --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/OrganizationalLifeLineChartDTO.java @@ -0,0 +1,44 @@ +package com.epmet.resi.group.dto.act; + +import com.epmet.commons.tools.constant.NumConstant; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2021/9/3 3:35 下午 + * @DESC + */ +@Data +public class OrganizationalLifeLineChartDTO implements Serializable { + + private static final long serialVersionUID = -4224453421929580053L; + + /** + * 月份 + */ + private String month; + + /** + * 组织活动次数 + */ + private Integer organizationalActCount; + + /** + * 应参加活动次数 + */ + private Integer shouldJoinActCount; + + /** + * 活动签到次数 + */ + private Integer actSignCount; + + public OrganizationalLifeLineChartDTO() { + this.month = ""; + this.organizationalActCount = NumConstant.ZERO; + this.shouldJoinActCount = NumConstant.ZERO; + this.actSignCount = NumConstant.ZERO; + } +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/form/CommentFormDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/form/CommentFormDTO.java index 92fce732ae..8d3cbbcbe1 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/form/CommentFormDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/form/CommentFormDTO.java @@ -1,11 +1,13 @@ package com.epmet.resi.group.dto.act.form; import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import com.epmet.resi.group.dto.notice.form.NoticeFileDTO; import lombok.Data; import org.hibernate.validator.constraints.Length; import javax.validation.constraints.NotBlank; import java.io.Serializable; +import java.util.List; /** * 005、评论活动 @@ -27,6 +29,10 @@ public class CommentFormDTO implements Serializable { @NotBlank(message = "评论内容不能为空", groups = AddUserShowGroup.class) @Length(max = 500, message = "评论内容最多输入500字", groups = AddUserShowGroup.class) private String commentContent; + /** + * 图片附件集合 + */ + private List imageList; /** * 当前用户id diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/form/OrganizationalLifeFormDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/form/OrganizationalLifeFormDTO.java new file mode 100644 index 0000000000..3e515c2c75 --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/form/OrganizationalLifeFormDTO.java @@ -0,0 +1,22 @@ +package com.epmet.resi.group.dto.act.form; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2021/9/3 2:52 下午 + * @DESC + */ +@Data +public class OrganizationalLifeFormDTO implements Serializable { + + private static final long serialVersionUID = -8611679719504666547L; + + private String yearId; + + private String userId; + + private String customerId; +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/result/CommentResultDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/result/CommentResultDTO.java index efb8066f28..a6053ffc39 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/result/CommentResultDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/result/CommentResultDTO.java @@ -1,10 +1,13 @@ package com.epmet.resi.group.dto.act.result; +import com.epmet.resi.group.dto.group.result.CommentFileDTO; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import java.io.Serializable; +import java.util.ArrayList; import java.util.Date; +import java.util.List; /** * 006、活动评论列表查询 @@ -27,4 +30,11 @@ public class CommentResultDTO implements Serializable { private Date commentTime; private String commentUserId; + + /** + * 图片附件集合 + */ + private List imageList = new ArrayList<>(); + + } diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/result/OrganizationalLifeResultDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/result/OrganizationalLifeResultDTO.java new file mode 100644 index 0000000000..e68cbd02be --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/result/OrganizationalLifeResultDTO.java @@ -0,0 +1,47 @@ +package com.epmet.resi.group.dto.act.result; + +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.resi.group.dto.act.OrganizationalLifeLineChartDTO; +import lombok.Data; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * @Author zxc + * @DateTime 2021/9/3 2:35 下午 + * @DESC + */ +@Data +public class OrganizationalLifeResultDTO implements Serializable { + + private static final long serialVersionUID = 6991638491754890967L; + + /** + * 组织活动次数 + */ + private Integer organizationalActCount; + + /** + * 应参加活动次数 + */ + private Integer shouldJoinActCount; + + /** + * 活动签到次数 + */ + private Integer actSignCount; + + /** + * 折线图 + */ + private List lineChart; + + public OrganizationalLifeResultDTO() { + this.organizationalActCount = NumConstant.ZERO; + this.shouldJoinActCount = NumConstant.ZERO; + this.actSignCount = NumConstant.ZERO; + this.lineChart = new ArrayList<>(); + } +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/comment/result/ResiCommentResultDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/comment/result/ResiCommentResultDTO.java index c28985e054..57ae73c471 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/comment/result/ResiCommentResultDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/comment/result/ResiCommentResultDTO.java @@ -1,11 +1,14 @@ package com.epmet.resi.group.dto.comment.result; import com.alibaba.fastjson.annotation.JSONField; +import com.epmet.resi.group.dto.group.result.CommentFileDTO; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; import java.io.Serializable; +import java.util.ArrayList; import java.util.Date; +import java.util.List; /** * @Description @@ -54,4 +57,9 @@ public class ResiCommentResultDTO implements Serializable { * 评论状态 * */ private String commentStatus; + + /** + * 图片附件集合 + */ + private List imageList = new ArrayList<>(); } diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/GroupFormDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/GroupFormDTO.java index 2fc8ba7b9a..96295879f1 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/GroupFormDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/GroupFormDTO.java @@ -1,8 +1,10 @@ package com.epmet.resi.group.dto.group.form; +import com.epmet.resi.group.enums.SearchScopeTypeEnum; import lombok.Data; - +import javax.validation.constraints.NotNull; import java.io.Serializable; +import java.util.List; /** * @author zhaoqifeng @@ -11,7 +13,77 @@ import java.io.Serializable; */ @Data public class GroupFormDTO implements Serializable { + private static final long serialVersionUID = 5330629771935235995L; + + /** 排除某些指定id之外的组列表 */ + public interface GroupDetailsExcludeGroupIds {} + private String groupId; + private String gridId; + + /** 小组所属范围:grid网格,customer客户 */ + @NotNull(message = "搜索范围类型不能为空", groups = { GroupDetailsExcludeGroupIds.class }) + private SearchScopeTypeEnum searchScopeType; + + @NotNull(message = "搜索范围对象的ID不能为空", groups = { GroupDetailsExcludeGroupIds.class }) + private String searchScopeObjectId; + + private List excludeGroupIds; + + /** 从第几条开始取 */ + private Integer startRow = 0; + + /** 取几条数据 */ + private Integer rowCount = 10; + + @NotNull(message = "排序字段不能为空", groups = { GroupDetailsExcludeGroupIds.class }) + private SortTypeEnum sort; + + @NotNull(message = "排序方式不能为空", groups = { GroupDetailsExcludeGroupIds.class }) + private OrderTypeEnum order; + + /** + * @Description 排序类型 + * @author wxz + * @date 2021.09.07 17:00:24 + */ + public enum SortTypeEnum { + + CREATE_TIME("create_time"); + + private String sortField; + + SortTypeEnum(String sortField) { + this.sortField = sortField; + } + + public String getSortField() { + return sortField; + } + } + + /** + * @Description 排序方式 + * @author wxz + * @date 2021.09.07 17:02:05 + */ + public enum OrderTypeEnum { + + ASC("asc"), + DESC("desc"); + + private String orderType; + + OrderTypeEnum(String orderType) { + this.orderType = orderType; + } + + public String getOrderType() { + return orderType; + } + } + + } diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/AllGroupListResultDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/AllGroupListResultDTO.java index d31e01cab8..3ddbd344d2 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/AllGroupListResultDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/AllGroupListResultDTO.java @@ -47,4 +47,8 @@ public class AllGroupListResultDTO implements Serializable { */ private String groupType; + /** + * 群介绍 + */ + private String groupIntroduction = ""; } diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/CommentFileDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/CommentFileDTO.java new file mode 100644 index 0000000000..dfec88238a --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/CommentFileDTO.java @@ -0,0 +1,28 @@ +package com.epmet.resi.group.dto.group.result; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @Author sun + * @Description 话题、通知、活动评论附件 + */ +@NoArgsConstructor +@Data +public class CommentFileDTO implements Serializable { + + private static final long serialVersionUID = -3930520724652521552L; + private String name; + private String url; + private String type; + private String format; + private Integer size; + private Integer duration; + @JsonIgnore + private String commentId; + @JsonIgnore + private String userId; +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupDetailResultDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupDetailResultDTO.java index c7767054d4..93247725a4 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupDetailResultDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupDetailResultDTO.java @@ -9,7 +9,9 @@ import lombok.NoArgsConstructor; @AllArgsConstructor public class GroupDetailResultDTO { + private String gridId; private String groupHeadPhoto; + private String groupId; private String groupName; private String groupIntroduction; private Integer editNumLimit; @@ -17,5 +19,7 @@ public class GroupDetailResultDTO { private String auditStatus; private Boolean editable; private String remark; + /** 群组类型:branch:支部小组,ordinary:楼院小组 */ + private String groupType; } diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupSummarizeResultDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupSummarizeResultDTO.java index dbf681b90d..28755fffe8 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupSummarizeResultDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupSummarizeResultDTO.java @@ -69,6 +69,14 @@ public class GroupSummarizeResultDTO implements Serializable { * 进组审核open开启;close关闭 */ private String auditSwitch; + /** + * 小组类型(ordinary:楼院小组 branch:支部小组) + */ + private String groupType; + /** + * 小组类型名称 + */ + private String groupTypeName; private String level; public GroupSummarizeResultDTO(){ diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/RecommendGroupResultDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/RecommendGroupResultDTO.java index 72de523d2a..ff080a5864 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/RecommendGroupResultDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/RecommendGroupResultDTO.java @@ -48,4 +48,9 @@ public class RecommendGroupResultDTO implements Serializable { */ private String groupType; + /** + * 群介绍 + */ + private String groupIntroduction = ""; + } diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/RecommendedListResultDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/RecommendedListResultDTO.java index 47fbf7d9be..4e9834470a 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/RecommendedListResultDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/RecommendedListResultDTO.java @@ -37,4 +37,9 @@ public class RecommendedListResultDTO implements Serializable { * 组长名 */ private String leaderName; + + /** + * 群介绍 + */ + private String groupIntroduction = ""; } diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/notice/NoticeCommentAttachmentDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/notice/NoticeCommentAttachmentDTO.java new file mode 100644 index 0000000000..6e7c7e336f --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/notice/NoticeCommentAttachmentDTO.java @@ -0,0 +1,126 @@ +/** + * 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.resi.group.dto.notice; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 通知评论附件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-06 + */ +@Data +public class NoticeCommentAttachmentDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 客户ID + */ + private String customerId; + + /** + * 通知Id + */ + private String noticeId; + + /** + * 评论Id + */ + private String noticeCommentId; + + /** + * 文件名 + */ + private String fileName; + + /** + * 附件名(uuid随机生成) + */ + private String attachmentName; + + /** + * 文件大小,单位b + */ + private Integer attachmentSize; + + /** + * 文件格式(JPG、PNG、PDF、JPEG、BMP、MP4、WMA、M4A、MP3、DOC、DOCX、XLS) + */ + private String attachmentFormat; + + /** + * 附件类型((图片 - image、 视频 - video、 语音 - voice、 文档 - doc)) + */ + private String attachmentType; + + /** + * 附件地址 + */ + private String attachmentUrl; + + /** + * 排序字段 + */ + private Integer sort; + + /** + * 语音或视频时长,秒 + */ + private Integer duration; + + /** + * 删除标记 0:未删除,1:已删除 + */ + private String delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/notice/form/NoticeCommentFormDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/notice/form/NoticeCommentFormDTO.java index c543bf7222..f6d7488bb4 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/notice/form/NoticeCommentFormDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/notice/form/NoticeCommentFormDTO.java @@ -5,6 +5,7 @@ import lombok.Data; import org.hibernate.validator.constraints.Length; import javax.validation.constraints.NotBlank; +import java.util.List; /** * @Author sun @@ -22,7 +23,7 @@ public class NoticeCommentFormDTO { * 评论内容300 */ @NotBlank(message = "评论内容不能为空",groups = {NoticeCommentFormDTO.UserShow.class}) - @Length(max = 20, message = "评论内容不能超过300个字符",groups = {NoticeCommentFormDTO.UserShow.class}) + @Length(max = 300, message = "评论内容不能超过300个字符",groups = {NoticeCommentFormDTO.UserShow.class}) private String commentContent; /** @@ -30,6 +31,11 @@ public class NoticeCommentFormDTO { */ private String userId; + /** + * 图片附件集合 + */ + private List imageList; + public interface Comment{} public interface UserShow extends CustomerClientShowGroup {} } diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/notice/result/NoticeCommentListResultDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/notice/result/NoticeCommentListResultDTO.java index 726289e144..45a9c9f694 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/notice/result/NoticeCommentListResultDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/notice/result/NoticeCommentListResultDTO.java @@ -1,11 +1,13 @@ package com.epmet.resi.group.dto.notice.result; -import com.alibaba.fastjson.annotation.JSONField; +import com.epmet.resi.group.dto.group.result.CommentFileDTO; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import java.io.Serializable; +import java.util.ArrayList; import java.util.Date; +import java.util.List; /** * @Author sun @@ -42,4 +44,9 @@ public class NoticeCommentListResultDTO implements Serializable { * */ private String userId; + /** + * 图片附件集合 + */ + private List imageList = new ArrayList<>(); + } diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/ResiTopicCommentAttachmentDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/ResiTopicCommentAttachmentDTO.java new file mode 100644 index 0000000000..acd1c4e381 --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/ResiTopicCommentAttachmentDTO.java @@ -0,0 +1,126 @@ +/** + * 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.resi.group.dto.topic; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 话题评论附件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-06 + */ +@Data +public class ResiTopicCommentAttachmentDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 客户ID + */ + private String customerId; + + /** + * 话题Id + */ + private String topicId; + + /** + * 评论Id + */ + private String topicCommentId; + + /** + * 文件名 + */ + private String fileName; + + /** + * 附件名(uuid随机生成) + */ + private String attachmentName; + + /** + * 文件大小,单位b + */ + private Integer attachmentSize; + + /** + * 文件格式(JPG、PNG、PDF、JPEG、BMP、MP4、WMA、M4A、MP3、DOC、DOCX、XLS) + */ + private String attachmentFormat; + + /** + * 附件类型((图片 - image、 视频 - video、 语音 - voice、 文档 - doc)) + */ + private String attachmentType; + + /** + * 附件地址 + */ + private String attachmentUrl; + + /** + * 排序字段 + */ + private Integer sort; + + /** + * 语音或视频时长,秒 + */ + private Integer duration; + + /** + * 删除标记 0:未删除,1:已删除 + */ + private String delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/form/ResiPublishCommentFormDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/form/ResiPublishCommentFormDTO.java index 894364fe16..9e8b7338cd 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/form/ResiPublishCommentFormDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/topic/form/ResiPublishCommentFormDTO.java @@ -1,9 +1,11 @@ package com.epmet.resi.group.dto.topic.form; +import com.epmet.resi.group.dto.notice.form.NoticeFileDTO; import lombok.Data; import javax.validation.constraints.NotBlank; import java.io.Serializable; +import java.util.List; /** * @Description @@ -21,4 +23,9 @@ public class ResiPublishCommentFormDTO implements Serializable { @NotBlank(message = "评论内容不能为空") private String commentContent; + + /** + * 图片附件集合 + */ + private List imageList; } diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/enums/SearchScopeTypeEnum.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/enums/SearchScopeTypeEnum.java new file mode 100644 index 0000000000..474a2662a1 --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/enums/SearchScopeTypeEnum.java @@ -0,0 +1,22 @@ +package com.epmet.resi.group.enums; + +/** + * @Description 搜索范围类型枚举 + * @author wxz + * @date 2021.09.07 20:14:21 + */ +public enum SearchScopeTypeEnum { + + CUSTOMER("customer"), + GRID("grid"); + + private String scopeType; + + SearchScopeTypeEnum(String scopeType) { + this.scopeType = scopeType; + } + + public String getScopeType() { + return scopeType; + } +} \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/ResiGroupOpenFeignClient.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/ResiGroupOpenFeignClient.java index c7f815fce0..5f92693338 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/ResiGroupOpenFeignClient.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/ResiGroupOpenFeignClient.java @@ -289,4 +289,26 @@ public interface ResiGroupOpenFeignClient { */ @PostMapping("/resi/group/topic/get-topicdetail-byid/batch") Result> listTopicDetailsByIds(TopicDetailBatchFormDTO input); + /** + * @description 根据组id列表批量查询组信息列表 + * + * @param groupIds + * @return + * @author wxz + * @date 2021.09.07 15:33:58 + */ + @PostMapping("/resi/group/group/list-groupinfos-by-groupids") + Result> listGroupDetailsByGroupIds(@RequestBody List groupIds); + + /** + * @description 排除指定的组id之后,按照指定顺序取指定个数的组信息 + * + * @param form + * @return + * @author wxz + * @date 2021.09.07 17:15:55 + */ + @PostMapping("/resi/group/group/list-groupinfos-exclude-groupids") + Result> listGroupDetailsExcludeGroupIds(@RequestBody GroupFormDTO form); + } diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/fallback/ResiGroupOpenFeignClientFallback.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/fallback/ResiGroupOpenFeignClientFallback.java index 3e2369b147..23f2e25526 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/fallback/ResiGroupOpenFeignClientFallback.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/fallback/ResiGroupOpenFeignClientFallback.java @@ -232,4 +232,14 @@ public class ResiGroupOpenFeignClientFallback implements ResiGroupOpenFeignClien public Result> getTopicInfos(List issueIds) { return ModuleUtils.feignConError(ServiceConstant.RESI_GROUP_SERVER, "getTopicInfos", issueIds); } + + @Override + public Result> listGroupDetailsByGroupIds(List groupIds) { + return ModuleUtils.feignConError(ServiceConstant.RESI_GROUP_SERVER, "listGroupDetailsByGroupIds", groupIds); + } + + @Override + public Result> listGroupDetailsExcludeGroupIds(GroupFormDTO form) { + return ModuleUtils.feignConError(ServiceConstant.RESI_GROUP_SERVER, "listGroupDetailsExcludeGroupIds", form); + } } diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/controller/ActCommentAttachmentController.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/controller/ActCommentAttachmentController.java new file mode 100644 index 0000000000..e84a321e4b --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/controller/ActCommentAttachmentController.java @@ -0,0 +1,85 @@ +/** + * 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.modules.act.controller; + +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.modules.act.service.ActCommentAttachmentService; +import com.epmet.resi.group.dto.act.ActCommentAttachmentDTO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + + +/** + * 活动评论附件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-06 + */ +@RestController +@RequestMapping("actcommentattachment") +public class ActCommentAttachmentController { + + @Autowired + private ActCommentAttachmentService actCommentAttachmentService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = actCommentAttachmentService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + ActCommentAttachmentDTO data = actCommentAttachmentService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody ActCommentAttachmentDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + actCommentAttachmentService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody ActCommentAttachmentDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + actCommentAttachmentService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + actCommentAttachmentService.delete(ids); + return new Result(); + } + + +} \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/controller/GroupActInfoController.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/controller/GroupActInfoController.java index 4a1a973022..34fc73ec23 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/controller/GroupActInfoController.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/controller/GroupActInfoController.java @@ -27,6 +27,7 @@ import com.epmet.resi.group.dto.act.GroupActIdDTO; import com.epmet.resi.group.dto.act.form.*; import com.epmet.resi.group.dto.act.result.ActDetailByLinkResultDTO; import com.epmet.resi.group.dto.act.result.ActDetailResultDTO; +import com.epmet.resi.group.dto.act.result.OrganizationalLifeResultDTO; import com.epmet.resi.group.dto.notice.result.NoticeReadListResultDTO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; @@ -153,4 +154,16 @@ public class GroupActInfoController { return new Result(); } + /** + * @Description 组织生活 + * @Param formDTO + * @author zxc + * @date 2021/9/3 2:57 下午 + */ + @PostMapping("organizationallife") + public Result organizationalLife(@LoginUser TokenDto tokenDto, @RequestBody OrganizationalLifeFormDTO formDTO){ + formDTO.setUserId(tokenDto.getUserId()); + return new Result().ok(groupActInfoService.organizationalLife(formDTO)); + } + } \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/dao/ActCommentAttachmentDao.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/dao/ActCommentAttachmentDao.java new file mode 100644 index 0000000000..07f076a6f5 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/dao/ActCommentAttachmentDao.java @@ -0,0 +1,43 @@ +/** + * 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.modules.act.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.modules.act.entity.ActCommentAttachmentEntity; +import com.epmet.resi.group.dto.group.result.CommentFileDTO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 活动评论附件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-06 + */ +@Mapper +public interface ActCommentAttachmentDao extends BaseDao { + + /** + * @Author sun + * @Description 查询通知评论所有人员的附件信息 + **/ + List selectActComFile(@Param("groupActId") String groupActId); + +} \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/dao/GroupActInfoDao.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/dao/GroupActInfoDao.java index 85f243e608..c4082b67c9 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/dao/GroupActInfoDao.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/dao/GroupActInfoDao.java @@ -19,7 +19,13 @@ package com.epmet.modules.act.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.modules.act.entity.GroupActInfoEntity; +import com.epmet.resi.group.dto.act.OrganizationalLifeLineChartDTO; +import com.epmet.resi.group.dto.act.form.OrganizationalLifeFormDTO; +import com.epmet.resi.group.dto.act.result.OrganizationalLifeResultDTO; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 组织活动信息 @@ -29,5 +35,36 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface GroupActInfoDao extends BaseDao { - + + /** + * @Description 根据人查询支部小组,小组审核状态为 approved 的,小组类型为 branch 的,GROUP_LEADER_FLAG 为 leader 的,人员状态为 approved 的 + * @Param userId + * @Param leaderFlag 是否是组长标志 + * @author zxc + * @date 2021/9/3 3:48 下午 + */ + List selectBranchGroupByUserId(@Param("userId")String userId,@Param("leaderFlag")Boolean leaderFlag); + + /** + * @Description 按照yearId查询组织生活,组织活动次数、应参加活动次数、活动签到次数 + * @Param formDTO + * @Param groupIds + * @Param leaderFlag 是否是组长标志 + * @author zxc + * @date 2021/9/3 4:12 下午 + */ + OrganizationalLifeResultDTO selectOrgLife(@Param("userId")String userId, @Param("groupIds")List groupIds, + @Param("leaderFlag")Boolean leaderFlag,@Param("yearId")String yearId); + + /** + * @Description 组织生活折线图 + * @Param leaderGroupIds + * @Param memberGroupIds + * @Param yearId + * @author zxc + * @date 2021/9/6 10:24 上午 + */ + List selectLineChart(@Param("groupIds") List groupId,@Param("leaderFlag")Boolean leaderFlag, + @Param("yearId")String yearId); + } \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/entity/ActCommentAttachmentEntity.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/entity/ActCommentAttachmentEntity.java new file mode 100644 index 0000000000..1e290165ee --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/entity/ActCommentAttachmentEntity.java @@ -0,0 +1,93 @@ +/** + * 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.modules.act.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 活动评论附件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-06 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("act_comment_attachment") +public class ActCommentAttachmentEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户ID + */ + private String customerId; + + /** + * 活动Id[group_act_info.id] + */ + private String groupActId; + + /** + * 评论Id + */ + private String actCommentId; + + /** + * 文件名 + */ + private String fileName; + + /** + * 附件名(uuid随机生成) + */ + private String attachmentName; + + /** + * 文件大小,单位b + */ + private Integer attachmentSize; + + /** + * 文件格式(JPG、PNG、PDF、JPEG、BMP、MP4、WMA、M4A、MP3、DOC、DOCX、XLS) + */ + private String attachmentFormat; + + /** + * 附件类型((图片 - image、 视频 - video、 语音 - voice、 文档 - doc)) + */ + private String attachmentType; + + /** + * 附件地址 + */ + private String attachmentUrl; + + /** + * 排序字段 + */ + private Integer sort; + + /** + * 语音或视频时长,秒 + */ + private Integer duration; + +} diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/ActCommentAttachmentService.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/ActCommentAttachmentService.java new file mode 100644 index 0000000000..c1faff4a04 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/ActCommentAttachmentService.java @@ -0,0 +1,103 @@ +/** + * 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.modules.act.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.modules.act.entity.ActCommentAttachmentEntity; +import com.epmet.resi.group.dto.act.ActCommentAttachmentDTO; +import com.epmet.resi.group.dto.group.result.CommentFileDTO; + +import java.util.List; +import java.util.Map; + +/** + * 活动评论附件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-06 + */ +public interface ActCommentAttachmentService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2021-09-06 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2021-09-06 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return ActCommentAttachmentDTO + * @author generator + * @date 2021-09-06 + */ + ActCommentAttachmentDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2021-09-06 + */ + void save(ActCommentAttachmentDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2021-09-06 + */ + void update(ActCommentAttachmentDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2021-09-06 + */ + void delete(String[] ids); + + /** + * @Author sun + * @Description 查询活动评论所有人员的附件信息 + **/ + List getActComFile(String groupActId); + +} \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/GroupActInfoService.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/GroupActInfoService.java index b815bb7358..9ed4a2b015 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/GroupActInfoService.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/GroupActInfoService.java @@ -24,6 +24,7 @@ import com.epmet.resi.group.dto.act.GroupActInfoDTO; import com.epmet.resi.group.dto.act.form.*; import com.epmet.resi.group.dto.act.result.ActDetailByLinkResultDTO; import com.epmet.resi.group.dto.act.result.ActDetailResultDTO; +import com.epmet.resi.group.dto.act.result.OrganizationalLifeResultDTO; import com.epmet.resi.group.dto.notice.result.NoticeReadListResultDTO; /** @@ -89,4 +90,13 @@ public interface GroupActInfoService extends BaseService { * @return */ void closeAct(CloseGroupActFormDTO formDTO); + + /** + * @Description 组织生活 + * @Param formDTO + * @author zxc + * @date 2021/9/3 2:57 下午 + */ + OrganizationalLifeResultDTO organizationalLife(OrganizationalLifeFormDTO formDTO); + } \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/ActCommentAttachmentServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/ActCommentAttachmentServiceImpl.java new file mode 100644 index 0000000000..916cf5bdda --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/ActCommentAttachmentServiceImpl.java @@ -0,0 +1,110 @@ +/** + * 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.modules.act.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.modules.act.dao.ActCommentAttachmentDao; +import com.epmet.modules.act.entity.ActCommentAttachmentEntity; +import com.epmet.modules.act.service.ActCommentAttachmentService; +import com.epmet.resi.group.dto.act.ActCommentAttachmentDTO; +import com.epmet.resi.group.dto.group.result.CommentFileDTO; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 活动评论附件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-06 + */ +@Service +public class ActCommentAttachmentServiceImpl extends BaseServiceImpl implements ActCommentAttachmentService { + + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, ActCommentAttachmentDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, ActCommentAttachmentDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public ActCommentAttachmentDTO get(String id) { + ActCommentAttachmentEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, ActCommentAttachmentDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(ActCommentAttachmentDTO dto) { + ActCommentAttachmentEntity entity = ConvertUtils.sourceToTarget(dto, ActCommentAttachmentEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(ActCommentAttachmentDTO dto) { + ActCommentAttachmentEntity entity = ConvertUtils.sourceToTarget(dto, ActCommentAttachmentEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + /** + * @Author sun + * @Description 查询通知评论所有人员的附件信息 + **/ + @Override + public List getActComFile(String groupActId) { + return baseDao.selectActComFile(groupActId); + } + +} \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/ActCommentServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/ActCommentServiceImpl.java index c249c4ec28..a117db2b23 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/ActCommentServiceImpl.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/ActCommentServiceImpl.java @@ -18,6 +18,7 @@ package com.epmet.modules.act.service.impl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.scan.param.TextScanParamDTO; @@ -28,23 +29,31 @@ import com.epmet.commons.tools.utils.ScanContentUtils; import com.epmet.dto.result.UserBaseInfoResultDTO; import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.modules.act.dao.ActCommentDao; +import com.epmet.modules.act.entity.ActCommentAttachmentEntity; import com.epmet.modules.act.entity.ActCommentEntity; +import com.epmet.modules.act.service.ActCommentAttachmentService; import com.epmet.modules.act.service.ActCommentService; import com.epmet.modules.act.service.GroupActInfoService; import com.epmet.modules.constant.GroupActConstant; +import com.epmet.modules.notice.service.NoticeCommentService; import com.epmet.resi.group.dto.act.GroupActInfoDTO; import com.epmet.resi.group.dto.act.form.CommentFormDTO; import com.epmet.resi.group.dto.act.form.CommentQueryFormDTO; import com.epmet.resi.group.dto.act.result.CommentResultDTO; +import com.epmet.resi.group.dto.group.result.CommentFileDTO; +import com.epmet.resi.group.dto.notice.form.NoticeFileDTO; import com.github.pagehelper.PageHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.UUID; +import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; /** @@ -65,6 +74,10 @@ public class ActCommentServiceImpl extends BaseServiceImpl imageList = formDTO.getImageList().stream().map(NoticeFileDTO::getUrl).collect(Collectors.toList()); + noticeCommentService.safetyCheck(new ArrayList<>(), imageList); + //3、插入记录 ActCommentEntity actCommentEntity = new ActCommentEntity(); actCommentEntity.setCustomerId(formDTO.getCustomerId()); @@ -103,6 +121,33 @@ public class ActCommentServiceImpl extends BaseServiceImpl AttachmentEntityList = new ArrayList<>(); + //图片 + if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(formDTO.getImageList())) { + AtomicInteger sort = new AtomicInteger(); + formDTO.getImageList().forEach(img -> { + ActCommentAttachmentEntity attachment = new ActCommentAttachmentEntity(); + attachment.setCustomerId(formDTO.getCustomerId()); + attachment.setGroupActId(formDTO.getGroupActId()); + attachment.setActCommentId(actCommentEntity.getId()); + attachment.setFileName(img.getName()); + attachment.setAttachmentName(""); + attachment.setAttachmentSize(img.getSize()); + attachment.setAttachmentFormat(img.getFormat()); + attachment.setAttachmentType(img.getType()); + attachment.setAttachmentUrl(img.getUrl()); + attachment.setSort(sort.get()); + attachment.setDuration(img.getDuration()); + sort.getAndIncrement(); + AttachmentEntityList.add(attachment); + }); + } + if (AttachmentEntityList.size() > NumConstant.ZERO) { + actCommentAttachmentService.insertBatch(AttachmentEntityList); + } + } /** @@ -124,8 +169,12 @@ public class ActCommentServiceImpl extends BaseServiceImpl fileList = actCommentAttachmentService.getActComFile(formDTO.getGroupActId()); + if (!CollectionUtils.isEmpty(result.getData())) { - //3.遍历封装数据并返回 + //4.遍历封装数据并返回 list.forEach(l -> { result.getData().forEach(user -> { if (l.getCommentUserId().equals(user.getUserId())) { @@ -133,6 +182,14 @@ public class ActCommentServiceImpl extends BaseServiceImpl imageList = new ArrayList<>(); + for (CommentFileDTO f : fileList) { + if (l.getCommentId().equals(f.getCommentId()) && l.getCommentUserId().equals(f.getUserId())) { + imageList.add(f); + } + } + l.setImageList(imageList); }); } diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/GroupActInfoServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/GroupActInfoServiceImpl.java index 48334bac4e..41e77cee6a 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/GroupActInfoServiceImpl.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/GroupActInfoServiceImpl.java @@ -58,9 +58,11 @@ import com.epmet.modules.invitation.service.InvitationRecordService; import com.epmet.modules.member.service.ResiGroupMemberService; import com.epmet.resi.group.dto.act.GroupActIdDTO; import com.epmet.resi.group.dto.act.GroupActInfoDTO; +import com.epmet.resi.group.dto.act.OrganizationalLifeLineChartDTO; import com.epmet.resi.group.dto.act.form.*; import com.epmet.resi.group.dto.act.result.ActDetailByLinkResultDTO; import com.epmet.resi.group.dto.act.result.ActDetailResultDTO; +import com.epmet.resi.group.dto.act.result.OrganizationalLifeResultDTO; import com.epmet.resi.group.dto.group.GroupMessageDTO; import com.epmet.resi.group.dto.group.ResiGroupDTO; import com.epmet.resi.group.dto.invitation.InvitationRecordDTO; @@ -75,6 +77,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; +import java.time.LocalDate; import java.util.*; import java.util.stream.Collectors; @@ -862,4 +865,85 @@ public class GroupActInfoServiceImpl extends BaseServiceImpl leaderGroupIds = baseDao.selectBranchGroupByUserId(formDTO.getUserId(),true); + List chartResult = new ArrayList<>(); + if (!CollectionUtils.isEmpty(leaderGroupIds)){ + // 按照yearId查询组织生活【我创建的活动】,组织活动次数、应参加活动次数、活动签到次数 + OrganizationalLifeResultDTO dto = baseDao.selectOrgLife(formDTO.getUserId(), leaderGroupIds,true,formDTO.getYearId()); + result.setOrganizationalActCount(dto.getOrganizationalActCount()); + result.setActSignCount(dto.getActSignCount()); + // 当此人是组长,创建了几个活动就应参加几个活动 + result.setShouldJoinActCount(dto.getOrganizationalActCount()); + List chartDTOS = baseDao.selectLineChart(leaderGroupIds, true, formDTO.getYearId()); + if (!CollectionUtils.isEmpty(chartDTOS)){ + chartResult.addAll(chartDTOS); + } + } + // 查询此人不是组长,客户下所有支部小组 + List memberGroupIds = baseDao.selectBranchGroupByUserId(formDTO.getUserId(),false); + if (!CollectionUtils.isEmpty(memberGroupIds)){ + // 按照yearId查询组织生活【我所在支部组的活动】,组织活动次数、应参加活动次数、活动签到次数 + OrganizationalLifeResultDTO dto = baseDao.selectOrgLife(formDTO.getUserId(), memberGroupIds,false, formDTO.getYearId()); + result.setActSignCount(result.getActSignCount() + dto.getActSignCount()); + // 当此人不是组长,支部小组下有几个活动,应参加活动就是几 + result.setShouldJoinActCount(result.getShouldJoinActCount() + dto.getOrganizationalActCount()); + // 此人不是组长,我组织的活动这就不加了 + + List chartDTOS = baseDao.selectLineChart(memberGroupIds, false, formDTO.getYearId()); + if (!CollectionUtils.isEmpty(chartDTOS)){ + chartResult.addAll(chartDTOS); + } + } + // 折线图组装 + List lineChart = lineChart(); + if (!CollectionUtils.isEmpty(chartResult)){ + Map> groupByMonth = chartResult.stream().collect(Collectors.groupingBy(OrganizationalLifeLineChartDTO::getMonth)); + groupByMonth.forEach((month,list) -> { + lineChart.forEach(l -> { + if (month.equals(l.getMonth())){ + l.setOrganizationalActCount(list.stream().collect(Collectors.summingInt(OrganizationalLifeLineChartDTO::getOrganizationalActCount))); + l.setShouldJoinActCount(list.stream().collect(Collectors.summingInt(OrganizationalLifeLineChartDTO::getShouldJoinActCount))); + l.setActSignCount(list.stream().collect(Collectors.summingInt(OrganizationalLifeLineChartDTO::getActSignCount))); + } + }); + }); + } + result.setLineChart(lineChart); + return result; + } + + /** + * @Description 折线图构造 + * @author zxc + * @date 2021/9/6 10:55 上午 + */ + public List lineChart(){ + List lineChart = new ArrayList<>(); + for (int i = NumConstant.ONE; i <= NumConstant.TWELVE; i++) { + OrganizationalLifeLineChartDTO dto = new OrganizationalLifeLineChartDTO(); + if (i < NumConstant.TEN){ + dto.setMonth(NumConstant.ZERO + String.valueOf(i) + "月"); + }else { + dto.setMonth(String.valueOf(i) + "月"); + } + lineChart.add(dto); + } + return lineChart; + } + } \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/constant/UserMessageConstant.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/constant/UserMessageConstant.java index 86cb1a6ff2..831109fc67 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/constant/UserMessageConstant.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/constant/UserMessageConstant.java @@ -29,6 +29,7 @@ public interface UserMessageConstant { */ String INVITED_JOIN_GROUP = "您的好友-【%s】通过邀请连接,加入了【%s】"; String SCANCODE_JOIN_GROUP = "您的好友-【%s】通过扫描二维码,加入了【%s】"; + String SHARABLELINK_JOIN_GROUP = "您的好友-【%s】通过分享链接,加入了【%s】"; /** * 组成员被禁言时会收到消息:您已被禁言,禁言时间2020.03.20 12:20-2020.03.27 12:20 diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java index b577681ef7..e11508dc36 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java @@ -33,6 +33,7 @@ import com.epmet.resi.group.dto.group.result.*; import com.epmet.resi.group.dto.member.form.EditAuditSwitchFormDTO; import com.epmet.resi.group.dto.member.form.ResiIdentityFormDTO; import com.epmet.resi.group.dto.member.result.AchievementResultDTO; +import com.epmet.resi.group.enums.SearchScopeTypeEnum; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.PostMapping; @@ -598,4 +599,41 @@ public class ResiGroupController { public Result initAchievement(@RequestParam String customerId) { return new Result().ok(statsAchievementService.initAllGroupAchievement(customerId)); } + + /** + * @description 根据组id列表批量查询组信息列表 + * + * @param groupIds + * @return + * @author wxz + * @date 2021.09.07 15:33:58 + */ + @PostMapping("list-groupinfos-by-groupids") + public Result> listGroupDetailsByGroupIds(@RequestBody List groupIds) { + List groupDetails = resiGroupService.listGroupsByGroupIds(groupIds); + return new Result>().ok(groupDetails); + } + + /** + * @description 排除指定的组id之后,按照指定顺序取指定个数的组信息 + * + * @param form + * @return + * @author wxz + * @date 2021.09.07 17:15:55 + */ + @PostMapping("list-groupinfos-exclude-groupids") + public Result> listGroupDetailsExcludeGroupIds(@RequestBody GroupFormDTO form) { + ValidatorUtils.validateEntity(form, GroupFormDTO.GroupDetailsExcludeGroupIds.class); + Integer startRow = form.getStartRow(); + Integer rowCount = form.getRowCount(); + List excludeGroupIds = form.getExcludeGroupIds(); + GroupFormDTO.SortTypeEnum sort = form.getSort(); + GroupFormDTO.OrderTypeEnum order = form.getOrder(); + SearchScopeTypeEnum searchScopeType = form.getSearchScopeType(); + String searchScopeObjectId = form.getSearchScopeObjectId(); + + List groups = resiGroupService.listGroupDetailsExcludeGroupIds(excludeGroupIds, startRow, rowCount, searchScopeType.getScopeType(), searchScopeObjectId, sort.getSortField(), order.getOrderType()); + return new Result>().ok(groups); + } } diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupService.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupService.java index d7761738d8..eed7a355e6 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupService.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupService.java @@ -435,4 +435,30 @@ public interface ResiGroupService extends BaseService { * @return com.epmet.resi.group.dto.group.ResiGroupDTO */ ResiGroupDTO getGroupInfoAndGroupMember(String groupId); + + /** + * @description 根据id列表查询组信息 + * + * @param groupIds + * @return + * @author wxz + * @date 2021.09.07 15:27:35 + */ + List listGroupsByGroupIds(List groupIds); + + /** + * @description 排除指定的组id之后,按照指定顺序取指定个数的组信息 + * + * @param excludeGroupIds 排序的组id列表 + * @param startRow + * @param rowCount + * @param searchScopeObjectId 小组所属的范围对象id,如果是网格,那就是网格id,如果是客户那就是客户id + * @param searchScopeType 小组所属的范围,grid网格,customer客户 + * @param sortType 排序字段 + * @param orderType 排序类型 + * @return + * @author wxz + * @date 2021.09.07 17:17:09 + */ + List listGroupDetailsExcludeGroupIds(List excludeGroupIds, Integer startRow, Integer rowCount, String searchScopeType,String searchScopeObjectId, String sortType, String orderType); } diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java index 6c451b0521..e7b21ba01c 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java @@ -18,8 +18,10 @@ package com.epmet.modules.group.service.impl; import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.rocketmq.messages.GroupAchievementMQMsg; import com.epmet.commons.tools.constant.*; @@ -80,8 +82,11 @@ import com.epmet.resi.group.dto.member.ResiGroupMemberInfoRedisDTO; import com.epmet.resi.group.dto.member.form.EditAuditSwitchFormDTO; import com.epmet.resi.group.dto.member.result.AchievementResultDTO; import com.epmet.resi.group.dto.member.result.GroupAchievementDTO; +import com.epmet.resi.group.enums.SearchScopeTypeEnum; import com.epmet.send.SendMqMsgUtil; +import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; +import kotlin.jvm.internal.Lambda; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; @@ -1773,4 +1778,60 @@ public class ResiGroupServiceImpl extends BaseServiceImpl listGroupsByGroupIds(List groupIds) { + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.in(ResiGroupEntity::getId, groupIds); + query.orderByDesc(ResiGroupEntity::getCreatedTime); + query.eq(ResiGroupEntity::getDelFlag, 0); + List groupEntities = baseDao.selectList(query); + List groupDtos = groupEntities.stream().map(ge -> { + GroupDetailResultDTO dto = new GroupDetailResultDTO(); + dto.setGroupId(ge.getId()); + dto.setGroupName(ge.getGroupName()); + dto.setGroupHeadPhoto(ge.getGroupHeadPhoto()); + dto.setGroupIntroduction(ge.getGroupIntroduction()); + dto.setGroupType(ge.getGroupType()); + return dto; + }).collect(Collectors.toList()); + return groupDtos; + } + + @Override + public List listGroupDetailsExcludeGroupIds(List excludeGroupIds, Integer startRow, Integer rowCount, String searchScopeType, String searchScopeObjectId, String sortType, String orderType) { + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + if (CollectionUtils.isNotEmpty(excludeGroupIds)) { + query.notIn(ResiGroupEntity::getId, excludeGroupIds); + } + // 利用pagehelper计算起始条数 + query.last(String.format("limit %s, %s", startRow, rowCount)); + + SFunction sortFieldFun = null; + if (GroupFormDTO.SortTypeEnum.CREATE_TIME.getSortField().equals(sortType)) { + sortFieldFun = ResiGroupEntity::getCreatedTime; + } + + if (SearchScopeTypeEnum.GRID.getScopeType().equals(searchScopeType)) { + query.eq(ResiGroupEntity::getGridId, searchScopeObjectId); + } else if (SearchScopeTypeEnum.CUSTOMER.getScopeType().equals(searchScopeType)) { + query.eq(ResiGroupEntity::getCustomerId, searchScopeObjectId); + } + + if (GroupFormDTO.OrderTypeEnum.ASC.getOrderType().equals(orderType)) { + query.orderByAsc(sortFieldFun); + } else { + query.orderByDesc(sortFieldFun); + } + List groupList = baseDao.selectList(query); + return groupList.stream().map(ge -> { + GroupDetailResultDTO dto = new GroupDetailResultDTO(); + dto.setGroupId(ge.getId()); + dto.setGroupName(ge.getGroupName()); + dto.setGroupHeadPhoto(ge.getGroupHeadPhoto()); + dto.setGroupIntroduction(ge.getGroupIntroduction()); + dto.setGroupType(ge.getGroupType()); + dto.setGridId(ge.getGridId()); + return dto; + }).collect(Collectors.toList()); + } } diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/invitation/service/GroupInvitationService.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/invitation/service/GroupInvitationService.java index 4c8897c5f1..8577aa2bd9 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/invitation/service/GroupInvitationService.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/invitation/service/GroupInvitationService.java @@ -21,7 +21,7 @@ import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.Result; import com.epmet.modules.invitation.entity.GroupInvitationEntity; -import com.epmet.resi.group.dto.UserRoleDTO; +import com.epmet.resi.group.dto.group.ResiGroupDTO; import com.epmet.resi.group.dto.invitation.GroupInvitationDTO; import com.epmet.resi.group.dto.invitation.form.AccetInvitationFormDTO; import com.epmet.resi.group.dto.invitation.form.CreateGroupInvitationFormDTO; @@ -143,4 +143,11 @@ public interface GroupInvitationService extends BaseService page(Map params) { @@ -434,7 +434,11 @@ public class GroupMemeberOperationServiceImpl extends BaseServiceImpl + * 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.modules.notice.controller; + +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.modules.notice.service.NoticeCommentAttachmentService; +import com.epmet.resi.group.dto.notice.NoticeCommentAttachmentDTO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + + +/** + * 通知评论附件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-06 + */ +@RestController +@RequestMapping("noticecommentattachment") +public class NoticeCommentAttachmentController { + + @Autowired + private NoticeCommentAttachmentService noticeCommentAttachmentService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = noticeCommentAttachmentService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + NoticeCommentAttachmentDTO data = noticeCommentAttachmentService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody NoticeCommentAttachmentDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + noticeCommentAttachmentService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody NoticeCommentAttachmentDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + noticeCommentAttachmentService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + noticeCommentAttachmentService.delete(ids); + return new Result(); + } + + +} \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/dao/NoticeCommentAttachmentDao.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/dao/NoticeCommentAttachmentDao.java new file mode 100644 index 0000000000..2ad57a60cd --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/dao/NoticeCommentAttachmentDao.java @@ -0,0 +1,43 @@ +/** + * 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.modules.notice.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.modules.notice.entity.NoticeCommentAttachmentEntity; +import com.epmet.resi.group.dto.group.result.CommentFileDTO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 通知评论附件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-06 + */ +@Mapper +public interface NoticeCommentAttachmentDao extends BaseDao { + + /** + * @Author sun + * @Description 查询通知评论所有人员的附件信息 + **/ + List selectNoticeComFile(@Param("noticeId") String noticeId); + +} \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/entity/NoticeCommentAttachmentEntity.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/entity/NoticeCommentAttachmentEntity.java new file mode 100644 index 0000000000..7ab97e6634 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/entity/NoticeCommentAttachmentEntity.java @@ -0,0 +1,93 @@ +/** + * 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.modules.notice.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 通知评论附件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-06 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("notice_comment_attachment") +public class NoticeCommentAttachmentEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户ID + */ + private String customerId; + + /** + * 通知Id + */ + private String noticeId; + + /** + * 评论Id + */ + private String noticeCommentId; + + /** + * 文件名 + */ + private String fileName; + + /** + * 附件名(uuid随机生成) + */ + private String attachmentName; + + /** + * 文件大小,单位b + */ + private Integer attachmentSize; + + /** + * 文件格式(JPG、PNG、PDF、JPEG、BMP、MP4、WMA、M4A、MP3、DOC、DOCX、XLS) + */ + private String attachmentFormat; + + /** + * 附件类型((图片 - image、 视频 - video、 语音 - voice、 文档 - doc)) + */ + private String attachmentType; + + /** + * 附件地址 + */ + private String attachmentUrl; + + /** + * 排序字段 + */ + private Integer sort; + + /** + * 语音或视频时长,秒 + */ + private Integer duration; + +} diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/NoticeCommentAttachmentService.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/NoticeCommentAttachmentService.java new file mode 100644 index 0000000000..5baa7d553d --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/NoticeCommentAttachmentService.java @@ -0,0 +1,103 @@ +/** + * 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.modules.notice.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.modules.notice.entity.NoticeCommentAttachmentEntity; +import com.epmet.resi.group.dto.group.result.CommentFileDTO; +import com.epmet.resi.group.dto.notice.NoticeCommentAttachmentDTO; + +import java.util.List; +import java.util.Map; + +/** + * 通知评论附件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-06 + */ +public interface NoticeCommentAttachmentService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2021-09-06 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2021-09-06 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return NoticeCommentAttachmentDTO + * @author generator + * @date 2021-09-06 + */ + NoticeCommentAttachmentDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2021-09-06 + */ + void save(NoticeCommentAttachmentDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2021-09-06 + */ + void update(NoticeCommentAttachmentDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2021-09-06 + */ + void delete(String[] ids); + + /** + * @Author sun + * @Description 查询通知评论所有人员的附件信息 + **/ + List getNoticeComFile(String noticeId); + +} \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/NoticeCommentService.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/NoticeCommentService.java index 0ac50c21e7..6684e61d80 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/NoticeCommentService.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/NoticeCommentService.java @@ -48,4 +48,11 @@ public interface NoticeCommentService extends BaseService { * @Description 通知评论列表查询 **/ List noticeCommentList(NoticeCommentListFormDTO formDTO); + + /** + * @Author sun + * @Description 文字、图片安全校验 + **/ + void safetyCheck(List wordList, List imageList); + } \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeCommentAttachmentServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeCommentAttachmentServiceImpl.java new file mode 100644 index 0000000000..10c3710894 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeCommentAttachmentServiceImpl.java @@ -0,0 +1,110 @@ +/** + * 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.modules.notice.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.modules.notice.dao.NoticeCommentAttachmentDao; +import com.epmet.modules.notice.entity.NoticeCommentAttachmentEntity; +import com.epmet.modules.notice.service.NoticeCommentAttachmentService; +import com.epmet.resi.group.dto.group.result.CommentFileDTO; +import com.epmet.resi.group.dto.notice.NoticeCommentAttachmentDTO; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 通知评论附件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-06 + */ +@Service +public class NoticeCommentAttachmentServiceImpl extends BaseServiceImpl implements NoticeCommentAttachmentService { + + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, NoticeCommentAttachmentDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, NoticeCommentAttachmentDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public NoticeCommentAttachmentDTO get(String id) { + NoticeCommentAttachmentEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, NoticeCommentAttachmentDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(NoticeCommentAttachmentDTO dto) { + NoticeCommentAttachmentEntity entity = ConvertUtils.sourceToTarget(dto, NoticeCommentAttachmentEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(NoticeCommentAttachmentDTO dto) { + NoticeCommentAttachmentEntity entity = ConvertUtils.sourceToTarget(dto, NoticeCommentAttachmentEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + /** + * @Author sun + * @Description 查询通知评论所有人员的附件信息 + **/ + @Override + public List getNoticeComFile(String noticeId) { + return baseDao.selectNoticeComFile(noticeId); + } + +} \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeCommentServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeCommentServiceImpl.java index 2ab3994891..0ab3dbbc09 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeCommentServiceImpl.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeCommentServiceImpl.java @@ -17,10 +17,13 @@ package com.epmet.modules.notice.service.impl; +import com.alibaba.fastjson.JSON; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.scan.param.ImgScanParamDTO; +import com.epmet.commons.tools.scan.param.ImgTaskDTO; import com.epmet.commons.tools.scan.param.TextScanParamDTO; import com.epmet.commons.tools.scan.param.TextTaskDTO; import com.epmet.commons.tools.scan.result.SyncScanResult; @@ -30,18 +33,23 @@ import com.epmet.dto.result.UserBaseInfoResultDTO; import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.modules.member.service.ResiGroupMemberService; import com.epmet.modules.notice.dao.NoticeCommentDao; +import com.epmet.modules.notice.entity.NoticeCommentAttachmentEntity; import com.epmet.modules.notice.entity.NoticeCommentEntity; import com.epmet.modules.notice.redis.NoticeCommentRedis; +import com.epmet.modules.notice.service.NoticeCommentAttachmentService; import com.epmet.modules.notice.service.NoticeCommentService; import com.epmet.modules.notice.service.NoticeService; import com.epmet.modules.utils.ModuleConstant; import com.epmet.resi.group.constant.MemberStateConstant; import com.epmet.resi.group.constant.TopicConstant; +import com.epmet.resi.group.dto.group.result.CommentFileDTO; import com.epmet.resi.group.dto.member.ResiGroupMemberDTO; import com.epmet.resi.group.dto.notice.NoticeDTO; import com.epmet.resi.group.dto.notice.form.NoticeCommentFormDTO; import com.epmet.resi.group.dto.notice.form.NoticeCommentListFormDTO; +import com.epmet.resi.group.dto.notice.form.NoticeFileDTO; import com.epmet.resi.group.dto.notice.result.NoticeCommentListResultDTO; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -53,6 +61,7 @@ import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; import java.util.UUID; +import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; /** @@ -70,12 +79,16 @@ public class NoticeCommentServiceImpl extends BaseServiceImpl imageList = formDTO.getImageList().stream().map(NoticeFileDTO::getUrl).collect(Collectors.toList()); + safetyCheck(new ArrayList<>(), imageList); //2.判断当前用户是否被禁言、移除、非本组成员 NoticeDTO notice = noticeService.get(formDTO.getNoticeId()); @@ -139,6 +155,33 @@ public class NoticeCommentServiceImpl extends BaseServiceImpl AttachmentEntityList = new ArrayList<>(); + //图片 + if (CollectionUtils.isNotEmpty(formDTO.getImageList())) { + AtomicInteger sort = new AtomicInteger(); + formDTO.getImageList().forEach(img -> { + NoticeCommentAttachmentEntity attachment = new NoticeCommentAttachmentEntity(); + attachment.setCustomerId(notice.getCustomerId()); + attachment.setNoticeId(formDTO.getNoticeId()); + attachment.setNoticeCommentId(entity.getId()); + attachment.setFileName(img.getName()); + attachment.setAttachmentName(""); + attachment.setAttachmentSize(img.getSize()); + attachment.setAttachmentFormat(img.getFormat()); + attachment.setAttachmentType(img.getType()); + attachment.setAttachmentUrl(img.getUrl()); + attachment.setSort(sort.get()); + attachment.setDuration(img.getDuration()); + sort.getAndIncrement(); + AttachmentEntityList.add(attachment); + }); + } + if (AttachmentEntityList.size() > NumConstant.ZERO) { + noticeCommentAttachmentService.insertBatch(AttachmentEntityList); + } + } /** @@ -165,7 +208,10 @@ public class NoticeCommentServiceImpl extends BaseServiceImpl resultDTOList = result.getData(); - //3.封装数据并返回 + //3.查询通知评论所有人员的附件信息 + List fileList = noticeCommentAttachmentService.getNoticeComFile(formDTO.getNoticeId()); + + //4.封装数据并返回 resultList.forEach(l -> { StringBuffer name = new StringBuffer(); resultDTOList.forEach(user -> { @@ -175,9 +221,64 @@ public class NoticeCommentServiceImpl extends BaseServiceImpl imageList = new ArrayList<>(); + for (CommentFileDTO f : fileList) { + if (l.getNoticeCommentId().equals(f.getCommentId()) && l.getUserId().equals(f.getUserId())) { + imageList.add(f); + } + } + l.setImageList(imageList); }); return resultList; } + /** + * @Author sun + * @Description 文字、图片安全校验 + **/ + public void safetyCheck(List wordList, List imageList) { + if (imageList.size() != NumConstant.ZERO) { + wordList.forEach(word -> { + //创建话题内容审核 + TextScanParamDTO textScanParamDTO = new TextScanParamDTO(); + TextTaskDTO taskDTO = new TextTaskDTO(); + taskDTO.setContent(word); + taskDTO.setDataId(UUID.randomUUID().toString().replace("-", "")); + textScanParamDTO.getTasks().add(taskDTO); + Result textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO); + if (!textSyncScanResult.success()) { + logger.error("safetyCheck textScan return failed,result:"+ JSON.toJSONString(textSyncScanResult)); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } else { + if (!textSyncScanResult.getData().isAllPass()) { + logger.warn(EpmetErrorCode.TEXT_SCAN_FAILED.getMsg().concat(String.format(TopicConstant.CREATE_TOPIC, word))); + throw new RenException(EpmetErrorCode.TEXT_SCAN_FAILED.getCode()); + } + } + }); + } + //创建话题图片审核 + if (imageList.size() != NumConstant.ZERO) { + ImgScanParamDTO imgScanParamDTO = new ImgScanParamDTO(); + imageList.forEach(url -> { + ImgTaskDTO task = new ImgTaskDTO(); + task.setDataId(UUID.randomUUID().toString().replace("-", "")); + task.setUrl(url); + imgScanParamDTO.getTasks().add(task); + }); + Result imgScanResult = ScanContentUtils.imgSyncScan(scanApiUrl.concat(imgSyncScanMethod), imgScanParamDTO); + if (!imgScanResult.success()) { + logger.error("safetyCheck imgScan return failed,result:"+ JSON.toJSONString(imgScanResult)); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } + if (!imgScanResult.getData().isAllPass()) { + logger.warn(EpmetErrorCode.IMG_SCAN_FAILED.getMsg()); + throw new RenException(EpmetErrorCode.IMG_SCAN_FAILED.getCode()); + } + + } + } + } \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeServiceImpl.java index b21c69a4ae..49f240ca3c 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeServiceImpl.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/notice/service/impl/NoticeServiceImpl.java @@ -503,7 +503,7 @@ public class NoticeServiceImpl extends BaseServiceImpl * @Description 文字、图片安全校验 **/ private void safetyCheck(List wordList, List imageList) { - if (imageList.size() != NumConstant.ZERO) { + if (wordList.size() != NumConstant.ZERO) { wordList.forEach(word -> { //创建话题内容审核 TextScanParamDTO textScanParamDTO = new TextScanParamDTO(); diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/controller/ResiTopicCommentAttachmentController.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/controller/ResiTopicCommentAttachmentController.java new file mode 100644 index 0000000000..9c5dd8f841 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/controller/ResiTopicCommentAttachmentController.java @@ -0,0 +1,85 @@ +/** + * 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.modules.topic.controller; + +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.modules.topic.service.ResiTopicCommentAttachmentService; +import com.epmet.resi.group.dto.topic.ResiTopicCommentAttachmentDTO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + + +/** + * 话题评论附件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-06 + */ +@RestController +@RequestMapping("resitopiccommentattachment") +public class ResiTopicCommentAttachmentController { + + @Autowired + private ResiTopicCommentAttachmentService resiTopicCommentAttachmentService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = resiTopicCommentAttachmentService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + ResiTopicCommentAttachmentDTO data = resiTopicCommentAttachmentService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody ResiTopicCommentAttachmentDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + resiTopicCommentAttachmentService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody ResiTopicCommentAttachmentDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + resiTopicCommentAttachmentService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + resiTopicCommentAttachmentService.delete(ids); + return new Result(); + } + + +} \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/dao/ResiTopicCommentAttachmentDao.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/dao/ResiTopicCommentAttachmentDao.java new file mode 100644 index 0000000000..ab917a7ba5 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/dao/ResiTopicCommentAttachmentDao.java @@ -0,0 +1,43 @@ +/** + * 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.modules.topic.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.modules.topic.entity.ResiTopicCommentAttachmentEntity; +import com.epmet.resi.group.dto.group.result.CommentFileDTO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 话题评论附件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-06 + */ +@Mapper +public interface ResiTopicCommentAttachmentDao extends BaseDao { + + /** + * @Author sun + * @Description 查询通知评论所有人员的附件信息 + **/ + List selectTopicComFile(@Param("topicId") String topicId); + +} \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/entity/ResiTopicCommentAttachmentEntity.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/entity/ResiTopicCommentAttachmentEntity.java new file mode 100644 index 0000000000..d4400a14df --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/entity/ResiTopicCommentAttachmentEntity.java @@ -0,0 +1,93 @@ +/** + * 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.modules.topic.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 话题评论附件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-06 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("resi_topic_comment_attachment") +public class ResiTopicCommentAttachmentEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户ID + */ + private String customerId; + + /** + * 话题Id + */ + private String topicId; + + /** + * 评论Id + */ + private String topicCommentId; + + /** + * 文件名 + */ + private String fileName; + + /** + * 附件名(uuid随机生成) + */ + private String attachmentName; + + /** + * 文件大小,单位b + */ + private Integer attachmentSize; + + /** + * 文件格式(JPG、PNG、PDF、JPEG、BMP、MP4、WMA、M4A、MP3、DOC、DOCX、XLS) + */ + private String attachmentFormat; + + /** + * 附件类型((图片 - image、 视频 - video、 语音 - voice、 文档 - doc)) + */ + private String attachmentType; + + /** + * 附件地址 + */ + private String attachmentUrl; + + /** + * 排序字段 + */ + private Integer sort; + + /** + * 语音或视频时长,秒 + */ + private Integer duration; + +} diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/ResiTopicCommentAttachmentService.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/ResiTopicCommentAttachmentService.java new file mode 100644 index 0000000000..d29f410d33 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/ResiTopicCommentAttachmentService.java @@ -0,0 +1,102 @@ +/** + * 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.modules.topic.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.modules.topic.entity.ResiTopicCommentAttachmentEntity; +import com.epmet.resi.group.dto.group.result.CommentFileDTO; +import com.epmet.resi.group.dto.topic.ResiTopicCommentAttachmentDTO; + +import java.util.List; +import java.util.Map; + +/** + * 话题评论附件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-06 + */ +public interface ResiTopicCommentAttachmentService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2021-09-06 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2021-09-06 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return ResiTopicCommentAttachmentDTO + * @author generator + * @date 2021-09-06 + */ + ResiTopicCommentAttachmentDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2021-09-06 + */ + void save(ResiTopicCommentAttachmentDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2021-09-06 + */ + void update(ResiTopicCommentAttachmentDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2021-09-06 + */ + void delete(String[] ids); + + /** + * @Author sun + * @Description 查询话题评论所有人员的附件信息 + **/ + List getTopicComFile(String topicId); +} \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicCommentAttachmentServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicCommentAttachmentServiceImpl.java new file mode 100644 index 0000000000..e44dd792da --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicCommentAttachmentServiceImpl.java @@ -0,0 +1,110 @@ +/** + * 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.modules.topic.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.modules.topic.dao.ResiTopicCommentAttachmentDao; +import com.epmet.modules.topic.entity.ResiTopicCommentAttachmentEntity; +import com.epmet.modules.topic.service.ResiTopicCommentAttachmentService; +import com.epmet.resi.group.dto.group.result.CommentFileDTO; +import com.epmet.resi.group.dto.topic.ResiTopicCommentAttachmentDTO; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 话题评论附件表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-06 + */ +@Service +public class ResiTopicCommentAttachmentServiceImpl extends BaseServiceImpl implements ResiTopicCommentAttachmentService { + + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, ResiTopicCommentAttachmentDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, ResiTopicCommentAttachmentDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public ResiTopicCommentAttachmentDTO get(String id) { + ResiTopicCommentAttachmentEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, ResiTopicCommentAttachmentDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(ResiTopicCommentAttachmentDTO dto) { + ResiTopicCommentAttachmentEntity entity = ConvertUtils.sourceToTarget(dto, ResiTopicCommentAttachmentEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(ResiTopicCommentAttachmentDTO dto) { + ResiTopicCommentAttachmentEntity entity = ConvertUtils.sourceToTarget(dto, ResiTopicCommentAttachmentEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + /** + * @Author sun + * @Description 查询通知评论所有人员的附件信息 + **/ + @Override + public List getTopicComFile(String topicId) { + return baseDao.selectTopicComFile(topicId); + } + +} \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicCommentServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicCommentServiceImpl.java index f648ec88ec..f51dddb12b 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicCommentServiceImpl.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicCommentServiceImpl.java @@ -55,8 +55,11 @@ import com.epmet.modules.group.redis.ResiGroupRedis; import com.epmet.modules.member.dao.ResiGroupMemberDao; import com.epmet.modules.member.redis.ResiGroupMemberRedis; import com.epmet.modules.member.service.ResiGroupMemberService; +import com.epmet.modules.notice.service.NoticeCommentService; import com.epmet.modules.topic.dao.ResiTopicCommentDao; import com.epmet.modules.topic.dao.ResiTopicDao; +import com.epmet.modules.topic.entity.ResiTopicCommentAttachmentEntity; +import com.epmet.modules.topic.service.ResiTopicCommentAttachmentService; import com.epmet.modules.topic.service.ResiTopicCommentService; import com.epmet.modules.topic.service.ResiTopicService; import com.epmet.modules.utils.ModuleConstant; @@ -65,10 +68,11 @@ import com.epmet.resi.group.constant.TopicConstant; import com.epmet.resi.group.dto.comment.form.ResiQueryCommentFormDTO; import com.epmet.resi.group.dto.comment.result.ResiCommentResultDTO; import com.epmet.resi.group.dto.group.ResiGroupInfoRedisDTO; -import com.epmet.resi.group.dto.group.ResiGroupDTO; +import com.epmet.resi.group.dto.group.result.CommentFileDTO; import com.epmet.resi.group.dto.member.ResiGroupMemberDTO; import com.epmet.resi.group.dto.member.ResiGroupMemberInfoRedisDTO; import com.epmet.resi.group.dto.member.result.ResiGroupMemberInfoRedisResultDTO; +import com.epmet.resi.group.dto.notice.form.NoticeFileDTO; import com.epmet.resi.group.dto.topic.ResiTopicCommentDTO; import com.epmet.resi.group.dto.topic.ResiTopicDTO; import com.epmet.resi.group.dto.topic.form.ResiPublishCommentFormDTO; @@ -76,6 +80,7 @@ import com.epmet.resi.group.dto.topic.result.IssueGridResultDTO; import com.epmet.resi.mine.dto.from.MyPartProjectsFormDTO; import com.google.common.base.CharMatcher; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -85,6 +90,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; /** @@ -99,32 +105,28 @@ public class ResiTopicCommentServiceImpl extends BaseServiceImpl imageList = resiCommentFormDTO.getImageList().stream().map(NoticeFileDTO::getUrl).collect(Collectors.toList()); + noticeCommentService.safetyCheck(new ArrayList<>(), imageList); + //1.判断当前用户是否被禁言 ResiTopicDTO topic = resiTopicService.get(resiCommentFormDTO.getTopicId()); if(null == topic){ @@ -314,6 +320,32 @@ public class ResiTopicCommentServiceImpl extends BaseServiceImpl AttachmentEntityList = new ArrayList<>(); + //图片 + if (CollectionUtils.isNotEmpty(resiCommentFormDTO.getImageList())) { + AtomicInteger sort = new AtomicInteger(); + resiCommentFormDTO.getImageList().forEach(img -> { + ResiTopicCommentAttachmentEntity attachment = new ResiTopicCommentAttachmentEntity(); + attachment.setCustomerId(comment.getCustomerId()); + attachment.setTopicId(resiCommentFormDTO.getTopicId()); + attachment.setTopicCommentId(comment.getId()); + attachment.setFileName(img.getName()); + attachment.setAttachmentName(""); + attachment.setAttachmentSize(img.getSize()); + attachment.setAttachmentFormat(img.getFormat()); + attachment.setAttachmentType(img.getType()); + attachment.setAttachmentUrl(img.getUrl()); + attachment.setSort(sort.get()); + attachment.setDuration(img.getDuration()); + sort.getAndIncrement(); + AttachmentEntityList.add(attachment); + }); + } + if (AttachmentEntityList.size() > NumConstant.ZERO) { + resiTopicCommentAttachmentService.insertBatch(AttachmentEntityList); + } + //对所有关注这个话题的人发送微信订阅 resiTopicService.sendWxmpUpdateSubscribe(tokenDto,topic.getId(), WxmpSubscribeConstant.TYPE_COMMENT); return new Result(); @@ -372,6 +404,20 @@ public class ResiTopicCommentServiceImpl extends BaseServiceImpl fileList = resiTopicCommentAttachmentService.getTopicComFile(commentFormDTO.getTopicId()); + //封装数据并返回 + comments.forEach(l -> { + //每一条评论的附件信息 + List imageList = new ArrayList<>(); + for (CommentFileDTO f : fileList) { + if (l.getCommentId().equals(f.getCommentId()) && l.getUserId().equals(f.getUserId())) { + imageList.add(f); + } + } + l.setImageList(imageList); + }); + } return new Result>().ok(comments); diff --git a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/act/ActCommentAttachmentDao.xml b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/act/ActCommentAttachmentDao.xml new file mode 100644 index 0000000000..b74e6adc02 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/act/ActCommentAttachmentDao.xml @@ -0,0 +1,26 @@ + + + + + + + + \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/act/GroupActInfoDao.xml b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/act/GroupActInfoDao.xml index 70b86b20e5..6ebd2be427 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/act/GroupActInfoDao.xml +++ b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/act/GroupActInfoDao.xml @@ -3,6 +3,65 @@ + + + + + + \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/group/ResiGroupDao.xml b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/group/ResiGroupDao.xml index 0051fecc80..69fef4786a 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/group/ResiGroupDao.xml +++ b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/group/ResiGroupDao.xml @@ -77,12 +77,12 @@ AND rg.CUSTOMER_ID = #{customerId} AND rg.GRID_ID =#{gridId} AND rgm.CUSTOMER_USER_ID = #{userId} - AND rgm.STATUS IN ( 'approved', 'silent' ) - AND rg.STATE in('approved','hidden','closed') + AND rgm.STATUS IN ( 'approved', 'silent' ,'under_auditting') + AND rg.STATE in('approved','hidden','closed','under_auditting') AND rg.GROUP_TYPE = #{groupType} - order by rg.LATEST_TOPIC_PUBLISH_DATE desc + order by rg.CREATED_TIME desc LIMIT #{pageNo}, #{pageSize} @@ -157,7 +157,8 @@ rg.GROUP_NAME AS groupName, rg.GROUP_TYPE AS groupType, rgs.TOTAL_MEMBERS AS totalMember, - rgs.TOTAL_PARTY_MEMBERS AS totalPartyMember + rgs.TOTAL_PARTY_MEMBERS AS totalPartyMember, + rg.GROUP_INTRODUCTION FROM resi_group rg LEFT JOIN resi_group_statistical rgs ON ( rg.id = rgs.RESI_GROUP_ID ) @@ -246,14 +247,17 @@ AND gmo.OPERATE_STATUS = 'under_auditting' ) AS totalApplyingMember, rgs.TOTAL_TOPICS, - rg.AUDIT_SWITCH + rg.AUDIT_SWITCH, + rg.group_type groupType, + gs.`name` groupTypeName FROM resi_group rg LEFT JOIN resi_group_statistical rgs ON ( rg.id = rgs.RESI_GROUP_ID ) LEFT JOIN resi_group_member rgm - ON ( rg.id = rgm.RESI_GROUP_ID - AND rgm.DEL_FLAG='0' - AND rgm.CUSTOMER_USER_ID =#{userId}) + ON ( rg.id = rgm.RESI_GROUP_ID + AND rgm.DEL_FLAG='0' + AND rgm.CUSTOMER_USER_ID =#{userId}) + LEFT JOIN resi_group_setup gs ON rg.GROUP_TYPE = gs.GROUP_TYPE AND gs.CUSTOMER_ID = 'default' WHERE rg.DEL_FLAG = '0' AND rgs.DEL_FLAG = '0' @@ -452,7 +456,8 @@ rg.GROUP_HEAD_PHOTO AS groupHeadPhoto, rg.GROUP_NAME AS groupName, rgs.TOTAL_MEMBERS AS totalMember, - rgs.TOTAL_PARTY_MEMBERS AS totalPartyMember + rgs.TOTAL_PARTY_MEMBERS AS totalPartyMember, + rg.GROUP_INTRODUCTION FROM resi_group rg LEFT JOIN resi_group_statistical rgs ON ( rg.id = rgs.RESI_GROUP_ID ) @@ -630,7 +635,8 @@ rg.group_name AS groupName, rg.group_type AS groupType, rgs.total_members AS totalMember, - rgs.total_party_members AS totalPartyMember + rgs.total_party_members AS totalPartyMember, + rg.GROUP_INTRODUCTION FROM resi_group rg LEFT JOIN resi_group_statistical rgs ON (rg.id = rgs.resi_group_id) diff --git a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/notice/NoticeCommentAttachmentDao.xml b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/notice/NoticeCommentAttachmentDao.xml new file mode 100644 index 0000000000..d20f434692 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/notice/NoticeCommentAttachmentDao.xml @@ -0,0 +1,26 @@ + + + + + + + + \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/ResiTopicCommentAttachmentDao.xml b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/ResiTopicCommentAttachmentDao.xml new file mode 100644 index 0000000000..f4616d1913 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/ResiTopicCommentAttachmentDao.xml @@ -0,0 +1,26 @@ + + + + + + + + \ No newline at end of file diff --git a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/ResiPartyMemberOpenFeignClient.java b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/ResiPartyMemberOpenFeignClient.java index 0eb5f2f018..0f320cf9be 100644 --- a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/ResiPartyMemberOpenFeignClient.java +++ b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/ResiPartyMemberOpenFeignClient.java @@ -95,4 +95,14 @@ public interface ResiPartyMemberOpenFeignClient { **/ @PostMapping(value = "/resi/partymember/partymemberinfo/getPartymemberInfoByGridId", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) Result> getPartymemberInfoByGridId(@RequestBody List gridIdList); + + /** + * @Description 根据客户ID查询党员 + * @Param customerId + * @author zxc + * @date 2021/9/6 3:54 下午 + */ + @PostMapping(value = "/resi/partymember/partymemberinfo/getpartymemberinfobycustomerid") + Result> getPartyMemberInfoByCustomerId(@RequestParam("customerId")String customerId); + } diff --git a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/fallback/ResiPartyMemberOpenFeignClientFallback.java b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/fallback/ResiPartyMemberOpenFeignClientFallback.java index 9591f35234..953d5ca326 100644 --- a/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/fallback/ResiPartyMemberOpenFeignClientFallback.java +++ b/epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/feign/fallback/ResiPartyMemberOpenFeignClientFallback.java @@ -64,4 +64,9 @@ public class ResiPartyMemberOpenFeignClientFallback implements ResiPartyMemberOp public Result> getPartymemberInfoByGridId(List gridIdList) { return ModuleUtils.feignConError(ServiceConstant.RESI_PARTYMEMBER_SERVER, "getPartymemberInfoByGridId", gridIdList); } + + @Override + public Result> getPartyMemberInfoByCustomerId(String customerId) { + return ModuleUtils.feignConError(ServiceConstant.RESI_PARTYMEMBER_SERVER, "getPartyMemberInfoByCustomerId", customerId); + } } diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/PartymemberInfoController.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/PartymemberInfoController.java index 5d7d081e13..98b56b8475 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/PartymemberInfoController.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/PartymemberInfoController.java @@ -157,4 +157,15 @@ public class PartymemberInfoController { List list = partymemberInfoService.listPartymemberInfoByGridId(gridIdList); return new Result>().ok(list); } + + /** + * @Description 根据客户ID查询党员 + * @Param customerId + * @author zxc + * @date 2021/9/6 3:54 下午 + */ + @PostMapping("getpartymemberinfobycustomerid") + public Result> getPartyMemberInfoByCustomerId(@RequestParam("customerId")String customerId){ + return new Result>().ok(partymemberInfoService.getPartyMemberInfoByCustomerId(customerId)); + } } diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/dao/PartymemberInfoDao.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/dao/PartymemberInfoDao.java index f395beac8b..c363cd42a0 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/dao/PartymemberInfoDao.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/dao/PartymemberInfoDao.java @@ -95,4 +95,12 @@ public interface PartymemberInfoDao extends BaseDao { * @Date 2020/7/22 12:14 **/ List selectListPartymemberInfoByGridId(@Param("gridIdList") List gridIdList); + + /** + * @Description 根据客户ID查询党员 + * @Param customerId + * @author zxc + * @date 2021/9/6 3:54 下午 + */ + List selectListPartyMemberInfoByCustomerId(@Param("customerId") String customerId); } diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/PartymemberInfoService.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/PartymemberInfoService.java index 4a25939dad..eed9482da3 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/PartymemberInfoService.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/PartymemberInfoService.java @@ -170,4 +170,12 @@ public interface PartymemberInfoService extends BaseService getPartyMemberInfoByCustomerId(String customerId); } diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartyMemberConfirmServiceImpl.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartyMemberConfirmServiceImpl.java index 80cc4cc91e..1610de67c6 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartyMemberConfirmServiceImpl.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartyMemberConfirmServiceImpl.java @@ -193,7 +193,7 @@ public class PartyMemberConfirmServiceImpl implements PartyMemberConfirmService PartymemberInfoEntity.class); PartymemberInfoDTO info = partymemberInfoService.getPartyMemberInfoByUser(partyMemberInfoDTO.getCustomerId(), partyMemberInfoDTO.getUserId()); if (null != info) { - partyMemberInfoDTO.setId(info.getId()); + partyMemberInfoEntity.setId(info.getId()); } if (confirmAutoDTO == null || !confirmAutoDTO.getComparisonResults()) { log.info("submit confirmAutoDTO return null or false:{}",JSON.toJSONString(confirmAutoDTO)); diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartymemberInfoServiceImpl.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartymemberInfoServiceImpl.java index 57e6a2922c..dfb4c42f71 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartymemberInfoServiceImpl.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartymemberInfoServiceImpl.java @@ -248,4 +248,15 @@ public class PartymemberInfoServiceImpl extends BaseServiceImpl getPartyMemberInfoByCustomerId(String customerId) { + return baseDao.selectListPartyMemberInfoByCustomerId(customerId); + } } diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partymember/PartymemberInfoDao.xml b/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partymember/PartymemberInfoDao.xml index 876e1102f0..d6585f8dfb 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partymember/PartymemberInfoDao.xml +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partymember/PartymemberInfoDao.xml @@ -169,4 +169,15 @@ + + + diff --git a/epmet-openapi/epmet-openapi-sdk/pom.xml b/epmet-openapi/epmet-openapi-sdk/pom.xml new file mode 100644 index 0000000000..c006c05b10 --- /dev/null +++ b/epmet-openapi/epmet-openapi-sdk/pom.xml @@ -0,0 +1,15 @@ + + + + epmet-openapi + com.epmet + 2.0.0 + + 4.0.0 + + epmet-openapi-sdk + + + \ No newline at end of file diff --git a/epmet-openapi/epmet-openapi-sdk/src/main/java/com/epmet/openapi/sdk/encrypt/Md5Util.java b/epmet-openapi/epmet-openapi-sdk/src/main/java/com/epmet/openapi/sdk/encrypt/Md5Util.java new file mode 100644 index 0000000000..0838048629 --- /dev/null +++ b/epmet-openapi/epmet-openapi-sdk/src/main/java/com/epmet/openapi/sdk/encrypt/Md5Util.java @@ -0,0 +1,133 @@ +package com.epmet.openapi.sdk.encrypt; + +import java.io.UnsupportedEncodingException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +public class Md5Util { + /** + * 加密盐 值 + */ + public static final String SALT = "EPMET_UMD_SALT"; + + public static String md5(String string) throws Exception { + if (string == null || string.trim().length() == 0) { + return null; + } + return getMD5(string.getBytes("GBK")); + } + + private static final char hexDigits[] = { // 用来将字节转换成 16 进制表示的字符 + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; + + private static String getMD5(byte[] source) throws Exception { + String s = null; + MessageDigest md = MessageDigest.getInstance("MD5"); + md.update(source); + byte tmp[] = md.digest(); // MD5 的计算结果是一个 128 位的长整数, + // 用字节表示就是 16 个字节 + char str[] = new char[16 * 2]; // 每个字节用 16 进制表示的话,使用两个字符, + // 所以表示成 16 进制需要 32 个字符 + int k = 0; // 表示转换结果中对应的字符位置 + for (int i = 0; i < 16; i++) { // 从第一个字节开始,对 MD5 的每一个字节 + // 转换成 16 进制字符的转换 + byte byte0 = tmp[i]; // 取第 i 个字节 + str[k++] = hexDigits[byte0 >>> 4 & 0xf]; // 取字节中高 4 位的数字转换, + // >>> 为逻辑右移,将符号位一起右移 + str[k++] = hexDigits[byte0 & 0xf]; // 取字节中低 4 位的数字转换 + } + s = new String(str); // 换后的结果转换为字符串 + return s; + } + + private static String byteArrayToHexString(byte b[]) { + StringBuffer resultSb = new StringBuffer(); + for (int i = 0; i < b.length; i++) + resultSb.append(byteToHexString(b[i])); + + return resultSb.toString(); + } + + private static String byteToHexString(byte b) { + int n = b; + if (n < 0) + n += 256; + int d1 = n / 16; + int d2 = n % 16; + return hexDigits[d1] + "" + hexDigits[d2]; + } + + public static String MD5Encode(String origin, String charsetname) throws Exception { + String resultString = null; + resultString = new String(origin); + MessageDigest md = MessageDigest.getInstance("MD5"); + if (charsetname == null || "".equals(charsetname)) + resultString = byteArrayToHexString(md.digest(resultString + .getBytes())); + else + resultString = byteArrayToHexString(md.digest(resultString + .getBytes(charsetname))); + return resultString; + } + + + public static void main(String[] args) { + for (int i = 0; i < 5; i++) { + String uuid = "03a1dcd8cb1811eabac1c03fd56f7847"; + System.out.println(get12Char(uuid)); + } + } + + /** + * 获取短字符 + * + * @param str + * @return 大写 + */ + public static String get12Char(String str) { + String arr[] = ShortText(str); + String rst = (arr[0] + arr[1]).toUpperCase(); + return rst.substring(0, 4) + rst.substring(4, 8) + rst.substring(8, 12); + } + + private static String[] ShortText(String string) { + String[] chars = new String[]{ // 要使用生成URL的字符 + "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", + "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", + "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", + "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", + "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}; + + String hex = ""; + + MessageDigest md = null; + try { + md = MessageDigest.getInstance("MD5"); + hex = byteArrayToHexString(md.digest(SALT.concat(string) + .getBytes("utf-8"))); + } catch (Exception e) { + e.printStackTrace(); + } + + int hexLen = hex.length(); + int subHexLen = hexLen / 8; + String[] ShortStr = new String[4]; + + for (int i = 0; i < subHexLen; i++) { + String outChars = ""; + int j = i + 1; + String subHex = hex.substring(i * 8, j * 8); + long idx = Long.valueOf("3FFFFFFF", 16) & Long.valueOf(subHex, 16); + + for (int k = 0; k < 6; k++) { + int index = (int) (Long.valueOf("0000003D", 16) & idx); + outChars += chars[index]; + idx = idx >> 5; + } + ShortStr[i] = outChars; + } + + return ShortStr; + } + +} diff --git a/epmet-openapi/epmet-openapi-sdk/src/main/java/com/epmet/openapi/sdk/sign/OpenApiSignUtils.java b/epmet-openapi/epmet-openapi-sdk/src/main/java/com/epmet/openapi/sdk/sign/OpenApiSignUtils.java new file mode 100644 index 0000000000..e44b17aa30 --- /dev/null +++ b/epmet-openapi/epmet-openapi-sdk/src/main/java/com/epmet/openapi/sdk/sign/OpenApiSignUtils.java @@ -0,0 +1,109 @@ +package com.epmet.openapi.sdk.sign; + +import com.epmet.openapi.sdk.encrypt.Md5Util; + +import java.util.*; + +/** + * OpenApi签名工具 + */ +public class OpenApiSignUtils { + + /** + * @Description 创建签名 + * @return + * @author wxz + * @date 2021.03.22 16:47 + */ + public static String createSign(Map contentMap, String signKey) throws Exception { + String str2beSigned = mapToSignStr(contentMap); + str2beSigned = str2beSigned.concat("&sign_key=").concat(signKey); + return Md5Util.md5(str2beSigned); + } + + /** + * @Description 验签 + * @return + * @author wxz + * @date 2021.03.22 16:51 + */ + public static boolean checkSign(Map contentMap, String signKey) throws Exception { + String newSign = createSign(contentMap, signKey); + return newSign.equals(contentMap.get("sign")); + } + + /** + * @Description map转化为签名明文 + * @return + * @author wxz + * @date 2021.03.22 16:47 + */ + public static String mapToSignStr(Map map) { + Set keySet = map.keySet(); + String[] keyArray = (String[])keySet.toArray(new String[keySet.size()]); + Arrays.sort(keyArray); + StringBuilder sb = new StringBuilder(); + + for(int i = 0; i < keyArray.length; ++i) { + String key = keyArray[i]; + String val = (String)map.get(key); + if (val != null && val.trim().length() > 0 && !"sign".equals(key)) { + if (!sb.toString().isEmpty()) { + sb.append("&"); + } + + sb.append(key).append("=").append((String)map.get(key)); + } + } + + return sb.toString(); + } + + public static void main(String[] args) throws Exception { + generateGetAccessTokenSign(); + System.out.println("=============="); + generateGetOrgDetailSign(); + } + + private static void generateGetAccessTokenSign() throws Exception { + long now = System.currentTimeMillis(); + System.out.println(now); + + String uuid = UUID.randomUUID().toString().replace("-", ""); + + HashMap content = new HashMap<>(); + content.put("app_id", "7d98b8af2d05752b4225709c4cfd4bd0"); + content.put("timestamp", String.valueOf(now)); + content.put("nonce", uuid); + content.put("auth_type", "take_token"); + + String secret = "3209ee9f41704482be1a1fb5873a25376f2899191ca846119d44168316bc3e44"; + + String sign = createSign(content, secret); + + System.out.println("时间戳:" + now); + System.out.println("随机数:" + uuid); + System.out.println("签名:" + sign); + } + + private static void generateGetOrgDetailSign() throws Exception { + long now = System.currentTimeMillis(); + String uuid = UUID.randomUUID().toString().replace("-", "");; + System.out.println("时间戳:" + now); + System.out.println("随机数:" + uuid); + + HashMap content = new HashMap<>(); + //content.put("orgId", "aaa"); + //content.put("test", null); + content.put("gridId", "12128e0f614f1c00a058ea9a107033b2"); + content.put("app_id", "7d98b8af2d05752b4225709c4cfd4bd0"); + content.put("timestamp", String.valueOf(now)); + content.put("nonce", uuid); + content.put("auth_type", "take_token"); + + String secret = "3209ee9f41704482be1a1fb5873a25376f2899191ca846119d44168316bc3e44"; + + String sign = createSign(content, secret); + System.out.println("签名:" + sign); + } +} diff --git a/epmet-openapi/pom.xml b/epmet-openapi/pom.xml index 9db62073f3..a3be582a53 100644 --- a/epmet-openapi/pom.xml +++ b/epmet-openapi/pom.xml @@ -13,6 +13,7 @@ epmet-openapi epmet-openapi-scan + epmet-openapi-sdk \ No newline at end of file