2022-03-22 21:01:38 +08:00
|
|
|
|
package com.engine.salary.service.impl;
|
|
|
|
|
|
|
2022-03-25 18:05:07 +08:00
|
|
|
|
import com.engine.common.util.ServiceUtil;
|
2022-03-22 21:01:38 +08:00
|
|
|
|
import com.engine.core.impl.Service;
|
2022-03-25 18:05:07 +08:00
|
|
|
|
import com.engine.salary.biz.*;
|
|
|
|
|
|
import com.engine.salary.constant.SalaryDefaultTenantConstant;
|
2022-05-05 11:19:13 +08:00
|
|
|
|
import com.engine.salary.entity.salaryacct.po.SalaryAcctRecordPO;
|
2022-03-25 18:05:07 +08:00
|
|
|
|
import com.engine.salary.entity.salaryitem.bo.SysSalaryItemBO;
|
|
|
|
|
|
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
|
|
|
|
|
|
import com.engine.salary.entity.salaryitem.po.SysSalaryItemPO;
|
2022-11-16 10:32:05 +08:00
|
|
|
|
import com.engine.salary.entity.salarysob.bo.*;
|
2022-03-22 21:01:38 +08:00
|
|
|
|
import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO;
|
|
|
|
|
|
import com.engine.salary.entity.salarysob.param.SalarySobBasicSaveParam;
|
|
|
|
|
|
import com.engine.salary.entity.salarysob.param.SalarySobDisableParam;
|
|
|
|
|
|
import com.engine.salary.entity.salarysob.param.SalarySobDuplicateParam;
|
2022-05-31 16:41:11 +08:00
|
|
|
|
import com.engine.salary.entity.salarysob.param.SalarySobListQueryParam;
|
2022-03-25 18:05:07 +08:00
|
|
|
|
import com.engine.salary.entity.salarysob.po.*;
|
2022-10-09 17:51:30 +08:00
|
|
|
|
import com.engine.salary.entity.taxagent.dto.TaxAgentManageRangeListDTO;
|
|
|
|
|
|
import com.engine.salary.entity.taxagent.param.TaxAgentRangeQueryParam;
|
2022-05-31 16:41:11 +08:00
|
|
|
|
import com.engine.salary.entity.taxagent.po.TaxAgentAdminPO;
|
|
|
|
|
|
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
|
2022-03-25 18:05:07 +08:00
|
|
|
|
import com.engine.salary.enums.SalarySystemTypeEnum;
|
2022-03-22 21:01:38 +08:00
|
|
|
|
import com.engine.salary.enums.salarysob.IncomeCategoryEnum;
|
2022-10-09 17:51:30 +08:00
|
|
|
|
import com.engine.salary.enums.salarysob.SalaryEmployeeStatusEnum;
|
2022-03-22 21:01:38 +08:00
|
|
|
|
import com.engine.salary.exception.SalaryRunTimeException;
|
2022-11-22 14:36:59 +08:00
|
|
|
|
import com.engine.salary.mapper.salarysob.SalarySobBackItemMapper;
|
2022-06-20 19:39:01 +08:00
|
|
|
|
import com.engine.salary.mapper.salarysob.SalarySobMapper;
|
2022-05-05 11:19:13 +08:00
|
|
|
|
import com.engine.salary.service.*;
|
2022-03-22 21:01:38 +08:00
|
|
|
|
import com.engine.salary.util.SalaryEntityUtil;
|
|
|
|
|
|
import com.engine.salary.util.SalaryI18nUtil;
|
2022-06-20 19:39:01 +08:00
|
|
|
|
import com.engine.salary.util.db.MapperProxyFactory;
|
2022-05-31 16:41:11 +08:00
|
|
|
|
import com.engine.salary.util.page.PageInfo;
|
|
|
|
|
|
import com.engine.salary.util.page.SalaryPageUtil;
|
2022-03-22 21:01:38 +08:00
|
|
|
|
import com.engine.salary.util.valid.RuntimeTypeEnum;
|
|
|
|
|
|
import com.engine.salary.util.valid.ValidUtil;
|
2022-03-25 18:05:07 +08:00
|
|
|
|
import com.google.common.collect.Lists;
|
2022-09-22 09:06:53 +08:00
|
|
|
|
import dm.jdbc.util.IdGenerator;
|
2022-03-22 21:01:38 +08:00
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
2022-05-31 16:41:11 +08:00
|
|
|
|
import org.apache.commons.lang3.BooleanUtils;
|
2022-03-22 21:01:38 +08:00
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
2022-03-25 18:05:07 +08:00
|
|
|
|
import org.apache.commons.lang3.math.NumberUtils;
|
2022-03-22 21:01:38 +08:00
|
|
|
|
import org.springframework.beans.BeanUtils;
|
2022-03-25 18:05:07 +08:00
|
|
|
|
import weaver.hrm.User;
|
2022-03-22 21:01:38 +08:00
|
|
|
|
|
|
|
|
|
|
import java.time.YearMonth;
|
|
|
|
|
|
import java.util.*;
|
2022-06-06 19:24:49 +08:00
|
|
|
|
import java.util.function.Function;
|
2022-03-25 18:05:07 +08:00
|
|
|
|
import java.util.stream.Collectors;
|
2022-03-22 21:01:38 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 薪资账套
|
|
|
|
|
|
* <p>Copyright: Copyright (c) 2022</p>
|
|
|
|
|
|
* <p>Company: 泛微软件</p>
|
|
|
|
|
|
*
|
|
|
|
|
|
* @author qiantao
|
|
|
|
|
|
* @version 1.0
|
|
|
|
|
|
**/
|
|
|
|
|
|
public class SalarySobServiceImpl extends Service implements SalarySobService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private SalarySobBiz salarySobMapper = new SalarySobBiz();
|
2022-03-25 18:05:07 +08:00
|
|
|
|
private SalarySobRangeBiz salarySobRangeService = new SalarySobRangeBiz();
|
|
|
|
|
|
private SalarySobEmpFieldBiz empFieldBiz = new SalarySobEmpFieldBiz();
|
|
|
|
|
|
private SalarySobDefaultItemGroupBiz defaultItemGroupBiz = new SalarySobDefaultItemGroupBiz();
|
|
|
|
|
|
private SalarySobEmpFieldBiz salarySobEmpFieldService = new SalarySobEmpFieldBiz();
|
|
|
|
|
|
private SalarySobDefaultItemBiz salarySobDefaultItemService = new SalarySobDefaultItemBiz();
|
|
|
|
|
|
private SalarySobItemBiz salarySobItemService = new SalarySobItemBiz();
|
|
|
|
|
|
private SalarySobItemGroupBiz salarySobItemGroupService = new SalarySobItemGroupBiz();
|
2022-03-24 16:59:52 +08:00
|
|
|
|
|
2022-09-22 09:35:52 +08:00
|
|
|
|
private SalarySobItemHideBiz salarySobItemHideService = new SalarySobItemHideBiz();
|
|
|
|
|
|
|
2022-10-09 17:51:30 +08:00
|
|
|
|
private SalarySobRangeBiz salarySobRangeBiz = new SalarySobRangeBiz();
|
|
|
|
|
|
|
2022-11-22 14:36:59 +08:00
|
|
|
|
private SalarySobBackItemMapper getSalarySobBackItemMapper() {
|
|
|
|
|
|
return MapperProxyFactory.getProxy(SalarySobBackItemMapper.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-06-20 19:39:01 +08:00
|
|
|
|
private SalarySobMapper getSalarySobMapper() {
|
|
|
|
|
|
return MapperProxyFactory.getProxy(SalarySobMapper.class);
|
|
|
|
|
|
}
|
2022-03-24 16:59:52 +08:00
|
|
|
|
|
2022-03-25 18:05:07 +08:00
|
|
|
|
private SalaryItemService getSalaryItemService(User user) {
|
2022-05-31 16:41:11 +08:00
|
|
|
|
return ServiceUtil.getService(SalaryItemServiceImpl.class, user);
|
2022-03-25 18:05:07 +08:00
|
|
|
|
}
|
2022-03-24 16:59:52 +08:00
|
|
|
|
|
2022-03-25 18:05:07 +08:00
|
|
|
|
private SysSalaryItemService getSysSalaryItemService(User user) {
|
2022-05-31 16:41:11 +08:00
|
|
|
|
return ServiceUtil.getService(SysSalaryItemServiceImpl.class, user);
|
2022-03-25 18:05:07 +08:00
|
|
|
|
}
|
2022-05-31 16:41:11 +08:00
|
|
|
|
|
2022-03-30 20:27:17 +08:00
|
|
|
|
private SalarySobAdjustRuleBiz salarySobAdjustRuleService = new SalarySobAdjustRuleBiz();
|
|
|
|
|
|
|
|
|
|
|
|
private SalarySobCheckRuleService getSalarySobCheckRuleService(User user) {
|
2022-05-31 16:41:11 +08:00
|
|
|
|
return ServiceUtil.getService(SalarySobCheckRuleServiceImpl.class, user);
|
2022-03-30 20:27:17 +08:00
|
|
|
|
}
|
2022-05-31 16:41:11 +08:00
|
|
|
|
|
2022-05-05 11:19:13 +08:00
|
|
|
|
private SalaryAcctRecordService getSalaryAcctRecordService(User user) {
|
2022-05-31 16:41:11 +08:00
|
|
|
|
return ServiceUtil.getService(SalaryAcctRecordServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-05-31 21:05:59 +08:00
|
|
|
|
private TaxAgentService getTaxAgentService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
|
2022-05-05 11:19:13 +08:00
|
|
|
|
}
|
2022-03-22 21:01:38 +08:00
|
|
|
|
|
2022-05-31 16:41:11 +08:00
|
|
|
|
private TaxAgentAdminService getTaxAgentAdminService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(TaxAgentAdminServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-10-09 17:51:30 +08:00
|
|
|
|
private TaxAgentManageRangeService getTaxAgentManageRangeService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(TaxAgentManageRangeServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-16 10:32:05 +08:00
|
|
|
|
private SalarySobBackItemService getSalarySobBackItemService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SalarySobBackItemServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-05-31 16:41:11 +08:00
|
|
|
|
|
2022-03-22 21:01:38 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public SalarySobPO getById(Long id) {
|
|
|
|
|
|
return salarySobMapper.getById(id);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<SalarySobPO> listByIds(Collection<Long> ids) {
|
|
|
|
|
|
if (CollectionUtils.isEmpty(ids)) {
|
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
|
}
|
|
|
|
|
|
return salarySobMapper.listSome(SalarySobPO.builder().ids(ids).build());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<SalarySobPO> listByName(String name) {
|
|
|
|
|
|
if (StringUtils.isEmpty(name)) {
|
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
|
}
|
2022-06-15 15:27:23 +08:00
|
|
|
|
List<SalarySobPO> salarySobPOS = salarySobMapper.listByName(SalarySobPO.builder().name(name).build());
|
|
|
|
|
|
return salarySobPOS;
|
2022-03-22 21:01:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<SalarySobPO> listByNameLike(String nameLike) {
|
|
|
|
|
|
if (StringUtils.isEmpty(nameLike)) {
|
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
|
}
|
2022-06-02 17:10:54 +08:00
|
|
|
|
List<SalarySobPO> salarySobPOS = salarySobMapper.listByParam(SalarySobPO.builder().name(nameLike).build());
|
|
|
|
|
|
return filterByAuthority(salarySobPOS);
|
2022-03-22 21:01:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<SalarySobPO> listByDisable(Integer disable) {
|
2022-06-02 17:10:54 +08:00
|
|
|
|
List<SalarySobPO> salarySobPOS = salarySobMapper.listSome(SalarySobPO.builder().disable(disable).build());
|
|
|
|
|
|
return filterByAuthority(salarySobPOS);
|
2022-03-22 21:01:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-06-07 15:43:22 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public List<SalarySobPO> listByAdmin() {
|
2022-11-16 14:22:25 +08:00
|
|
|
|
List<SalarySobPO> salarySobPOS = salarySobMapper.listSome(SalarySobPO.builder().build());
|
2022-06-07 15:43:22 +08:00
|
|
|
|
return filterByAdmin(salarySobPOS);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<SalarySobPO> listByTaxAgentId(Long taxAgentId) {
|
|
|
|
|
|
return salarySobMapper.listSome(SalarySobPO.builder().disable(NumberUtils.INTEGER_ZERO).taxAgentId(taxAgentId).build());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-22 21:01:38 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public List<SalarySobPO> listByIncomeCategory(IncomeCategoryEnum incomeCategory) {
|
|
|
|
|
|
return salarySobMapper.listSome(SalarySobPO.builder().incomeCategory(incomeCategory.getValue()).build());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-05-31 16:41:11 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public PageInfo<SalarySobPO> listPageByParam(SalarySobListQueryParam queryParam) {
|
|
|
|
|
|
long employeeId = user.getUID();
|
|
|
|
|
|
// 分页参数
|
|
|
|
|
|
PageInfo<SalarySobPO> page = SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize());
|
|
|
|
|
|
// 判断是否是“总管理员”
|
|
|
|
|
|
Boolean isChief = getTaxAgentService(user).isChief(employeeId);
|
|
|
|
|
|
// 是否开启分权
|
|
|
|
|
|
Boolean openDevolution = getTaxAgentService(user).isOpenDevolution();
|
|
|
|
|
|
// 总管理员拥有全部权限
|
|
|
|
|
|
// 开启分权后需要过滤薪资账套
|
|
|
|
|
|
String name = queryParam.getName();
|
|
|
|
|
|
// 查询所有的薪资账套
|
|
|
|
|
|
SalarySobPO build = SalarySobPO.builder().build();
|
|
|
|
|
|
if (StringUtils.isNotBlank(name)) {
|
|
|
|
|
|
build.setName(name);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (BooleanUtils.isTrue(openDevolution) && !isChief) {
|
2022-06-02 17:10:54 +08:00
|
|
|
|
List<SalarySobPO> salarySobPOS = salarySobMapper.listSome(build);
|
2022-05-31 16:41:11 +08:00
|
|
|
|
// 根据权限过滤
|
|
|
|
|
|
List<SalarySobPO> salarySobsFilterByAuthority = filterByAuthority(salarySobPOS);
|
|
|
|
|
|
if (CollectionUtils.isEmpty(salarySobsFilterByAuthority)) {
|
|
|
|
|
|
return page;
|
|
|
|
|
|
}
|
2022-06-02 17:10:54 +08:00
|
|
|
|
List<SalarySobPO> subSalarySobs = SalaryPageUtil.subList((int) page.getPageNum(), (int) page.getPageSize(), salarySobsFilterByAuthority);
|
2022-05-31 16:41:11 +08:00
|
|
|
|
page.setTotal(salarySobsFilterByAuthority.size());
|
|
|
|
|
|
page.setList(subSalarySobs);
|
|
|
|
|
|
return page;
|
2022-06-02 17:10:54 +08:00
|
|
|
|
} else {
|
2022-05-31 16:41:11 +08:00
|
|
|
|
SalaryPageUtil.start(queryParam.getCurrent(), queryParam.getPageSize());
|
|
|
|
|
|
List<SalarySobPO> salarySobPOS = salarySobMapper.listSome(build);
|
2022-06-02 17:10:54 +08:00
|
|
|
|
return new PageInfo<>(salarySobPOS, SalarySobPO.class);
|
2022-05-31 16:41:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-03-22 21:01:38 +08:00
|
|
|
|
|
2022-06-01 21:15:48 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public List<SalarySobPO> listByParam(SalarySobListQueryParam queryParam) {
|
|
|
|
|
|
long employeeId = user.getUID();
|
|
|
|
|
|
// 判断是否是“总管理员”
|
|
|
|
|
|
Boolean isChief = getTaxAgentService(user).isChief(employeeId);
|
|
|
|
|
|
// 是否开启分权
|
|
|
|
|
|
Boolean openDevolution = getTaxAgentService(user).isOpenDevolution();
|
|
|
|
|
|
// 总管理员拥有全部权限
|
|
|
|
|
|
// 开启分权后需要过滤薪资账套
|
|
|
|
|
|
String name = queryParam.getName();
|
|
|
|
|
|
// 查询所有的薪资账套
|
|
|
|
|
|
SalarySobPO build = SalarySobPO.builder().build();
|
|
|
|
|
|
if (StringUtils.isNotBlank(name)) {
|
|
|
|
|
|
build.setName(name);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (BooleanUtils.isTrue(openDevolution) && !isChief) {
|
|
|
|
|
|
|
|
|
|
|
|
Boolean adminEnable = getTaxAgentService(user).isAdminEnable(employeeId);
|
|
|
|
|
|
//非管理员
|
2022-06-02 17:10:54 +08:00
|
|
|
|
if (!adminEnable) {
|
2022-06-01 21:15:48 +08:00
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<SalarySobPO> salarySobPOS = salarySobMapper.listSome(build);
|
|
|
|
|
|
|
|
|
|
|
|
// 根据权限过滤
|
|
|
|
|
|
List<SalarySobPO> salarySobsFilterByAuthority = filterByAuthority(salarySobPOS);
|
|
|
|
|
|
if (CollectionUtils.isEmpty(salarySobsFilterByAuthority)) {
|
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
|
}
|
|
|
|
|
|
return salarySobsFilterByAuthority;
|
|
|
|
|
|
|
2022-06-02 17:10:54 +08:00
|
|
|
|
} else {
|
2022-06-01 21:15:48 +08:00
|
|
|
|
return salarySobMapper.listSome(build);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-22 21:01:38 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public Long save(SalarySobBasicSaveParam saveParam) {
|
|
|
|
|
|
|
|
|
|
|
|
ValidUtil.doValidator(saveParam);
|
|
|
|
|
|
|
|
|
|
|
|
// 薪资账套的名称不能重复
|
|
|
|
|
|
List<SalarySobPO> salarySobPOS = listByName(saveParam.getName());
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(salarySobPOS)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98403, "薪资账套名称已存在"));
|
|
|
|
|
|
}
|
2022-10-09 17:51:30 +08:00
|
|
|
|
|
2022-03-22 21:01:38 +08:00
|
|
|
|
// 保存参数转换成薪资账套po
|
|
|
|
|
|
SalarySobPO salarySobPO = SalarySobBO.convert2PO(saveParam, (long) user.getUID());
|
|
|
|
|
|
// 保存薪资账套
|
|
|
|
|
|
salarySobMapper.insert(salarySobPO);
|
|
|
|
|
|
//todo 记录日志
|
|
|
|
|
|
// LoggerContext<SalarySobPO> loggerContext = new LoggerContext<>();
|
|
|
|
|
|
// loggerContext.setTargetId(String.valueOf(salarySobPO.getId()));
|
|
|
|
|
|
// loggerContext.setTargetName(salarySobPO.getName());
|
|
|
|
|
|
// loggerContext.setOperateType(OperateTypeEnum.ADD.getValue());
|
|
|
|
|
|
// loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(98404, "新建薪资账套"));
|
|
|
|
|
|
// loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(98404, "新建薪资账套") + ": " + salarySobPO.getName());
|
|
|
|
|
|
// loggerContext.setOldValues(salarySobPO);
|
|
|
|
|
|
// salarySobLoggerTemplate.write(loggerContext);
|
|
|
|
|
|
// 新建薪资账套时,保存默认的员工信息字段
|
|
|
|
|
|
saveDefaultEmpField(salarySobPO);
|
|
|
|
|
|
// 新建薪资账套时,保存默认的薪资项目
|
|
|
|
|
|
saveDefaultItem(salarySobPO);
|
2022-10-09 17:51:30 +08:00
|
|
|
|
// 新建薪资账套时,保存默认的关联人员范围及从范围中排除
|
|
|
|
|
|
saveDefaultEmployeeRange(salarySobPO);
|
2022-03-22 21:01:38 +08:00
|
|
|
|
// 返回薪资账套的主键id
|
|
|
|
|
|
return salarySobPO.getId();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-10-09 17:51:30 +08:00
|
|
|
|
|
2022-03-22 21:01:38 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 新建薪资账套时,保存默认的员工信息字段
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param salarySobPO 薪资账套
|
|
|
|
|
|
*/
|
|
|
|
|
|
private void saveDefaultEmpField(SalarySobPO salarySobPO) {
|
2022-03-25 18:05:07 +08:00
|
|
|
|
// 查询薪资账套默认的员工信息字段
|
|
|
|
|
|
List<SalarySobDefaultEmpFieldPO> salarySobDefaultEmpFieldPOS = empFieldBiz.listDefaultEmpField();
|
|
|
|
|
|
// 转换成薪资账套员工信息字段po
|
|
|
|
|
|
List<SalarySobEmpFieldPO> salarySobEmpFieldPOS = SalarySobItemBO.convert2EmpFieldPO(salarySobPO.getId(), salarySobDefaultEmpFieldPOS, (long) user.getUID());
|
|
|
|
|
|
// 保存
|
|
|
|
|
|
empFieldBiz.batchInsert(salarySobEmpFieldPOS);
|
2022-03-22 21:01:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 新建薪资账套时,保存默认的薪资项目
|
|
|
|
|
|
* 1、薪资账套默认引用的系统薪资项目
|
|
|
|
|
|
* 2、自定义薪资项目中开启了"默认使用"的薪资项目
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param salarySobPO 薪资账套
|
|
|
|
|
|
*/
|
|
|
|
|
|
private void saveDefaultItem(SalarySobPO salarySobPO) {
|
2022-03-25 18:05:07 +08:00
|
|
|
|
// 1、根据薪资类型查询薪资账套默认使用的薪资项目分类以及薪资项目
|
|
|
|
|
|
IncomeCategoryEnum incomeCategoryEnum = IncomeCategoryEnum.parseByValue(salarySobPO.getIncomeCategory());
|
|
|
|
|
|
List<SalarySobDefaultItemGroupPO> salarySobDefaultItemGroupPOS = defaultItemGroupBiz.listByIncomeCategory(incomeCategoryEnum);
|
|
|
|
|
|
List<SalarySobDefaultItemPO> salarySobDefaultItemPOS = salarySobDefaultItemService.listByIncomeCategory(SalarySobDefaultItemPO.builder().incomeCategory(incomeCategoryEnum.getValue()).build());
|
|
|
|
|
|
// 2、薪资账套默认引用的系统薪资项目如果没有添加到薪资项目中,这里要给添加保存
|
|
|
|
|
|
// 2.1、查询已经添加到薪资项目中的系统薪资项目
|
|
|
|
|
|
Set<Long> defaultSysSalaryItemIds = SalaryEntityUtil.properties(salarySobDefaultItemPOS, SalarySobDefaultItemPO::getSysSalaryItemId);
|
2022-11-16 10:32:05 +08:00
|
|
|
|
// 薪资账套的默认的回算薪资项目
|
2022-11-22 14:36:59 +08:00
|
|
|
|
Set<Long> SalarySobBackItemIds = SalaryEntityUtil.properties(SalarySobBackItemBO.getDefault(), SalarySobDefaultBackItemPO::getSysSalaryItemId);
|
|
|
|
|
|
defaultSysSalaryItemIds.addAll(SalarySobBackItemIds);
|
2022-11-16 10:32:05 +08:00
|
|
|
|
|
2022-03-25 18:05:07 +08:00
|
|
|
|
List<SalaryItemPO> salaryItemPOS = getSalaryItemService(user).listBySysSalaryItemIds(defaultSysSalaryItemIds);
|
|
|
|
|
|
Set<Long> sysSalaryItemIds = SalaryEntityUtil.properties(salaryItemPOS, SalaryItemPO::getSysSalaryItemId);
|
|
|
|
|
|
// 2.2、需要添加进薪资项目中的系统薪资项目id
|
|
|
|
|
|
Set<Long> needAddSysSalaryItemIds = salarySobDefaultItemPOS.stream()
|
|
|
|
|
|
.map(SalarySobDefaultItemPO::getSysSalaryItemId)
|
|
|
|
|
|
.filter(sysSalaryItemId -> !sysSalaryItemIds.contains(sysSalaryItemId))
|
|
|
|
|
|
.collect(Collectors.toSet());
|
2022-11-22 14:36:59 +08:00
|
|
|
|
// 需要添加进薪资项目中的回算薪资项目
|
|
|
|
|
|
needAddSysSalaryItemIds.addAll( SalarySobBackItemIds.stream().filter(salarySobBackItemId -> !sysSalaryItemIds.contains(salarySobBackItemId)).collect(Collectors.toList()) );
|
2022-03-25 18:05:07 +08:00
|
|
|
|
List<SysSalaryItemPO> needAddSysSalaryItemPOS = getSysSalaryItemService(user).listByIds(needAddSysSalaryItemIds);
|
|
|
|
|
|
// 2.3、需要保存的薪资项目
|
|
|
|
|
|
List<SalaryItemPO> needInsertSalaryItemPOS = SysSalaryItemBO.convert2SalaryItemPO(needAddSysSalaryItemPOS, (long) user.getUID());
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(needInsertSalaryItemPOS)) {
|
|
|
|
|
|
getSalaryItemService(user).batchSave(needInsertSalaryItemPOS);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 3、查询开启了"默认使用"的自定义薪资项目
|
|
|
|
|
|
List<SalaryItemPO> useDefaultSalaryItemPOS = getSalaryItemService(user).listBySystemTypeAndUseDefault(SalarySystemTypeEnum.CUSTOM, NumberUtils.INTEGER_ONE);
|
|
|
|
|
|
|
|
|
|
|
|
// 4、默认引用的薪资项目(=薪资账套默认引用的系统薪资项目(已添加进薪资项目中的) + 薪资账套默认引用的系统薪资项目(待添加进薪资项目中的) + 自定义薪资项目中开启了"默认使用"的薪资项目)
|
|
|
|
|
|
List<SalaryItemPO> defaultSalaryItemPOS = Lists.newArrayListWithExpectedSize(salaryItemPOS.size() + needInsertSalaryItemPOS.size() + useDefaultSalaryItemPOS.size());
|
|
|
|
|
|
defaultSalaryItemPOS.addAll(salaryItemPOS);
|
|
|
|
|
|
defaultSalaryItemPOS.addAll(needInsertSalaryItemPOS);
|
|
|
|
|
|
defaultSalaryItemPOS.addAll(useDefaultSalaryItemPOS);
|
|
|
|
|
|
|
|
|
|
|
|
// 5、保存
|
|
|
|
|
|
SalarySobItemBO.Result result = SalarySobItemBO.initSalarySobItem(salarySobPO.getId(), salarySobDefaultItemGroupPOS, salarySobDefaultItemPOS, defaultSalaryItemPOS, (long) user.getUID(), SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY);
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(result.getNeedInsertSalarySobItems())) {
|
2022-06-06 19:24:49 +08:00
|
|
|
|
|
|
|
|
|
|
List<SalarySobItemPO> list = new ArrayList<>(result.getNeedInsertSalarySobItems().stream()
|
|
|
|
|
|
.collect(Collectors.toMap(SalarySobItemPO::getSalaryItemId, Function.identity(), (oldValue, newValue) -> oldValue))
|
|
|
|
|
|
.values());
|
|
|
|
|
|
|
|
|
|
|
|
salarySobItemService.batchInsert(list);
|
2022-03-25 18:05:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(result.getNeedInsertSalarySobItemGroups())) {
|
|
|
|
|
|
salarySobItemGroupService.batchInsert(result.getNeedInsertSalarySobItemGroups());
|
|
|
|
|
|
}
|
2022-11-16 10:32:05 +08:00
|
|
|
|
if (CollectionUtils.isNotEmpty(result.getNeedInsertSalarySobBackItems())) {
|
|
|
|
|
|
getSalarySobBackItemService(user).batchInsert(result.getNeedInsertSalarySobBackItems());
|
|
|
|
|
|
}
|
2022-03-22 21:01:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-10-09 17:51:30 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @description 新建薪资账套时,保存默认的关联人员范围及从范围中排除
|
|
|
|
|
|
* @return void
|
|
|
|
|
|
* @author Harryxzy
|
|
|
|
|
|
* @date 2022/10/9 15:30
|
|
|
|
|
|
*/
|
|
|
|
|
|
private void saveDefaultEmployeeRange(SalarySobPO salarySobPO) {
|
|
|
|
|
|
// 获取人员范围列表
|
|
|
|
|
|
TaxAgentRangeQueryParam queryParam = TaxAgentRangeQueryParam.builder().taxAgentId(salarySobPO.getTaxAgentId()).build();
|
|
|
|
|
|
queryParam.setCurrent(1);
|
|
|
|
|
|
queryParam.setPageSize(100000);
|
|
|
|
|
|
List<TaxAgentManageRangeListDTO> includeList = (List<TaxAgentManageRangeListDTO>) getTaxAgentManageRangeService(user).listPageByParamAndIncludeType(queryParam, NumberUtils.INTEGER_ONE).getList();
|
|
|
|
|
|
includeList.stream().forEach(item->{
|
|
|
|
|
|
item.setEmployeeStatus(parseEnum2ValueStr(item.getEmployeeStatus()));
|
|
|
|
|
|
});
|
|
|
|
|
|
// 获取从范围中排除
|
|
|
|
|
|
List<TaxAgentManageRangeListDTO> excludeList = (List<TaxAgentManageRangeListDTO>) getTaxAgentManageRangeService(user).listPageByParamAndIncludeType(queryParam, NumberUtils.INTEGER_ZERO).getList();
|
|
|
|
|
|
excludeList.stream().forEach(item->{
|
|
|
|
|
|
item.setEmployeeStatus(parseEnum2ValueStr(item.getEmployeeStatus()));
|
|
|
|
|
|
});
|
|
|
|
|
|
// 将TaxAgentManageRangeListDTO转换为SalarySobRangePO
|
|
|
|
|
|
List<SalarySobRangePO> rangeList = convert2SalarySobRangePO(salarySobPO.getId(),includeList,excludeList);
|
|
|
|
|
|
// 保存SalarySobRangePO
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(rangeList)) {
|
|
|
|
|
|
salarySobRangeBiz.batchInsert(rangeList);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @description 将TaxAgentManageRangeListDTO转换为SalarySobRangePO
|
2022-11-22 14:36:59 +08:00
|
|
|
|
* @return List<SalarySobRangePO>
|
2022-10-09 17:51:30 +08:00
|
|
|
|
* @author Harryxzy
|
|
|
|
|
|
* @date 2022/10/9 16:06
|
|
|
|
|
|
*/
|
|
|
|
|
|
private List<SalarySobRangePO> convert2SalarySobRangePO(Long salarySobID,List<TaxAgentManageRangeListDTO> includeList, List<TaxAgentManageRangeListDTO> excludeList) {
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
|
ArrayList<SalarySobRangePO> result = new ArrayList<SalarySobRangePO>();
|
|
|
|
|
|
// 关联人员范围
|
|
|
|
|
|
includeList.stream().forEach(item->{
|
|
|
|
|
|
SalarySobRangePO salarySobRangePO = SalarySobRangePO.builder()
|
|
|
|
|
|
.salarySobId(salarySobID)
|
|
|
|
|
|
.targetType(item.getTargetType().getValue())
|
|
|
|
|
|
.targetId(item.getTargetId())
|
|
|
|
|
|
.employeeStatuses(item.getEmployeeStatus())
|
|
|
|
|
|
.includeType(1)
|
|
|
|
|
|
.creator(Long.valueOf(user.getUID()))
|
|
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.deleteType(0)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
result.add(salarySobRangePO);
|
|
|
|
|
|
});
|
|
|
|
|
|
// 从范围中排除
|
|
|
|
|
|
excludeList.stream().forEach(item->{
|
|
|
|
|
|
SalarySobRangePO salarySobRangePO = SalarySobRangePO.builder()
|
|
|
|
|
|
.salarySobId(salarySobID)
|
|
|
|
|
|
.targetType(item.getTargetType().getValue())
|
|
|
|
|
|
.targetId(item.getTargetId())
|
|
|
|
|
|
.employeeStatuses(item.getEmployeeStatus())
|
|
|
|
|
|
.includeType(0)
|
|
|
|
|
|
.creator(Long.valueOf(user.getUID()))
|
|
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.deleteType(0)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
result.add(salarySobRangePO);
|
|
|
|
|
|
});
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @description 将枚举的defaultLabel转换为value
|
|
|
|
|
|
* @return String
|
|
|
|
|
|
* @author Harryxzy
|
|
|
|
|
|
* @date 2022/10/9 16:56
|
|
|
|
|
|
*/
|
|
|
|
|
|
private String parseEnum2ValueStr(String employeeStatus) {
|
|
|
|
|
|
String[] split = employeeStatus.split(",");
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
for (SalaryEmployeeStatusEnum statusEnum : SalaryEmployeeStatusEnum.values()) {
|
|
|
|
|
|
for(int i =0;i<split.length;i++){
|
|
|
|
|
|
if(statusEnum.getDefaultLabel().equals(split[i])){
|
|
|
|
|
|
sb.append(statusEnum.getValue());
|
|
|
|
|
|
if(i+1 != split.length){
|
|
|
|
|
|
sb.append(",");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return sb.toString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-22 21:01:38 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public Long update(SalarySobBasicSaveParam saveParam) {
|
|
|
|
|
|
|
|
|
|
|
|
ValidUtil.doValidator(saveParam, RuntimeTypeEnum.UPDATE);
|
|
|
|
|
|
|
|
|
|
|
|
// 查询薪资账套
|
|
|
|
|
|
SalarySobPO salarySobPO = getById(saveParam.getId());
|
|
|
|
|
|
if (Objects.isNull(salarySobPO)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除"));
|
|
|
|
|
|
}
|
|
|
|
|
|
// 薪资账套的名称不能重复
|
|
|
|
|
|
List<SalarySobPO> salarySobPOS = listByName(saveParam.getName());
|
|
|
|
|
|
boolean duplicateName = salarySobPOS.stream().anyMatch(e -> !Objects.equals(e.getId(), saveParam.getId()));
|
|
|
|
|
|
if (duplicateName) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98403, "薪资账套名称已存在"));
|
|
|
|
|
|
}
|
|
|
|
|
|
// 更新薪资账套
|
|
|
|
|
|
SalarySobPO newSalarySobPO = new SalarySobPO();
|
|
|
|
|
|
BeanUtils.copyProperties(salarySobPO, newSalarySobPO);
|
2022-03-30 18:32:44 +08:00
|
|
|
|
newSalarySobPO.setId(saveParam.getId())
|
|
|
|
|
|
.setName(saveParam.getName())
|
2022-06-17 17:22:48 +08:00
|
|
|
|
.setTaxAgentId(saveParam.getTaxAgentId())
|
2022-03-22 21:01:38 +08:00
|
|
|
|
.setIncomeCategory(saveParam.getTaxableItems())
|
|
|
|
|
|
.setSalaryCycleType(saveParam.getSalaryCycleType())
|
|
|
|
|
|
.setSalaryCycleFromDay(saveParam.getSalaryCycleFromDay())
|
|
|
|
|
|
.setTaxCycleType(saveParam.getTaxCycleType())
|
|
|
|
|
|
.setAttendCycleType(saveParam.getAttendCycleType())
|
|
|
|
|
|
.setAttendCycleFromDay(saveParam.getAttendCycleFromDay())
|
|
|
|
|
|
.setSocialSecurityCycleType(saveParam.getSocialSecurityCycleType())
|
|
|
|
|
|
.setDescription(saveParam.getDescription())
|
|
|
|
|
|
.setUpdateTime(new Date());
|
|
|
|
|
|
salarySobMapper.updateById(newSalarySobPO);
|
|
|
|
|
|
// 记录日志
|
|
|
|
|
|
// LoggerContext<SalarySobPO> loggerContext = new LoggerContext<>();
|
|
|
|
|
|
// loggerContext.setTargetId(String.valueOf(newSalarySobPO.getId()));
|
|
|
|
|
|
// loggerContext.setTargetName(newSalarySobPO.getName());
|
|
|
|
|
|
// loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue());
|
|
|
|
|
|
// loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(98526, "编辑薪资账套基础设置"));
|
|
|
|
|
|
// loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(98526, "编辑薪资账套基础设置"));
|
|
|
|
|
|
// loggerContext.setOldValues(salarySobPO);
|
|
|
|
|
|
// loggerContext.setNewValues(newSalarySobPO);
|
|
|
|
|
|
// salarySobLoggerTemplate.write(loggerContext);
|
|
|
|
|
|
// 返回薪资账套的主键id
|
|
|
|
|
|
return salarySobPO.getId();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void updateDisable(SalarySobDisableParam disableParam) {
|
|
|
|
|
|
// 查询薪资账套
|
|
|
|
|
|
SalarySobPO salarySobPO = getById(disableParam.getId());
|
|
|
|
|
|
if (Objects.isNull(salarySobPO)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除"));
|
|
|
|
|
|
}
|
|
|
|
|
|
// 启用/禁用 薪资账套
|
|
|
|
|
|
salarySobPO.setDisable(disableParam.getDisable());
|
|
|
|
|
|
salarySobPO.setUpdateTime(new Date());
|
|
|
|
|
|
salarySobMapper.updateById(salarySobPO);
|
|
|
|
|
|
// todo 记录日志
|
|
|
|
|
|
// String operateTypeName = Objects.equals(disableParam.getDisable(), NumberUtils.INTEGER_ONE) ?
|
|
|
|
|
|
// SalaryI18nUtil.getI18nLabel(98591, "禁用薪资账套") : SalaryI18nUtil.getI18nLabel(98592, "启用薪资账套");
|
|
|
|
|
|
// LoggerContext<SalarySobPO> loggerContext = new LoggerContext<>();
|
|
|
|
|
|
// loggerContext.setTargetId("" + salarySobPO.getId());
|
|
|
|
|
|
// loggerContext.setTargetName(salarySobPO.getName());
|
|
|
|
|
|
// loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue());
|
|
|
|
|
|
// loggerContext.setOperateTypeName(operateTypeName);
|
|
|
|
|
|
// loggerContext.setOperatedesc(operateTypeName + ": " + salarySobPO.getName());
|
|
|
|
|
|
// salarySobLoggerTemplate.write(loggerContext);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void deleteByIds(Collection<Long> ids) {
|
2022-06-07 19:10:40 +08:00
|
|
|
|
|
|
|
|
|
|
//分权
|
|
|
|
|
|
Boolean isOpenDevolution = getTaxAgentService(user).isOpenDevolution();
|
|
|
|
|
|
if (isOpenDevolution) {
|
|
|
|
|
|
List<SalarySobPO> salarySobPOS = listByAdmin();
|
|
|
|
|
|
Set<Long> salarySobIds = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId);
|
|
|
|
|
|
Optional<Long> first = ids.stream().filter(f -> !salarySobIds.contains(f)).findFirst();
|
|
|
|
|
|
if (first.isPresent()) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "无权限删除"));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-22 21:01:38 +08:00
|
|
|
|
// 查询薪资账套
|
|
|
|
|
|
List<SalarySobPO> salarySobPOS = listByIds(ids);
|
|
|
|
|
|
if (CollectionUtils.isEmpty(salarySobPOS)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除"));
|
|
|
|
|
|
}
|
|
|
|
|
|
ids = SalaryEntityUtil.properties(salarySobPOS, SalarySobPO::getId);
|
|
|
|
|
|
// 根据薪资账套id查询薪资核算记录,存在薪资核算记录就不能删除账套了
|
2022-05-05 11:19:13 +08:00
|
|
|
|
List<SalaryAcctRecordPO> salaryAcctRecordPOS = getSalaryAcctRecordService(user).listBySalarySobIds(ids);
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(salaryAcctRecordPOS)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(99713, "账套已用于薪资核算,不能删除"));
|
|
|
|
|
|
}
|
|
|
|
|
|
//关联其他的删除
|
2022-03-25 18:05:07 +08:00
|
|
|
|
// 删除薪资账套
|
|
|
|
|
|
salarySobMapper.deleteByIds(ids);
|
|
|
|
|
|
// 删除薪资账套的人员范围
|
|
|
|
|
|
salarySobRangeService.deleteBySalarySobIds(ids);
|
|
|
|
|
|
// 删除薪资账套的人员信息字段
|
|
|
|
|
|
salarySobEmpFieldService.deleteBySalarySobIds(ids);
|
|
|
|
|
|
// 删除薪资账套的薪资项目
|
|
|
|
|
|
salarySobItemService.deleteBySalarySobIds(ids);
|
|
|
|
|
|
// 删除薪资账套的薪资项目分类
|
|
|
|
|
|
salarySobItemGroupService.deleteBySalarySobIds(ids);
|
2022-09-22 09:35:52 +08:00
|
|
|
|
// 删除薪资账套的薪资项目隐藏信息
|
|
|
|
|
|
salarySobItemHideService.deleteBySalarySobIds(ids);
|
2022-03-25 18:05:07 +08:00
|
|
|
|
// 删除薪资账套的调薪计薪规则
|
2022-03-30 20:27:17 +08:00
|
|
|
|
salarySobAdjustRuleService.deleteBySalarySobIds(ids);
|
2022-11-22 14:36:59 +08:00
|
|
|
|
// 删除薪资账套的回算薪资项目
|
|
|
|
|
|
getSalarySobBackItemMapper().deleteBySalarySobIds(ids);
|
|
|
|
|
|
// 删除薪资账套的校验规则
|
2022-03-30 20:27:17 +08:00
|
|
|
|
getSalarySobCheckRuleService(user).deleteBySalarySobIds(ids);
|
2022-03-22 21:01:38 +08:00
|
|
|
|
// // 记录日志
|
|
|
|
|
|
// salarySobPOS.forEach(salarySobPO -> {
|
|
|
|
|
|
// LoggerContext<SalarySobPO> loggerContext = new LoggerContext<>();
|
|
|
|
|
|
// loggerContext.setTargetId("" + salarySobPO.getId());
|
|
|
|
|
|
// loggerContext.setTargetName(salarySobPO.getName());
|
|
|
|
|
|
// loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue());
|
|
|
|
|
|
// loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(98535, "删除薪资账套"));
|
|
|
|
|
|
// loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(98535, "删除薪资账套"));
|
|
|
|
|
|
// salarySobLoggerTemplate.write(loggerContext);
|
|
|
|
|
|
// });
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void duplicate(SalarySobDuplicateParam duplicateParam) {
|
2022-06-17 17:22:48 +08:00
|
|
|
|
ValidUtil.doValidator(duplicateParam);
|
|
|
|
|
|
|
2022-03-22 21:01:38 +08:00
|
|
|
|
// 查询薪资账套
|
|
|
|
|
|
SalarySobPO salarySobPO = getById(duplicateParam.getId());
|
|
|
|
|
|
if (Objects.isNull(salarySobPO)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除"));
|
|
|
|
|
|
}
|
|
|
|
|
|
// 薪资账套名称不能重复
|
|
|
|
|
|
List<SalarySobPO> salarySobPOS = listByName(duplicateParam.getName());
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(salarySobPOS)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98403, "薪资账套名称已存在"));
|
|
|
|
|
|
}
|
2022-06-17 17:22:48 +08:00
|
|
|
|
|
|
|
|
|
|
Boolean openDevolution = getTaxAgentService(user).isOpenDevolution();
|
|
|
|
|
|
if (openDevolution) {
|
|
|
|
|
|
Collection<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listAllTaxAgentsAsAdmin((long) user.getUID());
|
|
|
|
|
|
Set<Long> taxAgentIds = SalaryEntityUtil.properties(taxAgentPOS, TaxAgentPO::getId);
|
|
|
|
|
|
if (!taxAgentIds.contains(duplicateParam.getTaxAgentId())) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98403, "该扣缴义务人不在权限范围内!"));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-30 20:27:17 +08:00
|
|
|
|
// 查询薪资账套的员工信息字段
|
|
|
|
|
|
List<SalarySobEmpFieldPO> salarySobEmpFieldPOS = salarySobEmpFieldService.listSome(SalarySobEmpFieldPO.builder().salarySobId(duplicateParam.getId()).build());
|
|
|
|
|
|
// 查询薪资账套的薪资项目副本
|
2022-09-22 09:06:53 +08:00
|
|
|
|
List<SalarySobItemPO> salarySobItemPOS = salarySobItemService.listBySalarySobIdWithHideItem(SalarySobItemPO.builder().salarySobId(duplicateParam.getId()).build());
|
2022-03-30 20:27:17 +08:00
|
|
|
|
// 查询薪资账套的薪资项目分类
|
2022-09-22 09:06:53 +08:00
|
|
|
|
List<SalarySobItemGroupPO> salarySobItemGroupPOS = salarySobItemGroupService.listSomeWithItemHide(SalarySobItemGroupPO.builder().salarySobId(duplicateParam.getId()).build());
|
2022-03-30 20:27:17 +08:00
|
|
|
|
// 查询薪资账套的调薪计薪规则
|
|
|
|
|
|
List<SalarySobAdjustRulePO> salarySobAdjustRulePOS = salarySobAdjustRuleService.listBySalarySobId(duplicateParam.getId());
|
|
|
|
|
|
// 查询薪资账套的校验规则
|
|
|
|
|
|
List<SalarySobCheckRulePO> salarySobCheckRulePOS = getSalarySobCheckRuleService(user).listBySalarySobId(duplicateParam.getId());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 复制薪资账套的基础设置
|
|
|
|
|
|
SalarySobPO newSalarySob = SalarySobPO.builder()
|
|
|
|
|
|
.name(duplicateParam.getName())
|
2022-06-17 17:22:48 +08:00
|
|
|
|
.taxAgentId(duplicateParam.getTaxAgentId())
|
2022-03-30 20:27:17 +08:00
|
|
|
|
.incomeCategory(salarySobPO.getIncomeCategory())
|
|
|
|
|
|
.salaryCycleType(salarySobPO.getSalaryCycleType())
|
|
|
|
|
|
.salaryCycleFromDay(salarySobPO.getSalaryCycleFromDay())
|
|
|
|
|
|
.taxCycleType(salarySobPO.getTaxCycleType())
|
|
|
|
|
|
.attendCycleType(salarySobPO.getAttendCycleType())
|
|
|
|
|
|
.attendCycleFromDay(salarySobPO.getAttendCycleFromDay())
|
|
|
|
|
|
.socialSecurityCycleType(salarySobPO.getSocialSecurityCycleType())
|
|
|
|
|
|
.disable(salarySobPO.getDisable())
|
2022-05-31 16:41:11 +08:00
|
|
|
|
.creator((long) user.getUID())
|
2022-03-30 20:27:17 +08:00
|
|
|
|
.createTime(new Date())
|
|
|
|
|
|
.updateTime(new Date())
|
|
|
|
|
|
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.deleteType(NumberUtils.INTEGER_ZERO)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
salarySobMapper.insert(newSalarySob);
|
|
|
|
|
|
// 复制
|
|
|
|
|
|
SalarySobDuplicateBO salarySobDuplicateBO = new SalarySobDuplicateBO(newSalarySob, salarySobEmpFieldPOS, salarySobItemPOS,
|
|
|
|
|
|
salarySobItemGroupPOS, salarySobAdjustRulePOS, salarySobCheckRulePOS);
|
2022-05-31 16:41:11 +08:00
|
|
|
|
SalarySobDuplicateBO.Result result = salarySobDuplicateBO.duplicate((long) user.getUID());
|
2022-03-30 20:27:17 +08:00
|
|
|
|
// 复制薪资账套的员工信息字段
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(result.getSalarySobEmpFields())) {
|
|
|
|
|
|
salarySobEmpFieldService.batchInsert(result.getSalarySobEmpFields());
|
|
|
|
|
|
}
|
|
|
|
|
|
// 复制薪资账套的薪资项目副本
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(result.getSalarySobItems())) {
|
|
|
|
|
|
salarySobItemService.batchInsert(result.getSalarySobItems());
|
|
|
|
|
|
}
|
2022-09-22 09:06:53 +08:00
|
|
|
|
|
|
|
|
|
|
// 复制薪资账套的薪资项目隐藏副本
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(result.getSalarySobItems())) {
|
|
|
|
|
|
List<SalarySobItemPO> salarySobItems = result.getSalarySobItems();
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
|
salarySobItems.stream().forEach(k->{
|
|
|
|
|
|
Long salarySobItemShowId = IdGenerator.generate();
|
|
|
|
|
|
SalarySobItemHidePO salarySobItemHidePO = SalarySobItemHidePO.builder()
|
|
|
|
|
|
.id(salarySobItemShowId)
|
|
|
|
|
|
.salarySobId(k.getSalarySobId())
|
|
|
|
|
|
.salaryItemId(k.getSalaryItemId())
|
|
|
|
|
|
.isGroup(0)
|
|
|
|
|
|
.itemHide(k.getItemHide())
|
|
|
|
|
|
.creator((long)user.getUID())
|
|
|
|
|
|
.deleteType(NumberUtils.INTEGER_ZERO)
|
|
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
if(k.getItemHide()==null){
|
|
|
|
|
|
salarySobItemHidePO.setItemHide(Long.valueOf(0));
|
|
|
|
|
|
}
|
|
|
|
|
|
salarySobItemService.InsertItemShow(salarySobItemHidePO);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-30 20:27:17 +08:00
|
|
|
|
// 复制薪资账套的薪资项目分类
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(result.getSalarySobItemGroups())) {
|
|
|
|
|
|
salarySobItemGroupService.batchInsert(result.getSalarySobItemGroups());
|
|
|
|
|
|
}
|
2022-09-22 09:06:53 +08:00
|
|
|
|
|
|
|
|
|
|
// 复制薪资账套的薪资项目分类隐藏信息
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(result.getSalarySobItemGroups())) {
|
|
|
|
|
|
List<SalarySobItemGroupPO> salarySobItemGroups = result.getSalarySobItemGroups();
|
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
|
salarySobItemGroups.stream().forEach(k->{
|
|
|
|
|
|
Long salarySobItemShowId = IdGenerator.generate();
|
|
|
|
|
|
SalarySobItemHidePO salarySobItemHidePO = SalarySobItemHidePO.builder()
|
|
|
|
|
|
.id(salarySobItemShowId)
|
|
|
|
|
|
.salarySobId(k.getSalarySobId())
|
|
|
|
|
|
.salaryItemId(k.getId())
|
|
|
|
|
|
.isGroup(1)
|
|
|
|
|
|
.itemHide(k.getItemHide())
|
|
|
|
|
|
.creator((long)user.getUID())
|
|
|
|
|
|
.deleteType(NumberUtils.INTEGER_ZERO)
|
|
|
|
|
|
.createTime(now)
|
|
|
|
|
|
.updateTime(now)
|
|
|
|
|
|
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
if(k.getItemHide()==null){
|
|
|
|
|
|
salarySobItemHidePO.setItemHide(Long.valueOf(0));
|
|
|
|
|
|
}
|
|
|
|
|
|
salarySobItemService.InsertItemShow(salarySobItemHidePO);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-30 20:27:17 +08:00
|
|
|
|
// 复制薪资账套的调薪计薪规则
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(result.getSalaryAdjustmentRules())) {
|
|
|
|
|
|
salarySobAdjustRuleService.batchInsert(result.getSalaryAdjustmentRules());
|
|
|
|
|
|
}
|
|
|
|
|
|
// 复制薪资账套的校验规则
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(result.getSalarySobCheckRules())) {
|
|
|
|
|
|
getSalarySobCheckRuleService(user).batchSave(result.getSalarySobCheckRules());
|
|
|
|
|
|
}
|
2022-03-22 21:01:38 +08:00
|
|
|
|
// // 记录日志
|
|
|
|
|
|
// LoggerContext<SalarySobPO> loggerContext = new LoggerContext<>();
|
|
|
|
|
|
// loggerContext.setTargetId("" + result.getSalarySob().getId());
|
|
|
|
|
|
// loggerContext.setTargetName(result.getSalarySob().getName());
|
|
|
|
|
|
// loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue());
|
|
|
|
|
|
// loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(98570, "复制薪资账套"));
|
|
|
|
|
|
// loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(98570, "复制薪资账套") + ": " + salarySobPO.getName());
|
|
|
|
|
|
// salarySobLoggerTemplate.write(loggerContext);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public SalarySobCycleDTO getSalarySobCycle(Long id, YearMonth salaryMonth) {
|
|
|
|
|
|
// 查询薪资账套
|
|
|
|
|
|
SalarySobPO salarySobPO = getById(id);
|
|
|
|
|
|
if (Objects.isNull(salarySobPO)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除"));
|
|
|
|
|
|
}
|
|
|
|
|
|
return SalarySobCycleBO.buildSalarySobCycle(salarySobPO, salaryMonth);
|
|
|
|
|
|
}
|
2022-05-31 16:41:11 +08:00
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<SalarySobPO> filterByAuthority(List<SalarySobPO> salarySobPOS) {
|
|
|
|
|
|
long employeeId = user.getUID();
|
|
|
|
|
|
// 判断是否是“总管理员”
|
|
|
|
|
|
Boolean isChief = getTaxAgentService(user).isChief(employeeId);
|
|
|
|
|
|
// 是否开启分权
|
|
|
|
|
|
Boolean openDevolution = getTaxAgentService(user).isOpenDevolution();
|
|
|
|
|
|
// 开启分权后
|
|
|
|
|
|
// 总管理员都能看见
|
2022-06-02 17:10:54 +08:00
|
|
|
|
// 管理员自己管理的个税下的
|
2022-05-31 16:41:11 +08:00
|
|
|
|
if (!openDevolution || isChief) {
|
|
|
|
|
|
return salarySobPOS;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 查询所有的个税扣缴义务人
|
2022-06-01 21:15:48 +08:00
|
|
|
|
Collection<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listAll();
|
2022-05-31 16:41:11 +08:00
|
|
|
|
Set<Long> allTaxAgentIds = SalaryEntityUtil.properties(taxAgentPOS, TaxAgentPO::getId);
|
|
|
|
|
|
// 查询个税扣缴义务人的管理员
|
|
|
|
|
|
List<TaxAgentAdminPO> taxAgentAdminPOS = getTaxAgentAdminService(user).listByTaxAgentIds(allTaxAgentIds);
|
|
|
|
|
|
Map<Long, Set<Long>> adminMap = SalaryEntityUtil.group2Map(taxAgentAdminPOS, TaxAgentAdminPO::getEmployeeId, TaxAgentAdminPO::getTaxAgentId);
|
|
|
|
|
|
return salarySobPOS.stream().filter(salarySobPO -> {
|
|
|
|
|
|
Set<Long> taxAgentIds = adminMap.get(employeeId);
|
|
|
|
|
|
if (CollectionUtils.isEmpty(taxAgentIds)) {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
return taxAgentIds.contains(salarySobPO.getTaxAgentId());
|
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-06-20 19:39:01 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public List<SalarySobPO> listByTaxAgentIds(Collection<Long> taxAgentIds) {
|
|
|
|
|
|
if(CollectionUtils.isEmpty(taxAgentIds)){
|
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
|
}
|
|
|
|
|
|
return getSalarySobMapper().listSome(SalarySobPO.builder().taxAgentIds(taxAgentIds).build());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-06-07 15:43:22 +08:00
|
|
|
|
|
|
|
|
|
|
public List<SalarySobPO> filterByAdmin(List<SalarySobPO> salarySobPOS) {
|
|
|
|
|
|
long employeeId = user.getUID();
|
|
|
|
|
|
// 是否开启分权
|
|
|
|
|
|
Boolean openDevolution = getTaxAgentService(user).isOpenDevolution();
|
|
|
|
|
|
// 开启分权后
|
|
|
|
|
|
// 管理员自己管理的个税下的
|
|
|
|
|
|
if (!openDevolution) {
|
|
|
|
|
|
return salarySobPOS;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 查询所有的个税扣缴义务人
|
|
|
|
|
|
Collection<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listAll();
|
|
|
|
|
|
Set<Long> allTaxAgentIds = SalaryEntityUtil.properties(taxAgentPOS, TaxAgentPO::getId);
|
|
|
|
|
|
// 查询个税扣缴义务人的管理员
|
|
|
|
|
|
List<TaxAgentAdminPO> taxAgentAdminPOS = getTaxAgentAdminService(user).listByTaxAgentIds(allTaxAgentIds);
|
|
|
|
|
|
Map<Long, Set<Long>> adminMap = SalaryEntityUtil.group2Map(taxAgentAdminPOS, TaxAgentAdminPO::getEmployeeId, TaxAgentAdminPO::getTaxAgentId);
|
|
|
|
|
|
return salarySobPOS.stream().filter(salarySobPO -> {
|
|
|
|
|
|
Set<Long> taxAgentIds = adminMap.get(employeeId);
|
|
|
|
|
|
if (CollectionUtils.isEmpty(taxAgentIds)) {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
return taxAgentIds.contains(salarySobPO.getTaxAgentId());
|
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-22 21:01:38 +08:00
|
|
|
|
}
|