考勤,出勤汇总功能优化

zm_dev
sy 1 year ago
parent fbcdecdf52
commit 9348686aca

@ -89,8 +89,8 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS
//插入汇总数据
List<List> dataList = new ArrayList<>();
String insertSql = " insert into uf_jcl_kq_cqhz_dt1(mainid,ry,kqxm," +
" lc,lf,ls,lt," +
" gzfb,gzbm) values(?,?,?,?,?,?,?,?,?)";
"lc,lf,ls,lt," +
"gzfb,gzbm) values(?,?,?,?,?,?,?,?,?)";
for (Map<String, String> map : addList) {
List<String> list = new ArrayList<>();
list.add(mainId);
@ -100,8 +100,8 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS
list.add(map.get("lf"));
list.add(map.get("ls"));
list.add(map.get("lt"));
list.add(map.get("gzfb"));
list.add(map.get("gzbm"));
list.add("".equals(map.get("gzfb")) ? null : map.get("gzfb"));
list.add("".equals(map.get("gzbm")) ? null : map.get("gzbm"));
dataList.add(list);
}
@ -230,6 +230,8 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS
dtDates = getDtDates(targetYear, targetMonth, status, subCompanyId, departmentId, resourceId);
} else {
//调用临时汇总数据方法,生成数据
jsonObj.put("fromDate", fromDate);
jsonObj.put("toDate", toDate);
dtDates = getTemAttendanceSummary(jsonObj);
}
bs.writeLog("dtDates_size : " + (dtDates==null ? "null" : dtDates.size()));
@ -280,8 +282,8 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS
}
});
//分页处理
int start = pageIndex * pageSize;
int end = Math.min((pageIndex + 1) * pageSize, dataList.size());
int start = (pageIndex - 1) * pageSize;
int end = Math.min(pageIndex * pageSize, dataList.size());
List<Map<String, String>> resultList = new ArrayList<>();
if (start <= dataList.size()) {
resultList = dataList.subList(start, end);
@ -292,8 +294,8 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS
} else {
pageCount = count / pageSize + ((count % pageSize > 0) ? 1 : 0);
}
isHaveNext = (pageIndex + 1 <= pageCount) ? 1 : 0;
isHavePre = (pageIndex - 1 >= 1) ? 1 : 0;
isHaveNext = (pageIndex <= pageCount) ? 1 : 0;
isHavePre = (pageIndex >= 1) ? 1 : 0;
List<Object> lsHolidays = KQHolidaySetBiz.getHolidaySetListByScope(""+user.getUID(),fromDate,toDate);
retmap.put("holidays", lsHolidays);
@ -340,8 +342,12 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS
}
bs.writeLog("mainIds : " + mainIds);
String dtListSql = "select * from uf_jcl_kq_cqhz_dt1 a left join hrmresource b on a.ry = b.id where 1=1";
if (!status.equals("") && !status.equals("9")) {
dtListSql = dtListSql + " and b.status = " + status;
if(status.length()>0){
if (!status.equals("8") && !status.equals("9")) {
dtListSql += " and b.status = "+status+ "";
}else if (status.equals("8")) {
dtListSql += " and (b.status = 0 or b.status = 1 or b.status = 2 or b.status = 3) ";
}
}
if (!subCompanyIds.equals("")) {
dtListSql = dtListSql + " and a.gzfb in (" + subCompanyIds + ")";
@ -643,6 +649,13 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS
}
}
//获取考勤项目和核算单位的映射
Map<String, String> hsdwInfoMap = new HashMap<>();
String kqxmSql = "select * from uf_jcl_kq_kqxm";
List<Map<String,Object>> kqxmData = DbTools.getSqlToList(kqxmSql);
for(Map<String,Object> kqxmMap : kqxmData) {
hsdwInfoMap.put(kqxmMap.get("id").toString(), Util.null2String(kqxmMap.get("hsdw")));
}
//处理分组好的数据
List<Map<String, String>> cqAddList = new ArrayList<>();
for(List<Map<String,Object>> list : toDealCqDataWithGroup.values()) {
@ -654,9 +667,9 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS
int num = 0;
double time = 0;
//查询考勤项目核算单位:天,小时,分钟,次,即0123
String kqxmSql = "select * from uf_jcl_kq_kqxm where id = " + kqxm;
Map<String,Object> kqxmData = DbTools.getSqlToMap(kqxmSql);
String accountUnit = Util.null2String(kqxmData.get("hsdw"));
// String kqxmSql = "select * from uf_jcl_kq_kqxm where id = " + kqxm;
// Map<String,Object> kqxmData = DbTools.getSqlToMap(kqxmSql);
String accountUnit = Util.null2String(hsdwInfoMap.get(kqxm));
//汇总区间数据
for (Map<String, Object> map : list) {
if (!accountUnit.equals("3")) {
@ -803,7 +816,7 @@ 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) {
String cqSql = "select a.* from uf_jcl_kq_cqjg a left join hrmresource b on a.ygid = b.id where b.status = " + empStatus + " and a.rq >= '" + startDate +"'" + " and a.rq <= '" + endDate +"'";
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 + ")";
}
@ -813,6 +826,13 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS
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<>();
@ -1077,7 +1097,7 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS
String bdkSql = "select a.*, b.fbid, b.bm from uf_jcl_kq_bdkjl a " +
"left join uf_jcl_kq_cqjg b on a.bdkry = b.ygid and a.dkrq = b.rq " +
"left join hrmresource c on a.bdkry = c.id " +
"where c.status = " + empStatus + " and a.dkrq >= '" + startDate +"'" + " and a.dkrq <= '" + endDate +"'";
"where a.dkrq >= '" + startDate +"'" + " and a.dkrq <= '" + endDate +"'";
if (!subCompanyIds.equals("")) {
bdkSql = bdkSql + " and b.fbid in (" + subCompanyIds + ")";
}
@ -1087,6 +1107,13 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS
if (!empIds.equals("")) {
bdkSql = bdkSql + " and a.bdkry in (" + empIds + ")";
}
if(empStatus.length()>0){
if (!empStatus.equals("8") && !empStatus.equals("9")) {
bdkSql += " and c.status = "+empStatus+ "";
}else if (empStatus.equals("8")) {
bdkSql += " and (c.status = 0 or c.status = 1 or c.status = 2 or c.status = 3) ";
}
}
List<Map<String,Object>> bdkDates = DbTools.getSqlToList(bdkSql);
//先根据分部、部门、人员、项目分组
Map<String, List<Map<String,Object>>> toDealBdkDataWithGroup = new HashMap<>();
@ -1133,7 +1160,7 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS
String cqjtSql = "select a.*, b.fbid, b.bm from uf_jcl_kq_cqjt a " +
"left join uf_jcl_kq_cqjg b on a.yg = b.ygid and a.rq = b.rq " +
"left join hrmresource c on a.yg = c.id " +
"where c.status = " + empStatus + " and a.rq >= '" + startDate +"'" + " and a.rq <= '" + endDate +"'";
"where a.rq >= '" + startDate +"'" + " and a.rq <= '" + endDate +"'";
if (!subCompanyIds.equals("")) {
cqjtSql = cqjtSql + " and b.fbid in (" + subCompanyIds + ")";
}
@ -1143,6 +1170,13 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS
if (!empIds.equals("")) {
cqjtSql = cqjtSql + " and a.yg in (" + empIds + ")";
}
if(empStatus.length()>0){
if (!empStatus.equals("8") && !empStatus.equals("9")) {
cqjtSql += " and c.status = "+empStatus+ "";
}else if (empStatus.equals("8")) {
cqjtSql += " and (c.status = 0 or c.status = 1 or c.status = 2 or c.status = 3) ";
}
}
List<Map<String,Object>> cqjtDates = DbTools.getSqlToList(cqjtSql);
//先根据分部、部门、人员、项目分组
Map<String, List<Map<String,Object>>> toDealCqjtDataWithGroup = new HashMap<>();

Loading…
Cancel
Save