2022-03-22 21:01:38 +08:00
|
|
|
|
package com.engine.salary.service.impl;
|
|
|
|
|
|
|
2024-08-13 18:15:04 +08:00
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
2024-08-30 10:49:46 +08:00
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
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;
|
2024-05-30 14:41:28 +08:00
|
|
|
|
import com.engine.hrmelog.entity.dto.LoggerContext;
|
2022-03-25 18:05:07 +08:00
|
|
|
|
import com.engine.salary.biz.*;
|
2024-02-21 18:19:02 +08:00
|
|
|
|
import com.engine.salary.config.SalaryElogConfig;
|
2022-03-25 18:05:07 +08:00
|
|
|
|
import com.engine.salary.constant.SalaryDefaultTenantConstant;
|
2023-04-07 16:06:47 +08:00
|
|
|
|
import com.engine.salary.entity.salaryBill.po.SalaryTemplatePO;
|
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.*;
|
2024-08-08 09:50:04 +08:00
|
|
|
|
import com.engine.salary.entity.salarysob.config.SalarySobConfig;
|
2022-03-22 21:01:38 +08:00
|
|
|
|
import com.engine.salary.entity.salarysob.dto.SalarySobCycleDTO;
|
2023-04-17 10:10:39 +08:00
|
|
|
|
import com.engine.salary.entity.salarysob.param.*;
|
2022-03-25 18:05:07 +08:00
|
|
|
|
import com.engine.salary.entity.salarysob.po.*;
|
2023-04-17 10:10:39 +08:00
|
|
|
|
import com.engine.salary.entity.taxagent.po.TaxAgentExtRangePO;
|
2024-09-04 13:59:00 +08:00
|
|
|
|
import com.engine.salary.entity.taxagent.po.TaxAgentManageRangePO;
|
2024-02-21 18:19:02 +08:00
|
|
|
|
import com.engine.salary.enums.OperateTypeEnum;
|
2022-03-25 18:05:07 +08:00
|
|
|
|
import com.engine.salary.enums.SalarySystemTypeEnum;
|
2024-08-28 10:02:39 +08:00
|
|
|
|
import com.engine.salary.enums.auth.AuthFilterTypeEnum;
|
2022-03-22 21:01:38 +08:00
|
|
|
|
import com.engine.salary.enums.salarysob.IncomeCategoryEnum;
|
|
|
|
|
|
import com.engine.salary.exception.SalaryRunTimeException;
|
2022-06-20 19:39:01 +08:00
|
|
|
|
import com.engine.salary.mapper.salarysob.SalarySobMapper;
|
2024-09-02 14:13:29 +08:00
|
|
|
|
import com.engine.salary.mapper.salarysob.SobTaxLinkMapper;
|
2023-04-17 10:10:39 +08:00
|
|
|
|
import com.engine.salary.mapper.taxagent.TaxAgentExtRangeMapper;
|
2022-05-05 11:19:13 +08:00
|
|
|
|
import com.engine.salary.service.*;
|
2024-08-28 10:02:39 +08:00
|
|
|
|
import com.engine.salary.service.auth.AuthService;
|
|
|
|
|
|
import com.engine.salary.service.auth.AuthServiceImpl;
|
2024-08-16 11:18:27 +08:00
|
|
|
|
import com.engine.salary.sys.entity.vo.UploadConfigResponse;
|
2023-07-04 09:32:12 +08:00
|
|
|
|
import com.engine.salary.sys.enums.TaxDeclarationFunctionEnum;
|
|
|
|
|
|
import com.engine.salary.sys.service.SalarySysConfService;
|
|
|
|
|
|
import com.engine.salary.sys.service.impl.SalarySysConfServiceImpl;
|
2022-03-22 21:01:38 +08:00
|
|
|
|
import com.engine.salary.util.SalaryEntityUtil;
|
|
|
|
|
|
import com.engine.salary.util.SalaryI18nUtil;
|
2024-08-13 18:15:04 +08:00
|
|
|
|
import com.engine.salary.util.db.IdGenerator;
|
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;
|
2024-08-15 16:25:31 +08:00
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
2022-03-22 21:01:38 +08:00
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
|
|
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
|
|
|
|
|
|
**/
|
2024-08-15 16:25:31 +08:00
|
|
|
|
@Slf4j
|
2022-03-22 21:01:38 +08:00
|
|
|
|
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-12-13 16:39:39 +08:00
|
|
|
|
// private SalarySobBackItemMapper getSalarySobBackItemMapper() {
|
|
|
|
|
|
// return MapperProxyFactory.getProxy(SalarySobBackItemMapper.class);
|
|
|
|
|
|
// }
|
2022-11-22 14:36:59 +08:00
|
|
|
|
|
2024-08-08 16:53:31 +08:00
|
|
|
|
private SalarySobItemService getSalarySobItemService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SalarySobItemServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private SalarySobItemGroupService getSalarySobItemGroupService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SalarySobItemGroupServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private SalarySobEmpFieldService getSalarySobEmpFieldService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SalarySobEmpFieldServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private SalarySobAdjustRuleService getSalarySobAdjustRuleService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SalarySobAdjustRuleServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-13 18:15:04 +08:00
|
|
|
|
private SalaryFormulaService getSalaryFormulaService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SalaryFormulaServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-08 16:53:31 +08:00
|
|
|
|
|
2022-06-20 19:39:01 +08:00
|
|
|
|
private SalarySobMapper getSalarySobMapper() {
|
|
|
|
|
|
return MapperProxyFactory.getProxy(SalarySobMapper.class);
|
|
|
|
|
|
}
|
2022-03-24 16:59:52 +08:00
|
|
|
|
|
2023-04-17 10:10:39 +08:00
|
|
|
|
private TaxAgentExtRangeMapper getTaxAgentExtRangeMapper() {
|
|
|
|
|
|
return MapperProxyFactory.getProxy(TaxAgentExtRangeMapper.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-02 14:13:29 +08:00
|
|
|
|
private SobTaxLinkMapper getSobTaxLinkMapper() {
|
|
|
|
|
|
return MapperProxyFactory.getProxy(SobTaxLinkMapper.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-04-17 10:10:39 +08:00
|
|
|
|
private SalarySobExtRangeService getSalarySobExtRangeService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SalarySobExtRangeServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-07 16:06:47 +08:00
|
|
|
|
private SalaryTemplateService getSalaryTemplateService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SalaryTemplateServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-07-04 09:32:12 +08:00
|
|
|
|
private SalarySysConfService getSalarySysConfService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SalarySysConfServiceImpl.class, user);
|
|
|
|
|
|
}
|
2022-11-16 10:32:05 +08:00
|
|
|
|
|
2024-08-28 10:02:39 +08:00
|
|
|
|
public AuthService getAuthService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(AuthServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-04-25 15:30:25 +08:00
|
|
|
|
private SalaryApprovalRuleService getSalaryApprovalRuleService(User user) {
|
|
|
|
|
|
return ServiceUtil.getService(SalaryApprovalRuleServiceImpl.class, user);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-22 21:01:38 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public SalarySobPO getById(Long id) {
|
2024-09-05 10:26:52 +08:00
|
|
|
|
handleHistory();
|
|
|
|
|
|
return getSalarySobMapper().getById(id);
|
2022-03-22 21:01:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-02 17:36:41 +08:00
|
|
|
|
|
2022-03-22 21:01:38 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public List<SalarySobPO> listByIds(Collection<Long> ids) {
|
|
|
|
|
|
if (CollectionUtils.isEmpty(ids)) {
|
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
|
}
|
2024-09-05 10:26:52 +08:00
|
|
|
|
return getSalarySobMapper().listSome(SalarySobPO.builder().ids(ids).build());
|
2022-03-22 21:01:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@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());
|
2024-09-04 13:59:00 +08:00
|
|
|
|
return getAuthService(user).auth(salarySobPOS, AuthFilterTypeEnum.DATA_OPT, SalarySobPO.class);
|
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());
|
2024-09-04 13:59:00 +08:00
|
|
|
|
return getAuthService(user).auth(salarySobPOS, AuthFilterTypeEnum.DATA_OPT, SalarySobPO.class);
|
2022-03-22 21:01:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-05-26 11:17:25 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public List<SalarySobPO> listAll() {
|
|
|
|
|
|
return salarySobMapper.listSome(SalarySobPO.builder().build());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-13 13:45:24 +08:00
|
|
|
|
@Override
|
2024-09-09 11:13:10 +08:00
|
|
|
|
public List<SalarySobPO> listAuth(SalarySobQueryParam param) {
|
|
|
|
|
|
// 开启分权后需要过滤薪资账套
|
|
|
|
|
|
String name = param.getName();
|
|
|
|
|
|
// 查询所有的薪资账套
|
|
|
|
|
|
SalarySobPO build = SalarySobPO.builder().build();
|
|
|
|
|
|
if (StringUtils.isNotBlank(name)) {
|
|
|
|
|
|
build.setName(name);
|
2024-08-13 13:45:24 +08:00
|
|
|
|
}
|
2024-09-09 11:13:10 +08:00
|
|
|
|
if (param.getTaxAgentId() != null) {
|
|
|
|
|
|
List<SobTaxLinkPO> sobTaxLinkPOS = getSobTaxLinkMapper().listSome(SobTaxLinkPO.builder().taxAgentId(param.getTaxAgentId()).build());
|
|
|
|
|
|
build.setIds(sobTaxLinkPOS.stream().map(SobTaxLinkPO::getTaxAgentId).collect(Collectors.toList()));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-12 11:50:18 +08:00
|
|
|
|
if(CollectionUtil.isNotEmpty(param.getTaxAgentIds())){
|
|
|
|
|
|
List<SobTaxLinkPO> sobTaxLinkPOS = getSobTaxLinkMapper().listSome(SobTaxLinkPO.builder().taxAgentIds(param.getTaxAgentIds()).build());
|
|
|
|
|
|
build.setIds(sobTaxLinkPOS.stream().map(SobTaxLinkPO::getTaxAgentId).collect(Collectors.toList()));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-09 11:13:10 +08:00
|
|
|
|
List<SalarySobPO> list = getSalarySobMapper().listSome(build);
|
|
|
|
|
|
return getAuthService(user).auth(list, param.getFilterType(), SalarySobPO.class);
|
2024-08-13 13:45:24 +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());
|
2024-09-09 11:13:10 +08:00
|
|
|
|
return getAuthService(user).auth(salarySobPOS, AuthFilterTypeEnum.QUERY_DATA, SalarySobPO.class);
|
2022-06-07 15:43:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public List<SalarySobPO> listByTaxAgentId(Long taxAgentId) {
|
2024-09-03 14:30:57 +08:00
|
|
|
|
return getSalarySobMapper().listByTaxAgentId(taxAgentId);
|
2022-06-07 15:43:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
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) {
|
|
|
|
|
|
// 开启分权后需要过滤薪资账套
|
|
|
|
|
|
String name = queryParam.getName();
|
|
|
|
|
|
// 查询所有的薪资账套
|
|
|
|
|
|
SalarySobPO build = SalarySobPO.builder().build();
|
|
|
|
|
|
if (StringUtils.isNotBlank(name)) {
|
|
|
|
|
|
build.setName(name);
|
|
|
|
|
|
}
|
2024-04-01 20:25:23 +08:00
|
|
|
|
if (queryParam.getTaxAgentId() != null) {
|
2024-09-03 15:48:20 +08:00
|
|
|
|
List<SobTaxLinkPO> sobTaxLinkPOS = getSobTaxLinkMapper().listSome(SobTaxLinkPO.builder().taxAgentId(queryParam.getTaxAgentId()).build());
|
|
|
|
|
|
build.setIds(sobTaxLinkPOS.stream().map(SobTaxLinkPO::getTaxAgentId).collect(Collectors.toList()));
|
2023-11-20 16:14:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-05 10:26:52 +08:00
|
|
|
|
List<SalarySobPO> list = getSalarySobMapper().listSome(build);
|
2024-08-28 10:02:39 +08:00
|
|
|
|
|
|
|
|
|
|
list = getAuthService(user).auth(list, AuthFilterTypeEnum.DATA_OPT, SalarySobPO.class);
|
2024-09-05 10:26:52 +08:00
|
|
|
|
|
2024-08-28 10:02:39 +08:00
|
|
|
|
return SalaryPageUtil.buildPage(queryParam.getCurrent(), queryParam.getPageSize(), list, 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) {
|
2024-09-04 13:59:00 +08:00
|
|
|
|
|
2022-06-01 21:15:48 +08:00
|
|
|
|
String name = queryParam.getName();
|
|
|
|
|
|
// 查询所有的薪资账套
|
|
|
|
|
|
SalarySobPO build = SalarySobPO.builder().build();
|
|
|
|
|
|
if (StringUtils.isNotBlank(name)) {
|
|
|
|
|
|
build.setName(name);
|
|
|
|
|
|
}
|
2024-09-04 13:59:00 +08:00
|
|
|
|
if (queryParam.getTaxAgentId() != null) {
|
|
|
|
|
|
List<SobTaxLinkPO> sobTaxLinkPOS = getSobTaxLinkMapper().listSome(SobTaxLinkPO.builder().taxAgentId(queryParam.getTaxAgentId()).build());
|
|
|
|
|
|
build.setIds(sobTaxLinkPOS.stream().map(SobTaxLinkPO::getTaxAgentId).collect(Collectors.toList()));
|
|
|
|
|
|
}
|
2022-06-01 21:15:48 +08:00
|
|
|
|
|
2024-09-04 13:59:00 +08:00
|
|
|
|
List<SalarySobPO> list = salarySobMapper.listSome(build);
|
2022-06-01 21:15:48 +08:00
|
|
|
|
|
2024-09-04 13:59:00 +08:00
|
|
|
|
return getAuthService(user).auth(list, AuthFilterTypeEnum.DATA_OPT, SalarySobPO.class);
|
2022-06-01 21:15:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
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);
|
2024-02-21 18:19:02 +08:00
|
|
|
|
// 记录日志
|
2024-08-08 16:53:31 +08:00
|
|
|
|
LoggerContext<SalarySobPO> loggerContext = new LoggerContext<>();
|
|
|
|
|
|
loggerContext.setUser(user);
|
|
|
|
|
|
loggerContext.setTargetId(String.valueOf(salarySobPO.getId()));
|
|
|
|
|
|
loggerContext.setTargetName(salarySobPO.getName());
|
|
|
|
|
|
loggerContext.setOperateType(OperateTypeEnum.ADD.getValue());
|
|
|
|
|
|
loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "新建薪资账套"));
|
|
|
|
|
|
loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "新建薪资账套") + ": " + salarySobPO.getName());
|
|
|
|
|
|
loggerContext.setNewValues(salarySobPO);
|
|
|
|
|
|
SalaryElogConfig.salarySobLoggerTemplate.write(loggerContext);
|
2024-09-02 14:13:29 +08:00
|
|
|
|
|
|
|
|
|
|
//保存个税扣缴义务人联系
|
2024-09-04 13:59:00 +08:00
|
|
|
|
saveSobTaxLink(saveParam.getTaxAgentIds(), salarySobPO);
|
2022-03-22 21:01:38 +08:00
|
|
|
|
// 新建薪资账套时,保存默认的员工信息字段
|
|
|
|
|
|
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();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-04 13:59:00 +08:00
|
|
|
|
private void saveSobTaxLink(List<Long> taxAgentIds, SalarySobPO salarySobPO) {
|
2024-09-02 14:13:29 +08:00
|
|
|
|
getSobTaxLinkMapper().deleteBySobId(salarySobPO.getId());
|
|
|
|
|
|
for (Long taxAgentId : taxAgentIds) {
|
|
|
|
|
|
SobTaxLinkPO taxLinkPO = SobTaxLinkPO.builder()
|
|
|
|
|
|
.id(IdGenerator.generate())
|
|
|
|
|
|
.taxAgentId(taxAgentId)
|
|
|
|
|
|
.sobId(salarySobPO.getId())
|
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
|
.createTime(new Date())
|
|
|
|
|
|
.updateTime(new Date())
|
|
|
|
|
|
.deleteType(0)
|
|
|
|
|
|
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
getSobTaxLinkMapper().insertIgnoreNull(taxLinkPO);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
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());
|
2023-07-04 09:32:12 +08:00
|
|
|
|
|
|
|
|
|
|
//是否需要系统算税,不需要则去除系统项目
|
|
|
|
|
|
TaxDeclarationFunctionEnum taxDeclarationFunctionEnum = getSalarySysConfService(user).getTaxDeclaration();
|
|
|
|
|
|
if (taxDeclarationFunctionEnum == TaxDeclarationFunctionEnum.CLOSURE) {
|
|
|
|
|
|
salarySobDefaultItemGroupPOS = new ArrayList<>();
|
|
|
|
|
|
salarySobDefaultItemPOS = new ArrayList<>();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-25 18:05:07 +08:00
|
|
|
|
// 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
|
|
|
|
// 需要添加进薪资项目中的回算薪资项目
|
2023-07-04 09:32:12 +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
|
|
|
|
|
2024-08-13 18:15:04 +08:00
|
|
|
|
List<SalarySobItemPO> list = new ArrayList<>(result.getNeedInsertSalarySobItems().stream().collect(Collectors.toMap(SalarySobItemPO::getSalaryItemId, Function.identity(), (oldValue, newValue) -> oldValue)).values());
|
2022-06-06 19:24:49 +08:00
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
/**
|
|
|
|
|
|
* @return void
|
2023-07-04 09:32:12 +08:00
|
|
|
|
* @description 新建薪资账套时,保存默认的关联人员范围及从范围中排除
|
2022-10-09 17:51:30 +08:00
|
|
|
|
* @author Harryxzy
|
|
|
|
|
|
* @date 2022/10/9 15:30
|
|
|
|
|
|
*/
|
2023-10-16 16:59:18 +08:00
|
|
|
|
public void saveDefaultEmployeeRange(SalarySobPO salarySobPO) {
|
2024-09-04 13:59:00 +08:00
|
|
|
|
Long sobId = salarySobPO.getId();
|
2024-09-05 10:26:52 +08:00
|
|
|
|
salarySobPO = getById(sobId);
|
2024-09-04 13:59:00 +08:00
|
|
|
|
|
|
|
|
|
|
salarySobPO.getTaxAgentIds().forEach(taxAgentId -> {
|
|
|
|
|
|
// 获取人员范围列表
|
|
|
|
|
|
List<TaxAgentManageRangePO> includeList = getTaxAgentManageRangeService(user).listByTaxAgentIdAndIncludeType(taxAgentId, NumberUtils.INTEGER_ONE);
|
|
|
|
|
|
includeList.forEach(item -> {
|
2024-09-11 10:28:20 +08:00
|
|
|
|
item.setEmployeeStatus(parseJson2ValueStr(item.getEmployeeStatus()));
|
2024-09-04 13:59:00 +08:00
|
|
|
|
});
|
|
|
|
|
|
// 获取从范围中排除
|
|
|
|
|
|
List<TaxAgentManageRangePO> excludeList = getTaxAgentManageRangeService(user).listByTaxAgentIdAndIncludeType(taxAgentId, NumberUtils.INTEGER_ZERO);
|
|
|
|
|
|
excludeList.forEach(item -> {
|
2024-09-11 10:28:20 +08:00
|
|
|
|
item.setEmployeeStatus(parseJson2ValueStr(item.getEmployeeStatus()));
|
2024-09-04 13:59:00 +08:00
|
|
|
|
});
|
|
|
|
|
|
// 将TaxAgentManageRangeListDTO转换为SalarySobRangePO
|
|
|
|
|
|
List<SalarySobRangePO> rangeList = convert2SalarySobRangePO(sobId, includeList, excludeList);
|
|
|
|
|
|
// 保存SalarySobRangePO
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(rangeList)) {
|
|
|
|
|
|
salarySobRangeBiz.batchInsert(rangeList);
|
|
|
|
|
|
}
|
2022-10-09 17:51:30 +08:00
|
|
|
|
|
2024-09-04 13:59:00 +08:00
|
|
|
|
//非系统人员
|
|
|
|
|
|
List<TaxAgentExtRangePO> taxAgentExtRangePOS = getTaxAgentExtRangeMapper().listSome(TaxAgentExtRangePO.builder().taxAgentId(taxAgentId).build());
|
|
|
|
|
|
taxAgentExtRangePOS.forEach(po -> {
|
|
|
|
|
|
SalarySobRangeExtSaveParam build = SalarySobRangeExtSaveParam.builder().salarySobId(sobId).targetIds(Collections.singletonList(po.getTargetId())).targetType(1L).build();
|
|
|
|
|
|
getSalarySobExtRangeService(user).saveExtRange(build);
|
|
|
|
|
|
});
|
2023-04-17 15:31:56 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
2023-04-17 10:10:39 +08:00
|
|
|
|
|
2022-10-09 17:51:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2022-11-22 14:36:59 +08:00
|
|
|
|
* @return List<SalarySobRangePO>
|
2023-07-04 09:32:12 +08:00
|
|
|
|
* @description 将TaxAgentManageRangeListDTO转换为SalarySobRangePO
|
2022-10-09 17:51:30 +08:00
|
|
|
|
* @author Harryxzy
|
|
|
|
|
|
* @date 2022/10/9 16:06
|
|
|
|
|
|
*/
|
2024-09-04 13:59:00 +08:00
|
|
|
|
private List<SalarySobRangePO> convert2SalarySobRangePO(Long salarySobID, List<TaxAgentManageRangePO> includeList, List<TaxAgentManageRangePO> excludeList) {
|
2022-10-09 17:51:30 +08:00
|
|
|
|
Date now = new Date();
|
|
|
|
|
|
ArrayList<SalarySobRangePO> result = new ArrayList<SalarySobRangePO>();
|
|
|
|
|
|
// 关联人员范围
|
2023-07-04 09:32:12 +08:00
|
|
|
|
includeList.stream().forEach(item -> {
|
2022-10-09 17:51:30 +08:00
|
|
|
|
SalarySobRangePO salarySobRangePO = SalarySobRangePO.builder()
|
|
|
|
|
|
.salarySobId(salarySobID)
|
2024-09-04 13:59:00 +08:00
|
|
|
|
.targetType(item.getTargetType())
|
2022-10-09 17:51:30 +08:00
|
|
|
|
.targetId(item.getTargetId())
|
2024-08-15 10:37:41 +08:00
|
|
|
|
.target(item.getTarget())
|
2022-10-09 17:51:30 +08:00
|
|
|
|
.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);
|
|
|
|
|
|
});
|
|
|
|
|
|
// 从范围中排除
|
2023-07-04 09:32:12 +08:00
|
|
|
|
excludeList.stream().forEach(item -> {
|
2022-10-09 17:51:30 +08:00
|
|
|
|
SalarySobRangePO salarySobRangePO = SalarySobRangePO.builder()
|
|
|
|
|
|
.salarySobId(salarySobID)
|
2024-09-04 13:59:00 +08:00
|
|
|
|
.targetType(item.getTargetType())
|
2022-10-09 17:51:30 +08:00
|
|
|
|
.targetId(item.getTargetId())
|
2024-08-15 13:47:55 +08:00
|
|
|
|
.target(item.getTarget())
|
2022-10-09 17:51:30 +08:00
|
|
|
|
.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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2024-09-11 10:28:20 +08:00
|
|
|
|
* ["0","1","2","3","4","5","6"] -> 0,1,2,3,4,5,6
|
|
|
|
|
|
* @param employeeStatus
|
|
|
|
|
|
* @return
|
2022-10-09 17:51:30 +08:00
|
|
|
|
*/
|
2024-09-11 10:28:20 +08:00
|
|
|
|
private String parseJson2ValueStr(String employeeStatus) {
|
|
|
|
|
|
return employeeStatus.replace("[","").replace("]","").replaceAll("\"", "");
|
2022-10-09 17:51:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
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())
|
2024-09-04 13:59:00 +08:00
|
|
|
|
.setTaxAgentId(saveParam.getTaxAgentIds().get(0))
|
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);
|
2024-09-02 14:13:29 +08:00
|
|
|
|
|
|
|
|
|
|
//保存个税扣缴义务人联系
|
2024-09-04 13:59:00 +08:00
|
|
|
|
saveSobTaxLink(saveParam.getTaxAgentIds(), salarySobPO);
|
2024-09-02 14:13:29 +08:00
|
|
|
|
|
2022-03-22 21:01:38 +08:00
|
|
|
|
// 记录日志
|
2024-02-23 15:11:56 +08:00
|
|
|
|
SalarySobPO salarySobPO4log = getSalarySobMapper().getById(newSalarySobPO.getId());
|
|
|
|
|
|
LoggerContext<SalarySobPO> loggerContext = new LoggerContext<>();
|
|
|
|
|
|
loggerContext.setUser(user);
|
|
|
|
|
|
loggerContext.setTargetId(String.valueOf(newSalarySobPO.getId()));
|
|
|
|
|
|
loggerContext.setTargetName(newSalarySobPO.getName());
|
|
|
|
|
|
loggerContext.setOperateType(OperateTypeEnum.UPDATE.getValue());
|
|
|
|
|
|
loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "编辑薪资账套基础设置"));
|
|
|
|
|
|
loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "编辑薪资账套基础设置"));
|
|
|
|
|
|
loggerContext.setOldValues(salarySobPO);
|
|
|
|
|
|
loggerContext.setNewValues(salarySobPO4log);
|
|
|
|
|
|
SalaryElogConfig.salarySobLoggerTemplate.write(loggerContext);
|
2022-03-22 21:01:38 +08:00
|
|
|
|
// 返回薪资账套的主键id
|
|
|
|
|
|
return salarySobPO.getId();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void updateDisable(SalarySobDisableParam disableParam) {
|
|
|
|
|
|
// 查询薪资账套
|
|
|
|
|
|
SalarySobPO salarySobPO = getById(disableParam.getId());
|
2024-02-21 18:19:02 +08:00
|
|
|
|
SalarySobPO oldSalarySobPO = new SalarySobPO();
|
|
|
|
|
|
BeanUtils.copyProperties(salarySobPO, oldSalarySobPO);
|
2022-03-22 21:01:38 +08:00
|
|
|
|
if (Objects.isNull(salarySobPO)) {
|
|
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98379, "参数错误,薪资账套不存在或者已被删除"));
|
|
|
|
|
|
}
|
|
|
|
|
|
// 启用/禁用 薪资账套
|
|
|
|
|
|
salarySobPO.setDisable(disableParam.getDisable());
|
|
|
|
|
|
salarySobPO.setUpdateTime(new Date());
|
|
|
|
|
|
salarySobMapper.updateById(salarySobPO);
|
2024-02-21 18:19:02 +08:00
|
|
|
|
// 记录日志
|
2024-08-15 16:25:31 +08:00
|
|
|
|
String operateTypeName = Objects.equals(disableParam.getDisable(), NumberUtils.INTEGER_ONE) ?
|
|
|
|
|
|
SalaryI18nUtil.getI18nLabel(0, "禁用薪资账套") : SalaryI18nUtil.getI18nLabel(0, "启用薪资账套");
|
|
|
|
|
|
LoggerContext<SalarySobPO> 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 + ": " + salarySobPO.getName());
|
|
|
|
|
|
loggerContext.setOldValues(oldSalarySobPO);
|
|
|
|
|
|
loggerContext.setNewValues(salarySobPO);
|
|
|
|
|
|
SalaryElogConfig.salarySobLoggerTemplate.write(loggerContext);
|
2022-03-22 21:01:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@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, "账套已用于薪资核算,不能删除"));
|
|
|
|
|
|
}
|
2023-04-07 16:06:47 +08:00
|
|
|
|
|
|
|
|
|
|
// 根据薪资账套id查询工资单模板,存在该账套下的工资单模板就不能删除账套了
|
|
|
|
|
|
List<SalaryTemplatePO> salaryTemplatePOS = getSalaryTemplateService(user).getBySalarySobIds(ids);
|
2023-07-04 09:32:12 +08:00
|
|
|
|
if (CollectionUtils.isNotEmpty(salaryTemplatePOS)) {
|
2023-04-07 16:06:47 +08:00
|
|
|
|
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(99713, "账套存在工资单模板,不能删除,请先删除该账套所对应的工资单模板"));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-05-05 11:19:13 +08:00
|
|
|
|
//关联其他的删除
|
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
|
|
|
|
// 删除薪资账套的回算薪资项目
|
2022-12-13 16:39:39 +08:00
|
|
|
|
getSalarySobBackItemService(user).deleteBySalarySobIds(ids);
|
2022-11-22 14:36:59 +08:00
|
|
|
|
// 删除薪资账套的校验规则
|
2022-03-30 20:27:17 +08:00
|
|
|
|
getSalarySobCheckRuleService(user).deleteBySalarySobIds(ids);
|
2024-04-25 15:30:25 +08:00
|
|
|
|
// 删除薪资审批规则
|
|
|
|
|
|
getSalaryApprovalRuleService(user).deleteBySalarySobIds(ids);
|
2024-02-21 18:19:02 +08:00
|
|
|
|
// 记录日志
|
2024-08-15 16:25:31 +08:00
|
|
|
|
salarySobPOS.forEach(salarySobPO -> {
|
|
|
|
|
|
LoggerContext<SalarySobPO> loggerContext = new LoggerContext<>();
|
|
|
|
|
|
loggerContext.setUser(user);
|
|
|
|
|
|
loggerContext.setTargetId("" + salarySobPO.getId());
|
|
|
|
|
|
loggerContext.setTargetName(salarySobPO.getName());
|
|
|
|
|
|
loggerContext.setOperateType(OperateTypeEnum.DELETE.getValue());
|
|
|
|
|
|
loggerContext.setOperateTypeName(SalaryI18nUtil.getI18nLabel(0, "删除薪资账套"));
|
|
|
|
|
|
loggerContext.setOperatedesc(SalaryI18nUtil.getI18nLabel(0, "删除薪资账套"));
|
|
|
|
|
|
loggerContext.setOldValues(salarySobPO);
|
|
|
|
|
|
SalaryElogConfig.salarySobLoggerTemplate.write(loggerContext);
|
|
|
|
|
|
});
|
2022-03-22 21:01:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@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, "薪资账套名称已存在"));
|
|
|
|
|
|
}
|
2023-07-04 09:32:12 +08:00
|
|
|
|
|
2022-03-30 20:27:17 +08:00
|
|
|
|
// 查询薪资账套的员工信息字段
|
|
|
|
|
|
List<SalarySobEmpFieldPO> salarySobEmpFieldPOS = salarySobEmpFieldService.listSome(SalarySobEmpFieldPO.builder().salarySobId(duplicateParam.getId()).build());
|
|
|
|
|
|
// 查询薪资账套的薪资项目副本
|
2024-05-30 12:01:53 +08:00
|
|
|
|
List<SalarySobItemPO> salarySobItemPOS = salarySobItemService.listSome(SalarySobItemPO.builder().salarySobId(duplicateParam.getId()).build());
|
2023-04-07 15:14:07 +08:00
|
|
|
|
// 薪资项目副本去重
|
|
|
|
|
|
salarySobItemPOS = salarySobItemPOS.stream().filter(SalaryEntityUtil.distinctByKey(PO -> PO.getSalarySobId() + "-" + PO.getSalaryItemId())).collect(Collectors.toList());
|
2022-03-30 20:27:17 +08:00
|
|
|
|
// 查询薪资账套的薪资项目分类
|
2024-05-06 16:03:29 +08:00
|
|
|
|
List<SalarySobItemGroupPO> salarySobItemGroupPOS = salarySobItemGroupService.listSome(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());
|
2022-12-13 16:39:39 +08:00
|
|
|
|
// 查询薪资账套的回算薪资项目
|
|
|
|
|
|
List<SalarySobBackItemPO> salarySobBackItemPOS = getSalarySobBackItemService(user).listBySalarySobId(duplicateParam.getId());
|
2022-03-30 20:27:17 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 复制薪资账套的基础设置
|
|
|
|
|
|
SalarySobPO newSalarySob = SalarySobPO.builder()
|
|
|
|
|
|
.name(duplicateParam.getName())
|
2024-09-04 13:59:00 +08:00
|
|
|
|
.taxAgentId(duplicateParam.getTaxAgentIds().get(0))
|
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);
|
2024-09-04 13:59:00 +08:00
|
|
|
|
|
|
|
|
|
|
|
2024-12-27 14:34:03 +08:00
|
|
|
|
saveSobTaxLink(duplicateParam.getTaxAgentIds(), newSalarySob);
|
2022-03-30 20:27:17 +08:00
|
|
|
|
// 复制
|
|
|
|
|
|
SalarySobDuplicateBO salarySobDuplicateBO = new SalarySobDuplicateBO(newSalarySob, salarySobEmpFieldPOS, salarySobItemPOS,
|
2022-12-13 16:39:39 +08:00
|
|
|
|
salarySobItemGroupPOS, salarySobAdjustRulePOS, salarySobCheckRulePOS, salarySobBackItemPOS);
|
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
|
|
|
|
|
2022-12-13 16:39:39 +08:00
|
|
|
|
// 复制薪资账套的回算薪资项目
|
2023-07-04 09:32:12 +08:00
|
|
|
|
if (CollectionUtils.isNotEmpty(result.getSalarySobBackItems())) {
|
2022-12-13 16:39:39 +08:00
|
|
|
|
getSalarySobBackItemService(user).batchInsert(result.getSalarySobBackItems());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-22 09:06:53 +08:00
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
|
}
|
2024-08-15 16:25:31 +08:00
|
|
|
|
// 记录日志
|
|
|
|
|
|
LoggerContext<SalarySobPO> loggerContext = new LoggerContext<>();
|
|
|
|
|
|
loggerContext.setUser(user);
|
|
|
|
|
|
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());
|
|
|
|
|
|
SalaryElogConfig.salarySobLoggerTemplate.write(loggerContext);
|
2022-03-22 21:01:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@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
|
2024-09-02 17:36:41 +08:00
|
|
|
|
public List<SalarySobPO> listByTaxAgentIds(List<Long> taxAgentIds) {
|
2023-07-04 09:32:12 +08:00
|
|
|
|
if (CollectionUtils.isEmpty(taxAgentIds)) {
|
2022-06-20 19:39:01 +08:00
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
|
}
|
2024-09-04 13:59:00 +08:00
|
|
|
|
return getSalarySobMapper().listByTaxAgentIds(taxAgentIds);
|
2022-06-20 19:39:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-08 09:50:04 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public List<SalarySobConfig> getConfig(Long taxAgentId) {
|
2024-08-08 16:53:31 +08:00
|
|
|
|
List<SalarySobPO> salarySobPOS = getSalarySobMapper().listSome(SalarySobPO.builder().taxAgentId(taxAgentId).build());
|
|
|
|
|
|
return salarySobPOS.stream().map(salarySobPO -> {
|
|
|
|
|
|
Long salarySobId = salarySobPO.getId();
|
|
|
|
|
|
List<SalarySobEmpFieldPO> salarySobEmpFieldPOS = getSalarySobEmpFieldService(user).listBySalarySobId(salarySobId);
|
2024-08-13 18:15:04 +08:00
|
|
|
|
List<SalarySobItemGroupPO> salarySobItemGroupPOS = getSalarySobItemGroupService(user).getConfig(salarySobId);
|
|
|
|
|
|
List<SalarySobItemPO> salarySobItemPOS = getSalarySobItemService(user).getConfig(salarySobId);
|
|
|
|
|
|
List<SalarySobBackItemPO> salarySobBackItemPOS = getSalarySobBackItemService(user).getConfig(salarySobId);
|
2024-08-08 16:53:31 +08:00
|
|
|
|
List<SalarySobAdjustRulePO> salarySobAdjustRulePOS = getSalarySobAdjustRuleService(user).listBySalarySobId(salarySobId);
|
2024-08-13 18:15:04 +08:00
|
|
|
|
return SalarySobConfig.builder().salarySob(salarySobPO).salarySobEmpFields(salarySobEmpFieldPOS).salarySobItemGroups(salarySobItemGroupPOS).salarySobItems(salarySobItemPOS).salarySobBackItems(salarySobBackItemPOS).salarySobAdjustRules(salarySobAdjustRulePOS).build();
|
2024-08-08 16:53:31 +08:00
|
|
|
|
}).collect(Collectors.toList());
|
2024-08-08 09:50:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-09 09:22:27 +08:00
|
|
|
|
@Override
|
2024-08-16 11:18:27 +08:00
|
|
|
|
public List<UploadConfigResponse.Result> parseConfig(Long taxAgentId, List<SalarySobConfig> salarySobConfigs) {
|
|
|
|
|
|
List<UploadConfigResponse.Result> results = new ArrayList<>();
|
2024-08-09 09:22:27 +08:00
|
|
|
|
long uid = user.getUID();
|
|
|
|
|
|
List<SalarySobPO> salarySobPOS = listByTaxAgentId(taxAgentId);
|
|
|
|
|
|
Map<String, SalarySobPO> sobPOMap = SalaryEntityUtil.convert2Map(salarySobPOS, SalarySobPO::getName);
|
|
|
|
|
|
|
2024-08-14 14:47:27 +08:00
|
|
|
|
List<SalaryItemPO> salaryItemPOList = getSalaryItemService(user).listAll();
|
|
|
|
|
|
Map<String, SalaryItemPO> salaryItemNameMap = SalaryEntityUtil.convert2Map(salaryItemPOList, SalaryItemPO::getName);
|
|
|
|
|
|
|
2024-08-13 18:15:04 +08:00
|
|
|
|
Optional.ofNullable(salarySobConfigs).orElse(new ArrayList<>()).forEach(salarySobConfig -> {
|
|
|
|
|
|
SalarySobPO salarySobPO = salarySobConfig.getSalarySob();
|
|
|
|
|
|
String sobPOName = salarySobPO.getName();
|
2024-08-16 11:18:27 +08:00
|
|
|
|
|
|
|
|
|
|
UploadConfigResponse.Result result = UploadConfigResponse.Result.builder()
|
|
|
|
|
|
.message(String.format("账套:%s基础信息加载完毕", sobPOName))
|
|
|
|
|
|
.success(new ArrayList<>())
|
|
|
|
|
|
.warning(new ArrayList<>())
|
|
|
|
|
|
.error(new ArrayList<>())
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
2024-08-13 18:15:04 +08:00
|
|
|
|
if (sobPOMap.containsKey(sobPOName)) {
|
|
|
|
|
|
SalarySobPO oldSob = sobPOMap.get(sobPOName);
|
|
|
|
|
|
salarySobPO.setId(oldSob.getId());
|
|
|
|
|
|
salarySobPO.setCreator(uid);
|
2024-08-20 09:29:14 +08:00
|
|
|
|
salarySobPO.setTaxAgentId(oldSob.getTaxAgentId());
|
2024-08-13 18:15:04 +08:00
|
|
|
|
getSalarySobMapper().updateIgnoreNull(salarySobPO);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
salarySobPO.setCreator(uid);
|
2024-08-14 14:47:27 +08:00
|
|
|
|
salarySobPO.setTaxAgentId(taxAgentId);
|
2024-08-13 18:15:04 +08:00
|
|
|
|
getSalarySobMapper().insertIgnoreNull(salarySobPO);
|
|
|
|
|
|
}
|
2024-08-09 09:22:27 +08:00
|
|
|
|
|
2024-08-16 11:18:27 +08:00
|
|
|
|
result.getSuccess().add(String.format("账套:%s基础信息加载成功", sobPOName));
|
|
|
|
|
|
|
2024-08-13 18:15:04 +08:00
|
|
|
|
Long sobId = salarySobPO.getId();
|
|
|
|
|
|
getSalarySobEmpFieldService(user).deleteBySalarySobIds(Collections.singletonList(sobId));
|
|
|
|
|
|
List<SalarySobEmpFieldPO> salarySobEmpFields = salarySobConfig.getSalarySobEmpFields();
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(salarySobEmpFields)) {
|
|
|
|
|
|
for (SalarySobEmpFieldPO salarySobEmpField : salarySobEmpFields) {
|
|
|
|
|
|
salarySobEmpField.setSalarySobId(sobId);
|
|
|
|
|
|
salarySobEmpField.setCreator(uid);
|
|
|
|
|
|
}
|
|
|
|
|
|
getSalarySobEmpFieldService(user).batchSave(salarySobEmpFields);
|
|
|
|
|
|
}
|
2024-08-16 11:18:27 +08:00
|
|
|
|
result.getSuccess().add(String.format("账套:%s人员字段加载成功", sobPOName));
|
2024-08-09 09:22:27 +08:00
|
|
|
|
|
2024-08-13 18:15:04 +08:00
|
|
|
|
getSalarySobItemService(user).deleteBySalarySobIds(Collections.singletonList(sobId));
|
|
|
|
|
|
List<SalarySobItemPO> salarySobItems = salarySobConfig.getSalarySobItems();
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(salarySobItems)) {
|
|
|
|
|
|
salarySobItems.forEach(sobItem -> {
|
|
|
|
|
|
sobItem.setId(IdGenerator.generate());
|
|
|
|
|
|
sobItem.setSalarySobId(sobId);
|
|
|
|
|
|
sobItem.setCreator(uid);
|
|
|
|
|
|
Long formulaId = getSalaryFormulaService(user).add(sobItem.getFormula());
|
|
|
|
|
|
sobItem.setFormulaId(formulaId);
|
2024-08-14 14:47:27 +08:00
|
|
|
|
|
|
|
|
|
|
SalaryItemPO salaryItem = sobItem.getSalaryItem();
|
|
|
|
|
|
if (salaryItem != null) {
|
|
|
|
|
|
SalaryItemPO salaryItemPO = salaryItemNameMap.get(salaryItem.getName());
|
|
|
|
|
|
if (salaryItemPO != null) {
|
|
|
|
|
|
sobItem.setSalaryItemId(salaryItemPO.getId());
|
2024-08-15 16:25:31 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
SalaryItemPO itemPO = getSalaryItemService(user).getItem(salaryItem);
|
|
|
|
|
|
if (itemPO != null) {
|
|
|
|
|
|
sobItem.setSalaryItemId(itemPO.getId());
|
2024-08-16 11:18:27 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
result.getError().add(String.format("错误,账套:%s,薪资项目:%s,未找到对应薪资项目id", sobPOName, salaryItem.getName()));
|
|
|
|
|
|
log.error("item not found:{}", salaryItem);
|
2024-08-15 16:25:31 +08:00
|
|
|
|
}
|
2024-08-14 14:47:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-13 18:15:04 +08:00
|
|
|
|
});
|
|
|
|
|
|
getSalarySobItemService(user).batchSave(salarySobItems);
|
|
|
|
|
|
}
|
2024-08-09 09:22:27 +08:00
|
|
|
|
|
2024-08-13 18:15:04 +08:00
|
|
|
|
getSalarySobItemGroupService(user).deleteBySalarySobIds(Collections.singletonList(sobId));
|
|
|
|
|
|
List<SalarySobItemGroupPO> salarySobItemGroups = salarySobConfig.getSalarySobItemGroups();
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(salarySobItemGroups)) {
|
|
|
|
|
|
for (SalarySobItemGroupPO salarySobItemGroup : salarySobItemGroups) {
|
|
|
|
|
|
long groupId = IdGenerator.generate();
|
|
|
|
|
|
salarySobItemGroup.setId(groupId);
|
|
|
|
|
|
salarySobItemGroup.setSalarySobId(sobId);
|
|
|
|
|
|
salarySobItemGroup.setCreator(uid);
|
|
|
|
|
|
|
|
|
|
|
|
List<SalarySobItemPO> sobItems = salarySobItemGroup.getSalarySobItems();
|
2024-08-14 14:47:27 +08:00
|
|
|
|
if (CollectionUtil.isNotEmpty(sobItems)) {
|
2024-08-13 18:15:04 +08:00
|
|
|
|
sobItems.forEach(sobItem -> {
|
|
|
|
|
|
sobItem.setId(IdGenerator.generate());
|
|
|
|
|
|
sobItem.setSalarySobId(sobId);
|
|
|
|
|
|
sobItem.setSalarySobItemGroupId(groupId);
|
|
|
|
|
|
sobItem.setCreator(uid);
|
|
|
|
|
|
Long formulaId = getSalaryFormulaService(user).add(sobItem.getFormula());
|
|
|
|
|
|
sobItem.setFormulaId(formulaId);
|
2024-08-14 14:47:27 +08:00
|
|
|
|
|
|
|
|
|
|
SalaryItemPO salaryItem = sobItem.getSalaryItem();
|
|
|
|
|
|
if (salaryItem != null) {
|
|
|
|
|
|
SalaryItemPO salaryItemPO = salaryItemNameMap.get(salaryItem.getName());
|
|
|
|
|
|
if (salaryItemPO != null) {
|
2024-08-15 16:25:31 +08:00
|
|
|
|
sobItem.setSalaryItemId(salaryItemPO.getId());
|
|
|
|
|
|
} else {
|
|
|
|
|
|
SalaryItemPO itemPO = getSalaryItemService(user).getItem(salaryItem);
|
|
|
|
|
|
if (itemPO != null) {
|
|
|
|
|
|
sobItem.setSalaryItemId(itemPO.getId());
|
2024-08-16 11:18:27 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
result.getError().add(String.format("错误,账套:%s,薪资项目:%s,未找到对应薪资项目id", sobPOName, salaryItem.getName()));
|
|
|
|
|
|
log.error("item not found:{}", salaryItem);
|
2024-08-15 16:25:31 +08:00
|
|
|
|
}
|
2024-08-14 14:47:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-08-13 18:15:04 +08:00
|
|
|
|
});
|
2024-08-14 14:47:27 +08:00
|
|
|
|
getSalarySobItemService(user).batchSave(sobItems);
|
2024-08-09 09:22:27 +08:00
|
|
|
|
}
|
2024-08-13 18:15:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
getSalarySobItemGroupService(user).batchSave(salarySobItemGroups);
|
|
|
|
|
|
}
|
2024-08-16 11:18:27 +08:00
|
|
|
|
result.getSuccess().add(String.format("账套:%s薪资项目加载成功", sobPOName));
|
2024-08-09 09:22:27 +08:00
|
|
|
|
|
2024-08-13 18:15:04 +08:00
|
|
|
|
getSalarySobBackItemService(user).deleteBySalarySobIds(Collections.singletonList(sobId));
|
|
|
|
|
|
List<SalarySobBackItemPO> salarySobBackItems = salarySobConfig.getSalarySobBackItems();
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(salarySobBackItems)) {
|
|
|
|
|
|
for (SalarySobBackItemPO salarySobBackItem : salarySobBackItems) {
|
|
|
|
|
|
salarySobBackItem.setId(IdGenerator.generate());
|
|
|
|
|
|
salarySobBackItem.setSalarySobId(sobId);
|
|
|
|
|
|
salarySobBackItem.setCreator(uid);
|
|
|
|
|
|
|
|
|
|
|
|
Long formulaId = getSalaryFormulaService(user).add(salarySobBackItem.getFormula());
|
|
|
|
|
|
salarySobBackItem.setFormulaId(formulaId);
|
2024-08-14 14:47:27 +08:00
|
|
|
|
|
|
|
|
|
|
SalaryItemPO salaryItem = salarySobBackItem.getSalaryItem();
|
|
|
|
|
|
if (salaryItem != null) {
|
|
|
|
|
|
SalaryItemPO salaryItemPO = salaryItemNameMap.get(salaryItem.getName());
|
|
|
|
|
|
if (salaryItemPO != null) {
|
2024-08-15 16:25:31 +08:00
|
|
|
|
salarySobBackItem.setSalaryItemId(salaryItemPO.getId());
|
|
|
|
|
|
} else {
|
|
|
|
|
|
SalaryItemPO itemPO = getSalaryItemService(user).getItem(salaryItem);
|
|
|
|
|
|
if (itemPO != null) {
|
|
|
|
|
|
salarySobBackItem.setSalaryItemId(itemPO.getId());
|
2024-08-16 11:18:27 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
result.getError().add(String.format("错误,账套:%s,薪资项目:%s,未找到对应薪资项目id", sobPOName, salaryItem.getName()));
|
|
|
|
|
|
log.error("item not found:{}", salaryItem);
|
2024-08-15 16:25:31 +08:00
|
|
|
|
}
|
2024-08-14 14:47:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-08-13 18:15:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
getSalarySobBackItemService(user).batchInsert(salarySobBackItems);
|
|
|
|
|
|
}
|
2024-08-16 11:18:27 +08:00
|
|
|
|
result.getSuccess().add(String.format("账套:%s回算加载成功", sobPOName));
|
2024-08-13 18:15:04 +08:00
|
|
|
|
|
|
|
|
|
|
getSalarySobAdjustRuleService(user).deleteBySalarySobIds(Collections.singletonList(sobId));
|
|
|
|
|
|
List<SalarySobAdjustRulePO> salarySobAdjustRules = salarySobConfig.getSalarySobAdjustRules();
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(salarySobAdjustRules)) {
|
|
|
|
|
|
for (SalarySobAdjustRulePO salarySobAdjustRule : salarySobAdjustRules) {
|
|
|
|
|
|
salarySobAdjustRule.setId(IdGenerator.generate());
|
|
|
|
|
|
salarySobAdjustRule.setSalarySobId(sobId);
|
|
|
|
|
|
salarySobAdjustRule.setCreator(uid);
|
|
|
|
|
|
}
|
|
|
|
|
|
getSalarySobAdjustRuleService(user).batchSave(salarySobAdjustRules);
|
|
|
|
|
|
}
|
2024-08-16 11:18:27 +08:00
|
|
|
|
result.getSuccess().add(String.format("账套:%s调薪计薪规则加载成功", sobPOName));
|
|
|
|
|
|
|
|
|
|
|
|
results.add(result);
|
2024-08-13 18:15:04 +08:00
|
|
|
|
});
|
2024-08-16 11:18:27 +08:00
|
|
|
|
|
|
|
|
|
|
return results;
|
2024-08-09 09:22:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-30 10:49:46 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public List<SalarySobPO> list(SalarySobQueryParam param) {
|
|
|
|
|
|
SalarySobPO sobPO = SalarySobPO.builder().build();
|
|
|
|
|
|
if (StrUtil.isNotBlank(param.getName())) {
|
|
|
|
|
|
sobPO.setName(param.getName());
|
|
|
|
|
|
}
|
2022-06-07 15:43:22 +08:00
|
|
|
|
|
2024-08-30 10:49:46 +08:00
|
|
|
|
if (param.getTaxAgentId() != null) {
|
2024-09-03 14:30:57 +08:00
|
|
|
|
List<SobTaxLinkPO> sobTaxLinkPOS = getSobTaxLinkMapper().listSome(SobTaxLinkPO.builder().taxAgentId(param.getTaxAgentId()).build());
|
|
|
|
|
|
sobPO.setIds(SalaryEntityUtil.properties(sobTaxLinkPOS, SobTaxLinkPO::getSobId));
|
2022-06-07 15:43:22 +08:00
|
|
|
|
}
|
2024-08-30 10:49:46 +08:00
|
|
|
|
return getSalarySobMapper().listSome(sobPO);
|
2022-06-07 15:43:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-05 10:26:52 +08:00
|
|
|
|
@Override
|
|
|
|
|
|
public void handleHistory() {
|
|
|
|
|
|
|
|
|
|
|
|
int count = getSobTaxLinkMapper().count();
|
2024-09-11 10:28:20 +08:00
|
|
|
|
if (count > 0) {
|
2024-09-05 10:26:52 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<SalarySobPO> salarySobPOS = getSalarySobMapper().listAll();
|
|
|
|
|
|
salarySobPOS.forEach(sobPO -> {
|
2024-09-11 10:28:20 +08:00
|
|
|
|
SobTaxLinkPO taxLinkPO = SobTaxLinkPO.builder()
|
|
|
|
|
|
.id(IdGenerator.generate())
|
|
|
|
|
|
.taxAgentId(sobPO.getTaxAgentId())
|
|
|
|
|
|
.sobId(sobPO.getId())
|
|
|
|
|
|
.creator((long) user.getUID())
|
|
|
|
|
|
.createTime(new Date())
|
|
|
|
|
|
.updateTime(new Date())
|
|
|
|
|
|
.deleteType(0)
|
|
|
|
|
|
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
|
|
|
|
|
|
.build();
|
|
|
|
|
|
getSobTaxLinkMapper().insertIgnoreNull(taxLinkPO);
|
2024-09-05 10:26:52 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
2022-03-22 21:01:38 +08:00
|
|
|
|
}
|