Merge branch 'release/3.0.1.2503.01' into custom/联特

This commit is contained in:
钱涛 2025-03-21 11:24:46 +08:00
commit 66250c2ddc
21 changed files with 440 additions and 77 deletions

View File

@ -1,5 +1,5 @@
log=false
defaultCloseNonStandard149=true
AESEncryptScrect=990EB004A1C862721C1513AE90038C9E
version=3.0.0.2502.01
version=3.0.0.2503.01
openFormulaForcedEditing=false

View File

@ -96,15 +96,18 @@ public class CheckStopSalaryAction implements Action {
List<TaxAgentPO> taxAgentPOS = getTaxAgentMapper().listByName(taxAgentName);
if(CollectionUtils.isEmpty(taxAgentPOS)){
requestInfo.getRequestManager().setMessage("个税扣缴义务人不存在!");
log.error("停薪检查异常 requestId:{} msg:{}", requestInfo.getRequestid(), taxAgentName + "个税扣缴义务人不存在!");
return FAILURE_AND_CONTINUE;
}
Long taxAgentId = Long.valueOf( taxAgentPOS.get(0).getId() );
Long employeeId = Long.valueOf(importDataMap.getOrDefault("员工id", "-1").toString());
if( importDataMap.get("最后发薪日期") == null || StringUtils.isBlank(importDataMap.get("最后发薪日期").toString())){
requestInfo.getRequestManager().setMessage("缺少最后发薪日期字段!");
log.error("停薪检查异常 requestId:{} msg:{}", requestInfo.getRequestid(), "缺少最后发薪日期字段!");
return FAILURE_AND_CONTINUE;
}else if(SalaryDateUtil.stringToDate(importDataMap.get("最后发薪日期").toString()) == null){
requestInfo.getRequestManager().setMessage("最后发薪日期格式错误格式为yyyy-MM-dd");
log.error("停薪检查异常 requestId:{} msg:{}", requestInfo.getRequestid(), "最后发薪日期格式错误格式为yyyy-MM-dd" + importDataMap.get("最后发薪日期").toString());
return FAILURE_AND_CONTINUE;
}
@ -115,15 +118,17 @@ public class CheckStopSalaryAction implements Action {
List<SalaryArchivePO> salaryArchiveList = getSalaryArchiveService(user).listSome(SalaryArchivePO.builder().taxAgentId(taxAgentId).employeeId(employeeId).deleteType(NumberUtils.INTEGER_ZERO).build());
if(CollectionUtils.isEmpty(salaryArchiveList)){
requestInfo.getRequestManager().setMessage("该个税扣缴义务人下该员工不存在薪资档案,请检查后重试!");
log.error("停薪检查异常 requestId:{} msg:{}", requestInfo.getRequestid(), taxAgentId +"_"+ employeeId+"该个税扣缴义务人下该员工不存在薪资档案,请检查后重试!");
return FAILURE_AND_CONTINUE;
}
if(salaryArchiveList.size() > 1){
requestInfo.getRequestManager().setMessage("该个税扣缴义务人下该员工存在多条薪资档案记录,请检查后重试!");
log.error("停薪检查异常 requestId:{} msg:{}", requestInfo.getRequestid(), taxAgentId +"_"+ employeeId+"该个税扣缴义务人下该员工存在多条薪资档案记录,请检查后重试!");
return FAILURE_AND_CONTINUE;
}
} catch (Exception e) {
log.error("停薪校验异常", e);
log.error("停薪检查异常", e);
requestInfo.getRequestManager().setMessage(e.getMessage());
return FAILURE_AND_CONTINUE;
}

View File

@ -107,15 +107,18 @@ public class StopSalaryAction implements Action {
List<TaxAgentPO> taxAgentPOS = getTaxAgentMapper().listByName(taxAgentName);
if(CollectionUtils.isEmpty(taxAgentPOS)){
requestInfo.getRequestManager().setMessage("个税扣缴义务人不存在!");
log.error("停薪异常 requestId:{} msg:{}", requestInfo.getRequestid(), taxAgentName + "个税扣缴义务人不存在!");
return FAILURE_AND_CONTINUE;
}
Long taxAgentId = Long.valueOf( taxAgentPOS.get(0).getId() );
Long employeeId = Long.valueOf(importDataMap.getOrDefault("员工id", "-1").toString());
if( importDataMap.get("最后发薪日期") == null || StringUtils.isBlank(importDataMap.get("最后发薪日期").toString())){
requestInfo.getRequestManager().setMessage("缺少最后发薪日期字段!");
log.error("停薪异常 requestId:{} msg:{}", requestInfo.getRequestid(), "缺少最后发薪日期字段!");
return FAILURE_AND_CONTINUE;
}else if(SalaryDateUtil.stringToDate(importDataMap.get("最后发薪日期").toString()) == null){
requestInfo.getRequestManager().setMessage("最后发薪日期格式错误格式为yyyy-MM-dd");
log.error("停薪异常 requestId:{} msg:{}", requestInfo.getRequestid(), "最后发薪日期格式错误格式为yyyy-MM-dd" + importDataMap.get("最后发薪日期").toString());
return FAILURE_AND_CONTINUE;
}
@ -123,10 +126,12 @@ public class StopSalaryAction implements Action {
List<SalaryArchivePO> salaryArchiveList = getSalaryArchiveService(user).listSome(SalaryArchivePO.builder().taxAgentId(taxAgentId).employeeId(employeeId).deleteType(NumberUtils.INTEGER_ZERO).build());
if(CollectionUtils.isEmpty(salaryArchiveList)){
requestInfo.getRequestManager().setMessage("该个税扣缴义务人下该员工不存在薪资档案,请检查后重试!");
log.error("停薪异常 requestId:{} msg:{}", requestInfo.getRequestid(), taxAgentId +"_"+ employeeId+"该个税扣缴义务人下该员工不存在薪资档案,请检查后重试!");
return FAILURE_AND_CONTINUE;
}
if(salaryArchiveList.size() > 1){
requestInfo.getRequestManager().setMessage("该个税扣缴义务人下该员工存在多条薪资档案记录,请检查后重试!");
log.error("停薪异常 requestId:{} msg:{}", requestInfo.getRequestid(), taxAgentId +"_"+ employeeId+"该个税扣缴义务人下该员工存在多条薪资档案记录,请检查后重试!");
return FAILURE_AND_CONTINUE;
}
// 设置最后发薪日期

View File

@ -1,7 +1,7 @@
package com.engine.salary.entity.datacollection.bo;
import cn.hutool.core.util.NumberUtil;
import com.engine.core.impl.Service;
import com.engine.salary.constant.SalaryArchiveConstant;
import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.datacollection.param.VariableArchiveImportHandleParam;
@ -23,7 +23,6 @@ import weaver.general.Util;
import weaver.hrm.User;
import java.util.*;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
@ -232,7 +231,7 @@ public class VariableArchiveExcelBO extends Service {
if (optionalVariableItem.isPresent()) {
VariableItemPO variableItemPO = optionalVariableItem.get();
// 数值类型判断
boolean isNotNumber = variableItemPO.getDataType().equals(SalaryArchiveFieldTypeEnum.NUMBER.getValue()) && StringUtils.isNotEmpty(cellVal) && !Pattern.matches(SalaryArchiveConstant.NUMBER_REGEX, cellVal);
boolean isNotNumber = variableItemPO.getDataType().equals(SalaryArchiveFieldTypeEnum.NUMBER.getValue()) && StringUtils.isNotEmpty(cellVal) && !NumberUtil.isNumber(cellVal);
if (isNotNumber) {
Map<String, String> errorMessageMap = Maps.newHashMap();
errorMessageMap.put("message", rowindex + key + numberErr);

View File

@ -1,7 +1,7 @@
package com.engine.salary.entity.salaryarchive.bo;
import cn.hutool.core.util.NumberUtil;
import com.engine.core.impl.Service;
import com.engine.salary.constant.SalaryArchiveConstant;
import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveInitImportDTO;
@ -35,7 +35,6 @@ import weaver.hrm.User;
import java.time.LocalDate;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
@ -826,7 +825,7 @@ public class SalaryArchiveExcelBO extends Service {
if (isEnable) {
SalaryItemPO salaryItemPO = optionalSalaryItem.get();
// 数值类型判断
boolean isNotNumber = salaryItemPO.getDataType().equals(SalaryArchiveFieldTypeEnum.NUMBER.getValue()) && StringUtils.isNotEmpty(cellVal) && !Pattern.matches(SalaryArchiveConstant.NUMBER_REGEX, cellVal);
boolean isNotNumber = salaryItemPO.getDataType().equals(SalaryArchiveFieldTypeEnum.NUMBER.getValue()) && StringUtils.isNotEmpty(cellVal) && !NumberUtil.isNumber(cellVal);
if (isNotNumber) {
Map<String, String> errorMessageMap = Maps.newHashMap();
errorMessageMap.put("message", rowindex + key + numberErr);

View File

@ -192,4 +192,12 @@ public interface InsuranceAccountDetailMapper {
* 获取补差数据(账单月份+人员id+个税扣缴义务人)
*/
List<InsuranceAccountDetailPO> queryBalanceList(InsuranceAccountDetailPO po);
/**
* 根据id删除
* @param ids
*/
void deleteByIds(@Param("ids")List<Long> ids);
void deleteByEmpIds(@Param("employeeIds")List<Long> deleteEmployeeIds, @Param("billMonth") String billMonth, @Param("paymentOrganization") Long paymentOrganization);
}

View File

@ -553,6 +553,7 @@
<select id="selectList" resultMap="BaseResultMap">
SELECT
t.id,
t.employee_id,t.social_sum,t.fund_sum,t.other_sum,t.fund_pay_org,t.social_pay_org,
t.other_pay_org, t.payment_status
FROM
@ -1563,6 +1564,29 @@
AND employee_id = #{employeeId}
</delete>
<delete id="deleteByIds">
UPDATE hrsa_bill_detail
SET delete_type = 1
WHERE delete_type = 0
<if test="ids != null and ids.size()>0">
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</if>
</delete>
<delete id="deleteByEmpIds">
UPDATE hrsa_bill_detail
SET delete_type = 1
WHERE delete_type = 0
AND bill_month = #{billMonth}
AND payment_organization = #{paymentOrganization}
AND employee_id in
<foreach collection="employeeIds" open="(" item="employeeId" separator="," close=")">
#{employeeId}
</foreach>
</delete>
<select id="getOneByBpep" resultMap="BaseResultMap">
SELECT
t.id,t.employee_id,t.social_per_json,t.social_com_json,

View File

@ -20,6 +20,8 @@ public interface InsuranceBaseInfoMapper {
*/
List<InsuranceArchivesBaseInfoPO> listAll();
List<InsuranceArchivesBaseInfoPO> listByEmployeeIds(@Param("employeeIds")Collection<Long> employeeIds);
/**
* 查询对应id集合的记录
*

View File

@ -43,6 +43,18 @@
WHERE delete_type = 0
</select>
<select id="listByEmployeeIds"
resultType="com.engine.salary.entity.siarchives.po.InsuranceArchivesBaseInfoPO">
SELECT
<include refid="baseColumns"/>
FROM hrsa_insurance_base_info t
WHERE delete_type = 0
AND employee_id IN
<foreach collection="employeeIds" open="(" item="employeeId" separator="," close=")">
#{employeeId}
</foreach>
</select>
<!-- 查询对应id的数据 -->
<select id="listByIds" resultMap="BaseResultMap">
SELECT

View File

@ -25,6 +25,9 @@ public class SalaryStatisticsEmployeeSalaryQueryParam extends BaseQueryParam {
// 关键字
private String keyword;
//人员ids
private List<Long> employeeIds;
// 起始年月
private String startDateStr;
private Date startDate;

View File

@ -16,6 +16,7 @@ import com.engine.salary.entity.taxagent.po.TaxAgentPO;
import com.engine.salary.enums.UserStatusEnum;
import com.engine.salary.enums.auth.AuthFilterTypeEnum;
import com.engine.salary.enums.datacollection.UseEmployeeTypeEnum;
import com.engine.salary.enums.salaryitem.SalaryDataTypeEnum;
import com.engine.salary.enums.salarysob.SalaryEmployeeStatusEnum;
import com.engine.salary.mapper.salaryacct.SalaryAcctEmployeeMapper;
import com.engine.salary.report.common.constant.SalaryConstant;
@ -221,12 +222,23 @@ public class SalaryStatisticsEmployeeServiceImpl extends Service implements Sala
List<SalaryAcctRecordPO> salaryAcctRecordPOS = getSalaryAcctRecordService(user).listAll();
Map<Long, Integer> salaryAcctRecordMap = SalaryEntityUtil.convert2Map(salaryAcctRecordPOS, SalaryAcctRecordPO::getId, SalaryAcctRecordPO::getAcctTimes);
List<SalaryItemPO> salaryItemPOList = getSalaryItemService(user).listAll();
Map<Long, String> itemDataTypeMap = SalaryEntityUtil.convert2Map(salaryItemPOList, SalaryItemPO::getId, SalaryItemPO::getDataType);
Map<Long, List<SalaryAcctResultPO>> acctResultValueList = SalaryEntityUtil.group2Map(salaryStatisticsEmployeeDetailResult.getSalaryAcctResultValueList(), SalaryAcctResultPO::getSalaryAcctEmpId);
Map<Long, Map<String, String>> acctResultValueMap = new HashMap<>();
Map<Long, Map<String, Object>> acctResultValueMap = new HashMap<>();
acctResultValueList.forEach((k, v) -> {
Map<String, String> map = new HashMap();
Map<String, Object> map = new HashMap();
v.forEach(l -> {
map.put(l.getSalaryItemId() + "", l.getResultValue());
String dataType = itemDataTypeMap.getOrDefault(l.getSalaryItemId(), "string");
SalaryDataTypeEnum typeEnum = SalaryDataTypeEnum.parseByValue(dataType);
String resultValue = l.getResultValue();
if (typeEnum == SalaryDataTypeEnum.NUMBER && NumberUtil.isNumber(resultValue)) {
map.put(l.getSalaryItemId() + "", Double.valueOf(resultValue));
} else {
map.put(l.getSalaryItemId() + "", resultValue);
}
});
acctResultValueMap.put(k, map);
});
@ -238,7 +250,7 @@ public class SalaryStatisticsEmployeeServiceImpl extends Service implements Sala
Map<String, Object> map;
for (SalaryAcctEmployeePO se : salaryStatisticsEmployeeDetailResult.getSalaryAcctEmployeeList()) {
map = Maps.newHashMap();
Map<String, String> resultValueMap = Optional.ofNullable(acctResultValueMap.get(se.getId())).orElse(Maps.newHashMap());
Map<String, Object> resultValueMap = Optional.ofNullable(acctResultValueMap.get(se.getId())).orElse(Maps.newHashMap());
Map<String, Object> finalMap = map;
resultValueMap.forEach((k, v) -> {
finalMap.put(k + SalaryConstant.DYNAMIC_SUFFIX, v);
@ -309,6 +321,13 @@ public class SalaryStatisticsEmployeeServiceImpl extends Service implements Sala
List<Long> employeeIds = employeeList.stream().map(DataCollectionEmployee::getEmployeeId).collect(Collectors.toList());
salaryAcctEmployeeList = salaryAcctEmployeeList.stream().filter(acctEmp -> employeeIds.contains(acctEmp.getEmployeeId())).collect(Collectors.toList());
}
//人员浏览按钮筛选
List<Long> employeeIds = queryParam.getEmployeeIds();
if(CollectionUtils.isNotEmpty(employeeIds)){
salaryAcctEmployeeList = salaryAcctEmployeeList.stream().filter(acctEmp -> employeeIds.contains(acctEmp.getEmployeeId())).collect(Collectors.toList());
}
if (CollectionUtils.isEmpty(salaryAcctEmployeeList)) {
return new PageInfo<>();
}

View File

@ -320,5 +320,9 @@ public interface SIAccountService {
void cacheWelfareField(List<String> welfareNames);
void cacheBalanceWelfareField(List<String> welfareNames);
void deleteSocialAcctEmp(SaveCommonAccountParam param);
String addSocialAcctEmp(SaveCommonAccountParam param);
}

View File

@ -65,7 +65,7 @@ public class AuthRoleServiceImpl extends Service implements AuthRoleService {
List<AuthRolePO> authRolePOS = getAuthRoleMapper().list(param);
int total = authRolePOS.size();
List<AuthRoleDTO> collect = SalaryPageUtil.subList(param.getCurrent(), param.getPageSize(), authRolePOS)
List<AuthRoleDTO> list = SalaryPageUtil.subList(param.getCurrent(), param.getPageSize(), authRolePOS)
.stream().map(po -> {
Long roleId = po.getId();
AuthMemberQueryParam roleQueryParam = AuthMemberQueryParam.builder().roleId(roleId).build();
@ -84,7 +84,8 @@ public class AuthRoleServiceImpl extends Service implements AuthRoleService {
.resources(authResources.size())
.build();
}).collect(Collectors.toList());
PageInfo<AuthRoleDTO> pageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), collect, AuthRoleDTO.class);
PageInfo<AuthRoleDTO> pageInfo = SalaryPageUtil.buildPage(param.getCurrent(), param.getPageSize(), AuthRoleDTO.class);
pageInfo.setList(list);
pageInfo.setTotal(total);
return pageInfo;
}
@ -92,7 +93,7 @@ public class AuthRoleServiceImpl extends Service implements AuthRoleService {
@Override
public AuthRoleDTO getRole(Long id) {
AuthRolePO po = getAuthRoleMapper().getById(id);
if (po == null){
if (po == null) {
throw new SalaryRunTimeException("业务线不存在");
}
Long roleId = po.getId();
@ -244,6 +245,6 @@ public class AuthRoleServiceImpl extends Service implements AuthRoleService {
@Override
public List<AuthRolePO> listAll() {
return getAuthRoleMapper().listAll();
return getAuthRoleMapper().listAll();
}
}

View File

@ -61,10 +61,6 @@ public class AuthServiceImpl extends Service implements AuthService {
Boolean isOpenDevolution = getTaxAgentService(user).isOpenDevolution();
boolean isAuth = clazz.isAnnotationPresent(Auth.class);
if (!isOpenDevolution || !isAuth) {
return list;
}
Auth auth = clazz.getAnnotation(Auth.class);
String taxAgentIdField = auth.taxAgentIdField();
String taxAgentIdFieldGetter = "get" + taxAgentIdField.substring(0, 1).toUpperCase() + taxAgentIdField.substring(1);
@ -76,6 +72,34 @@ public class AuthServiceImpl extends Service implements AuthService {
String optsFieldGetter = "get" + optsField.substring(0, 1).toUpperCase() + optsField.substring(1);
String optsFieldSetter = "set" + optsField.substring(0, 1).toUpperCase() + optsField.substring(1);
//不开启分权
if (!isOpenDevolution) {
if (filterType == AuthFilterTypeEnum.DATA_OPT) {
list.forEach(t -> {
try {
Method optsFieldGetterMethod = t.getClass().getMethod(optsFieldGetter);
Set<String> opts = (Set<String>) optsFieldGetterMethod.invoke(t);
if (opts == null) {
opts = new HashSet<>();
}
opts.add("query");
opts.add("admin");
Method optsFieldSetterMethod = t.getClass().getMethod(optsFieldSetter, Set.class);
optsFieldSetterMethod.invoke(t, opts);
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
throw new SalaryRunTimeException(e);
}
});
}
return list;
}
//未配置分权
if (!isAuth) {
return list;
}
//给总管理员赋值最大权限
Boolean isChief = getTaxAgentService(user).isChief((long) user.getUID());
if (isChief || filterType == AuthFilterTypeEnum.NO_AUTH) {

View File

@ -4923,6 +4923,15 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
validIds.addAll(emp2);
validIds.addAll(emp3);
if (!param.isFlag()) {
// 不是首次创建核算 还需要添加历史核算人员
List<InsuranceAccountDetailPO> insuranceAccountDetailPOS = getInsuranceAccountDetailMapper().selectList(param.getBillMonth(), param.getPaymentOrganization());
List<Long> historyEmpIds = insuranceAccountDetailPOS.stream().filter(po -> po.getPaymentStatus().equals(PaymentStatusEnum.COMMON.getValue())).map(InsuranceAccountDetailPO::getEmployeeId).collect(Collectors.toList());
validIds.addAll(historyEmpIds);
List<Long> finalEmpIds = empIds;
empIds.addAll(historyEmpIds.stream().filter(empId -> !finalEmpIds.contains(empId)).collect(Collectors.toList()));
}
List<Long> finalValidIds = validIds.stream().distinct().collect(Collectors.toList());
ids = empIds.stream().filter(finalValidIds::contains).collect(Collectors.toList());
} else {
@ -4980,14 +4989,11 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
Map<Long, InsuranceArchivesAccountPO> insuranceArchivesAccountPOS = getSIArchivesService(user).buildBatchAccount(ids, paymentOrganization);
List<InsuranceAccountDetailPO> historyDetailData = new ArrayList<>();
List<DataCollectionEmployee> employeeList = getSalaryEmployeeService(user).listByIds(ids);
if (!isFirstFlag) {
// 不是首次核算需要把社保历史数据取出
List<List<Long>> partition = Lists.partition(ids, 100);
partition.forEach(part -> {
historyDetailData.addAll(getInsuranceAccountDetailMapper().list(InsuranceAccountDetailParam.builder().billMonth(billMonth).paymentOrganization(paymentOrganization.toString()).employeeIds(part).build()));
historyDetailData.addAll(getInsuranceAccountDetailMapper().extList(InsuranceAccountDetailParam.builder().billMonth(billMonth).paymentOrganization(paymentOrganization.toString()).employeeIds(part).build()));
});
}
List<List<Long>> partition = Lists.partition(ids, 100);
partition.forEach(part -> {
historyDetailData.addAll(getInsuranceAccountDetailMapper().list(InsuranceAccountDetailParam.builder().billMonth(billMonth).paymentOrganization(paymentOrganization.toString()).employeeIds(part).build()));
historyDetailData.addAll(getInsuranceAccountDetailMapper().extList(InsuranceAccountDetailParam.builder().billMonth(billMonth).paymentOrganization(paymentOrganization.toString()).employeeIds(part).build()));
});
Map<Long, InsuranceAccountDetailPO> historyDetailDataMap = SalaryEntityUtil.convert2Map(historyDetailData, InsuranceAccountDetailPO::getEmployeeId);
Map<Long, DataCollectionEmployee> employeeMap = SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId);
@ -5063,14 +5069,18 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
}
//临时表入库前先对可能存在的历史数据进行删除
// List<List<Long>> partition = Lists.partition((List<Long>) ids, 100);
// partition.forEach(part -> {
// getSIAccountDetailTempMapper().batchDelByEmpIdsAndMonthAndPayOrg(part, billMonth, paymentOrganization);
// });
// 根据人员id删会少删不再参与社保核算的人
getSIAccountDetailTempMapper().batchDelByMonthAndPayOrg(billMonth, paymentOrganization);
partition.forEach(part -> {
getSIAccountDetailTempMapper().batchDelByEmpIdsAndMonthAndPayOrg(part, billMonth, paymentOrganization);
});
// // 根据人员id删会少删不再参与社保核算的人
// getSIAccountDetailTempMapper().batchDelByMonthAndPayOrg(billMonth, paymentOrganization);
//临时表数据入库
if (CollectionUtils.isNotEmpty(list)) {
if (!isFirstFlag) {
// 点击台账内的核算按钮核算人员不变(不增加人)
List<String> existDataKey = historyDetailData.stream().map(po -> po.getPaymentOrganization() + "_" + po.getEmployeeId()).collect(Collectors.toList());
list = list.stream().filter(po -> existDataKey.contains(po.getPaymentOrganization() + "_" + po.getEmployeeId())).collect(Collectors.toList());
}
encryptUtil.encryptList(list, InsuranceAccountDetailTempPO.class);
List<List<InsuranceAccountDetailTempPO>> lists = splitList(list, 20);
lists.forEach(subList -> {
@ -6795,4 +6805,188 @@ public class SIAccountServiceImpl extends Service implements SIAccountService {
/*****以上代码为SIAccountBiz中方法逻辑迁移旨在减少Biz类的使用*****/
/**
* 正常缴纳页 删除社保核算人员
* @param param
*/
@Override
public void deleteSocialAcctEmp(SaveCommonAccountParam param) {
if (StringUtils.isBlank(param.getBillMonth()) || param.getPaymentOrganization() == null) {
throw new SalaryRunTimeException("参数错误");
}
if (CollectionUtils.isEmpty(param.getIds())) {
return;
}
List<InsuranceAccountDetailPO> insuranceAccountDetailPOS = getInsuranceAccountDetailMapper().selectList(param.getBillMonth(), param.getPaymentOrganization());
insuranceAccountDetailPOS = insuranceAccountDetailPOS.stream().filter(detailPO -> param.getIds().contains(detailPO.getId())).collect(Collectors.toList());
List<Long> deleteEmployeeIds = insuranceAccountDetailPOS.stream().map(InsuranceAccountDetailPO::getEmployeeId).collect(Collectors.toList());
deleteAccountDetailsByEmpIds(deleteEmployeeIds, param.getBillMonth(), param.getPaymentOrganization());
if (CollectionUtils.isNotEmpty(deleteEmployeeIds)) {
// 重新计算合计值
updateBatchAccount((AccountParam.builder().billMonth(param.getBillMonth()).paymentOrganization(param.getPaymentOrganization())).build());
}
}
public void deleteAccountDetailsByEmpIds(List<Long> deleteEmployeeIds, String billMonth, Long paymentOrganization) {
if (CollectionUtils.isNotEmpty(deleteEmployeeIds)) {
List<List<Long>> partition = Lists.partition(deleteEmployeeIds, 100);
partition.forEach(part -> {
// 删除该台账下员工的所有数据
getInsuranceAccountDetailMapper().deleteByEmpIds(part, billMonth, paymentOrganization);
});
}
}
/**
* 正常缴纳页 添加社保核算人员
* @param param
*/
@Override
public String addSocialAcctEmp(SaveCommonAccountParam param) {
if (StringUtils.isBlank(param.getBillMonth()) || param.getPaymentOrganization() == null) {
throw new SalaryRunTimeException("参数错误");
}
if (CollectionUtils.isEmpty(param.getIncludes())) {
return "";
}
InsuranceAccountBatchPO insuranceAccountBatchPO = getInsuranceAccountBatchMapper().getByBillMonth(param.getBillMonth(), param.getPaymentOrganization());
if (insuranceAccountBatchPO == null) {
throw new SalaryRunTimeException("台账不存在或已被删除");
}
// 校验是否可以添加这些员工
List<Long> empIds = param.getIncludes();
List<Long> validIds = new ArrayList<>();
// 获取当前台账已经存在的人员
List<InsuranceAccountDetailPO> insuranceAccountDetailPOS = getInsuranceAccountDetailMapper().queryNormalListByBillMonth(param.getBillMonth(), param.getPaymentOrganization());
List<Long> existEmpIds = insuranceAccountDetailPOS.stream().map(InsuranceAccountDetailPO::getEmployeeId).collect(Collectors.toList());
Optional<Long> existOptional = empIds.stream().filter(existEmpIds::contains).findFirst();
if (existOptional.isPresent()) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(101581, "人员已存在,请勿重复添加"));
}
//过滤出需要核算的人员即福利档案基础信息表中runStatus为正在缴纳和待减员的人员
List<InsuranceArchivesBaseInfoPO> baseInfoPOList = getInsuranceBaseInfoMapper().listByEmployeeIds(empIds);
List<Long> canAccountIds = baseInfoPOList.stream()
.filter(f->f.getPaymentOrganization().equals(param.getPaymentOrganization()))
.map(InsuranceArchivesBaseInfoPO::getEmployeeId)
.collect(Collectors.toList());
//20231122逻辑优化过滤出不在起始缴纳月和最后缴纳月区间的人员
List<Long> empIdsInPayMonthRange = listCanPayEmpIds(param.getPaymentOrganization(), param.getBillMonth());
empIds = empIds.stream().filter(f->canAccountIds.contains(f) && empIdsInPayMonthRange.contains(f)).collect(Collectors.toList());
List<InsuranceArchivesSocialSchemePO> socials = getSIArchivesService(user).getSocialByEmployeeIds(empIds);
//过滤出目标个税扣缴义务人相关信息
socials = socials.stream().filter(f -> f.getPaymentOrganization().equals(param.getPaymentOrganization())).collect(Collectors.toList());
List<Long> emp1 = socials.stream()
.filter(s -> !(StringUtils.isBlank(s.getSocialEndTime()) && StringUtils.isBlank(s.getSocialStartTime())) &&
(StringUtils.isBlank(s.getSocialEndTime()) || (SalaryDateUtil.stringToDate(s.getSocialEndTime() + "-01") != null && !SalaryDateUtil.stringToDate(param.getBillMonth() + "-01").after(SalaryDateUtil.stringToDate(s.getSocialEndTime() + "-01")))) )
.map(InsuranceArchivesSocialSchemePO::getEmployeeId)
.collect(Collectors.toList());
List<InsuranceArchivesFundSchemePO> funds = getSIArchivesService(user).getFundByEmployeeIds(empIds);
//过滤出目标个税扣缴义务人相关信息
funds = funds.stream().filter(f -> f.getPaymentOrganization().equals(param.getPaymentOrganization())).collect(Collectors.toList());
List<Long> emp2 = funds.stream()
.filter(s -> !(StringUtils.isBlank(s.getFundStartTime()) && StringUtils.isBlank(s.getFundEndTime())) &&
(StringUtils.isBlank(s.getFundEndTime()) || (SalaryDateUtil.stringToDate(s.getFundEndTime() + "-01") != null && !SalaryDateUtil.stringToDate(param.getBillMonth() + "-01").after(SalaryDateUtil.stringToDate(s.getFundEndTime() + "-01")))))
.map(InsuranceArchivesFundSchemePO::getEmployeeId)
.collect(Collectors.toList());
List<InsuranceArchivesOtherSchemePO> others = getSIArchivesService(user).getOtherByEmployeeIds(empIds);
//过滤出目标个税扣缴义务人相关信息
others = others.stream().filter(f -> f.getPaymentOrganization().equals(param.getPaymentOrganization())).collect(Collectors.toList());
List<Long> emp3 = others.stream()
.filter(s -> !(StringUtils.isBlank(s.getOtherStartTime()) && StringUtils.isBlank(s.getOtherEndTime())) &&
(StringUtils.isBlank(s.getOtherEndTime()) || (SalaryDateUtil.stringToDate(s.getOtherEndTime() + "-01") != null && !SalaryDateUtil.stringToDate(param.getBillMonth() + "-01").after(SalaryDateUtil.stringToDate(s.getOtherEndTime() + "-01")))))
.map(InsuranceArchivesOtherSchemePO::getEmployeeId)
.collect(Collectors.toList());
validIds.addAll(emp1);
validIds.addAll(emp2);
validIds.addAll(emp3);
List<Long> finalValidIds = validIds.stream().distinct().collect(Collectors.toList());
List<Long> conNotAddEmpIds = param.getIncludes().stream().filter(empId -> !finalValidIds.contains(empId)).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(conNotAddEmpIds)) {
String canNotAddName = getSalaryEmployeeService(user).listByIds(conNotAddEmpIds).stream().map(DataCollectionEmployee::getUsername).collect(Collectors.joining(","));
throw new SalaryRunTimeException("添加失败,员工:" +canNotAddName + ",社保、公积金、其他福利需至少有一种在当前账单月需缴纳,并且社保档案需为在缴员工");
}
addCommonEmpAndAccount(param.getBillMonth(), empIds, param.getPaymentOrganization());
return "success";
}
/**
* 添加正常缴纳人员并核算
* @param billMonth
* @param ids
* @param paymentOrganization
*/
public void addCommonEmpAndAccount(String billMonth, List<Long> ids, Long paymentOrganization) {
Map<Long, InsuranceArchivesAccountPO> insuranceArchivesAccountPOS = getSIArchivesService(user).buildBatchAccount(ids, paymentOrganization);
List<DataCollectionEmployee> employeeList = getSalaryEmployeeService(user).listByIds(ids);
Map<Long, DataCollectionEmployee> employeeMap = SalaryEntityUtil.convert2Map(employeeList, DataCollectionEmployee::getEmployeeId);
List<InsuranceAccountDetailTempPO> list = new ArrayList<>();
for (Map.Entry<Long, InsuranceArchivesAccountPO> entry : insuranceArchivesAccountPOS.entrySet()) {
Long k = entry.getKey();
InsuranceArchivesAccountPO v = entry.getValue();
InsuranceAccountDetailPO insuranceAccountDetailPO = new InsuranceAccountDetailPO();
insuranceAccountDetailPO.setBillMonth(billMonth);
insuranceAccountDetailPO.setBillStatus(BillStatusEnum.NOT_ARCHIVED.getValue());
insuranceAccountDetailPO.setCreator((long) user.getUID());
insuranceAccountDetailPO.setCreateTime(new Date());
insuranceAccountDetailPO.setDeleteType(DeleteTypeEnum.NOT_DELETED.getValue());
insuranceAccountDetailPO.setEmployeeId(k);
insuranceAccountDetailPO.setUpdateTime(new Date());
insuranceAccountDetailPO.setPaymentStatus(PaymentStatusEnum.COMMON.getValue());
insuranceAccountDetailPO.setResourceFrom(ResourceFromEnum.SYSTEM.getValue());
insuranceAccountDetailPO.setTenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY);
insuranceAccountDetailPO.setPaymentOrganization(paymentOrganization);
DataCollectionEmployee employee = employeeMap.get(k);
if (employee != null) {
insuranceAccountDetailPO.setSubcompanyName(employee.getSubcompanyName());
insuranceAccountDetailPO.setSubcompanyId(employee.getSubcompanyid());
insuranceAccountDetailPO.setDepartmentName(employee.getDepartmentName());
insuranceAccountDetailPO.setDepartmentId(employee.getDepartmentId());
insuranceAccountDetailPO.setJobtitleName(employee.getJobtitleName());
insuranceAccountDetailPO.setJobtitleId(employee.getJobtitleId());
insuranceAccountDetailPO.setJobcall(employee.getJobcall());
insuranceAccountDetailPO.setJobcallId(employee.getJobcallId());
insuranceAccountDetailPO.setStatus(employee.getStatus());
}
//核算社保
accountSocial(insuranceAccountDetailPO, v, billMonth);
//核算公积金
accountFund(insuranceAccountDetailPO, v, billMonth);
//核算其他福利
accountOther(insuranceAccountDetailPO, v, billMonth);
//计算合计
account(insuranceAccountDetailPO);
//临时表PO
InsuranceAccountDetailTempPO insuranceAccountDetailTempPO = new InsuranceAccountDetailTempPO();
BeanUtils.copyProperties(insuranceAccountDetailPO, insuranceAccountDetailTempPO);
list.add(insuranceAccountDetailTempPO);
}
// 入库
//生成bill_detail入库数据
List<InsuranceAccountDetailPO> collect = list.stream().map(item -> {
InsuranceAccountDetailPO insuranceAccountDetailPO = new InsuranceAccountDetailPO();
BeanUtils.copyProperties(item, insuranceAccountDetailPO);
return insuranceAccountDetailPO;
}).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(collect)) {
encryptUtil.encryptList(collect, InsuranceAccountDetailPO.class);
List<List<InsuranceAccountDetailPO>> lists = splitDetailList(collect, 20);
lists.forEach(subList -> {
getInsuranceAccountDetailMapper().batchSaveAccountDetails(subList);
});
updateBatchAccount((AccountParam.builder().billMonth(billMonth).paymentOrganization(paymentOrganization)).build());
}
}
}

View File

@ -76,6 +76,8 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.stream.Collectors;
import static com.engine.salary.sys.constant.SalarySysConstant.SALARY_ACCT_SYNC_TYPE;
/**
* 薪资核算结果
* <p>Copyright: Copyright (c) 2022</p>
@ -863,6 +865,8 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
// 12.4是否采用系统算税
TaxDeclarationFunctionEnum taxDeclarationFunction = getSalarySysConfService(user).getTaxDeclaration();
// 12.5多线程运算运算结果存放在临时表中
//是否同步计算
boolean isSync = "0".equals(getSalarySysConfService(user).getValueByCode(SALARY_ACCT_SYNC_TYPE));
for (List<SalaryAcctEmployeePO> acctEmployeePOS : partition) {
SalaryAcctCalculateBO salaryAcctCalculateBO = new SalaryAcctCalculateBO()
.setSalaryAcctRecordPO(salaryAcctRecordPO)
@ -884,13 +888,17 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
.setVariableItems(variableItemPOS)
.setTaxDeclarationFunction(taxDeclarationFunction);
List<SalarySobBackItemPO> finalSalarySobBackItems = salarySobBackItems;
LocalRunnable localRunnable = new LocalRunnable() {
@Override
public void execute() {
getSalaryAcctCalculateService(user).calculate(salaryAcctCalculateBO, simpleEmployee, finalSalarySobBackItems);
}
};
ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.HRM, "salaryAcctCalculate", localRunnable);
if (isSync) {
getSalaryAcctCalculateService(user).calculate(salaryAcctCalculateBO, simpleEmployee, finalSalarySobBackItems);
} else {
LocalRunnable localRunnable = new LocalRunnable() {
@Override
public void execute() {
getSalaryAcctCalculateService(user).calculate(salaryAcctCalculateBO, simpleEmployee, finalSalarySobBackItems);
}
};
ThreadPoolUtil.fixedPoolExecute(ModulePoolEnum.HRM, "salaryAcctCalculate", localRunnable);
}
}
// 13等待所有子线程执行完毕
childMonitor.await();
@ -927,6 +935,10 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
// 记录日志
// 查询操作日志的targetName
String targetName = getSalaryAcctRecordService(user).getLogTargetNameById(calculateParam.getSalaryAcctRecordId());
Collection<Long> ids = calculateParam.getIds();
if (CollectionUtils.isNotEmpty(ids)) {
targetName += ids;
}
LoggerContext<SalaryCheckResultPO> loggerContext = new LoggerContext<>();
loggerContext.setUser(user);
loggerContext.setTargetId(String.valueOf(calculateParam.getSalaryAcctRecordId()));

View File

@ -207,6 +207,11 @@ public class TaxDeclarationServiceImpl extends Service implements TaxDeclaration
// 查询薪资所属月的薪资核算记录
salaryAcctRecordPOS = listBySalaryMonth(SalaryAcctRecordPO.builder().salaryMonths(salaryMonthDateRange).build());
// 无薪资核算记录不允许生成个税申报表
if (CollectionUtils.isEmpty(salaryAcctRecordPOS)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98874, "{0}无申报数据").replace("{0}", saveParam.getSalaryMonth().toString()));
}
// 如果当前薪资所属月下存在不同的税款所属期属于异常业务场景不允许生成个税申报表
taxCycle = salaryAcctRecordPOS.get(0).getTaxCycle();
boolean differentTaxCycle = salaryAcctRecordPOS.stream().anyMatch(salaryAcctRecordPO -> salaryAcctRecordPO.getTaxCycle().compareTo(taxCycle) != 0);

View File

@ -71,6 +71,11 @@ public class SalarySysConstant {
*/
public static final String SALARY_ACCT_EMPLOYEE_RULE = "salaryAcctEmployeeRule";
/**
* 是否采用线程池同步异步/1异步 0同步
*/
public static final String SALARY_ACCT_SYNC_TYPE = "SALARY_ACCT_SYNC_TYPE";
/**
* 工资单二次验证方式
*/

View File

@ -42,6 +42,11 @@ import java.util.stream.Collectors;
@Slf4j
public class AutoSyncEmpArchiveStartDateJob extends BaseCronJob {
private String syncInsuranceArchive;
private String syncSalaryArchive;
private String allStayAddToPay;
private String allGotoFixed;
private SalaryArchiveService getSalaryArchiveService(User user) {
return ServiceUtil.getService(SalaryArchiveServiceImpl.class, user);
}
@ -55,12 +60,6 @@ public class AutoSyncEmpArchiveStartDateJob extends BaseCronJob {
return ServiceUtil.getService(SIArchivesServiceImpl.class, user);
}
private String syncInsuranceArchive;
private String syncSalaryArchive;
private String allStayAddToPay;
private String allGotoFixed;
private SalaryArchiveBiz getSalaryArchiveMapper = new SalaryArchiveBiz();
private SocialSchemeMapper getSocialSchemeMapper() {

View File

@ -31,6 +31,13 @@ import java.util.*;
*/
public class AutoSyncResignationEmpArchiveJob extends BaseCronJob {
private String syncInsuranceArchive;
private String syncSalaryArchive;
private String allStayAddToPay;
private String allGotoFixed;
private SalaryArchiveService getSalaryArchiveService(User user) {
return ServiceUtil.getService(SalaryArchiveServiceImpl.class,user);
}
@ -73,39 +80,43 @@ public class AutoSyncResignationEmpArchiveJob extends BaseCronJob {
}
cal.add(Calendar.MONTH, preMonthValue);
Map<Long, String> resignationMap = getSalaryEmployeeService(user).getResignationMapByDate(SalaryDateUtil.getFormatDate(cal.getTime()));
// 获取离职人员中没有设置最后发薪日期的薪资档案
List<SalaryArchivePO> salaryArchivePOS = getSalaryArchiveService(user).listPayEndDateIsNull(new ArrayList<>(resignationMap.keySet()));
Date now = new Date();
List<SalaryArchivePO> needUpdateSalaryArchiveList = new ArrayList<>();
for(SalaryArchivePO archive : salaryArchivePOS){
String dismissDate = resignationMap.get(archive.getEmployeeId());
if (StringUtils.isNotBlank(dismissDate)) {
archive.setPayEndDate(SalaryDateUtil.dateStrToLocalDate(dismissDate));
archive.setUpdateTime(now);
needUpdateSalaryArchiveList.add(archive);
if (StringUtils.isBlank(syncSalaryArchive) || !StringUtils.equals(syncSalaryArchive, "false")) {
// 获取离职人员中没有设置最后发薪日期的薪资档案
List<SalaryArchivePO> salaryArchivePOS = getSalaryArchiveService(user).listPayEndDateIsNull(new ArrayList<>(resignationMap.keySet()));
Date now = new Date();
List<SalaryArchivePO> needUpdateSalaryArchiveList = new ArrayList<>();
for(SalaryArchivePO archive : salaryArchivePOS){
String dismissDate = resignationMap.get(archive.getEmployeeId());
if (StringUtils.isNotBlank(dismissDate)) {
archive.setPayEndDate(SalaryDateUtil.dateStrToLocalDate(dismissDate));
archive.setUpdateTime(now);
needUpdateSalaryArchiveList.add(archive);
}
}
if (CollectionUtils.isNotEmpty(needUpdateSalaryArchiveList)) {
getSalaryArchiveMapper.batchUpdate(needUpdateSalaryArchiveList);
}
}
if (CollectionUtils.isNotEmpty(needUpdateSalaryArchiveList)) {
getSalaryArchiveMapper.batchUpdate(needUpdateSalaryArchiveList);
}
// 获取离职人员中没有设置最后缴纳月的社保福利档案
if (StringUtils.isBlank(syncInsuranceArchive) || !StringUtils.equals(syncInsuranceArchive, "false")) {
// 获取离职人员中没有设置最后缴纳月的社保福利档案
// List<InsuranceArchivesBaseInfoPO> needSyncList = siArchivesBiz.listEndDateIsNull(new ArrayList<>(resignationMap.keySet()));
List<InsuranceArchivesBaseInfoPO> needSyncList = getSIArchivesService(user).listEndDateIsNull(new ArrayList<>(resignationMap.keySet()));
// 设置社保公积金最后缴纳月
for(InsuranceArchivesBaseInfoPO po : needSyncList){
String dismissDate = resignationMap.get(po.getEmployeeId());
if (StringUtils.isNotEmpty(dismissDate)) {
dismissDate = StringUtils.substring(dismissDate,0,7);
// 更新社保最后缴纳月
Long socialArchivesId = po.getSocialArchivesId();
getSocialSchemeMapper().updateEndTime(socialArchivesId, dismissDate);
// 更新公积金最后缴纳月
Long fundArchivesId = po.getFundArchivesId();
getFundSchemeMapper().updateEndTime(fundArchivesId, dismissDate);
// 更新企业年金及其他福利最后缴纳月
Long otherArchivesId = po.getOtherArchivesId();
getOtherSchemeMapper().updateEndTime(otherArchivesId, dismissDate);
List<InsuranceArchivesBaseInfoPO> needSyncList = getSIArchivesService(user).listEndDateIsNull(new ArrayList<>(resignationMap.keySet()));
// 设置社保公积金最后缴纳月
for(InsuranceArchivesBaseInfoPO po : needSyncList){
String dismissDate = resignationMap.get(po.getEmployeeId());
if (StringUtils.isNotEmpty(dismissDate)) {
dismissDate = StringUtils.substring(dismissDate,0,7);
// 更新社保最后缴纳月
Long socialArchivesId = po.getSocialArchivesId();
getSocialSchemeMapper().updateEndTime(socialArchivesId, dismissDate);
// 更新公积金最后缴纳月
Long fundArchivesId = po.getFundArchivesId();
getFundSchemeMapper().updateEndTime(fundArchivesId, dismissDate);
// 更新企业年金及其他福利最后缴纳月
Long otherArchivesId = po.getOtherArchivesId();
getOtherSchemeMapper().updateEndTime(otherArchivesId, dismissDate);
}
}
}
}

View File

@ -243,6 +243,38 @@ public class SIAccountController {
}
}
/**
* 正常缴纳页 删除社保核算人员
* @param request
* @param response
* @param param
* @return
*/
@POST
@Path("/deleteSocialAcctEmp")
@Produces(MediaType.APPLICATION_JSON)
public String deleteSocialAcctEmp(@Context HttpServletRequest request, @Context HttpServletResponse response,
@RequestBody SaveCommonAccountParam param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<SaveCommonAccountParam, String>(user).run(getService(user)::deleteSocialAcctEmp, param);
}
/**
* 正常缴纳页 添加社保核算人员
* @param request
* @param response
* @param param
* @return
*/
@POST
@Path("/addSocialAcctEmp")
@Produces(MediaType.APPLICATION_JSON)
public String addSocialAcctEmp(@Context HttpServletRequest request, @Context HttpServletResponse response,
@RequestBody SaveCommonAccountParam param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<SaveCommonAccountParam, String>(user).run(getService(user)::addSocialAcctEmp, param);
}
/**
* 删除月份表单