From 9348686aca1ac0f5c67c041aa7a9ac37df47a5c7 Mon Sep 17 00:00:00 2001 From: sy Date: Wed, 24 Apr 2024 11:04:32 +0800 Subject: [PATCH] =?UTF-8?q?=E8=80=83=E5=8B=A4=EF=BC=8C=E5=87=BA=E5=8B=A4?= =?UTF-8?q?=E6=B1=87=E6=80=BB=E5=8A=9F=E8=83=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/AttendanceSummaryServiceImpl.java | 66 ++++++++++++++----- 1 file changed, 50 insertions(+), 16 deletions(-) diff --git a/src/com/engine/attendance/workflow/service/impl/AttendanceSummaryServiceImpl.java b/src/com/engine/attendance/workflow/service/impl/AttendanceSummaryServiceImpl.java index 53bb059..9a3f158 100644 --- a/src/com/engine/attendance/workflow/service/impl/AttendanceSummaryServiceImpl.java +++ b/src/com/engine/attendance/workflow/service/impl/AttendanceSummaryServiceImpl.java @@ -89,8 +89,8 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS //插入汇总数据 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 map : addList) { List 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> 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 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 hsdwInfoMap = new HashMap<>(); + String kqxmSql = "select * from uf_jcl_kq_kqxm"; + List> kqxmData = DbTools.getSqlToList(kqxmSql); + for(Map kqxmMap : kqxmData) { + hsdwInfoMap.put(kqxmMap.get("id").toString(), Util.null2String(kqxmMap.get("hsdw"))); + } //处理分组好的数据 List> cqAddList = new ArrayList<>(); for(List> list : toDealCqDataWithGroup.values()) { @@ -654,9 +667,9 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS int num = 0; double time = 0; //查询考勤项目核算单位:天,小时,分钟,次,即0,1,2,3 - String kqxmSql = "select * from uf_jcl_kq_kqxm where id = " + kqxm; - Map kqxmData = DbTools.getSqlToMap(kqxmSql); - String accountUnit = Util.null2String(kqxmData.get("hsdw")); +// String kqxmSql = "select * from uf_jcl_kq_kqxm where id = " + kqxm; +// Map kqxmData = DbTools.getSqlToMap(kqxmSql); + String accountUnit = Util.null2String(hsdwInfoMap.get(kqxm)); //汇总区间数据 for (Map map : list) { if (!accountUnit.equals("3")) { @@ -803,7 +816,7 @@ public class AttendanceSummaryServiceImpl extends Service implements AttendanceS //临时汇总出勤结果表 private List> 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> cqDates = DbTools.getSqlToList(cqSql); //先根据分部、部门、人员、项目分组 Map>> 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> bdkDates = DbTools.getSqlToList(bdkSql); //先根据分部、部门、人员、项目分组 Map>> 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> cqjtDates = DbTools.getSqlToList(cqjtSql); //先根据分部、部门、人员、项目分组 Map>> toDealCqjtDataWithGroup = new HashMap<>();