万德隆工资核算数据月度统计

This commit is contained in:
Harryxzy 2025-06-11 17:25:38 +08:00
parent 3d0539a8b9
commit 3b524dc87b
15 changed files with 635 additions and 3 deletions

View File

@ -38,6 +38,17 @@ public class SalaryArchiveItemBiz {
}
}
public List<SalaryArchiveItemPO> getCurrentEffectiveItemList4Wdl(SalaryArchiveItemQueryParam build) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {
SalaryArchiveItemMapper mapper = sqlSession.getMapper(SalaryArchiveItemMapper.class);
List<SalaryArchiveItemPO> salaryArchiveItemPOS = mapper.listByParam4Wdl(build);
return encryptUtil.decryptList(salaryArchiveItemPOS, SalaryArchiveItemPO.class);
} finally {
sqlSession.close();
}
}
public List<SalaryArchiveItemPO> listByParam(SalaryArchiveItemQueryParam build) {
SqlSession sqlSession = MyBatisFactory.sqlSessionFactory.openSession();
try {

View File

@ -0,0 +1,56 @@
package com.engine.salary.entity.salaryarchive.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
import java.util.Map;
/**
* @author Harryxzy
* @ClassName WdlGzhssjtj
* @date 2025/06/10 15:15
* @description 万德隆 工资核算数据统计
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class WdlGzhssjtj {
private Long mainId;
private Long id;
// 姓名
private Long xm;
// 变化日期
private Date bhrq;
// 变化日期止
private Date bhrqz;
// 计薪天数
private String jxts;
// 漏打卡
private Integer ldk;
// 迟到次数
private Integer cdcs;
// 严重迟到次数
private Integer yzcdcs;
// 早退次数
private Integer ztcs;
// 旷工次数
private Integer kgcs;
// 薪资档案需要赋值到流程的
Map<String, String> archiveItemValueMap;
}

View File

@ -0,0 +1,27 @@
package com.engine.salary.entity.salaryarchive.param;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* @ClassName WdlGzsqydtjParam
* @author Harryxzy
* @date 2025/6/11 14:56
* @description 万德隆 工资核算数据月度统计
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class WdlGzsqydtjParam {
// 薪资所属月
private Date salaryMonth;
// 主表id
private Long mainId;
}

View File

@ -84,6 +84,7 @@ public interface SalaryArchiveItemMapper {
List<SalaryArchiveItemPO> listByParam(@Param("param")SalaryArchiveItemQueryParam build);
List<SalaryArchiveItemPO> listByParam4Wdl(@Param("param")SalaryArchiveItemQueryParam build);
List<SalaryArchiveItemPO> getIneffectiveSalaryItems(@Param("param") SalaryArchiveItemQueryParam build);

View File

@ -974,6 +974,36 @@
ORDER BY t.effective_time DESC
</select>
<select id="listByParam4Wdl" resultMap="BaseResultMap"
parameterType="com.engine.salary.entity.salaryarchive.po.SalaryArchiveItemPO">
SELECT
<include refid="baseColumns"/>
FROM hrsa_salary_archive_item t
WHERE delete_type = 0
<if test="param.effectiveTime != null">
AND t.effective_time &lt; #{param.effectiveTime}
</if>
<if test="param.salaryItemIds != null and param.salaryItemIds.size()>0">
AND t.salary_item_id IN
<foreach collection="param.salaryItemIds" open="(" item="salaryItemId" separator="," close=")">
#{salaryItemId}
</foreach>
</if>
<if test="param.salaryArchivesIds != null and param.salaryArchivesIds.size()>0">
AND t.salary_archive_id IN
<foreach collection="param.salaryArchivesIds" open="(" item="salaryArchiveId" separator="," close=")">
#{salaryArchiveId}
</foreach>
</if>
<if test="param.employeeIds != null and param.employeeIds.size()>0">
AND t.employee_id IN
<foreach collection="param.employeeIds" open="(" item="employeeId" separator="," close=")">
#{employeeId}
</foreach>
</if>
ORDER BY t.effective_time DESC
</select>
<select id="getIneffectiveSalaryItems" resultMap="BaseResultMap"
parameterType="com.engine.salary.entity.salaryarchive.po.SalaryArchiveItemPO">
SELECT

View File

@ -18,7 +18,7 @@ public interface RemoteAttend4SalaryService {
* @param attend4Salary
* @return
*/
List<Map<String,String>> getDatas(Attend4Salary attend4Salary);
List<Map<String,String>> getDatas(Attend4Salary attend4Salary, boolean onlyKqData);
/**
* 获取假期余额列

View File

@ -147,7 +147,7 @@ public class RemoteAttend4SalaryServiceImpl extends Service implements RemoteAtt
}
@Override
public List<Map<String, String>> getDatas(Attend4Salary attend4Salary) {
public List<Map<String, String>> getDatas(Attend4Salary attend4Salary, boolean onlyKqData) {
List<Map<String, String>> list = new ArrayList<>();
try {
@ -178,6 +178,9 @@ public class RemoteAttend4SalaryServiceImpl extends Service implements RemoteAtt
log.error("salaryAttend获取考勤数据失败", e);
}
if (onlyKqData) {
return list;
}
try {
//假期余额信息
List<Map<String, String>> balanceOfLeaveDatas = getBalanceOfLeaveDatas(attend4Salary);

View File

@ -15,6 +15,7 @@ import com.engine.salary.util.page.PageInfo;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -69,6 +70,11 @@ public interface SalaryArchiveService {
*/
List<SalaryArchiveItemPO> getCurrentEffectiveItemList(Collection<Long> salaryArchivesIds, Collection<Long> salaryItemIds);
List<SalaryArchiveItemPO> getCurrentEffectiveItemListByTime(Collection<Long> salaryArchivesIds, Collection<Long> salaryItemIds, Date effectiveTime);
List<SalaryArchiveItemPO> getCurrentEffectiveItemListByTime4Wdl(Collection<Long> salaryArchivesIds, Collection<Long> salaryItemIds, Date effectiveTime);
/**
* 获取薪资档案对应的当前生效的个税扣缴义务人
*
@ -243,6 +249,8 @@ public interface SalaryArchiveService {
List<SalaryArchivePO> listByRunStatus(List<String> asList);
List<SalaryArchivePO> listByRunStatusAndEmployeeIds(List<String> list, List<Long> employeeIds);
/**
* 同步所有档案起始发薪日期变为入职日期
*
@ -260,4 +268,6 @@ public interface SalaryArchiveService {
SalaryArchivePO getByTaxAgentIdAndEmployeeId(Long id, Long employeeId);
String getEffectiveItemValue(SalaryArchiveQueryParam param);
void generateWdlData(WdlGzsqydtjParam param);
}

View File

@ -532,7 +532,7 @@ public class AttendQuoteDataServiceImpl extends Service implements AttendQuoteDa
.collect(Collectors.joining(","));
attend4Salary.setAttendanceSerial(attendanceSerial);
List<Map<String, String>> attendResult = getRemoteAttend4SalaryService(user).getDatas(attend4Salary);
List<Map<String, String>> attendResult = getRemoteAttend4SalaryService(user).getDatas(attend4Salary, false);
AttendQuoteDataBO.buildAttendDataFromRemote(attendResult, attendQuoteFields, attendQuoteSyncData);

View File

@ -15,6 +15,7 @@ import com.engine.salary.entity.datacollection.DataCollectionEmployee;
import com.engine.salary.entity.salaryarchive.bo.SalaryArchiveBO;
import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveDataDTO;
import com.engine.salary.entity.salaryarchive.dto.SalaryArchiveListDTO;
import com.engine.salary.entity.salaryarchive.dto.WdlGzhssjtj;
import com.engine.salary.entity.salaryarchive.param.*;
import com.engine.salary.entity.salaryarchive.po.SalaryArchiveDimissionPO;
import com.engine.salary.entity.salaryarchive.po.SalaryArchiveItemPO;
@ -35,6 +36,9 @@ import com.engine.salary.enums.taxagent.TaxAgentEmpChangeModuleEnum;
import com.engine.salary.exception.SalaryRunTimeException;
import com.engine.salary.mapper.archive.SalaryArchiveItemMapper;
import com.engine.salary.mapper.archive.SalaryArchiveMapper;
import com.engine.salary.remote.attend.entity.Attend4Salary;
import com.engine.salary.remote.attend.service.RemoteAttend4SalaryService;
import com.engine.salary.remote.attend.service.impl.RemoteAttend4SalaryServiceImpl;
import com.engine.salary.service.*;
import com.engine.salary.service.auth.AuthService;
import com.engine.salary.service.auth.AuthServiceImpl;
@ -68,12 +72,17 @@ import org.apache.poi.util.IOUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.BeanUtils;
import org.springframework.transaction.annotation.Transactional;
import weaver.conn.RecordSet;
import weaver.file.ImageFileManager;
import weaver.formmode.setup.ModeRightInfo;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.wechat.util.Utils;
import java.io.InputStream;
import java.math.BigDecimal;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Pattern;
@ -136,6 +145,10 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe
return ServiceUtil.getService(SalarySobServiceImpl.class, user);
}
private RemoteAttend4SalaryService getRemoteAttend4SalaryService(User user) {
return ServiceUtil.getService(RemoteAttend4SalaryServiceImpl.class, user);
}
public AuthService getAuthService(User user) {
return ServiceUtil.getService(AuthServiceImpl.class, user);
}
@ -409,6 +422,37 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe
return salaryArchiveItems.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getSalaryArchiveId() + "-" + f.getSalaryItemId()))), ArrayList::new));
}
/**
* 获取薪资档案对应的当前生效的薪资项目
*
* @param salaryArchivesIds
* @return
*/
@Override
public List<SalaryArchiveItemPO> getCurrentEffectiveItemListByTime(Collection<Long> salaryArchivesIds, Collection<Long> salaryItemIds, Date effectiveTime) {
if (CollectionUtils.isEmpty(salaryItemIds) || effectiveTime == null) {
return Collections.EMPTY_LIST;
}
List<SalaryArchiveItemPO> salaryArchiveItems = salaryArchiveItemMapper.getCurrentEffectiveItemList(SalaryArchiveItemQueryParam.builder().salaryArchivesIds(salaryArchivesIds).salaryItemIds(salaryItemIds).effectiveTime(effectiveTime).build());
return salaryArchiveItems.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getSalaryArchiveId() + "-" + f.getSalaryItemId()))), ArrayList::new));
}
/**
* 获取薪资档案对应的当前生效的薪资项目
*
* @param salaryArchivesIds
* @return
*/
@Override
public List<SalaryArchiveItemPO> getCurrentEffectiveItemListByTime4Wdl(Collection<Long> salaryArchivesIds, Collection<Long> salaryItemIds, Date effectiveTime) {
if (CollectionUtils.isEmpty(salaryItemIds) || effectiveTime == null) {
return Collections.EMPTY_LIST;
}
List<SalaryArchiveItemPO> salaryArchiveItems = salaryArchiveItemMapper.getCurrentEffectiveItemList4Wdl(SalaryArchiveItemQueryParam.builder().salaryArchivesIds(salaryArchivesIds).salaryItemIds(salaryItemIds).effectiveTime(effectiveTime).build());
return salaryArchiveItems.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(f -> f.getSalaryArchiveId() + "-" + f.getSalaryItemId()))), ArrayList::new));
}
/**
* 获取薪资档案对应的当前生效的个税扣缴义务人
*
@ -1370,6 +1414,19 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe
return getSalaryArchiveMapper().listSome(SalaryArchivePO.builder().runStatusList(list).build());
}
@Override
public List<SalaryArchivePO> listByRunStatusAndEmployeeIds(List<String> list, List<Long> employeeIds) {
if (CollectionUtils.isEmpty(employeeIds)) {
return Collections.emptyList();
}
List<List<Long>> partition = Lists.partition(employeeIds, 500);
List<SalaryArchivePO> resultList = new ArrayList<>();
partition.forEach(part -> {
resultList.addAll(getSalaryArchiveMapper().listSome(SalaryArchivePO.builder().runStatusList(list).employeeIds(part).build()));
});
return resultList;
}
/**
* 同步所有档案起始发薪日期变为入职日期
*
@ -1429,4 +1486,304 @@ public class SalaryArchiveServiceImpl extends Service implements SalaryArchiveSe
}
return "";
}
/**
* 生成万德隆分段扣款数据
* @param
*/
@Override
public void generateWdlData(WdlGzsqydtjParam param) {
Date date = param.getSalaryMonth();
if (date == null && param.getMainId() == null) {
return;
}
RecordSet rs = new RecordSet();
if (date == null && param.getMainId() != null) {
// 获取主表数据
String sql = "select ny from uf_gzhssjydtj where id =" + param.getMainId();
rs.execute(sql);
if (rs.next()) {
date = SalaryDateUtil.dateStrToLocalYearMonth(rs.getString("ny"));
}
}
if (date == null) {
return;
}
List<WdlGzhssjtj> wdlGzhssjtjList = listGzhssjydtjBySalaryMonth(date, param.getMainId());
// 获取当月起止日期
Date firstDay = SalaryDateUtil.getFirstDayDateOfMonthWithMinutesAndSeconds(date);
Date lastDay = SalaryDateUtil.getLastDayOfMonthWithMinutesAndSeconds(date);
// 获取所有可被引用的薪资项目
List<SalaryItemPO> salaryItems = getSalaryArchiveItemService(user).getCanAdjustSalaryItems();
List<Long> salaryItemIds = salaryItems.stream().map(SalaryItemPO::getId).collect(Collectors.toList());
// 获取薪资档案
List<String> runStatus = new ArrayList<>();
runStatus.add(SalaryArchiveStatusEnum.FIXED.getValue());
runStatus.add(SalaryArchiveStatusEnum.SUSPEND.getValue());
runStatus.add(SalaryArchiveStatusEnum.STOP_FROM_SUSPEND.getValue());
List<Long> employeeIds = wdlGzhssjtjList.stream().map(WdlGzhssjtj::getXm).filter(xm -> xm != null).collect(Collectors.toList());
List<SalaryArchivePO> salaryArchives = listByRunStatusAndEmployeeIds(runStatus, employeeIds);
Map<Long, SalaryArchivePO> salaryArchiveMap = SalaryEntityUtil.convert2Map(salaryArchives, SalaryArchivePO::getEmployeeId);
BaseBean baseBean = new BaseBean();
boolean isLog = baseBean.getPropValue("wdlSalary", "is_log").equals("true");
// 旷工天数字段
String kgtsIndex = baseBean.getPropValue("wdlSalary", "kgts_index");
// 事假天数字段
String sjtsIndex = baseBean.getPropValue("wdlSalary", "sjts_index");
// 漏打卡字段
String ldkIndex = baseBean.getPropValue("wdlSalary", "ldkcs_index");
// 迟到字段
String cdIndex = baseBean.getPropValue("wdlSalary", "cdcs_index");
// 严重迟到字段
String yzcdIndex = baseBean.getPropValue("wdlSalary", "yzcdcs_index");
// 早退字段
String ztIndex = baseBean.getPropValue("wdlSalary", "ztcs_index");
// 旷工次数字段
String kgcsIndex = baseBean.getPropValue("wdlSalary", "kgcs_index");
// 获取薪资档案赋值映射关系
List<String> salaryWorkflowField = Arrays.stream(baseBean.getPropValue("wdlSalary", "salary_workflow_field").split(",")).collect(Collectors.toList());
Map<String, List<Long>> fieldItemIdMap = new HashMap<>();
salaryWorkflowField.stream().forEach(field -> {
List<Long> itemIdList = Arrays.stream(baseBean.getPropValue("wdlSalary", field + "_item_id").split(","))
.filter(NumberUtils::isCreatable)
.map(Long::valueOf)
.collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(itemIdList)) {
fieldItemIdMap.put(field, itemIdList);
}
});
List<WdlGzhssjtj> needUpdateList = new ArrayList<>();
// 根据人员id分组获取哪些人本月有异动
if (isLog) {
baseBean.writeLog("工资核算数据月度统计开始计算"+param.getSalaryMonth()+","+param.getMainId()+","+wdlGzhssjtjList.size());
}
Map<Long, List<WdlGzhssjtj>> gzhssjtjDataGroup = SalaryEntityUtil.group2Map(wdlGzhssjtjList, WdlGzhssjtj::getXm);
for (Map.Entry<Long, List<WdlGzhssjtj>> entry : gzhssjtjDataGroup.entrySet()) {
Long employeeId = entry.getKey();
List<WdlGzhssjtj> dataList = entry.getValue();
if (CollectionUtils.isNotEmpty(dataList)) {
if (dataList.size() == 1) {
// 当月没有异动的
WdlGzhssjtj updateDTO = new WdlGzhssjtj();
WdlGzhssjtj wdlGzhssjtj = dataList.get(0);
updateDTO.setId(wdlGzhssjtj.getId());
updateDTO.setMainId(wdlGzhssjtj.getMainId());
// 当月没有发生调薪, 获取考勤数据
Attend4Salary attend4Salary = new Attend4Salary();
Date beginDate = wdlGzhssjtj.getBhrq() == null ? firstDay : wdlGzhssjtj.getBhrq();
Date endDate = wdlGzhssjtj.getBhrqz() == null ? lastDay : wdlGzhssjtj.getBhrqz();
attend4Salary.setBeginDate(beginDate);
attend4Salary.setEndDate(endDate);
attend4Salary.setOnlyEmpIds(Collections.singletonList(employeeId));
List<Map<String, String>> attendResult = getRemoteAttend4SalaryService(user).getDatas(attend4Salary, true);
if (attendResult != null && attendResult.size() > 0) {
Map<String, String> attendMap = attendResult.get(0);
BigDecimal kgts = NumberUtils.isCreatable(attendMap.get(kgtsIndex)) ? new BigDecimal(Util.null2String(attendMap.get(kgtsIndex))) : BigDecimal.ZERO;
BigDecimal sjts = NumberUtils.isCreatable(attendMap.get(sjtsIndex)) ? new BigDecimal(Util.null2String(attendMap.get(sjtsIndex))) : BigDecimal.ZERO;
// 计算计薪天数
BigDecimal dayDiff = new BigDecimal(SalaryDateUtil.dateToLocalDate(beginDate).until(SalaryDateUtil.dateToLocalDate(endDate), ChronoUnit.DAYS) + 1);
// 第一个数据 计薪天数
updateDTO.setJxts(dayDiff.subtract(kgts).subtract(sjts).toString());
// 第二个数据 漏打卡 迟到次数 严重迟到次数 早退次数 旷工次数
updateDTO.setLdk(NumberUtils.isCreatable(attendMap.get(ldkIndex)) ? Integer.valueOf(attendMap.get(ldkIndex)) : null);
updateDTO.setCdcs(NumberUtils.isCreatable(attendMap.get(cdIndex)) ? Integer.valueOf(attendMap.get(cdIndex).toString()) : null);
updateDTO.setYzcdcs(NumberUtils.isCreatable(attendMap.get(yzcdIndex)) ? Integer.valueOf(attendMap.get(yzcdIndex).toString()) : null);
updateDTO.setZtcs(NumberUtils.isCreatable(attendMap.get(ztIndex)) ? Integer.valueOf(attendMap.get(ztIndex).toString()) : null);
updateDTO.setKgcs(NumberUtils.isCreatable(attendMap.get(kgcsIndex)) ? Integer.valueOf(attendMap.get(kgcsIndex).toString()) : null);
}
// 获取薪资档案数据
SalaryArchivePO salaryArchivePO = salaryArchiveMap.get(employeeId);
if (salaryArchivePO != null) {
List<SalaryArchiveItemPO> salaryArchiveItemList = getCurrentEffectiveItemListByTime4Wdl(Collections.singletonList(salaryArchivePO.getId()), salaryItemIds, endDate);
Map<String, String> archiveItemValueMap = calcArchiveItemValue(salaryArchiveItemList, salaryWorkflowField, fieldItemIdMap);
// 第三个数据 薪资档案值
updateDTO.setArchiveItemValueMap(archiveItemValueMap);
}
needUpdateList.add(updateDTO);
} else {
// 当月有异动的,先根据变化日期排序如果第一个变化日期为空或最后一个变化日期止为空则赋默认值
dataList.stream().forEach(data -> {
if (data.getBhrq() == null) {
data.setBhrq(firstDay);
}
});
// 根据变化日期排序
dataList.sort(Comparator.comparing(WdlGzhssjtj::getBhrq));
for (int i = 0; i < dataList.size(); i++) {
WdlGzhssjtj wdlGzhssjtj = dataList.get(i);
WdlGzhssjtj updateDTO = new WdlGzhssjtj();
updateDTO.setId(wdlGzhssjtj.getId());
updateDTO.setMainId(wdlGzhssjtj.getMainId());
// 当月没有发生调薪, 获取考勤数据
Attend4Salary attend4Salary = new Attend4Salary();
Date beginDate = wdlGzhssjtj.getBhrq();
Date endDate = wdlGzhssjtj.getBhrqz() == null ? lastDay : wdlGzhssjtj.getBhrqz();
attend4Salary.setBeginDate(beginDate);
attend4Salary.setEndDate(endDate);
attend4Salary.setOnlyEmpIds(Collections.singletonList(employeeId));
List<Map<String, String>> attendResult = getRemoteAttend4SalaryService(user).getDatas(attend4Salary, true);
if (attendResult != null && attendResult.size() > 0) {
Map<String, String> attendMap = attendResult.get(0);
BigDecimal kgts = NumberUtils.isCreatable(attendMap.get(kgtsIndex)) ? new BigDecimal(Util.null2String(attendMap.get(kgtsIndex))) : BigDecimal.ZERO;
BigDecimal sjts = NumberUtils.isCreatable(attendMap.get(sjtsIndex)) ? new BigDecimal(Util.null2String(attendMap.get(sjtsIndex))) : BigDecimal.ZERO;
// 计算计薪天数
BigDecimal dayDiff = new BigDecimal(SalaryDateUtil.dateToLocalDate(beginDate).until(SalaryDateUtil.dateToLocalDate(endDate), ChronoUnit.DAYS));
// 最后一条加一条
if (i == dataList.size() - 1) {
dayDiff = dayDiff.add(BigDecimal.ONE);
}
// 第一个数据 计薪天数
updateDTO.setJxts(dayDiff.subtract(kgts).subtract(sjts).toString());
// 第二个数据 漏打卡 迟到次数 严重迟到次数 早退次数 旷工次数
updateDTO.setLdk(NumberUtils.isCreatable(attendMap.get(ldkIndex)) ? Integer.valueOf(attendMap.get(ldkIndex)) : null);
updateDTO.setCdcs(NumberUtils.isCreatable(attendMap.get(cdIndex)) ? Integer.valueOf(attendMap.get(cdIndex).toString()) : null);
updateDTO.setYzcdcs(NumberUtils.isCreatable(attendMap.get(yzcdIndex)) ? Integer.valueOf(attendMap.get(yzcdIndex).toString()) : null);
updateDTO.setZtcs(NumberUtils.isCreatable(attendMap.get(ztIndex)) ? Integer.valueOf(attendMap.get(ztIndex).toString()) : null);
updateDTO.setKgcs(NumberUtils.isCreatable(attendMap.get(kgcsIndex)) ? Integer.valueOf(attendMap.get(kgcsIndex).toString()) : null);
}
// 获取薪资档案数据
SalaryArchivePO salaryArchivePO = salaryArchiveMap.get(employeeId);
if (salaryArchivePO != null) {
List<SalaryArchiveItemPO> salaryArchiveItemList = getCurrentEffectiveItemListByTime4Wdl(Collections.singletonList(salaryArchivePO.getId()), salaryItemIds, endDate);
Map<String, String> archiveItemValueMap = calcArchiveItemValue(salaryArchiveItemList, salaryWorkflowField, fieldItemIdMap);
// 第三个数据 薪资档案值
updateDTO.setArchiveItemValueMap(archiveItemValueMap);
}
needUpdateList.add(updateDTO);
}
}
}
}
// 入库
if (CollectionUtils.isNotEmpty(needUpdateList)) {
if (isLog) {
baseBean.writeLog("工资核算数据月度统计开始入库"+param.getSalaryMonth()+","+param.getMainId()+","+needUpdateList.size());
}
for (WdlGzhssjtj updateDTO: needUpdateList) {
StringBuilder sqlSB = new StringBuilder("update uf_gzhssjydtj_dt1 set ");
if (updateDTO.getJxts() != null && StringUtils.isNotBlank(updateDTO.getJxts())) {
// 漏打卡
sqlSB.append("jxts=" + updateDTO.getJxts() + ",");
}
if (updateDTO.getLdk() != null) {
// 漏打卡
sqlSB.append("ldk=" + updateDTO.getLdk() + ",");
}
if (updateDTO.getCdcs() != null) {
// 迟到次数
sqlSB.append("cdcs=" + updateDTO.getCdcs() + ",");
}
if (updateDTO.getYzcdcs() != null) {
// 严重迟到次数
sqlSB.append("yzcdcs=" + updateDTO.getYzcdcs() + ",");
}
if (updateDTO.getZtcs() != null) {
// 早退次数
sqlSB.append("ztcs=" + updateDTO.getZtcs() + ",");
}
if (updateDTO.getKgcs() != null) {
// 旷工次数
sqlSB.append("kgcs=" + updateDTO.getKgcs() + ",");
}
Map<String, String> archiveItemValueMap = updateDTO.getArchiveItemValueMap();
if (archiveItemValueMap != null && !archiveItemValueMap.isEmpty()) {
for (String field : salaryWorkflowField) {
String value = archiveItemValueMap.get(field);
if (NumberUtils.isCreatable(value)) {
sqlSB.append(field+"=" + value + ",");
}
}
}
if (sqlSB.toString().contains("=")) {
// 去除sqlsb中最后一个逗号
sqlSB.deleteCharAt(sqlSB.length() - 1);
sqlSB.append(" where id=" + updateDTO.getId());
if (isLog) {
baseBean.writeLog("工资核算数据sql:" + sqlSB.toString());
}
rs.execute(sqlSB.toString());
}
}
// 权限重构
Integer modeId = SalaryEntityUtil.string2Integer(baseBean.getPropValue("wdlSalary", "gzhssjydtj_mode_id"));
if (modeId != null ) {
needUpdateList.stream()
.map(WdlGzhssjtj::getMainId)
.filter(id -> id != null)
.distinct()
.forEach(id -> {
ModeRightInfo ModeRightInfo = new ModeRightInfo();
ModeRightInfo.setNewRight(true);
ModeRightInfo.editModeDataShare(1, modeId, id.intValue());
});
}
}
}
/**
* 计算薪资档案需要赋值到流程中的值
* @param salaryArchiveItemList
* @param salaryWorkflowField
* @param fieldItemIdMap
* @return
*/
private Map<String, String> calcArchiveItemValue(List<SalaryArchiveItemPO> salaryArchiveItemList, List<String> salaryWorkflowField, Map<String, List<Long>> fieldItemIdMap) {
Map<String, String> resultMap = new HashMap<>();
if (CollectionUtils.isEmpty(salaryArchiveItemList) || CollectionUtils.isEmpty(salaryWorkflowField) || fieldItemIdMap.isEmpty()) {
return resultMap;
}
Map<Long, String> itemValueMap = SalaryEntityUtil.convert2Map(salaryArchiveItemList, SalaryArchiveItemPO::getSalaryItemId, archiveItem -> Utils.null2String(archiveItem.getItemValue()));
for (String fieldId : salaryWorkflowField) {
List<Long> itemIdList = fieldItemIdMap.get(fieldId);
if (CollectionUtils.isNotEmpty(itemIdList)) {
String sumValue = itemIdList.stream().map(itemId -> Utils.null2String(itemValueMap.get(itemId)))
.filter(NumberUtils::isCreatable)
.map(BigDecimal::new)
.reduce(new BigDecimal("0"), BigDecimal::add)
.setScale(0, BigDecimal.ROUND_HALF_UP)
.toString();
resultMap.put(fieldId, sumValue);
}
}
return resultMap;
}
/**
* 获取工资核算数据月度统计数据
* @param date
* @return
*/
List<WdlGzhssjtj> listGzhssjydtjBySalaryMonth(Date date, Long mainId) {
if (date == null) {
return Collections.emptyList();
}
// 根据薪资所属月获取需要同步的数据
RecordSet rs = new RecordSet();
String ny = SalaryDateUtil.getFormatYearMonth(date);
String sql ="SELECT t.id as tid,d.id as did,xm,bhrq,bhrqz FROM uf_gzhssjydtj t left join uf_gzhssjydtj_dt1 d on t.id = d.mainid where t.ny = '" +ny+"'";
if (mainId != null) {
sql = sql + " and t.id = " + mainId;
}
rs.execute(sql);
List<WdlGzhssjtj> dataList = new ArrayList<>();
while (rs.next()) {
WdlGzhssjtj po = new WdlGzhssjtj();
po.setMainId(SalaryEntityUtil.string2Long(rs.getString("tid")));
po.setId(SalaryEntityUtil.string2Long(rs.getString("did")));
po.setXm(SalaryEntityUtil.string2Long(rs.getString("xm")));
po.setBhrq(SalaryDateUtil.stringToDate(rs.getString("bhrq")));
po.setBhrqz(SalaryDateUtil.stringToDate(rs.getString("bhrqz")));
if (po.getId() != null) {
dataList.add(po);
}
}
return dataList;
}
}

