fix: 一键累计添加日期与校验
This commit is contained in:
parent
815e37e50b
commit
63ee9c9b8e
|
|
@ -154,5 +154,5 @@ public interface AddUpDeductionService {
|
|||
* @return void
|
||||
* @author lfc
|
||||
*/
|
||||
void autoAddAll(Date yearMonth);
|
||||
String autoAddAll(Date yearMonth);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -639,7 +639,7 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
|
|||
}
|
||||
|
||||
@Override
|
||||
public void autoAddAll(Date yearMonth) {
|
||||
public String autoAddAll(Date yearMonth) {
|
||||
int uid = user.getUID();
|
||||
Boolean isChief = getTaxAgentService(user).isChief((long) uid);
|
||||
Collection<TaxAgentPO> taxAgents;
|
||||
|
|
@ -663,7 +663,9 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
|
|||
}
|
||||
List<AddUpDeduction> updateList = new ArrayList<>();
|
||||
List<AddUpDeduction> insertList = new ArrayList<>();
|
||||
List<String> errorMessages = new ArrayList<>();
|
||||
List<Long> errorMessages = new ArrayList<>();
|
||||
List<SalaryAcctEmployeePO> accountedEmployeeData =
|
||||
getAccountedEmployeeData(DateUtil.format(yearMonth, "yyyy-MM"));
|
||||
for (TaxAgentPO taxAgent : taxAgents) {
|
||||
Collection<Long> employeeIds = getTaxAgentService(user)
|
||||
.listEmployeeIdsInTaxAgent(taxAgent.getId());
|
||||
|
|
@ -682,6 +684,15 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
|
|||
|
||||
employeePOs.forEach(employeePO -> {
|
||||
Long employeeId = employeePO.getEmployeeId();
|
||||
// 如果该员工当前月份已经核算,不做累计
|
||||
SalaryAcctEmployeePO anyAccountedEmployee = accountedEmployeeData.stream()
|
||||
.filter(e -> e.getEmployeeId().equals(employeeId))
|
||||
.filter(e -> e.getTaxAgentId().equals(taxAgent.getId()))
|
||||
.findAny().orElse(null);
|
||||
if (anyAccountedEmployee != null) {
|
||||
errorMessages.add(employeeId);
|
||||
return;
|
||||
}
|
||||
AddUpDeduction addUpDeduction = Optional.ofNullable(lastEmpInfo.get(employeeId))
|
||||
.flatMap(list -> list.stream().findFirst())
|
||||
.orElseGet(AddUpDeduction::new);
|
||||
|
|
@ -713,6 +724,15 @@ public class AddUpDeductionServiceImpl extends Service implements AddUpDeduction
|
|||
.forEach(l -> getAddUpDeductionMapper().insertData((List<AddUpDeduction>) l));
|
||||
Lists.partition(updateList, 100)
|
||||
.forEach(l -> getAddUpDeductionMapper().updateDataAndDeclareMonth((List<AddUpDeduction>) l));
|
||||
if (!errorMessages.isEmpty()) {
|
||||
String userNames = getSalaryEmployeeService(user)
|
||||
.listByIds(errorMessages)
|
||||
.stream()
|
||||
.map(DataCollectionEmployee::getUsername)
|
||||
.collect(Collectors.joining(","));
|
||||
return "一键累计完成!员工" + userNames + "在该年月已核算归档,跳过本次累计";
|
||||
}
|
||||
return "一键累计完成!";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -354,12 +354,13 @@ public class AddUpDeductionController {
|
|||
try {
|
||||
date = DateUtil.parse(param.getYearMonth(), "yyyy-MM");
|
||||
} catch (Exception e) {
|
||||
//ignore 放在service中处理,这里处理了页面上收不到
|
||||
//ignore
|
||||
// 放在service中处理,这里处理了页面上收不到
|
||||
}
|
||||
} else {
|
||||
date = DateUtil.beginOfMonth(new Date());
|
||||
}
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return new ResponseResult<Date, Void>(user).run(getAddUpDeductionWrapper(user)::autoAddAll, date);
|
||||
return new ResponseResult<Date, String>(user).run(getAddUpDeductionWrapper(user)::autoAddAll, date);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,13 +170,13 @@ public class AddUpDeductionWrapper extends Service {
|
|||
return getAddUpDeductionService(user).getAddUpDeduction(param);
|
||||
}
|
||||
|
||||
public void autoAddAll(Date yearMonth) {
|
||||
public String autoAddAll(Date yearMonth) {
|
||||
if (isLog) {
|
||||
log.info("一键累计, 操作人 「{}」", user.getUsername());
|
||||
}
|
||||
if (yearMonth == null) {
|
||||
throw new SalaryRunTimeException("一键累计传入日期格式错误");
|
||||
}
|
||||
getAddUpDeductionService(user).autoAddAll(yearMonth);
|
||||
return getAddUpDeductionService(user).autoAddAll(yearMonth);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue