diff --git a/src/WEB-INF/nbkq_main.properties b/src/WEB-INF/nbkq_main.properties index 9f8322a..c403c88 100644 --- a/src/WEB-INF/nbkq_main.properties +++ b/src/WEB-INF/nbkq_main.properties @@ -1,4 +1,4 @@ -#宁波精华考勤需求 +#宁波精华考勤需求 #管理人员指定人员考勤组id glrygroupid=6 #管理人员考勤组id @@ -8,7 +8,7 @@ sjbjcjid=6,7,8 #婚假丧假id hjsjid=10,11 #预入职流程id -yrzWfid=518 +yrzWfid=533 #固定流程创建人id lccjr=43 #目录id @@ -22,9 +22,11 @@ searIdYb=2 #管理人员12小时班制夜班最大加班时长 ybMaxMins=240 #加班申请流程表名 -lctableName=formtable_main_374 -#两小时起步加班休班次id +lctableName=formtable_main_436 +#休班次两小时起步 twoStartSerId=12 +#支援班次id 11 支援休班次id 21 支援夜班次id 22 +supportSerId=11,21,22 diff --git a/src/com/api/nbkq/web/NbJhWorkflowActionApi.java b/src/com/api/nbkq/web/NbJhWorkflowActionApi.java new file mode 100644 index 0000000..10232ce --- /dev/null +++ b/src/com/api/nbkq/web/NbJhWorkflowActionApi.java @@ -0,0 +1,10 @@ +package com.api.nbkq.web; + +import com.engine.nbkq.web.NbjhWorkflowAction; + +import javax.ws.rs.Path; + + +@Path("/nbjh/leaveworkflow") +public class NbJhWorkflowActionApi extends NbjhWorkflowAction { +} diff --git a/src/com/engine/kq/biz/KQFormatData.java b/src/com/engine/kq/biz/KQFormatData.java index f99a049..31e20aa 100644 --- a/src/com/engine/kq/biz/KQFormatData.java +++ b/src/com/engine/kq/biz/KQFormatData.java @@ -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,flowinfo" + (definedField.length() > 0 ? "," + definedField + "" : "") + ") " + - " values(?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?" + (definedField.length() > 0 ? "," + definedParam + "" : "") + ")"; + " leaveMins,leaveinfo,evectionMins,outMins,forgotbeginworkcheckmins,otherinfo" + (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); @@ -285,7 +285,7 @@ public class KQFormatData extends BaseBean { //用来计算实际打卡时长用的 int signInTimeIndx4Sign = -1; int signInTimeOutdx4Sign = -1; - Map flowinfo = new HashMap<>();//流程信息 +// Map flowinfo = new HashMap<>();//流程信息 String signBeginDateTime = signTimeScope.getBeginTimeAcross() ? nextDate : kqDate; @@ -551,7 +551,7 @@ public class KQFormatData extends BaseBean { if (workFlowInfo.get(dateKey) != null) { workFlow = (List) workFlowInfo.get(dateKey); } - List flowList = Lists.newArrayList(); +// 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")); @@ -559,27 +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"))); - String begintime = Util.null2String(data.get("begintime")); - String endtime = Util.null2String(data.get("endtime")); - beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(begintime); - endIdx = kqTimesArrayComInfo.getArrayindexByTimes(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); - } +// 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 @@ -881,7 +881,7 @@ public class KQFormatData extends BaseBean { params.add(outMins); params.add(forgotBeginWorkCheckMins); params.add(JSONObject.toJSONString(otherinfo)); - params.add(JSONObject.toJSONString(flowinfo)); +// 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 f1bec85..51cba68 100644 --- a/src/com/engine/kq/biz/KQOverTimeRuleCalBiz.java +++ b/src/com/engine/kq/biz/KQOverTimeRuleCalBiz.java @@ -24,6 +24,8 @@ import java.time.format.DateTimeFormatter; import java.util.*; import java.util.Map.Entry; import java.util.stream.Collectors; + +import org.apache.commons.lang3.StringUtils; import weaver.common.DateUtil; import weaver.conn.RecordSet; import weaver.formmode.setup.ModeRightInfo; @@ -106,6 +108,8 @@ public class KQOverTimeRuleCalBiz { computingModeMap,kqTimesArrayComInfo,uuid,singleRs); } } + fromDate=preFromDate.format(dateFormatter); + updateTiaoXiu(resourceid, fromDate, toDate); }catch (Exception e){ kqLog.info("加班生成数据报错:KQOverTimeRuleCalBiz:"); StringWriter errorsWriter = new StringWriter(); @@ -114,6 +118,116 @@ public class KQOverTimeRuleCalBiz { } } + + /** + * 更新调休 + * @param resourceid + * @param fromDate + * @param toDate + */ + public void updateTiaoXiu(String resourceid, String fromDate, String toDate){ + //假期类型的缓存类 + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + //[调休]的假期类型的ID + String leaveRulesId = ""; + //找到[调休]的假期类型ID + rulesComInfo.setTofirstRow(); + while (rulesComInfo.next()) { + if (KQLeaveRulesBiz.isTiaoXiu(rulesComInfo.getId())) { + if("1".equals(rulesComInfo.getIsEnable())){ + leaveRulesId = rulesComInfo.getId(); + break; + } + } + } + RecordSet recordSet = new RecordSet(); + String sql = " select * from kq_balanceOfLeave " + + " where (isDelete is null or isDelete<>1) and resourceId=" + resourceid + + " and leaveRulesId=" + leaveRulesId + + " and effectiveDate>='" + fromDate + "' and effectiveDate<='" +toDate+"'"+ + " order by belongYear asc,effectiveDate asc,id asc "; + recordSet.executeQuery(sql); + String all_tiaoxiuids = ""; + BigDecimal duration = new BigDecimal("0"); + while (recordSet.next()) { + //额外 + BigDecimal extraAmount = new BigDecimal(Util.null2s(recordSet.getString("extraAmount"), "0")); + //加班生成调休 + BigDecimal tiaoxiuAmount = new BigDecimal(Util.null2s(recordSet.getString("tiaoxiuamount"), "0")); + //已休 + BigDecimal usedAmount = new BigDecimal(Util.null2s(recordSet.getString("usedAmount"), "0")); + + if (extraAmount.add(tiaoxiuAmount).subtract(usedAmount).doubleValue() >= 0) { + continue; + } + String id = recordSet.getString("id"); + if(id.length() > 0 && Util.getIntValue(id) > 0){ + all_tiaoxiuids += ","+id; + duration =duration.add(extraAmount).add(tiaoxiuAmount).subtract(usedAmount); + } + } + duration = duration.abs(); + List updateList = new ArrayList(); + sql = " select * from kq_balanceOfLeave " + + " where (isDelete is null or isDelete<>1) and resourceId=" + resourceid + + " and leaveRulesId=" + leaveRulesId + + " and effectiveDate>='" + fromDate + "'"+ + " order by belongYear asc,effectiveDate asc,id asc "; + recordSet.executeQuery(sql); + int total = recordSet.getCounts(); + int index = 0; + while (recordSet.next()) { + index++; + String id = recordSet.getString("id"); + //额外 + BigDecimal extraAmount = new BigDecimal(Util.null2s(recordSet.getString("extraAmount"), "0")); + //加班生成调休 + BigDecimal tiaoxiuAmount = new BigDecimal(Util.null2s(recordSet.getString("tiaoxiuamount"), "0")); + //已休 + BigDecimal usedAmount = new BigDecimal(Util.null2s(recordSet.getString("usedAmount"), "0")); + + if (extraAmount.add(tiaoxiuAmount).subtract(usedAmount).doubleValue() <= 0) { + continue; + } + BigDecimal temp = extraAmount.add(tiaoxiuAmount).subtract(usedAmount).subtract(duration); + /*该假期剩余假期余额不足以扣减,记录错误日志,退出方法*/ + if (index == total && temp.doubleValue() < 0) { + kqLog.info("该人员的该假期所有的剩余假期余额都不足以扣减。" + + "resourceId=" + resourceid + ",date=" + fromDate + ",ruleId=" + leaveRulesId + ",duration=" + duration + ",extraAmount=" + extraAmount.doubleValue() + ",usedAmount=" + usedAmount.doubleValue()); + String newUsedAmount = usedAmount.add(duration).setScale(5, RoundingMode.HALF_UP).toPlainString(); + String updateSql = "update kq_balanceOfLeave set usedAmount=" + (newUsedAmount) + " where id=" + id; + updateList.add(updateSql); + break; + } + if (temp.doubleValue() >= 0) { + String newUsedAmount = usedAmount.add(duration).setScale(5, RoundingMode.HALF_UP).toPlainString(); + String updateSql = "update kq_balanceOfLeave set usedAmount=" + (newUsedAmount) + " where id=" + id; + updateList.add(updateSql); + break; + } else { + duration = duration.add(usedAmount).subtract(extraAmount).subtract(tiaoxiuAmount); + String newUsedAmount = extraAmount.add(tiaoxiuAmount).setScale(5, RoundingMode.HALF_UP).toPlainString(); + String updateSql = "update kq_balanceOfLeave set usedAmount=" + (newUsedAmount) + " where id=" + id; + updateList.add(updateSql); + continue; + } + } + if(all_tiaoxiuids.length() > 0) { + all_tiaoxiuids = all_tiaoxiuids.substring(1); + updateList.add("update kq_balanceOfLeave set isDelete=1 where id in (" +all_tiaoxiuids+")"); + } + kqLog.info("updateList:"+updateList); + /*SQL操作批处理*/ + for (int i = 0; i < updateList.size(); i++) { + boolean flag = recordSet.executeUpdate(updateList.get(i)); + if (!flag) { + kqLog.info("刷新加班流程数据失败:数据库更新失败" ); + return; + } + } + + } + /** * 需审批,以打卡为准,取流程和打卡的交集 * @param resourceid @@ -303,6 +417,8 @@ public class KQOverTimeRuleCalBiz { // } int across_mins = 0; + String fromTimeCheck = ""; + String toTimeCheck = ""; for(int i = 0 ; i < cross_time_list.size() ;) { int cross_fromtime_index = cross_time_list.get(i); int cross_totime_index = cross_time_list.get(i + 1); @@ -335,7 +451,8 @@ public class KQOverTimeRuleCalBiz { String cross_totime = kqTimesArrayComInfo.getTimesByArrayindex(flow_cross_totime_index); String cross_fromdate = realSplitDate; String cross_todate = realSplitDate; - + fromTimeCheck = cross_fromtime; + toTimeCheck = cross_totime; boolean needSplitByTime = false; if(needSplitByTime){ // 按照加班时长转调休的 时长设置 这个逻辑如果后面要开启来可以直接用的 @@ -440,6 +557,26 @@ public class KQOverTimeRuleCalBiz { }else{ otherParam.put("overtimeLogMap", overtimeLogMap); logOvertimeMap(overtimeLogMap, across_mins, flow_key+"|最终生成的加班分钟数|overtime_mins"); + + String searIdFrom = workTimeEntity.getSerialId(); + //如果是休班次,加班类型为休息日加班 + if (isRestSerial(searIdFrom,rs)) { + kqLog.info("原始across_mins:"+across_mins+"fromTimeCheck:"+fromTimeCheck+"toTimeCheck:"+toTimeCheck); + String signinTimeNew = kqTimesArrayComInfo.turn48to24Time(signinTime); + String signoutTimeNew = kqTimesArrayComInfo.turn48to24Time(signoutTime); + if(StringUtils.isNotBlank(fromTimeCheck)){ + signinTimeNew = fromTimeCheck; + } + + if(StringUtils.isNotBlank(toTimeCheck)){ + signoutTimeNew = toTimeCheck; + } + Double newHours = recalculateOverTime(divide(String.valueOf(across_mins),"60"),searIdFrom, signinDate, signinTimeNew, signoutDate, signoutTimeNew, rs, singleRs); + Double newMinsBy = newHours*60; + across_mins = newMinsBy.intValue(); + kqLog.info("newHours:"+newHours+"mins:"+across_mins); + } + /*获取考勤组的ID,因为考勤组有有效期,所以需要传入日期*/ KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); String groupId = kqGroupMemberComInfo.getKQGroupId(resourceid, realSplitDate); @@ -462,7 +599,7 @@ public class KQOverTimeRuleCalBiz { String lctableName = bb.getPropValue("nbkq_main","lctableName"); Integer bxszh = changeBxs(across_mins); Integer yxszh = changeyxs(across_mins); - String searIdFrom = workTimeEntity.getSerialId(); + kqLog.info("半小时计提时长bxszh:"+bxszh+"yxszh:"+yxszh+"searIdFrom:"+searIdFrom); String jblx = ""; String bxfs = ""; @@ -584,6 +721,40 @@ public class KQOverTimeRuleCalBiz { String overtimeid = get_overtime_uuid(overtime_uuid); kqEventLogBiz.updateOvertimeId(uuid, overtimeid); + + new BaseBean().writeLog("tiaoxiuId---2:"+tiaoxiuId); + if(StringUtils.isNotBlank(tiaoxiuId)){ + if (isRestSerial(searIdFrom,rs)) { + + Double sc = divide(String.valueOf(across_mins),"60"); + + new BaseBean().writeLog("更新kq_balanceOfLeave的sc:"+across_mins); +// sc = recalculateOverTime(sc,searIdFrom, fromdatedb, fromtimedb, todatedb, totimedb, rs, singleRs); + new BaseBean().writeLog("重新计算后的sc:"+sc); + String sql = " select * from kq_balanceOfLeave where id = "+tiaoxiuId ; + rs.executeQuery(sql); + if(rs.next()){ + String tiaoxiuamount = Util.null2String(rs.getString("tiaoxiuamount")); + new BaseBean().writeLog("系统计算的调休是:"+tiaoxiuamount); + } + sql = "update kq_balanceOfLeave set tiaoxiuamount="+sc+" where id = "+tiaoxiuId ; + new BaseBean().writeLog("重新计算sql:"+sql); + boolean isTrue = rs.executeUpdate(sql); + new BaseBean().writeLog("重新计算更新:"+isTrue); + new BaseBean().writeLog("overtime_uuid:"+overtime_uuid); + +// if(StringUtils.isNotBlank(overtime_uuid)){ +// int duration_min = (int)sc.doubleValue()*60; +// sql = " update kq_flow_overtime set duration_min='"+duration_min+"' where uuid='"+overtime_uuid+"'" ; +// new BaseBean().writeLog("重新计算kq_flow_overtime的sql:"+sql); +// isTrue = rs.executeUpdate(sql); +// new BaseBean().writeLog("kq_flow_overtime重新计算更新:"+isTrue); +// } + + + } + } + } } }else{ @@ -846,6 +1017,19 @@ public class KQOverTimeRuleCalBiz { }else{ logOvertimeMap(overtimeLogMap, mins, flow_cross_key+"|最终生成的加班分钟数|overtime_mins"); + + String searIdFrom = workTimeEntity.getSerialId(); + //如果是休班次,加班类型为休息日加班 + if (isRestSerial(searIdFrom,rs)) { + kqLog.info("原始across_mins:"+mins); + String signinTimeNew = kqTimesArrayComInfo.turn48to24Time(signinTime); + String signoutTimeNew = kqTimesArrayComInfo.turn48to24Time(signoutTime); + Double newHours = recalculateOverTime(divide(String.valueOf(mins),"60"),searIdFrom, signinDate, signinTimeNew, signoutDate, signoutTimeNew, rs, singleRs); + Double newMinsBy = newHours*60; + mins = newMinsBy.intValue(); + kqLog.info("newHours:"+newHours+"mins:"+mins); + } + /*获取考勤组的ID,因为考勤组有有效期,所以需要传入日期*/ KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); String groupId = kqGroupMemberComInfo.getKQGroupId(resourceid, realSplitDate); @@ -861,8 +1045,14 @@ public class KQOverTimeRuleCalBiz { String searIdYb = bb.getPropValue("nbkq_main","searIdYb"); //管理人员12小时班制夜班最大加班时长 Integer ybMaxMins = Util.getIntValue(bb.getPropValue("nbkq_main","ybMaxMins")); + if(searIdYb.equals(searIdFrom)){ + //12夜补半小时 + mins = mins + 30; + kqLog.info("12夜补半小时:"+mins); + } + Integer bxszh = changeBxs(mins); - String searIdFrom = workTimeEntity.getSerialId(); + kqLog.info("半小时计提时长bxszh:"+bxszh+"searIdFrom:"+searIdFrom); if(searIdBb.equals(searIdFrom)){ kqLog.info("白班"); @@ -906,8 +1096,39 @@ public class KQOverTimeRuleCalBiz { String overtimeid = get_overtime_uuid(overtime_uuid); kqEventLogBiz.updateOvertimeId(uuid, overtimeid); - } + + new BaseBean().writeLog("tiaoxiuId---:"+tiaoxiuId); + if(StringUtils.isNotBlank(tiaoxiuId)) { + if (isRestSerial(searIdFrom, rs)) { + + Double sc = divide(String.valueOf(mins), "60"); + + new BaseBean().writeLog("更新kq_balanceOfLeave的sc:" + mins); +// sc = recalculateOverTime(sc, searIdFrom, signinDate, signinTime, signoutDate, signoutTime, rs, singleRs); + new BaseBean().writeLog("重新计算后的sc:" + sc); + String sql = " select * from kq_balanceOfLeave where id = " + tiaoxiuId; + rs.executeQuery(sql); + if (rs.next()) { + String tiaoxiuamount = Util.null2String(rs.getString("tiaoxiuamount")); + new BaseBean().writeLog("系统计算的调休是:" + tiaoxiuamount); + } + sql = "update kq_balanceOfLeave set tiaoxiuamount=" + sc + " where id = " + tiaoxiuId; + new BaseBean().writeLog("重新计算sql:" + sql); + boolean isTrue = rs.executeUpdate(sql); + new BaseBean().writeLog("重新计算更新:" + isTrue); + new BaseBean().writeLog("overtime_uuid:" + overtime_uuid); + +// if(StringUtils.isNotBlank(overtime_uuid)){ +// int duration_min = (int)sc.doubleValue()*60; +// sql = " update kq_flow_overtime set duration_min='"+duration_min+"' where uuid='"+overtime_uuid+"'" ; +// new BaseBean().writeLog("重新计算kq_flow_overtime的sql:"+sql); +// isTrue = rs.executeUpdate(sql); +// new BaseBean().writeLog("kq_flow_overtime重新计算更新:"+isTrue); +// } + } + } + } } }else{ logOvertimeMap(overtimeLogMap, "打卡区间不正确|"+flow_cross_key, mapKey+"|"+"打卡区间,得到打卡时长|over_count"); @@ -3144,8 +3365,8 @@ public class KQOverTimeRuleCalBiz { //如果是休班次,加班类型为休息日加班 if (isRestSerial(searIdFrom,rs)) { jblxNew = "1"; - new BaseBean().writeLog("insertJbtz 原始sc:"+sc); - sc = recalculateOverTime(sc,searIdFrom, ksrq, kssj, jsrq, jssj, rs, singleRs); +// new BaseBean().writeLog("insertJbtz 原始sc:"+sc); +// sc = recalculateOverTime(sc,searIdFrom, ksrq, kssj, jsrq, jssj, rs, singleRs); } String sqlMode = "insert into uf_jbtz (jbr,gjsc,bcfs,jbxz,sqr,szbm,sjh,zzdksj,zwdkrq,ly,gh,bm,zw,jblx,ksrq,jsrq,sqsy,kssj,jssj,gzrq,FORMMODEID,MODEDATACREATER,MODEDATACREATERTYPE,MODEDATACREATEDATE,MODEDATACREATETIME) \n" + @@ -3250,7 +3471,7 @@ public class KQOverTimeRuleCalBiz { BigDecimal b1 = new BigDecimal(v1); BigDecimal b2 = new BigDecimal(v2); BigDecimal divide = b1.divide(b2, 2, BigDecimal.ROUND_HALF_UP); - return divide.setScale(0, RoundingMode.DOWN).doubleValue(); + return divide.doubleValue(); } /** diff --git a/src/com/engine/kq/biz/KQReportBiz.java b/src/com/engine/kq/biz/KQReportBiz.java index d1672a2..b714543 100644 --- a/src/com/engine/kq/biz/KQReportBiz.java +++ b/src/com/engine/kq/biz/KQReportBiz.java @@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject; import com.engine.kq.cmd.attendanceButton.ButtonStatusEnum; import com.engine.kq.enums.KqSplitFlowTypeEnum; import com.engine.kq.log.KQLog; +import com.engine.kq.nbjh.KqUtil; import com.engine.kq.util.KQDurationCalculatorUtil; import weaver.common.DateUtil; import weaver.conn.RecordSet; @@ -84,10 +85,10 @@ public class KQReportBiz extends BaseBean { List datas = null; Map data = null; sql = " select kqdate,serialid, workbegindate, workbegintime,workenddate, workendtime," + - " signintime,signouttime,beLateMins,graveBeLateMins,leaveEarlyMins,graveLeaveEarlyMins," + - " absenteeismMins, forgotCheckMins,forgotBeginWorkCheckMins,otherinfo "+ - " from kq_format_detail " + - " where resourceid=? and kqdate>=? and kqdate<=? "; + " signintime,signouttime,beLateMins,graveBeLateMins,leaveEarlyMins,graveLeaveEarlyMins," + + " absenteeismMins, forgotCheckMins,forgotBeginWorkCheckMins,otherinfo "+ + " from kq_format_detail " + + " where resourceid=? and kqdate>=? and kqdate<=? "; if(!isAll){ if(rs.getDBType().equalsIgnoreCase("oracle") || Util.null2String(rs.getOrgindbtype()).equals("dm") || Util.null2String(rs.getOrgindbtype()).equals("st")) { sql += " and beLateMins+graveBeLateMins+leaveEarlyMins+graveLeaveEarlyMins+absenteeismMins+forgotCheckMins+nvl(forgotBeginWorkCheckMins,0)>0 "; @@ -1176,8 +1177,8 @@ public class KQReportBiz extends BaseBean { } sql = " select resourceid, durationrule, changetype,sum(duration) as val from hrmresource a, "+ KqSplitFlowTypeEnum.PROCESSCHANGE.getTablename()+" b "+ - " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' "+sqlWhere+ - " group by resourceid, durationrule,changetype "; + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' "+sqlWhere+ + " group by resourceid, durationrule,changetype "; rs.execute(sql); while (rs.next()) { String resourceid = rs.getString("resourceid"); @@ -1277,8 +1278,8 @@ 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+"' " +sqlWhere + - " group by resourceid, newleavetype, durationrule,belongdate "; + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere + + " group by resourceid, newleavetype, durationrule,belongdate "; rs.execute(sql); while (rs.next()) { String resourceid = rs.getString("resourceid"); @@ -1369,8 +1370,8 @@ public class KQReportBiz extends BaseBean { } 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+"' " +sqlWhere + - " group by resourceid, newleavetype, durationrule,belongdate "; + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere + + " group by resourceid, newleavetype, durationrule,belongdate "; rs.execute(sql); while (rs.next()) { String resourceid = rs.getString("resourceid"); @@ -1464,9 +1465,9 @@ public class KQReportBiz extends BaseBean { 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 "; + " 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()) { @@ -1675,9 +1676,9 @@ public class KQReportBiz extends BaseBean { } sql = " select resourceid,changeType,belongdate,paidLeaveEnable, sum(cast(duration_min as decimal(18,4))) as val "+ - " from hrmresource a, kq_flow_overtime b "+ - " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere+ - " group by resourceid,changeType,paidLeaveEnable,belongdate "; + " from hrmresource a, kq_flow_overtime b "+ + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere+ + " group by resourceid,changeType,paidLeaveEnable,belongdate "; rs.execute(sql); while (rs.next()) { String resourceid = rs.getString("resourceid"); @@ -1822,13 +1823,15 @@ public class KQReportBiz extends BaseBean { String sql = ""; try { sql = " select resourceid, kqdate, workMins, belatemins, graveBeLateMins, leaveearlymins, graveLeaveEarlyMins, absenteeismmins, forgotcheckMins, forgotBeginWorkCheckMins, "+ - " leaveMins,leaveInfo,evectionMins,outMins " + - " from kq_format_detail " + - " where resourceid = ? and kqdate>=? and kqdate<=? "+ - " order by resourceid, kqdate, serialnumber "; + " leaveMins,leaveInfo,evectionMins,outMins " + + " from kq_format_detail " + + " where resourceid = ? and kqdate>=? and kqdate<=? "+ + " order by resourceid, kqdate, serialnumber "; rs.executeQuery(sql,resourceId, fromDate,toDate); while (rs.next()) { - String key = rs.getString("resourceid") + "|" + rs.getString("kqdate"); + String userid = rs.getString("resourceid"); + String kqdate = rs.getString("kqdate"); + String key = userid + "|" + kqdate; int workMins = rs.getInt("workMins"); int beLateMins = rs.getInt("beLateMins"); int leaveEarlyMins = rs.getInt("leaveEarlyMins"); @@ -1856,6 +1859,9 @@ public class KQReportBiz extends BaseBean { flag = Util.null2String(tmpmap.get("text")); } + // 判断 指定日期 是否在 哺乳假流程 日期范围内 + boolean bool = KqUtil.checkIsBetweenRange(userid,kqdate); + if (workMins<=0) { if(text.length()>0) text +=" "; text += SystemEnv.getHtmlLabelName(26593, user.getLanguage()); @@ -1890,38 +1896,47 @@ 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()); - } - } - }else{ - if(text.indexOf(SystemEnv.getHtmlLabelName(670, user.getLanguage()))==-1) { + 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 += SystemEnv.getHtmlLabelName(670, user.getLanguage()); + //text += kqLeaveRulesComInfo.getLeaveName(newLeaveType)+tmpLeaveMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); + text += Util.formatMultiLang( kqLeaveRulesComInfo.getLeaveName(newLeaveType),""+user.getLanguage()); } } - } - if (evectionMins > 0) {//出差 - if(text.indexOf(SystemEnv.getHtmlLabelName(20084, user.getLanguage()))==-1) { + }else{ + if(text.indexOf(SystemEnv.getHtmlLabelName(670, user.getLanguage()))==-1) { if (text.length() > 0) text += " "; - text += SystemEnv.getHtmlLabelName(20084, user.getLanguage()); + text += SystemEnv.getHtmlLabelName(670, user.getLanguage()); } } - if (outMins > 0) {//公出 - if(text.indexOf(SystemEnv.getHtmlLabelName(24058, user.getLanguage()))==-1) { - if (text.length() > 0) text += " "; - text += SystemEnv.getHtmlLabelName(24058, user.getLanguage()); - } + } + if (evectionMins > 0) {//出差 + if(text.indexOf(SystemEnv.getHtmlLabelName(20084, user.getLanguage()))==-1) { + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20084, user.getLanguage()); + } + } + if (outMins > 0) {//公出 + if(text.indexOf(SystemEnv.getHtmlLabelName(24058, user.getLanguage()))==-1) { + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(24058, user.getLanguage()); + } + } + + // 指定日期 在 哺乳假流程范围内 + if(bool){ + if (text.length() > 0) text += " "; + //不包含 休息 + if(!text.contains(SystemEnv.getHtmlLabelName(26593, user.getLanguage()))) { + text += SystemEnv.getHtmlLabelName(24062, user.getLanguage()); } + } if(text.length()==0) { text = "√"; @@ -2398,16 +2413,25 @@ 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()){ int serialid = Util.getIntValue(rs.getString("serialid")); double attendanceMins = Util.getDoubleValue(rs.getString("attendanceMins"),0.00); + attendanceMins = attendanceMins / 60; double overTimeTotal = getOverTimeTotal(kqdate,userid); double time = attendanceMins+overTimeTotal; - if(serialid == sixnight_serialid|| serialid == twelvehours_night_serialid){ + //1、 12小时工作制夜班、做六休一夜班有夜班补贴,并且出勤(上班时间+加班时间)>=8小时,统计一次 + if(serialid == sixnight_serialid || serialid == twelvehours_night_serialid){ if(time >= 8){ - result = 1; + result ++; + } + } + //2、当一线人员排“夜休”班次,并且加班台账当天导入的加班时长>=8小时,统计一次。 + if(serialid == night_rest_serialid){ + if(overTimeTotal >= 8){ + result ++; } } } @@ -2426,19 +2450,32 @@ 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 kqdate <= ? and resourceid=?",fromDate,toDate,userid); rs.writeLog("select * from kq_format_total where kqdate >= '"+ fromDate +"' and kqdate <= '"+ toDate +"' and resourceid="+ userid); while(rs.next()){ int serialid = Util.getIntValue(rs.getString("serialid")); String kqdate = Util.null2String(rs.getString("kqdate")); double attendanceMins = Util.getDoubleValue(rs.getString("attendanceMins"),0.00); + attendanceMins = attendanceMins / 60; + rs.writeLog("========= getNightSubsidyTotal attendanceMins ========== "+ attendanceMins); double overTimeTotal = getOverTimeTotal(kqdate,userid); + rs.writeLog("========= getNightSubsidyTotal overTimeTotal ========== "+ overTimeTotal); double time = attendanceMins+overTimeTotal; - if(serialid == sixnight_serialid|| serialid == twelvehours_night_serialid){ + rs.writeLog("========= getNightSubsidyTotal time ========== "+ time); + if(serialid == sixnight_serialid || serialid == twelvehours_night_serialid){ if(time >= 8){ result++; } } + rs.writeLog("========= getNightSubsidyTotal result 111 ========== "+ result); + //2、当一线人员排“夜休”班次,并且加班台账当天导入的加班时长>=8小时,统计一次。 + if(serialid == night_rest_serialid){ + if(overTimeTotal >= 8){ + result ++; + } + } + rs.writeLog("========= getNightSubsidyTotal result 222 ========== "+ result); } return result; } @@ -2471,13 +2508,12 @@ 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" + - "and a.ksrq >=? and a.jsrq <=? and a.resourceId=?",fromDate,toDate,userid); - if(rs.next()){ - + 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 b.detail_signdate <=? and a.resourceId=?",fromDate,toDate,userid); + while(rs.next()){ + result++; } - result = rs.getCounts(); return result; } @@ -2495,8 +2531,8 @@ public class KQReportBiz extends BaseBean { 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; + while(rs.next()){ + result ++; } return result; } diff --git a/src/com/engine/kq/cmd/report/ExportDailyExcelCmd.java b/src/com/engine/kq/cmd/report/ExportDailyExcelCmd.java index 6217223..bf85f20 100644 --- a/src/com/engine/kq/cmd/report/ExportDailyExcelCmd.java +++ b/src/com/engine/kq/cmd/report/ExportDailyExcelCmd.java @@ -7,12 +7,12 @@ import com.engine.common.entity.BizLogContext; import com.engine.core.interceptor.CommandContext; import com.engine.kq.biz.*; import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit; +import com.engine.kq.nbjh.KqUtil; import com.engine.kq.util.ExcelUtil; import com.engine.kq.util.KQDurationCalculatorUtil; import org.apache.commons.lang3.StringUtils; import org.springframework.util.CollectionUtils; import weaver.common.DateUtil; -import weaver.common.StringUtil; import weaver.conn.RecordSet; import weaver.general.BaseBean; import weaver.general.TimeUtil; @@ -27,11 +27,7 @@ import weaver.systeminfo.SystemEnv; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import java.util.*; public class ExportDailyExcelCmd extends AbstractCommonCommand> { @@ -196,7 +192,7 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand> { //支援班次统计 String supportSerId = new BaseBean().getPropValue("nbkq_main", "supportSerId"); 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 count(0) from kq_shiftschedule where resourceid = a.id and kqdate >='" + fromDate + "' and kqdate <='" + toDate + "' and serialid in (" + supportSerId + ") )as supportTotal," + " (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," + + " a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1 as subcompanyid,a.departmentid,a.jobtitle,a.companystartdate," + " 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, " + " sum(b.graveBeLate) as graveBeLate, sum(b.graveBeLateMins) as graveBeLateMins,sum(b.leaveEearly) as leaveEearly," + @@ -228,7 +229,7 @@ public class ExportExcelCmd extends AbstractCommonCommand> { "where a.id= b.resourceid and c.id=b.serialid and (c.rest_shift is null or c.rest_shift=0) " + "and b.kqdate >='" + fromDate + "' and b.kqdate <='" + toDate + "'"; String sqlWhere = rightSql; - String groupBy = " group by a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1,a.departmentid,a.jobtitle "; + String groupBy = " group by a.id,a.lastname,a.workcode,a.dsporder,a.companystartdate,b.resourceid,a.subcompanyid1,a.departmentid,a.jobtitle "; if (subCompanyId.length() > 0) { sqlWhere += " and a.subcompanyid1 in(" + subCompanyId + ") "; } @@ -291,6 +292,14 @@ public class ExportExcelCmd extends AbstractCommonCommand> { //补卡次数int if (fieldName.equals("fillCard")) { fieldValue = KQDurationCalculatorUtil.getDurationRound(String.valueOf(kqReportBiz.getFillCardCount(fromDate, toDate, id))); + } else if (fieldName.equals("attendancedays")) { + fieldValue = KQDurationCalculatorUtil.getDurationRound(String.valueOf(KqUtil.getAttendancedays(id, fromDate, toDate, user))); + data.add(fieldValue); + continue; + } + //哺乳假 + else if (fieldName.equals("breastfeedLeave")) { + fieldValue = KQDurationCalculatorUtil.getDurationRound(String.valueOf(KqUtil.getBreastfeedLeave(fromDate, toDate, id))); } else if (fieldName.equals("subcompany")) { String tmpSubcompanyId = Util.null2String(rs.getString("subcompanyid")); if (tmpSubcompanyId.length() == 0) { @@ -464,10 +473,13 @@ 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")) { + String lsCascadeValue = lsCascadekey.get(i); + String unittype = kqReportFieldComInfo.getUnittype(fieldid); + if (unittype.equals("2")&& + (lsCascadeValue.contains("LateMins") || lsCascadeValue.contains("EarlyMins") || lsCascadeValue.contains("cd") || lsCascadeValue.contains("zt"))) { fieldValue = rs.getString(lsCascadekey.get(i)); } else { - fieldValue = getFieldValueByUnitType(rs.getString(lsCascadekey.get(i)), kqReportFieldComInfo.getUnittype(fieldid)); + fieldValue = getFieldValueByUnitType(rs.getString(lsCascadekey.get(i)), kqReportFieldComInfo.getUnittype(fieldid)); } } else { fieldValue = "0"; @@ -731,11 +743,14 @@ public class ExportExcelCmd extends AbstractCommonCommand> { if (!kqReportFieldComInfo.getReportType().equals("month")) continue; if (kqReportFieldComInfo.getFieldname().equals(lsCascadeKey.get(i))) { title = new HashMap<>(); - //二开 迟到使用分钟 - if (kqReportFieldComInfo.getFieldname().contains("LateMins") || kqReportFieldComInfo.getFieldname().contains("EarlyMins")) { + //二开 迟到早退使用分钟 + String fieldname = kqReportFieldComInfo.getFieldname(); + String unittype = kqReportFieldComInfo.getUnittype(); + if (unittype.equals("2") && (fieldname.contains("LateMins") || fieldname.contains("EarlyMins") + || fieldname.contains("cd") || fieldname.contains("zt"))) { title.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage()) + "(分钟)"); } else { - title.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage()) + "(" + KQReportBiz.getUnitType(kqReportFieldComInfo, user) + ")"); + title.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage()) + "(" + KQReportBiz.getUnitType(kqReportFieldComInfo, user) + ")"); } title.put("width", 30 * 256); titleList.add(title); diff --git a/src/com/engine/kq/cmd/report/GetKQDailyReportCmd.java b/src/com/engine/kq/cmd/report/GetKQDailyReportCmd.java index fa98247..86f7242 100644 --- a/src/com/engine/kq/cmd/report/GetKQDailyReportCmd.java +++ b/src/com/engine/kq/cmd/report/GetKQDailyReportCmd.java @@ -9,11 +9,11 @@ import com.engine.kq.biz.*; import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit; import com.engine.kq.entity.WorkTimeEntity; import com.engine.kq.log.KQLog; +import com.engine.kq.nbjh.KqUtil; 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; @@ -156,7 +156,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("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); @@ -711,11 +715,11 @@ 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("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); @@ -739,15 +743,11 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand 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 78815a2..20e912c 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.nbjh.KqUtil; import com.engine.kq.util.KQDurationCalculatorUtil; import com.engine.kq.util.PageUidFactory; import org.apache.commons.lang3.StringUtils; @@ -128,7 +129,9 @@ public class GetKQReportCmd extends AbstractCommonCommand> { columnsInfo.stream().forEach(item -> { Map map = (Map) item; String title = (String) map.get("title"); - if (title.contains("迟到时长") || title.contains("早退时长")) { + String dataIndex = (String) map.get("dataIndex"); + String unit = (String) map.get("unit"); + if ((title.contains("迟到时长") || title.contains("早退时长") || dataIndex.contains("zt") || dataIndex.contains("cd")) && unit.contains("小时")) { map.put("title", title + "(分钟)"); map.put("unit", ""); } @@ -186,12 +189,12 @@ public class GetKQReportCmd extends AbstractCommonCommand> { String definedFieldSum = Util.null2String(definedFieldInfo.get("definedFieldSum")); //支援班次统计 String supportSerId = new BaseBean().getPropValue("nbkq_main", "supportSerId"); - 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," + + 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 in (" + supportSerId + ") )as supportTotal," + " (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," + + "a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1 as subcompanyid,a.departmentid,a.jobtitle,a.companystartdate," + " 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, " + " sum(b.graveBeLate) as graveBeLate, sum(b.graveBeLateMins) as graveBeLateMins,sum(b.leaveEearly) as leaveEearly," + @@ -207,7 +210,7 @@ public class GetKQReportCmd extends AbstractCommonCommand> { "where a.id= b.resourceid and c.id=b.serialid and (c.rest_shift is null or c.rest_shift=0) " + "and b.kqdate >='" + fromDate + "' and b.kqdate <='" + toDate + "'"; String sqlWhere = rightSql; - String groupBy = " group by a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1,a.departmentid,a.jobtitle "; + String groupBy = " group by a.id,a.lastname,a.workcode,a.dsporder,a.companystartdate,b.resourceid,a.subcompanyid1,a.departmentid,a.jobtitle "; if (subCompanyId.length() > 0) { sqlWhere += " and a.subcompanyid1 in(" + subCompanyId + ") "; } @@ -438,10 +441,10 @@ public class GetKQReportCmd extends AbstractCommonCommand> { if (fieldValue.length() == 0) { fieldValue = "0"; } else { - //2024-01-31 二开 迟到使用分钟 + //2024-01-31 二开 迟到使用分钟 20240424迟到早退自定义列 writeLog("testreport-" + fieldName + fieldValue); if (kqReportFieldComInfo.getUnittype().equals("2") - && !fieldName.contains("LateMins") && !fieldName.contains("EarlyMins")) { + && !fieldName.contains("LateMins") && !fieldName.contains("EarlyMins") && !fieldName.contains("cd") && !fieldName.contains("zt")) { fieldValue = KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(fieldValue) / 60.0))); } } @@ -593,6 +596,14 @@ public class GetKQReportCmd extends AbstractCommonCommand> { workingDayOvertime_nonleave + restDayOvertime_nonleave + holidayOvertime_nonleave)); data.put("overtimeTotal", overtimeTotal); + //哺乳假 + String breastfeedLeave = KQDurationCalculatorUtil.getDurationRound(String.valueOf(KqUtil.getBreastfeedLeave(fromDate, toDate, id))); + data.put("breastfeedLeave", breastfeedLeave); + + //实际出勤天数 + String attendancedays = KQDurationCalculatorUtil.getDurationRound(String.valueOf(KqUtil.getAttendancedays(id, fromDate, toDate, user))); + data.put("attendancedays", attendancedays); + //夜班补贴次数 String nightSubsidy = KQDurationCalculatorUtil.getDurationRound(String.valueOf(kqReportBiz.getNightSubsidyTotal(fromDate, toDate, id))); data.put("nightSubsidy", nightSubsidy); diff --git a/src/com/engine/kq/nbjh/KqUtil.java b/src/com/engine/kq/nbjh/KqUtil.java new file mode 100644 index 0000000..9d6a5bc --- /dev/null +++ b/src/com/engine/kq/nbjh/KqUtil.java @@ -0,0 +1,325 @@ +package com.engine.kq.nbjh; + +import com.alibaba.fastjson.JSON; +import com.engine.kq.biz.KQLeaveRulesComInfo; +import com.engine.kq.biz.KQWorkTime; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.math.BigDecimal; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Map; + +/** + * @Title + * @Author wangchaofa + * @CreateDate 2024/4/2 + * @Version 1.0 + * @Description + */ +public class KqUtil { + + /** + * 获取 实际出勤天数(带有哺乳假流程的,提前打卡的情况) + * @param resourceId + * @param fromdate + * @param todate + * @return + */ + public static double getAttendancedays(String resourceId,String fromdate,String todate,User user){ + double result = 0.00; + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + RecordSet rs = new RecordSet(); + String sql = " select resourceid, kqdate, workMins, belatemins, graveBeLateMins, leaveearlymins, graveLeaveEarlyMins, absenteeismmins, forgotcheckMins, forgotBeginWorkCheckMins, "+ + " leaveMins,leaveInfo,evectionMins,outMins " + + " from kq_format_detail " + + " where resourceid = ? and kqdate>=? and kqdate<=? "+ + " order by resourceid, kqdate, serialnumber "; + rs.executeQuery(sql,resourceId,fromdate,todate); + while (rs.next()) { + String userid = rs.getString("resourceid"); + String kqdate = rs.getString("kqdate"); + int workMins = rs.getInt("workMins"); + int beLateMins = rs.getInt("beLateMins"); + int leaveEarlyMins = rs.getInt("leaveEarlyMins"); + int graveBeLateMins = rs.getInt("graveBeLateMins"); + int absenteeismMins = rs.getInt("absenteeismMins"); + int graveLeaveEarlyMins = rs.getInt("graveLeaveEarlyMins"); + int forgotCheckMins = rs.getInt("forgotCheckMins"); + int forgotBeginWorkCheckMins = rs.getInt("forgotBeginWorkCheckMins"); + int leaveMins = rs.getInt("leaveMins"); + String leaveInfo = rs.getString("leaveInfo"); + int evectionMins = rs.getInt("evectionMins"); + int outMins = rs.getInt("outMins"); + + // 判断 指定日期 是否在 哺乳假流程 日期范围内 + boolean bool = checkIsBetweenRange(userid,kqdate); + String text = ""; + + if (workMins<=0) { + if(text.length()>0) text +=" "; + text += SystemEnv.getHtmlLabelName(26593, user.getLanguage()); + } else { + if (absenteeismMins > 0) {//旷工 + if(text.length()>0) text+=" "; + text += SystemEnv.getHtmlLabelName(20085, user.getLanguage()); + }else { + if (beLateMins > 0) {//迟到 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20081, user.getLanguage()); + } + if (graveBeLateMins > 0) {//严重迟到 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(500546, user.getLanguage()); + } + if (leaveEarlyMins > 0) {//早退 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20082, user.getLanguage()); + } + if (graveLeaveEarlyMins > 0) {//严重早退 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(500547, user.getLanguage()); + } + if (forgotCheckMins > 0) {//漏签 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + } + if (forgotBeginWorkCheckMins > 0) {//漏签 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + } + } + } + if (leaveMins > 0) {//请假 + Map jsonObject = null; + 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 += 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 (evectionMins > 0) {//出差 + if(text.indexOf(SystemEnv.getHtmlLabelName(20084, user.getLanguage()))==-1) { + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20084, user.getLanguage()); + } + } + if (outMins > 0) {//公出 + if(text.indexOf(SystemEnv.getHtmlLabelName(24058, user.getLanguage()))==-1) { + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(24058, user.getLanguage()); + } + } + + if(text.length()==0) { + result += 1; + }else{ + //包含 漏签、早退、严重早退、迟到、严重迟到 + if(checkHasSignInfo(userid,kqdate)) { + //当天有 哺乳假 或者 当天 在哺乳假的日期范围内 + if(bool) { + result += 1; + } + } + } + } + rs.writeLog("================== KqUtil getAttendancedays ==================== "+ result); + return result; + } + + public static boolean checkHasSignInfo(String userid,String date){ + boolean bool = false; + RecordSet rs = new RecordSet(); + rs.executeQuery("select * from HrmScheduleSign where userId=? and signDate=?",userid,date); + if(rs.next()){ + bool = true; + } + return bool; + } + + /** + * 判断日期是否在 哺乳假流程日期范围内 + * @param userid + * @param date + * @return + */ + public static boolean checkIsBetweenRange(String userid,String date){ + boolean bool = false; + RecordSet rs = new RecordSet(); + String breastfeedLeave_table = rs.getPropValue("nbjh_ygdjblc","breastfeedLeave_table"); + rs.executeQuery(" select a.mtgjxs as result,a.ksrq,a.jsrq from "+ breastfeedLeave_table +" a,workflow_requestbase b " + + " where a.requestid=b.requestid and b.currentnodetype=3 " + + " and a.ksrq <= ? and a.jsrq >= ? and a.xm = ?",date,date,userid); + if(rs.next()){ + bool = true; + } + return bool; + } + + /** + * 获取 哺乳假 数据 + * @param fromDate + * @param toDate + * @param userid + * @return + * 查询的 2024-03-01 2024-03-31 + * 流程里的 2024-03-12 2024-11-21 + * 2024-02-10 2024-04-10 + * 2024-02-10 2024-02-20 + */ + public static double getBreastfeedLeave(String fromDate,String toDate,String userid){ + double result = 0.00; + int ycqdays = 0; + double day = 0.00; + RecordSet rs = new RecordSet(); + String lc_fromDate = ""; + String lc_toDate = ""; + rs.writeLog("============== fromDate =================== "+ fromDate); + rs.writeLog("============== toDate =================== "+ toDate); + String currentdate = TimeUtil.getCurrentDateString(); + + String breastfeedLeave_table = rs.getPropValue("nbjh_ygdjblc","breastfeedLeave_table"); + rs.executeQuery(" select a.mtgjxs as result,a.ksrq,a.jsrq from "+ breastfeedLeave_table +" a,workflow_requestbase b " + + " where a.requestid=b.requestid and b.currentnodetype=3 " + + " and a.xm = ?",userid); + if(rs.next()){ + lc_fromDate = Util.null2String(rs.getString("ksrq")); + lc_toDate = Util.null2String(rs.getString("jsrq")); + day = Util.getDoubleValue(rs.getString("result"),0.00); + + // 流程里的开始日期 2024-03-12 >= 查询的开始日期 2024-03-01 + if(compareDate(lc_fromDate,fromDate)){ + //流程里的开始日期 2024-03-12 <= 查询的结束日期 2024-03-031 + if(compareDate(toDate,lc_fromDate)){ + //流程里的结束日期 2024-03-20 <= 查询的结束日期 2024-03-31 。 此时 应该 计算 流程里的开始日期 到 流程里的结束日期,这个范围内的 应出勤天数 + if(compareDate(toDate,lc_toDate)){ + ycqdays = getWorkdays(lc_fromDate,lc_toDate,userid); + } + //流程里的结束日期 2024-04-10 > 查询的结束日期 2024-03-31 。此时 应该 计算 流程里的开始日期 到 查询的结束日期,这个范围内的 应出勤天数 + else{ + ycqdays = getWorkdays(lc_fromDate,toDate,userid); + } + } + //流程里的开始日期 2024-04-10 > 查询的结束日期 2024-03-31 + else{ + ycqdays = 0; + } + } + //流程里的开始日期 2024-02-10 < 查询的开始日期 2024-03-01 + else{ + //流程里的结束日期 2024-03-10 >= 查询的开始日期 2024-03-01 + if(compareDate(lc_toDate,fromDate)){ + //流程里的结束日期 2024-03-10 <= 查询的结束日期 2024-03-31 。此时 应该 计算 查询的开始日期 到 流程里的结束日期,这个范围内的 应出勤天数 + if(compareDate(toDate,lc_toDate)){ + //流程里的结束日期 >= 当前日期 + if(compareDate(lc_toDate,currentdate)){ + ycqdays = getWorkdays(fromDate,currentdate,userid); + }else{ + ycqdays = getWorkdays(fromDate,lc_toDate,userid); + } + } + // 流程里的结束日期 2024-04-10 > 查询的结束日期 2024-03-31 。此时 应该 计算 查询的开始日期 到 查询的结束日期,这个范围内的 应出勤天数 + else{ + //流程里的结束日期 >= 当前日期 + if(compareDate(toDate,currentdate)){ + ycqdays = getWorkdays(fromDate,currentdate,userid); + }else{ + ycqdays = getWorkdays(fromDate,toDate,userid); + } + } + } + //查询的开始日期 2024-03-01 > 流程里的结束日期 2024-02-20 + else{ + ycqdays = 0; + } + } + } + rs.writeLog("=============== ycqdays ================= "+ ycqdays); + rs.writeLog("=============== day ================= "+ day); + result = ycqdays * day; + + return result; + } + + /** + * 获取日期范围内某个人的应出勤天数 + * @param fromDate 开始日期 + * @param toDate 结束日期 + * @param resourceId 人员id + * @return + */ + public static int getWorkdays(String fromDate, String toDate, String resourceId) { + int workDays = 0; + /**统计应出勤天数*/ + KQWorkTime kqWorkTime = new KQWorkTime(); + boolean isEnd = false; + for (String date = fromDate; !isEnd; ) { + if (date.compareTo(toDate)>=0) { + isEnd = true; + } + boolean isWorkDay = kqWorkTime.isWorkDay(resourceId, date); + if (isWorkDay) { + workDays += 1; + } + date = DateUtil.getDate(date, 1); + } + return workDays; + } + + /** + * 比较时间的大小 + * @param a + * @param b + * @return + * @throws ParseException + */ + public static boolean compareDate(String a, String b){ + boolean bool = false; + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + try { + long t1 = sdf.parse(a).getTime(); + long t2 = sdf.parse(b).getTime(); + if (t1 >= t2) { + bool = true; + } + return bool; + }catch (Exception e){ + e.printStackTrace(); + } + return bool; + } + + /** + * 方法描述 : 对两个字符串进行金额的相加 + * @param a + * @param b + * @return + * String + */ + public static String floatAdd(String a, String b) { + a=a.equals("")?"0":a; + b=b.equals("")?"0":b; + BigDecimal bg1 = new BigDecimal(a); + BigDecimal bg2 = new BigDecimal(b); + BigDecimal bd = bg1.add(bg2); + return bd.toString(); + } + + +} diff --git a/src/com/engine/nbkq/service/impl/NbkqServiceImpl.java b/src/com/engine/nbkq/service/impl/NbkqServiceImpl.java index 7c51c09..00a998c 100644 --- a/src/com/engine/nbkq/service/impl/NbkqServiceImpl.java +++ b/src/com/engine/nbkq/service/impl/NbkqServiceImpl.java @@ -153,7 +153,7 @@ public class NbkqServiceImpl extends Service implements NbkqService { requestMap.put("zy",zy); } if(StringUtils.isNotBlank(hklx)){ - requestMap.put("hklx",hklx); + requestMap.put("hklx1",hklx); } if(StringUtils.isNotBlank(zc)){ requestMap.put("zc",zc); @@ -198,7 +198,7 @@ public class NbkqServiceImpl extends Service implements NbkqService { requestMap.put("sg", sg); } if(StringUtils.isNotBlank(zzmm)) { - requestMap.put("zzmm", zzmm); + requestMap.put("zzmr", zzmm); } if(StringUtils.isNotBlank(cjgzsj)) { requestMap.put("cjgzsj", cjgzsj); @@ -248,7 +248,7 @@ public class NbkqServiceImpl extends Service implements NbkqService { bb.writeLog("开始处理明细"); //明细表1处理 List> list = new ArrayList>(); - String sqlDt1 = " select ksrq,jsrq,xx,zy,bz from uf_yrzbd_dt1 where mainid = "+id; + String sqlDt1 = " select ksrq,jsrq,xx,zy,bz,zmr,lxdh from uf_yrzbd_dt1 where mainid = "+id; rs.executeQuery(sqlDt1); while (rs.next()){ Map mapMode = new HashMap<>(); @@ -257,6 +257,8 @@ public class NbkqServiceImpl extends Service implements NbkqService { String xxNew = Util.null2String(rs.getString("xx")); String zyNew = Util.null2String(rs.getString("zy")); String bz = Util.null2String(rs.getString("bz")); + String zmr = Util.null2String(rs.getString("zmr")); + String lxdhDto = Util.null2String(rs.getString("lxdh")); if (StringUtils.isNotBlank(ksrq)){ mapMode.put("ksrq",ksrq); } @@ -272,6 +274,12 @@ public class NbkqServiceImpl extends Service implements NbkqService { if (StringUtils.isNotBlank(bz)){ mapMode.put("bz",bz); } + if (StringUtils.isNotBlank(zmr)){ + mapMode.put("zmr",zmr); + } + if (StringUtils.isNotBlank(lxdhDto)){ + mapMode.put("lxdh",lxdhDto); + } list.add(mapMode); } @@ -300,7 +308,7 @@ public class NbkqServiceImpl extends Service implements NbkqService { //明细表2处理 List> list2 = new ArrayList>(); - String sqlDt2 = " select ksrq,jsrq,gzdw,zw,lzyy,zmr from uf_yrzbd_dt2 where mainid = "+id; + String sqlDt2 = " select ksrq,jsrq,gzdw,zw,lzyy,zmr,xz,lxdh from uf_yrzbd_dt2 where mainid = "+id; rs.executeQuery(sqlDt2); while (rs.next()){ Map mapMode = new HashMap<>(); @@ -310,6 +318,8 @@ public class NbkqServiceImpl extends Service implements NbkqService { String zw = Util.null2String(rs.getString("zw")); String lzyy = Util.null2String(rs.getString("lzyy")); String zmr = Util.null2String(rs.getString("zmr")); + String xz = Util.null2String(rs.getString("xz")); + String lxdhDtT = Util.null2String(rs.getString("lxdh")); if (StringUtils.isNotBlank(ksrq)){ mapMode.put("ksrq",ksrq); } @@ -328,6 +338,12 @@ public class NbkqServiceImpl extends Service implements NbkqService { if (StringUtils.isNotBlank(zmr)){ mapMode.put("zmr",zmr); } + if (StringUtils.isNotBlank(xz)){ + mapMode.put("xz",xz); + } + if (StringUtils.isNotBlank(lxdhDtT)){ + mapMode.put("lxdh",lxdhDtT); + } list2.add(mapMode); } @@ -347,7 +363,7 @@ public class NbkqServiceImpl extends Service implements NbkqService { //明细表3处理 List> list3 = new ArrayList>(); - String sqlDt3 = " select xm,nl,ybrgx,zz,zy from uf_yrzbd_dt3 where mainid = "+id; + String sqlDt3 = " select xm,nl,ybrgx,zz,zy,lxdh from uf_yrzbd_dt3 where mainid = "+id; rs.executeQuery(sqlDt3); while (rs.next()){ Map mapMode = new HashMap<>(); @@ -356,6 +372,7 @@ public class NbkqServiceImpl extends Service implements NbkqService { String ybrgx = Util.null2String(rs.getString("ybrgx")); String zz = Util.null2String(rs.getString("zz")); String zyNew = Util.null2String(rs.getString("zy")); + String lxdhDtTh = Util.null2String(rs.getString("lxdh")); if (StringUtils.isNotBlank(xmNew)){ mapMode.put("xm",xmNew); @@ -372,6 +389,9 @@ public class NbkqServiceImpl extends Service implements NbkqService { if (StringUtils.isNotBlank(zyNew)){ mapMode.put("zy",zyNew); } + if (StringUtils.isNotBlank(lxdhDtTh)){ + mapMode.put("lxdh",lxdhDtTh); + } list3.add(mapMode); } diff --git a/src/com/engine/nbkq/web/NbjhWorkflowAction.java b/src/com/engine/nbkq/web/NbjhWorkflowAction.java new file mode 100644 index 0000000..1dfb812 --- /dev/null +++ b/src/com/engine/nbkq/web/NbjhWorkflowAction.java @@ -0,0 +1,39 @@ +package com.engine.nbkq.web; + +import com.alibaba.fastjson.JSONObject; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import java.util.HashMap; +import java.util.Map; + +public class NbjhWorkflowAction { + + @GET + @Path("/getUserSecLevel") + @Produces({MediaType.TEXT_PLAIN}) + public String checkOverTime(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try{ + User user = HrmUserVarify.getUser(request, response); + String secLevel = user.getSeclevel(); + String userId = user.getUID()+""; + apidatas.put("secLevel",secLevel); + apidatas.put("userId",userId); + apidatas.put("api_status",true); + }catch (Exception e) { + e.printStackTrace(); + apidatas.put("api_status",false); + apidatas.put("api_errormsg","exception:"+e.getMessage()); + } + return JSONObject.toJSONString(apidatas); + } + +} diff --git a/src/weaver/interfaces/bnkq/action/UpdateCcTimeAction.java b/src/weaver/interfaces/bnkq/action/UpdateCcTimeAction.java index c5f6617..16ec87e 100644 --- a/src/weaver/interfaces/bnkq/action/UpdateCcTimeAction.java +++ b/src/weaver/interfaces/bnkq/action/UpdateCcTimeAction.java @@ -1,13 +1,11 @@ package weaver.interfaces.bnkq.action; +import com.engine.kq.biz.KQFormatBiz; import com.engine.kq.biz.KQWorkTime; import com.engine.kq.entity.WorkTimeEntity; -import com.engine.workflow.service.HtmlToPdfService; -import org.apache.commons.lang3.StringUtils; import weaver.conn.RecordSet; import weaver.general.BaseBean; -import weaver.general.PinyinUtil; import weaver.general.TimeUtil; import weaver.general.Util; import weaver.interfaces.workflow.action.Action; @@ -20,7 +18,7 @@ import java.text.SimpleDateFormat; import java.util.*; /** - * 更新出差时长Action + * 更新出差时长Action */ public class UpdateCcTimeAction implements Action { @@ -50,36 +48,41 @@ public class UpdateCcTimeAction implements Action { //实际出差结束时间 String sjccjsrq = Util.null2String(mainInfo.get("sjccjsrq")); //部门 - String szbm = Util.null2String(mainInfo.get("szbm")); + String szbm = Util.null2String(mainInfo.get("szbm")); //分部 - String szgs = Util.null2String(mainInfo.get("szgs")); + String szgs = Util.null2String(mainInfo.get("szgs")); //相差天数 - Integer cz = TimeUtil.dateInterval(sjksrq, sjccjsrq) + 1; + Integer cz = TimeUtil.dateInterval(sjksrq,sjccjsrq)+1; //插入出差表 - Double czours = multiply(String.valueOf(cz), "8"); + Double czours = multiply(String.valueOf(cz),"8"); Set all = new HashSet<>(); all.add(sjksrq); - List back = days(sjksrq, sjccjsrq); + List back = days(sjksrq,sjccjsrq); all.addAll(back); all.add(sjccjsrq); KQWorkTime kqWorkTime = new KQWorkTime(); kqWorkTime.setIsFormat(true); - for (String date : all) { - bb.writeLog("date:" + date); + List> paramInsert = new ArrayList<>(); + for(String date:all){ + bb.writeLog("date:"+date); WorkTimeEntity tmpworkTime = kqWorkTime.getWorkTime(sqr, date); - if (tmpworkTime.getWorkMins() > 0) { - bb.writeLog("当天排班了:" + tmpworkTime.getWorkMins()); - insertLeave(reqid, Integer.valueOf(sqr), date, 8.00, "3", "1", szgs, szbm, date, wfid, tablaName); - insertDetail(sqr, date, rs); + if(tmpworkTime.getWorkMins()>0){ + bb.writeLog("当天排班了:"+tmpworkTime.getWorkMins()); + insertLeave(reqid,Integer.valueOf(sqr),date,8.00,"3","1",szgs,szbm,date,wfid,tablaName); + List params = new ArrayList<>(); + params.add(sqr); + params.add(date); + paramInsert.add(params); } } + new KQFormatBiz().format(paramInsert); } catch (Exception e) { e.printStackTrace(); bb.writeLog(e); - bb.writeLog("更新人员出差时长error" + e.getMessage()); + bb.writeLog("更新人员出差时长error"+e.getMessage()); info.getRequestManager().setMessageid("2000"); info.getRequestManager().setMessagecontent("更新人员出差时长error"); return Action.FAILURE_AND_CONTINUE; @@ -87,15 +90,9 @@ public class UpdateCcTimeAction implements Action { return Action.SUCCESS; } - private void insertDetail(String resourceId, String date, RecordSet rs) { - String sql = "update kq_format_detail set evectionMins=480,absenteeismMins=0 where resourceid=? and kqdate='" + date + "'"; - rs.executeUpdate(sql, resourceId); - } - /** * 获取两个日期之间所有的日期 - * * @param date1 * @param date2 * @return @@ -158,7 +155,6 @@ public class UpdateCcTimeAction implements Action { /** * 提供精确的乘法运算。 - * * @param v1 被加数 * @param v2 加数 * @return 两个参数的和 @@ -171,34 +167,19 @@ public class UpdateCcTimeAction implements Action { /** * 插入请假拆分表 - * * @param requestid * @param userid * @param fromDate * @param MaxHours */ - private static void insertLeave(String requestid, Integer userid, String fromDate, Double MaxHours, String durationrule, String newleavetype, String subcompany, String department, String toDate, String wfid, String tablename) { - BaseBean bb = new BaseBean(); + private static void insertLeave(String requestid,Integer userid,String fromDate,Double MaxHours,String durationrule,String newleavetype,String subcompany,String department,String toDate,String wfid,String tablename){ + BaseBean bb = new BaseBean(); //插入加班时间 RecordSet rsInsert = new RecordSet(); String sql = "insert into kq_flow_split_evection (requestid,resourceid,fromdate,fromtime,todate,totime,duration,durationrule,belongdate,newleavetype,subcompanyid,departmentid,workflowid,tablenamedb) " + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?) "; - 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); - } - - + rsInsert.executeUpdate(sql, requestid,userid,fromDate,"08:00",toDate,"17:00",MaxHours,durationrule,fromDate,newleavetype,subcompany,department,wfid,tablename); + bb.writeLog("insertSql:"+sql); } }