View File

@ -0,0 +1,47 @@
package com.engine.salary.timer;
import com.engine.common.util.ServiceUtil;
import com.engine.salary.entity.salaryarchive.param.WdlGzsqydtjParam;
import com.engine.salary.service.SalaryArchiveService;
import com.engine.salary.service.impl.SalaryArchiveServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.math.NumberUtils;
import weaver.hrm.User;
import weaver.interfaces.schedule.BaseCronJob;
import java.util.Calendar;
import java.util.Date;
/**
* @ClassName SyncWdlGzhssjydtjJob
* @author Harryxzy
* @date 2025/6/10 15:02
* @description 同步万德隆工资核算数据月度统计
*/
@Slf4j
public class SyncWdlGzhssjydtjJob extends BaseCronJob {
private String preMonth;
private SalaryArchiveService getSalaryArchiveService(User user) {
return ServiceUtil.getService(SalaryArchiveServiceImpl.class, user);
}
@Override
public void execute() {
User user = new User();
user.setUid(1);
user.setLoginid("sysadmin");
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
int preMonthValue = -1;
if (preMonth != null && NumberUtils.isCreatable(preMonth)) {
preMonthValue = -1 * Integer.valueOf(preMonth);
}
cal.add(Calendar.MONTH, preMonthValue);
getSalaryArchiveService(user).generateWdlData(WdlGzsqydtjParam.builder().salaryMonth(cal.getTime()).build());
}
}

