From e2be8de0145303e62e2234f5b5ee1bd5733dc59d Mon Sep 17 00:00:00 2001 From: zxc <954985706@qq.com> Date: Mon, 25 May 2020 18:00:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/controller/IssueController.java | 13 ++ .../src/main/java/com/epmet/dao/IssueDao.java | 8 ++ .../java/com/epmet/service/IssueService.java | 9 ++ .../epmet/service/impl/IssueServiceImpl.java | 11 ++ .../impl/IssueVoteStatisticalServiceImpl.java | 10 +- .../src/main/resources/mapper/IssueDao.xml | 11 ++ .../modules/feign/GovIssueFeignClient.java | 9 ++ .../fallback/GovIssueFeignClientFallBack.java | 6 + .../service/impl/ResiTopicServiceImpl.java | 119 +++++++++--------- .../epmet/modules/utils/ModuleConstant.java | 2 + 10 files changed, 138 insertions(+), 60 deletions(-) diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueController.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueController.java index db84562cb9..bedb47f25c 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueController.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueController.java @@ -13,8 +13,10 @@ import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.dto.IssueDTO; import com.epmet.dto.result.*; import com.epmet.excel.IssueExcel; +import com.epmet.resi.group.dto.topic.form.TopicInfoFormDTO; import com.epmet.service.IssueService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; @@ -138,5 +140,16 @@ public class IssueController { return new Result>().ok(issueService.getNewestIssueList(formDTO)); } + /** + * @Description 校验话题是否已转议题 + * @param formDTO + * @author zxc + */ + @PostMapping(value = "checktopicshiftissue") + public Result checkTopicShiftIssue(@RequestBody TopicInfoFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO); + return new Result().ok(issueService.checkTopicShiftIssue(formDTO)); + } + } diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueDao.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueDao.java index 377c731120..9dee92932c 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueDao.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueDao.java @@ -22,6 +22,7 @@ import com.epmet.dto.IssueDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.entity.IssueEntity; +import com.epmet.resi.group.dto.topic.form.TopicInfoFormDTO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -136,4 +137,11 @@ public interface IssueDao extends BaseDao { * @date 2020.05.22 00:36 **/ Set selectIssueIdsByCondition(IssueDTO issueDTO); + + /** + * @Description 校验话题是否已转议题 + * @param formDTO + * @author zxc + */ + Integer checkTopicShiftIssue(TopicInfoFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueService.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueService.java index 2d2860ce8a..d9f4417ec6 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueService.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueService.java @@ -2,6 +2,7 @@ package com.epmet.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.dto.IssueDTO; import com.epmet.dto.form.CloseIssueFormDTO; import com.epmet.dto.form.DepartmentStaffListFormDTO; @@ -20,6 +21,7 @@ import com.epmet.dto.form.IssueDetailFormDTO; import com.epmet.dto.result.*; import com.epmet.dto.form.IssueShiftedFromTopicFormDTO; import com.epmet.entity.IssueEntity; +import com.epmet.resi.group.dto.topic.form.TopicInfoFormDTO; import org.springframework.web.bind.annotation.RequestBody; import java.util.List; @@ -223,4 +225,11 @@ public interface IssueService extends BaseService { * @date 2020.05.22 00:36 **/ Set getIssueIdsByCondition(IssueDTO issueDTO); + + /** + * @Description 校验话题是否已转议题 + * @param formDTO + * @author zxc + */ + Integer checkTopicShiftIssue(TopicInfoFormDTO formDTO); } diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java index b310d78e48..af0693928a 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java @@ -31,6 +31,7 @@ import com.epmet.feign.*; import com.epmet.redis.GovIssueRedis; import com.epmet.resi.group.dto.topic.ResiTopicDTO; import com.epmet.resi.group.dto.topic.form.GovTopicIssueInfoFormDTO; +import com.epmet.resi.group.dto.topic.form.TopicInfoFormDTO; import com.epmet.resi.group.dto.topic.result.GovTopicIssueInfoResultDTO; import com.epmet.service.IssueProcessService; import com.epmet.service.IssueProjectRelationService; @@ -706,4 +707,14 @@ public class IssueServiceImpl extends BaseServiceImpl imp return baseDao.selectIssueIdsByCondition(issueDTO); } + /** + * @Description 校验话题是否已转议题 + * @param formDTO + * @author zxc + */ + @Override + public Integer checkTopicShiftIssue(TopicInfoFormDTO formDTO) { + return baseDao.checkTopicShiftIssue(formDTO); + } + } 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 e7b2475d59..aa229214b7 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 @@ -168,21 +168,24 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl polyLineDTOS = issueVoteStatisticalDao.polyLineData(issueId); PolyLineDTO polyLineDTO = new PolyLineDTO(); polyLineDTO.setVoteDate(LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8"))); + //议题 已转项目 或 已结案 的时间 + String date = issueDao.operateTime(issueId.getIssueId()); //今天刚转项目或刚刚关闭,当天数据DB没有,直接从缓存拿 - if (polyLineDTOS.size() == NumConstant.ZERO) { + if (polyLineDTOS.size() == NumConstant.ZERO && date.equals(LocalDate.now().toString())) { polyLineDTO.setSupportIncrement(voteRedisFormDTO.getSupportAmount()); polyLineDTO.setOppositionIncrement(voteRedisFormDTO.getOppositionAmount()); polyLineDTOS.add(polyLineDTO); } else { - //折线数据=DB - String date = issueDao.operateTime(issueId.getIssueId()); + //折线数据=DB,今天之前转成的议题,今天 “已转项目”或“已结案” if (date.equals(LocalDate.now().toString())) { Integer yesterdaySupport = 0; Integer yesterdayOppose = 0; @@ -195,6 +198,7 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl + + + \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/feign/GovIssueFeignClient.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/feign/GovIssueFeignClient.java index d9f7c146b1..1b9622fb8e 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/feign/GovIssueFeignClient.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/feign/GovIssueFeignClient.java @@ -4,6 +4,7 @@ import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.IssueShiftedFromTopicFormDTO; import com.epmet.modules.feign.fallback.GovIssueFeignClientFallBack; +import com.epmet.resi.group.dto.topic.form.TopicInfoFormDTO; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.PostMapping; @@ -26,4 +27,12 @@ public interface GovIssueFeignClient { **/ @PostMapping(value = "gov/issue/issue/topicshiftissue", consumes = MediaType.APPLICATION_JSON_VALUE) Result issueShiftedToTopic(IssueShiftedFromTopicFormDTO issueShiftedFromTopicFormDTO); + + /** + * @Description 校验话题是否已转议题 + * @param formDTO + * @author zxc + */ + @PostMapping(value = "gov/issue/issue/checktopicshiftissue", consumes = MediaType.APPLICATION_JSON_VALUE) + Result checkTopicShiftIssue(TopicInfoFormDTO formDTO); } diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/feign/fallback/GovIssueFeignClientFallBack.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/feign/fallback/GovIssueFeignClientFallBack.java index b3cc109467..d518647f76 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/feign/fallback/GovIssueFeignClientFallBack.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/feign/fallback/GovIssueFeignClientFallBack.java @@ -5,6 +5,7 @@ import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.form.IssueShiftedFromTopicFormDTO; import com.epmet.modules.feign.GovIssueFeignClient; +import com.epmet.resi.group.dto.topic.form.TopicInfoFormDTO; import org.springframework.stereotype.Component; /** @@ -20,4 +21,9 @@ public class GovIssueFeignClientFallBack implements GovIssueFeignClient { public Result issueShiftedToTopic(IssueShiftedFromTopicFormDTO issueShiftedFromTopicFormDTO) { return ModuleUtils.feignConError(ServiceConstant.GOV_ISSUE_SERVER, "issueShiftedToTopic", issueShiftedFromTopicFormDTO); } + + @Override + public Result checkTopicShiftIssue(TopicInfoFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ISSUE_SERVER, "checkTopicShiftIssue", formDTO); + } } diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicServiceImpl.java index d60d161e6b..9c6ecbc007 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicServiceImpl.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicServiceImpl.java @@ -1025,67 +1025,72 @@ public class ResiTopicServiceImpl extends BaseServiceImpl dataFilterResult = - govOrgFeignClient.gridDataFilter(dataFilterParam); - if(dataFilterResult.success() && null != dataFilterResult.getData()){ - IssueShiftedFromTopicFormDTO issueInfo = ConvertUtils.sourceToTarget(topicTurnIssueFromDTO,IssueShiftedFromTopicFormDTO.class); - issueInfo.setCreatedTime(now); - issueInfo.setGridId(group.getGridId()); - issueInfo.setCustomerId(group.getCustomerId()); - issueInfo.setOrgId(dataFilterResult.getData().getAgencyId()); - issueInfo.setOrgIdPath(dataFilterResult.getData().getOrgIdPath()); - issueInfo.setOrgName(dataFilterResult.getData().getOrgName()); - //3.获取小组名称、话题作者、议题发起人 - ResiGroupMemberInfoRedisDTO topicAuthor = resiGroupMemberRedis.get(group.getGroupId(), group.getTopicAuthorId()); - issueInfo.setTopicAuthor(null == topicAuthor ? ModuleConstant.EMPTY_STR : topicAuthor.getUserShowName()); - ResiGroupMemberInfoRedisDTO issueAuthor = resiGroupMemberRedis.get(group.getGroupId(),topicTurnIssueFromDTO.getUserId()); - issueInfo.setIssueAuthor(null == issueAuthor ? ModuleConstant.EMPTY_STR : issueAuthor.getUserShowName()); - ResiGroupInfoRedisDTO groupCache = resiGroupRedis.get(group.getGroupId()); - issueInfo.setGroupName(null == groupCache ? ModuleConstant.EMPTY_STR : groupCache.getGroupName()); - issueInfo.setVotableCount(resiGroupMemberService.gridResiCount(group.getGridId())); - //4.调用gov-issue新增议题 - Result issueResult = govIssueFeignClient.issueShiftedToTopic(issueInfo); - //5.修改话题shiftIssue字段 - if(issueResult.success() && StringUtils.isNotBlank(issueResult.getData())){ - ResiTopicEntity topic2Upd = new ResiTopicEntity(); - topic2Upd.setId(topicTurnIssueFromDTO.getTopicId()); - topic2Upd.setUpdatedBy(topicTurnIssueFromDTO.getUserId()); - topic2Upd.setShiftIssue(Boolean.TRUE); - topic2Upd.setIssueId(issueResult.getData()); - topic2Upd.setUpdatedTime(now); - int topicResult = baseDao.updateOne(topic2Upd); - //6.新增话题操作记录 - if(topicResult == NumConstant.ONE) { - ResiTopicOperationEntity operation = new ResiTopicOperationEntity(); - operation.setCreatedTime(now); - operation.setCreatedBy(topicTurnIssueFromDTO.getUserId()); - operation.setTopicId(topicTurnIssueFromDTO.getTopicId()); - operation.setOperationType(ModuleConstant.TOPIC_OPERATION_TYPE_SHIFT_ISSUE); - int operationResult = resiTopicOperationDao.insertOneByParams(operation); - if(operationResult != NumConstant.ONE){ - logger.warn(ModuleConstant.FAILURE_TO_ADD_TOPIC_OPERATION); - } - } - //7.更新组统计信息 议题数量+1 - resiGroupStatisticalDao.incryTotalIssues(group.getGroupId()); - if(null != groupCache && null != groupCache.getGroupStatisticalInfo()){ - groupCache.getGroupStatisticalInfo().setTotalIssues( - null == groupCache.getGroupStatisticalInfo().getTotalIssues() ? NumConstant.ONE - : groupCache.getGroupStatisticalInfo().getTotalIssues() + NumConstant.ONE - ); - resiGroupRedis.set(groupCache); + if(null == group) { + throw new RenException(ModuleConstant.FAILURE_TO_TURN_ISSUE); + } + TopicInfoFormDTO topicId = new TopicInfoFormDTO(); + topicId.setTopicId(topicTurnIssueFromDTO.getTopicId()); + Integer issueCount = govIssueFeignClient.checkTopicShiftIssue(topicId).getData(); + if (issueCount != NumConstant.ZERO){ + throw new RenException(ModuleConstant.ALREADY_SHIFT_ISSUE); + } + CommonGridIdFormDTO dataFilterParam = new CommonGridIdFormDTO(); + dataFilterParam.setUserId(topicTurnIssueFromDTO.getUserId()); + dataFilterParam.setGridId(group.getGridId()); + Result dataFilterResult = + govOrgFeignClient.gridDataFilter(dataFilterParam); + if(dataFilterResult.success() && null != dataFilterResult.getData()){ + IssueShiftedFromTopicFormDTO issueInfo = ConvertUtils.sourceToTarget(topicTurnIssueFromDTO,IssueShiftedFromTopicFormDTO.class); + issueInfo.setCreatedTime(now); + issueInfo.setGridId(group.getGridId()); + issueInfo.setCustomerId(group.getCustomerId()); + issueInfo.setOrgId(dataFilterResult.getData().getAgencyId()); + issueInfo.setOrgIdPath(dataFilterResult.getData().getOrgIdPath()); + issueInfo.setOrgName(dataFilterResult.getData().getOrgName()); + //3.获取小组名称、话题作者、议题发起人 + ResiGroupMemberInfoRedisDTO topicAuthor = resiGroupMemberRedis.get(group.getGroupId(), group.getTopicAuthorId()); + issueInfo.setTopicAuthor(null == topicAuthor ? ModuleConstant.EMPTY_STR : topicAuthor.getUserShowName()); + ResiGroupMemberInfoRedisDTO issueAuthor = resiGroupMemberRedis.get(group.getGroupId(),topicTurnIssueFromDTO.getUserId()); + issueInfo.setIssueAuthor(null == issueAuthor ? ModuleConstant.EMPTY_STR : issueAuthor.getUserShowName()); + ResiGroupInfoRedisDTO groupCache = resiGroupRedis.get(group.getGroupId()); + issueInfo.setGroupName(null == groupCache ? ModuleConstant.EMPTY_STR : groupCache.getGroupName()); + issueInfo.setVotableCount(resiGroupMemberService.gridResiCount(group.getGridId())); + //4.调用gov-issue新增议题 + Result issueResult = govIssueFeignClient.issueShiftedToTopic(issueInfo); + //5.修改话题shiftIssue字段 + if(issueResult.success() && StringUtils.isNotBlank(issueResult.getData())){ + ResiTopicEntity topic2Upd = new ResiTopicEntity(); + topic2Upd.setId(topicTurnIssueFromDTO.getTopicId()); + topic2Upd.setUpdatedBy(topicTurnIssueFromDTO.getUserId()); + topic2Upd.setShiftIssue(Boolean.TRUE); + topic2Upd.setIssueId(issueResult.getData()); + topic2Upd.setUpdatedTime(now); + int topicResult = baseDao.updateOne(topic2Upd); + //6.新增话题操作记录 + if(topicResult == NumConstant.ONE) { + ResiTopicOperationEntity operation = new ResiTopicOperationEntity(); + operation.setCreatedTime(now); + operation.setCreatedBy(topicTurnIssueFromDTO.getUserId()); + operation.setTopicId(topicTurnIssueFromDTO.getTopicId()); + operation.setOperationType(ModuleConstant.TOPIC_OPERATION_TYPE_SHIFT_ISSUE); + int operationResult = resiTopicOperationDao.insertOneByParams(operation); + if(operationResult != NumConstant.ONE){ + logger.warn(ModuleConstant.FAILURE_TO_ADD_TOPIC_OPERATION); } - logger.warn(ModuleConstant.FAILURE_TO_UPDATE_TOPIC); - } + //7.更新组统计信息 议题数量+1 + resiGroupStatisticalDao.incryTotalIssues(group.getGroupId()); + if(null != groupCache && null != groupCache.getGroupStatisticalInfo()){ + groupCache.getGroupStatisticalInfo().setTotalIssues( + null == groupCache.getGroupStatisticalInfo().getTotalIssues() ? NumConstant.ONE + : groupCache.getGroupStatisticalInfo().getTotalIssues() + NumConstant.ONE + ); + resiGroupRedis.set(groupCache); + } + logger.warn(ModuleConstant.FAILURE_TO_UPDATE_TOPIC); + } - return; } - throw new RenException(ModuleConstant.FAILURE_TO_TURN_ISSUE); } /** 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 e152122a75..f077980f7f 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 @@ -311,4 +311,6 @@ public interface ModuleConstant extends Constant { * 组状态 审核中 * */ String GROUP_STATUS_UNDER_AUDITTING = "under_auditting"; + + String ALREADY_SHIFT_ISSUE = "话题已转议题,请勿重复操作"; }