Commit 5fd3e7cb authored by fangxinjiang's avatar fangxinjiang

户及户基数调整-fxj

parent dc47c17b
......@@ -819,4 +819,18 @@ public class Common {
// 支持三种格式:2025-11、2025/11、202511
return str.matches("\\d{4}[-/]\\d{1,2}") || str.matches("\\d{6}");
}
/**
* 安全解析字符串为Integer,处理可能的转换异常
*/
public static Integer parseInteger(String value) {
if (Common.isEmpty(value)) {
return null;
}
try {
return Integer.valueOf(value);
} catch (NumberFormatException e) {
return null;
}
}
}
......@@ -1432,29 +1432,40 @@ public class SysBaseSetInfoServiceImpl extends ServiceImpl<SysBaseSetInfoMapper,
if (Common.isEmpty(sysBaseSetInfos)){
return;
}
// 转换参数为Integer类型,处理可能的转换异常
Integer provinceInt = Common.parseInteger(province);
Integer cityInt = Common.parseInteger(city);
Integer townInt = Common.parseInteger(town);
LambdaUpdateWrapper<SysBaseSetInfo> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(SysBaseSetInfo::getDepartName,name)
.eq(SysBaseSetInfo::getBaseType,type)
.set(SysBaseSetInfo::getTown,Common.isEmpty(town)?null:Integer.valueOf(town))
.set(SysBaseSetInfo::getCity,Common.isEmpty(city)?null:Integer.valueOf(city))
.set(SysBaseSetInfo::getProvince,Common.isEmpty(province)?null:Integer.valueOf(province));
.set(SysBaseSetInfo::getTown, townInt)
.set(SysBaseSetInfo::getCity, cityInt)
.set(SysBaseSetInfo::getProvince, provinceInt);
this.update(updateWrapper);
//添加日志
SysBaseSetInfo old = null;
int logType = CommonConstants.ONE_INT;
if (CommonConstants.ONE_STRING.equals(type)) {
logType = CommonConstants.TWO_INT;
}
// 创建旧数据副本用于日志记录
SysBaseSetInfo old = null;
for (SysBaseSetInfo sysBaseSetInfo : sysBaseSetInfos){
// 创建旧数据副本用于日志记录
old = new SysBaseSetInfo();
BeanUtil.copyProperties(sysBaseSetInfo,old);
old.setTown(Common.isEmpty(old.getTown())?null:Integer.valueOf(old.getTown()));
old.setCity(Common.isEmpty(old.getCity())?null:Integer.valueOf(old.getCity()));
old.setProvince(Common.isEmpty(old.getProvince())?null:Integer.valueOf(old.getProvince()));
sysBaseSetInfo.setProvince(Common.isEmpty(province) ?null:Integer.valueOf(province));
sysBaseSetInfo.setCity(Common.isEmpty(city)?null:Integer.valueOf(city));
sysBaseSetInfo.setTown(Common.isEmpty(town)?null:Integer.valueOf(town));
// 转换旧数据中的区域码为Integer类型
old.setTown(Common.parseInteger(String.valueOf(old.getTown())));
old.setCity(Common.parseInteger(String.valueOf(old.getCity())));
old.setProvince(Common.parseInteger(String.valueOf(old.getProvince())));
// 设置新值到原对象用于日志记录
sysBaseSetInfo.setProvince(provinceInt);
sysBaseSetInfo.setCity(cityInt);
sysBaseSetInfo.setTown(townInt);
tSocialLogService.saveModificationRecord(logType,old.getId(),old,sysBaseSetInfo);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment