Browse Source

Merge remote-tracking branch 'remotes/origin/dev_article_fix' into develop

master
jianjun 4 years ago
parent
commit
de9683656a
  1. 14
      epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/feign/EpmetPointOpenFeignClient.java
  2. 15
      epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/feign/fallback/EpmetPointOpenFeignClientFallback.java
  3. 16
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/GroupPointController.java
  4. 9
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/BizPointTotalDetailService.java
  5. 19
      epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/BizPointTotalDetailServiceImpl.java
  6. 9
      epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/CommonArticleListFormDTO.java
  7. 38
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/ArticleDao.java
  8. 2
      epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java
  9. 2
      epmet-module/gov-voice/gov-voice-server/src/main/resources/logback-spring.xml
  10. 14
      epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/ArticleDao.xml
  11. 2
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/fallback/ResiGroupOpenFeignClientFallback.java
  12. 6
      epmet-module/resi-group/resi-group-server/pom.xml
  13. 2
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java
  14. 37
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/redis/ResiGroupRedis.java

14
epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/feign/EpmetPointOpenFeignClient.java

@ -2,12 +2,15 @@ package com.epmet.feign;
import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.BizPointTotalDetailDTO;
import com.epmet.dto.InitPointRuleResultDTO; import com.epmet.dto.InitPointRuleResultDTO;
import com.epmet.dto.form.CommonUserFormDTO; import com.epmet.dto.form.CommonUserFormDTO;
import com.epmet.dto.form.GroupPointFormDTO;
import com.epmet.dto.result.ResiPointDetailResultDTO; import com.epmet.dto.result.ResiPointDetailResultDTO;
import com.epmet.feign.fallback.EpmetPointOpenFeignClientFallback; import com.epmet.feign.fallback.EpmetPointOpenFeignClientFallback;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/** /**
* 本服务对外开放的API,其他服务通过引用此client调用该服务 * 本服务对外开放的API,其他服务通过引用此client调用该服务
@ -34,4 +37,15 @@ public interface EpmetPointOpenFeignClient {
**/ **/
@PostMapping("/point/opback/initpointrule") @PostMapping("/point/opback/initpointrule")
Result<InitPointRuleResultDTO> initPointRule(); Result<InitPointRuleResultDTO> initPointRule();
/**
* 获取小组积分
* @author zhaoqifeng
* @date 2021/6/24 12:24
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.BizPointTotalDetailDTO>
*/
@PostMapping("/point/group/point/grouppoint")
Result<BizPointTotalDetailDTO> getGroupPoint(@RequestBody GroupPointFormDTO formDTO);
} }

15
epmet-module/epmet-point/epmet-point-client/src/main/java/com/epmet/feign/fallback/EpmetPointOpenFeignClientFallback.java

@ -3,8 +3,10 @@ package com.epmet.feign.fallback;
import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.ModuleUtils;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.BizPointTotalDetailDTO;
import com.epmet.dto.InitPointRuleResultDTO; import com.epmet.dto.InitPointRuleResultDTO;
import com.epmet.dto.form.CommonUserFormDTO; import com.epmet.dto.form.CommonUserFormDTO;
import com.epmet.dto.form.GroupPointFormDTO;
import com.epmet.dto.result.ResiPointDetailResultDTO; import com.epmet.dto.result.ResiPointDetailResultDTO;
import com.epmet.feign.EpmetPointOpenFeignClient; import com.epmet.feign.EpmetPointOpenFeignClient;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -26,4 +28,17 @@ public class EpmetPointOpenFeignClientFallback implements EpmetPointOpenFeignCli
public Result<InitPointRuleResultDTO> initPointRule() { public Result<InitPointRuleResultDTO> initPointRule() {
return ModuleUtils.feignConError(ServiceConstant.EPMET_POINT_SERVER, "initPointRule"); return ModuleUtils.feignConError(ServiceConstant.EPMET_POINT_SERVER, "initPointRule");
} }
/**
* 获取小组积分
*
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.BizPointTotalDetailDTO>
* @author zhaoqifeng
* @date 2021/6/24 12:24
*/
@Override
public Result<BizPointTotalDetailDTO> getGroupPoint(GroupPointFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_POINT_SERVER, "formDTO");
}
} }

16
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/controller/GroupPointController.java

