|
|
@ -11,29 +11,35 @@ import com.epmet.bean.ResiImportResiCategoryChangedCache; |
|
|
|
import com.epmet.bean.ResiImportChangedData; |
|
|
|
import com.epmet.commons.tools.constant.ServiceConstant; |
|
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
|
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; |
|
|
|
import com.epmet.commons.tools.dto.result.OptionResultDTO; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.ExceptionUtils; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.feign.ResultDataResolver; |
|
|
|
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.security.user.LoginUserUtil; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.dao.IcResiUserDao; |
|
|
|
import com.epmet.dao.IcUserChangeDetailedDao; |
|
|
|
import com.epmet.dao.IcUserChangeRecordDao; |
|
|
|
import com.epmet.dao.IcUserTransferRecordDao; |
|
|
|
import com.epmet.dto.*; |
|
|
|
import com.epmet.dto.form.GridOptionFormDTO; |
|
|
|
import com.epmet.dto.form.HouseFormDTO; |
|
|
|
import com.epmet.dto.form.LoginUserDetailsFormDTO; |
|
|
|
import com.epmet.dto.result.FormItemResult; |
|
|
|
import com.epmet.dto.result.LoginUserDetailsResultDTO; |
|
|
|
import com.epmet.dto.result.OptionDTO; |
|
|
|
import com.epmet.dto.result.ResiCategoryItemResultDTO; |
|
|
|
import com.epmet.dto.form.*; |
|
|
|
import com.epmet.dto.result.*; |
|
|
|
import com.epmet.entity.IcResiUserEntity; |
|
|
|
import com.epmet.entity.IcUserChangeDetailedEntity; |
|
|
|
import com.epmet.entity.IcUserChangeRecordEntity; |
|
|
|
import com.epmet.entity.IcUserTransferRecordEntity; |
|
|
|
import com.epmet.enums.IcResiUserTableEnum; |
|
|
|
import com.epmet.excel.handler.DynamicEasyExcelListener; |
|
|
|
import com.epmet.feign.EpmetAdminOpenFeignClient; |
|
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
|
import com.epmet.feign.GovOrgOpenFeignClient; |
|
|
|
import com.epmet.feign.OperCustomizeOpenFeignClient; |
|
|
|
import com.epmet.service.IcResiUserImportService; |
|
|
|
import com.epmet.service.*; |
|
|
|
import com.google.common.cache.Cache; |
|
|
|
import com.google.common.cache.CacheBuilder; |
|
|
|
import lombok.Data; |
|
|
@ -74,7 +80,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
/** |
|
|
|
* 居民类别items列表 |
|
|
|
*/ |
|
|
|
public static final ThreadLocal<List<String>> resiCategoryItemsCache = new ThreadLocal<>(); |
|
|
|
public static final ThreadLocal<Map<String, String>> resiCategoryItemsCache = new ThreadLocal<>(); |
|
|
|
|
|
|
|
/** |
|
|
|
* key: itemId |
|
|
@ -103,6 +109,19 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
@Autowired |
|
|
|
private OperCustomizeOpenFeignClient operCustomizeOpenFeignClient; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IcUserChangeRecordDao icUserChangeRecordDao; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IcUserChangeDetailedDao icUserChangeDetailedDao; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IcUserTransferRecordDao icUserTransferRecordDao; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private UserService userService; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @description 列信息封装 |
|
|
|
* |
|
|
@ -196,10 +215,11 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
userForm.setClient(loginUserClient); |
|
|
|
userForm.setUserId(loginUserId); |
|
|
|
|
|
|
|
LoginUserDetailsResultDTO loginUserDetails = getResultDataOrThrowsException(epmetUserOpenFeignClient.getLoginUserDetails(userForm), ServiceConstant.EPMET_USER_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null, null); |
|
|
|
String currUserAgencyId = loginUserDetails.getAgencyId(); |
|
|
|
String currUserAgencyId = userService.getLoginUserDetails( |
|
|
|
loginUserUtil.getLoginUserApp(), |
|
|
|
loginUserUtil.getLoginUserClient(), |
|
|
|
loginUserUtil.getLoginUserId()).getAgencyId(); |
|
|
|
|
|
|
|
//String excelPathName = "/opt/test/基础信息表/resi_info.xls";
|
|
|
|
CustomerAgencyDTO agencyInfo = getResultDataOrThrowsException(govOrgOpenFeignClient.getAgencyById(currUserAgencyId), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null, null); |
|
|
|
String customerId = agencyInfo.getCustomerId(); |
|
|
|
|
|
|
@ -230,9 +250,15 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
|
|
|
|
// 执行人员类别变更记录
|
|
|
|
Map<String, ResiImportCategoryData> newResis = categoryChangedResi.get().getNewResis(); |
|
|
|
// todo 此处没测试
|
|
|
|
Map<String, ResiImportChangedData> categoryChangedResis = categoryChangedResi.get().getCategoryChangedResis(); |
|
|
|
Map<String, ResiImportChangedData> transferedResis = categoryChangedResi.get().getTransferedResis(); |
|
|
|
|
|
|
|
//保存调动或者变更记录
|
|
|
|
saveNewResiCategoryRecord(newResis); |
|
|
|
saveResiCategoryChangedRecord(categoryChangedResis); |
|
|
|
saveTransferedResiRecord(transferedResis); |
|
|
|
|
|
|
|
try { |
|
|
|
downLoadResults(response); |
|
|
|
} catch (IOException e) { |
|
|
@ -275,8 +301,9 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
String.format("【居民信息导入】查询居民类别items失败,customerId:%s", customerId), |
|
|
|
"居民信息导入失败"); |
|
|
|
|
|
|
|
List<String> l = resiCategoryItems.stream().map(ResiCategoryItemResultDTO::getColumnName).collect(Collectors.toList()); |
|
|
|
resiCategoryItemsCache.set(l); |
|
|
|
Map<String, String> columnNameAndLabel = resiCategoryItems.stream().collect(Collectors.toMap((o) -> o.getColumnName(), (o) -> o.getLabel())); |
|
|
|
|
|
|
|
resiCategoryItemsCache.set(columnNameAndLabel); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -434,7 +461,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
columnAndValues.put("ID", UUID.randomUUID().toString().replace("-", "")); |
|
|
|
icResiUserDao.add(tableName, columnAndValues); |
|
|
|
|
|
|
|
Map<String, String> categories = resiCategoryItemsCache.get() |
|
|
|
Map<String, String> categories = resiCategoryItemsCache.get().keySet() |
|
|
|
.stream() |
|
|
|
.filter((categoryColumnName) -> "1".equals(columnAndValues.get(categoryColumnName))) |
|
|
|
.collect(Collectors.toMap((k) -> k, (k) -> columnAndValues.get(k))); |
|
|
@ -507,19 +534,6 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
|
|
|
|
String icResiId = icResiUserBaseInfo.getId(); |
|
|
|
|
|
|
|
//if (CollectionUtils.isNotEmpty(icResiUserDao.selectSubTableRecords(customerId, icResiId, targetTableName))) {
|
|
|
|
// log.info("身份证号为【{}】的居民【{}】信息已存在,跳过导入", idCard, targetTableName);
|
|
|
|
//
|
|
|
|
// SkipedRow skipedRow = new SkipedRow();
|
|
|
|
// skipedRow.setName(columnAndValues.get("NAME"));
|
|
|
|
// skipedRow.setIdCard(columnAndValues.get("ID_CARD"));
|
|
|
|
// skipedRow.setInfo("信息已存在,跳过导入");
|
|
|
|
// skipedRow.setTableName(targetTableName);
|
|
|
|
// skipedRows.get().get(targetTableName).add(skipedRow);
|
|
|
|
//
|
|
|
|
// continue;
|
|
|
|
//}
|
|
|
|
|
|
|
|
columnAndValues.put("IC_RESI_USER", icResiId); |
|
|
|
columnAndValues.put("CUSTOMER_ID", loginUserUtil.getLoginUserCustomerId()); |
|
|
|
columnAndValues.put("UPDATED_BY", currentUserId); |
|
|
@ -543,6 +557,9 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
icResiUserDao.add(targetTableName, columnAndValues); |
|
|
|
} |
|
|
|
|
|
|
|
// 保存到类别变更缓存中
|
|
|
|
saveSubTableInfoToCategoryChangedResiCache(icResiId, Objects.requireNonNull(IcResiUserTableEnum.getObjectByTableName(targetTableName)).getMainTableFlagColumnName()); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
String errorMsg; |
|
|
|
if (e instanceof RenException) { |
|
|
@ -1005,36 +1022,9 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
workbook.write(response.getOutputStream()); |
|
|
|
} |
|
|
|
|
|
|
|
public ResiImportCategoryData generateResiImportChangeData(String agencyId, String gridId, String villageId, String buildId, String unitId, |
|
|
|
String homeId , Map<String, String> categories) { |
|
|
|
ResiImportCategoryData ricd = new ResiImportCategoryData(); |
|
|
|
ricd.setAgencyId(agencyId); |
|
|
|
ricd.setBuildId(buildId); |
|
|
|
ricd.setGridId(gridId); |
|
|
|
ricd.setVillageId(villageId); |
|
|
|
ricd.setUnitId(unitId); |
|
|
|
ricd.setHomeId(homeId); |
|
|
|
ricd.setCategories(categories); |
|
|
|
return ricd; |
|
|
|
} |
|
|
|
|
|
|
|
///**
|
|
|
|
// * 判断是否有组织维度的变化
|
|
|
|
// * @param existingResiMap
|
|
|
|
// * @param newResiMap
|
|
|
|
// * @return
|
|
|
|
// */
|
|
|
|
//public boolean isOrgDimChanged(Map<String, String> existingResiMap, Map<String, String> newResiMap) {
|
|
|
|
// return !existingResiMap.get("AGENCY_ID").equals(newResiMap.get("AGENCY_ID"))
|
|
|
|
// || !existingResiMap.get("GRID_ID").equals(newResiMap.get("GRID_ID"))
|
|
|
|
// || !existingResiMap.get("VILLAGE_ID").equals(newResiMap.get("VILLAGE_ID"))
|
|
|
|
// || !existingResiMap.get("BUILD_ID").equals(newResiMap.get("BUILD_ID"))
|
|
|
|
// || !existingResiMap.get("UNIT_ID").equals(newResiMap.get("UNIT_ID"))
|
|
|
|
// || !existingResiMap.get("HOME_ID").equals(newResiMap.get("HOME_ID"))
|
|
|
|
//}
|
|
|
|
|
|
|
|
/** |
|
|
|
* 生成导入调动数据 |
|
|
|
* 1.新老数据中,只要状态是1的,都放入缓存 |
|
|
|
* @param existingResiMap |
|
|
|
* @param newResiMap |
|
|
|
* @return |
|
|
@ -1055,7 +1045,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
HashMap<String, String> existingResiCategories = new HashMap<>(); |
|
|
|
HashMap<String, String> newResiCategories = new HashMap<>(); |
|
|
|
|
|
|
|
for (String categoryColumnName : resiCategoryItemsCache.get()) { |
|
|
|
for (String categoryColumnName : resiCategoryItemsCache.get().keySet()) { |
|
|
|
String oldCategoryValue = existingResiMap.get(categoryColumnName); |
|
|
|
String newCategoryValue = newResiMap.get(categoryColumnName); |
|
|
|
|
|
|
@ -1077,7 +1067,8 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
existingResiMap.get("HOME_ID"), |
|
|
|
existingResiCategories); |
|
|
|
|
|
|
|
ResiImportCategoryData newOne = new ResiImportCategoryData(existingResiMap.get("AGENCY_ID"), |
|
|
|
ResiImportCategoryData newOne = new ResiImportCategoryData( |
|
|
|
existingResiMap.get("AGENCY_ID"), |
|
|
|
newResiMap.get("GRID_ID"), |
|
|
|
newResiMap.get("VILLAGE_ID"), |
|
|
|
newResiMap.get("BUILD_ID"), |
|
|
@ -1090,6 +1081,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
|
|
|
|
/** |
|
|
|
* 类别变更的居民信息封装 |
|
|
|
* 1. |
|
|
|
* @param existingResiMap |
|
|
|
* @param newResiMap |
|
|
|
* @return |
|
|
@ -1099,7 +1091,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
HashMap<String, String> oldCategories = new HashMap<>(); |
|
|
|
HashMap<String, String> newCategories = new HashMap<>(); |
|
|
|
|
|
|
|
List<String> categoryColumnNames = resiCategoryItemsCache.get(); |
|
|
|
Set<String> categoryColumnNames = resiCategoryItemsCache.get().keySet(); |
|
|
|
for (String categoryColumnName : categoryColumnNames) { |
|
|
|
String existingColumnValue = existingResiMap.get(categoryColumnName); |
|
|
|
String newColumnValue = newResiMap.get(categoryColumnName); |
|
|
@ -1107,19 +1099,16 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
if (StringUtils.isAllBlank(existingColumnValue, newColumnValue)) { |
|
|
|
// 都为空,则没发生变化
|
|
|
|
continue; |
|
|
|
} else if (StringUtils.isNoneBlank(existingColumnValue, newColumnValue)) { |
|
|
|
// 都不为空,则执行比较
|
|
|
|
} else { |
|
|
|
// 先转为0再对比
|
|
|
|
if (StringUtils.isBlank(existingColumnValue)) existingColumnValue = "0"; |
|
|
|
if (StringUtils.isBlank(newColumnValue)) newColumnValue = "0"; |
|
|
|
|
|
|
|
if (!existingColumnValue.equals(newColumnValue)) { |
|
|
|
oldCategories.put(categoryColumnName, existingColumnValue); |
|
|
|
newCategories.put(categoryColumnName, newColumnValue); |
|
|
|
continue; |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 一个为空一个不为空,则发生变化
|
|
|
|
oldCategories.put(categoryColumnName, existingColumnValue); |
|
|
|
newCategories.put(categoryColumnName, newColumnValue); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (oldCategories.size() == 0) { |
|
|
@ -1145,4 +1134,491 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
|
|
|
|
return new ResiImportChangedData(oldOne, newOne); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* @param icResiId 居民id |
|
|
|
* @param columnName 该项信息在主表的列名 |
|
|
|
*/ |
|
|
|
private void saveSubTableInfoToCategoryChangedResiCache(String icResiId, String columnName) { |
|
|
|
|
|
|
|
ResiImportResiCategoryChangedCache cc = categoryChangedResi.get(); |
|
|
|
Map<String, ResiImportCategoryData> newResis = cc.getNewResis(); |
|
|
|
Map<String, ResiImportChangedData> categoryChangedResis = cc.getCategoryChangedResis(); |
|
|
|
Map<String, ResiImportChangedData> transferedResis = cc.getTransferedResis(); |
|
|
|
|
|
|
|
ResiImportCategoryData newResi = newResis.get(icResiId); |
|
|
|
if (newResi != null) { |
|
|
|
//说明是新增居民
|
|
|
|
newResi.getCategories().put(columnName, "1"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
ResiImportChangedData categoryChangedData = categoryChangedResis.get(icResiId); |
|
|
|
if (categoryChangedData != null) { |
|
|
|
// 说明是类别变更的居民
|
|
|
|
Map<String, String> oldCategories = categoryChangedData.getOldData().getCategories(); |
|
|
|
Map<String, String> newCategories = categoryChangedData.getNewData().getCategories(); |
|
|
|
|
|
|
|
if (!oldCategories.containsKey(columnName)) { |
|
|
|
// 没有这个类别,说明旧数据中是0,新数据中也是0,新数据改成1
|
|
|
|
oldCategories.put(columnName, "0"); |
|
|
|
newCategories.put(columnName, "1"); |
|
|
|
} else { |
|
|
|
// 有这个类别,说明旧数据中是1,新数据中是0,新数据改成1,最后保存的时候,需要判断,新旧都是1,那么不创建变更记录
|
|
|
|
newCategories.put(columnName, "1"); |
|
|
|
} |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
ResiImportChangedData transferedData = transferedResis.get(icResiId); |
|
|
|
if (transferedData != null) { |
|
|
|
// 说明是发生调动的居民,旧数据不用管了,新数据改成1
|
|
|
|
Map<String, String> newCategories = transferedData.getNewData().getCategories(); |
|
|
|
newCategories.put(columnName, "1"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 非新增,非调动,那么就是居民类别变更的,只不过变更的数据不在主sheet中,而在附sheet中
|
|
|
|
ResiImportCategoryData oldOne = new ResiImportCategoryData(); |
|
|
|
ResiImportCategoryData newOne = new ResiImportCategoryData(); |
|
|
|
|
|
|
|
oldOne.getCategories().put(columnName, "0"); |
|
|
|
newOne.getCategories().put(columnName, "1"); |
|
|
|
|
|
|
|
ResiImportChangedData cd = new ResiImportChangedData(oldOne, newOne); |
|
|
|
categoryChangedResis.put(icResiId, cd); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 居民类别变更record |
|
|
|
*/ |
|
|
|
public void saveResiCategoryChangedRecord(Map<String, ResiImportChangedData> categoryChangedResis) { |
|
|
|
|
|
|
|
Date now = new Date(); |
|
|
|
|
|
|
|
CustomerStaffInfoCacheResult operator = CustomerStaffRedis.getStaffInfo(loginUserUtil.getLoginUserCustomerId(), loginUserUtil.getLoginUserId()); |
|
|
|
|
|
|
|
// 循环当前居民的所有类别的map
|
|
|
|
for (Map.Entry<String, ResiImportChangedData> entry : categoryChangedResis.entrySet()) { |
|
|
|
String resiId = entry.getKey(); |
|
|
|
|
|
|
|
ResiImportCategoryData oldData = entry.getValue().getOldData(); |
|
|
|
ResiImportCategoryData newData = entry.getValue().getNewData(); |
|
|
|
Map<String, String> oldCategories = oldData.getCategories(); |
|
|
|
Map<String, String> newCategories = newData.getCategories(); |
|
|
|
|
|
|
|
StringBuilder sbBefore = new StringBuilder(""); |
|
|
|
StringBuilder sbAfter = new StringBuilder(""); |
|
|
|
|
|
|
|
//主表的语言描述
|
|
|
|
for (Map.Entry<String, String> newEntry : newCategories.entrySet()) { |
|
|
|
String columnName = newEntry.getKey(); |
|
|
|
String newColumnValue = newEntry.getValue(); |
|
|
|
String oldColumnValue = oldCategories.get(columnName); |
|
|
|
|
|
|
|
if (newColumnValue.equals(oldColumnValue)) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
String beforeValueName = "0".equals(oldColumnValue) ? "否" : "是"; |
|
|
|
String newValueName = "0".equals(newColumnValue) ? "否" : "是"; |
|
|
|
|
|
|
|
String label = resiCategoryItemsCache.get().get(columnName); |
|
|
|
|
|
|
|
sbBefore.append(label).append(":").append(beforeValueName).append("\n"); |
|
|
|
sbAfter.append(label).append(":").append(newValueName).append("\n"); |
|
|
|
} |
|
|
|
|
|
|
|
// 生成changeRecord并存入
|
|
|
|
IcResiUserEntity resiInfo = icResiUserDao.selectById(resiId); |
|
|
|
IcUserChangeRecordEntity changeRecord = fillChangeRecord(loginUserUtil.getLoginUserCustomerId(), resiId, resiInfo.getName(), null, loginUserUtil.getLoginUserId(), |
|
|
|
operator.getRealName() , sbBefore.toString(), sbAfter.toString(), "category", "类别", "", now); |
|
|
|
icUserChangeRecordDao.insert(changeRecord); |
|
|
|
|
|
|
|
for (Map.Entry<String, String> columnEntry : newCategories.entrySet()) { |
|
|
|
String newValue = columnEntry.getValue(); |
|
|
|
String oldValue = oldCategories.get(columnEntry.getKey()); |
|
|
|
oldValue = oldValue == null ? "0" : oldValue; |
|
|
|
|
|
|
|
if (newValue.equals(oldValue)) { |
|
|
|
// 新旧值相等,跳过
|
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
int value = newValue.equals("1") && oldValue.equals("0") ? 1 : -1; |
|
|
|
|
|
|
|
|
|
|
|
IcUserChangeDetailedEntity newDetail = fillChangeDetail(loginUserUtil.getLoginUserCustomerId(), resiId, changeRecord.getId(), newData.getAgencyId(), |
|
|
|
newData.getGridId(), newData.getVillageId(), newData.getBuildId(), newData.getUnitId(), |
|
|
|
newData.getHomeId(), "category", "类别", columnEntry.getKey(), value, resiInfo.getPids()); |
|
|
|
|
|
|
|
icUserChangeDetailedDao.insert(newDetail); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 保存新增居民类别记录 |
|
|
|
* @param newResis |
|
|
|
*/ |
|
|
|
public void saveNewResiCategoryRecord(Map<String, ResiImportCategoryData> newResis) { |
|
|
|
Date now = new Date(); |
|
|
|
|
|
|
|
CustomerStaffInfoCacheResult operator = CustomerStaffRedis.getStaffInfo(loginUserUtil.getLoginUserCustomerId(), loginUserUtil.getLoginUserId()); |
|
|
|
|
|
|
|
for (Map.Entry<String, ResiImportCategoryData> resi : newResis.entrySet()) { |
|
|
|
String resiId = resi.getKey(); |
|
|
|
ResiImportCategoryData data = resi.getValue(); |
|
|
|
|
|
|
|
IcResiUserEntity resiInfo = icResiUserDao.selectById(resiId); |
|
|
|
|
|
|
|
// 插入changeRecord
|
|
|
|
IcUserChangeRecordEntity changeRecord = fillChangeRecord(loginUserUtil.getLoginUserCustomerId(), resiId, resiInfo.getName(), null, |
|
|
|
loginUserUtil.getLoginUserId(), operator.getRealName(), "-", "-", |
|
|
|
"add", "新增", "", now); |
|
|
|
icUserChangeRecordDao.insert(changeRecord); |
|
|
|
|
|
|
|
// 插入changeDetail
|
|
|
|
for (Map.Entry<String, String> column : data.getCategories().entrySet()) { |
|
|
|
IcUserChangeDetailedEntity changedetail = fillChangeDetail(loginUserUtil.getLoginUserCustomerId(), resiId, changeRecord.getId(), data.getAgencyId(), |
|
|
|
data.getGridId(), data.getVillageId(), data.getBuildId(), data.getUnitId(), |
|
|
|
data.getHomeId(), "add", "新增", column.getKey(), 1, resiInfo.getPids()); |
|
|
|
|
|
|
|
icUserChangeDetailedDao.insert(changedetail); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 调动居民变更记录 |
|
|
|
* @param transferedResis |
|
|
|
*/ |
|
|
|
public void saveTransferedResiRecord(Map<String, ResiImportChangedData> transferedResis) { |
|
|
|
Date now = new Date(); |
|
|
|
for (Map.Entry<String, ResiImportChangedData> resi : transferedResis.entrySet()) { |
|
|
|
String customerId = loginUserUtil.getLoginUserCustomerId(); |
|
|
|
|
|
|
|
String resiId = resi.getKey(); |
|
|
|
ResiImportCategoryData oldData = resi.getValue().getOldData(); |
|
|
|
ResiImportCategoryData newData = resi.getValue().getNewData(); |
|
|
|
|
|
|
|
StringBuilder sbBefore = new StringBuilder(); |
|
|
|
StringBuilder sbAfter = new StringBuilder(); |
|
|
|
|
|
|
|
String oldAgencyId = oldData.getAgencyId(); |
|
|
|
String oldGridId = oldData.getGridId(); |
|
|
|
String oldvillageId = oldData.getVillageId(); |
|
|
|
String oldBuildId = oldData.getBuildId(); |
|
|
|
String oldUnitId = oldData.getUnitId(); |
|
|
|
String oldHomeId = oldData.getHomeId(); |
|
|
|
//
|
|
|
|
String newAgencyId = newData.getAgencyId(); |
|
|
|
String newGridId = newData.getGridId(); |
|
|
|
String newvillageId = newData.getVillageId(); |
|
|
|
String newBuildId = newData.getBuildId(); |
|
|
|
String newUnitId = newData.getUnitId(); |
|
|
|
String newHomeId = newData.getHomeId(); |
|
|
|
|
|
|
|
IcResiUserOrgMsgFormDTO oldOrgFormDTO = new IcResiUserOrgMsgFormDTO(); |
|
|
|
oldOrgFormDTO.setCustomerId(customerId); |
|
|
|
oldOrgFormDTO.setAgencyId(oldData.getAgencyId()); |
|
|
|
oldOrgFormDTO.setGridId(oldData.getGridId()); |
|
|
|
oldOrgFormDTO.setNeighborHoodId(oldData.getVillageId()); |
|
|
|
oldOrgFormDTO.setBuildingId(oldData.getBuildId()); |
|
|
|
oldOrgFormDTO.setBuildingUnitId(oldData.getUnitId()); |
|
|
|
oldOrgFormDTO.setHouseId(oldData.getHomeId()); |
|
|
|
Result<IcResiUserOrgMsgResultDTO> oldOrgInfoRst = govOrgOpenFeignClient.icResiUserOrgMsg(oldOrgFormDTO); |
|
|
|
|
|
|
|
IcResiUserOrgMsgFormDTO newOrgInfo = new IcResiUserOrgMsgFormDTO(); |
|
|
|
newOrgInfo.setCustomerId(customerId); |
|
|
|
newOrgInfo.setAgencyId(newData.getAgencyId()); |
|
|
|
newOrgInfo.setGridId(newData.getGridId()); |
|
|
|
newOrgInfo.setNeighborHoodId(newData.getVillageId()); |
|
|
|
newOrgInfo.setBuildingId(newData.getBuildId()); |
|
|
|
newOrgInfo.setBuildingUnitId(newData.getUnitId()); |
|
|
|
newOrgInfo.setHouseId(newData.getHomeId()); |
|
|
|
Result<IcResiUserOrgMsgResultDTO> newOrgInfoRst = govOrgOpenFeignClient.icResiUserOrgMsg(newOrgInfo); |
|
|
|
|
|
|
|
IcResiUserOrgMsgResultDTO oldOrg = null; |
|
|
|
IcResiUserOrgMsgResultDTO newOrg = null; |
|
|
|
|
|
|
|
if (oldOrgInfoRst.success()) { |
|
|
|
oldOrg = oldOrgInfoRst.getData(); |
|
|
|
} |
|
|
|
|
|
|
|
if (newOrgInfoRst.success()) { |
|
|
|
newOrg = newOrgInfoRst.getData(); |
|
|
|
} |
|
|
|
|
|
|
|
// 生成中文描述
|
|
|
|
if (oldOrg != null) { |
|
|
|
CustomerGridDTO gridDTO = oldOrg.getGridDTO(); |
|
|
|
IcNeighborHoodDTO neighborHoodDTO = oldOrg.getNeighborHoodDTO(); |
|
|
|
IcBuildingDTO buildingDTO = oldOrg.getBuildingDTO(); |
|
|
|
IcBuildingUnitDTO buildingUnitDTO = oldOrg.getBuildingUnitDTO(); |
|
|
|
IcHouseDTO houseDTO = oldOrg.getHouseDTO(); |
|
|
|
|
|
|
|
if (gridDTO != null) { |
|
|
|
sbBefore.append(gridDTO.getGridName()); |
|
|
|
} |
|
|
|
if (neighborHoodDTO != null) { |
|
|
|
sbBefore.append("-").append(neighborHoodDTO.getNeighborHoodName()); |
|
|
|
} |
|
|
|
if (buildingDTO != null) { |
|
|
|
sbBefore.append("-").append(buildingDTO.getBuildingName()); |
|
|
|
} |
|
|
|
if (buildingUnitDTO != null) { |
|
|
|
sbBefore.append("-").append(buildingUnitDTO.getUnitName()); |
|
|
|
} |
|
|
|
if (houseDTO != null) { |
|
|
|
sbBefore.append("-").append(houseDTO.getHouseName()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (newOrg != null) { |
|
|
|
CustomerGridDTO gridDTO = newOrg.getGridDTO(); |
|
|
|
IcNeighborHoodDTO neighborHoodDTO = newOrg.getNeighborHoodDTO(); |
|
|
|
IcBuildingDTO buildingDTO = newOrg.getBuildingDTO(); |
|
|
|
IcBuildingUnitDTO buildingUnitDTO = newOrg.getBuildingUnitDTO(); |
|
|
|
IcHouseDTO houseDTO = newOrg.getHouseDTO(); |
|
|
|
|
|
|
|
if (gridDTO != null) { |
|
|
|
sbAfter.append(gridDTO.getGridName()); |
|
|
|
} |
|
|
|
if (neighborHoodDTO != null) { |
|
|
|
sbAfter.append("-").append(neighborHoodDTO.getNeighborHoodName()); |
|
|
|
} |
|
|
|
if (buildingDTO != null) { |
|
|
|
sbAfter.append("-").append(buildingDTO.getBuildingName()); |
|
|
|
} |
|
|
|
if (buildingUnitDTO != null) { |
|
|
|
sbAfter.append("-").append(buildingUnitDTO.getUnitName()); |
|
|
|
} |
|
|
|
if (houseDTO != null) { |
|
|
|
sbAfter.append("-").append(houseDTO.getHouseName()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
CustomerStaffInfoCacheResult operator = CustomerStaffRedis.getStaffInfo(customerId, loginUserUtil.getLoginUserId()); |
|
|
|
|
|
|
|
IcResiUserEntity resiInfo = icResiUserDao.selectById(resiId); |
|
|
|
|
|
|
|
// 保存 transferRecord
|
|
|
|
IcUserTransferRecordEntity transferRecord = fillTransferRecord(resiInfo, operator, customerId, oldAgencyId, oldGridId, |
|
|
|
oldvillageId, oldBuildId, oldUnitId, oldHomeId, customerId, |
|
|
|
newAgencyId, newGridId, newvillageId, newBuildId, newUnitId, newHomeId, oldOrg, newOrg); |
|
|
|
icUserTransferRecordDao.insert(transferRecord); |
|
|
|
|
|
|
|
// 保存 changeRecord
|
|
|
|
IcUserChangeRecordEntity changeRecord = fillChangeRecord(customerId, resiId, resiInfo.getName(), transferRecord.getId(), operator.getStaffId(), |
|
|
|
operator.getRealName(), sbBefore.toString(), sbAfter.toString(), "transfer", "调动", "", now); |
|
|
|
icUserChangeRecordDao.insert(changeRecord); |
|
|
|
|
|
|
|
// 保存 changeDetail
|
|
|
|
for (Map.Entry<String, String> oldCategories : oldData.getCategories().entrySet()) { |
|
|
|
String key = oldCategories.getKey(); |
|
|
|
String value = oldCategories.getValue(); |
|
|
|
|
|
|
|
// 之前是这个类型,那这个类型需要-1
|
|
|
|
IcUserChangeDetailedEntity changeDetail = fillChangeDetail(customerId, resiId, changeRecord.getId(), oldData.getAgencyId(), |
|
|
|
oldData.getGridId(), oldData.getVillageId(), oldData.getBuildId(), oldData.getUnitId(), |
|
|
|
oldData.getHomeId(), "category", "调动", key, -1, resiInfo.getPids()); |
|
|
|
|
|
|
|
icUserChangeDetailedDao.insert(changeDetail); |
|
|
|
} |
|
|
|
|
|
|
|
for (Map.Entry<String, String> newCategories : newData.getCategories().entrySet()) { |
|
|
|
String key = newCategories.getKey(); |
|
|
|
String value = newCategories.getValue(); |
|
|
|
|
|
|
|
// 现在是这个类型,这个类型要+1
|
|
|
|
IcUserChangeDetailedEntity changeDetail = fillChangeDetail(customerId, resiId, changeRecord.getId(), newData.getAgencyId(), |
|
|
|
newData.getGridId(), newData.getVillageId(), newData.getBuildId(), newData.getUnitId(), |
|
|
|
newData.getHomeId(), "category", "调动", key, 1, resiInfo.getPids()); |
|
|
|
|
|
|
|
icUserChangeDetailedDao.insert(changeDetail); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 填充变更明细 |
|
|
|
* @param customerId |
|
|
|
* @param resiId |
|
|
|
* @param changeRecordId |
|
|
|
* @param agencyId |
|
|
|
* @param gridId |
|
|
|
* @param neighborhoodId |
|
|
|
* @param buildingId |
|
|
|
* @param initId |
|
|
|
* @param houseId |
|
|
|
* @param type |
|
|
|
* @param typeName |
|
|
|
* @param fieldName |
|
|
|
* @param value |
|
|
|
* @param pids |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private IcUserChangeDetailedEntity fillChangeDetail(String customerId, String resiId, String changeRecordId, String agencyId, String gridId, |
|
|
|
String neighborhoodId, String buildingId, String initId, String houseId, |
|
|
|
String type, String typeName, String fieldName, Integer value, String pids) { |
|
|
|
IcUserChangeDetailedEntity detail = new IcUserChangeDetailedEntity(); |
|
|
|
detail.setCustomerId(customerId); |
|
|
|
detail.setIcUserChangeRecordId(changeRecordId); |
|
|
|
detail.setPids(pids); |
|
|
|
detail.setAgencyId(agencyId); |
|
|
|
detail.setGridId(gridId); |
|
|
|
detail.setNeighborHoodId(neighborhoodId); |
|
|
|
detail.setBuildingId(buildingId); |
|
|
|
detail.setBuildingUnitId(initId); |
|
|
|
detail.setHouseId(houseId); |
|
|
|
detail.setIcUserId(resiId); |
|
|
|
detail.setType(type); |
|
|
|
detail.setTypeName(typeName); |
|
|
|
detail.setFieldName(fieldName); |
|
|
|
detail.setValue(value); |
|
|
|
return detail; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 填充变更记录 |
|
|
|
* @param customerId |
|
|
|
* @param resiId |
|
|
|
* @param resiName |
|
|
|
* @param transferRecordId |
|
|
|
* @param operatorId |
|
|
|
* @param operatorName |
|
|
|
* @param beforeChangeName |
|
|
|
* @param afterChangeName |
|
|
|
* @param type |
|
|
|
* @param typeName |
|
|
|
* @param remark |
|
|
|
* @param changeTime |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private IcUserChangeRecordEntity fillChangeRecord(String customerId, String resiId, String resiName, String transferRecordId, |
|
|
|
String operatorId, String operatorName, String beforeChangeName, String afterChangeName, |
|
|
|
String type, String typeName, String remark, Date changeTime) { |
|
|
|
IcUserChangeRecordEntity changeRecord = new IcUserChangeRecordEntity(); |
|
|
|
changeRecord.setAfterChangeName(afterChangeName); |
|
|
|
changeRecord.setBeforeChangeName(beforeChangeName); |
|
|
|
changeRecord.setChangeTime(changeTime); |
|
|
|
changeRecord.setCustomerId(customerId); |
|
|
|
changeRecord.setIcUserId(resiId); |
|
|
|
changeRecord.setIcUserName(resiName); |
|
|
|
changeRecord.setIcUserTransferRecordId(transferRecordId); |
|
|
|
changeRecord.setOperatorId(operatorId); |
|
|
|
changeRecord.setOperatorName(operatorName); |
|
|
|
changeRecord.setRemark(remark); |
|
|
|
changeRecord.setType(type); |
|
|
|
changeRecord.setTypeName(typeName); |
|
|
|
|
|
|
|
return changeRecord; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 填充调动记录 |
|
|
|
* @param resiInfo |
|
|
|
* @param operator |
|
|
|
* @param oldCustomerId |
|
|
|
* @param oldAgencyId |
|
|
|
* @param oldGridId |
|
|
|
* @param oldVillageId |
|
|
|
* @param oldBuildId |
|
|
|
* @param oldUnitId |
|
|
|
* @param oldHomeId |
|
|
|
* @param newCustomerId |
|
|
|
* @param newAgencyId |
|
|
|
* @param newGridId |
|
|
|
* @param newVillageId |
|
|
|
* @param newBuildId |
|
|
|
* @param newUnitId |
|
|
|
* @param newHomeId |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private IcUserTransferRecordEntity fillTransferRecord(IcResiUserEntity resiInfo, CustomerStaffInfoCacheResult operator, String oldCustomerId, String oldAgencyId, String oldGridId, |
|
|
|
String oldVillageId, String oldBuildId, String oldUnitId, String oldHomeId, String newCustomerId, |
|
|
|
String newAgencyId, String newGridId, String newVillageId, String newBuildId, String newUnitId, |
|
|
|
String newHomeId, IcResiUserOrgMsgResultDTO oldOrg, IcResiUserOrgMsgResultDTO newOrg) { |
|
|
|
|
|
|
|
IcUserTransferRecordEntity recordEntity = new IcUserTransferRecordEntity(); |
|
|
|
recordEntity.setIcUserId(resiInfo.getId()); |
|
|
|
recordEntity.setOperatorId(operator.getStaffId()); |
|
|
|
recordEntity.setIcUserName(resiInfo.getName()); |
|
|
|
recordEntity.setOperatorName(operator.getRealName()); |
|
|
|
recordEntity.setOldCustomerId(oldCustomerId); |
|
|
|
recordEntity.setOldAgencyId(oldAgencyId); |
|
|
|
recordEntity.setOldAgencyName(oldOrg != null ? oldOrg.getAgencyDTO().getOrganizationName() : ""); |
|
|
|
recordEntity.setOldGridId(oldGridId); |
|
|
|
recordEntity.setOldGridName(oldOrg != null ? oldOrg.getGridDTO().getGridName() : ""); |
|
|
|
recordEntity.setOldNeighborHoodId(oldVillageId); |
|
|
|
recordEntity.setOldNeighborHoodName(oldOrg != null ? oldOrg.getNeighborHoodDTO().getNeighborHoodName() : ""); |
|
|
|
recordEntity.setOldBuildingId(oldBuildId); |
|
|
|
recordEntity.setOldBuildingName(oldOrg != null ? oldOrg.getBuildingDTO().getBuildingName() : ""); |
|
|
|
recordEntity.setOldBuildingUnitId(oldUnitId); |
|
|
|
recordEntity.setOldBuildingUnitName(oldOrg != null ? oldOrg.getBuildingUnitDTO().getUnitName() : ""); |
|
|
|
recordEntity.setOldHouseId(oldHomeId); |
|
|
|
recordEntity.setOldHouseName(oldOrg != null ? oldOrg.getHouseDTO().getHouseName() : ""); |
|
|
|
recordEntity.setTransferTime(new Date()); |
|
|
|
recordEntity.setRemark(""); |
|
|
|
recordEntity.setNewCustomerId(newCustomerId); |
|
|
|
recordEntity.setNewAgencyId(newAgencyId); |
|
|
|
recordEntity.setNewAgencyName(newOrg != null ? newOrg.getAgencyDTO().getOrganizationName(): ""); |
|
|
|
recordEntity.setNewGridId(newGridId); |
|
|
|
recordEntity.setNewGridName(newOrg != null ? newOrg.getGridDTO().getGridName(): ""); |
|
|
|
recordEntity.setNewNeighborHoodId(newVillageId); |
|
|
|
recordEntity.setNewNeighborHoodName(newOrg != null ? newOrg.getNeighborHoodDTO().getNeighborHoodName(): ""); |
|
|
|
recordEntity.setNewBuildingId(newBuildId); |
|
|
|
recordEntity.setNewBuildingName(newOrg != null ? newOrg.getBuildingDTO().getBuildingName(): ""); |
|
|
|
recordEntity.setNewBuildingUnitId(newUnitId); |
|
|
|
recordEntity.setNewBuildingUnitName(newOrg != null ? newOrg.getBuildingUnitDTO().getUnitName(): ""); |
|
|
|
recordEntity.setNewHouseId(newHomeId); |
|
|
|
recordEntity.setNewHouseName(newOrg != null ? newOrg.getHouseDTO().getHouseName(): ""); |
|
|
|
|
|
|
|
return recordEntity; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//private IcUserTransferRecordEntity fillTransferRecord(String resiId, String resiName, String operatorId, String operatorName, String oldCustomerId,
|
|
|
|
// String oldAgencyId, String oldAgencyName, String oldGridId, String oldGridName, String neighborhoodId,
|
|
|
|
// String neighborhoodName, String oldBuildingId, String oldBuildingName, ) {
|
|
|
|
|
|
|
|
//IcUserTransferRecordEntity recordEntity = new IcUserTransferRecordEntity();
|
|
|
|
//recordEntity.setIcUserId();
|
|
|
|
//recordEntity.setOperatorId();
|
|
|
|
//recordEntity.setIcUserName();
|
|
|
|
//recordEntity.setOperatorName();
|
|
|
|
//recordEntity.setOldCustomerId();
|
|
|
|
//recordEntity.setOldAgencyId();
|
|
|
|
//recordEntity.setOldAgencyName();
|
|
|
|
//recordEntity.setOldGridId();
|
|
|
|
//recordEntity.setOldGridName();
|
|
|
|
//recordEntity.setOldNeighborHoodId();
|
|
|
|
//recordEntity.setOldNeighborHoodName();
|
|
|
|
//recordEntity.setOldBuildingId();
|
|
|
|
//recordEntity.setOldBuildingName();
|
|
|
|
//recordEntity.setOldBuildingUnitId();
|
|
|
|
//recordEntity.setOldBuildingUnitName();
|
|
|
|
//recordEntity.setOldHouseId();
|
|
|
|
//recordEntity.setOldHouseName();
|
|
|
|
//recordEntity.setTransferTime();
|
|
|
|
//recordEntity.setRemark();
|
|
|
|
//recordEntity.setNewCustomerId();
|
|
|
|
//recordEntity.setNewAgencyId();
|
|
|
|
//recordEntity.setNewAgencyName();
|
|
|
|
//recordEntity.setNewGridId();
|
|
|
|
//recordEntity.setNewGridName();
|
|
|
|
//recordEntity.setNewNeighborHoodId();
|
|
|
|
//recordEntity.setNewNeighborHoodName();
|
|
|
|
//recordEntity.setNewBuildingId();
|
|
|
|
//recordEntity.setNewBuildingName();
|
|
|
|
//recordEntity.setNewBuildingUnitId();
|
|
|
|
//recordEntity.setNewBuildingUnitName();
|
|
|
|
//recordEntity.setNewHouseId();
|
|
|
|
//recordEntity.setNewHouseName();
|
|
|
|
//}
|
|
|
|
} |
|
|
|