diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aop/NoRepeatSubmit.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aop/NoRepeatSubmit.java new file mode 100644 index 0000000000..aad5ee733a --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aop/NoRepeatSubmit.java @@ -0,0 +1,17 @@ +package com.epmet.commons.tools.aop; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/11/24 9:56 + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface NoRepeatSubmit { + +} \ No newline at end of file diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aop/NoRepeatSubmitAop.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aop/NoRepeatSubmitAop.java new file mode 100644 index 0000000000..42f1950d5f --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aop/NoRepeatSubmitAop.java @@ -0,0 +1,82 @@ +package com.epmet.commons.tools.aop; + +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.RenException; +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.AfterThrowing; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; +import java.lang.reflect.Method; +import java.util.Objects; +import java.util.concurrent.TimeUnit; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/11/24 9:59 + */ +@Aspect +@Configuration +@Slf4j +public class NoRepeatSubmitAop { + + + /** + * 重复提交判断时间为2s + */ + private static final Cache CACHES = CacheBuilder.newBuilder() + // 最大缓存 100 个 + .maximumSize(1000) + // 设置写缓存后 5 秒钟过期 + .expireAfterWrite(5, TimeUnit.SECONDS) + .build(); + @Before("execution(public * com.epmet..*Controller.*(..))") + public void before(JoinPoint joinPoint) { + System.out.println(joinPoint.getSignature().getName()); + } + + @Around("execution(public * com.epmet..*Controller.*(..)) && @annotation(com.epmet.commons.tools.aop.NoRepeatSubmit)") + public Object around(ProceedingJoinPoint pjp) { + try { + ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + assert attributes != null; + HttpServletRequest request = attributes.getRequest(); + String key = getKey(request.getRequestURI(), pjp.getArgs()); + // 如果缓存中有这个url视为重复提交 + if (CACHES.getIfPresent(key) == null) { + Object o = pjp.proceed(); + CACHES.put(key, NumConstant.ZERO); + return o; + } else { + log.error("重复提交"); + throw new RenException(EpmetErrorCode.REPEATED_SUBMIT_ERROR.getCode()); + } + } catch (RenException e) { + throw e; + } catch (Throwable e) { + log.error("验证重复提交时出现未知异常!"); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } + + } + + private String getKey(String keyExpress, Object[] args) { + for (int i = 0; i < args.length; i++) { + keyExpress = keyExpress.replace("arg[" + i + "]", args[i].toString()); + } + return keyExpress; + } + + +} \ No newline at end of file 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 6b83914554..4d3c107de3 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 @@ -48,7 +48,7 @@ public enum EpmetErrorCode { IDCARDNO_ALREADY_EXITS(8109,"系统已存在相同身份证号码,请重新输入"), IDCARDNO_ERROR(8110,"身份证号格式错误,请重新输入"), CANNOT_DELETE_PARTY_MEMBER(8111,"该用户已注册党员,不允许删除"), - GROUP_LEADER_CAN_EDIT_GROUP_INFO(8112,"只有组长才可以修改小组信息"), + GROUP_LEADER_CAN_EDIT_GROUP_INFO(8112,"只有组长才可以操作"), INVITE_NEW_MEMBER(8113,"只有讨论中的小组才可以邀请新成员"), ACT_TITLE_SCAN_FAILED(8114,"活动标题审核失败,请重新编辑"), ACT_REQ_SCAN_FAILED(8115,"活动报名条件审核失败,请重新编辑"), @@ -68,6 +68,7 @@ public enum EpmetErrorCode { NOT_DEL_AGENCY(8202, "该机关存在下级机关,不允许删除"), NOT_DEL_AGENCY_PER(8205, "该机关存在工作人员,不允许删除"), NOT_DEL_DEPARTMENT(8206, "该部门存在工作人员,不允许删除"), + NOT_DEL_AGENCY_GRID(8207, "该机关存在网格,不允许删除"), REQUIRE_PERMISSION(8301, "您没有足够的操作权限"), @@ -99,6 +100,7 @@ public enum EpmetErrorCode { //徽章管理 DUPLICATE_BADGE_NAME(8515, "徽章名已存在"), DUPLICATE_PARTY_BADGE_NAME(8516, "不可删除党员徽章"), + ONLINE_BADGE_COUNT(8517, "最多上线5个徽章"), // 该错误不会提示给前端,只是后端传输错误信息用。 ACCESS_SQL_FILTER_MISSION_ARGS(8701, "缺少生成权限过滤SQL所需参数"), @@ -122,7 +124,7 @@ public enum EpmetErrorCode { // 党建声音 前端提示 88段 DRAFT_CONTENT_IS_NULL(8801, "至少需要添加一个段落"), ARTICLE_PUBLISH_ERROR(8801, "发布文章失败,请刷新重试"), - + REPEATED_SUBMIT_ERROR(8998, "请勿重复提交"), CUSTOMER_VALIDATE_ERROR(8999, "内部数据校验异常"), //公众号 865..开头的码 diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpContextUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpContextUtils.java index d27da23ab7..a23b8f5d55 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpContextUtils.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpContextUtils.java @@ -66,4 +66,20 @@ public class HttpContextUtils { } return defaultLanguage; } + + public static String getRequestServerNameAndPort() { + HttpServletRequest request = getHttpServletRequest(); + //X-Forwarded-Scheme是nginx中添加的一个header,用于获取真实的$scheme + String scheme = request.getHeader("X-Forwarded-Scheme"); + if (StringUtils.isBlank(scheme)) { + scheme = "http"; + } + + String hostAndPort = request.getHeader("Host-And-Port"); + if (StringUtils.isBlank(hostAndPort)) { + hostAndPort = request.getServerName().concat(":").concat(String.valueOf(request.getServerPort())); + } + + return String.format("%s://%s", scheme, hostAndPort); + } } diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/MonthBarchartResult.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/MonthBarchartResult.java index ef79775673..051af134ba 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/MonthBarchartResult.java +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/MonthBarchartResult.java @@ -3,6 +3,7 @@ package com.epmet.evaluationindex.screen.dto.result; import lombok.Data; import java.io.Serializable; +import java.math.BigDecimal; /** * @Author zxc @@ -22,4 +23,20 @@ public class MonthBarchartResult implements Serializable { private Double governAbility; private Double indexTotal; + + //新增返回权重 + /** + * 服务能力指数 权重 + */ + private BigDecimal serviceAblityWeight; + + /** + * 党建能力指数权重 + */ + private BigDecimal partyDevWeight; + + /** + * 治理能力分数,权重 + */ + private BigDecimal governAblityWeight; } diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/MonthBarchartResultDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/MonthBarchartResultDTO.java index ad21904ba2..8a8da975f1 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/MonthBarchartResultDTO.java +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/MonthBarchartResultDTO.java @@ -3,6 +3,7 @@ package com.epmet.evaluationindex.screen.dto.result; import lombok.Data; import java.io.Serializable; +import java.math.BigDecimal; import java.util.List; /** @@ -38,4 +39,20 @@ public class MonthBarchartResultDTO implements Serializable { * 总指数集合 */ private List totalIndexData; + + //新增返回权重 + /** + * 服务能力指数 权重 + */ + private List serviceAblityWeightData; + + /** + * 党建能力指数权重 + */ + private List partyDevWeightData; + + /** + * 治理能力分数,权重 + */ + private List governAblityWeightData; } diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/MonthScoreListResultDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/MonthScoreListResultDTO.java index 19fad59717..91cfa81af7 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/MonthScoreListResultDTO.java +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/MonthScoreListResultDTO.java @@ -55,6 +55,14 @@ public class MonthScoreListResultDTO implements Serializable { */ @JsonIgnore private String indexCode; + /** + * 自身指标权重 + */ + private Double selfWeight; + /** + * 下级指标权重 + */ + private Double subWeight; } 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 4ff84d3ab6..30afda20ef 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 @@ -106,6 +106,11 @@ public class IndexServiceImpl implements IndexService { List partyDevAbilityData = new ArrayList<>(); List governAbilityData = new ArrayList<>(); List totalIndexData = new ArrayList<>(); + + //添加返回权重 + List serviceAblityWeightData = new ArrayList<>(); + List partyDevWeightData = new ArrayList<>(); + List governAblityWeightData = new ArrayList<>(); // 1. x轴 result.setXAxis(partyMemberLeadServiceImpl.getXPro()); // 2. 查询近一年的指数值【包括本月】 @@ -116,11 +121,19 @@ public class IndexServiceImpl implements IndexService { partyDevAbilityData.add(NumConstant.ZERO_DOT_ZERO); governAbilityData.add(NumConstant.ZERO_DOT_ZERO); totalIndexData.add(NumConstant.ZERO_DOT_ZERO); + //添加返回权重 + serviceAblityWeightData.add(BigDecimal.ZERO); + partyDevWeightData.add(BigDecimal.ZERO); + governAblityWeightData.add(BigDecimal.ZERO); } result.setServiceAbilityData(serviceAbilityData); result.setPartyDevAbilityData(partyDevAbilityData); result.setGovernAbilityData(governAbilityData); result.setTotalIndexData(totalIndexData); + //添加返回权重 + result.setServiceAblityWeightData(serviceAblityWeightData); + result.setPartyDevWeightData(partyDevWeightData); + result.setGovernAblityWeightData(governAblityWeightData); return result; } // 处理小数四舍五入 @@ -129,6 +142,10 @@ public class IndexServiceImpl implements IndexService { 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)); + barchart.setPartyDevWeight(barchart.getPartyDevWeight().setScale(NumConstant.TWO,BigDecimal.ROUND_HALF_UP)); + barchart.setGovernAblityWeight(barchart.getGovernAblityWeight().setScale(NumConstant.TWO,BigDecimal.ROUND_HALF_UP)); }); List collect = monthBarchartResults.stream().sorted(Comparator.comparing(MonthBarchartResult::getMonthId)).collect(Collectors.toList()); //升序 当前月份在队尾 @@ -153,6 +170,10 @@ public class IndexServiceImpl implements IndexService { partyDevAbilityData.add(NumConstant.ZERO_DOT_ZERO); governAbilityData.add(NumConstant.ZERO_DOT_ZERO); totalIndexData.add(NumConstant.ZERO_DOT_ZERO); + //权重默认0 + serviceAblityWeightData.add(BigDecimal.ZERO); + partyDevWeightData.add(BigDecimal.ZERO); + governAblityWeightData.add(BigDecimal.ZERO); //保持cursor不变 }else{ MonthBarchartResult data = collect.get(cursor); @@ -161,6 +182,10 @@ public class IndexServiceImpl implements IndexService { partyDevAbilityData.add(null == data.getPartyDevAbility() ? NumConstant.ZERO_DOT_ZERO : data.getPartyDevAbility()); governAbilityData.add(null == data.getGovernAbility() ? NumConstant.ZERO_DOT_ZERO : data.getGovernAbility()); totalIndexData.add(null == data.getIndexTotal() ? NumConstant.ZERO_DOT_ZERO : data.getIndexTotal()); + //添加权重 + serviceAblityWeightData.add(null==data.getServiceAblityWeight()?BigDecimal.ZERO:data.getServiceAblityWeight()); + partyDevWeightData.add(null==data.getPartyDevWeight()?BigDecimal.ZERO:data.getPartyDevWeight()); + governAblityWeightData.add(null==data.getGovernAblityWeight()?BigDecimal.ZERO:data.getGovernAblityWeight()); //统计日期一致后移动游标 cursor++; } @@ -177,6 +202,10 @@ public class IndexServiceImpl implements IndexService { result.setPartyDevAbilityData(partyDevAbilityData); result.setGovernAbilityData(governAbilityData); result.setTotalIndexData(totalIndexData); + //添加返回权重 + result.setServiceAblityWeightData(serviceAblityWeightData); + result.setPartyDevWeightData(partyDevWeightData); + result.setGovernAblityWeightData(governAblityWeightData); return result; } 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 6eb14469a2..3fce81dc73 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 @@ -55,7 +55,9 @@ fact.WEIGHT AS "indexTotalSupWeight", ROUND(self.self_score*fact.WEIGHT, 1) AS "agencyScore", ROUND(self.sub_score*fact.WEIGHT, 1) AS "subAgencyScore", - fact.index_code AS "indexCode" + fact.index_code AS "indexCode", + self.SELF_WEIGHT AS "selfWeight", + self.SUB_WEIGHT AS "subWeight" FROM fact_index_agency_score fact INNER JOIN fact_index_agency_self_sub_score self ON fact.agency_id = self.agency_id diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCommunityScoreDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCommunityScoreDao.xml index ca682e107b..c48ba651ac 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCommunityScoreDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCommunityScoreDao.xml @@ -55,7 +55,9 @@ fact.WEIGHT AS "indexTotalSupWeight", ROUND(self.self_score*fact.WEIGHT, 1) AS "agencyScore", ROUND(self.sub_score*fact.WEIGHT, 1) AS "subAgencyScore", - fact.index_code AS "indexCode" + fact.index_code AS "indexCode", + self.SELF_WEIGHT AS "selfWeight", + self.SUB_WEIGHT AS "subWeight" FROM fact_index_community_score fact INNER JOIN fact_index_community_self_sub_score self ON fact.agency_id = self.agency_id 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 708a5fbf1f..a731e9c1db 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 @@ -56,7 +56,9 @@ fact.WEIGHT AS "indexTotalSupWeight", ROUND(self.self_score*fact.WEIGHT, 1) AS "agencyScore", ROUND(self.sub_score*fact.WEIGHT, 1) AS "subAgencyScore", - fact.index_code AS "indexCode" + fact.index_code AS "indexCode", + self.SELF_WEIGHT AS "selfWeight", + self.SUB_WEIGHT AS "subWeight" FROM fact_index_grid_score fact INNER JOIN fact_index_grid_self_sub_score self ON fact.grid_id = self.grid_id diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml index 55dd281ff5..8011535fdb 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml @@ -33,7 +33,10 @@ month_id AS monthId, service_ablity * SERVICE_ABLITY_WEIGHT AS serviceAbility, party_dev_ablity * PARTY_DEV_WEIGHT AS partyDevAbility, - govern_ablity * GOVERN_ABLITY_WEIGHT AS governAbility + govern_ablity * GOVERN_ABLITY_WEIGHT AS governAbility, + SERVICE_ABLITY_WEIGHT as serviceAblityWeight, + PARTY_DEV_WEIGHT as partyDevWeight, + GOVERN_ABLITY_WEIGHT as governAblityWeight FROM screen_index_data_monthly WHERE diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java index 8043413311..f57bb25da3 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java @@ -40,5 +40,5 @@ public interface EpmetHeartOpenFeignClient { * @return com.epmet.commons.tools.utils.Result> */ @PostMapping("/heart/resi/act/published/{staffId}") - Result> getPublishedAct(@PathVariable String staffId); + Result> getPublishedAct(@PathVariable("staffId") String staffId); } diff --git a/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/OssFeignClient.java b/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/OssFeignClient.java index 47daa888cc..239ca51acc 100644 --- a/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/OssFeignClient.java +++ b/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/OssFeignClient.java @@ -30,6 +30,8 @@ import org.springframework.web.multipart.MultipartFile; */ @FeignClient(name = ServiceConstant.EPMET_OSS_SERVER, configuration = OssFeignClient.MultipartSupportConfig.class, fallback = OssFeignClientFallback.class) +//@FeignClient(name = ServiceConstant.EPMET_OSS_SERVER, configuration = OssFeignClient.MultipartSupportConfig.class, fallback = +// OssFeignClientFallback.class) public interface OssFeignClient { /** * 文件上传 @@ -44,7 +46,7 @@ public interface OssFeignClient { Result uploadQrCode(@RequestPart(value = "file") MultipartFile file); - @Configuration + //@Configuration class MultipartSupportConfig { @Bean public Encoder feignFormEncoder() { diff --git a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java index ff52e99ce4..0f78958d58 100644 --- a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java +++ b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java @@ -159,6 +159,7 @@ public class OssController { public Result uploadQrCode(@RequestPart(value = "file") MultipartFile file) { return ossService.uploadImg(file); } + /** * 上传客户logo(考虑到以后可能会针对不同的业务有不同的限制条件,这里不再使用通用的接口 * 针对每一个业务新建上传接口) diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/AccessTokenDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/AccessTokenDTO.java new file mode 100644 index 0000000000..dac9be670e --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/AccessTokenDTO.java @@ -0,0 +1,19 @@ +package com.epmet.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @description: + * @author: liushaowen + * @date: 2020/11/17 10:07 + */ +@Data +public class AccessTokenDTO implements Serializable { + private String resiToken; + + private String workToken; + + private String errMsg; +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/utils/ThirdUtils.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/utils/ThirdUtils.java new file mode 100644 index 0000000000..426bab2b82 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/utils/ThirdUtils.java @@ -0,0 +1,53 @@ +package com.epmet.utils; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.epmet.commons.tools.enums.EnvEnum; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.HttpClientManager; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.AccessTokenDTO; +import com.epmet.dto.result.CustomerTokensResultDTO; +import org.apache.commons.lang3.StringUtils; + +import java.util.HashMap; +import java.util.Map; + +/** + * @description: + * @author: liushaowen + * @date: 2020/11/17 10:04 + */ + +public class ThirdUtils { + /** + * @Description 获取AccessToken公共方法 + * @param customerId + * @return com.epmet.dto.AccessTokenDTO + * @Author liushaowen + * @Date 2020/11/17 10:09 + */ + public static AccessTokenDTO getAccessToken(String customerId) { + EnvEnum envEnum = EnvEnum.getCurrentEnv(); + AccessTokenDTO accessToken = new AccessTokenDTO(); + + String url = "https://epmet-cloud.elinkservice.cn/api/third/pacustomer/tokenlist"; + JSONObject postData = new JSONObject(); + postData.put("customerId", customerId); + String data = HttpClientManager.getInstance().sendPostByJSON(url, JSON.toJSONString(postData)).getData(); + JSONObject toResult = JSON.parseObject(data); + Result mapToResult = ConvertUtils.mapToEntity(toResult, Result.class); + if (null != toResult.get("code")) { + mapToResult.setCode(((Integer) toResult.get("code")).intValue()); + } + if (!mapToResult.success()) { + accessToken.setErrMsg( StringUtils.isBlank(mapToResult.getMsg()) ? mapToResult.getInternalMsg() : mapToResult.getMsg()); + } + Object CustomerTokensResultDTO = mapToResult.getData(); + JSONObject json = JSON.parseObject(CustomerTokensResultDTO.toString()); + CustomerTokensResultDTO customerTokensResultDTO = ConvertUtils.mapToEntity(json, com.epmet.dto.result.CustomerTokensResultDTO.class); + accessToken.setResiToken(customerTokensResultDTO.getResiAuthorizerToken()); + accessToken.setWorkToken(customerTokensResultDTO.getWorkAuthorizerToken()); + return accessToken; + } +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/MiniInfoDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/MiniInfoDao.java index 6add27be9a..42d942a6cb 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/MiniInfoDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/MiniInfoDao.java @@ -63,5 +63,16 @@ public interface MiniInfoDao extends BaseDao { * @return java.lang.String */ String getNickName(@Param("customerId") String customerId, @Param("clientType") String clientType); + + /** + * 更新小程序名 + * @author zhaoqifeng + * @date 2020/12/2 9:37 + * @param customerId + * @param clientType + * @param nickName + * @return void + */ + void updateNickName(@Param("customerId") String customerId, @Param("clientType") String clientType, @Param("nickName") String nickName); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java index 7e1208dcc4..e230b87f3b 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java @@ -142,10 +142,14 @@ public class CodeServiceImpl implements CodeService { resiName = getNickName(authInfo.getAuthorizerAppid()); AuthorizationInfoDTO workAuthInfo = authorizationInfoDao.getAuthInfoByCustomer(formDTO.getCustomerId(), CodeConstant.WORK); workName = getNickName(workAuthInfo.getAuthorizerAppid()); + miniInfoDao.updateNickName(formDTO.getCustomerId(), formDTO.getClientType(), resiName); + miniInfoDao.updateNickName(formDTO.getCustomerId(), CodeConstant.WORK, workName); } else { workName = getNickName(authInfo.getAuthorizerAppid()); AuthorizationInfoDTO resiAuthInfo = authorizationInfoDao.getAuthInfoByCustomer(formDTO.getCustomerId(), CodeConstant.RESI); resiName = getNickName(resiAuthInfo.getAuthorizerAppid()); + miniInfoDao.updateNickName(formDTO.getCustomerId(), formDTO.getClientType(), workName); + miniInfoDao.updateNickName(formDTO.getCustomerId(), CodeConstant.RESI, resiName); } //获取小程序居民端与工作端名称 @@ -831,6 +835,7 @@ public class CodeServiceImpl implements CodeService { String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_GET_AUTHORIZER_INFO + componentAccessToken , JSON.toJSONString(jsonObject)).getData(); Map map = JSON.parseObject(data, Map.class); Map authInfo = (Map) map.get(ModuleConstant.AUTHORIZER_INFO); + ConvertUtils.mapToEntity(authInfo, MiniInfoFormDTO.class).getNick_name(); return ConvertUtils.mapToEntity(authInfo, MiniInfoFormDTO.class).getNick_name(); } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/MiniInfoDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/MiniInfoDao.xml index f70597f4d5..87708b05ce 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/MiniInfoDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/MiniInfoDao.xml @@ -31,6 +31,13 @@ NOW() ) + + update mini_info + set NICK_NAME = #{nickName} + where CUSTOMER_ID = #{customerId} + and CLIENT_TYPE = #{clientType} + and DEL_FLAG = '0' + diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/config/PermissionInitializer.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/config/PermissionInitializer.java index a88f27c992..5196bd2c8c 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/config/PermissionInitializer.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/config/PermissionInitializer.java @@ -4,13 +4,11 @@ import com.epmet.commons.tools.enums.RequirePermissionEnum; import com.epmet.entity.OperationEntity; import com.epmet.service.OperationService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Configuration; import org.springframework.util.CollectionUtils; import javax.annotation.PostConstruct; import java.util.*; -import java.util.stream.Collectors; @Configuration public class PermissionInitializer { @@ -23,38 +21,49 @@ public class PermissionInitializer { */ @PostConstruct public void initOpePermissions() { - Set operationKeys = getExistsOperationKeys(); + final Map existsOpesMap = new HashMap<>(); + List allExistsOpeEntities = operationService.listAllOperations(); + allExistsOpeEntities.stream().forEach(ope -> existsOpesMap.put(ope.getOperationKey(), ope)); ArrayList operations2Create = new ArrayList<>(); + ArrayList operations2Update = new ArrayList<>(); - RequirePermissionEnum[] requirePermissionEnums = RequirePermissionEnum.values(); - Arrays.stream(requirePermissionEnums).forEach(perm -> { + // 1.收集需要添加的 + List permEnums = Arrays.asList(RequirePermissionEnum.values()); + for (RequirePermissionEnum perm : permEnums) { String key = perm.getKey(); - if (!operationKeys.contains(key)) { + if (!existsOpesMap.containsKey(key)) { OperationEntity operationEntity = new OperationEntity(); operationEntity.setOperationKey(key); operationEntity.setBrief(perm.getBrief()); operationEntity.setOperationName(perm.getName()); operations2Create.add(operationEntity); } - }); + } + + //2.收集需要修改的 + for (RequirePermissionEnum perm : permEnums) { + String key = perm.getKey(); + String name = perm.getName(); + String brief = perm.getBrief(); + if (existsOpesMap.containsKey(key)) { + OperationEntity ope = existsOpesMap.get(key); + if (!name.equals(ope.getOperationName()) || !brief.equals(ope.getBrief())) { + // name或者brief发生过变化的,需要更新 + ope.setBrief(brief); + ope.setOperationName(name); + operations2Update.add(ope); + } + } + } + //3.批量添加和修改 if (!CollectionUtils.isEmpty(operations2Create)) { operationService.createBatch(operations2Create); } - } - /** - * 获取现有的操作key列表 - * @return - */ - public Set getExistsOperationKeys() { - List operationEntities = operationService.listAllOperations(); - if (!CollectionUtils.isEmpty(operationEntities)) { - return operationEntities.stream().map(ope -> ope.getOperationKey()).collect(Collectors.toSet()); + if (!CollectionUtils.isEmpty(operations2Update)) { + operationService.updateBatch(operations2Update); } - return new HashSet<>(); } - - } diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperationService.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperationService.java index 26c9303bbe..edfaa41473 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperationService.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/OperationService.java @@ -10,4 +10,5 @@ public interface OperationService { List listAllOperations(); void createBatch(ArrayList operations2Create); + void updateBatch(ArrayList operations2Update); } diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessConfigServiceImpl.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessConfigServiceImpl.java index 79d35436a8..06f391eada 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessConfigServiceImpl.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/AccessConfigServiceImpl.java @@ -233,12 +233,14 @@ public class AccessConfigServiceImpl implements AccessConfigService { for (String roleId : roleIds) { // 只给没有添加该权限的用户赋予该权限,已经添加了和添加了又取消的不操作 RoleOperationEntity roleOpe = roleOperationDao.getRoleOpe(roleId, operationKey); + boolean needRefreshCache = false; if (roleOpe == null) { // 没有该操作,则添加 RoleOperationEntity roleOperation = new RoleOperationEntity(); roleOperation.setOperationKey(operationKey); roleOperation.setRoleId(roleId); roleOperationDao.insert(roleOperation); + needRefreshCache = true; } for (String scopeKey : scopeKeys) { // 没有的话则添加 @@ -249,8 +251,14 @@ public class AccessConfigServiceImpl implements AccessConfigService { roleScopeEntity.setRoleId(roleId); roleScopeEntity.setScopeKey(scopeKey); roleScopeDao.insert(roleScopeEntity); + needRefreshCache = true; } } + + // 清空角色的权限缓存 + if (needRefreshCache) { + roleOpeScopeRedis.delRoleAllOpeScopes(roleId); + } } } } diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperationServiceImpl.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperationServiceImpl.java index ff20e3d2da..ca28d43d0b 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperationServiceImpl.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/OperationServiceImpl.java @@ -26,4 +26,10 @@ public class OperationServiceImpl implements OperationService { public void createBatch(ArrayList operations2Create) { operations2Create.forEach(ope -> operationDao.insert(ope)); } + + @Transactional + @Override + public void updateBatch(ArrayList operations2Update) { + operations2Update.forEach(ope -> operationDao.updateById(ope)); + } } diff --git a/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/result/MyPartIssuesResultDTO.java b/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/result/MyPartIssuesResultDTO.java index fdce22e8f2..7e04a6a07c 100644 --- a/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/result/MyPartIssuesResultDTO.java +++ b/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/result/MyPartIssuesResultDTO.java @@ -38,4 +38,22 @@ public class MyPartIssuesResultDTO implements Serializable { @JsonIgnore private String gridId; + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + MyPartIssuesResultDTO u = (MyPartIssuesResultDTO)obj; + return issueId.equals(u.issueId); + } + + @Override + public int hashCode() { + String in = issueId; + return in.hashCode(); + } } diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueVoteDetailDao.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueVoteDetailDao.java index 45ed993354..622a68e6cd 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueVoteDetailDao.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueVoteDetailDao.java @@ -82,7 +82,7 @@ public interface IssueVoteDetailDao extends BaseDao { * @author zxc * @date 2020/11/10 10:01 上午 */ - List myPartIssues(@Param("userId")String userId); + List myPartIssues(@Param("userId")String userId, @Param("topicIds")List topicIds); List myPartIssuesByTopicId(@Param("topicIds")List topicIds); diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueVoteStatisticalServiceImpl.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueVoteStatisticalServiceImpl.java index d995c8166a..fc8a5138de 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueVoteStatisticalServiceImpl.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueVoteStatisticalServiceImpl.java @@ -45,6 +45,7 @@ import com.epmet.feign.ResiGroupFeignClient; import com.epmet.redis.IssueVoteDetailRedis; import com.epmet.redis.IssueVoteStatisticalRedis; import com.epmet.resi.group.dto.topic.form.MyPartIssueFormDTO; +import com.epmet.resi.group.dto.topic.form.TopicIdListFormDTO; import com.epmet.resi.group.dto.topic.result.MyPartIssueResultDTO; import com.epmet.resi.group.feign.ResiGroupOpenFeignClient; import com.epmet.service.IssueVoteDetailService; @@ -549,22 +550,35 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl myPartIssues(MyPartIssuesFormDTO myPartIssuesFormDTO) { - List myPartIssuesResult = issueVoteDetailDao.myPartIssues(myPartIssuesFormDTO.getUserId()); + List myPartIssuesResult = new ArrayList<>(); + //我创建的话题 + TopicIdListFormDTO topicIdListFormDTO = new TopicIdListFormDTO(); + topicIdListFormDTO.setUserId(myPartIssuesFormDTO.getUserId()); + Result> myCreateIssueResult = resiGroupOpenFeignClient.selectMyCreateTopic(topicIdListFormDTO); + if (!myCreateIssueResult.success()){ + throw new RenException("查询我创建的话题失败......"); + } + //我参与的议题 + myPartIssuesResult = issueVoteDetailDao.myPartIssues(myPartIssuesFormDTO.getUserId(), myCreateIssueResult.getData()); + //我参与的话题 MyPartIssueFormDTO formDTO = new MyPartIssueFormDTO(); formDTO.setUserId(myPartIssuesFormDTO.getUserId()); Result myPartIssueResult = resiGroupOpenFeignClient.selectMyPartTopic(formDTO); if (!myPartIssueResult.success()){ throw new RenException("查询我评论过的话题失败......"); } + //我参与的话题转了议题的 if (!CollectionUtils.isEmpty(myPartIssueResult.getData().getTopicIds())){ - List myPartIssuesResultDTOS = issueVoteDetailDao.myPartIssuesByTopicId(myPartIssueResult.getData().getTopicIds()); - myPartIssuesResult.addAll(myPartIssuesResultDTOS); + List myPartIssues = issueVoteDetailDao.myPartIssuesByTopicId(myPartIssueResult.getData().getTopicIds()); + myPartIssuesResult.addAll(myPartIssues); } if (CollectionUtils.isEmpty(myPartIssuesResult)){ return new ArrayList<>(); } + Set set = new HashSet<>(myPartIssuesResult); + myPartIssuesResult = new ArrayList<>(set); List collect = myPartIssuesResult.stream().sorted(Comparator.comparing(MyPartIssuesResultDTO::getShiftIssueTime).reversed()).distinct().collect(Collectors.toList()); - List orgIds = collect.stream().map(m -> m.getGridId()).collect(Collectors.toList()); + List orgIds = collect.stream().map(MyPartIssuesResultDTO::getGridId).collect(Collectors.toList()); Result> listResult = govOrgOpenFeignClient.getGridListByGridIds(orgIds); if (!listResult.success()){ throw new RenException("查询议题来源网格名称失败......"); diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueVoteDetailDao.xml b/epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueVoteDetailDao.xml index ff7d88384a..426c741806 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueVoteDetailDao.xml +++ b/epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueVoteDetailDao.xml @@ -73,7 +73,7 @@ - SELECT vd.ISSUE_ID, i.SUGGESTION, @@ -85,6 +85,11 @@ WHERE i.DEL_FLAG = '0' AND vd.DEL_FLAG = '0' AND vd.CREATED_BY = #{userId} + + + i.SOURCE_ID != #{topicId} + + ORDER BY i.CREATED_TIME DESC @@ -97,8 +102,7 @@ UNIX_TIMESTAMP(i.CREATED_TIME) AS shiftIssueTime FROM issue i WHERE i.DEL_FLAG = '0' - AND - + i.SOURCE_ID = #{topicId} ORDER BY i.CREATED_TIME DESC diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/ExtUserInfoResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/ExtUserInfoResultDTO.java index a7649e03a2..01f9ee8cf8 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/ExtUserInfoResultDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/ExtUserInfoResultDTO.java @@ -75,6 +75,22 @@ public class ExtUserInfoResultDTO implements Serializable { * */ private String gridName = ""; + /** + * 手机号(注册手机号) + */ + private String mobile = ""; + + /** + * 用户微信openId + * */ + private String wxOpenId = ""; + + /** + * 性别(1男2女0未知) + */ + private String gender = ""; + + /** * 用户角色列表 * */ diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java index 8fbd617cf2..afb9739daa 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/AgencyServiceImpl.java @@ -26,6 +26,7 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.constant.CustomerAgencyConstant; import com.epmet.constant.RoleKeyConstants; import com.epmet.dao.CustomerAgencyDao; +import com.epmet.dao.CustomerGridDao; import com.epmet.dto.CustomerAgencyDTO; import com.epmet.dto.GovStaffRoleDTO; import com.epmet.dto.form.*; @@ -64,6 +65,8 @@ public class AgencyServiceImpl implements AgencyService { private EpmetUserOpenFeignClient epmetUserOpenFeignClient; @Autowired private StaffServiceImpl staffServiceImpl; + @Autowired + private CustomerGridDao customerGridDao; /** * @param formDTO @@ -188,7 +191,14 @@ public class AgencyServiceImpl implements AgencyService { result.setMsg(EpmetErrorCode.NOT_DEL_AGENCY_PER.getMsg()); return result; } - //3:删除当前机关组织(逻辑删) + //3:组织下有网格,不允许删除 + int gridCount = customerGridDao.selectGridCountByAgencyId(formDTO.getAgencyId()); + if (gridCount > NumConstant.ZERO) { + result.setCode(EpmetErrorCode.NOT_DEL_AGENCY_GRID.getCode()); + result.setMsg(EpmetErrorCode.NOT_DEL_AGENCY_GRID.getMsg()); + return result; + } + //4:删除当前机关组织(逻辑删) if (customerAgencyDao.deleteById(formDTO.getAgencyId()) < NumConstant.ONE) { log.error(CustomerAgencyConstant.DEL_EXCEPTION); throw new RenException(CustomerAgencyConstant.DEL_EXCEPTION); diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java index 1d6676e96f..df895b4f11 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java @@ -566,6 +566,10 @@ public class CustomerGridServiceImpl extends BaseServiceImpl> getGridListByGridIds(List gridIdList) { Result> result = new Result>(); + if (gridIdList.size() < NumConstant.ONE) { + logger.error("根据网格Id集合获取网格列表信息-传入的网格Id集合为空数组!"); + return result; + } List list = baseDao.selectGridByIds(gridIdList); return result.ok(list); } diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/constant/GroupCodeConstant.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/constant/GroupCodeConstant.java new file mode 100644 index 0000000000..2dd3ab893c --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/constant/GroupCodeConstant.java @@ -0,0 +1,23 @@ +package com.epmet.resi.group.constant; + +/** + * @description: + * @author: liushaowen + * @date: 2020/11/13 16:23 + */ + +public interface GroupCodeConstant { + /** + * 群二维码类型-邀请 + */ + String CODE_TYPE_INVITE = "invite"; + + /** + * aliyun图片地址域名对应正则表达式 + */ + String PATTERN = "^((http://)|(https://))?([a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,6}(/)"; + /** + * 供前端下载图片jenkins转发前缀 + */ + String STORAGE = "/storage/"; +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/constant/GroupStateConstant.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/constant/GroupStateConstant.java index fcb2afc28f..ee3bcda420 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/constant/GroupStateConstant.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/constant/GroupStateConstant.java @@ -41,4 +41,20 @@ public interface GroupStateConstant { * 群已关闭 - closed */ String GROUP_CLOSED = "closed"; + /** + * 邀请链接:invited + */ + String GROUP_INVITED = "invited"; + /** + * 扫码:scancode + */ + String GROUP_SCANCODE = "scancode"; + /** + * 进组审核open开启;close关闭 + */ + String AUDIT_SWITCH_OPEN = "open"; + /** + * 进组审核open开启;close关闭 + */ + String AUDIT_SWITCH_CLOSED = "close"; } diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/QRCodeMultipartFileDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/QRCodeMultipartFileDTO.java new file mode 100644 index 0000000000..5b8f6a8cd9 --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/QRCodeMultipartFileDTO.java @@ -0,0 +1,66 @@ +package com.epmet.resi.group.dto; + +import lombok.Data; +import org.apache.commons.lang3.ArrayUtils; +import org.springframework.web.multipart.MultipartFile; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; + +/** + * @description: + * @author: liushaowen + * @date: 2020/11/16 13:52 + */ +@Data +public class QRCodeMultipartFileDTO implements MultipartFile { + + private String name = "file"; + + private String originalFilename; + + private String contentType = "image/jpeg"; + + private byte[] bytes; + + @Override + public String getName() { + return this.name; + } + + @Override + public String getOriginalFilename() { + return this.originalFilename; + } + + @Override + public String getContentType() { + return this.contentType; + } + + @Override + public boolean isEmpty() { + return ArrayUtils.isEmpty(bytes)?true:false; + } + + @Override + public long getSize() { + return ArrayUtils.isEmpty(bytes)?bytes.length:0; + } + + @Override + public byte[] getBytes() { + return this.bytes; + } + + @Override + public InputStream getInputStream() { + return null; + } + + @Override + public void transferTo(File file) { + + } +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/ResiGroupCodeDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/ResiGroupCodeDTO.java new file mode 100644 index 0000000000..ac301a624c --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/ResiGroupCodeDTO.java @@ -0,0 +1,101 @@ +/** + * 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.group; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 小组二维码 小组唯一二维码,海报码和小组码是同一个二维码,长期有效的 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-11-13 + */ +@Data +public class ResiGroupCodeDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 客户ID + */ + private String customerId; + + /** + * 网格ID + */ + private String gridId; + + /** + * 小组Id + */ + private String groupId; + + /** + * 二维码类型 + */ + private String type; + + /** + * 邀请ID + */ + private String invitationId; + + /** + * 二维码路径 + */ + private String url; + + /** + * 删除标志 + */ + private String delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/ResiGroupDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/ResiGroupDTO.java index 9045ac28ea..be61d33c2a 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/ResiGroupDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/ResiGroupDTO.java @@ -74,6 +74,11 @@ Ps: 如果一个小组被拒绝,当前小组的状态将永久停留在“审 */ private Date latestTopicPublishDate; + /** + * 进组审核open开启;close关闭 + */ + private String auditSwitch; + /** * 删除标记 0:未删除,1:已删除 */ diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/CreateGroupCodeFormDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/CreateGroupCodeFormDTO.java new file mode 100644 index 0000000000..2de7fe7531 --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/CreateGroupCodeFormDTO.java @@ -0,0 +1,40 @@ +package com.epmet.resi.group.dto.group.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @description: + * @author: liushaowen + * @date: 2020/11/13 16:22 + */ +@Data +public class CreateGroupCodeFormDTO implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 客户id + */ + @NotBlank(message = "客户id不能为空") + private String customerId; + + /** + * 网格id + */ + @NotBlank(message = "网格id不能为空") + private String gridId; + + /** + * 组id + */ + @NotBlank(message = "群组id不能为空") + private String groupId; + + /** + * 类型 GroupCodeConstant中的类型 + */ + @NotBlank(message = "二维码类型不能为空") + private String type; +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/GetGroupCodeFormDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/GetGroupCodeFormDTO.java new file mode 100644 index 0000000000..351c8dbc7b --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/GetGroupCodeFormDTO.java @@ -0,0 +1,40 @@ +package com.epmet.resi.group.dto.group.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @description: + * @author: liushaowen + * @date: 2020/11/16 9:31 + */ +@Data +public class GetGroupCodeFormDTO implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 客户id + */ + @NotBlank(message = "客户id不能为空") + private String customerId; + + /** + * 网格id + */ + @NotBlank(message = "网格id不能为空") + private String gridId; + + /** + * 组id + */ + @NotBlank(message = "群组id不能为空") + private String groupId; + + /** + * 类型 GroupCodeConstant中的类型 + */ + @NotBlank(message = "二维码类型不能为空") + private String type; +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/GroupCodeBasicInfoFormDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/GroupCodeBasicInfoFormDTO.java new file mode 100644 index 0000000000..b9a6102ecd --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/GroupCodeBasicInfoFormDTO.java @@ -0,0 +1,33 @@ +package com.epmet.resi.group.dto.group.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @description: 获取生成海报(小组码)信息-接口入参 + * @author: sun + */ +@Data +public class GroupCodeBasicInfoFormDTO implements Serializable { + private static final long serialVersionUID = 1L; + /** + * 客户id + */ + @NotBlank(message = "客户id不能为空", groups = {GroupCodeBasicInfoFormDTO.GroupCodeInfo.class}) + private String customerId; + /** + * 网格id + */ + @NotBlank(message = "网格id不能为空", groups = {GroupCodeBasicInfoFormDTO.GroupCodeInfo.class}) + private String gridId; + /** + * 组id + */ + @NotBlank(message = "群组id不能为空", groups = {GroupCodeBasicInfoFormDTO.GroupCodeInfo.class}) + private String groupId; + + public interface GroupCodeInfo {} + +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupCodeBasicInfoResultDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupCodeBasicInfoResultDTO.java new file mode 100644 index 0000000000..b3275408bf --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupCodeBasicInfoResultDTO.java @@ -0,0 +1,35 @@ +package com.epmet.resi.group.dto.group.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @description: 获取生成海报(小组码)信息-接口入参 + * @author: sun + */ +@Data +public class GroupCodeBasicInfoResultDTO implements Serializable { + private static final long serialVersionUID = -1590972041272087570L; + + /** + * 小组Id + */ + private String groupId; + /** + * 小组名称 + */ + private String groupName; + /** + * 小组头像 + */ + private String groupHeadPhoto; + /** + * 小组介绍 + */ + private String groupIntroduction; + /** + * 小组二维码路径 + */ + private String groupCodeUrl; +} 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 9e54c59eb5..0b19208c9f 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 @@ -65,6 +65,10 @@ public class GroupSummarizeResultDTO implements Serializable { */ private String leaderFlag; + /** + * 进组审核open开启;close关闭 + */ + private String auditSwitch; public GroupSummarizeResultDTO(){ this.setGroupId(""); this.setGroupHeadPhoto(""); @@ -76,5 +80,6 @@ public class GroupSummarizeResultDTO implements Serializable { this.setTotalApplyingMember(NumConstant.ZERO); this.setTotalTopics(NumConstant.ZERO); this.setLeaderFlag(""); + this.setAuditSwitch("open"); } } diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/invitation/GroupInvitationDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/invitation/GroupInvitationDTO.java index b4bc7fe18a..f157c439d1 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/invitation/GroupInvitationDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/invitation/GroupInvitationDTO.java @@ -68,6 +68,11 @@ public class GroupInvitationDTO implements Serializable { */ private Date validEndTime; + /** + * 邀请链接:invited;扫码:scancode + */ + private String invitationType; + /** * 删除标记 0:未删除,1:已删除 */ diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/invitation/result/AcceptInvitationResultDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/invitation/result/AcceptInvitationResultDTO.java new file mode 100644 index 0000000000..c7dc6cf6f7 --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/invitation/result/AcceptInvitationResultDTO.java @@ -0,0 +1,19 @@ +package com.epmet.resi.group.dto.invitation.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description 同意邀请进组 + * @Author sun + */ +@Data +public class AcceptInvitationResultDTO implements Serializable { + private static final long serialVersionUID = 8860336693592035343L; + + /** + * true 已经入组过需要审核 false没有入组过 + */ + private Boolean awaitAudit = false; +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/invitation/result/LinkGroupInfoResultDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/invitation/result/LinkGroupInfoResultDTO.java index 4e3fd08cd5..441571f202 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/invitation/result/LinkGroupInfoResultDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/invitation/result/LinkGroupInfoResultDTO.java @@ -14,6 +14,10 @@ import java.io.Serializable; public class LinkGroupInfoResultDTO implements Serializable { private static final long serialVersionUID = 8860336693592035343L; + /** + * true 已经入组过需要审核 false没有入组过 + */ + private Boolean awaitAudit; /** * 是否在群内标志,已经在群内yes 不在群内no */ diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/GroupMemeberOperationDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/GroupMemeberOperationDTO.java index 23a8331ac0..751153861a 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/GroupMemeberOperationDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/GroupMemeberOperationDTO.java @@ -62,7 +62,7 @@ public class GroupMemeberOperationDTO implements Serializable { private String operateStatus; /** - * 入群方式:(受邀请入群 - invited 、 主动加入 - join、created群主创建群自动进入群) + * 入群方式:(受邀请入群 - invited 、 主动加入 - join、created群主创建群自动进入群、扫码入群 - scancode) */ private String enterGroupType; diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/ResiGroupMemberDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/ResiGroupMemberDTO.java index 49de542902..c6cd651968 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/ResiGroupMemberDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/ResiGroupMemberDTO.java @@ -54,7 +54,7 @@ public class ResiGroupMemberDTO implements Serializable { private String groupLeaderFlag; /** - * 入群方式:(受邀请入群 - invited 、 主动加入 - join、created群主创建群自动进入群) + * 入群方式:(受邀请入群 - invited 、 主动加入 - join、created群主创建群自动进入群、扫码入群 - scancode) */ private String enterGroupType; diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/form/EditAuditSwitchFormDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/form/EditAuditSwitchFormDTO.java new file mode 100644 index 0000000000..da1391fa51 --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/form/EditAuditSwitchFormDTO.java @@ -0,0 +1,27 @@ +package com.epmet.resi.group.dto.member.form; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * 组长开启/关闭入群审核 + * + * @author yinzuomei@elink-cn.com + * @date 2020/11/17 14:02 + */ +@Data +public class EditAuditSwitchFormDTO implements Serializable { + private static final long serialVersionUID = -8185514609968752625L; + public interface AddUserShowGroup extends CustomerClientShowGroup { + } + @NotBlank(message = "小组id不能为空") + private String groupId; + /** + * 进组审核open开启;close关闭 + */ + @NotBlank(message = "请选择是否开启", groups = {EditAuditSwitchFormDTO.AddUserShowGroup.class}) + private String auditSwitch; +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/result/ApplyingMemberResultDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/result/ApplyingMemberResultDTO.java index 6374a9314b..915523354b 100644 --- a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/result/ApplyingMemberResultDTO.java +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/result/ApplyingMemberResultDTO.java @@ -47,6 +47,12 @@ public class ApplyingMemberResultDTO implements Serializable { */ private String status; + /** + * invited:通过链接加入 ; join:申请加入;scancode通过扫码加入 + */ + private String enterGroupType; + + /** * 用户徽章Url列表 */ 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 494cdc0dc4..574af0884f 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 @@ -17,12 +17,18 @@ import com.epmet.resi.group.dto.topic.result.MyPartIssueResultDTO; import com.epmet.resi.group.dto.topic.result.ParticipatedTopicUnitResultDTO; import com.epmet.resi.group.feign.fallback.ResiGroupOpenFeignClientFallback; import com.epmet.resi.mine.dto.from.MyPartProjectsFormDTO; +import com.epmet.commons.tools.utils.Result; +import com.epmet.resi.group.dto.group.form.CreateGroupCodeFormDTO; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import java.util.HashMap; import java.util.List; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; /** * 本服务对外开放的API,其他服务通过引用此client调用该服务 @@ -58,6 +64,16 @@ public interface ResiGroupOpenFeignClient { Result govAuditEdit(@RequestBody GroupEditionAuditFormDTO param); + /** + * @Description 创建群组二维码 + * @param dto + * @return com.epmet.commons.tools.utils.Result + * @Author liushaowen + * @Date 2020/11/13 16:33 + */ + @PostMapping(value = "/resi/group/resigroupcode/creategroupcode", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) + Result createGroupCode(@RequestBody CreateGroupCodeFormDTO dto); + /** * @Description 查询用户参与的且不是自己发表的话题对应的议题Id集合 * @author sun 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 164d1ddfc7..7df5d859cf 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 @@ -17,6 +17,10 @@ import com.epmet.resi.group.dto.topic.form.*; import com.epmet.resi.group.dto.topic.result.IssueGridResultDTO; import com.epmet.resi.group.dto.topic.result.MyPartIssueResultDTO; import com.epmet.resi.group.dto.topic.result.ParticipatedTopicUnitResultDTO; +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.ModuleUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.resi.group.dto.group.form.CreateGroupCodeFormDTO; import com.epmet.resi.group.feign.ResiGroupOpenFeignClient; import com.epmet.resi.mine.dto.from.MyPartProjectsFormDTO; import org.springframework.stereotype.Component; @@ -46,6 +50,17 @@ public class ResiGroupOpenFeignClientFallback implements ResiGroupOpenFeignClien public Result govAuditEdit(GroupEditionAuditFormDTO param) { return ModuleUtils.feignConError(ServiceConstant.RESI_GROUP_SERVER, "govAuditEdit", param); } + /** + * @param dto + * @return com.epmet.commons.tools.utils.Result + * @Description 创建群组二维码 + * @Author liushaowen + * @Date 2020/11/13 16:33 + */ + @Override + public Result createGroupCode(CreateGroupCodeFormDTO dto) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "createGroupCode", dto); + } @Override public Result> topicToIssueList(MyPartProjectsFormDTO formDTO) { diff --git a/epmet-module/resi-group/resi-group-server/pom.xml b/epmet-module/resi-group/resi-group-server/pom.xml index 86ccf538e0..6585d78081 100644 --- a/epmet-module/resi-group/resi-group-server/pom.xml +++ b/epmet-module/resi-group/resi-group-server/pom.xml @@ -94,6 +94,18 @@ 2.0.0 compile + + com.epmet + epmet-third-client + 2.0.0 + compile + + + com.epmet + epmet-oss-client + 2.0.0 + compile + @@ -148,6 +160,11 @@ false https://epmet-dev.elinkservice.cn/api/epmetscan/api + + 5 + 8 + 10 + 30 @@ -188,6 +205,11 @@ false https://epmet-dev.elinkservice.cn/api/epmetscan/api + + 5 + 8 + 10 + 30 @@ -227,6 +249,11 @@ true https://epmet-dev.elinkservice.cn/api/epmetscan/api + + 5 + 8 + 10 + 30 @@ -263,6 +290,11 @@ true https://epmet-open.elinkservice.cn/api/epmetscan/api + + 5 + 8 + 10 + 30 diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/config/AsyncConfig.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/config/AsyncConfig.java new file mode 100644 index 0000000000..8a1a958939 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/config/AsyncConfig.java @@ -0,0 +1,49 @@ +package com.epmet.config; + +import com.epmet.properties.ThreadProperties; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; + +import java.util.concurrent.Executor; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.ThreadPoolExecutor; + +/** + * 线程池配置类 + */ +@Configuration +@EnableConfigurationProperties(ThreadProperties.class) +@EnableAsync +public class AsyncConfig { + + @Autowired + private ThreadProperties threadProperties; + + @Bean + public Executor executor() { + ThreadProperties.ThreadPoolProperties threadPoolProps = threadProperties.getThreadPool(); + + ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); + executor.setCorePoolSize(threadPoolProps.getCorePoolSize()); + executor.setMaxPoolSize(threadPoolProps.getMaxPoolSize()); + executor.setQueueCapacity(threadPoolProps.getQueueCapacity()); + executor.setThreadNamePrefix("epmet-resi-group-"); + // rejection-policy:当pool已经达到max size的时候,如何处理新任务 + // CALLER_RUNS:不在新线程中执行任务,而是由调用者所在的线程来执行 + executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); //对拒绝task的处理策略 + executor.setKeepAliveSeconds(threadPoolProps.getKeepAlive()); + executor.initialize(); + return executor; + } + + @Bean + public ExecutorService executorService() { + ThreadPoolTaskExecutor executor = (ThreadPoolTaskExecutor) executor(); + return executor.getThreadPoolExecutor(); + } + +} 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 dcc8e30fce..29f89329e4 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 @@ -28,6 +28,7 @@ public interface UserMessageConstant { * 成员通过链接同意进群后,组长会收到:您的好友-【认证的居民名字 xxx路-王先生】通过邀请链接,加入了【组名】 */ String INVITED_JOIN_GROUP = "您的好友-【%s】通过邀请连接,加入了【%s】"; + String SCANCODE_JOIN_GROUP = "您的好友-【%s】通过扫描二维码,加入了【%s】"; /** * 组成员被禁言时会收到消息:您已被禁言,禁言时间2020.03.20 12:20-2020.03.27 12:20 @@ -79,4 +80,14 @@ public interface UserMessageConstant { */ String WX_CREATE_GROUP_BEHAVIOR = "建组申请消息"; + /** + * 邀请入组的入组理由 + */ + String INVITED_OPERATE = "通过邀请链接加入小组。"; + + /** + * 扫码入组的入组理由 + */ + String SCANCODE_OPERATE = "通过扫码加入小组。"; + } diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupCodeController.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupCodeController.java new file mode 100644 index 0000000000..34b4458ea8 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupCodeController.java @@ -0,0 +1,112 @@ +/** + * 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.group.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.group.service.ResiGroupCodeService; +import com.epmet.resi.group.dto.group.ResiGroupCodeDTO; +import com.epmet.resi.group.dto.group.form.CreateGroupCodeFormDTO; +import com.epmet.resi.group.dto.group.form.GetGroupCodeFormDTO; +import com.epmet.resi.group.dto.group.form.GroupCodeBasicInfoFormDTO; +import com.epmet.resi.group.dto.group.result.GroupCodeBasicInfoResultDTO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + + +/** + * 小组二维码 小组唯一二维码,海报码和小组码是同一个二维码,长期有效的 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-11-13 + */ +@RestController +@RequestMapping("resigroupcode") +public class ResiGroupCodeController { + + @Autowired + private ResiGroupCodeService resiGroupCodeService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = resiGroupCodeService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + ResiGroupCodeDTO data = resiGroupCodeService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody ResiGroupCodeDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + resiGroupCodeService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody ResiGroupCodeDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + resiGroupCodeService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + resiGroupCodeService.delete(ids); + return new Result(); + } + + @RequestMapping("creategroupcode") + public Result createGroupCode(@RequestBody CreateGroupCodeFormDTO dto){ + ValidatorUtils.validateEntity(dto); + return new Result().ok(resiGroupCodeService.createGroupCode(dto, true)); + } + + @RequestMapping("getgroupcode") + public Result getGroupCode(@RequestBody GetGroupCodeFormDTO dto){ + ValidatorUtils.validateEntity(dto); + return resiGroupCodeService.getGroupCode(dto); + } + + /** + * @param formDTO + * @Description 获取生成海报(小组码)信息 + * @author sun + */ + @PostMapping("groupcodebasicinfo") + public Result groupCodeBasicInfo(@RequestBody GroupCodeBasicInfoFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, GroupCodeBasicInfoFormDTO.GroupCodeInfo.class); + return new Result().ok(resiGroupCodeService.groupCodeBasicInfo(formDTO)); + } + +} 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 793cdbb83b..d8e11dc942 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 @@ -28,6 +28,7 @@ import com.epmet.resi.group.dto.group.GroupProcessingCountResultDTO; import com.epmet.resi.group.dto.group.ResiGroupDTO; import com.epmet.resi.group.dto.group.form.*; 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 org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.CollectionUtils; @@ -35,6 +36,10 @@ 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 org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; import java.util.HashMap; import java.util.List; @@ -109,7 +114,7 @@ public class ResiGroupController { * @param modifyGroupFormDTO * @return com.epmet.commons.tools.utils.Result * @Author yinzuomei - * @Description 修改组信息 + * @Description 修改组信息 此接口废弃 * @Date 2020/3/28 22:20 **/ @PostMapping("modifygroup") @@ -429,6 +434,19 @@ public class ResiGroupController { } + /** + * @param formDTO + * @author yinzuomei + * @description 组长开启/关闭入群审核 + * @Date 2020/11/17 14:18 + **/ + @PostMapping("editauditswitch") + public Result editAuditSwitch(@RequestBody EditAuditSwitchFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO,EditAuditSwitchFormDTO.AddUserShowGroup.class); + resiGroupService.editAuditSwitch(formDTO); + return new Result(); + } + /** * @Description 查询话题所属小组名 * @Param groupInfoFormDTO diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/dao/ResiGroupCodeDao.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/dao/ResiGroupCodeDao.java new file mode 100644 index 0000000000..14415b5447 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/dao/ResiGroupCodeDao.java @@ -0,0 +1,41 @@ +/** + * 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.group.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.modules.group.entity.ResiGroupCodeEntity; +import com.epmet.resi.group.dto.group.form.GroupCodeBasicInfoFormDTO; +import com.epmet.resi.group.dto.group.result.GroupCodeBasicInfoResultDTO; +import org.apache.ibatis.annotations.Mapper; + +/** + * 小组二维码 小组唯一二维码,海报码和小组码是同一个二维码,长期有效的 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-11-13 + */ +@Mapper +public interface ResiGroupCodeDao extends BaseDao { + + /** + * @param formDTO + * @Description 获取生成海报(小组码)信息 + * @author sun + */ + GroupCodeBasicInfoResultDTO selectGroupCodeBasicInfo(GroupCodeBasicInfoFormDTO formDTO); +} diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/entity/ResiGroupCodeEntity.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/entity/ResiGroupCodeEntity.java new file mode 100644 index 0000000000..3859492d3a --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/entity/ResiGroupCodeEntity.java @@ -0,0 +1,72 @@ +/** + * 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.group.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 小组二维码 小组唯一二维码,海报码和小组码是同一个二维码,长期有效的 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-11-13 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("resi_group_code") +public class ResiGroupCodeEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户ID + */ + private String customerId; + + /** + * 网格ID + */ + private String gridId; + + /** + * 小组Id + */ + private String groupId; + + /** + * 二维码类型 + */ + private String type; + + /** + * 邀请ID + */ + private String invitationId; + + /** + * 二维码路径 + */ + private String url; + +} diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/entity/ResiGroupEntity.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/entity/ResiGroupEntity.java index 0305fb7834..8dfa5e2db8 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/entity/ResiGroupEntity.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/entity/ResiGroupEntity.java @@ -74,4 +74,9 @@ Ps: 如果一个小组被拒绝,当前小组的状态将永久停留在“审 */ private Date latestTopicPublishDate; + /** + * 进组审核open开启;close关闭 + */ + private String auditSwitch; + } diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/redis/ResiGroupCodeRedis.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/redis/ResiGroupCodeRedis.java new file mode 100644 index 0000000000..a34bae4c5e --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/redis/ResiGroupCodeRedis.java @@ -0,0 +1,58 @@ +/** + * 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.group.redis; + +import com.epmet.commons.tools.redis.RedisUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.Map; + +/** + * 小组二维码 小组唯一二维码,海报码和小组码是同一个二维码,长期有效的 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-11-13 + */ +@Component +public class ResiGroupCodeRedis { + @Autowired + private RedisUtils redisUtils; + + public void delete(Object[] ids) { + + } + + public void set(){ + + } + + public String get(String id){ + return null; + } + + /** + * @Description 获取刷新 + * @param key = epmet:wechartthird:authorizerrefreshtoken:customerId:clientType 前缀+客户ID+客户端类型 + * @author zxc + */ + public Map getAuthorizerRefreshToken(String key){ + Map result = redisUtils.hGetAll("epmet:wechartthird:authorizerrefreshtoken:" + key); + return result; + } +} diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupCodeService.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupCodeService.java new file mode 100644 index 0000000000..e0b5e7ec4d --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupCodeService.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.modules.group.service; + + +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.group.entity.ResiGroupCodeEntity; +import com.epmet.resi.group.dto.group.ResiGroupCodeDTO; +import com.epmet.resi.group.dto.group.form.CreateGroupCodeFormDTO; +import com.epmet.resi.group.dto.group.form.GetGroupCodeFormDTO; +import com.epmet.resi.group.dto.group.form.GroupCodeBasicInfoFormDTO; +import com.epmet.resi.group.dto.group.result.GroupCodeBasicInfoResultDTO; + +import java.util.List; +import java.util.Map; + +/** + * 小组二维码 小组唯一二维码,海报码和小组码是同一个二维码,长期有效的 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-11-13 + */ +public interface ResiGroupCodeService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-11-13 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-11-13 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return ResiGroupCodeDTO + * @author generator + * @date 2020-11-13 + */ + ResiGroupCodeDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-11-13 + */ + void save(ResiGroupCodeDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-11-13 + */ + void update(ResiGroupCodeDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-11-13 + */ + void delete(String[] ids); + + /** + * @Description 创建群组二维码 + * @param dto,syncFlag(是否同步执行,true同步,false异步) + * @return String + * @Author liushaowen + * @Date 2020/11/13 16:32 + */ + String createGroupCode(CreateGroupCodeFormDTO dto, boolean syncFlag); + + /** + * @Description 获取群组二维码 + * @param dto + * @return com.epmet.commons.tools.utils.Result + * @Author liushaowen + * @Date 2020/11/16 9:37 + */ + Result getGroupCode(GetGroupCodeFormDTO dto); + + /** + * @param formDTO + * @Description 获取生成海报(小组码)信息 + * @author sun + */ + GroupCodeBasicInfoResultDTO groupCodeBasicInfo(GroupCodeBasicInfoFormDTO formDTO); +} 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 fa1768d946..0fd92bf582 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 @@ -27,6 +27,7 @@ import com.epmet.resi.group.dto.group.GroupProcessingCountResultDTO; import com.epmet.resi.group.dto.group.ResiGroupDTO; import com.epmet.resi.group.dto.group.form.*; import com.epmet.resi.group.dto.group.result.*; +import com.epmet.resi.group.dto.member.form.EditAuditSwitchFormDTO; import java.util.HashMap; import java.util.List; @@ -135,6 +136,7 @@ public interface ResiGroupService extends BaseService { * @Description 修改组信息 * @Date 2020/3/28 22:27 **/ + @Deprecated void modifyGroup(ModifyGroupFormDTO modifyGroupFormDTO); /** @@ -326,6 +328,15 @@ public interface ResiGroupService extends BaseService { */ void auditEdit(GroupEditionAuditFormDTO param); + /** + * @return void + * @param formDTO + * @author yinzuomei + * @description 组长开启/关闭入群审核 + * @Date 2020/11/17 14:18 + **/ + void editAuditSwitch(EditAuditSwitchFormDTO formDTO); + /** * @Description 查询话题所属小组名 * @Param groupInfoFormDTO diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupCodeServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupCodeServiceImpl.java new file mode 100644 index 0000000000..6615ca4bb1 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupCodeServiceImpl.java @@ -0,0 +1,305 @@ +/** + * 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.group.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +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.exception.ExceptionUtils; +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.HttpClientManager; +import com.epmet.commons.tools.utils.HttpContextUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.result.UploadImgResultDTO; +import com.epmet.feign.OssFeignClient; +import com.epmet.modules.group.dao.ResiGroupCodeDao; +import com.epmet.modules.group.entity.ResiGroupCodeEntity; +import com.epmet.modules.group.redis.ResiGroupCodeRedis; +import com.epmet.modules.group.service.ResiGroupCodeService; +import com.epmet.modules.group.service.ResiGroupService; +import com.epmet.modules.invitation.service.GroupInvitationService; +import com.epmet.modules.utils.ModuleConstant; +import com.epmet.resi.group.constant.GroupCodeConstant; +import com.epmet.resi.group.dto.QRCodeMultipartFileDTO; +import com.epmet.resi.group.dto.group.ResiGroupCodeDTO; +import com.epmet.resi.group.dto.group.form.CreateGroupCodeFormDTO; +import com.epmet.resi.group.dto.group.form.GetGroupCodeFormDTO; +import com.epmet.resi.group.dto.group.form.GroupCodeBasicInfoFormDTO; +import com.epmet.resi.group.dto.group.result.GroupCodeBasicInfoResultDTO; +import com.epmet.resi.group.dto.invitation.form.CreateGroupInvitationFormDTO; +import com.epmet.resi.group.dto.invitation.result.CreateGroupInvitationResultDTO; +import com.epmet.utils.ThirdUtils; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.io.UnsupportedEncodingException; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ExecutorService; + +/** + * 小组二维码 小组唯一二维码,海报码和小组码是同一个二维码,长期有效的 + * + * @author qu qu@elink-cn.com + * @since v1.0.0 2020-11-13 + */ +@Service +public class ResiGroupCodeServiceImpl extends BaseServiceImpl implements ResiGroupCodeService { + + private static final Logger logger = LoggerFactory.getLogger(ResiGroupCodeServiceImpl.class); + + @Autowired + private ResiGroupCodeRedis resiGroupCodeRedis; + + @Autowired + private OssFeignClient ossFeignClient; + + @Autowired + private ExecutorService executorService; + + @Autowired + private GroupInvitationService groupInvitationService; + + @Autowired + private ResiGroupService resiGroupService; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, ResiGroupCodeDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, ResiGroupCodeDTO.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 ResiGroupCodeDTO get(String id) { + ResiGroupCodeEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, ResiGroupCodeDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(ResiGroupCodeDTO dto) { + ResiGroupCodeEntity entity = ConvertUtils.sourceToTarget(dto, ResiGroupCodeEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(ResiGroupCodeDTO dto) { + ResiGroupCodeEntity entity = ConvertUtils.sourceToTarget(dto, ResiGroupCodeEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + /** + * @param dto, syncFlag(是否同步执行,true同步,false异步) + * @return String + * @Description 创建群组二维码 + * @Author liushaowen + * @Date 2020/11/13 16:32 + */ + @Override + public String createGroupCode(CreateGroupCodeFormDTO dto, boolean syncFlag) { + if (syncFlag){ + return createCodeFunction(dto); + }else { + executorService.execute(()->{ + try { + long startTs = System.currentTimeMillis(); + createCodeFunction(dto); + long endTs = System.currentTimeMillis(); + logger.info("异步创建群二维码成功,执行时长:{}", endTs - startTs); + } catch (Exception e) { + logger.error("异步创建群二维码失败,错误信息:{}", ExceptionUtils.getErrorStackTrace(e)); + } + }); + return ""; + } + } + + /** + * @param dto + * @return com.epmet.commons.tools.utils.Result + * @Description 获取群组二维码 + * @Author liushaowen + * @Date 2020/11/16 9:37 + */ + @Override + public Result getGroupCode(GetGroupCodeFormDTO dto) { + ResiGroupCodeEntity codeByGroupId = getCode(dto.getGroupId(), dto.getType()); + if (codeByGroupId != null) { + //数据库有数据 + return new Result().ok(codeByGroupId.getUrl()); + } else { + //从微信获取二维码并存储 + CreateGroupCodeFormDTO createDto = new CreateGroupCodeFormDTO(); + BeanUtils.copyProperties(dto, createDto); + String url = createGroupCode(createDto, true); + if (StringUtils.isBlank(url)){ + throw new RenException("获取二维码失败"); + } + return new Result().ok(url); + } + } + + private ResiGroupCodeEntity getCode(String groupId, String type) { + if (StringUtils.isBlank(groupId) || StringUtils.isBlank(type)) { + throw new RenException("获取二维码失败,groupId或type为空"); + } + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("DEL_FLAG", "0"); + queryWrapper.eq("GROUP_ID", groupId); + queryWrapper.eq("TYPE", type); + return baseDao.selectOne(queryWrapper); + } + + private String createCodeFunction(CreateGroupCodeFormDTO dto){ + String result = ""; + ResiGroupCodeEntity codeByGroupId = getCode(dto.getGroupId(), dto.getType()); + if (codeByGroupId != null) { + logger.error("本群组该类型二维码已存在,请勿重复添加。groupId:{},type:{}", dto.getGroupId(), dto.getType()); + throw new RenException("本群组该类型二维码已存在,请勿重复添加。"); + } else { + //向微信获取二维码 + + // 获取AccessToken + String accessToken = ThirdUtils.getAccessToken(dto.getCustomerId()).getResiToken(); + if (StringUtils.isBlank(accessToken)) { + logger.error("获取accessToken失败,customerId:{}", dto.getCustomerId()); + throw new RenException("获取accessToken失败"); + } + //跳转的页面 + StringBuilder path = new StringBuilder(ModuleConstant.CODE_INVITE_PAGE); + //获取invitationId + CreateGroupInvitationFormDTO invitationFormDTO = new CreateGroupInvitationFormDTO(); + //获取群主userId + invitationFormDTO.setUserId(resiGroupService.get(dto.getGroupId()).getCreatedBy()); + invitationFormDTO.setGroupId(dto.getGroupId()); + CreateGroupInvitationResultDTO groupScanCodeInvitation = groupInvitationService.createGroupScanCodeInvitation(invitationFormDTO); + path.append("?invitationId=").append(groupScanCodeInvitation.getInvitationId()); + + //需要发送的Json + JSONObject data = new JSONObject(); + data.put("path", path.toString()); + data.put("width", 400); + //发送 + byte[] buffer = HttpClientManager.getInstance().getMediaByteArray(ModuleConstant.GET_CODE_URL + accessToken, JSON.toJSONString(data)).getData(); + if (buffer != null && buffer.length < 500) { + String wxResult = ""; + try { + wxResult = new String(buffer, "UTF-8"); + if (-1 != wxResult.indexOf("errcode")) { + logger.error("获取二维码接口返回错误:{}", wxResult); + throw new RenException("获取二维码失败"); + } + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + } + //上传 + QRCodeMultipartFileDTO qrCodeMultipartFile = new QRCodeMultipartFileDTO(); + qrCodeMultipartFile.setBytes(buffer); + qrCodeMultipartFile.setOriginalFilename("qrcode.jpg"); + Result uploadResult = ossFeignClient.uploadQrCode(qrCodeMultipartFile); + if (uploadResult.success()) { + result = uploadResult.getData().getUrl(); + //存表 + ResiGroupCodeEntity entity = new ResiGroupCodeEntity(); + BeanUtils.copyProperties(dto, entity); + entity.setInvitationId(groupScanCodeInvitation.getInvitationId()); + entity.setUrl(uploadResult.getData().getUrl()); + baseDao.insert(entity); + } else { + logger.error("上传图片失败:{}", uploadResult.getMsg()); + throw new RenException("上传图片失败"); + } + } + return result; + } + + /** + * @param formDTO + * @Description 获取生成海报(小组码)信息 + * @author sun + */ + @Override + public GroupCodeBasicInfoResultDTO groupCodeBasicInfo(GroupCodeBasicInfoFormDTO formDTO) { + String headUrl = ""; + String url = ""; + //1.获取小组基本信息 + GroupCodeBasicInfoResultDTO resultDTO = baseDao.selectGroupCodeBasicInfo(formDTO); + if (null == resultDTO) { + logger.error(String.format("获取小组码基本信息失败,小组Id:%s", formDTO.getGroupId())); + throw new RenException("获取小组码基本信息失败"); + } + if (null == resultDTO.getGroupCodeUrl() || "".equals(resultDTO.getGroupCodeUrl())) { + CreateGroupCodeFormDTO dto = ConvertUtils.sourceToTarget(formDTO, CreateGroupCodeFormDTO.class); + dto.setType(GroupCodeConstant.CODE_TYPE_INVITE); + url = createGroupCode(dto, true); + if (StringUtils.isBlank(url)) { + logger.error(String.format("生成小组二维码失败,小组Id:%s", formDTO.getGroupId())); + throw new RenException("获取小组码基本信息失败"); + } + resultDTO.setGroupCodeUrl(url); + } + headUrl = resultDTO.getGroupHeadPhoto(); + url = resultDTO.getGroupCodeUrl(); + + //2.图片的url,服务器域名端口+storage+阿里云相对路径,storage段是为了nginx做oss代理,前缀 + String requestDomain = HttpContextUtils.getRequestServerNameAndPort(); + resultDTO.setGroupHeadPhoto(requestDomain.concat(headUrl.replaceAll(GroupCodeConstant.PATTERN, GroupCodeConstant.STORAGE))); + resultDTO.setGroupCodeUrl(requestDomain.concat(url.replaceAll(GroupCodeConstant.PATTERN, GroupCodeConstant.STORAGE))); + return resultDTO; + } + +} 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 b2aae6f9b5..5a2a9915cb 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 @@ -28,6 +28,10 @@ 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.page.PageData; +import com.epmet.commons.tools.security.user.LoginUserUtil; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.scan.param.ImgScanParamDTO; import com.epmet.commons.tools.scan.param.ImgTaskDTO; import com.epmet.commons.tools.scan.param.TextScanParamDTO; @@ -51,6 +55,7 @@ import com.epmet.modules.group.entity.GroupEditSubmitRecordEntity; import com.epmet.modules.group.entity.ResiGroupEntity; import com.epmet.modules.group.entity.ResiGroupOperationEntity; import com.epmet.modules.group.redis.ResiGroupRedis; +import com.epmet.modules.group.service.ResiGroupCodeService; import com.epmet.modules.group.service.ResiGroupOperationService; import com.epmet.modules.group.service.ResiGroupService; import com.epmet.modules.group.service.ResiGroupStatisticalService; @@ -71,6 +76,7 @@ import com.epmet.resi.group.dto.member.GroupMemeberOperationDTO; import com.epmet.resi.group.dto.member.ResiGroupMemberDTO; import com.epmet.resi.group.dto.member.ResiGroupMemberInfoRedisDTO; import com.github.pagehelper.PageHelper; +import com.epmet.resi.group.dto.member.form.EditAuditSwitchFormDTO; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -155,6 +161,9 @@ public class ResiGroupServiceImpl extends BaseServiceImpl page(Map params) { IPage page = baseDao.selectPage( @@ -555,6 +564,18 @@ public class ResiGroupServiceImpl extends BaseServiceImpl param = new HashMap<>(); @@ -793,7 +814,7 @@ public class ResiGroupServiceImpl extends BaseServiceImpl().ok(resultDTO); @@ -891,8 +912,8 @@ public class ResiGroupServiceImpl extends BaseServiceImpl accetInvitationV2(@LoginUser TokenDto tokenDto, @RequestBody AccetInvitationFormDTO formDTO) { + formDTO.setUserId(tokenDto.getUserId()); + formDTO.setApp(tokenDto.getApp()); + ValidatorUtils.validateEntity(formDTO); + return new Result().ok(groupInvitationService.accetInvitationV2(formDTO)); + } } diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/invitation/entity/GroupInvitationEntity.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/invitation/entity/GroupInvitationEntity.java index 5595d7fd5c..bba85a4635 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/invitation/entity/GroupInvitationEntity.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/invitation/entity/GroupInvitationEntity.java @@ -68,4 +68,9 @@ public class GroupInvitationEntity extends BaseEpmetEntity { */ private Date validEndTime; + /** + * 邀请链接:invited;扫码:scancode + */ + private String invitationType; + } 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 053c4e036e..44f61b26ec 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 @@ -25,6 +25,7 @@ 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; import com.epmet.resi.group.dto.invitation.form.LinkGroupInfoFormDTO; +import com.epmet.resi.group.dto.invitation.result.AcceptInvitationResultDTO; import com.epmet.resi.group.dto.invitation.result.CreateGroupInvitationResultDTO; import com.epmet.resi.group.dto.invitation.result.LinkGroupInfoResultDTO; @@ -103,11 +104,20 @@ public interface GroupInvitationService extends BaseService * @param formDTO * @Author yinzuomei - * @Description 生成邀请连接 + * @Description 生成邀请连接-链接 * @Date 2020/3/31 22:50 **/ CreateGroupInvitationResultDTO createGroupInvitation(CreateGroupInvitationFormDTO formDTO); + /** + * @return com.epmet.commons.tools.utils.Result + * @param formDTO + * @Author liushaowen + * @Description 生成邀请连接-扫码 + * @Date 2020-11-17 13:58 + **/ + CreateGroupInvitationResultDTO createGroupScanCodeInvitation(CreateGroupInvitationFormDTO formDTO); + /** * @return com.epmet.commons.tools.utils.Result * @param formDTO @@ -124,5 +134,12 @@ public interface GroupInvitationService extends BaseService page(Map params) { @@ -181,6 +185,41 @@ public class GroupInvitationServiceImpl extends BaseServiceImpl + * @Author liushaowen + * @Description 生成邀请连接-扫码 + * @Date 2020-11-17 13:58 + **/ + @Override + public CreateGroupInvitationResultDTO createGroupScanCodeInvitation(CreateGroupInvitationFormDTO formDTO) { + //1、只有群主可以邀请新成员(这块界面限制死了,只有群主才能看到邀请新成员按钮) + //2、审核通过(讨论中)的群才可以分享邀请连接 + ResiGroupDTO resiGroupDTO = resiGroupService.get(formDTO.getGroupId()); + if (!GroupStateConstant.GROUP_APPROVED.equals(resiGroupDTO.getState())) { + logger.error(String.format("生成群成员链接失败,原因:%s",EpmetErrorCode.INVITE_NEW_MEMBER.getMsg())); + throw new RenException(EpmetErrorCode.INVITE_NEW_MEMBER.getCode()); + } + //3、插入一条邀请记录 + GroupInvitationEntity groupInvitationEntity = new GroupInvitationEntity(); + groupInvitationEntity.setInviterUserId(formDTO.getUserId()); + groupInvitationEntity.setInviterCustomerId(resiGroupDTO.getCustomerId()); + groupInvitationEntity.setInviterGridId(resiGroupDTO.getGridId()); + //添加类型字段 scancode + groupInvitationEntity.setInvitationType(GroupStateConstant.GROUP_SCANCODE); + //暂定50年有效期 + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) + NumConstant.FIFTY); + groupInvitationEntity.setValidEndTime(calendar.getTime()); + groupInvitationEntity.setResiGroupId(formDTO.getGroupId()); insert(groupInvitationEntity); CreateGroupInvitationResultDTO resultDTO = new CreateGroupInvitationResultDTO(); resultDTO.setInvitationId(groupInvitationEntity.getId()); @@ -206,6 +245,13 @@ public class GroupInvitationServiceImpl extends BaseServiceImpl result=resiGuideFeignClient.enterGrid(userEnterGridFormDTO); + if (!result.success() || null == result.getData()) { + logger.error(String.format("用户同意邀请进组,进入网格失败。入参:userId【%s】、invitationId【%s】、groupId【%s】、customerId【%s】、gridId【%s】", + formDTO.getUserId(), formDTO.getInvitationId(), + groupInvitationDTO.getResiGroupId()), + resiGroupDTO.getCustomerId(), resiGroupDTO.getGridId()); + logger.error(String.format("用户同意邀请进组,进入网格失败。当前接口返回8000,调用enterGrid接口返回", result.toString())); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } + //4、校验是否已经注册居民 + if(null==result.getData().getUserRoleList()||result.getData().getUserRoleList().size()==0){ + logger.error(String.format("用户同意邀请进组失败,返回角色列表为空错误编码%s,错误提示%s",EpmetErrorCode.CANNOT_JOIN_GROUP.getCode(),EpmetErrorCode.CANNOT_JOIN_GROUP.getMsg())); + throw new RenException(EpmetErrorCode.CANNOT_JOIN_GROUP.getCode()); + } + //2020.11.17 sun 新增扫描或邀请进组是否需要审核的逻辑 start + GroupMemeberOperationDTO groupMemeberOperation = new GroupMemeberOperationDTO(); + groupMemeberOperation.setGroupId(resiGroupDTO.getId()); + groupMemeberOperation.setCustomerUserId(formDTO.getUserId()); + groupMemeberOperation.setEnterGroupType(groupInvitationDTO.getInvitationType()); + groupMemeberOperation.setGroupInvitationId(formDTO.getInvitationId()); + groupMemeberOperation.setOperateUserId(formDTO.getUserId()); + //邀请入组 + if (StringUtils.isNotBlank(groupInvitationDTO.getInvitationType())) { + if (groupInvitationDTO.getInvitationType().equals(GroupStateConstant.GROUP_INVITED)) { + groupMemeberOperation.setOperateDes(UserMessageConstant.INVITED_OPERATE); + //扫码入组 + } else if (groupInvitationDTO.getInvitationType().equals(GroupStateConstant.GROUP_SCANCODE)) { + groupMemeberOperation.setOperateDes(UserMessageConstant.SCANCODE_OPERATE); + } + } else {//兼容旧程序 + groupMemeberOperation.setOperateDes(UserMessageConstant.INVITED_OPERATE); + } + //入组审核开关是开启状态则需要组长审核 + if (StringUtils.isNotBlank(resiGroupDTO.getAuditSwitch()) && GroupStateConstant.AUDIT_SWITCH_OPEN.equals(resiGroupDTO.getAuditSwitch())) { + groupMemeberOperation.setOperateStatus(MemberStateConstant.UNDER_AUDITTING); + //新增一条入组申请 + groupMemeberOperationService.accetInvitation(groupMemeberOperation); + //给小组长推送站内信 + resiGroupMemberServiceImpl.sendMessageToGroupLeader(resiGroupDTO, formDTO.getUserId()); + resultDTO.setAwaitAudit(true); + return resultDTO; + } + UserRoleDTO userRoleDTO = this.getUserRoleDTO(result.getData().getUserRoleList()); + //5、新增一条邀请入群、直接审核通过的入群记录 + groupMemeberOperation.setOperateStatus(MemberStateConstant.APPROVED); + //2020.11.17 end + groupMemeberOperationService.accetInvitation(groupMemeberOperation); + //6、直接加入群成员关系表 + //如果是之前被移除的,则修改resi_group_member记录 + ResiGroupMemberDTO resiGroupMemberDTO = new ResiGroupMemberDTO(); + ResiGroupMemberDTO resiGroupMember = resiGroupMemberDao.selectGroupMemberInfo(groupInvitationDTO.getResiGroupId(), formDTO.getUserId()); + if (null != resiGroupMember) { + resiGroupMemberDTO.setId(resiGroupMember.getId()); + } + resiGroupMemberDTO.setCustomerUserId(groupMemeberOperation.getCustomerUserId()); + resiGroupMemberDTO.setResiGroupId(groupMemeberOperation.getGroupId()); + resiGroupMemberDTO.setGroupLeaderFlag(LeaderFlagConstant.GROUP_MEMBER); + resiGroupMemberDTO.setEnterGroupType(groupMemeberOperation.getEnterGroupType()); + resiGroupMemberDTO.setStatus(MemberStateConstant.APPROVED); + resiGroupMemberDTO.setCreatedBy(groupMemeberOperation.getCustomerUserId()); + resiGroupMemberService.saveOrUpdate(resiGroupMemberDTO); + //7、修改群统计值 + resiGroupMemberDao.updateResiGroupStatistical(groupMemeberOperation.getGroupId(), userRoleDTO); ResiGroupInfoRedisDTO groupCache = resiGroupRedis.get(groupInvitationDTO.getResiGroupId()); if(null != groupCache && null != groupCache.getGroupStatisticalInfo()){ @@ -387,6 +551,7 @@ public class GroupInvitationServiceImpl extends BaseServiceImpl userRoleList) { @@ -428,7 +593,17 @@ public class GroupInvitationServiceImpl extends BaseServiceImpl resultUserInfo = epmetUserFeignClient.getUserResiInfoDTO(userResiInfoFormDTO); if (!resultUserInfo.success() || null == resultUserInfo.getData()) { - logger.error(String.format("居民申请入群,给组长发送消息通知错误,调用%s服务查询申请用户名称失败,入参%s", ServiceConstant.EPMET_USER_SERVER, JSON.toJSONString(userResiInfoFormDTO))); + logger.warn(String.format("居民申请入群,给组长发送消息通知错误,调用%s服务查询申请用户名称失败,入参%s", ServiceConstant.EPMET_USER_SERVER, JSON.toJSONString(userResiInfoFormDTO))); } else { currentUserName = resultUserInfo.getData().getShowName(); } @@ -288,7 +288,7 @@ public class ResiGroupMemberServiceImpl extends BaseServiceImpl list = baseDao.selectListGroupMember(groupMemberListFormDTO); if (null == list || list.size() == 0) { - logger.error(String.format("群成员列表查询列表为空,selectListGroupMember入参%s",JSON.toJSONString(groupMemberListFormDTO))); + logger.warn(String.format("群成员列表查询列表为空,selectListGroupMember入参%s",JSON.toJSONString(groupMemberListFormDTO))); return new ArrayList<>(); } List userIdList=new ArrayList<>(); @@ -424,13 +424,13 @@ public class ResiGroupMemberServiceImpl extends BaseServiceImpl r = epmetUserFeignClient.selectIssueInitiator(issueInitiator); + if (!r.success()){ + throw new RenException("查询话题发起人失败......"); + } + IssueInitiatorResultDTO issueInitiatorResult = r.getData(); if (!StringUtils.isBlank(issueInitiatorResult.getIssueInitiator())) { topicInfo.setPublishedUser(issueInitiatorResult.getIssueInitiator()); } @@ -1707,18 +1711,23 @@ public class ResiTopicServiceImpl extends BaseServiceImpl gridIdAndNames = new HashMap<>(); List gridIds = myTopics.stream().map(c -> c.getReleaseGridId()).collect(Collectors.toList()); + if (org.apache.commons.collections4.CollectionUtils.isEmpty(gridIds)) { + return myTopics; + } + Result> gridsResult = govOrgOpenFeignClient.getGridListByGridIds(gridIds); if (gridsResult.success()) { List grids = gridsResult.getData(); - grids.stream().forEach(g -> gridIdAndNames.put(g.getGridId(), g.getGridName())); + if (grids != null && grids.size() != 0) { + grids.stream().forEach(g -> gridIdAndNames.put(g.getGridId(), g.getGridName())); + for (MyCreateTopicsResultDTO myTopic : myTopics) { + myTopic.setReleaseGridName(gridIdAndNames.get(myTopic.getReleaseGridId())); + } + } } else { log.error("【我创建的话题列表】,查询组织-网格名称出错,没有抛出,内部处理。内部消息:{},外部消息:{}", gridsResult.getInternalMsg(), gridsResult.getMsg()); } - for (MyCreateTopicsResultDTO myTopic : myTopics) { - myTopic.setReleaseGridName(gridIdAndNames.get(myTopic.getReleaseGridId())); - } - return myTopics; } diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/utils/ModuleConstant.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/utils/ModuleConstant.java index d9ad6e9b8e..118ed1f5a7 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/utils/ModuleConstant.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/utils/ModuleConstant.java @@ -359,4 +359,13 @@ public interface ModuleConstant extends Constant { * 审核操作 拒绝 */ String AUDITING_OPERATION_REJECT = "rejected"; + + /** + * 获取二维码的url + */ + String GET_CODE_URL = "https://api.weixin.qq.com/wxa/getwxacode?access_token="; + /** + * 群邀请二维码跳转页面 + */ + String CODE_INVITE_PAGE = "pages/group/group/invitation/invitation"; } diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/properties/ThreadProperties.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/properties/ThreadProperties.java new file mode 100644 index 0000000000..aaec7cb719 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/properties/ThreadProperties.java @@ -0,0 +1,25 @@ +package com.epmet.properties; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * 线程池属性类 + */ +@ConfigurationProperties(prefix = "thread") +@Data +public class ThreadProperties { + + private ThreadPoolProperties threadPool; + + @Data + public static class ThreadPoolProperties { + private int corePoolSize; + private int maxPoolSize; + private int queueCapacity; + private int keepAlive; + + public ThreadPoolProperties() { + } + } +} diff --git a/epmet-module/resi-group/resi-group-server/src/main/resources/bootstrap.yml b/epmet-module/resi-group/resi-group-server/src/main/resources/bootstrap.yml index d836a237c2..717cff838d 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/resources/bootstrap.yml +++ b/epmet-module/resi-group/resi-group-server/src/main/resources/bootstrap.yml @@ -127,6 +127,15 @@ openapi: imgSyncScan: /imgSyncScan textSyncScan: /textSyncScan +thread: + # 线程池配置 + threadPool: + corePoolSize: @thread.pool.core-pool-size@ + maxPoolSize: @thread.pool.max-pool-size@ + queueCapacity: @thread.pool.queue-capacity@ + keepAlive: @thread.pool.keep-alive@ + + dingTalk: robot: webHook: @dingTalk.robot.webHook@ diff --git a/epmet-module/resi-group/resi-group-server/src/main/resources/db/migration/V0.0.5__group_code.sql b/epmet-module/resi-group/resi-group-server/src/main/resources/db/migration/V0.0.5__group_code.sql new file mode 100644 index 0000000000..3dfd63919e --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/resources/db/migration/V0.0.5__group_code.sql @@ -0,0 +1,16 @@ +CREATE TABLE `resi_group_code` ( + `ID` varchar(64) NOT NULL COMMENT '主键', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户ID', + `GRID_ID` varchar(64) NOT NULL COMMENT '网格ID', + `GROUP_ID` varchar(64) NOT NULL COMMENT '小组Id', + `INVITATION_ID` varchar(64) NOT NULL COMMENT '邀请id', + `TYPE` varchar(32) NOT NULL COMMENT '微信二维码使用类型 邀请:invite', + `URL` varchar(128) NOT NULL COMMENT '二维码路径', + `DEL_FLAG` varchar(1) NOT NULL COMMENT '删除标志', + `REVISION` int(11) NOT NULL COMMENT '乐观锁', + `CREATED_BY` varchar(32) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='小组二维码 小组唯一二维码,海报码和小组码是同一个二维码,长期有效的'; \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/resources/db/migration/V0.0.6__group_audit_switch.sql b/epmet-module/resi-group/resi-group-server/src/main/resources/db/migration/V0.0.6__group_audit_switch.sql new file mode 100644 index 0000000000..a23bb95f98 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/resources/db/migration/V0.0.6__group_audit_switch.sql @@ -0,0 +1,9 @@ +ALTER TABLE `resi_group` +ADD COLUMN `AUDIT_SWITCH` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'open' COMMENT '进组审核open开启;close关闭' AFTER `LATEST_TOPIC_PUBLISH_DATE`; + +ALTER TABLE `group_invitation` +ADD COLUMN `INVITATION_TYPE` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'link' COMMENT '邀请链接:invited;扫码:scancode' AFTER `RESI_GROUP_ID`; + +alter table group_memeber_operation MODIFY ENTER_GROUP_TYPE varchar(32) not null comment '入群方式:(受邀请入群 - invited;主动加入 - join;created创建群自动进入;scancode扫码入群)'; + +alter table resi_group_member modify ENTER_GROUP_TYPE varchar(32) not null comment '入群方式:(受邀请入群 - invited 、 主动加入 - join、created创建群自动进入、扫码入群-scancode)'; diff --git a/epmet-module/resi-group/resi-group-server/src/main/resources/db/migration/V0.0.7__group_invitation.sql b/epmet-module/resi-group/resi-group-server/src/main/resources/db/migration/V0.0.7__group_invitation.sql new file mode 100644 index 0000000000..8b67b6e747 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/resources/db/migration/V0.0.7__group_invitation.sql @@ -0,0 +1,6 @@ +ALTER TABLE `group_invitation` +DROP COLUMN `INVITATION_TYPE`; + +ALTER TABLE `group_invitation` +ADD COLUMN `INVITATION_TYPE` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'invited' COMMENT '邀请链接:invited;扫码:scancode' AFTER `RESI_GROUP_ID`; + diff --git a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/group/ResiGroupCodeDao.xml b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/group/ResiGroupCodeDao.xml new file mode 100644 index 0000000000..a3cc1c6fd5 --- /dev/null +++ b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/group/ResiGroupCodeDao.xml @@ -0,0 +1,27 @@ + + + + + + + + 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 356844a5c2..ccc4d1b945 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 @@ -150,7 +150,8 @@ AND gmo.GROUP_ID = rg.id AND gmo.OPERATE_STATUS = 'under_auditting' ) AS totalApplyingMember, - rgs.TOTAL_TOPICS + rgs.TOTAL_TOPICS, + rg.AUDIT_SWITCH 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/member/ResiGroupMemberDao.xml b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/member/ResiGroupMemberDao.xml index 7910965741..f125ebb551 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/member/ResiGroupMemberDao.xml +++ b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/member/ResiGroupMemberDao.xml @@ -30,8 +30,9 @@ gmo.CUSTOMER_USER_ID AS applyUserId, NULL AS applyUserHeadPhoto, NULL AS applyUserName, - gmo.OPERATE_DES AS applyReason, - gmo.OPERATE_STATUS as status + IFNULL(gmo.OPERATE_DES, '') AS applyReason, + gmo.OPERATE_STATUS as status, + gmo.ENTER_GROUP_TYPE as enterGroupType FROM group_memeber_operation gmo WHERE diff --git a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/ResiTopicDao.xml b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/ResiTopicDao.xml index 0267f664c4..f51b0f7216 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/ResiTopicDao.xml +++ b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/topic/ResiTopicDao.xml @@ -506,7 +506,6 @@ resi_topic WHERE del_flag = '0' - AND STATUS = 'discussing' AND created_by = #{userId} diff --git a/epmet-module/resi-mine/resi-mine-client/src/main/java/com/epmet/resi/mine/dto/result/InitInfoResultDTO.java b/epmet-module/resi-mine/resi-mine-client/src/main/java/com/epmet/resi/mine/dto/result/InitInfoResultDTO.java index f89028a9dd..75c60668c6 100644 --- a/epmet-module/resi-mine/resi-mine-client/src/main/java/com/epmet/resi/mine/dto/result/InitInfoResultDTO.java +++ b/epmet-module/resi-mine/resi-mine-client/src/main/java/com/epmet/resi/mine/dto/result/InitInfoResultDTO.java @@ -36,4 +36,8 @@ public class InitInfoResultDTO implements Serializable { * 详细地址 */ private String buildingAddress; + /** + * 昵称 + */ + private String nickname; } diff --git a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/mine/service/impl/PersonalCenterServiceImpl.java b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/mine/service/impl/PersonalCenterServiceImpl.java index f758bf53b4..d3cf8a2a64 100644 --- a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/mine/service/impl/PersonalCenterServiceImpl.java +++ b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/mine/service/impl/PersonalCenterServiceImpl.java @@ -39,6 +39,7 @@ public class PersonalCenterServiceImpl implements PersonalCenterService { resultDTO.setStreet(baseInfoResult.getData().getStreet()); resultDTO.setDistrict(baseInfoResult.getData().getDistrict()); resultDTO.setBuildingAddress(baseInfoResult.getData().getBuildingAddress()); + resultDTO.setNickname(baseInfoResult.getData().getNickname()); return resultDTO; } diff --git a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/person/service/impl/TopicServiceImpl.java b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/person/service/impl/TopicServiceImpl.java index fe816108c1..3d8cadd357 100644 --- a/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/person/service/impl/TopicServiceImpl.java +++ b/epmet-module/resi-mine/resi-mine-server/src/main/java/com/epmet/modules/person/service/impl/TopicServiceImpl.java @@ -58,18 +58,23 @@ public class TopicServiceImpl implements TopicService { } List projects = result.getData(); + if (org.apache.commons.collections4.CollectionUtils.isEmpty(projects)) { + return new ArrayList(); + } List projectTopics = ConvertUtils.sourceToTarget(projects, MyShiftProjectTopicsResultDTO.class); List gridIds = projects.stream().map(p -> p.getGridId()).collect(Collectors.toList()); Result> rst = govOrgOpenFeignClient.getGridListByGridIds(gridIds); if (!rst.success()) { - logger.error("查询我创建的话题列表(已转议题),根据网格id查询网格名称失败, InternalMsg:{},Msg:{}", rst.getInternalMsg(), rst.getMsg()); + logger.error("查询我创建的话题列表(已转项目),根据网格id查询网格名称失败, InternalMsg:{},Msg:{}", rst.getInternalMsg(), rst.getMsg()); } else { List gridInfos = rst.getData(); - HashMap gridIdAndNames = new HashMap<>(); - gridInfos.stream().forEach(g -> gridIdAndNames.put(g.getGridId(), g.getGridName())); - projectTopics.stream().forEach(pt -> pt.setReleaseGridName(gridIdAndNames.get(pt.getGridId()))); + if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(gridInfos)) { + HashMap gridIdAndNames = new HashMap<>(); + gridInfos.stream().forEach(g -> gridIdAndNames.put(g.getGridId(), g.getGridName())); + projectTopics.stream().forEach(pt -> pt.setReleaseGridName(gridIdAndNames.get(pt.getGridId()))); + } } return projectTopics; diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/warmhearted/service/impl/ResiWarmheartedApplyServiceImpl.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/warmhearted/service/impl/ResiWarmheartedApplyServiceImpl.java index d1c595282e..cc6d73e9f0 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/warmhearted/service/impl/ResiWarmheartedApplyServiceImpl.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/warmhearted/service/impl/ResiWarmheartedApplyServiceImpl.java @@ -423,7 +423,7 @@ public class ResiWarmheartedApplyServiceImpl extends BaseServiceImpl> listRolesByRoleKey(@PathVariable("role-key") String roleKey); + /** + * 根据userId集合查询用户注册信息 + * @author sun + */ + @PostMapping("/epmetuser/userresiinfo/getuserresiinfolist") + Result> getUserResiInfoList(@RequestBody UserResiInfoListFormDTO userResiInfoListFormDTO); + + /** * @Description 个人中心-我的建议列表 * @param dto diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java index 938973838a..69371a19cd 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/feign/fallback/EpmetUserOpenFeignClientFallback.java @@ -283,6 +283,11 @@ public class EpmetUserOpenFeignClientFallback implements EpmetUserOpenFeignClien return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "listRolesByRoleKey", roleKey); } + @Override + public Result> getUserResiInfoList(UserResiInfoListFormDTO fromDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "getUserResiInfoList", fromDTO); + } + @Override public Result> myAdviceList(MyAdviceListFormDTO dto) { return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "myAdviceList", dto); diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/BadgeMessageConstant.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/BadgeMessageConstant.java index 429baa87ad..459f67554c 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/BadgeMessageConstant.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/BadgeMessageConstant.java @@ -19,5 +19,5 @@ public interface BadgeMessageConstant { /** * 审核驳回消息模板 */ - String REJECTED_MSG = "您好,您提交的%s申请,由于%s,已被驳回。"; + String REJECTED_MSG = "您好,您的%s由于%s,已被驳回。"; } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/BadgeController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/BadgeController.java index f4e2c3feee..edf52d1f97 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/BadgeController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/BadgeController.java @@ -1,6 +1,7 @@ package com.epmet.controller; import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.aop.NoRepeatSubmit; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; @@ -82,6 +83,7 @@ public class BadgeController { * @return com.epmet.commons.tools.utils.Result */ @PostMapping("edit") + @NoRepeatSubmit public Result edit(@LoginUser TokenDto tokenDto, @RequestBody EditBadgeFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO); badgeService.edit(tokenDto, formDTO); @@ -147,6 +149,7 @@ public class BadgeController { * @return com.epmet.commons.tools.utils.Result */ @PostMapping("audit") + @NoRepeatSubmit public Result audit(@LoginUser TokenDto tokenDto, @RequestBody BadgeAuditFormDTO formDTO) { ValidatorUtils.validateEntity(formDTO); badgeService.audit(tokenDto, formDTO); diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserAdviceController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserAdviceController.java index ed52f4da9d..e33e672739 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserAdviceController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserAdviceController.java @@ -42,6 +42,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.List; import java.util.Map; import java.util.regex.Pattern; @@ -145,9 +148,18 @@ public class UserAdviceController { @PostMapping("advicelist") public Result> adviceList(@RequestBody AdviceListFormDTO dto) { ValidatorUtils.validateEntity(dto); - if (dto.getStartTime() != null && dto.getEndTime() != null) { - if (dto.getStartTime().after(dto.getEndTime())) { - throw new RenException("开始时间不能大于结束时间"); + //校验时间 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + if (StringUtils.isNotBlank(dto.getStartTime()) && StringUtils.isNotBlank(dto.getEndTime())){ + try { + Date start = sdf.parse(dto.getStartTime()); + Date end = sdf.parse(dto.getEndTime()); + if (start.after(end)){ + throw new RenException("开始时间不能大于结束时间"); + } + }catch (ParseException e){ + throw new RenException("日期转换失败"); } } PageData page = userAdviceService.adviceList(dto); diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java index 2765fd9064..e4ad4a63b0 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/UserBadgeController.java @@ -74,7 +74,7 @@ public class UserBadgeController { } /** - * @Description 个人中心-获取徽章认证页面详情 + * @Description 个人中心-获取徽章认证页面详情 如果是未认证,则将居民base信息带出,如果是已认证,根据上次认证信息显示内容 * @Param tokenDto * @Param certificationDetailFormDTO * @author zxc diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeCertificateRecordDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeCertificateRecordDao.java index f7f4dba91c..2d73b4bac6 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeCertificateRecordDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/UserBadgeCertificateRecordDao.java @@ -20,6 +20,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.entity.UserBadgeCertificateRecordEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; /** * 用户认证徽章记录表 @@ -29,5 +30,14 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface UserBadgeCertificateRecordDao extends BaseDao { - + + /** + * @Description 查询是否已存在记录 + * @Param badgeId + * @Param userId + * @author zxc + * @date 2020/11/23 上午9:50 + */ + Integer selectIsExist(@Param("badgeId")String badgeId,@Param("userId")String userId); + } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java index 13a8dd8b2c..d29a25ec0f 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java @@ -178,6 +178,7 @@ public class UserBadgeRedis { * @date 2020.11.05 13:37 */ public long pushOrRemoveUserBadge4List(String userId, String badgeId, String customerId) { + if(StringUtils.isNotBlank(userId)) return illumeOrExtinguishStronglyConsistent(userId,customerId); List orient = redisUtils.lrange(UserRedisKeys.getResiUserBadgeKey(customerId,userId), NumConstant.ZERO, NumConstant.ONE_NEG, UserBadgeUnitFormDTO.class); UserBadgeUnitFormDTO unit = null; @@ -210,6 +211,27 @@ public class UserBadgeRedis { return NumConstant.ONE; } + /** + * @Description 用户点亮或取消徽章 强一致性 + * @param + * @return long + * @author wangc + * @date 2020.11.25 14:17 + */ + public long illumeOrExtinguishStronglyConsistent(String userId, String customerId){ + List db = badgeService.getUserSortedBadge(userId,customerId); + redisUtils.delete(UserRedisKeys.getResiUserBadgeKey(customerId,userId)); + if(CollectionUtils.isNotEmpty(db)) { + redisTemplate.executePipelined((RedisCallback>) connection -> { + db.forEach(badge -> { + connection.listCommands().rPush(UserRedisKeys.getResiUserBadgeKey(customerId, userId).getBytes(), + redisTemplate.getValueSerializer().serialize(badge)); + }); + return null; + }); + } + return NumConstant.ONE; + } /** * @Description 批量清除用户徽章信息,用处:在客户取消点亮某个徽章后,批量清除该客户下所有用户的徽章缓存,当需要查取时再次初始化进缓存中 diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeService.java index a8c7e7b0f9..ecdfd1d4db 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/UserBadgeService.java @@ -47,7 +47,7 @@ public interface UserBadgeService { void badgeSendCode(BadgeSendCodeFormDTO badgeSendCodeFormDTO); /** - * @Description 个人中心-获取徽章认证页面详情 + * @Description 个人中心-获取徽章认证页面详情 如果是未认证,则将居民base信息带出,如果是已认证,根据上次认证信息显示内容 * @Param tokenDto * @Param certificationDetailFormDTO * @author zxc diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/BadgeServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/BadgeServiceImpl.java index 0e0b6012a9..3a92a310fb 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/BadgeServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/BadgeServiceImpl.java @@ -36,6 +36,7 @@ import com.epmet.constant.BadgeConstant; import com.epmet.constant.BadgeMessageConstant; import com.epmet.constant.UserConstant; import com.epmet.dao.BadgeDao; +import com.epmet.dao.UserBadgeDao; import com.epmet.dto.BadgeDTO; import com.epmet.dto.ResiUserBadgeDTO; import com.epmet.dto.UserBadgeCertificateRecordDTO; @@ -80,6 +81,8 @@ public class BadgeServiceImpl extends BaseServiceImpl imp private MessageFeignClient messageFeignClient; @Autowired private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; + @Autowired + private UserBadgeDao userBadgeDao; @Override @@ -159,6 +162,13 @@ public class BadgeServiceImpl extends BaseServiceImpl imp @Override @Transactional(rollbackFor = Exception.class) public void add(TokenDto tokenDto, AddBadgeFormDTO formDTO) { + //上线徽章数校验 + if(BadgeConstant.ONLINE.equals(formDTO.getBadgeStatus())) { + List onlineList = userBadgeDao.selectAllBadge(tokenDto.getCustomerId()); + if (CollectionUtils.isNotEmpty(onlineList) && onlineList.size() >= NumConstant.FIVE) { + throw new RenException(EpmetErrorCode.ONLINE_BADGE_COUNT.getCode()); + } + } //重名校验 List list = baseDao.getDuplicateName(tokenDto.getCustomerId(), formDTO.getBadgeName()); if (CollectionUtils.isNotEmpty(list)) { @@ -215,6 +225,16 @@ public class BadgeServiceImpl extends BaseServiceImpl imp @Override @Transactional(rollbackFor = Exception.class) public void edit(TokenDto tokenDto, EditBadgeFormDTO formDTO) { + //上线徽章数校验 + if(BadgeConstant.ONLINE.equals(formDTO.getBadgeStatus())) { + List onlineList = userBadgeDao.selectAllBadge(tokenDto.getCustomerId()); + if (CollectionUtils.isNotEmpty(onlineList) && onlineList.size() >= NumConstant.FIVE) { + BadgeEntity badge = baseDao.selectBadgeInfo(tokenDto.getCustomerId(), formDTO.getBadgeId()); + if (BadgeConstant.OFFLINE.equals(badge.getBadgeStatus())) { + throw new RenException(EpmetErrorCode.ONLINE_BADGE_COUNT.getCode()); + } + } + } //重名校验 List list = baseDao.getDuplicateNameForEdit(tokenDto.getCustomerId(), formDTO.getBadgeId(), formDTO.getBadgeName()); if (CollectionUtils.isNotEmpty(list)) { diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserAdviceServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserAdviceServiceImpl.java index 46a5e96c95..9fb3f13947 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserAdviceServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserAdviceServiceImpl.java @@ -61,6 +61,8 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.*; /** @@ -251,6 +253,7 @@ public class UserAdviceServiceImpl extends BaseServiceImpl wrapper = new QueryWrapper<>(); //del_flag + wrapper.eq("DEL_FLAG","0"); //客户Id wrapper.eq(StringUtils.isNotBlank(dto.getCustomerId()), "CUSTOMER_ID", dto.getCustomerId()); @@ -264,10 +267,11 @@ public class UserAdviceServiceImpl extends BaseServiceImplwrapper1.eq("AGENCY_ID", dto.getAgencyId()) @@ -290,7 +294,7 @@ public class UserAdviceServiceImpl extends BaseServiceImpl result = new ArrayList<>(); + result.addAll(userBadgeListResultDTOS); redisUserBadgeList.forEach(u -> { userBadgeListResultDTOS.forEach(badge -> { if (u.getBadgeId().equals(badge.getBadgeId())){ badge.setBadgeIcon(u.getBadgeIcon()); + u.setUpdatedTime(badge.getUpdatedTime()); u.setStatus(true); } }); }); - List noOpenBadge = new ArrayList<>(); - redisUserBadgeList.forEach(u -> { - if (!u.getStatus()){ - noOpenBadge.add(u); - } - }); - if (!CollectionUtils.isEmpty(noOpenBadge)){ - userBadgeListResultDTOS.addAll(noOpenBadge); + Map> collect = redisUserBadgeList.stream().collect(Collectors.groupingBy(UserBadgeListResultDTO::getStatus)); + List noIsLight = collect.get(false); + if (CollectionUtils.isEmpty(noIsLight)){ + return result; } - return userBadgeListResultDTOS.stream().sorted(Comparator.comparing(UserBadgeListResultDTO::getIsOpened,Comparator.reverseOrder()).thenComparing(UserBadgeListResultDTO::getUpdatedTime,Comparator.reverseOrder()).thenComparing(UserBadgeListResultDTO::getSort)).collect(Collectors.toList()); + result.addAll(noIsLight.stream().sorted(Comparator.comparing(UserBadgeListResultDTO::getSort)).collect(Collectors.toList())); + return result; } /** @@ -241,6 +244,10 @@ public class UserBadgeServiceImpl implements UserBadgeService { @Override @Transactional(rollbackFor = Exception.class) public Result authBadgeRecord(CertificationAddFormDTO certificationAddFormDTO) { + Integer recordCount = userBadgeCertificateRecordDao.selectIsExist(certificationAddFormDTO.getBadgeId(), certificationAddFormDTO.getUserId()); + if (recordCount>NumConstant.ZERO){ + throw new RenException("不允许重复提交审核"); + } log.info(JSON.toJSONString(certificationAddFormDTO)); AuthFieldFormDTO authFieldFormDTO = new AuthFieldFormDTO(); authFieldFormDTO.setCustomerId(certificationAddFormDTO.getCustomerId()); @@ -270,7 +277,8 @@ public class UserBadgeServiceImpl implements UserBadgeService { //TODO 站内信发送 String badgeName = badgeDao.selectBadgeName(form.getCustomerId(), form.getBadgeId()); - sendMessage(BadgeConstant.AUTH_TITLE,String.format(BadgeConstant.READ_FLAG,userBaseInfoResultDTOS.get(NumConstant.ZERO).getDistrict().concat(userBaseInfoResultDTOS.get(NumConstant.ZERO).getRealName()),badgeName),form.getGridId(),form.getUserId(),form.getCustomerId()); + String msg = String.format(BadgeConstant.MESSAGE_CONTENT, userBaseInfoResultDTOS.get(NumConstant.ZERO).getDistrict().concat(userBaseInfoResultDTOS.get(NumConstant.ZERO).getRealName()), badgeName); + sendMessage(BadgeConstant.AUTH_TITLE,msg,form.getGridId(),form.getUserId(),form.getCustomerId()); return new Result(); } @@ -326,10 +334,18 @@ public class UserBadgeServiceImpl implements UserBadgeService { */ @Override public CertificationDetailResultDTO certificationDetail(TokenDto tokenDto, CertificationDetailFormDTO certificationDetailFormDTO) { + //工作端 if (StringUtils.isNotBlank(certificationDetailFormDTO.getRecordId())){ return userBadgeDao.selectBadgeAuthRecord(null, certificationDetailFormDTO.getBadgeId(),certificationDetailFormDTO.getRecordId()); } - return userBadgeDao.selectBadgeAuthRecord(tokenDto.getUserId(), certificationDetailFormDTO.getBadgeId(),certificationDetailFormDTO.getRecordId()); + //居民端 + CertificationDetailResultDTO resiResult = userBadgeDao.selectBadgeAuthRecord(tokenDto.getUserId(), certificationDetailFormDTO.getBadgeId(),certificationDetailFormDTO.getRecordId()); + if(null == resiResult){ + UserBaseInfoResultDTO userInfo = userBaseInfoRedis.getUserInfo(tokenDto.getUserId()); + resiResult = ConvertUtils.sourceToTarget(userInfo,CertificationDetailResultDTO.class); + if(null != resiResult) resiResult.setIdcard(userInfo.getIdNum()); + } + return resiResult; } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBaseInfoServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBaseInfoServiceImpl.java index 7a961e6fd9..2072097574 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBaseInfoServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/UserBaseInfoServiceImpl.java @@ -35,6 +35,7 @@ import com.epmet.dto.form.ResiVolunteerAuthenticateFormDTO; import com.epmet.dto.form.UserRoleFormDTO; import com.epmet.dto.result.*; import com.epmet.entity.UserBaseInfoEntity; +import com.epmet.entity.UserWechatEntity; import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.redis.UserBaseInfoRedis; import com.epmet.resi.partymember.dto.partymember.PartymemberInfoDTO; @@ -341,11 +342,22 @@ public class UserBaseInfoServiceImpl extends BaseServiceImpl list = userWechatDao.selectByUserId(param.getUserId()); + if (list.size() > NumConstant.ZERO) { + result.setWxOpenId(StringUtils.isNotBlank(list.get(NumConstant.ZERO).getWxOpenId()) ? list.get(NumConstant.ZERO).getWxOpenId() : ""); + } + result.setGender(StringUtils.isNotBlank(userMsg.getGender()) ? userMsg.getGender() : ""); + //end }else{ logger.error("com.epmet.service.impl.UserBaseInfoServiceImpl.extUserInfo,查询不到用户信息,用户Id:{}",param.getUserId()); return result; diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/BadgeDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/BadgeDao.xml index db53fcc094..c9be676412 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/BadgeDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/BadgeDao.xml @@ -306,6 +306,7 @@ FROM badge WHERE DEL_FLAG = 0 AND (CUSTOMER_ID = 'default' OR CUSTOMER_ID = #{customerId}) + AND ID = #{badgeId} ORDER BY CREATED_TIME DESC LIMIT 1 diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeCertificateRecordDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeCertificateRecordDao.xml index a2f59e8b8e..2a58027d9c 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeCertificateRecordDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeCertificateRecordDao.xml @@ -28,5 +28,17 @@ + + + \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml index 74183a1073..9e00787142 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/UserBadgeDao.xml @@ -31,14 +31,25 @@ b.sort, UNIX_TIMESTAMP(ub.updated_time) AS updatedTime FROM resi_user_badge ub - LEFT JOIN badge b ON b.ID = ub.BADGE_ID + LEFT JOIN + (SELECT * FROM + ( + SELECT * FROM badge + WHERE CUSTOMER_ID = #{customerId} AND DEL_FLAG = '0' AND BADGE_STATUS = 'online' + UNION ALL + SELECT * FROM badge a + WHERE CUSTOMER_ID = 'default' AND a.DEL_FLAG = '0' + AND NOT EXISTS + ( SELECT ID FROM badge b WHERE CUSTOMER_ID = #{customerId} AND a.ID = b.ID)) t + ORDER BY + CREATED_TIME DESC) b ON b.ID = ub.BADGE_ID WHERE ub.DEL_FLAG = '0' - AND b.DEL_FLAG = 0 - AND ub.CERTIFICATION_AUTID_STATUS = 'approved' - AND b.CUSTOMER_ID = 'default' - AND b.BADGE_STATUS = 'online' - AND ub.USER_ID = #{userId} - ORDER BY ub.UPDATED_TIME DESC + AND b.DEL_FLAG = 0 + AND ub.CERTIFICATION_AUTID_STATUS = 'approved' + AND b.BADGE_STATUS = 'online' + AND ub.IS_OPENED = 1 + AND ub.USER_ID = #{userId} + ORDER BY ub.UPDATED_TIME DESC @@ -219,7 +230,7 @@ badgeInfo.BADGE_ICON FROM resi_user_badge userBadge - LEFT JOIN ( + INNER JOIN ( SELECT id AS badgeId, CUSTOMER_ID, @@ -265,7 +276,7 @@ badgeInfo.BADGE_ICON FROM resi_user_badge userBadge - LEFT JOIN ( + INNER JOIN ( SELECT id AS badgeId, CUSTOMER_ID, diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/UserBaseInfoDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/UserBaseInfoDao.xml index 276e11a1ac..260fe0db93 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/UserBaseInfoDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/UserBaseInfoDao.xml @@ -78,7 +78,7 @@ REAL_NAME realName, ID_NUM idNum, GENDER gender, - MOBILE mobile, + IFNULL(MOBILE,'') mobile, STREET street, DISTRICT district, BUILDING_ADDRESS buildingAddress,