@ -4,6 +4,7 @@ import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.BizPointTotalDetailDTO;
import com.epmet.dto.form.GroupPointFormDTO; import com.epmet.dto.form.GroupPointFormDTO;
import com.epmet.dto.result.GroupPointRankingResultDTO; import com.epmet.dto.result.GroupPointRankingResultDTO;
import com.epmet.dto.result.GroupPointRuleResultDTO; import com.epmet.dto.result.GroupPointRuleResultDTO;
@ -97,4 +98,19 @@ public class GroupPointController {
result.setGroupSummary(ModuleConstant.GROUP_RULE_SUMMARY); result.setGroupSummary(ModuleConstant.GROUP_RULE_SUMMARY);
return new Result<GroupPointRuleResultDTO>().ok(result); return new Result<GroupPointRuleResultDTO>().ok(result);
} }
/**
* 获取小组积分
* @author zhaoqifeng
* @date 2021/6/24 12:17
* @param formDTO
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.BizPointTotalDetailDTO>
*/
@PostMapping("grouppoint")
public Result<BizPointTotalDetailDTO> getGroupPoint(@RequestBody GroupPointFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO, GroupPointFormDTO.GroupPoint.class);
BizPointTotalDetailDTO result = bizPointTotalDetailService.getGroupPoint(formDTO);
return new Result<BizPointTotalDetailDTO>().ok(result);
}
} }

9
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/BizPointTotalDetailService.java

@ -126,4 +126,13 @@ public interface BizPointTotalDetailService extends BaseService<BizPointTotalDet
* @date 2021/4/21 14:05 * @date 2021/4/21 14:05
*/ */
List<GroupPointRankingResultDTO> groupPointRanking(GroupPointFormDTO formDTO); List<GroupPointRankingResultDTO> groupPointRanking(GroupPointFormDTO formDTO);
/**
* 获取小组积分
* @author zhaoqifeng
* @date 2021/6/24 12:17
* @param formDTO
* @return com.epmet.dto.BizPointTotalDetailDTO
*/
BizPointTotalDetailDTO getGroupPoint(GroupPointFormDTO formDTO);
} }

19
epmet-module/epmet-point/epmet-point-server/src/main/java/com/epmet/service/impl/BizPointTotalDetailServiceImpl.java

@ -17,6 +17,7 @@
package com.epmet.service.impl; package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
@ -220,4 +221,22 @@ public class BizPointTotalDetailServiceImpl extends BaseServiceImpl<BizPointTota
return list; return list;
} }
/**
* 获取小组积分
*
* @param formDTO
* @return com.epmet.dto.BizPointTotalDetailDTO
* @author zhaoqifeng
* @date 2021/6/24 12:17
*/
@Override
public BizPointTotalDetailDTO getGroupPoint(GroupPointFormDTO formDTO) {
LambdaQueryWrapper<BizPointTotalDetailEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(BizPointTotalDetailEntity :: getBizType, "group")
.eq(BizPointTotalDetailEntity ::getObjectId, formDTO.getGroupId())
.eq(BizPointTotalDetailEntity ::getDelFlag, NumConstant.ZERO_STR);
BizPointTotalDetailEntity entity = baseDao.selectOne(wrapper);
return ConvertUtils.sourceToTarget(entity, BizPointTotalDetailDTO.class);
}
} }

9
epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/form/CommonArticleListFormDTO.java

@ -31,4 +31,13 @@ public class CommonArticleListFormDTO implements Serializable {
* */ * */
private Integer num; private Integer num;
/**
* 标签名称(高级配置里的参数)
* */
private String tagName;
/**
* 排除的标签名称(高级配置里的参数)
* */
private String excludeTagName;
} }

38
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/dao/ArticleDao.java

