diff --git a/src/com/api/xcy/web/KQXCYAction.java b/src/com/api/xcy/web/KQXCYAction.java new file mode 100644 index 0000000..ef61aaa --- /dev/null +++ b/src/com/api/xcy/web/KQXCYAction.java @@ -0,0 +1,7 @@ +package com.api.xcy.web; + +import javax.ws.rs.Path; + +@Path("/xcy/kq") +public class KQXCYAction extends com.engine.xcy.web.KQXCYAction { +} diff --git a/src/com/engine/kq/bean/KQBalanceDetail.java b/src/com/engine/kq/bean/KQBalanceDetail.java index 7f27232..774c6cb 100644 --- a/src/com/engine/kq/bean/KQBalanceDetail.java +++ b/src/com/engine/kq/bean/KQBalanceDetail.java @@ -124,10 +124,10 @@ public class KQBalanceDetail extends BaseBean { errorInfo = ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005288,weaver.general.ThreadVarLanguage.getLang())+""; return errorInfo; } - if (_totalAmount < _usedAmount) { - errorInfo = ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(508124,weaver.general.ThreadVarLanguage.getLang())+""; - return errorInfo; - } +// if (_totalAmount < _usedAmount) { +// errorInfo = ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(508124,weaver.general.ThreadVarLanguage.getLang())+""; +// return errorInfo; +// } if (this.leaveRulesId.equals("")) { errorInfo = ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005289,weaver.general.ThreadVarLanguage.getLang())+"ID"; return errorInfo; diff --git a/src/com/engine/kq/biz/KQReportBiz.java b/src/com/engine/kq/biz/KQReportBiz.java index 23e1a46..6a521cb 100644 --- a/src/com/engine/kq/biz/KQReportBiz.java +++ b/src/com/engine/kq/biz/KQReportBiz.java @@ -303,16 +303,22 @@ public class KQReportBiz extends BaseBean { return unitTypeName; } - public Map getFlowData(Map params, User user){ - Map datas = new HashMap<>();; - try{ - datas.putAll(getFlowLeaveData(params,user)); - datas.putAll(getFlowEvectionOutData(params,user)); - datas.putAll(getFlowOverTimeDataNew(params,user)); - datas.putAll(getFlowOtherData(params,user)); - datas.putAll(getFlowLeaveBackData(params,user)); - datas.putAll(getFlowProcessChangeData(params,user)); - }catch (Exception e){ + public Map getFlowData(Map params, User user) { + Map datas = new HashMap<>(); + try { + datas.putAll(getFlowLeaveData(params, user, "")); + datas.putAll(getFlowEvectionOutData(params, user)); + datas.putAll(getFlowOverTimeDataNew(params, user)); + datas.putAll(getFlowOtherData(params, user)); + datas.putAll(getFlowLeaveBackData(params, user)); + datas.putAll(getFlowProcessChangeData(params, user)); + // 新创元二开:跨厂办公时长 +// datas.putAll(getFlowKCBGData(params, user)); + // 新创元二开: 补卡次数 + datas.putAll(getFlowBKCSData(params, user)); + // 新创元二开: 年累计事假 + datas.putAll(getFlowLeaveData(params, user, "1")); + } catch (Exception e) { writeLog(e); } return datas; @@ -324,14 +330,18 @@ public class KQReportBiz extends BaseBean { * @param user * @return */ - public Map getDailyFlowData(Map params, User user){ - Map datas = new HashMap<>();; - try{ - datas.putAll(getDailyFlowLeaveData(params,user)); - datas.putAll(getDailyFlowEvectionOutData(params,user)); - datas.putAll(getDailyFlowOverTimeData(params,user)); - datas.putAll(getDailyFlowLeaveBackData(params,user)); - }catch (Exception e){ + public Map getDailyFlowData(Map params, User user) { + Map datas = new HashMap<>(); + try { + datas.putAll(getDailyFlowLeaveData(params, user)); + datas.putAll(getDailyFlowEvectionOutData(params, user)); + datas.putAll(getDailyFlowOverTimeData(params, user)); + datas.putAll(getDailyFlowLeaveBackData(params, user)); + // 新创元二开:跨厂办公时长 +// datas.putAll(getFlowKCBGData(params, user)); + // 新创元二开:补卡次数 + datas.putAll(getFlowBKCSData(params, user)); + } catch (Exception e) { writeLog(e); } return datas; @@ -399,18 +409,19 @@ public class KQReportBiz extends BaseBean { } for(String table : tables){ - sql = " select resourceid, durationrule, sum(duration) as val from hrmresource a, "+table+" b "+ - " where a.id = b.resourceid and (b.status is null or b.status<>1) and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' "+sqlWhere+ - " group by resourceid, durationrule "; + sql = " select b.resourceid, durationrule, sum(b.duration) as val,CCSQLX from hrmresource a, "+table+" b,"+kcbgFlowTable+" c "+ + " where a.id = b.resourceid AND b.REQUESTID = c.REQUESTID and (b.status is null or b.status<>1) and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' "+sqlWhere+ + " group by b.resourceid, durationrule, CCSQLX "; rs.execute(sql); while (rs.next()) { String resourceid = rs.getString("resourceid"); double value = rs.getDouble("val"); String durationrule = rs.getString("durationrule"); + String evectionType = rs.getString("CCSQLX");//此次出差类型 String flowType = ""; if(KqSplitFlowTypeEnum.EVECTION.getTablename().equals(table)){ - flowType = "businessLeave"; + flowType = "businessLeave|"+evectionType; minimumUnit = KQTravelRulesBiz.getMinimumUnit();//单位类型 proportion = Util.getDoubleValue(KQTravelRulesBiz.getHoursToDay());//换算关系 @@ -507,19 +518,20 @@ public class KQReportBiz extends BaseBean { } for(String table : tables){ - sql = " select resourceid, durationrule, sum(duration) as val,belongdate from hrmresource a, "+table+" b "+ - " where a.id = b.resourceid and (b.status is null or b.status<>1) and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' "+sqlWhere+ - " group by resourceid, durationrule,belongdate "; + sql = " select b.resourceid, durationrule, sum(b.duration) as val,belongdate,CCSQLX from hrmresource a, "+table+" b,"+kcbgFlowTable+" c "+ + " where a.id = b.resourceid and b.REQUESTID = c.REQUESTID and (b.status is null or b.status<>1) and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' "+sqlWhere+ + " group by b.resourceid, durationrule,belongdate,CCSQLX "; rs.execute(sql); while (rs.next()) { String resourceid = rs.getString("resourceid"); String belongdate = rs.getString("belongdate"); double value = rs.getDouble("val"); String durationrule = rs.getString("durationrule"); + String evectionType = rs.getString("CCSQLX");//此次出差类型 String flowType = ""; if(KqSplitFlowTypeEnum.EVECTION.getTablename().equals(table)){ - flowType = "businessLeave"; + flowType = "businessLeave"+"|"+evectionType; minimumUnit = KQTravelRulesBiz.getMinimumUnit();//单位类型 proportion = Util.getDoubleValue(KQTravelRulesBiz.getHoursToDay());//换算关系 }else if(KqSplitFlowTypeEnum.OUT.getTablename().equals(table)){ @@ -559,7 +571,7 @@ public class KQReportBiz extends BaseBean { * @param user * @return */ - public Map getFlowLeaveData(Map params, User user){ + public Map getFlowLeaveData(Map params, User user,String type){ Map datas = new HashMap<>();; RecordSet rs = new RecordSet(); String sql = ""; @@ -567,6 +579,7 @@ public class KQReportBiz extends BaseBean { try{ KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); String toDate = Util.null2String(jsonObj.get("toDate")); String typeselect =Util.null2String(jsonObj.get("typeselect")); @@ -580,6 +593,13 @@ public class KQReportBiz extends BaseBean { toDate = TimeUtil.getDateByOption(typeselect,"1"); } } + + if (type.equals("1")) {//二开:type =1 时,统计请假 汇总值(本年累加) + fromDate = TimeUtil.getDateByOption("5","0");//本年第一天 + if (typeselect.equals("6")) { + fromDate = fromDate.substring(0,4) + "-01-01"; + } + } String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); String departmentId = Util.null2String(jsonObj.get("departmentId")); String resourceId = Util.null2String(jsonObj.get("resourceId")); @@ -631,6 +651,9 @@ public class KQReportBiz extends BaseBean { } String key = resourceid+"|leaveType_"+newleavetype; + if (type.equals("1")) {//二开:汇总 + key = resourceid+"|leaveType_all_"+newleavetype; + } if(datas.containsKey(key)){ value += Util.getDoubleValue(Util.null2String(datas.get(key))); } @@ -1437,6 +1460,7 @@ public class KQReportBiz extends BaseBean { Map tmpdata = null; Map tmpmap = null; RecordSet rs = new RecordSet(); + RecordSet recordSet = new RecordSet(); String sql = ""; try { sql = " select resourceid, kqdate, workMins, belatemins, graveBeLateMins, leaveearlymins, graveLeaveEarlyMins, absenteeismmins, forgotcheckMins, forgotBeginWorkCheckMins, "+ @@ -1447,6 +1471,7 @@ public class KQReportBiz extends BaseBean { rs.executeQuery(sql,resourceId, fromDate,toDate); while (rs.next()) { String key = rs.getString("resourceid") + "|" + rs.getString("kqdate"); + String kqdate = rs.getString("kqdate"); int workMins = rs.getInt("workMins"); int beLateMins = rs.getInt("beLateMins"); int leaveEarlyMins = rs.getInt("leaveEarlyMins"); @@ -1529,6 +1554,12 @@ public class KQReportBiz extends BaseBean { } } if (evectionMins > 0) {//出差 + String kcbgsql = "select a.REQUESTID from kq_flow_split_evection a,"+kcbgFlowTable+" b\n" + + "WHERE a.REQUESTID = b.REQUESTID AND b.ccsqlx = 1 and b.RESOURCEID ='"+resourceId+"' AND a.FROMDATE >= '"+kqdate+"' AND a.TODATE <= '"+kqdate+"'"; + recordSet.execute(kcbgsql); + if (recordSet.next()) { + text += "跨厂办公"; + } if(text.indexOf(SystemEnv.getHtmlLabelName(20084, user.getLanguage()))==-1) { if (text.length() > 0) text += " "; text += SystemEnv.getHtmlLabelName(20084, user.getLanguage()); @@ -1796,6 +1827,161 @@ public class KQReportBiz extends BaseBean { return text; } + /** + * 获取出差/跨厂办公审批流中出差时长 + * @param params + * @param user + * @return + */ + public Map getFlowKCBGData(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and b.resourceid in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + sql = "SELECT b.resourceid,b.REQUESTID,max(c.duration) duration FROM HRMRESOURCE a, kq_flow_split_evection b,"+kcbgFlowTable+" c\n" + + "WHERE a.id=b.RESOURCEID AND b.REQUESTID = c.REQUESTID AND c.ccsqlx='2' and fromdatedb >='"+fromDate+"' and fromdatedb <='"+toDate+"' "+sqlWhere+ + "GROUP BY b.resourceid,b.REQUESTID "; + rs.execute(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + double value = rs.getDouble("duration"); + String flowType = "kcbg"; + String key = resourceid+"|"+flowType; + if(datas.containsKey(key)){ + value += Util.getDoubleValue(Util.null2String(datas.get(key))); + } + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + datas.put(key, df.format(value)); + } + + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + // 补卡流程 + private static final String bkWorkFlowMainTable = new BaseBean().getPropValue("xcy_kq", "xcy_kq_bk_mainTab"); + private static final String bkWorkFlowDetTable = new BaseBean().getPropValue("xcy_kq", "xcy_kq_bk_detailTab"); + // 跨厂办公流程表 + private static final String kcbgFlowTable = new BaseBean().getPropValue("xcy_kq","xcy_kq_cckcbg"); + + /** + * 获取补卡次数 + * @param params + * @param user + * @return + */ + public Map getFlowBKCSData(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String fromSql = " from hrmResource a,"+bkWorkFlowMainTable+" b, "+bkWorkFlowDetTable+" c "; + String sqlWhere = ""; + try{ + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and b.resourceid in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + sql = "SELECT b.resourceId,c.detail_signdate,count(1) AS bkcs " +fromSql+ + "WHERE a.id=b.resourceId AND b.id=c.mainid AND c.bkyy=0 AND c.detail_signdate >='"+fromDate+"' and c.detail_signdate <='"+toDate+"' "+sqlWhere+ + "GROUP BY b.resourceId,c.detail_signdate"; + rs.execute(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceId"); + String value = rs.getString("bkcs"); + String flowType = "bkcs"; + String key = resourceid+"|"+flowType; + datas.put(key, value); + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + public static boolean getShowFlowText(String leaveInfo,String onOrOff){ Map jsonObject = null; jsonObject = JSON.parseObject(leaveInfo); diff --git a/src/com/engine/kq/cmd/balanceofleavedetail/EditBalanceCmd.java b/src/com/engine/kq/cmd/balanceofleavedetail/EditBalanceCmd.java index 1e4d599..822c312 100644 --- a/src/com/engine/kq/cmd/balanceofleavedetail/EditBalanceCmd.java +++ b/src/com/engine/kq/cmd/balanceofleavedetail/EditBalanceCmd.java @@ -83,11 +83,11 @@ public class EditBalanceCmd extends AbstractCommonCommand> { double _tiaoxiuAmount = Util.getDoubleValue(tiaoxiuAmount, 0.00); BigDecimal _tiaoxiuamount = new BigDecimal(Util.getDoubleValue(tiaoxiuAmount, 0.00)).setScale(2,RoundingMode.HALF_UP); /*已休不能大于总数*/ - if ((_totalAmount+_tiaoxiuAmount) < _usedAmount) { +/* if ((_totalAmount+_tiaoxiuAmount) < _usedAmount) { resultMap.put("sign", "-1"); resultMap.put("message", SystemEnv.getHtmlLabelName(529202, user.getLanguage())); return resultMap; - } + }*/ /*失效日期不能小于加班日期*/ if (!"".equals(expirationDate)&& !"".equals(effectiveDate) && expirationDate.compareTo(effectiveDate) < 0) { resultMap.put("sign", "-1"); diff --git a/src/com/engine/kq/cmd/report/GetKQDailyReportCmd.java b/src/com/engine/kq/cmd/report/GetKQDailyReportCmd.java index fd195ad..2526216 100644 --- a/src/com/engine/kq/cmd/report/GetKQDailyReportCmd.java +++ b/src/com/engine/kq/cmd/report/GetKQDailyReportCmd.java @@ -12,6 +12,8 @@ import com.engine.kq.log.KQLog; import com.engine.kq.util.KQDurationCalculatorUtil; import com.engine.kq.util.PageUidFactory; import java.math.BigDecimal; + +import com.engine.kq.util.UtilKQXcy; import weaver.common.DateUtil; import weaver.conn.RecordSet; import weaver.general.TimeUtil; @@ -39,6 +41,7 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand execute(CommandContext commandContext) { Map retmap = new HashMap(); RecordSet rs = new RecordSet(); + RecordSet recordSet = new RecordSet(); String sql = ""; try{ String pageUid = PageUidFactory.getHrmPageUid("KQDailyReport"); @@ -128,8 +131,11 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand serialIdList = new ArrayList<>(); + while (rs.next()) { + serialIdList.add(Util.null2String(rs.getString("id"))); + } + rs.execute(sql); while (rs.next()) { String id = rs.getString("id"); @@ -292,7 +305,7 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand0) {//弹性工作制没有班次 data.put("serialid", shiftManagementToolKit.getShiftOnOffWorkSections(fieldValue, user.getLanguage())); } - }else { + } else if (fieldName.equals("ybts") ) {//夜班天数 + String serialid = rs.getString("serialid"); + if (serialIdList.contains(serialid)) { + fieldValue = isSign(resourceId,kqdate,serialid) ? "1" : "0"; + } else { + fieldValue = "0"; + } + data.put(fieldName, fieldValue); + } else if (fieldName.equals("companystartdate")) {//入职日期 + fieldValue = Util.null2String(rs.getString("companystartdate")); + data.put(fieldName, fieldValue); + } else if (fieldName.equals("companyenddate")) {//离职日期 + fieldValue = getCompanyEndDate(recordSet,id); + data.put(fieldName, fieldValue); + } else if (fieldName.equals("bkcs")) {//补卡次数 + fieldValue = new UtilKQXcy().getBkCounts(recordSet,id,kqdate,kqdate); + data.put(fieldName, fieldValue); + } else if (fieldName.equals("qqts")) {//缺勤天数 + // 每日报表中国缺勤取旷工数 + String absenteeism = Util.null2String(rs.getString("absenteeism")); + data.put(fieldName,absenteeism); + } else { fieldValue = Util.null2String(rs.getString(fieldName)); if (kqReportFieldComInfo.getUnittype().equals("2") && fieldValue.length() > 0) { fieldValue = KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(fieldValue) / 60.0))); @@ -389,6 +427,21 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand> { public Map execute(CommandContext commandContext) { Map retmap = new HashMap(); RecordSet rs = new RecordSet(); + RecordSet recordSet = new RecordSet(); String sql = ""; try { String pageUid = PageUidFactory.getHrmPageUid("KQReport"); @@ -160,10 +164,13 @@ public class GetKQReportCmd extends AbstractCommonCommand> { String forgotBeginWorkCheck_field = " sum(b.forgotBeginWorkCheck) "; + String xcy_fields = " max(b.serialId) as serialId,max(a.companystartdate) companystartdate, "; + if (rs.getDBType().equalsIgnoreCase("oracle")) { forgotBeginWorkCheck_field = " sum(nvl(b.forgotBeginWorkCheck,0)) "; } else if ((rs.getDBType()).equalsIgnoreCase("mysql")) { forgotBeginWorkCheck_field = " sum(ifnull(b.forgotBeginWorkCheck,0)) "; + xcy_fields = "b.serialId,a.companystartdate, "; } else { forgotBeginWorkCheck_field = " sum(isnull(b.forgotBeginWorkCheck,0)) "; } @@ -171,7 +178,7 @@ public class GetKQReportCmd extends AbstractCommonCommand> { Map definedFieldInfo = new KQFormatBiz().getDefinedField(); String definedFieldSum = Util.null2String(definedFieldInfo.get("definedFieldSum")); - String backFields = " a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1 as subcompanyid,a.departmentid,a.jobtitle," + + String backFields = "a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1 as subcompanyid,a.departmentid,a.jobtitle," + xcy_fields + " 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," + @@ -306,6 +313,14 @@ public class GetKQReportCmd extends AbstractCommonCommand> { String isShowFullPath = Util.null2String(kqSettingsComInfo.getMain_val(fullPathMainKey), "0"); Map flowData = kqReportBiz.getFlowData(params, user); + + // 查询班次名中含有“夜班”的班次号 + rs.executeQuery("select id from kq_shiftmanagement where serial like '%夜班%'"); + List serialIdList = new ArrayList<>(); + while (rs.next()) { + serialIdList.add(Util.null2String(rs.getString("id"))); + } + rs.execute(sql); while (rs.next()) { data = new HashMap<>(); @@ -361,7 +376,7 @@ public class GetKQReportCmd extends AbstractCommonCommand> { data.put(serialIds.get(i), kqReportBiz.getSerialCount(id, fromDate, toDate, serialIds.get(i))); } } else if (kqReportFieldComInfo.getParentid().equals("overtime") || kqReportFieldComInfo.getParentid().equals("overtime_nonleave") - || kqReportFieldComInfo.getParentid().equals("overtime_4leave") || fieldName.equals("businessLeave") || fieldName.equals("officialBusiness")) { + || kqReportFieldComInfo.getParentid().equals("overtime_4leave") || fieldName.equals("businessLeave") || fieldName.equals("officialBusiness")|| fieldName.equals("kcbg")) { if (fieldName.equals("overtimeTotal")) { double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|workingDayOvertime_4leave"))); workingDayOvertime_4leave = workingDayOvertime_4leave < 0 ? 0 : workingDayOvertime_4leave; @@ -381,6 +396,9 @@ public class GetKQReportCmd extends AbstractCommonCommand> { workingDayOvertime_nonleave + restDayOvertime_nonleave + holidayOvertime_nonleave)); } else if (fieldName.equals("businessLeave") || fieldName.equals("officialBusiness")) { String businessLeaveData = Util.null2s(Util.null2String(flowData.get(id + "|" + fieldName)), "0.0"); + if (fieldName.equals("businessLeave")) { + businessLeaveData = Util.null2s(Util.null2String(flowData.get(id + "|" + fieldName + "|0")), "0.0"); + } String backType = fieldName + "_back"; String businessLeavebackData = Util.null2s(Util.null2String(flowData.get(id + "|" + backType)), "0.0"); String businessLeave = ""; @@ -401,9 +419,62 @@ public class GetKQReportCmd extends AbstractCommonCommand> { } catch (Exception e) { } fieldValue = KQDurationCalculatorUtil.getDurationRound(businessLeave); - } else { + } else if (fieldName.equals("kcbg")) {//跨厂办公 + fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|businessLeave|1"))); + } + else { fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|" + fieldName))); } + } else if (fieldName.equals("ybcs")) {//夜班次数 + fieldValue = getMonthYBCS(recordSet, fromDate, toDate, resourceId, String.join(",", serialIdList)); + } else if (fieldName.equals("companystartdate")) {//入职日期 + fieldValue = Util.null2String(rs.getString("companystartdate")); + } else if (fieldName.equals("companyenddate")) {//离职日期 + fieldValue = getCompanyEndDate(recordSet,id); + } else if (fieldName.equals("bkcs")) {//补卡次数 + fieldValue = new UtilKQXcy().getBkCounts(recordSet,id,fromDate,toDate); + } else if (fieldName.equals("qqts")) {//缺勤天数 + String companystartdate = Util.null2String(rs.getString("companystartdate")); + String companyenddate = getCompanyEndDate(recordSet,id); +// String companystartdate = "2023-04-12"; +// String companyenddate = "2023-04-20"; + //判断入职日期、离职日期是否在选择范围中 + UtilKQXcy utilKQXcy = new UtilKQXcy(); + WorkDayDao workDayDao = new WorkDayDao(); + List workDays = new ArrayList(); + int absenteeism = Util.getIntValue(rs.getInt("absenteeism")); + if (companystartdate.length() > 0) { + boolean startFlag = utilKQXcy.isRangeOfDate(fromDate,toDate,companystartdate); + if (startFlag) {//缺勤天数加上 月初到入职日期的工作日 + workDays = workDayDao.getWorkDays(fromDate,companystartdate,id); + absenteeism = absenteeism + workDays.size(); + } + } + if (companyenddate.length()>0) { + boolean endFlag = utilKQXcy.isRangeOfDate(fromDate, toDate, companyenddate); + if (endFlag) {//缺勤天数加上 离职日期到月末的工作日 + workDays = workDayDao.getWorkDays(companyenddate, toDate, id); + absenteeism = absenteeism + workDays.size(); + } + } + fieldValue = String.valueOf(absenteeism); + } else if (fieldName.equals("yearPersonalLeave")) {//年累计事假天数 + String yearLeaveData = Util.null2String(flowData.get(id + "|leaveType_all_6"));//原事假天数 + //以防止出现精度问题 + if (yearLeaveData.length() == 0) { + yearLeaveData = "0.0"; + } + fieldValue = KQDurationCalculatorUtil.getDurationRound(yearLeaveData); + } else if (fieldName.equals("yearabsenteeism")) {//年累计旷工天数 + String begDate = fromDate.substring(0,4)+"-01-01"; + String yearAbsenteeismSql = "select b.resourceid,sum(b.absenteeism) AS yearabsenteeism from hrmresource a, kq_format_total b where a.id= b.resourceid and " + + "b.kqdate >= '"+begDate+"' and b.kqdate <='"+toDate+"' and a.id="+id+" group by b.resourceid"; + recordSet.executeQuery(yearAbsenteeismSql); + String yearAbsenteeism = ""; + if (recordSet.next()) { + yearAbsenteeism = Util.null2String(recordSet.getString("yearabsenteeism")); + } + fieldValue = yearAbsenteeism.length() == 0 ? "0" : yearAbsenteeism ; } else { fieldValue = Util.null2String(rs.getString(fieldName)); if (Util.null2String(kqReportFieldComInfo.getUnittype()).length() > 0) { @@ -631,6 +702,33 @@ public class GetKQReportCmd extends AbstractCommonCommand> { return lsChildColumns; } + // 考勤汇总报表中夜班次数 + private String getMonthYBCS (RecordSet rs,String fromDate,String toDate,String resourceId,String serialIds) { + String count = "0"; + String sql = "select count(1) ybcs from kq_format_detail where kqdate >= '"+fromDate+"' and kqdate <='"+toDate+"' and resourceid='"+resourceId+"' and serialid in ("+serialIds+")"; + String sqlWhere = ""; + if (rs.getDBType().equalsIgnoreCase("oracle")) { + sqlWhere = " and nvl(signindate,'')!='' and nvl(signintime,'')!='' and nvl(signoutdate,'') != '' and nvl(signouttime,'') !=''"; + } else { + sqlWhere = " and IFNULL(signindate,'')!='' and IFNULL(signintime,'')!='' and IFNULL(signoutdate,'') != '' and IFNULL(signouttime,'') !=''"; + } + rs.execute(sql+sqlWhere); + if (rs.next()) { + count = Util.null2String(rs.getString("ybcs")); + } + return count; + } + + // 获取人员离职日期 + private String getCompanyEndDate (RecordSet rs,String resourceId) { + String sql = "select changedate from hrmstatushistory a where TYPE_N=5 and RESOURCEID=?"; + rs.executeQuery(sql,resourceId); + if (rs.next()) { + return Util.null2String(rs.getString("changedate")); + } + return ""; + } + @Override public BizLogContext getLogContext() { return null; diff --git a/src/com/engine/kq/util/UtilKQXcy.java b/src/com/engine/kq/util/UtilKQXcy.java new file mode 100644 index 0000000..b8bc1c6 --- /dev/null +++ b/src/com/engine/kq/util/UtilKQXcy.java @@ -0,0 +1,78 @@ +package com.engine.kq.util; + +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * @Author ml + * @Date 2023/4/24 + * @Description 新创元考勤模块 + * @Since version-1.0 + */ +public class UtilKQXcy extends BaseBean { + // 补卡流程 + private static final String bkWorkFlowMainTable = new BaseBean().getPropValue("xcy_kq", "xcy_kq_bk_mainTab"); + private static final String bkWorkFlowDetTable = new BaseBean().getPropValue("xcy_kq", "xcy_kq_bk_detailTab"); + + /** + * 获取人员离职日期 + * @return String + */ + public String getCompanyEndDate (RecordSet rs,String resourceId) { + String sql = "select changedate from hrmstatushistory a where TYPE_N=5 and RESOURCEID=?"; + rs.executeQuery(sql,resourceId); + if (rs.next()) { + return Util.null2String(rs.getString("changedate")); + } + return ""; + } + + /** + * 判断日期是否在选择日期范围内 + * @return boolean + */ + public boolean isRangeOfDate (String begDate, String endDate, String targetDate) { + + SimpleDateFormat simpleDateFormat =new SimpleDateFormat("yyyy-MM-dd"); + try { + Date date1 = simpleDateFormat.parse(begDate); + Date date2 = simpleDateFormat.parse(endDate); + Date date3 = simpleDateFormat.parse(targetDate); + + if(date1.getTime()<=date3.getTime() && date2.getTime()>=date3.getTime()){ + System.out.println("date3在date1和date2日期范围内!"); + return true; + } + } catch (ParseException e) { + throw new RuntimeException(e); + } + return false; + } + + // 获取人员补卡次数 + public String getBkCounts (RecordSet rs,String resourceId,String fromDate,String toDate) { + String sql = "SELECT userid,signfrom FROM HRMRESOURCE a,\n" + + "HrmScheduleSign b WHERE a.id=b.USERID AND a.id ='"+resourceId+"' AND signdate >= '"+fromDate+"' AND signdate <= '"+toDate+"'"; + rs.execute(sql); + RecordSet recordSet = new RecordSet(); + int count = 0; + while (rs.next()) { + String signfrom = Util.null2String(rs.getString("signfrom")); + if (signfrom.contains("card")) { + String signfrom1 = signfrom.substring(signfrom.indexOf("|",signfrom.indexOf("|") + 1) + 1); + String signfrom2 = signfrom1.substring(signfrom1.indexOf("|",signfrom1.indexOf("|") + 1) + 1); + String requestId = signfrom2.substring(0,signfrom2.indexOf("|")); + recordSet.execute("SELECT count(1) counts FROM "+bkWorkFlowMainTable+" a,"+bkWorkFlowDetTable+" b WHERE a.ID =b.MAINID AND a.REQUESTID = '"+requestId+"' AND bkyy='0'"); + if (recordSet.next()) { + count = count + Integer.parseInt(recordSet.getString("counts")); + } + } + } + return String.valueOf(count); + } +} diff --git a/src/com/engine/xcy/cmd/GetOverTimeWorkDurationXcyCmd.java b/src/com/engine/xcy/cmd/GetOverTimeWorkDurationXcyCmd.java new file mode 100644 index 0000000..35927d1 --- /dev/null +++ b/src/com/engine/xcy/cmd/GetOverTimeWorkDurationXcyCmd.java @@ -0,0 +1,90 @@ +package com.engine.xcy.cmd; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQGroupMemberComInfo; +import com.engine.kq.biz.KQOvertimeRulesBiz; +import com.engine.kq.biz.KQWorkTime; +import com.engine.kq.entity.WorkTimeEntity; +import com.engine.kq.enums.DurationTypeEnum; +import com.engine.kq.util.KQDurationCalculatorUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.Map; + +public class GetOverTimeWorkDurationXcyCmd extends AbstractCommonCommand> { + + public GetOverTimeWorkDurationXcyCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + String sql = ""; + try{ + String resourceId = Util.null2String(params.get("resourceId")); + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + String fromTime = Util.null2String(params.get("fromTime")); + String toTime = Util.null2String(params.get("toTime")); + String overtime_type = Util.null2String(params.get("overtime_type")); + String timestamp = Util.null2String(params.get("timestamp")); + + int minimumUnit = KQOvertimeRulesBiz.getMinimumUnit(); + // + KQWorkTime kqWorkTime = new KQWorkTime(); + WorkTimeEntity kqWorkTimeEntity = kqWorkTime.getWorkTime(resourceId,fromDate); + if(kqWorkTimeEntity != null){ + String kqType = Util.null2String(kqWorkTimeEntity.getKQType()); + if("3".equalsIgnoreCase(kqType)){ + writeLog("自由班制不计算加班"); + retmap.put("status", "1"); + retmap.put("message", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005330,weaver.general.ThreadVarLanguage.getLang())+""); + return retmap; + } + } + ResourceComInfo rci = new ResourceComInfo(); + KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo(); + String groupid = kqGroupMemberComInfo.getKQGroupId(resourceId,fromDate); + if(resourceId.length() > 0 && groupid.length() == 0){ + retmap.put("status", "-1"); + retmap.put("message", rci.getLastname(resourceId)+","+fromDate+""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005329,weaver.general.ThreadVarLanguage.getLang())+""); + return retmap; + } + + + //加班默认是工作日加班 + KQDurationCalculatorUtil kqDurationCalculatorUtil =new KQDurationCalculatorUtil.DurationParamBuilder(resourceId). + fromDateParam(fromDate).toDateParam(toDate).fromTimeParam(fromTime).toTimeParam(toTime).computingModeParam("1"). + durationRuleParam(minimumUnit+"").durationTypeEnumParam(DurationTypeEnum.OVERTIME). + overtime_typeParam(overtime_type).build(); + + Map durationMap = kqDurationCalculatorUtil.getWorkDuration(); + + retmap.put("duration", Util.null2String(durationMap.get("min_duration"))); + retmap.put("timestamp", timestamp); + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} + diff --git a/src/com/engine/xcy/service/KQXCYService.java b/src/com/engine/xcy/service/KQXCYService.java new file mode 100644 index 0000000..439b66b --- /dev/null +++ b/src/com/engine/xcy/service/KQXCYService.java @@ -0,0 +1,20 @@ +package com.engine.xcy.service; + +import weaver.hrm.User; + +import java.util.Map; + + +/** + * 新创元二开:考勤流程相关的ajax请求事件 + */ +public interface KQXCYService { + + /** + * 获取加班工作时长 + * @param params + * @param user + * @return + */ + public Map getOverTimeDuration(Map params, User user); +} diff --git a/src/com/engine/xcy/service/impl/KQXCYServiceImpl.java b/src/com/engine/xcy/service/impl/KQXCYServiceImpl.java new file mode 100644 index 0000000..b06ab8c --- /dev/null +++ b/src/com/engine/xcy/service/impl/KQXCYServiceImpl.java @@ -0,0 +1,16 @@ +package com.engine.xcy.service.impl; + +import com.engine.core.impl.Service; +import com.engine.xcy.cmd.GetOverTimeWorkDurationXcyCmd; +import com.engine.xcy.service.KQXCYService; +import weaver.hrm.User; + +import java.util.Map; + +public class KQXCYServiceImpl extends Service implements KQXCYService { + + @Override + public Map getOverTimeDuration(Map params, User user) { + return commandExecutor.execute(new GetOverTimeWorkDurationXcyCmd(params, user)); + } +} diff --git a/src/com/engine/xcy/web/KQXCYAction.java b/src/com/engine/xcy/web/KQXCYAction.java new file mode 100644 index 0000000..5d927b1 --- /dev/null +++ b/src/com/engine/xcy/web/KQXCYAction.java @@ -0,0 +1,51 @@ +package com.engine.xcy.web; + +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.xcy.service.KQXCYService; +import com.engine.xcy.service.impl.KQXCYServiceImpl; +import weaver.general.BaseBean; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.POST; +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 KQXCYAction { + + private final BaseBean logger = new BaseBean(); + + private KQXCYService getService(User user) { + return (KQXCYServiceImpl) ServiceUtil.getService(KQXCYServiceImpl.class, user); + } + + /** + * 获取加班的工作时长 + * @param request + * @param response + * @return + */ + @POST + @Path("/getOverTimeDurationXcy") + @Produces(MediaType.TEXT_PLAIN) + public String getOverTimeDuration(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map apidatas = new HashMap(); + try { + User user = HrmUserVarify.getUser (request , response) ; + // 调用新创元处理逻辑 + apidatas = getService(user).getOverTimeDuration(ParamUtil.request2Map(request), user); + } catch (Exception e) { + apidatas.put("status", "-1"); + logger.writeLog(e); + } + return JSONObject.toJSONString(apidatas); + } +}