人员范围保存校验

This commit is contained in:
钱涛 2022-06-10 14:21:21 +08:00
parent 382620c589
commit d09856c390
2 changed files with 39 additions and 78 deletions

View File

@ -1 +1,9 @@
ALTER TABLE hrsa_tax_declaration ADD COLUMN income_category int(255) NOT NULL COMMENT '薪资类型。1正常工资薪金所得、4劳务所得' ;
ALTER TABLE hrsa_tax_declaration ADD COLUMN income_category int(255) NOT NULL COMMENT '薪资类型。1正常工资薪金所得、4劳务所得' ;
ALTER TABLE hrsa_tax_declaration_detail ADD COLUMN employee_type int(255) NOT NULL ;
ALTER TABLE hrsa_tax_declaration ADD income_category int NULL
GO
ALTER TABLE hrsa_tax_declaration_detail ADD employee_type int NULL
GO

View File

@ -332,6 +332,35 @@ public class TaxAgentManageRangeServiceImpl extends Service implements TaxAgentM
*/
@Override
public void save(TaxAgentRangeSaveParam saveParam) {
if (saveParam == null) {
throw new SalaryRunTimeException("参数错误");
}
if (Objects.isNull(saveParam.getTaxAgentId())) {
throw new SalaryRunTimeException("个税扣缴义务人的id不允许为空");
}
if (saveParam.getIncludeType() != 0 && saveParam.getIncludeType() != 1) {
throw new SalaryRunTimeException("只能选择 关联人员范围/从范围中排除");
}
if (CollectionUtils.isEmpty(saveParam.getEmployeeStatus())) {
throw new SalaryRunTimeException("员工状态不允许为空");
}
if (CollectionUtils.isNotEmpty(saveParam.getTargetParams())) {
saveParam.getTargetParams().forEach(target -> {
if (target.getTargetType() == null) {
throw new SalaryRunTimeException("对象类型不能为空");
}
if (target.getTargetId() == null) {
throw new SalaryRunTimeException("对象不能为空");
}
});
}
// 查询薪资账套
TaxAgentPO taxAgent = getTaxAgentV2Service(user).getById(saveParam.getTaxAgentId());
if (Objects.isNull(taxAgent)) {
@ -387,11 +416,7 @@ public class TaxAgentManageRangeServiceImpl extends Service implements TaxAgentM
taskExecutor.execute(() -> {
syncLocalEmp(taxAgentId, allSalaryEmployees, allSubAdminRanges, (long) user.getUID());
});
// new Thread() {
// public void run() {
// syncLocalEmp(taxAgentId, allSalaryEmployees, allSubAdminRanges, (long) user.getUID());
// }
// }.start();
}
/**
@ -408,78 +433,6 @@ public class TaxAgentManageRangeServiceImpl extends Service implements TaxAgentM
return getTaxAgentManageRangeMapper().listSome(TaxAgentManageRangePO.builder().taxAgentId(taxAgentId).rangeType(TaxAgentRangeTypeEnum.SUBADMIN.getValue()).build());
}
// @Override
// @Transactional(rollbackFor = Exception.class)
// public void save4SubAdmin(TaxAgentSubAdminRangeSaveParam saveParam) {
// // 查询薪资账套
// TaxAgentSubAdminPO taxAgentSubAdmin = taxAgentSubAdminService.getById(saveParam.getSubAdminId());
// if (Objects.isNull(taxAgentSubAdmin)) {
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(106687, "参数错误,分管理员不存在或者已被删除"));
// }
// // 查询已有的管理范围
// List<TaxAgentManageRangePO> taxAgentManageAllRanges = listBySubAdminId(saveParam.getSubAdminId());
// List<TaxAgentManageRangePO> taxAgentManageRanges = taxAgentManageAllRanges.stream().filter(f -> f.getIncludeType().equals(saveParam.getIncludeType())).collect(Collectors.toList());
// // 处理一下本次的保存参数如果原来添加过对应的人员/部门/岗位那么本次不需要新增只需要更新
// TaxAgentBO.Result result = TaxAgentBO.handleSubAdminRange(taxAgentManageRanges, saveParam, taxAgentSubAdmin.getTaxAgentId(), taxAgentSubAdmin.getId(), (long) user.getUID());
//
// // 当前库中所有分管理员的管理范围
// List<TaxAgentManageRangePO> allSubAdminRangesExist = listSunAdminRangeByTaxAgentId(taxAgentSubAdmin.getTaxAgentId());
// /** 检查当前分管理员的范围与其他分管理员人员范围===========================start */
// // 当前分管理员的范围
// List<TaxAgentManageRangePO> allSubAdminRangesCuttent = Lists.newArrayList(taxAgentManageAllRanges);
// // 其他分管理员的范围
// List<TaxAgentManageRangePO> otherSubAdminRangesExist = allSubAdminRangesExist.stream().filter(f -> !f.getTaxAgentSubAdminId().equals(saveParam.getSubAdminId())).collect(Collectors.toList());
// allSubAdminRangesCuttent.addAll(result.getNeedInsertTaxAgentManageRanges());
// allSubAdminRangesCuttent.addAll(result.getNeedUpdateTaxAgentManageRanges());
//
// // 当前分管理员的所有人员
// List<DataCollectionEmployee> currentSubAdminSalaryEmployees = this.getManageRangeSalaryEmployees(null, taxAgentSubAdmin.getTaxAgentId(), allSubAdminRangesCuttent);
// // 其他分管理员的所有人员
// List<DataCollectionEmployee> otherSubAdminSalaryEmployees = this.getManageRangeSalaryEmployees(null, taxAgentSubAdmin.getTaxAgentId(), otherSubAdminRangesExist);
// for (DataCollectionEmployee se : currentSubAdminSalaryEmployees) {
// Optional<DataCollectionEmployee> optionalSe = otherSubAdminSalaryEmployees.stream().filter(f -> f.getEmployeeId().equals(se.getEmployeeId())).findFirst();
// if (optionalSe.isPresent()) {
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(110149, "不可包含其他分管理员的人员"));
// }
// }
// /** 检查当前分管理员的范围与其他分管理员人员范围===========================end */
//
// /** 检查当前分管理员的范围与所属个税扣缴义务人的人员范围===========================start */
// // 所属个税扣缴义务人的所有分管理员的管理范围
// List<TaxAgentManageRangePO> allSubAdminRanges = Lists.newArrayList(allSubAdminRangesExist);
// allSubAdminRanges.addAll(result.getNeedInsertTaxAgentManageRanges());
// allSubAdminRanges.addAll(result.getNeedUpdateTaxAgentManageRanges());
// // 去重
// allSubAdminRanges = allSubAdminRanges.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(
// Comparator.comparing(f -> f.getTaxAgentSubAdminId() + "." + f.getRangeType() + "." + f.getTargetType() + "." + f.getTargetId() + "." + f.getEmployeeStatus() + "." + f.getIncludeType()))
// ), ArrayList::new));
// // 所属个税扣缴义务人的所有人员
// List<TaxAgentManageRangePO> allRanges = listByTaxAgentId(taxAgentSubAdmin.getTaxAgentId());
// List<DataCollectionEmployee> allSalaryEmployees = this.getManageRangeSalaryEmployees(null, taxAgentSubAdmin.getTaxAgentId(), allRanges);
// // 所有分管理员的所有人员
// List<DataCollectionEmployee> allSubAdminSalaryEmployees = this.getManageRangeSalaryEmployees(null, taxAgentSubAdmin.getTaxAgentId(), allSubAdminRanges);
// List<Long> allSalaryEmployeeIds = allSalaryEmployees.stream().map(DataCollectionEmployee::getEmployeeId).collect(Collectors.toList());
// allSubAdminSalaryEmployees.removeIf(a -> allSalaryEmployeeIds.contains(a.getEmployeeId()));
// if (CollectionUtils.isNotEmpty(allSubAdminSalaryEmployees)) {
// throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(110125, "超出了整体人员范围"));
// }
// /** 检查当前分管理员的范围与所属个税扣缴义务人的人员范围===========================end */
//
// // 保存
// if (CollectionUtils.isNotEmpty(result.getNeedInsertTaxAgentManageRanges())) {
// result.getNeedInsertTaxAgentManageRanges().forEach(range -> getTaxAgentManageRangeMapper().insertIgnoreNull(range));
//// todo this.saveBatch(result.getNeedInsertTaxAgentManageRanges());
// }
// if (CollectionUtils.isNotEmpty(result.getNeedUpdateTaxAgentManageRanges())) {
// result.getNeedUpdateTaxAgentManageRanges().forEach(range -> getTaxAgentManageRangeMapper().updateIgnoreNull(range));
//// todo this.updateBatchById(result.getNeedUpdateTaxAgentManageRanges());
// }
// /** 同步本地人员范围的关联人员=========================== */
// List<TaxAgentManageRangePO> finalAllSubAdminRanges = allSubAdminRanges;
//
// syncLocalEmp(taxAgentSubAdmin.getTaxAgentId(), allSalaryEmployees, allSubAdminRanges);
// // 记录日志 todo
// }
/**