From a0acd57a3102673ba99873dbbda53afef8eab770 Mon Sep 17 00:00:00 2001 From: chenwei <3291673014@qq.com> Date: Tue, 7 May 2024 22:47:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A5=E7=A6=BB=E8=81=8C=E5=B7=A5=E6=97=B6?= =?UTF-8?q?=E5=8A=A0=E4=B8=8A=E8=80=83=E5=8B=A4=E6=8A=A5=E8=A1=A8=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/engine/kq/biz/KQFormatData.java | 50 +++ src/com/engine/kq/biz/KQReportBiz.java | 304 +++++++++++++++++- .../kq/cmd/report/ExportDailyExcelCmd.java | 11 +- .../engine/kq/cmd/report/ExportExcelCmd.java | 9 + .../kq/cmd/report/GetKQDailyReportCmd.java | 11 + .../engine/kq/cmd/report/GetKQReportCmd.java | 202 +++++++++++- 6 files changed, 581 insertions(+), 6 deletions(-) diff --git a/src/com/engine/kq/biz/KQFormatData.java b/src/com/engine/kq/biz/KQFormatData.java index 2db7629..2ab25a5 100644 --- a/src/com/engine/kq/biz/KQFormatData.java +++ b/src/com/engine/kq/biz/KQFormatData.java @@ -27,7 +27,9 @@ import weaver.soa.workflow.request.RequestService; import java.math.BigDecimal; import java.math.RoundingMode; +import java.time.Duration; import java.time.LocalDate; +import java.time.LocalDateTime; import java.time.LocalTime; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; @@ -964,6 +966,54 @@ public class KQFormatData extends BaseBean { leaveEarlyMins = 0; graveLeaveEarlyMins = 0; } + + //增加功能--如果上班卡和下班卡相差十分钟,旷工计一天 + String inTemp = ""; + String outTemp = ""; + for (int j = 0; lsCheckInfo != null && j < lsCheckInfo.size(); j++) { + Map checkInfo = (Map) lsCheckInfo.get(j); + String signType = Util.null2String(checkInfo.get("signType")); + String signTime = Util.null2String(checkInfo.get("signTime")); + String signDate = Util.null2String(checkInfo.get("signDate")); + + if (signType.equals("1")) { + inTemp = signDate + " " + signTime; + } + if (signType.equals("2")) { + outTemp = signDate + " " + signTime; + } + + } + + bb.writeLog("inTemp:" + inTemp); + bb.writeLog("outTemp:" + outTemp); + + if(StringUtils.isNotBlank(inTemp) && StringUtils.isNotBlank(outTemp)){ + + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + LocalDateTime startTime = LocalDateTime.parse(inTemp, formatter); + LocalDateTime endTime = LocalDateTime.parse(outTemp, formatter); + + // 计算两个LocalDateTime对象之间的Duration + Duration duration = Duration.between(startTime, endTime); + + // 将Duration转换为分钟 + long minutesLong = duration.toMinutes(); + int minutes = (int) minutesLong; + if(minutes<=10){ + //优化:考虑请假公出出差的时长 + if (evectionMins == 0 && leaveMins == 0 && outMins == 0) { + absenteeismMins = 480; + } else { + absenteeismMins = 480 - leaveMins - evectionMins - outMins; + } + beLateMins = 0; + graveBeLateMins = 0; + leaveEarlyMins = 0; + graveLeaveEarlyMins = 0; + } + } + //计算实际出勤时间(出差公出算出勤)=应出勤-旷工-请假-迟到-早退 bb.writeLog("workMins: " + workMins); bb.writeLog("absenteeismMins: " + absenteeismMins); diff --git a/src/com/engine/kq/biz/KQReportBiz.java b/src/com/engine/kq/biz/KQReportBiz.java index a9c61f2..7599e43 100644 --- a/src/com/engine/kq/biz/KQReportBiz.java +++ b/src/com/engine/kq/biz/KQReportBiz.java @@ -430,6 +430,12 @@ public class KQReportBiz extends BaseBean { //考勤二开--异常考勤转事假 datas.putAll(getAbnAttToComLeaveData(params,user)); + //考勤二开--上月请假 + datas.putAll(getFlowLastLeaveData(params,user)); + //考勤二开--上月销假 + datas.putAll(getFlowLeaveLastBackData(params,user)); + //考勤二开--上月加班 + datas.putAll(getFlowLastOverTimeDataNew(params,user)); }catch (Exception e){ writeLog(e); @@ -1303,14 +1309,14 @@ public class KQReportBiz extends BaseBean { } //再查批量加班申请流程 String overtimeBatchTableName = basebean.getPropValue("project_sskj","overtimeBatchTableName"); - String acqOverTimeBatchSql = "select jbry, ksrq, kssj, jsrq, jssj from ( " + - " select a.jbry, a.ksrq, a.kssj, a.jsrq, a.jssj, b.subcompanyid1, b.departmentid, b.managerstr, b.managerid, b.loginid " + + String acqOverTimeBatchSql = "select resourceid, ksrq, kssj, jsrq, jssj from ( " + + " select a.jbry as resourceid, a.ksrq, a.kssj, a.jsrq, a.jssj, b.subcompanyid1, b.departmentid, b.managerstr, b.managerid, b.loginid " + " FROM "+overtimeBatchTableName+"_dt1 a " + " left join hrmresource b on b.id = a.jbry " + " ) c where c.ksrq >= '"+fromDate+"' and c.jsrq <='" + toDate + "' " + sqlWhere; rs.executeQuery(acqOverTimeBatchSql); while (rs.next()) { - String resourceid = Util.null2String(rs.getString("jbry")); + String resourceid = Util.null2String(rs.getString("resourceid")); String fromdate = Util.null2String(rs.getString("ksrq")); String fromtime = Util.null2String(rs.getString("kssj")); String todate = Util.null2String(rs.getString("jsrq")); @@ -1727,6 +1733,100 @@ public class KQReportBiz extends BaseBean { return datas; } + /** + * 获取上月请假数据 + * @param params + * @param user + * @return + */ + public Map getFlowLastLeaveData(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 ="7"; + 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.LEAVE.getTablename()+" b "+ + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +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"); + if( !newleavetype.equals("5")){ + continue; + } + + 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+"|lastleaveType_"+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,format(value)); + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + //获取打卡数据用于判断外勤,补卡等信息=============================== public Map getCardMap(Map params, User user){ @@ -1903,6 +2003,97 @@ public class KQReportBiz extends BaseBean { return datas; } + /** + * 获取上月销假数据 + * @param params + * @param user + * @return + */ + public Map getFlowLeaveLastBackData(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 ="7"; + 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+"' " +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+"|lastleavebackType_"+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,format(value)); + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + /** * 获取考勤变更流程数据 * @param params @@ -2476,6 +2667,113 @@ public class KQReportBiz extends BaseBean { return datas; } + /** + * 获取上月实际加班数据,包括流程,打卡生成的 + * @return + */ + public Map getFlowLastOverTimeDataNew(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz(); + 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 a.id 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<>'' "); + } + + int uintType = kqOvertimeRulesBiz.getMinimumUnit();//当前加班单位 + double hoursToDay = kqOvertimeRulesBiz.getHoursToDay();//当前天跟小时计算关系 + + String valueField = ""; + + sql = " select resourceid,changeType, sum(cast(duration_min as decimal(18,4))) as val,paidLeaveEnable "+ + " from hrmresource a, kq_flow_overtime b "+ + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere+ + " group by resourceid,changeType,paidLeaveEnable "; + rs.execute(sql); + kqLog.info("getFlowOverTimeDataNew:sql:"+sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + String paidLeaveEnable = rs.getString("paidLeaveEnable"); + int changeType =rs.getInt("changeType");//1-节假日、2-工作日、3-休息日 + double value = rs.getDouble("val")<0?0:rs.getDouble("val"); + if(uintType==3 || uintType== 5 || uintType== 6){//按小时计算 + value = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(value/(60.0)+"")); + }else{//按天计算 + value = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(value/(60.0*hoursToDay)+"")); + } + String flowType = ""; + if(changeType==1){ + flowType = "holidayOvertime"; + }else if(changeType==2){ + flowType = "workingDayOvertime"; + }else if(changeType==3){ + flowType = "restDayOvertime"; + } + if("1".equalsIgnoreCase(paidLeaveEnable)){ + //1表示关联调休 + flowType += "_4leave"; + }else{ + //0表示不关联调休 + flowType += "_nonleave"; + } + String key = resourceid+"|"+flowType+"last"; + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + if(datas.containsKey(key)){ + double tmpVal = Util.getDoubleValue(Util.null2String(datas.get(key)),0.0); + tmpVal += value; + datas.put(key,format(tmpVal)); + }else{ + datas.put(key,format(value)); + } + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + /** * 获取加班数据 diff --git a/src/com/engine/kq/cmd/report/ExportDailyExcelCmd.java b/src/com/engine/kq/cmd/report/ExportDailyExcelCmd.java index 8ffc2a7..802d516 100644 --- a/src/com/engine/kq/cmd/report/ExportDailyExcelCmd.java +++ b/src/com/engine/kq/cmd/report/ExportDailyExcelCmd.java @@ -543,7 +543,16 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand> { data.add(restdayValue); data.add(fieldValue); + continue; + }else if(fieldName.equals("reissuecard")){//补卡 + int intValue = Util.getIntValue(Util.null2String(flowData.get(id + "|reissueCard"))); + if (intValue < 0) { + fieldValue = "0"; + } else { + fieldValue = String.valueOf(intValue); + } + data.add(fieldValue); continue; } else if(fieldName.equals("overtime")){ // fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|workingDayOvertime_nonleave"))); diff --git a/src/com/engine/kq/cmd/report/GetKQDailyReportCmd.java b/src/com/engine/kq/cmd/report/GetKQDailyReportCmd.java index cae8232..571e011 100644 --- a/src/com/engine/kq/cmd/report/GetKQDailyReportCmd.java +++ b/src/com/engine/kq/cmd/report/GetKQDailyReportCmd.java @@ -516,6 +516,17 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand 0) { diff --git a/src/com/engine/kq/cmd/report/GetKQReportCmd.java b/src/com/engine/kq/cmd/report/GetKQReportCmd.java index 52fd6bc..99587e4 100644 --- a/src/com/engine/kq/cmd/report/GetKQReportCmd.java +++ b/src/com/engine/kq/cmd/report/GetKQReportCmd.java @@ -6,6 +6,7 @@ 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.enums.KqSplitFlowTypeEnum; import com.engine.kq.util.KQDurationCalculatorUtil; import com.engine.kq.util.PageUidFactory; import org.apache.commons.lang3.StringUtils; @@ -25,8 +26,12 @@ import weaver.systeminfo.SystemEnv; import java.math.BigDecimal; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; import java.util.*; +import static com.api.formmode.cache.ModeExpandPageComInfo.groupid; + public class GetKQReportCmd extends AbstractCommonCommand> { BaseBean bb = new BaseBean(); @@ -457,6 +462,118 @@ public class GetKQReportCmd extends AbstractCommonCommand> { for(int i=0;serialIds!=null&&i 0){ + flowLeaveData = KQDurationCalculatorUtil.getDurationRound(b_flowLeaveData); + }else{ + flowLeaveData = KQDurationCalculatorUtil.getDurationRound(Util.null2String(Util.getDoubleValue(leaveData,0.0)-Util.getDoubleValue(leavebackData,0.0))); + } + double leaveDuration = Math.max(Util.getDoubleValue(Util.null2String(flowLeaveData)),0.00); + + double temp = overtimeDuration - leaveDuration; + fieldValue = String.valueOf(temp); + + } else if(fieldName.equals("lastRemOt")){//上月加班剩余 + double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|workingDayOvertime_4leavelast"))); + workingDayOvertime_4leave = workingDayOvertime_4leave<0?0:workingDayOvertime_4leave; + double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|restDayOvertime_4leavelast"))); + restDayOvertime_4leave = restDayOvertime_4leave<0?0:restDayOvertime_4leave; + double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|holidayOvertime_4leavelast"))); + holidayOvertime_4leave = holidayOvertime_4leave<0?0:holidayOvertime_4leave; + + double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|workingDayOvertime_nonleavelast"))); + workingDayOvertime_nonleave = workingDayOvertime_nonleave<0?0:workingDayOvertime_nonleave; + double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|restDayOvertime_nonleavelast"))); + restDayOvertime_nonleave = restDayOvertime_nonleave<0?0:restDayOvertime_nonleave; + double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|holidayOvertime_nonleavelast"))); + holidayOvertime_nonleave = holidayOvertime_nonleave<0?0:holidayOvertime_nonleave; + + double overtimeDuration = workingDayOvertime_4leave+restDayOvertime_4leave+holidayOvertime_4leave+ + workingDayOvertime_nonleave+restDayOvertime_nonleave+holidayOvertime_nonleave; + + //请假时长统计 + String leaveData = Util.null2String(flowData.get(id+"|lastleaveType_5")); + String leavebackData = Util.null2s(Util.null2String(flowData.get(id+"|lastleavebackType_5")),"0.0"); + String b_flowLeaveData = ""; + String flowLeaveData = ""; + try{ + //以防止出现精度问题 + if(leaveData.length() == 0){ + leaveData = "0.0"; + } + if(leavebackData.length() == 0){ + leavebackData = "0.0"; + } + BigDecimal b_leaveData = new BigDecimal(leaveData); + BigDecimal b_leavebackData = new BigDecimal(leavebackData); + b_flowLeaveData = b_leaveData.subtract(b_leavebackData).toString(); + if(Util.getDoubleValue(b_flowLeaveData, -1) < 0){ + b_flowLeaveData = "0.0"; + } + }catch (Exception e){ + writeLog("GetKQReportCmd:leaveData"+leaveData+":leavebackData:"+leavebackData+":"+e); + } + + //考虑下冻结的数据 + if(b_flowLeaveData.length() > 0){ + flowLeaveData = KQDurationCalculatorUtil.getDurationRound(b_flowLeaveData); + }else{ + flowLeaveData = KQDurationCalculatorUtil.getDurationRound(Util.null2String(Util.getDoubleValue(leaveData,0.0)-Util.getDoubleValue(leavebackData,0.0))); + } + double leaveDuration = Math.max(Util.getDoubleValue(Util.null2String(flowLeaveData)),0.00); + + double temp = overtimeDuration - leaveDuration; + fieldValue = String.valueOf(temp); + } else if(kqReportFieldComInfo.getParentid().equals("overtime")||kqReportFieldComInfo.getParentid().equals("overtime_nonleave") ||kqReportFieldComInfo.getParentid().equals("overtime_4leave")||fieldName.equals("businessLeave") || fieldName.equals("officialBusiness")){ if(fieldName.equals("overtimeTotal")){ @@ -502,7 +619,7 @@ public class GetKQReportCmd extends AbstractCommonCommand> { }else{ fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id+"|"+fieldName))); } - }else if("holiDuration".equals(fieldName)){ + } else if("holiDuration".equals(fieldName)){ int intValue = Util.getIntValue(Util.null2String(flowData.get("HoliDurationData|" + id))); if (intValue >= 0) { data.put(fieldName,intValue); @@ -529,7 +646,49 @@ public class GetKQReportCmd extends AbstractCommonCommand> { } bb.writeLog("劳务公司 fieldValue: " + fieldValue); data.put(fieldName, fieldValue); - }else if ("laborHours".equals(kqReportFieldComInfo.getParentid()) ) { + } else if ("startOrEndDays".equals(fieldName)) {//考勤二开--入离职工时 + int absenceDays = 0; + if ("3".equals(typeselect) || "7".equals(typeselect)) { + Map employAndResignDates = getEmployAndResignDateById(id); + + String companystartdate = Util.null2String(employAndResignDates.get("companystartdate")); + String resignDate = Util.null2String(employAndResignDates.get("resignDate")); + + if (StringUtils.isNotBlank(companystartdate) && StringUtils.isBlank(resignDate)) { + String substring1 = companystartdate.substring(0, 7); + String substring2 = fromDate.substring(0, 7); + if (substring1.equals(substring2)) { + absenceDays = getAbsenceDays(id, fromDate, companystartdate, toDate); + } + } else if (StringUtils.isBlank(companystartdate) && StringUtils.isNotBlank(resignDate)) { + String substring1 = resignDate.substring(0, 7); + String substring2 = toDate.substring(0, 7); + if (substring1.equals(substring2)) { + absenceDays = getAbsenceDays(id, resignDate, toDate, fromDate); + } + + } else if (StringUtils.isNotBlank(companystartdate) && StringUtils.isNotBlank(resignDate)) { + String substring1 = companystartdate.substring(0, 7); + String substring2 = resignDate.substring(0, 7); + String substring3 = fromDate.substring(0, 7); + String substring4 = toDate.substring(0, 7); + if ( substring1.equals(substring2) && substring2.equals(substring3) + && substring3.equals(substring4) ) {//考勤月入职且离职 + int temp1 = getAbsenceDays(id, fromDate, companystartdate, toDate); + int temp2 = getAbsenceDays(id, resignDate, toDate, fromDate); + absenceDays = temp1 + temp2; + } else if (substring1.equals(substring3) && !substring2.equals(substring3)) {//考勤月入职,非考勤月离职 + absenceDays = getAbsenceDays(id, fromDate, companystartdate, toDate); + } else if ( !substring1.equals(substring3) && !substring2.equals(substring3)){//非考勤月入职,考勤月离职 + absenceDays = getAbsenceDays(id, resignDate, toDate, fromDate); + } + } + + } + fieldValue = String.valueOf(absenceDays); + + data.put(fieldName, fieldValue); + } else if ("laborHours".equals(kqReportFieldComInfo.getParentid()) ) { if ("laborHoursTotal".equals(fieldName)) { // @@ -728,6 +887,7 @@ public class GetKQReportCmd extends AbstractCommonCommand> { } return retmap; } + /*获取人员多级部门*/ private String getMultiLevelDepartmentById(String id){ RecordSet rs = new RecordSet(); @@ -756,6 +916,7 @@ public class GetKQReportCmd extends AbstractCommonCommand> { } return str; } + /*获取人员加班类型*/ private String getOvertimeTypeById(String id){ RecordSet rs = new RecordSet(); @@ -768,6 +929,7 @@ public class GetKQReportCmd extends AbstractCommonCommand> { } return field35; } + /*获取人员入离职时间*/ private Map getEmployAndResignDateById(String id){ RecordSet rs = new RecordSet(); @@ -930,6 +1092,42 @@ public class GetKQReportCmd extends AbstractCommonCommand> { return lsChildColumns; } + public int getAbsenceDays(String resourceId, String startDate, String endDate, String groupDate){ + int days = 0; + + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + + LocalDate startDateL = LocalDate.parse(startDate, formatter); + LocalDate endDateL = LocalDate.parse(endDate, formatter); + + List dates = new ArrayList<>(); + LocalDate currentDate = startDateL; + + while (!currentDate.isAfter(endDateL)) { + dates.add("'"+currentDate.format(formatter)+"'"); + currentDate = currentDate.plusDays(1); + } + + String selDates = String.join(",", dates); + int size = dates.size(); + + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + String groupid = Util.null2String(kqGroupMemberComInfo.getKQGroupId(resourceId, groupDate)); + String acqNumberSql = "select count(*) as number from KQ_HolidaySet where groupid = " + groupid +" changeType in (1,3) " + + "and holidayDate in ("+selDates+")"; + bb.writeLog("acqNumberSql: " + acqNumberSql); + RecordSet rs = new RecordSet(); + rs.executeQuery(acqNumberSql); + int number = 0; + while (rs.next()) { + number = Math.max(Util.getIntValue(Util.null2String(rs.getString("number"))), 0); + } + + days = size - number; + + return days; + } + @Override public BizLogContext getLogContext() { return null;