diff --git a/src/com/engine/kq/biz/KQFormatData.java b/src/com/engine/kq/biz/KQFormatData.java index 0d71ddd..f99a049 100644 --- a/src/com/engine/kq/biz/KQFormatData.java +++ b/src/com/engine/kq/biz/KQFormatData.java @@ -86,7 +86,7 @@ public class KQFormatData extends BaseBean { //没有考勤组不需格式化 return resultMap; } - if (workTime == null || workTime.getWorkMins() == 0) { + if (workTime == null || (workTime.getWorkMins() == 0 && workTime.getRestShift() != 1)) { kqLog.info("workTime == null || workTime.getWorkMins() == 0 插入空记录"); nonlsParam = new ArrayList<>(); formatNonWork(userId, kqDate, nonlsParam, workTime, workFlowInfo); @@ -133,8 +133,8 @@ public class KQFormatData extends BaseBean { " resourceid,kqdate,groupid,serialid,serialnumber,workbegindate,workbegintime,workenddate,workendtime,workmins," + " signindate,signintime,signinid,signoutdate,signouttime,signoutid,signMins," + " attendanceMins,belatemins,graveBeLateMins,leaveearlymins,graveLeaveEarlyMins,absenteeismmins,forgotcheckMins," + - " leaveMins,leaveinfo,evectionMins,outMins,forgotbeginworkcheckmins,otherinfo" + (definedField.length() > 0 ? "," + definedField + "" : "") + ") " + - " values(?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?,?,?,?" + (definedField.length() > 0 ? "," + definedParam + "" : "") + ")"; + " leaveMins,leaveinfo,evectionMins,outMins,forgotbeginworkcheckmins,otherinfo,flowinfo" + (definedField.length() > 0 ? "," + definedField + "" : "") + ") " + + " values(?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?" + (definedField.length() > 0 ? "," + definedParam + "" : "") + ")"; for (int i = 0; i < lsParam.size(); i++) { List param = lsParam.get(i); boolean isok = rs.executeUpdate(sql, param); @@ -147,8 +147,12 @@ public class KQFormatData extends BaseBean { " leaveMins,evectionMins,outMins,forgotbeginworkcheck,forgotbeginworkcheckmins" + (definedField.length() > 0 ? "," + definedField + "" : "") + ") " + " select a.resourceid,kqdate,b.subcompanyid1,b.departmentid,b.jobtitle,groupid,serialid," + " case when sum(workmins)>0 then 1 end as workdays, sum(workmins) as workmins," + - " cast(sum(attendanceMins)AS decimal(10, 2))/sum(workmins) as attendancedays, sum(attendanceMins) as attendanceMins," + - " cast(sum(signmins)AS decimal(10, 2))/sum(workmins) as signdays, sum(signmins) as signmins," + + " case when sum(workmins)>0 then cast(sum(attendanceMins)AS decimal(10, 2))/sum(workmins) else 0 end as attendancedays, sum(attendanceMins) as attendanceMins," + +// " cast(sum(attendanceMins)AS decimal(10, 2))/sum(workmins) as attendancedays, sum(attendanceMins) as attendanceMins," + + + " case when sum(workmins)>0 then cast(sum(signmins)AS decimal(10, 2))/sum(workmins) else 0 end as signdays, sum(signmins) as signmins," + +// " cast(sum(signmins)AS decimal(10, 2))/sum(workmins) as signdays, sum(signmins) as signmins," + + " sum(case when belatemins> 0 then 1 else 0 end) as belate,sum(belatemins) as belatemins," + " sum(case when graveBeLateMins> 0 then 1 else 0 end) as graveBeLate,sum(graveBeLateMins) as graveBeLateMins," + " sum(case when leaveearlymins> 0 then 1 else 0 end) as leaveearly,sum(leaveearlymins) as leaveearlymins," + @@ -193,11 +197,13 @@ public class KQFormatData extends BaseBean { List lsRestTime = new ArrayList<>(); List workFlow = null; + int workminsNew = 0; if (workTime != null) { lsSignTime = workTime.getSignTime();//允许打卡时间 lsWorkTime = workTime.getWorkTime();//工作时间 lsRestTime = workTime.getRestTime();//休息时段时间 oneSign = lsWorkTime != null && lsWorkTime.size() == 1; + workminsNew = workTime.getWorkMins(); } int[] dayMins = new int[2880];//一天所有分钟数 @@ -279,6 +285,8 @@ public class KQFormatData extends BaseBean { //用来计算实际打卡时长用的 int signInTimeIndx4Sign = -1; int signInTimeOutdx4Sign = -1; + Map flowinfo = new HashMap<>();//流程信息 + String signBeginDateTime = signTimeScope.getBeginTimeAcross() ? nextDate : kqDate; if (signTimeScope.isBeginTimePreAcross()) { @@ -543,7 +551,7 @@ public class KQFormatData extends BaseBean { if (workFlowInfo.get(dateKey) != null) { workFlow = (List) workFlowInfo.get(dateKey); } - + List flowList = Lists.newArrayList(); for (int j = 0; workFlow != null && j < workFlow.size(); j++) { Map data = (Map) workFlow.get(j); String flowType = Util.null2String(data.get("flowtype")); @@ -551,11 +559,27 @@ public class KQFormatData extends BaseBean { String signtype = Util.null2String(data.get("signtype")); String serial = Util.null2String(data.get("serial")); String requestId = Util.null2String(data.get("requestId")); - beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(Util.null2String(data.get("begintime"))); - endIdx = kqTimesArrayComInfo.getArrayindexByTimes(Util.null2String(data.get("endtime"))); +// beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(Util.null2String(data.get("begintime"))); +// endIdx = kqTimesArrayComInfo.getArrayindexByTimes(Util.null2String(data.get("endtime"))); + String begintime = Util.null2String(data.get("begintime")); + String endtime = Util.null2String(data.get("endtime")); + beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(begintime); + endIdx = kqTimesArrayComInfo.getArrayindexByTimes(endtime); if (beginIdx >= endIdx) { continue; } + Map flowMap = Maps.newHashMap(); + flowMap.put("newLeaveType", newLeaveType); + flowMap.put("begintime", begintime); + flowMap.put("endtime", endtime); + List> flowMapList = Lists.newArrayList(); + if(flowinfo.containsKey(flowType)){ + List> tmpFlowMapList = (List>) flowinfo.get(flowType); + tmpFlowMapList.add(flowMap); + }else{ + flowMapList.add(flowMap); + flowinfo.put(flowType, flowMapList); + } if (flowType.equals(FlowReportTypeEnum.EVECTION.getFlowType())) { Arrays.fill(dayMins, beginIdx, endIdx, 7);//出差抵扣时段标识 7 @@ -746,7 +770,7 @@ public class KQFormatData extends BaseBean { forgotCheckMins = 0; } - if (workTime.getIsExclude()) {//无需考勤人员没有异常状态 + if (workminsNew == 0 || workTime.getIsExclude()) {//无需考勤人员没有异常状态 beLateMins = 0; graveBeLateMins = 0; leaveEarlyMins = 0; @@ -786,9 +810,14 @@ public class KQFormatData extends BaseBean { if ("0".equals(nosign_is_absent)) { attendanceMins = attendanceMins - forgotCheckMins - forgotBeginWorkCheckMins; } - if (beforeBegin || attendanceMins < 0) {//还未到上班时间,不用计算任何状体 + if(workminsNew == 0) { attendanceMins = 0; + workMins = 0; } + if(beforeBegin || attendanceMins < 0) {//还未到上班时间,不用计算任何状体 + attendanceMins = 0; + } + kqLog.info("实际出勤计算公式" + "实际出勤=应出勤- 旷工-请假-迟到-早退 userId" + userId + "kqDate==" + kqDate + ":hostIps:" + hostIps + ":uuid::" + uuid); kqLog.info("实际出勤计算结果" + attendanceMins + "=" + workMins + "- " + absenteeismMins + "-" + leaveMins + "-" + (beLateMins + graveBeLateMins) + "-" + (leaveEarlyMins - graveLeaveEarlyMins) + " userId" + userId + "kqDate==" + kqDate + ":hostIps:" + hostIps + ":uuid::" + uuid); if (this.writeLog) { @@ -820,6 +849,10 @@ public class KQFormatData extends BaseBean { params.add(kqTimesArrayComInfo.turn48to24Time(ori_workBeginTime)); params.add(workEndDate); params.add(kqTimesArrayComInfo.turn48to24Time(ori_workEndTime)); + //二开 休班次 工作时长计算0 + if (workTime.getRestShift() == 1) { + workMins = 0; + } params.add(workMins); params.add(signInDate); params.add(signInTime); @@ -839,6 +872,7 @@ public class KQFormatData extends BaseBean { if (workTime.getRestShift() == 1 && absenteeismMins > 0) { absenteeismMins = 0; } + params.add(absenteeismMins); params.add(forgotCheckMins); params.add(leaveMins); @@ -847,6 +881,7 @@ public class KQFormatData extends BaseBean { params.add(outMins); params.add(forgotBeginWorkCheckMins); params.add(JSONObject.toJSONString(otherinfo)); + params.add(JSONObject.toJSONString(flowinfo)); Map definedFieldInfo = new KQFormatBiz().getDefinedField(); String[] definedFields = Util.splitString(Util.null2String(definedFieldInfo.get("definedField")), ","); diff --git a/src/com/engine/kq/biz/KQOverTimeRuleCalBiz.java b/src/com/engine/kq/biz/KQOverTimeRuleCalBiz.java index 143f6e7..33c194d 100644 --- a/src/com/engine/kq/biz/KQOverTimeRuleCalBiz.java +++ b/src/com/engine/kq/biz/KQOverTimeRuleCalBiz.java @@ -1225,7 +1225,7 @@ public class KQOverTimeRuleCalBiz { } } if(all_has_duration_min > 0){ - for(Entry me : hasCardMap.entrySet()){ + for(Map.Entry me : hasCardMap.entrySet()){ String cardKey = me.getKey(); String cardValue = me.getValue(); if(cardKey.equalsIgnoreCase(nowCardKey)){ diff --git a/src/com/engine/kq/biz/KQReportBiz.java b/src/com/engine/kq/biz/KQReportBiz.java index 3fad2bf..b0a84cc 100644 --- a/src/com/engine/kq/biz/KQReportBiz.java +++ b/src/com/engine/kq/biz/KQReportBiz.java @@ -1,8 +1,11 @@ package com.engine.kq.biz; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean; import com.engine.kq.cmd.attendanceButton.ButtonStatusEnum; +import com.engine.kq.enums.FlowReportTypeEnum; import com.engine.kq.enums.KqSplitFlowTypeEnum; import com.engine.kq.log.KQLog; import com.engine.kq.util.KQDurationCalculatorUtil; @@ -321,6 +324,97 @@ public class KQReportBiz extends BaseBean { return datas; } + /** + * 获取周六销假数据 + * @param params + * @param user + * @return + */ + public Map getSaturdayFlowLeaveBackData(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and b.resourceid in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + + sql = " select resourceid, newleavetype, durationrule, sum(duration) as val from hrmresource a, "+KqSplitFlowTypeEnum.LEAVEBACK.getTablename()+" b "+ + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' and (DATEPART(dw, belongdate) = 7 or DATEPART(dw, belongdate) = 1) and belongdate NOT IN (select holidayDate from KQ_HolidaySet where changeType = 3 AND groupid = groupId) " +sqlWhere + + " group by resourceid, newleavetype, durationrule "; + rs.execute(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + String newleavetype = rs.getString("newleavetype"); + String durationrule = rs.getString("durationrule"); + double value = rs.getDouble("val")<0?0:rs.getDouble("val"); + + double proportion = Util.getDoubleValue(kqLeaveRulesComInfo.getProportion(newleavetype)); + if(KQUnitBiz.isLeaveHour(newleavetype,kqLeaveRulesComInfo)){//按小时 + if(!KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value*proportion; + } + }else{//按天 + if(KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value/proportion; + } + } + + String key = resourceid+"|leavebackType_"+newleavetype; + if(datas.containsKey(key)){ + value += Util.getDoubleValue(Util.null2String(datas.get(key))); + } + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + datas.put(key,df.format(value)); + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + /** * 获取周六请假数据 * @param params @@ -379,7 +473,7 @@ public class KQReportBiz extends BaseBean { } sql = " select resourceid, newleavetype, durationrule, sum(duration) as val from hrmresource a, "+KqSplitFlowTypeEnum.LEAVE.getTablename()+" b "+ - " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' and (DATEPART(dw, belongdate) = 7 or DATEPART(dw, belongdate) = 1) " +sqlWhere + + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' and (DATEPART(dw, belongdate) = 7 or DATEPART(dw, belongdate) = 1) and belongdate NOT IN (select holidayDate from KQ_HolidaySet where changeType = 3 AND groupid = groupId) " +sqlWhere + " group by resourceid, newleavetype, durationrule "; rs.execute(sql); while (rs.next()) { @@ -416,6 +510,98 @@ public class KQReportBiz extends BaseBean { return datas; } + /** + * 获取每日销假数据 + * @param params + * @param user + * @return + */ + public Map getDailySaturdayFlowLeaveBackData(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and b.resourceid in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + + sql = " select resourceid, newleavetype, durationrule, sum(duration) as val,belongdate from hrmresource a, "+KqSplitFlowTypeEnum.LEAVEBACK.getTablename()+" b "+ + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' and (DATEPART(dw, belongdate) = 7 or DATEPART(dw, belongdate) = 1) and belongdate NOT IN (select holidayDate from KQ_HolidaySet where changeType = 3 AND groupid = groupId) " +sqlWhere + + " group by resourceid, newleavetype, durationrule,belongdate "; + rs.execute(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + String belongdate = rs.getString("belongdate"); + String newleavetype = rs.getString("newleavetype"); + String durationrule = rs.getString("durationrule"); + double value = rs.getDouble("val")<0?0:rs.getDouble("val"); + + double proportion = Util.getDoubleValue(kqLeaveRulesComInfo.getProportion(newleavetype)); + if(KQUnitBiz.isLeaveHour(newleavetype,kqLeaveRulesComInfo)){//按小时 + if(!KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value*proportion; + } + }else{//按天 + if(KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value/proportion; + } + } + + String key = resourceid+"|"+belongdate+"|leavebackType_"+newleavetype; + if(datas.containsKey(key)){ + value += Util.getDoubleValue(Util.null2String(datas.get(key))); + } + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + datas.put(key,df.format(value)); + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + /** * 获取周六请假数据 * @param params @@ -473,7 +659,7 @@ public class KQReportBiz extends BaseBean { } sql = " select resourceid, newleavetype, durationrule, sum(duration) as val,belongdate from hrmresource a, "+KqSplitFlowTypeEnum.LEAVE.getTablename()+" b "+ - " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' and (DATEPART(dw, belongdate) = 7 or DATEPART(dw, belongdate) = 1) " +sqlWhere + + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' and (DATEPART(dw, belongdate) = 7 or DATEPART(dw, belongdate) = 1) and belongdate NOT IN (select holidayDate from KQ_HolidaySet where changeType = 3 AND groupid = groupId) " +sqlWhere + " group by resourceid, newleavetype, durationrule,belongdate "; rs.execute(sql); while (rs.next()) { @@ -1832,6 +2018,17 @@ public class KQReportBiz extends BaseBean { int evectionMins = Util.getIntValue(Util.null2String(signInfo.get("evectionMins"))); int outMins = Util.getIntValue(Util.null2String(signInfo.get("outMins"))); + String resourceId = Util.null2String(signInfo.get("resourceId")); + String kqDate = Util.null2String(signInfo.get("kqdate")); + String flowinfo = Util.null2String(signInfo.get("flowinfo")); + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + int split_time_index = 0; + ShiftInfoBean shiftInfoBean = KQDurationCalculatorUtil.getWorkTime(resourceId, kqDate, false); + List halfWorkIndex = shiftInfoBean.getHalfWorkIndex(); + if(halfWorkIndex != null && !halfWorkIndex.isEmpty()) { + int[] halfWorkIndexs = halfWorkIndex.get(0); + split_time_index = halfWorkIndexs[1];//半天的时间 + } if(worktime.length()>0){ if (absenteeismMins > 0) {//旷工 text = SystemEnv.getHtmlLabelName(20085, user.getLanguage())+absenteeismMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); @@ -1860,21 +2057,71 @@ public class KQReportBiz extends BaseBean { if (leaveMins > 0) {//请假 Map jsonObject = null; - if(leaveInfo.length()>0){ - jsonObject = JSON.parseObject(leaveInfo); - for (Entry entry : jsonObject.entrySet()) { - String newLeaveType = entry.getKey(); - String tmpLeaveMins = Util.null2String(entry.getValue()); - if(text.indexOf(kqLeaveRulesComInfo.getLeaveName(newLeaveType))==-1){ - if (text.length() > 0) text += " "; - //text += kqLeaveRulesComInfo.getLeaveName(newLeaveType)+tmpLeaveMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); - text += Util.formatMultiLang(kqLeaveRulesComInfo.getLeaveName(newLeaveType),""+user.getLanguage()); - } +// if(leaveInfo.length()>0){ +// jsonObject = JSON.parseObject(leaveInfo); +// for (Map.Entry entry : jsonObject.entrySet()) { +// String newLeaveType = entry.getKey(); +// String tmpLeaveMins = Util.null2String(entry.getValue()); +// if(text.indexOf(kqLeaveRulesComInfo.getLeaveName(newLeaveType))==-1){ +// if (text.length() > 0) text += " "; +// //text += kqLeaveRulesComInfo.getLeaveName(newLeaveType)+tmpLeaveMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); +// text += Util.formatMultiLang(kqLeaveRulesComInfo.getLeaveName(newLeaveType),""+user.getLanguage()); +// } +// } +// }else{ +// if(text.indexOf(SystemEnv.getHtmlLabelName(670, user.getLanguage()))==-1) { +// if (text.length() > 0) text += " "; +// text += SystemEnv.getHtmlLabelName(670, user.getLanguage()); +// } +// } + + if(flowinfo.length() > 0) { + jsonObject = JSON.parseObject(flowinfo); + String jsonKey = ""; + String jsonValue = ""; + if (jsonObject.containsKey(FlowReportTypeEnum.LEAVE.getFlowType())) { + jsonKey = FlowReportTypeEnum.LEAVE.getFlowType(); + jsonValue = SystemEnv.getHtmlLabelName(670, user.getLanguage()); } - }else{ - if(text.indexOf(SystemEnv.getHtmlLabelName(670, user.getLanguage()))==-1) { - if (text.length() > 0) text += " "; - text += SystemEnv.getHtmlLabelName(670, user.getLanguage()); + if (jsonKey.length() > 0) { + JSONArray jsonArray = (JSONArray) jsonObject.get(jsonKey); + String text4temp = ""; + if (jsonArray != null && !jsonArray.isEmpty()) { + //客户不存在多个重复流程的情况,只是显示第一个就行 + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject jsonObject1 = (JSONObject) jsonArray.get(i); + if (jsonObject1 != null && !jsonObject1.isEmpty()) { + String newLeaveType = Util.null2s(Util.null2String(jsonObject1.get("newLeaveType")), ""); + String begintime = Util.null2s(Util.null2String(jsonObject1.get("begintime")), ""); + String endtime = Util.null2s(Util.null2String(jsonObject1.get("endtime")), ""); + int beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(begintime); + int endIdx = kqTimesArrayComInfo.getArrayindexByTimes(endtime); + if (jsonKey.equalsIgnoreCase(FlowReportTypeEnum.LEAVE.getFlowType())) { + if (newLeaveType.length() > 0) { + jsonValue = kqLeaveRulesComInfo.getLeaveName(newLeaveType); + } + } + if (beginIdx <= split_time_index && endIdx <= split_time_index) { + //上午 + if ("on".equalsIgnoreCase(onOrOff)) { + text4temp = jsonValue; + } + } else if (beginIdx >= split_time_index && endIdx >= split_time_index) { + //下午 + if ("off".equalsIgnoreCase(onOrOff)) { + text4temp = jsonValue; + } + } else { + //全天 + text4temp = jsonValue; + } + } + } + if(text4temp.length()>0){ + if (text.length() > 0) text += " "; + text += text4temp; + } + } } } } @@ -2206,6 +2453,7 @@ public class KQReportBiz extends BaseBean { RecordSet rs = new RecordSet(); int sixnight_serialid = Integer.parseInt(rs.getPropValue("nbjh_ygdjblc","sixnight_serialid")); int twelvehours_night_serialid = Integer.parseInt(rs.getPropValue("nbjh_ygdjblc","twelvehours_night_serialid")); + int night_rest_serialid = Integer.parseInt(rs.getPropValue("nbjh_ygdjblc","night_rest_serialid")); rs.executeQuery("select * from kq_format_total where kqdate = ? and resourceid=?",kqdate,userid); rs.writeLog("select * from kq_format_total where kqdate = '"+ kqdate +"' and resourceid="+ userid); while(rs.next()){ @@ -2213,11 +2461,18 @@ public class KQReportBiz extends BaseBean { double attendanceMins = Util.getDoubleValue(rs.getString("attendanceMins"),0.00); double overTimeTotal = getOverTimeTotal(kqdate,userid); double time = attendanceMins+overTimeTotal; + //1、 12小时工作制夜班、做六休一夜班有夜班补贴,并且出勤(上班时间+加班时间)>=8小时,统计一次 if(serialid == sixnight_serialid|| serialid == twelvehours_night_serialid){ if(time >= 8){ result = 1; } } + //2、当一线人员排“夜休”班次,并且加班台账当天导入的加班时长>=8小时,统计一次。 + if(serialid == night_rest_serialid){ + if(overTimeTotal >= 8){ + result += 1; + } + } } return result; } @@ -2279,8 +2534,8 @@ public class KQReportBiz extends BaseBean { RecordSet rs = new RecordSet(); String tablename = rs.getPropValue("nbjh_ygdjblc","fillcard_table"); String tablename_dt = tablename+"_dt1"; - rs.executeQuery("select b.* from "+ tablename +" a,"+ tablename_dt +" b,workflow_requestbase c" + - "where a.requestid = c.requestid and a.id=b.mainid and c.currentnodetype=3" + + rs.executeQuery("select b.* from "+ tablename +" a,"+ tablename_dt +" b,workflow_requestbase c " + + "where a.requestid = c.requestid and a.id=b.mainid and c.currentnodetype=3 " + "and a.ksrq >=? and a.jsrq <=? and a.resourceId=?",fromDate,toDate,userid); if(rs.next()){ @@ -2300,8 +2555,8 @@ public class KQReportBiz extends BaseBean { RecordSet rs = new RecordSet(); String tablename = rs.getPropValue("nbjh_ygdjblc","fillcard_table"); String tablename_dt = tablename+"_dt1"; - rs.executeQuery("select b.* from "+ tablename +" a,"+ tablename_dt +" b,workflow_requestbase c" + - "where a.requestid = c.requestid and a.id=b.mainid and c.currentnodetype=3" + + rs.executeQuery("select b.* from "+ tablename +" a,"+ tablename_dt +" b,workflow_requestbase c " + + "where a.requestid = c.requestid and a.id=b.mainid and c.currentnodetype=3 " + "and b.detail_signdate =? and a.resourceId=?",kqdate,userid); if(rs.next()){ result = 1; diff --git a/src/com/engine/kq/biz/KQShiftManagementComInfo.java b/src/com/engine/kq/biz/KQShiftManagementComInfo.java index de64279..0f28c31 100644 --- a/src/com/engine/kq/biz/KQShiftManagementComInfo.java +++ b/src/com/engine/kq/biz/KQShiftManagementComInfo.java @@ -188,7 +188,7 @@ public class KQShiftManagementComInfo extends CacheBase implements Serializable CacheItem cacheItem = createCacheItem(); Iterator> iterator = shiftInfoBeanMap.entrySet().iterator(); while (iterator.hasNext()) { - Entry entry = iterator.next(); + Map.Entry entry = iterator.next(); String id = entry.getKey(); Object value = entry.getValue(); cacheItem.set(PK_INDEX, id); @@ -292,7 +292,7 @@ public class KQShiftManagementComInfo extends CacheBase implements Serializable if(shiftInfoBeanMap.size()>0){ Iterator> iterator = shiftInfoBeanMap.entrySet().iterator(); while (iterator.hasNext()) { - Entry entry = iterator.next(); + Map.Entry entry = iterator.next(); String id = entry.getKey(); Object value = entry.getValue(); CacheItem cacheItem = createCacheItem(); diff --git a/src/com/engine/kq/biz/KQWorkTime.java b/src/com/engine/kq/biz/KQWorkTime.java index 9694bdb..77b6ebb 100644 --- a/src/com/engine/kq/biz/KQWorkTime.java +++ b/src/com/engine/kq/biz/KQWorkTime.java @@ -56,7 +56,7 @@ public class KQWorkTime extends BaseBean { Map result = new HashMap<>(); try { KQShiftManagementComInfo kQShiftManagementComInfo = new KQShiftManagementComInfo(); - Map serialInfo = getSerialInfo(userId, workdate, containYesterday); + Map serialInfo = getSerialInfo(userId, workdate, containYesterday,true); kqLog.info("考勤组获取成员所在的班次 getWorkButton:serialInfo:"+ serialInfo); String kqType = Util.null2String(serialInfo.get("kqType")); if(serialInfo!=null&&serialInfo.size()>0){ @@ -94,7 +94,6 @@ public class KQWorkTime extends BaseBean { Map workTimeMap = null; KQShiftManagementComInfo kQShiftManagementComInfo = new KQShiftManagementComInfo(); Map serialInfo = getSerialInfo(userId, workdate, true); - writeLog("getWorkDuration-serialInfo-" + userId + "-" + workdate + serialInfo); if(isLog){ kqLog.info("考勤组获取成员所在的班次 getWorkDuration:"+serialInfo); } @@ -169,7 +168,7 @@ public class KQWorkTime extends BaseBean { try { KQShiftManagementComInfo kQShiftManagementComInfo = new KQShiftManagementComInfo(); ShiftManagementToolKit shiftManagementToolKit = new ShiftManagementToolKit(); - Map serialInfo = getSerialInfo(userId, workdate, false); + Map serialInfo = getSerialInfo(userId, workdate, false,true); workTimeEntity.setIsExclude(Util.null2String(serialInfo.get("isExclude")).equals("1")); workTimeEntity.setGroupId(Util.null2String(serialInfo.get("groupId"))); if(serialInfo!=null&&serialInfo.size()>0) { @@ -262,6 +261,27 @@ public class KQWorkTime extends BaseBean { return serialInfo!=null?Util.null2String(serialInfo.get(workdate)):""; } + /** + * 获取今天所含班次的考勤时间(今天的) + * @param userId + * @param workdate + * @return + */ + public ShiftInfoCominfoBean getShiftInfoCominfoBeanIncludeHoliday(String userId, String workdate) { + ShiftInfoCominfoBean shiftInfoCominfoBean = null; + try { + KQShiftManagementComInfo kQShiftManagementComInfo = new KQShiftManagementComInfo(); + Map serialInfo = getSerialInfo(userId, workdate, false, true); + + if(serialInfo!=null&&serialInfo.size()>0){ + shiftInfoCominfoBean = kQShiftManagementComInfo.getShiftInfoCominfoBean(workdate,serialInfo); + } + } catch (Exception e) { + writeLog(e); + } + return shiftInfoCominfoBean; + } + /** * 获取班次信息 获取顺序 工作日调整、排班、固定班和周期班 * @param userId @@ -270,6 +290,10 @@ public class KQWorkTime extends BaseBean { * @return */ public Map getSerialInfo(String userId, String workdate, boolean containYesterday) { + return getSerialInfo(userId, workdate, containYesterday, false); + } + + public Map getSerialInfo(String userId, String workdate, boolean containYesterday , boolean includeHoliday) { Map serialInfo = new HashMap<>(); String preworkdate = ""; try { @@ -284,7 +308,7 @@ public class KQWorkTime extends BaseBean { preworkdate = DateUtil.addDate(workdate,-1); if(containYesterday){ - Map pre_serialInfo = getSerialInfo(userId, preworkdate, false); + Map pre_serialInfo = getSerialInfo(userId, preworkdate, false, includeHoliday); if(pre_serialInfo != null && !pre_serialInfo.isEmpty()){ if(pre_serialInfo.containsKey(preworkdate)){ serialInfo.put(preworkdate,pre_serialInfo.get(preworkdate));//获取前一天的班次 @@ -354,6 +378,7 @@ public class KQWorkTime extends BaseBean { serialInfo.put("groupName",groupname); serialInfo.put("kqType",kqtype); serialInfo.put("isHoliday",isHoliday); + if(includeHoliday) isHoliday = false; if (kqtype.equals("1")) {//固定班 // if(containYesterday && !serialInfo.containsKey(preworkdate)) { // serialid = Util.null2String(kqFixedSchedulceComInfo.getSerialid(groupid,preDayOfweek)); @@ -374,6 +399,7 @@ public class KQWorkTime extends BaseBean { // serialInfo.put(preworkdate,Util.null2String(kqShiftScheduleComInfo.getSerialId(userId,preworkdate)));//获取前一天的班次 // } serialid = Util.null2String(kqShiftScheduleComInfo.getSerialId(userId,workdate)); + if(serialid.length()>0 && !isHoliday && Util.getIntValue(serialid) > 0){ serialInfo.put(workdate,Util.null2String(kqShiftScheduleComInfo.getSerialId(userId,workdate)));//获取当天的班次 } diff --git a/src/com/engine/kq/cmd/attendanceEvent/GetLeaveWorkDurationCmd.java b/src/com/engine/kq/cmd/attendanceEvent/GetLeaveWorkDurationCmd.java index edb778f..dfbb296 100644 --- a/src/com/engine/kq/cmd/attendanceEvent/GetLeaveWorkDurationCmd.java +++ b/src/com/engine/kq/cmd/attendanceEvent/GetLeaveWorkDurationCmd.java @@ -44,7 +44,7 @@ public class GetLeaveWorkDurationCmd extends AbstractCommonCommand 0 && groupid.length() == 0){ retmap.put("status", "-1"); - retmap.put("message", rci.getLastname(resourceId)+","+fromDate+""+ SystemEnv.getHtmlLabelName(10005329,weaver.general.ThreadVarLanguage.getLang())+""); + retmap.put("message", rci.getLastname(resourceId)+","+fromDate+""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005329,weaver.general.ThreadVarLanguage.getLang())+""); return retmap; } diff --git a/src/com/engine/kq/cmd/report/ExportExcelCmd.java b/src/com/engine/kq/cmd/report/ExportExcelCmd.java index 00b989b..86bd04b 100644 --- a/src/com/engine/kq/cmd/report/ExportExcelCmd.java +++ b/src/com/engine/kq/cmd/report/ExportExcelCmd.java @@ -5,7 +5,14 @@ import com.alibaba.fastjson.JSONObject; import com.engine.common.biz.AbstractCommonCommand; import com.engine.common.entity.BizLogContext; import com.engine.core.interceptor.CommandContext; -import com.engine.kq.biz.*; +import com.engine.kq.biz.KQFormatBiz; +import com.engine.kq.biz.KQLeaveRulesBiz; +import com.engine.kq.biz.KQOvertimeRulesBiz; +import com.engine.kq.biz.KQReportBiz; +import com.engine.kq.biz.KQReportFieldComInfo; +import com.engine.kq.biz.KQSettingsComInfo; +import com.engine.kq.biz.KQShiftManagementComInfo; +import com.engine.kq.biz.KQUnitBiz; import com.engine.kq.util.ExcelUtil; import com.engine.kq.util.KQDurationCalculatorUtil; import com.engine.kq.util.UtilKQ; @@ -272,6 +279,10 @@ public class ExportExcelCmd extends AbstractCommonCommand> { //System.out.println("start" + DateUtil.getFullDate()); Map flowData = new KQReportBiz().getFlowData(params, user); Map saturdayFlowLeaveData = kqReportBiz.getSaturdayFlowLeaveData(params, user); + Map saturdayFlowLeaveBackData = kqReportBiz.getSaturdayFlowLeaveBackData(params, user); + if ((!CollectionUtils.isEmpty(saturdayFlowLeaveBackData)) || saturdayFlowLeaveBackData.size() > 0) { + saturdayFlowLeaveData.putAll(saturdayFlowLeaveBackData); + } //System.out.println("end" + DateUtil.getFullDate()); // #1475814-概述:满足考勤报分部部门显示及导出时显示全路径 @@ -465,7 +476,7 @@ public class ExportExcelCmd extends AbstractCommonCommand> { if (Util.null2String(rs.getString(lsCascadekey.get(i))).length() > 0) { fieldid = KQReportFieldComInfo.field2Id.get(lsCascadekey.get(i)); //迟到早退使用分钟 - if (lsCascadekey.get(i).contains("LateMins") || lsCascadekey.get(i).contains("EarlyMins")) { + if (fieldName.contains("LateMins") || fieldName.contains("EarlyMins")) { fieldValue = rs.getString(lsCascadekey.get(i)); } else { fieldValue = getFieldValueByUnitType(rs.getString(lsCascadekey.get(i)), kqReportFieldComInfo.getUnittype(fieldid)); @@ -487,9 +498,10 @@ public class ExportExcelCmd extends AbstractCommonCommand> { String sjbjcjRes = "0.0"; List> allLeaveRules = kqLeaveRulesBiz.getAllLeaveRules(); Map leaveRule = null; - for (int i = 0; allLeaveRules != null && i < allLeaveRules.size(); i++) { + for (int ia = 0; allLeaveRules != null && ia < allLeaveRules.size(); ia++) { + leaveRule = (Map) allLeaveRules.get(ia); + int i = Integer.valueOf(leaveRule.get("id").toString()); if (((!CollectionUtils.isEmpty(sjbjcjidList)) && sjbjcjidList.contains(i))) { - leaveRule = (Map) allLeaveRules.get(i); String flowType = Util.null2String("leaveType_" + leaveRule.get("id")); String leaveData = Util.null2String(saturdayFlowLeaveData.get(id + "|" + flowType)); String flowLeaveBackType = Util.null2String("leavebackType_" + leaveRule.get("id")); @@ -540,9 +552,10 @@ public class ExportExcelCmd extends AbstractCommonCommand> { String hjsjRes = "0.0"; List> allLeaveRules = kqLeaveRulesBiz.getAllLeaveRules(); Map leaveRule = null; - for (int i = 0; allLeaveRules != null && i < allLeaveRules.size(); i++) { + for (int ia = 0; allLeaveRules != null && ia < allLeaveRules.size(); ia++) { + leaveRule = (Map) allLeaveRules.get(ia); + int i = Integer.valueOf(leaveRule.get("id").toString()); if (((!CollectionUtils.isEmpty(hjsjidList)) && hjsjidList.contains(i))) { - leaveRule = (Map) allLeaveRules.get(i); String flowType = Util.null2String("leaveType_" + leaveRule.get("id")); String leaveData = Util.null2String(saturdayFlowLeaveData.get(id + "|" + flowType)); String flowLeaveBackType = Util.null2String("leavebackType_" + leaveRule.get("id")); diff --git a/src/com/engine/kq/cmd/report/GetKQDailyReportCmd.java b/src/com/engine/kq/cmd/report/GetKQDailyReportCmd.java index dba9add..fa98247 100644 --- a/src/com/engine/kq/cmd/report/GetKQDailyReportCmd.java +++ b/src/com/engine/kq/cmd/report/GetKQDailyReportCmd.java @@ -13,6 +13,7 @@ import com.engine.kq.util.KQDurationCalculatorUtil; import com.engine.kq.util.PageUidFactory; import org.apache.commons.lang3.StringUtils; import org.springframework.util.CollectionUtils; +import weaver.common.StringUtil; import weaver.conn.RecordSet; import weaver.general.BaseBean; import weaver.general.TimeUtil; @@ -151,10 +152,10 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand flowData = kqReportBiz.getDailyFlowData(params, user); Map dailySaturdayFlowLeaveData = kqReportBiz.getDailySaturdayFlowLeaveData(params, user); + Map dailySaturdayFlowLeaveBackData = kqReportBiz.getDailySaturdayFlowLeaveBackData(params, user); + if ((!CollectionUtils.isEmpty(dailySaturdayFlowLeaveBackData)) || dailySaturdayFlowLeaveBackData.size() > 0) { + dailySaturdayFlowLeaveData.putAll(dailySaturdayFlowLeaveBackData); + } // #1475814-概述:满足考勤报分部部门显示及导出时显示全路径 String fullPathMainKey = "show_full_path"; @@ -403,10 +408,11 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand) allLeaveRules.get(ia); + int i = Integer.valueOf(leaveRule.get("id").toString()); if (((!CollectionUtils.isEmpty(sjbjcjidList)) && sjbjcjidList.contains(i)) || ((!CollectionUtils.isEmpty(hjsjidList)) && hjsjidList.contains(i))) { - leaveRule = (Map) allLeaveRules.get(i); String flowType = Util.null2String("leaveType_" + leaveRule.get("id")); String leaveData = Util.null2String(dailySaturdayFlowLeaveData.get(id + "|" + flowType)); String flowLeaveBackType = Util.null2String("leavebackType_" + leaveRule.get("id")); @@ -641,7 +647,7 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand 0) { if (workbegintime.length() > 0) { signStatusInfo = new HashMap(); + signStatusInfo.put("resourceId",resourceid); + signStatusInfo.put("kqdate",kqdate); + signStatusInfo.put("flowinfo",flowinfo); + signStatusInfo.put("workbegintime",workbegintime); + signStatusInfo.put("workendtime",workendtime); signStatusInfo.put("workdate", workbegindate); signStatusInfo.put("worktime", workbegintime); signStatusInfo.put("beLateMins", beLateMins); @@ -689,11 +701,21 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand 0) { signStatusInfo = new HashMap(); + signStatusInfo.put("resourceId",resourceid); + signStatusInfo.put("kqdate",kqdate); + signStatusInfo.put("flowinfo",flowinfo); + signStatusInfo.put("workbegintime",workbegintime); + signStatusInfo.put("workendtime",workendtime); signStatusInfo.put("workdate", workenddate); signStatusInfo.put("worktime", kqTimesArrayComInfo.turn48to24Time(workendtime)); signStatusInfo.put("leaveEarlyMins", leaveEarlyMins); @@ -705,20 +727,27 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand 0) { //弹性工时打卡时间取自签到签退数据 } signStatusInfo = new HashMap(); - signStatusInfo.put("leaveMins", leaveMins); - signStatusInfo.put("leaveInfo", leaveInfo); - signStatusInfo.put("evectionMins", evectionMins); - signStatusInfo.put("outMins", outMins); - + signStatusInfo.put("resourceId",resourceid); + signStatusInfo.put("kqdate",kqdate); + signStatusInfo.put("leaveMins",leaveMins); + signStatusInfo.put("leaveInfo",leaveInfo); + signStatusInfo.put("evectionMins",evectionMins); + signStatusInfo.put("outMins",outMins); + signStatusInfo.put("flowinfo",flowinfo); + signStatusInfo.put("workbegintime",workbegintime); + signStatusInfo.put("workendtime",workendtime); if (signinid.length() > 0) { data.put("signintime" + serialnumber, signintime.length() == 0 ? SystemEnv.getHtmlLabelName(25994, user.getLanguage()) : signintime); data.put("signinstatus" + serialnumber, KQReportBiz.getSignStatus(signStatusInfo, user, "on")); diff --git a/src/com/engine/kq/cmd/report/GetKQReportCmd.java b/src/com/engine/kq/cmd/report/GetKQReportCmd.java index 1d8d1e1..28f18ca 100644 --- a/src/com/engine/kq/cmd/report/GetKQReportCmd.java +++ b/src/com/engine/kq/cmd/report/GetKQReportCmd.java @@ -5,7 +5,15 @@ import com.alibaba.fastjson.JSONObject; import com.engine.common.biz.AbstractCommonCommand; import com.engine.common.entity.BizLogContext; import com.engine.core.interceptor.CommandContext; -import com.engine.kq.biz.*; +import com.engine.kq.biz.KQFormatBiz; +import com.engine.kq.biz.KQHolidaySetBiz; +import com.engine.kq.biz.KQLeaveRulesBiz; +import com.engine.kq.biz.KQOvertimeRulesBiz; +import com.engine.kq.biz.KQReportBiz; +import com.engine.kq.biz.KQReportFieldComInfo; +import com.engine.kq.biz.KQSettingsComInfo; +import com.engine.kq.biz.KQShiftManagementComInfo; +import com.engine.kq.biz.KQUnitBiz; import com.engine.kq.util.KQDurationCalculatorUtil; import com.engine.kq.util.PageUidFactory; import org.apache.commons.lang3.StringUtils; @@ -190,11 +198,11 @@ public class GetKQReportCmd extends AbstractCommonCommand> { String definedFieldSum = Util.null2String(definedFieldInfo.get("definedFieldSum")); //支援班次统计 String supportSerId = new BaseBean().getPropValue("nbkq_main", "supportSerId"); - String backFields = " (select sum(workdays) from kq_format_total where resourceid = a.id and kqdate >='" + fromDate + "' and kqdate <='" + toDate + "' and (DATEPART(dw, kqdate) = 7 or DATEPART(dw, kqdate) = 1)) as saturdayworkdays," + + String backFields = " (select sum(zma.workdays) from kq_format_total zma where zma.resourceid = a.id and zma.kqdate >='" + fromDate + "' and zma.kqdate <='" + toDate + "' and (DATEPART(dw, zma.kqdate) = 7 or DATEPART(dw, zma.kqdate) = 1) AND zma.kqdate NOT IN (select holidayDate from KQ_HolidaySet where changeType = 3 AND zma.groupid = groupId)) as saturdayworkdays," + " (select count(0) from kq_shiftschedule where resourceid = a.id and kqdate >='" + fromDate + "' and kqdate <='" + toDate + "' and serialid=" + supportSerId + " )as supportTotal," + - " (select sum(attendancedays) from kq_format_total where resourceid = a.id and kqdate >='" + fromDate + "' and kqdate <='" + toDate + "' and (DATEPART(dw, kqdate) = 7 or DATEPART(dw, kqdate) = 1)) as saturdayattendancedays," + - " (select sum(workdays) from kq_format_total where resourceid = a.id and kqdate >='" + fromDate + "' and kqdate <='" + toDate + "' and DATEPART(dw, kqdate) != 7 and DATEPART(dw, kqdate) != 1) as weekdayworkdays," + - " (select sum(attendancedays) from kq_format_total where resourceid = a.id and kqdate >='" + fromDate + "' and kqdate <='" + toDate + "' and DATEPART(dw, kqdate) != 7 and DATEPART(dw, kqdate) != 1) as weekdayattendancedays," + + " (select sum(zma.attendancedays) from kq_format_total zma where zma.resourceid = a.id and zma.kqdate >='" + fromDate + "' and zma.kqdate <='" + toDate + "' and (DATEPART(dw, zma.kqdate) = 7 or DATEPART(dw, zma.kqdate) = 1) AND zma.kqdate NOT IN (select holidayDate from KQ_HolidaySet where changeType = 3 AND zma.groupid = groupId)) as saturdayattendancedays," + + " (select sum(zma.workdays) from kq_format_total zma where zma.resourceid = a.id and zma.kqdate >='" + fromDate + "' and zma.kqdate <='" + toDate + "' and ((DATEPART(dw, zma.kqdate) != 7 and DATEPART(dw, zma.kqdate) != 1) or ((DATEPART(dw, zma.kqdate) = 7 or DATEPART(dw, zma.kqdate) = 1) and zma.kqdate IN (select holidayDate from KQ_HolidaySet where changeType = 3 and zma.groupid = groupId)))) as weekdayworkdays," + + " (select sum(zma.attendancedays) from kq_format_total zma where zma.resourceid = a.id and zma.kqdate >='" + fromDate + "' and zma.kqdate <='" + toDate + "' and ((DATEPART(dw, zma.kqdate) != 7 and DATEPART(dw, zma.kqdate) != 1) or ((DATEPART(dw, zma.kqdate) = 7 or DATEPART(dw, zma.kqdate) = 1) and zma.kqdate IN (select holidayDate from KQ_HolidaySet where changeType = 3 and zma.groupid = groupId)))) as weekdayattendancedays," + "a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1 as subcompanyid,a.departmentid,a.jobtitle," + " sum(b.workdays) as workdays,sum(b.workMins) as workMins,sum(b.attendancedays) as attendancedays," + " sum(b.attendanceMins) as attendanceMins,sum(b.beLate) as beLate,sum(b.beLateMins) as beLateMins, " + @@ -333,6 +341,10 @@ public class GetKQReportCmd extends AbstractCommonCommand> { Map flowData = kqReportBiz.getFlowData(params, user); Map saturdayFlowLeaveData = kqReportBiz.getSaturdayFlowLeaveData(params, user); + Map saturdayFlowLeaveBackData = kqReportBiz.getSaturdayFlowLeaveBackData(params, user); + if ((!CollectionUtils.isEmpty(saturdayFlowLeaveBackData)) || saturdayFlowLeaveBackData.size() > 0) { + saturdayFlowLeaveData.putAll(saturdayFlowLeaveBackData); + } rs.execute(sql); rs.writeLog("========== GetKQReportCmd sql ========== " + sql); while (rs.next()) { @@ -504,10 +516,11 @@ public class GetKQReportCmd extends AbstractCommonCommand> { } String sjbjcjRes = "0.0"; String hjsjRes = "0.0"; - for (int i = 0; allLeaveRules != null && i < allLeaveRules.size(); i++) { + for (int ia = 0; allLeaveRules != null && ia < allLeaveRules.size(); ia++) { + leaveRule = (Map) allLeaveRules.get(ia); + int i = Integer.valueOf(leaveRule.get("id").toString()); if (((!CollectionUtils.isEmpty(sjbjcjidList)) && sjbjcjidList.contains(i)) || ((!CollectionUtils.isEmpty(hjsjidList)) && hjsjidList.contains(i))) { - leaveRule = (Map) allLeaveRules.get(i); String flowType = Util.null2String("leaveType_" + leaveRule.get("id")); String leaveData = Util.null2String(saturdayFlowLeaveData.get(id + "|" + flowType)); String flowLeaveBackType = Util.null2String("leavebackType_" + leaveRule.get("id")); diff --git a/src/com/engine/kq/util/KQDurationCalculatorUtil.java b/src/com/engine/kq/util/KQDurationCalculatorUtil.java index cc3b434..b9c8418 100644 --- a/src/com/engine/kq/util/KQDurationCalculatorUtil.java +++ b/src/com/engine/kq/util/KQDurationCalculatorUtil.java @@ -20,7 +20,6 @@ import com.engine.kq.enums.DurationTypeEnum; import com.engine.kq.log.KQLog; import com.engine.kq.wfset.bean.SplitBean; import com.engine.kq.wfset.util.KQFlowUtil; - import java.time.LocalDateTime; import java.time.LocalTime; import java.time.format.DateTimeFormatter; @@ -36,617 +35,597 @@ import weaver.hrm.User; import weaver.hrm.report.schedulediff.HrmScheduleDiffUtil; public class KQDurationCalculatorUtil extends BaseBean { - private KQLog kqLog = new KQLog(); - private final String resourceid; - private String fromDate; - private String toDate; - private String fromTime; - private String toTime; - private String newLeaveType; - /** - * 获取最小计算单位 - * 1-按天计算 - * 2-按半天计算 - * 3-按小时计算 - * 4-按整天计算 - */ - private String durationrule; - /** - * 1-按工作日计算计算时长 - * 2-按自然日计算计算时长 - */ - private String computingMode; - - /** - * 加班类型 - */ - private String overtime_type; - - private DurationTypeEnum durationTypeEnum; - - //外部类的构造函数 - private KQDurationCalculatorUtil(DurationParamBuilder build) { - this.resourceid = build.resourceid; - this.fromDate = build.fromDate; - this.toDate = build.toDate; - this.fromTime = build.fromTime; - this.toTime = build.toTime; - this.newLeaveType = build.newLeaveType; - this.durationrule = build.durationrule; - this.computingMode = build.computingMode; - this.durationTypeEnum = build.durationTypeEnum; - this.overtime_type = build.overtime_type; + private KQLog kqLog = new KQLog(); + + private final String resourceid; + private String fromDate; + private String toDate; + private String fromTime; + private String toTime; + private String newLeaveType; + /** + * 获取最小计算单位 + * 1-按天计算 + * 2-按半天计算 + * 3-按小时计算 + * 4-按整天计算 + */ + private String durationrule; + /** + * 1-按工作日计算计算时长 + * 2-按自然日计算计算时长 + */ + private String computingMode; + + /** + * 加班类型 + */ + private String overtime_type; + + private DurationTypeEnum durationTypeEnum; + + //外部类的构造函数 + private KQDurationCalculatorUtil(DurationParamBuilder build){ + this.resourceid = build.resourceid; + this.fromDate = build.fromDate; + this.toDate = build.toDate; + this.fromTime = build.fromTime; + this.toTime = build.toTime; + this.newLeaveType = build.newLeaveType; + this.durationrule = build.durationrule; + this.computingMode = build.computingMode; + this.durationTypeEnum = build.durationTypeEnum; + this.overtime_type = build.overtime_type; + } + + /** + * 根据人和指定的日期获取办公时段 + * @param resourceid + * @param date + * @param containYesterday + * @return + */ + public static ShiftInfoBean getWorkTime(String resourceid, String date,boolean containYesterday){ + User user = User.getUser(Util.getIntValue(resourceid), 0); + if(user == null){ + return null; } + return getWorkTime(user, date,containYesterday); + } - /** - * 根据人和指定的日期获取办公时段 - * - * @param resourceid - * @param date - * @param containYesterday - * @return - */ - public static ShiftInfoBean getWorkTime(String resourceid, String date, boolean containYesterday) { - - User user = User.getUser(Util.getIntValue(resourceid), 0); - if (user == null) { - return null; + public static ShiftInfoBean getWorkTimeNew(String resourceid, String date,boolean containYesterday){ + User user = User.getUser(Util.getIntValue(resourceid), 0); + if(user == null){ + return null; + } + return getWorkTime(user, date, containYesterday, true, false); + } + + /** + * 不记录日志的,流程的超时提醒日志太大 + * @param resourceid + * @param date + * @param containYesterday + * @param isLog + * @return + */ + public static ShiftInfoBean getWorkTime(String resourceid, String date,boolean containYesterday,boolean isLog){ + User user = User.getUser(Util.getIntValue(resourceid), 0); + if(user == null){ + return null; + } + return getWorkTime(user, date,containYesterday,isLog); + } + + public static ShiftInfoCominfoBean getShiftInfoCominfoBean(String resourceid, String date){ + KQWorkTime kqWorkTime = new KQWorkTime(); + Map kqWorkTimeMap = new HashMap<>(); + ShiftInfoCominfoBean shiftInfoCominfoBean = kqWorkTime.getShiftInfoCominfoBean(resourceid, date); + return shiftInfoCominfoBean; + } + + /** + * 直接根据user来获取 + * @param user + * @param date + * @param containYesterday + * @param isLog + * @return + */ + public static ShiftInfoBean getWorkTime(User user, String date,boolean containYesterday,boolean isLog){ + return getWorkTime(user, date, containYesterday, isLog, true); + } + + public static ShiftInfoBean getWorkTime(User user, String date,boolean containYesterday,boolean isLog, boolean isUsedRestShift){ + KQWorkTime kqWorkTime = new KQWorkTime(); + Map kqWorkTimeMap = new HashMap<>(); + kqWorkTimeMap = kqWorkTime.getWorkDuration(""+user.getUID(), date,containYesterday,isLog); + boolean isfree = "1".equalsIgnoreCase(Util.null2String(kqWorkTimeMap.get("isfree"))); + if(isfree){ + ShiftInfoBean shiftInfoBean = new ShiftInfoBean(); + shiftInfoBean.setIsfree(true); + String signStart = Util.null2String(kqWorkTimeMap.get("signStart")); + String workMins = Util.null2String(kqWorkTimeMap.get("workMins")); + shiftInfoBean.setFreeSignStart(signStart); + shiftInfoBean.setFreeWorkMins(workMins); + shiftInfoBean.setSplitDate(date); + if(signStart.length() > 0 && workMins.length() > 0){ + DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm"); + LocalTime signLocalTime = LocalTime.parse(signStart, dateTimeFormatter); + shiftInfoBean.setFreeSignEnd(signLocalTime.plusMinutes(Util.getIntValue(workMins)).format(dateTimeFormatter)); + shiftInfoBean.setFreeSignMiddle(signLocalTime.plusMinutes(Util.getIntValue(workMins)/2).format(dateTimeFormatter)); + } + + return shiftInfoBean; + }else{ + if(kqWorkTimeMap.get("shiftInfoBean") != null){ + ShiftInfoBean shiftInfoBean = (ShiftInfoBean)kqWorkTimeMap.get("shiftInfoBean"); + if(isUsedRestShift) { + int serialid = Util.getIntValue(Util.null2String(shiftInfoBean.getSerialid()), 0); + KQShiftManagementComInfo kQShiftManagementComInfo = new KQShiftManagementComInfo(); + int restShift = StringUtil.parseToInt(kQShiftManagementComInfo.getRestShift(String.valueOf(serialid)), 0); + if(restShift == 1) { + return null; + } } - return getWorkTime(user, date, containYesterday); + return shiftInfoBean; + }else{ + return null; + } } - - public static ShiftInfoBean getWorkTimeNew(String resourceid, String date, boolean containYesterday) { - User user = User.getUser(Util.getIntValue(resourceid), 0); - if (user == null) { - return null; + } + + /** + * 直接根据user来获取 + * @param user + * @param date + * @param containYesterday + * @return + */ + public static ShiftInfoBean getWorkTime(User user, String date,boolean containYesterday){ + return getWorkTime(user, date, containYesterday, true); + } + + public static Map getWorkButton(String resourceid, String date, boolean containYesterday){ + User user = User.getUser(Util.getIntValue(resourceid), 0); + return getWorkButton(user,date,containYesterday); + } + + public static Map getWorkButton(User user, String date, boolean containYesterday){ + KQWorkTime kqWorkTime = new KQWorkTime(); + Map kqWorkTimeMap = new HashMap<>(); + kqWorkTimeMap = kqWorkTime.getWorkButton(""+user.getUID(), date,containYesterday); + + return kqWorkTimeMap; + } + + /** + * 根据传入的用户和时段返回非工作时长 + * @return + */ + public Map getNonWorkDuration(){ + + Map durationMap = new HashMap<>(); + try{ + double D_Duration = 0.0; + double Min_Duration = 0.0; + //公众假日加班时长 + double D_Pub_Duration = 0.0; + double D_Pub_Mins = 0.0; + //工作日加班时长 + double D_Work_Duration = 0.0; + double D_Work_Mins = 0.0; + //休息日加班时长 + double D_Rest_Duration = 0.0; + double D_Rest_Mins = 0.0; + + SplitBean splitBean = new SplitBean(); + splitBean.setFromDate(fromDate); + splitBean.setFromTime(fromTime); + splitBean.setToDate(toDate); + splitBean.setToTime(toTime); + splitBean.setResourceId(resourceid); + splitBean.setFromdatedb(fromDate); + splitBean.setTodatedb(toDate); + splitBean.setFromtimedb(fromTime); + splitBean.setTotimedb(toTime); + splitBean.setDurationrule(durationrule); + splitBean.setComputingMode(computingMode); + splitBean.setDurationTypeEnum(DurationTypeEnum.OVERTIME); + splitBean.setOvertime_type(overtime_type); + + List splitBeans = new ArrayList<>(); + + NonWorkDurationChain hourUnitSplitChain = new NonHourUnitSplitChain(splitBeans); + NonWorkDurationChain dayUnitSplitChain = new NonDayUnitSplitChain(splitBeans); + NonWorkDurationChain halfUnitSplitChain = new NonHalfUnitSplitChain(splitBeans); + NonWorkDurationChain wholeUnitSplitChain = new NonWholeUnitSplitChain(splitBeans); + + //设置执行链 + hourUnitSplitChain.setDurationChain(dayUnitSplitChain); + dayUnitSplitChain.setDurationChain(halfUnitSplitChain); + halfUnitSplitChain.setDurationChain(wholeUnitSplitChain); + //把初始数据设置进去 + hourUnitSplitChain.handleDuration(splitBean); + + //每一天的流程时长都在这里了,搞吧 + for(SplitBean sb : splitBeans){ +// * 1-公众假日、2-工作日、3-休息日 + int changeType = sb.getChangeType(); + double durations = Util.getDoubleValue(sb.getDuration(), 0.0); + double durationMins = sb.getD_Mins(); + if(1 == changeType){ + D_Pub_Duration += durations; + D_Pub_Mins += durationMins; + } + if(2 == changeType){ + D_Work_Duration += durations; + D_Work_Mins += durationMins; + } + if(3 == changeType){ + D_Rest_Duration += durations; + D_Rest_Mins += durationMins; } - return getWorkTime(user, date, containYesterday, true, false); + } + Min_Duration = D_Pub_Mins+D_Work_Mins+D_Rest_Mins; + + if("3".equalsIgnoreCase(durationrule) || "5".equalsIgnoreCase(durationrule) || "6".equalsIgnoreCase(durationrule)){ + double d_hour = Min_Duration/60.0; + durationMap.put("duration", KQDurationCalculatorUtil.getDurationRound(""+d_hour)); + }else { + double oneDayHour = KQFlowUtil.getOneDayHour(DurationTypeEnum.OVERTIME,""); + double d_day = Min_Duration/(oneDayHour * 60); + durationMap.put("duration", KQDurationCalculatorUtil.getDurationRound(""+d_day)); + } + + durationMap.put("min_duration", KQDurationCalculatorUtil.getDurationRound(""+Min_Duration)); + + }catch (Exception e){ + e.printStackTrace(); } - - /** - * 不记录日志的,流程的超时提醒日志太大 - * - * @param resourceid - * @param date - * @param containYesterday - * @param isLog - * @return - */ - public static ShiftInfoBean getWorkTime(String resourceid, String date, boolean containYesterday, boolean isLog) { - User user = User.getUser(Util.getIntValue(resourceid), 0); - if (user == null) { - return null; + return durationMap; + } + + /** + * 根据传入的用户和时段返回工作时长 + * @return + */ + public Map getWorkDuration(){ + + Map durationMap = new HashMap<>(); + try{ + if(!isValidate(fromDate,toDate,fromTime,toTime)){ + durationMap.put("duration", "0.0"); + return durationMap; + } + if(durationTypeEnum != DurationTypeEnum.COMMON_CAL){ + kqLog.info("getWorkDuration:"+durationTypeEnum.getDurationType()+":fromDate:"+fromDate+":toDate:"+toDate+":fromTime:"+fromTime+":toTime:"+toTime+":durationrule:"+durationrule+":computingMode:"+computingMode); + } + //如果是加班 + if(durationTypeEnum ==DurationTypeEnum.OVERTIME){ + return getNonWorkDuration(); + } + //时长 + double D_Duration = 0.0; + //分钟数 + double Min_Duration = 0.0; + + SplitBean splitBean = new SplitBean(); + splitBean.setFromDate(fromDate); + splitBean.setFromTime(fromTime); + splitBean.setToDate(toDate); + splitBean.setToTime(toTime); + splitBean.setResourceId(resourceid); + splitBean.setFromdatedb(fromDate); + splitBean.setTodatedb(toDate); + splitBean.setFromtimedb(fromTime); + splitBean.setTotimedb(toTime); + splitBean.setDurationrule(durationrule); + splitBean.setDurationTypeEnum(durationTypeEnum); + splitBean.setComputingMode(computingMode); + splitBean.setNewLeaveType(newLeaveType); + if("2".equalsIgnoreCase(computingMode)){ + double oneDayHour = KQFlowUtil.getOneDayHour(durationTypeEnum,newLeaveType); + splitBean.setOneDayHour(oneDayHour); + if(durationTypeEnum == DurationTypeEnum.LEAVE){ + //只有自然日 请假才有这个排除节假日、休息日的功能 + splitBean.setFilterholidays(KQLeaveRulesBiz.getFilterHolidays(splitBean.getNewLeaveType())); } - return getWorkTime(user, date, containYesterday, isLog); + } + if(durationTypeEnum ==DurationTypeEnum.LEAVE || durationTypeEnum ==DurationTypeEnum.LEAVEBACK){ + if(newLeaveType.length() > 0){ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + String conversion = kqLeaveRulesComInfo.getConversion(newLeaveType); + splitBean.setConversion(conversion); + } + } + + List splitBeans = new ArrayList<>(); + + WorkDurationChain hourUnitSplitChain = new WorkHourUnitSplitChain(splitBeans); + WorkDurationChain dayUnitSplitChain = new WorkDayUnitSplitChain(splitBeans); + WorkDurationChain halfUnitSplitChain = new WorkHalfUnitSplitChain(splitBeans); + WorkDurationChain wholeUnitSplitChain = new WorkWholeUnitSplitChain(splitBeans); + + //设置执行链 + hourUnitSplitChain.setDurationChain(dayUnitSplitChain); + dayUnitSplitChain.setDurationChain(halfUnitSplitChain); + halfUnitSplitChain.setDurationChain(wholeUnitSplitChain); + //把初始数据设置进去 + hourUnitSplitChain.handleDuration(splitBean); + + //每一天的流程时长都在这里了,搞吧 + for(SplitBean sb : splitBeans){ + double durations = Util.getDoubleValue(sb.getDuration(), 0.0); + double min_durations = sb.getD_Mins(); + D_Duration += durations; + Min_Duration += min_durations; + } + + durationMap.put("duration", KQDurationCalculatorUtil.getDurationRound(""+D_Duration)); + durationMap.put("min_duration", KQDurationCalculatorUtil.getDurationRound(""+Min_Duration)); + + }catch (Exception e){ + e.printStackTrace(); } + return durationMap; + } - public static ShiftInfoCominfoBean getShiftInfoCominfoBean(String resourceid, String date) { - KQWorkTime kqWorkTime = new KQWorkTime(); - Map kqWorkTimeMap = new HashMap<>(); - ShiftInfoCominfoBean shiftInfoCominfoBean = kqWorkTime.getShiftInfoCominfoBean(resourceid, date); - return shiftInfoCominfoBean; - } + /** + * 校验是传入的参数数据是否正常 + * @return false 表示数据有误 + */ + private boolean isValidate(String fromDate,String toDate,String fromTime,String toTime) { - /** - * 直接根据user来获取 - * - * @param user - * @param date - * @param containYesterday - * @param isLog - * @return - */ - public static ShiftInfoBean getWorkTime(User user, String date, boolean containYesterday, boolean isLog) { - return getWorkTime(user, date, containYesterday, isLog, true); + if(fromDate.length() == 0 || toDate.length() == 0){ + return false; } - - public static ShiftInfoBean getWorkTime(User user, String date, boolean containYesterday, boolean isLog, boolean isUsedRestShift) { - KQWorkTime kqWorkTime = new KQWorkTime(); - Map kqWorkTimeMap = new HashMap<>(); - kqWorkTimeMap = kqWorkTime.getWorkDuration("" + user.getUID(), date, containYesterday, isLog); - boolean isfree = "1".equalsIgnoreCase(Util.null2String(kqWorkTimeMap.get("isfree"))); - if (isfree) { - ShiftInfoBean shiftInfoBean = new ShiftInfoBean(); - shiftInfoBean.setIsfree(true); - String signStart = Util.null2String(kqWorkTimeMap.get("signStart")); - String workMins = Util.null2String(kqWorkTimeMap.get("workMins")); - shiftInfoBean.setFreeSignStart(signStart); - shiftInfoBean.setFreeWorkMins(workMins); - shiftInfoBean.setSplitDate(date); - if (signStart.length() > 0 && workMins.length() > 0) { - DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm"); - LocalTime signLocalTime = LocalTime.parse(signStart, dateTimeFormatter); - shiftInfoBean.setFreeSignEnd(signLocalTime.plusMinutes(Util.getIntValue(workMins)).format(dateTimeFormatter)); - shiftInfoBean.setFreeSignMiddle(signLocalTime.plusMinutes(Util.getIntValue(workMins) / 2).format(dateTimeFormatter)); - } - - return shiftInfoBean; - } else { - if (kqWorkTimeMap.get("shiftInfoBean") != null) { - ShiftInfoBean shiftInfoBean = (ShiftInfoBean) kqWorkTimeMap.get("shiftInfoBean"); - if (isUsedRestShift) { - int serialid = Util.getIntValue(Util.null2String(shiftInfoBean.getSerialid()), 0); - KQShiftManagementComInfo kQShiftManagementComInfo = new KQShiftManagementComInfo(); - int restShift = StringUtil.parseToInt(kQShiftManagementComInfo.getRestShift(String.valueOf(serialid)), 0); - if (restShift == 1) { - return null; - } - } - return shiftInfoBean; - } else { - return null; - } - } + if(fromTime.length() == 0 || toTime.length() == 0){ + return false; } - /** - * 直接根据user来获取 - * - * @param user - * @param date - * @param containYesterday - * @return - */ - public static ShiftInfoBean getWorkTime(User user, String date, boolean containYesterday) { - return getWorkTime(user, date, containYesterday, true); - } + DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); - public static Map getWorkButton(String resourceid, String date, boolean containYesterday) { - User user = User.getUser(Util.getIntValue(resourceid), 0); - return getWorkButton(user, date, containYesterday); - } + String fromDateTime = fromDate+" "+fromTime+":00"; + String toDateTime = toDate+" "+toTime+":00"; - public static Map getWorkButton(User user, String date, boolean containYesterday) { - KQWorkTime kqWorkTime = new KQWorkTime(); - Map kqWorkTimeMap = new HashMap<>(); - kqWorkTimeMap = kqWorkTime.getWorkButton("" + user.getUID(), date, containYesterday); + LocalDateTime localFromDateTime = LocalDateTime.parse(fromDateTime,fullFormatter); + LocalDateTime localToDateTime = LocalDateTime.parse(toDateTime,fullFormatter); - return kqWorkTimeMap; + if(localFromDateTime.isAfter(localToDateTime) || localFromDateTime.isEqual(localToDateTime)){ + return false; } - - /** - * 根据传入的用户和时段返回非工作时长 - * - * @return - */ - public Map getNonWorkDuration() { - - Map durationMap = new HashMap<>(); - try { - double D_Duration = 0.0; - double Min_Duration = 0.0; - //公众假日加班时长 - double D_Pub_Duration = 0.0; - double D_Pub_Mins = 0.0; - //工作日加班时长 - double D_Work_Duration = 0.0; - double D_Work_Mins = 0.0; - //休息日加班时长 - double D_Rest_Duration = 0.0; - double D_Rest_Mins = 0.0; - - SplitBean splitBean = new SplitBean(); - splitBean.setFromDate(fromDate); - splitBean.setFromTime(fromTime); - splitBean.setToDate(toDate); - splitBean.setToTime(toTime); - splitBean.setResourceId(resourceid); - splitBean.setFromdatedb(fromDate); - splitBean.setTodatedb(toDate); - splitBean.setFromtimedb(fromTime); - splitBean.setTotimedb(toTime); - splitBean.setDurationrule(durationrule); - splitBean.setComputingMode(computingMode); - splitBean.setDurationTypeEnum(DurationTypeEnum.OVERTIME); - splitBean.setOvertime_type(overtime_type); - - List splitBeans = new ArrayList<>(); - - NonWorkDurationChain hourUnitSplitChain = new NonHourUnitSplitChain(splitBeans); - NonWorkDurationChain dayUnitSplitChain = new NonDayUnitSplitChain(splitBeans); - NonWorkDurationChain halfUnitSplitChain = new NonHalfUnitSplitChain(splitBeans); - NonWorkDurationChain wholeUnitSplitChain = new NonWholeUnitSplitChain(splitBeans); - - //设置执行链 - hourUnitSplitChain.setDurationChain(dayUnitSplitChain); - dayUnitSplitChain.setDurationChain(halfUnitSplitChain); - halfUnitSplitChain.setDurationChain(wholeUnitSplitChain); - //把初始数据设置进去 - hourUnitSplitChain.handleDuration(splitBean); - - //每一天的流程时长都在这里了,搞吧 - for (SplitBean sb : splitBeans) { -// * 1-公众假日、2-工作日、3-休息日 - int changeType = sb.getChangeType(); - double durations = Util.getDoubleValue(sb.getDuration(), 0.0); - double durationMins = sb.getD_Mins(); - if (1 == changeType) { - D_Pub_Duration += durations; - D_Pub_Mins += durationMins; - } - if (2 == changeType) { - D_Work_Duration += durations; - D_Work_Mins += durationMins; - } - if (3 == changeType) { - D_Rest_Duration += durations; - D_Rest_Mins += durationMins; - } - } - Min_Duration = D_Pub_Mins + D_Work_Mins + D_Rest_Mins; - - if ("3".equalsIgnoreCase(durationrule) || "5".equalsIgnoreCase(durationrule) || "6".equalsIgnoreCase(durationrule)) { - double d_hour = Min_Duration / 60.0; - durationMap.put("duration", KQDurationCalculatorUtil.getDurationRound("" + d_hour)); - } else { - double oneDayHour = KQFlowUtil.getOneDayHour(DurationTypeEnum.OVERTIME, ""); - double d_day = Min_Duration / (oneDayHour * 60); - durationMap.put("duration", KQDurationCalculatorUtil.getDurationRound("" + d_day)); - } - - durationMap.put("min_duration", KQDurationCalculatorUtil.getDurationRound("" + Min_Duration)); - - } catch (Exception e) { - e.printStackTrace(); - } - return durationMap; + return true; + } + + /** + * 得到排除非工作时间的时长 + * @param fromDate + * @param fromTime + * @param toDate + * @param toTime + * @param resourceid + * @return + */ + public Map getTotalWorkingDurations(String fromDate,String fromTime,String toDate,String toTime,String resourceid){ + KQDurationCalculatorUtil kqDurationCalculatorUtil =new KQDurationCalculatorUtil.DurationParamBuilder(resourceid). + fromDateParam(fromDate).toDateParam(toDate).fromTimeParam(fromTime).toTimeParam(toTime).durationRuleParam("1") + .computingModeParam("1").durationTypeEnumParam(DurationTypeEnum.COMMON_CAL).build(); + + Map durationMap = kqDurationCalculatorUtil.getWorkDuration(); + return durationMap; + } + + /** + * 得到排除非工作时间的天数 + * @param fromDate + * @param fromTime + * @param toDate + * @param toTime + * @param resourceid + * @return + */ + public String getTotalWorkingDays(String fromDate,String fromTime,String toDate,String toTime,String resourceid){ + Map durationMap = getTotalWorkingDurations(fromDate,fromTime,toDate,toTime,resourceid); + + String duration4day = Util.null2s(Util.null2String(durationMap.get("duration")),"0"); + return KQDurationCalculatorUtil.getDurationRound(duration4day); + } + + /** + * 得到排除非工作时间的小时 + * @param fromDate + * @param fromTime + * @param toDate + * @param toTime + * @param resourceid + * @return + */ + public String getTotalWorkingHours(String fromDate,String fromTime,String toDate,String toTime,String resourceid){ + Map durationMap = getTotalWorkingDurations(fromDate,fromTime,toDate,toTime,resourceid); + String duration4min = Util.null2s(Util.null2String(durationMap.get("min_duration")),"0"); + double duration4hour = Util.getDoubleValue(duration4min)/60.0; + + return KQDurationCalculatorUtil.getDurationRound(duration4hour+""); + } + + /** + * 得到排除非工作时间的分钟 + * @param fromDate + * @param fromTime + * @param toDate + * @param toTime + * @param resourceid + * @return + */ + public String getTotalWorkingMins(String fromDate,String fromTime,String toDate,String toTime,String resourceid){ + Map durationMap = getTotalWorkingDurations(fromDate,fromTime,toDate,toTime,resourceid); + String duration4min = Util.null2s(Util.null2String(durationMap.get("min_duration")),"0"); + + return KQDurationCalculatorUtil.getDurationRound(duration4min+""); + } + + /** + * 得到非工作时间的天数 + * @param fromDate + * @param fromTime + * @param toDate + * @param toTime + * @param resourceid + * @return + */ + public String getTotalNonWorkingDays(String fromDate,String fromTime,String toDate,String toTime,String resourceid){ + KQDurationCalculatorUtil kqDurationCalculatorUtil =new KQDurationCalculatorUtil.DurationParamBuilder(resourceid). + fromDateParam(fromDate).toDateParam(toDate).fromTimeParam(fromTime).toTimeParam(toTime).computingModeParam("1"). + durationRuleParam("1").durationTypeEnumParam(DurationTypeEnum.OVERTIME).build(); + Map durationMap = kqDurationCalculatorUtil.getNonWorkDuration(); + + String duration = Util.null2String(durationMap.get("duration")); + return KQDurationCalculatorUtil.getDurationRound(duration); + } + + /** + * 得到非工作时间的小时 + * @param fromDate + * @param fromTime + * @param toDate + * @param toTime + * @param resourceid + * @return + */ + public String getTotalNonWorkingHours(String fromDate,String fromTime,String toDate,String toTime,String resourceid){ + KQDurationCalculatorUtil kqDurationCalculatorUtil =new KQDurationCalculatorUtil.DurationParamBuilder(resourceid). + fromDateParam(fromDate).toDateParam(toDate).fromTimeParam(fromTime).toTimeParam(toTime).computingModeParam("1"). + durationRuleParam("3").durationTypeEnumParam(DurationTypeEnum.OVERTIME).build(); + Map durationMap = kqDurationCalculatorUtil.getNonWorkDuration(); + + String duration = Util.null2String(durationMap.get("duration")); + return KQDurationCalculatorUtil.getDurationRound(duration); + } + + /** + * 考勤通用精度 2 + * @param duration + * @return + */ + public static String getDurationRound(String duration){ + if(HrmScheduleDiffUtil.isFromFlow()){ + return Util.round(duration,5) ; } + return Util.round(duration, 2); + } + + /** + * 考勤流程中间表精度 5 + * @param duration + * @return + */ + public static String getDurationRound5(String duration){ + return Util.round(duration, 5); + } + + /** + * 针对可能存在的多种参数类型 创建参数静态内部类Builder + */ + public static class DurationParamBuilder { + + //必选变量 人员看怎么都是需要的 + private final String resourceid; + //可选变量 + private String fromDate = ""; + private String toDate = ""; + private String fromTime = ""; + private String toTime = ""; /** - * 根据传入的用户和时段返回工作时长 - * - * @return + * 请假用的请假类型 */ - public Map getWorkDuration() { - writeLog("KQDurationCalculatorUtil-getWorkDuration"); - - Map durationMap = new HashMap<>(); - try { - if (!isValidate(fromDate, toDate, fromTime, toTime)) { - durationMap.put("duration", "0.0"); - return durationMap; - } - if (durationTypeEnum != DurationTypeEnum.COMMON_CAL) { - kqLog.info("getWorkDuration:" + durationTypeEnum.getDurationType() + ":fromDate:" + fromDate + ":toDate:" + toDate + ":fromTime:" + fromTime + ":toTime:" + toTime + ":durationrule:" + durationrule + ":computingMode:" + computingMode); - } - //如果是加班 - if (durationTypeEnum == DurationTypeEnum.OVERTIME) { - return getNonWorkDuration(); - } - //时长 - double D_Duration = 0.0; - //分钟数 - double Min_Duration = 0.0; - - SplitBean splitBean = new SplitBean(); - splitBean.setFromDate(fromDate); - splitBean.setFromTime(fromTime); - splitBean.setToDate(toDate); - splitBean.setToTime(toTime); - splitBean.setResourceId(resourceid); - splitBean.setFromdatedb(fromDate); - splitBean.setTodatedb(toDate); - splitBean.setFromtimedb(fromTime); - splitBean.setTotimedb(toTime); - splitBean.setDurationrule(durationrule); - splitBean.setDurationTypeEnum(durationTypeEnum); - splitBean.setComputingMode(computingMode); - splitBean.setNewLeaveType(newLeaveType); - writeLog("getWorkDuration-" + splitBean); - if ("2".equalsIgnoreCase(computingMode)) { - double oneDayHour = KQFlowUtil.getOneDayHour(durationTypeEnum, newLeaveType); - splitBean.setOneDayHour(oneDayHour); - if (durationTypeEnum == DurationTypeEnum.LEAVE) { - //只有自然日 请假才有这个排除节假日、休息日的功能 - splitBean.setFilterholidays(KQLeaveRulesBiz.getFilterHolidays(splitBean.getNewLeaveType())); - } - } - if (durationTypeEnum == DurationTypeEnum.LEAVE || durationTypeEnum == DurationTypeEnum.LEAVEBACK) { - if (newLeaveType.length() > 0) { - KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); - String conversion = kqLeaveRulesComInfo.getConversion(newLeaveType); - splitBean.setConversion(conversion); - } - } - - List splitBeans = new ArrayList<>(); - - WorkDurationChain hourUnitSplitChain = new WorkHourUnitSplitChain(splitBeans); - WorkDurationChain dayUnitSplitChain = new WorkDayUnitSplitChain(splitBeans); - WorkDurationChain halfUnitSplitChain = new WorkHalfUnitSplitChain(splitBeans); - WorkDurationChain wholeUnitSplitChain = new WorkWholeUnitSplitChain(splitBeans); - - //设置执行链 - hourUnitSplitChain.setDurationChain(dayUnitSplitChain); - dayUnitSplitChain.setDurationChain(halfUnitSplitChain); - halfUnitSplitChain.setDurationChain(wholeUnitSplitChain); - //把初始数据设置进去 - hourUnitSplitChain.handleDuration(splitBean); - - //每一天的流程时长都在这里了,搞吧 - for (SplitBean sb : splitBeans) { - double durations = Util.getDoubleValue(sb.getDuration(), 0.0); - double min_durations = sb.getD_Mins(); - D_Duration += durations; - Min_Duration += min_durations; - } - - durationMap.put("duration", KQDurationCalculatorUtil.getDurationRound("" + D_Duration)); - durationMap.put("min_duration", KQDurationCalculatorUtil.getDurationRound("" + Min_Duration)); - - } catch (Exception e) { - e.printStackTrace(); - } - return durationMap; - } - + private String newLeaveType = ""; /** - * 校验是传入的参数数据是否正常 - * - * @return false 表示数据有误 + * 单位 + * 1-按天出差 + * 2-按半天出差 + * 3-按小时出差 + * 4-按整天出差 */ - private boolean isValidate(String fromDate, String toDate, String fromTime, String toTime) { - - if (fromDate.length() == 0 || toDate.length() == 0) { - return false; - } - if (fromTime.length() == 0 || toTime.length() == 0) { - return false; - } - - DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); - - String fromDateTime = fromDate + " " + fromTime + ":00"; - String toDateTime = toDate + " " + toTime + ":00"; - - LocalDateTime localFromDateTime = LocalDateTime.parse(fromDateTime, fullFormatter); - LocalDateTime localToDateTime = LocalDateTime.parse(toDateTime, fullFormatter); - - if (localFromDateTime.isAfter(localToDateTime) || localFromDateTime.isEqual(localToDateTime)) { - return false; - } - return true; - } - + private String durationrule = ""; /** - * 得到排除非工作时间的时长 - * - * @param fromDate - * @param fromTime - * @param toDate - * @param toTime - * @param resourceid - * @return + * 时长计算方式 + * 1-按照工作日计算请假时长 + * 2-按照自然日计算请假时长 */ - public Map getTotalWorkingDurations(String fromDate, String fromTime, String toDate, String toTime, String resourceid) { - KQDurationCalculatorUtil kqDurationCalculatorUtil = new DurationParamBuilder(resourceid). - fromDateParam(fromDate).toDateParam(toDate).fromTimeParam(fromTime).toTimeParam(toTime).durationRuleParam("1") - .computingModeParam("1").durationTypeEnumParam(DurationTypeEnum.COMMON_CAL).build(); - - Map durationMap = kqDurationCalculatorUtil.getWorkDuration(); - return durationMap; - } + private String computingMode = ""; /** - * 得到排除非工作时间的天数 - * - * @param fromDate - * @param fromTime - * @param toDate - * @param toTime - * @param resourceid - * @return + * 加班类型 */ - public String getTotalWorkingDays(String fromDate, String fromTime, String toDate, String toTime, String resourceid) { - Map durationMap = getTotalWorkingDurations(fromDate, fromTime, toDate, toTime, resourceid); - - String duration4day = Util.null2s(Util.null2String(durationMap.get("duration")), "0"); - return KQDurationCalculatorUtil.getDurationRound(duration4day); - } + private String overtime_type = ""; /** - * 得到排除非工作时间的小时 - * - * @param fromDate - * @param fromTime - * @param toDate - * @param toTime - * @param resourceid - * @return + * 哪种类型的时长计算,请假还是出差还是公出还是加班 */ - public String getTotalWorkingHours(String fromDate, String fromTime, String toDate, String toTime, String resourceid) { - Map durationMap = getTotalWorkingDurations(fromDate, fromTime, toDate, toTime, resourceid); - String duration4min = Util.null2s(Util.null2String(durationMap.get("min_duration")), "0"); - double duration4hour = Util.getDoubleValue(duration4min) / 60.0; + private DurationTypeEnum durationTypeEnum; - return KQDurationCalculatorUtil.getDurationRound(duration4hour + ""); + public DurationParamBuilder(String resourceid) { + this.resourceid = resourceid; + //初始化的时候需要把其他参数先清空下 + this.fromDate = ""; + this.toDate = ""; + this.fromTime = ""; + this.toTime = ""; + this.newLeaveType = ""; + this.durationrule = ""; + this.computingMode = ""; + this.overtime_type = ""; } - /** - * 得到排除非工作时间的分钟 - * - * @param fromDate - * @param fromTime - * @param toDate - * @param toTime - * @param resourceid - * @return - */ - public String getTotalWorkingMins(String fromDate, String fromTime, String toDate, String toTime, String resourceid) { - Map durationMap = getTotalWorkingDurations(fromDate, fromTime, toDate, toTime, resourceid); - String duration4min = Util.null2s(Util.null2String(durationMap.get("min_duration")), "0"); - - return KQDurationCalculatorUtil.getDurationRound(duration4min + ""); + //成员方法返回其自身,所以可以链式调用 + public DurationParamBuilder fromDateParam(final String fromDate) { + this.fromDate = fromDate; + return this; } - /** - * 得到非工作时间的天数 - * - * @param fromDate - * @param fromTime - * @param toDate - * @param toTime - * @param resourceid - * @return - */ - public String getTotalNonWorkingDays(String fromDate, String fromTime, String toDate, String toTime, String resourceid) { - KQDurationCalculatorUtil kqDurationCalculatorUtil = new DurationParamBuilder(resourceid). - fromDateParam(fromDate).toDateParam(toDate).fromTimeParam(fromTime).toTimeParam(toTime).computingModeParam("1"). - durationRuleParam("1").durationTypeEnumParam(DurationTypeEnum.OVERTIME).build(); - Map durationMap = kqDurationCalculatorUtil.getNonWorkDuration(); - - String duration = Util.null2String(durationMap.get("duration")); - return KQDurationCalculatorUtil.getDurationRound(duration); + public DurationParamBuilder toDateParam(final String toDate) { + this.toDate = toDate; + return this; } - /** - * 得到非工作时间的小时 - * - * @param fromDate - * @param fromTime - * @param toDate - * @param toTime - * @param resourceid - * @return - */ - public String getTotalNonWorkingHours(String fromDate, String fromTime, String toDate, String toTime, String resourceid) { - KQDurationCalculatorUtil kqDurationCalculatorUtil = new DurationParamBuilder(resourceid). - fromDateParam(fromDate).toDateParam(toDate).fromTimeParam(fromTime).toTimeParam(toTime).computingModeParam("1"). - durationRuleParam("3").durationTypeEnumParam(DurationTypeEnum.OVERTIME).build(); - Map durationMap = kqDurationCalculatorUtil.getNonWorkDuration(); - - String duration = Util.null2String(durationMap.get("duration")); - return KQDurationCalculatorUtil.getDurationRound(duration); + public DurationParamBuilder fromTimeParam(final String fromTime) { + this.fromTime = fromTime; + return this; } - /** - * 考勤通用精度 2 - * - * @param duration - * @return - */ - public static String getDurationRound(String duration) { - if (HrmScheduleDiffUtil.isFromFlow()) { - return Util.round(duration, 5); - } - return Util.round(duration, 2); + public DurationParamBuilder toTimeParam(final String toTime) { + this.toTime = toTime; + return this; } - /** - * 考勤流程中间表精度 5 - * - * @param duration - * @return - */ - public static String getDurationRound5(String duration) { - return Util.round(duration, 5); + public DurationParamBuilder newLeaveTypeParam(final String newLeaveType) { + this.newLeaveType = newLeaveType; + return this; } - /** - * 针对可能存在的多种参数类型 创建参数静态内部类Builder - */ - public static class DurationParamBuilder { - - //必选变量 人员看怎么都是需要的 - private final String resourceid; - - //可选变量 - private String fromDate = ""; - private String toDate = ""; - private String fromTime = ""; - private String toTime = ""; - /** - * 请假用的请假类型 - */ - private String newLeaveType = ""; - /** - * 单位 - * 1-按天出差 - * 2-按半天出差 - * 3-按小时出差 - * 4-按整天出差 - */ - private String durationrule = ""; - /** - * 时长计算方式 - * 1-按照工作日计算请假时长 - * 2-按照自然日计算请假时长 - */ - private String computingMode = ""; - - /** - * 加班类型 - */ - private String overtime_type = ""; - - /** - * 哪种类型的时长计算,请假还是出差还是公出还是加班 - */ - private DurationTypeEnum durationTypeEnum; - - public DurationParamBuilder(String resourceid) { - this.resourceid = resourceid; - //初始化的时候需要把其他参数先清空下 - this.fromDate = ""; - this.toDate = ""; - this.fromTime = ""; - this.toTime = ""; - this.newLeaveType = ""; - this.durationrule = ""; - this.computingMode = ""; - this.overtime_type = ""; - } - - //成员方法返回其自身,所以可以链式调用 - public DurationParamBuilder fromDateParam(final String fromDate) { - this.fromDate = fromDate; - return this; - } - - public DurationParamBuilder toDateParam(final String toDate) { - this.toDate = toDate; - return this; - } - - public DurationParamBuilder fromTimeParam(final String fromTime) { - this.fromTime = fromTime; - return this; - } - - public DurationParamBuilder toTimeParam(final String toTime) { - this.toTime = toTime; - return this; - } - - public DurationParamBuilder newLeaveTypeParam(final String newLeaveType) { - this.newLeaveType = newLeaveType; - return this; - } - - public DurationParamBuilder durationRuleParam(final String durationrule) { - this.durationrule = durationrule; - return this; - } - - public DurationParamBuilder computingModeParam(final String computingMode) { - this.computingMode = computingMode; - return this; - } - - public DurationParamBuilder overtime_typeParam(final String overtime_type) { - this.overtime_type = overtime_type; - return this; - } - - public DurationParamBuilder durationTypeEnumParam(final DurationTypeEnum durationTypeEnum) { - this.durationTypeEnum = durationTypeEnum; - return this; - } + public DurationParamBuilder durationRuleParam(final String durationrule) { + this.durationrule = durationrule; + return this; + } + public DurationParamBuilder computingModeParam(final String computingMode) { + this.computingMode = computingMode; + return this; + } + public DurationParamBuilder overtime_typeParam(final String overtime_type) { + this.overtime_type = overtime_type; + return this; + } + public DurationParamBuilder durationTypeEnumParam(final DurationTypeEnum durationTypeEnum) { + this.durationTypeEnum = durationTypeEnum; + return this; + } - //Builder的build方法,返回外部类的实例 - public KQDurationCalculatorUtil build() { - return new KQDurationCalculatorUtil(this); - } + //Builder的build方法,返回外部类的实例 + public KQDurationCalculatorUtil build() { + return new KQDurationCalculatorUtil(this); } + } } diff --git a/src/com/engine/kq/wfset/util/SplitActionUtil.java b/src/com/engine/kq/wfset/util/SplitActionUtil.java index dc26692..131257d 100644 --- a/src/com/engine/kq/wfset/util/SplitActionUtil.java +++ b/src/com/engine/kq/wfset/util/SplitActionUtil.java @@ -2,7 +2,17 @@ package com.engine.kq.wfset.util; import com.alibaba.fastjson.JSON; import com.engine.kq.bean.KQHrmScheduleSign; -import com.engine.kq.biz.*; +import com.engine.kq.biz.KQBalanceOfLeaveBiz; +import com.engine.kq.biz.KQFlowDataBiz; +import com.engine.kq.biz.KQOverTimeRuleCalBiz; +import com.engine.kq.biz.KQOvertimeRulesBiz; +import com.engine.kq.biz.KQScheduleSignBiz; +import com.engine.kq.biz.KQSettingsBiz; +import com.engine.kq.biz.KQShiftPersonalizedRuleCominfo; +import com.engine.kq.biz.KQShiftPersonalizedRuleDetailComInfo; +import com.engine.kq.biz.KQShiftRuleInfoBiz; +import com.engine.kq.biz.KQTimesArrayComInfo; +import com.engine.kq.biz.KQWorkTime; import com.engine.kq.biz.chain.duration.WorkHalfUnitSplitChain; import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean; import com.engine.kq.entity.KQOvertimeRulesDetailEntity; diff --git a/src/weaver/interfaces/bnkq/action/UpdateCcTimeAction.java b/src/weaver/interfaces/bnkq/action/UpdateCcTimeAction.java index 6a637e6..c5f6617 100644 --- a/src/weaver/interfaces/bnkq/action/UpdateCcTimeAction.java +++ b/src/weaver/interfaces/bnkq/action/UpdateCcTimeAction.java @@ -186,4 +186,19 @@ public class UpdateCcTimeAction implements Action { rsInsert.executeUpdate(sql, requestid, userid, fromDate, "08:00", toDate, "17:00", MaxHours, durationrule, fromDate, newleavetype, subcompany, department, wfid, tablename); bb.writeLog("insertSql:" + sql); } + + + public static void main(String[] args) { + Set all = new HashSet<>(); + all.add("2023-12-20"); + List back = days("2023-12-20", "2023-12-20"); + all.addAll(back); + all.add("2023-12-20"); + for (String date : all) { + System.out.println(date); + } + + + } + }