weaver-hrm-salary/src/com/engine/salary/remote/attend/service/impl/RemoteAttend4SalaryServiceI...

130 lines
6.8 KiB
Java
Raw Normal View History

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;
2022-04-25 13:57:33 +08:00
import com.engine.salary.remote.attend.cmd.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;
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;
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 {
@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);
2022-04-25 13:57:33 +08:00
paramsMap.put("typeselect", "6");
paramsMap.put("viewScope", "3");
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");
2022-04-24 17:42:32 +08:00
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);
}
}
});
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>();
2022-04-25 16:20:57 +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");
log.info("获取的考勤数据,{}", JSONUtils.toJSONString(list));
} catch (Exception e) {
log.error("获取考勤数据失败", e);
}
2022-04-24 17:42:32 +08:00
2022-04-25 14:51:30 +08:00
return list;
2022-04-24 17:42:32 +08:00
}
}