Merge remote-tracking branch 'remotes/origin/feature/240101工资单模板复制优化及福利基数调整记录优化' into release/2.10.1.2401.01

This commit is contained in:
sy 2024-01-30 14:32:59 +08:00
commit 8237ed48a6
14 changed files with 2264 additions and 78 deletions

View File

@ -54,4 +54,7 @@ public class SalaryTemplateListDTO {
@SalaryTableColumn(text = "备注", width = "20%", column = "description")
@TableTitle(title = "备注", dataIndex = "description", key = "description")
private String description;
// 薪资账套id
private Long salarySobId;
}

View File

@ -16,6 +16,8 @@ public class SalaryBillSalaryItemQueryParam extends BaseQueryParam {
private Long groupId;
private String groupName;
private Boolean isReplenish;
private List<String> existSalaryItemIds;

View File

@ -23,6 +23,8 @@ public class SalaryTemplateCopyParam {
// 模板名称")
private String name;
private Long salarySobId;
public static void checkParam(SalaryTemplateCopyParam copyParam) {
if (copyParam.getId() == null) {
throw new SalaryRunTimeException("id必选");

View File

@ -34,7 +34,7 @@ public class SalarySobItemGroupPO {
private Long salarySobId;
/**
* 薪资账套的名称
* 薪资账套中薪资项目分组的名称
*/
private String name;

View File

@ -42,4 +42,7 @@ public class AccountParam {
@DataCheck(require = true,message = "个税扣缴义务人不能为空")
private Long paymentOrganization;
// 是否核算后归档
private boolean fileFlag = false;
}

View File

@ -366,7 +366,8 @@
t.replenish_name as replenishName,
s.name as salarysob,
t.use_type as useType,
t.description
t.description,
t.salary_sob_id
from
hrsa_salary_template t left join hrsa_salary_sob s on t.salary_sob_id = s.id
where t.delete_type = 0
@ -398,7 +399,8 @@
t.replenish_name as replenishName,
s.name as salarysob,
t.use_type as useType,
t.description
t.description,
t.salary_sob_id
from
hrsa_salary_template t left join hrsa_salary_sob s on t.salary_sob_id = s.id
where t.delete_type = 0
@ -430,7 +432,8 @@
t.replenish_name as replenishName,
s.name as salarysob,
t.use_type as useType,
t.description
t.description,
t.salary_sob_id
from
hrsa_salary_template t left join hrsa_salary_sob s on t.salary_sob_id = s.id
where t.delete_type = 0

View File

@ -84,6 +84,13 @@ public interface SIAccountService {
*/
String save(AccountParam param);
/**
* 新建核算并归档
* @param param
* @return
*/
String saveAndFile(AccountParam param);
/**
* 正常缴纳页核算
* @param saveCommonAccountParam
@ -307,5 +314,7 @@ public interface SIAccountService {
boolean checkBalance(InsuranceAccountDetailPO po);
boolean checkBalancePayInsurance(InsuranceAccountDetailPO po);
List<InsuranceAccountViewListDTO> buildRecords(List<InsuranceAccountDetailPO> list, Map<Long, TaxAgentPO> paymentMap);
}

File diff suppressed because it is too large Load Diff

View File

@ -1159,6 +1159,20 @@ public class SIArchivesServiceImpl extends Service implements SIArchivesService
public PageInfo<InsuranceArchivesBaseHistoryDTO> historyListByEmployeeIdAndOperator(SIArchiveBaseHistoryListParam param) {
List<InsuranceArchivesBaseHistoryDTO> adjustHistoryDTOS = siArchivesBiz.getBaseHistoryByEmployeeIdAndOperator(param.getOperator(), param.getEmployeeId());
// 分权逻辑
Boolean needAuth = getTaxAgentService(user).isNeedAuth((long) user.getUID());
if (needAuth) {
Collection<TaxAgentPO> taxAgentPOS = getTaxAgentService(user).listAllTaxAgents((long) user.getUID());
List<Long> taxAgents = taxAgentPOS.stream().map(TaxAgentPO::getId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(taxAgents)) {
//防止普通用户查询
adjustHistoryDTOS = new ArrayList<>();
} else {
adjustHistoryDTOS = adjustHistoryDTOS.stream().filter(f -> taxAgents.contains(f.getPaymentOrganization())).collect(Collectors.toList());
}
}
adjustHistoryDTOS.forEach(f -> {
if (StringUtils.isNotBlank(f.getPaymentScope())) {
if(f.getPaymentScope().equals(PaymentScopeEnum.SCOPE_PERSON.getValue().toString())) {

View File

@ -5,7 +5,6 @@ import com.alibaba.fastjson.TypeReference;
import com.cloudstore.eccom.pc.table.WeaTableColumn;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.biz.SIAccountBiz;
import com.engine.salary.biz.SIArchivesBiz;
import com.engine.salary.encrypt.EncryptUtil;
import com.engine.salary.entity.siaccount.dto.InsuranceAccountViewListDTO;
@ -68,7 +67,7 @@ public class SIExportServiceImpl extends Service implements SIExportService {
private EncryptUtil encryptUtil = new EncryptUtil();
private SIAccountBiz siAccountBiz = new SIAccountBiz();
// private SIAccountBiz siAccountBiz = new SIAccountBiz();
private SIArchivesBiz siArchivesBiz = new SIArchivesBiz();
@ -117,7 +116,8 @@ public class SIExportServiceImpl extends Service implements SIExportService {
List<TaxAgentPO> paymentList =getTaxAgentMapper().listAll();
SalaryAssert.notEmpty(paymentList, SalaryI18nUtil.getI18nLabel(100341, "该租户无扣缴义务人"));
Map<Long, TaxAgentPO> paymentMap = paymentList.stream().collect(Collectors.toMap(TaxAgentPO::getId, Function.identity()));
List<InsuranceAccountViewListDTO> insuranceAccountViewListDTOS = siAccountBiz.buildRecords(insuranceAccountDetailPOS, paymentMap);
// List<InsuranceAccountViewListDTO> insuranceAccountViewListDTOS = siAccountBiz.buildRecords(insuranceAccountDetailPOS, paymentMap);
List<InsuranceAccountViewListDTO> insuranceAccountViewListDTOS = getSIAccountService(user).buildRecords(insuranceAccountDetailPOS, paymentMap);
List<List<Object>> excelSheetData = new ArrayList<>();
// 1.工作簿名称

View File

@ -1,7 +1,9 @@
package com.engine.salary.service.impl;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.salary.biz.SalarySobBiz;
@ -16,15 +18,18 @@ import com.engine.salary.entity.salaryBill.param.SalaryTemplateQueryParam;
import com.engine.salary.entity.salaryBill.param.SalaryTemplateSaveParam;
import com.engine.salary.entity.salaryBill.po.SalaryBillItemNamePO;
import com.engine.salary.entity.salaryBill.po.SalaryTemplatePO;
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
import com.engine.salary.entity.salarysob.dto.SalarySobItemAggregateDTO;
import com.engine.salary.entity.salarysob.dto.SalarySobItemDTO;
import com.engine.salary.entity.salarysob.dto.SalarySobItemGroupDTO;
import com.engine.salary.entity.salarysob.po.SalarySobItemHidePO;
import com.engine.salary.entity.salarysob.po.SalarySobPO;
import com.engine.salary.entity.salarysob.po.*;
import com.engine.salary.enums.salarybill.SalaryTemplateWhetherEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.mapper.salarysob.SalarySobEmpFieldMapper;
import com.engine.salary.service.*;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.db.MapperProxyFactory;
import com.engine.salary.util.page.PageInfo;
import com.engine.salary.util.page.SalaryPageUtil;
import com.mzlion.core.utils.BeanUtils;
@ -68,6 +73,14 @@ public class SalaryTemplateServiceImpl extends Service implements SalaryTemplate
return ServiceUtil.getService(SalaryBillItemNameServiceImpl.class, user);
}
private SalarySobEmpFieldService getSalarySobEmpFieldService(User user) {
return (SalarySobEmpFieldService) ServiceUtil.getService(SalarySobEmpFieldServiceImpl.class, user);
}
private SalarySobEmpFieldMapper getSalarySobEmpFieldMapper() {
return MapperProxyFactory.getProxy(SalarySobEmpFieldMapper.class);
}
@Override
public SalaryTemplatePO getById(Long id) {
return mapper.getById(id);
@ -271,7 +284,72 @@ public class SalaryTemplateServiceImpl extends Service implements SalaryTemplate
BeanUtils.copyProperties(salaryTemplate, salaryTemplateNew);
salaryTemplateNew.setId(null);
salaryTemplateNew.setName(copyParam.getName());
salaryTemplateNew.setReplenishName(copyParam.getName() + "-" + SalaryI18nUtil.getI18nLabel(0, "补发工资单"));
salaryTemplateNew.setUseType(SalaryTemplateWhetherEnum.FALSE.getValue());
//20240122逻辑变更拷贝工资单模板时可变更薪资账套
if (copyParam.getSalarySobId() != null && !copyParam.getSalarySobId().equals(salaryTemplate.getSalarySobId())) {
// 查询薪资账套的员工信息字段
List<SalarySobEmpFieldPO> salarySobEmpFieldPOS = getSalarySobEmpFieldService(user).listBySalarySobId(copyParam.getSalarySobId());
List<String> empFieldCodeList = salarySobEmpFieldPOS.stream().map(SalarySobEmpFieldPO::getFieldCode).collect(Collectors.toList());
Map<String, Long> empFieldCodeWithIdMap = SalaryEntityUtil.convert2Map(salarySobEmpFieldPOS, SalarySobEmpFieldPO::getFieldCode, SalarySobEmpFieldPO::getId);
// 查询薪资账套的薪资项目副本
List<SalarySobItemPO> salarySobItemPOS = getSalarySobItemService(user).listBySalarySobIdWithHideItem(copyParam.getSalarySobId());
List<Long> salaryItemIdList = salarySobItemPOS.stream().map(SalarySobItemPO::getSalaryItemId).collect(Collectors.toList());
//拷贝数据中的薪资项目
List<SalaryTemplateSalaryItemSetListDTO> salaryItemSettingList = StrUtil.isNotBlank(salaryTemplate.getSalaryItemSetting())
? JSONArray.parseArray(salaryTemplate.getSalaryItemSetting(), SalaryTemplateSalaryItemSetListDTO.class) : new ArrayList<>();
for (SalaryTemplateSalaryItemSetListDTO salaryItemSetting : salaryItemSettingList) {
if ("111111111111111111".equals(salaryItemSetting.getGroupId()) && salaryItemSetting.getItems() != null) {
List<SalaryTemplateSalaryItemListDTO> newItems = new ArrayList<>();
for (SalaryTemplateSalaryItemListDTO templateItem : salaryItemSetting.getItems()) {
SalarySobEmpFieldPO empFieldPO = getSalarySobEmpFieldMapper().getById(Long.valueOf(templateItem.getSalaryItemId()));
if (empFieldCodeList.contains(empFieldPO.getFieldCode()) && empFieldCodeWithIdMap.get(empFieldPO.getFieldCode()) != null) {
templateItem.setId(empFieldCodeWithIdMap.get(empFieldPO.getFieldCode()).toString());
templateItem.setSalaryItemId(empFieldCodeWithIdMap.get(empFieldPO.getFieldCode()).toString());
newItems.add(templateItem);
}
}
salaryItemSetting.setItems(newItems);
} else if (salaryItemSetting.getItems() != null){
List<SalaryTemplateSalaryItemListDTO> newItems = new ArrayList<>();
for (SalaryTemplateSalaryItemListDTO templateItem : salaryItemSetting.getItems()) {
if (salaryItemIdList.contains(Long.valueOf(templateItem.getSalaryItemId()))) {
newItems.add(templateItem);
}
}
salaryItemSetting.setItems(newItems);
}
}
List<SalaryTemplateSalaryItemSetListDTO> replenishSalaryItemSettingList = StrUtil.isNotBlank(salaryTemplate.getReplenishSalaryItemSetting())
? JSONArray.parseArray(salaryTemplate.getReplenishSalaryItemSetting(), SalaryTemplateSalaryItemSetListDTO.class): new ArrayList<>();
for (SalaryTemplateSalaryItemSetListDTO salaryItemSetting : replenishSalaryItemSettingList) {
if ("111111111111111111".equals(salaryItemSetting.getGroupId()) && salaryItemSetting.getItems() != null) {
List<SalaryTemplateSalaryItemListDTO> newItems = new ArrayList<>();
for (SalaryTemplateSalaryItemListDTO templateItem : salaryItemSetting.getItems()) {
SalarySobEmpFieldPO empFieldPO = getSalarySobEmpFieldMapper().getById(Long.valueOf(templateItem.getSalaryItemId()));
if (empFieldCodeList.contains(empFieldPO.getFieldCode()) && empFieldCodeWithIdMap.get(empFieldPO.getFieldCode()) != null) {
templateItem.setId(empFieldCodeWithIdMap.get(empFieldPO.getFieldCode()).toString());
templateItem.setSalaryItemId(empFieldCodeWithIdMap.get(empFieldPO.getFieldCode()).toString());
newItems.add(templateItem);
}
}
salaryItemSetting.setItems(newItems);
} else if (!"333333333333333333".equals(salaryItemSetting.getGroupId()) && salaryItemSetting.getItems() != null){
List<SalaryTemplateSalaryItemListDTO> newItems = new ArrayList<>();
for (SalaryTemplateSalaryItemListDTO templateItem : salaryItemSetting.getItems()) {
if (salaryItemIdList.contains(Long.valueOf(templateItem.getSalaryItemId()))) {
newItems.add(templateItem);
}
}
salaryItemSetting.setItems(newItems);
}
}
salaryTemplateNew.setSalaryItemSetting(salaryItemSettingList.size() > 0 ? JSONUtil.toJsonStr(salaryItemSettingList) : "");
salaryTemplateNew.setReplenishSalaryItemSetting(replenishSalaryItemSettingList.size() > 0 ? JSONUtil.toJsonStr(replenishSalaryItemSettingList) : "");
salaryTemplateNew.setSalarySobId(copyParam.getSalarySobId());
}
mapper.insert(salaryTemplateNew);
// 复制工资单自定义名称信息

View File

@ -0,0 +1,106 @@
package com.engine.salary.timer;
import cn.hutool.core.util.StrUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.salary.common.SalaryContext;
import com.engine.salary.entity.siaccount.param.AccountParam;
import com.engine.salary.entity.taxagent.po.TaxAgentPO;
import com.engine.salary.formlua.util.RegularUtil;
import com.engine.salary.service.SIAccountService;
import com.engine.salary.service.TaxAgentService;
import com.engine.salary.service.impl.SIAccountServiceImpl;
import com.engine.salary.service.impl.TaxAgentServiceImpl;
import lombok.extern.slf4j.Slf4j;
import weaver.hrm.User;
import weaver.interfaces.schedule.BaseCronJob;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author: sy
* @Description: 福利台账核算并归档任务
* @Date: 2024/1/15
**/
@Slf4j
public class AutoSiAccountAndFileJob extends BaseCronJob {
private String diffToCurrentMonth;
public String getDiffToCurrentMonth() {
return diffToCurrentMonth;
}
public void setDiffToCurrentMonth(String diffToCurrentMonth) {
this.diffToCurrentMonth = diffToCurrentMonth;
}
private String taxAgentNames;
public String getTaxAgentNames() {
return taxAgentNames;
}
public void setTaxAgentNames(String taxAgentNames) {
this.taxAgentNames = taxAgentNames;
}
private String fileFlag;
public String getFileFlag() {
return fileFlag;
}
public void setFileFlag(String fileFlag) {
this.fileFlag = fileFlag;
}
private TaxAgentService getTaxAgentService(User user) {
SalaryContext.get().setValue("user",user);
return ServiceUtil.getService(TaxAgentServiceImpl.class, user);
}
public SIAccountService getSIAccountService(User user) {
SalaryContext.get().setValue("user",user);
return ServiceUtil.getService(SIAccountServiceImpl.class, user);
}
@Override
public void execute() {
if (StrUtil.isNotBlank(diffToCurrentMonth) && (RegularUtil.isInteger(diffToCurrentMonth) || "0".equals(diffToCurrentMonth))) {
User user = new User();
user.setUid(1);
user.setLoginid("sysadmin");
user.setLastname("sysadmin");
Calendar accountTime= Calendar.getInstance();
accountTime.set(Calendar.MONTH, accountTime.get(Calendar.MONTH) + Integer.parseInt(diffToCurrentMonth));
SimpleDateFormat s=new SimpleDateFormat("yyyy-MM");
String accountMonth = s.format(accountTime.getTime());
boolean isFile = false;
if (StrUtil.isNotBlank(fileFlag) && "true".equals(fileFlag)) {
isFile = true;
}
//核算并归档
List<TaxAgentPO> taxAgentList = getTaxAgentService(user).listAll();
//判断是否过滤个税扣缴义务人
if (StrUtil.isNotBlank(taxAgentNames)) {
List<String> taxAgentNameList = Arrays.stream(taxAgentNames.split(",")).map(String::new).collect(Collectors.toList());
taxAgentList = taxAgentList.stream().filter(f -> taxAgentNameList.contains(f.getName())).collect(Collectors.toList());
}
for (TaxAgentPO po : taxAgentList) {
try {
getSIAccountService(user).saveAndFile(AccountParam.builder().paymentOrganization(po.getId()).billMonth(accountMonth).flag(true).fileFlag(isFile).build());
} catch (Exception e) {
log.info("个税扣缴义务人-" + po.getName() + ",新建账单月份" + accountMonth + "的福利核算(并归档)过程失败,原因:" + e.getMessage());
}
}
}
}
}

View File

@ -2,7 +2,6 @@ package com.engine.salary.web;
import cn.hutool.core.util.BooleanUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.salary.biz.SIAccountBiz;
import com.engine.salary.entity.siaccount.param.InspectAccountParam;
import com.engine.salary.entity.siaccount.po.InsuranceAccountInspectPO;
import com.engine.salary.entity.siarchives.param.InsuranceArchivesListParam;
@ -85,8 +84,9 @@ public class SIExportController {
@QueryParam("ids")List<Long> ids,@QueryParam("billMonth") String billMonth) {
InspectAccountParam param = InspectAccountParam.builder().ids(ids).billMonth(billMonth).build();
User user = HrmUserVarify.getUser(request, response);
SIAccountBiz siAccountBiz = new SIAccountBiz();
List<InsuranceAccountInspectPO> insuranceAccountInspectPOS = siAccountBiz.allInspects(param.getIds(), param.getBillMonth());
// SIAccountBiz siAccountBiz = new SIAccountBiz();
// List<InsuranceAccountInspectPO> insuranceAccountInspectPOS = siAccountBiz.allInspects(param.getIds(), param.getBillMonth());
List<InsuranceAccountInspectPO> insuranceAccountInspectPOS = getService(user).allInspects(param.getIds(), param.getBillMonth());
InsuranceArchivesListParam req = new InsuranceArchivesListParam();
req.setEmployeeIds(insuranceAccountInspectPOS.stream().map(InsuranceAccountInspectPO::getEmployeeId).distinct().collect(Collectors.toList()));
XSSFWorkbook workbook = getSIExportWrapper(user).export(req);
@ -236,12 +236,13 @@ public class SIExportController {
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response exportTemplate(@Context HttpServletRequest request, @Context HttpServletResponse response) {
InsuranceArchivesListParam param = buildParam(request);
SIAccountBiz siAccountBiz = new SIAccountBiz();
User user = HrmUserVarify.getUser(request, response);
// SIAccountBiz siAccountBiz = new SIAccountBiz();
if (param.getInspectAll() != null && param.getInspectAll()) {
List<InsuranceAccountInspectPO> insuranceAccountInspectPOS = siAccountBiz.allInspects(param.getIds(), param.getBillMonth());
// List<InsuranceAccountInspectPO> insuranceAccountInspectPOS = siAccountBiz.allInspects(param.getIds(), param.getBillMonth());
List<InsuranceAccountInspectPO> insuranceAccountInspectPOS = getService(user).allInspects(param.getIds(), param.getBillMonth());
param.setEmployeeIds(insuranceAccountInspectPOS.stream().map(InsuranceAccountInspectPO::getEmployeeId).distinct().collect(Collectors.toList()));
}
User user = HrmUserVarify.getUser(request, response);
XSSFWorkbook workbook = getSIImportWrapper(user).exportTemplate(param);
String time = LocalDate.now().toString();
String fileName = "";

View File

@ -9,16 +9,19 @@ import com.engine.salary.entity.salaryBill.po.SalaryBillItemNamePO;
import com.engine.salary.entity.salaryBill.po.SalaryTemplatePO;
import com.engine.salary.entity.salaryitem.po.SalaryItemPO;
import com.engine.salary.entity.salarysob.po.SalarySobBackItemPO;
import com.engine.salary.entity.salarysob.po.SalarySobItemGroupPO;
import com.engine.salary.entity.salarysob.po.SalarySobPO;
import com.engine.salary.enums.salarybill.SalaryTemplateReplenishRuleEnum;
import com.engine.salary.enums.salarybill.SalaryTemplateVarEnum;
import com.engine.salary.enums.salarybill.SalaryTemplateWhetherEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.mapper.salarysob.SalarySobItemGroupMapper;
import com.engine.salary.service.*;
import com.engine.salary.service.impl.*;
import com.engine.salary.util.JsonUtil;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.SalaryI18nUtil;
import com.engine.salary.util.db.MapperProxyFactory;
import com.engine.salary.util.page.PageInfo;
import com.mzlion.core.utils.BeanUtils;
import org.apache.commons.collections4.CollectionUtils;
@ -71,6 +74,10 @@ public class SalaryTemplateWrapper extends Service {
return ServiceUtil.getService(SalaryBillItemNameServiceImpl.class, user);
}
private SalarySobItemGroupMapper getSalarySobItemGroupMapper() {
return MapperProxyFactory.getProxy(SalarySobItemGroupMapper.class);
}
/**
* 工资单模板列表
*
@ -479,7 +486,13 @@ public class SalaryTemplateWrapper extends Service {
Boolean isReplenish = Optional.ofNullable(param.getIsReplenish()).orElse(false);
List<SalaryTemplateSalaryItemSetListDTO> salaryItemSet = getSalaryTemplateService(user).getSalaryItemSetContainHide(param.getSalarySobId(), param.getSalaryTemplateId(), isReplenish);
Long groupId = param.getGroupId();
return salaryItemSet.stream().filter(s -> Objects.equals(s.getGroupId(), groupId + "")).map(SalaryTemplateSalaryItemSetListDTO::getItems).findFirst().orElse(Collections.emptyList()).stream().filter(item -> !Optional.ofNullable(param.getExistSalaryItemIds()).orElse(Collections.emptyList()).contains(item.getId())).collect(Collectors.toList());
//工资单模板copy可能导致groupId不匹配
List<SalarySobItemGroupPO> salarySobItemGroupPOS = getSalarySobItemGroupMapper().listSome(SalarySobItemGroupPO.builder().salarySobId(param.getSalarySobId()).name(param.getGroupName()).build());
if (salarySobItemGroupPOS != null && salarySobItemGroupPOS.size() > 0) {
groupId = salarySobItemGroupPOS.get(0).getId();
}
Long finalGroupId = groupId;
return salaryItemSet.stream().filter(s -> Objects.equals(s.getGroupId(), finalGroupId + "")).map(SalaryTemplateSalaryItemSetListDTO::getItems).findFirst().orElse(Collections.emptyList()).stream().filter(item -> !Optional.ofNullable(param.getExistSalaryItemIds()).orElse(Collections.emptyList()).contains(item.getId())).collect(Collectors.toList());
}
/**