|
|
|
@ -19,7 +19,6 @@ package com.epmet.modules.warmhearted.service.impl; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
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.tools.constant.AppClientConstant; |
|
|
|
import com.epmet.commons.tools.constant.EpmetRoleKeyConstant; |
|
|
|
@ -33,9 +32,9 @@ import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.constant.PartyMemberConstant; |
|
|
|
import com.epmet.dto.UserRoleDTO; |
|
|
|
import com.epmet.dto.form.UserResiInfoFormDTO; |
|
|
|
import com.epmet.dto.form.UserResiInfoListFormDTO; |
|
|
|
import com.epmet.dto.result.UserResiInfoResultDTO; |
|
|
|
import com.epmet.modules.feign.EpmetUserFeignClient; |
|
|
|
import com.epmet.modules.utils.ModuleConstant; |
|
|
|
import com.epmet.modules.warmhearted.constant.ResiWarmheartedVisitConstant; |
|
|
|
import com.epmet.modules.warmhearted.dao.ResiWarmheartedApplyDao; |
|
|
|
import com.epmet.modules.warmhearted.entity.ResiWarmheartedApplyEntity; |
|
|
|
@ -44,21 +43,23 @@ 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.result.ResiWarmheartedAuditedResultDTO; |
|
|
|
import com.epmet.resi.partymember.dto.warmhearted.result.ResiWarmheartedResultDTO; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* 热心居民申请表 |
|
|
|
@ -69,174 +70,226 @@ import org.slf4j.LoggerFactory; |
|
|
|
@Service |
|
|
|
public class ResiWarmheartedApplyServiceImpl extends BaseServiceImpl<ResiWarmheartedApplyDao, ResiWarmheartedApplyEntity> implements ResiWarmheartedApplyService { |
|
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(ResiWarmheartedApplyServiceImpl.class); |
|
|
|
@Autowired |
|
|
|
private ResiWarmheartedApplyRedis resiWarmheartedApplyRedis; |
|
|
|
@Autowired |
|
|
|
private ResiWarmheartedVisitService resiWarmheartedVisitService; |
|
|
|
@Autowired |
|
|
|
private ResiWarmheartedApplyDao resiWarmheartedApplyDao; |
|
|
|
@Autowired |
|
|
|
private EpmetUserFeignClient epmetUserFeignClient; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<ResiWarmheartedApplyDTO> page(Map<String, Object> params) { |
|
|
|
IPage<ResiWarmheartedApplyEntity> page = baseDao.selectPage( |
|
|
|
getPage(params, FieldConstant.CREATED_TIME, false), |
|
|
|
getWrapper(params) |
|
|
|
); |
|
|
|
return getPageData(page, ResiWarmheartedApplyDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<ResiWarmheartedApplyDTO> list(Map<String, Object> params) { |
|
|
|
List<ResiWarmheartedApplyEntity> entityList = baseDao.selectList(getWrapper(params)); |
|
|
|
|
|
|
|
return ConvertUtils.sourceToTarget(entityList, ResiWarmheartedApplyDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
private QueryWrapper<ResiWarmheartedApplyEntity> getWrapper(Map<String, Object> params) { |
|
|
|
String id = (String) params.get(FieldConstant.ID_HUMP); |
|
|
|
|
|
|
|
QueryWrapper<ResiWarmheartedApplyEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|
|
|
|
|
|
|
return wrapper; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResiWarmheartedApplyDTO get(String id) { |
|
|
|
ResiWarmheartedApplyEntity entity = baseDao.selectById(id); |
|
|
|
return ConvertUtils.sourceToTarget(entity, ResiWarmheartedApplyDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void save(ResiWarmheartedApplyDTO dto) { |
|
|
|
ResiWarmheartedApplyEntity entity = ConvertUtils.sourceToTarget(dto, ResiWarmheartedApplyEntity.class); |
|
|
|
insert(entity); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void update(ResiWarmheartedApplyDTO dto) { |
|
|
|
ResiWarmheartedApplyEntity entity = ConvertUtils.sourceToTarget(dto, ResiWarmheartedApplyEntity.class); |
|
|
|
updateById(entity); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void delete(String[] ids) { |
|
|
|
// 逻辑删除(@TableLogic 注解)
|
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Result<ResiWarmheartedResultDTO> init(ResiWarmheartedFormDTO formDTO) { |
|
|
|
Result<ResiWarmheartedResultDTO> result = new Result<ResiWarmheartedResultDTO>(); |
|
|
|
//0:先判断该用户是否是已注册居民
|
|
|
|
UserResiInfoFormDTO userResiInfoFormDTO = new UserResiInfoFormDTO(); |
|
|
|
userResiInfoFormDTO.setCustomerId(formDTO.getCustomerId()); |
|
|
|
userResiInfoFormDTO.setUserId(formDTO.getUserId()); |
|
|
|
Result<UserResiInfoResultDTO> result1 = epmetUserFeignClient.getUserResiInfoDTO(userResiInfoFormDTO); |
|
|
|
if (!result1.success() || null == result1.getData()) { |
|
|
|
result.setCode(EpmetErrorCode.CANNOT_AUDIT_WARM.getCode()); |
|
|
|
result.setMsg(EpmetErrorCode.CANNOT_AUDIT_WARM.getMsg()); |
|
|
|
return result; |
|
|
|
} |
|
|
|
//1:热心居民申请行为记录表新增数据
|
|
|
|
result = resiWarmheartedVisitService.saveResiWarmheartedVisit(formDTO); |
|
|
|
if (!result.success()) { |
|
|
|
logger.error(ResiWarmheartedVisitConstant.OPERATION_EXCEPTION); |
|
|
|
} |
|
|
|
ResiWarmheartedResultDTO resiWarmheartedResultDTO = result.getData(); |
|
|
|
//2:查询是否已申请热心居民(不查询审核未通过的)
|
|
|
|
formDTO.setAuditStatus(ResiWarmheartedVisitConstant.REJECTED); |
|
|
|
ResiWarmheartedApplyDTO resiWarmheartedApplyDTO = resiWarmheartedApplyDao.selectResiWarmheartedApply(formDTO); |
|
|
|
if (null == resiWarmheartedApplyDTO || StringUtils.isEmpty(resiWarmheartedApplyDTO.getId())) { |
|
|
|
//是否已申请热心居民 0:否, 1:是
|
|
|
|
resiWarmheartedResultDTO.setIsApplied(NumConstant.ZERO_STR); |
|
|
|
} else { |
|
|
|
resiWarmheartedResultDTO.setIsApplied(NumConstant.ONE_STR); |
|
|
|
result.setCode(NumConstant.ZERO); |
|
|
|
result.setMsg(ResiWarmheartedVisitConstant.RESI_WARM_INIT); |
|
|
|
} |
|
|
|
return result.ok(resiWarmheartedResultDTO); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Result submit(ResiWarmheartedSubmitFormDTO formDTO) { |
|
|
|
Result result = new Result(); |
|
|
|
//0:为防止前台点击多次提交 先查询一下是否有已提交数据
|
|
|
|
ResiWarmheartedFormDTO ResiWarmheartedFormDTO = ConvertUtils.sourceToTarget(formDTO, ResiWarmheartedFormDTO.class); |
|
|
|
ResiWarmheartedFormDTO.setAuditStatus(ResiWarmheartedVisitConstant.REJECTED); |
|
|
|
ResiWarmheartedApplyDTO resiWarmheartedApplyDTO = resiWarmheartedApplyDao.selectResiWarmheartedApply(ResiWarmheartedFormDTO); |
|
|
|
if (null != resiWarmheartedApplyDTO) { |
|
|
|
logger.error(ResiWarmheartedVisitConstant.REPEAT_EXCEPTION); |
|
|
|
throw new RenException(ResiWarmheartedVisitConstant.REPEAT_EXCEPTION); |
|
|
|
}else{ |
|
|
|
//1:将申请记录存入热心居民申请表中
|
|
|
|
saveResiWarmApply(formDTO); |
|
|
|
//2:将最后一次操作行为更新到热心居民申请行为记录表中
|
|
|
|
resiWarmheartedVisitService.updateResiWarmVisit(formDTO); |
|
|
|
result.setCode(NumConstant.ZERO); |
|
|
|
result.setMsg(ResiWarmheartedVisitConstant.RESI_WARM_SUBMIT); |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 热心居民申请表新增数据 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public void saveResiWarmApply(ResiWarmheartedSubmitFormDTO formDTO) { |
|
|
|
ResiWarmheartedApplyEntity entity = new ResiWarmheartedApplyEntity(); |
|
|
|
entity.setCustomerId(formDTO.getCustomerId()); |
|
|
|
entity.setGridId(formDTO.getGridId()); |
|
|
|
entity.setUserId(formDTO.getUserId()); |
|
|
|
entity.setReason(formDTO.getReason()); |
|
|
|
entity.setResiWarmVisitId(formDTO.getResiWarmVisitId()); |
|
|
|
entity.setAuditStatus(ResiWarmheartedVisitConstant.UNDER_AUDITTING); |
|
|
|
baseDao.insert(entity); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Result manageAudit(ResiWarmheartedAuditFormDTO formDTO) { |
|
|
|
Result result = new Result(); |
|
|
|
//1:更新热心居民申请表数据
|
|
|
|
ResiWarmheartedApplyEntity entity = new ResiWarmheartedApplyEntity(); |
|
|
|
entity.setId(formDTO.getResiWarmApplyId()); |
|
|
|
if (NumConstant.ZERO_STR.equals(formDTO.getAuditStatus())) { |
|
|
|
//审核状态-未通过
|
|
|
|
entity.setAuditStatus(PartyMemberConstant.REJECTED); |
|
|
|
} else { |
|
|
|
//审核状态-通过
|
|
|
|
entity.setAuditStatus(PartyMemberConstant.APPROVED); |
|
|
|
} |
|
|
|
if (!StringUtils.isBlank(formDTO.getRefuseReason())) { |
|
|
|
entity.setRefuseReason(formDTO.getRefuseReason()); |
|
|
|
} |
|
|
|
int num = baseDao.updateById(entity); |
|
|
|
//2:审核通过的添加热心居民的角色
|
|
|
|
if (num > NumConstant.ZERO && NumConstant.ONE_STR.equals(formDTO.getAuditStatus())) { |
|
|
|
//查询需要添加热心居民角色的userId
|
|
|
|
ResiWarmheartedApplyEntity resiWarmheartedApplyEntity = baseDao.selectById(formDTO.getResiWarmApplyId()); |
|
|
|
UserRoleDTO dto = new UserRoleDTO(); |
|
|
|
dto.setCustomerId(formDTO.getCustomerId()); |
|
|
|
dto.setUserId(resiWarmheartedApplyEntity.getUserId()); |
|
|
|
//所属端-居民端
|
|
|
|
dto.setApp(AppClientConstant.APP_RESI); |
|
|
|
//角色-热心居民
|
|
|
|
dto.setRoleKey(EpmetRoleKeyConstant.WARMHEARTED); |
|
|
|
//角色表新增网格Id
|
|
|
|
dto.setGridId(resiWarmheartedApplyEntity.getGridId()); |
|
|
|
result = epmetUserFeignClient.saveUserRole(dto); |
|
|
|
private static final Logger logger = LoggerFactory.getLogger(ResiWarmheartedApplyServiceImpl.class); |
|
|
|
@Autowired |
|
|
|
private ResiWarmheartedApplyRedis resiWarmheartedApplyRedis; |
|
|
|
@Autowired |
|
|
|
private ResiWarmheartedVisitService resiWarmheartedVisitService; |
|
|
|
@Autowired |
|
|
|
private ResiWarmheartedApplyDao resiWarmheartedApplyDao; |
|
|
|
@Autowired |
|
|
|
private EpmetUserFeignClient epmetUserFeignClient; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<ResiWarmheartedApplyDTO> page(Map<String, Object> params) { |
|
|
|
IPage<ResiWarmheartedApplyEntity> page = baseDao.selectPage( |
|
|
|
getPage(params, FieldConstant.CREATED_TIME, false), |
|
|
|
getWrapper(params) |
|
|
|
); |
|
|
|
return getPageData(page, ResiWarmheartedApplyDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<ResiWarmheartedApplyDTO> list(Map<String, Object> params) { |
|
|
|
List<ResiWarmheartedApplyEntity> entityList = baseDao.selectList(getWrapper(params)); |
|
|
|
|
|
|
|
return ConvertUtils.sourceToTarget(entityList, ResiWarmheartedApplyDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
private QueryWrapper<ResiWarmheartedApplyEntity> getWrapper(Map<String, Object> params) { |
|
|
|
String id = (String) params.get(FieldConstant.ID_HUMP); |
|
|
|
|
|
|
|
QueryWrapper<ResiWarmheartedApplyEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|
|
|
|
|
|
|
return wrapper; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResiWarmheartedApplyDTO get(String id) { |
|
|
|
ResiWarmheartedApplyEntity entity = baseDao.selectById(id); |
|
|
|
return ConvertUtils.sourceToTarget(entity, ResiWarmheartedApplyDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void save(ResiWarmheartedApplyDTO dto) { |
|
|
|
ResiWarmheartedApplyEntity entity = ConvertUtils.sourceToTarget(dto, ResiWarmheartedApplyEntity.class); |
|
|
|
insert(entity); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void update(ResiWarmheartedApplyDTO dto) { |
|
|
|
ResiWarmheartedApplyEntity entity = ConvertUtils.sourceToTarget(dto, ResiWarmheartedApplyEntity.class); |
|
|
|
updateById(entity); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void delete(String[] ids) { |
|
|
|
// 逻辑删除(@TableLogic 注解)
|
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Result<ResiWarmheartedResultDTO> init(ResiWarmheartedFormDTO formDTO) { |
|
|
|
Result<ResiWarmheartedResultDTO> result = new Result<ResiWarmheartedResultDTO>(); |
|
|
|
//0:先判断该用户是否是已注册居民
|
|
|
|
UserResiInfoFormDTO userResiInfoFormDTO = new UserResiInfoFormDTO(); |
|
|
|
userResiInfoFormDTO.setCustomerId(formDTO.getCustomerId()); |
|
|
|
userResiInfoFormDTO.setUserId(formDTO.getUserId()); |
|
|
|
Result<UserResiInfoResultDTO> result1 = epmetUserFeignClient.getUserResiInfoDTO(userResiInfoFormDTO); |
|
|
|
if (!result1.success() || null == result1.getData()) { |
|
|
|
result.setCode(EpmetErrorCode.CANNOT_AUDIT_WARM.getCode()); |
|
|
|
result.setMsg(EpmetErrorCode.CANNOT_AUDIT_WARM.getMsg()); |
|
|
|
return result; |
|
|
|
} |
|
|
|
//1:热心居民申请行为记录表新增数据
|
|
|
|
result = resiWarmheartedVisitService.saveResiWarmheartedVisit(formDTO); |
|
|
|
if (!result.success()) { |
|
|
|
logger.error(ResiWarmheartedVisitConstant.OPERATION_EXCEPTION); |
|
|
|
} |
|
|
|
ResiWarmheartedResultDTO resiWarmheartedResultDTO = result.getData(); |
|
|
|
//2:查询是否已申请热心居民(不查询审核未通过的)
|
|
|
|
formDTO.setAuditStatus(ResiWarmheartedVisitConstant.REJECTED); |
|
|
|
ResiWarmheartedApplyDTO resiWarmheartedApplyDTO = resiWarmheartedApplyDao.selectResiWarmheartedApply(formDTO); |
|
|
|
if (null == resiWarmheartedApplyDTO || StringUtils.isEmpty(resiWarmheartedApplyDTO.getId())) { |
|
|
|
//是否已申请热心居民 0:否, 1:是
|
|
|
|
resiWarmheartedResultDTO.setIsApplied(NumConstant.ZERO_STR); |
|
|
|
} else { |
|
|
|
resiWarmheartedResultDTO.setIsApplied(NumConstant.ONE_STR); |
|
|
|
result.setCode(NumConstant.ZERO); |
|
|
|
result.setMsg(ResiWarmheartedVisitConstant.RESI_WARM_INIT); |
|
|
|
} |
|
|
|
return result.ok(resiWarmheartedResultDTO); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Result submit(ResiWarmheartedSubmitFormDTO formDTO) { |
|
|
|
Result result = new Result(); |
|
|
|
//0:为防止前台点击多次提交 先查询一下是否有已提交数据
|
|
|
|
ResiWarmheartedFormDTO ResiWarmheartedFormDTO = ConvertUtils.sourceToTarget(formDTO, ResiWarmheartedFormDTO.class); |
|
|
|
ResiWarmheartedFormDTO.setAuditStatus(ResiWarmheartedVisitConstant.REJECTED); |
|
|
|
ResiWarmheartedApplyDTO resiWarmheartedApplyDTO = resiWarmheartedApplyDao.selectResiWarmheartedApply(ResiWarmheartedFormDTO); |
|
|
|
if (null != resiWarmheartedApplyDTO) { |
|
|
|
logger.error(ResiWarmheartedVisitConstant.REPEAT_EXCEPTION); |
|
|
|
throw new RenException(ResiWarmheartedVisitConstant.REPEAT_EXCEPTION); |
|
|
|
} else { |
|
|
|
//1:将申请记录存入热心居民申请表中
|
|
|
|
saveResiWarmApply(formDTO); |
|
|
|
//2:将最后一次操作行为更新到热心居民申请行为记录表中
|
|
|
|
resiWarmheartedVisitService.updateResiWarmVisit(formDTO); |
|
|
|
result.setCode(NumConstant.ZERO); |
|
|
|
result.setMsg(ResiWarmheartedVisitConstant.RESI_WARM_SUBMIT); |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 热心居民申请表新增数据 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public void saveResiWarmApply(ResiWarmheartedSubmitFormDTO formDTO) { |
|
|
|
ResiWarmheartedApplyEntity entity = new ResiWarmheartedApplyEntity(); |
|
|
|
entity.setCustomerId(formDTO.getCustomerId()); |
|
|
|
entity.setGridId(formDTO.getGridId()); |
|
|
|
entity.setUserId(formDTO.getUserId()); |
|
|
|
entity.setReason(formDTO.getReason()); |
|
|
|
entity.setResiWarmVisitId(formDTO.getResiWarmVisitId()); |
|
|
|
entity.setAuditStatus(ResiWarmheartedVisitConstant.UNDER_AUDITTING); |
|
|
|
baseDao.insert(entity); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Result manageAudit(ResiWarmheartedAuditFormDTO formDTO) { |
|
|
|
Result result = new Result(); |
|
|
|
//1:更新热心居民申请表数据
|
|
|
|
ResiWarmheartedApplyEntity entity = new ResiWarmheartedApplyEntity(); |
|
|
|
entity.setId(formDTO.getResiWarmApplyId()); |
|
|
|
if (NumConstant.ZERO_STR.equals(formDTO.getAuditStatus())) { |
|
|
|
//审核状态-未通过
|
|
|
|
entity.setAuditStatus(PartyMemberConstant.REJECTED); |
|
|
|
} else { |
|
|
|
//审核状态-通过
|
|
|
|
entity.setAuditStatus(PartyMemberConstant.APPROVED); |
|
|
|
} |
|
|
|
if (!StringUtils.isBlank(formDTO.getRefuseReason())) { |
|
|
|
entity.setRefuseReason(formDTO.getRefuseReason()); |
|
|
|
} |
|
|
|
int num = baseDao.updateById(entity); |
|
|
|
//2:审核通过的添加热心居民的角色
|
|
|
|
if (num > NumConstant.ZERO && NumConstant.ONE_STR.equals(formDTO.getAuditStatus())) { |
|
|
|
//查询需要添加热心居民角色的userId
|
|
|
|
ResiWarmheartedApplyEntity resiWarmheartedApplyEntity = baseDao.selectById(formDTO.getResiWarmApplyId()); |
|
|
|
UserRoleDTO dto = new UserRoleDTO(); |
|
|
|
dto.setCustomerId(formDTO.getCustomerId()); |
|
|
|
dto.setUserId(resiWarmheartedApplyEntity.getUserId()); |
|
|
|
//所属端-居民端
|
|
|
|
dto.setApp(AppClientConstant.APP_RESI); |
|
|
|
//角色-热心居民
|
|
|
|
dto.setRoleKey(EpmetRoleKeyConstant.WARMHEARTED); |
|
|
|
//角色表新增网格Id
|
|
|
|
dto.setGridId(resiWarmheartedApplyEntity.getGridId()); |
|
|
|
result = epmetUserFeignClient.saveUserRole(dto); |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result<List<ResiWarmheartedAuditedResultDTO>> audited(ResiWarmheartedAuditedFromDTO formDTO) { |
|
|
|
Result<List<ResiWarmheartedAuditedResultDTO>> result = new Result<>(); |
|
|
|
List<ResiWarmheartedAuditedResultDTO> resultList = new ArrayList<>(); |
|
|
|
//查询条件
|
|
|
|
ResiWarmheartedApplyDTO applyDTO = ConvertUtils.sourceToTarget(formDTO, ResiWarmheartedApplyDTO.class); |
|
|
|
applyDTO.setAuditStatus(PartyMemberConstant.UNDER_AUDITTING); |
|
|
|
//获取审核列表
|
|
|
|
List<ResiWarmheartedApplyEntity> applyList = |
|
|
|
baseDao.selectList(getWrapper(applyDTO).orderByDesc("UPDATED_TIME")); |
|
|
|
if (null == applyList || applyList.size() == 0) { |
|
|
|
return result.ok(resultList); |
|
|
|
} |
|
|
|
//提取所有userID
|
|
|
|
List<String> userIds = |
|
|
|
applyList.stream().map(ResiWarmheartedApplyEntity::getUserId).collect(Collectors.toList()); |
|
|
|
//获取用户昵称,头像
|
|
|
|
UserResiInfoListFormDTO userResiInfoListFormDTO = new UserResiInfoListFormDTO(); |
|
|
|
userResiInfoListFormDTO.setUserIdList(userIds); |
|
|
|
List<UserResiInfoResultDTO> userResiInfoList = |
|
|
|
epmetUserFeignClient.getUserResiInfoList(userResiInfoListFormDTO).getData(); |
|
|
|
if (null == userResiInfoList || userResiInfoList.size() == 0) { |
|
|
|
return result.ok(resultList); |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
resultList = applyList.stream().flatMap(apply -> userResiInfoList.stream().filter(user -> |
|
|
|
apply.getUserId().equals(user.getUserId())).map(userInfo -> { |
|
|
|
ResiWarmheartedAuditedResultDTO resultDTO = new ResiWarmheartedAuditedResultDTO(); |
|
|
|
resultDTO.setApplyId(apply.getId()); |
|
|
|
resultDTO.setUserId(apply.getUserId()); |
|
|
|
resultDTO.setStatus(apply.getAuditStatus()); |
|
|
|
resultDTO.setApplyTime(apply.getUpdatedTime()); |
|
|
|
resultDTO.setMessageText(apply.getMessageText()); |
|
|
|
resultDTO.setUserNickName(userInfo.getShowName()); |
|
|
|
resultDTO.setUserHeadPhoto(userInfo.getHeadPhoto()); |
|
|
|
return resultDTO; |
|
|
|
})).collect(Collectors.toList()); |
|
|
|
|
|
|
|
return result.ok(resultList); |
|
|
|
} |
|
|
|
|
|
|
|
private QueryWrapper<ResiWarmheartedApplyEntity> getWrapper(ResiWarmheartedApplyDTO params) { |
|
|
|
String customerId = params.getCustomerId(); |
|
|
|
String gridId = params.getGridId(); |
|
|
|
String auditStatus = params.getAuditStatus(); |
|
|
|
QueryWrapper<ResiWarmheartedApplyEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(customerId), "CUSTOMER_ID", customerId) |
|
|
|
.eq(StringUtils.isNotBlank(gridId), "GRID_ID", gridId) |
|
|
|
.ne(StringUtils.isNotBlank(auditStatus), "AUDIT_STATUS", auditStatus); |
|
|
|
|
|
|
|
return wrapper; |
|
|
|
} |
|
|
|
} |
|
|
|
|