|
|
@ -1,31 +1,50 @@ |
|
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
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.dto.result.CustomerStaffInfoCacheResult; |
|
|
|
import com.epmet.commons.tools.enums.GenderEnum; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerIcHouseRedis; |
|
|
|
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.redis.common.bean.HouseInfoCache; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.constant.MessageConstant; |
|
|
|
import com.epmet.constant.ReadFlagConstant; |
|
|
|
import com.epmet.constant.UserMessageTypeConstant; |
|
|
|
import com.epmet.dao.IcResiUserConfirmDao; |
|
|
|
import com.epmet.dao.IcResiUserDao; |
|
|
|
import com.epmet.dto.IcResiUserConfirmDTO; |
|
|
|
import com.epmet.dto.form.IcResiUserConfirmGetDTO; |
|
|
|
import com.epmet.dto.form.IcResiUserConfirmSubmitDTO; |
|
|
|
import com.epmet.dto.form.MoveOutMemberFormDTO; |
|
|
|
import com.epmet.dto.form.*; |
|
|
|
import com.epmet.dto.result.ConfirmListResultDTO; |
|
|
|
import com.epmet.dto.result.MoveOutDetailResultDTO; |
|
|
|
import com.epmet.entity.IcResiUserConfirmEntity; |
|
|
|
import com.epmet.entity.IcResiUserEntity; |
|
|
|
import com.epmet.enums.UserConfirmEnum; |
|
|
|
import com.epmet.feign.EpmetMessageOpenFeignClient; |
|
|
|
import com.epmet.redis.IcResiUserConfirmRedis; |
|
|
|
import com.epmet.service.IcResiUserConfirmService; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
/** |
|
|
|
* 居民信息审核表 |
|
|
@ -33,6 +52,7 @@ import java.util.Map; |
|
|
|
* @author generator generator@elink-cn.com |
|
|
|
* @since v1.0.0 2022-06-01 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@Service |
|
|
|
public class IcResiUserConfirmServiceImpl extends BaseServiceImpl<IcResiUserConfirmDao, IcResiUserConfirmEntity> implements IcResiUserConfirmService { |
|
|
|
|
|
|
@ -45,6 +65,9 @@ public class IcResiUserConfirmServiceImpl extends BaseServiceImpl<IcResiUserConf |
|
|
|
@Autowired |
|
|
|
private IcResiUserConfirmDao icResiUserConfirmDao; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<IcResiUserConfirmDTO> page(Map<String, Object> params) { |
|
|
|
IPage<IcResiUserConfirmEntity> page = baseDao.selectPage( |
|
|
@ -141,8 +164,20 @@ public class IcResiUserConfirmServiceImpl extends BaseServiceImpl<IcResiUserConf |
|
|
|
@Override |
|
|
|
public Result<IcResiUserConfirmDTO> getMemberDetail(IcResiUserConfirmGetDTO dto) { |
|
|
|
IcResiUserConfirmDTO result = icResiUserDao.selectMemberDetail(dto.getIcResiUserId()); |
|
|
|
if (null != result && StringUtils.isBlank(result.getGender())) { |
|
|
|
result.setGender(""); |
|
|
|
if (null != result) { |
|
|
|
LambdaQueryWrapper<IcResiUserConfirmEntity> wrapper = new LambdaQueryWrapper<>(); |
|
|
|
wrapper.eq(IcResiUserConfirmEntity::getIcResiUserId, dto.getIcResiUserId()); |
|
|
|
wrapper.in(IcResiUserConfirmEntity::getSubmitType, Arrays.asList("in", "out")); |
|
|
|
wrapper.orderByDesc(IcResiUserConfirmEntity::getCreatedTime); |
|
|
|
List<IcResiUserConfirmEntity> list = baseDao.selectList(wrapper); |
|
|
|
if (CollectionUtils.isNotEmpty(list)) { |
|
|
|
result.setMoveOutStatus(list.get(NumConstant.ZERO).getConfirmResult()); |
|
|
|
} else { |
|
|
|
result.setMoveOutStatus(NumConstant.THREE_STR); |
|
|
|
} |
|
|
|
if(StringUtils.isBlank(result.getGender())) { |
|
|
|
result.setGender(""); |
|
|
|
} |
|
|
|
} |
|
|
|
return new Result().ok(result); |
|
|
|
} |
|
|
@ -189,14 +224,160 @@ public class IcResiUserConfirmServiceImpl extends BaseServiceImpl<IcResiUserConf |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void moveOutMember(MoveOutMemberFormDTO form) { |
|
|
|
form = icResiUserDao.moveOutMember(form.getIcResiUserId(), form.getCustomerId()); |
|
|
|
form.setSurname(form.getAllName().substring(0, 1)); |
|
|
|
form.setName(form.getAllName().substring(1)); |
|
|
|
if (icResiUserConfirmDao.selectByIdCard(form.getIdCard(), form.getCustomerId(), form.getSubmitType()) > 0) { |
|
|
|
icResiUserConfirmDao.deleteByIdCard(form.getIdCard(), form.getCustomerId(), form.getSubmitType()); |
|
|
|
MoveOutMemberFormDTO userInfo = icResiUserDao.moveOutMember(form.getIcResiUserId(), form.getCustomerId()); |
|
|
|
if (null == userInfo) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "居民已迁出", "居民已迁出"); |
|
|
|
} |
|
|
|
form.setName(userInfo.getAllName()); |
|
|
|
form.setAgencyId(userInfo.getAgencyId()); |
|
|
|
form.setPids(userInfo.getPids()); |
|
|
|
form.setHouseId(userInfo.getHouseId()); |
|
|
|
form.setGender(userInfo.getGender()); |
|
|
|
form.setIdCard(userInfo.getIdCard()); |
|
|
|
form.setBirthday(userInfo.getBirthday()); |
|
|
|
form.setHjszd(userInfo.getHjszd()); |
|
|
|
form.setXjzd(userInfo.getXjzd()); |
|
|
|
form.setMz(userInfo.getMz()); |
|
|
|
form.setYhzgx(userInfo.getYhzgx()); |
|
|
|
IcResiUserConfirmEntity entity = ConvertUtils.sourceToTarget(form, IcResiUserConfirmEntity.class); |
|
|
|
icResiUserConfirmDao.insert(entity); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 迁出审核列表 |
|
|
|
* |
|
|
|
* @param form |
|
|
|
* @Param form |
|
|
|
* @Return {@link PageData< ConfirmListResultDTO >} |
|
|
|
* @Author zhaoqifeng |
|
|
|
* @Date 2022/6/22 14:30 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public PageData<ConfirmListResultDTO> confirmList(ConfirmListFormDTO form) { |
|
|
|
//获取工作人员所属组织
|
|
|
|
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(form.getCustomerId(), form.getStaffId()); |
|
|
|
if (null == staffInfo) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取用户信息失败", "获取用户信息失败"); |
|
|
|
} |
|
|
|
form.setAgencyId(staffInfo.getAgencyId()); |
|
|
|
PageHelper.startPage(form.getPageNo(), form.getPageSize()); |
|
|
|
List<ConfirmListResultDTO> list =baseDao.getConfirmList(form); |
|
|
|
PageInfo<ConfirmListResultDTO> pageInfo = new PageInfo<>(list); |
|
|
|
if (CollectionUtils.isNotEmpty(list)) { |
|
|
|
list.forEach(item -> { |
|
|
|
//获取网格信息
|
|
|
|
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(item.getGridId()); |
|
|
|
if (null != gridInfo) { |
|
|
|
log.warn("迁出审核列表获取网格缓存失败"); |
|
|
|
item.setGridName(gridInfo.getGridNamePath()); |
|
|
|
} |
|
|
|
//获取房屋信息
|
|
|
|
HouseInfoCache houseInfo = CustomerIcHouseRedis.getHouseInfo(form.getCustomerId(), item.getHomeId()); |
|
|
|
if (null != houseInfo) { |
|
|
|
log.warn("迁出审核列表获取房屋缓存失败"); |
|
|
|
item.setHomeName(houseInfo.getAllName()); |
|
|
|
} |
|
|
|
item.setGender(GenderEnum.getName(item.getGender())); |
|
|
|
item.setConfirmResult(UserConfirmEnum.getName(item.getConfirmResult())); |
|
|
|
}); |
|
|
|
} |
|
|
|
return new PageData<>(list, pageInfo.getTotal()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 迁出审核详情 |
|
|
|
* |
|
|
|
* @param id |
|
|
|
* @Param id |
|
|
|
* @Return {@link MoveOutDetailResultDTO} |
|
|
|
* @Author zhaoqifeng |
|
|
|
* @Date 2022/6/22 16:21 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public MoveOutDetailResultDTO moveOutConfirmDetail(String customerId, String id) { |
|
|
|
MoveOutDetailResultDTO result = baseDao.getMoveOutConfirmDetail(id); |
|
|
|
if (null != result) { |
|
|
|
//获取房屋信息
|
|
|
|
HouseInfoCache houseInfo = CustomerIcHouseRedis.getHouseInfo(customerId, result.getHomeId()); |
|
|
|
if (null == houseInfo) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取房屋信息失败", "获取房屋信息失败"); |
|
|
|
} |
|
|
|
result.setGridName(houseInfo.getGridName()); |
|
|
|
result.setVillageName(houseInfo.getNeighborHoodName()); |
|
|
|
result.setBuildName(houseInfo.getBuildingName()); |
|
|
|
result.setUnitName(houseInfo.getUnitName()); |
|
|
|
result.setHomeName(houseInfo.getDoorName()); |
|
|
|
if (NumConstant.ZERO_STR.equals(result.getConfirmResult())) { |
|
|
|
LambdaQueryWrapper<IcResiUserEntity> wrapper = new LambdaQueryWrapper<>(); |
|
|
|
wrapper.eq(IcResiUserEntity::getId, result.getIcResiUserId()); |
|
|
|
wrapper.eq(IcResiUserEntity::getHomeId, result.getHomeId()); |
|
|
|
wrapper.eq(IcResiUserEntity::getStatus, NumConstant.ZERO_STR); |
|
|
|
IcResiUserEntity entity = icResiUserDao.selectOne(wrapper); |
|
|
|
if (null == entity) { |
|
|
|
result.setIsInHome(false); |
|
|
|
} else { |
|
|
|
result.setIsInHome(true); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 迁出审核 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @Param formDTO |
|
|
|
* @Return {@link null} |
|
|
|
* @Author zhaoqifeng |
|
|
|
* @Date 2022/6/22 16:45 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void moveOutConfirm(IcResiUserConfirmDTO formDTO) { |
|
|
|
if (NumConstant.TWO_STR.equals(formDTO.getConfirmResult())) { |
|
|
|
if (StringUtils.isBlank(formDTO.getReason())) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "驳回原因不能为空", "驳回原因不能为空"); |
|
|
|
} |
|
|
|
} |
|
|
|
baseDao.updateById(ConvertUtils.sourceToTarget(formDTO, IcResiUserConfirmEntity.class)); |
|
|
|
//审核不通过,发送消息
|
|
|
|
if (NumConstant.TWO_STR.equals(formDTO.getConfirmResult())) { |
|
|
|
String msg = String.format(MessageConstant.OVE_OUT_REJECTED_MSG, formDTO.getReason()); |
|
|
|
IcResiUserConfirmEntity entity = baseDao.selectById(formDTO.getId()); |
|
|
|
sendMessage(entity.getCustomerId(),entity.getGridId(), entity.getId(), entity.getCreatedBy(), msg); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void sendMessage(String customerId, String gridId, String targetId, String userId, String userMsg) { |
|
|
|
UserMessageFormDTO userMessageFormDTO = new UserMessageFormDTO(); |
|
|
|
userMessageFormDTO.setCustomerId(customerId); |
|
|
|
userMessageFormDTO.setGridId(gridId); |
|
|
|
userMessageFormDTO.setApp(AppClientConstant.APP_RESI); |
|
|
|
userMessageFormDTO.setTitle(MessageConstant.MOVE_OUT_TITLE); |
|
|
|
userMessageFormDTO.setMessageType(UserMessageTypeConstant.MOVE_OUT_HOME); |
|
|
|
userMessageFormDTO.setTargetId(targetId); |
|
|
|
userMessageFormDTO.setMessageContent(userMsg); |
|
|
|
userMessageFormDTO.setReadFlag(ReadFlagConstant.UN_READ); |
|
|
|
userMessageFormDTO.setUserId(userId); |
|
|
|
|
|
|
|
//发送微信订阅消息
|
|
|
|
WxSubscribeMessageFormDTO wxSubscribeMessageFormDTO = new WxSubscribeMessageFormDTO(); |
|
|
|
wxSubscribeMessageFormDTO.setCustomerId(customerId); |
|
|
|
wxSubscribeMessageFormDTO.setUserId(userId); |
|
|
|
wxSubscribeMessageFormDTO.setClientType(AppClientConstant.APP_RESI); |
|
|
|
wxSubscribeMessageFormDTO.setGridId(gridId); |
|
|
|
wxSubscribeMessageFormDTO.setBehaviorType(MessageConstant.MOVE_OUT_TITLE); |
|
|
|
wxSubscribeMessageFormDTO.setMessageContent(userMsg); |
|
|
|
wxSubscribeMessageFormDTO.setMessageTime(new Date()); |
|
|
|
List<WxSubscribeMessageFormDTO> msgList = new ArrayList<>(); |
|
|
|
msgList.add(wxSubscribeMessageFormDTO); |
|
|
|
epmetMessageOpenFeignClient.sendWxSubscribeMessage(msgList); |
|
|
|
//保存消息
|
|
|
|
epmetMessageOpenFeignClient.saveUserMessage(userMessageFormDTO); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|