|
|
@ -30,11 +30,18 @@ import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.constant.PartyMemberConstant; |
|
|
|
import com.epmet.constant.ReadFlagConstant; |
|
|
|
import com.epmet.dto.CustomerGridDTO; |
|
|
|
import com.epmet.dto.UserRoleDTO; |
|
|
|
import com.epmet.dto.form.CustomerGridFormDTO; |
|
|
|
import com.epmet.dto.form.UserMessageFormDTO; |
|
|
|
import com.epmet.dto.form.UserResiInfoFormDTO; |
|
|
|
import com.epmet.dto.form.UserResiInfoListFormDTO; |
|
|
|
import com.epmet.dto.result.UserResiInfoResultDTO; |
|
|
|
import com.epmet.modules.feign.EpmetMessageFeignClient; |
|
|
|
import com.epmet.modules.feign.EpmetUserFeignClient; |
|
|
|
import com.epmet.modules.feign.GovOrgFeignClient; |
|
|
|
import com.epmet.modules.warmhearted.constant.ResiWarmUserMessageConstant; |
|
|
|
import com.epmet.modules.warmhearted.constant.ResiWarmheartedVisitConstant; |
|
|
|
import com.epmet.modules.warmhearted.dao.ResiWarmheartedApplyDao; |
|
|
|
import com.epmet.modules.warmhearted.entity.ResiWarmheartedApplyEntity; |
|
|
@ -42,10 +49,8 @@ import com.epmet.modules.warmhearted.redis.ResiWarmheartedApplyRedis; |
|
|
|
import com.epmet.modules.warmhearted.service.ResiWarmheartedApplyService; |
|
|
|
import com.epmet.modules.warmhearted.service.ResiWarmheartedVisitService; |
|
|
|
import com.epmet.resi.partymember.dto.warmhearted.ResiWarmheartedApplyDTO; |
|
|
|
import com.epmet.resi.partymember.dto.warmhearted.form.ResiWarmheartedAuditFormDTO; |
|
|
|
import com.epmet.resi.partymember.dto.warmhearted.form.ResiWarmheartedAuditedFromDTO; |
|
|
|
import com.epmet.resi.partymember.dto.warmhearted.form.ResiWarmheartedFormDTO; |
|
|
|
import com.epmet.resi.partymember.dto.warmhearted.form.ResiWarmheartedSubmitFormDTO; |
|
|
|
import com.epmet.resi.partymember.dto.warmhearted.form.*; |
|
|
|
import com.epmet.resi.partymember.dto.warmhearted.result.ResiWarmAuditResultDTO; |
|
|
|
import com.epmet.resi.partymember.dto.warmhearted.result.ResiWarmheartedAuditedResultDTO; |
|
|
|
import com.epmet.resi.partymember.dto.warmhearted.result.ResiWarmheartedResultDTO; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
@ -79,6 +84,10 @@ public class ResiWarmheartedApplyServiceImpl extends BaseServiceImpl<ResiWarmhea |
|
|
|
private ResiWarmheartedApplyDao resiWarmheartedApplyDao; |
|
|
|
@Autowired |
|
|
|
private EpmetUserFeignClient epmetUserFeignClient; |
|
|
|
@Autowired |
|
|
|
private EpmetMessageFeignClient epmetMessageFeignClient; |
|
|
|
@Autowired |
|
|
|
private GovOrgFeignClient govOrgFeignClient; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<ResiWarmheartedApplyDTO> page(Map<String, Object> params) { |
|
|
@ -279,4 +288,171 @@ public class ResiWarmheartedApplyServiceImpl extends BaseServiceImpl<ResiWarmhea |
|
|
|
|
|
|
|
return result.ok(resultList); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 政府端-获取待审核的热心居民申请列表 |
|
|
|
* |
|
|
|
* @param |
|
|
|
* @return void |
|
|
|
* @author sun |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Result<List<ResiWarmAuditResultDTO>> auditing(ResiWarmAuditFormDTO formDTO) { |
|
|
|
Result<List<ResiWarmAuditResultDTO>> result = new Result<>(); |
|
|
|
List<ResiWarmAuditResultDTO> applyList = new ArrayList<>(); |
|
|
|
//1:查询待审核状态的热心居民申请
|
|
|
|
formDTO.setAuditStatus(PartyMemberConstant.UNDER_AUDITTING); |
|
|
|
applyList = baseDao.selectResiWarmAuditList(formDTO); |
|
|
|
if (null == applyList || applyList.size() < NumConstant.ONE) { |
|
|
|
return result.ok(applyList); |
|
|
|
} |
|
|
|
//2:调用epmet-user服务 获取用户头像 昵称
|
|
|
|
//遍历获取所有的userId
|
|
|
|
List<String> userIds = applyList.stream().map(ResiWarmAuditResultDTO::getUserId).collect(Collectors.toList()); |
|
|
|
//获取所有用户的头像 昵称
|
|
|
|
UserResiInfoListFormDTO userResiInfoListFormDTO = new UserResiInfoListFormDTO(); |
|
|
|
userResiInfoListFormDTO.setUserIdList(userIds); |
|
|
|
List<UserResiInfoResultDTO> userResiInfoList = epmetUserFeignClient.getUserResiInfoList(userResiInfoListFormDTO).getData(); |
|
|
|
if (null == userResiInfoList || userResiInfoList.size() < NumConstant.ONE) { |
|
|
|
return result.ok(applyList); |
|
|
|
} |
|
|
|
//3:将每个用户的头像 昵称放到对应实体中返回给前台
|
|
|
|
List<ResiWarmAuditResultDTO> resultList = applyList.stream().flatMap(apply -> userResiInfoList.stream().filter(user -> |
|
|
|
apply.getUserId().equals(user.getUserId())).map(userInfo -> { |
|
|
|
ResiWarmAuditResultDTO resultDTO = ConvertUtils.sourceToTarget(apply, ResiWarmAuditResultDTO.class); |
|
|
|
resultDTO.setUserNickName(null == userInfo.getShowName() ? "" : userInfo.getShowName()); |
|
|
|
resultDTO.setUserHeadPhoto(null == userInfo.getHeadPhoto() ? "" : userInfo.getHeadPhoto()); |
|
|
|
return resultDTO; |
|
|
|
})).collect(Collectors.toList()); |
|
|
|
|
|
|
|
return result.ok(resultList); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 政府端-热心居民申请-审核通过 |
|
|
|
* |
|
|
|
* @param |
|
|
|
* @return void |
|
|
|
* @author sun |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Result approve(ResiWarmAuditApproveFormDTO formDTO) { |
|
|
|
Result result = new Result(); |
|
|
|
//1:更新热心居民申请表数据
|
|
|
|
ResiWarmheartedApplyEntity entity = new ResiWarmheartedApplyEntity(); |
|
|
|
entity.setId(formDTO.getApplyId()); |
|
|
|
//审核状态-通过
|
|
|
|
entity.setAuditStatus(PartyMemberConstant.APPROVED); |
|
|
|
int num = baseDao.updateById(entity); |
|
|
|
//2:审核通过的添加热心居民的角色
|
|
|
|
if (num < NumConstant.ONE) { |
|
|
|
result.error(ResiWarmheartedVisitConstant.UPDATE_EXCEPTION); |
|
|
|
return result; |
|
|
|
} |
|
|
|
//查询需要添加热心居民角色的userId
|
|
|
|
ResiWarmheartedApplyEntity resiWarmheartedApplyEntity = baseDao.selectById(formDTO.getApplyId()); |
|
|
|
UserRoleDTO dto = new UserRoleDTO(); |
|
|
|
dto.setCustomerId(resiWarmheartedApplyEntity.getCustomerId()); |
|
|
|
dto.setUserId(resiWarmheartedApplyEntity.getUserId()); |
|
|
|
//所属端-居民端
|
|
|
|
dto.setApp(AppClientConstant.APP_RESI); |
|
|
|
//角色-热心居民
|
|
|
|
dto.setRoleKey(EpmetRoleKeyConstant.WARMHEARTED); |
|
|
|
//角色表新增网格Id
|
|
|
|
dto.setGridId(resiWarmheartedApplyEntity.getGridId()); |
|
|
|
result = epmetUserFeignClient.saveUserRole(dto); |
|
|
|
//3:为申请人发送审核通过消息提示
|
|
|
|
auditMessage(resiWarmheartedApplyEntity, ResiWarmUserMessageConstant.AUDIT_APPROVE_MSG); |
|
|
|
return result; |
|
|
|
} |
|
|
|
/** |
|
|
|
* 热心居民申请审核通过向申请人发送消息 |
|
|
|
* @Author sun |
|
|
|
* @param formDTO |
|
|
|
* @param userMsg 消息模板 |
|
|
|
*/ |
|
|
|
private void auditMessage(ResiWarmheartedApplyEntity formDTO, String userMsg) { |
|
|
|
UserMessageFormDTO userMessageFormDTO = new UserMessageFormDTO(); |
|
|
|
userMessageFormDTO.setCustomerId(formDTO.getCustomerId()); |
|
|
|
userMessageFormDTO.setGridId(formDTO.getGridId()); |
|
|
|
userMessageFormDTO.setUserId(formDTO.getUserId()); |
|
|
|
userMessageFormDTO.setApp(AppClientConstant.APP_RESI); |
|
|
|
userMessageFormDTO.setTitle(ResiWarmUserMessageConstant.GROUP_TITLE); |
|
|
|
//调用gov-org服务查询网格信息
|
|
|
|
CustomerGridFormDTO customerGridFormDTO = new CustomerGridFormDTO(); |
|
|
|
customerGridFormDTO.setGridId(formDTO.getGridId()); |
|
|
|
Result<CustomerGridDTO> result = govOrgFeignClient.getCustomerGridByGridId(customerGridFormDTO); |
|
|
|
String gridName = null; |
|
|
|
if (result.success() && null != result.getData()) { |
|
|
|
gridName = result.getData().getGridName(); |
|
|
|
} |
|
|
|
String messageContent = String.format(userMsg, gridName); |
|
|
|
userMessageFormDTO.setMessageContent(messageContent); |
|
|
|
userMessageFormDTO.setReadFlag(ReadFlagConstant.UN_READ); |
|
|
|
//保存消息
|
|
|
|
epmetMessageFeignClient.saveUserMessage(userMessageFormDTO); |
|
|
|
} |
|
|
|
/** |
|
|
|
* 政府端-热心居民申请-审核驳回 |
|
|
|
* |
|
|
|
* @param |
|
|
|
* @return void |
|
|
|
* @author sun |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Result reject(ResiWarmAuditRejectFormDTO formDTO) { |
|
|
|
Result result = new Result(); |
|
|
|
//1:更新热心居民申请表数据
|
|
|
|
ResiWarmheartedApplyEntity entity = new ResiWarmheartedApplyEntity(); |
|
|
|
entity.setId(formDTO.getApplyId()); |
|
|
|
//审核状态-未通过
|
|
|
|
entity.setAuditStatus(PartyMemberConstant.REJECTED); |
|
|
|
entity.setRefuseReason(formDTO.getRefuseReason()); |
|
|
|
baseDao.updateById(entity); |
|
|
|
//2:为申请人发送审核驳回消息提示
|
|
|
|
//查询申请信息
|
|
|
|
ResiWarmheartedApplyEntity resiWarmheartedApplyEntity = baseDao.selectById(formDTO.getApplyId()); |
|
|
|
auditMessage(resiWarmheartedApplyEntity, ResiWarmUserMessageConstant.AUDIT_REJECT_MSG); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 政府端-热心居民申请详情信息 |
|
|
|
* |
|
|
|
* @param |
|
|
|
* @return void |
|
|
|
* @author sun |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Result<ResiWarmAuditResultDTO> getDetail(ResiWarmGetDetailFormDTO formDTO) { |
|
|
|
Result<ResiWarmAuditResultDTO> result = new Result<>(); |
|
|
|
//1:根据申请Id查询热心居民申请审核详情
|
|
|
|
ResiWarmheartedApplyEntity entity = baseDao.selectById(formDTO.getApplyId()); |
|
|
|
if (null == entity) { |
|
|
|
result.error(ResiWarmheartedVisitConstant.SELECT_EXCEPTION); |
|
|
|
return result; |
|
|
|
} |
|
|
|
//2:修改申请数据状态为已读
|
|
|
|
if(!ResiWarmheartedVisitConstant.READ.equals(entity.getReadFlag())){ |
|
|
|
entity.setReadFlag(ResiWarmheartedVisitConstant.READ); |
|
|
|
baseDao.updateById(entity); |
|
|
|
} |
|
|
|
//3:调用epmet-user服务查询用户头像 昵称信息
|
|
|
|
UserResiInfoFormDTO userResiInfoFormDTO = new UserResiInfoFormDTO(); |
|
|
|
userResiInfoFormDTO.setCustomerId(entity.getCustomerId()); |
|
|
|
userResiInfoFormDTO.setUserId(entity.getUserId()); |
|
|
|
Result<UserResiInfoResultDTO> resultUserInfo = epmetUserFeignClient.getUserResiInfoDTO(userResiInfoFormDTO); |
|
|
|
if (!resultUserInfo.success() || null == resultUserInfo.getData()) { |
|
|
|
result.error(ResiWarmheartedVisitConstant.SELECT_EXCEPTION); |
|
|
|
return result; |
|
|
|
} |
|
|
|
UserResiInfoResultDTO userInfo = resultUserInfo.getData(); |
|
|
|
ResiWarmAuditResultDTO resultDTO = ConvertUtils.sourceToTarget(entity, ResiWarmAuditResultDTO.class); |
|
|
|
resultDTO.setApplyTime(entity.getUpdatedTime()); |
|
|
|
resultDTO.setUserNickName(null == userInfo.getShowName() ? "" : userInfo.getShowName()); |
|
|
|
resultDTO.setUserHeadPhoto(null == userInfo.getHeadPhoto() ? "" : userInfo.getHeadPhoto()); |
|
|
|
return result.ok(resultDTO); |
|
|
|
} |
|
|
|
} |
|
|
|