Commit 0b70bd3f authored by fangxinjiang's avatar fangxinjiang

户截止日调整-fxj

parent a164cdbd
......@@ -186,14 +186,14 @@ public class THouseHoldLimitController {
}
/**
* 户截止日配置表 批量导入
* 户截止日配置表 批量导入 新增或更新
*
* @author fxj
* @date 2025-12-11 14:19:54
**/
@SneakyThrows
@Operation(description = "批量新增户截止日配置表")
@SysLog("批量新增户截止日配置表")
@Operation(description = "批量新增或更新户截止日配置表")
@SysLog("批量新增或更新户截止日配置表")
@PostMapping("/importListAdd")
public R<List<ErrorMessage>> importListAdd(@RequestBody MultipartFile file) {
YifuUser user = SecurityUtils.getUser();
......
......@@ -306,14 +306,9 @@ public class THouseHoldLimitServiceImpl extends ServiceImpl<THouseHoldLimitMappe
continue;
}
holdLimit = baseMapper.selectOne(Wrappers.<THouseHoldLimit>query().lambda()
.eq(THouseHoldLimit::getType,excel.getType())
.eq(THouseHoldLimit::getName,excel.getName())
.last(CommonConstants.LAST_ONE_SQL));
if (null != holdLimit){
errorMsg = new ErrorMessage(excel.getRowIndex(), "该户名及户类型已存在", excel);
errorMessageList.add(errorMsg);
continue;
}
.eq(THouseHoldLimit::getType,excel.getType())
.eq(THouseHoldLimit::getName,excel.getName())
.last(CommonConstants.LAST_ONE_SQL));
if (Common.isNotNull(excel.getDeadLineDay())){
if (!Common.isNumber(excel.getDeadLineDay())){
errorMsg = new ErrorMessage(excel.getRowIndex(), "派增截止(日)只能是数字", excel);
......@@ -347,17 +342,32 @@ public class THouseHoldLimitServiceImpl extends ServiceImpl<THouseHoldLimitMappe
limitInsert.setDeadLineDay(excel.getDeadLineDay());
limitInsert.setAddHandleRule(excel.getAddHandleRule());
limitInsert.setName(excel.getName());
limitInsert.setCreateBy(user.getId());
limitInsert.setUpdateBy(user.getId());
limitInsert.setCreateTime(LocalDateTime.now());
limitInsert.setUpdateTime(LocalDateTime.now());
limitInsert.setCreateName(user.getNickname());
limitInsert.setProvince(houseHold.getProvince());
limitInsert.setCity(houseHold.getCity());
limitInsert.setTown(houseHold.getTown());
// 从户配置中覆盖省市县信息(处理空值情况)
limitInsert.setProvince(Common.isEmpty(houseHold.getProvince()) ? "" : houseHold.getProvince());
limitInsert.setCity(Common.isEmpty(houseHold.getCity()) ? null : houseHold.getCity());
limitInsert.setTown(Common.isEmpty(houseHold.getTown()) ? null : houseHold.getTown());
map.put(excel.getName()+excel.getType(),excel.getRowIndex().toString());
// 插入
if (!insertExcel(limitInsert)){
// 判断是新增还是更新
boolean success;
if (null != holdLimit){
// 更新已有记录
limitInsert.setId(holdLimit.getId());
limitInsert.setCreateBy(holdLimit.getCreateBy());
limitInsert.setCreateTime(holdLimit.getCreateTime());
limitInsert.setCreateName(holdLimit.getCreateName());
limitInsert.setUpdateBy(user.getId());
limitInsert.setUpdateTime(LocalDateTime.now());
success = updateExcel(limitInsert);
} else {
// 新增记录
limitInsert.setCreateBy(user.getId());
limitInsert.setCreateTime(LocalDateTime.now());
limitInsert.setCreateName(user.getNickname());
success = insertExcel(limitInsert);
}
if (!success){
errorMsg = new ErrorMessage(excel.getRowIndex(), "导入异常", excel);
errorMessageList.add(errorMsg);
continue;
......@@ -373,6 +383,13 @@ public class THouseHoldLimitServiceImpl extends ServiceImpl<THouseHoldLimitMappe
return baseMapper.insert(insert) >= 1;
}
/**
* 更新excel record
*/
private boolean updateExcel(THouseHoldLimit update) {
return baseMapper.updateById(update) >= 1;
}
/**
* 通过户名称及类型查询到具体截止日期后去看是否为工作日,如果不是工作日则往前推,知道找到工作日,然后返回工作日
* 如果找不到对应截止日期,则返回null
......
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