万君薪酬二开:1、考勤引用编辑

This commit is contained in:
Harryxzy 2025-04-25 13:54:41 +08:00
parent 6e6606f3ac
commit b0f87764ae
9 changed files with 256 additions and 28 deletions

View File

@ -32,4 +32,7 @@ public class DeptInfo {
* 所属分部id
*/
private Long subcompanyid1;
private Double showorder;
}

View File

@ -901,4 +901,65 @@ public class SalaryAcctResultBO {
}
public static List<Map<String, Object>> buildData4Report(List<SalaryItemPO> salaryItems,
List<SalarySobEmpFieldPO> salarySobEmpFields,
List<DataCollectionEmployee> simpleEmployees,
List<SalaryAcctEmployeePO> salaryAcctEmployees,
List<SalaryAcctResultPO> salaryAccountingResults,
boolean dynamicEmpInfo) {
if (CollectionUtils.isEmpty(salaryAcctEmployees)) {
return Collections.emptyList();
}
SalaryI18nUtil.i18nList(salaryAcctEmployees);
Map<Long, DataCollectionEmployee> employeeMap = SalaryEntityUtil.convert2Map(simpleEmployees, DataCollectionEmployee::getEmployeeId);
Map<Long, List<SalaryAcctResultPO>> acctResultMap = SalaryEntityUtil.group2Map(salaryAccountingResults, SalaryAcctResultPO::getSalaryAcctEmpId);
return salaryAcctEmployees.stream().map(e -> {
Map<Long, Object> resultValueMap = SalaryEntityUtil.convert2Map(acctResultMap.getOrDefault(e.getId(), Collections.emptyList()),
SalaryAcctResultPO::getSalaryItemId, SalaryAcctResultPO::getResultValue);
// 薪资项目的值
Map<String, Object> map = SalaryEntityUtil.convert2Map(salaryItems, o -> "" + o.getId(), o -> resultValueMap.getOrDefault(o.getId(), StringUtils.EMPTY));
// 人员信息字段的值
Map<String, String> fieldValueMap = SalaryAcctFormulaBO.convert2FormulaEmployee(employeeMap.get(e.getEmployeeId()), e, false );
for (SalarySobEmpFieldPO salarySobEmpField : salarySobEmpFields) {
// 员工信息字段的字段类型
if (dynamicEmpInfo) {
map.put(salarySobEmpField.getFieldCode(), fieldValueMap.get(salarySobEmpField.getFieldCode()));
} else {
if ("departmentName".equals(salarySobEmpField.getFieldCode())) {
map.put("departmentName", e.getDepartmentName());
} else if ("departmentId".equals(salarySobEmpField.getFieldCode())) {
map.put("departmentId", e.getDepartmentId());
} else if ("subcompanyName".equals(salarySobEmpField.getFieldCode())) {
map.put("subcompanyName", e.getSubcompanyName());
} else if ("jobcall".equals(salarySobEmpField.getFieldCode())) {
map.put("jobcall", e.getJobcall());
} else if ("jobcallId".equals(salarySobEmpField.getFieldCode())) {
map.put("jobcallId", e.getJobcallId());
} else if ("jobtitleName".equals(salarySobEmpField.getFieldCode())) {
map.put("jobtitleName", e.getJobtitleName());
} else if ("jobtitleId".equals(salarySobEmpField.getFieldCode())) {
map.put("jobtitleId", e.getJobtitleId());
} else if ("status".equals(salarySobEmpField.getFieldCode())) {
map.put("status", e.getStatus());
} else if ("statusName".equals(salarySobEmpField.getFieldCode())) {
map.put("statusName", UserStatusEnum.getDefaultLabelByValue(new Integer(e.getStatus())));
} else {
map.put(salarySobEmpField.getFieldCode(), fieldValueMap.get(salarySobEmpField.getFieldCode()));
}
}
map.put(salarySobEmpField.getFieldCode() + DATA_TYPE_SUFFIX, SalaryDataTypeEnum.STRING.getValue());
}
// 主键id
map.put("id", e.getId());
//人员id
map.put("employeeId", e.getEmployeeId());
map.put("userName", fieldValueMap.get("username"));
// 个税扣缴义务人
// String taxAgentName = taxAgentNameMap.getOrDefault(e.getTaxAgentId(), StringUtils.EMPTY);
// map.put("taxAgentName", taxAgentName);
return map;
}).collect(Collectors.toList());
}
}

View File

