2022-04-24 17:42:32 +08:00
|
|
|
package com.engine.salary.remote.attend.service.impl;
|
|
|
|
|
|
2022-06-13 10:52:32 +08:00
|
|
|
import com.alibaba.druid.support.json.JSONUtils;
|
2022-04-24 17:42:32 +08:00
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.engine.core.impl.Service;
|
2023-10-20 13:26:25 +08:00
|
|
|
import com.engine.kq.cmd.balanceofleaverp.GetSearchListCmd;
|
2023-02-01 14:03:13 +08:00
|
|
|
import com.engine.kq.cmd.report.GetKQReportCmd;
|
2022-04-24 17:42:32 +08:00
|
|
|
import com.engine.salary.remote.attend.entity.Attend4Salary;
|
|
|
|
|
import com.engine.salary.remote.attend.service.RemoteAttend4SalaryService;
|
2022-04-25 14:51:30 +08:00
|
|
|
import com.engine.salary.util.SalaryDateUtil;
|
2023-10-24 10:24:10 +08:00
|
|
|
import com.engine.salary.util.SalaryEntityUtil;
|
2022-04-25 14:51:30 +08:00
|
|
|
import com.engine.salary.util.valid.ValidUtil;
|
2022-04-25 13:57:33 +08:00
|
|
|
import com.google.common.collect.Maps;
|
2022-06-13 10:52:32 +08:00
|
|
|
import lombok.extern.slf4j.Slf4j;
|
2022-04-25 13:57:33 +08:00
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
2023-01-05 16:24:40 +08:00
|
|
|
import weaver.general.BaseBean;
|
2022-07-07 14:37:10 +08:00
|
|
|
import weaver.general.Util;
|
2022-04-24 17:42:32 +08:00
|
|
|
|
2022-04-25 13:57:33 +08:00
|
|
|
import java.util.*;
|
2022-04-25 14:51:30 +08:00
|
|
|
import java.util.stream.Collectors;
|
2022-04-24 17:42:32 +08:00
|
|
|
|
2022-06-13 10:52:32 +08:00
|
|
|
@Slf4j
|
2022-04-24 17:42:32 +08:00
|
|
|
public class RemoteAttend4SalaryServiceImpl extends Service implements RemoteAttend4SalaryService {
|
2023-01-05 16:24:40 +08:00
|
|
|
private final Boolean isLog = "true".equals(new BaseBean().getPropValue("hrmSalary", "log"));
|
2022-04-24 17:42:32 +08:00
|
|
|
|
|
|
|
|
@Override
|
2022-04-25 13:57:33 +08:00
|
|
|
public List<Map<String, String>> getColumns() {
|
2022-04-24 17:42:32 +08:00
|
|
|
Map<String, Object> paramsMap = new HashMap<String, Object>();
|
2022-04-25 16:20:57 +08:00
|
|
|
// paramsMap.put("pageIndex", 1);
|
|
|
|
|
// paramsMap.put("pageSize", 10);
|
2023-02-01 14:03:13 +08:00
|
|
|
paramsMap.put("typeselect", "3");
|
|
|
|
|
paramsMap.put("viewScope", "0");
|
2022-04-25 13:57:33 +08:00
|
|
|
paramsMap.put("isNoAccount", "1");
|
|
|
|
|
paramsMap.put("attendanceSerial", "");
|
|
|
|
|
paramsMap.put("isFromMyAttendance", "1");
|
|
|
|
|
Map<String, Object> temp = new HashMap<String, Object>();
|
|
|
|
|
temp.put("data", JSONObject.toJSONString(paramsMap));
|
|
|
|
|
temp.put("reportType", "month");
|
|
|
|
|
List<Map> datas = (List<Map>) commandExecutor.execute(new GetKQReportCmd(temp, user)).get("columns");
|
2023-02-01 14:03:13 +08:00
|
|
|
if (isLog) {
|
|
|
|
|
log.info("同步考勤字段,{}", JSONUtils.toJSONString(datas));
|
|
|
|
|
}
|
2022-04-25 13:57:33 +08:00
|
|
|
List<Map<String, String>> columns = new ArrayList<>();
|
|
|
|
|
datas.stream().filter(column -> Objects.nonNull(column.get("dataIndex"))).forEach(column -> {
|
|
|
|
|
String dataIndex = column.get("dataIndex").toString();
|
|
|
|
|
//请假
|
|
|
|
|
if (dataIndex.equals("leave") && column.get("children") != null) {
|
|
|
|
|
List<Map> list = (List<Map>) column.get("children");
|
|
|
|
|
if (CollectionUtils.isNotEmpty(list)) {
|
|
|
|
|
list.stream()
|
|
|
|
|
.filter(leave -> leave.get("dataIndex") != null && StringUtils.isNotBlank(leave.get("dataIndex").toString()))
|
|
|
|
|
.forEach(leave -> {
|
|
|
|
|
Map<String, String> map = Maps.newHashMapWithExpectedSize(2);
|
|
|
|
|
map.put("code", leave.get("dataIndex").toString());
|
2022-07-07 14:37:10 +08:00
|
|
|
map.put("name", Util.null2String(column.get("title")) + "-" + leave.get("title") + "(" + leave.get("unit").toString() + ")");
|
2022-04-25 13:57:33 +08:00
|
|
|
columns.add(map);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//加班
|
2022-06-13 10:52:32 +08:00
|
|
|
else if (dataIndex.equals("overtime") && column.get("children") != null) {
|
2022-05-06 16:01:33 +08:00
|
|
|
List<Map> list = (List<Map>) column.get("children");
|
|
|
|
|
if (CollectionUtils.isNotEmpty(list)) {
|
2022-07-07 14:37:10 +08:00
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
|
|
Map overtimeMap = list.get(i);
|
|
|
|
|
if (overtimeMap.get("dataIndex") != null && StringUtils.isNotBlank(overtimeMap.get("dataIndex").toString()) && overtimeMap.get("children") == null) {
|
|
|
|
|
Map<String, String> map = Maps.newHashMapWithExpectedSize(2);
|
|
|
|
|
map.put("code", overtimeMap.get("dataIndex").toString());
|
|
|
|
|
map.put("name", Util.null2String(column.get("title")) + "-" + overtimeMap.get("title") + "(" + overtimeMap.get("unit").toString() + ")");
|
|
|
|
|
columns.add(map);
|
|
|
|
|
}
|
|
|
|
|
if (overtimeMap.get("dataIndex") != null && StringUtils.isNotBlank(overtimeMap.get("dataIndex").toString()) && overtimeMap.get("children") != null) {
|
|
|
|
|
List<Map> overtimes = (List<Map>) overtimeMap.get("children");
|
|
|
|
|
if (CollectionUtils.isNotEmpty(overtimes)) {
|
|
|
|
|
overtimes.stream().filter(leave -> leave.get("dataIndex") != null && StringUtils.isNotBlank(leave.get("dataIndex").toString()))
|
|
|
|
|
.forEach(leave -> {
|
|
|
|
|
Map<String, String> map = Maps.newHashMapWithExpectedSize(2);
|
|
|
|
|
map.put("code", leave.get("dataIndex").toString());
|
|
|
|
|
map.put("name", Util.null2String(column.get("title")) + "-" + Util.null2String(overtimeMap.get("title")) + "-" + leave.get("title") + "(" + leave.get("unit").toString() + ")");
|
|
|
|
|
columns.add(map);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2022-05-06 16:01:33 +08:00
|
|
|
}
|
2022-04-25 13:57:33 +08:00
|
|
|
}
|
|
|
|
|
//普通考勤
|
|
|
|
|
else {
|
|
|
|
|
if (column.get("unit") != null && StringUtils.isNotBlank(column.get("unit").toString())) {
|
|
|
|
|
Map<String, String> map = Maps.newHashMapWithExpectedSize(2);
|
|
|
|
|
map.put("code", dataIndex);
|
|
|
|
|
map.put("name", column.get("title") + "(" + column.get("unit").toString() + ")");
|
|
|
|
|
columns.add(map);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2023-10-20 13:26:25 +08:00
|
|
|
|
2023-10-24 10:24:10 +08:00
|
|
|
//假期余额字段
|
|
|
|
|
columns.addAll(getBalanceOfLeaveColumns());
|
2022-04-25 13:57:33 +08:00
|
|
|
return columns;
|
2022-04-24 17:42:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-06-13 10:52:32 +08:00
|
|
|
public List<Map<String, String>> getDatas(Attend4Salary attend4Salary) {
|
2022-04-25 14:51:30 +08:00
|
|
|
ValidUtil.doValidator(attend4Salary);
|
2022-06-13 10:52:32 +08:00
|
|
|
log.info("开始获取的考勤数据,参数{}", attend4Salary);
|
|
|
|
|
List<Map<String, String>> list = new ArrayList<>();
|
|
|
|
|
try {
|
|
|
|
|
Map<String, Object> paramsMap = new HashMap<String, Object>();
|
2023-02-06 10:33:12 +08:00
|
|
|
paramsMap.put("pageIndex", 1);
|
|
|
|
|
paramsMap.put("pageSize", 500);
|
2022-06-13 10:52:32 +08:00
|
|
|
paramsMap.put("typeselect", "6");
|
|
|
|
|
paramsMap.put("fromDate", SalaryDateUtil.getFormatLocalDate(attend4Salary.getBeginDate()));
|
|
|
|
|
paramsMap.put("toDate", SalaryDateUtil.getFormatLocalDate(attend4Salary.getEndDate()));
|
|
|
|
|
paramsMap.put("viewScope", "3");
|
|
|
|
|
List<String> resourceIds = attend4Salary.getOnlyEmpIds().stream().map(String::valueOf).collect(Collectors.toList());
|
|
|
|
|
paramsMap.put("resourceId", String.join(",", resourceIds));
|
|
|
|
|
paramsMap.put("isNoAccount", "1");
|
|
|
|
|
paramsMap.put("attendanceSerial", "");
|
|
|
|
|
paramsMap.put("isFromMyAttendance", "1");
|
|
|
|
|
Map<String, Object> temp = new HashMap<String, Object>();
|
|
|
|
|
temp.put("data", JSONObject.toJSONString(paramsMap));
|
|
|
|
|
temp.put("reportType", "month");
|
|
|
|
|
list = (List<Map<String, String>>) commandExecutor.execute(new GetKQReportCmd(temp, user)).get("datas");
|
2023-01-05 16:24:40 +08:00
|
|
|
if (isLog) {
|
|
|
|
|
log.info("获取的考勤数据,{}", JSONUtils.toJSONString(list));
|
|
|
|
|
}
|
2023-10-24 10:24:10 +08:00
|
|
|
|
2023-10-24 11:43:14 +08:00
|
|
|
|
|
|
|
|
//假期余额信息
|
2023-10-24 10:24:10 +08:00
|
|
|
List<Map<String, String>> balanceOfLeaveDatas = getBalanceOfLeaveDatas(attend4Salary);
|
2023-10-24 11:43:14 +08:00
|
|
|
Map<String, String> balanceMap = SalaryEntityUtil.convert2Map(balanceOfLeaveDatas, m -> m.get("id"), m -> m.get("2"));
|
|
|
|
|
|
|
|
|
|
//给有考勤的赋值
|
|
|
|
|
List<String> attendEmpIds = list.stream().map(attend -> {
|
|
|
|
|
String resourceId = attend.get("resourceId");
|
|
|
|
|
attend.put("balanceOfLeave2", balanceMap.get(resourceId));
|
|
|
|
|
return resourceId;
|
|
|
|
|
}).collect(Collectors.toList());
|
2023-10-24 10:24:10 +08:00
|
|
|
|
2023-10-24 11:43:14 +08:00
|
|
|
//没有考勤,但有假期余额的人赋值
|
|
|
|
|
List<Map<String, String>> balanceOfLeaveList = balanceMap.keySet().stream()
|
|
|
|
|
.filter(k -> !attendEmpIds.contains(k))
|
|
|
|
|
.map(k -> {
|
|
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
|
|
map.put("resourceId", k);
|
|
|
|
|
map.put("balanceOfLeave2", balanceMap.get(k));
|
|
|
|
|
return map;
|
|
|
|
|
})
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
list.addAll(balanceOfLeaveList);
|
2022-06-13 10:52:32 +08:00
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("获取考勤数据失败", e);
|
|
|
|
|
}
|
2022-04-25 14:51:30 +08:00
|
|
|
return list;
|
2022-04-24 17:42:32 +08:00
|
|
|
}
|
2023-10-20 13:26:25 +08:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<Map<String, String>> getBalanceOfLeaveColumns() {
|
|
|
|
|
Map<String, Object> paramsMap = new HashMap<String, Object>();
|
|
|
|
|
paramsMap.put("dateScope", "6");
|
|
|
|
|
paramsMap.put("selectedYear", 2023);
|
|
|
|
|
paramsMap.put("dataScope", "3");
|
|
|
|
|
paramsMap.put("resourceId", 92);
|
|
|
|
|
paramsMap.put("status", "9");
|
|
|
|
|
paramsMap.put("isNoAccount", true);
|
2023-10-24 10:24:10 +08:00
|
|
|
List<Map<String, String>> columns = (List<Map<String, String>>) commandExecutor.execute(new GetSearchListCmd(paramsMap, user)).get("columns");
|
|
|
|
|
Map<String, String> map = Maps.newHashMapWithExpectedSize(2);
|
|
|
|
|
//年假
|
|
|
|
|
map.put("code", "balanceOfLeave" + 2);
|
|
|
|
|
map.put("name", columns.stream().filter(m -> "2".equals(m.get("key"))).findFirst().map(m -> m.get("title")).orElse("年假余额"));
|
|
|
|
|
|
|
|
|
|
List<Map<String, String>> balanceOfLeaveColumns = new ArrayList<>();
|
|
|
|
|
balanceOfLeaveColumns.add(map);
|
|
|
|
|
return balanceOfLeaveColumns;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<Map<String, String>> getBalanceOfLeaveDatas(Attend4Salary attend4Salary) {
|
|
|
|
|
Map<String, Object> paramsMap = new HashMap<String, Object>();
|
|
|
|
|
paramsMap.put("dateScope", "6");
|
|
|
|
|
paramsMap.put("selectedYear", SalaryDateUtil.date2Year(attend4Salary.getBeginDate()));
|
|
|
|
|
paramsMap.put("dataScope", "3");
|
|
|
|
|
paramsMap.put("resourceId", attend4Salary.getOnlyEmpIds().stream().map(String::valueOf).collect(Collectors.joining(",")));
|
|
|
|
|
paramsMap.put("status", "9");
|
|
|
|
|
paramsMap.put("isNoAccount", true);
|
|
|
|
|
return (List<Map<String, String>>) commandExecutor.execute(new GetSearchListCmd(paramsMap, user)).get("datas");
|
2023-10-20 13:26:25 +08:00
|
|
|
}
|
2022-04-24 17:42:32 +08:00
|
|
|
}
|