|
|
|
@ -2,6 +2,7 @@ package com.engine.jucailinkq.attendance.attendanceanalysis.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.engine.jucailinkq.attendance.enums.AccountingUnitEnum;
|
|
|
|
|
import com.engine.jucailinkq.attendance.enums.PersonGroupListTypeEnum;
|
|
|
|
|
import com.engine.jucailinkq.attendance.workflow.cmd.GetCqSummarySearchConditionCmd;
|
|
|
|
|
import com.engine.jucailinkq.attendance.attendanceanalysis.service.AttendanceSummaryService;
|
|
|
|
@ -60,6 +61,11 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS
|
|
|
|
|
String startUpdateSql = "update uf_jcl_kq_cqhz set hzzt = 1 where id in (" + mainIds + ")";
|
|
|
|
|
DbTools.update(startUpdateSql);
|
|
|
|
|
try {
|
|
|
|
|
//考勤项目
|
|
|
|
|
String kqxmSql = "select * from uf_jcl_kq_kqxm";
|
|
|
|
|
List<Map<String,Object>> kqxmDates = DbTools.getSqlToList(kqxmSql);
|
|
|
|
|
//收集考勤项目id-核算单位映射
|
|
|
|
|
Map<String, String> kqxmUnitInfo = kqxmDates.stream().collect(Collectors.toMap(e->Util.null2String(e.get("id")),e->Util.null2String(e.get("hsdw"))));
|
|
|
|
|
for (String mainId : mainIdList) {
|
|
|
|
|
List<Map<String, String>> addList = new ArrayList<>();
|
|
|
|
|
//查询出勤汇总主表信息
|
|
|
|
@ -73,7 +79,7 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS
|
|
|
|
|
String subCompanyListStr = SubCompanyComInfo.getAllChildSubcompanyId(subCompany, subCompany);
|
|
|
|
|
//汇总出勤结果表、补打卡表、出勤津贴表数据
|
|
|
|
|
//出勤结果表
|
|
|
|
|
List<Map<String, String>> cqAddList = getCqAddList(mainId, subCompanyListStr, startDate, endDate);
|
|
|
|
|
List<Map<String, String>> cqAddList = getCqAddList(mainId, subCompanyListStr, startDate, endDate, kqxmUnitInfo);
|
|
|
|
|
bs.writeLog("cqAddList_size : " + cqAddList.size());
|
|
|
|
|
if (cqAddList.size() > 0) {
|
|
|
|
|
addList.addAll(cqAddList);
|
|
|
|
@ -232,6 +238,8 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS
|
|
|
|
|
columns.add(column);
|
|
|
|
|
}
|
|
|
|
|
bs.writeLog("columns : " + columns);
|
|
|
|
|
//收集考勤项目id-核算单位映射
|
|
|
|
|
Map<String, String> kqxmUnitInfo = kqxmDates.stream().collect(Collectors.toMap(e->Util.null2String(e.get("id")),e->Util.null2String(e.get("hsdw"))));
|
|
|
|
|
//获取列表结果,typeSelect为9、10时查询出勤汇总明细表数据,其他则生成临时汇总数据
|
|
|
|
|
List<Map<String,Object>> dtDates = null;
|
|
|
|
|
LocalDate targetDate = LocalDate.now(); // 获取当前日期
|
|
|
|
@ -251,7 +259,7 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS
|
|
|
|
|
//调用临时汇总数据方法,生成数据
|
|
|
|
|
jsonObj.put("fromDate", fromDate);
|
|
|
|
|
jsonObj.put("toDate", toDate);
|
|
|
|
|
dtDates = getTemAttendanceSummary(jsonObj);
|
|
|
|
|
dtDates = getTemAttendanceSummary(jsonObj, kqxmUnitInfo);
|
|
|
|
|
}
|
|
|
|
|
bs.writeLog("dtDates_size : " + (dtDates==null ? "null" : dtDates.size()));
|
|
|
|
|
//处理明细表数据,分组生成列表数据
|
|
|
|
@ -671,7 +679,7 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS
|
|
|
|
|
* @param params
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public List<Map<String, Object>> getTemAttendanceSummary(Map<String, Object> params) {
|
|
|
|
|
public List<Map<String, Object>> getTemAttendanceSummary(Map<String, Object> params, Map<String, String> kqxmUnitInfo) {
|
|
|
|
|
|
|
|
|
|
bs.writeLog("params : " + params);
|
|
|
|
|
List<Map<String, Object>> addList = new ArrayList<>();
|
|
|
|
@ -707,7 +715,7 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS
|
|
|
|
|
if (!startDate.equals("") && !endDate.equals("")) {
|
|
|
|
|
//临时汇总出勤结果表、补打卡表、出勤津贴表数据
|
|
|
|
|
//出勤结果表
|
|
|
|
|
List<Map<String, Object>> cqAddList = getTemCqAddList(startDate, endDate, subCompanyIds, departmentIds, empIds, empStatus, userManageInfo);
|
|
|
|
|
List<Map<String, Object>> cqAddList = getTemCqAddList(startDate, endDate, subCompanyIds, departmentIds, empIds, empStatus, userManageInfo, kqxmUnitInfo);
|
|
|
|
|
bs.writeLog("cqAddList_size : " + cqAddList.size());
|
|
|
|
|
if (cqAddList.size() > 0) {
|
|
|
|
|
addList.addAll(cqAddList);
|
|
|
|
@ -756,7 +764,7 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//汇总出勤结果表
|
|
|
|
|
public List<Map<String, String>> getCqAddList(String mainId, String subCompanyListStr, String startDate, String endDate) {
|
|
|
|
|
public List<Map<String, String>> getCqAddList(String mainId, String subCompanyListStr, String startDate, String endDate, Map<String, String> kqxmUnitInfo) {
|
|
|
|
|
String cqSql = "select * from uf_jcl_kq_cqjg where fbid in (" + subCompanyListStr + ") and rq >= '" + startDate +"'" + " and rq <= '" + endDate +"'";
|
|
|
|
|
List<Map<String,Object>> cqDates = DbTools.getSqlToList(cqSql);
|
|
|
|
|
//先根据分部、部门、人员、项目分组
|
|
|
|
@ -764,17 +772,24 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS
|
|
|
|
|
for (Map<String,Object> map : cqDates) {
|
|
|
|
|
//出勤状态
|
|
|
|
|
String cqzt = Util.null2String(map.get("cqzt"));
|
|
|
|
|
if (!cqzt.equals("")) {
|
|
|
|
|
if (!"".equals(cqzt)) {
|
|
|
|
|
//匹配出勤状态对应的考勤项目id
|
|
|
|
|
String kqxmId = cqzt.equals("0") ? "1" : "5";
|
|
|
|
|
|
|
|
|
|
String kqxmId = "0".equals(cqzt) ? "1" : "5";
|
|
|
|
|
String groupKey = map.get("fbid") + "_" + map.get("bm") + "_" + map.get("ygid") + "_" + kqxmId;
|
|
|
|
|
Map<String,Object> itemMap = new HashMap<>();
|
|
|
|
|
itemMap.put("fbid", map.get("fbid"));
|
|
|
|
|
itemMap.put("bm", map.get("bm"));
|
|
|
|
|
itemMap.put("ygid", map.get("ygid"));
|
|
|
|
|
itemMap.put("xm", kqxmId);
|
|
|
|
|
itemMap.put("sc", "1");
|
|
|
|
|
if ("1".equals(kqxmId) && Util.null2String(kqxmUnitInfo.get("1")).equals(AccountingUnitEnum.HOUR.getKey())) {
|
|
|
|
|
itemMap.put("fbid", map.get("fbid"));
|
|
|
|
|
itemMap.put("bm", map.get("bm"));
|
|
|
|
|
itemMap.put("ygid", map.get("ygid"));
|
|
|
|
|
itemMap.put("xm", kqxmId);
|
|
|
|
|
itemMap.put("sc", Util.null2String(map.get("cqsc")));
|
|
|
|
|
} else {
|
|
|
|
|
itemMap.put("fbid", map.get("fbid"));
|
|
|
|
|
itemMap.put("bm", map.get("bm"));
|
|
|
|
|
itemMap.put("ygid", map.get("ygid"));
|
|
|
|
|
itemMap.put("xm", kqxmId);
|
|
|
|
|
itemMap.put("sc", "1");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (toDealCqDataWithGroup.get(groupKey) != null) {
|
|
|
|
|
toDealCqDataWithGroup.get(groupKey).add(itemMap);
|
|
|
|
@ -1139,7 +1154,8 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//临时汇总出勤结果表
|
|
|
|
|
private List<Map<String, Object>> getTemCqAddList(String startDate, String endDate, String subCompanyIds, String departmentIds, String empIds, String empStatus, Map<String, Object> userManageInfo) {
|
|
|
|
|
private List<Map<String, Object>> getTemCqAddList(String startDate, String endDate, String subCompanyIds, String departmentIds, String empIds, String empStatus,
|
|
|
|
|
Map<String, Object> userManageInfo, Map<String, String> kqxmUnitInfo) {
|
|
|
|
|
String cqSql = "select a.* from uf_jcl_kq_cqjg a left join hrmresource b on a.ygid = b.id where a.rq >= '" + startDate +"'" + " and a.rq <= '" + endDate +"'";
|
|
|
|
|
if (!subCompanyIds.equals("")) {
|
|
|
|
|
cqSql = cqSql + " and a.fbid in (" + subCompanyIds + ")";
|
|
|
|
@ -1170,14 +1186,21 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS
|
|
|
|
|
if (!cqzt.equals("")) {
|
|
|
|
|
//匹配出勤状态对应的考勤项目id
|
|
|
|
|
String kqxmId = cqzt.equals("0") ? "1" : "5";
|
|
|
|
|
|
|
|
|
|
String groupKey = map.get("fbid") + "_" + map.get("bm") + "_" + map.get("ygid") + "_" + kqxmId;
|
|
|
|
|
Map<String,Object> itemMap = new HashMap<>();
|
|
|
|
|
itemMap.put("fbid", map.get("fbid"));
|
|
|
|
|
itemMap.put("bm", map.get("bm"));
|
|
|
|
|
itemMap.put("ygid", map.get("ygid"));
|
|
|
|
|
itemMap.put("xm", kqxmId);
|
|
|
|
|
itemMap.put("sc", "1");
|
|
|
|
|
if ("1".equals(kqxmId) && Util.null2String(kqxmUnitInfo.get("1")).equals(AccountingUnitEnum.HOUR.getKey())) {
|
|
|
|
|
itemMap.put("fbid", map.get("fbid"));
|
|
|
|
|
itemMap.put("bm", map.get("bm"));
|
|
|
|
|
itemMap.put("ygid", map.get("ygid"));
|
|
|
|
|
itemMap.put("xm", kqxmId);
|
|
|
|
|
itemMap.put("sc", Util.null2String(map.get("cqsc")));
|
|
|
|
|
} else {
|
|
|
|
|
itemMap.put("fbid", map.get("fbid"));
|
|
|
|
|
itemMap.put("bm", map.get("bm"));
|
|
|
|
|
itemMap.put("ygid", map.get("ygid"));
|
|
|
|
|
itemMap.put("xm", kqxmId);
|
|
|
|
|
itemMap.put("sc", "1");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (toDealCqDataWithGroup.get(groupKey) != null) {
|
|
|
|
|
toDealCqDataWithGroup.get(groupKey).add(itemMap);
|
|
|
|
|