@ -23,7 +23,6 @@ import com.epmet.dto.result.GovArticleDetailResultDTO;
import com.epmet.dto.result.ArticleBannerResultDTO; import com.epmet.dto.result.ArticleBannerResultDTO;
import com.epmet.dto.result.ArticleDetailResultDTO; import com.epmet.dto.result.ArticleDetailResultDTO;
import com.epmet.dto.result.ArticleLatestResultDTO; import com.epmet.dto.result.ArticleLatestResultDTO;
import com.epmet.dto.result.ArticleWithTagsResultDTO;
import com.epmet.entity.ArticleEntity; import com.epmet.entity.ArticleEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -43,45 +42,45 @@ public interface ArticleDao extends BaseDao<ArticleEntity> {
/** /**
* 政府端查询文章详情 * 政府端查询文章详情
* *
* @param articleId * @param articleId 文章id
* 文章id
*/ */
GovArticleDetailResultDTO queryGovArticleDetail(String articleId); GovArticleDetailResultDTO queryGovArticleDetail(String articleId);
/** /**
* 政府端查询文章详情-内容 * 政府端查询文章详情-内容
* *
* @param articleId * @param articleId 文章id
* 文章id
*/ */
List<GovArticleContentDTO> queryGovArticleContent(String articleId); List<GovArticleContentDTO> queryGovArticleContent(String articleId);
/** /**
* @Description
* @param formDto * @param formDto
* @Description
* @author zxc * @author zxc
*/ */
Integer checkPublishArticle(ResiTagListFormDTO formDto); Integer checkPublishArticle(ResiTagListFormDTO formDto);
/** /**
* 已发布列表---组织工作人员 * 已发布列表---组织工作人员
* @author zhaoqifeng *
* @date 2020/6/2 16:59
* @param customerId * @param customerId
* @param tagIdList * @param tagIdList
* @return java.util.List<com.epmet.dto.result.PublishedListResultDTO> * @return java.util.List<com.epmet.dto.result.PublishedListResultDTO>
* @author zhaoqifeng
* @date 2020/6/2 16:59
*/ */
@DataFilter(tableAliases = "a", gridIdsArgName = "gridList") @DataFilter(tableAliases = "a", gridIdsArgName = "gridList")
List<PublishedListResultDTO> selectArticleListForAgency(@Param("customerId") String customerId, @Param("tagIdList") List<String> tagIdList, Set<String> gridList); List<PublishedListResultDTO> selectArticleListForAgency(@Param("customerId") String customerId, @Param("tagIdList") List<String> tagIdList, Set<String> gridList);
/** /**
* 已发布列表---网格工作人员 * 已发布列表---网格工作人员
* @author zhaoqifeng *
* @date 2020/6/5 16:35
* @param customerId * @param customerId
* @param tagIdList * @param tagIdList
* @param gridList * @param gridList
* @return java.util.List<com.epmet.dto.result.PublishedListResultDTO> * @return java.util.List<com.epmet.dto.result.PublishedListResultDTO>
* @author zhaoqifeng
* @date 2020/6/5 16:35
*/ */
List<PublishedListResultDTO> selectArticleListForGrid(@Param("customerId") String customerId, List<PublishedListResultDTO> selectArticleListForGrid(@Param("customerId") String customerId,
@Param("tagIdList") List<String> tagIdList, @Param("tagIdList") List<String> tagIdList,
@ -89,58 +88,61 @@ public interface ArticleDao extends BaseDao<ArticleEntity> {
/** /**
* 已下线文章列表 * 已下线文章列表
* @author zhaoqifeng *
* @date 2020/6/3 15:16
* @param gridList * @param gridList
* @return java.util.List<com.epmet.dto.result.OfflineListResultDTO> * @return java.util.List<com.epmet.dto.result.OfflineListResultDTO>
* @author zhaoqifeng
* @date 2020/6/3 15:16
*/ */
@DataFilter(tableAliases = "a", gridIdsArgName = "gridList") @DataFilter(tableAliases = "a", gridIdsArgName = "gridList")
List<OfflineListResultDTO> selectOfflineList(Set<String> gridList); List<OfflineListResultDTO> selectOfflineList(Set<String> gridList);
/** /**
* @Description 根据网格Id查找置顶文章的相关信息列表 用处:居民端首页轮播
* @param gridId * @param gridId
* @param num * @param num
* @return List<ArticleBannerResultDTO> * @return List<ArticleBannerResultDTO>
* @Description 根据网格Id查找置顶文章的相关信息列表 用处:居民端首页轮播
* @author wangc * @author wangc
* @date 2020.06.02 16:04 * @date 2020.06.02 16:04
**/ **/
List<ArticleBannerResultDTO> selectTopArticleMsg(@Param("gridId") String gridId, @Param("num") Integer num); List<ArticleBannerResultDTO> selectTopArticleMsg(@Param("gridId") String gridId, @Param("num") Integer num);
/** /**
* @Description 根据网格Id查找最新文章的相关信息列表 用处:居民端最新文章列表
* @param gridId * @param gridId
* @param tagName
* @param excludeTagName
* @param num * @param num
* @return List<ArticleBannerResultDTO> * @return List<ArticleBannerResultDTO>
* @Description 根据网格Id查找最新文章的相关信息列表 用处:居民端最新文章列表
* @author wangc * @author wangc
* @date 2020.06.02 16:04 * @date 2020.06.02 16:04
**/ **/
List<ArticleLatestResultDTO> selectLatestArticleMsg(@Param("gridId")String gridId,@Param("num")Integer num); List<ArticleLatestResultDTO> selectLatestArticleMsg(@Param("gridId") String gridId, @Param("tagName") String tagName, @Param("excludeTagName") String excludeTagName, @Param("num") Integer num);
/** /**
* @Description 根据网格Id和标签列表查找文章的相关信息列表 用处:居民端党建声音列表
* @param gridId * @param gridId
* @param tagIdList * @param tagIdList
* @return List<ArticleListResultDTO> * @return List<ArticleListResultDTO>
* @Description 根据网格Id和标签列表查找文章的相关信息列表 用处:居民端党建声音列表
* @author wangc * @author wangc
* @date 2020.06.03 14:19 * @date 2020.06.03 14:19
**/ **/
List<ArticleListResultDTO> selectArticleList(@Param("gridId") String gridId, @Param("tagIdList") List<String> tagIdList); List<ArticleListResultDTO> selectArticleList(@Param("gridId") String gridId, @Param("tagIdList") List<String> tagIdList);
/** /**
* @Description 根绝文章Id查询出文章的内容封面等相关信息如果居民端传入的网格Id不在该文章的发布范围内则返回NULL
* @param gridId * @param gridId
* @param articleId * @param articleId
* @return ArticleDetailResultDTO * @return ArticleDetailResultDTO
* @Description 根绝文章Id查询出文章的内容封面等相关信息如果居民端传入的网格Id不在该文章的发布范围内则返回NULL
* @author wangc * @author wangc
* @date 2020.06.03 18:28 * @date 2020.06.03 18:28
**/ **/
ArticleDetailResultDTO selectArticleDetail(@Param("gridId") String gridId, @Param("articleId") String articleId); ArticleDetailResultDTO selectArticleDetail(@Param("gridId") String gridId, @Param("articleId") String articleId);
/** /**
* @Description 根据draftId获取文章id
* @param draftId * @param draftId
* @Description 根据draftId获取文章id
* @author zxc * @author zxc
*/ */
String getArticleIdByDraftId(@Param("draftId") String draftId); String getArticleIdByDraftId(@Param("draftId") String draftId);

2
epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java

@ -688,7 +688,7 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit
**/ **/
@Override @Override
public List<ArticleLatestResultDTO> getLatestArticleList(CommonArticleListFormDTO commonArticleListFormDTO) { public List<ArticleLatestResultDTO> getLatestArticleList(CommonArticleListFormDTO commonArticleListFormDTO) {
return baseDao.selectLatestArticleMsg(commonArticleListFormDTO.getGridId(), return baseDao.selectLatestArticleMsg(commonArticleListFormDTO.getGridId(),commonArticleListFormDTO.getTagName(),commonArticleListFormDTO.getExcludeTagName(),
null == commonArticleListFormDTO.getNum() || commonArticleListFormDTO.getNum() <= NumConstant.ZERO ? null == commonArticleListFormDTO.getNum() || commonArticleListFormDTO.getNum() <= NumConstant.ZERO ?
NumConstant.FIVE : commonArticleListFormDTO.getNum()); NumConstant.FIVE : commonArticleListFormDTO.getNum());
} }

2
epmet-module/gov-voice/gov-voice-server/src/main/resources/logback-spring.xml

@ -139,7 +139,7 @@
</appender> </appender>
<!-- 开发、测试环境 --> <!-- 开发、测试环境 -->
<springProfile name="dev,test"> <springProfile name="local,dev,test">
<logger name="org.springframework.web" level="INFO"/> <logger name="org.springframework.web" level="INFO"/>
<logger name="org.springboot.sample" level="INFO"/> <logger name="org.springboot.sample" level="INFO"/>
<logger name="com.epmet.dao" level="INFO"/> <logger name="com.epmet.dao" level="INFO"/>

14
epmet-module/gov-voice/gov-voice-server/src/main/resources/mapper/ArticleDao.xml

@ -193,9 +193,11 @@
art.TITLE AS articleTitle , art.TITLE AS articleTitle ,
IFNULL(artcover.IMG_URL,'') AS articleCoverImg, IFNULL(artcover.IMG_URL,'') AS articleCoverImg,
art.PUBLISHER_NAME AS publishName, art.PUBLISHER_NAME AS publishName,
art.PUBLISH_DATE AS publishDate art.PUBLISH_DATE AS publishDate,
group_concat(tag.TAG_NAME) tags #条件筛选用
FROM FROM
ARTICLE art ARTICLE art
LEFT JOIN article_tags tag ON tag.ARTICLE_ID = art.ID AND tag.DEL_FLAG = '0'
LEFT JOIN ( LEFT JOIN (
SELECT SELECT
@ -222,7 +224,17 @@
art.DEL_FLAG = '0' art.DEL_FLAG = '0'
AND AND
art.STATUS_FLAG = 'published' art.STATUS_FLAG = 'published'
<if test="(tagName != null and tagName != '') or (excludeTagName != null and excludeTagName != '')">
GROUP BY art.ID
HAVING
<if test="tagName != null and tagName != ''">
FIND_IN_SET(#{tagName},tags)
</if>
<if test="excludeTagName != null and excludeTagName != ''">
AND !FIND_IN_SET(#{excludeTagName},tags)
</if>
</if>
ORDER BY art.PUBLISH_DATE DESC , art.CREATED_TIME DESC ORDER BY art.PUBLISH_DATE DESC , art.CREATED_TIME DESC
LIMIT #{num} LIMIT #{num}
</select> </select>

2
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/feign/fallback/ResiGroupOpenFeignClientFallback.java

@ -204,7 +204,7 @@ public class ResiGroupOpenFeignClientFallback implements ResiGroupOpenFeignClien
* @date 2021/4/21 16:30 * @date 2021/4/21 16:30
*/ */
@Override @Override
public Result<GroupPointDetailResultDTO> groupPointDetail(@RequestBody GroupPointDetailFormDTO formDTO) { public Result<GroupPointDetailResultDTO> groupPointDetail(GroupPointDetailFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.RESI_GROUP_SERVER, "groupPointDetail", formDTO); return ModuleUtils.feignConError(ServiceConstant.RESI_GROUP_SERVER, "groupPointDetail", formDTO);
} }

6
epmet-module/resi-group/resi-group-server/pom.xml

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

2
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java

@ -560,7 +560,7 @@ public class ResiGroupController {
* @param formDTO * @param formDTO
* @return com.epmet.commons.tools.utils.Result<com.epmet.resi.group.dto.group.result.GroupPointDetailResultDTO> * @return com.epmet.commons.tools.utils.Result<com.epmet.resi.group.dto.group.result.GroupPointDetailResultDTO>
*/ */
@PostMapping("groupPointDetail/{groupId}") @PostMapping("groupPointDetail")
public Result<GroupPointDetailResultDTO> groupPointDetail(@RequestBody GroupPointDetailFormDTO formDTO) { public Result<GroupPointDetailResultDTO> groupPointDetail(@RequestBody GroupPointDetailFormDTO formDTO) {
return new Result<GroupPointDetailResultDTO>().ok(resiGroupService.groupPointDetail(formDTO)); return new Result<GroupPointDetailResultDTO>().ok(resiGroupService.groupPointDetail(formDTO));
} }

37
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/redis/ResiGroupRedis.java

@ -19,15 +19,20 @@ package com.epmet.modules.group.redis;
import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.BizPointTotalDetailDTO;
import com.epmet.dto.form.GroupPointFormDTO;
import com.epmet.dto.result.UserBaseInfoResultDTO; import com.epmet.dto.result.UserBaseInfoResultDTO;
import com.epmet.feign.EpmetPointOpenFeignClient;
import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.feign.EpmetUserOpenFeignClient;
import com.epmet.modules.constant.ResiGroupRedisKeys; import com.epmet.modules.constant.ResiGroupRedisKeys;
import com.epmet.modules.group.service.ResiGroupService; import com.epmet.modules.group.service.ResiGroupService;
import com.epmet.modules.group.service.ResiGroupStatisticalService; import com.epmet.modules.group.service.ResiGroupStatisticalService;
import com.epmet.modules.support.GroupLevelUtils;
import com.epmet.modules.utils.ModuleConstant; import com.epmet.modules.utils.ModuleConstant;
import com.epmet.resi.group.constant.TopicConstant; import com.epmet.resi.group.constant.TopicConstant;
import com.epmet.resi.group.dto.group.ResiGroupDTO; import com.epmet.resi.group.dto.group.ResiGroupDTO;
@ -64,6 +69,8 @@ public class ResiGroupRedis {
@Autowired @Autowired
private EpmetUserOpenFeignClient epmetUserOpenFeignClient; private EpmetUserOpenFeignClient epmetUserOpenFeignClient;
@Autowired
private EpmetPointOpenFeignClient epmetPointOpenFeignClient;
public void delete(Object[] ids) { public void delete(Object[] ids) {
@ -92,16 +99,37 @@ public class ResiGroupRedis {
public ResiGroupInfoRedisDTO get(String groupId){ public ResiGroupInfoRedisDTO get(String groupId){
if(StringUtils.isNotBlank(groupId)){ if(StringUtils.isNotBlank(groupId)){
GroupPointFormDTO groupPointFormDTO = new GroupPointFormDTO();
groupPointFormDTO.setGroupId(groupId);
Result<BizPointTotalDetailDTO> bizPointTotalDetailResult = epmetPointOpenFeignClient.getGroupPoint(groupPointFormDTO);
if (!bizPointTotalDetailResult.success()) {
throw new RenException(bizPointTotalDetailResult.getCode(), bizPointTotalDetailResult.getMsg());
}
Integer level = 1;
if (null != bizPointTotalDetailResult.getData()) {
level = GroupLevelUtils.getLevel(bizPointTotalDetailResult.getData().getTotalPoint());
if (null == level) {
level = 1;
}
}
ResiGroupDTO groupMySql = groupService.get(groupId);
if (!level.equals(groupMySql.getLevel())) {
ResiGroupDTO dto = new ResiGroupDTO();
dto.setId(groupMySql.getId());
dto.setLevel(level);
groupService.update(dto);
}
ResiGroupInfoRedisDTO groupCache = (ResiGroupInfoRedisDTO) ResiGroupInfoRedisDTO groupCache = (ResiGroupInfoRedisDTO)
redisUtils.get(ResiGroupRedisKeys.getResiGroupInfoKey(groupId)); redisUtils.get(ResiGroupRedisKeys.getResiGroupInfoKey(groupId));
if(null == groupCache || StringUtils.isBlank(groupCache.getGroupId()) || null == groupCache.getGroupStatisticalInfo()){ if(null == groupCache || StringUtils.isBlank(groupCache.getGroupId()) || null == groupCache.getGroupStatisticalInfo()){
//如果缓存中没有该组信息,从数据库中查询并放入缓存 //如果缓存中没有该组信息,从数据库中查询并放入缓存
ResiGroupDTO groupMySql = groupService.get(groupId); if(StringUtils.isNotBlank(groupMySql.getId())){
if(null != groupMySql && StringUtils.isNotBlank(groupMySql.getId())){
ResiGroupInfoRedisDTO groupRedis = ConvertUtils.sourceToTarget(groupMySql,ResiGroupInfoRedisDTO.class); ResiGroupInfoRedisDTO groupRedis = ConvertUtils.sourceToTarget(groupMySql,ResiGroupInfoRedisDTO.class);
groupRedis.setGroupId(groupMySql.getId()); groupRedis.setGroupId(groupMySql.getId());
groupRedis.setGroupState(groupMySql.getState()); groupRedis.setGroupState(groupMySql.getState());
groupRedis.setLevel("LV" + groupMySql.getLevel()); groupRedis.setLevel("LV" + level);
Map<String,Object> param = new HashMap<>(); Map<String,Object> param = new HashMap<>();
param.put(TopicConstant.RESI_GROUP_ID,groupId); param.put(TopicConstant.RESI_GROUP_ID,groupId);
param.put(FieldConstant.DEL_FLAG, NumConstant.ZERO_STR); param.put(FieldConstant.DEL_FLAG, NumConstant.ZERO_STR);
@ -127,6 +155,9 @@ public class ResiGroupRedis {
//返回数据 //返回数据
return groupRedis; return groupRedis;
} }
} else {
groupCache.setLevel("LV" + level);
set(groupCache);
} }
return groupCache; return groupCache;
} }

Loading…
Cancel
Save