|
|
|
@ -14,6 +14,8 @@ import com.engine.kq.biz.KQHolidaySetBiz;
|
|
|
|
|
import com.engine.kq.biz.KQReportBiz;
|
|
|
|
|
import com.engine.kq.util.ExcelUtil;
|
|
|
|
|
import com.engine.kq.util.PageUidFactory;
|
|
|
|
|
import com.google.common.collect.Sets;
|
|
|
|
|
import org.apache.xpath.operations.Bool;
|
|
|
|
|
import weaver.conn.RecordSet;
|
|
|
|
|
import weaver.general.BaseBean;
|
|
|
|
|
import weaver.general.TimeUtil;
|
|
|
|
@ -221,8 +223,23 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS
|
|
|
|
|
column.put("width", 105);
|
|
|
|
|
column.put("showDetial", "1");
|
|
|
|
|
columns.add(column);
|
|
|
|
|
//获取要查询的考勤项目id
|
|
|
|
|
String queryKqxmIds = Util.null2String(jsonObj.get("columns"));
|
|
|
|
|
queryKqxmIds = queryKqxmIds.replace("kqxm_", "");
|
|
|
|
|
List<String> kqxmIdList = Arrays.asList(queryKqxmIds.split(","));
|
|
|
|
|
if (queryKqxmIds.equals("") || kqxmIdList.size() == 0) {
|
|
|
|
|
retmap.put("columns",columns);
|
|
|
|
|
retmap.put("datas", new ArrayList<>());
|
|
|
|
|
retmap.put("pagesize", pageSize);
|
|
|
|
|
retmap.put("pageindex", pageIndex);
|
|
|
|
|
retmap.put("count", 0);
|
|
|
|
|
retmap.put("pagecount", 0);
|
|
|
|
|
retmap.put("ishavepre", 1);
|
|
|
|
|
retmap.put("ishavenext", 0);
|
|
|
|
|
return retmap;
|
|
|
|
|
}
|
|
|
|
|
//考勤项目
|
|
|
|
|
String kqxmSql = "select * from uf_jcl_kq_kqxm";
|
|
|
|
|
String kqxmSql = "select * from uf_jcl_kq_kqxm where id in (" + String.join(",", kqxmIdList) + ")";
|
|
|
|
|
List<Map<String,Object>> kqxmDates = DbTools.getSqlToList(kqxmSql);
|
|
|
|
|
for(Map<String,Object> kqxm : kqxmDates) {
|
|
|
|
|
String unit = getKqxmUnit(Util.null2String(kqxm.get("hsdw")));
|
|
|
|
@ -240,6 +257,8 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS
|
|
|
|
|
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"))));
|
|
|
|
|
//收集考勤项目id-考勤项目名称映射
|
|
|
|
|
Map<String, String> kqxmMcInfo = kqxmDates.stream().collect(Collectors.toMap(e->Util.null2String(e.get("id")),e->Util.null2String(e.get("mc"))));
|
|
|
|
|
//获取列表结果,typeSelect为9、10时查询出勤汇总明细表数据,其他则生成临时汇总数据
|
|
|
|
|
List<Map<String,Object>> dtDates = null;
|
|
|
|
|
LocalDate targetDate = LocalDate.now(); // 获取当前日期
|
|
|
|
@ -248,18 +267,18 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS
|
|
|
|
|
String targetYear = String.valueOf(targetDate.getYear());
|
|
|
|
|
String targetMonth = String.valueOf(targetDate.getMonthValue());
|
|
|
|
|
bs.writeLog("targetYear : " + targetYear + ", targetMonth : " + targetMonth);
|
|
|
|
|
dtDates = getDtDates(targetYear, targetMonth, status, subCompanyId, departmentId, resourceId);
|
|
|
|
|
dtDates = getDtDates(targetYear, targetMonth, status, subCompanyId, departmentId, resourceId, kqxmIdList);
|
|
|
|
|
} else if (typeSelect.equals("10")) {
|
|
|
|
|
targetDate = targetDate.minusMonths(1);
|
|
|
|
|
String targetYear = String.valueOf(targetDate.getYear());
|
|
|
|
|
String targetMonth = String.valueOf(targetDate.getMonthValue());
|
|
|
|
|
bs.writeLog("targetYear : " + targetYear + ", targetMonth : " + targetMonth);
|
|
|
|
|
dtDates = getDtDates(targetYear, targetMonth, status, subCompanyId, departmentId, resourceId);
|
|
|
|
|
dtDates = getDtDates(targetYear, targetMonth, status, subCompanyId, departmentId, resourceId, kqxmIdList);
|
|
|
|
|
} else {
|
|
|
|
|
//调用临时汇总数据方法,生成数据
|
|
|
|
|
jsonObj.put("fromDate", fromDate);
|
|
|
|
|
jsonObj.put("toDate", toDate);
|
|
|
|
|
dtDates = getTemAttendanceSummary(jsonObj, kqxmUnitInfo);
|
|
|
|
|
dtDates = getTemAttendanceSummary(jsonObj, kqxmUnitInfo, kqxmMcInfo, kqxmIdList);
|
|
|
|
|
}
|
|
|
|
|
bs.writeLog("dtDates_size : " + (dtDates==null ? "null" : dtDates.size()));
|
|
|
|
|
//处理明细表数据,分组生成列表数据
|
|
|
|
@ -439,13 +458,14 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS
|
|
|
|
|
Map<String, Object> retmap = new HashMap<>();
|
|
|
|
|
String sql = "";
|
|
|
|
|
String viewName = "v_attdaily";
|
|
|
|
|
String viewNameCapital = "V_ATTDAILY";
|
|
|
|
|
//判断视图v_attdaily是否存在
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
String dbType = rs.getDBType();
|
|
|
|
|
if ("mysql".equals(dbType) || "postgresql".equals(dbType) || "sqlserver".equals(dbType) || "dm".equals(dbType) || "st".equals(dbType)) {
|
|
|
|
|
sql = "SELECT * FROM information_schema.views WHERE table_name = '" + viewName + "'";
|
|
|
|
|
} else if ("oracle".equals(dbType)) {
|
|
|
|
|
sql = "SELECT * FROM ALL_VIEWS WHERE VIEW_NAME = '" + viewName + "'";
|
|
|
|
|
sql = "SELECT * FROM ALL_VIEWS WHERE VIEW_NAME = '" + viewNameCapital + "'";
|
|
|
|
|
} else if ("jc".equals(dbType)) {
|
|
|
|
|
sql = "SELECT * FROM sys.views WHERE viewname = '" + viewName + "'";
|
|
|
|
|
} else {
|
|
|
|
@ -571,7 +591,7 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<Map<String,Object>> getDtDates(String targetYear, String targetMonth, String status, String subCompanyIds, String depIds, String empIds) {
|
|
|
|
|
private List<Map<String,Object>> getDtDates(String targetYear, String targetMonth, String status, String subCompanyIds, String depIds, String empIds, List<String> kqxmIdList) {
|
|
|
|
|
//20240528需求变更,
|
|
|
|
|
// 当前登录人员为人员分组管理员时,取其管理的人员明细(人员id,生效日期,失效日期)来筛选待汇总的数据;
|
|
|
|
|
// 当前登录人员非人员分组管理员时,取其下属的人员id来筛选待汇总的数据
|
|
|
|
@ -611,7 +631,7 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS
|
|
|
|
|
dtListSql = dtListSql + " and a.ry in (" + String.join(",",targetEmpIdList) + ")";
|
|
|
|
|
}
|
|
|
|
|
if (mainIds.size() > 0) {
|
|
|
|
|
dtListSql = dtListSql + " and a.mainid in (" + String.join(",", mainIds) + ")";
|
|
|
|
|
dtListSql = dtListSql + " and a.mainid in (" + String.join(",", mainIds) + ") and a.kqxm in (" + String.join(",", kqxmIdList) + ")";
|
|
|
|
|
List<Map<String,Object>> dtDates = DbTools.getSqlToList(dtListSql);
|
|
|
|
|
bs.writeLog("dtDates_size : " + dtDates.size() + ", dtListSql : " + dtListSql);
|
|
|
|
|
return dtDates;
|
|
|
|
@ -679,7 +699,7 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS
|
|
|
|
|
* @param params
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public List<Map<String, Object>> getTemAttendanceSummary(Map<String, Object> params, Map<String, String> kqxmUnitInfo) {
|
|
|
|
|
public List<Map<String, Object>> getTemAttendanceSummary(Map<String, Object> params, Map<String, String> kqxmUnitInfo, Map<String, String> kqxmMcInfo, List<String> kqxmIdList) {
|
|
|
|
|
|
|
|
|
|
bs.writeLog("params : " + params);
|
|
|
|
|
List<Map<String, Object>> addList = new ArrayList<>();
|
|
|
|
@ -714,23 +734,30 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS
|
|
|
|
|
Map<String, Object> userManageInfo = getUserManageInfo();
|
|
|
|
|
if (!startDate.equals("") && !endDate.equals("")) {
|
|
|
|
|
//临时汇总出勤结果表、补打卡表、出勤津贴表数据
|
|
|
|
|
//出勤结果表
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
//补打卡表
|
|
|
|
|
List<Map<String, Object>> bdkAddList = getTemBdkAddList(startDate, endDate, subCompanyIds, departmentIds, empIds, empStatus, userManageInfo);
|
|
|
|
|
bs.writeLog("bdkAddList_size : " + bdkAddList.size());
|
|
|
|
|
if (bdkAddList.size() > 0) {
|
|
|
|
|
addList.addAll(bdkAddList);
|
|
|
|
|
}
|
|
|
|
|
//出勤津贴表
|
|
|
|
|
List<Map<String, Object>> cqjtAddList = getTemCqjtAddList(startDate, endDate, subCompanyIds, departmentIds, empIds, empStatus, userManageInfo);
|
|
|
|
|
bs.writeLog("cqjtAddList_size : " + cqjtAddList.size());
|
|
|
|
|
if (cqjtAddList.size() > 0) {
|
|
|
|
|
addList.addAll(cqjtAddList);
|
|
|
|
|
// //出勤结果表
|
|
|
|
|
// 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);
|
|
|
|
|
// }
|
|
|
|
|
// //补打卡表
|
|
|
|
|
// List<Map<String, Object>> bdkAddList = getTemBdkAddList(startDate, endDate, subCompanyIds, departmentIds, empIds, empStatus, userManageInfo);
|
|
|
|
|
// bs.writeLog("bdkAddList_size : " + bdkAddList.size());
|
|
|
|
|
// if (bdkAddList.size() > 0) {
|
|
|
|
|
// addList.addAll(bdkAddList);
|
|
|
|
|
// }
|
|
|
|
|
// //出勤津贴表
|
|
|
|
|
// List<Map<String, Object>> cqjtAddList = getTemCqjtAddList(startDate, endDate, subCompanyIds, departmentIds, empIds, empStatus, userManageInfo);
|
|
|
|
|
// bs.writeLog("cqjtAddList_size : " + cqjtAddList.size());
|
|
|
|
|
// if (cqjtAddList.size() > 0) {
|
|
|
|
|
// addList.addAll(cqjtAddList);
|
|
|
|
|
// }
|
|
|
|
|
//考勤日报视图
|
|
|
|
|
List<Map<String, Object>> dailyKqAddList = getTemDailyKqAddList(startDate, endDate, subCompanyIds, departmentIds, empIds, empStatus, userManageInfo,
|
|
|
|
|
kqxmUnitInfo, kqxmMcInfo, kqxmIdList);
|
|
|
|
|
bs.writeLog("dailyKqAddList_size : " + dailyKqAddList.size());
|
|
|
|
|
if (dailyKqAddList.size() > 0) {
|
|
|
|
|
addList.addAll(dailyKqAddList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -1444,6 +1471,133 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS
|
|
|
|
|
return cqAddList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//临时汇总考勤日报表
|
|
|
|
|
private List<Map<String, Object>> getTemDailyKqAddList(String startDate, String endDate, String subCompanyIds, String departmentIds, String empIds, String empStatus,
|
|
|
|
|
Map<String, Object> userManageInfo, Map<String, String> kqxmUnitInfo, Map<String, String> kqxmMcInfo, List<String> kqxmIdList) {
|
|
|
|
|
String cqSql = "select a.* from v_attdaily 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 + ")";
|
|
|
|
|
}
|
|
|
|
|
if (!departmentIds.equals("")) {
|
|
|
|
|
cqSql = cqSql + " and a.bm in (" + departmentIds + ")";
|
|
|
|
|
}
|
|
|
|
|
if (!empIds.equals("")) {
|
|
|
|
|
cqSql = cqSql + " and a.ygid in (" + empIds + ")";
|
|
|
|
|
}
|
|
|
|
|
if(empStatus.length()>0){
|
|
|
|
|
if (!empStatus.equals("8") && !empStatus.equals("9")) {
|
|
|
|
|
cqSql += " and b.status = "+empStatus+ "";
|
|
|
|
|
}else if (empStatus.equals("8")) {
|
|
|
|
|
cqSql += " and (b.status = 0 or b.status = 1 or b.status = 2 or b.status = 3) ";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
List<Map<String,Object>> cqDates = DbTools.getSqlToList(cqSql);
|
|
|
|
|
//先根据分部、部门、人员、项目分组
|
|
|
|
|
Map<String, List<Map<String,Object>>> toDealCqDataWithGroup = new HashMap<>();
|
|
|
|
|
//判断单一人员所有查询的考勤项目是否存在都为0的情况,存在则不输出查询结果,不存在则记录人员的groupKey在下面对象
|
|
|
|
|
Map<String, Boolean> finalRecordEmpInfo = new HashMap<>();
|
|
|
|
|
//将考勤项目id转为“名称”+“_c/t/s/f”
|
|
|
|
|
Map<String, String> kqxmMcUnitInfo = kqxmIdToMcUnit(kqxmIdList, kqxmUnitInfo, kqxmMcInfo);
|
|
|
|
|
String groupKey;
|
|
|
|
|
Map<String,Object> itemMap;
|
|
|
|
|
for (Map<String,Object> map : cqDates) {
|
|
|
|
|
//20240528需求变更,校验当前登录人是否有权限查看相关数据
|
|
|
|
|
if (!checkViewAuth(userManageInfo, map.get("rq").toString(), map.get("ygid").toString())) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
//遍历需要查询的考勤项目名称信息
|
|
|
|
|
String scValue = "";
|
|
|
|
|
for (Map.Entry<String, String> entry : kqxmMcUnitInfo.entrySet()) {
|
|
|
|
|
scValue = Util.null2String(map.get(entry.getValue()));
|
|
|
|
|
if ("".equals(scValue) || "0".equals(scValue) || "0.00".equals(scValue)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
groupKey = map.get("fbid") + "_" + map.get("bm") + "_" + map.get("ygid") + "_" + entry.getKey();
|
|
|
|
|
finalRecordEmpInfo.put(groupKey, true);
|
|
|
|
|
|
|
|
|
|
itemMap = new HashMap<>();
|
|
|
|
|
itemMap.put("fbid", map.get("fbid"));
|
|
|
|
|
itemMap.put("bm", map.get("bm"));
|
|
|
|
|
itemMap.put("ygid", map.get("ygid"));
|
|
|
|
|
itemMap.put("xm", entry.getKey());
|
|
|
|
|
itemMap.put("sc", scValue);
|
|
|
|
|
|
|
|
|
|
if (toDealCqDataWithGroup.get(groupKey) != null) {
|
|
|
|
|
toDealCqDataWithGroup.get(groupKey).add(itemMap);
|
|
|
|
|
} else {
|
|
|
|
|
List<Map<String,Object>> list = new ArrayList<>();
|
|
|
|
|
list.add(itemMap);
|
|
|
|
|
toDealCqDataWithGroup.put(groupKey, list);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//处理分组好的数据
|
|
|
|
|
List<Map<String, Object>> dailyKqAddList = new ArrayList<>();
|
|
|
|
|
for(List<Map<String,Object>> list : toDealCqDataWithGroup.values()) {
|
|
|
|
|
String ry = list.get(0).get("ygid").toString();
|
|
|
|
|
String kqxm = list.get(0).get("xm").toString();
|
|
|
|
|
String gsfb = list.get(0).get("fbid").toString();
|
|
|
|
|
String gsbm = list.get(0).get("bm").toString();
|
|
|
|
|
|
|
|
|
|
int num = 0;
|
|
|
|
|
double time = 0;
|
|
|
|
|
String accountUnit = kqxmUnitInfo.get(kqxm);
|
|
|
|
|
//汇总区间数据
|
|
|
|
|
for (Map<String, Object> map : list) {
|
|
|
|
|
if (!accountUnit.equals(AccountingUnitEnum.ONCE.getKey())) {
|
|
|
|
|
num++;
|
|
|
|
|
double sc = Util.null2String(map.get("sc")).equals("") ? 0 : Double.parseDouble(map.get("sc").toString());
|
|
|
|
|
time += sc;
|
|
|
|
|
} else {
|
|
|
|
|
num ++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//设置出勤汇总子表数据
|
|
|
|
|
itemMap = new HashMap<>();
|
|
|
|
|
itemMap.put("ry", ry);
|
|
|
|
|
itemMap.put("kqxm", kqxm);
|
|
|
|
|
itemMap.put("gzfb", gsfb);
|
|
|
|
|
itemMap.put("gzbm", gsbm);
|
|
|
|
|
itemMap.put("lc", String.valueOf(num));
|
|
|
|
|
if (accountUnit.equals(AccountingUnitEnum.DAY.getKey())) {
|
|
|
|
|
itemMap.put("lt", String.format("%.2f", time));
|
|
|
|
|
}
|
|
|
|
|
if (accountUnit.equals(AccountingUnitEnum.HOUR.getKey())) {
|
|
|
|
|
itemMap.put("ls", String.format("%.2f", time));
|
|
|
|
|
}
|
|
|
|
|
if (accountUnit.equals(AccountingUnitEnum.MINUTES.getKey())) {
|
|
|
|
|
itemMap.put("lf", String.format("%.2f", time));
|
|
|
|
|
}
|
|
|
|
|
dailyKqAddList.add(itemMap);
|
|
|
|
|
}
|
|
|
|
|
return dailyKqAddList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Map<String, String> kqxmIdToMcUnit(List<String> kqxmIdList, Map<String, String> kqxmUnitInfo, Map<String, String> kqxmMcInfo) {
|
|
|
|
|
Map<String, String>result = new HashMap<>();
|
|
|
|
|
String unit = "";
|
|
|
|
|
String mc = "";
|
|
|
|
|
for (String kqxmId : kqxmIdList) {
|
|
|
|
|
unit = Util.null2String(kqxmUnitInfo.get(kqxmId));
|
|
|
|
|
mc = Util.null2String(kqxmMcInfo.get(kqxmId));
|
|
|
|
|
if ("".equals(unit) || "".equals(mc)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (unit.equals(AccountingUnitEnum.DAY.getKey())) {
|
|
|
|
|
result.put(kqxmId, mc + "_t");
|
|
|
|
|
} else if (unit.equals(AccountingUnitEnum.HOUR.getKey())) {
|
|
|
|
|
result.put(kqxmId, mc + "_s");
|
|
|
|
|
} else if (unit.equals(AccountingUnitEnum.MINUTES.getKey())) {
|
|
|
|
|
result.put(kqxmId, mc + "_f");
|
|
|
|
|
} else if (unit.equals(AccountingUnitEnum.ONCE.getKey())) {
|
|
|
|
|
result.put(kqxmId, mc + "_c");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean checkViewAuth(Map<String, Object> userManageInfo, String rq, String empId) {
|
|
|
|
|
if (empId.equals(String.valueOf(user.getUID()))) {
|
|
|
|
|
return true;
|
|
|
|
|