|
|
@ -12,6 +12,7 @@ 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.constant.ThreadLocalConstant; |
|
|
|
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; |
|
|
|
import com.epmet.commons.tools.dto.result.OptionResultDTO; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
@ -39,6 +40,7 @@ import com.epmet.entity.IcUserChangeRecordEntity; |
|
|
|
import com.epmet.entity.IcUserTransferRecordEntity; |
|
|
|
import com.epmet.enums.IcResiUserTableEnum; |
|
|
|
import com.epmet.excel.handler.IcResiImportDynamicExcelListener; |
|
|
|
import com.epmet.excel.handler.IcResiVirtualSheetImportListener; |
|
|
|
import com.epmet.feign.*; |
|
|
|
import com.epmet.service.*; |
|
|
|
import com.google.common.cache.Cache; |
|
|
@ -73,6 +75,11 @@ import java.util.stream.Collectors; |
|
|
|
@Service |
|
|
|
public class IcResiUserImportServiceImpl implements IcResiUserImportService, ResultDataResolver { |
|
|
|
|
|
|
|
/** |
|
|
|
* 身份证号列序号 |
|
|
|
*/ |
|
|
|
public static final Integer ID_CARD_COLUMN_NO = 9; |
|
|
|
|
|
|
|
// 错误和跳过excel行暂存
|
|
|
|
public static final ThreadLocal<Map<String, List<ErrorRow>>> errorRows = new ThreadLocal<>(); |
|
|
|
|
|
|
@ -200,24 +207,6 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
private String errorInfo; |
|
|
|
} |
|
|
|
|
|
|
|
@Data |
|
|
|
public static class SkipedRow { |
|
|
|
|
|
|
|
@Excel(name = "工作表") |
|
|
|
private String sheetName; |
|
|
|
|
|
|
|
private String tableName; |
|
|
|
|
|
|
|
@Excel(name = "身份证号") |
|
|
|
private String idCard; |
|
|
|
|
|
|
|
@Excel(name = "姓名") |
|
|
|
private String name; |
|
|
|
|
|
|
|
@Excel(name = "信息") |
|
|
|
private String info; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 导入居民信息 |
|
|
|
* @param importTaskId 导入任务id |
|
|
@ -245,8 +234,6 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
CustomerAgencyDTO agencyInfo = getResultDataOrThrowsException(govOrgOpenFeignClient.getAgencyById(currUserAgencyId), ServiceConstant.GOV_ORG_SERVER, EpmetErrorCode.SERVER_ERROR.getCode(), null, null); |
|
|
|
String customerId = agencyInfo.getCustomerId(); |
|
|
|
|
|
|
|
boolean hasErrorRows = false; |
|
|
|
|
|
|
|
try { |
|
|
|
initImportThreadLocal(customerId); |
|
|
|
|
|
|
@ -256,12 +243,13 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
|
|
|
|
// 上传附表信息
|
|
|
|
for (IcResiUserTableEnum sheet : IcResiUserTableEnum.values()) { |
|
|
|
// 是主表
|
|
|
|
if (sheet == IcResiUserTableEnum.IC_RESI_USER) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
importIcResiExtraInfoFromExcel(formItemList, excelPathName, sheet.getSheetNo(), sheet.getHeadRowNo(), currUserAgencyId, loginUserId, sheet.getTableName(), customerId); |
|
|
|
importIcResiExtraInfoFromExcel(formItemList, excelPathName, sheet, currUserAgencyId, loginUserId, customerId); |
|
|
|
} catch (Exception e) { |
|
|
|
String errorMsg = ExceptionUtils.getErrorStackTrace(e); |
|
|
|
log.error("导入IC居民附加信息【{}】错误:{}", sheet.getTableComment(), errorMsg); |
|
|
@ -339,12 +327,6 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
String operatorId = loginUserUtil.getLoginUserId(); |
|
|
|
String importTag = operatorId + System.currentTimeMillis(); |
|
|
|
|
|
|
|
// 跳过的,不导入的行
|
|
|
|
Map<String, List<SkipedRow>> skipedRowsMap = new LinkedHashMap<>(); |
|
|
|
for (IcResiUserTableEnum e : IcResiUserTableEnum.values()) { |
|
|
|
skipedRowsMap.put(e.getTableName(), new LinkedList<>()); |
|
|
|
} |
|
|
|
|
|
|
|
// 错误信息
|
|
|
|
Map<String, List<ErrorRow>> errorRowsMap = new LinkedHashMap<>(); |
|
|
|
for (IcResiUserTableEnum e : IcResiUserTableEnum.values()) { |
|
|
@ -392,19 +374,35 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
* |
|
|
|
* @param formItemList |
|
|
|
* @param excelPathName |
|
|
|
* @param sheetNo |
|
|
|
* @param headRowNumber |
|
|
|
* @param sheetEnumObject sheet枚举对象 |
|
|
|
* @param currUserAgencyId |
|
|
|
* @param currentUserId |
|
|
|
* @param targetTableName 要插入哪一个表 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private void importIcResiExtraInfoFromExcel(List<FormItemResult> formItemList, String excelPathName, int sheetNo, int headRowNumber, String currUserAgencyId, String currentUserId, |
|
|
|
String targetTableName, String customerId) { |
|
|
|
|
|
|
|
IcResiImportDynamicExcelListener readListener = new IcResiImportDynamicExcelListener(this, customerId, currentUserId, currUserAgencyId, null, |
|
|
|
false, targetTableName, formItemList, headRowNumber); |
|
|
|
EasyExcelFactory.read(new File(excelPathName)).registerReadListener(readListener).headRowNumber(headRowNumber).sheet(sheetNo).doRead(); |
|
|
|
private void importIcResiExtraInfoFromExcel(List<FormItemResult> formItemList, String excelPathName, IcResiUserTableEnum sheetEnumObject, String currUserAgencyId, |
|
|
|
String currentUserId, String customerId) { |
|
|
|
|
|
|
|
// 如果该sheet对应有实际的数据库表,使用items动态的解析
|
|
|
|
if (sheetEnumObject.isExistsDBTable()) { |
|
|
|
IcResiImportDynamicExcelListener readListener = new IcResiImportDynamicExcelListener( |
|
|
|
this, customerId, currentUserId, currUserAgencyId, null, |
|
|
|
false, sheetEnumObject.getTableName(), formItemList, sheetEnumObject.getHeadRowNo()); |
|
|
|
|
|
|
|
EasyExcelFactory.read(new File(excelPathName)) |
|
|
|
.registerReadListener(readListener) |
|
|
|
.headRowNumber(sheetEnumObject.getHeadRowNo()) |
|
|
|
.sheet(sheetEnumObject.getTableComment()) |
|
|
|
.doRead(); |
|
|
|
} else { |
|
|
|
// 实际上并不存在该sheet对应的数据库表,此时无法使用items解析,就要读取固定的ID_CARD字段数据,更新主表字段为true
|
|
|
|
IcResiVirtualSheetImportListener vitualSheetReadListener = new IcResiVirtualSheetImportListener(this, sheetEnumObject); |
|
|
|
|
|
|
|
EasyExcelFactory.read(new File(excelPathName)) |
|
|
|
.registerReadListener(vitualSheetReadListener) |
|
|
|
.headRowNumber(sheetEnumObject.getHeadRowNo()) |
|
|
|
.sheet(sheetEnumObject.getTableComment()) |
|
|
|
.doRead(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -427,7 +425,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
|
|
|
|
String idCard = columnAndValues.get("ID_CARD"); |
|
|
|
|
|
|
|
Map<String, String> existingResiMap = icResiUserDao.selectResiInfoMap(idCard); |
|
|
|
Map<String, String> existingResiMap = icResiUserDao.selectResiInfoMap(idCard, null); |
|
|
|
|
|
|
|
if (existingResiMap == null) { |
|
|
|
// 新导入的居民,因为还没有读取子sheet,所以这些居民类别没有办法获取,先默认设置成0,后面读取子sheet的时候再更新
|
|
|
@ -439,6 +437,16 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
columnAndValues.put("IS_UNITED_FRONT", "0"); |
|
|
|
columnAndValues.put("IS_VETERANS", "0"); |
|
|
|
columnAndValues.put("IS_VOLUNTEER", "0"); |
|
|
|
columnAndValues.put("IS_DBH", "0"); |
|
|
|
columnAndValues.put("IS_YLFN", "0"); |
|
|
|
columnAndValues.put("IS_XFRY", "0"); |
|
|
|
columnAndValues.put("IS_KC", "0"); |
|
|
|
columnAndValues.put("IS_SD", "0"); |
|
|
|
columnAndValues.put("IS_SN", "0"); |
|
|
|
columnAndValues.put("IS_SZ", "0"); |
|
|
|
columnAndValues.put("IS_CJ", "0"); |
|
|
|
columnAndValues.put("IS_DB", "0"); |
|
|
|
columnAndValues.put("IS_MB", "0"); |
|
|
|
} else { |
|
|
|
// 该居民已存在,要做更新操作,因为还没有读取子sheet,所以这些居民最新类别没有办法获取,先设置上旧的数据
|
|
|
|
columnAndValues.put("IS_ENSURE_HOUSE", existingResiMap.get("IS_ENSURE_HOUSE")); |
|
|
@ -449,6 +457,16 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
columnAndValues.put("IS_UNITED_FRONT", existingResiMap.get("IS_UNITED_FRONT")); |
|
|
|
columnAndValues.put("IS_VETERANS", existingResiMap.get("IS_VETERANS")); |
|
|
|
columnAndValues.put("IS_VOLUNTEER", existingResiMap.get("IS_VOLUNTEER")); |
|
|
|
columnAndValues.put("IS_DBH", existingResiMap.get("IS_DBH")); |
|
|
|
columnAndValues.put("IS_YLFN", existingResiMap.get("IS_YLFN")); |
|
|
|
columnAndValues.put("IS_XFRY", existingResiMap.get("IS_XFRY")); |
|
|
|
columnAndValues.put("IS_KC", existingResiMap.get("IS_KC")); |
|
|
|
columnAndValues.put("IS_SD", existingResiMap.get("IS_SD")); |
|
|
|
columnAndValues.put("IS_SN", existingResiMap.get("IS_SN")); |
|
|
|
columnAndValues.put("IS_SZ", existingResiMap.get("IS_SZ")); |
|
|
|
columnAndValues.put("IS_CJ", existingResiMap.get("IS_CJ")); |
|
|
|
columnAndValues.put("IS_DB", existingResiMap.get("IS_DB")); |
|
|
|
columnAndValues.put("IS_MB", existingResiMap.get("IS_MB")); |
|
|
|
} |
|
|
|
|
|
|
|
columnAndValues.put("AGENCY_ID", currUserAgencyId); |
|
|
@ -465,12 +483,6 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
ResiImportChangedData transferData; |
|
|
|
if ((transferData = this.getResiImportTrasferData(existingResiMap, columnAndValues)) != null) { |
|
|
|
newlyOrChangedResi.get().getTransferedResis().put(existingResiMap.get("ID"), transferData); |
|
|
|
} else { |
|
|
|
// 组织维度没有发生变化,看是否有居民类型变更
|
|
|
|
ResiImportChangedData d = getResiImportCategoryChangedData(existingResiMap, columnAndValues); |
|
|
|
if (d != null) { |
|
|
|
newlyOrChangedResi.get().getCategoryChangedResis().put(existingResiMap.get("ID"), d); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 新增居民
|
|
|
@ -478,22 +490,8 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
|
|
|
|
columnAndValues.put("CREATED_BY", currentUserId); |
|
|
|
columnAndValues.put("ID", resiId); |
|
|
|
icResiUserDao.add(tableName, columnAndValues); |
|
|
|
|
|
|
|
// 过滤出本居民含有哪些类别
|
|
|
|
Map<String, String> resiCategories = resiCategoryColumnNameAndLabel.get().keySet() |
|
|
|
.stream() |
|
|
|
.filter((categoryColumnName) -> "1".equals(columnAndValues.get(categoryColumnName))) |
|
|
|
.collect(Collectors.toMap((k) -> k, (k) -> columnAndValues.get(k))); |
|
|
|
|
|
|
|
// newlyOrChangedResi.get().getNewResis().put(resiId,
|
|
|
|
// new ResiImportCategoryData(columnAndValues.get("AGENCY_ID"),
|
|
|
|
// columnAndValues.get("GRID_ID"),
|
|
|
|
// columnAndValues.get("VILLAGE_ID"),
|
|
|
|
// columnAndValues.get("BUILD_ID"),
|
|
|
|
// columnAndValues.get("UNIT_ID"),
|
|
|
|
// columnAndValues.get("HOME_ID"),
|
|
|
|
// resiCategories));
|
|
|
|
icResiUserDao.add(tableName, columnAndValues); |
|
|
|
|
|
|
|
ResiImportCategoryData categoryData = new ResiImportCategoryData(resiId, |
|
|
|
columnAndValues.get("AGENCY_ID"), |
|
|
@ -502,7 +500,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
columnAndValues.get("BUILD_ID"), |
|
|
|
columnAndValues.get("UNIT_ID"), |
|
|
|
columnAndValues.get("HOME_ID"), |
|
|
|
resiCategories); |
|
|
|
new HashMap<>()); |
|
|
|
|
|
|
|
redisUtils.hMSet(RedisKeys.icResiImportResiCategoryKey(newlyOrChangedResi.get().getImportTag(), "add", resiId), BeanUtil.beanToMap(categoryData)); |
|
|
|
categoryData = null; |
|
|
@ -560,13 +558,13 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
} |
|
|
|
|
|
|
|
// 检查用户是否存在
|
|
|
|
Map<String, String> resiInfoMap = icResiUserDao.selectResiInfoMap(idCard); |
|
|
|
Map<String, String> existResiInfoMap = icResiUserDao.selectResiInfoMap(idCard, null); |
|
|
|
|
|
|
|
if (resiInfoMap == null || resiInfoMap.size() == 0) { |
|
|
|
if (existResiInfoMap == null || existResiInfoMap.size() == 0) { |
|
|
|
throw new RenException(EpmetErrorCode.RESI_NOT_FOUND.getCode(), String.format("身份证号为【%s】的居民信息未找到,请确认该居民信息存在", idCard)); |
|
|
|
} |
|
|
|
|
|
|
|
String icResiId = resiInfoMap.get("ID"); |
|
|
|
String icResiId = existResiInfoMap.get("ID"); |
|
|
|
|
|
|
|
columnAndValues.put("IC_RESI_USER", icResiId); |
|
|
|
columnAndValues.put("CUSTOMER_ID", loginUserUtil.getLoginUserCustomerId()); |
|
|
@ -594,7 +592,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
// 保存到类别变更缓存中
|
|
|
|
saveSubTableInfoToCategoryChangedResiCache(icResiId, |
|
|
|
Objects.requireNonNull(IcResiUserTableEnum.getObjectByTableName(targetTableName)).getMainTableFlagColumnName(), |
|
|
|
resiInfoMap); |
|
|
|
existResiInfoMap); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
String errorMsg; |
|
|
@ -617,6 +615,45 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 虚拟(不对应实际的数据库表)sheet的数据导入持久化 |
|
|
|
* @param sheetEnumObject |
|
|
|
*/ |
|
|
|
public void persistIcResiVirtualSheetExtraInfo(List<Map<String, String>> resiInfo, IcResiUserTableEnum sheetEnumObject) { |
|
|
|
for (Map<String, String> columnAndValues : resiInfo) { |
|
|
|
String idCard = columnAndValues.get(ID_CARD_COLUMN_NO); |
|
|
|
try { |
|
|
|
Map<String, String> resiInfoMap = icResiUserDao.selectResiInfoMap(idCard, null); |
|
|
|
|
|
|
|
if (resiInfoMap == null || resiInfoMap.size() == 0) { |
|
|
|
throw new RenException(EpmetErrorCode.RESI_NOT_FOUND.getCode(), String.format("身份证号为【%s】的居民信息未找到,请确认该居民信息存在", idCard)); |
|
|
|
} |
|
|
|
String icResiId = resiInfoMap.get("ID"); |
|
|
|
|
|
|
|
// 更新主表中该居民类型字段为true
|
|
|
|
updateMainTableResiTypeFlag(sheetEnumObject, icResiId); |
|
|
|
|
|
|
|
// 保存类别变更信息
|
|
|
|
saveSubTableInfoToCategoryChangedResiCache(icResiId, sheetEnumObject.getMainTableFlagColumnName(), resiInfoMap); |
|
|
|
} catch (Exception e) { |
|
|
|
String errorMsg; |
|
|
|
if (e instanceof RenException || e instanceof EpmetException) { |
|
|
|
errorMsg = e.getMessage(); |
|
|
|
} else { |
|
|
|
errorMsg = "未知系统错误"; |
|
|
|
log.error(ExceptionUtils.getErrorStackTrace(e)); |
|
|
|
} |
|
|
|
|
|
|
|
ErrorRow errorRow = new ErrorRow(); |
|
|
|
errorRow.setName(columnAndValues.get("NAME")); |
|
|
|
errorRow.setIdCard(idCard); |
|
|
|
errorRow.setErrorInfo(errorMsg); |
|
|
|
errorRow.setTableName(sheetEnumObject.getTableName()); |
|
|
|
errorRows.get().get(sheetEnumObject.getTableName()).add(errorRow); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 去掉多余的列 |
|
|
|
* @param originColumnAndValues |
|
|
@ -1060,7 +1097,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
private void updateMainTableResiTypeFlag(IcResiUserTableEnum icResiUserTableEnum, String resiUserId) { |
|
|
|
HashMap<String, Boolean> map = new HashMap<>(); |
|
|
|
map.put(icResiUserTableEnum.getMainTableFlagColumnName(), true); |
|
|
|
icResiUserDao.upTable("ic_resi_user", resiUserId, map); |
|
|
|
icResiUserDao.upTable(IcResiUserTableEnum.IC_RESI_USER.getTableName(), resiUserId, map); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -1127,93 +1164,6 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
HashMap<String, String> existingResiCategories = new HashMap<>(); |
|
|
|
HashMap<String, String> newResiCategories = new HashMap<>(); |
|
|
|
|
|
|
|
for (String categoryColumnName : resiCategoryColumnNameAndLabel.get().keySet()) { |
|
|
|
String oldCategoryValue = existingResiMap.get(categoryColumnName); |
|
|
|
String newCategoryValue = newResiMap.get(categoryColumnName); |
|
|
|
|
|
|
|
if (StringUtils.isBlank(oldCategoryValue)) oldCategoryValue = "0"; |
|
|
|
if (StringUtils.isBlank(newCategoryValue)) newCategoryValue = "0"; |
|
|
|
|
|
|
|
if ("1".equals(oldCategoryValue) || "1".equals(newCategoryValue)) { |
|
|
|
// 新旧值有一个为1,则放入
|
|
|
|
existingResiCategories.put(categoryColumnName, oldCategoryValue); |
|
|
|
newResiCategories.put(categoryColumnName, newCategoryValue); |
|
|
|
} |
|
|
|
|
|
|
|
// if ("1".equals(oldCategoryValue)) {
|
|
|
|
// existingResiCategories.put(categoryColumnName, oldCategoryValue);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if ("1".equals(newCategoryValue)) {
|
|
|
|
// newResiCategories.put(categoryColumnName, newCategoryValue);
|
|
|
|
// }
|
|
|
|
} |
|
|
|
|
|
|
|
ResiImportCategoryData oldOne = new ResiImportCategoryData( |
|
|
|
existingResiMap.get("ID"), |
|
|
|
existingResiMap.get("AGENCY_ID"), |
|
|
|
existingResiMap.get("GRID_ID"), |
|
|
|
existingResiMap.get("VILLAGE_ID"), |
|
|
|
existingResiMap.get("BUILD_ID"), |
|
|
|
existingResiMap.get("UNIT_ID"), |
|
|
|
existingResiMap.get("HOME_ID"), |
|
|
|
existingResiCategories); |
|
|
|
|
|
|
|
ResiImportCategoryData newOne = new ResiImportCategoryData( |
|
|
|
newResiMap.get("ID"), |
|
|
|
newResiMap.get("AGENCY_ID"), |
|
|
|
newResiMap.get("GRID_ID"), |
|
|
|
newResiMap.get("VILLAGE_ID"), |
|
|
|
newResiMap.get("BUILD_ID"), |
|
|
|
newResiMap.get("UNIT_ID"), |
|
|
|
newResiMap.get("HOME_ID"), |
|
|
|
newResiCategories); |
|
|
|
|
|
|
|
return new ResiImportChangedData(oldOne, newOne); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 类别变更的居民信息封装。只要发生变化,0或者1都要保存 |
|
|
|
* 1. |
|
|
|
* @param existingResiMap |
|
|
|
* @param newResiMap |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private ResiImportChangedData getResiImportCategoryChangedData(Map<String, String> existingResiMap, Map<String, String> newResiMap) { |
|
|
|
// 发生变化的类别列明
|
|
|
|
HashMap<String, String> oldCategories = new HashMap<>(); |
|
|
|
HashMap<String, String> newCategories = new HashMap<>(); |
|
|
|
|
|
|
|
Set<String> categoryColumnNames = resiCategoryColumnNameAndLabel.get().keySet(); |
|
|
|
for (String categoryColumnName : categoryColumnNames) { |
|
|
|
|
|
|
|
String existingColumnValue = existingResiMap.get(categoryColumnName); |
|
|
|
String newColumnValue = newResiMap.get(categoryColumnName); |
|
|
|
|
|
|
|
// 先转为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); |
|
|
|
} |
|
|
|
|
|
|
|
// if (StringUtils.isAllBlank(existingColumnValue, newColumnValue)) {
|
|
|
|
// // 都为空,则没发生变化
|
|
|
|
// continue;
|
|
|
|
// } else {
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
} |
|
|
|
|
|
|
|
if (oldCategories.size() == 0) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
ResiImportCategoryData oldOne = new ResiImportCategoryData( |
|
|
|
existingResiMap.get("ID"), |
|
|
|
existingResiMap.get("AGENCY_ID"), |
|
|
@ -1222,7 +1172,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
existingResiMap.get("BUILD_ID"), |
|
|
|
existingResiMap.get("UNIT_ID"), |
|
|
|
existingResiMap.get("HOME_ID"), |
|
|
|
oldCategories); |
|
|
|
new HashMap<>()); |
|
|
|
|
|
|
|
ResiImportCategoryData newOne = new ResiImportCategoryData( |
|
|
|
newResiMap.get("ID"), |
|
|
@ -1232,7 +1182,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
newResiMap.get("BUILD_ID"), |
|
|
|
newResiMap.get("UNIT_ID"), |
|
|
|
newResiMap.get("HOME_ID"), |
|
|
|
newCategories); |
|
|
|
new HashMap<>()); |
|
|
|
|
|
|
|
return new ResiImportChangedData(oldOne, newOne); |
|
|
|
} |
|
|
@ -1241,20 +1191,19 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
* |
|
|
|
* @param icResiId 居民id |
|
|
|
* @param columnName 该项信息在主表的列名 |
|
|
|
* @param existResiInfoMap 已存在的居民信息map |
|
|
|
*/ |
|
|
|
private void saveSubTableInfoToCategoryChangedResiCache(String icResiId, String columnName, Map<String, String> resiInfoMap) { |
|
|
|
private void saveSubTableInfoToCategoryChangedResiCache(String icResiId, String columnName, Map<String, String> existResiInfoMap) { |
|
|
|
|
|
|
|
ResiImportResiCategoryChangedCache cc = newlyOrChangedResi.get(); |
|
|
|
// Map<String, ResiImportCategoryData> newResis = cc.getNewResis();
|
|
|
|
Map<String, ResiImportChangedData> categoryChangedResis = cc.getCategoryChangedResis(); |
|
|
|
Map<String, ResiImportChangedData> transferedResis = cc.getTransferedResis(); |
|
|
|
|
|
|
|
// ResiImportCategoryData newResi = newResis.get(icResiId);
|
|
|
|
|
|
|
|
// 为新增居民
|
|
|
|
String userCateRedisKey = RedisKeys.icResiImportResiCategoryKey(newlyOrChangedResi.get().getImportTag(), "add", icResiId); |
|
|
|
Map < String, Object > addUserMap = redisUtils.hGetAll(userCateRedisKey); |
|
|
|
Map<String, Object> addUserMap = redisUtils.hGetAll(userCateRedisKey); |
|
|
|
if (addUserMap != null && addUserMap.size() > 0) { |
|
|
|
//说明是新增居民
|
|
|
|
ResiImportCategoryData newResiCateData = ConvertUtils.mapToEntity(addUserMap, ResiImportCategoryData.class); |
|
|
|
newResiCateData.getCategories().put(columnName, "1"); |
|
|
|
redisUtils.hMSet(userCateRedisKey, BeanUtil.beanToMap(newResiCateData)); |
|
|
@ -1262,47 +1211,53 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
ResiImportChangedData categoryChangedData = categoryChangedResis.get(icResiId); |
|
|
|
if (categoryChangedData != null) { |
|
|
|
// 说明是类别变更的居民
|
|
|
|
Map<String, String> oldCategories = categoryChangedData.getOldData().getCategories(); |
|
|
|
Map<String, String> newCategories = categoryChangedData.getNewData().getCategories(); |
|
|
|
|
|
|
|
if ("0".equals(resiInfoMap.get(columnName))) { |
|
|
|
oldCategories.put(columnName, "0"); |
|
|
|
newCategories.put(columnName, "1"); |
|
|
|
} |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
String oldValue = existResiInfoMap.get(columnName); |
|
|
|
|
|
|
|
// 为发生调动的居民。不管标志相同与否都往里面put
|
|
|
|
ResiImportChangedData transferedData = transferedResis.get(icResiId); |
|
|
|
if (transferedData != null) { |
|
|
|
// 说明是发生调动的居民,新数据值为1
|
|
|
|
Map<String, String> newCategories = transferedData.getNewData().getCategories(); |
|
|
|
Map<String, String> oldCategories = transferedData.getOldData().getCategories(); |
|
|
|
|
|
|
|
String oldValue = resiInfoMap.get(columnName); |
|
|
|
if (StringUtils.isBlank(oldValue)) { |
|
|
|
oldValue = "0"; |
|
|
|
} |
|
|
|
|
|
|
|
oldCategories.put(columnName, oldValue); |
|
|
|
oldCategories.put(columnName, oldValue); |
|
|
|
newCategories.put(columnName, "1"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if ("0".equals(resiInfoMap.get(columnName))) { |
|
|
|
// 非新增,非调动,变更的数据不在主sheet中,而在附sheet中。看是否发生人员类型变更(从0->1)
|
|
|
|
ResiImportCategoryData oldOne = new ResiImportCategoryData(); |
|
|
|
ResiImportCategoryData newOne = new ResiImportCategoryData(); |
|
|
|
// 类别变更的居民。不管标志相同与否都往里面put
|
|
|
|
ResiImportChangedData categoryChangedData = categoryChangedResis.get(icResiId); |
|
|
|
if (categoryChangedData != null) { |
|
|
|
Map<String, String> oldCategories = categoryChangedData.getOldData().getCategories(); |
|
|
|
Map<String, String> newCategories = categoryChangedData.getNewData().getCategories(); |
|
|
|
|
|
|
|
oldOne.getCategories().put(columnName, "0"); |
|
|
|
newOne.getCategories().put(columnName, "1"); |
|
|
|
oldCategories.put(columnName, oldValue); |
|
|
|
newCategories.put(columnName, "1"); |
|
|
|
|
|
|
|
ResiImportChangedData cd = new ResiImportChangedData(oldOne, newOne); |
|
|
|
categoryChangedResis.put(icResiId, cd); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 非新增,非调动,可能是类别变更的,只是主表中没有数据,只有附加表的数据
|
|
|
|
ResiImportCategoryData oldOne = new ResiImportCategoryData(); |
|
|
|
ResiImportCategoryData newOne = new ResiImportCategoryData(); |
|
|
|
|
|
|
|
oldOne.setAgencyId(existResiInfoMap.get("AGENCY_ID")); |
|
|
|
oldOne.setGridId(existResiInfoMap.get("GRID_ID")); |
|
|
|
oldOne.setVillageId(existResiInfoMap.get("VILLAGE_ID")); |
|
|
|
oldOne.setBuildId(existResiInfoMap.get("BUILD_ID")); |
|
|
|
oldOne.setUnitId(existResiInfoMap.get("UNIT_ID")); |
|
|
|
oldOne.setHomeId(existResiInfoMap.get("HOME_ID")); |
|
|
|
oldOne.getCategories().put(columnName, oldValue); |
|
|
|
|
|
|
|
newOne.setAgencyId(existResiInfoMap.get("AGENCY_ID")); |
|
|
|
newOne.setGridId(existResiInfoMap.get("GRID_ID")); |
|
|
|
newOne.setVillageId(existResiInfoMap.get("VILLAGE_ID")); |
|
|
|
newOne.setBuildId(existResiInfoMap.get("BUILD_ID")); |
|
|
|
newOne.setUnitId(existResiInfoMap.get("UNIT_ID")); |
|
|
|
newOne.setHomeId(existResiInfoMap.get("HOME_ID")); |
|
|
|
newOne.getCategories().put(columnName, "1"); |
|
|
|
|
|
|
|
ResiImportChangedData cd = new ResiImportChangedData(oldOne, newOne); |
|
|
|
categoryChangedResis.put(icResiId, cd); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -1322,7 +1277,9 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
Map<String, String> oldCategories = oldData.getCategories(); |
|
|
|
Map<String, String> newCategories = newData.getCategories(); |
|
|
|
|
|
|
|
fillResiSubCategoryInfo4TransferAndCategoryChange(oldData, newData); |
|
|
|
Map<String, String> resiInfoMap = icResiUserDao.selectResiInfoMap(null, resiId); |
|
|
|
|
|
|
|
fillResiSubCategoryInfo4TransferAndCategoryChange(oldData, newData, resiInfoMap); |
|
|
|
|
|
|
|
StringBuilder sbBefore = new StringBuilder(""); |
|
|
|
StringBuilder sbAfter = new StringBuilder(""); |
|
|
@ -1339,23 +1296,19 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
} |
|
|
|
|
|
|
|
// 生成changeRecord并存入
|
|
|
|
IcResiUserEntity resiInfo = icResiUserDao.selectById(resiId); |
|
|
|
IcUserChangeRecordEntity changeRecord = fillChangeRecord(loginUserUtil.getLoginUserCustomerId(), resiId, resiInfo.getName(), null, loginUserUtil.getLoginUserId(), |
|
|
|
IcUserChangeRecordEntity changeRecord = fillChangeRecord(loginUserUtil.getLoginUserCustomerId(), resiId, resiInfoMap.get("NAME"), null, loginUserUtil.getLoginUserId(), |
|
|
|
operator.getRealName() , descBefore, descAfter, "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; |
|
|
|
|
|
|
|
String agencyId = newData.getAgencyId(); |
|
|
|
String gridId = newData.getGridId(); |
|
|
|
String villageId = newData.getVillageId(); |
|
|
@ -1363,17 +1316,9 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
String unitId = newData.getUnitId(); |
|
|
|
String homeId = newData.getHomeId(); |
|
|
|
|
|
|
|
// 如果只有附加表信息,但是没有主表信息,并且附加表基础信息很多空着的,此处需要从主表获取了然后填充一下该信息
|
|
|
|
if (agencyId == null) agencyId = resiInfo.getAgencyId(); |
|
|
|
if (gridId == null) gridId = resiInfo.getGridId(); |
|
|
|
if (villageId == null) villageId = resiInfo.getVillageId(); |
|
|
|
if (buildId == null) buildId = resiInfo.getBuildId(); |
|
|
|
if (unitId == null) unitId = resiInfo.getUnitId(); |
|
|
|
if (homeId == null) homeId = resiInfo.getHomeId(); |
|
|
|
|
|
|
|
IcUserChangeDetailedEntity newDetail = fillChangeDetail(loginUserUtil.getLoginUserCustomerId(), resiId, changeRecord.getId(), agencyId, |
|
|
|
gridId, villageId, buildId, unitId, |
|
|
|
homeId, "category", "类别", columnEntry.getKey(), value, resiInfo.getPids()); |
|
|
|
homeId, "category", "类别", columnEntry.getKey(), 1, resiInfoMap.get("PIDS")); |
|
|
|
|
|
|
|
icUserChangeDetailedDao.insert(newDetail); |
|
|
|
} |
|
|
@ -1431,10 +1376,10 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
icUserChangeRecordDao.insert(changeRecord); |
|
|
|
|
|
|
|
// 插入changeDetail
|
|
|
|
for (Map.Entry<String, String> column : newResiInfoObj.getCategories().entrySet()) { |
|
|
|
for (Map.Entry<String, String> mainTableColumn : newResiInfoObj.getCategories().entrySet()) { |
|
|
|
IcUserChangeDetailedEntity changedetail = fillChangeDetail(loginUserUtil.getLoginUserCustomerId(), newResiInfoObj.getResiId(), changeRecord.getId(), newResiInfoObj.getAgencyId(), |
|
|
|
newResiInfoObj.getGridId(), newResiInfoObj.getVillageId(), newResiInfoObj.getBuildId(), newResiInfoObj.getUnitId(), |
|
|
|
newResiInfoObj.getHomeId(), "add", "新增", column.getKey(), 1, resiInfo.getPids()); |
|
|
|
newResiInfoObj.getHomeId(), "add", "新增", mainTableColumn.getKey(), 1, resiInfo.getPids()); |
|
|
|
|
|
|
|
icUserChangeDetailedDao.insert(changedetail); |
|
|
|
changedetail = null; |
|
|
@ -1457,11 +1402,15 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
for (Map.Entry<String, ResiImportChangedData> resi : transferedResis.entrySet()) { |
|
|
|
|
|
|
|
String resiId = resi.getKey(); |
|
|
|
Map<String, String> resiInfoMap = icResiUserDao.selectResiInfoMap(null, resiId); |
|
|
|
String resiName = resiInfoMap.get("NAME"); |
|
|
|
String pids = resiInfoMap.get("PIDS"); |
|
|
|
|
|
|
|
ResiImportCategoryData oldData = resi.getValue().getOldData(); |
|
|
|
ResiImportCategoryData newData = resi.getValue().getNewData(); |
|
|
|
|
|
|
|
// 把附加表的旧数据填充到新数据中
|
|
|
|
fillResiSubCategoryInfo4TransferAndCategoryChange(oldData, newData); |
|
|
|
fillResiSubCategoryInfo4TransferAndCategoryChange(oldData, newData, resiInfoMap); |
|
|
|
|
|
|
|
StringBuilder sbBefore = new StringBuilder(); |
|
|
|
StringBuilder sbAfter = new StringBuilder(); |
|
|
@ -1472,7 +1421,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
String oldBuildId = oldData.getBuildId(); |
|
|
|
String oldUnitId = oldData.getUnitId(); |
|
|
|
String oldHomeId = oldData.getHomeId(); |
|
|
|
//
|
|
|
|
|
|
|
|
String newAgencyId = newData.getAgencyId(); |
|
|
|
String newGridId = newData.getGridId(); |
|
|
|
String newvillageId = newData.getVillageId(); |
|
|
@ -1482,22 +1431,22 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
|
|
|
|
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()); |
|
|
|
oldOrgFormDTO.setAgencyId(oldAgencyId); |
|
|
|
oldOrgFormDTO.setGridId(oldGridId); |
|
|
|
oldOrgFormDTO.setNeighborHoodId(oldvillageId); |
|
|
|
oldOrgFormDTO.setBuildingId(oldBuildId); |
|
|
|
oldOrgFormDTO.setBuildingUnitId(oldUnitId); |
|
|
|
oldOrgFormDTO.setHouseId(oldHomeId); |
|
|
|
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()); |
|
|
|
newOrgInfo.setAgencyId(newAgencyId); |
|
|
|
newOrgInfo.setGridId(newGridId); |
|
|
|
newOrgInfo.setNeighborHoodId(newvillageId); |
|
|
|
newOrgInfo.setBuildingId(newBuildId); |
|
|
|
newOrgInfo.setBuildingUnitId(newUnitId); |
|
|
|
newOrgInfo.setHouseId(newHomeId); |
|
|
|
Result<IcResiUserOrgMsgResultDTO> newOrgInfoRst = govOrgOpenFeignClient.icResiUserOrgMsg(newOrgInfo); |
|
|
|
|
|
|
|
IcResiUserOrgMsgResultDTO oldOrg = null; |
|
|
@ -1560,16 +1509,14 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
IcResiUserEntity resiInfo = icResiUserDao.selectById(resiId); |
|
|
|
|
|
|
|
// 保存 transferRecord
|
|
|
|
IcUserTransferRecordEntity transferRecord = fillTransferRecord(resiInfo, operator, customerId, oldAgencyId, oldGridId, |
|
|
|
oldvillageId, oldBuildId, oldUnitId, oldHomeId, customerId, |
|
|
|
IcUserTransferRecordEntity transferRecord = fillTransferRecord(resiId, resiName, operator, customerId, |
|
|
|
oldAgencyId, oldGridId, oldvillageId, oldBuildId, oldUnitId, oldHomeId, customerId, |
|
|
|
newAgencyId, newGridId, newvillageId, newBuildId, newUnitId, newHomeId, oldOrg, newOrg); |
|
|
|
icUserTransferRecordDao.insert(transferRecord); |
|
|
|
|
|
|
|
// 保存 调动changeRecord
|
|
|
|
IcUserChangeRecordEntity transferChangeRecord = fillChangeRecord(customerId, resiId, resiInfo.getName(), transferRecord.getId(), operator.getStaffId(), |
|
|
|
IcUserChangeRecordEntity transferChangeRecord = fillChangeRecord(customerId, resiId, resiName, transferRecord.getId(), operator.getStaffId(), |
|
|
|
operator.getRealName(), sbBefore.toString(), sbAfter.toString(), "transfer", "调动", "", now); |
|
|
|
icUserChangeRecordDao.insert(transferChangeRecord); |
|
|
|
|
|
|
@ -1578,17 +1525,14 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
sbAfter = new StringBuilder(); |
|
|
|
|
|
|
|
// 过滤居民类别的key并集
|
|
|
|
Set<String> bingji = new HashSet<>(); |
|
|
|
newData.getCategories().keySet().forEach((k) -> bingji.add(k)); |
|
|
|
oldData.getCategories().keySet().forEach((k) -> bingji.add(k)); |
|
|
|
// Set<String> bingji = new HashSet<>();
|
|
|
|
// newData.getCategories().keySet().forEach((k) -> bingji.add(k));
|
|
|
|
// oldData.getCategories().keySet().forEach((k) -> bingji.add(k));
|
|
|
|
|
|
|
|
for (String category : bingji) { |
|
|
|
for (String category : newData.getCategories().keySet()) { |
|
|
|
String newColumnValue = newData.getCategories().get(category); |
|
|
|
String oldColumnValue = oldData.getCategories().get(category); |
|
|
|
|
|
|
|
if (oldColumnValue == null) oldColumnValue = "0"; |
|
|
|
if (newColumnValue == null) newColumnValue = "0"; |
|
|
|
|
|
|
|
if (newColumnValue.equals(oldColumnValue)) { |
|
|
|
continue; |
|
|
|
} |
|
|
@ -1606,7 +1550,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
String categoryDescAfter = sbAfter.toString(); |
|
|
|
|
|
|
|
if (!StringUtils.isAllBlank(categoryDescBefore, categoryDescAfter)) { |
|
|
|
IcUserChangeRecordEntity categoryChangeRecord = fillChangeRecord(customerId, resiId, resiInfo.getName(), transferRecord.getId(), operator.getStaffId(), |
|
|
|
IcUserChangeRecordEntity categoryChangeRecord = fillChangeRecord(customerId, resiId, resiName, transferRecord.getId(), operator.getStaffId(), |
|
|
|
operator.getRealName(), categoryDescBefore, categoryDescAfter , "category", "类别", "", now); |
|
|
|
icUserChangeRecordDao.insert(categoryChangeRecord); |
|
|
|
} |
|
|
@ -1619,9 +1563,9 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
// 之前是这个类型,那这个类型需要-1
|
|
|
|
String oldValue = oldCategories.getValue(); |
|
|
|
if ("1".equals(oldValue)) { |
|
|
|
IcUserChangeDetailedEntity changeDetail = fillChangeDetail(customerId, resiId, transferChangeRecord.getId(), oldData.getAgencyId(), |
|
|
|
oldData.getGridId(), oldData.getVillageId(), oldData.getBuildId(), oldData.getUnitId(), |
|
|
|
oldData.getHomeId(), transferChangeRecord.getType(), transferChangeRecord.getTypeName(), key, -1, resiInfo.getPids()); |
|
|
|
IcUserChangeDetailedEntity changeDetail = fillChangeDetail(customerId, resiId, transferChangeRecord.getId(), oldAgencyId, |
|
|
|
oldGridId, oldvillageId, oldBuildId, oldUnitId, |
|
|
|
oldHomeId, transferChangeRecord.getType(), transferChangeRecord.getTypeName(), key, -1, pids); |
|
|
|
icUserChangeDetailedDao.insert(changeDetail); |
|
|
|
} |
|
|
|
} |
|
|
@ -1633,9 +1577,9 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
|
|
|
|
// 现在是这个类型,这个类型要+1
|
|
|
|
if ("1".equals(newValue)) { |
|
|
|
IcUserChangeDetailedEntity changeDetail = fillChangeDetail(customerId, resiId, transferChangeRecord.getId(), newData.getAgencyId(), |
|
|
|
newData.getGridId(), newData.getVillageId(), newData.getBuildId(), newData.getUnitId(), |
|
|
|
newData.getHomeId(), transferChangeRecord.getType(), transferChangeRecord.getTypeName(), key, 1, resiInfo.getPids()); |
|
|
|
IcUserChangeDetailedEntity changeDetail = fillChangeDetail(customerId, resiId, transferChangeRecord.getId(), newAgencyId, |
|
|
|
newGridId, newvillageId, newBuildId, newUnitId, |
|
|
|
newHomeId, transferChangeRecord.getType(), transferChangeRecord.getTypeName(), key, 1, pids); |
|
|
|
icUserChangeDetailedDao.insert(changeDetail); |
|
|
|
} |
|
|
|
} |
|
|
@ -1648,18 +1592,43 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
* @param oldData |
|
|
|
* @param newData |
|
|
|
*/ |
|
|
|
private void fillResiSubCategoryInfo4TransferAndCategoryChange(ResiImportCategoryData oldData, ResiImportCategoryData newData) { |
|
|
|
for (String category : oldData.getCategories().keySet()) { |
|
|
|
String newValue = newData.getCategories().get(category); |
|
|
|
String oldValue = oldData.getCategories().get(category); |
|
|
|
|
|
|
|
// 如果新数据中没有或者是0,并且是附加表信息,并且旧数据是1, 拿旧数据的过来
|
|
|
|
if ((newValue == null || "0".equals(newValue)) |
|
|
|
&& "1".equals(oldValue) |
|
|
|
&& IcResiUserTableEnum.existsColumn(category)) { |
|
|
|
newData.getCategories().put(category, "1"); |
|
|
|
private void fillResiSubCategoryInfo4TransferAndCategoryChange(ResiImportCategoryData oldData, ResiImportCategoryData newData, Map<String, String> resiInfoMap) { |
|
|
|
|
|
|
|
Map<String, String> oldCates = oldData.getCategories(); |
|
|
|
Map<String, String> newCates = newData.getCategories(); |
|
|
|
|
|
|
|
for (IcResiUserTableEnum c : IcResiUserTableEnum.values()) { |
|
|
|
// 主表,跳过
|
|
|
|
String mainTableColumnName = c.getMainTableFlagColumnName(); |
|
|
|
if (mainTableColumnName == null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 不为空,说明本次导入含有该居民的类别信息,不需要补充
|
|
|
|
String oldValue = oldCates.get(mainTableColumnName); |
|
|
|
if (StringUtils.isNotBlank(oldValue)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 本次导入不含有该居民类别信息,db中存储的数据,如果是1,newValue和oldValue都应该为1
|
|
|
|
oldValue = resiInfoMap.get(mainTableColumnName); |
|
|
|
if ("1".equals(oldValue)) { |
|
|
|
oldCates.put(mainTableColumnName, oldValue); |
|
|
|
newCates.put(mainTableColumnName, oldValue); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// for (String category : oldData.getCategories().keySet()) {
|
|
|
|
// String newValue = newData.getCategories().get(category);
|
|
|
|
// String oldValue = oldData.getCategories().get(category);
|
|
|
|
//
|
|
|
|
// // 如果新数据中没有或者是0,并且是附加表信息,并且旧数据是1, 拿旧数据的过来
|
|
|
|
// if ((newValue == null || "0".equals(newValue))
|
|
|
|
// && "1".equals(oldValue)
|
|
|
|
// && IcResiUserTableEnum.existsColumn(category)) {
|
|
|
|
// newData.getCategories().put(category, "1");
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -1739,7 +1708,6 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
|
|
|
|
/** |
|
|
|
* 填充调动记录 |
|
|
|
* @param resiInfo |
|
|
|
* @param operator |
|
|
|
* @param oldCustomerId |
|
|
|
* @param oldAgencyId |
|
|
@ -1757,15 +1725,15 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res |
|
|
|
* @param newHomeId |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private IcUserTransferRecordEntity fillTransferRecord(IcResiUserEntity resiInfo, CustomerStaffInfoCacheResult operator, String oldCustomerId, String oldAgencyId, String oldGridId, |
|
|
|
private IcUserTransferRecordEntity fillTransferRecord(String resiId, String resiName, 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.setIcUserId(resiId); |
|
|
|
recordEntity.setOperatorId(operator.getStaffId()); |
|
|
|
recordEntity.setIcUserName(resiInfo.getName()); |
|
|
|
recordEntity.setIcUserName(resiName); |
|
|
|
recordEntity.setOperatorName(operator.getRealName()); |
|
|
|
recordEntity.setOldCustomerId(oldCustomerId); |
|
|
|
recordEntity.setOldAgencyId(oldAgencyId); |
|
|
|