Merge remote-tracking branch 'remotes/origin/release/2.9.10.2312.02' into feature/231202-福利台账自动核算并归档

This commit is contained in:
sy 2024-01-22 11:03:37 +08:00
commit 56651196fa
5 changed files with 184 additions and 38 deletions

View File

@ -1,5 +1,6 @@
package com.engine.salary.biz;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
@ -69,6 +70,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static com.engine.salary.sys.constant.SalarySysConstant.WEL_BASE_AUTO_ADJUST;
import static com.engine.salary.sys.constant.SalarySysConstant.WEL_BASE_DIFF_BY_PER_AND_COM;
@ -279,15 +281,19 @@ public class SIArchivesBiz {
//判断是否要区分个人和单位福利基数
SalarySysConfPO welBaseDiff = getSalarySysConfService(user).getOneByCode(WEL_BASE_DIFF_BY_PER_AND_COM);
boolean welBaseDiffSign = welBaseDiff != null && welBaseDiff.getConfValue().equals(OpenEnum.OPEN.getValue());
//判断是否要自动调整基数
SalarySysConfPO welBaseAutoAdjust = getSalarySysConfService(user).getOneByCode(WEL_BASE_AUTO_ADJUST);
boolean welBaseAutoAdjustSign = welBaseAutoAdjust != null && welBaseAutoAdjust.getConfValue().equals(OpenEnum.OPEN.getValue());
switch (welfareType) {
case SOCIAL_SECURITY:
data = buildSocialPaymentForm(user, employeeId, schemeId, operateId, welfareType.getValue(), paymentOrganization, welBaseDiffSign);
data = buildSocialPaymentForm(user, employeeId, schemeId, operateId, welfareType.getValue(), paymentOrganization, welBaseDiffSign, welBaseAutoAdjustSign);
break;
case ACCUMULATION_FUND:
data = buildFundPaymentForm(user, employeeId, schemeId, operateId, welfareType.getValue(), paymentOrganization, welBaseDiffSign);
data = buildFundPaymentForm(user, employeeId, schemeId, operateId, welfareType.getValue(), paymentOrganization, welBaseDiffSign, welBaseAutoAdjustSign);
break;
case OTHER:
data = buildOtherPaymentForm(user, employeeId, schemeId, operateId, welfareType.getValue(), paymentOrganization, welBaseDiffSign);
data = buildOtherPaymentForm(user, employeeId, schemeId, operateId, welfareType.getValue(), paymentOrganization, welBaseDiffSign, welBaseAutoAdjustSign);
break;
default:
}
@ -302,19 +308,30 @@ public class SIArchivesBiz {
* @param operateId
* @return
*/
public Map<String, Object> buildOtherPaymentForm(User user, Long employeeId, Long schemeId, long operateId, Integer welfareType, Long paymentOrganization, boolean welBaseDiffSign) {
public Map<String, Object> buildOtherPaymentForm(User user, Long employeeId, Long schemeId, long operateId, Integer welfareType, Long paymentOrganization, boolean welBaseDiffSign, boolean welBaseAutoAdjustSign) {
Map<String, Object> dataMap = new HashMap<>();
InsuranceArchivesOtherSchemeDTO data = buildOtherForm(employeeId, operateId, paymentOrganization);
Map<String, Object> insuranceValueMap = new HashMap<>();
Map<String, Object> insuranceComValueMap = new HashMap<>();
if (data != null) {
dataMap.put("data", JSONObject.parseObject(data.getOtherPaymentBaseString(), new TypeReference<Map<String, Object>>() {
}));
insuranceValueMap = StrUtil.isNotBlank(data.getOtherPaymentBaseString())
? JSONObject.parseObject(data.getOtherPaymentBaseString(), new TypeReference<Map<String, Object>>() {}) : new HashMap<>();
if (welBaseDiffSign) {
dataMap.put("comData", JSONObject.parseObject(data.getOtherPaymentComBaseString(), new TypeReference<Map<String, Object>>() {
}));
insuranceComValueMap = StrUtil.isNotBlank(data.getOtherPaymentComBaseString())
? JSONObject.parseObject(data.getOtherPaymentComBaseString(), new TypeReference<Map<String, Object>>() {}) : new HashMap<>();
}
}
List<SearchConditionGroup> addGroups = new ArrayList<>();
List<SearchConditionItem> inputItems = buildPaymentBase(user, schemeId, welfareType);
//如果查询结果中存在 方案中缺失福利险种的值设置初始值
for (SearchConditionItem item : inputItems) {
String insuranceId = item.getDomkey().length > 0 ? item.getDomkey()[0] : null;
if (StrUtil.isNotBlank(insuranceId) && insuranceValueMap.get(insuranceId) == null) {
String basicValue = welBaseAutoAdjustSign ? ("0.000".equals(item.getMin()) ? "0" : item.getMin()) : "0";
insuranceValueMap.put(insuranceId, basicValue);
}
}
dataMap.put("data", insuranceValueMap);
addGroups.add(new SearchConditionGroup("其它福利缴纳基数", true, inputItems));
dataMap.put("items", addGroups);
if (welBaseDiffSign) {
@ -322,6 +339,15 @@ public class SIArchivesBiz {
List<SearchConditionItem> inputComItems = buildPaymentComBase(user, schemeId, welfareType);
addComGroups.add(new SearchConditionGroup("其它福利缴纳基数", true, inputComItems));
dataMap.put("comItems", addComGroups);
for (SearchConditionItem item : inputComItems) {
String insuranceId = item.getDomkey().length > 0 ? item.getDomkey()[0] : null;
if (StrUtil.isNotBlank(insuranceId) && insuranceComValueMap.get(insuranceId) == null) {
String basicValue = welBaseAutoAdjustSign ? ("0.000".equals(item.getMin()) ? "0" : item.getMin()) : "0";
insuranceComValueMap.put(insuranceId, basicValue);
}
}
dataMap.put("comData", insuranceComValueMap);
}
return dataMap;
}
@ -334,20 +360,32 @@ public class SIArchivesBiz {
* @param operateId
* @return
*/
public Map<String, Object> buildFundPaymentForm(User user, Long employeeId, Long schemeId, long operateId, Integer welfareType, Long paymentOrganization, boolean welBaseDiffSign) {
public Map<String, Object> buildFundPaymentForm(User user, Long employeeId, Long schemeId, long operateId, Integer welfareType, Long paymentOrganization, boolean welBaseDiffSign, boolean welBaseAutoAdjustSign) {
Map<String, Object> dataMap = new HashMap<>();
InsuranceArchivesFundSchemeDTO data = buildFundForm(employeeId, operateId, paymentOrganization);
Map<String, Object> insuranceValueMap = new HashMap<>();
Map<String, Object> insuranceComValueMap = new HashMap<>();
if (data != null) {
dataMap.put("data", JSONObject.parseObject(data.getFundPaymentBaseString(), new TypeReference<Map<String, Object>>() {
}));
insuranceValueMap = StrUtil.isNotBlank(data.getFundPaymentBaseString())
? JSONObject.parseObject(data.getFundPaymentBaseString(), new TypeReference<Map<String, Object>>() {}) : new HashMap<>();
if (welBaseDiffSign) {
dataMap.put("comData", JSONObject.parseObject(data.getFundPaymentComBaseString(), new TypeReference<Map<String, Object>>() {
}));
insuranceComValueMap = StrUtil.isNotBlank(data.getFundPaymentComBaseString())
? JSONObject.parseObject(data.getFundPaymentComBaseString(), new TypeReference<Map<String, Object>>() {}) : new HashMap<>();
}
}
List<SearchConditionGroup> addGroups = new ArrayList<>();
List<SearchConditionItem> inputItems = buildPaymentBase(user, schemeId, welfareType);
//如果查询结果中存在 方案中缺失福利险种的值设置初始值
for (SearchConditionItem item : inputItems) {
String insuranceId = item.getDomkey().length > 0 ? item.getDomkey()[0] : null;
if (StrUtil.isNotBlank(insuranceId) && insuranceValueMap.get(insuranceId) == null) {
String basicValue = welBaseAutoAdjustSign ? ("0.000".equals(item.getMin()) ? "0" : item.getMin()) : "0";
insuranceValueMap.put(insuranceId, basicValue);
}
}
dataMap.put("data", insuranceValueMap);
addGroups.add(new SearchConditionGroup("公积金缴纳基数", true, inputItems));
dataMap.put("items", addGroups);
if (welBaseDiffSign) {
@ -355,6 +393,15 @@ public class SIArchivesBiz {
List<SearchConditionItem> inputComItems = buildPaymentComBase(user, schemeId, welfareType);
addComGroups.add(new SearchConditionGroup("公积金缴纳基数", true, inputComItems));
dataMap.put("comItems", addComGroups);
for (SearchConditionItem item : inputComItems) {
String insuranceId = item.getDomkey().length > 0 ? item.getDomkey()[0] : null;
if (StrUtil.isNotBlank(insuranceId) && insuranceComValueMap.get(insuranceId) == null) {
String basicValue = welBaseAutoAdjustSign ? ("0.000".equals(item.getMin()) ? "0" : item.getMin()) : "0";
insuranceComValueMap.put(insuranceId, basicValue);
}
}
dataMap.put("comData", insuranceComValueMap);
}
return dataMap;
}
@ -367,20 +414,31 @@ public class SIArchivesBiz {
* @param operateId
* @return
*/
public Map<String, Object> buildSocialPaymentForm(User user, Long employeeId, Long schemeId, long operateId, Integer welfareType, Long paymentOrganization, boolean welBaseDiffSign) {
public Map<String, Object> buildSocialPaymentForm(User user, Long employeeId, Long schemeId, long operateId, Integer welfareType, Long paymentOrganization, boolean welBaseDiffSign, boolean welBaseAutoAdjustSign) {
Map<String, Object> dataMap = new HashMap<>();
InsuranceArchivesSocialSchemeDTO data = buildSocialForm(employeeId, operateId, paymentOrganization);
Map<String, Object> insuranceValueMap = new HashMap<>();
Map<String, Object> insuranceComValueMap = new HashMap<>();
if (data != null) {
dataMap.put("data", JSONObject.parseObject(data.getSchemePaymentBaseString(), new TypeReference<Map<String, Object>>() {
}));
insuranceValueMap = StrUtil.isNotBlank(data.getSchemePaymentBaseString())
? JSONObject.parseObject(data.getSchemePaymentBaseString(), new TypeReference<Map<String, Object>>() {}) : new HashMap<>();
if (welBaseDiffSign) {
dataMap.put("comData", JSONObject.parseObject(data.getSchemePaymentComBaseString(), new TypeReference<Map<String, Object>>() {
}));
insuranceComValueMap = StrUtil.isNotBlank(data.getSchemePaymentComBaseString())
? JSONObject.parseObject(data.getSchemePaymentComBaseString(), new TypeReference<Map<String, Object>>() {}) : new HashMap<>();
}
}
List<SearchConditionGroup> addGroups = new ArrayList<>();
List<SearchConditionItem> inputItems = buildPaymentBase(user, schemeId, welfareType);
//如果查询结果中存在 方案中缺失福利险种的值设置初始值
for (SearchConditionItem item : inputItems) {
String insuranceId = item.getDomkey().length > 0 ? item.getDomkey()[0] : null;
if (StrUtil.isNotBlank(insuranceId) && insuranceValueMap.get(insuranceId) == null) {
String basicValue = welBaseAutoAdjustSign ? ("0.000".equals(item.getMin()) ? "0" : item.getMin()) : "0";
insuranceValueMap.put(insuranceId, basicValue);
}
}
dataMap.put("data", insuranceValueMap);
addGroups.add(new SearchConditionGroup("社保缴纳基数", true, inputItems));
dataMap.put("items", addGroups);
if (welBaseDiffSign) {
@ -388,6 +446,15 @@ public class SIArchivesBiz {
List<SearchConditionItem> inputComItems = buildPaymentComBase(user, schemeId, welfareType);
addComGroups.add(new SearchConditionGroup("社保缴纳基数", true, inputComItems));
dataMap.put("comItems", addComGroups);
for (SearchConditionItem item : inputComItems) {
String insuranceId = item.getDomkey().length > 0 ? item.getDomkey()[0] : null;
if (StrUtil.isNotBlank(insuranceId) && insuranceComValueMap.get(insuranceId) == null) {
String basicValue = welBaseAutoAdjustSign ? ("0.000".equals(item.getMin()) ? "0" : item.getMin()) : "0";
insuranceComValueMap.put(insuranceId, basicValue);
}
}
dataMap.put("comData", insuranceComValueMap);
}
return dataMap;

View File

@ -10,6 +10,7 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Collection;
import java.util.Date;
import java.util.List;
/**
@ -88,4 +89,25 @@ public class SalaryArchiveQueryParam extends BaseQueryParam {
*/
private boolean extSalaryArchiveList;
private String payStartDateStartDateStr;
private String payStartDateEndDateStr;
// 起始发薪日期起
private Date payStartDateStartDate;
// 起始发薪日期止
private Date payStartDateEndDate;
// 最后发薪日期起
private String payEndDateStartDateStr;
// 最后发薪日期止
private String payEndDateEndDateStr;
// 最后发薪日期起
private Date payEndDateStartDate;
// 最后发薪日期止
private Date payEndDateEndDate;
}

View File

@ -183,6 +183,18 @@
#{runStatus}
</foreach>
</if>
<if test="param.payStartDateStartDate != null and param.payStartDateStartDate != null">
AND pay_start_date <![CDATA[ >= ]]> #{param.payStartDateStartDate}
</if>
<if test="param.payStartDateEndDate != null and param.payStartDateEndDate != null">
AND pay_start_date <![CDATA[ <= ]]> #{param.payStartDateEndDate}
</if>
<if test="param.payEndDateStartDate != null and param.payEndDateStartDate != null">
AND pay_end_date <![CDATA[ >= ]]> #{param.payEndDateStartDate}
</if>
<if test="param.payEndDateEndDate != null and param.payEndDateEndDate != null">
AND pay_end_date <![CDATA[ <= ]]> #{param.payEndDateEndDate}
</if>
<!-- 排序 -->
<if test="param.orderRule != null">
ORDER BY ${param.orderRule.orderRule} ${param.orderRule.ascOrDesc}
@ -264,6 +276,18 @@
#{runStatus}
</foreach>
</if>
<if test="param.payStartDateStartDate != null and param.payStartDateStartDate != null">
AND pay_start_date <![CDATA[ >= ]]> #{param.payStartDateStartDate}
</if>
<if test="param.payStartDateEndDate != null and param.payStartDateEndDate != null">
AND pay_start_date <![CDATA[ <= ]]> #{param.payStartDateEndDate}
</if>
<if test="param.payEndDateStartDate != null and param.payEndDateStartDate != null">
AND pay_end_date <![CDATA[ >= ]]> #{param.payEndDateStartDate}
</if>
<if test="param.payEndDateEndDate != null and param.payEndDateEndDate != null">
AND pay_end_date <![CDATA[ <= ]]> #{param.payEndDateEndDate}
</if>
<!-- 排序 -->
<if test="param.orderRule != null">
ORDER BY ${param.orderRule.orderRule} ${param.orderRule.ascOrDesc}
@ -346,6 +370,18 @@
#{runStatus}
</foreach>
</if>
<if test="param.payStartDateStartDate != null and param.payStartDateStartDate != null">
AND pay_start_date <![CDATA[ >= ]]> #{param.payStartDateStartDate}
</if>
<if test="param.payStartDateEndDate != null and param.payStartDateEndDate != null">
AND pay_start_date <![CDATA[ <= ]]> #{param.payStartDateEndDate}
</if>
<if test="param.payEndDateStartDate != null and param.payEndDateStartDate != null">
AND pay_end_date <![CDATA[ >= ]]> #{param.payEndDateStartDate}
</if>
<if test="param.payEndDateEndDate != null and param.payEndDateEndDate != null">
AND pay_end_date <![CDATA[ <= ]]> #{param.payEndDateEndDate}
</if>
<!-- 排序 -->
<if test="param.orderRule != null">
ORDER BY ${param.orderRule.orderRule} ${param.orderRule.ascOrDesc}

View File

@ -163,6 +163,19 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe
if (queryParam.isExtSalaryArchiveList()) {
return getSalaryArchiveMapper().listExtSalaryArchive(queryParam);
}
if (StringUtils.isNotBlank(queryParam.getPayStartDateStartDateStr())) {
queryParam.setPayStartDateStartDate(SalaryDateUtil.stringToDate(queryParam.getPayStartDateStartDateStr()));
}
if (Objects.nonNull(queryParam.getPayStartDateEndDateStr())) {
queryParam.setPayStartDateEndDate(SalaryDateUtil.stringToDate(queryParam.getPayStartDateEndDateStr()));
}
if (StringUtils.isNotBlank(queryParam.getPayEndDateStartDateStr())) {
queryParam.setPayEndDateStartDate(SalaryDateUtil.stringToDate(queryParam.getPayEndDateStartDateStr()));
}
if (Objects.nonNull(queryParam.getPayEndDateEndDateStr())) {
queryParam.setPayEndDateEndDate(SalaryDateUtil.stringToDate(queryParam.getPayEndDateEndDateStr()));
}
return getSalaryArchiveMapper().list(queryParam);
}
@ -320,11 +333,11 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe
@Override
public void deleteSalaryArchive(Collection<Long> salaryArchiveIds) {
if(CollectionUtils.isEmpty(salaryArchiveIds)){
if (CollectionUtils.isEmpty(salaryArchiveIds)) {
throw new SalaryRunTimeException("薪资档案参数为空!");
}
SalarySysConfPO canDelete = getSalarySysConfService(user).getOneByCode(SalarySysConstant.SALARY_ARCHIVE_DELETE);
if(Objects.isNull(canDelete) || StringUtils.equals(canDelete.getConfValue(),"0") ){
if (Objects.isNull(canDelete) || StringUtils.equals(canDelete.getConfValue(), "0")) {
throw new SalaryRunTimeException("不允许删除薪资档案,请先开启删除档案规则配置!");
}
List<SalaryArchivePO> salaryArchiveList = getSalaryArchiveMapper().listSome(SalaryArchivePO.builder().ids(salaryArchiveIds).build());
@ -333,17 +346,17 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe
List<Long> canDeleteTaxAgentIds = getTaxAgentService(user).listAllTaxAgentsAsAdmin((long) user.getUID())
.stream().map(TaxAgentPO::getId).collect(Collectors.toList());
boolean err = salaryArchiveList.stream().anyMatch(po -> !canDeleteTaxAgentIds.contains(po.getTaxAgentId()));
if(CollectionUtils.isEmpty(salaryArchiveList) || err){
if (CollectionUtils.isEmpty(salaryArchiveList) || err) {
throw new SalaryRunTimeException("薪资档案不存在,或没有权限删除该薪资档案!");
}
Optional<SalaryArchivePO> fixedList = salaryArchiveList.stream().filter(archive -> !StringUtils.equals(archive.getRunStatus(), SalaryArchiveStatusEnum.PENDING.getValue())
&& !StringUtils.equals(archive.getRunStatus(), SalaryArchiveStatusEnum.STOP_FROM_PENDING.getValue())).findFirst();
if(fixedList.isPresent()){
if (fixedList.isPresent()) {
throw new SalaryRunTimeException("发薪员工、待停薪员工、停薪_来自待停薪无法删除薪资档案");
}
List<Long> deleteIds = salaryArchiveList.stream().map(SalaryArchivePO::getId).collect(Collectors.toList());
// 删除薪资档案及档案项目
if(CollectionUtils.isNotEmpty(deleteIds)){
if (CollectionUtils.isNotEmpty(deleteIds)) {
getSalaryArchiveMapper().deleteByIds(deleteIds);
getSalaryArchiveItemMapper().deleteBySalaryArchiveId(deleteIds);
}
@ -432,7 +445,7 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe
List<Long> salaryItemIds = salaryItems.stream().map(SalaryItemPO::getId).collect(Collectors.toList());
// 1.获取薪资档案所对应的当前生效的薪资项目数据
List<SalaryArchiveItemPO> salaryArchiveItemList = Collections.emptyList();
if(CollectionUtils.isNotEmpty(ids) && CollectionUtils.isNotEmpty(salaryItemIds) || !isPage){
if (CollectionUtils.isNotEmpty(ids) && CollectionUtils.isNotEmpty(salaryItemIds) || !isPage) {
salaryArchiveItemList = getCurrentEffectiveItemList(ids, salaryItemIds);
}
List<SalaryArchiveItemPO> finalSalaryArchiveItemList = salaryArchiveItemList;
@ -461,7 +474,7 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe
// 3.组装数据
List<Map<String, Object>> listMaps = new ArrayList<>();
salaryArchives.forEach(e -> {
e.setEmployeeStatus(UserStatusEnum.getDefaultLabelByValue(Integer.parseInt(e.getEmployeeStatus())));
e.setEmployeeStatus(NumberUtils.isCreatable(e.getEmployeeStatus()) ? UserStatusEnum.getDefaultLabelByValue(Integer.parseInt(e.getEmployeeStatus())) : "");
Map<String, Object> map = new LinkedHashMap<>();
map.put("id", e.getId());
@ -757,11 +770,11 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe
// 获取核算人员规则
List<String> statusList = Collections.emptyList();
SalarySysConfPO employeeRule = getSalarySysConfService(user).getOneByCode(SalarySysConstant.SALARY_ACCT_EMPLOYEE_RULE);
if(Objects.isNull(employeeRule) || StringUtils.equals(employeeRule.getConfValue(), SalaryAcctEmployeeRuleEnum.BYPAYENDTIME.getValue())){
if (Objects.isNull(employeeRule) || StringUtils.equals(employeeRule.getConfValue(), SalaryAcctEmployeeRuleEnum.BYPAYENDTIME.getValue())) {
// 默认包含停薪列表
statusList = Arrays.asList(SalaryArchiveStatusEnum.FIXED.getValue(), SalaryArchiveStatusEnum.SUSPEND.getValue(),
SalaryArchiveStatusEnum.STOP_FROM_SUSPEND.getValue() );
}else{
SalaryArchiveStatusEnum.STOP_FROM_SUSPEND.getValue());
} else {
// 仅包含发薪待定薪
statusList = Arrays.asList(SalaryArchiveStatusEnum.FIXED.getValue(), SalaryArchiveStatusEnum.SUSPEND.getValue());
}

View File

@ -3,6 +3,9 @@ package com.engine.salary.util.page;
import com.github.pagehelper.PageHelper;
import org.apache.commons.collections4.CollectionUtils;
import java.awt.*;
import java.awt.font.FontRenderContext;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -91,18 +94,23 @@ public class SalaryPageUtil {
endIndex > source.size() ? source.size() : endIndex);
}
static Font font = new Font("Arial", Font.PLAIN, 12); // 设置字体样式大小等属性
static FontRenderContext frc = new FontRenderContext(null, true, false);
// GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
/**
* 自适应文字长度
* @param chars
* @param width
* @return
*/
public static String selfAdaption(String chars, Integer width) {
if (width != null && width != 0){
if (width != null && width != 0) {
return width + "";
}
int adaption = 0;
if (chars != null) {
adaption = chars.length() * 12 + 55;
}
if (adaption < 79) {
adaption = 79;
}
return adaption + "";
Rectangle2D bounds = font.getStringBounds(chars, frc);
int pxLength = (int) Math.ceil(bounds.getWidth());
return pxLength + 55 + "";
}
}