@ -381,6 +381,9 @@
<if test="param.attendQuoteId != null and param.attendQuoteId != ''">
AND attend_quote_id = #{param.attendQuoteId}
</if>
<if test="param.attendQuoteDataId != null and param.attendQuoteDataId != ''">
AND attend_quote_data_id = #{param.attendQuoteDataId}
</if>
<if test="param.employeeIds != null and param.employeeIds.size() > 0">
AND employee_id IN
<foreach collection="param.employeeIds" open="(" item="employeeId" separator="," close=")">

View File

@ -343,7 +343,8 @@
<select id="getDeptInfoList" resultType="com.engine.salary.entity.hrm.DeptInfo">
select d.departmentname as name,
d.id as id
d.id as id,
showorder
from hrmdepartment d
where 1=1
<if test="departmentIds != null and departmentIds.size()>0">

View File

@ -231,4 +231,6 @@ public interface SalaryAcctResultService {
* @version 1.0
**/
List<SalaryAcctResultPO> listBySobSalaryMonth(Date salaryMonth, Long salarySobId, List<Long> employeeIds);
Map<String, Object> listSalaryApprovalDepartmentReport(SalaryAcctResultQueryParam queryParam);
}

View File

@ -4,9 +4,7 @@ import cn.hutool.core.util.NumberUtil;
import com.alibaba.druid.support.json.JSONUtils;
import com.alibaba.fastjson.JSONObject;
import com.api.formmode.mybatis.util.SqlProxyHandle;
import com.cloudstore.eccom.pc.table.WeaTable;
import com.cloudstore.eccom.pc.table.WeaTableColumn;
import com.cloudstore.eccom.result.WeaResultMsg;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.hrmelog.entity.dto.LoggerContext;
@ -195,6 +193,7 @@ public class AttendQuoteDataServiceImpl extends Service implements AttendQuoteDa
}
@Override
public List<AttendQuoteDataDTO> getAttendQuoteData(YearMonth salaryYearMonth, Long salarySobId, List<Long> employeeIds) {
if (salaryYearMonth == null || salarySobId == null) {
@ -882,6 +881,9 @@ public class AttendQuoteDataServiceImpl extends Service implements AttendQuoteDa
@Override
public void editData(AttendQuoteDataEditParam attendQuoteDataEditParam) {
Map<String, String> attendQuoteData = attendQuoteDataEditParam.getAttendQuoteData();
if (attendQuoteData == null || attendQuoteData.keySet().size() == 0) {
return;
}
AttendQuoteDataBiz dataBiz = new AttendQuoteDataBiz();
AttendQuoteDataValueBiz attendQuoteDataValueBiz = new AttendQuoteDataValueBiz();
ArrayList<Long> ids = new ArrayList<>();
@ -891,15 +893,35 @@ public class AttendQuoteDataServiceImpl extends Service implements AttendQuoteDa
if (list == null || list.size() == 0) {
throw new SalaryRunTimeException("该数据不存在!");
}
Map<String, String> attendQuoteFieldData = new HashMap<>();
AttendQuoteDataBaseDTO attendQuoteDataBaseDTO = list.get(0);
Date now = new Date();
List<AttendQuoteDataValuePO> values = new ArrayList<>();
for (Map.Entry<String, String> entrySet : attendQuoteData.entrySet()) {
String[] s = entrySet.getKey().split("_");
attendQuoteFieldData.put(s[0], entrySet.getValue());
}
for (Map.Entry<String, String> entrySet : attendQuoteFieldData.entrySet()) {
AttendQuoteDataValuePO updatePO = AttendQuoteDataValuePO.builder().employeeId(list.get(0).getEmployeeId()).attendQuoteFieldId(SalaryEntityUtil.string2Long(entrySet.getKey())).dataValue(entrySet.getValue()).build();
attendQuoteDataValueBiz.updateDataValue(updatePO);
values.add(AttendQuoteDataValuePO.builder()
.createTime(now)
.updateTime(now)
.creator((long) user.getUID())
.tenantKey(SalaryDefaultTenantConstant.DEFAULT_TENANT_KEY)
.employeeId(attendQuoteDataBaseDTO.getEmployeeId())
.attendQuoteId(attendQuoteDataBaseDTO.getAttendQuoteId())
.attendQuoteDataId(attendQuoteDataBaseDTO.getId())
.attendQuoteFieldId(Long.valueOf(s[0]))
.dataValue(Utils.null2String(entrySet.getValue()))
.build());
}
// 先删除数据
attendQuoteDataValueBiz.deleteByAttendQuoteDataIds(ids);
// 批量插入
values = values.stream()
.filter(po -> StringUtils.isNotBlank(po.getDataValue()))
.map(val -> {
val.setDataValue(val.getDataValue().trim());
return val;
})
.collect(Collectors.toList());
dataValueBiz.insertData(values);
}
/**
@ -919,32 +941,38 @@ public class AttendQuoteDataServiceImpl extends Service implements AttendQuoteDa
}
// 所有考勤字段
List<AttendQuoteFieldPO> attendQuoteFields = getAllAttendQuoteFields();
// 获取最终结果
List<Map<String, Object>> listMaps = getListMaps(list);
AttendQuoteDataBaseDTO attendQuoteDataBaseDTO = list.get(0);
// 考核数据值
List<AttendQuoteDataValuePO> attendQuoteDataValues = dataValueBiz.listSome(AttendQuoteDataValuePO.builder().attendQuoteDataId(attendQuoteDataBaseDTO.getId()).build());
Map<String, Object> valueMap = new LinkedHashMap<>();
valueMap.put("id", attendQuoteDataBaseDTO.getId());
valueMap.put("username", attendQuoteDataBaseDTO.getUsername());
valueMap.put("departmentName", attendQuoteDataBaseDTO.getDepartmentName());
valueMap.put("mobile", attendQuoteDataBaseDTO.getMobile());
valueMap.put("jobNum", attendQuoteDataBaseDTO.getJobNum());
valueMap.put("idNo", attendQuoteDataBaseDTO.getIdNo());
// 考勤数据
attendQuoteDataValues.stream().filter(a -> a.getAttendQuoteDataId().equals(attendQuoteDataBaseDTO.getId())).collect(Collectors.toList()).forEach(e -> {
valueMap.put(e.getAttendQuoteFieldId() + "_attendQuoteData", e.getDataValue());
});
List<WeaTableColumn> columns = new ArrayList<>();
columns.add(new WeaTableColumn("150", SalaryI18nUtil.getI18nLabel(85429, "姓名"), "username"));
columns.add(new WeaTableColumn("150", SalaryI18nUtil.getI18nLabel(86185, "部门"), "departmentName"));
columns.add(new WeaTableColumn("150", SalaryI18nUtil.getI18nLabel(86186, "手机号"), "mobile"));
columns.add(new WeaTableColumn("150", SalaryI18nUtil.getI18nLabel(86317, "工号"), "jobNum"));
columns.add(new WeaTableColumn("150", SalaryI18nUtil.getI18nLabel(86317, "身份证号"), "idNo"));
// 动态列
if (CollectionUtils.isNotEmpty(listMaps)) {
Map<String, Object> map = listMaps.stream().max(Comparator.comparingInt(m -> m.keySet().size())).get();
for (AttendQuoteFieldPO attendQuoteField : attendQuoteFields) {
if (map.containsKey(attendQuoteField.getId() + "_attendQuoteData")) {
columns.add(new WeaTableColumn("150", attendQuoteField.getFieldName(), attendQuoteField.getId() + "_attendQuoteData"));
}
}
for (AttendQuoteFieldPO attendQuoteField : attendQuoteFields) {
columns.add(new WeaTableColumn("150", attendQuoteField.getFieldName(), attendQuoteField.getId() + "_attendQuoteData"));
}
WeaTable weaTable = new WeaTable();
weaTable.setColumns(columns);
WeaResultMsg result = new WeaResultMsg(false);
result.putAll(weaTable.makeDataResult());
result.success();
Map<String, Object> datas = new HashMap<>();
datas.put("data", listMaps.get(0));
datas.put("dataKey", result.getResultMap());
return datas;
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("data", valueMap);
resultMap.put("columns", columns);
return resultMap;
}
/**

View File

@ -6,6 +6,7 @@ import com.engine.core.impl.Service;
import com.engine.hrmelog.entity.dto.LoggerContext;
import com.engine.salary.cache.SalaryCacheKey;
import com.engine.salary.common.LocalDateRange;
import com.engine.salary.component.WeaTableColumnGroup;
import com.engine.salary.config.SalaryElogConfig;
import com.engine.salary.constant.SalaryDefaultTenantConstant;
import com.engine.salary.encrypt.EncryptUtil;
@ -1283,4 +1284,113 @@ public class SalaryAcctResultServiceImpl extends Service implements SalaryAcctRe
encryptUtil.decryptList(salaryAcctResultPOS, SalaryAcctResultPO.class);
return salaryAcctResultPOS;
}
@Override
public Map<String, Object> listSalaryApprovalDepartmentReport(SalaryAcctResultQueryParam queryParam) {
ValidUtil.doValidator(queryParam);
Map<String, Object> map = new HashMap<>();
// 审批信息
SalaryApprovalDTO approvalInfoByRecordId = getSalaryApprovalRuleService(user).getApprovalInfoByRecordId(queryParam.getSalaryAcctRecordId());
// 查询薪资核算记录
SalaryAcctRecordPO salaryAcctRecordPO = getSalaryAcctRecordService(user).getById(queryParam.getSalaryAcctRecordId());
if (Objects.isNull(salaryAcctRecordPO)) {
throw new SalaryRunTimeException(SalaryI18nUtil.getI18nLabel(98747, "薪资核算记录不存在或已被删除"));
}
// 查询薪资核算人员
List<SalaryAcctEmployeePO> salaryAcctEmployeePOList = getSalaryAcctEmployeeService(user).listBySalaryAcctRecordIds(Collections.singletonList(queryParam.getSalaryAcctRecordId()));
if (CollectionUtils.isEmpty(salaryAcctEmployeePOList)) {
return map;
}
// 获取员工信息
List<Long> salaryAcctEmpIds = salaryAcctEmployeePOList.stream().map(SalaryAcctEmployeePO::getId).distinct().collect(Collectors.toList());
List<Long> empIds = salaryAcctEmployeePOList.stream().map(SalaryAcctEmployeePO::getEmployeeId).distinct().collect(Collectors.toList());
List<DataCollectionEmployee> employeeList = getSalaryEmployeeService(user).listByIds(empIds);
List<SalaryItemPO> salaryItemPOList = getSalaryItemService(user).listAll();
Map<Long, SalaryItemPO> salaryItemIdMap = SalaryEntityUtil.convert2Map(salaryItemPOList, SalaryItemPO::getId);
List<Long> allNumberItemIds = salaryItemPOList.stream().filter(item -> item.getDataType().equals(SalaryDataTypeEnum.NUMBER.getValue())).map(SalaryItemPO::getId).collect(Collectors.toList());
// 获取需要统计的薪资项目
List<Long> needSumItemIds = new ArrayList<>();
approvalInfoByRecordId.getApprovalItemGroup().stream().forEach(group -> {
if (CollectionUtils.isNotEmpty(group.getApprovalItems())) {
needSumItemIds.addAll(group.getApprovalItems().stream()
.filter(item -> allNumberItemIds.contains(item.getSalaryItemId()))
.map(SalaryApprovalDTO.approvalItem::getSalaryItemId)
.collect(Collectors.toList()));
}
});
// 查询薪资核算结果
List<SalaryAcctResultPO> acctResultList = getSalaryAcctResultService(user).listByAcctEmployeeIdsAndSalaryItemIds(salaryAcctEmpIds, needSumItemIds);
// 查询薪资核算结果
List<SalarySobEmpFieldPO> salarySobEmpFields = new ArrayList<>();
salarySobEmpFields.add(SalarySobEmpFieldPO.builder().fieldCode("departmentName").build());
salarySobEmpFields.add(SalarySobEmpFieldPO.builder().fieldCode("departmentId").build());
ArrayList<SalaryItemPO> needSumItemList = new ArrayList<>();
needSumItemIds.stream().forEach(id -> {
SalaryItemPO salaryItemPO = salaryItemIdMap.get(id);
if (salaryItemPO != null) {
needSumItemList.add(salaryItemPO);
}
});
List<Map<String, Object>> acctResultMap = SalaryAcctResultBO.buildData4Report(needSumItemList, salarySobEmpFields, employeeList, salaryAcctEmployeePOList, acctResultList, false);
// 根据部门分组
Map<String, List<Map<String, Object>>> acctResultGroupMap = SalaryEntityUtil.group2Map(acctResultMap, resultMap -> resultMap.getOrDefault("departmentId", "").toString());
LinkedHashMap<String, Map<String, Object>> sumResultByGroup = getSumResultByGroup(acctResultGroupMap, Collections.emptyList(), needSumItemList);
// 构建表头
List<WeaTableColumnGroup> columns = new ArrayList<>();
WeaTableColumnGroup depCol = new WeaTableColumnGroup("150px", "部门", "departmentName");
depCol.setFixed("left");
columns.add(depCol);
columns.add(new WeaTableColumnGroup("150px", "人数", "empNums"));
for (SalaryItemPO salaryItemPO : needSumItemList) {
columns.add(new WeaTableColumnGroup("150px", salaryItemPO.getName(), salaryItemPO.getId().toString()));
}
map.put("column", columns);
map.put("data", sumResultByGroup.values().stream().collect(Collectors.toList()));
return map;
}
private LinkedHashMap<String, Map<String, Object>> getSumResultByGroup(Map<String, List<Map<String, Object>>> groupBy,
List<SalarySobItemPO> salarySobItemPOS,
List<SalaryItemPO> numberItems) {
LinkedHashMap<String, List<Map<String, Object>>> sortedGroupBy = new LinkedHashMap<>();
List<Long> deptIdList = groupBy.keySet().stream().filter(NumberUtils::isCreatable).map(Long::valueOf).collect(Collectors.toList());
Map<String, Double> deptOrderMap = SalaryEntityUtil.convert2Map(getSalaryEmployeeService(user).getDeptInfoList(deptIdList), dept -> dept.getId().toString(), DeptInfo::getShoworder);
groupBy.entrySet().stream()
.sorted((k1,k2) -> {
Double order1 = deptOrderMap.get(k1.getKey()) == null ? new Double(0) : deptOrderMap.get(k1.getKey());
Double order2 = deptOrderMap.get(k2.getKey()) == null ? new Double(0) : deptOrderMap.get(k2.getKey());
return order1.compareTo(order2);
})
.forEachOrdered(x -> sortedGroupBy.put(x.getKey(), x.getValue()));
LinkedHashMap<String, Map<String, Object>> result = new LinkedHashMap<>();
// 本次薪资核算所用的薪资账套下的薪资项目
Map<Long, SalarySobItemPO> salaryItemIdKeySalarySobItemPOMap = SalaryEntityUtil.convert2Map(salarySobItemPOS, SalarySobItemPO::getSalaryItemId);
for(Map.Entry<String, List<Map<String, Object>>> entrySet : sortedGroupBy.entrySet()){
// 每个分类中的核算数据
List<Map<String, Object>> value = entrySet.getValue();
Map<String, Object> itemSum = new HashMap<>();
numberItems.forEach(item -> {
List<String> itemValue = value.stream().filter(v -> v.get(item.getId().toString()) != null).map(v -> (String)v.get(item.getId().toString())).collect(Collectors.toList());
BigDecimal sum = itemValue
.stream()
.filter(NumberUtils::isCreatable)
.map(BigDecimal::new)
.reduce(BigDecimal.ZERO, BigDecimal::add);
itemSum.put( item.getId().toString(), SalaryAcctFormulaBO.roundResultValue(sum.toString(), item, Collections.emptyList(), Collections.emptyMap(), salaryItemIdKeySalarySobItemPOMap) );
});
itemSum.put("empNums", entrySet.getValue().size());
itemSum.put("departmentName", CollectionUtils.isEmpty(value) ? "" : value.get(0).get("departmentName"));
result.put(entrySet.getKey(), itemSum);
}
return result;
}
}

View File

@ -673,6 +673,21 @@ public class SalarySobController {
return new ResponseResult<ApprovalRequestSaveParam, String>(user).run(getSalaryApprovalWrapper(user)::saveApprovalRequestId, param);
}
/**
* 获取审批时薪资核算部门报表
* @param request
* @param response
* @param param
* @return
*/
@POST
@Path("/salaryApproval/acctresult/departmentReport")
@Produces(MediaType.APPLICATION_JSON)
public String listSalaryApprovalDepartmentReport(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody SalaryAcctResultQueryParam param) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<SalaryAcctResultQueryParam, Map<String, Object>>(user).run(getSalaryApprovalWrapper(user)::listSalaryApprovalDepartmentReport, param);
}
/**********************************薪资审批规则 start*********************************/
}

View File

@ -165,4 +165,9 @@ public class SalaryApprovalWrapper extends Service {
public void saveApprovalRequestId(ApprovalRequestSaveParam saveParam) {
getSalaryApprovalRuleService(user).saveApprovalRequestId(saveParam);
}
public Map<String, Object> listSalaryApprovalDepartmentReport(SalaryAcctResultQueryParam queryParam) {
return getSalaryAcctResultService(user).listSalaryApprovalDepartmentReport(queryParam);
}
}