View File

@ -0,0 +1,59 @@
package com.engine.salary.timer;
import com.engine.common.util.ServiceUtil;
import com.engine.salary.entity.salaryarchive.param.WdlGzsqydtjParam;
import com.engine.salary.service.SalaryArchiveService;
import com.engine.salary.service.impl.SalaryArchiveServiceImpl;
import weaver.formmode.customjavacode.AbstractModeExpandJavaCodeNew;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.soa.workflow.request.RequestInfo;
import java.util.HashMap;
import java.util.Map;
/**
* @author Harryxzy
* @ClassName WdlGzhssjydtjModeExpand
* @date 2025/06/11 15:12
* @description
*/
public class WdlGzhssjydtjModeExpand extends AbstractModeExpandJavaCodeNew {
private SalaryArchiveService getSalaryArchiveService(User user) {
return ServiceUtil.getService(SalaryArchiveServiceImpl.class,user);
}
/**
* 执行模块扩展动作
* @param param
* param包含(但不限于)以下数据
* user 当前用户
* importtype 导入方式(仅在批量导入的接口动作会传输) 1 追加2覆盖,3更新获取方式(int)param.get("importtype")
* 导入链接中拼接的特殊参数(仅在批量导入的接口动作会传输)比如a=1可通过param.get("a")获取参数值
* 页面链接拼接的参数比如b=2,可以通过param.get("b")来获取参数
* @return
*/
public Map<String, String> doModeExpand(Map<String, Object> param) {
Map<String, String> result = new HashMap<String, String>();
try {
User user = (User)param.get("user");
int billid = -1;//数据id
int modeid = -1;//模块id
RequestInfo requestInfo = (RequestInfo)param.get("RequestInfo");
if(requestInfo!=null){
billid = Util.getIntValue(requestInfo.getRequestid());
modeid = Util.getIntValue(requestInfo.getWorkflowid());
if(billid>0&&modeid>0){
//------请在下面编写业务逻辑代码------
}
}
getSalaryArchiveService(user).generateWdlData(WdlGzsqydtjParam.builder().mainId(Long.valueOf(billid)).build());
} catch (Exception e) {
result.put("errmsg","自定义出错信息");
result.put("flag", "false");
}
return result;
}
}

