扣缴义务人和账套的人员范围支持编辑
This commit is contained in:
parent
d21258596a
commit
ad48063ca9
|
|
@ -1,5 +1,9 @@
|
|||
select id from hrsa_tax_agent_emp
|
||||
where tax_agent_id =扣缴义务人id and delete_type = 0 and employee_id not in (select employee_id from hrsa_salary_archive where tax_agent_id =扣缴义务人id and delete_type = 0)
|
||||
where tax_agent_id =扣缴义务人id
|
||||
and delete_type = 0
|
||||
and employee_id not in
|
||||
(select employee_id from hrsa_salary_archive
|
||||
where tax_agent_id =扣缴义务人id and delete_type = 0)
|
||||
|
||||
|
||||
update hrsa_tax_agent_emp set delete_type = 3
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.engine.hrmelog.annotation.ElogTransform;
|
|||
import com.engine.salary.enums.salarysob.SalaryEmployeeStatusEnum;
|
||||
import com.engine.salary.enums.salarysob.TargetTypeEnum;
|
||||
import com.engine.salary.util.valid.DataCheck;
|
||||
import com.engine.salary.util.valid.RuntimeTypeEnum;
|
||||
import com.engine.salary.util.valid.ValidTypeEnum;
|
||||
import lombok.Data;
|
||||
|
||||
|
|
@ -22,6 +23,9 @@ import java.util.List;
|
|||
//薪资账套人员范围保存参数")
|
||||
public class SalarySobRangeSaveParam {
|
||||
|
||||
@DataCheck(require = true, message = "ID不允许为空",runtime = {RuntimeTypeEnum.UPDATE})
|
||||
private Long id;
|
||||
|
||||
//薪资账套的id
|
||||
@DataCheck(require = true, message = "薪资账套的ID不允许为空")
|
||||
@ElogTransform( name = "薪资账套id" )
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ import java.util.List;
|
|||
@Data
|
||||
public class TaxAgentManageRangeSaveParam {
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 只能选择 关联人员范围/从范围中排除
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ public interface SalarySobRangeService {
|
|||
* @param saveParam 保存参数
|
||||
*/
|
||||
void save(SalarySobRangeSaveParam saveParam);
|
||||
void edit(SalarySobRangeSaveParam param);
|
||||
|
||||
/**
|
||||
* 根据主键id删除薪资账套的人员范围
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public interface TaxAgentManageRangeService {
|
|||
* @param saveParam 保存参数
|
||||
*/
|
||||
void save(TaxAgentRangeSaveParam saveParam);
|
||||
|
||||
void edit(TaxAgentRangeSaveParam param);
|
||||
|
||||
/**
|
||||
* 根据主键id删除管理范围
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@ import com.api.formmode.mybatis.util.SqlProxyHandle;
|
|||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.hrm.biz.OrganizationShowSetBiz;
|
||||
import com.engine.hrmelog.entity.dto.LoggerContext;
|
||||
import com.engine.salary.biz.SalarySobRangeBiz;
|
||||
import com.engine.salary.biz.SpecialAddDeductionBiz;
|
||||
import com.engine.salary.config.SalaryElogConfig;
|
||||
import com.engine.hrmelog.entity.dto.LoggerContext;
|
||||
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
|
||||
import com.engine.salary.entity.hrm.DeptInfo;
|
||||
import com.engine.salary.entity.hrm.PositionInfo;
|
||||
|
|
@ -41,6 +41,7 @@ import com.engine.salary.util.excel.ExcelParseHelper;
|
|||
import com.engine.salary.util.excel.ExcelUtil;
|
||||
import com.engine.salary.util.page.PageInfo;
|
||||
import com.engine.salary.util.page.SalaryPageUtil;
|
||||
import com.engine.salary.util.valid.RuntimeTypeEnum;
|
||||
import com.engine.salary.util.valid.ValidUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
|
@ -198,6 +199,43 @@ public class SalarySobRangeServiceImpl extends Service implements SalarySobRange
|
|||
SalaryElogConfig.salarySobLoggerTemplate.write(loggerContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void edit(SalarySobRangeSaveParam param) {
|
||||
ValidUtil.doValidator(param, RuntimeTypeEnum.UPDATE);
|
||||
|
||||
// 查询薪资账套
|
||||
SalarySobPO salarySobPO = getSalarySobService(user).getById(param.getSalarySobId());
|
||||
if (Objects.isNull(salarySobPO)) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除"));
|
||||
}
|
||||
|
||||
deleteByIds(Collections.singleton(param.getId()));
|
||||
|
||||
// 查询已有的人员范围
|
||||
List<SalarySobRangePO> salarySobRangePOS = listBySalarySobIdAndIncludeType(param.getSalarySobId(), param.getIncludeType());
|
||||
// 处理一下本次的保存参数(如果原来添加过对应的人员(/部门/岗位),那么本次不需要新增,只需要更新)
|
||||
SalarySobRangeSaveBO.Result result = SalarySobRangeSaveBO.handle(salarySobRangePOS, param, (long) user.getUID(), false);
|
||||
// 保存
|
||||
if (CollectionUtils.isNotEmpty(result.getNeedInsertSalarySobRanges())) {
|
||||
salarySobRangeBiz.batchInsert(result.getNeedInsertSalarySobRanges());
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(result.getNeedUpdateSalarySobRanges())) {
|
||||
result.getNeedUpdateSalarySobRanges().forEach(e -> salarySobRangeBiz.updateById(e));
|
||||
}
|
||||
//记录日志
|
||||
String operateTypeName = Objects.equals(param.getIncludeType(), 1) ?
|
||||
SalaryI18nUtil.getI18nLabel(0, "关联人员范围新增对象") : SalaryI18nUtil.getI18nLabel(0, "从范围中排除新增对象");
|
||||
LoggerContext<SalarySobRangeSaveParam> loggerContext = new LoggerContext<>();
|
||||
loggerContext.setUser(user);
|
||||
loggerContext.setTargetId("" + salarySobPO.getId());
|
||||
loggerContext.setTargetName(salarySobPO.getName());
|
||||
loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue());
|
||||
loggerContext.setOperateTypeName(operateTypeName);
|
||||
loggerContext.setOperatedesc(operateTypeName);
|
||||
loggerContext.setNewValues(param);
|
||||
SalaryElogConfig.salarySobLoggerTemplate.write(loggerContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByIds(Collection<Long> ids) {
|
||||
// 查询薪资账套的人员范围
|
||||
|
|
|
|||
|
|
@ -338,39 +338,7 @@ 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.getTargetType() == TargetTypeEnum.SQL) {
|
||||
if (target.getTarget() == null) {
|
||||
throw new SalaryRunTimeException("sql不能为空");
|
||||
}
|
||||
target.setTargetId(0L);
|
||||
} else {
|
||||
if (target.getTargetId() == null) {
|
||||
throw new SalaryRunTimeException("对象不能为空");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
checkParam(saveParam);
|
||||
|
||||
// 查询个税扣缴义务人
|
||||
TaxAgentPO taxAgent = getTaxAgentService(user).getById(saveParam.getTaxAgentId());
|
||||
|
|
@ -427,6 +395,108 @@ public class TaxAgentManageRangeServiceImpl extends Service implements TaxAgentM
|
|||
|
||||
}
|
||||
|
||||
private void checkParam(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.getTargetType() == TargetTypeEnum.SQL) {
|
||||
if (target.getTarget() == null) {
|
||||
throw new SalaryRunTimeException("sql不能为空");
|
||||
}
|
||||
target.setTargetId(0L);
|
||||
} else {
|
||||
if (target.getTargetId() == null) {
|
||||
throw new SalaryRunTimeException("对象不能为空");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void edit(TaxAgentRangeSaveParam param) {
|
||||
checkParam(param);
|
||||
|
||||
if (param.getId() == null) {
|
||||
throw new SalaryRunTimeException("id不能为空");
|
||||
}
|
||||
|
||||
// 查询个税扣缴义务人
|
||||
TaxAgentPO taxAgent = getTaxAgentService(user).getById(param.getTaxAgentId());
|
||||
if (Objects.isNull(taxAgent)) {
|
||||
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(108605, "参数错误,个税扣缴义务人不存在或不在权限范围内"));
|
||||
}
|
||||
|
||||
//删除原有的管理范围
|
||||
getTaxAgentManageRangeMapper().deleteByIds(Collections.singleton(param.getId()));
|
||||
|
||||
// 查询已有的管理范围
|
||||
List<TaxAgentManageRangePO> taxAgentManageAllRanges = listByTaxAgentId(param.getTaxAgentId());
|
||||
|
||||
List<TaxAgentManageRangePO> taxAgentManageRanges = taxAgentManageAllRanges.stream().filter(f -> f.getIncludeType().equals(param.getIncludeType())).collect(Collectors.toList());
|
||||
List<TaxAgentManageRangePO> oldManageList = new ArrayList<>();
|
||||
taxAgentManageRanges.stream().forEach(p -> {
|
||||
TaxAgentManageRangePO target = new TaxAgentManageRangePO();
|
||||
BeanUtils.copyProperties(p, target);
|
||||
oldManageList.add(target);
|
||||
});
|
||||
// 处理一下本次的保存参数(如果原来添加过对应的人员(/部门/岗位),那么本次不需要新增,只需要更新)
|
||||
TaxAgentBO.Result result = TaxAgentBO.handleTaxAgentRange(taxAgentManageRanges, param, taxAgent.getId(), (long) user.getUID(), false);
|
||||
|
||||
/* 检查当前个税扣缴义务人的所有人员范围与所有分管理员的管理范围===========================start */
|
||||
List<TaxAgentManageRangePO> allRanges = Lists.newArrayList(taxAgentManageAllRanges);
|
||||
allRanges.addAll(result.getNeedInsertTaxAgentManageRanges());
|
||||
allRanges.addAll(result.getNeedUpdateTaxAgentManageRanges());
|
||||
// 去重
|
||||
allRanges = allRanges.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getTaxAgentId() + "." + f.getRangeType() + "." + f.getTargetType() + "." + f.getTargetId() + "." + f.getEmployeeStatus() + "." + f.getIncludeType()))), ArrayList::new));
|
||||
|
||||
List<DataCollectionEmployee> salaryEmployees = getSalaryEmployeeService().listAll(UseEmployeeTypeEnum.ALL);
|
||||
List<DataCollectionEmployee> allSalaryEmployees = this.getManageRangeSalaryEmployees(param.getTaxAgentId(), allRanges, salaryEmployees);
|
||||
|
||||
/* 检查当前个税扣缴义务人的所有人员范围与所有分管理员的管理范围===========================end */
|
||||
if (CollectionUtils.isNotEmpty(result.getNeedInsertTaxAgentManageRanges())) {
|
||||
result.getNeedInsertTaxAgentManageRanges().forEach(range -> {
|
||||
getTaxAgentManageRangeMapper().insertIgnoreNull(range);
|
||||
// 记录操作日志
|
||||
String name = taxAgent.getName() + "_" + TargetTypeEnum.parseByValue(range.getTargetType()).getDefaultLabel() + "_" + range.getTargetId();
|
||||
SalaryLoggerUtil.recordAddSingleLog(SalaryElogConfig.taxAgentLoggerTemplate, range.getTaxAgentId(), name, SalaryI18nUtil.getI18nLabel(0, "新增人员范围"), SalaryI18nUtil.getI18nLabel(0, "新增人员范围") + name, range, user);
|
||||
});
|
||||
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(result.getNeedUpdateTaxAgentManageRanges())) {
|
||||
Map<Long, TaxAgentManageRangePO> oldMap = SalaryEntityUtil.convert2Map(oldManageList, TaxAgentManageRangePO::getId);
|
||||
result.getNeedUpdateTaxAgentManageRanges().forEach(range -> {
|
||||
getTaxAgentManageRangeMapper().updateIgnoreNull(range);
|
||||
// 记录操作日志
|
||||
TaxAgentManageRangePO oldPO = oldMap.getOrDefault(range.getId(), TaxAgentManageRangePO.builder().build());
|
||||
String name = taxAgent.getName() + "_" + TargetTypeEnum.parseByValue(range.getTargetType()).getDefaultLabel() + "_" + range.getTargetId();
|
||||
SalaryLoggerUtil.recordUpdateSingleLog(SalaryElogConfig.taxAgentLoggerTemplate, range.getTaxAgentId(), name, SalaryI18nUtil.getI18nLabel(0, "更新人员范围"), SalaryI18nUtil.getI18nLabel(0, "更新人员范围") + name, oldPO, range, user);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/* 同步本地人员范围的关联人员=========================== */
|
||||
syncLocalEmp(param.getTaxAgentId(), allSalaryEmployees, param.isSync());
|
||||
}
|
||||
|
||||
private void syncLocalEmp(Long taxAgentId, List<DataCollectionEmployee> allSalaryEmployees, boolean isSync) {
|
||||
if (isSync) {
|
||||
syncLocalEmpRange(taxAgentId, allSalaryEmployees, (long) user.getUID());
|
||||
|
|
|
|||
|
|
@ -248,6 +248,17 @@ public class SalarySobController {
|
|||
return new ResponseResult<SalarySobRangeSaveParam, String>(user).run(getSalarySobRangeWrapper(user)::save, saveParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存薪资账套人员范围
|
||||
*/
|
||||
@POST
|
||||
@Path("/range/edit")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String editSalarySobRange(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalarySobRangeSaveParam saveParam) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return new ResponseResult<SalarySobRangeSaveParam, String>(user).run(getSalarySobRangeWrapper(user)::edit, saveParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除薪资账套人员范围
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -255,6 +255,14 @@ public class TaxAgentController {
|
|||
return new ResponseResult<TaxAgentRangeSaveParam, String>(user).run(getTaxAgentWrapper(user)::saveRange, saveParam);
|
||||
}
|
||||
|
||||
//保存人员范围
|
||||
@POST
|
||||
@Path("/range/edit")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String editRange(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody TaxAgentRangeSaveParam param) {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return new ResponseResult<TaxAgentRangeSaveParam, String>(user).run(getTaxAgentWrapper(user)::editRange, param);
|
||||
}
|
||||
|
||||
|
||||
//删除人员范围
|
||||
|
|
|
|||
|
|
@ -104,6 +104,36 @@ public class SalarySobRangeWrapper extends Service {
|
|||
getSalarySobRangeService(user).save(saveParam);
|
||||
}
|
||||
|
||||
|
||||
public void edit(SalarySobRangeSaveParam param) {
|
||||
Optional.ofNullable(param.getTargetParams()).orElse(new ArrayList<>())
|
||||
.forEach(targetParam -> {
|
||||
if (StrUtil.isNotBlank(targetParam.getTarget())) {
|
||||
targetParam.setTarget(targetParam.getTarget()
|
||||
.replace("select", "select")
|
||||
.replace("SELECT", "SELECT")
|
||||
.replace("join", "join")
|
||||
.replace("JOIN", "JOIN")
|
||||
.replace("and", "and")
|
||||
.replace("AND", "AND")
|
||||
.replace("or", "or")
|
||||
.replace("OR", "OR")
|
||||
.replace("in", "in")
|
||||
.replace("IN", "IN")
|
||||
.replace("like", "like")
|
||||
.replace("LIKE", "LIKE")
|
||||
.replace("exists", "exists")
|
||||
.replace("EXISTS", "EXISTS")
|
||||
.replace("between", "between")
|
||||
.replace("BETWEEN", "BETWEEN")
|
||||
.replace("union", "union")
|
||||
.replace("UNION", "UNION"));
|
||||
}
|
||||
});
|
||||
|
||||
getSalarySobRangeService(user).edit(param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
|
|
|
|||
|
|
@ -375,6 +375,40 @@ public class TaxAgentWrapper extends Service {
|
|||
}
|
||||
|
||||
|
||||
public String editRange(TaxAgentRangeSaveParam param) {
|
||||
//将select因XSS过滤造成的异常字符转换回来
|
||||
|
||||
Optional.ofNullable(param.getTargetParams()).orElse(new ArrayList<>())
|
||||
.forEach(targetParam -> {
|
||||
if (StrUtil.isNotBlank(targetParam.getTarget())) {
|
||||
targetParam.setTarget(targetParam.getTarget()
|
||||
.replace("select", "select")
|
||||
.replace("SELECT", "SELECT")
|
||||
.replace("join", "join")
|
||||
.replace("JOIN", "JOIN")
|
||||
.replace("and", "and")
|
||||
.replace("AND", "AND")
|
||||
.replace("or", "or")
|
||||
.replace("OR", "OR")
|
||||
.replace("in", "in")
|
||||
.replace("IN", "IN")
|
||||
.replace("like", "like")
|
||||
.replace("LIKE", "LIKE")
|
||||
.replace("exists", "exists")
|
||||
.replace("EXISTS", "EXISTS")
|
||||
.replace("between", "between")
|
||||
.replace("BETWEEN", "BETWEEN")
|
||||
.replace("union", "union")
|
||||
.replace("UNION", "UNION"));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
getTaxAgentManageRangeService(user).edit(param);
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除管理范围
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue