|
|
@ -18,6 +18,7 @@ |
|
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; |
|
|
|
import com.epmet.commons.tools.enums.IcResiUserSubStatusEnum; |
|
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
@ -25,6 +26,7 @@ import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerStaffRedis; |
|
|
|
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.dao.IcResiUserDao; |
|
|
|
import com.epmet.dao.IcUserTransferRecordDao; |
|
|
@ -82,27 +84,9 @@ public class IcUserTransferRecordServiceImpl extends BaseServiceImpl<IcUserTrans |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void add(IcResiUserTransferFormDTO formDTO) { |
|
|
|
//1.判断被调动人员是否有效
|
|
|
|
IcResiUserDTO resiUserDTO = icResiUserDao.selectIdByIdCard(formDTO.getCustomerId(), null, formDTO.getIcUserId()); |
|
|
|
if (null == resiUserDTO) { |
|
|
|
throw new RenException("9000", "人员调动失败,被调动人不存在!"); |
|
|
|
} |
|
|
|
|
|
|
|
IcResiUserDTO resiUserDTO=getIcResiUserDTO(formDTO.getCustomerId(),formDTO.getIcUserId()); |
|
|
|
//2.查询人员调动前的组织、网格、小区、楼栋、单元、房屋信息
|
|
|
|
IcResiUserOrgMsgFormDTO orgMsgFormDTO1 = new IcResiUserOrgMsgFormDTO(); |
|
|
|
orgMsgFormDTO1.setCustomerId(resiUserDTO.getCustomerId()); |
|
|
|
orgMsgFormDTO1.setAgencyId(resiUserDTO.getAgencyId()); |
|
|
|
orgMsgFormDTO1.setGridId(resiUserDTO.getGridId()); |
|
|
|
orgMsgFormDTO1.setNeighborHoodId(resiUserDTO.getVillageId()); |
|
|
|
orgMsgFormDTO1.setBuildingId(resiUserDTO.getBuildId()); |
|
|
|
orgMsgFormDTO1.setBuildingUnitId(resiUserDTO.getUnitId()); |
|
|
|
orgMsgFormDTO1.setHouseId(resiUserDTO.getHomeId()); |
|
|
|
Result<IcResiUserOrgMsgResultDTO> result1 = govOrgOpenFeignClient.icResiUserOrgMsg(orgMsgFormDTO1); |
|
|
|
if (!result1.success() || null == result1.getData().getAgencyDTO() || null == result1.getData().getGridDTO() || null == result1.getData().getNeighborHoodDTO() |
|
|
|
|| null == result1.getData().getBuildingDTO() || null == result1.getData().getBuildingUnitDTO() || null == result1.getData().getHouseDTO()) { |
|
|
|
log.warn("查找被调动人调动前的组织、网格、小区、楼栋、单元、房屋信息失败"); |
|
|
|
throw new RenException("9000", "获取被调动人基础信息失败"); |
|
|
|
} |
|
|
|
|
|
|
|
IcResiUserOrgMsgResultDTO icResiUserOrgMsgResultDTO=getIcResiUserOrgMsgResultDTO(resiUserDTO); |
|
|
|
//3.查询人员调动后的组织、网格、小区、楼栋、单元、房屋信息
|
|
|
|
Result<IcResiUserOrgMsgResultDTO> result2 = new Result<>(); |
|
|
|
if("in".equals(formDTO.getType())){ |
|
|
@ -145,7 +129,7 @@ public class IcUserTransferRecordServiceImpl extends BaseServiceImpl<IcUserTrans |
|
|
|
|
|
|
|
//5.生成调动记录
|
|
|
|
CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId()); |
|
|
|
IcUserTransferRecordEntity recordEntity = saveTransferRecord(staffInfoCache, formDTO, resiUserDTO, result1.getData(), result2.getData()); |
|
|
|
IcUserTransferRecordEntity recordEntity = saveTransferRecord(staffInfoCache, formDTO, resiUserDTO, icResiUserOrgMsgResultDTO, result2.getData()); |
|
|
|
insert(recordEntity); |
|
|
|
|
|
|
|
//6.生成调动前后的变更记录、变更明细
|
|
|
@ -162,9 +146,9 @@ public class IcUserTransferRecordServiceImpl extends BaseServiceImpl<IcUserTrans |
|
|
|
changeRecordEntity.setType("transfer"); |
|
|
|
changeRecordEntity.setTypeName("调动"); |
|
|
|
StringBuffer beforeName = new StringBuffer(); |
|
|
|
beforeName.append(result1.getData().getAgencyDTO().getOrganizationName()).append("-").append(result1.getData().getGridDTO().getGridName()).append("-") |
|
|
|
.append(result1.getData().getNeighborHoodDTO().getNeighborHoodName()).append("-").append(result1.getData().getBuildingDTO().getBuildingName()).append("-") |
|
|
|
.append(result1.getData().getBuildingUnitDTO().getUnitName()).append("-").append(result1.getData().getHouseDTO().getHouseName()); |
|
|
|
beforeName.append(icResiUserOrgMsgResultDTO.getAgencyDTO().getOrganizationName()).append("-").append(icResiUserOrgMsgResultDTO.getGridDTO().getGridName()).append("-") |
|
|
|
.append(icResiUserOrgMsgResultDTO.getNeighborHoodDTO().getNeighborHoodName()).append("-").append(icResiUserOrgMsgResultDTO.getBuildingDTO().getBuildingName()).append("-") |
|
|
|
.append(icResiUserOrgMsgResultDTO.getBuildingUnitDTO().getUnitName()).append("-").append(icResiUserOrgMsgResultDTO.getHouseDTO().getHouseName()); |
|
|
|
changeRecordEntity.setBeforeChangeName(beforeName.toString()); |
|
|
|
StringBuffer afterName = new StringBuffer(); |
|
|
|
if ("in".equals(formDTO.getType())) { |
|
|
@ -186,7 +170,7 @@ public class IcUserTransferRecordServiceImpl extends BaseServiceImpl<IcUserTrans |
|
|
|
} |
|
|
|
List<String> columns = categoryListResult.getData().stream().map(IcResiCategoryStatsConfigDTO::getColumnName).collect(Collectors.toList()); |
|
|
|
Map<String, String> map = icResiUserDao.getCategoryListMap(columns, formDTO.getIcUserId()); |
|
|
|
List<IcUserChangeDetailedEntity> changeDetailedEntityList = saveChangeDetailed(categoryListResult.getData(), map, changeRecordEntity.getId(), formDTO, resiUserDTO); |
|
|
|
List<IcUserChangeDetailedEntity> changeDetailedEntityList = saveChangeDetailed(categoryListResult.getData(), map, changeRecordEntity.getId(), formDTO, resiUserDTO, NumConstant.ONE_STR); |
|
|
|
icUserChangeDetailedService.insertBatch(changeDetailedEntityList); |
|
|
|
|
|
|
|
} |
|
|
@ -236,10 +220,16 @@ public class IcUserTransferRecordServiceImpl extends BaseServiceImpl<IcUserTrans |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param origin 1:变动;2:迁出;3:死亡 |
|
|
|
* @Author sun |
|
|
|
* @Description 变更明细 |
|
|
|
**/ |
|
|
|
private List<IcUserChangeDetailedEntity> saveChangeDetailed(List<IcResiCategoryStatsConfigDTO> configList, Map<String, String> map, String icUserChangeRecordId, IcResiUserTransferFormDTO formDTO, IcResiUserDTO resiUserDTO) { |
|
|
|
private List<IcUserChangeDetailedEntity> saveChangeDetailed(List<IcResiCategoryStatsConfigDTO> configList, |
|
|
|
Map<String, String> map, |
|
|
|
String icUserChangeRecordId, |
|
|
|
IcResiUserTransferFormDTO formDTO, |
|
|
|
IcResiUserDTO resiUserDTO, |
|
|
|
String origin) { |
|
|
|
List<IcUserChangeDetailedEntity> list = new ArrayList<>(); |
|
|
|
IcUserChangeDetailedEntity outEntity = null; |
|
|
|
IcUserChangeDetailedEntity inEntity = null; |
|
|
@ -268,13 +258,18 @@ public class IcUserTransferRecordServiceImpl extends BaseServiceImpl<IcUserTrans |
|
|
|
outEntity.setBuildingUnitId(resiUserDTO.getUnitId()); |
|
|
|
outEntity.setHouseId(resiUserDTO.getHomeId()); |
|
|
|
outEntity.setIcUserId(formDTO.getIcUserId()); |
|
|
|
outEntity.setType("out"); |
|
|
|
outEntity.setTypeName("迁出"); |
|
|
|
if (NumConstant.ONE_STR.equals(origin) || NumConstant.TWO_STR.equals(origin)) { |
|
|
|
outEntity.setType("out"); |
|
|
|
outEntity.setTypeName("迁出"); |
|
|
|
}else if( NumConstant.THREE_STR.equals(origin)){ |
|
|
|
outEntity.setType("die"); |
|
|
|
outEntity.setTypeName("死亡"); |
|
|
|
} |
|
|
|
outEntity.setFieldName(cf.getColumnName()); |
|
|
|
outEntity.setValue(-1); |
|
|
|
list.add(outEntity); |
|
|
|
//迁入
|
|
|
|
if ("in".equals(formDTO.getType())) { |
|
|
|
//原来的变动,并且是迁入到同客户内走下面的流程
|
|
|
|
if ("in".equals(formDTO.getType()) && NumConstant.ONE_STR.equals(origin)) { |
|
|
|
inEntity = new IcUserChangeDetailedEntity(); |
|
|
|
inEntity.setCustomerId(formDTO.getCustomerId()); |
|
|
|
inEntity.setIcUserChangeRecordId(icUserChangeRecordId); |
|
|
@ -297,4 +292,139 @@ public class IcUserTransferRecordServiceImpl extends BaseServiceImpl<IcUserTrans |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 迁出管理:新增迁出人员时,插入调动记录 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void moveOutResi(IcResiUserTransferFormDTO formDTO) { |
|
|
|
//1.判断被调动人员是否有效
|
|
|
|
IcResiUserDTO resiUserDTO = getIcResiUserDTO(formDTO.getCustomerId(), formDTO.getIcUserId()); |
|
|
|
//2.查询人员调动前的组织、网格、小区、楼栋、单元、房屋信息
|
|
|
|
IcResiUserOrgMsgResultDTO icResiUserOrgMsgResultDTO = getIcResiUserOrgMsgResultDTO(resiUserDTO); |
|
|
|
//3.查询人员调动后的组织、网格、小区、楼栋、单元、房屋信息;
|
|
|
|
Result<IcResiUserOrgMsgResultDTO> result2 = getNewHouseInfo(formDTO); |
|
|
|
|
|
|
|
CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId()); |
|
|
|
IcUserChangeRecordEntity changeRecordEntity = new IcUserChangeRecordEntity(); |
|
|
|
//5.生成调动记录: 只有迁出的才生成
|
|
|
|
if("out".equals(formDTO.getMoveType())){ |
|
|
|
IcUserTransferRecordEntity recordEntity = saveTransferRecord(staffInfoCache, formDTO, resiUserDTO, icResiUserOrgMsgResultDTO, result2.getData()); |
|
|
|
insert(recordEntity); |
|
|
|
changeRecordEntity.setIcUserTransferRecordId(recordEntity.getId()); |
|
|
|
} |
|
|
|
|
|
|
|
//6.生成调动前后的变更记录、变更明细
|
|
|
|
//6-1.变更记录
|
|
|
|
changeRecordEntity.setCustomerId(formDTO.getCustomerId()); |
|
|
|
changeRecordEntity.setOperatorId(formDTO.getStaffId()); |
|
|
|
changeRecordEntity.setIcUserId(formDTO.getIcUserId()); |
|
|
|
changeRecordEntity.setOperatorName(staffInfoCache.getRealName()); |
|
|
|
changeRecordEntity.setIcUserName(resiUserDTO.getName()); |
|
|
|
//迁出存调动,死亡存注销
|
|
|
|
if ("out".equals(formDTO.getMoveType())) { |
|
|
|
changeRecordEntity.setType("transfer"); |
|
|
|
changeRecordEntity.setTypeName("调动"); |
|
|
|
} else if ("died".equals(formDTO.getMoveType())) { |
|
|
|
changeRecordEntity.setType("logout"); |
|
|
|
changeRecordEntity.setTypeName("注销"); |
|
|
|
} |
|
|
|
StringBuffer beforeName = new StringBuffer(); |
|
|
|
beforeName.append(icResiUserOrgMsgResultDTO.getAgencyDTO().getOrganizationName()).append("-").append(icResiUserOrgMsgResultDTO.getGridDTO().getGridName()).append("-") |
|
|
|
.append(icResiUserOrgMsgResultDTO.getNeighborHoodDTO().getNeighborHoodName()).append("-").append(icResiUserOrgMsgResultDTO.getBuildingDTO().getBuildingName()).append("-") |
|
|
|
.append(icResiUserOrgMsgResultDTO.getBuildingUnitDTO().getUnitName()).append("-").append(icResiUserOrgMsgResultDTO.getHouseDTO().getHouseName()); |
|
|
|
changeRecordEntity.setBeforeChangeName(beforeName.toString()); |
|
|
|
StringBuffer afterName = new StringBuffer(); |
|
|
|
if ("in".equals(formDTO.getType())) { |
|
|
|
afterName.append(result2.getData().getAgencyDTO().getOrganizationName()).append("-").append(result2.getData().getGridDTO().getGridName()).append("-") |
|
|
|
.append(result2.getData().getNeighborHoodDTO().getNeighborHoodName()).append("-").append(result2.getData().getBuildingDTO().getBuildingName()).append("-") |
|
|
|
.append(result2.getData().getBuildingUnitDTO().getUnitName()).append("-").append(result2.getData().getHouseDTO().getHouseName()); |
|
|
|
} |
|
|
|
changeRecordEntity.setAfterChangeName(StringUtils.isEmpty(afterName.toString()) ? "-" : afterName.toString()); |
|
|
|
changeRecordEntity.setChangeTime(formDTO.getTransferTime()); |
|
|
|
changeRecordEntity.setReason(formDTO.getReason()); |
|
|
|
changeRecordEntity.setRemark(formDTO.getRemark()); |
|
|
|
icUserChangeRecordService.insert(changeRecordEntity); |
|
|
|
//6-2.变更明细【类别明细迁出组织的-1,迁入组织的1】
|
|
|
|
IcResiCategoryStatsConfigDTO dto = new IcResiCategoryStatsConfigDTO(); |
|
|
|
dto.setCustomerId(formDTO.getCustomerId()); |
|
|
|
Result<List<IcResiCategoryStatsConfigDTO>> categoryListResult = operCustomizeOpenFeignClient.getCategoryList(dto); |
|
|
|
if (!categoryListResult.success()) { |
|
|
|
throw new RenException("人员调动,获取客户居民类别预警配置表数据失败"); |
|
|
|
} |
|
|
|
List<String> columns = categoryListResult.getData().stream().map(IcResiCategoryStatsConfigDTO::getColumnName).collect(Collectors.toList()); |
|
|
|
Map<String, String> map = icResiUserDao.getCategoryListMap(columns, formDTO.getIcUserId()); |
|
|
|
List<IcUserChangeDetailedEntity> changeDetailedEntityList = saveChangeDetailed(categoryListResult.getData(), map, changeRecordEntity.getId(), formDTO, resiUserDTO, NumConstant.TWO_STR); |
|
|
|
icUserChangeDetailedService.insertBatch(changeDetailedEntityList); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 根据userId查询ic_resi_user |
|
|
|
* |
|
|
|
* @param customerId |
|
|
|
* @param icUserId |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private IcResiUserDTO getIcResiUserDTO(String customerId, String icUserId) { |
|
|
|
IcResiUserDTO resiUserDTO = icResiUserDao.selectIdByIdCard(customerId, null, icUserId); |
|
|
|
if (null == resiUserDTO) { |
|
|
|
throw new RenException("9000", "人员调动失败,被调动人不存在!"); |
|
|
|
} |
|
|
|
return resiUserDTO; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 校验居民调动前的基础信息 |
|
|
|
* |
|
|
|
* @param resiUserDTO |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private IcResiUserOrgMsgResultDTO getIcResiUserOrgMsgResultDTO(IcResiUserDTO resiUserDTO) { |
|
|
|
IcResiUserOrgMsgFormDTO orgMsgFormDTO1 = ConvertUtils.sourceToTarget(resiUserDTO, IcResiUserOrgMsgFormDTO.class); |
|
|
|
orgMsgFormDTO1.setNeighborHoodId(resiUserDTO.getVillageId()); |
|
|
|
orgMsgFormDTO1.setBuildingId(resiUserDTO.getBuildId()); |
|
|
|
orgMsgFormDTO1.setBuildingUnitId(resiUserDTO.getUnitId()); |
|
|
|
orgMsgFormDTO1.setHouseId(resiUserDTO.getHomeId()); |
|
|
|
Result<IcResiUserOrgMsgResultDTO> result1 = govOrgOpenFeignClient.icResiUserOrgMsg(orgMsgFormDTO1); |
|
|
|
if (!result1.success() || null == result1.getData().getAgencyDTO() || null == result1.getData().getGridDTO() || null == result1.getData().getNeighborHoodDTO() |
|
|
|
|| null == result1.getData().getBuildingDTO() || null == result1.getData().getBuildingUnitDTO() || null == result1.getData().getHouseDTO()) { |
|
|
|
log.warn("查找被调动人调动前的组织、网格、小区、楼栋、单元、房屋信息失败"); |
|
|
|
throw new RenException("9000", "获取被调动人基础信息失败"); |
|
|
|
} |
|
|
|
return result1.getData(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 迁出管理的,校验下拟迁入的房屋 |
|
|
|
* @param formDTO |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private Result<IcResiUserOrgMsgResultDTO> getNewHouseInfo(IcResiUserTransferFormDTO formDTO) { |
|
|
|
Result<IcResiUserOrgMsgResultDTO> result2 = new Result<>(); |
|
|
|
if ("out".equals(formDTO.getMoveType())) { |
|
|
|
IcResiUserOrgMsgFormDTO orgMsgFormDTO2 = new IcResiUserOrgMsgFormDTO(); |
|
|
|
orgMsgFormDTO2.setCustomerId(formDTO.getCustomerId()); |
|
|
|
orgMsgFormDTO2.setAgencyId(formDTO.getNewAgencyId()); |
|
|
|
orgMsgFormDTO2.setGridId(formDTO.getNewGridId()); |
|
|
|
orgMsgFormDTO2.setNeighborHoodId(formDTO.getNewNeighborHoodId()); |
|
|
|
orgMsgFormDTO2.setBuildingId(formDTO.getNewBuildingId()); |
|
|
|
orgMsgFormDTO2.setBuildingUnitId(formDTO.getNewBuildingUnitId()); |
|
|
|
orgMsgFormDTO2.setHouseId(formDTO.getNewHouseId()); |
|
|
|
result2 = govOrgOpenFeignClient.icResiUserOrgMsg(orgMsgFormDTO2); |
|
|
|
if (!result2.success() || null == result2.getData().getAgencyDTO() || null == result2.getData().getGridDTO() || null == result2.getData().getNeighborHoodDTO() |
|
|
|
|| null == result2.getData().getBuildingDTO() || null == result2.getData().getBuildingUnitDTO() || null == result2.getData().getHouseDTO()) { |
|
|
|
log.warn("查找被调动人调动后的组织、网格、小区、楼栋、单元、房屋信息失败"); |
|
|
|
throw new RenException("9000", "获取被调动人基础信息失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
return result2; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |