diff --git a/src/com/customization/sskj/GetTabsCmdInter.java b/src/com/customization/sskj/GetTabsCmdInter.java index 7a37d41..b9a74b4 100644 --- a/src/com/customization/sskj/GetTabsCmdInter.java +++ b/src/com/customization/sskj/GetTabsCmdInter.java @@ -41,6 +41,10 @@ public class GetTabsCmdInter extends AbstractCommandProxy> { temp.put("key","3"); temp.put("title", SystemEnv.getHtmlLabelName(10000,user.getLanguage())); tabs.add(temp); + temp = new HashMap<>(); + temp.put("key","4"); + temp.put("title", SystemEnv.getHtmlLabelName(10003,user.getLanguage())); + tabs.add(temp); } } } diff --git a/src/com/engine/kq/biz/KQAttFlowSetBiz.java b/src/com/engine/kq/biz/KQAttFlowSetBiz.java index 9c551a7..418761b 100644 --- a/src/com/engine/kq/biz/KQAttFlowSetBiz.java +++ b/src/com/engine/kq/biz/KQAttFlowSetBiz.java @@ -626,6 +626,34 @@ public class KQAttFlowSetBiz { bb.writeLog("-buildFlowSetTableString orderby: " + orderby); /*考勤二开--转事假end*/ + /*考勤二开--异常考勤转事假start*/ + + if ( ("leaveType_"+calLeaveId).equals(type) && "4".equals(tabkey)) { + backfields = " a.resourceid, a.duration, a.belongdate, b.lastname, b.departmentId "; + fromSql = " from uf_AbnAttToComLeave a " + + " left join hrmresource b " + + " on b.id = a.resourceid "; + sqlWhere = " where a.resourceid = " + resourceId + " and a.belongdate >='" + fromDate + "' and a.belongdate <='" + toDate + "' "; + + tableString =" "+ + " "+ + " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString += " "; + tableString +=" "+ + "
"; + + } + bb.writeLog("-buildFlowSetTableString backfields: " + backfields); + bb.writeLog("-buildFlowSetTableString fromSql: " + fromSql); + bb.writeLog("-buildFlowSetTableString sqlwhere: " + sqlWhere); + bb.writeLog("-buildFlowSetTableString orderby: " + orderby); + /*考勤二开--异常考勤转事假end*/ + + String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); Util_TableMap.setVal(sessionkey, tableString); return sessionkey; diff --git a/src/com/engine/kq/biz/KQFormatData.java b/src/com/engine/kq/biz/KQFormatData.java index 9bfae8a..c9b60cf 100644 --- a/src/com/engine/kq/biz/KQFormatData.java +++ b/src/com/engine/kq/biz/KQFormatData.java @@ -2,12 +2,14 @@ package com.engine.kq.biz; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.engine.kq.biz.chain.cominfo.ShiftInfoCominfoBean; import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean; import com.engine.kq.entity.KQShiftRuleEntity; import com.engine.kq.entity.TimeScopeEntity; import com.engine.kq.entity.WorkTimeEntity; import com.engine.kq.enums.FlowReportTypeEnum; import com.engine.kq.log.KQLog; +import com.engine.sskj.util.SskjUtil; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.googlecode.aviator.AviatorEvaluator; @@ -20,7 +22,11 @@ import weaver.general.BaseBean; import weaver.general.InitServer; import weaver.general.Util; import weaver.interfaces.sskj.comInfo.PropBean; +import weaver.soa.workflow.request.RequestInfo; +import weaver.soa.workflow.request.RequestService; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.time.LocalDate; import java.time.LocalTime; import java.time.format.DateTimeFormatter; @@ -39,6 +45,8 @@ public class KQFormatData extends BaseBean { private boolean writeLog = false; private LinkedHashMap logInfo = new LinkedHashMap<>(); + SskjUtil ssutil = new SskjUtil(); + /*** * 该方法不允许直接调用 * @param userId @@ -183,6 +191,7 @@ public class KQFormatData extends BaseBean { List> lsParam = new ArrayList<>(); List params = null; try { + KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo(); KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); String nosign_is_absent = Util.null2String(kqSettingsComInfo.getMain_val("nosign_is_absent"),"1"); KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); @@ -634,6 +643,7 @@ public class KQFormatData extends BaseBean { } } + List> restList = new ArrayList<>(); if(lsRestTime != null && !lsRestTime.isEmpty()){ for(int k = 0 ; k < lsRestTime.size(); k++){ TimeScopeEntity restTimeScope = lsRestTime.get(k); @@ -643,6 +653,10 @@ public class KQFormatData extends BaseBean { beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(restBeginTime); endIdx = kqTimesArrayComInfo.getArrayindexByTimes(restEndTime); if (endIdx > beginIdx) { + Map temp = new HashMap<>(); + temp.put("start",beginIdx); + temp.put("end",endIdx); + restList.add(temp); Arrays.fill(dayMins, beginIdx, endIdx, -11);//休息时间 } } @@ -883,6 +897,58 @@ public class KQFormatData extends BaseBean { } } + /*考勤二开--阶梯式记旷工start*/ + //迟到、早退(注意严重迟到、严重早退的情况) belateMins--迟到 graveBeLateMins--严重迟到 leaveEarlyMins--早退 graveLeaveEarlyMins--严重早退 + String changeBeforeData = "beLateMins:" + beLateMins + "graveBeLateMins:" + graveBeLateMins + "leaveEarlyMins:" + leaveEarlyMins + "graveLeaveEarlyMins:" + graveLeaveEarlyMins; + int abnormalMins = beLateMins + graveBeLateMins + leaveEarlyMins + graveLeaveEarlyMins; + if ( abnormalMins > 0 && abnormalMins <= 30 ) { + beLateMins = 0; + graveBeLateMins = 0; + leaveEarlyMins = 0; + graveLeaveEarlyMins = 0; + } + if ( abnormalMins > 30 && abnormalMins <= 120) { + absenteeismMins = 0; + beLateMins = 0; + graveBeLateMins = 0; + leaveEarlyMins = 0; + graveLeaveEarlyMins = 0; + leaveMins = 240; + //转事假 + SskjUtil sskjUtil = new SskjUtil(); + RecordSet rs = new RecordSet(); + String toCusLeaveSql = "insert into uf_AbnAttToComLeave (resourceid, belongdate, duration, formmodeid, modedatacreater, modedatacreatertype, modedatacreatedate, modedatacreatetime, MODEUUID) values (?,?,?,?,?,?,?,?,?)"; + String abnAttToComLeaveModeId = bb.getPropValue("project_sskj", "abnAttToComLeaveModeId"); + Integer modedatacreater = 1; + Integer modedatacreatertype = 0; + String modedatacreatedate = cn.hutool.core.date.DateUtil.format(new Date(), "yyyy-MM-dd"); + String modedatacreatetime = cn.hutool.core.date.DateUtil.format(new Date(), "HH:mm:ss"); + String abnUuid = UUID.randomUUID().toString(); + bb.writeLog("toCusLeaveSql:" + toCusLeaveSql); + + boolean addFlag = rs.executeUpdate(toCusLeaveSql, userId, kqDate, leaveMins, abnAttToComLeaveModeId, modedatacreater, modedatacreatertype, modedatacreatedate, + modedatacreatetime, abnUuid); + bb.writeLog("addFlag:" + addFlag); + if (addFlag) { + String billid = "-1"; + String acqModeIdSql = "select id from uf_AbnAttToComLeave where MODEUUID = ?"; + rs.executeQuery(acqModeIdSql, abnUuid); + while (rs.next()) { + billid = Util.null2String(rs.getString("id")); + } + bb.writeLog("billid:" + billid); + sskjUtil.modePerRecon(modedatacreater, abnAttToComLeaveModeId, billid); + } + } + if ( abnormalMins > 120) { + absenteeismMins = 240; + } + //计算实际出勤时间(出差公出算出勤)=应出勤-旷工-请假-迟到-早退 + attendanceMins = workMins - absenteeismMins-leaveMins-beLateMins-graveBeLateMins-leaveEarlyMins-graveLeaveEarlyMins; +// ssutil.customLog(); + /*考勤二开--阶梯式记旷工end*/ + + // //计算实际出勤时间(出差公出算出勤)=应出勤-旷工-请假-迟到-早退 // attendanceMins = workMins - absenteeismMins-leaveMins-beLateMins-graveBeLateMins-leaveEarlyMins-graveLeaveEarlyMins; // // 如果没有开启"漏签是否算实际出勤"开关,则漏签不算实际出勤时长 @@ -898,6 +964,9 @@ public class KQFormatData extends BaseBean { // } //end + + + kqLog.info("实际出勤计算公式" + "实际出勤=应出勤- 旷工-请假-迟到-早退 userId" + userId + "kqDate==" + kqDate+":hostIps:"+hostIps+":uuid::"+uuid); kqLog.info("实际出勤计算结果" + attendanceMins + "=" + workMins + "- " + absenteeismMins + "-" + leaveMins + "-" + (beLateMins + graveBeLateMins) + "-" + (leaveEarlyMins - graveLeaveEarlyMins)+" userId" + userId + "kqDate==" + kqDate+":hostIps:"+hostIps+":uuid::"+uuid); if(this.writeLog) { diff --git a/src/com/engine/kq/biz/KQReportBiz.java b/src/com/engine/kq/biz/KQReportBiz.java index 6dab8c6..72dc7c9 100644 --- a/src/com/engine/kq/biz/KQReportBiz.java +++ b/src/com/engine/kq/biz/KQReportBiz.java @@ -14,6 +14,7 @@ import weaver.general.BaseBean; import weaver.general.TimeUtil; import weaver.general.Util; import weaver.hrm.User; +import weaver.interfaces.sskj.comInfo.PropBean; import weaver.systeminfo.SystemEnv; import java.text.DecimalFormat; @@ -382,6 +383,10 @@ public class KQReportBiz extends BaseBean { basebean.writeLog("getDailyFlowData toComLeave"); datas.putAll(getDailyToComLeaveData(params,user)); + //考勤二开--异常考勤转事假 + basebean.writeLog("getDailyFlowData abnAttToComLeave"); + datas.putAll(getDailyAbnAttToComLeaveData(params,user)); + }catch (Exception e){ writeLog(e); @@ -414,9 +419,249 @@ public class KQReportBiz extends BaseBean { basebean.writeLog("getFlowData getToComLeaveData"); datas.putAll(getToComLeaveData(params,user)); + //考勤二开--统计公休时长 + basebean.writeLog("getFlowData getHoliDurationData"); + datas.putAll(getHoliDurationData(params,user)); + + //考勤二开--统计劳务工时 + basebean.writeLog("getFlowData getLaborHoursData"); + datas.putAll(getLaborHoursData(params,user)); + + //考勤二开--异常考勤转事假 + basebean.writeLog("getFlowData getAbnAttToComLeaveData"); + datas.putAll(getAbnAttToComLeaveData(params,user)); + + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + public Map getLaborHoursData(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 b.subcompanyid1 in(" + subCompanyId + ") "; + } + + if (departmentId.length() > 0) { + sqlWhere += " and b.departmentid in(" + departmentId + ") "; + } + + if (resourceId.length() > 0) { + sqlWhere += " and b.id in(" + resourceId + ") "; + } + + if (viewScope.equals("4")) {//我的下属 + if (allLevel.equals("1")) {//所有下属 + sqlWhere += " and b.managerstr like '%," + user.getUID() + ",%'"; + } else { + sqlWhere += " and b.managerid=" + user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and b.loginid is not null " + (rs.getDBType().equals("oracle") ? "" : " and b.loginid<>'' "); + } + + //获取劳务工人员 + List empTypes = new ArrayList<>(); + String empType = Util.null2String(PropBean.getUfPropValue("empType"),"field9"); + basebean.writeLog("empType: " + empType); + + String acqLaSql = "select id from cus_fielddata where scopeid = -1 and scope = 'HrmCustomFieldByInfoType' and " + empType + " = 0"; + basebean.writeLog("acqLaSql: " + acqLaSql); + + rs.executeQuery(acqLaSql); + while (rs.next()) { + String id = Util.null2String(rs.getString("id")); + if (StringUtils.isNotBlank(id) ) { + empTypes.add(id); + } + } + + //获取出勤时长 + KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz(); + sql = "select a.attendancemins, a.resourceid, a.kqdate from kq_format_total a left join hrmresource b on a.resourceid = b.id " + + " where a.resourceid in (" + String.join(",", empTypes) + ") and kqdate >='" + fromDate + "' and kqdate <='" + toDate + "' " + sqlWhere; + basebean.writeLog("sql: " + sql); + + rs.executeQuery(sql); + while (rs.next()) { + String resourceid = Util.null2String(rs.getString("resourceid")); + String kqdate = Util.null2String(rs.getString("kqdate")); + double attendancemins = Util.getDoubleValue(Util.null2String(rs.getString("attendancemins"))); + + if (attendancemins >= 0.00) { + int changeType = kqOvertimeRulesBiz.getChangeType(resourceid, kqdate); + //节假日 + if (changeType == 1 ) { + double temp = Util.getDoubleValue(Util.null2String(datas.get("LaborHoursData|" + resourceid + "|holiday"))); + if (temp >=0.00) { + double attendanceHours = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(String.valueOf(attendancemins / 60.0))) + temp; + datas.put("LaborHoursData|" + resourceid + "|holiday" , attendanceHours); + } else { + double attendanceHours = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(String.valueOf(attendancemins / 60.0))); + datas.put("LaborHoursData|" + resourceid + "|holiday" , attendanceHours); + } + } + + //工作日 + if (changeType == 2 ) { + double temp = Util.getDoubleValue(Util.null2String(datas.get("LaborHoursData|" + resourceid + "|workday"))); + if (temp >=0.00) { + double attendanceHours = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(String.valueOf(attendancemins / 60.0))) + temp; + datas.put("LaborHoursData|" + resourceid + "|workday" , attendanceHours); + } else { + double attendanceHours = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(String.valueOf(attendancemins / 60.0))); + datas.put("LaborHoursData|" + resourceid + "|workday" , attendanceHours); + } + } + + //休息日 + if (changeType == 3 ) { + double temp = Util.getDoubleValue(Util.null2String(datas.get("LaborHoursData|" + resourceid + "|restday"))); + if (temp >=0.00) { + double attendanceHours = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(String.valueOf(attendancemins / 60.0))) + temp; + datas.put("LaborHoursData|" + resourceid + "|restday" , attendanceHours); + } else { + double attendanceHours = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(String.valueOf(attendancemins / 60.0))); + datas.put("LaborHoursData|" + resourceid + "|restday" , attendanceHours); + } + } + + } + } + + //获取加班时长 + Map overTimeDataNew = this.getFlowOverTimeDataNew(params, user); + for (Entry entry : overTimeDataNew.entrySet()) { + String key = entry.getKey(); + double value = Util.getDoubleValue(Util.null2String(entry.getValue()), 0.00); + String[] split = key.split("\\|"); + if (split[1].contains("holiday")) { + double doubleValue = Util.getDoubleValue(Util.null2String(datas.get("LaborHoursData|" + split[0] + "|holiday")), 0.00); + datas.put("LaborHoursData|" + split[0] + "|holiday" , doubleValue + value); + } + + if (split[1].contains("workingDay")) { + double doubleValue = Util.getDoubleValue(Util.null2String(datas.get("LaborHoursData|" + split[0] + "|workday")), 0.00); + datas.put("LaborHoursData|" + split[0] + "|workday" , doubleValue + value); + } + + if (split[1].contains("restDay")) { + double doubleValue = Util.getDoubleValue(Util.null2String(datas.get("LaborHoursData|" + split[0] + "|restday")), 0.00); + datas.put("LaborHoursData|" + split[0] + "|restday" , doubleValue + value); + } + + } + + + }catch (Exception e){ + writeLog(e); + basebean.writeLog("getLaborHoursData Exception:" + e); + } + basebean.writeLog("getLaborHoursData datas:" + datas); + return datas; + } + + public Map getHoliDurationData(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 b.subcompanyid1 in(" + subCompanyId + ") "; + } + + if (departmentId.length() > 0) { + sqlWhere += " and b.departmentid in(" + departmentId + ") "; + } + + if (resourceId.length() > 0) { + sqlWhere += " and a.resourceid in(" + resourceId + ") "; + } + + if (viewScope.equals("4")) {//我的下属 + if (allLevel.equals("1")) {//所有下属 + sqlWhere += " and b.managerstr like '%," + user.getUID() + ",%'"; + } else { + sqlWhere += " and b.managerid=" + user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and b.loginid is not null " + (rs.getDBType().equals("oracle") ? "" : " and b.loginid<>'' "); + } + + /*考勤二开--公休时长统计start*/ + String offdutyId = Util.null2String(PropBean.getUfPropValue("shift.offduty.id"),"7"); + basebean.writeLog("offdutyId: " + offdutyId); + /*考勤二开--公休时长统计end*/ + + sql = " select a.resourceid, count(*) as number from kq_format_total a left join hrmresource b on b.id = a. resourceid" + + " where a.serialid = " + offdutyId + " " + sqlWhere; + basebean.writeLog("getHoliDurationData sql: " + sql); + + rs.executeQuery(sql); + while (rs.next()) { + int number = Util.getIntValue(Util.null2String(rs.getString("number"))); + String resourceid = Util.null2String(rs.getString("resourceid")); + datas.put("HoliDurationData|" + resourceid, number); + } + + }catch (Exception e){ writeLog(e); + basebean.writeLog("getHoliDurationData Exception:" + e); } + basebean.writeLog("getHoliDurationData datas:" + datas); return datas; } @@ -479,11 +724,11 @@ public class KQReportBiz extends BaseBean { while (rs.next()) { double duration = Util.getDoubleValue(Util.null2String(rs.getString("duration"))); if ( duration > 0.00){ - double temp = Util.getDoubleValue(Util.null2String(datas.get("ToComLeaveData|" + resourceId))); + double temp = Util.getDoubleValue(Util.null2String(datas.get("-ToComLeaveData|" + resourceId))); if (temp <= 0.00) { - datas.put("ToComLeaveData|" + resourceId, duration); + datas.put("-ToComLeaveData|" + resourceId, duration); } else { - datas.put("ToComLeaveData|" + resourceId, temp + duration); + datas.put("-ToComLeaveData|" + resourceId, temp + duration); } } } @@ -496,6 +741,168 @@ public class KQReportBiz extends BaseBean { return datas; } + /** + * 异常考勤转事假--汇总表 + * @param params + * @param user + * @return + */ + public Map getAbnAttToComLeaveData(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 c.subcompanyid1 in(" + subCompanyId + ") "; + } + + if (departmentId.length() > 0) { + sqlWhere += " and c.departmentid in(" + departmentId + ") "; + } + + if (resourceId.length() > 0) { + sqlWhere += " and c.resourceid in(" + resourceId + ") "; + } + + if (viewScope.equals("4")) {//我的下属 + if (allLevel.equals("1")) {//所有下属 + sqlWhere += " and c.managerstr like '%," + user.getUID() + ",%'"; + } else { + sqlWhere += " and c.managerid=" + user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and c.loginid is not null " + (rs.getDBType().equals("oracle") ? "" : " and c.loginid<>'' "); + } + + sql = sql = " select * from (select a.resourceId, a.duration, a.belongDate, b.subcompanyid1, b.departmentid, b.managerstr, b.managerid, b.loginid " + + " from uf_AbnAttToComLeave a left join hrmresource b on b.id = a.resourceid " + + " where a.belongdate >='" + fromDate + "' and a.belongdate <='" + toDate + "' ) c where 1=1 " + sqlWhere; + basebean.writeLog("getAbnAttToComLeaveData sql: " + sql); + + rs.executeQuery(sql); + while (rs.next()) { + double duration = Util.getDoubleValue(Util.null2String(rs.getString("duration"))); + String resId = Util.null2String(rs.getString("resourceId")); + if ( duration > 0.00){ + double temp = Util.getDoubleValue(Util.null2String(datas.get("-AbnAttToComLeaveData|" + resId ))); + if (temp <= 0.00) { + datas.put("-AbnAttToComLeaveData|" + resId , duration); + } else { + datas.put("-AbnAttToComLeaveData|" + resId , temp + duration); + } + } + } + + + }catch (Exception e){ + writeLog(e); + } + basebean.writeLog("getAbnAttToComLeaveData datas:" + datas); + return datas; + } + + public Map getDailyAbnAttToComLeaveData(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 c.subcompanyid1 in(" + subCompanyId + ") "; + } + + if (departmentId.length() > 0) { + sqlWhere += " and c.departmentid in(" + departmentId + ") "; + } + + if (resourceId.length() > 0) { + sqlWhere += " and c.resourceId in(" + resourceId + ") "; + } + + if (viewScope.equals("4")) {//我的下属 + if (allLevel.equals("1")) {//所有下属 + sqlWhere += " and c.managerstr like '%," + user.getUID() + ",%'"; + } else { + sqlWhere += " and c.managerid=" + user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and c.loginid is not null " + (rs.getDBType().equals("oracle") ? "" : " and c.loginid<>'' "); + } + + sql = " select * from (select a.resourceId, a.duration, a.belongDate, b.subcompanyid1, b.departmentid, b.managerstr, b.managerid, b.loginid " + + " from uf_AbnAttToComLeave a left join hrmresource b on b.id = a.resourceid " + + " where a.belongdate >='" + fromDate + "' and a.belongdate <='" + toDate + "' ) c where 1=1 " + sqlWhere; + basebean.writeLog("getDailyAbnAttToComLeaveData sql: " + sql); + + rs.executeQuery(sql); + while (rs.next()) { + double duration = Util.getDoubleValue(Util.null2String(rs.getString("duration"))); + String kqdate = Util.null2String(rs.getString("belongDate")); + String resId = Util.null2String(rs.getString("resourceId")); + if ( duration > 0.00){ + double temp = Util.getDoubleValue(Util.null2String(datas.get("DailyAbnAttToComLeaveData|" + resId + "|" + kqdate))); + if (temp <= 0.00) { + datas.put("DailyAbnAttToComLeaveData|" + resId + "|" + kqdate, duration); + } else { + datas.put("DailyAbnAttToComLeaveData|" + resId + "|" + kqdate, temp + duration); + } + } + } + + + }catch (Exception e){ + writeLog(e); + } + basebean.writeLog("getDailyAbnAttToComLeaveData datas:" + datas); + return datas; + } public Map getDailyToComLeaveData(Map params, User user){ Map datas = new HashMap<>(); @@ -548,8 +955,8 @@ public class KQReportBiz extends BaseBean { sqlWhere += " and c.loginid is not null " + (rs.getDBType().equals("oracle") ? "" : " and c.loginid<>'' "); } - sql = " select * from (select * from uf_casleave a left join hrmresource on a.resourceid = b.id " + - " where a.startdate >='" + fromDate + "' and a.enddate <='" + toDate +"' and (isdecu = 0 or isdecu is null ) ) c where 1=1 " + sqlWhere; + sql = " select * from (select * from uf_casleave a left join hrmresource b on a.resourceid = b.id " + + " where a.startdate >='" + fromDate + "' and a.enddate <='" + toDate +"' and ( a.isdecu = 0 or a.isdecu is null ) ) c where 1=1 " + sqlWhere; basebean.writeLog("getDailyToComLeaveData sql: " + sql); rs.executeQuery(sql); diff --git a/src/com/engine/kq/cmd/balanceofleavedetail/GetSearchListCmd.java b/src/com/engine/kq/cmd/balanceofleavedetail/GetSearchListCmd.java new file mode 100644 index 0000000..c4f0fc5 --- /dev/null +++ b/src/com/engine/kq/cmd/balanceofleavedetail/GetSearchListCmd.java @@ -0,0 +1,128 @@ +package com.engine.kq.cmd.balanceofleavedetail; + +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQLeaveRulesBiz; +import com.engine.kq.biz.KQLeaveRulesComInfo; +import weaver.general.PageIdConst; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.Map; + +/** + * 加班生成调休的明细 + */ +public class GetSearchListCmd extends AbstractCommonCommand> { + + public GetSearchListCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + try { + /*人员ID*/ + String resourceId = Util.null2String(params.get("resourceId")); + /*搜索条件中的年份*/ + String searchYearSelect = Util.null2String(params.get("searchYearSelect"));//日期控件的选择值 + String searchYear = Util.null2String(params.get("searchYear"));//年份 + if (searchYearSelect.equals("5") || searchYearSelect.equals("8")) { + searchYear = TimeUtil.getDateByOption(searchYearSelect, "0").substring(0, 4); + } + //假期类型的ID + String leaveRulesId = Util.null2String(params.get("ruleId")); + + if (resourceId.equals("") || searchYear.equals("") || leaveRulesId.equals("")) { + resultMap.put("status", "-1"); + resultMap.put("message", SystemEnv.getHtmlLabelName(388858, user.getLanguage()));//参数有误 + return resultMap; + } + boolean isTiaoXiu = KQLeaveRulesBiz.isTiaoXiu(leaveRulesId); + + KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo(); + //调休的单位 + String unitName = rulesComInfo.getUnitName(leaveRulesId, user.getLanguage()); + + /**********************************************************************************************************/ + + boolean canEdit = HrmUserVarify.checkUserRight("KQLeaveRulesEdit:Edit", user);//是否具有编辑权限 + boolean canDelete = HrmUserVarify.checkUserRight("KQLeaveRulesDelete:Delete", user);//是否具有删除权限 + boolean canLog = HrmUserVarify.checkUserRight("KQLeaveRules:Log", user);//是否具有查看日志的权限 + + /**********************************************************************************************************/ + + String backFields = " b.id,a.lastName,b.belongYear,b.belongMonth,b.overtimeType,b.baseAmount,b.extraAmount,b.usedAmount,0 as invalidAmount,0 as restAmount,b.effectiveDate,b.expirationDate,b.tiaoxiuamount,CASE " + + " WHEN c.changetype = 1 THEN '节假日' " + + " WHEN c.changetype = 2 THEN '工作日' " + + " WHEN c.changetype = 3 THEN '休息日' " + + " ELSE '未知' END as changetype "; + String sqlFrom = " from HrmResource a,KQ_BalanceOfLeave b, kq_flow_overtime c "; + String sqlWhere = " where 1=1 and a.id=b.resourceId and (isDelete is null or isDelete<>1) "; + String orderBy = " b.belongYear asc,b.expirationDate asc,b.id asc "; + + if (!resourceId.equals("")) { + sqlWhere += " and a.id in (" + resourceId + ")"; + } + if (!searchYear.equals("")) { + sqlWhere += " and b.belongYear='" + searchYear + "' "; + } + if (!leaveRulesId.equals("")) { + sqlWhere += " and b.leaveRulesId=" + leaveRulesId; + } + + String pageUid = "b29847fa-6877-f7bd-f12b-5d3a35183b25"; + String operateString = ""; + operateString = ""; + operateString += " "; + operateString += " "; + operateString += " "; + operateString += " "; + operateString += ""; + String tiaoxiuColString = ""; + if(isTiaoXiu){ + tiaoxiuColString =" "; + tiaoxiuColString = tiaoxiuColString + " "; + } + String tableString = "" + + "" + + "" + + operateString + + " " + + " " + + " " + + " " + + //" " + + " " + + " " + + " " + + tiaoxiuColString+ + " " + + " " + + " " + + " " + + "
"; + String sessionKey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + Util_TableMap.setVal(sessionKey, tableString); + resultMap.put("sessionkey", sessionKey); + } catch (Exception e) { + writeLog(e); + resultMap.put("status", "-1"); + resultMap.put("message", e.getMessage()); + } + return resultMap; + } +} diff --git a/src/com/engine/kq/cmd/report/ExportDailyExcelCmd.java b/src/com/engine/kq/cmd/report/ExportDailyExcelCmd.java index bb7d9d3..d7d33d6 100644 --- a/src/com/engine/kq/cmd/report/ExportDailyExcelCmd.java +++ b/src/com/engine/kq/cmd/report/ExportDailyExcelCmd.java @@ -5,10 +5,11 @@ import com.alibaba.fastjson.JSONObject; import com.engine.common.biz.AbstractCommonCommand; import com.engine.common.entity.BizLogContext; import com.engine.core.interceptor.CommandContext; -import com.engine.kq.biz.KQReportBiz; +import com.engine.kq.biz.*; import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit; import com.engine.kq.util.ExcelUtil; import com.engine.kq.util.KQDurationCalculatorUtil; +import org.apache.commons.lang3.StringUtils; import weaver.common.DateUtil; import weaver.conn.RecordSet; import weaver.general.BaseBean; @@ -19,6 +20,7 @@ import weaver.hrm.company.DepartmentComInfo; import weaver.hrm.company.SubCompanyComInfo; import weaver.hrm.job.JobTitlesComInfo; import weaver.hrm.resource.ResourceComInfo; +import weaver.interfaces.sskj.comInfo.PropBean; import weaver.systeminfo.SystemEnv; import javax.servlet.http.HttpServletRequest; @@ -122,6 +124,7 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand0){//结束如期不大于今天 @@ -262,6 +265,25 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand empTypes = new HashMap<>(); + String empType = Util.null2String(PropBean.getUfPropValue("empType"),"field9"); + String acqLaSql = "select id, " + empType + " from cus_fielddata where scopeid = -1 and scope = 'HrmCustomFieldByInfoType'"; + rs.executeQuery(acqLaSql); + while (rs.next()) { + String id = Util.null2String(rs.getString("id")); + String empTypeValue = Util.null2String(rs.getString(empType)); + if (StringUtils.isNotBlank(id) && StringUtils.isNotBlank(empTypeValue)) { + empTypes.put(id, empTypeValue); + } + } + /*考勤二开--劳务工时end*/ + rs.execute(sql); while (rs.next()) { data = new ArrayList<>(); @@ -278,6 +300,7 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand= 0.00) { - flowLeaveData = flowLeaveData + temp; + temp = Double.parseDouble(KQDurationCalculatorUtil.getDurationRound(String.valueOf(temp / 60.0))); + double doubleValue = Util.getDoubleValue(Util.null2String(flowLeaveData)); + flowLeaveData = String.valueOf(doubleValue > 0.00? doubleValue : 0.00 + temp); } bb.writeLog("flowLeaveData: " + flowLeaveData); } /*考勤二开--转事假end*/ + /*考勤二开--异常考勤转事假start*/ + if ( flowType.equals( ("leaveType_" + calLeaveId) ) ) { + bb.writeLog("-flowLeaveData: " + flowLeaveData); + double temp = Util.getDoubleValue(Util.null2String(flowData.get("DailyAbnAttToComLeaveData|" + id + "|" + kqdate))); + bb.writeLog("-temp: " + temp); + if (temp >= 0.00) { + temp = Double.parseDouble(KQDurationCalculatorUtil.getDurationRound(String.valueOf(temp / 60.0))); + double doubleValue = Util.getDoubleValue(Util.null2String(flowLeaveData)); + flowLeaveData = String.valueOf(doubleValue > 0.00? doubleValue : 0.00 + temp); + } + bb.writeLog("-flowLeaveData: " + flowLeaveData); + } + /*考勤二开--异常考勤转事假end*/ fieldValue = flowLeaveData; @@ -489,7 +527,66 @@ public class ExportDailyExcelCmd extends AbstractCommonCommand> { data.add(flowLeaveData); } continue; - }else if(fieldName.equals("overtime")){ + } else if("holiDuration".equals(fieldName)){ + int intValue = Util.getIntValue(Util.null2String(flowData.get("HoliDurationData|" + id))); + if (intValue >= 0) { + data.add(intValue); + } else { + data.add("0"); + } + continue; + }else if ("laborHours".equals(fieldName) ) { + + double holidayValue = Util.getDoubleValue(Util.null2String(flowData.get("LaborHoursData|" + id + "|holiday")), 0.00); + double workdayValue = Util.getDoubleValue(Util.null2String(flowData.get("LaborHoursData|" + id + "|workday")), 0.00); + double restdayValue = Util.getDoubleValue(Util.null2String(flowData.get("LaborHoursData|" + id + "|restday")), 0.00); + + double total = holidayValue + workdayValue + restdayValue; + + fieldValue = String.valueOf(total); + data.add(holidayValue); + data.add(workdayValue); + data.add(restdayValue); + data.add(fieldValue); + + continue; + } else if(fieldName.equals("overtime")){ fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|workingDayOvertime_nonleave"))); data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("workingDayOvertime_nonleave")))); diff --git a/src/com/engine/kq/cmd/report/GetKQDailyReportCmd.java b/src/com/engine/kq/cmd/report/GetKQDailyReportCmd.java index 6014f23..1412235 100644 --- a/src/com/engine/kq/cmd/report/GetKQDailyReportCmd.java +++ b/src/com/engine/kq/cmd/report/GetKQDailyReportCmd.java @@ -6,12 +6,13 @@ import com.alibaba.fastjson.JSONObject; import com.engine.common.biz.AbstractCommonCommand; import com.engine.common.entity.BizLogContext; import com.engine.core.interceptor.CommandContext; -import com.engine.kq.biz.KQReportBiz; +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.util.KQDurationCalculatorUtil; import com.engine.kq.util.PageUidFactory; +import org.apache.commons.lang3.StringUtils; import weaver.conn.RecordSet; import weaver.general.BaseBean; import weaver.general.TimeUtil; @@ -21,6 +22,7 @@ import weaver.hrm.company.DepartmentComInfo; import weaver.hrm.company.SubCompanyComInfo; import weaver.hrm.job.JobTitlesComInfo; import weaver.hrm.resource.ResourceComInfo; +import weaver.interfaces.sskj.comInfo.PropBean; import weaver.systeminfo.SystemEnv; import java.math.BigDecimal; @@ -237,6 +239,25 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand empTypes = new HashMap<>(); + String empType = Util.null2String(PropBean.getUfPropValue("empType"),"field9"); + String acqLaSql = "select id, " + empType + " from cus_fielddata where scopeid = -1 and scope = 'HrmCustomFieldByInfoType'"; + rs.executeQuery(acqLaSql); + while (rs.next()) { + String id = Util.null2String(rs.getString("id")); + String empTypeValue = Util.null2String(rs.getString(empType)); + if (StringUtils.isNotBlank(id) && StringUtils.isNotBlank(empTypeValue)) { + empTypes.put(id, empTypeValue); + } + } + /*考勤二开--劳务工时end*/ + // #1475814-概述:满足考勤报分部部门显示及导出时显示全路径 String fullPathMainKey = "show_full_path"; KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); @@ -252,10 +273,12 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand(); kqReportFieldComInfo.setTofirstRow(); while (kqReportFieldComInfo.next()) { + if (!Util.null2String(kqReportFieldComInfo.getIsdataColumn()).equals("1")) continue; if (!kqReportFieldComInfo.getReportType().equals("all") && !kqReportFieldComInfo.getReportType().equals("daily")) continue; String fieldName = kqReportFieldComInfo.getFieldname(); + String fieldValue = ""; if (fieldName.equals("subcompany")) { String fieldValueID = rs.getString("subcompanyid"); @@ -356,6 +379,56 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand 0) { @@ -406,14 +479,29 @@ public class GetKQDailyReportCmd extends AbstractCommonCommand= 0.00) { - flowLeaveData = flowLeaveData + temp; + temp = Double.parseDouble(KQDurationCalculatorUtil.getDurationRound(String.valueOf(temp / 60.0))); + double doubleValue = Util.getDoubleValue(Util.null2String(flowLeaveData)); + flowLeaveData = String.valueOf(doubleValue > 0.00? doubleValue : 0.00 + temp); } bb.writeLog("flowLeaveData: " + flowLeaveData); } /*考勤二开--转事假end*/ + /*考勤二开--异常考勤转事假start*/ + if ( flowType.equals( ("leaveType_" + calLeaveId) ) ) { + bb.writeLog("-flowLeaveData: " + flowLeaveData); + double temp = Util.getDoubleValue(Util.null2String(flowData.get("DailyAbnAttToComLeaveData|" + id + "|" + kqdate))); + bb.writeLog("-temp: " + temp); + if (temp >= 0.00) { + temp = Double.parseDouble(KQDurationCalculatorUtil.getDurationRound(String.valueOf(temp / 60.0))); + double doubleValue = Util.getDoubleValue(Util.null2String(flowLeaveData)); + flowLeaveData = String.valueOf(doubleValue > 0.00? doubleValue : 0.00 + temp); + } + bb.writeLog("-flowLeaveData: " + flowLeaveData); + } + /*考勤二开--异常考勤转事假end*/ data.put(flowType, flowLeaveData); } diff --git a/src/com/engine/kq/cmd/report/GetKQReportCmd.java b/src/com/engine/kq/cmd/report/GetKQReportCmd.java index 2108b65..86ad81b 100644 --- a/src/com/engine/kq/cmd/report/GetKQReportCmd.java +++ b/src/com/engine/kq/cmd/report/GetKQReportCmd.java @@ -5,7 +5,7 @@ import com.alibaba.fastjson.JSONObject; import com.engine.common.biz.AbstractCommonCommand; import com.engine.common.entity.BizLogContext; import com.engine.core.interceptor.CommandContext; -import com.engine.kq.biz.KQReportBiz; +import com.engine.kq.biz.*; import com.engine.kq.util.KQDurationCalculatorUtil; import com.engine.kq.util.PageUidFactory; import weaver.common.DateUtil; @@ -194,7 +194,7 @@ public class GetKQReportCmd extends AbstractCommonCommand> { " sum(b.absenteeismMins) as absenteeismMins, sum(b.forgotCheck)+"+forgotBeginWorkCheck_field+" as forgotCheck "+(definedFieldSum.length()>0?","+definedFieldSum+"":""); if(rs.getDBType().equals("oracle")){ - backFields = "/*+ index(kq_format_total IDX_KQ_FORMAT_TOTAL_KQDATE) */ "+backFields; + backFields = "/*+ index(kq_format_total IDX_KQ_FORMAT_TOTAL_KQDATE) */ "+backFields; } String sqlFrom = " from hrmresource a, kq_format_total b where a.id= b.resourceid and b.kqdate >='"+fromDate+"' and b.kqdate <='"+toDate+"'"; String sqlWhere = rightSql; @@ -289,12 +289,10 @@ public class GetKQReportCmd extends AbstractCommonCommand> { } else if (rs.getDBType().equals("mysql")) { sql = " select * from (select " + sql+") t "+orderBy; sql = "select t1.* from (" + sql + ") t1 limit " + ((pageIndex - 1) * pageSize) + "," + pageSize; - } - else if (rs.getDBType().equals("postgresql")) { + } else if (rs.getDBType().equals("postgresql")) { sql = " select * from (select " + sql+") t "+orderBy; sql = "select t1.* from (" + sql + ") t1 limit " +pageSize + " offset " + ((pageIndex - 1) * pageSize); - } - else { + } else { orderBy = " order by dsporder asc, lastname asc "; descOrderBy = " order by dsporder desc, lastname desc "; if (pageIndex > 1) { @@ -384,7 +382,7 @@ public class GetKQReportCmd extends AbstractCommonCommand> { for(int i=0;serialIds!=null&&i> { }else{ fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id+"|"+fieldName))); } + }else if("holiDuration".equals(fieldName)){ + int intValue = Util.getIntValue(Util.null2String(flowData.get("HoliDurationData|" + id))); + if (intValue >= 0) { + data.put(fieldName,intValue); + } else { + data.put(fieldName,"0"); + } + } else if ("laborHours".equals(kqReportFieldComInfo.getParentid()) ) { + + if ("laborHoursTotal".equals(fieldName)) { +// + double holidayValue = Util.getDoubleValue(Util.null2String(flowData.get("LaborHoursData|" + id + "|holiday")), 0.00); + double workdayValue = Util.getDoubleValue(Util.null2String(flowData.get("LaborHoursData|" + id + "|workday")), 0.00); + double restdayValue = Util.getDoubleValue(Util.null2String(flowData.get("LaborHoursData|" + id + "|restday")), 0.00); +// + double total = holidayValue + workdayValue + restdayValue; + bb.writeLog("--total: " +total); +// +// data.put("holiday", holidayValue); +// data.put("workday", workdayValue); +// data.put("restday", restdayValue); + fieldValue = String.valueOf(total); + + }else { + + double temp = Util.getDoubleValue(Util.null2String(flowData.get("LaborHoursData|" + id + "|" + fieldName)), 0.00); + fieldValue = String.valueOf(temp); + + } + } else { + fieldValue = Util.null2String(rs.getString(fieldName)); if(Util.null2String(kqReportFieldComInfo.getUnittype()).length()>0) { if(fieldValue.length() == 0){ @@ -441,8 +470,10 @@ public class GetKQReportCmd extends AbstractCommonCommand> { } } } + data.put(fieldName,fieldValue); } + bb.writeLog("--end data: " +data); writeLog("howeccccccccccccggggggg13"+ System.currentTimeMillis()); //请假 List> allLeaveRules = kqLeaveRulesBiz.getAllLeaveRules(); @@ -479,6 +510,34 @@ public class GetKQReportCmd extends AbstractCommonCommand> { }else{ flowLeaveData = KQDurationCalculatorUtil.getDurationRound(Util.null2String(Util.getDoubleValue(leaveData,0.0)-Util.getDoubleValue(leavebackData,0.0))); } + + /*考勤二开--转事假start*/ + if ( flowType.equals( ("leaveType_" + calLeaveId) ) ) { + bb.writeLog("flowLeaveData: " + flowLeaveData); + double temp = Util.getDoubleValue(Util.null2String(flowData.get("-ToComLeaveData|" + id))); + bb.writeLog("temp: " + temp); + if (temp >= 0.00) { + temp = Double.parseDouble(KQDurationCalculatorUtil.getDurationRound(String.valueOf(temp / 60.0))); + double doubleValue = Util.getDoubleValue(Util.null2String(flowLeaveData)); + flowLeaveData = String.valueOf(doubleValue > 0.00? doubleValue : 0.00 + temp); + } + bb.writeLog("flowLeaveData: " + flowLeaveData); + } + /*考勤二开--转事假end*/ + /*考勤二开--异常考勤转事假start*/ + if ( flowType.equals( ("leaveType_" + calLeaveId) ) ) { + bb.writeLog("-flowLeaveData: " + flowLeaveData); + double temp = Util.getDoubleValue(Util.null2String(flowData.get("-AbnAttToComLeaveData|" + id ))); + bb.writeLog("-temp: " + temp); + if (temp >= 0.00) { + temp = Double.parseDouble(KQDurationCalculatorUtil.getDurationRound(String.valueOf(temp / 60.0))); + double doubleValue = Util.getDoubleValue(Util.null2String(flowLeaveData)); + flowLeaveData = String.valueOf(doubleValue > 0.00? doubleValue : 0.00 + temp); + } + bb.writeLog("-flowLeaveData: " + flowLeaveData); + } + /*考勤二开--异常考勤转事假end*/ + data.put(flowType,flowLeaveData); } @@ -553,6 +612,7 @@ public class GetKQReportCmd extends AbstractCommonCommand> { } datas.add(data); } + bb.writeLog("--datas: " +datas); List lsHolidays = KQHolidaySetBiz.getHolidaySetListByScope(""+user.getUID(),fromDate,toDate); retmap.put("holidays", lsHolidays); diff --git a/src/com/engine/kq/cmd/reportdetial/GetLeaveInfoCmd.java b/src/com/engine/kq/cmd/reportdetial/GetLeaveInfoCmd.java new file mode 100644 index 0000000..5222fdf --- /dev/null +++ b/src/com/engine/kq/cmd/reportdetial/GetLeaveInfoCmd.java @@ -0,0 +1,78 @@ +package com.engine.kq.cmd.reportdetial; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQAttFlowSetBiz; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.HashMap; +import java.util.Map; + +/*** + * 请假信息 + */ +public class GetLeaveInfoCmd extends AbstractCommonCommand> { + + public GetLeaveInfoCmd(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 dialogTitle = ""; + String type = Util.null2String(params.get("type")); + if(type.equals("leave")||type.startsWith("leaveType_")){//请假 + dialogTitle = SystemEnv.getHtmlLabelName(20092, user.getLanguage()); + if(type.startsWith("leaveType_")) { + String[] typeInfo = Util.splitString(type, "_"); + if (typeInfo[0].equals("leaveType")) { + params.put("kqtype", KqSplitFlowTypeEnum.LEAVE.getFlowtype()); + } + params.put("newleavetype", typeInfo[1]); + }else{ + params.put("kqtype", KqSplitFlowTypeEnum.LEAVE.getFlowtype()); + } + }else{ + if(type.equals("overtimeTotal")){//加班 + dialogTitle = SystemEnv.getHtmlLabelName(33501, user.getLanguage()); + params.put("kqtype",KqSplitFlowTypeEnum.OVERTIME.getFlowtype()); + }else if(type.equals("businessLeave")){//出差 + dialogTitle = SystemEnv.getHtmlLabelName(20093, user.getLanguage()); + params.put("kqtype",KqSplitFlowTypeEnum.EVECTION.getFlowtype()); + }else if(type.equals("officialBusiness")){//公出 + dialogTitle = SystemEnv.getHtmlLabelName(20094, user.getLanguage()); + params.put("kqtype",KqSplitFlowTypeEnum.OUT.getFlowtype()); + }else if(type.equals("leaveDeduction")){//异常冲抵 + dialogTitle = SystemEnv.getHtmlLabelName(391404, user.getLanguage()); + params.put("kqtype",KqSplitFlowTypeEnum.OTHER.getFlowtype()); + } + } + + retmap.put("dialogTitle",dialogTitle); + retmap.put("sessionkey",new KQAttFlowSetBiz().buildFlowSetTableString(params, user)); + 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/kq/cmd/shiftschedule/ExportExcelCmd.java b/src/com/engine/kq/cmd/shiftschedule/ExportExcelCmd.java new file mode 100644 index 0000000..4f29f87 --- /dev/null +++ b/src/com/engine/kq/cmd/shiftschedule/ExportExcelCmd.java @@ -0,0 +1,359 @@ +package com.engine.kq.cmd.shiftschedule; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.biz.KQShiftManagementComInfo; +import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit; +import com.engine.kq.log.KQLog; +import com.engine.kq.util.ExcelUtil; +import org.apache.commons.lang3.StringUtils; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.*; + +public class ExportExcelCmd extends AbstractCommonCommand> { + + private HttpServletRequest request; + private HttpServletResponse response; + + BaseBean bb = new BaseBean(); + + public ExportExcelCmd(Map params, HttpServletRequest request, HttpServletResponse response, User user) { + this.user = user; + this.params = params; + this.request = request; + this.response = response; + } + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + String sql = ""; + try { + if (!HrmUserVarify.checkUserRight("HrmKQGroup:Add", user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String status = Util.null2String(jsonObj.get("status")); + String groupId = Util.null2String(jsonObj.get("groupId"));//考勤组id + String kqMonth = Util.null2String(jsonObj.get("kqMonth"));//年月 + String viewscope = Util.null2String(jsonObj.get("viewscope")); + String startDate = DateUtil.getFirstDayOfMonth(kqMonth+"-01"); + String endDate = DateUtil.getLastDayOfMonth(kqMonth+"-01"); + + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + ResourceComInfo resourceComInfo = new ResourceComInfo(); + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo(); + LinkedHashMap workbook = new LinkedHashMap<>(); + List lsSheet = new ArrayList<>(); + Map sheet = null; + List titleList = null; + Map title = null; + List> dataList = null; + List data = null; + List> constraintList = null; + Map constraint = null; + + sheet = new HashMap<>(); + sheet.put("sheetName", SystemEnv.getHtmlLabelName(389516, user.getLanguage())); + sheet.put("sheetTitle", Util.formatMultiLang(kqGroupComInfo.getGroupname(groupId), user.getLanguage() + "")+SystemEnv.getHtmlLabelName(389516, user.getLanguage())); + boolean isEnd = false; + Calendar cal = DateUtil.getCalendar(); + + //部门 工号 姓名 + titleList = new ArrayList<>(); + title = new HashMap<>(); + title.put("title",SystemEnv.getHtmlLabelName(124, user.getLanguage())); + title.put("width",30*256); + titleList.add(title); + + title = new HashMap<>(); + title.put("title",SystemEnv.getHtmlLabelName(714, user.getLanguage())); + title.put("width",15*256); + titleList.add(title); + + title = new HashMap<>(); + title.put("title",SystemEnv.getHtmlLabelName(413, user.getLanguage())); + title.put("width",15*256); + titleList.add(title); + + int firstRow = 6; + int endRow = 0; + int firstCol = 3; + int endCol = 0; + + for(String date=startDate; !isEnd;) { + if (date.equals(endDate)) isEnd = true; + title = new HashMap<>(); + title.put("title",date); + title.put("width",16*256); + titleList.add(title); + cal.setTime(DateUtil.parseToDate(date)); + date = DateUtil.getDate(cal.getTime(), 1); + } + endCol = titleList.size()+firstCol; + sheet.put("titleList", titleList); + + Map mapShiftSchedule = new HashMap<>(); + String tmpSerialids = ""; + sql = " select serialid, resourceid, kqdate from kq_shiftschedule where (isdelete is null or isdelete <> '1') and groupid=? "; + rs.executeQuery(sql,groupId); + while(rs.next()){ + mapShiftSchedule.put(rs.getString("kqdate")+"|"+rs.getString("resourceid"),rs.getString("serialid")); + if((","+tmpSerialids+",").indexOf(","+rs.getString("serialid")+",")==-1 && rs.getInt("serialid")>0) { + if (tmpSerialids.length() > 0) tmpSerialids += ","; + tmpSerialids += rs.getString("serialid"); + } + } + List sheetMemo = new ArrayList<>(); + ShiftManagementToolKit shiftManagementToolKit = new ShiftManagementToolKit(); + sheetMemo.add(SystemEnv.getHtmlLabelName(390620, user.getLanguage())); + List tmpserialids = Util.splitString2List( Util.null2String(kqGroupComInfo.getSerialids(groupId)),","); + tmpSerialids = "" ; + if(tmpSerialids != null){ + for(String ts : tmpserialids){ + if(tmpSerialids.length() > 0) tmpSerialids += "," ; + tmpSerialids += ts ; + } + } + sheetMemo.add( Util.formatMultiLang(shiftManagementToolKit.getShiftOnOffWorkSections(tmpSerialids,user.getLanguage()), user.getLanguage()+"")+" "+SystemEnv.getHtmlLabelName(390605, user.getLanguage())); + sheet.put("sheetMemo",sheetMemo); + + + String sqlWhere = " "; + + //考勤二开--权限处理 + sqlWhere += getViewDepts(user); + bb.writeLog("schedule exportExcelCmd sqlWhere: " + sqlWhere); + + if(viewscope.length()>0){ + if(viewscope.equals("1")){//分部 + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + sqlWhere += " and t.subcompanyid1 in ("+subCompanyId+") "; + }else if(viewscope.equals("2")){//部门 + String departmentId = Util.null2String(jsonObj.get("departmentId")); + sqlWhere += " and t.departmentid in ("+departmentId+") "; + }else if(viewscope.equals("3")){//人员 + String resourceId = Util.null2String(jsonObj.get("resourceId")); + sqlWhere += " and t.resourceid in ("+resourceId+") "; + } + } + + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));// 是否显示无账号人员 + if (!"1".equals(isNoAccount)) { + sqlWhere += " and status in(0,1,2,3) and loginid is not null "+(rs.getDBType().equals("oracle")?"":" and loginid<>'' "); + } + if(status.length()>0){ + if (!status.equals("8") && !status.equals("9")) { + sqlWhere += " and t.status = "+status+ ""; + }else if (status.equals("8")) { + sqlWhere += " and (t.status = 0 or t.status = 1 or t.status = 2 or t.status = 3) "; + } + } + + if(!Util.null2String(kqGroupComInfo.getExcludecount(groupId)).equals("1")) { + //剔除无需排班人员 + String excludeid = Util.null2String(kqGroupComInfo.getExcludeid(groupId)); + if (excludeid.length() > 0) { + sqlWhere += " and t.resourceid not in (" + excludeid + ")"; + } + } + + dataList = new ArrayList<>(); + List resList = new ArrayList<>(); + + sql = " select b.id, b.kqdate, b.serialid, t.resourceid, t.subcompanyid1, t.departmentid, t.loginid from (\n" + + " SELECT distinct t.resourceid, t.groupid, t.status, t.dsporder,t.lastname,t.subcompanyid1, t.departmentid, t.loginid FROM ( \n" + + " SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" + + " WHERE (a.id=b.typevalue and b.type =1) and (b.isdelete is null or b.isdelete <> '1') \n" + + " UNION ALL \n" + + " SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" + + " WHERE (a.subcompanyid1 = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=2) and (b.isdelete is null or b.isdelete <> '1') \n" + + " UNION ALL \n" + + " SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" + + " WHERE (a.departmentid = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=3) and (b.isdelete is null or b.isdelete <> '1') \n" + + " UNION ALL \n" + + " SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" + + " WHERE (a.jobtitle = b.typevalue AND b.type=5 and (b.isdelete is null or b.isdelete <> '1') AND (b.jobtitlelevel=1 OR (b.jobtitlelevel=2 AND a.subcompanyid1 IN(b.jobtitlelevelvalue)) OR (b.jobtitlelevel=3 AND a.departmentid IN(b.jobtitlelevelvalue)))) \n" + + " UNION ALL \n" + + " SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" + + " WHERE b.type=6 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1'))t) t left join kq_shiftschedule b on t.resourceid=b.resourceid " + + " and t.groupid=b.groupid and (b.isdelete is null or b.isdelete <> '1') and b.kqdate>=? and b.kqdate<=? where t.groupid=? \n " + + sqlWhere + + " order by t.dsporder,t.lastname"; + new KQLog().info("ExportExcelCmd:"+sql); + bb.writeLog("schedule ExportExcelCmd sql: " + sql); + rs.executeQuery(sql,startDate,startDate,groupId); + while(rs.next()){ + data = new ArrayList<>(); + String resourceid = rs.getString("resourceid"); + if(resList.contains(resourceid)){ + continue; + } + resList.add(resourceid); + data.add(Util.formatMultiLang(departmentComInfo.getDepartmentName(resourceComInfo.getDepartmentID(resourceid)),""+user.getLanguage())); + data.add(Util.formatMultiLang(resourceComInfo.getWorkcode(resourceid),""+user.getLanguage())); + data.add(Util.formatMultiLang(resourceComInfo.getLastname(resourceid),""+user.getLanguage())); + isEnd = false; + for(String date=startDate; !isEnd;) { + if (date.equals(endDate)) isEnd = true; + String serialId = Util.null2String(mapShiftSchedule.get(date+"|"+resourceid)); + String serialName = ""; + if(serialId.equals("-1")){ + serialName = SystemEnv.getHtmlLabelName(26593, user.getLanguage()); + }else{ + serialName = Util.formatMultiLang(kqShiftManagementComInfo.getSerial(serialId),""+user.getLanguage()); + } + data.add(serialName); + cal.setTime(DateUtil.parseToDate(date)); + date = DateUtil.getDate(cal.getTime(), 1); + } + dataList.add(data); + } + endRow = dataList.size()+firstRow; + sheet.put("dataList", dataList); + + //增加数据有效性校验 + constraintList = new ArrayList<>(); + constraint = new HashMap<>(); + constraint.put("firstRow",firstRow); + constraint.put("endRow",endRow); + constraint.put("firstCol",firstCol); + constraint.put("endCol",endCol); + List serialids = Util.splitString2List( Util.null2String(kqGroupComInfo.getSerialids(groupId)),","); + serialids.add("-1"); + String[] serialnames = new String[serialids.size()]; + for(int i=0;i exportMap = ExcelUtil.export(workbook, request, response); + retmap.putAll(exportMap); + 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; + } + + /*考勤二开--权限处理start*/ + private String getViewDepts(User user) { + String result = " and 1=1 "; + + try { + int userId = user.getUID(); + if (userId == 1 ) { + return result; + } else { + List temp = new ArrayList<>(); + String acqDeptsSql = "select department from uf_scheauthority where resourceid = ? "; + RecordSet rs = new RecordSet(); + rs.executeQuery(acqDeptsSql, userId); + while (rs.next()) { + String department = Util.null2String(rs.getString("department")); + if (StringUtils.isNotBlank(department)) { + temp.add(department); + } + } + if (temp != null & temp.size() > 0) { + String sqlWhere = queryDepartmentSubordinate(temp); + result += " and departmentid in (" + sqlWhere + ")"; + } + } + + }catch (Exception e) { + bb.writeLog("getViewDepts exception: " +e); + } + + return result; + } + + public String queryDepartmentSubordinate(List deptids){ + + bb.writeLog("queryDepartmentSubordinate start"); + + RecordSet rs = new RecordSet(); + List list = new ArrayList(); + if(deptids != null && deptids.size() > 0) { + String sql = " select * from hrmdepartment where id in ("+ String.join(",", deptids) +")"; + bb.writeLog("sql: " + sql); + + rs.executeQuery(sql); + while (rs.next()){ + String id = Util.null2String(rs.getString("id")); + list.add(id); + bb.writeLog("id: " + id); + bb.writeLog("list: " + list); + addChildDept(list,id); + } + } + bb.writeLog("-=-=-list: " + list); + if(list !=null && list.size()> 0){ + String sqlWhere = String.join(",", list); + return sqlWhere; + }else{ + return ""; + } + } + + public void addChildDept(List datasList, String parentid){ + bb.writeLog("addChildDept start"); + String sql = " select id from hrmdepartment where supdepid="+parentid; + bb.writeLog("sql: " + sql); + List> dataList = new ArrayList<>(); + RecordSet rs = new RecordSet(); + rs.execute(sql); + while(rs.next()){ + String id = Util.null2String(rs.getString("id")); + bb.writeLog("id: " + id); + + if(!datasList.contains(id)){ + datasList.add(id); + } + bb.writeLog("datasList: " + datasList); + + addChildDept(datasList,id); + } + } + + /*考勤二开--权限处理end*/ + +} diff --git a/src/com/engine/kq/cmd/shiftschedule/GetShiftScheduleCmd.java b/src/com/engine/kq/cmd/shiftschedule/GetShiftScheduleCmd.java new file mode 100644 index 0000000..f195aa2 --- /dev/null +++ b/src/com/engine/kq/cmd/shiftschedule/GetShiftScheduleCmd.java @@ -0,0 +1,396 @@ +package com.engine.kq.cmd.shiftschedule; + +import com.alibaba.fastjson.JSONObject; +import com.alipay.api.domain.UserInfoFromNJ; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.biz.KQHolidaySetBiz; +import com.engine.kq.biz.KQShiftManagementComInfo; +import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit; +import com.engine.kq.log.KQLog; +import org.apache.commons.lang3.StringUtils; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.util.*; + +public class GetShiftScheduleCmd extends AbstractCommonCommand> { + + BaseBean bb = new BaseBean(); + + public GetShiftScheduleCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + Map shiftSchedule = new HashMap(); + List lsDatas = null; + List lsKeyDatas = null; + Map data = null; + RecordSet rs = new RecordSet(); + + String sql = ""; + try{ + //必要的权限判断 + if(!HrmUserVarify.checkUserRight("HrmKQGroup:Add",user)) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + return retmap; + } + + int count = 0; + int pageCount = 0; + int isHavePre = 0; + int isHaveNext = 0; + + KQGroupComInfo kQGroupComInfo = new KQGroupComInfo(); + KQShiftManagementComInfo kQShiftManagementComInfo = new KQShiftManagementComInfo(); + ShiftManagementToolKit shiftManagementToolKit = new ShiftManagementToolKit(); + ResourceComInfo resourceComInfo = new ResourceComInfo(); + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + String status = Util.null2String(params.get("status")); + + String groupId = Util.null2String(params.get("groupId"));//考勤组id + String kqMonth = Util.null2String(params.get("kqMonth"));//月份 + String viewscope = Util.null2String(params.get("viewscope"));//0:总部 1:分部 2:部门 3:人员 4:我的下属 + int pageIndex = Util.getIntValue(Util.null2String(params.get("pageIndex")), 1); + int pageSize = Util.getIntValue(Util.null2String(params.get("pageSize")), 20); + String year = kqMonth.substring(0,4); + String month = kqMonth.substring(5,7); + String monthBeginDate = DateUtil.getFirstDayOfMonth(kqMonth+"-01"); + String monthEndDate = DateUtil.getLastDayOfMonth(kqMonth+"-01"); + + String serialidStr = Util.null2String(kQGroupComInfo.getSerialids(groupId)); + List serialids = new ArrayList<>(); + List lsSerialDatas = new ArrayList<>(); + if(serialidStr.length() > 0){ + serialids = Util.splitString2List(serialidStr,","); + for(int i=0;i(); + data.put("id",serialids.get(i)); + data.put("name",shiftManagementToolKit.getShiftOnOffWorkSections(serialids.get(i),user.getLanguage())); + data.put("bgColor",kQShiftManagementComInfo.getColor(serialids.get(i))); + lsSerialDatas.add(data); + } + } + + lsDatas = new ArrayList<>(); + sql = "select id,shiftcyclename,shiftcycleserialids from kq_group_shiftcycle where groupid = ? order by id asc "; + rs.executeQuery(sql,groupId); + while(rs.next()){ + data = new HashMap<>(); + data.put("name",Util.null2String(rs.getString("shiftcyclename")));//周期名称, + data.put("serial",Util.splitString(Util.null2String(rs.getString("shiftcycleserialids")),","));//周期顺序,例7天一周期 + lsDatas.add(data); + } + retmap.put("serialInfo", lsDatas); + lsDatas = KQHolidaySetBiz.getGroupHolidaySetList(groupId,year,month); + retmap.put("holidays", lsDatas); + + String sqlWhere = " "; + if(viewscope.length()>0){ + if(viewscope.equals("1")){//分部 + String subCompanyId = Util.null2String(params.get("subCompanyId")); + sqlWhere += " and t.subcompanyid1 in ("+subCompanyId+") "; + }else if(viewscope.equals("2")){//部门 + String departmentId = Util.null2String(params.get("departmentId")); + sqlWhere += " and t.departmentid in ("+departmentId+") "; + }else if(viewscope.equals("3")){//人员 + String resourceId = Util.null2String(params.get("resourceId")); + sqlWhere += " and t.resourceid in ("+resourceId+") "; + } + } + + String isNoAccount = Util.null2String(params.get("isNoAccount"));// 是否显示无账号人员 + if (!"1".equals(isNoAccount)) { + sqlWhere += " and t.status in(0,1,2,3) and t.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and t.loginid<>'' "); + } + if(status.length()>0){ + if (!status.equals("8") && !status.equals("9")) { + sqlWhere += " and t.status = "+status+ ""; + }else if (status.equals("8")) { + sqlWhere += " and (t.status = 0 or t.status = 1 or t.status = 2 or t.status = 3) "; + } + } + + if(!Util.null2String(kQGroupComInfo.getExcludecount(groupId)).equals("1")) { + //剔除无需排班人员 + String excludeid = Util.null2String(kQGroupComInfo.getExcludeid(groupId)); + if (excludeid.length() > 0) { + sqlWhere += " and t.resourceid not in (" + excludeid + ")"; + } + } + + + String backFields = " t.resourceid, t.groupid, t.status, t.dsporder,t.lastname,t.subcompanyid1, t.departmentid, t.loginid "; + String sqlFrom = " from (SELECT distinct t.resourceid, t.groupid, t.status, t.dsporder,t.lastname,t.subcompanyid1, t.departmentid, t.loginid FROM ( \n" + + " SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" + + " WHERE a.id=b.typevalue and b.type =1 and (b.isdelete is null or b.isdelete <> '1') \n" + + " UNION ALL \n" + + " SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" + + " WHERE a.subcompanyid1 = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=2 and (b.isdelete is null or b.isdelete <> '1') \n" + + " UNION ALL \n" + + " SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" + + " WHERE a.departmentid = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=3 and (b.isdelete is null or b.isdelete <> '1') \n" + + " UNION ALL \n" + + " SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" + + " WHERE (a.jobtitle = b.typevalue AND b.type=5 and (b.isdelete is null or b.isdelete <> '1') AND (b.jobtitlelevel=1 OR (b.jobtitlelevel=2 AND a.subcompanyid1 IN(b.jobtitlelevelvalue)) OR (b.jobtitlelevel=3 AND a.departmentid IN(b.jobtitlelevelvalue)))) \n" + + " UNION ALL " + + " SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" + + " WHERE b.type=6 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1')" + + " )t ) t where t.groupid = "+groupId; + String groupBy = " "; + + + lsKeyDatas = new ArrayList<>(); + lsDatas = new ArrayList<>(); +// sql = " select b.id, b.kqdate, b.serialid, t.resourceid, t.subcompanyid1, t.departmentid, t.loginid from (\n" + +// " SELECT distinct t.resourceid, t.groupid, t.status, t.dsporder,t.lastname,t.subcompanyid1, t.departmentid, t.loginid FROM ( \n" + +// " SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" + +// " WHERE a.id=b.typevalue and b.type =1 and (b.isdelete is null or b.isdelete <> '1') \n" + +// " UNION ALL \n" + +// " SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" + +// " WHERE a.subcompanyid1 = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=2 and (b.isdelete is null or b.isdelete <> '1') \n" + +// " UNION ALL \n" + +// " SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" + +// " WHERE a.departmentid = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=3 and (b.isdelete is null or b.isdelete <> '1') \n" + +// " UNION ALL \n" + +// " SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" + +// " WHERE (a.jobtitle = b.typevalue AND b.type=5 and (b.isdelete is null or b.isdelete <> '1') AND (b.jobtitlelevel=1 OR (b.jobtitlelevel=2 AND a.subcompanyid1 IN(b.jobtitlelevelvalue)) OR (b.jobtitlelevel=3 AND a.departmentid IN(b.jobtitlelevelvalue)))) \n" + +// " UNION ALL " + +// " SELECT a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" + +// " WHERE b.type=6 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1')" + +// " )t ) t left join kq_shiftschedule b on t.resourceid=b.resourceid and t.groupid = b.groupid and (b.isdelete is null or b.isdelete <> '1') and b.kqdate>=? and b.kqdate<=? where t.groupid=? \n " + +// sqlWhere + +// " order by t.dsporder,t.lastname"; + +// sql = " select count(*) as c from ( select 1 as c "+sqlFrom+sqlWhere+groupBy+") t"; + //考勤二开 + String newSqlWhere = getViewDepts(user); + + sql = " select count(*) as c from ( select 1 as c, departmentid "+sqlFrom+sqlWhere + " and" +newSqlWhere +groupBy+") t"; + bb.writeLog("--==--sql: " + sql); + rs.execute(sql); + if (rs.next()){ + count = rs.getInt("c"); + } + + if (count <= 0) { + pageCount = 0; + } + + pageCount = count / pageSize + ((count % pageSize > 0) ? 1 : 0); + + isHaveNext = (pageIndex + 1 <= pageCount) ? 1 : 0; + + isHavePre = (pageIndex - 1 >= 1) ? 1 : 0; + + String orderBy = " order by t.dsporder asc, t.lastname asc "; + String descOrderBy = " order by t.dsporder desc, t.lastname desc "; + + sql = backFields + sqlFrom + sqlWhere + groupBy; + + if (pageIndex > 0 && pageSize > 0) { + if (rs.getDBType().equals("oracle")) { + sql = " select * from (select " + sql+") t "+orderBy; + sql = "select * from ( select row_.*, rownum rownum_ from ( " + sql + " ) row_ where rownum <= " + + (pageIndex * pageSize) + ") where rownum_ > " + ((pageIndex - 1) * pageSize); + } else if (rs.getDBType().equals("mysql")) { + sql = " select * from (select " + sql+") t "+orderBy; +// sql = "select t1.* from (" + sql + ") t1 limit " + ((pageIndex - 1) * pageSize) + "," + pageSize; + sql = "select t1.* from (" + sql + ") t1 where " + newSqlWhere + " limit " + ((pageIndex - 1) * pageSize) + "," + pageSize; + } else if (rs.getDBType().equals("postgresql")) { + sql = " select * from (select " + sql+") t "+orderBy; + sql = "select t1.* from (" + sql + ") t1 limit " +pageSize + " offset " + ((pageIndex - 1) * pageSize); + } else { + orderBy = " order by dsporder asc, lastname asc "; + descOrderBy = " order by dsporder desc, lastname desc "; + if (pageIndex > 1) { + int topSize = pageSize; + if (pageSize * pageIndex > count) { + topSize = count - (pageSize * (pageIndex - 1)); + } + sql = " select top " + topSize + " * from ( select top " + topSize + " * from ( select top " + + (pageIndex * pageSize) + sql + orderBy+ " ) tbltemp1 " + descOrderBy + ") tbltemp2 " + orderBy; + } else { + sql = " select top " + pageSize + sql+orderBy; + } + } + } else { + sql = " select " + sql; + } + new KQLog().info("GetShiftScheduleCmd:"+sql); + bb.writeLog("GetShiftScheduleCmd sql: " + sql); + rs.executeQuery(sql); + while(rs.next()){ + String resourceid = Util.null2String(rs.getString("resourceid")); + data = new HashMap<>(); + data.put("resourceid",resourceid); + data.put("name",resourceComInfo.getLastname(resourceid)); + data.put("department",departmentComInfo.getDepartmentname(resourceComInfo.getDepartmentID(resourceid))); + List shiftScheduleDatas = this.getShiftSchedule(groupId, resourceid, monthBeginDate,monthEndDate); + for(int i=0;shiftScheduleDatas!=null&&i shiftScheduleData = (Map)shiftScheduleDatas.get(i); + String id = Util.null2String(shiftScheduleData.get("id")); + String kqdate = Util.null2String(shiftScheduleData.get("kqdate")); + String serialid = Util.null2String(shiftScheduleData.get("serialid")); + if(!serialids.contains(serialid) && !serialid.equals("-1")){ + serialids.add(serialid); + Map serialdata = new HashMap<>(); + serialdata.put("id",serialid); + serialdata.put("name",shiftManagementToolKit.getShiftOnOffWorkSections(serialid,user.getLanguage())); + serialdata.put("bgColor",kQShiftManagementComInfo.getColor(serialid)); + serialdata.put("isDelete",1); + lsSerialDatas.add(serialdata); + } + data.put(kqdate,serialid); + lsKeyDatas.add(resourceid+"|"+kqdate+"|"+id); + } + lsDatas.add(data); + } + retmap.put("pagesize", pageSize); + retmap.put("pageindex", pageIndex); + retmap.put("count", count); + retmap.put("pagecount", pageCount); + retmap.put("ishavepre", isHavePre); + retmap.put("ishavenext", isHaveNext); + retmap.put("datas", lsDatas); + retmap.put("keyDatas", lsKeyDatas); + retmap.put("shiftList", lsSerialDatas); + retmap.put("groupName", kQGroupComInfo.getGroupname(groupId)); + retmap.put("today", DateUtil.getCurrentDate()); + if(Util.null2String(kQGroupComInfo.getValidity(groupId)).equals("1")){//考勤组设置了有效期 + retmap.put("validityFromDate", kQGroupComInfo.getValidityfromdate(groupId)); + retmap.put("validityEndDate", kQGroupComInfo.getValidityenddate(groupId)); + } + retmap.put("status", "1"); + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + private List getShiftSchedule(String groupid, String resourceid, String monthBeginDate,String monthEndDate){ + List datas = new ArrayList<>(); + Map data = null; + String sql = ""; + RecordSet rs = new RecordSet(); + sql = " select id,kqdate, serialid from kq_shiftschedule where groupid= '"+groupid+"' and resourceid="+resourceid+" " + + " and kqdate>='"+monthBeginDate+"' and kqdate<='"+monthEndDate+"' and (isdelete is null or isdelete <> '1')"; + rs.executeQuery(sql); + while(rs.next()){ + String id = Util.null2String(rs.getString("id")); + String kqdate = Util.null2String(rs.getString("kqdate")); + String serialid = Util.null2String(rs.getString("serialid")); + + data = new HashMap<>(); + data.put("id",id); + data.put("kqdate",kqdate); + data.put("serialid",serialid); + datas.add(data); + } + return datas; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + /*考勤二开--权限处理start*/ + private String getViewDepts(User user) { + String result = " 1=1 "; + + try { + int userId = user.getUID(); + if (userId == 1 ) { + return result; + } else { + List temp = new ArrayList<>(); + String acqDeptsSql = "select department from uf_scheauthority where resourceid = ? "; + RecordSet rs = new RecordSet(); + rs.executeQuery(acqDeptsSql, userId); + while (rs.next()) { + String department = Util.null2String(rs.getString("department")); + if (StringUtils.isNotBlank(department)) { + temp.add(department); + } + } + if (temp != null & temp.size() > 0) { + String sqlWhere = queryDepartmentSubordinate(temp); + result += " and departmentid in (" + sqlWhere + ")"; + } + } + + }catch (Exception e) { + bb.writeLog("getViewDepts exception: " +e); + } + + return result; + } + + public String queryDepartmentSubordinate(List deptids){ + + bb.writeLog("queryDepartmentSubordinate start"); + + RecordSet rs = new RecordSet(); + List list = new ArrayList(); + if(deptids != null && deptids.size() > 0) { + String sql = " select * from hrmdepartment where id in ("+ String.join(",", deptids) +")"; + bb.writeLog("sql: " + sql); + + rs.executeQuery(sql); + while (rs.next()){ + String id = Util.null2String(rs.getString("id")); + list.add(id); + bb.writeLog("id: " + id); + bb.writeLog("list: " + list); + addChildDept(list,id); + } + } + bb.writeLog("-=-=-list: " + list); + if(list !=null && list.size()> 0){ + String sqlWhere = String.join(",", list); + return sqlWhere; + }else{ + return ""; + } + } + + public void addChildDept(List datasList, String parentid){ + bb.writeLog("addChildDept start"); + String sql = " select id from hrmdepartment where supdepid="+parentid; + bb.writeLog("sql: " + sql); + List> dataList = new ArrayList<>(); + RecordSet rs = new RecordSet(); + rs.execute(sql); + while(rs.next()){ + String id = Util.null2String(rs.getString("id")); + bb.writeLog("id: " + id); + + if(!datasList.contains(id)){ + datasList.add(id); + } + bb.writeLog("datasList: " + datasList); + + addChildDept(datasList,id); + } + } + + /*考勤二开--权限处理end*/ + +} diff --git a/src/com/engine/sskj/service/impl/EntryServiceImpl.java b/src/com/engine/sskj/service/impl/EntryServiceImpl.java index da9dcc9..1fc44bc 100644 --- a/src/com/engine/sskj/service/impl/EntryServiceImpl.java +++ b/src/com/engine/sskj/service/impl/EntryServiceImpl.java @@ -112,13 +112,13 @@ public class EntryServiceImpl extends Service implements EntryService { return result; } - if ( "6".equals(entryType) && StringUtils.isEmpty(serviceCompany)) { + if ( "4".equals(entryType) && StringUtils.isEmpty(serviceCompany)) { result.put("code",500); result.put("msg","请先选择劳务公司"); return result; } - if ( "6".equals(entryType)) {//劳务外包 + if ( "4".equals(entryType)) {//劳务派遣 //获取劳务公司代码 String compCode = ""; String acqOutCompSql = "select gsdm from uf_lwgs where id = ? "; @@ -142,8 +142,8 @@ public class EntryServiceImpl extends Service implements EntryService { if ( StringUtils.isBlank(maxNum)) {//该公司该月没有生成最大流程号 SskjUtil sskjUtil =new SskjUtil(); maxNum = "001"; - String addMaxNumSql = "insert into uf_OutEmpNum ( outComp, entryDate, maxNum, formmodeid, modedatacreater, modedatacreatertype, modedatacreatedate, modedatacreatetime, MODEUUID)" + - " values (?,?,?,?,?,?,?,?,?)"; + String addMaxNumSql = "insert into uf_OutEmpNum ( prefix, outComp, entryDate, maxNum, formmodeid, modedatacreater, modedatacreatertype, modedatacreatedate, modedatacreatetime, MODEUUID)" + + " values (?,?,?,?,?,?,?,?,?,?)"; String outEmpNumModeId = basebean.getPropValue("project_sskj", "outEmpNumModeId"); Integer modedatacreater = user.getUID(); Integer modedatacreatertype = user.getType(); @@ -151,7 +151,7 @@ public class EntryServiceImpl extends Service implements EntryService { String modedatacreatetime = DateUtil.format(new Date(), "HH:mm:ss"); String uuid = UUID.randomUUID().toString(); - boolean addFlag = rs.executeUpdate(addMaxNumSql, serviceCompany, entryMonth, maxNum, outEmpNumModeId, modedatacreater, modedatacreatertype, modedatacreatedate, + boolean addFlag = rs.executeUpdate(addMaxNumSql, compCode, serviceCompany, entryMonth, maxNum, outEmpNumModeId, modedatacreater, modedatacreatertype, modedatacreatedate, modedatacreatetime, uuid); if (addFlag) { String billid = "-1"; @@ -198,8 +198,8 @@ public class EntryServiceImpl extends Service implements EntryService { basebean.writeLog("非外包,没有流水"); basebean.writeLog("maxNum:" + maxNum); - String addMaxNumSql = "insert into uf_NoOutEmpNum ( entryDate, maxNum, formmodeid, modedatacreater, modedatacreatertype, modedatacreatedate, modedatacreatetime, MODEUUID)" + - " values (?,?,?,?,?,?,?,?)"; + String addMaxNumSql = "insert into uf_NoOutEmpNum ( prefix, entryDate, maxNum, formmodeid, modedatacreater, modedatacreatertype, modedatacreatedate, modedatacreatetime, MODEUUID)" + + " values (?,?,?,?,?,?,?,?,?)"; String noOutEmpNumModeId = basebean.getPropValue("project_sskj", "noOutEmpNumModeId"); Integer modedatacreater = user.getUID(); Integer modedatacreatertype = user.getType(); @@ -208,7 +208,7 @@ public class EntryServiceImpl extends Service implements EntryService { String uuid = UUID.randomUUID().toString(); basebean.writeLog("addMaxNumSql:" + addMaxNumSql); - boolean addFlag = rs.executeUpdate(addMaxNumSql, entryMonth, maxNum, noOutEmpNumModeId, modedatacreater, modedatacreatertype, modedatacreatedate, + boolean addFlag = rs.executeUpdate(addMaxNumSql, "SSKJ", entryMonth, maxNum, noOutEmpNumModeId, modedatacreater, modedatacreatertype, modedatacreatedate, modedatacreatetime, uuid); basebean.writeLog("addFlag:" + addFlag); if (addFlag) { diff --git a/src/weaver/interfaces/sskj/job/SyncZkKqDataJob.java b/src/weaver/interfaces/sskj/job/SyncZkKqDataJob.java index 10d7e92..39f727f 100644 --- a/src/weaver/interfaces/sskj/job/SyncZkKqDataJob.java +++ b/src/weaver/interfaces/sskj/job/SyncZkKqDataJob.java @@ -35,6 +35,25 @@ import static weaver.interfaces.sskj.util.HttpsUtil.doPostJsonRequest; */ public class SyncZkKqDataJob extends BaseCronJob { + private String startTime; + private String endTime; + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getEndTime() { + return endTime; + } + + public void setEndTime(String endTime) { + this.endTime = endTime; + } + @Override public void execute() { new BaseBean(); @@ -53,13 +72,18 @@ public class SyncZkKqDataJob extends BaseCronJob { idWorkcodeMap.put(workcode,userId); } } + //获取开始时间结束时间 - Calendar beforeTime = Calendar.getInstance(); - beforeTime.add(Calendar.MINUTE, -5);// 5分钟之前的时间 - Date beforeD = beforeTime.getTime(); - String startTime = DateUtil.format(beforeD,"yyyy-MM-dd HH:mm:ss"); - Date now = new Date(); - String endTime = DateUtil.format(now,"yyyy-MM-dd HH:mm:ss"); + bb.writeLog("startTime = " + startTime); + bb.writeLog("endTime = " + endTime); + if (StringUtils.isBlank(startTime) && StringUtils.isNotBlank(endTime)) { + Calendar beforeTime = Calendar.getInstance(); + beforeTime.add(Calendar.MINUTE, -5);// 5分钟之前的时间 + Date beforeD = beforeTime.getTime(); + startTime = DateUtil.format(beforeD,"yyyy-MM-dd HH:mm:ss"); + Date now = new Date(); + endTime = DateUtil.format(now,"yyyy-MM-dd HH:mm:ss"); + } bb.writeLog("startTime:"+startTime); bb.writeLog("endTime:"+endTime);