|
|
@ -1,15 +1,21 @@ |
|
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
import com.alibaba.excel.ExcelWriter; |
|
|
|
import com.alibaba.excel.write.metadata.WriteSheet; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.nacos.client.utils.StringUtils; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.rocketmq.messages.GroupAchievementMQMsg; |
|
|
|
import com.epmet.commons.tools.constant.AppClientConstant; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
|
import com.epmet.commons.tools.distributedlock.DistributedLock; |
|
|
|
import com.epmet.commons.tools.dto.commondto.IcEventComDTO; |
|
|
|
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; |
|
|
|
import com.epmet.commons.tools.enums.AchievementTypeEnum; |
|
|
|
import com.epmet.commons.tools.enums.EventEnum; |
|
|
@ -17,14 +23,17 @@ import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerStaffRedis; |
|
|
|
import com.epmet.commons.tools.redis.common.bean.GridInfoCache; |
|
|
|
import com.epmet.commons.tools.scan.param.ImgScanParamDTO; |
|
|
|
import com.epmet.commons.tools.scan.param.ImgTaskDTO; |
|
|
|
import com.epmet.commons.tools.scan.param.TextScanParamDTO; |
|
|
|
import com.epmet.commons.tools.scan.param.TextTaskDTO; |
|
|
|
import com.epmet.commons.tools.scan.result.SyncScanResult; |
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.commons.tools.utils.ScanContentUtils; |
|
|
|
import com.epmet.commons.tools.utils.*; |
|
|
|
import com.epmet.commons.tools.utils.poi.excel.handler.FreezeAndFilter; |
|
|
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
|
|
|
import com.epmet.constant.IssueConstant; |
|
|
|
import com.epmet.constant.ReadFlagConstant; |
|
|
@ -39,12 +48,12 @@ import com.epmet.dto.form.IssueAuditionFormDTO; |
|
|
|
import com.epmet.dto.form.IssueShiftedFromTopicFormDTO; |
|
|
|
import com.epmet.dto.form.*; |
|
|
|
import com.epmet.dto.result.*; |
|
|
|
import com.epmet.entity.IssueEntity; |
|
|
|
import com.epmet.entity.IssueProcessEntity; |
|
|
|
import com.epmet.entity.IssueProjectRelationEntity; |
|
|
|
import com.epmet.entity.*; |
|
|
|
import com.epmet.excel.AllIssueListExportExcel; |
|
|
|
import com.epmet.feign.*; |
|
|
|
import com.epmet.redis.GovIssueRedis; |
|
|
|
import com.epmet.redis.IssueVoteDetailRedis; |
|
|
|
import com.epmet.resi.group.constant.TopicConstant; |
|
|
|
import com.epmet.resi.group.dto.group.form.AllIssueFormDTO; |
|
|
|
import com.epmet.resi.group.dto.group.form.GroupInfoFormDTO; |
|
|
|
import com.epmet.resi.group.dto.group.result.GroupClosedListResultDTO; |
|
|
@ -71,10 +80,16 @@ import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.PrintWriter; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.atomic.AtomicReference; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
import static com.epmet.commons.tools.utils.DateUtils.DATE_PATTERN; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Author zxc |
|
|
|
* @CreateTime 2020/5/11 9:46 |
|
|
@ -140,12 +155,16 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp |
|
|
|
private IssueVoteDetailService issueVoteDetailService; |
|
|
|
@Autowired |
|
|
|
private DistributedLock distributedLock; |
|
|
|
@Autowired |
|
|
|
private IssueAttachmentService issueAttachmentService; |
|
|
|
|
|
|
|
|
|
|
|
@Value("${openapi.scan.server.url}") |
|
|
|
private String scanApiUrl; |
|
|
|
@Value("${openapi.scan.method.textSyncScan}") |
|
|
|
private String textSyncScanMethod; |
|
|
|
@Value("${openapi.scan.method.imgSyncScan}") |
|
|
|
private String imgSyncScanMethod; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<IssueDTO> page(Map<String, Object> params) { |
|
|
@ -209,13 +228,8 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp |
|
|
|
//议题信息
|
|
|
|
IssueResultDTO issueResult = issueDao.issueDetail(issueDetail); |
|
|
|
if (null != issueResult && StringUtils.isNotBlank(issueResult.getGridId())) { |
|
|
|
BelongGridNameFormDTO formDTO = new BelongGridNameFormDTO(); |
|
|
|
formDTO.setGridId(issueResult.getGridId()); |
|
|
|
Result<BelongGridNameResultDTO> result = govOrgOpenFeignClient.getGridNameByGridId(formDTO); |
|
|
|
logger.info("根据网格id查询网格名称接口返参:" + JSON.toJSONString(result)); |
|
|
|
if (result.success() && null != result.getData()) { |
|
|
|
issueResult.setGridName(result.getData().getBelongsGridName()); |
|
|
|
} |
|
|
|
GridInfoCache gridInfoCache = CustomerOrgRedis.getGridInfo(issueResult.getGridId()); |
|
|
|
issueResult.setGridName(null != gridInfoCache ? gridInfoCache.getGridNamePath() : StrConstant.EPMETY_STR); |
|
|
|
} |
|
|
|
return issueResult; |
|
|
|
} |
|
|
@ -376,8 +390,11 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp |
|
|
|
result.setAuditSwitch(ifOpen ? ModuleConstants.AUDIT_SWITCH_OPEN : ModuleConstants.AUDIT_SWITCH_CLOSE); |
|
|
|
|
|
|
|
//2.居民端组长提交议题审核
|
|
|
|
|
|
|
|
//默认打开
|
|
|
|
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(param.getGridId()); |
|
|
|
if (null == gridInfo){ |
|
|
|
throw new EpmetException("查询网格信息失败:"+param.getGridId()); |
|
|
|
} |
|
|
|
//默认打开
|
|
|
|
//2.1查询是否存在application记录
|
|
|
|
Map<String, Object> applicationParam = new HashMap<>(); |
|
|
|
applicationParam.put(ModuleConstants.FIELD_JAVA_TOPIC_ID, param.getTopicId()); |
|
|
@ -390,6 +407,8 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp |
|
|
|
if(ifOpen) { |
|
|
|
//首次提交 新增application
|
|
|
|
IssueApplicationDTO newApplication = ConvertUtils.sourceToTarget(param, IssueApplicationDTO.class); |
|
|
|
newApplication.setOrgId(gridInfo.getPid()); |
|
|
|
newApplication.setOrgIdPath(gridInfo.getPids()); |
|
|
|
newApplication.setApplyStatus(defaultStatusUnderAuditing); |
|
|
|
newApplication.setId(UUID.randomUUID().toString().replace("-", "")); |
|
|
|
applicationService.save(newApplication); |
|
|
@ -558,8 +577,6 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp |
|
|
|
app2update.setIssueId(issueResult.getIssueId()); |
|
|
|
|
|
|
|
} |
|
|
|
}else { |
|
|
|
throw new RenException(topicInfo.getInternalMsg()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -591,7 +608,7 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp |
|
|
|
boolean flag = SendMqMsgUtil.build().openFeignClient(epmetMessageOpenFeignClient) |
|
|
|
.sendGroupAchievementMqMsg(new GroupAchievementMQMsg(application.getCustomerId(), application.getGroupId(), AchievementTypeEnum.TOISSUE.getCode())); |
|
|
|
if (!flag) { |
|
|
|
logger.error("发送(小组成就)系统消息到message服务失败"); |
|
|
|
logger.warn("发送(小组成就)系统消息到message服务失败"); |
|
|
|
} |
|
|
|
return app2update.getIssueId(); |
|
|
|
} |
|
|
@ -606,7 +623,8 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp |
|
|
|
@Override |
|
|
|
public List<VotingIssueListResultDTO> votingList(CommonIssueListFormDTO issueListForm) { |
|
|
|
PageHelper.startPage(issueListForm.getPageNo(), issueListForm.getPageSize(), issueListForm.getIsPage()); |
|
|
|
return baseDao.selectVotingList(issueListForm); |
|
|
|
List<VotingIssueListResultDTO> resultList=baseDao.selectVotingList(issueListForm); |
|
|
|
return resultList; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -619,7 +637,8 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp |
|
|
|
@Override |
|
|
|
public List<ClosedIssueListResultDTO> closedList(CommonIssueListFormDTO issueListForm) { |
|
|
|
PageHelper.startPage(issueListForm.getPageNo(), issueListForm.getPageSize(), issueListForm.getIsPage()); |
|
|
|
return baseDao.selectClosedList(issueListForm); |
|
|
|
List<ClosedIssueListResultDTO> resultDTOList=baseDao.selectClosedList(issueListForm); |
|
|
|
return resultDTOList; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -633,7 +652,11 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp |
|
|
|
public GovIssueDetailResultDTO issueDetailGov(IssueDetailFormDTO issueParam) { |
|
|
|
//1.得到议题信息
|
|
|
|
IssueEntity issueDetail = selectById(issueParam.getIssueId()); |
|
|
|
|
|
|
|
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(issueDetail.getGridId()); |
|
|
|
if(null == gridInfo){ |
|
|
|
throw new EpmetException("查询网格信息失败"+issueDetail.getGridId()); |
|
|
|
} |
|
|
|
GovIssueDetailResultDTO issueInfo = new GovIssueDetailResultDTO(); |
|
|
|
//2.1如果此条议题来源自话题
|
|
|
|
if(StringUtils.equals(ModuleConstants.ISSUE_FROM_TOPIC,issueDetail.getSourceType())){ |
|
|
|
GovTopicIssueInfoFormDTO topicParam = new GovTopicIssueInfoFormDTO(); |
|
|
@ -645,10 +668,11 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp |
|
|
|
resiGroupFeignClient.topicInfoForIssueDetailGov(topicParam); |
|
|
|
if(topicResult.success() && null != topicResult.getData()){ |
|
|
|
GovTopicOfIssueInfoResultDTO topicInfo = ConvertUtils.sourceToTarget(topicResult.getData(),GovTopicOfIssueInfoResultDTO.class); |
|
|
|
GovIssueDetailResultDTO issueInfo = ConvertUtils.sourceToTarget(topicResult.getData(),GovIssueDetailResultDTO.class); |
|
|
|
issueInfo = ConvertUtils.sourceToTarget(topicResult.getData(),GovIssueDetailResultDTO.class); |
|
|
|
issueInfo.setIssueStatus(issueDetail.getIssueStatus()); |
|
|
|
issueInfo.setIssueSuggestion(issueDetail.getSuggestion()); |
|
|
|
issueInfo.setIssueTitle(issueDetail.getIssueTitle()); |
|
|
|
issueInfo.setSourceId(issueDetail.getSourceId()); |
|
|
|
issueInfo.setVotingDeadline(null == issueDetail.getVotingDeadline() |
|
|
|
? NumConstant.ZERO_L : issueDetail.getVotingDeadline().getTime()/NumConstant.ONE_THOUSAND); |
|
|
|
issueInfo.setTopicInfo(topicInfo); |
|
|
@ -660,6 +684,29 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp |
|
|
|
return issueInfo; |
|
|
|
} |
|
|
|
//查询话题失败异常
|
|
|
|
}else if (ModuleConstants.ISSUE.equals(issueDetail.getSourceType())){ |
|
|
|
issueInfo = ConvertUtils.sourceToTarget(issueDetail,GovIssueDetailResultDTO.class); |
|
|
|
issueInfo.setIssueSuggestion(issueDetail.getSuggestion()); |
|
|
|
Result<List<UserBaseInfoResultDTO>> userResult = userOpenFeignClient.queryUserBaseInfo(Arrays.asList(issueDetail.getCreatedBy())); |
|
|
|
if (!userResult.success() || CollectionUtils.isEmpty(userResult.getData())){ |
|
|
|
throw new EpmetException("查询居民信息失败"); |
|
|
|
} |
|
|
|
UserBaseInfoResultDTO user = userResult.getData().get(NumConstant.ZERO); |
|
|
|
issueInfo.setIssueInitiator(user.getShowName()); |
|
|
|
issueInfo.setIssuePublisherMobile(user.getMobile()); |
|
|
|
issueInfo.setBelongsGridName(gridInfo.getGridNamePath()); |
|
|
|
return issueInfo; |
|
|
|
}else { |
|
|
|
issueInfo = ConvertUtils.sourceToTarget(issueDetail,GovIssueDetailResultDTO.class); |
|
|
|
issueInfo.setIssueSuggestion(issueDetail.getSuggestion()); |
|
|
|
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(issueDetail.getCustomerId(), issueDetail.getCreatedBy()); |
|
|
|
if (null == staffInfo){ |
|
|
|
throw new EpmetException("查询工作人员信息失败:"+issueDetail.getCreatedBy()); |
|
|
|
} |
|
|
|
issueInfo.setIssueInitiator(staffInfo.getRealName()); |
|
|
|
issueInfo.setIssuePublisherMobile(staffInfo.getMobile()); |
|
|
|
issueInfo.setBelongsGridName(gridInfo.getGridNamePath()); |
|
|
|
return issueInfo; |
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
@ -675,50 +722,37 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void closeIssue(CloseIssueFormDTO formDTO) { |
|
|
|
//公开回复内容审核
|
|
|
|
if (StringUtils.isNotBlank(formDTO.getCloseReason())) { |
|
|
|
TextScanParamDTO textScanParamDTO = new TextScanParamDTO(); |
|
|
|
TextTaskDTO taskDTO = new TextTaskDTO(); |
|
|
|
taskDTO.setDataId(UUID.randomUUID().toString().replace("-", "")); |
|
|
|
taskDTO.setContent(formDTO.getCloseReason()); |
|
|
|
textScanParamDTO.getTasks().add(taskDTO); |
|
|
|
Result<SyncScanResult> textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO); |
|
|
|
if (!textSyncScanResult.success()){ |
|
|
|
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); |
|
|
|
} else { |
|
|
|
if (!textSyncScanResult.getData().isAllPass()) { |
|
|
|
throw new RenException(EpmetErrorCode.TEXT_SCAN_FAILED.getCode()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
checkCloseReason(formDTO.getCloseReason()); |
|
|
|
|
|
|
|
Date date = new Date(); |
|
|
|
Date nowTime = new Date(); |
|
|
|
//1:更新议题详情表数据
|
|
|
|
IssueEntity entity = baseDao.selectById(formDTO.getIssueId()); |
|
|
|
if (null == entity) { |
|
|
|
throw new RenException(IssueConstant.SELECT_EXCEPTION); |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),IssueConstant.SELECT_EXCEPTION,"议题不存在"); |
|
|
|
} |
|
|
|
if (IssueConstant.ISSUE_CLOSED.equals(entity.getIssueStatus())) { |
|
|
|
throw new RenException(IssueConstant.OPERATION_EXCEPTION); |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),IssueConstant.OPERATION_EXCEPTION,"议题不存在"); |
|
|
|
} |
|
|
|
entity.setIssueStatus(IssueConstant.ISSUE_CLOSED); |
|
|
|
entity.setCloseReason(formDTO.getCloseReason()); |
|
|
|
entity.setResolveType(formDTO.getResolveType()); |
|
|
|
entity.setVotingDeadline(date); |
|
|
|
entity.setClosedTime(date); |
|
|
|
entity.setVotingDeadline(nowTime); |
|
|
|
entity.setClosedTime(nowTime); |
|
|
|
if (baseDao.updateById(entity) < NumConstant.ONE) { |
|
|
|
throw new RenException(IssueConstant.UPPDATE_EXCEPTION); |
|
|
|
} |
|
|
|
|
|
|
|
//2:调用gov-org服务,查询组织网格名称
|
|
|
|
AgencyGridResultDTO agencyGridResultDTO = new AgencyGridResultDTO(); |
|
|
|
/*AgencyGridResultDTO agencyGridResultDTO = new AgencyGridResultDTO(); |
|
|
|
agencyGridResultDTO.setAgencyId(entity.getOrgId()); |
|
|
|
agencyGridResultDTO.setGridId(entity.getGridId()); |
|
|
|
Result<AgencyGridResultDTO> resultDTO = govOrgFeignClient.getAgencyAndGrid(agencyGridResultDTO); |
|
|
|
if (!resultDTO.success() || null == resultDTO.getData()) { |
|
|
|
throw new RenException(IssueConstant.SELECT_GOV_ORG_EXCEPTION); |
|
|
|
} |
|
|
|
agencyGridResultDTO = resultDTO.getData(); |
|
|
|
|
|
|
|
agencyGridResultDTO = resultDTO.getData();*/ |
|
|
|
//上面代码注释,改用缓存
|
|
|
|
GridInfoCache gridInfoCache=CustomerOrgRedis.getGridInfo(entity.getGridId()); |
|
|
|
//3:议题进展记录表新增数据
|
|
|
|
IssueProcessEntity processEntity = new IssueProcessEntity(); |
|
|
|
processEntity.setIssueId(formDTO.getIssueId()); |
|
|
@ -726,30 +760,28 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp |
|
|
|
processEntity.setOrgType(IssueConstant.ISSUE_GRID); |
|
|
|
processEntity.setOrgId(entity.getGridId()); |
|
|
|
processEntity.setOperationExplain(formDTO.getCloseReason()); |
|
|
|
processEntity.setOrgName(agencyGridResultDTO.getAgencyName() + "-" + agencyGridResultDTO.getGridName()); |
|
|
|
// processEntity.setOrgName(agencyGridResultDTO.getAgencyName() + "-" + agencyGridResultDTO.getGridName());
|
|
|
|
processEntity.setOrgName(gridInfoCache.getGridNamePath()); |
|
|
|
processEntity.setCreatedTime(nowTime); |
|
|
|
processEntity.setUpdatedTime(nowTime); |
|
|
|
processEntity.setCustomerId(entity.getCustomerId()); |
|
|
|
issueProcessDao.insert(processEntity); |
|
|
|
|
|
|
|
//4:调用epmet-message服务,给居民端话题创建人和议题发起人发送消息
|
|
|
|
//4.1:调用resi-group查询话题创建人数据(目前议题来源只有来自话题)
|
|
|
|
Result<ResiTopicDTO> resultTopicDTO = resiGroupFeignClient.getTopicById(entity.getSourceId()); |
|
|
|
if (!resultTopicDTO.success() || null == resultTopicDTO.getData()) { |
|
|
|
throw new RenException(IssueConstant.SELECT_TOPIC_EXCEPTION); |
|
|
|
} |
|
|
|
ResiTopicDTO topicDTO = resultTopicDTO.getData(); |
|
|
|
//4.2:创建消息模板
|
|
|
|
String messageContent = ""; |
|
|
|
if (IssueConstant.ISSUE_RESOLVED.equals(formDTO.getResolveType())) { |
|
|
|
messageContent = String.format(UserMessageConstant.ISSUE_RESOLVED_MSG, topicDTO.getTopicContent(), formDTO.getCloseReason()); |
|
|
|
} else if (IssueConstant.ISSUE_UNRESOLVED.equals(formDTO.getResolveType())) { |
|
|
|
messageContent = String.format(UserMessageConstant.ISSUE_UNRESOLVED_MSG, topicDTO.getTopicContent(), formDTO.getCloseReason()); |
|
|
|
} |
|
|
|
//4.3:调用服务,发送消息
|
|
|
|
if (!saveUserMessageList(topicDTO, messageContent, entity).success()) { |
|
|
|
throw new RenException(IssueConstant.SAVE_MSG_EXCEPTION); |
|
|
|
} |
|
|
|
//4.4:2020.10.26 添加推送微信订阅消息功能 sun
|
|
|
|
if (!saveWxmpMessageList(topicDTO, messageContent, entity).success()) { |
|
|
|
logger.error("议题关闭,推送微信订阅消息失败!"); |
|
|
|
if (entity.getSourceType().equals(ModuleConstants.ISSUE_FROM_TOPIC)){ |
|
|
|
//4.1:调用resi-group查询话题创建人数据(目前议题来源只有来自话题)
|
|
|
|
sendToTopicAndShiftIssueResiUser(entity.getSourceId(),formDTO.getResolveType(),entity,formDTO.getCloseReason()); |
|
|
|
}else if(entity.getSourceType().equals("ic_event")){ |
|
|
|
ColseProjectOrDemandFormDTO colseProjectOrDemandFormDTO=new ColseProjectOrDemandFormDTO(); |
|
|
|
colseProjectOrDemandFormDTO.setCustomerId(entity.getCustomerId()); |
|
|
|
colseProjectOrDemandFormDTO.setIcEventId(entity.getSourceId()); |
|
|
|
colseProjectOrDemandFormDTO.setType("issue"); |
|
|
|
colseProjectOrDemandFormDTO.setUserId(formDTO.getCurrentUserId()); |
|
|
|
colseProjectOrDemandFormDTO.setCloseCaseTime(nowTime); |
|
|
|
Result result = govProjectOpenFeignClient.closeProjectOrDemand(colseProjectOrDemandFormDTO); |
|
|
|
if (!result.success()) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"议题关闭异常,该议题来源于事件,回写事件信息失败","议题关闭异常:事件办结异常"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
@ -757,12 +789,57 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp |
|
|
|
SelectIssueVotingDetailFormDTO dto = new SelectIssueVotingDetailFormDTO(); |
|
|
|
dto.setGridId(entity.getGridId()); |
|
|
|
dto.setIssueId(formDTO.getIssueId()); |
|
|
|
dto.setSourceType(entity.getSourceType()); |
|
|
|
issueVoteDetailService.updateVote(dto); |
|
|
|
}catch (RenException e){ |
|
|
|
logger.error(e.getInternalMsg()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 议题关闭时,填写的关闭理由,走内容审核 |
|
|
|
* @param closeReason |
|
|
|
*/ |
|
|
|
private void checkCloseReason(String closeReason) { |
|
|
|
if (StringUtils.isNotBlank(closeReason)) { |
|
|
|
TextScanParamDTO textScanParamDTO = new TextScanParamDTO(); |
|
|
|
TextTaskDTO taskDTO = new TextTaskDTO(); |
|
|
|
taskDTO.setDataId(UUID.randomUUID().toString().replace("-", "")); |
|
|
|
taskDTO.setContent(closeReason); |
|
|
|
textScanParamDTO.getTasks().add(taskDTO); |
|
|
|
Result<SyncScanResult> textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO); |
|
|
|
if (!textSyncScanResult.success()) { |
|
|
|
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); |
|
|
|
} else { |
|
|
|
if (!textSyncScanResult.getData().isAllPass()) { |
|
|
|
throw new RenException(EpmetErrorCode.TEXT_SCAN_FAILED.getCode()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void sendToTopicAndShiftIssueResiUser(String topicId,String resolveType,IssueEntity issueEntity,String closeReason) { |
|
|
|
Result<ResiTopicDTO> resultTopicDTO = resiGroupFeignClient.getTopicById(topicId); |
|
|
|
if (resultTopicDTO.success() &&null != resultTopicDTO.getData()) { |
|
|
|
ResiTopicDTO topicDTO = resultTopicDTO.getData(); |
|
|
|
//4.2:创建消息模板
|
|
|
|
String messageContent = ""; |
|
|
|
if (IssueConstant.ISSUE_RESOLVED.equals(resolveType)) { |
|
|
|
messageContent = String.format(UserMessageConstant.ISSUE_RESOLVED_MSG, topicDTO.getTopicContent(), closeReason); |
|
|
|
} else if (IssueConstant.ISSUE_UNRESOLVED.equals(resolveType)) { |
|
|
|
messageContent = String.format(UserMessageConstant.ISSUE_UNRESOLVED_MSG, topicDTO.getTopicContent(), closeReason); |
|
|
|
} |
|
|
|
//4.3:调用服务,发送消息
|
|
|
|
if (!saveUserMessageList(topicDTO, messageContent, issueEntity).success()) { |
|
|
|
throw new RenException(IssueConstant.SAVE_MSG_EXCEPTION); |
|
|
|
} |
|
|
|
//4.4:2020.10.26 添加推送微信订阅消息功能 sun
|
|
|
|
if (!saveWxmpMessageList(topicDTO, messageContent, issueEntity).success()) { |
|
|
|
logger.warn("议题关闭,推送微信订阅消息失败!"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 关闭议题时给话题创建人和议题发起人发送消息 |
|
|
|
* @author sun |
|
|
@ -938,7 +1015,7 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp |
|
|
|
} |
|
|
|
|
|
|
|
try{ |
|
|
|
issueVoteStatisticalService.syncVotingCacheToDbByParams(formDTO.getIssueId(),entity.getGridId(),null); |
|
|
|
issueVoteStatisticalService.syncVotingCacheToDbByParams(entity,null); |
|
|
|
}catch(RenException e){ |
|
|
|
logger.error(e.getInternalMsg()); |
|
|
|
} |
|
|
@ -1005,18 +1082,21 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp |
|
|
|
//因需要保证议题表中的转项目时间与创建项目时间一致 因此先新增项目数据再更新议题数据
|
|
|
|
|
|
|
|
//2:调用resi-group查询话题创建人数据(目前议题来源只有来自话题),为了到项目服务初始数据以及发送消息使用
|
|
|
|
Result<ResiTopicDTO> resultTopicDTO = resiGroupFeignClient.getTopicById(entity.getSourceId()); |
|
|
|
if (!resultTopicDTO.success() || null == resultTopicDTO.getData()) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),IssueConstant.SELECT_TOPIC_EXCEPTION,IssueConstant.SELECT_TOPIC_EXCEPTION); |
|
|
|
if("resi_topic".equals(entity.getSourceType())){ |
|
|
|
Result<ResiTopicDTO> resultTopicDTO = resiGroupFeignClient.getTopicById(entity.getSourceId()); |
|
|
|
if (!resultTopicDTO.success() || null == resultTopicDTO.getData()) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),IssueConstant.SELECT_TOPIC_EXCEPTION,IssueConstant.SELECT_TOPIC_EXCEPTION); |
|
|
|
} |
|
|
|
ResiTopicDTO topicDTO = resultTopicDTO.getData(); |
|
|
|
formDTO.setTopicDTO(topicDTO); |
|
|
|
} |
|
|
|
ResiTopicDTO topicDTO = resultTopicDTO.getData(); |
|
|
|
formDTO.setTopicDTO(topicDTO); |
|
|
|
|
|
|
|
//3:调用gov-project服务,新增项目各业务表初始数据
|
|
|
|
formDTO.setCategoryList(categoryList); |
|
|
|
formDTO.setGridId(entity.getGridId()); |
|
|
|
List<IssueTagsDTO> tagList = issueTagsService.getTagsByIssue(formDTO.getIssueId()); |
|
|
|
formDTO.setTagList(tagList); |
|
|
|
// 议题转项目!!!!!!!!!!!!在这步
|
|
|
|
Result<IssueProjectResultDTO> resultDTO = govProjectFeignClient.issueShiftProject(formDTO); |
|
|
|
if (!resultDTO.success() || null == resultDTO.getData()) { |
|
|
|
logger.error(resultDTO.getInternalMsg()); |
|
|
@ -1065,9 +1145,9 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp |
|
|
|
//6:缓存中网格下表决中的议题总数减1
|
|
|
|
govIssueRedis.subtractWorkGrassrootsIssueRedDotValue(entity.getGridId()); |
|
|
|
try{ |
|
|
|
issueVoteStatisticalService.syncVotingCacheToDbByParams(formDTO.getIssueId(),entity.getGridId(),null); |
|
|
|
issueVoteStatisticalService.syncVotingCacheToDbByParams(entity,null); |
|
|
|
}catch(RenException e){ |
|
|
|
logger.error(e.getInternalMsg()); |
|
|
|
logger.error("subtractWorkGrassrootsIssueRedDotValue报错:"+e.getInternalMsg()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1104,32 +1184,50 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp |
|
|
|
|
|
|
|
List<UserMessageFormDTO> msgList = new ArrayList<>(); |
|
|
|
//1:创建话题发起人、议题发表人消息对象
|
|
|
|
UserMessageFormDTO msgDTO = new UserMessageFormDTO(); |
|
|
|
msgDTO.setCustomerId(entity.getCustomerId()); |
|
|
|
msgDTO.setGridId(entity.getGridId()); |
|
|
|
msgDTO.setApp(AppClientConstant.APP_RESI); |
|
|
|
msgDTO.setTitle(UserMessageConstant.ISSUE_TITLE); |
|
|
|
String topicIssueMessage = String.format(UserMessageConstant.ISSUE_SHIFT_PROJECT_MSG, formDTO.getTopicDTO().getTopicContent(), issueProjectResultDTO.getOrgName()); |
|
|
|
msgDTO.setMessageContent(topicIssueMessage); |
|
|
|
msgDTO.setReadFlag(ReadFlagConstant.UN_READ); |
|
|
|
msgDTO.setUserId(formDTO.getTopicDTO().getCreatedBy()); |
|
|
|
if ("resi_topic".equals(entity.getSourceType()) && null != formDTO.getTopicDTO()) { |
|
|
|
UserMessageFormDTO msgDTO = new UserMessageFormDTO(); |
|
|
|
msgDTO.setCustomerId(entity.getCustomerId()); |
|
|
|
msgDTO.setGridId(entity.getGridId()); |
|
|
|
msgDTO.setApp(AppClientConstant.APP_RESI); |
|
|
|
msgDTO.setTitle(UserMessageConstant.ISSUE_TITLE); |
|
|
|
String topicIssueMessage = String.format(UserMessageConstant.ISSUE_SHIFT_PROJECT_MSG, formDTO.getTopicDTO().getTopicContent(), issueProjectResultDTO.getOrgName()); |
|
|
|
msgDTO.setMessageContent(topicIssueMessage); |
|
|
|
msgDTO.setReadFlag(ReadFlagConstant.UN_READ); |
|
|
|
msgDTO.setUserId(formDTO.getTopicDTO().getCreatedBy()); |
|
|
|
|
|
|
|
//21.09.10:记录消息类型和对应的业务id
|
|
|
|
msgDTO.setMessageType(UserMessageTypeConstant.ISSUE_SHIFT_PROJECT); |
|
|
|
msgDTO.setTargetId(entity.getId()); |
|
|
|
//21.09.10:记录消息类型和对应的业务id
|
|
|
|
msgDTO.setMessageType(UserMessageTypeConstant.ISSUE_SHIFT_PROJECT); |
|
|
|
msgDTO.setTargetId(entity.getId()); |
|
|
|
|
|
|
|
msgList.add(msgDTO); |
|
|
|
//话题人和议题人是同一个人时则只发送一条居民消息
|
|
|
|
if (!formDTO.getTopicDTO().getCreatedBy().equals(entity.getCreatedBy())) { |
|
|
|
UserMessageFormDTO msgIssue = ConvertUtils.sourceToTarget(msgDTO, UserMessageFormDTO.class); |
|
|
|
msgIssue.setUserId(entity.getCreatedBy()); |
|
|
|
msgList.add(msgDTO); |
|
|
|
|
|
|
|
//21.09.10:记录消息类型和对应的业务id
|
|
|
|
msgIssue.setMessageType(UserMessageTypeConstant.ISSUE_SHIFT_PROJECT); |
|
|
|
msgIssue.setTargetId(entity.getId()); |
|
|
|
//话题人和议题人是同一个人时则只发送一条居民消息
|
|
|
|
if (!formDTO.getTopicDTO().getCreatedBy().equals(entity.getCreatedBy())) { |
|
|
|
UserMessageFormDTO msgIssue = ConvertUtils.sourceToTarget(msgDTO, UserMessageFormDTO.class); |
|
|
|
msgIssue.setUserId(entity.getCreatedBy()); |
|
|
|
|
|
|
|
msgList.add(msgIssue); |
|
|
|
//21.09.10:记录消息类型和对应的业务id
|
|
|
|
msgIssue.setMessageType(UserMessageTypeConstant.ISSUE_SHIFT_PROJECT); |
|
|
|
msgIssue.setTargetId(entity.getId()); |
|
|
|
|
|
|
|
msgList.add(msgIssue); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
//居民端发布的议题,只给议题发布人发送消息
|
|
|
|
UserMessageFormDTO msgDTO = new UserMessageFormDTO(); |
|
|
|
msgDTO.setCustomerId(entity.getCustomerId()); |
|
|
|
msgDTO.setGridId(entity.getGridId()); |
|
|
|
msgDTO.setApp(AppClientConstant.APP_RESI); |
|
|
|
msgDTO.setTitle(UserMessageConstant.ISSUE_TITLE); |
|
|
|
String issueMessage = String.format(UserMessageConstant.PUB_ISSUE_SHIFT_PROJECT_MSG, entity.getIssueTitle(), issueProjectResultDTO.getOrgName()); |
|
|
|
msgDTO.setMessageContent(issueMessage); |
|
|
|
msgDTO.setReadFlag(ReadFlagConstant.UN_READ); |
|
|
|
msgDTO.setUserId(entity.getCreatedBy()); |
|
|
|
msgDTO.setMessageType(UserMessageTypeConstant.ISSUE_SHIFT_PROJECT); |
|
|
|
msgDTO.setTargetId(entity.getId()); |
|
|
|
msgList.add(msgDTO); |
|
|
|
} |
|
|
|
|
|
|
|
//2:创建项目工作人员消息对象
|
|
|
|
String projectStaffMessage = String.format(UserMessageConstant.PROJECT_RESOLVED_MSG, entity.getIssueTitle()); |
|
|
|
//所选人员如果即在部门下又在网格下则只发一条消息
|
|
|
@ -1161,20 +1259,34 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp |
|
|
|
*/ |
|
|
|
private Result wxmpShiftProjectMessage(IssueProjectResultDTO issueProjectResultDTO, ShiftProjectFormDTO formDTO, IssueEntity entity) { |
|
|
|
List<WxSubscribeMessageFormDTO> msgList = new ArrayList<>(); |
|
|
|
//1:创建话题发起人、议题发表人消息对象
|
|
|
|
WxSubscribeMessageFormDTO msgDTO = new WxSubscribeMessageFormDTO(); |
|
|
|
msgDTO.setCustomerId(entity.getCustomerId()); |
|
|
|
msgDTO.setClientType(AppClientConstant.APP_RESI); |
|
|
|
msgDTO.setUserId(formDTO.getTopicDTO().getCreatedBy()); |
|
|
|
msgDTO.setBehaviorType(UserMessageConstant.WXMP_ISSUE_TITLE); |
|
|
|
String topicIssueMessage = String.format(UserMessageConstant.ISSUE_SHIFT_PROJECT_MSG, formDTO.getTopicDTO().getTopicContent(), issueProjectResultDTO.getOrgName()); |
|
|
|
msgDTO.setMessageContent(topicIssueMessage); |
|
|
|
msgDTO.setMessageTime(new Date()); |
|
|
|
msgDTO.setGridId(entity.getGridId()); |
|
|
|
msgList.add(msgDTO); |
|
|
|
//话题人和议题人是同一个人时则只发送一条居民消息
|
|
|
|
if (!formDTO.getTopicDTO().getCreatedBy().equals(entity.getCreatedBy())) { |
|
|
|
WxSubscribeMessageFormDTO msgIssue = ConvertUtils.sourceToTarget(msgDTO, WxSubscribeMessageFormDTO.class); |
|
|
|
if ("resi_topic".equals(entity.getSourceType()) && null != formDTO.getTopicDTO()) { |
|
|
|
//1:创建话题发起人、议题发表人消息对象
|
|
|
|
WxSubscribeMessageFormDTO msgDTO = new WxSubscribeMessageFormDTO(); |
|
|
|
msgDTO.setCustomerId(entity.getCustomerId()); |
|
|
|
msgDTO.setClientType(AppClientConstant.APP_RESI); |
|
|
|
msgDTO.setUserId(formDTO.getTopicDTO().getCreatedBy()); |
|
|
|
msgDTO.setBehaviorType(UserMessageConstant.WXMP_ISSUE_TITLE); |
|
|
|
String topicIssueMessage = String.format(UserMessageConstant.ISSUE_SHIFT_PROJECT_MSG, formDTO.getTopicDTO().getTopicContent(), issueProjectResultDTO.getOrgName()); |
|
|
|
msgDTO.setMessageContent(topicIssueMessage); |
|
|
|
msgDTO.setMessageTime(new Date()); |
|
|
|
msgDTO.setGridId(entity.getGridId()); |
|
|
|
msgList.add(msgDTO); |
|
|
|
//话题人和议题人是同一个人时则只发送一条居民消息
|
|
|
|
if (!formDTO.getTopicDTO().getCreatedBy().equals(entity.getCreatedBy())) { |
|
|
|
WxSubscribeMessageFormDTO msgIssue = ConvertUtils.sourceToTarget(msgDTO, WxSubscribeMessageFormDTO.class); |
|
|
|
msgIssue.setUserId(entity.getCreatedBy()); |
|
|
|
msgList.add(msgIssue); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
//只给议题发布人发送微信消息
|
|
|
|
WxSubscribeMessageFormDTO msgIssue = new WxSubscribeMessageFormDTO(); |
|
|
|
msgIssue.setCustomerId(entity.getCustomerId()); |
|
|
|
msgIssue.setClientType(AppClientConstant.APP_RESI); |
|
|
|
msgIssue.setBehaviorType(UserMessageConstant.WXMP_ISSUE_TITLE); |
|
|
|
String topicIssueMessage = String.format(UserMessageConstant.PUB_ISSUE_SHIFT_PROJECT_MSG, entity.getIssueTitle(), issueProjectResultDTO.getOrgName()); |
|
|
|
msgIssue.setMessageContent(topicIssueMessage); |
|
|
|
msgIssue.setMessageTime(new Date()); |
|
|
|
msgIssue.setGridId(entity.getGridId()); |
|
|
|
msgIssue.setUserId(entity.getCreatedBy()); |
|
|
|
msgList.add(msgIssue); |
|
|
|
} |
|
|
@ -1342,11 +1454,11 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp |
|
|
|
throw new RenException("查询议题来源网格名称失败......"); |
|
|
|
} |
|
|
|
list.forEach(l -> gridNameList.getData().stream().filter(o -> l.getGridId().equals(o.getGridId())).forEach(o -> l.setTopicReleaseGridName(o.getGridName()))); |
|
|
|
Result<List<GroupInfoResultDTO>> groupNameList = resiGroupOpenFeignClient.selectGroupInfo(new GroupInfoFormDTO(list.stream().map(m -> m.getTopicId()).collect(Collectors.toList()))); |
|
|
|
Result<List<GroupInfoResultDTO>> groupNameList = resiGroupOpenFeignClient.selectGroupInfo(new GroupInfoFormDTO(list.stream().filter(l -> l.getSourceType().equals(ModuleConstants.ISSUE_FROM_TOPIC)).map(m -> m.getTopicId()).collect(Collectors.toList()))); |
|
|
|
if (!groupNameList.success()){ |
|
|
|
throw new RenException("查询议题来源小组名称失败......"); |
|
|
|
} |
|
|
|
list.forEach(l -> groupNameList.getData().stream().filter(g -> l.getTopicId().equals(g.getTopicId())).forEach(g -> l.setTopicReleaseGroupName(g.getTopicGroupName()))); |
|
|
|
list.forEach(l -> groupNameList.getData().stream().filter(g -> org.apache.commons.lang3.StringUtils.isNotBlank(l.getTopicId()) && l.getTopicId().equals(g.getTopicId())).forEach(g -> l.setTopicReleaseGroupName(g.getTopicGroupName()))); |
|
|
|
} |
|
|
|
return list; |
|
|
|
} |
|
|
@ -1500,12 +1612,14 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp |
|
|
|
if (!CollectionUtils.isEmpty(votedCount)){ |
|
|
|
userIds.addAll(votedCount); |
|
|
|
} |
|
|
|
// 话题创建者
|
|
|
|
Result<String> topicCreatedUser = resiGroupOpenFeignClient.topicCreatedUser(issueEntity.getSourceId()); |
|
|
|
if (!topicCreatedUser.success()){ |
|
|
|
throw new RenException("【查询话题创建者失败】["+topicCreatedUser.getMsg()+"]"); |
|
|
|
if("resi_topic".equals(issueEntity.getSourceType())){ |
|
|
|
// 话题创建者
|
|
|
|
Result<String> topicCreatedUser = resiGroupOpenFeignClient.topicCreatedUser(issueEntity.getSourceId()); |
|
|
|
if (!topicCreatedUser.success()){ |
|
|
|
throw new RenException("【查询话题创建者失败】["+topicCreatedUser.getMsg()+"]"); |
|
|
|
} |
|
|
|
userIds.add(topicCreatedUser.getData()); |
|
|
|
} |
|
|
|
userIds.add(topicCreatedUser.getData()); |
|
|
|
// 去重
|
|
|
|
return userIds.stream().distinct().collect(Collectors.toList()); |
|
|
|
} |
|
|
@ -1572,7 +1686,7 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp |
|
|
|
|
|
|
|
/** |
|
|
|
* 无需解决解决列表 |
|
|
|
* |
|
|
|
* 无需解决:结案选择无需解决的项目、关闭选择无需解决的议题 |
|
|
|
* @param fromDTO |
|
|
|
* @return java.util.List<com.epmet.dto.result.UnResolvedResultDTO> |
|
|
|
* @author zhaoqifeng |
|
|
@ -1581,28 +1695,56 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp |
|
|
|
@Override |
|
|
|
public List<UnResolvedResultDTO> getUnResolvedList(ShiftProjectListFromDTO fromDTO) { |
|
|
|
List<UnResolvedResultDTO> resultList = new ArrayList<>(); |
|
|
|
List<UnResolvedResultDTO> allList = new ArrayList<>(); |
|
|
|
//1、该网格下已关闭且无需解决的议题
|
|
|
|
List<UnResolvedResultDTO> issueList = baseDao.selectUnResolvedList(fromDTO.getGridId()); |
|
|
|
if (CollectionUtils.isNotEmpty(issueList)) { |
|
|
|
resultList.addAll(issueList); |
|
|
|
allList.addAll(issueList); |
|
|
|
} |
|
|
|
//2、来源于议题的项目,结案无需解决的项目
|
|
|
|
List<UnResolvedResultDTO> projectList = govProjectOpenFeignClient.getUnResolvedList(fromDTO).getData(); |
|
|
|
if (CollectionUtils.isNotEmpty(projectList)) { |
|
|
|
resultList.addAll(projectList); |
|
|
|
allList.addAll(projectList); |
|
|
|
} |
|
|
|
if (CollectionUtils.isNotEmpty(resultList)) { |
|
|
|
resultList = resultList.stream().sorted(Comparator.comparing(UnResolvedResultDTO::getClosedTime).reversed()).collect(Collectors.toList()); |
|
|
|
if (CollectionUtils.isNotEmpty(allList)) { |
|
|
|
allList = allList.stream().sorted(Comparator.comparing(UnResolvedResultDTO::getClosedTime).reversed()).collect(Collectors.toList()); |
|
|
|
if (fromDTO.getIsPage()) { |
|
|
|
int fromIndex = (fromDTO.getPageNo() - NumConstant.ONE) * fromDTO.getPageSize(); |
|
|
|
int toIndex = fromDTO.getPageNo() * fromDTO.getPageSize(); |
|
|
|
if (fromIndex >= resultList.size()) { |
|
|
|
if (fromIndex >= allList.size()) { |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
if (toIndex > resultList.size()) { |
|
|
|
toIndex = resultList.size(); |
|
|
|
if (toIndex > allList.size()) { |
|
|
|
toIndex = allList.size(); |
|
|
|
} |
|
|
|
resultList = resultList.subList(fromIndex, toIndex); |
|
|
|
resultList = allList.subList(fromIndex, toIndex); |
|
|
|
} |
|
|
|
} |
|
|
|
//重新查询一下所有议题的来源类型, 且来源于事件的议题,赋值icEventInfo
|
|
|
|
List<String> issueIds=resultList.stream().map(i -> i.getIssueId()).collect(Collectors.toList()); |
|
|
|
List<IssueEntity> issueEntityList = CollectionUtils.isEmpty(issueIds) ? new ArrayList<>() : baseDao.selectBatchIds(issueIds); |
|
|
|
if(CollectionUtils.isNotEmpty(issueEntityList)){ |
|
|
|
Map<String, IcEventDTO> eventMap=new HashMap<>(); |
|
|
|
// 来源于事件的
|
|
|
|
List<String> icEventIds = issueEntityList.stream().filter(t -> t.getSourceType().equals("ic_event")).map(i -> i.getSourceId()).collect(Collectors.toList()); |
|
|
|
if (!org.springframework.util.CollectionUtils.isEmpty(icEventIds)) { |
|
|
|
Result<List<IcEventDTO>> eventInfoRes = govProjectOpenFeignClient.batchSelectById(icEventIds); |
|
|
|
if (eventInfoRes.success() && !org.springframework.util.CollectionUtils.isEmpty(eventInfoRes.getData())) { |
|
|
|
eventMap = eventInfoRes.getData().stream().collect(Collectors.toMap(IcEventDTO::getId, o -> o, (o1, o2) -> o1)); |
|
|
|
} |
|
|
|
} |
|
|
|
Map<String,IssueEntity> issueMap=issueEntityList.stream().collect(Collectors.toMap(IssueEntity::getId, o -> o, (o1, o2) -> o1)); |
|
|
|
Map<String, IcEventDTO> finalEventMap = eventMap; |
|
|
|
resultList.forEach(vi -> { |
|
|
|
vi.setIssueSourceType(null != issueMap.get(vi.getIssueId()) ? issueMap.get(vi.getIssueId()).getSourceType() : StrConstant.EPMETY_STR); |
|
|
|
IcEventDTO event = finalEventMap.get(vi.getSourceId()); |
|
|
|
if (null != event) { |
|
|
|
IcEventComDTO eventComDTO = ConvertUtils.sourceToTarget(event, IcEventComDTO.class); |
|
|
|
eventComDTO.setIcEventId(event.getId()); |
|
|
|
vi.setIcEventInfo(eventComDTO); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
return resultList; |
|
|
|
} |
|
|
|
|
|
|
@ -1766,5 +1908,299 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Desc: 创建议题【直接创建】 |
|
|
|
* @param issueDTO |
|
|
|
* @author zxc |
|
|
|
* @date 2022/10/8 09:03 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void createIssue(IssueDTO issueDTO) { |
|
|
|
// 先审核
|
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(issueDTO.getIssueTitle()) || org.apache.commons.lang3.StringUtils.isNotBlank(issueDTO.getSuggestion())) { |
|
|
|
TextScanParamDTO textScan = new TextScanParamDTO(); |
|
|
|
//标题
|
|
|
|
TextTaskDTO taskTitle = new TextTaskDTO(); |
|
|
|
taskTitle.setContent(issueDTO.getIssueTitle()); |
|
|
|
taskTitle.setDataId(IdWorker.getIdStr()); |
|
|
|
textScan.getTasks().add(taskTitle); |
|
|
|
//建议
|
|
|
|
TextTaskDTO taskSuggestion = new TextTaskDTO(); |
|
|
|
taskSuggestion.setDataId(IdWorker.getIdStr()); |
|
|
|
taskSuggestion.setContent(issueDTO.getSuggestion()); |
|
|
|
textScan.getTasks().add(taskSuggestion); |
|
|
|
Result<SyncScanResult> textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScan); |
|
|
|
if (!textSyncScanResult.success()) { |
|
|
|
throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode()); |
|
|
|
} else { |
|
|
|
if (!textSyncScanResult.getData().isAllPass()) { |
|
|
|
logger.error(String.format(TopicConstant.SHIFT_ISSUE, issueDTO.getIssueTitle(), issueDTO.getSuggestion())); |
|
|
|
throw new EpmetException(EpmetErrorCode.TEXT_SCAN_FAILED.getCode()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (CollectionUtils.isNotEmpty(issueDTO.getAttachmentList())){ |
|
|
|
ImgScanParamDTO imgScanParamDTO = new ImgScanParamDTO(); |
|
|
|
issueDTO.getAttachmentList().forEach(url -> { |
|
|
|
ImgTaskDTO task = new ImgTaskDTO(); |
|
|
|
task.setDataId(IdWorker.getIdStr()); |
|
|
|
task.setUrl(url.getUrl()); |
|
|
|
imgScanParamDTO.getTasks().add(task); |
|
|
|
}); |
|
|
|
Result<SyncScanResult> imgScanResult = ScanContentUtils.imgSyncScan(scanApiUrl.concat(imgSyncScanMethod), imgScanParamDTO); |
|
|
|
if (!imgScanResult.success()){ |
|
|
|
throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode()); |
|
|
|
} else { |
|
|
|
if (!imgScanResult.getData().isAllPass()) { |
|
|
|
throw new EpmetException(EpmetErrorCode.IMG_SCAN_FAILED.getCode()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 是否开启
|
|
|
|
String openStatus = configurationParameterService.checkIssueAuditSwitchIfOpen(issueDTO.getCustomerId()); |
|
|
|
if (ModuleConstants.AUDIT_SWITCH_OPEN.equals(openStatus)){ |
|
|
|
// 审核表 历史表
|
|
|
|
IssueApplicationEntity iae = ConvertUtils.sourceToTarget(issueDTO, IssueApplicationEntity.class); |
|
|
|
iae.setApplyStatus(ModuleConstants.UNDER_AUDITING); |
|
|
|
applicationService.insert(iae); |
|
|
|
IssueApplicationHistoryEntity iahe = new IssueApplicationHistoryEntity(); |
|
|
|
iahe.setCustomerId(issueDTO.getCustomerId()); |
|
|
|
iahe.setIssueApplicationId(iae.getId()); |
|
|
|
iahe.setActionType(ModuleConstants.UNDER_AUDITING); |
|
|
|
historyService.insert(iahe); |
|
|
|
insertAtt(issueDTO.getAttachmentList(),iae.getId(),ModuleConstants.ISSUE_APPLICATION,issueDTO.getCustomerId()); |
|
|
|
}else { |
|
|
|
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(issueDTO.getGridId()); |
|
|
|
if(null == gridInfo){ |
|
|
|
throw new EpmetException("查询网格信息失败"+issueDTO.getGridId()); |
|
|
|
} |
|
|
|
Result<List<UserBaseInfoResultDTO>> userResult = userOpenFeignClient.queryUserBaseInfo(Arrays.asList(issueDTO.getUserId())); |
|
|
|
if (!userResult.success() || CollectionUtils.isEmpty(userResult.getData())){ |
|
|
|
throw new EpmetException("查询居民信息失败:"+issueDTO.getUserId()); |
|
|
|
} |
|
|
|
// 议题 议题进程
|
|
|
|
issueDTO.setOrgId(gridInfo.getPid()); |
|
|
|
issueDTO.setOrgIdPath(gridInfo.getPids()); |
|
|
|
IssueEntity e = ConvertUtils.sourceToTarget(issueDTO, IssueEntity.class); |
|
|
|
e.setIssueStatus(ModuleConstants.ISSUE_STATUS_VOTING); |
|
|
|
e.setSourceType(ModuleConstants.ISSUE); |
|
|
|
e.setDecidedTime(new Date()); |
|
|
|
baseDao.insert(e); |
|
|
|
IssueProcessEntity issueProcessEntity = new IssueProcessEntity(); |
|
|
|
issueProcessEntity.setIssueId(e.getId()); |
|
|
|
issueProcessEntity.setIssueStatus(ModuleConstants.ISSUE_STATUS_VOTING); |
|
|
|
issueProcessEntity.setOrgType(ModuleConstants.ISSUE_PROCESS_ORG_TYPE_GRID); |
|
|
|
issueProcessEntity.setOrgId(issueDTO.getGridId()); |
|
|
|
UserBaseInfoResultDTO user = userResult.getData().get(NumConstant.ZERO); |
|
|
|
issueProcessEntity.setOperationExplain(user.getShowName() + "发表议题【"+issueDTO.getSuggestion()+"】"); |
|
|
|
issueProcessEntity.setOrgName(gridInfo.getGridNamePath()); |
|
|
|
issueProcessEntity.setCustomerId(issueDTO.getCustomerId()); |
|
|
|
issueProcessService.insert(issueProcessEntity); |
|
|
|
insertAtt(issueDTO.getAttachmentList(),e.getId(),ModuleConstants.ISSUE,issueDTO.getCustomerId()); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Desc: 附件插入 |
|
|
|
* @param sourceList 附件集合 |
|
|
|
* @param businessId 业务ID |
|
|
|
* @param attachTo |
|
|
|
* @param customerId |
|
|
|
* @author zxc |
|
|
|
* @date 2022/10/8 09:01 |
|
|
|
*/ |
|
|
|
private void insertAtt(Collection<?> sourceList,String businessId,String attachTo,String customerId){ |
|
|
|
if (CollectionUtils.isNotEmpty(sourceList)){ |
|
|
|
List<IssueAttachmentEntity> list = ConvertUtils.sourceToTarget(sourceList, IssueAttachmentEntity.class); |
|
|
|
Integer sort = NumConstant.ZERO; |
|
|
|
for (IssueAttachmentEntity e : list) { |
|
|
|
e.setCustomerId(customerId); |
|
|
|
e.setBusinessId(businessId); |
|
|
|
e.setAttachTo(attachTo); |
|
|
|
e.setStatus(ModuleConstants.AUDITION_TYPE_AUTO_PASSED); |
|
|
|
e.setSort(sort); |
|
|
|
sort++; |
|
|
|
} |
|
|
|
issueAttachmentService.insertBatch(list); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据议题ids查询议题简要信息 |
|
|
|
* |
|
|
|
* @param issueIds |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<IssueProfileDTO> getIssueProfile(List<String> issueIds) { |
|
|
|
if(CollectionUtils.isEmpty(issueIds)){ |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
return baseDao.selectIssueProfile(issueIds); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Desc: 查询所有议题 |
|
|
|
* @param formDTO |
|
|
|
* @author zxc |
|
|
|
* @date 2022/10/9 16:58 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public PageData<AllIssueListResultDTO> allIssueList(AllIssueListFormDTO formDTO) { |
|
|
|
if (org.apache.commons.lang3.StringUtils.isBlank(formDTO.getOrgId())){ |
|
|
|
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getUserId()); |
|
|
|
if (null == staffInfo){ |
|
|
|
throw new EpmetException("查询工作人员信息失败:"+formDTO.getUserId()); |
|
|
|
} |
|
|
|
formDTO.setOrgId(staffInfo.getAgencyId()); |
|
|
|
formDTO.setOrgType(ModuleConstants.ISSUE_PROCESS_ORG_TYPE_AGENCY); |
|
|
|
} |
|
|
|
PageData<AllIssueListResultDTO> result = new PageData<>(new ArrayList(),NumConstant.ZERO_L); |
|
|
|
if (formDTO.getIsPage()){ |
|
|
|
PageInfo<AllIssueListResultDTO> pageInfo = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.allIssueList(formDTO)); |
|
|
|
result.setList(pageInfo.getList()); |
|
|
|
result.setTotal(Integer.valueOf(String.valueOf(pageInfo.getTotal()))); |
|
|
|
}else { |
|
|
|
List<AllIssueListResultDTO> allIssueListResultDTOS = baseDao.allIssueList(formDTO); |
|
|
|
result.setList(allIssueListResultDTOS); |
|
|
|
result.setTotal(allIssueListResultDTOS.size()); |
|
|
|
} |
|
|
|
if (CollectionUtils.isNotEmpty(result.getList())){ |
|
|
|
for (AllIssueListResultDTO l : result.getList()) { |
|
|
|
if (l.getIssueStatus().equals(ModuleConstants.ISSUE_STATUS_VOTING)){ |
|
|
|
String endDate = null == l.getVotingDeadline() ? |
|
|
|
DateUtils.format(new Date(),DATE_PATTERN) : |
|
|
|
DateUtils.format(l.getVotingDeadline(),DATE_PATTERN); |
|
|
|
String today = LocalDate.now().toString(); |
|
|
|
if (today.equals(endDate)){ |
|
|
|
PolyLineDTO polyLineDTO = issueVoteDetailDao.polyLineData(l.getIssueId(), endDate); |
|
|
|
l.setSupportCount(l.getSupportCount() + polyLineDTO.getSupportIncrement()); |
|
|
|
l.setOppositionCount(l.getOppositionCount() + polyLineDTO.getOppositionIncrement()); |
|
|
|
} |
|
|
|
} |
|
|
|
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(l.getGridId()); |
|
|
|
if(null == gridInfo){ |
|
|
|
logger.warn("查询网格信息失败:"+l.getGridId()); |
|
|
|
continue; |
|
|
|
} |
|
|
|
l.setGridName(gridInfo.getGridNamePath()); |
|
|
|
} |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void allIssueListExport(AllIssueListFormDTO formDTO, HttpServletResponse response) throws IOException { |
|
|
|
ExcelWriter excelWriter = null; |
|
|
|
formDTO.setPageNo(NumConstant.ONE); |
|
|
|
formDTO.setPageSize(NumConstant.TEN_THOUSAND); |
|
|
|
try { |
|
|
|
String fileName = "议题管理" + DateUtils.format(new Date()) + ".xlsx"; |
|
|
|
excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response), AllIssueListExportExcel.class).build(); |
|
|
|
WriteSheet writeSheet = EasyExcel.writerSheet("Sheet1").registerWriteHandler(new FreezeAndFilter()).build(); |
|
|
|
List<AllIssueListExportExcel> list = null; |
|
|
|
do { |
|
|
|
PageData<AllIssueListResultDTO> data = allIssueList(formDTO); |
|
|
|
list = ConvertUtils.sourceToTarget(data.getList(), AllIssueListExportExcel.class); |
|
|
|
formDTO.setPageNo(formDTO.getPageNo() + NumConstant.ONE); |
|
|
|
excelWriter.write(list, writeSheet); |
|
|
|
} while (CollectionUtils.isNotEmpty(list) && list.size() == formDTO.getPageSize()); |
|
|
|
} catch (EpmetException e) { |
|
|
|
response.reset(); |
|
|
|
response.setCharacterEncoding("UTF-8"); |
|
|
|
response.setHeader("content-type", "application/json; charset=UTF-8"); |
|
|
|
PrintWriter printWriter = response.getWriter(); |
|
|
|
Result<Object> result = new Result<>().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),e.getMsg()); |
|
|
|
printWriter.write(JSON.toJSONString(result)); |
|
|
|
printWriter.close(); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("export exception", e); |
|
|
|
} finally { |
|
|
|
if (excelWriter != null) { |
|
|
|
excelWriter.finish(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 发布议题 |
|
|
|
* 事件转议题 |
|
|
|
* |
|
|
|
* @param issueFormDTO |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
public IssueDTO publishIssue(PublishIssueFormDTO issueFormDTO) { |
|
|
|
// 事件转议题,是由工作端无需审核
|
|
|
|
IssueEntity issueEntity = ConvertUtils.sourceToTarget(issueFormDTO, IssueEntity.class); |
|
|
|
baseDao.insert(issueEntity); |
|
|
|
|
|
|
|
IssueProcessEntity issueProcessEntity = new IssueProcessEntity(); |
|
|
|
issueProcessEntity.setIssueId(issueEntity.getId()); |
|
|
|
issueProcessEntity.setIssueStatus(issueEntity.getIssueStatus()); |
|
|
|
issueProcessEntity.setOrgType(ModuleConstants.ISSUE_PROCESS_ORG_TYPE_AGENCY); |
|
|
|
CustomerStaffInfoCacheResult staffInfo=CustomerStaffRedis.getStaffInfo(issueFormDTO.getCustomerId(),issueFormDTO.getCreatedBy()); |
|
|
|
issueProcessEntity.setOrgId(staffInfo.getAgencyId()); |
|
|
|
issueProcessEntity.setOperationExplain(String.format("【%s】发表的事件被【%s】转为议题【%s】", issueFormDTO.getEventReportUserName(), staffInfo.getAgencyName(), issueEntity.getIssueTitle())); |
|
|
|
issueProcessEntity.setOrgName(staffInfo.getAgencyName()); |
|
|
|
issueProcessEntity.setCustomerId(issueFormDTO.getCustomerId()); |
|
|
|
issueProcessService.insert(issueProcessEntity); |
|
|
|
|
|
|
|
//查询网格的所属居民数
|
|
|
|
AllResiByGridFormDTO allResiByGridFormDTO=new AllResiByGridFormDTO(); |
|
|
|
allResiByGridFormDTO.setGridId(issueEntity.getGridId()); |
|
|
|
Result<Integer> regUserTotalRes=userOpenFeignClient.getAllResiByGrid(allResiByGridFormDTO); |
|
|
|
//3.新增议题表决统计表
|
|
|
|
IssueVoteStatisticalDTO voteStatistical = new IssueVoteStatisticalDTO(); |
|
|
|
voteStatistical.setIssueId(issueEntity.getId()); |
|
|
|
//应表决数,该网格下所有的居民
|
|
|
|
voteStatistical.setVotableCount(regUserTotalRes.success() ? regUserTotalRes.getData() : NumConstant.ZERO); |
|
|
|
issueVoteStatisticalService.save(voteStatistical); |
|
|
|
VoteRedisFormDTO voteInitCache = new VoteRedisFormDTO(); |
|
|
|
voteInitCache.setIssueId(issueEntity.getId()); |
|
|
|
voteInitCache.setShouldVoteCount(regUserTotalRes.success() ? regUserTotalRes.getData() : NumConstant.ZERO); |
|
|
|
issueVoteDetailRedis.set(voteInitCache); |
|
|
|
|
|
|
|
IssueDTO issueDTO = ConvertUtils.sourceToTarget(issueEntity, IssueDTO.class); |
|
|
|
issueDTO.setIssueId(issueEntity.getId()); |
|
|
|
return issueDTO; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 删除事件时,事件转了议题,调用此方法,删除议题 |
|
|
|
* 批量删除议题(议题如果转了项目,此方法不删除项目!) |
|
|
|
* 删除issue、issue_category、issue_tags |
|
|
|
* @param delIssueFormDTO |
|
|
|
* @return 删除的议题中,转为了项目,返回议题id,上层再单独去删除项目 |
|
|
|
*/ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
public List<String> deleteIssueInternal(DelIssueFormDTO delIssueFormDTO) { |
|
|
|
List<String> shiftProjectIssueIds = new ArrayList<>(); |
|
|
|
Date nowTime = new Date(); |
|
|
|
for (String issueId : delIssueFormDTO.getIssueIds()) { |
|
|
|
IssueEntity issueEntity = baseDao.selectById(issueId); |
|
|
|
if (null == issueEntity) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
// 删除议题主表
|
|
|
|
LambdaUpdateWrapper<IssueEntity> wrapper = new LambdaUpdateWrapper(); |
|
|
|
wrapper.eq(IssueEntity::getId, issueId) |
|
|
|
.set(IssueEntity::getUpdatedTime, nowTime) |
|
|
|
.set(IssueEntity::getUpdatedBy, delIssueFormDTO.getUserId()) |
|
|
|
.set(IssueEntity::getDelFlag, NumConstant.ONE_STR); |
|
|
|
baseDao.update(null, wrapper); |
|
|
|
// 删除议题分类关系表
|
|
|
|
issueCategoryService.delByIssueId(issueId, delIssueFormDTO.getUserId(), nowTime); |
|
|
|
// 删除议题标签关系表
|
|
|
|
issueTagsService.delByIssueId(issueId, delIssueFormDTO.getUserId(), nowTime); |
|
|
|
if ("shift_project".equals(issueEntity.getIssueStatus())) { |
|
|
|
shiftProjectIssueIds.add(issueEntity.getId()); |
|
|
|
} |
|
|
|
} |
|
|
|
return shiftProjectIssueIds; |
|
|
|
} |
|
|
|
} |
|
|
|