Compare commits

...

15 Commits

16 changed files with 363 additions and 58 deletions

View File

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

View File

@ -34,8 +34,8 @@ CREATE TABLE hrsa_push_record_detail
)
/
ALTER TABLE hrsa_push_record ADD fail_reason varchar2(4000);
ALTER TABLE hrsa_push_record ADD fail_reason varchar2(4000)
/
ALTER TABLE hrsa_push_record_detail ADD fail_reason varchar2(4000);
ALTER TABLE hrsa_push_record_detail ADD fail_reason varchar2(4000)
/

View File

@ -1,5 +1,5 @@
ALTER TABLE hrsa_push_setting_item ADD sorted_index NUMBER;
ALTER TABLE hrsa_push_setting_item ADD sorted_index NUMBER
/
ALTER TABLE hrsa_push_record_detail ADD data_id NUMBER(38,0);
ALTER TABLE hrsa_push_record_detail ADD data_id NUMBER(38,0)
/

View File

@ -1,6 +1,8 @@
package com.engine.salary.entity.salaryacct.bo;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
import com.engine.kq.service.KQGroupService;
import com.engine.salary.annotation.SalaryFormulaVar;
import com.engine.salary.common.LocalDateRange;
import com.engine.salary.constant.SalaryFormulaFieldConstant;
@ -24,16 +26,22 @@ import com.engine.salary.enums.UserStatusEnum;
import com.engine.salary.enums.salaryformula.SalaryFormulaReferenceEnum;
import com.engine.salary.enums.salaryformula.SalarySQLReferenceEnum;
import com.engine.salary.enums.salarysob.SalarySobAdjustRuleTypeEnum;
import com.engine.salary.mapper.SQLMapper;
import com.engine.salary.util.JsonUtil;
import com.engine.salary.util.SalaryDateUtil;
import com.engine.salary.util.SalaryEntityUtil;
import com.engine.salary.util.db.MapperProxyFactory;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.mzlion.core.lang.CollectionUtils;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.User;
import java.lang.reflect.Field;
import java.math.BigDecimal;
@ -66,6 +74,8 @@ public class CalculateFormulaVarBO {
*/
private List<SalaryArchiveDataDTO> salaryArchiveData;
private List<SalaryArchiveDataDTO> lastMonthSalaryArchiveData;
/**
* 累计情况
*/
@ -106,6 +116,11 @@ public class CalculateFormulaVarBO {
*/
List<SalaryAcctResultPO> lastMonthResultPOS;
private SQLMapper getSQLMapper() {
return MapperProxyFactory.getProxy(SQLMapper.class);
}
public CalculateFormulaVarBO(List<DataCollectionEmployee> simpleEmployees,
List<SalaryArchiveDataDTO> salaryArchiveData,
List<AddUpSituation> addUpSituationPOS,
@ -115,7 +130,8 @@ public class CalculateFormulaVarBO {
List<AttendQuoteDataDTO> attendQuoteDataDTOS,
List<SalaryAcctResultPO> salaryAcctResultPOS,
List<Map<String, Object>> variableArchiveList,
List<SalaryAcctResultPO> lastMonthResultPOS) {
List<SalaryAcctResultPO> lastMonthResultPOS,
List<SalaryArchiveDataDTO> lastMonthSalaryArchiveData) {
this.simpleEmployees = simpleEmployees;
this.salaryArchiveData = salaryArchiveData;
this.addUpSituationPOS = addUpSituationPOS;
@ -126,6 +142,7 @@ public class CalculateFormulaVarBO {
this.salaryAcctResultPOS = salaryAcctResultPOS;
this.variableArchiveList = variableArchiveList;
this.lastMonthResultPOS = lastMonthResultPOS;
this.lastMonthSalaryArchiveData = lastMonthSalaryArchiveData;
}
/**
@ -134,12 +151,12 @@ public class CalculateFormulaVarBO {
* @param salaryAcctCalculateBO 核算参数
* @return
*/
public Map<String, List<FormulaVarValue>> convert2FormulaVar(SalaryAcctCalculateBO salaryAcctCalculateBO) {
public Map<String, List<FormulaVarValue>> convert2FormulaVar(SalaryAcctCalculateBO salaryAcctCalculateBO, KQGroupService kqGroupService) {
Map<String, List<FormulaVarValue>> resultMap = Maps.newHashMapWithExpectedSize(salaryAcctCalculateBO.getSalaryAcctEmployeePOS().size());
// 处理薪资核算结果
handleSalaryAcctResult(salaryAcctCalculateBO, resultMap);
// 处理薪资档案
handleSalaryArchiveData(salaryAcctCalculateBO, resultMap);
handleSalaryArchiveData(salaryAcctCalculateBO, resultMap, kqGroupService);
// 处理浮动薪资档案
handleVariableArchiveData(salaryAcctCalculateBO, resultMap);
// 处理往期累计情况
@ -267,16 +284,33 @@ public class CalculateFormulaVarBO {
* @param salaryAcctCalculateBO 薪资核算参数
* @param resultMap 返回结果集
*/
private void handleSalaryArchiveData(SalaryAcctCalculateBO salaryAcctCalculateBO, Map<String, List<FormulaVarValue>> resultMap) {
private void handleSalaryArchiveData(SalaryAcctCalculateBO salaryAcctCalculateBO, Map<String, List<FormulaVarValue>> resultMap, KQGroupService kqGroupService) {
// 调薪计薪规则
Map<Long, SalarySobAdjustRulePO> salarySobAdjustRulePOMap = SalaryEntityUtil.convert2Map(salaryAcctCalculateBO.getSalarySobAdjustRulePOS(),
SalarySobAdjustRulePO::getSalaryItemId);
Map<Long, SalaryArchiveDataDTO> lastMonthSalaryArchiveDataMap = SalaryEntityUtil.convert2Map(lastMonthSalaryArchiveData, SalaryArchiveDataDTO::getEmployeeId);
// 获取3个档案的薪资项目id
BaseBean baseBean = new BaseBean();
Long jbgzItemId = NumberUtils.isCreatable(baseBean.getPropValue("wyhzzxSalary", "jbgz_item_id")) ? Long.valueOf(baseBean.getPropValue("wyhzzxSalary", "jbgz_item_id")) : 0L;
Long gwgzItemId = NumberUtils.isCreatable(baseBean.getPropValue("wyhzzxSalary", "gwgz_item_id")) ? Long.valueOf(baseBean.getPropValue("wyhzzxSalary", "gwgz_item_id")) : 0L;
Long jxgzItemId = NumberUtils.isCreatable(baseBean.getPropValue("wyhzzxSalary", "jxgz_item_id")) ? Long.valueOf(baseBean.getPropValue("wyhzzxSalary", "jxgz_item_id")) : 0L;
for (SalaryArchiveDataDTO salaryArchiveDataDTO : salaryArchiveData) {
SalaryArchiveDataDTO lastMonthSalaryArchiveDataDTO = lastMonthSalaryArchiveDataMap.get(salaryArchiveDataDTO.getEmployeeId()) == null
? SalaryArchiveDataDTO.builder().taxAgents(new ArrayList<>()).build() : lastMonthSalaryArchiveDataMap.get(salaryArchiveDataDTO.getEmployeeId());
List<SalaryArchiveTaxAgentDataDTO> lastMonthSalaryArchiveTaxAgentDataList = lastMonthSalaryArchiveDataDTO.getTaxAgents() == null ? new ArrayList<>() : lastMonthSalaryArchiveDataDTO.getTaxAgents();
for (SalaryArchiveTaxAgentDataDTO salaryArchiveTaxAgentDataDTO : salaryArchiveDataDTO.getTaxAgents()) {
String key = salaryArchiveDataDTO.getEmployeeId() + "_" + salaryArchiveTaxAgentDataDTO.getTaxAgentId();
List<FormulaVarValue> formulaVarValues = resultMap.computeIfAbsent(key, k -> Lists.newArrayList());
Optional<SalaryArchiveTaxAgentDataDTO> lastMonthDataDTOOptional = lastMonthSalaryArchiveTaxAgentDataList.stream().filter(dto -> dto.getTaxAgentId().equals(salaryArchiveTaxAgentDataDTO.getTaxAgentId())).findFirst();
List<SalaryArchiveItemDataDTO> lastMonthSalaryItemValues = new ArrayList<>();
if (lastMonthDataDTOOptional.isPresent()) {
lastMonthSalaryItemValues = lastMonthDataDTOOptional.get().getSalaryItemValues();
}
// 将薪资档案的值转换成公式中的变量填充到返回结果集中
formulaVarValues.addAll(handleSalaryArchiveItemVal(salaryAcctCalculateBO, salaryArchiveTaxAgentDataDTO.getSalaryItemValues(), salarySobAdjustRulePOMap));
formulaVarValues.addAll(handleSalaryArchiveItemVal(salaryAcctCalculateBO, salaryArchiveTaxAgentDataDTO.getSalaryItemValues(), salarySobAdjustRulePOMap, lastMonthSalaryItemValues, kqGroupService, salaryArchiveDataDTO.getEmployeeId(), jbgzItemId, gwgzItemId, jxgzItemId));
}
}
}
@ -312,7 +346,11 @@ public class CalculateFormulaVarBO {
*/
private List<FormulaVarValue> handleSalaryArchiveItemVal(SalaryAcctCalculateBO salaryAcctCalculateBO,
List<SalaryArchiveItemDataDTO> salaryArchiveItemDataList,
Map<Long, SalarySobAdjustRulePO> salarySobAdjustRulePOMap) {
Map<Long, SalarySobAdjustRulePO> salarySobAdjustRulePOMap,
List<SalaryArchiveItemDataDTO> lastMonthSalaryItemValues,
KQGroupService kqGroupService, Long employeeId,
Long jbgzItemId, Long gwgzItemId, Long jxgzItemId) {
DataCollectionEmployee employee = simpleEmployees.stream().filter(emp -> emp.getEmployeeId().equals(employeeId)).findFirst().orElse(null);
// 薪资周期
LocalDateRange salaryCycle = salaryAcctCalculateBO.getSalarySobCycleDTO().getSalaryCycle();
// key:薪资项目的idvalue:薪资项目的code
@ -323,26 +361,91 @@ public class CalculateFormulaVarBO {
Collectors.collectingAndThen(Collectors.toList(), salaryArchiveItemDataDTOS -> salaryArchiveItemDataDTOS.stream()
.sorted(Comparator.comparing(salaryArchiveItemDataDTO -> salaryArchiveItemDataDTO.getEffectiveDateRange().getFromDate()))
.collect(Collectors.toList()))));
// 上月薪资周期
LocalDateRange lastMonthSalaryCycle = salaryAcctCalculateBO.getLastMonthSalarySobCycleDTO().getSalaryCycle();
String lastMonthSalaryCycleFromDate = SalaryDateUtil.getFormatLocalDate(lastMonthSalaryCycle.getFromDate());
String thisMonthSalaryCycleFromDate = SalaryDateUtil.getFormatLocalDate(salaryAcctCalculateBO.getSalarySobCycleDTO().getSalaryCycle().getFromDate());
// 将薪资档案的调薪记录按照薪资项目id聚合(同一个薪资项目可能存在多次调薪按照生效日期对调薪记录排序)
Map<Long, List<SalaryArchiveItemDataDTO>> lastMonthdataMap = lastMonthSalaryItemValues.stream()
.collect(Collectors.groupingBy(SalaryArchiveItemDataDTO::getSalaryItemId,
Collectors.collectingAndThen(Collectors.toList(), salaryArchiveItemDataDTOS -> salaryArchiveItemDataDTOS.stream()
.sorted(Comparator.comparing(salaryArchiveItemDataDTO -> salaryArchiveItemDataDTO.getEffectiveDateRange().getFromDate()))
.collect(Collectors.toList()))));
// 将薪资档案的值转换成公式编辑器中的变量
List<FormulaVarValue> formulaVarValues = Lists.newArrayListWithExpectedSize(dataMap.size());
for (Map.Entry<Long, List<SalaryArchiveItemDataDTO>> entry : dataMap.entrySet()) {
String value;
// 获取薪资项目的调薪规则
SalarySobAdjustRulePO salaryAdjustmentRulePO = salarySobAdjustRulePOMap.get(entry.getKey());
if (entry.getValue().size() > 2) {
// 如果薪资项目在薪资周期内经历了多次调薪则默认分段计薪
value = calculateBySalarySobAdjustRule(salaryCycle, SalarySobAdjustRuleTypeEnum.PARTITION, entry.getValue());
} else if (salaryAdjustmentRulePO == null || entry.getValue().size() < 2) {
// 如果薪资项目没有设置调薪计薪规则默认取薪资周期内薪资档案中最新的值
// 如果薪资项目在薪资周期内没有调薪默认取薪资周期内薪资档案中最新的值
value = calculateBySalarySobAdjustRule(salaryCycle, SalarySobAdjustRuleTypeEnum.USE_AFTER_ADJUSTMENT, entry.getValue());
// if (entry.getValue().size() > 2) {
// // 如果薪资项目在薪资周期内经历了多次调薪则默认分段计薪
// value = calculateBySalarySobAdjustRule(salaryCycle, SalarySobAdjustRuleTypeEnum.PARTITION, entry.getValue());
// } else if (salaryAdjustmentRulePO == null || entry.getValue().size() < 2) {
// // 如果薪资项目没有设置调薪计薪规则默认取薪资周期内薪资档案中最新的值
// // 如果薪资项目在薪资周期内没有调薪默认取薪资周期内薪资档案中最新的值
// value = calculateBySalarySobAdjustRule(salaryCycle, SalarySobAdjustRuleTypeEnum.USE_AFTER_ADJUSTMENT, entry.getValue());
// } else {
// // 如果薪资项目在薪资周期内只有一次调薪则根据调薪计薪规则处理
// SalarySobAdjustRuleTypeEnum adjustRuleTypeEnum = salaryAdjustmentRulePO.getDayOfMonth() < SalaryDateUtil.dateToLocalDate(entry.getValue().get(0).getEffectiveDateRange().getEndDate()).getDayOfMonth()
// ? SalarySobAdjustRuleTypeEnum.parseByValue(salaryAdjustmentRulePO.getAfterAdjustmentType())
// : SalarySobAdjustRuleTypeEnum.parseByValue(salaryAdjustmentRulePO.getBeforeAdjustmentType());
// // 根据调薪计薪规则处理薪资档案的调薪
// value = calculateBySalarySobAdjustRule(salaryCycle, adjustRuleTypeEnum, entry.getValue());
// }
List<SalaryArchiveItemDataDTO> thisMonthEntryValue = new ArrayList<>();
if (CollectionUtils.isEmpty(entry.getValue())) {
thisMonthEntryValue = new ArrayList<>();
SalaryArchiveItemDataDTO zeroData = SalaryArchiveItemDataDTO.builder().effectiveDateRange(salaryAcctCalculateBO.getSalarySobCycleDTO().getSalaryCycle()).salaryItemId(entry.getKey()).value("0").build();
thisMonthEntryValue.add(zeroData);
} else {
// 如果薪资项目在薪资周期内只有一次调薪则根据调薪计薪规则处理
SalarySobAdjustRuleTypeEnum adjustRuleTypeEnum = salaryAdjustmentRulePO.getDayOfMonth() < SalaryDateUtil.dateToLocalDate(entry.getValue().get(0).getEffectiveDateRange().getEndDate()).getDayOfMonth()
? SalarySobAdjustRuleTypeEnum.parseByValue(salaryAdjustmentRulePO.getAfterAdjustmentType())
: SalarySobAdjustRuleTypeEnum.parseByValue(salaryAdjustmentRulePO.getBeforeAdjustmentType());
// 根据调薪计薪规则处理薪资档案的调薪
value = calculateBySalarySobAdjustRule(salaryCycle, adjustRuleTypeEnum, entry.getValue());
thisMonthEntryValue = entry.getValue();
// 如果第一个生效范围的起始日不是薪资周期起始日在最前面补一条为值0的数据
String effectiveFromDate = SalaryDateUtil.getFormatLocalDate(entry.getValue().get(0).getEffectiveDateRange().getFromDate());
if (!thisMonthSalaryCycleFromDate.equals(effectiveFromDate)) {
LocalDateRange localDateRange = LocalDateRange.builder()
.fromDate(salaryAcctCalculateBO.getSalarySobCycleDTO().getSalaryCycle().getFromDate())
.endDate(entry.getValue().get(0).getEffectiveDateRange().getFromDate())
.build();
SalaryArchiveItemDataDTO zeroData = SalaryArchiveItemDataDTO.builder().effectiveDateRange(localDateRange).salaryItemId(entry.getKey()).value("0").build();
thisMonthEntryValue.add(0, zeroData);
}
}
// 直接取调薪前的金额
value = calculateBySalarySobAdjustRule(salaryCycle, SalarySobAdjustRuleTypeEnum.USE_BEFORE_ADJUSTMENT, thisMonthEntryValue);
if (entry.getKey().equals(jbgzItemId) || entry.getKey().equals(gwgzItemId) || entry.getKey().equals(jxgzItemId)) {
List<SalaryArchiveItemDataDTO> lastMonthEntryValue = lastMonthdataMap.get(entry.getKey());
if (lastMonthEntryValue == null) {
lastMonthEntryValue = new ArrayList<>();
SalaryArchiveItemDataDTO zeroData = SalaryArchiveItemDataDTO.builder().effectiveDateRange(lastMonthSalaryCycle).salaryItemId(entry.getKey()).value("0").build();
lastMonthEntryValue.add(zeroData);
} else {
// 如果第一个生效范围的起始日不是薪资周期起始日补一条为值0的数据
String effectiveFromDate = SalaryDateUtil.getFormatLocalDate(lastMonthEntryValue.get(0).getEffectiveDateRange().getFromDate());
if (!lastMonthSalaryCycleFromDate.equals(effectiveFromDate)) {
LocalDateRange localDateRange = LocalDateRange.builder()
.fromDate(lastMonthSalaryCycle.getFromDate())
.endDate(lastMonthEntryValue.get(0).getEffectiveDateRange().getFromDate())
.build();
SalaryArchiveItemDataDTO zeroData = SalaryArchiveItemDataDTO.builder().effectiveDateRange(localDateRange).salaryItemId(entry.getKey()).value("0").build();
lastMonthEntryValue.add(0, zeroData);
}
}
// 绩效工资是需要获取上月的值(调薪前)
if (entry.getKey().equals(jxgzItemId)) {
value = CollectionUtils.isEmpty(lastMonthEntryValue) ? "0" : lastMonthEntryValue.get(0).getValue();
}
// 获取上月是否发生了调薪并计算需要补的金额
BigDecimal supplementValue = getNeedSupplementValue(entry.getKey(), employeeId, employee,
lastMonthEntryValue, lastMonthSalaryCycle, kqGroupService, jxgzItemId);
if (supplementValue != null) {
value = (NumberUtils.isCreatable(value) ? new BigDecimal(value) : new BigDecimal("0")).add(supplementValue).toString();
}
}
String fieldId = SalaryFormulaReferenceEnum.SALARY_ARCHIVES.getValue()
+ SalaryFormulaFieldConstant.FIELD_ID_SEPARATOR
@ -352,6 +455,172 @@ public class CalculateFormulaVarBO {
return formulaVarValues;
}
/**
* @ClassName CalculateFormulaVarBO
* @author Harryxzy
* @date 2025/5/14 13:58
* @description 获取上月是否发生了调薪并计算需要补的金额
*/
private BigDecimal getNeedSupplementValue(Long salaryItemId, Long employeeId, DataCollectionEmployee employee,
List<SalaryArchiveItemDataDTO> salaryArchiveItemDataDTOS,
LocalDateRange lastMonthSalaryCycle, KQGroupService kqGroupService,
Long jxgzItemId) {
if (CollectionUtils.isEmpty(salaryArchiveItemDataDTOS) || salaryArchiveItemDataDTOS.size() < 2) {
// 上月没有值或没有发生调薪
return BigDecimal.ZERO;
}
// 绩效工资只有是入职月离职月才计算
if (salaryItemId.equals(jxgzItemId)) {
if (employee == null) {
return BigDecimal.ZERO;
}
Date fromDate = lastMonthSalaryCycle.getFromDate();
Date endDate = lastMonthSalaryCycle.getEndDate();
Date dismissDate = SalaryDateUtil.stringToDate(employee.getDismissdate());
Date companystartdate = SalaryDateUtil.stringToDate(employee.getCompanystartdate());
String status = employee.getStatus();
List<String> departureStatusList = Arrays.asList("4", "5", "6");
boolean needAccount = false;
if (dismissDate != null && DateUtil.isIn(dismissDate, fromDate, endDate) && departureStatusList.contains(status)) {
needAccount = true;
}
if (companystartdate != null && DateUtil.isIn(companystartdate, fromDate, endDate)) {
needAccount = true;
}
if (!needAccount) {
return BigDecimal.ZERO;
}
}
// 可能存在多次调薪
// = (第一段的值*第一段的自然日+第二段的值*第二段的自然日+)/薪资所属月自然日
// BigDecimal valueSum = BigDecimal.ZERO;
BigDecimal firstValue = BigDecimal.ZERO;
BigDecimal baseValue = new BigDecimal("21.75");
// 调薪补差金额
BigDecimal needAddValue = new BigDecimal(0);
if (CollectionUtils.isNotEmpty(salaryArchiveItemDataDTOS)) {
firstValue = SalaryEntityUtil.empty2Zero(salaryArchiveItemDataDTOS.get(0).getValue());
}
BaseBean baseBean = new BaseBean();
baseBean.writeLog("wysize"+salaryArchiveItemDataDTOS.size());
for (int i = 1; i < salaryArchiveItemDataDTOS.size(); i++) {
// 五院二开调薪前工资+调薪后工资-调薪前工资/21.75*调薪后的应出勤天数+调薪后的法定节假日天数
SalaryArchiveItemDataDTO dataDTO = salaryArchiveItemDataDTOS.get(i);
// 获取应出勤日期+法定节假日
BigDecimal ycq = new BigDecimal("0");
BigDecimal fdjjr = new BigDecimal("0");
if (Objects.equals(i, salaryArchiveItemDataDTOS.size() - 1)) {
ycq = getKQScq(dataDTO.getEffectiveDateRange().getFromDate(), dataDTO.getEffectiveDateRange().getEndDate(), employeeId);
fdjjr = getFdjjr(SalaryDateUtil.getFormatDate(dataDTO.getEffectiveDateRange().getFromDate()), SalaryDateUtil.getFormatDate(dataDTO.getEffectiveDateRange().getEndDate()), employeeId.toString(), kqGroupService);
} else {
// 不是最后一个需要往前挪1天
Date endDate = SalaryDateUtil.localDateToDate(SalaryDateUtil.dateToLocalDate(dataDTO.getEffectiveDateRange().getEndDate()).minusDays(1));
ycq = getKQScq(dataDTO.getEffectiveDateRange().getFromDate(), endDate, employeeId);
fdjjr = getFdjjr(SalaryDateUtil.getFormatDate(dataDTO.getEffectiveDateRange().getFromDate()), SalaryDateUtil.getFormatDate(endDate), employeeId.toString(), kqGroupService);
}
baseBean.writeLog("wy-ycq" +ycq);
BigDecimal days = ycq.add(fdjjr);
if (days.compareTo(baseValue) > 0) {
days = baseValue;
}
needAddValue = needAddValue.add(SalaryEntityUtil.empty2Zero(dataDTO.getValue()).subtract(firstValue).divide(baseValue, 15, RoundingMode.HALF_UP).multiply(days));
}
baseBean.writeLog("wy-ycq" +needAddValue);
return needAddValue;
}
/**
* 获取应出勤时数
* @param fromDate
* @param endDate
* @param userId
*/
private BigDecimal getKQScq(Date fromDate, Date endDate, Long userId) {
double scq = 0;
BaseBean baseBean = new BaseBean();
try {;
scq = 0.00;
String sql = "SELECT sum(attendancedays) as a FROM kq_format_total WHERE workdays is not null and resourceid = "+userId+" and kqdate >= '" +SalaryDateUtil.getFormatDate(fromDate)+"' and kqdate <= '"+ SalaryDateUtil.getFormatDate(endDate)+"'";
baseBean.writeLog("wy-1" + sql);
List<Map> list = getSQLMapper().runSQL(sql);
baseBean.writeLog("wy-list" +list);
if (CollectionUtils.isNotEmpty(list) && list.get(0) != null) {
Object value = list.get(0).get("a");
if (value != null) {
baseBean.writeLog("wy-value" +value);
scq = NumberUtils.isCreatable(value.toString()) ? Double.valueOf(value.toString()) : Double.valueOf("0");
}
}
return new BigDecimal(String.valueOf(scq));
} catch (Exception e) {
baseBean.writeLog("获取实出勤出错" + e);
return new BigDecimal("0");
}
}
/**
* 获取法定节假日天数
*/
public BigDecimal getFdjjr(String fromDate, String toDate, String userId, KQGroupService kqGroupService) {
BaseBean baseBean = new BaseBean();
try {
if (StringUtils.isEmpty(userId) || StringUtils.isEmpty(fromDate) || StringUtils.isEmpty(toDate)) {
baseBean.writeLog("userId or fromDate or toDate is null!" + fromDate + toDate + userId);
return new BigDecimal("0");
}
Map<String, Object> params = new HashMap<>();
params.put("viewScope", 3);
params.put("resourceId", userId);
params.put("groupType", 0);
params.put("pageSize", 10);
params.put("pageIndex", 1);
User tmpUser = new User();
tmpUser.setUid(1);
tmpUser.setLoginid("sysadmin");
//获取当前人员的生效考勤组
String activeGroupId = null;
List<Map<String, Object>> dataSource = null;
Map<String, Object> groupInfo = kqGroupService.getGroupMemberList(params, tmpUser);
if (groupInfo != null && groupInfo.size() > 0) {
if (groupInfo.get("dataSource") != null) {
dataSource = (List<Map<String, Object>>) groupInfo.get("dataSource");
if (dataSource != null && dataSource.size() > 0) {
Map<String, Object> dataMap = dataSource.get(0);
activeGroupId = dataMap.get("activeGroupId") + "";
}
}
}
if (activeGroupId == null && activeGroupId.length() > 0) {
baseBean.writeLog("activeGroupId is null:" + params + dataSource);
return new BigDecimal("0");
}
// 计算公共假期
RecordSet rs = new RecordSet();
String sql ="select count(1) from kq_HolidaySet where changeType =1 and holidayDate>= '"+ fromDate + "' and holidayDate<= '"+toDate+"' and groupId = "+ activeGroupId;
rs.execute(sql);
int jq =0;
if(rs.next()){
jq = rs.getInt(1);
}
if(jq == -1) {
jq = 0;
}
return new BigDecimal(String.valueOf(jq));
} catch (Exception e) {
baseBean.writeLog("获取法定节假日出错" + e);
return new BigDecimal("0");
}
}
/**
* 根据调薪计薪规则计算调薪后的值
*

View File

@ -123,6 +123,8 @@ public class SalaryAcctCalculateBO {
*/
private List<VariableItemPO> variableItems;
private SalarySobCycleDTO lastMonthSalarySobCycleDTO;
@Data
@AllArgsConstructor
public static class Result {

View File

@ -116,6 +116,8 @@ public interface SalaryAcctRecordService {
*/
SalarySobCycleDTO getSalarySobCycleById(Long id);
SalarySobCycleDTO getLastMonthSalarySobCycleById(Long id);
/**
* 保存
*

View File

@ -4,6 +4,8 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.kq.service.KQGroupService;
import com.engine.kq.service.impl.KQGroupServiceImpl;
import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.push.dto.PushRecordDTO;
@ -299,8 +301,12 @@ public class PushServiceImpl extends Service implements PushService {
List<Long> salaryAcctEmployeeIds = SalaryEntityUtil.properties(salaryAcctCalculateBO.getSalaryAcctEmployeePOS(), SalaryAcctEmployeePO::getId, Collectors.toList());
List<SalaryAcctResultPO> salaryAcctResultPOS = getSalaryAcctResultService(user).listBySalaryAcctEmployeeIds(salaryAcctEmployeeIds);
CalculateFormulaVarBO calculateFormulaVarBO = new CalculateFormulaVarBO(simpleEmployees, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), salaryAcctResultPOS, new ArrayList<>(), new ArrayList<>());
Map<String, List<CalculateFormulaVarBO.FormulaVarValue>> formulaVarMap = calculateFormulaVarBO.convert2FormulaVar(salaryAcctCalculateBO);
CalculateFormulaVarBO calculateFormulaVarBO = new CalculateFormulaVarBO(simpleEmployees, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), salaryAcctResultPOS, new ArrayList<>(), new ArrayList<>(), new ArrayList<>());
User tempUser = new User();
tempUser.setUid(1);
tempUser.setLoginid("sysadmin");
KQGroupService kqGroupService = ServiceUtil.getService(KQGroupServiceImpl.class, tempUser);
Map<String, List<CalculateFormulaVarBO.FormulaVarValue>> formulaVarMap = calculateFormulaVarBO.convert2FormulaVar(salaryAcctCalculateBO, kqGroupService);
//推送记录id
List<Long> recordIds = new ArrayList<>();

View File

@ -3,6 +3,8 @@ package com.engine.salary.service.impl;
import cn.hutool.core.util.StrUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.kq.service.KQGroupService;
import com.engine.kq.service.impl.KQGroupServiceImpl;
import com.engine.salary.cache.SalaryCacheKey;
import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.salary.constant.SalaryFormulaFieldConstant;
@ -131,6 +133,8 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc
// 2查询薪资档案的数据
sw.start("查询薪资档案的数据");
List<SalaryArchiveDataDTO> salaryArchiveData = getSalaryArchiveService(user).getSalaryArchiveData(salarySobCycleDTO.getSalaryCycle(), employeeIds, taxAgentIds);
// 获取上月的薪资档案值
List<SalaryArchiveDataDTO> lastMonthSalaryArchiveData = getSalaryArchiveService(user).getSalaryArchiveData(salaryAcctCalculateBO.getLastMonthSalarySobCycleDTO().getSalaryCycle(), employeeIds, taxAgentIds);
sw.stop();
// 3查询往期累计情况(查询的是上个税款所属期的的累计情况)
sw.start("查询往期累计情况");
@ -196,8 +200,12 @@ public class SalaryAcctCalculateServiceImpl extends Service implements SalaryAcc
sw.stop();
// 10转换成公式编辑器中的变量
sw.start("转换成公式编辑器中的变量");
CalculateFormulaVarBO calculateFormulaVarBO = new CalculateFormulaVarBO(simpleEmployees, salaryArchiveData, addUpSituationPOS, addUpDeductionPOS, otherDeductionPOS, welfareData, attendQuoteDataDTOS, salaryAcctResultPOS, variableArchiveList,lastMonthResultPOS);
Map<String, List<CalculateFormulaVarBO.FormulaVarValue>> formulaVarMap = calculateFormulaVarBO.convert2FormulaVar(salaryAcctCalculateBO);
CalculateFormulaVarBO calculateFormulaVarBO = new CalculateFormulaVarBO(simpleEmployees, salaryArchiveData, addUpSituationPOS, addUpDeductionPOS, otherDeductionPOS, welfareData, attendQuoteDataDTOS, salaryAcctResultPOS, variableArchiveList,lastMonthResultPOS, lastMonthSalaryArchiveData);
User tempUser = new User();
tempUser.setUid(1);
tempUser.setLoginid("sysadmin");
KQGroupService kqGroupService = ServiceUtil.getService(KQGroupServiceImpl.class, tempUser);
Map<String, List<CalculateFormulaVarBO.FormulaVarValue>> formulaVarMap = calculateFormulaVarBO.convert2FormulaVar(salaryAcctCalculateBO, kqGroupService);
sw.stop();
sw.start("数据结构准备");
// 本次薪资核算所用的薪资账套下的薪资项目

View File

@ -279,6 +279,17 @@ public class SalaryAcctRecordServiceImpl extends Service implements SalaryAcctRe
}
@Override
public SalarySobCycleDTO getLastMonthSalarySobCycleById(Long id) {
// 查询薪资核算
SalaryAcctRecordPO salaryAcctRecordPO = getById(id);
if (Objects.isNull(salaryAcctRecordPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除"));
}
// 查询薪资核算所用薪资账套的薪资周期考勤周期
return getSalarySobService(user).getSalarySobCycle(salaryAcctRecordPO.getSalarySobId(), SalaryDateUtil.localDate2YearMonth(salaryAcctRecordPO.getSalaryMonth()).minusMonths(1));
}
@Override
public Long save(SalaryAcctRecordSaveParam saveParam) {
ValidUtil.doValidator(saveParam);

View File

@ -899,6 +899,7 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
}
// 2查询薪资核算记录的薪资周期考勤周期等
SalarySobCycleDTO salarySobCycleDTO = getSalaryAcctRecordService(user).getSalarySobCycleById(calculateParam.getSalaryAcctRecordId());
SalarySobCycleDTO lastMonthSalarySobCycleDTO = getSalaryAcctRecordService(user).getLastMonthSalarySobCycleById(calculateParam.getSalaryAcctRecordId());
// 3查询薪资核算记录所用薪资账套的薪资项目副本
List<SalarySobItemPO> salarySobItemPOS = salaryAcctSobConfig.getSalarySobItems();
if (CollectionUtils.isEmpty(salarySobItemPOS)) {
@ -983,7 +984,8 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
.setResults(calculateResults)
.setCalculateKey(calculateKey)
.setVariableItems(variableItemPOS)
.setTaxDeclarationFunction(taxDeclarationFunction);
.setTaxDeclarationFunction(taxDeclarationFunction)
.setLastMonthSalarySobCycleDTO(lastMonthSalarySobCycleDTO);
List<SalarySobBackItemPO> finalSalarySobBackItems = salarySobBackItems;
if (isSync) {
getSalaryAcctCalculateService(user).calculate(salaryAcctCalculateBO, simpleEmployee, finalSalarySobBackItems);

View File

@ -497,6 +497,11 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
if (salarySendInfo == null) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100511, "工资单信息不存在"));
}
if (!Objects.equals(salarySendInfo.getSendStatus(), 1)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(100511, "工资单信息不存在"));
}
Long employeeId = salarySendInfo.getEmployeeId();
if (currentEmployeeId.compareTo(employeeId) != 0) {
@ -1386,7 +1391,6 @@ public class SalarySendServiceImpl extends Service implements SalarySendService
}
@Override
public Map<String, Object> withdraw(SalarySendWithdrawParam param) {
if (param.getSalarySendId() == null) {

View File

@ -687,29 +687,15 @@ public class TaxAgentServiceImpl extends Service implements TaxAgentService {
return taxAgentManageRangeEmployeeList;
}
List<Long> taxAgentIds = allTaxAgents.stream().map(TaxAgentPO::getId).collect(Collectors.toList());
if (employeeStatus != null) {
List<String> personnelStatusList;
// 查询人员状态
// if (employeeStatus.equals(SalaryEmployeeStatusEnum.NORMAL)) {
// allEmployees = allEmployees.stream().filter(f -> UserStatusEnum.getNormalStatus().contains(f.getStatus())).collect(Collectors.toList());
// } else if (employeeStatus.equals(SalaryEmployeeStatusEnum.UNAVAILABLE)) {
// allEmployees = allEmployees.stream().filter(f -> UserStatusEnum.getUnavailableStatus().contains(f.getStatus())).collect(Collectors.toList());
// }
}
TaxAgentQueryParam param = TaxAgentQueryParam.builder().build();
param.setFilterType(AuthFilterTypeEnum.QUERY_DATA);
List<TaxAgentPO> taxAgentList = listAuth(param);
List<Long> taxAgentIds = SalaryEntityUtil.properties(taxAgentList, TaxAgentPO::getId, Collectors.toList());
// 是否开启分权
if (!isOpenDevolution() || isChief(employeeId)) {
return getTaxAgentEmp(allTaxAgents, taxAgentIds);
}
// 1.判断自己是否是管理员 如果是管理员就是能够操作所属个税扣缴义务人下的所有人的数据
List<TaxAgentAdminPO> taxAgentAdminList = getTaxAgentAdminService(user).listByTaxAgentIdsAndEmployeeId(taxAgentIds, (long) user.getUID());
// 是管理员的列表
List<Long> adminTaxAgentIds = taxAgentAdminList.stream().map(TaxAgentAdminPO::getTaxAgentId).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(adminTaxAgentIds)) {
taxAgentManageRangeEmployeeList.addAll(getTaxAgentEmp(allTaxAgents, adminTaxAgentIds));
if (CollectionUtils.isNotEmpty(taxAgentIds)) {
List<TaxAgentManageRangeEmployeeDTO> taxAgentEmp = getTaxAgentEmp(allTaxAgents, taxAgentIds);
taxAgentManageRangeEmployeeList.addAll(taxAgentEmp);
}
return taxAgentManageRangeEmployeeList;

View File

@ -6,6 +6,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.*;
import weaver.wechat.util.Utils;
import java.awt.Color;
import java.math.BigDecimal;
@ -131,10 +132,10 @@ public class ExcelUtilPlus {
for (int i = 0; i < header.size(); i++) {
WeaTableColumnGroup columnGroupItem = (WeaTableColumnGroup) header.get(i);
XSSFCell rowZeroCell = row0.createCell(i, CellType.STRING);
rowZeroCell.setCellValue(columnGroupItem.getText().toString());
rowZeroCell.setCellValue(columnGroupItem.getText());
rowZeroCell.setCellStyle(titleCellStyle);
//设置列宽
sheet.setColumnWidth(i, Math.min(255, Math.max(12, columnGroupItem.getText().length() * 4)) * 256);
sheet.setColumnWidth(i, Math.min(255, Math.max(12, Utils.null2String(columnGroupItem.getText()).length() * 4)) * 256);
patternList.add(columnGroupItem.getPattern());
}

View File

@ -250,7 +250,9 @@ public class ValidUtil {
.replace("", "between")
.replace("", "BETWEEN")
.replace("", "union")
.replace("", "UNION");
.replace("", "UNION")
.replace("", "substr")
.replace("", "SUBSTR");
}
setValue(t, field.getName(), result);
} else if (valueTypeEnum == ValueTypeEnum.OBJECT) {

View File

@ -97,7 +97,10 @@ public class SalarySobRangeWrapper extends Service {
.replace("", "between")
.replace("", "BETWEEN")
.replace("", "union")
.replace("", "UNION"));
.replace("", "UNION")
.replace("", "substr")
.replace("", "SUBSTR")
);
}
});
@ -127,7 +130,10 @@ public class SalarySobRangeWrapper extends Service {
.replace("", "between")
.replace("", "BETWEEN")
.replace("", "union")
.replace("", "UNION"));
.replace("", "UNION")
.replace("", "substr")
.replace("", "SUBSTR")
);
}
});

View File

@ -352,7 +352,10 @@ public class TaxAgentWrapper extends Service {
.replace("", "between")
.replace("", "BETWEEN")
.replace("", "union")
.replace("", "UNION"));
.replace("", "UNION")
.replace("", "substr")
.replace("", "SUBSTR")
);
}
});
@ -386,7 +389,10 @@ public class TaxAgentWrapper extends Service {
.replace("", "between")
.replace("", "BETWEEN")
.replace("", "union")
.replace("", "UNION"));
.replace("", "UNION")
.replace("", "substr")
.replace("", "SUBSTR")
);
}
});