View File

@ -284,6 +284,18 @@ public class SalaryDateUtil {
return cal.getTime();
}
public static Date getLastDayOfMonthWithMinutesAndSeconds(final Date date) {
final Calendar cal = Calendar.getInstance();
cal.setTime(date);
final int last = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
cal.set(Calendar.DAY_OF_MONTH, last);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal.getTime();
}
public static Date getFirstDayDateOfYear(final Date date) {
final Calendar cal = Calendar.getInstance();
cal.setTime(date);

View File

@ -1086,4 +1086,19 @@ public class SalaryArchiveController {
return new ResponseResult<String, Map<String, Object>>(user).run(getSalaryArchiveWrapper(user)::handleRepeatData);
}
/**
* 万德隆薪资数据同步
*
* @param saveParam
* @return
*/
@POST
@Path("/generateWdlData")
@Produces(MediaType.APPLICATION_JSON)
public String generateWdlData(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody WdlGzsqydtjParam saveParam) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<WdlGzsqydtjParam, String>(user).run(getSalaryArchiveWrapper(user)::generateWdlData, saveParam);
}
}

View File

@ -643,4 +643,8 @@ public class SalaryArchiveWrapper extends Service {
public String syncPayStartDate() {
return getSalaryArchiveService(user).syncPayStartDate();
}
public void generateWdlData(WdlGzsqydtjParam param) {
getSalaryArchiveService(user).generateWdlData(param);
}
}