|
|
@ -10,17 +10,13 @@ import com.epmet.constant.ReadFlagConstant; |
|
|
|
import com.epmet.constant.UserMessageConstant; |
|
|
|
import com.epmet.dao.IssueDao; |
|
|
|
import com.epmet.dao.IssueProcessDao; |
|
|
|
import com.epmet.dto.form.CloseIssueFormDTO; |
|
|
|
import com.epmet.dto.form.DepartmentStaffListFormDTO; |
|
|
|
import com.epmet.dto.form.IssueDetailFormDTO; |
|
|
|
import com.epmet.dto.form.UserMessageFormDTO; |
|
|
|
import com.epmet.dto.result.AgencyGridResultDTO; |
|
|
|
import com.epmet.dto.result.DepartmentStaffListResultDTO; |
|
|
|
import com.epmet.dto.result.GridVotingIssueCountResultDTO; |
|
|
|
import com.epmet.dto.result.IssueResultDTO; |
|
|
|
import com.epmet.dto.ProjectDTO; |
|
|
|
import com.epmet.dto.form.*; |
|
|
|
import com.epmet.dto.result.*; |
|
|
|
import com.epmet.entity.IssueEntity; |
|
|
|
import com.epmet.entity.IssueProcessEntity; |
|
|
|
import com.epmet.feign.GovOrgFeignClient; |
|
|
|
import com.epmet.feign.GovProjectFeignClient; |
|
|
|
import com.epmet.feign.MessageFeignClient; |
|
|
|
import com.epmet.feign.ResiGroupFeignClient; |
|
|
|
import com.epmet.redis.GovIssueRedis; |
|
|
@ -33,6 +29,7 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Author zxc |
|
|
@ -41,132 +38,162 @@ import java.util.List; |
|
|
|
@Service |
|
|
|
public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> implements IssueService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IssueDao issueDao; |
|
|
|
@Autowired |
|
|
|
private GovOrgFeignClient govOrgFeignClient; |
|
|
|
@Autowired |
|
|
|
private IssueProcessDao issueProcessDao; |
|
|
|
@Autowired |
|
|
|
private ResiGroupFeignClient resiGroupFeignClient; |
|
|
|
@Autowired |
|
|
|
private MessageFeignClient messageFeignClient; |
|
|
|
@Autowired |
|
|
|
private GovIssueRedis govIssueRedis; |
|
|
|
@Autowired |
|
|
|
private IssueDao issueDao; |
|
|
|
@Autowired |
|
|
|
private GovOrgFeignClient govOrgFeignClient; |
|
|
|
@Autowired |
|
|
|
private IssueProcessDao issueProcessDao; |
|
|
|
@Autowired |
|
|
|
private ResiGroupFeignClient resiGroupFeignClient; |
|
|
|
@Autowired |
|
|
|
private MessageFeignClient messageFeignClient; |
|
|
|
@Autowired |
|
|
|
private GovIssueRedis govIssueRedis; |
|
|
|
@Autowired |
|
|
|
private GovProjectFeignClient govProjectFeignClient; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 议题详情 |
|
|
|
* @param issueDetail |
|
|
|
* @author zxc |
|
|
|
* @date 2020/5/11 10:04 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public IssueResultDTO detail(IssueDetailFormDTO issueDetail) { |
|
|
|
//议题信息
|
|
|
|
IssueResultDTO issueResult = issueDao.issueDetail(issueDetail); |
|
|
|
return issueResult; |
|
|
|
} |
|
|
|
/** |
|
|
|
* @param issueDetail |
|
|
|
* @Description 议题详情 |
|
|
|
* @author zxc |
|
|
|
* @date 2020/5/11 10:04 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public IssueResultDTO detail(IssueDetailFormDTO issueDetail) { |
|
|
|
//议题信息
|
|
|
|
IssueResultDTO issueResult = issueDao.issueDetail(issueDetail); |
|
|
|
return issueResult; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param formDTO |
|
|
|
* @return |
|
|
|
* @Author sun |
|
|
|
* @Description 议题管理-关闭议题 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void closeIssue(CloseIssueFormDTO formDTO) { |
|
|
|
Date date = new Date(); |
|
|
|
//1:更新议题详情表数据
|
|
|
|
IssueEntity entity = baseDao.selectById(formDTO.getIssueId()); |
|
|
|
if (null == entity) { |
|
|
|
throw new RenException(IssueConstant.SELECT_EXCEPTION); |
|
|
|
} |
|
|
|
entity.setIssueStatus(IssueConstant.ISSUE_CLOSED); |
|
|
|
entity.setCloseReason(formDTO.getCloseReason()); |
|
|
|
entity.setResolveType(formDTO.getResolveType()); |
|
|
|
entity.setVotingDeadline(date); |
|
|
|
entity.setClosedTime(date); |
|
|
|
if (baseDao.updateById(entity) < NumConstant.ONE) { |
|
|
|
throw new RenException(IssueConstant.UPPDATE_EXCEPTION); |
|
|
|
} |
|
|
|
//2:调用gov-org服务,查询组织网格名称
|
|
|
|
AgencyGridResultDTO agencyGridResultDTO = new AgencyGridResultDTO(); |
|
|
|
agencyGridResultDTO.setAgencyId(entity.getOrgId()); |
|
|
|
agencyGridResultDTO.setGridId(entity.getGridId()); |
|
|
|
Result<AgencyGridResultDTO> resultDTO = govOrgFeignClient.getAgencyAndGrid(agencyGridResultDTO); |
|
|
|
agencyGridResultDTO = resultDTO.getData(); |
|
|
|
//3:议题进展记录表新增数据
|
|
|
|
IssueProcessEntity processEntity = new IssueProcessEntity(); |
|
|
|
processEntity.setIssueId(formDTO.getIssueId()); |
|
|
|
processEntity.setIssueStatus(IssueConstant.ISSUE_CLOSED); |
|
|
|
processEntity.setOrgType(IssueConstant.ISSUE_GRID); |
|
|
|
processEntity.setOrgId(entity.getOrgId()); |
|
|
|
processEntity.setOperationExplain(formDTO.getCloseReason()); |
|
|
|
processEntity.setOrgName(agencyGridResultDTO.getAgencyName()+"-"+agencyGridResultDTO.getGridName()); |
|
|
|
issueProcessDao.insert(processEntity); |
|
|
|
//4:调用epmet-message服务,给居民端话题创建人和议题发起人发送消息
|
|
|
|
if(!saveUserMessageList(formDTO, entity).success()){ |
|
|
|
throw new RenException(IssueConstant.SAVE_MSG_EXCEPTION); |
|
|
|
} |
|
|
|
} |
|
|
|
/** |
|
|
|
* @param formDTO |
|
|
|
* @return |
|
|
|
* @Author sun |
|
|
|
* @Description 议题管理-关闭议题 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void closeIssue(CloseIssueFormDTO formDTO) { |
|
|
|
Date date = new Date(); |
|
|
|
//1:更新议题详情表数据
|
|
|
|
IssueEntity entity = baseDao.selectById(formDTO.getIssueId()); |
|
|
|
if (null == entity) { |
|
|
|
throw new RenException(IssueConstant.SELECT_EXCEPTION); |
|
|
|
} |
|
|
|
entity.setIssueStatus(IssueConstant.ISSUE_CLOSED); |
|
|
|
entity.setCloseReason(formDTO.getCloseReason()); |
|
|
|
entity.setResolveType(formDTO.getResolveType()); |
|
|
|
entity.setVotingDeadline(date); |
|
|
|
entity.setClosedTime(date); |
|
|
|
if (baseDao.updateById(entity) < NumConstant.ONE) { |
|
|
|
throw new RenException(IssueConstant.UPPDATE_EXCEPTION); |
|
|
|
} |
|
|
|
//2:调用gov-org服务,查询组织网格名称
|
|
|
|
AgencyGridResultDTO agencyGridResultDTO = new AgencyGridResultDTO(); |
|
|
|
agencyGridResultDTO.setAgencyId(entity.getOrgId()); |
|
|
|
agencyGridResultDTO.setGridId(entity.getGridId()); |
|
|
|
Result<AgencyGridResultDTO> resultDTO = govOrgFeignClient.getAgencyAndGrid(agencyGridResultDTO); |
|
|
|
agencyGridResultDTO = resultDTO.getData(); |
|
|
|
//3:议题进展记录表新增数据
|
|
|
|
IssueProcessEntity processEntity = new IssueProcessEntity(); |
|
|
|
processEntity.setIssueId(formDTO.getIssueId()); |
|
|
|
processEntity.setIssueStatus(IssueConstant.ISSUE_CLOSED); |
|
|
|
processEntity.setOrgType(IssueConstant.ISSUE_GRID); |
|
|
|
processEntity.setOrgId(entity.getOrgId()); |
|
|
|
processEntity.setOperationExplain(formDTO.getCloseReason()); |
|
|
|
processEntity.setOrgName(agencyGridResultDTO.getAgencyName() + "-" + agencyGridResultDTO.getGridName()); |
|
|
|
issueProcessDao.insert(processEntity); |
|
|
|
//4:调用epmet-message服务,给居民端话题创建人和议题发起人发送消息
|
|
|
|
if (!saveUserMessageList(formDTO, entity).success()) { |
|
|
|
throw new RenException(IssueConstant.SAVE_MSG_EXCEPTION); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<GridVotingIssueCountResultDTO> queryVotingIssueCount(List<String> gridIdList) { |
|
|
|
List<GridVotingIssueCountResultDTO> list=new ArrayList<>(); |
|
|
|
for(String gridId:gridIdList){ |
|
|
|
GridVotingIssueCountResultDTO gridVotingIssueCountResultDTO=new GridVotingIssueCountResultDTO(); |
|
|
|
gridVotingIssueCountResultDTO.setGridId(gridId); |
|
|
|
Long auditingCount=govIssueRedis.queryVotingIssueCount(gridId); |
|
|
|
gridVotingIssueCountResultDTO.setCount(auditingCount); |
|
|
|
list.add(gridVotingIssueCountResultDTO); |
|
|
|
} |
|
|
|
return list; |
|
|
|
} |
|
|
|
@Override |
|
|
|
public List<GridVotingIssueCountResultDTO> queryVotingIssueCount(List<String> gridIdList) { |
|
|
|
List<GridVotingIssueCountResultDTO> list = new ArrayList<>(); |
|
|
|
for (String gridId : gridIdList) { |
|
|
|
GridVotingIssueCountResultDTO gridVotingIssueCountResultDTO = new GridVotingIssueCountResultDTO(); |
|
|
|
gridVotingIssueCountResultDTO.setGridId(gridId); |
|
|
|
Long auditingCount = govIssueRedis.queryVotingIssueCount(gridId); |
|
|
|
gridVotingIssueCountResultDTO.setCount(auditingCount); |
|
|
|
list.add(gridVotingIssueCountResultDTO); |
|
|
|
} |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 关闭议题给话题创建人和议题发起人发送消息 |
|
|
|
* @author sun |
|
|
|
*/ |
|
|
|
private Result saveUserMessageList(CloseIssueFormDTO formDTO, IssueEntity entity){ |
|
|
|
//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(); |
|
|
|
//2:分别给话题创建人、议题发起人发送消息
|
|
|
|
List<UserMessageFormDTO> msgList = new ArrayList<>(); |
|
|
|
UserMessageFormDTO msgDTO = new UserMessageFormDTO(); |
|
|
|
msgDTO.setCustomerId(entity.getCustomerId()); |
|
|
|
msgDTO.setGridId(entity.getGridId()); |
|
|
|
msgDTO.setApp(AppClientConstant.APP_RESI); |
|
|
|
msgDTO.setTitle(UserMessageConstant.ISSUE_TITLE); |
|
|
|
String messageContent = ""; |
|
|
|
if (IssueConstant.ISSUE_RESLOVED.equals(formDTO.getResolveType())) { |
|
|
|
messageContent = String.format(UserMessageConstant.ISSUE_RESLOVED_MSG, topicDTO.getTopicContent(), formDTO.getCloseReason()); |
|
|
|
} else if (IssueConstant.ISSUE_UNRESLOVED.equals(formDTO.getResolveType())) { |
|
|
|
messageContent = String.format(UserMessageConstant.ISSUE_UNRESLOVED_MSG, topicDTO.getTopicContent(), formDTO.getCloseReason()); |
|
|
|
} |
|
|
|
msgDTO.setMessageContent(messageContent); |
|
|
|
msgDTO.setReadFlag(ReadFlagConstant.UN_READ); |
|
|
|
msgDTO.setUserId(topicDTO.getCreatedBy()); |
|
|
|
msgList.add(msgDTO); |
|
|
|
msgDTO.setUserId(entity.getCreatedBy()); |
|
|
|
msgList.add(msgDTO); |
|
|
|
return messageFeignClient.saveUserMessageList(msgList); |
|
|
|
} |
|
|
|
/** |
|
|
|
* @Description 关闭议题给话题创建人和议题发起人发送消息 |
|
|
|
* @author sun |
|
|
|
*/ |
|
|
|
private Result saveUserMessageList(CloseIssueFormDTO formDTO, IssueEntity entity) { |
|
|
|
//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(); |
|
|
|
//2:分别给话题创建人、议题发起人发送消息
|
|
|
|
List<UserMessageFormDTO> msgList = new ArrayList<>(); |
|
|
|
UserMessageFormDTO msgDTO = new UserMessageFormDTO(); |
|
|
|
msgDTO.setCustomerId(entity.getCustomerId()); |
|
|
|
msgDTO.setGridId(entity.getGridId()); |
|
|
|
msgDTO.setApp(AppClientConstant.APP_RESI); |
|
|
|
msgDTO.setTitle(UserMessageConstant.ISSUE_TITLE); |
|
|
|
String messageContent = ""; |
|
|
|
if (IssueConstant.ISSUE_RESLOVED.equals(formDTO.getResolveType())) { |
|
|
|
messageContent = String.format(UserMessageConstant.ISSUE_RESLOVED_MSG, topicDTO.getTopicContent(), formDTO.getCloseReason()); |
|
|
|
} else if (IssueConstant.ISSUE_UNRESLOVED.equals(formDTO.getResolveType())) { |
|
|
|
messageContent = String.format(UserMessageConstant.ISSUE_UNRESLOVED_MSG, topicDTO.getTopicContent(), formDTO.getCloseReason()); |
|
|
|
} |
|
|
|
msgDTO.setMessageContent(messageContent); |
|
|
|
msgDTO.setReadFlag(ReadFlagConstant.UN_READ); |
|
|
|
msgDTO.setUserId(topicDTO.getCreatedBy()); |
|
|
|
msgList.add(msgDTO); |
|
|
|
msgDTO.setUserId(entity.getCreatedBy()); |
|
|
|
msgList.add(msgDTO); |
|
|
|
return messageFeignClient.saveUserMessageList(msgList); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param formDTO |
|
|
|
* @return |
|
|
|
* @Author sun |
|
|
|
* @Description 议题管理-部门人员选择 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public DepartmentStaffListResultDTO departmentStaffList(DepartmentStaffListFormDTO formDTO) { |
|
|
|
//1:调用gov-org服务,分别查询组织下人员,组织下部门人员,组织下网格人员列表信息
|
|
|
|
Result<DepartmentStaffListResultDTO> resultDTOResult = govOrgFeignClient.departmentStaffList(formDTO.getAgencyId()); |
|
|
|
return resultDTOResult.getData(); |
|
|
|
} |
|
|
|
/** |
|
|
|
* @param formDTO |
|
|
|
* @return |
|
|
|
* @Author sun |
|
|
|
* @Description 议题管理-部门人员选择 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public DepartmentStaffListResultDTO departmentStaffList(DepartmentStaffListFormDTO formDTO) { |
|
|
|
//1:调用gov-org服务,分别查询组织下人员,组织下部门人员,组织下网格人员列表信息
|
|
|
|
Result<DepartmentStaffListResultDTO> resultDTOResult = govOrgFeignClient.departmentStaffList(formDTO.getAgencyId()); |
|
|
|
return resultDTOResult.getData(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<ShiftProjectListResultDTO> getShiftProjectList(ShiftProjectListFromDTO fromDTO) { |
|
|
|
List<ShiftProjectListResultDTO> resultList = new ArrayList<>(); |
|
|
|
//查询条件
|
|
|
|
int pageIndex = (fromDTO.getPageNo() - NumConstant.ONE) * fromDTO.getPageSize(); |
|
|
|
fromDTO.setPageNo(pageIndex); |
|
|
|
List<IssueEntity> issueList = baseDao.selectIssueListByGridId(fromDTO); |
|
|
|
if (null == issueList || issueList.size() == 0) { |
|
|
|
return resultList; |
|
|
|
} |
|
|
|
//遍历获取所有的userId
|
|
|
|
List<String> issueIds = issueList.stream().map(IssueEntity::getId).collect(Collectors.toList()); |
|
|
|
ShiftProjectsFromDTO shiftProjectsFromDTO = new ShiftProjectsFromDTO(); |
|
|
|
shiftProjectsFromDTO.setIssueIds(issueIds); |
|
|
|
List<ShiftProjectResultDTO> projectList = govProjectFeignClient.getProjectByIssue(shiftProjectsFromDTO).getData(); |
|
|
|
resultList = issueList.stream().flatMap(issue -> projectList.stream().filter(p -> issue.getId().equals(p.getOriginId())).map(project ->{ |
|
|
|
ShiftProjectListResultDTO shiftProject = new ShiftProjectListResultDTO(); |
|
|
|
shiftProject.setIssueId(issue.getId()); |
|
|
|
shiftProject.setIssueTitle(issue.getIssueTitle()); |
|
|
|
shiftProject.setDepartmentNameList(project.getDepartmentNameList()); |
|
|
|
shiftProject.setPublicReply(project.getPublicReply()); |
|
|
|
shiftProject.setShiftedTime(project.getCreatedTime().getTime()); |
|
|
|
shiftProject.setProjectStatus(project.getStatus()); |
|
|
|
return shiftProject; |
|
|
|
})).collect(Collectors.toList()); |
|
|
|
return resultList; |
|
|
|
} |
|
|
|
} |
|
|
|