From 952f285f3890c1a4a53d3eeed39620b70ea76fe5 Mon Sep 17 00:00:00 2001 From: shilei <798989044@qq.com> Date: Mon, 1 Sep 2025 21:00:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=99=E6=96=87=E4=BB=A3=E7=A0=81=E5=A4=87?= =?UTF-8?q?=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 浙文眼镜/interface/zw/do.jsp | 1471 +++++++++++++++++ .../zw/workflow/htpblc/getSchedulingDateType.jsp | 284 ++++ .../workflow/htpblc/querySchedulingUserData.jsp | 221 +++ .../zw/workflow/htpblc/queryUserTransferData.jsp | 114 ++ .../zw/workflow/httblc/getSchedulingDateType.jsp | 282 ++++ .../workflow/httblc/querySchedulingUserData.jsp | 221 +++ .../zw/workflow/httblc/queryUserSerialByMonth.jsp | 840 ++++++++++ .../httblc/queryUserSerialByMonth_test.jsp | 848 ++++++++++ .../zw/workflow/mdtblc/countUserWorkTime.jsp | 264 +++ .../zw/workflow/mdtblc/getSchedulingDateType.jsp | 285 ++++ .../workflow/mdtblc/querySchedulingUserData.jsp | 221 +++ .../zw/workflow/mdtblc/queryUserSerialByMonth.jsp | 842 ++++++++++ .../mdtblc/queryUserSerialByMonth_test.jsp | 851 ++++++++++ .../zw/workflow/mdtblc/queryUserTransferData.jsp | 83 + .../mdtblc/queryUserTransferData_test.jsp | 87 + .../zw/workflow/mdtblc/queryUserWorkdayData.jsp | 440 +++++ .../zw/workflow/pblc/countUserWorkTime.jsp | 263 +++ .../zw/workflow/pblc/getSchedulingDateType.jsp | 306 ++++ .../workflow/pblc/queryMainSchedulingUserData.jsp | 54 + .../zw/workflow/pblc/querySchedulingUserData.jsp | 222 +++ .../zw/workflow/pblc/querySchedulingUserData2.jsp | 225 +++ .../zw/workflow/pblc/queryUserTransferData.jsp | 83 + .../zw/workflow/pblc/queryUserTransferData2.jsp | 87 + .../workflow/pblc/queryUserTransferData_test.jsp | 87 + .../zw/workflow/pblc/queryUserWorkdayData.jsp | 381 +++++ .../zw/workflow/pblc/queryUserWorkdayData2.jsp | 385 +++++ .../zw/workflow/pblc/queryUserWorkdayData3.jsp | 450 +++++ .../workflow/pblc/queryUserWorkdayData3_test.jsp | 450 +++++ .../workflow/pblc/queryUserWorkdayData3_test2.jsp | 248 +++ .../workflow/pblc/queryUserWorkdayData3_test3.jsp | 470 ++++++ .../zw/workflow/pblc/queryUserWorkdayData4.jsp | 514 ++++++ .../pblc/queryUserWorkdayDataByMonth2.jsp | 857 ++++++++++ .../pblc/queryUserWorkdayDataByMonth2bak.jsp | 849 ++++++++++ .../pblc/queryUserWorkdayDataByMonth3.jsp | 599 +++++++ .../interface/zw/workflow/pblc/testrs.jsp | 309 ++++ .../interface/zw/workflow/pblc/testrs3.jsp | 69 + .../zw/workflow/tblc/queryUserSerialByMonth.jsp | 840 ++++++++++ .../workflow/tblc/queryUserWorkdayDataByMonth.jsp | 916 ++++++++++ .../tblc/queryUserWorkdayDataByMonth_test.jsp | 939 +++++++++++ .../zw/cron/EmployeeDataSnapshotCron.java | 21 + .../zw/cron/EmployeeDataSnapshotDayCron.java | 22 + .../zw/cron/EmployeeDataSnapshotMonthCron.java | 22 + .../interfaces/zw/cron/EmployeeTransferCron.java | 62 + .../weaver/interfaces/zw/utils/CommonUtil.java | 136 ++ .../action/Htpblc2SchedulingEditAction.java | 373 +++++ .../action/Htpblc2SchedulingEditActionbak.java | 496 ++++++ .../action/Httblc2SchedulingEditAction.java | 331 ++++ .../action/Mdpblc2SchedulingEditAction.java | 351 ++++ .../action/Mdtblc2SchedulingEditAction.java | 331 ++++ .../action/SchedulingDataCheckAction.java | 261 +++ .../action/WorkflowToSchedulingAction.java | 317 ++++ .../action/WorkflowToSchedulingAddAction.java | 318 ++++ .../action/WorkflowToSchedulingEditAction.java | 334 ++++ .../action/WorkflowToSchedulingUpdateAction.java | 350 ++++ .../xygrzlc/NewEmployee2HrmResoyeceAction.java | 350 ++++ 55 files changed, 21032 insertions(+) create mode 100644 浙文眼镜/interface/zw/do.jsp create mode 100644 浙文眼镜/interface/zw/workflow/htpblc/getSchedulingDateType.jsp create mode 100644 浙文眼镜/interface/zw/workflow/htpblc/querySchedulingUserData.jsp create mode 100644 浙文眼镜/interface/zw/workflow/htpblc/queryUserTransferData.jsp create mode 100644 浙文眼镜/interface/zw/workflow/httblc/getSchedulingDateType.jsp create mode 100644 浙文眼镜/interface/zw/workflow/httblc/querySchedulingUserData.jsp create mode 100644 浙文眼镜/interface/zw/workflow/httblc/queryUserSerialByMonth.jsp create mode 100644 浙文眼镜/interface/zw/workflow/httblc/queryUserSerialByMonth_test.jsp create mode 100644 浙文眼镜/interface/zw/workflow/mdtblc/countUserWorkTime.jsp create mode 100644 浙文眼镜/interface/zw/workflow/mdtblc/getSchedulingDateType.jsp create mode 100644 浙文眼镜/interface/zw/workflow/mdtblc/querySchedulingUserData.jsp create mode 100644 浙文眼镜/interface/zw/workflow/mdtblc/queryUserSerialByMonth.jsp create mode 100644 浙文眼镜/interface/zw/workflow/mdtblc/queryUserSerialByMonth_test.jsp create mode 100644 浙文眼镜/interface/zw/workflow/mdtblc/queryUserTransferData.jsp create mode 100644 浙文眼镜/interface/zw/workflow/mdtblc/queryUserTransferData_test.jsp create mode 100644 浙文眼镜/interface/zw/workflow/mdtblc/queryUserWorkdayData.jsp create mode 100644 浙文眼镜/interface/zw/workflow/pblc/countUserWorkTime.jsp create mode 100644 浙文眼镜/interface/zw/workflow/pblc/getSchedulingDateType.jsp create mode 100644 浙文眼镜/interface/zw/workflow/pblc/queryMainSchedulingUserData.jsp create mode 100644 浙文眼镜/interface/zw/workflow/pblc/querySchedulingUserData.jsp create mode 100644 浙文眼镜/interface/zw/workflow/pblc/querySchedulingUserData2.jsp create mode 100644 浙文眼镜/interface/zw/workflow/pblc/queryUserTransferData.jsp create mode 100644 浙文眼镜/interface/zw/workflow/pblc/queryUserTransferData2.jsp create mode 100644 浙文眼镜/interface/zw/workflow/pblc/queryUserTransferData_test.jsp create mode 100644 浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayData.jsp create mode 100644 浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayData2.jsp create mode 100644 浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayData3.jsp create mode 100644 浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayData3_test.jsp create mode 100644 浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayData3_test2.jsp create mode 100644 浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayData3_test3.jsp create mode 100644 浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayData4.jsp create mode 100644 浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayDataByMonth2.jsp create mode 100644 浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayDataByMonth2bak.jsp create mode 100644 浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayDataByMonth3.jsp create mode 100644 浙文眼镜/interface/zw/workflow/pblc/testrs.jsp create mode 100644 浙文眼镜/interface/zw/workflow/pblc/testrs3.jsp create mode 100644 浙文眼镜/interface/zw/workflow/tblc/queryUserSerialByMonth.jsp create mode 100644 浙文眼镜/interface/zw/workflow/tblc/queryUserWorkdayDataByMonth.jsp create mode 100644 浙文眼镜/interface/zw/workflow/tblc/queryUserWorkdayDataByMonth_test.jsp create mode 100644 浙文眼镜/src/weaver/interfaces/zw/cron/EmployeeDataSnapshotCron.java create mode 100644 浙文眼镜/src/weaver/interfaces/zw/cron/EmployeeDataSnapshotDayCron.java create mode 100644 浙文眼镜/src/weaver/interfaces/zw/cron/EmployeeDataSnapshotMonthCron.java create mode 100644 浙文眼镜/src/weaver/interfaces/zw/cron/EmployeeTransferCron.java create mode 100644 浙文眼镜/src/weaver/interfaces/zw/utils/CommonUtil.java create mode 100755 浙文眼镜/src/weaver/interfaces/zw/workflow/action/Htpblc2SchedulingEditAction.java create mode 100755 浙文眼镜/src/weaver/interfaces/zw/workflow/action/Htpblc2SchedulingEditActionbak.java create mode 100755 浙文眼镜/src/weaver/interfaces/zw/workflow/action/Httblc2SchedulingEditAction.java create mode 100755 浙文眼镜/src/weaver/interfaces/zw/workflow/action/Mdpblc2SchedulingEditAction.java create mode 100755 浙文眼镜/src/weaver/interfaces/zw/workflow/action/Mdtblc2SchedulingEditAction.java create mode 100755 浙文眼镜/src/weaver/interfaces/zw/workflow/action/SchedulingDataCheckAction.java create mode 100755 浙文眼镜/src/weaver/interfaces/zw/workflow/action/WorkflowToSchedulingAction.java create mode 100755 浙文眼镜/src/weaver/interfaces/zw/workflow/action/WorkflowToSchedulingAddAction.java create mode 100755 浙文眼镜/src/weaver/interfaces/zw/workflow/action/WorkflowToSchedulingEditAction.java create mode 100755 浙文眼镜/src/weaver/interfaces/zw/workflow/action/WorkflowToSchedulingUpdateAction.java create mode 100755 浙文眼镜/src/weaver/interfaces/zw/workflow/xygrzlc/NewEmployee2HrmResoyeceAction.java diff --git a/浙文眼镜/interface/zw/do.jsp b/浙文眼镜/interface/zw/do.jsp new file mode 100644 index 0000000..75bbba6 --- /dev/null +++ b/浙文眼镜/interface/zw/do.jsp @@ -0,0 +1,1471 @@ +<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> +<%@page import="weaver.general.Util"%> +<%@ page import="java.math.BigDecimal" %> +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="com.engine.kq.util.KQDurationCalculatorUtil" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="java.text.SimpleDateFormat" %> +<%@ page import="java.text.ParseException" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="java.util.*" %> +<%@ page import="java.time.LocalDate" %> +<%@ page import="java.time.format.DateTimeFormatter" %> +<%@ page import="com.engine.kq.biz.KQWorkTime" %> +<%@ page import="com.engine.kq.entity.WorkTimeEntity" %> +<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %> +<%@ page import="com.engine.kq.entity.KQGroupEntity" %> + + + + +<% + int sum = 0; + String userid = Util.null2String(request.getParameter("userid")); + String fromdate = Util.null2String(request.getParameter("fromdate")); + String todate = Util.null2String(request.getParameter("todate")); + + User user = new User(Integer.parseInt(userid)); + + String username = user.getLastname(); + + rs.executeQuery("select groupid,sum(workdays)as workdays from kq_format_total " + + " where resourceid = ? and kqdate >= ? and kqdate <= ? group by groupid",userid,fromdate,todate); + rs.next(); + String workdays = Util.null2o(rs.getString("workdays")); + + //请假时长 + String leaveHours = getLeaveHours(fromdate,todate,userid); + + // 应出勤(排班)小时数 + String workhours = getWorkHours(fromdate,todate,userid); + + //月标准工时 + String standardWorkingHours = KQDurationCalculatorUtil.getDurationRound(String.valueOf(getStandardWorkingHours(fromdate, todate, userid))); + + //应计薪小时数 + String accruedPayHours = KQDurationCalculatorUtil.getDurationRound(String.valueOf(getAccruedPayHours(fromdate, todate, userid))); + + //国假排班小时(3倍) + String nationalHoliday3Hours = KQDurationCalculatorUtil.getDurationRound(String.valueOf(getNationalHoliday3Hours(fromdate, todate, userid))); + + //国假排班小时(2倍) + String nationalHoliday2Hours = KQDurationCalculatorUtil.getDurationRound(String.valueOf(getNationalHoliday2Hours(fromdate, todate, userid))); + + //国假在职小时数 + String nationalWorkingHours = KQDurationCalculatorUtil.getDurationRound(String.valueOf(getNationalWorkingHours(fromdate, todate, userid))); + + //补签卡次数 + String replaceCardNum = KQDurationCalculatorUtil.getDurationRound(String.valueOf(getReplaceCardNum(fromdate, todate, userid))); + + //迟到/早退(10分钟以内)/次 + String beLateLeaveEearly10 = KQDurationCalculatorUtil.getDurationRound(String.valueOf(getBeLateLeaveEearly10(fromdate, todate, userid))); + + //迟到/早退(10(含)-30分钟以内)/次 + String beLateLeaveEearly10To30 = KQDurationCalculatorUtil.getDurationRound(String.valueOf(getBeLateLeaveEearly10To30(fromdate, todate, userid))); + + //迟到/早退(30(含)-60分钟以内)/次 + String beLateLeaveEearly30To60 = KQDurationCalculatorUtil.getDurationRound(String.valueOf(getBeLateLeaveEearly30To60(fromdate, todate, userid))); + + //迟到/早退(60分钟以上)/次 + String beLateLeaveEearly60More = KQDurationCalculatorUtil.getDurationRound(String.valueOf(getBeLateLeaveEearly60More(fromdate,todate,userid))); + + //旷工合计小时 + String absenteeismTotalHours = KQDurationCalculatorUtil.getDurationRound(String.valueOf(getAbsenteeismTotalHours(fromdate,todate,userid))); + + //实际出勤小时数 + String actualAttendanceHours = KQDurationCalculatorUtil.getDurationRound(String.valueOf(getActualAttendanceHours(fromdate, todate, userid))); + + // 7:病假 6:事假 + String bjtypeid = "7"; + // 7:病假 6:事假 + String sjtypeid = "6"; + // 病假、事假 小时数 + String bjleavehours = getLeaveTypeHours(bjtypeid,fromdate,todate,userid); + + // 病假、事假 小时数 + String sjleavehours = getLeaveTypeHours(sjtypeid,fromdate,todate,userid); + + // 旷工小时数 + String absencehours = "0"; + // 漏签当天的排班时长之和 + String forgotserialhours = "0"; + rs1.executeQuery("select forgotcheck,forgotBeginWorkCheck,kqdate,absenteeismmins from kq_format_total where resourceid=? and kqdate >= ? and kqdate <= ? ",userid,fromdate,todate); + while(rs1.next()){ + String kqdate = Util.null2String(rs1.getString("kqdate")); + int forgotcheck1 = Util.getIntValue(rs1.getString("forgotcheck")); + int forgotBeginWorkCheck = Util.getIntValue(rs1.getString("forgotBeginWorkCheck")); + int forgotcheck = forgotcheck1 + forgotBeginWorkCheck; + // 旷工小时数 + String count1 = Util.null2o(rs1.getString("absenteeismmins")); + count1 = floatDivide(count1,"60"); + absencehours = floatAdd(absencehours,count1); + + // 当天有漏签 + if(forgotcheck > 0){ + // 漏签当天的排班时长之和 + String workhour = getWorkHours(kqdate,kqdate,userid); + workhour = floatMultiply(workhour,String.valueOf(forgotcheck)); + forgotserialhours = floatAdd(forgotserialhours,workhour); + } + } + + // 迟到分钟数 + double latemins = getLateMins(fromdate,userid); + + // 早退分钟数 + double leaveearlymins = getLeaveEarlyMins(fromdate,userid); + + KQWorkTime kqWorkTime = new KQWorkTime(); + WorkTimeEntity workTimeEntity = kqWorkTime.getWorkTime(userid, fromdate); + String searIdFrom = workTimeEntity.getSerialId(); + //第一个班段上班卡的 时间 + String oneStart = getBcTimes(searIdFrom,"start","0"); + oneStart += ":00"; + + //第一个班段下班卡的 时间 + String oneEnd = getBcTimes(searIdFrom,"end","0"); + oneEnd += ":00"; + + sum++; + +%> + +<%! + /** + * 获取 月标准工时 = 日历表上应出勤天数 * 8 + * @param fromDate + * @param toDate + * @param userid + * @return + */ + public static double getStandardWorkingHours(String fromDate, String toDate, String userid){ + RecordSet rs = new RecordSet(); + double result = 0.00; + int days = 0; + // 格式化日期 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + rs.executeQuery("select distinct groupid from kq_format_total " + + " where resourceid = ? and kqdate >= ? and kqdate <= ?",userid,fromDate,toDate); + rs.next(); +// String groupid = Util.null2String(rs.getString("groupid")); + + // 后台职能 考勤组id + String groupid = "5"; + + String[] dateStartArr = parseDate(fromDate); + String[] dateEndtArr = parseDate(toDate); + LocalDate startDate = LocalDate.of(Integer.parseInt(dateStartArr[0]), Integer.parseInt(dateStartArr[1]), Integer.parseInt(dateStartArr[2])); + LocalDate endDate = LocalDate.of(Integer.parseInt(dateEndtArr[0]), Integer.parseInt(dateEndtArr[1]), Integer.parseInt(dateEndtArr[2])); + // 遍历日期范围 + for (LocalDate date = startDate; !date.isAfter(endDate); date = date.plusDays(1)) { + // 输出格式化后的日期字符串 + String dateString = date.format(formatter); + // 是 周六或 周日 + if(isSaturdayOrSunday(dateString)) { + if(checkIsWorkday(groupid,dateString)){ + days++; + } + }else{ + if(!checkIsRestOrHoliday(groupid,dateString)){ + days++; + } + } + } + result = Double.valueOf(floatMultiply(String.valueOf(days),"8")); + return result; + } + + /** + * 获取 应计薪小时数 日历表上应出勤天数 * 8 + 法定(公众假日)天数 * 8 + * @param fromDate + * @param toDate + * @param userid + * @return + */ + public static String getAccruedPayHours(String fromDate, String toDate, String userid){ + String result = "0"; + RecordSet rs = new RecordSet(); + // + String attenddays = String.valueOf(getStandardWorkingHours(fromDate,toDate,userid)); + // + String publicHolidays = "0"; +// rs.executeQuery("select distinct groupid from kq_format_total " + +// " where resourceid = ? and kqdate >= ? and kqdate <= ?",userid,fromDate,toDate); +// while(rs.next()){ +// String groupid = Util.null2String(rs.getString("groupid")); + // 后台职能 考勤组id + String groupid = "5"; + // 法定(公众假日)天数 + publicHolidays = getPublicHolidays(fromDate,toDate,groupid); +// } + publicHolidays = floatMultiply(publicHolidays,"8"); + + result = floatAdd(attenddays,publicHolidays); + return result; + } + + /** + * 获取 国假排班小时(3倍) + * 【公众假日】的排班时长(小时数),且要扣减掉当前的请假时长; + * 如:10-01号,当前排班9小时,如果他当前请了2小时事假,统计后,则为:7小时,以此类推…… + * @param fromDate + * @param toDate + * @param userid + * @return + */ + public static double getNationalHoliday3Hours(String fromDate, String toDate, String userid){ + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + // 【公众假日】的排班时长(小时数) + String holidayHours = "0"; + // 【公众假日】的请假时长(小时数) + String leaveHours = "0"; + // 【公众假日】的矿工时长(小时数) + String absenseHours = "0"; + rs.executeQuery("select distinct groupid from kq_format_total " + + " where resourceid = ? and kqdate >= ? and kqdate <= ?",userid,fromDate,toDate); + rs.next(); + String groupid = Util.null2String(rs.getString("groupid")); + KQGroupMemberComInfo groupMemberComInfo = new KQGroupMemberComInfo(); + // 休息班 班次id + String rest_serial_id = rs.getPropValue("hrm_zhewen","rest_serial_id"); + rs1.executeQuery("select * from KQ_HolidaySet where holidayDate between ? and ? and changeType=1 and groupid = ?",fromDate,toDate,groupid); + while(rs1.next()){ + String holidayDate = Util.null2String(rs1.getString("holidayDate")); + String holiday_serialid = getSerialId(holidayDate,holidayDate,userid); + if(holiday_serialid != null && !"".equals(holiday_serialid)){ + // 非休息班次 + if(!rest_serial_id.equals(holiday_serialid)) { + KQGroupEntity kqGroupEntity = groupMemberComInfo.getUserKQGroupInfo(userid,holidayDate); + if(kqGroupEntity!=null) { + String kqtype = kqGroupEntity.getKqtype(); + //排班制 + if ("2".equals(kqtype)) { + String holiday_hours = getHoursBySerial(holiday_serialid); + holidayHours = floatAdd(holidayHours, holiday_hours); + + String leave_hour = getLeaveHours(holidayDate, holidayDate, userid); + leaveHours = floatAdd(leaveHours, leave_hour); + + String absense_hour = getAbsenteeishours(holidayDate, holidayDate, userid); + absenseHours = floatAdd(absenseHours, absense_hour); + } + } + } + } + } + String result = floatSubtract(floatSubtract(holidayHours,leaveHours),absenseHours); + if(floatCompare(result,"0") == -1){ + result = "0"; + } + return Double.valueOf(result); + } + + /** + * 获取 旷工 时长 + * @param fromdate + * @param todate + * @param userid + * @return + */ + public static String getAbsenteeishours(String fromdate, String todate,String userid){ + String result = "0"; + RecordSet rs = new RecordSet(); + rs.executeQuery("select sum(absenteeismmins) as count from kq_format_total "+ + " where resourceid = ? and kqdate >= ? and kqdate <= ? ",userid,fromdate,todate); + while(rs.next()){ + String count = Util.null2o(rs.getString("count")); + result = floatDivide(count,"60"); + } + return result; + } + + /** + * 获取 国假排班小时(2倍) + * 节假日设置的说明是这俩字【春节】,并且是【调配休息日】排班时长(小时数),且要扣减掉当前的请假时长; + * 扣减逻辑同上;只是这个只有春节期间才会统计出来。 + * 如:除开初一初二初三,剩下的休息天数(只有春节有这个加班) + * @param fromDate + * @param toDate + * @param userid + * @return + */ + public static double getNationalHoliday2Hours(String fromDate, String toDate, String userid){ + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + // 【公众假日,调配休息日】,假日设置的说明是这俩字【春节】,的排班时长(小时数) + String AdjustRestHours = "0"; + // 【公众假日】的请假时长(小时数) + String leaveHours = "0"; + // 【公众假日】的矿工时长(小时数) + String absenseHours = "0"; + KQGroupMemberComInfo groupMemberComInfo = new KQGroupMemberComInfo(); + rs.executeQuery("select distinct groupid from kq_format_total " + + " where resourceid = ? and kqdate >= ? and kqdate <= ?",userid,fromDate,toDate); + rs.next(); + String groupid = Util.null2String(rs.getString("groupid")); + // 休息班 班次id + String rest_serial_id = rs.getPropValue("hrm_zhewen","rest_serial_id"); + rs1.executeQuery("select * from KQ_HolidaySet where holidayDate between ? and ? and changeType=3 and holidayDesc like '%春节%' and groupid = ?",fromDate,toDate,groupid); + while(rs1.next()){ + String adjustrestDate = Util.null2String(rs1.getString("holidayDate")); + String adjustrest_serialid = getSerialId(adjustrestDate,adjustrestDate,userid); + if(adjustrest_serialid != null && !"".equals(adjustrest_serialid)){ + // 非休息班次 + if(!rest_serial_id.equals(adjustrest_serialid)) { + KQGroupEntity kqGroupEntity = groupMemberComInfo.getUserKQGroupInfo(userid,adjustrestDate); + if(kqGroupEntity!=null) { + String kqtype = kqGroupEntity.getKqtype(); + //排班制 + if ("2".equals(kqtype)) { + String adjustrest_hours = getHoursBySerial(adjustrest_serialid); + AdjustRestHours = floatAdd(AdjustRestHours, adjustrest_hours); + + String leave_hour = getLeaveHours(adjustrestDate, adjustrestDate, userid); + leaveHours = floatAdd(leaveHours, leave_hour); + + String absense_hour = getAbsenteeishours(adjustrestDate, adjustrestDate, userid); + absenseHours = floatAdd(absenseHours, absense_hour); + } + } + } + } + } + String result = floatSubtract(floatSubtract(AdjustRestHours,leaveHours),absenseHours); + if(floatCompare(result,"0") == -1){ + result = "0"; + } + return Double.valueOf(result); + } + + /** + * 获取 国假在职小时数 = 【公众假日】的天数 * 8小时 + * @param fromDate + * @param toDate + * @param userid + * @return + */ + public static double getNationalWorkingHours(String fromDate, String toDate, String userid){ + double result = 0.00; + RecordSet rs = new RecordSet(); + // 入职日期 + String companystartdate = getCompanyStartDate(userid); + // 离职日期 + String terminationdate = getTerminationDate(userid); + //入职日期在开始和结束之间 + if(belongStartCalendar(companystartdate,fromDate,toDate)){ + fromDate = companystartdate; + } + //离职日期在开始和结束之间 + if(belongStartCalendar(terminationdate,fromDate,toDate)){ + toDate = terminationdate; + } + rs.executeQuery("select distinct groupid from kq_format_total " + + " where resourceid = ? and kqdate >= ? and kqdate <= ?",userid,fromDate,toDate); + while(rs.next()){ + String groupid = Util.null2String(rs.getString("groupid")); + // 法定(公众假日)天数 + String publicHolidays = getPublicHolidays(fromDate,toDate,groupid); + String hours = floatMultiply(publicHolidays,"8"); + result = Double.valueOf(hours); + } + return result; + } + + /** + * 获取 离职日期 + * @param userid + * @return + */ + public static String getTerminationDate(String userid){ + String result = ""; + RecordSet rs = new RecordSet(); + rs.executeQuery("select enddate from hrmresource where id=?",userid); + while(rs.next()){ + result = Util.null2String(rs.getString("enddate")); + } + return result; + } + + /** + * 获取 补签卡次数 + * 系统提取《补卡流程》的明细数据,一行表示一次,流程中增加控制:只能补3天以内(含3天自然日)的异常考勤 + * (新员工入职30天以内不扣) + * @param fromDate + * @param toDate + * @param userid + * @return + */ + public static double getReplaceCardNum(String fromDate, String toDate, String userid){ + double result = 0.00; + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + String tablename = rs.getPropValue("hrm_zhewen","replacecard_tablename"); + String detailtable = tablename + "_dt1"; + // 入职日期 + String companystartdate = getCompanyStartDate(userid); + // 入职30天后的日期 + String company30date = addDateDay(companystartdate,30); + try { + + //入职30天后的日期 在 统计月份第一天 和 最后一天 之间 + if(belongStartCalendar(company30date,fromDate,toDate)){ + rs.executeQuery("select count(b.id)as count from "+tablename+" a," + detailtable + " b,workflow_requestbase c where a.id=b.mainid and a.requestid=c.requestid and c.currentnodetype='3' and a.resourceId=? and b.detail_signdate >= ? and b.detail_signdate <= ?", userid, company30date, toDate); + rs.next(); + result = Util.getDoubleValue(rs.getString("count"),0.00); + } + //入职30天后的日期 小于 统计月份第一天 + else if(compareDateTime(fromDate,company30date)){ + rs.executeQuery("select count(b.id)as count from "+tablename+" a," + detailtable + " b,workflow_requestbase c where a.id=b.mainid and a.requestid=c.requestid and c.currentnodetype='3' and a.resourceId=? and b.detail_signdate >= ? and b.detail_signdate <= ?", userid, fromDate, toDate); + rs.next(); + result = Util.getDoubleValue(rs.getString("count"),0.00); + }else if(compareDateTime(company30date,toDate)){ + result = 0.00; + } + + if(result < 0){ + result = 0.00; + } + }catch (Exception e){ + e.printStackTrace(); + } + return result; + } + + /** + * 获取 迟到/早退(10分钟以内)/次 + * @param fromDate + * @param toDate + * @param userid + * @return + */ + public static double getBeLateLeaveEearly10(String fromDate, String toDate, String userid){ + double result = 0.00; + RecordSet rs = new RecordSet(); + // 入职日期 + String companystartdate = getCompanyStartDate(userid); + // 入职30天后的日期 + String company30date = addDateDay(companystartdate,30); + try{ + rs.executeQuery("select forgotcheck,kqdate from kq_format_total where resourceid=? and kqdate >= ? and kqdate <= ?",userid,fromDate,toDate); + while(rs.next()){ + String kqdate = Util.null2String(rs.getString("kqdate")); + int forgotcheck = Util.getIntValue(rs.getString("forgotcheck"),0); + // 迟到分钟数 + double count_late = getLateMins(kqdate,userid); + // 早退分钟数 + double count_leaveearly = getLeaveEarlyMins(kqdate,userid); + //不在 新入职员工 30天内,需要累计 + if(!belongStartCalendar(kqdate,companystartdate,company30date)){ + // 当天没有漏签 + if(forgotcheck == 0){ + if(0 < count_late && count_late < 10){ + result ++; + } + if(0 < count_leaveearly && count_leaveearly < 10){ + result ++; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + rs.writeLog(e); + } + + return result; + } + + /** + * 获取 迟到/早退(10(含)-30分钟以内)/次 + * @param fromDate + * @param toDate + * @param userid + * @return + */ + public static double getBeLateLeaveEearly10To30(String fromDate, String toDate, String userid){ + double result = 0.00; + RecordSet rs = new RecordSet(); + // 入职日期 + String companystartdate = getCompanyStartDate(userid); + // 入职30天后的日期 + String company30date = addDateDay(companystartdate,30); + try{ + rs.executeQuery("select forgotcheck,kqdate from kq_format_total where resourceid=? and kqdate >= ? and kqdate <= ?",userid,fromDate,toDate); + while(rs.next()){ + String kqdate = Util.null2String(rs.getString("kqdate")); + int forgotcheck = Util.getIntValue(rs.getString("forgotcheck")); + // 迟到分钟数 + double count_late = getLateMins(kqdate,userid); + // 早退分钟数 + double count_leaveearly = getLeaveEarlyMins(kqdate,userid); + //不在 新入职员工 30天内,需要累计 + if(!belongStartCalendar(kqdate,companystartdate,company30date)){ + // 当天没有漏签 + if(forgotcheck == 0){ + if(10 <= count_late && count_late < 30){ + result ++; + } + if(10 <= count_leaveearly && count_leaveearly < 30){ + result ++; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + rs.writeLog(e); + } + + + return result; + } + + /** + * 获取 迟到/早退(30(含)-60分钟以内)/次 + * @param fromDate + * @param toDate + * @param userid + * @return + */ + public static double getBeLateLeaveEearly30To60(String fromDate, String toDate, String userid){ + double result = 0.00; + RecordSet rs = new RecordSet(); + // 入职日期 + String companystartdate = getCompanyStartDate(userid); + // 入职30天后的日期 + String company30date = addDateDay(companystartdate,30); + try{ + rs.executeQuery("select forgotcheck,kqdate from kq_format_total where resourceid=? and kqdate >= ? and kqdate <= ? ",userid,fromDate,toDate); + while(rs.next()){ + String kqdate = Util.null2String(rs.getString("kqdate")); + int forgotcheck = Util.getIntValue(rs.getString("forgotcheck")); + // 迟到分钟数 + double count_late = getLateMins(kqdate,userid); + // 早退分钟数 + double count_leaveearly = getLeaveEarlyMins(kqdate,userid); + //不在 新入职员工 30天内,需要累计 + if(!belongStartCalendar(kqdate,companystartdate,company30date)){ + // 当天没有漏签 + if(forgotcheck == 0){ + if(30 <= count_late && count_late < 60){ + result ++; + } + if(30 <= count_leaveearly && count_leaveearly < 60){ + result ++; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + rs.writeLog(e); + } + return result; + } + + /** + * 获取 迟到/早退(60分钟以上)/次 + * @param fromDate + * @param toDate + * @param userid + * @return + */ + public static double getBeLateLeaveEearly60More(String fromDate, String toDate, String userid){ + double result = 0.00; + RecordSet rs = new RecordSet(); + // 入职日期 + String companystartdate = getCompanyStartDate(userid); + // 入职30天后的日期 + String company30date = addDateDay(companystartdate,30); + try{ + rs.executeQuery("select forgotcheck,kqdate from kq_format_total where resourceid=? and kqdate >= ? and kqdate <= ? ",userid,fromDate,toDate); + while(rs.next()){ + String kqdate = Util.null2String(rs.getString("kqdate")); + int forgotcheck = Util.getIntValue(rs.getString("forgotcheck")); + // 迟到分钟数 + double count_late = getLateMins(kqdate,userid); + // 早退分钟数 + double count_leaveearly = getLeaveEarlyMins(kqdate,userid); + //不在 新入职员工 30天内,需要累计 + if(!belongStartCalendar(kqdate,companystartdate,company30date)){ + // 当天没有漏签 + if(forgotcheck == 0){ + if(count_late >= 60){ + result ++; + } + if(count_leaveearly >= 60){ + result ++; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + rs.writeLog(e); + } + return result; + } + + /** + * 获取 旷工合计小时数 = 旷工小时数 + 漏签当天的排班时长之和 + 迟到/早退(60分钟以上)/次*4小时计 + * @param fromDate + * @param toDate + * @param userid + * @return + */ + public static double getAbsenteeismTotalHours(String fromDate, String toDate, String userid){ + double result = 0.00; + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + // 入职日期 + String companystartdate = getCompanyStartDate(userid); + // 入职30天后的日期 + String company30date = addDateDay(companystartdate,30); + try{ + +// rs.executeQuery("select belate as count from kq_format_total where resourceid=? and kqdate >= ? and kqdate <= ? and belatemins >= 60",userid,fromDate,toDate); +// while(rs.next()){ +// String kqdate = Util.null2String(rs.getString("kqdate")); +// //不在 新入职员工 30天内,需要累计 +// if(!belongStartCalendar(kqdate,companystartdate,company30date)){ +// // 迟到/早退(60分钟以上)/次 * 4小时计 +// double countt = Util.getDoubleValue(rs.getString("count"),0.00); +// countt = Double.valueOf(floatMultiply(String.valueOf(countt),"4")); +// result += countt; +// } +// } + + // 迟到/早退(60分钟以上)/次 * 4小时计 + double lateMins = getBeLateLeaveEearly60More(fromDate,toDate,userid); + double countt = Double.valueOf(floatMultiply(String.valueOf(lateMins),"4")); + result += countt; + + rs1.executeQuery("select forgotcheck,forgotBeginWorkCheck,kqdate,absenteeismmins from kq_format_total where resourceid=? and kqdate >= ? and kqdate <= ? ",userid,fromDate,toDate); + while(rs1.next()){ + String kqdate = Util.null2String(rs1.getString("kqdate")); + int forgotcheck1 = Util.getIntValue(rs1.getString("forgotcheck")); + int forgotBeginWorkCheck = Util.getIntValue(rs1.getString("forgotBeginWorkCheck")); + int forgotcheck = forgotcheck1 + forgotBeginWorkCheck; + // 旷工小时数 + double count1 = Util.getDoubleValue(rs1.getString("absenteeismmins"),0.00); + count1 = Double.valueOf(floatDivide(String.valueOf(count1),"60")); + result += count1; + + // 当天有漏签 + if(forgotcheck > 0){ + // 漏签当天的排班时长之和 + String workhour = getWorkHours(kqdate,kqdate,userid); + workhour = floatMultiply(workhour,String.valueOf(forgotcheck)); + result += Double.valueOf(workhour); + } + } + }catch (Exception e){ + e.printStackTrace(); + rs.writeLog(e); + } + return result; + } + + /** + * 实际出勤小时数 = 排班表总时间-病假小时-事假小时-旷工小时数-漏签旷工小时数 + * + * -漏签旷工小时数 这个待确定是否 去除 2024-12-24 + * + * @param fromDate + * @param toDate + * @param userid + * @return + */ + public static double getActualAttendanceHours(String fromDate, String toDate, String userid){ + double result = 0.00; + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + // 应出勤(排班)小时数 + String workhours = getWorkHours(fromDate,toDate,userid); + // 7:病假 6:事假 + String typeid = "7,6"; + // 病假、事假 小时数 + String leavehours = getLeaveTypeHours(typeid,fromDate,toDate,userid); + // 旷工小时数 + String absencehours = "0"; + // 漏签当天的排班时长之和 + String forgotserialhours = "0"; + rs1.executeQuery("select forgotcheck,forgotBeginWorkCheck,kqdate,absenteeismmins from kq_format_total where resourceid=? and kqdate >= ? and kqdate <= ? ",userid,fromDate,toDate); + while(rs1.next()){ + String kqdate = Util.null2String(rs1.getString("kqdate")); + int forgotcheck1 = Util.getIntValue(rs1.getString("forgotcheck")); + int forgotBeginWorkCheck = Util.getIntValue(rs1.getString("forgotBeginWorkCheck")); + int forgotcheck = forgotcheck1 + forgotBeginWorkCheck; + // 旷工小时数 + String count1 = Util.null2o(rs1.getString("absenteeismmins")); + count1 = floatDivide(count1,"60"); + absencehours = floatAdd(absencehours,count1); + + // 当天有漏签 + if(forgotcheck > 0){ + // 漏签当天的排班时长之和 + String workhour = getWorkHours(kqdate,kqdate,userid); + workhour = floatMultiply(workhour,String.valueOf(forgotcheck)); + forgotserialhours = floatAdd(forgotserialhours,workhour); + } + } + result = Double.valueOf(floatSubtract(workhours,floatAdd(leavehours,floatAdd(absencehours,forgotserialhours)))); + if(result < 0 ){ + result = 0.00; + } + return result; + } + + /** + * 获取 请假 时长 + * @param fromDate + * @param toDate + * @param userid + * @return + */ + public static String getLeaveTypeHours(String typeid,String fromDate, String toDate,String userid){ + String result = "0"; + RecordSet rs = new RecordSet(); + String serialid = getSerialId(fromDate,toDate,userid); + String serial_hours = getHoursBySerial(serialid); + rs.executeQuery("select SUM(duration)as count,durationrule,resourceid,newleavetype from kq_flow_split_leave where 1=1 and newleavetype in ("+typeid+") and belongdate >= '"+fromDate+"' and belongdate <= '"+toDate+"' and resourceid = ? group by durationrule,resourceid,newleavetype ",userid); + while(rs.next()){ + String count = Util.null2o(rs.getString("count")); + // 1-按天请假、2-按半天请假、3-按小时请假、4-按整天请假、5-按半小时请假、6-按整小时请假 + int durationrule = Util.getIntValue(rs.getString("durationrule")); + // 请假类型 + int leavetype = Util.getIntValue(rs.getString("newleavetype")); + // 按天,需要 乘以 每天的班次的小时 + if(durationrule == 1 || durationrule == 2 || durationrule == 4){ + // 其中,2-年假、8-产假、9-陪产假、10-婚假、11-丧假,一天按8小时计算扣减; + if(leavetype == 2 || leavetype == 8 || leavetype == 9 || leavetype == 10 || leavetype == 11){ + result = floatMultiply(count,"8"); + }else{ + result = floatMultiply(count,serial_hours); + } + } + // 按小时 + if(durationrule == 3 || durationrule == 5 || durationrule == 6){ + result = count; + } + } + return result; + } + + + /** + * 获取 应出勤时长 = 排班时长 + * @param fromDate + * @param toDate + * @param userid + * @return + */ + public static String getWorkHours(String fromDate,String toDate,String userid){ + String result = "0"; + RecordSet rs = new RecordSet(); + rs.executeQuery("select sum(workmins)as mins from kq_format_total "+ + " where resourceid = ? and kqdate >= ? and kqdate <= ?",userid,fromDate,toDate); + rs.next(); + String count1 = Util.null2o(rs.getString("mins")); + result = floatDivide(count1,"60"); + return result; + } + + /** + * + * 方法描述 : 对两个字符串进行金额的相乘 + * @param a + * @param b + * @return + * String + */ + public static String floatMultiply(String a, String b) { + a=a.equals("")?"0":a; + b=b.equals("")?"0":b; + BigDecimal bg1 = new BigDecimal(a); + BigDecimal bg2 = new BigDecimal(b); + BigDecimal bd = bg1.multiply(bg2).setScale(4, BigDecimal.ROUND_HALF_UP); + return bd.toString(); + } + + /** + * + * 方法描述 : 对两个字符串进行金额的相除(默认保留两位小数) + * @param a + * @param b + * @return + * String + */ + public static String floatDivide(String a, String b) { + a=a.equals("")?"0":a; + b=b.equals("")?"0":b; + BigDecimal bg1 = new BigDecimal(a); + BigDecimal bg2 = new BigDecimal(b); + BigDecimal bd = bg1.divide(bg2, 2, BigDecimal.ROUND_HALF_UP); + return bd.toString(); + } + + /** + * 获取 班次id + * @param fromDate + * @param toDate + * @param userid + * @return + */ + public static String getSerialId(String fromDate, String toDate,String userid){ + String result = ""; + RecordSet rs = new RecordSet(); + rs.executeQuery("select distinct serialid from kq_format_total " + + " where resourceid = ? and kqdate >= ? and kqdate <= ?",userid,fromDate,toDate); + while(rs.next()){ + result = Util.null2String(rs.getString("serialid")); + } + return result; + } + + /** + * 获取班次对应的工作时长 分钟数 转换为 小时 + * @param serialid + * @return + */ + public static String getHoursBySerial(String serialid){ + String result = "0"; + RecordSet rs = new RecordSet(); + rs.executeQuery("select * from kq_ShiftManagement where id=?",serialid); + if(rs.next()) { + String worktime = Util.null2o(rs.getString("worktime")); + result = floatDivide(worktime,"60"); + } + return result; + } + + /** + * 获取 法定(公众假日)天数 + * @param fromDate + * @param toDate + * @param groupid + * @return + */ + public static String getPublicHolidays(String fromDate, String toDate,String groupid){ + String result = "0"; + RecordSet rs = new RecordSet(); + rs.executeQuery("select COUNT(id)as count from KQ_HolidaySet where holidayDate between ? and ? and changeType=1 and groupid = ?",fromDate,toDate,groupid); + while(rs.next()){ + result = Util.null2o(rs.getString("count")); + } + return result; + } + + /** + * 获取 请假 时长 + * @param fromDate + * @param toDate + * @param userid + * @return + */ + public static String getLeaveHours(String fromDate, String toDate,String userid){ + String result = "0"; + RecordSet rs = new RecordSet(); + String serialid = getSerialId(fromDate,toDate,userid); + String serial_hours = getHoursBySerial(serialid); + rs.executeQuery("select SUM(duration)as count,durationrule,resourceid from kq_flow_split_leave where 1=1 and belongdate between ? and ? and resourceid = ? group by durationrule,resourceid",fromDate,toDate,userid); + while(rs.next()){ + String count = Util.null2o(rs.getString("count")); + // 1-按天请假、2-按半天请假、3-按小时请假、4-按整天请假、5-按半小时请假、6-按整小时请假 + int durationrule = Util.getIntValue(rs.getString("durationrule")); + // 按天,需要 乘以 每天的班次的小时 + if(durationrule == 1 || durationrule == 2 || durationrule == 4){ + result = floatMultiply(count,serial_hours); + }else{ +// // 按小时 +// if(durationrule == 3){ + result = count; + } + } + return result; + } + + /** + * @param a 任意数 + * @return 是 + */ + private static String isZero(String a) { + if (a==null || "".equals(a)) { + a = "0"; + } + return a; + } + + /** + * 大小比较 + * + * @param a + * @param b + * @return -1 小于 0 等于 1 大于 + */ + public static int floatCompare(String a, String b) { + a = isZero(a); + b = isZero(b); + BigDecimal bg1 = new BigDecimal(a); + BigDecimal bg2 = new BigDecimal(b); + return bg1.compareTo(bg2); + } + + /** + * 方法描述 : 对两个字符串进行金额的相加 + * @param a + * @param b + * @return + * String + */ + public static String floatAdd(String a, String b) { + a=a.equals("")?"0":a; + b=b.equals("")?"0":b; + BigDecimal bg1 = new BigDecimal(a); + BigDecimal bg2 = new BigDecimal(b); + BigDecimal bd = bg1.add(bg2); + return bd.toString(); + } + + /** + * + * 方法描述 : 对两个字符串进行金额的相减 + * @param a + * @param b + * @return + * String + */ + public static String floatSubtract(String a, String b) { + a=a.equals("")?"0":a; + b=b.equals("")?"0":b; + BigDecimal bg1 = new BigDecimal(a); + BigDecimal bg2 = new BigDecimal(b); + BigDecimal bd = bg1.subtract(bg2); + return bd.toString(); + } + + /** + * 获取 入职日期 + * @param userid + * @return + */ + public static String getCompanyStartDate(String userid){ + String result = ""; + RecordSet rs = new RecordSet(); + rs.executeQuery("select companystartdate from hrmresource where id=?",userid); + while(rs.next()){ + result = Util.null2String(rs.getString("companystartdate")); + } + return result; + } + + /** + * 对时间的天数进行加减 + * @param daytime 时间的格式:yyyy-MM-dd HH:mm:ss + * @param day 天数 -1则代表减一天 + * @return + */ + public static String addDateDay(String daytime, int day){ + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + Date date = null; + try { + date = format.parse(daytime); + if (date == null){ + return ""; + } + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + cal.add(Calendar.DAY_OF_MONTH, day);// 加一天 + date = cal.getTime(); + cal = null; + return format.format(date); + } catch (Exception ex) { + ex.printStackTrace(); + } + return ""; + } + + /** + * 计算两个时间字符串日期的相差天数 + * + * @param date1 字符串时间1 + * @param date2 字符串时间2 + * @return 相差时间 + */ + public static int getDays(String date1, String date2) { + if (!"".equals(date1) && !"".equals(date2)) { + String date1Arr[] = date1.split("-"); + String date2Arr[] = date2.split("-"); + Calendar cal1 = Calendar.getInstance(); + cal1.set(Integer.parseInt(date1Arr[0]), Integer.parseInt(date1Arr[1]) - 1, Integer.parseInt(date1Arr[2])); + Date date1Obj = cal1.getTime(); + Calendar cal2 = Calendar.getInstance(); + cal2.set(Integer.parseInt(date2Arr[0]), Integer.parseInt(date2Arr[1]) - 1, Integer.parseInt(date2Arr[2])); + Date date2Obj = cal2.getTime(); + return calculateDays(date1Obj, date2Obj); + } + return 0; + } + + /** + * 计算天数 + * @param date1 日期 + * @param date2 日期 + * @return 天数 + */ + public static int calculateDays(Date date1, Date date2) { + Calendar cal1 = Calendar.getInstance(); + cal1.setTime(date1); + Calendar cal2 = Calendar.getInstance(); + cal2.setTime(date2); + int day1 = cal1.get(Calendar.DAY_OF_YEAR); + int day2 = cal2.get(Calendar.DAY_OF_YEAR); + int year1 = cal1.get(Calendar.YEAR); + int year2 = cal2.get(Calendar.YEAR); + if (year1 != year2) {//不同 年 + int timeDistance = 0; + if (year1 < year2) {//后面日期年大于前面日期 + for (int i = year1; i < year2; i++) { + if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0) {//闰年 + timeDistance += 366; + } else {//不是闰年 + timeDistance += 365; + } + } + } else { + for (int i = year2; i < year1; i++) { + if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0) {//闰年 + timeDistance += 366; + } else {//不是闰年 + timeDistance += 365; + timeDistance = 0 - timeDistance; + } + } + } + return timeDistance + (day2 - day1); + } else {//同一年 + return day2 - day1; + } + } + + /** + * 判断 日期是否是 周六 或 周日 + * @param dateString + * @return + */ + public static boolean isSaturdayOrSunday(String dateString) { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + Date date = null; + boolean flag = false; + try { + date = format.parse(dateString); + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK); + if(dayOfWeek == Calendar.SATURDAY || dayOfWeek == Calendar.SUNDAY){ + flag = true; + } + } catch (ParseException e) { + e.printStackTrace(); + } + return flag; + } + + /** + * 判断 是否是 调配休息日或者是 公众假日 + * @param dateString + * @return + */ + public static boolean checkIsRestOrHoliday(String groupid,String dateString){ + boolean bool = false; + RecordSet rs = new RecordSet(); + rs.executeQuery("select id,changeType from KQ_HolidaySet where groupId=? and holidayDate=?",groupid,dateString); + if(rs.next()){ + int changeType = Util.getIntValue(rs.getString("changeType")); + // 1-公众假日 2-调配工作日 3-调配休息日 + if(changeType == 1 || changeType == 3){ + bool = true; + } + } + return bool; + } + + /** + * 判断 是否是 调配工作日 + * @param dateString + * @return + */ + public static boolean checkIsWorkday(String groupid,String dateString){ + boolean bool = false; + RecordSet rs = new RecordSet(); + rs.executeQuery("select id,changeType from KQ_HolidaySet where groupId=? and holidayDate=?",groupid,dateString); + if(rs.next()){ + int changeType = Util.getIntValue(rs.getString("changeType")); + // 1-公众假日 2-调配工作日 3-调配休息日 + if(changeType == 2){ + bool = true; + } + } + return bool; + } + + private static String[] parseDate(String date){ + if (StringUtils.isEmpty(date)) { + return new String[]{"1990", "1", "1"}; + } + try { + String[] split = date.split("-"); + List list = new ArrayList<>(Arrays.asList(split)); + // 只有年 + if (list.size() == 1) { + // 添加月 + list.add("1"); + // 添加日 + list.add("1"); + + } + // 只有年月 + else if (list.size() == 2) { + list.add("1"); + } + return list.toArray(new String[]{}); + }catch (Exception e){ + e.printStackTrace(); + } + return null; + } + + /** + * 获取 迟到分钟数 + * @param fromDate + * @param userId + * @return + */ + public static double getLateMins(String fromDate,String userId){ + double result = 0.00; + RecordSet rs = new RecordSet(); + KQWorkTime kqWorkTime = new KQWorkTime(); + WorkTimeEntity workTimeEntity = kqWorkTime.getWorkTime(userId, fromDate); + String searIdFrom = workTimeEntity.getSerialId(); + //第一个班段上班卡的 时间 + String oneStart = getBcTimes(searIdFrom,"start","0"); + oneStart += ":00"; + + //休息开始时间 + String restStart = getRestTime(searIdFrom,"start"); + restStart += ":00"; + //休息结束时间 + String restEnd = getRestTime(searIdFrom,"end"); + restEnd += ":00"; + + //当天没有 公出 + if(!checkHasOut(userId,fromDate)) { + // 当天 有迟到 + if(checkHasLate(userId,fromDate)) { + rs.executeQuery("select signintime from kq_format_detail where resourceid = ? and kqdate = ?", userId, fromDate); + if (rs.next()) { + String signtime = Util.null2String(rs.getString("signintime")); + signtime += ":00"; + //上班打卡时间 大于等于 休息结束时间 + if(compareDateTime(fromDate+" "+signtime,fromDate+" "+restEnd)){ + double oneTimes = getBetwwenMins(oneStart,restStart); + double twoTimes = getBetwwenMins(restEnd,signtime); + result = oneTimes + twoTimes; + }else{ + // 上班打卡时间 大于等于 休息开始时间 + if(compareDateTime(fromDate+""+signtime,fromDate+" "+restStart)){ + double oneTimes = getBetwwenMins(oneStart,restStart); + result = oneTimes; + }else{ + double oneTimes = getBetwwenMins(oneStart,signtime); + result = oneTimes; + } + } + } + } + } + return result; + } + + /** + * 获取 早退分钟数 + * @param fromDate + * @param userId + * @return + */ + public static double getLeaveEarlyMins(String fromDate,String userId){ + double result = 0.00; + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + KQWorkTime kqWorkTime = new KQWorkTime(); + WorkTimeEntity workTimeEntity = kqWorkTime.getWorkTime(userId, fromDate); + String searIdFrom = workTimeEntity.getSerialId(); + //第一个班段下班卡的 时间 + String oneEnd = getBcTimes(searIdFrom,"end","0"); + oneEnd += ":00"; + + //休息开始时间 + String restStart = getRestTime(searIdFrom,"start"); + restStart += ":00"; + //休息结束时间 + String restEnd = getRestTime(searIdFrom,"end"); + restEnd += ":00"; + + // 当天没公出 + if(!checkHasOut(userId,fromDate)) { + // 当天有早退 + if(checkHasLeaveEarly(userId,fromDate)) { + rs.executeQuery("select signouttime from kq_format_detail where resourceid = ? and kqdate = ? ", userId, fromDate); + if (rs.next()) { + String signtime = Util.null2String(rs.getString("signouttime")); + signtime += ":00"; + //下班打卡时间 小于 休息开始时间 + if(compareDateTime(fromDate+" "+restStart,fromDate+" "+signtime)){ + double oneTimes = getBetwwenMins(signtime,restStart); + double twoTimes = getBetwwenMins(restEnd,oneEnd); + result = oneTimes + twoTimes; + }else{ + //下班打卡时间在 休息开始和结束之间 + if(compareDateTime(fromDate+" "+restEnd,fromDate+" "+signtime)){ + double twoTimes = getBetwwenMins(restEnd,oneEnd); + result = twoTimes; + }else{ + double twoTimes = getBetwwenMins(signtime,oneEnd); + result = twoTimes; + } + } + + } + } + } + return result; + } + + /** + * 给时间加上几个小时 + * @param day 时间的格式:HH:mm:ss + * @param hour 需要加的小时数 -1 则代表减1小时 + * @return + */ + public static String addDateHour(String day, int hour){ + SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss"); + Date date = null; + try { + date = format.parse(day); + if (date == null){ + return ""; + } + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + cal.add(Calendar.HOUR, hour);// 24小时制 + date = cal.getTime(); + cal = null; + return format.format(date); + } catch (Exception ex) { + ex.printStackTrace(); + } + return ""; + } + + /** + * 两个时间段相差分钟数 + * @param time1 + * @param time2 + * @return + */ + public static double getBetwwenMins(String time1,String time2){ + SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); + double result = 0; + try { + Date date1 = dateFormat.parse(time1); + Date date2 = dateFormat.parse(time2); + + long diff = date2.getTime() - date1.getTime(); + double diffMinutes = (double)diff / (60*1000); + + result = diffMinutes; + } catch (Exception e) { + e.printStackTrace(); + } + return result; + } + + /** + * 获取班次上班时段 + * @param serial + * @param status + * @param record + * @return times 00:00 + */ + private static String getBcTimes(String serial,String status,String record){ + RecordSet rs = new RecordSet(); + String sql = "select times from kq_ShiftOnOffWorkSections where serialid = "+serial+" and (isdelete is null or isdelete <> '1') and onoffworktype = '"+status+"' and record = "+record; + rs.execute(sql); + String times = ""; + if (rs.next()){ + times = Util.null2String(rs.getString("times")); + } + return times; + } + + /** + * 判断一个时间是否在一个时间段内 + * + * @param nowTimee 指定时间 + * @param beginTimee 开始时间 + * @param endTimee 结束时间 + */ + public static boolean belongStartCalendar(String nowTimee, String beginTimee, String endTimee) { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + Date nowTime = null; + Date beginTime = null; + Date endTime = null; + boolean b = false; + try { + nowTime = format.parse(nowTimee); + beginTime = format.parse(beginTimee); + endTime = format.parse(endTimee); + + Calendar date = Calendar.getInstance(); + date.setTime(nowTime); + Calendar begin = Calendar.getInstance(); + begin.setTime(beginTime); + Calendar end = Calendar.getInstance(); + end.setTime(endTime); + + if(nowTimee.equals(beginTimee)){ + b = true; + }else if(date.after(begin) && date.before(end)){//在时间段内 + b = true; + } + } catch (Exception ex) { + ex.printStackTrace(); + } + return b; + } + + /** + * 判断 当天 是否有 公出 + * @param userid + * @param date + * @return + */ + public static boolean checkHasOut(String userid,String date){ + boolean bool = false; + RecordSet rs = new RecordSet(); + rs.executeQuery("select id from kq_flow_split_out where resourceid = ? and belongdate = ?",userid,date); + if(rs.next()){ + bool = true; + } + return bool; + } + + /** + * 判断 当天是否 早退 + * @param userid + * @param date + * @return + */ + public static boolean checkHasLeaveEarly(String userid,String date){ + boolean bool = false; + RecordSet rs = new RecordSet(); + rs.executeQuery("select leaveearlymins from kq_format_total where resourceid = ? and kqdate = ?",userid,date); + while(rs.next()){ + int leaveearlymins = Util.getIntValue(rs.getString("leaveearlymins")); + if(leaveearlymins > 0){ + bool = true; + } + } + return bool; + } + + /** + * 判断 当天是否 迟到 + * @param userid + * @param date + * @return + */ + public static boolean checkHasLate(String userid,String date){ + boolean bool = false; + RecordSet rs = new RecordSet(); + rs.executeQuery("select belatemins from kq_format_total where resourceid = ? and kqdate = ?",userid,date); + while(rs.next()){ + int belatemins = Util.getIntValue(rs.getString("belatemins")); + if(belatemins > 0){ + bool = true; + } + } + return bool; + } + + /** + * 获取 休息时间 + * @param serial + * @param status + * @return times 00:00 + */ + private static String getRestTime(String serial,String status){ + RecordSet rs = new RecordSet(); + String sql = "select times from kq_ShiftRestTimeSections where serialid = "+serial+" and (isdelete is null or isdelete <> '1') and resttype = '"+status+"' "; + rs.execute(sql); + String times = ""; + if (rs.next()){ + times = Util.null2String(rs.getString("time")); + } + return times; + } + + /** + * 比较时间的大小 + * @param a + * @param b + * @return + * @throws ParseException + */ + public static boolean compareDateTime(String a, String b){ + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + boolean bool = false; + try { + long t1 = sdf.parse(a).getTime(); + long t2 = sdf.parse(b).getTime(); + if (t1 >= t2) { + bool = true; + } else { + bool = false; + } + }catch (Exception e){ + e.printStackTrace(); + } + return bool; + } + +%> + + + + +

以下是 <%=username%> <%=fromdate%> 到 <%=todate%> 的 相关数据展示

+

请假时长 <%=leaveHours%>

+

班次的开始时间 <%=oneStart%>

+

班次的结束时间 <%=oneEnd%>

+

应出勤(排班)小时数 <%=workhours%>

+

月标准工时 <%=standardWorkingHours%>

+

应计薪小时数 <%=accruedPayHours%>

+

国假排班小时(3倍) <%=nationalHoliday3Hours%>

+

国假排班小时(2倍) <%=nationalHoliday2Hours%>

+

国假在职小时数 <%=nationalWorkingHours%>

+

补签卡次数 <%=replaceCardNum%>

+

迟到/早退(10分钟以内)/次 <%=beLateLeaveEearly10%>

+

迟到/早退(10(含)-30分钟以内)/次 <%=beLateLeaveEearly10To30%>

+

迟到/早退(30(含)-60分钟以内)/次 <%=beLateLeaveEearly30To60%>

+

迟到/早退(60分钟以上)/次 <%=beLateLeaveEearly60More%>

+

旷工合计小时 <%=absenteeismTotalHours%>

+

实际出勤小时数=排班表总时间-病假小时-事假小时-旷工小时数-漏签旷工小时数 <%=actualAttendanceHours%>

+

病假 小时数 <%=bjleavehours%>

+

事假 小时数 <%=sjleavehours%>

+

旷工小时数 <%=absencehours%>

+

漏签旷工小时数 <%=forgotserialhours%>

+

迟到分钟数 <%=latemins%>

+

早退分钟数 <%=leaveearlymins%>

+ \ No newline at end of file diff --git a/浙文眼镜/interface/zw/workflow/htpblc/getSchedulingDateType.jsp b/浙文眼镜/interface/zw/workflow/htpblc/getSchedulingDateType.jsp new file mode 100644 index 0000000..c8b4b5f --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/htpblc/getSchedulingDateType.jsp @@ -0,0 +1,284 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="java.time.LocalDate" %> +<%@ page import="java.util.List" %> +<%@ page import="java.util.ArrayList" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="java.util.Map" %> +<%@ page import="java.util.HashMap" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="com.engine.kq.biz.KQGroupBiz" %> +<%@ page import="com.engine.kq.biz.KQGroupComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %> +<%@ page import="weaver.common.DateUtil" %> +<%@ page import="java.time.DayOfWeek" %> +<%@ page import="java.time.temporal.TemporalAdjusters" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } + + + RecordSet rs = new RecordSet(); + String pbyf = request.getParameter("pbyf"); + String userid = request.getParameter("userid"); + String cjrbm = request.getParameter("cjrbm"); + +// List> hrmList = new ArrayList>(); +// if(StringUtils.isNotBlank(cjrbm)) { +// String sql =" select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) and id not in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"')"+ +// " union "+ +// " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydhbm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) "+ +// " union "+ +// " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydsxrq >='"+pbyf+"-02' and bm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) " ; +// +// hrmList = queryListBySql(sql); +// } +// +// if(hrmList !=null && hrmList.size() > 0){ +// userid = hrmList.get(0).get("id"); +// } + + if(StringUtils.isBlank(userid)){ + userid = user.getUID()+""; + } + + String activeGroupId = ""; + int daysInMonth = 0; + Map weekMap = new HashMap(); + List> weekList = new ArrayList>(); + if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7) { + LocalDate date = LocalDate.parse(pbyf + "-01"); // 获取当前日期 + LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + LocalDate startDayOfMonth = date.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 + String monthStartDate = startDayOfMonth.toString(); + String monthEndDate = lastDayOfMonth.toString(); + + activeGroupId = getUserActiveGroupId(userid); + String fixedScheduleGroupId = "5"; + + Map holidayMap = getHolidayByGroupId(fixedScheduleGroupId,monthStartDate,monthEndDate); + + int thisMonth = date.getMonthValue(); // 获取当前是哪月 + daysInMonth = date.lengthOfMonth(); // 获取本月有多少天 + + for (int i = 1; i <= daysInMonth; i++) { + LocalDate currentDate = LocalDate.of(date.getYear(), thisMonth, i); + System.out.println("currentDate:" + currentDate.toString()); + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); + System.out.println(i + "号是周 " + dayOfWeek.getValue()); + int weekValue = dayOfWeek.getValue(); + String weekDayName = ""; + switch (weekValue) { + case 1: + weekDayName = "周一"; + break; + case 2: + weekDayName = "周二"; + break; + case 3: + weekDayName = "周三"; + break; + case 4: + weekDayName = "周四"; + break; + case 5: + weekDayName = "周五"; + break; + case 6: + weekDayName = "周六"; + break; + case 7: + weekDayName = "周日"; + break; + } + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + weekMap = new HashMap(); + weekMap.put("weekname", weekDayName); + weekMap.put("changeType", changeType); + weekMap.put("weekday", i+""); + weekMap.put("weekdate", currentDate.toString()); + weekList.add(weekMap); + } + } + + String serialids = ""; + if(StringUtils.isNotBlank(activeGroupId)){ + String sql = " select serialids from kq_group where id = "+activeGroupId ; + rs.executeQuery(sql); + if(rs.next()){ + serialids = Util.null2String(rs.getString("serialids")); + } + } + JSONObject jsonObject = new JSONObject(); + jsonObject.put("data",weekList); + jsonObject.put("count",daysInMonth); + jsonObject.put("group",activeGroupId); + jsonObject.put("serialids",serialids); +%> + +<%=jsonObject.toJSONString() %> + + +<%! + + /*** + * + * @param userid + * @return + */ + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } + + + public Map getHolidayByGroupId(String activeGroupId,String monthStartDate,String monthEndDate){ + + Map holidayMap = new HashMap(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + + try { + if(StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){ + //String activeGroupId = getUserActiveGroupId(userid); + // bb.writeLog("activeGroupId:"+activeGroupId); + if(StringUtils.isNotBlank(activeGroupId)){ + String sql =" select holidayDate,changeType from KQ_HolidaySet\n" + + " where groupid = " + activeGroupId+ + " and holidayDate >='"+monthStartDate+"'\n" + + " and holidayDate <='"+monthEndDate+"' " ; + rs.execute(sql); + while (rs.next()){ + String holidayDate = Util.null2String(rs.getString("holidayDate")); + String changeType = Util.null2String(rs.getString("changeType")); + String changeTypename = "" ; + if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 + changeTypename += "公众假日"; + }else if("2".equals(changeType)){ + changeTypename += "调配工作日"; + }else if("3".equals(changeType)){ + changeTypename += "调配休息日"; + } + holidayMap.put(holidayDate,changeTypename); + +// if(weekMap.containsKey(holidayDate)){ +// String holidayDate_new = weekMap.get(holidayDate); +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// holidayDate_new += "[公众假日]"; +// }else if("1".equals(changeType)){ +// holidayDate_new += "[调配工作日]"; +// }else if("2".equals(changeType)){ +// holidayDate_new += "[调配休息日]"; +// } +// weekMap.put(holidayDate,holidayDate_new); +// } + } + } + } + }catch (Exception e){ + + } + return holidayMap; + } + + + public static List> queryListBySql(String sql){ + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + List> list = new ArrayList>(); + try{ + if(StringUtils.isNotBlank(sql)){ + Map map = new HashMap(); + rs.executeQuery(sql); + String[] column = rs.getColumnName(); + while (rs.next()){ + map = new HashMap(); + for(int i=0;i0){ + list.add(map); + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("queryListBySql-e:"+e); + } + return list; + } + +%> + + diff --git a/浙文眼镜/interface/zw/workflow/htpblc/querySchedulingUserData.jsp b/浙文眼镜/interface/zw/workflow/htpblc/querySchedulingUserData.jsp new file mode 100644 index 0000000..8cd5a0f --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/htpblc/querySchedulingUserData.jsp @@ -0,0 +1,221 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="java.util.List" %> +<%@ page import="java.util.ArrayList" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="java.util.Map" %> +<%@ page import="java.util.HashMap" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupBiz" %> +<%@ page import="weaver.common.DateUtil" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } + + RecordSet rs = new RecordSet(); + String cjrbm = request.getParameter("cjrbm"); + String pbyf = request.getParameter("pbyf"); + + List> hrmList = new ArrayList>(); + Map valueMap = new HashMap<>(); + List> dt1List = new ArrayList>(); + if(StringUtils.isNotBlank(cjrbm)) { + String sql =" select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) and id not in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"')"+ + " union "+ + " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydhbm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) "+ + " union "+ + " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydsxrq >='"+pbyf+"-02' and bm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) " ; + + + hrmList = queryListBySql(sql); + valueMap = getMainUserDate(hrmList); + dt1List = getDt1UserDate(hrmList); + } + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("data",valueMap); + jsonObject.put("dt1",dt1List); + + String userid = user.getUID()+"" ; +// if(hrmList !=null && hrmList.size() > 0){ +// userid = hrmList.get(0).get("id"); +// } + + if(StringUtils.isNotBlank(userid)){ + String activeGroupId = getUserActiveGroupId(userid); + String serialids = ""; + if(StringUtils.isNotBlank(activeGroupId)){ + String sql = " select serialids from kq_group where id = "+activeGroupId ; + rs.executeQuery(sql); + if(rs.next()){ + serialids = Util.null2String(rs.getString("serialids")); + } + } + jsonObject.put("group",activeGroupId); + jsonObject.put("serialids",serialids); + } + +%> + +<%=jsonObject.toJSONString() %> + + +<%! + + public List> getDt1UserDate(List> hrmList){ + List> dt1List = new ArrayList>(); + for(int i=0;i hrmMap = hrmList.get(i); + + String userid = Util.null2String(hrmMap.get("id")); + String lastname = Util.null2String(hrmMap.get("lastname")); + + Map dt1Map = new HashMap(); + dt1Map.put("id",userid); + dt1Map.put("name",lastname); + + List> specialobjList2 = new ArrayList>(); + Map specialobjMap2 = new HashMap(); + specialobjMap2.put("id",userid); + specialobjMap2.put("name",lastname); + specialobjList2.add(specialobjMap2); + + Map valueMap2 = new HashMap(); + valueMap2.put("value",userid); + valueMap2.put("specialobj",specialobjList2); + dt1Map.put("value",valueMap2); + dt1List.add(dt1Map); + } + return dt1List; + } + /*** + * + * @param hrmList + * @return + */ + public Map getMainUserDate(List> hrmList){ + String userids = ""; + List> specialobjList = new ArrayList>(); + for(int i=0;i hrmMap = hrmList.get(i); + String userid = Util.null2String(hrmMap.get("id")); + String lastname = Util.null2String(hrmMap.get("lastname")); + userids += StringUtils.isBlank(userids) ? userid : ","+userid ; + + Map specialobjMap = new HashMap(); + specialobjMap.put("id",userid); + specialobjMap.put("name",lastname); + specialobjList.add(specialobjMap); + } + + Map valueMap = new HashMap(); + valueMap.put("value",userids); + valueMap.put("specialobj",specialobjList); + return valueMap; + } + + public List> queryListBySql(String sql){ + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + List> list = new ArrayList>(); + try{ + if(StringUtils.isNotBlank(sql)){ + Map map = new HashMap(); + rs.executeQuery(sql); + String[] column = rs.getColumnName(); + while (rs.next()){ + map = new HashMap(); + for(int i=0;i0){ + list.add(map); + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("queryListBySql-e:"+e); + } + return list; + } + + + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } + + +%> + + diff --git a/浙文眼镜/interface/zw/workflow/htpblc/queryUserTransferData.jsp b/浙文眼镜/interface/zw/workflow/htpblc/queryUserTransferData.jsp new file mode 100644 index 0000000..643670f --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/htpblc/queryUserTransferData.jsp @@ -0,0 +1,114 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="java.time.LocalDate" %> +<%@ page import="java.time.format.DateTimeFormatter" %> +<%@ page import="java.time.temporal.TemporalAdjusters" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } + + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + String cjrbm = request.getParameter("cjrbm"); + String pbyf = request.getParameter("pbyf"); + String yg = request.getParameter("yg"); + + String startdate = ""; + String enddate = ""; + String sfdd = "1"; + if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7){ + + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate dateTime = LocalDate.parse(pbyf+"-01", formatter); + LocalDate firstDayOfMonth = dateTime.with(TemporalAdjusters.firstDayOfMonth()); + LocalDate lastDayOfMonth = dateTime.with(TemporalAdjusters.lastDayOfMonth()); + startdate = firstDayOfMonth.toString(); + enddate = lastDayOfMonth.toString(); + +// if(StringUtils.isNotBlank(cjrbm)) { +// String sql =" select convert(varchar,dateadd(day,-1,ydsxrq), 23) as ydsxrq " + +// " from uf_ygddxx " + +// " where left(ydsxrq,7) = '"+pbyf+"' "+ +// " and xm = "+ yg + +// " and bm= "+ cjrbm+ +// " and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) "; +// rs.executeQuery(sql); +// if(rs.next()){ +// String ydsxrq = Util.null2String(rs.getString("ydsxrq")); +// if(StringUtils.isNotBlank(ydsxrq)){ +// enddate = ydsxrq; +// sfdd = "0"; +// } +// } +// sql =" select ydsxrq " + +// " from uf_ygddxx " + +// " where left(ydsxrq,7) = '"+pbyf+"' "+ +// " and xm ="+ yg + +// " and ydhbm="+cjrbm+ +// " and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) "; +// rs.executeQuery(sql); +// if(rs.next()){ +// String ydsxrq = Util.null2String(rs.getString("ydsxrq")); +// if(StringUtils.isNotBlank(ydsxrq)){ +// startdate = ydsxrq; +// sfdd = "0"; +// } +// } +// } + + if(StringUtils.isNotBlank(cjrbm)) { + String sql =" select ydsxrq " + + " from uf_ygddxx " + + " where left(ydsxrq,7) = '"+pbyf+"' "+ + " and xm ="+ yg + + " and ydhbm="+cjrbm+ + " and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) " + + " order by id desc "; + rs.executeQuery(sql); + if(rs.next()){ + String ydsxrq = Util.null2String(rs.getString("ydsxrq")); + if(StringUtils.isNotBlank(ydsxrq)){ + startdate = ydsxrq; + sfdd = "0"; + } + } + + sql =" select convert(varchar,dateadd(day,-1,ydsxrq), 23) as ydsxrq " + + " from uf_ygddxx " + + " where left(ydsxrq,7) = '"+pbyf+"' "+ + " and xm = "+ yg + + " and bm= "+ cjrbm+ + " and ydsxrq > "+startdate + + " and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) " + + " order by id desc "; + rs.executeQuery(sql); + if(rs.next()){ + String ydsxrq = Util.null2String(rs.getString("ydsxrq")); + if(StringUtils.isNotBlank(ydsxrq)){ + enddate = ydsxrq; + sfdd = "0"; + } + } + } + } + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("startdate",startdate); + jsonObject.put("enddate",enddate); + jsonObject.put("sfdd",sfdd); + +%> +<%=jsonObject.toJSONString() %> + + + diff --git a/浙文眼镜/interface/zw/workflow/httblc/getSchedulingDateType.jsp b/浙文眼镜/interface/zw/workflow/httblc/getSchedulingDateType.jsp new file mode 100644 index 0000000..99d84f6 --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/httblc/getSchedulingDateType.jsp @@ -0,0 +1,282 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="java.time.LocalDate" %> +<%@ page import="java.util.List" %> +<%@ page import="java.util.ArrayList" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="java.util.Map" %> +<%@ page import="java.util.HashMap" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="com.engine.kq.biz.KQGroupBiz" %> +<%@ page import="com.engine.kq.biz.KQGroupComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %> +<%@ page import="weaver.common.DateUtil" %> +<%@ page import="java.time.DayOfWeek" %> +<%@ page import="java.time.temporal.TemporalAdjusters" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } + + + RecordSet rs = new RecordSet(); + String pbyf = request.getParameter("pbyf"); + String userid = request.getParameter("userid"); + String cjrbm = request.getParameter("cjrbm"); + +// List> hrmList = new ArrayList>(); +// if(StringUtils.isNotBlank(cjrbm)) { +// String sql =" select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) and id not in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"')"+ +// " union "+ +// " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydhbm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) "+ +// " union "+ +// " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydsxrq >='"+pbyf+"-02' and bm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) " ; +// +// hrmList = queryListBySql(sql); +// } +// +// if(hrmList !=null && hrmList.size() > 0){ +// userid = hrmList.get(0).get("id"); +// } + if(StringUtils.isBlank(userid)){ + userid = user.getUID()+""; + } + String activeGroupId = ""; + int daysInMonth = 0; + Map weekMap = new HashMap(); + List> weekList = new ArrayList>(); + if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7) { + LocalDate date = LocalDate.parse(pbyf + "-01"); // 获取当前日期 + LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + LocalDate startDayOfMonth = date.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 + String monthStartDate = startDayOfMonth.toString(); + String monthEndDate = lastDayOfMonth.toString(); + + activeGroupId = getUserActiveGroupId(userid); + String fixedScheduleGroupId = "5"; + + Map holidayMap = getHolidayByGroupId(fixedScheduleGroupId,monthStartDate,monthEndDate); + + int thisMonth = date.getMonthValue(); // 获取当前是哪月 + daysInMonth = date.lengthOfMonth(); // 获取本月有多少天 + + for (int i = 1; i <= daysInMonth; i++) { + LocalDate currentDate = LocalDate.of(date.getYear(), thisMonth, i); + System.out.println("currentDate:" + currentDate.toString()); + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); + System.out.println(i + "号是周 " + dayOfWeek.getValue()); + int weekValue = dayOfWeek.getValue(); + String weekDayName = ""; + switch (weekValue) { + case 1: + weekDayName = "周一"; + break; + case 2: + weekDayName = "周二"; + break; + case 3: + weekDayName = "周三"; + break; + case 4: + weekDayName = "周四"; + break; + case 5: + weekDayName = "周五"; + break; + case 6: + weekDayName = "周六"; + break; + case 7: + weekDayName = "周日"; + break; + } + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + weekMap = new HashMap(); + weekMap.put("weekname", weekDayName); + weekMap.put("changeType", changeType); + weekMap.put("weekday", i+""); + weekMap.put("weekdate", currentDate.toString()); + weekList.add(weekMap); + } + } + + String serialids = ""; + if(StringUtils.isNotBlank(activeGroupId)){ + String sql = " select serialids from kq_group where id = "+activeGroupId ; + rs.executeQuery(sql); + if(rs.next()){ + serialids = Util.null2String(rs.getString("serialids")); + } + } + JSONObject jsonObject = new JSONObject(); + jsonObject.put("data",weekList); + jsonObject.put("count",daysInMonth); + jsonObject.put("group",activeGroupId); + jsonObject.put("serialids",serialids); +%> + +<%=jsonObject.toJSONString() %> + + +<%! + + /*** + * + * @param userid + * @return + */ + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } + + + public Map getHolidayByGroupId(String activeGroupId,String monthStartDate,String monthEndDate){ + + Map holidayMap = new HashMap(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + + try { + if(StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){ + //String activeGroupId = getUserActiveGroupId(userid); + // bb.writeLog("activeGroupId:"+activeGroupId); + if(StringUtils.isNotBlank(activeGroupId)){ + String sql =" select holidayDate,changeType from KQ_HolidaySet\n" + + " where groupid = " + activeGroupId+ + " and holidayDate >='"+monthStartDate+"'\n" + + " and holidayDate <='"+monthEndDate+"' " ; + rs.execute(sql); + while (rs.next()){ + String holidayDate = Util.null2String(rs.getString("holidayDate")); + String changeType = Util.null2String(rs.getString("changeType")); + String changeTypename = "" ; + if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 + changeTypename += "公众假日"; + }else if("2".equals(changeType)){ + changeTypename += "调配工作日"; + }else if("3".equals(changeType)){ + changeTypename += "调配休息日"; + } + holidayMap.put(holidayDate,changeTypename); + +// if(weekMap.containsKey(holidayDate)){ +// String holidayDate_new = weekMap.get(holidayDate); +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// holidayDate_new += "[公众假日]"; +// }else if("1".equals(changeType)){ +// holidayDate_new += "[调配工作日]"; +// }else if("2".equals(changeType)){ +// holidayDate_new += "[调配休息日]"; +// } +// weekMap.put(holidayDate,holidayDate_new); +// } + } + } + } + }catch (Exception e){ + + } + return holidayMap; + } + + + public static List> queryListBySql(String sql){ + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + List> list = new ArrayList>(); + try{ + if(StringUtils.isNotBlank(sql)){ + Map map = new HashMap(); + rs.executeQuery(sql); + String[] column = rs.getColumnName(); + while (rs.next()){ + map = new HashMap(); + for(int i=0;i0){ + list.add(map); + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("queryListBySql-e:"+e); + } + return list; + } + +%> + + diff --git a/浙文眼镜/interface/zw/workflow/httblc/querySchedulingUserData.jsp b/浙文眼镜/interface/zw/workflow/httblc/querySchedulingUserData.jsp new file mode 100644 index 0000000..27bb6de --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/httblc/querySchedulingUserData.jsp @@ -0,0 +1,221 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="java.util.List" %> +<%@ page import="java.util.ArrayList" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="java.util.Map" %> +<%@ page import="java.util.HashMap" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupBiz" %> +<%@ page import="weaver.common.DateUtil" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } + + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + String cjrbm = request.getParameter("cjrbm"); + String pbyf = request.getParameter("pbyf"); + + List> hrmList = new ArrayList>(); + Map valueMap = new HashMap<>(); + List> dt1List = new ArrayList>(); + if(StringUtils.isNotBlank(cjrbm)) { + String sql =" select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) and id not in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"')"+ + " union "+ + " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydhbm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) "+ + " union "+ + " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydsxrq >='"+pbyf+"-02' and bm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) " ; + + hrmList = queryListBySql(sql); + valueMap = getMainUserDate(hrmList); + dt1List = getDt1UserDate(hrmList); + } + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("data",valueMap); + jsonObject.put("dt1",dt1List); + + String userid =user.getUID()+"" ; +// if(hrmList !=null && hrmList.size() > 0){ +// userid = hrmList.get(0).get("id"); +// } + + if(StringUtils.isNotBlank(userid)){ + String activeGroupId = getUserActiveGroupId(userid); + String serialids = ""; + if(StringUtils.isNotBlank(activeGroupId)){ + String sql = " select serialids from kq_group where id = "+activeGroupId ; + rs.executeQuery(sql); + if(rs.next()){ + serialids = Util.null2String(rs.getString("serialids")); + } + } + jsonObject.put("group",activeGroupId); + jsonObject.put("serialids",serialids); + } + +%> + +<%=jsonObject.toJSONString() %> + + +<%! + + public List> getDt1UserDate(List> hrmList){ + List> dt1List = new ArrayList>(); + for(int i=0;i hrmMap = hrmList.get(i); + + String userid = Util.null2String(hrmMap.get("id")); + String lastname = Util.null2String(hrmMap.get("lastname")); + + Map dt1Map = new HashMap(); + dt1Map.put("id",userid); + dt1Map.put("name",lastname); + + List> specialobjList2 = new ArrayList>(); + Map specialobjMap2 = new HashMap(); + specialobjMap2.put("id",userid); + specialobjMap2.put("name",lastname); + specialobjList2.add(specialobjMap2); + + Map valueMap2 = new HashMap(); + valueMap2.put("value",userid); + valueMap2.put("specialobj",specialobjList2); + dt1Map.put("value",valueMap2); + dt1List.add(dt1Map); + } + return dt1List; + } + /*** + * + * @param hrmList + * @return + */ + public Map getMainUserDate(List> hrmList){ + String userids = ""; + List> specialobjList = new ArrayList>(); + for(int i=0;i hrmMap = hrmList.get(i); + String userid = Util.null2String(hrmMap.get("id")); + String lastname = Util.null2String(hrmMap.get("lastname")); + userids += StringUtils.isBlank(userids) ? userid : ","+userid ; + + Map specialobjMap = new HashMap(); + specialobjMap.put("id",userid); + specialobjMap.put("name",lastname); + specialobjList.add(specialobjMap); + } + + Map valueMap = new HashMap(); + valueMap.put("value",userids); + valueMap.put("specialobj",specialobjList); + return valueMap; + } + + public List> queryListBySql(String sql){ + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + List> list = new ArrayList>(); + try{ + if(StringUtils.isNotBlank(sql)){ + Map map = new HashMap(); + rs.executeQuery(sql); + String[] column = rs.getColumnName(); + while (rs.next()){ + map = new HashMap(); + for(int i=0;i0){ + list.add(map); + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("queryListBySql-e:"+e); + } + return list; + } + + + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } + + +%> + + diff --git a/浙文眼镜/interface/zw/workflow/httblc/queryUserSerialByMonth.jsp b/浙文眼镜/interface/zw/workflow/httblc/queryUserSerialByMonth.jsp new file mode 100644 index 0000000..173adb2 --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/httblc/queryUserSerialByMonth.jsp @@ -0,0 +1,840 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="weaver.common.DateUtil" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupBiz" %> +<%@ page import="java.time.LocalDate" %> +<%@ page import="java.time.format.DateTimeFormatter" %> +<%@ page import="java.time.DayOfWeek" %> +<%@ page import="java.time.temporal.TemporalAdjusters" %> +<%@ page import="java.util.*" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + String yg = request.getParameter("yg"); + String pbyf = request.getParameter("pbyf"); + String cjrbm = request.getParameter("cjrbm"); + + List> hrmList = new ArrayList>(); + if(StringUtils.isNotBlank(cjrbm)) { + String sql =" select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) and id not in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"')"+ + " union "+ + " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydhbm ="+cjrbm+") "+ + " union "+ + " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydsxrq >='"+pbyf+"-02' and bm ="+cjrbm+") " ; + + hrmList = queryListBySql(sql); + } + String userid = user.getUID()+""; + + String activeGroupId = getUserActiveGroupId(userid); + + List> scheduleList = new ArrayList>(); + if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7) { + LocalDate localDate = LocalDate.parse(pbyf + "-01"); // 获取当前日期 + LocalDate lastDayOfMonth = localDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + LocalDate firstDayOfMonth = localDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 + String monthStartDate = firstDayOfMonth.toString(); + String monthEndDate = lastDayOfMonth.toString(); + + String startDate = monthStartDate; + String endDate = monthEndDate ; + + String sql =" select ydsxrq " + + " from uf_ygddxx " + + " where left(ydsxrq,7) = '"+pbyf+"' "+ + " and xm ="+ yg + + " and ydhbm="+cjrbm+ + " and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) " + + " order by id desc "; + rs.executeQuery(sql); + if(rs.next()){ + String ydsxrq = Util.null2String(rs.getString("ydsxrq")); + if(StringUtils.isNotBlank(ydsxrq)){ + startDate = ydsxrq; + } + } + + sql =" select convert(varchar,dateadd(day,-1,ydsxrq), 23) as ydsxrq " + + " from uf_ygddxx " + + " where left(ydsxrq,7) = '"+pbyf+"' "+ + " and xm = "+ yg + + " and bm= "+ cjrbm+ + " and ydsxrq > "+startDate + + " and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) " + + " order by id desc "; + rs.executeQuery(sql); + if(rs.next()){ + String ydsxrq = Util.null2String(rs.getString("ydsxrq")); + if(StringUtils.isNotBlank(ydsxrq)){ + endDate = ydsxrq; + } + } + + sql =" select t.serialid,k.serial,t.resourceid,t.kqdate\n" + + " from kq_shiftschedule t\n" + + " inner join kq_ShiftManagement k on k.id = t.serialid\n" + + " where left(t.kqdate,7)='"+pbyf+"' \n" + + " and t.kqdate >='"+startDate+"' " + + " and t.kqdate <= '"+endDate+"'" + + " and t.groupid="+activeGroupId+" and (t.isDelete is null or t.isDelete = 0)\n" + + " and resourceid = " + yg + + " order by kqdate "; + + bb.writeLog("sql:"+sql); + List> sqlList = queryListBySql(sql); + + for(int i=0;i map = sqlList.get(i); + + String serialid = Util.null2String(map.get("serialid")); + String name = Util.null2String(map.get("serial")); + String kqdate = Util.null2String(map.get("kqdate")); + + String xh = ""; + if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){ + xh = kqdate.substring(8); + if(StringUtils.isNotBlank(xh)){ + if(xh.startsWith("0")){ + xh = xh.substring(1); + } + } + } + + if(StringUtils.isNotBlank(xh)){ + List> specialobjList = new ArrayList>(); + Map specialobjMap = new HashMap(); + specialobjMap.put("id",serialid); + specialobjMap.put("name",name); + specialobjList.add(specialobjMap); + + Map valueMap = new HashMap(); + valueMap.put("serialid",serialid); + valueMap.put("kqdate",kqdate); + valueMap.put("xh",xh); + valueMap.put("specialobj",specialobjList); + scheduleList.add(valueMap); + } + } + } + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("schedule",scheduleList); +%> + +<%=jsonObject.toJSONString() %> + +<%! + /*** + * + * @param hrmList + * @return + */ + public Map getMainUserDate(List> hrmList){ + String userids = ""; + List> specialobjList = new ArrayList>(); + for(int i=0;i hrmMap = hrmList.get(i); + String userid = Util.null2String(hrmMap.get("id")); + String lastname = Util.null2String(hrmMap.get("lastname")); + userids += StringUtils.isBlank(userids) ? userid : ","+userid ; + + Map specialobjMap = new HashMap(); + specialobjMap.put("id",userid); + specialobjMap.put("name",lastname); + specialobjList.add(specialobjMap); + } + + Map valueMap = new HashMap(); + valueMap.put("value",userids); + valueMap.put("specialobj",specialobjList); + return valueMap; + } + + /*** + * + * @param hrmList + * @return + */ + public List> getDt1UserDate(List> hrmList){ + List> dt1List = new ArrayList>(); + for(int i=0;i hrmMap = hrmList.get(i); + + String userid = Util.null2String(hrmMap.get("id")); + String lastname = Util.null2String(hrmMap.get("lastname")); + + Map dt1Map = new HashMap(); + dt1Map.put("id",userid); + dt1Map.put("name",lastname); + + List> specialobjList2 = new ArrayList>(); + Map specialobjMap2 = new HashMap(); + specialobjMap2.put("id",userid); + specialobjMap2.put("name",lastname); + specialobjList2.add(specialobjMap2); + + Map valueMap2 = new HashMap(); + valueMap2.put("value",userid); + valueMap2.put("specialobj",specialobjList2); + dt1Map.put("value",valueMap2); + + dt1List.add(dt1Map); + } + return dt1List; + } + + + + + + public String getWeekTypeByDate(String pbrq,String userid,String activeGroupId){ + + String dateType = "0"; + DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate currentDate = LocalDate.parse(pbrq, df); + + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); + int weekValue = dayOfWeek.getValue(); + + LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 + String monthStartDate = startDayOfMonth.toString(); + String monthEndDate = lastDayOfMonth.toString(); + Map holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate,activeGroupId); + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + + if("1".equals(changeType) || "3".equals(changeType)){ + dateType = "1"; + }else if(weekValue == 6 || weekValue == 7){ + dateType = "1"; + } + return dateType; + } + + /*** + * + * @param userid + * @param monthStartDate + * @param monthEndDate + * @return + */ + public Map getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate,String activeGroupId){ + + Map holidayMap = new HashMap(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + + try { + if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){ + if(StringUtils.isNotBlank(activeGroupId)){ + String sql =" select holidayDate,changeType from KQ_HolidaySet\n" + + " where groupid = " + activeGroupId+ + " and holidayDate >='"+monthStartDate+"'\n" + + " and holidayDate <='"+monthEndDate+"' " ; + rs.execute(sql); + while (rs.next()){ + String holidayDate = Util.null2String(rs.getString("holidayDate")); + String changeType = Util.null2String(rs.getString("changeType")); +// String changeTypename = "" ; +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// changeTypename += "公众假日"; +// }else if("2".equals(changeType)){ +// changeTypename += "调配工作日"; +// }else if("3".equals(changeType)){ +// changeTypename += "调配休息日"; +// } + holidayMap.put(holidayDate,changeType); + +// if(weekMap.containsKey(holidayDate)){ +// String holidayDate_new = weekMap.get(holidayDate); +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// holidayDate_new += "[公众假日]"; +// }else if("1".equals(changeType)){ +// holidayDate_new += "[调配工作日]"; +// }else if("2".equals(changeType)){ +// holidayDate_new += "[调配休息日]"; +// } +// weekMap.put(holidayDate,holidayDate_new); +// } + } + } + } + }catch (Exception e){ + + } + return holidayMap; + } + + /*** + * + * @param userid + * @return + */ + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } + + + + + + + + public static List> queryListBySql(String sql){ + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + List> list = new ArrayList>(); + try{ + if(StringUtils.isNotBlank(sql)){ + Map map = new HashMap(); + rs.executeQuery(sql); + String[] column = rs.getColumnName(); + while (rs.next()){ + map = new HashMap(); + for(int i=0;i0){ + list.add(map); + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("queryListBySql-e:"+e); + } + return list; + } + + /*** + * + * @return + */ + public Map getDt1UserMap(String ry,String lastname){ + Map valueMap = new HashMap(); + if(StringUtils.isNotBlank(ry)){ + List> specialobjList = new ArrayList>(); + Map specialobjMap = new HashMap(); + specialobjMap.put("id",ry); + specialobjMap.put("name",lastname); + specialobjList.add(specialobjMap); + valueMap.put("id",ry); + valueMap.put("name",lastname); + valueMap.put("specialobj",specialobjList); + } + + return valueMap; + } + + + /*** + * + * @param pbyf + * @param groupid + * @param resourceid + * @return + */ + public List> queryShiftScheduleByUser(String pbyf,String groupid,String resourceid,Map dateEffectiveMap){ + BaseBean bb = new BaseBean(); + List> scheduleList = new ArrayList>(); + try{ + List> sqlList = new ArrayList>(); + if(StringUtils.isNotBlank(pbyf) && StringUtils.isNotBlank(resourceid)){ + String startDate = "" ; + String endDate = ""; + if(dateEffectiveMap.containsKey(resourceid)){ + String effectiveDate = dateEffectiveMap.get(resourceid); + if(effectiveDate.contains(";")){ + String[] effective_Date = effectiveDate.split(";"); + startDate = effective_Date[0]; + endDate = effective_Date[1]; + } + } + + String sql =" select t.serialid,k.serial,t.resourceid,t.kqdate\n" + + " from kq_shiftschedule t\n" + + " inner join kq_ShiftManagement k on k.id = t.serialid\n" + + " where left(t.kqdate,7)='"+pbyf+"' \n" + + " and t.kqdate >='"+startDate+"' " + + " and t.kqdate <= '"+endDate+"'" + + " and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" + + " and resourceid = " + resourceid + + " order by kqdate "; + bb.writeLog("sql:"+sql); + sqlList = queryListBySql(sql); + } + + for(int i=0;i map = sqlList.get(i); + + String serialid = Util.null2String(map.get("serialid")); + String name = Util.null2String(map.get("serial")); + String kqdate = Util.null2String(map.get("kqdate")); + + String xh = ""; + if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){ + xh = kqdate.substring(8); + if(StringUtils.isNotBlank(xh)){ + if(xh.startsWith("0")){ + xh = xh.substring(1); + } + } + } + + if(StringUtils.isNotBlank(xh)){ + List> specialobjList = new ArrayList>(); + Map specialobjMap = new HashMap(); + specialobjMap.put("id",serialid); + specialobjMap.put("name",name); + specialobjList.add(specialobjMap); + + Map valueMap = new HashMap(); + valueMap.put("serialid",serialid); + valueMap.put("kqdate",kqdate); + valueMap.put("xh",xh); + + + + valueMap.put("specialobj",specialobjList); + + scheduleList.add(valueMap); + } + } + + }catch (Exception e){ + + } + return scheduleList; + } + + + public List getSchedulingRestData(){ + + List list = new ArrayList(); + RecordSet rs = new RecordSet(); + try{ + String sql =" select id " + + " from kq_ShiftManagement \n" + + " where is_rest = 1 \n" + + " and (isdelete is null or isdelete = 0) "; + + rs.executeQuery(sql); + while (rs.next()){ + String id = Util.null2String(rs.getString("id")); + list.add(id); + } + }catch (Exception e){ + + } + return list; + } + + /*** + * + * @param restList + * @param daysList + * @param weekMap + * @param serialList + */ + public Map queryCountWorkTime(List restList,List daysList,Map weekMap,List> serialList ){ + + BaseBean bb = new BaseBean(); + Map countMap = new HashMap<>(); + String worktime = "0"; + String totalworktime = "0"; + int restcount = 0; + int weekrestcount = 0; + + RecordSet rs = new RecordSet(); + try{ + String sql = ""; + for (int i = 0; i < serialList.size(); i++) { + Map serialMap = serialList.get(i); + String kqdate = Util.null2String(serialMap.get("kqdate")); + String serialid = Util.null2String(serialMap.get("serialid")); + if (daysList.contains(kqdate)) { + if (StringUtils.isNotBlank(serialid)) { + if (restList.contains(serialid)) { + restcount++; + } + + if(!restList.contains(serialid)){ + String sql2 = " select try_convert(int,worktime) as worktime from kq_ShiftManagement where id ="+serialid+" and (is_rest is null or is_rest = 0) " ; + sql += StringUtils.isBlank(sql) ? sql2 : " union all \n"+sql2 ; + } + } + + if (weekMap.containsKey(kqdate)) { + String value = weekMap.get(kqdate); + //6 = 周六 7 = 周日 11 = 公众假日、调配休息日 + if ("6".equals(value) || "7".equals(value) || "11".equals(value)) { + if (restList.contains(serialid)) { + weekrestcount++; + } + } + } + } + } + + if(StringUtils.isNotBlank(sql)){ + sql = " select round(sum(worktime)/60.0,2) as worktime,sum(worktime) as totalworktime from ("+sql+") w "; + rs.executeQuery(sql); + if(rs.next()){ + worktime = Util.null2String(rs.getString("worktime")); + totalworktime = Util.null2String(rs.getString("totalworktime")); + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("e:"+e); + } + + countMap.put("worktime",worktime); + countMap.put("totalworktime",totalworktime); + countMap.put("restcount",restcount+""); + countMap.put("weekrestcount",weekrestcount+""); + + return countMap; + } + + /*** + * + * @param daysList + * @param holidayMap + * @param yjl + * @param workSchedule + * @param hrmList + * @param groupid + * @return + */ + public List> queryScheduleStatusByDay(List daysList,Map holidayMap,String yjl,String[] workSchedule,List> hrmList,String groupid,Map dateEffectiveMap){ + + BaseBean bb = new BaseBean(); + List> resultList = new ArrayList>(); + + DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + RecordSet rs = new RecordSet(); + + try{ + List> workScheduleList = new ArrayList>(); + Map workScheduleMap = null; + for(int k=0;k0){ + String[] schedule = workSchedule[k].split("-"); + String scheduleStartTime = schedule[0]; + String scheduleEndTime = schedule[1]; + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + workScheduleMap = new HashMap(); + workScheduleMap.put("start",scheduleStartTime); + workScheduleMap.put("end",scheduleEndTime); + workScheduleList.add(workScheduleMap); + } + } + } + + + for(String pbrq:daysList){ + + String resourceids = ""; + for(int i=0;i hrmMap = hrmList.get(i); + String userid = Util.null2String(hrmMap.get("id")); + if(StringUtils.isNotBlank(userid)){ + if(dateEffectiveMap.containsKey(userid)){ + String effectiveDate = dateEffectiveMap.get(userid); + if(effectiveDate.contains(";")){ + String[] effective_Date = effectiveDate.split(";"); + if(pbrq.compareTo(effective_Date[0])>=0 && pbrq.compareTo(effective_Date[1])<=0){ + resourceids += StringUtils.isBlank(resourceids) ? userid : ","+userid ; + } + } + } + } + } + + String dateType = "0"; + if(StringUtils.isNotBlank(pbrq)){ + LocalDate currentDate = LocalDate.parse(pbrq, df); + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); + int weekValue = dayOfWeek.getValue(); + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + + if("1".equals(changeType) || "3".equals(changeType)){ + dateType = "1"; + }else if(weekValue == 6 || weekValue == 7){ + dateType = "1"; + } + } + + Map defaultScheduleMap = new HashMap(); + if(StringUtils.isNotBlank(yjl)){ + String sql = " select dysjd,pzrs from uf_pbjcsj where yjl = ? and pblx = ?" ; + rs.executeQuery(sql,new Object[]{yjl,dateType}); + while (rs.next()){ + int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd"))); + int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs"))); + + String sjd = ""; + if(dysd < workSchedule.length){ + sjd = workSchedule[dysd]; + if(StringUtils.isNotBlank(sjd)){ + defaultScheduleMap.put(sjd,pzrs); + } + } + } + } + + List> sqlList = new ArrayList>(); + if(StringUtils.isNotBlank(resourceids) && StringUtils.isNotBlank(pbrq)){ + + String sql =" select t.serialid,t.resourceid,t.kqdate \n" + + " from kq_shiftschedule t\n" + + " where t.kqdate='"+pbrq+"' \n" + + " and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" + + " and resourceid in( " + resourceids + ") "+ + " order by kqdate "; + sqlList = queryListBySql(sql); + } + + Map resultMap = queryScheduleStatusByUser(sqlList,workScheduleList,defaultScheduleMap,pbrq); + resultList.add(resultMap); + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("e:"+e); + } + + return resultList; + } + + /*** + * + * @param sqlList + * @param workScheduleList + * @param defaultScheduleMap + * @param kqdate + * @return + */ + public Map queryScheduleStatusByUser(List> sqlList,List> workScheduleList,Map defaultScheduleMap,String kqdate){ + + RecordSet rs = new RecordSet(); + + Map> userScheduleDayMap = new HashMap>(); + Map userScheduleMap = new HashMap(); + Map necessaryMap = new HashMap(); + String yxrys = "" ; + for(int i=0;i sqlMap = sqlList.get(i); + String resourceid = Util.null2String(sqlMap.get("resourceid")); + yxrys += StringUtils.isBlank(yxrys) ? resourceid :","+resourceid ; + } + if(StringUtils.isNotBlank(yxrys)) { + List userList = new ArrayList(); + String sql =" select h.id \n" + + " from hrmresource h \n" + + " inner join hrmjobtitles k on k.id = h.jobtitle\n" + + " where h.id in("+yxrys+")\n" + + " and k.jobtitlename in('店长','验光师')\n" + + " and h.status in(0,1,2,3,4)\n" + + " union \n" + + " select h.id \n" + + " from hrmresource h \n" + + " inner join cus_fielddata k on k.id = h.id\n" + + " where k.field39 = 2 \n" + + " and k.scopeid=3 \n" + + " and k.scope='HrmCustomFieldByInfoType' " + + " and h.id in("+yxrys+") and h.status in(0,1,2,3,4) " + + " union " + + " select h.id\n" + + " from hrmresource h \n" + + " inner join cus_fielddata k on k.id = h.id \n" + + " where k.scopeid=-1 " + + " and k.scope='HrmCustomFieldByInfoType'\n" + + " and substring(k.field1,charindex('_',k.field1)+1,len(k.field1)) in(select id from uf_gwjbsjb where jbmc in('配镜一级','配镜二级','配镜三级','配镜四级','配镜五级')) and charindex('_', k.field1) > 0 \n" + + " and h.status in(0,1,2,3,4) "+ + " and h.id in("+yxrys+") "; + + rs.executeQuery(sql); + while (rs.next()){ + String id = Util.null2String(rs.getString("id")); + userList.add(id); + } + + for(int i = 0;i sqlMap = sqlList.get(i); + String pbry = sqlMap.get("resourceid"); + String serialid = sqlMap.get("serialid"); + String startTime = ""; + String endTime = ""; + + sql = " select times,onoffworktype from kq_ShiftOnOffWorkSections where serialid = ? and (isdelete = 0 or isdelete is null) "; + rs.executeQuery(sql,new Object[]{serialid}); + while(rs.next()){ + String onoffworktype = Util.null2String(rs.getString("onoffworktype")); + if("start".equals(onoffworktype)){ + startTime = Util.null2String(rs.getString("times")); + }else if("end".equals(onoffworktype)){ + endTime = Util.null2String(rs.getString("times")); + } + } + + Map userSchedule_Map = new HashMap(); + if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){ + userSchedule_Map.put("startTime",startTime); + userSchedule_Map.put("endTime",endTime); + + for(int k=0;k workSchedule_Map = workScheduleList.get(k); + String scheduleStartTime = workSchedule_Map.get("start"); + String scheduleEndTime = workSchedule_Map.get("end"); + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + if(startTime.compareTo(scheduleStartTime) <=0 && endTime.compareTo(scheduleEndTime) >=0){ + + String defWorkSchedule = scheduleStartTime+"-"+scheduleEndTime ; + if(userScheduleMap.containsKey(defWorkSchedule)){ + int count = userScheduleMap.get(defWorkSchedule); + count++; + userScheduleMap.put(defWorkSchedule,count); + }else{ + userScheduleMap.put(defWorkSchedule,1); + } + + if(userList.contains(pbry)){ + necessaryMap.put(defWorkSchedule,1); + } + } + } + } + } + userScheduleDayMap.put(pbry,userSchedule_Map); + } + } + + int defaultcount = 0; + int datacount = 0; + Iterator> iterator = defaultScheduleMap.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); + int value =entry.getValue(); + String key = entry.getKey(); + if(userScheduleMap.containsKey(key)){ + int useValue = userScheduleMap.get(key); + if(useValue < value){ + datacount++; + } + }else{ + datacount++; + } + defaultcount++; + } + + + String xh = ""; + if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){ + xh = kqdate.substring(8); + if(StringUtils.isNotBlank(xh)){ + if(xh.startsWith("0")){ + xh = xh.substring(1); + } + } + } + Map resultMap = new HashMap<>(); + String status = "0"; + if(defaultcount >0 && datacount == 0){ + if(necessaryMap.size() == 4){ + status = "0"; + }else{ + status = "1"; + } + } + resultMap.put("kqdate",kqdate); + resultMap.put("status",status); + resultMap.put("xh",xh); + + return resultMap; + } + +%> + + diff --git a/浙文眼镜/interface/zw/workflow/httblc/queryUserSerialByMonth_test.jsp b/浙文眼镜/interface/zw/workflow/httblc/queryUserSerialByMonth_test.jsp new file mode 100644 index 0000000..d9c92a1 --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/httblc/queryUserSerialByMonth_test.jsp @@ -0,0 +1,848 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="weaver.common.DateUtil" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupBiz" %> +<%@ page import="java.time.LocalDate" %> +<%@ page import="java.time.format.DateTimeFormatter" %> +<%@ page import="java.time.DayOfWeek" %> +<%@ page import="java.time.temporal.TemporalAdjusters" %> +<%@ page import="java.util.*" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + String yg = request.getParameter("yg"); + String pbyf = request.getParameter("pbyf"); + String cjrbm = request.getParameter("cjrbm"); + + List> hrmList = new ArrayList>(); + if(StringUtils.isNotBlank(cjrbm)) { + String sql =" select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) and id not in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"')"+ + " union "+ + " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydhbm ="+cjrbm+") "+ + " union "+ + " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydsxrq >='"+pbyf+"-02' and bm ="+cjrbm+") " ; + out.print("sql:"+sql+"
"); + hrmList = queryListBySql(sql); + } + String userid = "" ; + if(hrmList !=null && hrmList.size() > 0){ + userid = hrmList.get(0).get("id"); + } + out.print("userid:"+userid+"
"); + String activeGroupId = getUserActiveGroupId(userid); + + List> scheduleList = new ArrayList>(); + if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7) { + LocalDate localDate = LocalDate.parse(pbyf + "-01"); // 获取当前日期 + LocalDate lastDayOfMonth = localDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + LocalDate firstDayOfMonth = localDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 + String monthStartDate = firstDayOfMonth.toString(); + String monthEndDate = lastDayOfMonth.toString(); + + String startDate = monthStartDate; + String endDate = monthEndDate ; + out.print("startDate:"+startDate+"
"); + out.print("endDate:"+endDate+"
"); + + String sql =" select convert(varchar,dateadd(day,-1,ydsxrq), 23) as ydsxrq " + + " from uf_ygddxx " + + " where left(ydsxrq,7) = '"+pbyf+"' "+ + " and xm = "+ yg + + " and bm= "+ cjrbm+ + " and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) "; + + out.print("sql:"+sql+"
"); + rs.executeQuery(sql); + if(rs.next()){ + String ydsxrq = Util.null2String(rs.getString("ydsxrq")); + if(StringUtils.isNotBlank(ydsxrq)){ + endDate = ydsxrq; + } + } + + sql =" select ydsxrq " + + " from uf_ygddxx " + + " where left(ydsxrq,7) = '"+pbyf+"' "+ + " and xm ="+ yg + + " and ydhbm="+cjrbm+ + " and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) "; + rs.executeQuery(sql); + out.print("sql:"+sql+"
"); + if(rs.next()){ + String ydsxrq = Util.null2String(rs.getString("ydsxrq")); + if(StringUtils.isNotBlank(ydsxrq)){ + startDate = ydsxrq; + } + } + + out.print("startDate:"+startDate+"
"); + out.print("endDate:"+endDate+"
"); + + sql =" select t.serialid,k.serial,t.resourceid,t.kqdate\n" + + " from kq_shiftschedule t\n" + + " inner join kq_ShiftManagement k on k.id = t.serialid\n" + + " where left(t.kqdate,7)='"+pbyf+"' \n" + + " and t.kqdate >='"+startDate+"' " + + " and t.kqdate <= '"+endDate+"'" + + " and t.groupid="+activeGroupId+" and (t.isDelete is null or t.isDelete = 0)\n" + + " and resourceid = " + yg + + " order by kqdate "; + out.print("sql:"+sql+"
"); + bb.writeLog("sql:"+sql); + List> sqlList = queryListBySql(sql); + out.print("sqlList:"+sqlList.size()+"
"); + for(int i=0;i map = sqlList.get(i); + + String serialid = Util.null2String(map.get("serialid")); + String name = Util.null2String(map.get("serial")); + String kqdate = Util.null2String(map.get("kqdate")); + + String xh = ""; + if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){ + xh = kqdate.substring(8); + if(StringUtils.isNotBlank(xh)){ + if(xh.startsWith("0")){ + xh = xh.substring(1); + } + } + } + + if(StringUtils.isNotBlank(xh)){ + List> specialobjList = new ArrayList>(); + Map specialobjMap = new HashMap(); + specialobjMap.put("id",serialid); + specialobjMap.put("name",name); + specialobjList.add(specialobjMap); + + Map valueMap = new HashMap(); + valueMap.put("serialid",serialid); + valueMap.put("kqdate",kqdate); + valueMap.put("xh",xh); + valueMap.put("specialobj",specialobjList); + scheduleList.add(valueMap); + } + } + } + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("schedule",scheduleList); +%> + +<%=jsonObject.toJSONString() %> + +<%! + /*** + * + * @param hrmList + * @return + */ + public Map getMainUserDate(List> hrmList){ + String userids = ""; + List> specialobjList = new ArrayList>(); + for(int i=0;i hrmMap = hrmList.get(i); + String userid = Util.null2String(hrmMap.get("id")); + String lastname = Util.null2String(hrmMap.get("lastname")); + userids += StringUtils.isBlank(userids) ? userid : ","+userid ; + + Map specialobjMap = new HashMap(); + specialobjMap.put("id",userid); + specialobjMap.put("name",lastname); + specialobjList.add(specialobjMap); + } + + Map valueMap = new HashMap(); + valueMap.put("value",userids); + valueMap.put("specialobj",specialobjList); + return valueMap; + } + + /*** + * + * @param hrmList + * @return + */ + public List> getDt1UserDate(List> hrmList){ + List> dt1List = new ArrayList>(); + for(int i=0;i hrmMap = hrmList.get(i); + + String userid = Util.null2String(hrmMap.get("id")); + String lastname = Util.null2String(hrmMap.get("lastname")); + + Map dt1Map = new HashMap(); + dt1Map.put("id",userid); + dt1Map.put("name",lastname); + + List> specialobjList2 = new ArrayList>(); + Map specialobjMap2 = new HashMap(); + specialobjMap2.put("id",userid); + specialobjMap2.put("name",lastname); + specialobjList2.add(specialobjMap2); + + Map valueMap2 = new HashMap(); + valueMap2.put("value",userid); + valueMap2.put("specialobj",specialobjList2); + dt1Map.put("value",valueMap2); + + dt1List.add(dt1Map); + } + return dt1List; + } + + + + + + public String getWeekTypeByDate(String pbrq,String userid,String activeGroupId){ + + String dateType = "0"; + DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate currentDate = LocalDate.parse(pbrq, df); + + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); + int weekValue = dayOfWeek.getValue(); + + LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 + String monthStartDate = startDayOfMonth.toString(); + String monthEndDate = lastDayOfMonth.toString(); + Map holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate,activeGroupId); + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + + if("1".equals(changeType) || "3".equals(changeType)){ + dateType = "1"; + }else if(weekValue == 6 || weekValue == 7){ + dateType = "1"; + } + return dateType; + } + + /*** + * + * @param userid + * @param monthStartDate + * @param monthEndDate + * @return + */ + public Map getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate,String activeGroupId){ + + Map holidayMap = new HashMap(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + + try { + if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){ + if(StringUtils.isNotBlank(activeGroupId)){ + String sql =" select holidayDate,changeType from KQ_HolidaySet\n" + + " where groupid = " + activeGroupId+ + " and holidayDate >='"+monthStartDate+"'\n" + + " and holidayDate <='"+monthEndDate+"' " ; + rs.execute(sql); + while (rs.next()){ + String holidayDate = Util.null2String(rs.getString("holidayDate")); + String changeType = Util.null2String(rs.getString("changeType")); +// String changeTypename = "" ; +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// changeTypename += "公众假日"; +// }else if("2".equals(changeType)){ +// changeTypename += "调配工作日"; +// }else if("3".equals(changeType)){ +// changeTypename += "调配休息日"; +// } + holidayMap.put(holidayDate,changeType); + +// if(weekMap.containsKey(holidayDate)){ +// String holidayDate_new = weekMap.get(holidayDate); +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// holidayDate_new += "[公众假日]"; +// }else if("1".equals(changeType)){ +// holidayDate_new += "[调配工作日]"; +// }else if("2".equals(changeType)){ +// holidayDate_new += "[调配休息日]"; +// } +// weekMap.put(holidayDate,holidayDate_new); +// } + } + } + } + }catch (Exception e){ + + } + return holidayMap; + } + + /*** + * + * @param userid + * @return + */ + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } + + + + + + + + public static List> queryListBySql(String sql){ + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + List> list = new ArrayList>(); + try{ + if(StringUtils.isNotBlank(sql)){ + Map map = new HashMap(); + rs.executeQuery(sql); + String[] column = rs.getColumnName(); + while (rs.next()){ + map = new HashMap(); + for(int i=0;i0){ + list.add(map); + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("queryListBySql-e:"+e); + } + return list; + } + + /*** + * + * @return + */ + public Map getDt1UserMap(String ry,String lastname){ + Map valueMap = new HashMap(); + if(StringUtils.isNotBlank(ry)){ + List> specialobjList = new ArrayList>(); + Map specialobjMap = new HashMap(); + specialobjMap.put("id",ry); + specialobjMap.put("name",lastname); + specialobjList.add(specialobjMap); + valueMap.put("id",ry); + valueMap.put("name",lastname); + valueMap.put("specialobj",specialobjList); + } + + return valueMap; + } + + + /*** + * + * @param pbyf + * @param groupid + * @param resourceid + * @return + */ + public List> queryShiftScheduleByUser(String pbyf,String groupid,String resourceid,Map dateEffectiveMap){ + BaseBean bb = new BaseBean(); + List> scheduleList = new ArrayList>(); + try{ + List> sqlList = new ArrayList>(); + if(StringUtils.isNotBlank(pbyf) && StringUtils.isNotBlank(resourceid)){ + String startDate = "" ; + String endDate = ""; + if(dateEffectiveMap.containsKey(resourceid)){ + String effectiveDate = dateEffectiveMap.get(resourceid); + if(effectiveDate.contains(";")){ + String[] effective_Date = effectiveDate.split(";"); + startDate = effective_Date[0]; + endDate = effective_Date[1]; + } + } + + String sql =" select t.serialid,k.serial,t.resourceid,t.kqdate\n" + + " from kq_shiftschedule t\n" + + " inner join kq_ShiftManagement k on k.id = t.serialid\n" + + " where left(t.kqdate,7)='"+pbyf+"' \n" + + " and t.kqdate >='"+startDate+"' " + + " and t.kqdate <= '"+endDate+"'" + + " and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" + + " and resourceid = " + resourceid + + " order by kqdate "; + bb.writeLog("sql:"+sql); + sqlList = queryListBySql(sql); + } + + for(int i=0;i map = sqlList.get(i); + + String serialid = Util.null2String(map.get("serialid")); + String name = Util.null2String(map.get("serial")); + String kqdate = Util.null2String(map.get("kqdate")); + + String xh = ""; + if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){ + xh = kqdate.substring(8); + if(StringUtils.isNotBlank(xh)){ + if(xh.startsWith("0")){ + xh = xh.substring(1); + } + } + } + + if(StringUtils.isNotBlank(xh)){ + List> specialobjList = new ArrayList>(); + Map specialobjMap = new HashMap(); + specialobjMap.put("id",serialid); + specialobjMap.put("name",name); + specialobjList.add(specialobjMap); + + Map valueMap = new HashMap(); + valueMap.put("serialid",serialid); + valueMap.put("kqdate",kqdate); + valueMap.put("xh",xh); + + + + valueMap.put("specialobj",specialobjList); + + scheduleList.add(valueMap); + } + } + + }catch (Exception e){ + + } + return scheduleList; + } + + + public List getSchedulingRestData(){ + + List list = new ArrayList(); + RecordSet rs = new RecordSet(); + try{ + String sql =" select id " + + " from kq_ShiftManagement \n" + + " where is_rest = 1 \n" + + " and (isdelete is null or isdelete = 0) "; + + rs.executeQuery(sql); + while (rs.next()){ + String id = Util.null2String(rs.getString("id")); + list.add(id); + } + }catch (Exception e){ + + } + return list; + } + + /*** + * + * @param restList + * @param daysList + * @param weekMap + * @param serialList + */ + public Map queryCountWorkTime(List restList,List daysList,Map weekMap,List> serialList ){ + + BaseBean bb = new BaseBean(); + Map countMap = new HashMap<>(); + String worktime = "0"; + String totalworktime = "0"; + int restcount = 0; + int weekrestcount = 0; + + RecordSet rs = new RecordSet(); + try{ + String sql = ""; + for (int i = 0; i < serialList.size(); i++) { + Map serialMap = serialList.get(i); + String kqdate = Util.null2String(serialMap.get("kqdate")); + String serialid = Util.null2String(serialMap.get("serialid")); + if (daysList.contains(kqdate)) { + if (StringUtils.isNotBlank(serialid)) { + if (restList.contains(serialid)) { + restcount++; + } + + if(!restList.contains(serialid)){ + String sql2 = " select try_convert(int,worktime) as worktime from kq_ShiftManagement where id ="+serialid+" and (is_rest is null or is_rest = 0) " ; + sql += StringUtils.isBlank(sql) ? sql2 : " union all \n"+sql2 ; + } + } + + if (weekMap.containsKey(kqdate)) { + String value = weekMap.get(kqdate); + //6 = 周六 7 = 周日 11 = 公众假日、调配休息日 + if ("6".equals(value) || "7".equals(value) || "11".equals(value)) { + if (restList.contains(serialid)) { + weekrestcount++; + } + } + } + } + } + + if(StringUtils.isNotBlank(sql)){ + sql = " select round(sum(worktime)/60.0,2) as worktime,sum(worktime) as totalworktime from ("+sql+") w "; + rs.executeQuery(sql); + if(rs.next()){ + worktime = Util.null2String(rs.getString("worktime")); + totalworktime = Util.null2String(rs.getString("totalworktime")); + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("e:"+e); + } + + countMap.put("worktime",worktime); + countMap.put("totalworktime",totalworktime); + countMap.put("restcount",restcount+""); + countMap.put("weekrestcount",weekrestcount+""); + + return countMap; + } + + /*** + * + * @param daysList + * @param holidayMap + * @param yjl + * @param workSchedule + * @param hrmList + * @param groupid + * @return + */ + public List> queryScheduleStatusByDay(List daysList,Map holidayMap,String yjl,String[] workSchedule,List> hrmList,String groupid,Map dateEffectiveMap){ + + BaseBean bb = new BaseBean(); + List> resultList = new ArrayList>(); + + DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + RecordSet rs = new RecordSet(); + + try{ + List> workScheduleList = new ArrayList>(); + Map workScheduleMap = null; + for(int k=0;k0){ + String[] schedule = workSchedule[k].split("-"); + String scheduleStartTime = schedule[0]; + String scheduleEndTime = schedule[1]; + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + workScheduleMap = new HashMap(); + workScheduleMap.put("start",scheduleStartTime); + workScheduleMap.put("end",scheduleEndTime); + workScheduleList.add(workScheduleMap); + } + } + } + + + for(String pbrq:daysList){ + + String resourceids = ""; + for(int i=0;i hrmMap = hrmList.get(i); + String userid = Util.null2String(hrmMap.get("id")); + if(StringUtils.isNotBlank(userid)){ + if(dateEffectiveMap.containsKey(userid)){ + String effectiveDate = dateEffectiveMap.get(userid); + if(effectiveDate.contains(";")){ + String[] effective_Date = effectiveDate.split(";"); + if(pbrq.compareTo(effective_Date[0])>=0 && pbrq.compareTo(effective_Date[1])<=0){ + resourceids += StringUtils.isBlank(resourceids) ? userid : ","+userid ; + } + } + } + } + } + + String dateType = "0"; + if(StringUtils.isNotBlank(pbrq)){ + LocalDate currentDate = LocalDate.parse(pbrq, df); + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); + int weekValue = dayOfWeek.getValue(); + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + + if("1".equals(changeType) || "3".equals(changeType)){ + dateType = "1"; + }else if(weekValue == 6 || weekValue == 7){ + dateType = "1"; + } + } + + Map defaultScheduleMap = new HashMap(); + if(StringUtils.isNotBlank(yjl)){ + String sql = " select dysjd,pzrs from uf_pbjcsj where yjl = ? and pblx = ?" ; + rs.executeQuery(sql,new Object[]{yjl,dateType}); + while (rs.next()){ + int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd"))); + int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs"))); + + String sjd = ""; + if(dysd < workSchedule.length){ + sjd = workSchedule[dysd]; + if(StringUtils.isNotBlank(sjd)){ + defaultScheduleMap.put(sjd,pzrs); + } + } + } + } + + List> sqlList = new ArrayList>(); + if(StringUtils.isNotBlank(resourceids) && StringUtils.isNotBlank(pbrq)){ + + String sql =" select t.serialid,t.resourceid,t.kqdate \n" + + " from kq_shiftschedule t\n" + + " where t.kqdate='"+pbrq+"' \n" + + " and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" + + " and resourceid in( " + resourceids + ") "+ + " order by kqdate "; + sqlList = queryListBySql(sql); + } + + Map resultMap = queryScheduleStatusByUser(sqlList,workScheduleList,defaultScheduleMap,pbrq); + resultList.add(resultMap); + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("e:"+e); + } + + return resultList; + } + + /*** + * + * @param sqlList + * @param workScheduleList + * @param defaultScheduleMap + * @param kqdate + * @return + */ + public Map queryScheduleStatusByUser(List> sqlList,List> workScheduleList,Map defaultScheduleMap,String kqdate){ + + RecordSet rs = new RecordSet(); + + Map> userScheduleDayMap = new HashMap>(); + Map userScheduleMap = new HashMap(); + Map necessaryMap = new HashMap(); + String yxrys = "" ; + for(int i=0;i sqlMap = sqlList.get(i); + String resourceid = Util.null2String(sqlMap.get("resourceid")); + yxrys += StringUtils.isBlank(yxrys) ? resourceid :","+resourceid ; + } + if(StringUtils.isNotBlank(yxrys)) { + List userList = new ArrayList(); + String sql =" select h.id \n" + + " from hrmresource h \n" + + " inner join hrmjobtitles k on k.id = h.jobtitle\n" + + " where h.id in("+yxrys+")\n" + + " and k.jobtitlename in('店长','验光师')\n" + + " and h.status in(0,1,2,3,4)\n" + + " union \n" + + " select h.id \n" + + " from hrmresource h \n" + + " inner join cus_fielddata k on k.id = h.id\n" + + " where k.field39 = 2 \n" + + " and k.scopeid=3 \n" + + " and k.scope='HrmCustomFieldByInfoType' " + + " and h.id in("+yxrys+") and h.status in(0,1,2,3,4) " + + " union " + + " select h.id\n" + + " from hrmresource h \n" + + " inner join cus_fielddata k on k.id = h.id \n" + + " where k.scopeid=-1 " + + " and k.scope='HrmCustomFieldByInfoType'\n" + + " and substring(k.field1,charindex('_',k.field1)+1,len(k.field1)) in(select id from uf_gwjbsjb where jbmc in('配镜一级','配镜二级','配镜三级','配镜四级','配镜五级')) and charindex('_', k.field1) > 0 \n" + + " and h.status in(0,1,2,3,4) "+ + " and h.id in("+yxrys+") "; + + rs.executeQuery(sql); + while (rs.next()){ + String id = Util.null2String(rs.getString("id")); + userList.add(id); + } + + for(int i = 0;i sqlMap = sqlList.get(i); + String pbry = sqlMap.get("resourceid"); + String serialid = sqlMap.get("serialid"); + String startTime = ""; + String endTime = ""; + + sql = " select times,onoffworktype from kq_ShiftOnOffWorkSections where serialid = ? and (isdelete = 0 or isdelete is null) "; + rs.executeQuery(sql,new Object[]{serialid}); + while(rs.next()){ + String onoffworktype = Util.null2String(rs.getString("onoffworktype")); + if("start".equals(onoffworktype)){ + startTime = Util.null2String(rs.getString("times")); + }else if("end".equals(onoffworktype)){ + endTime = Util.null2String(rs.getString("times")); + } + } + + Map userSchedule_Map = new HashMap(); + if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){ + userSchedule_Map.put("startTime",startTime); + userSchedule_Map.put("endTime",endTime); + + for(int k=0;k workSchedule_Map = workScheduleList.get(k); + String scheduleStartTime = workSchedule_Map.get("start"); + String scheduleEndTime = workSchedule_Map.get("end"); + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + if(startTime.compareTo(scheduleStartTime) <=0 && endTime.compareTo(scheduleEndTime) >=0){ + + String defWorkSchedule = scheduleStartTime+"-"+scheduleEndTime ; + if(userScheduleMap.containsKey(defWorkSchedule)){ + int count = userScheduleMap.get(defWorkSchedule); + count++; + userScheduleMap.put(defWorkSchedule,count); + }else{ + userScheduleMap.put(defWorkSchedule,1); + } + + if(userList.contains(pbry)){ + necessaryMap.put(defWorkSchedule,1); + } + } + } + } + } + userScheduleDayMap.put(pbry,userSchedule_Map); + } + } + + int defaultcount = 0; + int datacount = 0; + Iterator> iterator = defaultScheduleMap.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); + int value =entry.getValue(); + String key = entry.getKey(); + if(userScheduleMap.containsKey(key)){ + int useValue = userScheduleMap.get(key); + if(useValue < value){ + datacount++; + } + }else{ + datacount++; + } + defaultcount++; + } + + + String xh = ""; + if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){ + xh = kqdate.substring(8); + if(StringUtils.isNotBlank(xh)){ + if(xh.startsWith("0")){ + xh = xh.substring(1); + } + } + } + Map resultMap = new HashMap<>(); + String status = "0"; + if(defaultcount >0 && datacount == 0){ + if(necessaryMap.size() == 4){ + status = "0"; + }else{ + status = "1"; + } + } + resultMap.put("kqdate",kqdate); + resultMap.put("status",status); + resultMap.put("xh",xh); + + return resultMap; + } + +%> + + diff --git a/浙文眼镜/interface/zw/workflow/mdtblc/countUserWorkTime.jsp b/浙文眼镜/interface/zw/workflow/mdtblc/countUserWorkTime.jsp new file mode 100644 index 0000000..da66913 --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/mdtblc/countUserWorkTime.jsp @@ -0,0 +1,264 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="com.alibaba.fastjson.JSONArray" %> +<%@ page import="java.util.Map" %> +<%@ page import="java.util.List" %> +<%@ page import="java.util.ArrayList" %> +<%@ page import="java.time.LocalDate" %> +<%@ page import="java.time.temporal.TemporalAdjusters" %> +<%@ page import="java.time.DayOfWeek" %> +<%@ page import="java.util.HashMap" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupBiz" %> +<%@ page import="weaver.common.DateUtil" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } + RecordSet rs = new RecordSet(); + String serialids = request.getParameter("serialids"); + + String userid = request.getParameter("userid"); + String pbyf = request.getParameter("pbyf"); + String serdata = request.getParameter("serdata"); + List restList = getSchedulingRestData(); + + String worktime = "0"; + String totalworktime = "0"; + if(StringUtils.isNotBlank(serialids)){ + String sql = ""; + String[] serialidArray = serialids.split(","); + for(int i=0;i weekMap = queryWeekTypeByMonth(userid,pbyf); + if(StringUtils.isNotBlank(serdata)){ + JSONArray jsonArray = JSONArray.parseArray(serdata); + for(int i=0;i + +<%=jsonObject.toJSONString() %> + + +<%! + public Map queryWeekTypeByMonth(String userid,String pbyf){ + + Map weekMap = new HashMap(); + if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7) { + LocalDate date = LocalDate.parse(pbyf + "-01"); // 获取当前日期 + LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + LocalDate startDayOfMonth = date.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 + String monthStartDate = startDayOfMonth.toString(); + String monthEndDate = lastDayOfMonth.toString(); + Map holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate); + + int thisMonth = date.getMonthValue(); // 获取当前是哪月 + int daysInMonth = date.lengthOfMonth(); // 获取本月有多少天 + + for (int i = 1; i <= daysInMonth; i++) { + LocalDate currentDate = LocalDate.of(date.getYear(), thisMonth, i); + System.out.println("currentDate:" + currentDate.toString()); + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); + System.out.println(i + "号是周 " + dayOfWeek.getValue()); + int weekValue = dayOfWeek.getValue(); + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + + if("1".equals(changeType) || "3".equals(changeType)){ + weekValue = 11; + } + + if(StringUtils.isNotBlank(changeType)){ + weekMap.put(currentDate.toString(), weekValue+""); + }else{ + weekMap.put(currentDate.toString(), weekValue+""); + } + } + } + return weekMap; + } + + public Map getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate){ + + Map holidayMap = new HashMap(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + + try { + if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){ + String activeGroupId = getUserActiveGroupId(userid); + bb.writeLog("activeGroupId:"+activeGroupId); + + String fixedScheduleGroupId = "5"; + + if(StringUtils.isNotBlank(fixedScheduleGroupId)){ + String sql =" select holidayDate,changeType from KQ_HolidaySet\n" + + " where groupid = " + fixedScheduleGroupId+ + " and holidayDate >='"+monthStartDate+"'\n" + + " and holidayDate <='"+monthEndDate+"' " ; + rs.execute(sql); + while (rs.next()){ + String holidayDate = Util.null2String(rs.getString("holidayDate")); + String changeType = Util.null2String(rs.getString("changeType")); + holidayMap.put(holidayDate,changeType); + } + } + } + }catch (Exception e){ + + } + return holidayMap; + } + + /*** + * + * @param userid + * @return + */ + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } + + public List getSchedulingRestData(){ + + List list = new ArrayList(); + RecordSet rs = new RecordSet(); + try{ + String sql =" select id " + + " from kq_ShiftManagement \n" + + " where is_rest = 1 \n" + + " and (isdelete is null or isdelete = 0) "; + + rs.executeQuery(sql); + while (rs.next()){ + String id = Util.null2String(rs.getString("id")); + list.add(id); + } + }catch (Exception e){ + + } + return list; + } + +%> + + + diff --git a/浙文眼镜/interface/zw/workflow/mdtblc/getSchedulingDateType.jsp b/浙文眼镜/interface/zw/workflow/mdtblc/getSchedulingDateType.jsp new file mode 100644 index 0000000..53d0fba --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/mdtblc/getSchedulingDateType.jsp @@ -0,0 +1,285 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="java.time.LocalDate" %> +<%@ page import="java.util.List" %> +<%@ page import="java.util.ArrayList" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="java.util.Map" %> +<%@ page import="java.util.HashMap" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="com.engine.kq.biz.KQGroupBiz" %> +<%@ page import="com.engine.kq.biz.KQGroupComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %> +<%@ page import="weaver.common.DateUtil" %> +<%@ page import="java.time.DayOfWeek" %> +<%@ page import="java.time.temporal.TemporalAdjusters" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } + + BaseBean bb = new BaseBean(); + + RecordSet rs = new RecordSet(); + String pbyf = request.getParameter("pbyf"); + String userid = request.getParameter("userid"); + String cjrbm = request.getParameter("cjrbm"); + +// List> hrmList = new ArrayList>(); +// if(StringUtils.isNotBlank(cjrbm)) { +// String sql =" select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) and id not in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"')"+ +// " union "+ +// " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydhbm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) "+ +// " union "+ +// " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydsxrq >='"+pbyf+"-02' and bm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) " ; +// +// hrmList = queryListBySql(sql); +// } + +// if(hrmList !=null && hrmList.size() > 0){ +// userid = hrmList.get(0).get("id"); +// } + + if(StringUtils.isBlank(userid)){ + userid = user.getUID()+""; + } + + String activeGroupId = ""; + int daysInMonth = 0; + Map weekMap = new HashMap(); + List> weekList = new ArrayList>(); + if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7) { + LocalDate date = LocalDate.parse(pbyf + "-01"); // 获取当前日期 + LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + LocalDate startDayOfMonth = date.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 + String monthStartDate = startDayOfMonth.toString(); + String monthEndDate = lastDayOfMonth.toString(); + + activeGroupId = getUserActiveGroupId(userid); + String fixedScheduleGroupId = "5"; + + Map holidayMap = getHolidayByGroupId(fixedScheduleGroupId,monthStartDate,monthEndDate); + + int thisMonth = date.getMonthValue(); // 获取当前是哪月 + daysInMonth = date.lengthOfMonth(); // 获取本月有多少天 + + for (int i = 1; i <= daysInMonth; i++) { + LocalDate currentDate = LocalDate.of(date.getYear(), thisMonth, i); + System.out.println("currentDate:" + currentDate.toString()); + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); + System.out.println(i + "号是周 " + dayOfWeek.getValue()); + int weekValue = dayOfWeek.getValue(); + String weekDayName = ""; + switch (weekValue) { + case 1: + weekDayName = "周一"; + break; + case 2: + weekDayName = "周二"; + break; + case 3: + weekDayName = "周三"; + break; + case 4: + weekDayName = "周四"; + break; + case 5: + weekDayName = "周五"; + break; + case 6: + weekDayName = "周六"; + break; + case 7: + weekDayName = "周日"; + break; + } + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + weekMap = new HashMap(); + weekMap.put("weekname", weekDayName); + weekMap.put("changeType", changeType); + weekMap.put("weekday", i+""); + weekMap.put("weekdate", currentDate.toString()); + weekList.add(weekMap); + } + } + + String serialids = ""; + if(StringUtils.isNotBlank(activeGroupId)){ + String sql = " select serialids from kq_group where id = "+activeGroupId ; + rs.executeQuery(sql); + if(rs.next()){ + serialids = Util.null2String(rs.getString("serialids")); + } + } + JSONObject jsonObject = new JSONObject(); + jsonObject.put("data",weekList); + jsonObject.put("count",daysInMonth); + jsonObject.put("group",activeGroupId); + jsonObject.put("serialids",serialids); +%> + +<%=jsonObject.toJSONString() %> + + +<%! + + /*** + * + * @param userid + * @return + */ + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } + + + public Map getHolidayByGroupId(String activeGroupId,String monthStartDate,String monthEndDate){ + + Map holidayMap = new HashMap(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + + try { + if(StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){ + //String activeGroupId = getUserActiveGroupId(userid); + // bb.writeLog("activeGroupId:"+activeGroupId); + if(StringUtils.isNotBlank(activeGroupId)){ + String sql =" select holidayDate,changeType from KQ_HolidaySet\n" + + " where groupid = " + activeGroupId+ + " and holidayDate >='"+monthStartDate+"'\n" + + " and holidayDate <='"+monthEndDate+"' " ; + rs.execute(sql); + while (rs.next()){ + String holidayDate = Util.null2String(rs.getString("holidayDate")); + String changeType = Util.null2String(rs.getString("changeType")); + String changeTypename = "" ; + if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 + changeTypename += "公众假日"; + }else if("2".equals(changeType)){ + changeTypename += "调配工作日"; + }else if("3".equals(changeType)){ + changeTypename += "调配休息日"; + } + holidayMap.put(holidayDate,changeTypename); + +// if(weekMap.containsKey(holidayDate)){ +// String holidayDate_new = weekMap.get(holidayDate); +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// holidayDate_new += "[公众假日]"; +// }else if("1".equals(changeType)){ +// holidayDate_new += "[调配工作日]"; +// }else if("2".equals(changeType)){ +// holidayDate_new += "[调配休息日]"; +// } +// weekMap.put(holidayDate,holidayDate_new); +// } + } + } + } + }catch (Exception e){ + + } + return holidayMap; + } + + + public static List> queryListBySql(String sql){ + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + List> list = new ArrayList>(); + try{ + if(StringUtils.isNotBlank(sql)){ + Map map = new HashMap(); + rs.executeQuery(sql); + String[] column = rs.getColumnName(); + while (rs.next()){ + map = new HashMap(); + for(int i=0;i0){ + list.add(map); + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("queryListBySql-e:"+e); + } + return list; + } + +%> + + diff --git a/浙文眼镜/interface/zw/workflow/mdtblc/querySchedulingUserData.jsp b/浙文眼镜/interface/zw/workflow/mdtblc/querySchedulingUserData.jsp new file mode 100644 index 0000000..e64621b --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/mdtblc/querySchedulingUserData.jsp @@ -0,0 +1,221 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="java.util.List" %> +<%@ page import="java.util.ArrayList" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="java.util.Map" %> +<%@ page import="java.util.HashMap" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupBiz" %> +<%@ page import="weaver.common.DateUtil" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } + + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + String cjrbm = request.getParameter("cjrbm"); + String pbyf = request.getParameter("pbyf"); + + List> hrmList = new ArrayList>(); + Map valueMap = new HashMap<>(); + List> dt1List = new ArrayList>(); + if(StringUtils.isNotBlank(cjrbm)) { + String sql =" select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) and id not in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"')"+ + " union "+ + " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydhbm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) "+ + " union "+ + " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydsxrq >='"+pbyf+"-02' and bm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) " ; + + hrmList = queryListBySql(sql); + valueMap = getMainUserDate(hrmList); + dt1List = getDt1UserDate(hrmList); + } + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("data",valueMap); + jsonObject.put("dt1",dt1List); + + String userid = user.getUID()+"" ; +// if(hrmList !=null && hrmList.size() > 0){ +// userid = hrmList.get(0).get("id"); +// } + + if(StringUtils.isNotBlank(userid)){ + String activeGroupId = getUserActiveGroupId(userid); + String serialids = ""; + if(StringUtils.isNotBlank(activeGroupId)){ + String sql = " select serialids from kq_group where id = "+activeGroupId ; + rs.executeQuery(sql); + if(rs.next()){ + serialids = Util.null2String(rs.getString("serialids")); + } + } + jsonObject.put("group",activeGroupId); + jsonObject.put("serialids",serialids); + } + +%> + +<%=jsonObject.toJSONString() %> + + +<%! + + public List> getDt1UserDate(List> hrmList){ + List> dt1List = new ArrayList>(); + for(int i=0;i hrmMap = hrmList.get(i); + + String userid = Util.null2String(hrmMap.get("id")); + String lastname = Util.null2String(hrmMap.get("lastname")); + + Map dt1Map = new HashMap(); + dt1Map.put("id",userid); + dt1Map.put("name",lastname); + + List> specialobjList2 = new ArrayList>(); + Map specialobjMap2 = new HashMap(); + specialobjMap2.put("id",userid); + specialobjMap2.put("name",lastname); + specialobjList2.add(specialobjMap2); + + Map valueMap2 = new HashMap(); + valueMap2.put("value",userid); + valueMap2.put("specialobj",specialobjList2); + dt1Map.put("value",valueMap2); + dt1List.add(dt1Map); + } + return dt1List; + } + /*** + * + * @param hrmList + * @return + */ + public Map getMainUserDate(List> hrmList){ + String userids = ""; + List> specialobjList = new ArrayList>(); + for(int i=0;i hrmMap = hrmList.get(i); + String userid = Util.null2String(hrmMap.get("id")); + String lastname = Util.null2String(hrmMap.get("lastname")); + userids += StringUtils.isBlank(userids) ? userid : ","+userid ; + + Map specialobjMap = new HashMap(); + specialobjMap.put("id",userid); + specialobjMap.put("name",lastname); + specialobjList.add(specialobjMap); + } + + Map valueMap = new HashMap(); + valueMap.put("value",userids); + valueMap.put("specialobj",specialobjList); + return valueMap; + } + + public List> queryListBySql(String sql){ + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + List> list = new ArrayList>(); + try{ + if(StringUtils.isNotBlank(sql)){ + Map map = new HashMap(); + rs.executeQuery(sql); + String[] column = rs.getColumnName(); + while (rs.next()){ + map = new HashMap(); + for(int i=0;i0){ + list.add(map); + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("queryListBySql-e:"+e); + } + return list; + } + + + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } + + +%> + + diff --git a/浙文眼镜/interface/zw/workflow/mdtblc/queryUserSerialByMonth.jsp b/浙文眼镜/interface/zw/workflow/mdtblc/queryUserSerialByMonth.jsp new file mode 100644 index 0000000..df33179 --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/mdtblc/queryUserSerialByMonth.jsp @@ -0,0 +1,842 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="weaver.common.DateUtil" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupBiz" %> +<%@ page import="java.time.LocalDate" %> +<%@ page import="java.time.format.DateTimeFormatter" %> +<%@ page import="java.time.DayOfWeek" %> +<%@ page import="java.time.temporal.TemporalAdjusters" %> +<%@ page import="java.util.*" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + String yg = request.getParameter("yg"); + String pbyf = request.getParameter("pbyf"); + String cjrbm = request.getParameter("cjrbm"); + +// List> hrmList = new ArrayList>(); +// if(StringUtils.isNotBlank(cjrbm)) { +// String sql =" select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) and id not in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"')"+ +// " union "+ +// " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydhbm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) "+ +// " union "+ +// " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydsxrq >='"+pbyf+"-02' and bm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) " ; +// +// hrmList = queryListBySql(sql); +// } + String userid = user.getUID()+""; +// if(hrmList !=null && hrmList.size() > 0){ +// userid = hrmList.get(hrmList.size()-1).get("id"); +// } + + String activeGroupId = getUserActiveGroupId(userid); + + List> scheduleList = new ArrayList>(); + if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7) { + LocalDate localDate = LocalDate.parse(pbyf + "-01"); // 获取当前日期 + LocalDate lastDayOfMonth = localDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + LocalDate firstDayOfMonth = localDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 + String monthStartDate = firstDayOfMonth.toString(); + String monthEndDate = lastDayOfMonth.toString(); + + String startDate = monthStartDate; + String endDate = monthEndDate ; + + String sql =" select convert(varchar,dateadd(day,-1,ydsxrq), 23) as ydsxrq " + + " from uf_ygddxx " + + " where left(ydsxrq,7) = '"+pbyf+"' "+ + " and xm = "+ yg + + " and bm= "+ cjrbm+ + " and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) "+ + " order by id desc "; + rs.executeQuery(sql); + if(rs.next()){ + String ydsxrq = Util.null2String(rs.getString("ydsxrq")); + if(StringUtils.isNotBlank(ydsxrq)){ + endDate = ydsxrq; + } + } + + sql =" select ydsxrq " + + " from uf_ygddxx " + + " where left(ydsxrq,7) = '"+pbyf+"' "+ + " and xm ="+ yg + + " and ydhbm="+cjrbm+ + " and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) "+ + " order by id desc "; + rs.executeQuery(sql); + if(rs.next()){ + String ydsxrq = Util.null2String(rs.getString("ydsxrq")); + if(StringUtils.isNotBlank(ydsxrq)){ + startDate = ydsxrq; + } + } + + sql =" select t.serialid,k.serial,t.resourceid,t.kqdate\n" + + " from kq_shiftschedule t\n" + + " inner join kq_ShiftManagement k on k.id = t.serialid\n" + + " where left(t.kqdate,7)='"+pbyf+"' \n" + +// " and t.kqdate >='"+startDate+"' " + +// " and t.kqdate <= '"+endDate+"'" + + " and t.groupid="+activeGroupId+" and (t.isDelete is null or t.isDelete = 0)\n" + + " and resourceid = " + yg + + " order by kqdate "; + + bb.writeLog("sql:"+sql); + List> sqlList = queryListBySql(sql); + + for(int i=0;i map = sqlList.get(i); + + String serialid = Util.null2String(map.get("serialid")); + String name = Util.null2String(map.get("serial")); + String kqdate = Util.null2String(map.get("kqdate")); + + String xh = ""; + if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){ + xh = kqdate.substring(8); + if(StringUtils.isNotBlank(xh)){ + if(xh.startsWith("0")){ + xh = xh.substring(1); + } + } + } + + if(StringUtils.isNotBlank(xh)){ + List> specialobjList = new ArrayList>(); + Map specialobjMap = new HashMap(); + specialobjMap.put("id",serialid); + specialobjMap.put("name",name); + specialobjList.add(specialobjMap); + + Map valueMap = new HashMap(); + valueMap.put("serialid",serialid); + valueMap.put("kqdate",kqdate); + valueMap.put("xh",xh); + valueMap.put("specialobj",specialobjList); + scheduleList.add(valueMap); + } + } + } + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("schedule",scheduleList); +%> + +<%=jsonObject.toJSONString() %> + +<%! + /*** + * + * @param hrmList + * @return + */ + public Map getMainUserDate(List> hrmList){ + String userids = ""; + List> specialobjList = new ArrayList>(); + for(int i=0;i hrmMap = hrmList.get(i); + String userid = Util.null2String(hrmMap.get("id")); + String lastname = Util.null2String(hrmMap.get("lastname")); + userids += StringUtils.isBlank(userids) ? userid : ","+userid ; + + Map specialobjMap = new HashMap(); + specialobjMap.put("id",userid); + specialobjMap.put("name",lastname); + specialobjList.add(specialobjMap); + } + + Map valueMap = new HashMap(); + valueMap.put("value",userids); + valueMap.put("specialobj",specialobjList); + return valueMap; + } + + /*** + * + * @param hrmList + * @return + */ + public List> getDt1UserDate(List> hrmList){ + List> dt1List = new ArrayList>(); + for(int i=0;i hrmMap = hrmList.get(i); + + String userid = Util.null2String(hrmMap.get("id")); + String lastname = Util.null2String(hrmMap.get("lastname")); + + Map dt1Map = new HashMap(); + dt1Map.put("id",userid); + dt1Map.put("name",lastname); + + List> specialobjList2 = new ArrayList>(); + Map specialobjMap2 = new HashMap(); + specialobjMap2.put("id",userid); + specialobjMap2.put("name",lastname); + specialobjList2.add(specialobjMap2); + + Map valueMap2 = new HashMap(); + valueMap2.put("value",userid); + valueMap2.put("specialobj",specialobjList2); + dt1Map.put("value",valueMap2); + + dt1List.add(dt1Map); + } + return dt1List; + } + + + + + + public String getWeekTypeByDate(String pbrq,String userid,String activeGroupId){ + + String dateType = "0"; + DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate currentDate = LocalDate.parse(pbrq, df); + + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); + int weekValue = dayOfWeek.getValue(); + + LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 + String monthStartDate = startDayOfMonth.toString(); + String monthEndDate = lastDayOfMonth.toString(); + Map holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate,activeGroupId); + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + + if("1".equals(changeType) || "3".equals(changeType)){ + dateType = "1"; + }else if(weekValue == 6 || weekValue == 7){ + dateType = "1"; + } + return dateType; + } + + /*** + * + * @param userid + * @param monthStartDate + * @param monthEndDate + * @return + */ + public Map getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate,String activeGroupId){ + + Map holidayMap = new HashMap(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + + try { + if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){ + if(StringUtils.isNotBlank(activeGroupId)){ + String sql =" select holidayDate,changeType from KQ_HolidaySet\n" + + " where groupid = " + activeGroupId+ + " and holidayDate >='"+monthStartDate+"'\n" + + " and holidayDate <='"+monthEndDate+"' " ; + rs.execute(sql); + while (rs.next()){ + String holidayDate = Util.null2String(rs.getString("holidayDate")); + String changeType = Util.null2String(rs.getString("changeType")); +// String changeTypename = "" ; +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// changeTypename += "公众假日"; +// }else if("2".equals(changeType)){ +// changeTypename += "调配工作日"; +// }else if("3".equals(changeType)){ +// changeTypename += "调配休息日"; +// } + holidayMap.put(holidayDate,changeType); + +// if(weekMap.containsKey(holidayDate)){ +// String holidayDate_new = weekMap.get(holidayDate); +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// holidayDate_new += "[公众假日]"; +// }else if("1".equals(changeType)){ +// holidayDate_new += "[调配工作日]"; +// }else if("2".equals(changeType)){ +// holidayDate_new += "[调配休息日]"; +// } +// weekMap.put(holidayDate,holidayDate_new); +// } + } + } + } + }catch (Exception e){ + + } + return holidayMap; + } + + /*** + * + * @param userid + * @return + */ + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } + + + + + + + + public static List> queryListBySql(String sql){ + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + List> list = new ArrayList>(); + try{ + if(StringUtils.isNotBlank(sql)){ + Map map = new HashMap(); + rs.executeQuery(sql); + String[] column = rs.getColumnName(); + while (rs.next()){ + map = new HashMap(); + for(int i=0;i0){ + list.add(map); + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("queryListBySql-e:"+e); + } + return list; + } + + /*** + * + * @return + */ + public Map getDt1UserMap(String ry,String lastname){ + Map valueMap = new HashMap(); + if(StringUtils.isNotBlank(ry)){ + List> specialobjList = new ArrayList>(); + Map specialobjMap = new HashMap(); + specialobjMap.put("id",ry); + specialobjMap.put("name",lastname); + specialobjList.add(specialobjMap); + valueMap.put("id",ry); + valueMap.put("name",lastname); + valueMap.put("specialobj",specialobjList); + } + + return valueMap; + } + + + /*** + * + * @param pbyf + * @param groupid + * @param resourceid + * @return + */ + public List> queryShiftScheduleByUser(String pbyf,String groupid,String resourceid,Map dateEffectiveMap){ + BaseBean bb = new BaseBean(); + List> scheduleList = new ArrayList>(); + try{ + List> sqlList = new ArrayList>(); + if(StringUtils.isNotBlank(pbyf) && StringUtils.isNotBlank(resourceid)){ + String startDate = "" ; + String endDate = ""; + if(dateEffectiveMap.containsKey(resourceid)){ + String effectiveDate = dateEffectiveMap.get(resourceid); + if(effectiveDate.contains(";")){ + String[] effective_Date = effectiveDate.split(";"); + startDate = effective_Date[0]; + endDate = effective_Date[1]; + } + } + + String sql =" select t.serialid,k.serial,t.resourceid,t.kqdate\n" + + " from kq_shiftschedule t\n" + + " inner join kq_ShiftManagement k on k.id = t.serialid\n" + + " where left(t.kqdate,7)='"+pbyf+"' \n" + + " and t.kqdate >='"+startDate+"' " + + " and t.kqdate <= '"+endDate+"'" + + " and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" + + " and resourceid = " + resourceid + + " order by kqdate "; + bb.writeLog("sql:"+sql); + sqlList = queryListBySql(sql); + } + + for(int i=0;i map = sqlList.get(i); + + String serialid = Util.null2String(map.get("serialid")); + String name = Util.null2String(map.get("serial")); + String kqdate = Util.null2String(map.get("kqdate")); + + String xh = ""; + if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){ + xh = kqdate.substring(8); + if(StringUtils.isNotBlank(xh)){ + if(xh.startsWith("0")){ + xh = xh.substring(1); + } + } + } + + if(StringUtils.isNotBlank(xh)){ + List> specialobjList = new ArrayList>(); + Map specialobjMap = new HashMap(); + specialobjMap.put("id",serialid); + specialobjMap.put("name",name); + specialobjList.add(specialobjMap); + + Map valueMap = new HashMap(); + valueMap.put("serialid",serialid); + valueMap.put("kqdate",kqdate); + valueMap.put("xh",xh); + + + + valueMap.put("specialobj",specialobjList); + + scheduleList.add(valueMap); + } + } + + }catch (Exception e){ + + } + return scheduleList; + } + + + public List getSchedulingRestData(){ + + List list = new ArrayList(); + RecordSet rs = new RecordSet(); + try{ + String sql =" select id " + + " from kq_ShiftManagement \n" + + " where is_rest = 1 \n" + + " and (isdelete is null or isdelete = 0) "; + + rs.executeQuery(sql); + while (rs.next()){ + String id = Util.null2String(rs.getString("id")); + list.add(id); + } + }catch (Exception e){ + + } + return list; + } + + /*** + * + * @param restList + * @param daysList + * @param weekMap + * @param serialList + */ + public Map queryCountWorkTime(List restList,List daysList,Map weekMap,List> serialList ){ + + BaseBean bb = new BaseBean(); + Map countMap = new HashMap<>(); + String worktime = "0"; + String totalworktime = "0"; + int restcount = 0; + int weekrestcount = 0; + + RecordSet rs = new RecordSet(); + try{ + String sql = ""; + for (int i = 0; i < serialList.size(); i++) { + Map serialMap = serialList.get(i); + String kqdate = Util.null2String(serialMap.get("kqdate")); + String serialid = Util.null2String(serialMap.get("serialid")); + if (daysList.contains(kqdate)) { + if (StringUtils.isNotBlank(serialid)) { + if (restList.contains(serialid)) { + restcount++; + } + + if(!restList.contains(serialid)){ + String sql2 = " select try_convert(int,worktime) as worktime from kq_ShiftManagement where id ="+serialid+" and (is_rest is null or is_rest = 0) " ; + sql += StringUtils.isBlank(sql) ? sql2 : " union all \n"+sql2 ; + } + } + + if (weekMap.containsKey(kqdate)) { + String value = weekMap.get(kqdate); + //6 = 周六 7 = 周日 11 = 公众假日、调配休息日 + if ("6".equals(value) || "7".equals(value) || "11".equals(value)) { + if (restList.contains(serialid)) { + weekrestcount++; + } + } + } + } + } + + if(StringUtils.isNotBlank(sql)){ + sql = " select round(sum(worktime)/60.0,2) as worktime,sum(worktime) as totalworktime from ("+sql+") w "; + rs.executeQuery(sql); + if(rs.next()){ + worktime = Util.null2String(rs.getString("worktime")); + totalworktime = Util.null2String(rs.getString("totalworktime")); + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("e:"+e); + } + + countMap.put("worktime",worktime); + countMap.put("totalworktime",totalworktime); + countMap.put("restcount",restcount+""); + countMap.put("weekrestcount",weekrestcount+""); + + return countMap; + } + + /*** + * + * @param daysList + * @param holidayMap + * @param yjl + * @param workSchedule + * @param hrmList + * @param groupid + * @return + */ + public List> queryScheduleStatusByDay(List daysList,Map holidayMap,String yjl,String[] workSchedule,List> hrmList,String groupid,Map dateEffectiveMap){ + + BaseBean bb = new BaseBean(); + List> resultList = new ArrayList>(); + + DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + RecordSet rs = new RecordSet(); + + try{ + List> workScheduleList = new ArrayList>(); + Map workScheduleMap = null; + for(int k=0;k0){ + String[] schedule = workSchedule[k].split("-"); + String scheduleStartTime = schedule[0]; + String scheduleEndTime = schedule[1]; + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + workScheduleMap = new HashMap(); + workScheduleMap.put("start",scheduleStartTime); + workScheduleMap.put("end",scheduleEndTime); + workScheduleList.add(workScheduleMap); + } + } + } + + + for(String pbrq:daysList){ + + String resourceids = ""; + for(int i=0;i hrmMap = hrmList.get(i); + String userid = Util.null2String(hrmMap.get("id")); + if(StringUtils.isNotBlank(userid)){ + if(dateEffectiveMap.containsKey(userid)){ + String effectiveDate = dateEffectiveMap.get(userid); + if(effectiveDate.contains(";")){ + String[] effective_Date = effectiveDate.split(";"); + if(pbrq.compareTo(effective_Date[0])>=0 && pbrq.compareTo(effective_Date[1])<=0){ + resourceids += StringUtils.isBlank(resourceids) ? userid : ","+userid ; + } + } + } + } + } + + String dateType = "0"; + if(StringUtils.isNotBlank(pbrq)){ + LocalDate currentDate = LocalDate.parse(pbrq, df); + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); + int weekValue = dayOfWeek.getValue(); + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + + if("1".equals(changeType) || "3".equals(changeType)){ + dateType = "1"; + }else if(weekValue == 6 || weekValue == 7){ + dateType = "1"; + } + } + + Map defaultScheduleMap = new HashMap(); + if(StringUtils.isNotBlank(yjl)){ + String sql = " select dysjd,pzrs from uf_pbjcsj where yjl = ? and pblx = ?" ; + rs.executeQuery(sql,new Object[]{yjl,dateType}); + while (rs.next()){ + int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd"))); + int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs"))); + + String sjd = ""; + if(dysd < workSchedule.length){ + sjd = workSchedule[dysd]; + if(StringUtils.isNotBlank(sjd)){ + defaultScheduleMap.put(sjd,pzrs); + } + } + } + } + + List> sqlList = new ArrayList>(); + if(StringUtils.isNotBlank(resourceids) && StringUtils.isNotBlank(pbrq)){ + + String sql =" select t.serialid,t.resourceid,t.kqdate \n" + + " from kq_shiftschedule t\n" + + " where t.kqdate='"+pbrq+"' \n" + + " and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" + + " and resourceid in( " + resourceids + ") "+ + " order by kqdate "; + sqlList = queryListBySql(sql); + } + + Map resultMap = queryScheduleStatusByUser(sqlList,workScheduleList,defaultScheduleMap,pbrq); + resultList.add(resultMap); + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("e:"+e); + } + + return resultList; + } + + /*** + * + * @param sqlList + * @param workScheduleList + * @param defaultScheduleMap + * @param kqdate + * @return + */ + public Map queryScheduleStatusByUser(List> sqlList,List> workScheduleList,Map defaultScheduleMap,String kqdate){ + + RecordSet rs = new RecordSet(); + + Map> userScheduleDayMap = new HashMap>(); + Map userScheduleMap = new HashMap(); + Map necessaryMap = new HashMap(); + String yxrys = "" ; + for(int i=0;i sqlMap = sqlList.get(i); + String resourceid = Util.null2String(sqlMap.get("resourceid")); + yxrys += StringUtils.isBlank(yxrys) ? resourceid :","+resourceid ; + } + if(StringUtils.isNotBlank(yxrys)) { + List userList = new ArrayList(); + String sql =" select h.id \n" + + " from hrmresource h \n" + + " inner join hrmjobtitles k on k.id = h.jobtitle\n" + + " where h.id in("+yxrys+")\n" + + " and k.jobtitlename in('店长','验光师')\n" + + " and h.status in(0,1,2,3,4)\n" + + " union \n" + + " select h.id \n" + + " from hrmresource h \n" + + " inner join cus_fielddata k on k.id = h.id\n" + + " where k.field39 = 2 \n" + + " and k.scopeid=3 \n" + + " and k.scope='HrmCustomFieldByInfoType' " + + " and h.id in("+yxrys+") and h.status in(0,1,2,3,4) " + + " union " + + " select h.id\n" + + " from hrmresource h \n" + + " inner join cus_fielddata k on k.id = h.id \n" + + " where k.scopeid=-1 " + + " and k.scope='HrmCustomFieldByInfoType'\n" + + " and substring(k.field1,charindex('_',k.field1)+1,len(k.field1)) in(select id from uf_gwjbsjb where jbmc in('配镜一级','配镜二级','配镜三级','配镜四级','配镜五级')) and charindex('_', k.field1) > 0 \n" + + " and h.status in(0,1,2,3,4) "+ + " and h.id in("+yxrys+") "; + + rs.executeQuery(sql); + while (rs.next()){ + String id = Util.null2String(rs.getString("id")); + userList.add(id); + } + + for(int i = 0;i sqlMap = sqlList.get(i); + String pbry = sqlMap.get("resourceid"); + String serialid = sqlMap.get("serialid"); + String startTime = ""; + String endTime = ""; + + sql = " select times,onoffworktype from kq_ShiftOnOffWorkSections where serialid = ? and (isdelete = 0 or isdelete is null) "; + rs.executeQuery(sql,new Object[]{serialid}); + while(rs.next()){ + String onoffworktype = Util.null2String(rs.getString("onoffworktype")); + if("start".equals(onoffworktype)){ + startTime = Util.null2String(rs.getString("times")); + }else if("end".equals(onoffworktype)){ + endTime = Util.null2String(rs.getString("times")); + } + } + + Map userSchedule_Map = new HashMap(); + if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){ + userSchedule_Map.put("startTime",startTime); + userSchedule_Map.put("endTime",endTime); + + for(int k=0;k workSchedule_Map = workScheduleList.get(k); + String scheduleStartTime = workSchedule_Map.get("start"); + String scheduleEndTime = workSchedule_Map.get("end"); + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + if(startTime.compareTo(scheduleStartTime) <=0 && endTime.compareTo(scheduleEndTime) >=0){ + + String defWorkSchedule = scheduleStartTime+"-"+scheduleEndTime ; + if(userScheduleMap.containsKey(defWorkSchedule)){ + int count = userScheduleMap.get(defWorkSchedule); + count++; + userScheduleMap.put(defWorkSchedule,count); + }else{ + userScheduleMap.put(defWorkSchedule,1); + } + + if(userList.contains(pbry)){ + necessaryMap.put(defWorkSchedule,1); + } + } + } + } + } + userScheduleDayMap.put(pbry,userSchedule_Map); + } + } + + int defaultcount = 0; + int datacount = 0; + Iterator> iterator = defaultScheduleMap.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); + int value =entry.getValue(); + String key = entry.getKey(); + if(userScheduleMap.containsKey(key)){ + int useValue = userScheduleMap.get(key); + if(useValue < value){ + datacount++; + } + }else{ + datacount++; + } + defaultcount++; + } + + + String xh = ""; + if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){ + xh = kqdate.substring(8); + if(StringUtils.isNotBlank(xh)){ + if(xh.startsWith("0")){ + xh = xh.substring(1); + } + } + } + Map resultMap = new HashMap<>(); + String status = "0"; + if(defaultcount >0 && datacount == 0){ + if(necessaryMap.size() == 4){ + status = "0"; + }else{ + status = "1"; + } + } + resultMap.put("kqdate",kqdate); + resultMap.put("status",status); + resultMap.put("xh",xh); + + return resultMap; + } + +%> + + diff --git a/浙文眼镜/interface/zw/workflow/mdtblc/queryUserSerialByMonth_test.jsp b/浙文眼镜/interface/zw/workflow/mdtblc/queryUserSerialByMonth_test.jsp new file mode 100644 index 0000000..7c5d532 --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/mdtblc/queryUserSerialByMonth_test.jsp @@ -0,0 +1,851 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="weaver.common.DateUtil" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupBiz" %> +<%@ page import="java.time.LocalDate" %> +<%@ page import="java.time.format.DateTimeFormatter" %> +<%@ page import="java.time.DayOfWeek" %> +<%@ page import="java.time.temporal.TemporalAdjusters" %> +<%@ page import="java.util.*" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + String yg = request.getParameter("yg"); + String pbyf = request.getParameter("pbyf"); + String cjrbm = request.getParameter("cjrbm"); + +// List> hrmList = new ArrayList>(); +// if(StringUtils.isNotBlank(cjrbm)) { +// String sql =" select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) and id not in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"')"+ +// " union "+ +// " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydhbm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) "+ +// " union "+ +// " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydsxrq >='"+pbyf+"-02' and bm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) " ; +// out.print("sql:"+sql+"
"); +// hrmList = queryListBySql(sql); +// } + String userid = user.getUID()+"" ; +// if(hrmList !=null && hrmList.size() > 0){ +// userid = hrmList.get(hrmList.size()-1).get("id"); +// } + out.print("userid:"+userid+"
"); + String activeGroupId = getUserActiveGroupId(userid); + out.print("activeGroupId:"+activeGroupId+"
"); + + List> scheduleList = new ArrayList>(); + if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7) { + LocalDate localDate = LocalDate.parse(pbyf + "-01"); // 获取当前日期 + LocalDate lastDayOfMonth = localDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + LocalDate firstDayOfMonth = localDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 + String monthStartDate = firstDayOfMonth.toString(); + String monthEndDate = lastDayOfMonth.toString(); + + String startDate = monthStartDate; + String endDate = monthEndDate ; + + + + String sql =" select ydsxrq " + + " from uf_ygddxx " + + " where left(ydsxrq,7) = '"+pbyf+"' "+ + " and xm ="+ yg + + " and ydhbm="+cjrbm+ + " and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) " + + " order by id desc "; + out.print("sql:"+sql+"
"); + rs.executeQuery(sql); + if(rs.next()){ + String ydsxrq = Util.null2String(rs.getString("ydsxrq")); + if(StringUtils.isNotBlank(ydsxrq)){ + startDate = ydsxrq; + } + } + out.print("startDate:"+startDate+"
"); + + sql =" select convert(varchar,dateadd(day,-1,ydsxrq), 23) as ydsxrq " + + " from uf_ygddxx " + + " where left(ydsxrq,7) = '"+pbyf+"' "+ + " and xm = "+ yg + + " and bm= "+ cjrbm+ + " and ydsxrq > "+startDate + + " and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) "+ + " order by id desc "; + out.print("sql:"+sql+"
"); + rs.executeQuery(sql); + if(rs.next()){ + String ydsxrq = Util.null2String(rs.getString("ydsxrq")); + if(StringUtils.isNotBlank(ydsxrq)){ + endDate = ydsxrq; + } + } + out.print("endDate:"+endDate+"
"); + + sql =" select t.serialid,k.serial,t.resourceid,t.kqdate\n" + + " from kq_shiftschedule t\n" + + " inner join kq_ShiftManagement k on k.id = t.serialid\n" + + " where left(t.kqdate,7)='"+pbyf+"' \n" + +// " and t.kqdate >='"+startDate+"' " + +// " and t.kqdate <= '"+endDate+"'" + + " and t.groupid="+activeGroupId+" and (t.isDelete is null or t.isDelete = 0)\n" + + " and resourceid = " + yg + + " order by kqdate "; + out.print("sql:"+sql+"
"); + + bb.writeLog("sql:"+sql); + List> sqlList = queryListBySql(sql); + + for(int i=0;i map = sqlList.get(i); + + String serialid = Util.null2String(map.get("serialid")); + String name = Util.null2String(map.get("serial")); + String kqdate = Util.null2String(map.get("kqdate")); + + String xh = ""; + if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){ + xh = kqdate.substring(8); + if(StringUtils.isNotBlank(xh)){ + if(xh.startsWith("0")){ + xh = xh.substring(1); + } + } + } + + if(StringUtils.isNotBlank(xh)){ + List> specialobjList = new ArrayList>(); + Map specialobjMap = new HashMap(); + specialobjMap.put("id",serialid); + specialobjMap.put("name",name); + specialobjList.add(specialobjMap); + + Map valueMap = new HashMap(); + valueMap.put("serialid",serialid); + valueMap.put("kqdate",kqdate); + valueMap.put("xh",xh); + valueMap.put("specialobj",specialobjList); + scheduleList.add(valueMap); + } + } + } + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("schedule",scheduleList); +%> + +<%=jsonObject.toJSONString() %> + +<%! + /*** + * + * @param hrmList + * @return + */ + public Map getMainUserDate(List> hrmList){ + String userids = ""; + List> specialobjList = new ArrayList>(); + for(int i=0;i hrmMap = hrmList.get(i); + String userid = Util.null2String(hrmMap.get("id")); + String lastname = Util.null2String(hrmMap.get("lastname")); + userids += StringUtils.isBlank(userids) ? userid : ","+userid ; + + Map specialobjMap = new HashMap(); + specialobjMap.put("id",userid); + specialobjMap.put("name",lastname); + specialobjList.add(specialobjMap); + } + + Map valueMap = new HashMap(); + valueMap.put("value",userids); + valueMap.put("specialobj",specialobjList); + return valueMap; + } + + /*** + * + * @param hrmList + * @return + */ + public List> getDt1UserDate(List> hrmList){ + List> dt1List = new ArrayList>(); + for(int i=0;i hrmMap = hrmList.get(i); + + String userid = Util.null2String(hrmMap.get("id")); + String lastname = Util.null2String(hrmMap.get("lastname")); + + Map dt1Map = new HashMap(); + dt1Map.put("id",userid); + dt1Map.put("name",lastname); + + List> specialobjList2 = new ArrayList>(); + Map specialobjMap2 = new HashMap(); + specialobjMap2.put("id",userid); + specialobjMap2.put("name",lastname); + specialobjList2.add(specialobjMap2); + + Map valueMap2 = new HashMap(); + valueMap2.put("value",userid); + valueMap2.put("specialobj",specialobjList2); + dt1Map.put("value",valueMap2); + + dt1List.add(dt1Map); + } + return dt1List; + } + + + + + + public String getWeekTypeByDate(String pbrq,String userid,String activeGroupId){ + + String dateType = "0"; + DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate currentDate = LocalDate.parse(pbrq, df); + + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); + int weekValue = dayOfWeek.getValue(); + + LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 + String monthStartDate = startDayOfMonth.toString(); + String monthEndDate = lastDayOfMonth.toString(); + Map holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate,activeGroupId); + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + + if("1".equals(changeType) || "3".equals(changeType)){ + dateType = "1"; + }else if(weekValue == 6 || weekValue == 7){ + dateType = "1"; + } + return dateType; + } + + /*** + * + * @param userid + * @param monthStartDate + * @param monthEndDate + * @return + */ + public Map getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate,String activeGroupId){ + + Map holidayMap = new HashMap(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + + try { + if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){ + if(StringUtils.isNotBlank(activeGroupId)){ + String sql =" select holidayDate,changeType from KQ_HolidaySet\n" + + " where groupid = " + activeGroupId+ + " and holidayDate >='"+monthStartDate+"'\n" + + " and holidayDate <='"+monthEndDate+"' " ; + rs.execute(sql); + while (rs.next()){ + String holidayDate = Util.null2String(rs.getString("holidayDate")); + String changeType = Util.null2String(rs.getString("changeType")); +// String changeTypename = "" ; +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// changeTypename += "公众假日"; +// }else if("2".equals(changeType)){ +// changeTypename += "调配工作日"; +// }else if("3".equals(changeType)){ +// changeTypename += "调配休息日"; +// } + holidayMap.put(holidayDate,changeType); + +// if(weekMap.containsKey(holidayDate)){ +// String holidayDate_new = weekMap.get(holidayDate); +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// holidayDate_new += "[公众假日]"; +// }else if("1".equals(changeType)){ +// holidayDate_new += "[调配工作日]"; +// }else if("2".equals(changeType)){ +// holidayDate_new += "[调配休息日]"; +// } +// weekMap.put(holidayDate,holidayDate_new); +// } + } + } + } + }catch (Exception e){ + + } + return holidayMap; + } + + /*** + * + * @param userid + * @return + */ + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } + + + + + + + + public static List> queryListBySql(String sql){ + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + List> list = new ArrayList>(); + try{ + if(StringUtils.isNotBlank(sql)){ + Map map = new HashMap(); + rs.executeQuery(sql); + String[] column = rs.getColumnName(); + while (rs.next()){ + map = new HashMap(); + for(int i=0;i0){ + list.add(map); + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("queryListBySql-e:"+e); + } + return list; + } + + /*** + * + * @return + */ + public Map getDt1UserMap(String ry,String lastname){ + Map valueMap = new HashMap(); + if(StringUtils.isNotBlank(ry)){ + List> specialobjList = new ArrayList>(); + Map specialobjMap = new HashMap(); + specialobjMap.put("id",ry); + specialobjMap.put("name",lastname); + specialobjList.add(specialobjMap); + valueMap.put("id",ry); + valueMap.put("name",lastname); + valueMap.put("specialobj",specialobjList); + } + + return valueMap; + } + + + /*** + * + * @param pbyf + * @param groupid + * @param resourceid + * @return + */ + public List> queryShiftScheduleByUser(String pbyf,String groupid,String resourceid,Map dateEffectiveMap){ + BaseBean bb = new BaseBean(); + List> scheduleList = new ArrayList>(); + try{ + List> sqlList = new ArrayList>(); + if(StringUtils.isNotBlank(pbyf) && StringUtils.isNotBlank(resourceid)){ + String startDate = "" ; + String endDate = ""; + if(dateEffectiveMap.containsKey(resourceid)){ + String effectiveDate = dateEffectiveMap.get(resourceid); + if(effectiveDate.contains(";")){ + String[] effective_Date = effectiveDate.split(";"); + startDate = effective_Date[0]; + endDate = effective_Date[1]; + } + } + + String sql =" select t.serialid,k.serial,t.resourceid,t.kqdate\n" + + " from kq_shiftschedule t\n" + + " inner join kq_ShiftManagement k on k.id = t.serialid\n" + + " where left(t.kqdate,7)='"+pbyf+"' \n" + + " and t.kqdate >='"+startDate+"' " + + " and t.kqdate <= '"+endDate+"'" + + " and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" + + " and resourceid = " + resourceid + + " order by kqdate "; + bb.writeLog("sql:"+sql); + sqlList = queryListBySql(sql); + } + + for(int i=0;i map = sqlList.get(i); + + String serialid = Util.null2String(map.get("serialid")); + String name = Util.null2String(map.get("serial")); + String kqdate = Util.null2String(map.get("kqdate")); + + String xh = ""; + if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){ + xh = kqdate.substring(8); + if(StringUtils.isNotBlank(xh)){ + if(xh.startsWith("0")){ + xh = xh.substring(1); + } + } + } + + if(StringUtils.isNotBlank(xh)){ + List> specialobjList = new ArrayList>(); + Map specialobjMap = new HashMap(); + specialobjMap.put("id",serialid); + specialobjMap.put("name",name); + specialobjList.add(specialobjMap); + + Map valueMap = new HashMap(); + valueMap.put("serialid",serialid); + valueMap.put("kqdate",kqdate); + valueMap.put("xh",xh); + + + + valueMap.put("specialobj",specialobjList); + + scheduleList.add(valueMap); + } + } + + }catch (Exception e){ + + } + return scheduleList; + } + + + public List getSchedulingRestData(){ + + List list = new ArrayList(); + RecordSet rs = new RecordSet(); + try{ + String sql =" select id " + + " from kq_ShiftManagement \n" + + " where is_rest = 1 \n" + + " and (isdelete is null or isdelete = 0) "; + + rs.executeQuery(sql); + while (rs.next()){ + String id = Util.null2String(rs.getString("id")); + list.add(id); + } + }catch (Exception e){ + + } + return list; + } + + /*** + * + * @param restList + * @param daysList + * @param weekMap + * @param serialList + */ + public Map queryCountWorkTime(List restList,List daysList,Map weekMap,List> serialList ){ + + BaseBean bb = new BaseBean(); + Map countMap = new HashMap<>(); + String worktime = "0"; + String totalworktime = "0"; + int restcount = 0; + int weekrestcount = 0; + + RecordSet rs = new RecordSet(); + try{ + String sql = ""; + for (int i = 0; i < serialList.size(); i++) { + Map serialMap = serialList.get(i); + String kqdate = Util.null2String(serialMap.get("kqdate")); + String serialid = Util.null2String(serialMap.get("serialid")); + if (daysList.contains(kqdate)) { + if (StringUtils.isNotBlank(serialid)) { + if (restList.contains(serialid)) { + restcount++; + } + + if(!restList.contains(serialid)){ + String sql2 = " select try_convert(int,worktime) as worktime from kq_ShiftManagement where id ="+serialid+" and (is_rest is null or is_rest = 0) " ; + sql += StringUtils.isBlank(sql) ? sql2 : " union all \n"+sql2 ; + } + } + + if (weekMap.containsKey(kqdate)) { + String value = weekMap.get(kqdate); + //6 = 周六 7 = 周日 11 = 公众假日、调配休息日 + if ("6".equals(value) || "7".equals(value) || "11".equals(value)) { + if (restList.contains(serialid)) { + weekrestcount++; + } + } + } + } + } + + if(StringUtils.isNotBlank(sql)){ + sql = " select round(sum(worktime)/60.0,2) as worktime,sum(worktime) as totalworktime from ("+sql+") w "; + rs.executeQuery(sql); + if(rs.next()){ + worktime = Util.null2String(rs.getString("worktime")); + totalworktime = Util.null2String(rs.getString("totalworktime")); + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("e:"+e); + } + + countMap.put("worktime",worktime); + countMap.put("totalworktime",totalworktime); + countMap.put("restcount",restcount+""); + countMap.put("weekrestcount",weekrestcount+""); + + return countMap; + } + + /*** + * + * @param daysList + * @param holidayMap + * @param yjl + * @param workSchedule + * @param hrmList + * @param groupid + * @return + */ + public List> queryScheduleStatusByDay(List daysList,Map holidayMap,String yjl,String[] workSchedule,List> hrmList,String groupid,Map dateEffectiveMap){ + + BaseBean bb = new BaseBean(); + List> resultList = new ArrayList>(); + + DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + RecordSet rs = new RecordSet(); + + try{ + List> workScheduleList = new ArrayList>(); + Map workScheduleMap = null; + for(int k=0;k0){ + String[] schedule = workSchedule[k].split("-"); + String scheduleStartTime = schedule[0]; + String scheduleEndTime = schedule[1]; + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + workScheduleMap = new HashMap(); + workScheduleMap.put("start",scheduleStartTime); + workScheduleMap.put("end",scheduleEndTime); + workScheduleList.add(workScheduleMap); + } + } + } + + + for(String pbrq:daysList){ + + String resourceids = ""; + for(int i=0;i hrmMap = hrmList.get(i); + String userid = Util.null2String(hrmMap.get("id")); + if(StringUtils.isNotBlank(userid)){ + if(dateEffectiveMap.containsKey(userid)){ + String effectiveDate = dateEffectiveMap.get(userid); + if(effectiveDate.contains(";")){ + String[] effective_Date = effectiveDate.split(";"); + if(pbrq.compareTo(effective_Date[0])>=0 && pbrq.compareTo(effective_Date[1])<=0){ + resourceids += StringUtils.isBlank(resourceids) ? userid : ","+userid ; + } + } + } + } + } + + String dateType = "0"; + if(StringUtils.isNotBlank(pbrq)){ + LocalDate currentDate = LocalDate.parse(pbrq, df); + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); + int weekValue = dayOfWeek.getValue(); + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + + if("1".equals(changeType) || "3".equals(changeType)){ + dateType = "1"; + }else if(weekValue == 6 || weekValue == 7){ + dateType = "1"; + } + } + + Map defaultScheduleMap = new HashMap(); + if(StringUtils.isNotBlank(yjl)){ + String sql = " select dysjd,pzrs from uf_pbjcsj where yjl = ? and pblx = ?" ; + rs.executeQuery(sql,new Object[]{yjl,dateType}); + while (rs.next()){ + int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd"))); + int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs"))); + + String sjd = ""; + if(dysd < workSchedule.length){ + sjd = workSchedule[dysd]; + if(StringUtils.isNotBlank(sjd)){ + defaultScheduleMap.put(sjd,pzrs); + } + } + } + } + + List> sqlList = new ArrayList>(); + if(StringUtils.isNotBlank(resourceids) && StringUtils.isNotBlank(pbrq)){ + + String sql =" select t.serialid,t.resourceid,t.kqdate \n" + + " from kq_shiftschedule t\n" + + " where t.kqdate='"+pbrq+"' \n" + + " and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" + + " and resourceid in( " + resourceids + ") "+ + " order by kqdate "; + sqlList = queryListBySql(sql); + } + + Map resultMap = queryScheduleStatusByUser(sqlList,workScheduleList,defaultScheduleMap,pbrq); + resultList.add(resultMap); + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("e:"+e); + } + + return resultList; + } + + /*** + * + * @param sqlList + * @param workScheduleList + * @param defaultScheduleMap + * @param kqdate + * @return + */ + public Map queryScheduleStatusByUser(List> sqlList,List> workScheduleList,Map defaultScheduleMap,String kqdate){ + + RecordSet rs = new RecordSet(); + + Map> userScheduleDayMap = new HashMap>(); + Map userScheduleMap = new HashMap(); + Map necessaryMap = new HashMap(); + String yxrys = "" ; + for(int i=0;i sqlMap = sqlList.get(i); + String resourceid = Util.null2String(sqlMap.get("resourceid")); + yxrys += StringUtils.isBlank(yxrys) ? resourceid :","+resourceid ; + } + if(StringUtils.isNotBlank(yxrys)) { + List userList = new ArrayList(); + String sql =" select h.id \n" + + " from hrmresource h \n" + + " inner join hrmjobtitles k on k.id = h.jobtitle\n" + + " where h.id in("+yxrys+")\n" + + " and k.jobtitlename in('店长','验光师')\n" + + " and h.status in(0,1,2,3,4)\n" + + " union \n" + + " select h.id \n" + + " from hrmresource h \n" + + " inner join cus_fielddata k on k.id = h.id\n" + + " where k.field39 = 2 \n" + + " and k.scopeid=3 \n" + + " and k.scope='HrmCustomFieldByInfoType' " + + " and h.id in("+yxrys+") and h.status in(0,1,2,3,4) " + + " union " + + " select h.id\n" + + " from hrmresource h \n" + + " inner join cus_fielddata k on k.id = h.id \n" + + " where k.scopeid=-1 " + + " and k.scope='HrmCustomFieldByInfoType'\n" + + " and substring(k.field1,charindex('_',k.field1)+1,len(k.field1)) in(select id from uf_gwjbsjb where jbmc in('配镜一级','配镜二级','配镜三级','配镜四级','配镜五级')) and charindex('_', k.field1) > 0 \n" + + " and h.status in(0,1,2,3,4) "+ + " and h.id in("+yxrys+") "; + + rs.executeQuery(sql); + while (rs.next()){ + String id = Util.null2String(rs.getString("id")); + userList.add(id); + } + + for(int i = 0;i sqlMap = sqlList.get(i); + String pbry = sqlMap.get("resourceid"); + String serialid = sqlMap.get("serialid"); + String startTime = ""; + String endTime = ""; + + sql = " select times,onoffworktype from kq_ShiftOnOffWorkSections where serialid = ? and (isdelete = 0 or isdelete is null) "; + rs.executeQuery(sql,new Object[]{serialid}); + while(rs.next()){ + String onoffworktype = Util.null2String(rs.getString("onoffworktype")); + if("start".equals(onoffworktype)){ + startTime = Util.null2String(rs.getString("times")); + }else if("end".equals(onoffworktype)){ + endTime = Util.null2String(rs.getString("times")); + } + } + + Map userSchedule_Map = new HashMap(); + if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){ + userSchedule_Map.put("startTime",startTime); + userSchedule_Map.put("endTime",endTime); + + for(int k=0;k workSchedule_Map = workScheduleList.get(k); + String scheduleStartTime = workSchedule_Map.get("start"); + String scheduleEndTime = workSchedule_Map.get("end"); + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + if(startTime.compareTo(scheduleStartTime) <=0 && endTime.compareTo(scheduleEndTime) >=0){ + + String defWorkSchedule = scheduleStartTime+"-"+scheduleEndTime ; + if(userScheduleMap.containsKey(defWorkSchedule)){ + int count = userScheduleMap.get(defWorkSchedule); + count++; + userScheduleMap.put(defWorkSchedule,count); + }else{ + userScheduleMap.put(defWorkSchedule,1); + } + + if(userList.contains(pbry)){ + necessaryMap.put(defWorkSchedule,1); + } + } + } + } + } + userScheduleDayMap.put(pbry,userSchedule_Map); + } + } + + int defaultcount = 0; + int datacount = 0; + Iterator> iterator = defaultScheduleMap.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); + int value =entry.getValue(); + String key = entry.getKey(); + if(userScheduleMap.containsKey(key)){ + int useValue = userScheduleMap.get(key); + if(useValue < value){ + datacount++; + } + }else{ + datacount++; + } + defaultcount++; + } + + + String xh = ""; + if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){ + xh = kqdate.substring(8); + if(StringUtils.isNotBlank(xh)){ + if(xh.startsWith("0")){ + xh = xh.substring(1); + } + } + } + Map resultMap = new HashMap<>(); + String status = "0"; + if(defaultcount >0 && datacount == 0){ + if(necessaryMap.size() == 4){ + status = "0"; + }else{ + status = "1"; + } + } + resultMap.put("kqdate",kqdate); + resultMap.put("status",status); + resultMap.put("xh",xh); + + return resultMap; + } + +%> + + diff --git a/浙文眼镜/interface/zw/workflow/mdtblc/queryUserTransferData.jsp b/浙文眼镜/interface/zw/workflow/mdtblc/queryUserTransferData.jsp new file mode 100644 index 0000000..586fd87 --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/mdtblc/queryUserTransferData.jsp @@ -0,0 +1,83 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="java.time.LocalDate" %> +<%@ page import="java.time.format.DateTimeFormatter" %> +<%@ page import="java.time.temporal.TemporalAdjusters" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } + + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + String cjrbm = request.getParameter("cjrbm"); + String pbyf = request.getParameter("pbyf"); + String yg = request.getParameter("yg"); + + String startdate = ""; + String enddate = ""; + String sfdd = "1"; + if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7){ + + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate dateTime = LocalDate.parse(pbyf+"-01", formatter); + LocalDate firstDayOfMonth = dateTime.with(TemporalAdjusters.firstDayOfMonth()); + LocalDate lastDayOfMonth = dateTime.with(TemporalAdjusters.lastDayOfMonth()); + startdate = firstDayOfMonth.toString(); + enddate = lastDayOfMonth.toString(); + + if(StringUtils.isNotBlank(cjrbm)) { + String sql =" select ydsxrq " + + " from uf_ygddxx " + + " where left(ydsxrq,7) = '"+pbyf+"' "+ + " and xm ="+ yg + + " and ydhbm="+cjrbm+ + " and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) " + + " order by id desc "; + rs.executeQuery(sql); + if(rs.next()){ + String ydsxrq = Util.null2String(rs.getString("ydsxrq")); + if(StringUtils.isNotBlank(ydsxrq)){ + startdate = ydsxrq; + sfdd = "0"; + } + } + + sql =" select convert(varchar,dateadd(day,-1,ydsxrq), 23) as ydsxrq " + + " from uf_ygddxx " + + " where left(ydsxrq,7) = '"+pbyf+"' "+ + " and xm = "+ yg + + " and bm= "+ cjrbm+ + " and ydsxrq > '"+startdate + "'"+ + " and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) " + + " order by id desc "; + rs.executeQuery(sql); + if(rs.next()){ + String ydsxrq = Util.null2String(rs.getString("ydsxrq")); + if(StringUtils.isNotBlank(ydsxrq)){ + enddate = ydsxrq; + sfdd = "0"; + } + } + } + } + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("startdate",startdate); + jsonObject.put("enddate",enddate); + jsonObject.put("sfdd",sfdd); + +%> +<%=jsonObject.toJSONString() %> + + + diff --git a/浙文眼镜/interface/zw/workflow/mdtblc/queryUserTransferData_test.jsp b/浙文眼镜/interface/zw/workflow/mdtblc/queryUserTransferData_test.jsp new file mode 100644 index 0000000..0200682 --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/mdtblc/queryUserTransferData_test.jsp @@ -0,0 +1,87 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="java.time.LocalDate" %> +<%@ page import="java.time.format.DateTimeFormatter" %> +<%@ page import="java.time.temporal.TemporalAdjusters" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } + + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + String cjrbm = request.getParameter("cjrbm"); + String pbyf = request.getParameter("pbyf"); + String yg = request.getParameter("yg"); + + String startdate = ""; + String enddate = ""; + String sfdd = "1"; + if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7){ + + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate dateTime = LocalDate.parse(pbyf+"-01", formatter); + LocalDate firstDayOfMonth = dateTime.with(TemporalAdjusters.firstDayOfMonth()); + LocalDate lastDayOfMonth = dateTime.with(TemporalAdjusters.lastDayOfMonth()); + startdate = firstDayOfMonth.toString(); + enddate = lastDayOfMonth.toString(); + + if(StringUtils.isNotBlank(cjrbm)) { + String sql =" select ydsxrq " + + " from uf_ygddxx " + + " where left(ydsxrq,7) = '"+pbyf+"' "+ + " and xm ="+ yg + + " and ydhbm="+cjrbm+ + " and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) " + + " order by id desc "; + out.print("sql:"+sql+"
"); + rs.executeQuery(sql); + if(rs.next()){ + String ydsxrq = Util.null2String(rs.getString("ydsxrq")); + out.print("ydsxrq:"+ydsxrq+"
"); + if(StringUtils.isNotBlank(ydsxrq)){ + startdate = ydsxrq; + sfdd = "0"; + } + } + + sql =" select convert(varchar,dateadd(day,-1,ydsxrq), 23) as ydsxrq " + + " from uf_ygddxx " + + " where left(ydsxrq,7) = '"+pbyf+"' "+ + " and xm = "+ yg + + " and bm= "+ cjrbm+ + " and ydsxrq > "+startdate + + " and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) " + + " order by id desc "; + rs.executeQuery(sql); + out.print("sql:"+sql+"
"); + if(rs.next()){ + String ydsxrq = Util.null2String(rs.getString("ydsxrq")); + out.print("ydsxrq:"+ydsxrq+"
"); + if(StringUtils.isNotBlank(ydsxrq)){ + enddate = ydsxrq; + sfdd = "0"; + } + } + } + } + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("startdate",startdate); + jsonObject.put("enddate",enddate); + jsonObject.put("sfdd",sfdd); + +%> +<%=jsonObject.toJSONString() %> + + + diff --git a/浙文眼镜/interface/zw/workflow/mdtblc/queryUserWorkdayData.jsp b/浙文眼镜/interface/zw/workflow/mdtblc/queryUserWorkdayData.jsp new file mode 100644 index 0000000..b1ecbce --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/mdtblc/queryUserWorkdayData.jsp @@ -0,0 +1,440 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="weaver.common.DateUtil" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="com.alibaba.fastjson.JSONArray" %> +<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupBiz" %> +<%@ page import="java.time.LocalDate" %> +<%@ page import="java.time.format.DateTimeFormatter" %> +<%@ page import="java.time.DayOfWeek" %> +<%@ page import="java.time.temporal.TemporalAdjusters" %> +<%@ page import="java.util.*" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + + String[] workSchedule = {"09:00-11:00","11:00-16:00","16:00-20:00","20:00-21:30"}; + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } + int userid = user.getUID(); + RecordSet rs = new RecordSet(); + String pbdata = request.getParameter("pbdata"); + String bp = request.getParameter("bp"); +// String yjl = request.getParameter("yjl"); + + String ry = ""; + if(StringUtils.isNotBlank(pbdata)) { + JSONArray jsonArray = JSONArray.parseArray(pbdata); + if(jsonArray.size()>0){ + JSONObject jsonObject = jsonArray.getJSONObject(0); + ry = jsonObject.getString("userid"); + } + } + if(StringUtils.isBlank(ry)){ + ry = userid+""; + } + + String pbrq = request.getParameter("pbrq"); + String dateType = "0"; + if(StringUtils.isNotBlank(pbrq)){ + dateType = getWeekTypeByDate(pbrq,ry); + } + + Map defaultScheduleMap = new HashMap(); + if(StringUtils.isNotBlank(bp)){ + String sql = " select dysjd,pzrs from uf_pbjcsj where bprs = ? and pblx = ?" ; + rs.executeQuery(sql,new Object[]{bp,dateType}); + while (rs.next()){ + int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd"))); + int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs"))); + + String sjd = ""; + if(dysd < workSchedule.length){ + sjd = workSchedule[dysd]; + if(StringUtils.isNotBlank(sjd)){ + defaultScheduleMap.put(sjd,pzrs); + } + } + } + } + + List> workScheduleList = new ArrayList>(); + Map workScheduleMap = null; + for(int k=0;k0){ + String[] schedule = workSchedule[k].split("-"); + String scheduleStartTime = schedule[0]; + String scheduleEndTime = schedule[1]; + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + workScheduleMap = new HashMap(); + workScheduleMap.put("start",""); + workScheduleMap.put("end",scheduleEndTime); + workScheduleList.add(workScheduleMap); + } + } + }else if(k==(workSchedule.length-1)){ + if(workSchedule[k].indexOf("-")>0){ + String[] schedule = workSchedule[k].split("-"); + String scheduleStartTime = schedule[0]; + String scheduleEndTime = schedule[1]; + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + workScheduleMap = new HashMap(); + workScheduleMap.put("start",scheduleStartTime); + workScheduleMap.put("end",""); + workScheduleList.add(workScheduleMap); + } + } + }else{ + if(workSchedule[k].indexOf("-")>0){ + String[] schedule = workSchedule[k].split("-"); + String scheduleStartTime = schedule[0]; + String scheduleEndTime = schedule[1]; + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + workScheduleMap = new HashMap(); + workScheduleMap.put("start",scheduleStartTime); + workScheduleMap.put("end",scheduleEndTime); + workScheduleList.add(workScheduleMap); + } + } + } + } + + Map> userScheduleDayMap = new HashMap>(); + Map necessaryMap = new HashMap(); + + Map userScheduleMap = new HashMap(); + if(StringUtils.isNotBlank(pbdata)) { + JSONArray jsonArray = JSONArray.parseArray(pbdata); + + String yxrys = "" ; + for(int i = 0;i userList = new ArrayList(); + String sql =" select h.id \n" + + " from hrmresource h \n" + + " inner join hrmjobtitles k on k.id = h.jobtitle\n" + + " where h.id in("+yxrys+")\n" + + " and k.jobtitlename in('店长','验光师')\n" + + " and h.status in(0,1,2,3)\n" + + " union \n" + + " select h.id \n" + + " from hrmresource h \n" + + " inner join cus_fielddata k on k.id = h.id\n" + + " where k.field39 = 2 \n" + + " and k.scopeid=3 \n" + + " and k.scope='HrmCustomFieldByInfoType' " + + " and h.id in("+yxrys+") and h.status in(0,1,2,3) " + + " union " + + " select h.id\n" + + " from hrmresource h \n" + + " inner join cus_fielddata k on k.id = h.id \n" + + " where k.scopeid=-1 " + + " and k.scope='HrmCustomFieldByInfoType'\n" + + " and substring(k.field1,charindex('_',k.field1)+1,len(k.field1)) in(select id from uf_gwjbsjb where jbmc in('配镜一级','配镜二级','配镜三级','配镜四级','配镜五级')) and charindex('_', k.field1) > 0 \n" + + " and h.status in(0,1,2,3) "+ + " and h.id in("+yxrys+") "; + + rs.executeQuery(sql); + while (rs.next()){ + String id = Util.null2String(rs.getString("id")); + userList.add(id); + } + + for(int i = 0;i userSchedule_Map = new HashMap(); + if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){ + userSchedule_Map.put("startTime",startTime); + userSchedule_Map.put("endTime",endTime); + + + for(int k=0;k workSchedule_Map = workScheduleList.get(k); + String scheduleStartTime = workSchedule_Map.get("start"); + String scheduleEndTime = workSchedule_Map.get("end"); + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + if(startTime.compareTo(scheduleStartTime) <=0 && endTime.compareTo(scheduleEndTime) >=0){ + + String defWorkSchedule = scheduleStartTime+"-"+scheduleEndTime ; + if(userScheduleMap.containsKey(defWorkSchedule)){ + int count = userScheduleMap.get(defWorkSchedule); + count++; + userScheduleMap.put(defWorkSchedule,count); + }else{ + userScheduleMap.put(defWorkSchedule,1); + } + + if(userList.contains(pbry)){ + necessaryMap.put(defWorkSchedule,1); + } + } + }else{ + if(StringUtils.isNotBlank(scheduleStartTime)){ + + if(endTime.compareTo(scheduleStartTime) >=0 ){ + String define_scheduleEndTime = "21:30"; + String defWorkSchedule = scheduleStartTime+"-"+define_scheduleEndTime ; + if(userScheduleMap.containsKey(defWorkSchedule)){ + int count = userScheduleMap.get(defWorkSchedule); + count++; + userScheduleMap.put(defWorkSchedule,count); + }else{ + userScheduleMap.put(defWorkSchedule,1); + } + + if(userList.contains(pbry)){ + necessaryMap.put(defWorkSchedule,1); + } + } + }else if(StringUtils.isNotBlank(scheduleEndTime)){ + + if(startTime.compareTo(scheduleEndTime) <=0){ + String define_scheduleStartTime = "09:00"; + String defWorkSchedule = define_scheduleStartTime+"-"+scheduleEndTime ; + if(userScheduleMap.containsKey(defWorkSchedule)){ + int count = userScheduleMap.get(defWorkSchedule); + count++; + userScheduleMap.put(defWorkSchedule,count); + }else{ + userScheduleMap.put(defWorkSchedule,1); + } + + if(userList.contains(pbry)){ + necessaryMap.put(defWorkSchedule,1); + } + } + + } + } + } + } + userScheduleDayMap.put(pbry,userSchedule_Map); + } + } + + int defaultcount = 0; + int datacount = 0; + Iterator> iterator = defaultScheduleMap.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); + int value =entry.getValue(); + String key = entry.getKey(); + if(userScheduleMap.containsKey(key)){ + int useValue = userScheduleMap.get(key); + if(useValue < value){ + datacount++; + } + }else{ + datacount++; + } + defaultcount++; + } + + JSONObject jsonObject = new JSONObject(); + if(defaultcount >0 && datacount == 0){ + if(necessaryMap.size() == 4){ + jsonObject.put("pbcode","1"); + }else{ + jsonObject.put("pbcode","2"); + } + }else{ + jsonObject.put("pbcode","0"); + } + + jsonObject.put("pbinfo",userScheduleDayMap); +%> + +<%=jsonObject.toJSONString() %> + +<%! + + public String getWeekTypeByDate(String pbrq,String userid){ + + String dateType = "0"; + DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate currentDate = LocalDate.parse(pbrq, df); + + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); + int weekValue = dayOfWeek.getValue(); + + LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 + String monthStartDate = startDayOfMonth.toString(); + String monthEndDate = lastDayOfMonth.toString(); + Map holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate); + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + + if("2".equals(changeType)){ + dateType = "0"; + }else if("1".equals(changeType) || "3".equals(changeType)){ + dateType = "1"; + }else if(weekValue == 6 || weekValue == 7){ + dateType = "1"; + } + + return dateType; + } + + /*** + * + * @param userid + * @param monthStartDate + * @param monthEndDate + * @return + */ + public Map getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate){ + + Map holidayMap = new HashMap(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + + try { + if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){ +// String activeGroupId = getUserActiveGroupId(userid); +// bb.writeLog("activeGroupId:"+activeGroupId); + + String fixedScheduleGroupId = "5"; + if(StringUtils.isNotBlank(fixedScheduleGroupId)){ + String sql =" select holidayDate,changeType from KQ_HolidaySet\n" + + " where groupid = " + fixedScheduleGroupId+ + " and holidayDate >='"+monthStartDate+"'\n" + + " and holidayDate <='"+monthEndDate+"' " ; + rs.execute(sql); + while (rs.next()){ + String holidayDate = Util.null2String(rs.getString("holidayDate")); + String changeType = Util.null2String(rs.getString("changeType")); +// String changeTypename = "" ; +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// changeTypename += "公众假日"; +// }else if("2".equals(changeType)){ +// changeTypename += "调配工作日"; +// }else if("3".equals(changeType)){ +// changeTypename += "调配休息日"; +// } + holidayMap.put(holidayDate,changeType); + +// if(weekMap.containsKey(holidayDate)){ +// String holidayDate_new = weekMap.get(holidayDate); +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// holidayDate_new += "[公众假日]"; +// }else if("1".equals(changeType)){ +// holidayDate_new += "[调配工作日]"; +// }else if("2".equals(changeType)){ +// holidayDate_new += "[调配休息日]"; +// } +// weekMap.put(holidayDate,holidayDate_new); +// } + } + } + } + }catch (Exception e){ + + } + return holidayMap; + } + + /*** + * + * @param userid + * @return + */ + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } + + +%> + + diff --git a/浙文眼镜/interface/zw/workflow/pblc/countUserWorkTime.jsp b/浙文眼镜/interface/zw/workflow/pblc/countUserWorkTime.jsp new file mode 100644 index 0000000..cb89b56 --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/pblc/countUserWorkTime.jsp @@ -0,0 +1,263 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="com.alibaba.fastjson.JSONArray" %> +<%@ page import="java.util.Map" %> +<%@ page import="java.util.List" %> +<%@ page import="java.util.ArrayList" %> +<%@ page import="java.time.LocalDate" %> +<%@ page import="java.time.temporal.TemporalAdjusters" %> +<%@ page import="java.time.DayOfWeek" %> +<%@ page import="java.util.HashMap" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupBiz" %> +<%@ page import="weaver.common.DateUtil" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } + RecordSet rs = new RecordSet(); + String serialids = request.getParameter("serialids"); + + String userid = request.getParameter("userid"); + String pbyf = request.getParameter("pbyf"); + String serdata = request.getParameter("serdata"); + List restList = getSchedulingRestData(); + + String worktime = "0"; + String totalworktime = "0"; + if(StringUtils.isNotBlank(serialids)){ + String sql = ""; + String[] serialidArray = serialids.split(","); + for(int i=0;i weekMap = queryWeekTypeByMonth(userid,pbyf); + if(StringUtils.isNotBlank(serdata)){ + JSONArray jsonArray = JSONArray.parseArray(serdata); + for(int i=0;i + +<%=jsonObject.toJSONString() %> + + +<%! + public Map queryWeekTypeByMonth(String userid,String pbyf){ + + Map weekMap = new HashMap(); + if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7) { + LocalDate date = LocalDate.parse(pbyf + "-01"); // 获取当前日期 + LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + LocalDate startDayOfMonth = date.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 + String monthStartDate = startDayOfMonth.toString(); + String monthEndDate = lastDayOfMonth.toString(); + Map holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate); + + int thisMonth = date.getMonthValue(); // 获取当前是哪月 + int daysInMonth = date.lengthOfMonth(); // 获取本月有多少天 + + for (int i = 1; i <= daysInMonth; i++) { + LocalDate currentDate = LocalDate.of(date.getYear(), thisMonth, i); + System.out.println("currentDate:" + currentDate.toString()); + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); + System.out.println(i + "号是周 " + dayOfWeek.getValue()); + int weekValue = dayOfWeek.getValue(); + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + + if("1".equals(changeType) || "3".equals(changeType)){ + weekValue = 11; + } + + if(StringUtils.isNotBlank(changeType)){ + weekMap.put(currentDate.toString(), weekValue+""); + }else{ + weekMap.put(currentDate.toString(), weekValue+""); + } + } + } + return weekMap; + } + + public Map getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate){ + + Map holidayMap = new HashMap(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + + try { + if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){ +// String activeGroupId = getUserActiveGroupId(userid); + + String fixedScheduleGroupId = "5"; + bb.writeLog("activeGroupId:"+fixedScheduleGroupId); + if(StringUtils.isNotBlank(fixedScheduleGroupId)){ + String sql =" select holidayDate,changeType from KQ_HolidaySet\n" + + " where groupid = " + fixedScheduleGroupId+ + " and holidayDate >='"+monthStartDate+"'\n" + + " and holidayDate <='"+monthEndDate+"' " ; + rs.execute(sql); + while (rs.next()){ + String holidayDate = Util.null2String(rs.getString("holidayDate")); + String changeType = Util.null2String(rs.getString("changeType")); + holidayMap.put(holidayDate,changeType); + } + } + } + }catch (Exception e){ + + } + return holidayMap; + } + + /*** + * + * @param userid + * @return + */ + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } + + public List getSchedulingRestData(){ + + List list = new ArrayList(); + RecordSet rs = new RecordSet(); + try{ + String sql =" select id " + + " from kq_ShiftManagement \n" + + " where is_rest = 1 \n" + + " and (isdelete is null or isdelete = 0) "; + + rs.executeQuery(sql); + while (rs.next()){ + String id = Util.null2String(rs.getString("id")); + list.add(id); + } + }catch (Exception e){ + + } + return list; + } + +%> + + + diff --git a/浙文眼镜/interface/zw/workflow/pblc/getSchedulingDateType.jsp b/浙文眼镜/interface/zw/workflow/pblc/getSchedulingDateType.jsp new file mode 100644 index 0000000..7bfff21 --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/pblc/getSchedulingDateType.jsp @@ -0,0 +1,306 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="java.time.LocalDate" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="com.engine.kq.biz.KQGroupBiz" %> +<%@ page import="com.engine.kq.biz.KQGroupComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %> +<%@ page import="weaver.common.DateUtil" %> +<%@ page import="java.time.DayOfWeek" %> +<%@ page import="java.time.temporal.TemporalAdjusters" %> +<%@ page import="java.util.*" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } + + RecordSet rs = new RecordSet(); + String pbyf = request.getParameter("pbyf"); + String userid = user.getUID()+""; + Set groupSet = new HashSet(); + + List> userGroupList = getUserKqGroupData(userid); + String activeGroupId = getUserActiveGroupId(userid); + int daysInMonth = 0; + Map weekMap = new HashMap(); + List> weekList = new ArrayList>(); + if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7) { + LocalDate date = LocalDate.parse(pbyf + "-01"); // 获取当前日期 + LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + LocalDate startDayOfMonth = date.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 + String monthStartDate = startDayOfMonth.toString(); + String monthEndDate = lastDayOfMonth.toString(); + + String fixedScheduleGroupId = "5"; + Map holidayMap = getHolidayByGroupId(fixedScheduleGroupId,monthStartDate,monthEndDate); + + int thisMonth = date.getMonthValue(); // 获取当前是哪月 + daysInMonth = date.lengthOfMonth(); // 获取本月有多少天 + + + for (int i = 1; i <= daysInMonth; i++) { + LocalDate currentDate = LocalDate.of(date.getYear(), thisMonth, i); + System.out.println("currentDate:" + currentDate.toString()); + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); + System.out.println(i + "号是周 " + dayOfWeek.getValue()); + int weekValue = dayOfWeek.getValue(); + String weekDayName = ""; + switch (weekValue) { + case 1: + weekDayName = "周一"; + break; + case 2: + weekDayName = "周二"; + break; + case 3: + weekDayName = "周三"; + break; + case 4: + weekDayName = "周四"; + break; + case 5: + weekDayName = "周五"; + break; + case 6: + weekDayName = "周六"; + break; + case 7: + weekDayName = "周日"; + break; + } + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + weekMap = new HashMap(); + weekMap.put("weekname", weekDayName); + weekMap.put("changeType", changeType); + weekMap.put("weekday", i+""); + weekMap.put("weekdate", currentDate.toString()); + weekList.add(weekMap); + + String kqdate = currentDate.toString(); + for(int n=0;n userGrupMap = userGroupList.get(n); + String validatefrom = userGrupMap.get("validatefrom"); + String validateto = userGrupMap.get("validateto"); + if(kqdate.compareTo(validatefrom)>=0 && kqdate.compareTo(validateto) < 0){ + String groupid = userGrupMap.get("groupid"); + groupSet.add(groupid); + } + } + } + } + + String serialids = ""; + if(StringUtils.isNotBlank(activeGroupId)){ + String sql = " select serialids from kq_group where id = "+activeGroupId ; + rs.executeQuery(sql); + if(rs.next()){ + serialids = Util.null2String(rs.getString("serialids")); + } + } + JSONObject jsonObject = new JSONObject(); + jsonObject.put("data",weekList); + jsonObject.put("count",daysInMonth); + jsonObject.put("group",activeGroupId); + jsonObject.put("serialids",serialids); + jsonObject.put("size",groupSet.size()); +%> + +<%=jsonObject.toJSONString() %> + + +<%! + + /*** + * + * @param userid + * @return + */ + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } + + + public Map getHolidayByGroupId(String activeGroupId,String monthStartDate,String monthEndDate){ + + Map holidayMap = new HashMap(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + + try { + if(StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){ + //String activeGroupId = getUserActiveGroupId(userid); + // bb.writeLog("activeGroupId:"+activeGroupId); + if(StringUtils.isNotBlank(activeGroupId)){ + String sql =" select holidayDate,changeType from KQ_HolidaySet\n" + + " where groupid = " + activeGroupId+ + " and holidayDate >='"+monthStartDate+"'\n" + + " and holidayDate <='"+monthEndDate+"' " ; + rs.execute(sql); + while (rs.next()){ + String holidayDate = Util.null2String(rs.getString("holidayDate")); + String changeType = Util.null2String(rs.getString("changeType")); + String changeTypename = "" ; + if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 + changeTypename += "公众假日"; + }else if("2".equals(changeType)){ + changeTypename += "调配工作日"; + }else if("3".equals(changeType)){ + changeTypename += "调配休息日"; + } + holidayMap.put(holidayDate,changeTypename); + +// if(weekMap.containsKey(holidayDate)){ +// String holidayDate_new = weekMap.get(holidayDate); +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// holidayDate_new += "[公众假日]"; +// }else if("1".equals(changeType)){ +// holidayDate_new += "[调配工作日]"; +// }else if("2".equals(changeType)){ +// holidayDate_new += "[调配休息日]"; +// } +// weekMap.put(holidayDate,holidayDate_new); +// } + } + } + } + }catch (Exception e){ + + } + return holidayMap; + } + + + public List> getUserKqGroupData(String userid){ + + List> userGroupList = new ArrayList>(); + + try{ + if(StringUtils.isNotBlank(userid)){ + String sql =" select distinct resourceid, groupid,status,validatefrom,validateto FROM ( \n" + + " select a.id AS resourceid, b.groupid, a.status,b.validatefrom,b.validateto 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,b.validatefrom,b.validateto FROM HrmResource a, kq_groupmember b \n" + + " where a.subcompanyid1 = b.typevalue and b.type=2 and a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1') \n" + + " union all \n" + + " SELECT a.id AS resourceid, b.groupid, a.status,b.validatefrom,b.validateto FROM HrmResource a, kq_groupmember b \n" + + " WHERE a.departmentid = b.typevalue AND b.type=3 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1') \n" + + " UNION ALL \n" + + " SELECT a.id AS resourceid, b.groupid, a.status,b.validatefrom,b.validateto FROM HrmResource a, kq_groupmember b \n" + + " WHERE a.jobtitle = b.typevalue AND b.type=5 \n" + + " 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" + + " and (b.isdelete is null or b.isdelete <> '1') \n" + + " UNION ALL \n" + + " SELECT a.id AS resourceid, b.groupid, a.status,b.validatefrom,b.validateto 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\n" + + " where resourceid="+userid ; + userGroupList = queryListBySql(sql); + } + }catch (Exception e){ + + } + return userGroupList; + } + + + public List> queryListBySql(String sql){ + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + List> list = new ArrayList>(); + try{ + if(StringUtils.isNotBlank(sql)){ + Map map = new HashMap(); + rs.executeQuery(sql); + String[] column = rs.getColumnName(); + while (rs.next()){ + map = new HashMap(); + for(int i=0;i0){ + list.add(map); + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("queryListBySql-e:"+e); + } + return list; + } + +%> + + diff --git a/浙文眼镜/interface/zw/workflow/pblc/queryMainSchedulingUserData.jsp b/浙文眼镜/interface/zw/workflow/pblc/queryMainSchedulingUserData.jsp new file mode 100644 index 0000000..fc1d4d8 --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/pblc/queryMainSchedulingUserData.jsp @@ -0,0 +1,54 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="java.util.List" %> +<%@ page import="java.util.ArrayList" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="java.util.Map" %> +<%@ page import="java.util.HashMap" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } + + List> mainList = new ArrayList>(); + RecordSet rs = new RecordSet(); + String pbry = request.getParameter("pbry"); + if(StringUtils.isNotBlank(pbry)) { + String sql = "select id,lastname from hrmresource where id in("+pbry+")"; + rs.executeQuery(sql); + while (rs.next()){ + String userid = Util.null2String(rs.getString("id")); + String lastname = Util.null2String(rs.getString("lastname")); + + Map mainMap = new HashMap(); + mainMap.put("id",userid); + mainMap.put("name",lastname); + + List> specialobjList = new ArrayList>(); + Map specialobjMap = new HashMap(); + specialobjMap.put("id",userid); + specialobjMap.put("name",lastname); + specialobjList.add(specialobjMap); + + Map valueMap = new HashMap(); + valueMap.put("value",userid); + valueMap.put("specialobj",specialobjList); + mainMap.put("value",valueMap); + mainList.add(mainMap); + } + } + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("main",mainList); +%> + +<%=jsonObject.toJSONString() %> + + diff --git a/浙文眼镜/interface/zw/workflow/pblc/querySchedulingUserData.jsp b/浙文眼镜/interface/zw/workflow/pblc/querySchedulingUserData.jsp new file mode 100644 index 0000000..9643254 --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/pblc/querySchedulingUserData.jsp @@ -0,0 +1,222 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="java.util.List" %> +<%@ page import="java.util.ArrayList" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="java.util.Map" %> +<%@ page import="java.util.HashMap" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupBiz" %> +<%@ page import="weaver.common.DateUtil" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } + + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + String cjrbm = request.getParameter("cjrbm"); + String pbyf = request.getParameter("pbyf"); + + List> hrmList = new ArrayList>(); + Map valueMap = new HashMap<>(); + List> dt1List = new ArrayList>(); + if(StringUtils.isNotBlank(cjrbm)) { +// String sql =" select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('督导','营运经理'))"+ +// " union "+ +// " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydhbm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('督导','营运经理')) " ; + + String sql =" select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) and id not in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"')"+ + " union "+ + " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydhbm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) "+ + " union "+ + " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydsxrq >='"+pbyf+"-02' and bm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) " ; + + hrmList = queryListBySql(sql); + valueMap = getMainUserDate(hrmList); + dt1List = getDt1UserDate(hrmList); + } + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("data",valueMap); + jsonObject.put("dt1",dt1List); + + String userid = user.getUID()+""; + + if(StringUtils.isNotBlank(userid)){ + String activeGroupId = getUserActiveGroupId(userid); + String serialids = ""; + if(StringUtils.isNotBlank(activeGroupId)){ + String sql = " select serialids from kq_group where id = "+activeGroupId ; + rs.executeQuery(sql); + if(rs.next()){ + serialids = Util.null2String(rs.getString("serialids")); + } + } + jsonObject.put("group",activeGroupId); + jsonObject.put("serialids",serialids); + } + +%> + +<%=jsonObject.toJSONString() %> + + +<%! + + public List> getDt1UserDate(List> hrmList){ + List> dt1List = new ArrayList>(); + for(int i=0;i hrmMap = hrmList.get(i); + + String userid = Util.null2String(hrmMap.get("id")); + String lastname = Util.null2String(hrmMap.get("lastname")); + + Map dt1Map = new HashMap(); + dt1Map.put("id",userid); + dt1Map.put("name",lastname); + + List> specialobjList2 = new ArrayList>(); + Map specialobjMap2 = new HashMap(); + specialobjMap2.put("id",userid); + specialobjMap2.put("name",lastname); + specialobjList2.add(specialobjMap2); + + Map valueMap2 = new HashMap(); + valueMap2.put("value",userid); + valueMap2.put("specialobj",specialobjList2); + dt1Map.put("value",valueMap2); + dt1List.add(dt1Map); + } + return dt1List; + } + /*** + * + * @param hrmList + * @return + */ + public Map getMainUserDate(List> hrmList){ + String userids = ""; + List> specialobjList = new ArrayList>(); + for(int i=0;i hrmMap = hrmList.get(i); + String userid = Util.null2String(hrmMap.get("id")); + String lastname = Util.null2String(hrmMap.get("lastname")); + userids += StringUtils.isBlank(userids) ? userid : ","+userid ; + + Map specialobjMap = new HashMap(); + specialobjMap.put("id",userid); + specialobjMap.put("name",lastname); + specialobjList.add(specialobjMap); + } + + Map valueMap = new HashMap(); + valueMap.put("value",userids); + valueMap.put("specialobj",specialobjList); + return valueMap; + } + + public List> queryListBySql(String sql){ + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + List> list = new ArrayList>(); + try{ + if(StringUtils.isNotBlank(sql)){ + Map map = new HashMap(); + rs.executeQuery(sql); + String[] column = rs.getColumnName(); + while (rs.next()){ + map = new HashMap(); + for(int i=0;i0){ + list.add(map); + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("queryListBySql-e:"+e); + } + return list; + } + + + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } + + +%> + + diff --git a/浙文眼镜/interface/zw/workflow/pblc/querySchedulingUserData2.jsp b/浙文眼镜/interface/zw/workflow/pblc/querySchedulingUserData2.jsp new file mode 100644 index 0000000..4a55faa --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/pblc/querySchedulingUserData2.jsp @@ -0,0 +1,225 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="java.util.List" %> +<%@ page import="java.util.ArrayList" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="java.util.Map" %> +<%@ page import="java.util.HashMap" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupBiz" %> +<%@ page import="weaver.common.DateUtil" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } + + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + String cjrbm = request.getParameter("cjrbm"); + String pbyf = request.getParameter("pbyf"); + + List> hrmList = new ArrayList>(); + Map valueMap = new HashMap<>(); + List> dt1List = new ArrayList>(); + if(StringUtils.isNotBlank(cjrbm)) { +// String sql =" select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('督导','营运经理'))"+ +// " union "+ +// " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydhbm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('督导','营运经理')) " ; + + String sql =" select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))"+ + " union "+ + " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydhbm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) " ; + + + hrmList = queryListBySql(sql); + valueMap = getMainUserDate(hrmList); + dt1List = getDt1UserDate(hrmList); + } + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("data",valueMap); + jsonObject.put("dt1",dt1List); + + + String userid = "" ; + if(hrmList !=null && hrmList.size() > 0){ + userid = hrmList.get(0).get("id"); + } + + if(StringUtils.isNotBlank(userid)){ + String activeGroupId = getUserActiveGroupId(userid); + String serialids = ""; + if(StringUtils.isNotBlank(activeGroupId)){ + String sql = " select serialids from kq_group where id = "+activeGroupId ; + rs.executeQuery(sql); + if(rs.next()){ + serialids = Util.null2String(rs.getString("serialids")); + } + } + jsonObject.put("group",activeGroupId); + jsonObject.put("serialids",serialids); + } + +%> + +<%=jsonObject.toJSONString() %> + + +<%! + + public List> getDt1UserDate(List> hrmList){ + List> dt1List = new ArrayList>(); + for(int i=0;i hrmMap = hrmList.get(i); + + String userid = Util.null2String(hrmMap.get("id")); + String lastname = Util.null2String(hrmMap.get("lastname")); + + Map dt1Map = new HashMap(); + dt1Map.put("id",userid); + dt1Map.put("name",lastname); + + List> specialobjList2 = new ArrayList>(); + Map specialobjMap2 = new HashMap(); + specialobjMap2.put("id",userid); + specialobjMap2.put("name",lastname); + specialobjList2.add(specialobjMap2); + + Map valueMap2 = new HashMap(); + valueMap2.put("value",userid); + valueMap2.put("specialobj",specialobjList2); + dt1Map.put("value",valueMap2); + dt1List.add(dt1Map); + } + return dt1List; + } + /*** + * + * @param hrmList + * @return + */ + public Map getMainUserDate(List> hrmList){ + String userids = ""; + List> specialobjList = new ArrayList>(); + for(int i=0;i hrmMap = hrmList.get(i); + String userid = Util.null2String(hrmMap.get("id")); + String lastname = Util.null2String(hrmMap.get("lastname")); + userids += StringUtils.isBlank(userids) ? userid : ","+userid ; + + Map specialobjMap = new HashMap(); + specialobjMap.put("id",userid); + specialobjMap.put("name",lastname); + specialobjList.add(specialobjMap); + } + + Map valueMap = new HashMap(); + valueMap.put("value",userids); + valueMap.put("specialobj",specialobjList); + return valueMap; + } + + public List> queryListBySql(String sql){ + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + List> list = new ArrayList>(); + try{ + if(StringUtils.isNotBlank(sql)){ + Map map = new HashMap(); + rs.executeQuery(sql); + String[] column = rs.getColumnName(); + while (rs.next()){ + map = new HashMap(); + for(int i=0;i0){ + list.add(map); + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("queryListBySql-e:"+e); + } + return list; + } + + + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } + + +%> + + diff --git a/浙文眼镜/interface/zw/workflow/pblc/queryUserTransferData.jsp b/浙文眼镜/interface/zw/workflow/pblc/queryUserTransferData.jsp new file mode 100644 index 0000000..d9aab96 --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/pblc/queryUserTransferData.jsp @@ -0,0 +1,83 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="java.time.LocalDate" %> +<%@ page import="java.time.format.DateTimeFormatter" %> +<%@ page import="java.time.temporal.TemporalAdjusters" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } + + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + String cjrbm = request.getParameter("cjrbm"); + String pbyf = request.getParameter("pbyf"); + String yg = request.getParameter("yg"); + + String startdate = ""; + String enddate = ""; + String sfdd = "1"; + if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7){ + + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate dateTime = LocalDate.parse(pbyf+"-01", formatter); + LocalDate firstDayOfMonth = dateTime.with(TemporalAdjusters.firstDayOfMonth()); + LocalDate lastDayOfMonth = dateTime.with(TemporalAdjusters.lastDayOfMonth()); + startdate = firstDayOfMonth.toString(); + enddate = lastDayOfMonth.toString(); + + if(StringUtils.isNotBlank(cjrbm)) { + String sql =" select ydsxrq " + + " from uf_ygddxx " + + " where left(ydsxrq,7) = '"+pbyf+"' "+ + " and xm ="+ yg + + " and ydhbm="+cjrbm+ + " and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) " + + " order by id desc "; + rs.executeQuery(sql); + if(rs.next()){ + String ydsxrq = Util.null2String(rs.getString("ydsxrq")); + if(StringUtils.isNotBlank(ydsxrq)){ + startdate = ydsxrq; + sfdd = "0"; + } + } + + sql =" select convert(varchar,dateadd(day,-1,ydsxrq), 23) as ydsxrq " + + " from uf_ygddxx " + + " where left(ydsxrq,7) = '"+pbyf+"' "+ + " and xm = "+ yg + + " and bm= "+ cjrbm+ + " and ydsxrq > '"+startdate +"'"+ + " and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) " + + " order by id desc "; + rs.executeQuery(sql); + if(rs.next()){ + String ydsxrq = Util.null2String(rs.getString("ydsxrq")); + if(StringUtils.isNotBlank(ydsxrq)){ + enddate = ydsxrq; + sfdd = "0"; + } + } + } + } + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("startdate",startdate); + jsonObject.put("enddate",enddate); + jsonObject.put("sfdd",sfdd); + +%> +<%=jsonObject.toJSONString() %> + + + diff --git a/浙文眼镜/interface/zw/workflow/pblc/queryUserTransferData2.jsp b/浙文眼镜/interface/zw/workflow/pblc/queryUserTransferData2.jsp new file mode 100644 index 0000000..42e458d --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/pblc/queryUserTransferData2.jsp @@ -0,0 +1,87 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="java.time.LocalDate" %> +<%@ page import="java.time.format.DateTimeFormatter" %> +<%@ page import="java.time.temporal.TemporalAdjusters" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } + + RecordSet rs = new RecordSet(); + String cjrbm = request.getParameter("cjrbm"); + String pbyf = request.getParameter("pbyf"); + String yg = request.getParameter("yg"); + out.print("cjrbm:"+cjrbm+"
"); + out.print("pbyf:"+pbyf+"
"); + out.print("yg:"+yg+"
"); + + String startdate = ""; + String enddate = ""; + + if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7){ + +// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); +// LocalDate dateTime = LocalDate.parse(pbyf+"-01", formatter); +// LocalDate firstDayOfMonth = dateTime.with(TemporalAdjusters.firstDayOfMonth()); +// LocalDate lastDayOfMonth = dateTime.with(TemporalAdjusters.lastDayOfMonth()); +// startdate = firstDayOfMonth.toString(); +// enddate = lastDayOfMonth.toString(); +// out.print("startdate:"+startdate+"
"); +// out.print("enddate:"+enddate+"
"); + + if(StringUtils.isNotBlank(cjrbm)) { + + String sql =" select ydsxrq " + + " from uf_ygddxx " + + " where left(ydsxrq,7) = '"+pbyf+"' "+ + " and xm = "+ yg + + " and ydhbm= "+ cjrbm+ + " and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) "; + out.print("sql:"+sql+"
"); + + rs.executeQuery(sql); + if(rs.next()){ + String ydsxrq = Util.null2String(rs.getString("ydsxrq")); + if(StringUtils.isNotBlank(ydsxrq)){ + enddate = ydsxrq; + } + } + out.print("enddate:"+enddate+"
"); + sql =" select ydsxrq " + + " from uf_ygddxx " + + " where left(ydsxrq,7) = '"+pbyf+"' "+ + " and xm ="+ yg + + " and ydhbm="+cjrbm+ + " and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) "; + rs.executeQuery(sql); + out.print("sql:"+sql+"
"); + if(rs.next()){ + String ydsxrq = Util.null2String(rs.getString("ydsxrq")); + if(StringUtils.isNotBlank(ydsxrq)){ + startdate = ydsxrq; + } + } + + out.print("startdate:"+startdate+"
"); + + } + } + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("startdate",startdate); + jsonObject.put("enddate",enddate); + +%> +<%=jsonObject.toJSONString() %> + + + diff --git a/浙文眼镜/interface/zw/workflow/pblc/queryUserTransferData_test.jsp b/浙文眼镜/interface/zw/workflow/pblc/queryUserTransferData_test.jsp new file mode 100644 index 0000000..8cdd46f --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/pblc/queryUserTransferData_test.jsp @@ -0,0 +1,87 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="java.time.LocalDate" %> +<%@ page import="java.time.format.DateTimeFormatter" %> +<%@ page import="java.time.temporal.TemporalAdjusters" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } + + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + String cjrbm = request.getParameter("cjrbm"); + String pbyf = request.getParameter("pbyf"); + String yg = request.getParameter("yg"); + + String startdate = ""; + String enddate = ""; + String sfdd = "1"; + if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7){ + + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate dateTime = LocalDate.parse(pbyf+"-01", formatter); + LocalDate firstDayOfMonth = dateTime.with(TemporalAdjusters.firstDayOfMonth()); + LocalDate lastDayOfMonth = dateTime.with(TemporalAdjusters.lastDayOfMonth()); + startdate = firstDayOfMonth.toString(); + enddate = lastDayOfMonth.toString(); + + if(StringUtils.isNotBlank(cjrbm)) { + String sql =" select ydsxrq " + + " from uf_ygddxx " + + " where left(ydsxrq,7) = '"+pbyf+"' "+ + " and xm ="+ yg + + " and ydhbm="+cjrbm+ + " and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) " + + " order by id desc "; + out.print("sql:"+sql+"
"); + rs.executeQuery(sql); + if(rs.next()){ + String ydsxrq = Util.null2String(rs.getString("ydsxrq")); + out.print("ydsxrq:"+ydsxrq+"
"); + if(StringUtils.isNotBlank(ydsxrq)){ + startdate = ydsxrq; + sfdd = "0"; + } + } + + sql =" select convert(varchar,dateadd(day,-1,ydsxrq), 23) as ydsxrq " + + " from uf_ygddxx " + + " where left(ydsxrq,7) = '"+pbyf+"' "+ + " and xm = "+ yg + + " and bm= "+ cjrbm+ + " and ydsxrq > '"+startdate +"'"+ + " and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) " + + " order by id desc "; + rs.executeQuery(sql); + out.print("sql:"+sql+"
"); + if(rs.next()){ + String ydsxrq = Util.null2String(rs.getString("ydsxrq")); + out.print("ydsxrq:"+ydsxrq+"
"); + if(StringUtils.isNotBlank(ydsxrq)){ + enddate = ydsxrq; + sfdd = "0"; + } + } + } + } + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("startdate",startdate); + jsonObject.put("enddate",enddate); + jsonObject.put("sfdd",sfdd); + +%> +<%=jsonObject.toJSONString() %> + + + diff --git a/浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayData.jsp b/浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayData.jsp new file mode 100644 index 0000000..5e180dc --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayData.jsp @@ -0,0 +1,381 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="weaver.common.DateUtil" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="com.alibaba.fastjson.JSONArray" %> +<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupBiz" %> +<%@ page import="java.time.LocalDate" %> +<%@ page import="java.time.format.DateTimeFormatter" %> +<%@ page import="java.time.DayOfWeek" %> +<%@ page import="java.time.temporal.TemporalAdjusters" %> +<%@ page import="java.util.*" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + + String[] workSchedule = {"09:00-11:00","11:00-16:00","16:00-20:00","20:00-21:30"}; + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } + int userid = user.getUID(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + String pbdata = request.getParameter("pbdata"); +// if(StringUtils.isBlank(pb)){ +// +// JSONArray jsonArray = new JSONArray(); +// JSONObject userObject = new JSONObject(); +// userObject.put("userid","3039"); +// userObject.put("serialid","10"); +// jsonArray.add(userObject); +// +// userObject = new JSONObject(); +// userObject.put("userid","3373"); +// userObject.put("serialid","7"); +// jsonArray.add(userObject); +// +// userObject = new JSONObject(); +// userObject.put("userid","3661"); +// userObject.put("serialid","9"); +// jsonArray.add(userObject); +// pb = jsonArray.toJSONString(); +// } + String yjl = request.getParameter("yjl"); + String pbrq = request.getParameter("pbrq"); + String dateType = "0"; + if(StringUtils.isNotBlank(pbrq)){ + dateType = getWeekTypeByDate(pbrq,userid+""); + } + + Map defaultScheduleMap = new HashMap(); + if(StringUtils.isNotBlank(yjl)){ + String sql = " select dysjd,pzrs from uf_pbjcsj where yjl = ? and pblx = ?" ; + rs.executeQuery(sql,new Object[]{yjl,dateType}); + while (rs.next()){ + int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd"))); + int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs"))); + + String sjd = ""; + if(dysd < workSchedule.length){ + sjd = workSchedule[dysd]; + if(StringUtils.isNotBlank(sjd)){ + defaultScheduleMap.put(sjd,pzrs); + } + } + } + } + + List> workScheduleList = new ArrayList>(); + Map workScheduleMap = null; + for(int k=0;k0){ + String[] schedule = workSchedule[k].split("-"); + String scheduleStartTime = schedule[0]; + String scheduleEndTime = schedule[1]; + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + workScheduleMap = new HashMap(); + workScheduleMap.put("start",scheduleStartTime); + workScheduleMap.put("end",scheduleEndTime); + workScheduleList.add(workScheduleMap); + } + } + } + + Map> userScheduleDayMap = new HashMap>(); + Map necessaryMap = new HashMap(); + + Map userScheduleMap = new HashMap(); + if(StringUtils.isNotBlank(pbdata)) { + JSONArray jsonArray = JSONArray.parseArray(pbdata); + + String yxrys = "" ; + for(int i = 0;i userList = new ArrayList(); + String sql =" select h.id \n" + + " from hrmresource h \n" + + " inner join hrmjobtitles k on k.id = h.jobtitle\n" + + " where h.id in("+yxrys+")\n" + + " and k.jobtitlename in('店长','验光师')\n" + + " and h.status in(0,1,2,3,4)\n" + + " union \n" + + " select h.id \n" + + " from hrmresource h \n" + + " inner join cus_fielddata k on k.id = h.id\n" + + " where k.field39 = 2 \n" + + " and k.scopeid=3 \n" + + " and k.scope='HrmCustomFieldByInfoType' " + + " and h.id in("+yxrys+") and h.status in(0,1,2,3,4) " + + " union " + + " select h.id\n" + + " from hrmresource h \n" + + " inner join cus_fielddata k on k.id = h.id \n" + + " where k.scopeid=-1 " + + " and k.scope='HrmCustomFieldByInfoType'\n" + + " and substring(k.field1,charindex('_',k.field1)+1,len(k.field1)) in(select id from uf_gwjbsjb where jbmc in('配镜一级','配镜二级','配镜三级','配镜四级','配镜五级')) and charindex('_', k.field1) > 0 \n" + + " and h.status in(0,1,2,3,4) "+ + " and h.id in("+yxrys+") "; + + rs.executeQuery(sql); + while (rs.next()){ + String id = Util.null2String(rs.getString("id")); + userList.add(id); + } + + for(int i = 0;i userSchedule_Map = new HashMap(); + if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){ + userSchedule_Map.put("startTime",startTime); + userSchedule_Map.put("endTime",endTime); + + + for(int k=0;k workSchedule_Map = workScheduleList.get(k); + String scheduleStartTime = workSchedule_Map.get("start"); + String scheduleEndTime = workSchedule_Map.get("end"); + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + if(startTime.compareTo(scheduleStartTime) <=0 && endTime.compareTo(scheduleEndTime) >=0){ + + String defWorkSchedule = scheduleStartTime+"-"+scheduleEndTime ; + if(userScheduleMap.containsKey(defWorkSchedule)){ + int count = userScheduleMap.get(defWorkSchedule); + count++; + userScheduleMap.put(defWorkSchedule,count); + }else{ + userScheduleMap.put(defWorkSchedule,1); + } + + if(userList.contains(pbry)){ + necessaryMap.put(defWorkSchedule,1); + } + } + } + } + } + userScheduleDayMap.put(pbry,userSchedule_Map); + } + } + + int defaultcount = 0; + int datacount = 0; + Iterator> iterator = defaultScheduleMap.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); + int value =entry.getValue(); + String key = entry.getKey(); + if(userScheduleMap.containsKey(key)){ + int useValue = userScheduleMap.get(key); + if(useValue < value){ + datacount++; + } + }else{ + datacount++; + } + defaultcount++; + } + + JSONObject jsonObject = new JSONObject(); + if(defaultcount >0 && datacount == 0){ + if(necessaryMap.size() == 4){ + jsonObject.put("pbcode","1"); + }else{ + jsonObject.put("pbcode","2"); + } + }else{ + jsonObject.put("pbcode","0"); + } + + jsonObject.put("pbinfo",userScheduleDayMap); +%> + +<%=jsonObject.toJSONString() %> + +<%! + + public String getWeekTypeByDate(String pbrq,String userid){ + + String dateType = "0"; + DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate currentDate = LocalDate.parse(pbrq, df); + + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); + int weekValue = dayOfWeek.getValue(); + + LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 + String monthStartDate = startDayOfMonth.toString(); + String monthEndDate = lastDayOfMonth.toString(); + Map holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate); + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + + if("1".equals(changeType) || "3".equals(changeType)){ + dateType = "1"; + }else if(weekValue == 6 || weekValue == 7){ + dateType = "1"; + } + return dateType; + } + + /*** + * + * @param userid + * @param monthStartDate + * @param monthEndDate + * @return + */ + public Map getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate){ + + Map holidayMap = new HashMap(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + + try { + if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){ +// String activeGroupId = getUserActiveGroupId(userid); +// bb.writeLog("activeGroupId:"+activeGroupId); + + String fixedScheduleGroupId = "5"; + + if(StringUtils.isNotBlank(fixedScheduleGroupId)){ + String sql =" select holidayDate,changeType from KQ_HolidaySet\n" + + " where groupid = " + fixedScheduleGroupId+ + " and holidayDate >='"+monthStartDate+"'\n" + + " and holidayDate <='"+monthEndDate+"' " ; + rs.execute(sql); + while (rs.next()){ + String holidayDate = Util.null2String(rs.getString("holidayDate")); + String changeType = Util.null2String(rs.getString("changeType")); +// String changeTypename = "" ; +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// changeTypename += "公众假日"; +// }else if("2".equals(changeType)){ +// changeTypename += "调配工作日"; +// }else if("3".equals(changeType)){ +// changeTypename += "调配休息日"; +// } + holidayMap.put(holidayDate,changeType); + +// if(weekMap.containsKey(holidayDate)){ +// String holidayDate_new = weekMap.get(holidayDate); +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// holidayDate_new += "[公众假日]"; +// }else if("1".equals(changeType)){ +// holidayDate_new += "[调配工作日]"; +// }else if("2".equals(changeType)){ +// holidayDate_new += "[调配休息日]"; +// } +// weekMap.put(holidayDate,holidayDate_new); +// } + } + } + } + }catch (Exception e){ + + } + return holidayMap; + } + + /*** + * + * @param userid + * @return + */ + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } + + +%> + + diff --git a/浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayData2.jsp b/浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayData2.jsp new file mode 100644 index 0000000..d7d4068 --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayData2.jsp @@ -0,0 +1,385 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="weaver.common.DateUtil" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="com.alibaba.fastjson.JSONArray" %> +<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupBiz" %> +<%@ page import="java.time.LocalDate" %> +<%@ page import="java.time.format.DateTimeFormatter" %> +<%@ page import="java.time.DayOfWeek" %> +<%@ page import="java.time.temporal.TemporalAdjusters" %> +<%@ page import="java.util.*" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + + String[] workSchedule = {"09:00-11:00","11:00-16:00","16:00-20:00","20:00-21:30"}; + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } + int userid = user.getUID(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + String pbdata = request.getParameter("pbdata"); +// if(StringUtils.isBlank(pb)){ +// +// JSONArray jsonArray = new JSONArray(); +// JSONObject userObject = new JSONObject(); +// userObject.put("userid","3039"); +// userObject.put("serialid","10"); +// jsonArray.add(userObject); +// +// userObject = new JSONObject(); +// userObject.put("userid","3373"); +// userObject.put("serialid","7"); +// jsonArray.add(userObject); +// +// userObject = new JSONObject(); +// userObject.put("userid","3661"); +// userObject.put("serialid","9"); +// jsonArray.add(userObject); +// pb = jsonArray.toJSONString(); +// } + String yjl = request.getParameter("yjl"); + String pbrq = request.getParameter("pbrq"); + String dateType = "0"; + if(StringUtils.isNotBlank(pbrq)){ + dateType = getWeekTypeByDate(pbrq,userid+""); + } + + Map defaultScheduleMap = new HashMap(); + if(StringUtils.isNotBlank(yjl)){ + String sql = " select dysjd,pzrs from uf_pbjcsj where yjl = ? and pblx = ?" ; + rs.executeQuery(sql,new Object[]{yjl,dateType}); + while (rs.next()){ + int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd"))); + int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs"))); + + String sjd = ""; + if(dysd < workSchedule.length){ + sjd = workSchedule[dysd]; + if(StringUtils.isNotBlank(sjd)){ + defaultScheduleMap.put(sjd,pzrs); + } + } + } + } + + List> workScheduleList = new ArrayList>(); + Map workScheduleMap = null; + for(int k=0;k0){ + String[] schedule = workSchedule[k].split("-"); + String scheduleStartTime = schedule[0]; + String scheduleEndTime = schedule[1]; + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + workScheduleMap = new HashMap(); + workScheduleMap.put("start",scheduleStartTime); + workScheduleMap.put("end",scheduleEndTime); + workScheduleList.add(workScheduleMap); + } + } + } + + Map> userScheduleDayMap = new HashMap>(); + + Map userScheduleMap = new HashMap(); + Map necessaryMap = new HashMap(); + if(StringUtils.isNotBlank(pbdata)) { + JSONArray jsonArray = JSONArray.parseArray(pbdata); + + String yxrys = "" ; + for(int i = 0;i"); + List userList = new ArrayList(); + String sql =" select h.id \n" + + " from hrmresource h \n" + + " inner join hrmjobtitles k on k.id = h.jobtitle\n" + + " where h.id in("+yxrys+")\n" + + " and k.jobtitlename in('店长','验光师')\n" + + " and h.status in(0,1,2,3,4)\n" + + " union \n" + + " select h.id \n" + + " from hrmresource h \n" + + " inner join cus_fielddata k on k.id = h.id\n" + + " where k.field39 = 2 \n" + + " and k.scopeid=3 \n" + + " and k.scope='HrmCustomFieldByInfoType' " + + " and h.id in("+yxrys+") and h.status in(0,1,2,3,4) " + + " union " + + " select h.id\n" + + " from hrmresource h \n" + + " inner join cus_fielddata k on k.id = h.id \n" + + " where k.scopeid=-1 " + + " and k.scope='HrmCustomFieldByInfoType'\n" + + " and substring(k.field1,charindex('_',k.field1)+1,len(k.field1)) in(select id from uf_gwjbsjb where jbmc in('配镜一级','配镜二级','配镜三级','配镜四级','配镜五级')) and charindex('_', k.field1) > 0 \n" + + " and h.status in(0,1,2,3,4) "+ + " and h.id in("+yxrys+") "; + + out.println("sql:"+sql+"
"); + rs.executeQuery(sql); + while (rs.next()){ + String id = Util.null2String(rs.getString("id")); + out.println("id:"+id+"
"); + userList.add(id); + } + + for(int i = 0;i userSchedule_Map = new HashMap(); + if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){ + userSchedule_Map.put("startTime",startTime); + userSchedule_Map.put("endTime",endTime); + + + for(int k=0;k workSchedule_Map = workScheduleList.get(k); + String scheduleStartTime = workSchedule_Map.get("start"); + String scheduleEndTime = workSchedule_Map.get("end"); + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + if(startTime.compareTo(scheduleStartTime) <=0 && endTime.compareTo(scheduleEndTime) >=0){ + + String defWorkSchedule = scheduleStartTime+"-"+scheduleEndTime ; + if(userScheduleMap.containsKey(defWorkSchedule)){ + int count = userScheduleMap.get(defWorkSchedule); + count++; + userScheduleMap.put(defWorkSchedule,count); + }else{ + userScheduleMap.put(defWorkSchedule,1); + } + + if(userList.contains(pbry)){ + necessaryMap.put(defWorkSchedule,1); + } + } + } + } + } + userScheduleDayMap.put(pbry,userSchedule_Map); + } + } + + int defaultcount = 0; + int datacount = 0; + Iterator> iterator = defaultScheduleMap.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); + int value =entry.getValue(); + String key = entry.getKey(); + if(userScheduleMap.containsKey(key)){ + int useValue = userScheduleMap.get(key); + if(useValue < value){ + datacount++; + } + }else{ + datacount++; + } + defaultcount++; + } + + out.println("necessaryMap:"+necessaryMap.size()); + + JSONObject jsonObject = new JSONObject(); + if(defaultcount >0 && datacount == 0){ + if(necessaryMap.size() == 4){ + jsonObject.put("pbcode","1"); + }else{ + jsonObject.put("pbcode","2"); + } + }else{ + jsonObject.put("pbcode","0"); + } + + jsonObject.put("pbinfo",userScheduleDayMap); +%> + +<%=jsonObject.toJSONString() %> + +<%! + + public String getWeekTypeByDate(String pbrq,String userid){ + + String dateType = "0"; + DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate currentDate = LocalDate.parse(pbrq, df); + + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); + int weekValue = dayOfWeek.getValue(); + + LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 + String monthStartDate = startDayOfMonth.toString(); + String monthEndDate = lastDayOfMonth.toString(); + Map holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate); + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + + if("1".equals(changeType) || "3".equals(changeType)){ + dateType = "1"; + }else if(weekValue == 6 || weekValue == 7){ + dateType = "1"; + } + return dateType; + } + + /*** + * + * @param userid + * @param monthStartDate + * @param monthEndDate + * @return + */ + public Map getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate){ + + Map holidayMap = new HashMap(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + + try { + if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){ +// String activeGroupId = getUserActiveGroupId(userid); +// bb.writeLog("activeGroupId:"+activeGroupId); + + String fixedScheduleGroupId = "5"; + if(StringUtils.isNotBlank(fixedScheduleGroupId)){ + String sql =" select holidayDate,changeType from KQ_HolidaySet\n" + + " where groupid = " + fixedScheduleGroupId+ + " and holidayDate >='"+monthStartDate+"'\n" + + " and holidayDate <='"+monthEndDate+"' " ; + rs.execute(sql); + while (rs.next()){ + String holidayDate = Util.null2String(rs.getString("holidayDate")); + String changeType = Util.null2String(rs.getString("changeType")); +// String changeTypename = "" ; +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// changeTypename += "公众假日"; +// }else if("2".equals(changeType)){ +// changeTypename += "调配工作日"; +// }else if("3".equals(changeType)){ +// changeTypename += "调配休息日"; +// } + holidayMap.put(holidayDate,changeType); + +// if(weekMap.containsKey(holidayDate)){ +// String holidayDate_new = weekMap.get(holidayDate); +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// holidayDate_new += "[公众假日]"; +// }else if("1".equals(changeType)){ +// holidayDate_new += "[调配工作日]"; +// }else if("2".equals(changeType)){ +// holidayDate_new += "[调配休息日]"; +// } +// weekMap.put(holidayDate,holidayDate_new); +// } + } + } + } + }catch (Exception e){ + + } + return holidayMap; + } + + /*** + * + * @param userid + * @return + */ + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } + + +%> + + diff --git a/浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayData3.jsp b/浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayData3.jsp new file mode 100644 index 0000000..6de6b31 --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayData3.jsp @@ -0,0 +1,450 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="weaver.common.DateUtil" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="com.alibaba.fastjson.JSONArray" %> +<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupBiz" %> +<%@ page import="java.time.LocalDate" %> +<%@ page import="java.time.format.DateTimeFormatter" %> +<%@ page import="java.time.DayOfWeek" %> +<%@ page import="java.time.temporal.TemporalAdjusters" %> +<%@ page import="java.util.*" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + + String[] workSchedule = {"09:00-11:00","11:00-16:00","16:00-20:00","20:00-21:30"}; + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } + int userid = user.getUID(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + String pbdata = request.getParameter("pbdata"); + String bp = request.getParameter("bp"); + +// if(StringUtils.isBlank(pb)){ +// +// JSONArray jsonArray = new JSONArray(); +// JSONObject userObject = new JSONObject(); +// userObject.put("userid","3039"); +// userObject.put("serialid","10"); +// jsonArray.add(userObject); +// +// userObject = new JSONObject(); +// userObject.put("userid","3373"); +// userObject.put("serialid","7"); +// jsonArray.add(userObject); +// +// userObject = new JSONObject(); +// userObject.put("userid","3661"); +// userObject.put("serialid","9"); +// jsonArray.add(userObject); +// pb = jsonArray.toJSONString(); +// } + + String yjl = request.getParameter("yjl"); + String pbrq = request.getParameter("pbrq"); + String dateType = "0"; + if(StringUtils.isNotBlank(pbrq)){ + dateType = getWeekTypeByDate(pbrq,userid+""); + } + + Map defaultScheduleMap = new HashMap(); + if(StringUtils.isNotBlank(bp)){ + String sql = " select dysjd,pzrs from uf_pbjcsj where bprs = ? and pblx = ?" ; + rs.executeQuery(sql,new Object[]{bp,dateType}); + while (rs.next()){ + int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd"))); + int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs"))); + + String sjd = ""; + if(dysd < workSchedule.length){ + sjd = workSchedule[dysd]; + if(StringUtils.isNotBlank(sjd)){ + defaultScheduleMap.put(sjd,pzrs); + } + } + } + } + + List> workScheduleList = new ArrayList>(); + Map workScheduleMap = null; + for(int k=0;k0){ + String[] schedule = workSchedule[k].split("-"); + String scheduleStartTime = schedule[0]; + String scheduleEndTime = schedule[1]; + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + workScheduleMap = new HashMap(); + workScheduleMap.put("start",""); + workScheduleMap.put("end",scheduleEndTime); + workScheduleList.add(workScheduleMap); + } + } + }else if(k==(workSchedule.length-1)){ + if(workSchedule[k].indexOf("-")>0){ + String[] schedule = workSchedule[k].split("-"); + String scheduleStartTime = schedule[0]; + String scheduleEndTime = schedule[1]; + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + workScheduleMap = new HashMap(); + workScheduleMap.put("start",scheduleStartTime); + workScheduleMap.put("end",""); + workScheduleList.add(workScheduleMap); + } + } + }else{ + if(workSchedule[k].indexOf("-")>0){ + String[] schedule = workSchedule[k].split("-"); + String scheduleStartTime = schedule[0]; + String scheduleEndTime = schedule[1]; + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + workScheduleMap = new HashMap(); + workScheduleMap.put("start",scheduleStartTime); + workScheduleMap.put("end",scheduleEndTime); + workScheduleList.add(workScheduleMap); + } + } + } + } + + Map> userScheduleDayMap = new HashMap>(); + Map necessaryMap = new HashMap(); + + Map userScheduleMap = new HashMap(); + if(StringUtils.isNotBlank(pbdata)) { + JSONArray jsonArray = JSONArray.parseArray(pbdata); + + String yxrys = "" ; + for(int i = 0;i userList = new ArrayList(); + String sql =" select h.id \n" + + " from hrmresource h \n" + + " inner join hrmjobtitles k on k.id = h.jobtitle\n" + + " where h.id in("+yxrys+")\n" + + " and k.jobtitlename in('店长','验光师')\n" + + " and h.status in(0,1,2,3)\n" + + " union \n" + + " select h.id \n" + + " from hrmresource h \n" + + " inner join cus_fielddata k on k.id = h.id\n" + + " where k.field39 = 2 \n" + + " and k.scopeid=3 \n" + + " and k.scope='HrmCustomFieldByInfoType' " + + " and h.id in("+yxrys+") and h.status in(0,1,2,3) " + + " union " + + " select h.id\n" + + " from hrmresource h \n" + + " inner join cus_fielddata k on k.id = h.id \n" + + " where k.scopeid=-1 " + + " and k.scope='HrmCustomFieldByInfoType'\n" + + " and substring(k.field1,charindex('_',k.field1)+1,len(k.field1)) in(select id from uf_gwjbsjb where jbmc in('配镜一级','配镜二级','配镜三级','配镜四级','配镜五级')) and charindex('_', k.field1) > 0 \n" + + " and h.status in(0,1,2,3) "+ + " and h.id in("+yxrys+") "; + + rs.executeQuery(sql); + while (rs.next()){ + String id = Util.null2String(rs.getString("id")); + userList.add(id); + } + + for(int i = 0;i userSchedule_Map = new HashMap(); + if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){ + userSchedule_Map.put("startTime",startTime); + userSchedule_Map.put("endTime",endTime); + + + for(int k=0;k workSchedule_Map = workScheduleList.get(k); + String scheduleStartTime = workSchedule_Map.get("start"); + String scheduleEndTime = workSchedule_Map.get("end"); + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + if(startTime.compareTo(scheduleStartTime) <=0 && endTime.compareTo(scheduleEndTime) >=0){ + + String defWorkSchedule = scheduleStartTime+"-"+scheduleEndTime ; + if(userScheduleMap.containsKey(defWorkSchedule)){ + int count = userScheduleMap.get(defWorkSchedule); + count++; + userScheduleMap.put(defWorkSchedule,count); + }else{ + userScheduleMap.put(defWorkSchedule,1); + } + + if(userList.contains(pbry)){ + necessaryMap.put(defWorkSchedule,1); + } + } + }else{ + if(StringUtils.isNotBlank(scheduleStartTime)){ + + if(endTime.compareTo(scheduleStartTime) >=0 ){ + String define_scheduleEndTime = "21:30"; + String defWorkSchedule = scheduleStartTime+"-"+define_scheduleEndTime ; + if(userScheduleMap.containsKey(defWorkSchedule)){ + int count = userScheduleMap.get(defWorkSchedule); + count++; + userScheduleMap.put(defWorkSchedule,count); + }else{ + userScheduleMap.put(defWorkSchedule,1); + } + + if(userList.contains(pbry)){ + necessaryMap.put(defWorkSchedule,1); + } + } + }else if(StringUtils.isNotBlank(scheduleEndTime)){ + + if(startTime.compareTo(scheduleEndTime) <=0){ + String define_scheduleStartTime = "09:00"; + String defWorkSchedule = define_scheduleStartTime+"-"+scheduleEndTime ; + if(userScheduleMap.containsKey(defWorkSchedule)){ + int count = userScheduleMap.get(defWorkSchedule); + count++; + userScheduleMap.put(defWorkSchedule,count); + }else{ + userScheduleMap.put(defWorkSchedule,1); + } + + if(userList.contains(pbry)){ + necessaryMap.put(defWorkSchedule,1); + } + } + + } + } + } + } + userScheduleDayMap.put(pbry,userSchedule_Map); + } + } + + int defaultcount = 0; + int datacount = 0; + Iterator> iterator = defaultScheduleMap.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); + int value =entry.getValue(); + String key = entry.getKey(); + if(userScheduleMap.containsKey(key)){ + int useValue = userScheduleMap.get(key); + if(useValue < value){ + datacount++; + } + }else{ + datacount++; + } + defaultcount++; + } + + JSONObject jsonObject = new JSONObject(); + if(defaultcount >0 && datacount == 0){ + if(necessaryMap.size() == 4){ + jsonObject.put("pbcode","1"); + }else{ + jsonObject.put("pbcode","2"); + } + }else{ + jsonObject.put("pbcode","0"); + } + + jsonObject.put("pbinfo",userScheduleDayMap); +%> + +<%=jsonObject.toJSONString() %> + +<%! + + public String getWeekTypeByDate(String pbrq,String userid){ + + String dateType = "0"; + DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate currentDate = LocalDate.parse(pbrq, df); + + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); + int weekValue = dayOfWeek.getValue(); + + LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 + String monthStartDate = startDayOfMonth.toString(); + String monthEndDate = lastDayOfMonth.toString(); + Map holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate); + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + + if("2".equals(changeType)){ + dateType = "0"; + }else if("1".equals(changeType) || "3".equals(changeType)){ + dateType = "1"; + }else if(weekValue == 6 || weekValue == 7){ + dateType = "1"; + } + + return dateType; + } + + /*** + * + * @param userid + * @param monthStartDate + * @param monthEndDate + * @return + */ + public Map getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate){ + + Map holidayMap = new HashMap(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + + try { + if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){ +// String activeGroupId = getUserActiveGroupId(userid); +// bb.writeLog("activeGroupId:"+activeGroupId); + + String fixedScheduleGroupId = "5"; + if(StringUtils.isNotBlank(fixedScheduleGroupId)){ + String sql =" select holidayDate,changeType from KQ_HolidaySet\n" + + " where groupid = " + fixedScheduleGroupId+ + " and holidayDate >='"+monthStartDate+"'\n" + + " and holidayDate <='"+monthEndDate+"' " ; + rs.execute(sql); + while (rs.next()){ + String holidayDate = Util.null2String(rs.getString("holidayDate")); + String changeType = Util.null2String(rs.getString("changeType")); +// String changeTypename = "" ; +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// changeTypename += "公众假日"; +// }else if("2".equals(changeType)){ +// changeTypename += "调配工作日"; +// }else if("3".equals(changeType)){ +// changeTypename += "调配休息日"; +// } + + holidayMap.put(holidayDate,changeType); + +// if(weekMap.containsKey(holidayDate)){ +// String holidayDate_new = weekMap.get(holidayDate); +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// holidayDate_new += "[公众假日]"; +// }else if("1".equals(changeType)){ +// holidayDate_new += "[调配工作日]"; +// }else if("2".equals(changeType)){ +// holidayDate_new += "[调配休息日]"; +// } +// weekMap.put(holidayDate,holidayDate_new); +// } + } + } + } + }catch (Exception e){ + + } + return holidayMap; + } + + /*** + * + * @param userid + * @return + */ + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } + + +%> + + diff --git a/浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayData3_test.jsp b/浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayData3_test.jsp new file mode 100644 index 0000000..5279621 --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayData3_test.jsp @@ -0,0 +1,450 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="weaver.common.DateUtil" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="com.alibaba.fastjson.JSONArray" %> +<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupBiz" %> +<%@ page import="java.time.LocalDate" %> +<%@ page import="java.time.format.DateTimeFormatter" %> +<%@ page import="java.time.DayOfWeek" %> +<%@ page import="java.time.temporal.TemporalAdjusters" %> +<%@ page import="java.util.*" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + + String[] workSchedule = {"09:00-11:00","11:00-16:00","16:00-20:00","20:00-21:30"}; + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } + int userid = user.getUID(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + String pbdata = request.getParameter("pbdata"); + String bp = request.getParameter("bp"); + +// if(StringUtils.isBlank(pb)){ +// +// JSONArray jsonArray = new JSONArray(); +// JSONObject userObject = new JSONObject(); +// userObject.put("userid","3039"); +// userObject.put("serialid","10"); +// jsonArray.add(userObject); +// +// userObject = new JSONObject(); +// userObject.put("userid","3373"); +// userObject.put("serialid","7"); +// jsonArray.add(userObject); +// +// userObject = new JSONObject(); +// userObject.put("userid","3661"); +// userObject.put("serialid","9"); +// jsonArray.add(userObject); +// pb = jsonArray.toJSONString(); +// } + + String yjl = request.getParameter("yjl"); + String pbrq = request.getParameter("pbrq"); + String dateType = "0"; + if(StringUtils.isNotBlank(pbrq)){ + dateType = getWeekTypeByDate(pbrq,userid+""); + } + out.print("dateType:"+dateType); + + Map defaultScheduleMap = new HashMap(); + if(StringUtils.isNotBlank(bp)){ + String sql = " select dysjd,pzrs from uf_pbjcsj where bprs = ? and pblx = ?" ; + rs.executeQuery(sql,new Object[]{bp,dateType}); + while (rs.next()){ + int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd"))); + int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs"))); + + String sjd = ""; + if(dysd < workSchedule.length){ + sjd = workSchedule[dysd]; + if(StringUtils.isNotBlank(sjd)){ + defaultScheduleMap.put(sjd,pzrs); + } + } + } + } + + List> workScheduleList = new ArrayList>(); + Map workScheduleMap = null; + for(int k=0;k0){ + String[] schedule = workSchedule[k].split("-"); + String scheduleStartTime = schedule[0]; + String scheduleEndTime = schedule[1]; + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + workScheduleMap = new HashMap(); + workScheduleMap.put("start",""); + workScheduleMap.put("end",scheduleEndTime); + workScheduleList.add(workScheduleMap); + } + } + }else if(k==(workSchedule.length-1)){ + if(workSchedule[k].indexOf("-")>0){ + String[] schedule = workSchedule[k].split("-"); + String scheduleStartTime = schedule[0]; + String scheduleEndTime = schedule[1]; + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + workScheduleMap = new HashMap(); + workScheduleMap.put("start",scheduleStartTime); + workScheduleMap.put("end",""); + workScheduleList.add(workScheduleMap); + } + } + }else{ + if(workSchedule[k].indexOf("-")>0){ + String[] schedule = workSchedule[k].split("-"); + String scheduleStartTime = schedule[0]; + String scheduleEndTime = schedule[1]; + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + workScheduleMap = new HashMap(); + workScheduleMap.put("start",scheduleStartTime); + workScheduleMap.put("end",scheduleEndTime); + workScheduleList.add(workScheduleMap); + } + } + } + } + + Map> userScheduleDayMap = new HashMap>(); + Map necessaryMap = new HashMap(); + + Map userScheduleMap = new HashMap(); + if(StringUtils.isNotBlank(pbdata)) { + JSONArray jsonArray = JSONArray.parseArray(pbdata); + + String yxrys = "" ; + for(int i = 0;i userList = new ArrayList(); + String sql =" select h.id \n" + + " from hrmresource h \n" + + " inner join hrmjobtitles k on k.id = h.jobtitle\n" + + " where h.id in("+yxrys+")\n" + + " and k.jobtitlename in('店长','验光师')\n" + + " and h.status in(0,1,2,3)\n" + + " union \n" + + " select h.id \n" + + " from hrmresource h \n" + + " inner join cus_fielddata k on k.id = h.id\n" + + " where k.field39 = 2 \n" + + " and k.scopeid=3 \n" + + " and k.scope='HrmCustomFieldByInfoType' " + + " and h.id in("+yxrys+") and h.status in(0,1,2,3) " + + " union " + + " select h.id\n" + + " from hrmresource h \n" + + " inner join cus_fielddata k on k.id = h.id \n" + + " where k.scopeid=-1 " + + " and k.scope='HrmCustomFieldByInfoType'\n" + + " and substring(k.field1,charindex('_',k.field1)+1,len(k.field1)) in(select id from uf_gwjbsjb where jbmc in('配镜一级','配镜二级','配镜三级','配镜四级','配镜五级')) and charindex('_', k.field1) > 0 \n" + + " and h.status in(0,1,2,3) "+ + " and h.id in("+yxrys+") "; + + rs.executeQuery(sql); + while (rs.next()){ + String id = Util.null2String(rs.getString("id")); + userList.add(id); + } + + for(int i = 0;i userSchedule_Map = new HashMap(); + if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){ + userSchedule_Map.put("startTime",startTime); + userSchedule_Map.put("endTime",endTime); + + + for(int k=0;k workSchedule_Map = workScheduleList.get(k); + String scheduleStartTime = workSchedule_Map.get("start"); + String scheduleEndTime = workSchedule_Map.get("end"); + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + if(startTime.compareTo(scheduleStartTime) <=0 && endTime.compareTo(scheduleEndTime) >=0){ + + String defWorkSchedule = scheduleStartTime+"-"+scheduleEndTime ; + if(userScheduleMap.containsKey(defWorkSchedule)){ + int count = userScheduleMap.get(defWorkSchedule); + count++; + userScheduleMap.put(defWorkSchedule,count); + }else{ + userScheduleMap.put(defWorkSchedule,1); + } + + if(userList.contains(pbry)){ + necessaryMap.put(defWorkSchedule,1); + } + } + }else{ + if(StringUtils.isNotBlank(scheduleStartTime)){ + + if(endTime.compareTo(scheduleStartTime) >=0 ){ + String define_scheduleEndTime = "21:30"; + String defWorkSchedule = scheduleStartTime+"-"+define_scheduleEndTime ; + if(userScheduleMap.containsKey(defWorkSchedule)){ + int count = userScheduleMap.get(defWorkSchedule); + count++; + userScheduleMap.put(defWorkSchedule,count); + }else{ + userScheduleMap.put(defWorkSchedule,1); + } + + if(userList.contains(pbry)){ + necessaryMap.put(defWorkSchedule,1); + } + } + }else if(StringUtils.isNotBlank(scheduleEndTime)){ + + if(startTime.compareTo(scheduleEndTime) <=0){ + String define_scheduleStartTime = "09:00"; + String defWorkSchedule = define_scheduleStartTime+"-"+scheduleEndTime ; + if(userScheduleMap.containsKey(defWorkSchedule)){ + int count = userScheduleMap.get(defWorkSchedule); + count++; + userScheduleMap.put(defWorkSchedule,count); + }else{ + userScheduleMap.put(defWorkSchedule,1); + } + + if(userList.contains(pbry)){ + necessaryMap.put(defWorkSchedule,1); + } + } + + } + } + } + } + userScheduleDayMap.put(pbry,userSchedule_Map); + } + } + + int defaultcount = 0; + int datacount = 0; + Iterator> iterator = defaultScheduleMap.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); + int value =entry.getValue(); + String key = entry.getKey(); + if(userScheduleMap.containsKey(key)){ + int useValue = userScheduleMap.get(key); + if(useValue < value){ + datacount++; + } + }else{ + datacount++; + } + defaultcount++; + } + + JSONObject jsonObject = new JSONObject(); + if(defaultcount >0 && datacount == 0){ + if(necessaryMap.size() == 4){ + jsonObject.put("pbcode","1"); + }else{ + jsonObject.put("pbcode","2"); + } + }else{ + jsonObject.put("pbcode","0"); + } + + jsonObject.put("pbinfo",userScheduleDayMap); +%> + +<%=jsonObject.toJSONString() %> + +<%! + + public String getWeekTypeByDate(String pbrq,String userid){ + + String dateType = "0"; + DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate currentDate = LocalDate.parse(pbrq, df); + + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); + int weekValue = dayOfWeek.getValue(); + + LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 + String monthStartDate = startDayOfMonth.toString(); + String monthEndDate = lastDayOfMonth.toString(); + Map holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate); + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + + if("1".equals(changeType) || "3".equals(changeType)){ + dateType = "1"; + }else if(weekValue == 6 || weekValue == 7){ + dateType = "1"; + }else if("2".equals(changeType)){ + dateType = "0"; + } + return dateType; + } + + /*** + * + * @param userid + * @param monthStartDate + * @param monthEndDate + * @return + */ + public Map getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate){ + + Map holidayMap = new HashMap(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + + try { + if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){ +// String activeGroupId = getUserActiveGroupId(userid); +// bb.writeLog("activeGroupId:"+activeGroupId); + + String fixedScheduleGroupId = "5"; + if(StringUtils.isNotBlank(fixedScheduleGroupId)){ + String sql =" select holidayDate,changeType from KQ_HolidaySet\n" + + " where groupid = " + fixedScheduleGroupId+ + " and holidayDate >='"+monthStartDate+"'\n" + + " and holidayDate <='"+monthEndDate+"' " ; + rs.execute(sql); + while (rs.next()){ + String holidayDate = Util.null2String(rs.getString("holidayDate")); + String changeType = Util.null2String(rs.getString("changeType")); +// String changeTypename = "" ; +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// changeTypename += "公众假日"; +// }else if("2".equals(changeType)){ +// changeTypename += "调配工作日"; +// }else if("3".equals(changeType)){ +// changeTypename += "调配休息日"; +// } + + holidayMap.put(holidayDate,changeType); + +// if(weekMap.containsKey(holidayDate)){ +// String holidayDate_new = weekMap.get(holidayDate); +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// holidayDate_new += "[公众假日]"; +// }else if("1".equals(changeType)){ +// holidayDate_new += "[调配工作日]"; +// }else if("2".equals(changeType)){ +// holidayDate_new += "[调配休息日]"; +// } +// weekMap.put(holidayDate,holidayDate_new); +// } + } + } + } + }catch (Exception e){ + + } + return holidayMap; + } + + /*** + * + * @param userid + * @return + */ + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } + + +%> + + diff --git a/浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayData3_test2.jsp b/浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayData3_test2.jsp new file mode 100644 index 0000000..1aa1718 --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayData3_test2.jsp @@ -0,0 +1,248 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="weaver.common.DateUtil" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="com.alibaba.fastjson.JSONArray" %> +<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupBiz" %> +<%@ page import="java.time.LocalDate" %> +<%@ page import="java.time.format.DateTimeFormatter" %> +<%@ page import="java.time.DayOfWeek" %> +<%@ page import="java.time.temporal.TemporalAdjusters" %> +<%@ page import="java.util.*" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + + String[] workSchedule = {"09:00-11:00","11:00-16:00","16:00-20:00","20:00-21:30"}; + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } + int userid = user.getUID(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + String pbrq = request.getParameter("pbrq"); + String bp = request.getParameter("bp"); + + + + String dateType = "0"; + DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate currentDate = LocalDate.parse(pbrq, df); + + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); + int weekValue = dayOfWeek.getValue(); + + LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 + String monthStartDate = startDayOfMonth.toString(); + String monthEndDate = lastDayOfMonth.toString(); + Map holidayMap = getHolidayByGroupId(userid+"",monthStartDate,monthEndDate); + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + out.print("changeType:"+changeType+"
"); + } + + if("2".equals(changeType)){ + dateType = "0"; + }else if("1".equals(changeType) || "3".equals(changeType)){ + dateType = "1"; + }else if(weekValue == 6 || weekValue == 7){ + dateType = "1"; + } + + out.print("dateType:"+dateType+"
"); + + Map defaultScheduleMap = new HashMap(); + if(StringUtils.isNotBlank(bp)){ + String sql = " select dysjd,pzrs from uf_pbjcsj where bprs = ? and pblx = ?" ; + out.print("sql:"+sql+"
"); + rs.executeQuery(sql,new Object[]{bp,dateType}); + while (rs.next()){ + int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd"))); + int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs"))); + + String sjd = ""; + if(dysd < workSchedule.length){ + sjd = workSchedule[dysd]; + if(StringUtils.isNotBlank(sjd)){ + defaultScheduleMap.put(sjd,pzrs); + } + } + } + } + +%> + + +<%! + + public String getWeekTypeByDate(String pbrq,String userid){ + + String dateType = "0"; + DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate currentDate = LocalDate.parse(pbrq, df); + + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); + int weekValue = dayOfWeek.getValue(); + + LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 + String monthStartDate = startDayOfMonth.toString(); + String monthEndDate = lastDayOfMonth.toString(); + Map holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate); + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + + if("1".equals(changeType) || "3".equals(changeType)){ + dateType = "1"; + }else if(weekValue == 6 || weekValue == 7){ + dateType = "1"; + }else if("2".equals(changeType)){ + dateType = "0"; + } + return dateType; + } + + /*** + * + * @param userid + * @param monthStartDate + * @param monthEndDate + * @return + */ + public Map getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate){ + + Map holidayMap = new HashMap(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + + try { + if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){ +// String activeGroupId = getUserActiveGroupId(userid); +// bb.writeLog("activeGroupId:"+activeGroupId); + + String fixedScheduleGroupId = "5"; + if(StringUtils.isNotBlank(fixedScheduleGroupId)){ + String sql =" select holidayDate,changeType from KQ_HolidaySet\n" + + " where groupid = " + fixedScheduleGroupId+ + " and holidayDate >='"+monthStartDate+"'\n" + + " and holidayDate <='"+monthEndDate+"' " ; + rs.execute(sql); + while (rs.next()){ + String holidayDate = Util.null2String(rs.getString("holidayDate")); + String changeType = Util.null2String(rs.getString("changeType")); +// String changeTypename = "" ; +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// changeTypename += "公众假日"; +// }else if("2".equals(changeType)){ +// changeTypename += "调配工作日"; +// }else if("3".equals(changeType)){ +// changeTypename += "调配休息日"; +// } + + holidayMap.put(holidayDate,changeType); + +// if(weekMap.containsKey(holidayDate)){ +// String holidayDate_new = weekMap.get(holidayDate); +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// holidayDate_new += "[公众假日]"; +// }else if("1".equals(changeType)){ +// holidayDate_new += "[调配工作日]"; +// }else if("2".equals(changeType)){ +// holidayDate_new += "[调配休息日]"; +// } +// weekMap.put(holidayDate,holidayDate_new); +// } + } + } + } + }catch (Exception e){ + + } + return holidayMap; + } + + /*** + * + * @param userid + * @return + */ + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } + + +%> + + diff --git a/浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayData3_test3.jsp b/浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayData3_test3.jsp new file mode 100644 index 0000000..58d1793 --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayData3_test3.jsp @@ -0,0 +1,470 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="weaver.common.DateUtil" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="com.alibaba.fastjson.JSONArray" %> +<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupBiz" %> +<%@ page import="java.time.LocalDate" %> +<%@ page import="java.time.format.DateTimeFormatter" %> +<%@ page import="java.time.DayOfWeek" %> +<%@ page import="java.time.temporal.TemporalAdjusters" %> +<%@ page import="java.util.*" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + + String[] workSchedule = {"09:00-11:00","11:00-16:00","16:00-20:00","20:00-21:30"}; + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } + int userid = user.getUID(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + String pbdata = request.getParameter("pbdata"); + String bp = request.getParameter("bp"); + +// if(StringUtils.isBlank(pb)){ +// +// JSONArray jsonArray = new JSONArray(); +// JSONObject userObject = new JSONObject(); +// userObject.put("userid","3039"); +// userObject.put("serialid","10"); +// jsonArray.add(userObject); +// +// userObject = new JSONObject(); +// userObject.put("userid","3373"); +// userObject.put("serialid","7"); +// jsonArray.add(userObject); +// +// userObject = new JSONObject(); +// userObject.put("userid","3661"); +// userObject.put("serialid","9"); +// jsonArray.add(userObject); +// pb = jsonArray.toJSONString(); +// } + + String yjl = request.getParameter("yjl"); + String pbrq = request.getParameter("pbrq"); + String dateType = "0"; + if(StringUtils.isNotBlank(pbrq)){ + dateType = getWeekTypeByDate(pbrq,userid+""); + } + + out.print("bp:"+bp+"
"); + out.print("dateType:"+dateType+"
"); + Map defaultScheduleMap = new HashMap(); + if(StringUtils.isNotBlank(bp)){ + String sql = " select dysjd,pzrs from uf_pbjcsj where bprs = ? and pblx = ?" ; + rs.executeQuery(sql,new Object[]{bp,dateType}); + while (rs.next()){ + int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd"))); + int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs"))); + out.print("dysd:"+dateType+"
"); + out.print("pzrs:"+pzrs+"
"); + + String sjd = ""; + if(dysd < workSchedule.length){ + sjd = workSchedule[dysd]; + if(StringUtils.isNotBlank(sjd)){ + defaultScheduleMap.put(sjd,pzrs); + } + } + } + } + + List> workScheduleList = new ArrayList>(); + Map workScheduleMap = null; + for(int k=0;k0){ + String[] schedule = workSchedule[k].split("-"); + String scheduleStartTime = schedule[0]; + String scheduleEndTime = schedule[1]; + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + workScheduleMap = new HashMap(); + workScheduleMap.put("start",""); + workScheduleMap.put("end",scheduleEndTime); + workScheduleList.add(workScheduleMap); + } + } + }else if(k==(workSchedule.length-1)){ + if(workSchedule[k].indexOf("-")>0){ + String[] schedule = workSchedule[k].split("-"); + String scheduleStartTime = schedule[0]; + String scheduleEndTime = schedule[1]; + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + workScheduleMap = new HashMap(); + workScheduleMap.put("start",scheduleStartTime); + workScheduleMap.put("end",""); + workScheduleList.add(workScheduleMap); + } + } + }else{ + if(workSchedule[k].indexOf("-")>0){ + String[] schedule = workSchedule[k].split("-"); + String scheduleStartTime = schedule[0]; + String scheduleEndTime = schedule[1]; + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + workScheduleMap = new HashMap(); + workScheduleMap.put("start",scheduleStartTime); + workScheduleMap.put("end",scheduleEndTime); + workScheduleList.add(workScheduleMap); + } + } + } + } + + Map> userScheduleDayMap = new HashMap>(); + Map necessaryMap = new HashMap(); + + Map userScheduleMap = new HashMap(); + if(StringUtils.isNotBlank(pbdata)) { + JSONArray jsonArray = JSONArray.parseArray(pbdata); + + String yxrys = "" ; + for(int i = 0;i userList = new ArrayList(); + String sql =" select h.id \n" + + " from hrmresource h \n" + + " inner join hrmjobtitles k on k.id = h.jobtitle\n" + + " where h.id in("+yxrys+")\n" + + " and k.jobtitlename in('店长','验光师')\n" + + " and h.status in(0,1,2,3)\n" + + " union \n" + + " select h.id \n" + + " from hrmresource h \n" + + " inner join cus_fielddata k on k.id = h.id\n" + + " where k.field39 = 2 \n" + + " and k.scopeid=3 \n" + + " and k.scope='HrmCustomFieldByInfoType' " + + " and h.id in("+yxrys+") and h.status in(0,1,2,3) " + + " union " + + " select h.id\n" + + " from hrmresource h \n" + + " inner join cus_fielddata k on k.id = h.id \n" + + " where k.scopeid=-1 " + + " and k.scope='HrmCustomFieldByInfoType'\n" + + " and substring(k.field1,charindex('_',k.field1)+1,len(k.field1)) in(select id from uf_gwjbsjb where jbmc in('配镜一级','配镜二级','配镜三级','配镜四级','配镜五级')) and charindex('_', k.field1) > 0 \n" + + " and h.status in(0,1,2,3) "+ + " and h.id in("+yxrys+") "; + + out.print("sql:"+sql+"
"); + + rs.executeQuery(sql); + while (rs.next()){ + String id = Util.null2String(rs.getString("id")); + userList.add(id); + } + out.print("userList:"+userList.size()+"
"); + + for(int i = 0;i"); + rs.executeQuery(sql,new Object[]{serialid}); + while(rs.next()){ + String onoffworktype = Util.null2String(rs.getString("onoffworktype")); + if("start".equals(onoffworktype)){ + startTime = Util.null2String(rs.getString("times")); + }else if("end".equals(onoffworktype)){ + endTime = Util.null2String(rs.getString("times")); + } + } + + out.print("startTime:"+startTime+"
"); + out.print("endTime:"+endTime+"
"); + + + Map userSchedule_Map = new HashMap(); + if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){ + userSchedule_Map.put("startTime",startTime); + userSchedule_Map.put("endTime",endTime); + + + for(int k=0;k workSchedule_Map = workScheduleList.get(k); + String scheduleStartTime = workSchedule_Map.get("start"); + String scheduleEndTime = workSchedule_Map.get("end"); + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + if(startTime.compareTo(scheduleStartTime) <=0 && endTime.compareTo(scheduleEndTime) >=0){ + + String defWorkSchedule = scheduleStartTime+"-"+scheduleEndTime ; + if(userScheduleMap.containsKey(defWorkSchedule)){ + int count = userScheduleMap.get(defWorkSchedule); + count++; + userScheduleMap.put(defWorkSchedule,count); + }else{ + userScheduleMap.put(defWorkSchedule,1); + } + + if(userList.contains(pbry)){ + necessaryMap.put(defWorkSchedule,1); + } + } + }else{ + if(StringUtils.isNotBlank(scheduleStartTime)){ + + if(endTime.compareTo(scheduleStartTime) >=0 ){ + String define_scheduleEndTime = "21:30"; + String defWorkSchedule = scheduleStartTime+"-"+define_scheduleEndTime ; + if(userScheduleMap.containsKey(defWorkSchedule)){ + int count = userScheduleMap.get(defWorkSchedule); + count++; + userScheduleMap.put(defWorkSchedule,count); + }else{ + userScheduleMap.put(defWorkSchedule,1); + } + + if(userList.contains(pbry)){ + necessaryMap.put(defWorkSchedule,1); + } + } + }else if(StringUtils.isNotBlank(scheduleEndTime)){ + + if(startTime.compareTo(scheduleEndTime) <=0){ + String define_scheduleStartTime = "09:00"; + String defWorkSchedule = define_scheduleStartTime+"-"+scheduleEndTime ; + if(userScheduleMap.containsKey(defWorkSchedule)){ + int count = userScheduleMap.get(defWorkSchedule); + count++; + userScheduleMap.put(defWorkSchedule,count); + }else{ + userScheduleMap.put(defWorkSchedule,1); + } + + if(userList.contains(pbry)){ + necessaryMap.put(defWorkSchedule,1); + } + } + + } + } + } + } + userScheduleDayMap.put(pbry,userSchedule_Map); + } + } + + out.print("userScheduleDayMap:"+userScheduleDayMap.size()+"
"); + + + int defaultcount = 0; + int datacount = 0; + Iterator> iterator = defaultScheduleMap.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); + int value =entry.getValue(); + String key = entry.getKey(); + out.print("value:"+value+"
"); + out.print("key:"+key+"
"); + + if(userScheduleMap.containsKey(key)){ + int useValue = userScheduleMap.get(key); + out.print("useValue:"+useValue+"
"); + if(useValue < value){ + datacount++; + } + }else{ + datacount++; + out.print("datacount:"+datacount+"
"); + } + defaultcount++; + } + + JSONObject jsonObject = new JSONObject(); + if(defaultcount >0 && datacount == 0){ + if(necessaryMap.size() == 4){ + jsonObject.put("pbcode","1"); + }else{ + jsonObject.put("pbcode","2"); + } + }else{ + jsonObject.put("pbcode","0"); + } + + jsonObject.put("pbinfo",userScheduleDayMap); +%> + +<%=jsonObject.toJSONString() %> + +<%! + + public String getWeekTypeByDate(String pbrq,String userid){ + + String dateType = "0"; + DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate currentDate = LocalDate.parse(pbrq, df); + + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); + int weekValue = dayOfWeek.getValue(); + + LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 + String monthStartDate = startDayOfMonth.toString(); + String monthEndDate = lastDayOfMonth.toString(); + Map holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate); + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + + if("2".equals(changeType)){ + dateType = "0"; + }else if("1".equals(changeType) || "3".equals(changeType)){ + dateType = "1"; + }else if(weekValue == 6 || weekValue == 7){ + dateType = "1"; + } + + return dateType; + } + + /*** + * + * @param userid + * @param monthStartDate + * @param monthEndDate + * @return + */ + public Map getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate){ + + Map holidayMap = new HashMap(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + + try { + if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){ +// String activeGroupId = getUserActiveGroupId(userid); +// bb.writeLog("activeGroupId:"+activeGroupId); + + String fixedScheduleGroupId = "5"; + if(StringUtils.isNotBlank(fixedScheduleGroupId)){ + String sql =" select holidayDate,changeType from KQ_HolidaySet\n" + + " where groupid = " + fixedScheduleGroupId+ + " and holidayDate >='"+monthStartDate+"'\n" + + " and holidayDate <='"+monthEndDate+"' " ; + rs.execute(sql); + while (rs.next()){ + String holidayDate = Util.null2String(rs.getString("holidayDate")); + String changeType = Util.null2String(rs.getString("changeType")); +// String changeTypename = "" ; +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// changeTypename += "公众假日"; +// }else if("2".equals(changeType)){ +// changeTypename += "调配工作日"; +// }else if("3".equals(changeType)){ +// changeTypename += "调配休息日"; +// } + + holidayMap.put(holidayDate,changeType); + +// if(weekMap.containsKey(holidayDate)){ +// String holidayDate_new = weekMap.get(holidayDate); +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// holidayDate_new += "[公众假日]"; +// }else if("1".equals(changeType)){ +// holidayDate_new += "[调配工作日]"; +// }else if("2".equals(changeType)){ +// holidayDate_new += "[调配休息日]"; +// } +// weekMap.put(holidayDate,holidayDate_new); +// } + } + } + } + }catch (Exception e){ + + } + return holidayMap; + } + + /*** + * + * @param userid + * @return + */ + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } + + +%> + + diff --git a/浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayData4.jsp b/浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayData4.jsp new file mode 100644 index 0000000..bee9589 --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayData4.jsp @@ -0,0 +1,514 @@ +<%@page import="com.alibaba.fastjson.JSON"%> +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="weaver.common.DateUtil" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="com.alibaba.fastjson.JSONArray" %> +<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupBiz" %> +<%@ page import="java.time.LocalDate" %> +<%@ page import="java.time.format.DateTimeFormatter" %> +<%@ page import="java.time.DayOfWeek" %> +<%@ page import="java.time.temporal.TemporalAdjusters" %> +<%@ page import="java.util.*" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + + String[] workSchedule = {"09:00-11:00","11:00-16:00","16:00-20:00","20:00-21:30"}; + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } + int userid = user.getUID(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + String pbdata = request.getParameter("pbdata"); + String bp = request.getParameter("bp"); + +// if(StringUtils.isBlank(pb)){ +// +// JSONArray jsonArray = new JSONArray(); +// JSONObject userObject = new JSONObject(); +// userObject.put("userid","3039"); +// userObject.put("serialid","10"); +// jsonArray.add(userObject); +// +// userObject = new JSONObject(); +// userObject.put("userid","3373"); +// userObject.put("serialid","7"); +// jsonArray.add(userObject); +// +// userObject = new JSONObject(); +// userObject.put("userid","3661"); +// userObject.put("serialid","9"); +// jsonArray.add(userObject); +// pb = jsonArray.toJSONString(); +// } + + String yjl = request.getParameter("yjl"); + String pbrq = request.getParameter("pbrq"); + String dateType = "0"; + if(StringUtils.isNotBlank(pbrq)){ + dateType = getWeekTypeByDate(pbrq,userid+""); + } + out.println("dateType1:"+dateType+"
"); + +// if(StringUtils.isNoneBlank(dateType)){ +// String dateType2 = "0"; +// DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd"); +// LocalDate currentDate = LocalDate.parse(pbrq, df); +// +// DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); +// int weekValue = dayOfWeek.getValue(); +// +// LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 +// LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 +// String monthStartDate = startDayOfMonth.toString(); +// String monthEndDate = lastDayOfMonth.toString(); +// Map holidayMap = getHolidayByGroupId(userid+"", monthStartDate, monthEndDate); +// +// String changeType = "" ; +// if(holidayMap.containsKey(currentDate.toString())){ +// changeType = holidayMap.get(currentDate.toString()); +// } +// out.println("monthStartDate:"+monthStartDate+"
"); +// out.println("monthEndDate:"+monthEndDate+"
"); +// out.println("userid:"+userid+"
"); +// out.println("changeType:"+changeType+"
"); +// out.println("weekValue:"+weekValue+"
"); +// +// if("1".equals(changeType) || "3".equals(changeType)){ +// dateType2 = "1"; +// }else if(weekValue == 6 || weekValue == 7){ +// dateType2 = "1"; +// } +// } + + out.println("dateType2:"+dateType+"
"); + Map defaultScheduleMap = new HashMap(); + if(StringUtils.isNotBlank(bp)){ + String sql = " select dysjd,pzrs from uf_pbjcsj where bprs = ? and pblx = ?" ; + out.println("sql:"+sql+"
"); + rs.executeQuery(sql,new Object[]{bp,dateType}); + while (rs.next()){ + int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd"))); + int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs"))); + + String sjd = ""; + if(dysd < workSchedule.length){ + sjd = workSchedule[dysd]; + if(StringUtils.isNotBlank(sjd)){ + defaultScheduleMap.put(sjd,pzrs); + } + } + } + } + + List> workScheduleList = new ArrayList>(); + Map workScheduleMap = null; + for(int k=0;k0){ + String[] schedule = workSchedule[k].split("-"); + String scheduleStartTime = schedule[0]; + String scheduleEndTime = schedule[1]; + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + workScheduleMap = new HashMap(); + workScheduleMap.put("start",""); + workScheduleMap.put("end",scheduleEndTime); + workScheduleList.add(workScheduleMap); + } + } + }else if(k==(workSchedule.length-1)){ + if(workSchedule[k].indexOf("-")>0){ + String[] schedule = workSchedule[k].split("-"); + String scheduleStartTime = schedule[0]; + String scheduleEndTime = schedule[1]; + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + workScheduleMap = new HashMap(); + workScheduleMap.put("start",scheduleStartTime); + workScheduleMap.put("end",""); + workScheduleList.add(workScheduleMap); + } + } + }else{ + if(workSchedule[k].indexOf("-")>0){ + String[] schedule = workSchedule[k].split("-"); + String scheduleStartTime = schedule[0]; + String scheduleEndTime = schedule[1]; + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + workScheduleMap = new HashMap(); + workScheduleMap.put("start",scheduleStartTime); + workScheduleMap.put("end",scheduleEndTime); + workScheduleList.add(workScheduleMap); + } + } + } + } + + Map> userScheduleDayMap = new HashMap>(); + Map necessaryMap = new HashMap(); + + Map userScheduleMap = new HashMap(); + if(StringUtils.isNotBlank(pbdata)) { + JSONArray jsonArray = JSONArray.parseArray(pbdata); + + String yxrys = "" ; + for(int i = 0;i userList = new ArrayList(); + String sql =" select h.id \n" + + " from hrmresource h \n" + + " inner join hrmjobtitles k on k.id = h.jobtitle\n" + + " where h.id in("+yxrys+")\n" + + " and k.jobtitlename in('店长','验光师')\n" + + " and h.status in(0,1,2,3)\n" + + " union \n" + + " select h.id \n" + + " from hrmresource h \n" + + " inner join cus_fielddata k on k.id = h.id\n" + + " where k.field39 = 2 \n" + + " and k.scopeid=3 \n" + + " and k.scope='HrmCustomFieldByInfoType' " + + " and h.id in("+yxrys+") and h.status in(0,1,2,3) " + + " union " + + " select h.id\n" + + " from hrmresource h \n" + + " inner join cus_fielddata k on k.id = h.id \n" + + " where k.scopeid=-1 " + + " and k.scope='HrmCustomFieldByInfoType'\n" + + " and substring(k.field1,charindex('_',k.field1)+1,len(k.field1)) in(select id from uf_gwjbsjb where jbmc in('配镜一级','配镜二级','配镜三级','配镜四级','配镜五级')) and charindex('_', k.field1) > 0 \n" + + " and h.status in(0,1,2,3) "+ + " and h.id in("+yxrys+") "; + + rs.executeQuery(sql); + while (rs.next()){ + String id = Util.null2String(rs.getString("id")); + userList.add(id); + } + + for(int i = 0;i"); + rs.executeQuery(sql,new Object[]{serialid}); + while(rs.next()){ + String onoffworktype = Util.null2String(rs.getString("onoffworktype")); + if("start".equals(onoffworktype)){ + startTime = Util.null2String(rs.getString("times")); + }else if("end".equals(onoffworktype)){ + endTime = Util.null2String(rs.getString("times")); + } + } + + Map userSchedule_Map = new HashMap(); + if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){ + userSchedule_Map.put("startTime",startTime); + userSchedule_Map.put("endTime",endTime); + + + for(int k=0;k workSchedule_Map = workScheduleList.get(k); + String scheduleStartTime = workSchedule_Map.get("start"); + String scheduleEndTime = workSchedule_Map.get("end"); + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + if(startTime.compareTo(scheduleStartTime) <=0 && endTime.compareTo(scheduleEndTime) >=0){ + + String defWorkSchedule = scheduleStartTime+"-"+scheduleEndTime ; + if(userScheduleMap.containsKey(defWorkSchedule)){ + int count = userScheduleMap.get(defWorkSchedule); + count++; + userScheduleMap.put(defWorkSchedule,count); + }else{ + userScheduleMap.put(defWorkSchedule,1); + } + + if(userList.contains(pbry)){ + necessaryMap.put(defWorkSchedule,1); + } + } + }else{ + if(StringUtils.isNotBlank(scheduleStartTime)){ + + if(endTime.compareTo(scheduleStartTime) >=0 ){ + String define_scheduleEndTime = "21:30"; + String defWorkSchedule = scheduleStartTime+"-"+define_scheduleEndTime ; + if(userScheduleMap.containsKey(defWorkSchedule)){ + int count = userScheduleMap.get(defWorkSchedule); + count++; + userScheduleMap.put(defWorkSchedule,count); + }else{ + userScheduleMap.put(defWorkSchedule,1); + } + + if(userList.contains(pbry)){ + necessaryMap.put(defWorkSchedule,1); + } + } + }else if(StringUtils.isNotBlank(scheduleEndTime)){ + + if(startTime.compareTo(scheduleEndTime) <=0){ + String define_scheduleStartTime = "09:00"; + String defWorkSchedule = define_scheduleStartTime+"-"+scheduleEndTime ; + if(userScheduleMap.containsKey(defWorkSchedule)){ + int count = userScheduleMap.get(defWorkSchedule); + count++; + userScheduleMap.put(defWorkSchedule,count); + }else{ + userScheduleMap.put(defWorkSchedule,1); + } + + if(userList.contains(pbry)){ + necessaryMap.put(defWorkSchedule,1); + } + } + + } + } + } + } + + + userScheduleDayMap.put(pbry,userSchedule_Map); + } + } + + + Iterator> iterator3 = userScheduleMap.entrySet().iterator(); + while (iterator3.hasNext()) { + Map.Entry entry = iterator3.next(); + int value = entry.getValue(); + String key = entry.getKey(); + + out.println("userScheduleMap--value:"+value+" key:"+key+"
"); + } + + + /* Iterator>> iterator2 = userScheduleDayMap.entrySet().iterator(); + while (iterator2.hasNext()) { + Map.Entry> entry = iterator2.next(); + Map valMap = entry.getValue(); + String key = entry.getKey(); + + String valJson = JSONObject.toJSONString(valMap); + out.println("userScheduleDayMap--value:"+valJson+" key:"+key+"
"); + } */ + + + + int defaultcount = 0; + int datacount = 0; + Iterator> iterator = defaultScheduleMap.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); + int value = entry.getValue(); + String key = entry.getKey(); + out.println("defaultScheduleMap-value:"+value+" key:"+key+"
"); + if(userScheduleMap.containsKey(key)){ + int useValue = userScheduleMap.get(key); + if(useValue < value){ + datacount++; + } + }else{ + datacount++; + } + defaultcount++; + } + + JSONObject jsonObject = new JSONObject(); + if(defaultcount >0 && datacount == 0){ + if(necessaryMap.size() == 4){ + jsonObject.put("pbcode","1"); + }else{ + jsonObject.put("pbcode","2"); + } + }else{ + jsonObject.put("pbcode","0"); + } + + jsonObject.put("pbinfo",userScheduleDayMap); +%> + +<%=jsonObject.toJSONString() %> + +<%! + + public String getWeekTypeByDate(String pbrq,String userid){ + + String dateType = "0"; + DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate currentDate = LocalDate.parse(pbrq, df); + + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); + int weekValue = dayOfWeek.getValue(); + + LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 + String monthStartDate = startDayOfMonth.toString(); + String monthEndDate = lastDayOfMonth.toString(); + Map holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate); + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + + if("1".equals(changeType) || "3".equals(changeType)){ + dateType = "1"; + }else if(weekValue == 6 || weekValue == 7){ + dateType = "1"; + } + return dateType; + } + + /*** + * + * @param userid + * @param monthStartDate + * @param monthEndDate + * @return + */ + public Map getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate){ + + Map holidayMap = new HashMap(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + + try { + if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){ +// String activeGroupId = getUserActiveGroupId(userid); +// bb.writeLog("activeGroupId:"+activeGroupId); + + String fixedScheduleGroupId = "5"; + + if(StringUtils.isNotBlank(fixedScheduleGroupId)){ + String sql =" select holidayDate,changeType from KQ_HolidaySet\n" + + " where groupid = " + fixedScheduleGroupId+ + " and holidayDate >='"+monthStartDate+"'\n" + + " and holidayDate <='"+monthEndDate+"' " ; + rs.execute(sql); + while (rs.next()){ + String holidayDate = Util.null2String(rs.getString("holidayDate")); + String changeType = Util.null2String(rs.getString("changeType")); +// String changeTypename = "" ; +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// changeTypename += "公众假日"; +// }else if("2".equals(changeType)){ +// changeTypename += "调配工作日"; +// }else if("3".equals(changeType)){ +// changeTypename += "调配休息日"; +// } + holidayMap.put(holidayDate,changeType); + +// if(weekMap.containsKey(holidayDate)){ +// String holidayDate_new = weekMap.get(holidayDate); +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// holidayDate_new += "[公众假日]"; +// }else if("1".equals(changeType)){ +// holidayDate_new += "[调配工作日]"; +// }else if("2".equals(changeType)){ +// holidayDate_new += "[调配休息日]"; +// } +// weekMap.put(holidayDate,holidayDate_new); +// } + } + } + } + }catch (Exception e){ + + } + return holidayMap; + } + + /*** + * + * @param userid + * @return + */ + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } + + + + +%> + + + + + diff --git a/浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayDataByMonth2.jsp b/浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayDataByMonth2.jsp new file mode 100644 index 0000000..6c00082 --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayDataByMonth2.jsp @@ -0,0 +1,857 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="weaver.common.DateUtil" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupBiz" %> +<%@ page import="java.time.LocalDate" %> +<%@ page import="java.time.format.DateTimeFormatter" %> +<%@ page import="java.time.DayOfWeek" %> +<%@ page import="java.time.temporal.TemporalAdjusters" %> +<%@ page import="java.util.*" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + + String[] workSchedule = {"09:00-11:00","11:00-16:00","16:00-20:00","20:00-21:30"}; + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } +// int userid = user.getUID(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + String cjr = request.getParameter("cjr"); + String pbyf = request.getParameter("pbyf"); + String yjl = request.getParameter("yjl"); //mdyj + String cjrbm = request.getParameter("cjrbm"); + + + String activeGroupId = getUserActiveGroupId(cjr+""); +// List> scheduleList = queryShiftScheduleByUser(pbyf,activeGroupId,cjr); +// out.println("scheduleList"+ JSON.toJSON(scheduleList)); + + List> hrmList = new ArrayList>(); + +// out.println("cjrbm:"+cjrbm+"
"); + if(StringUtils.isNotBlank(cjrbm)) { + String sql = "select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) "; + hrmList = queryListBySql(sql); + } + + int daysInMonth = 0; + Map holidayMap = new HashMap(); + List daysList = new ArrayList(); + Map weekMap = new HashMap(); + + List> weekList = new ArrayList>(); + + + if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7) { + LocalDate localDate = LocalDate.parse(pbyf + "-01"); // 获取当前日期 + LocalDate lastDayOfMonth = localDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + LocalDate firstDayOfMonth = localDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 + +// for (LocalDate date = firstDayOfMonth; !date.isAfter(lastDayOfMonth); date = date.plusDays(1)) { +// daysList.add(date.toString()); +// } + + String monthStartDate = firstDayOfMonth.toString(); + String monthEndDate = lastDayOfMonth.toString(); + holidayMap = getHolidayByGroupId(monthStartDate, monthEndDate,activeGroupId); + + daysInMonth = localDate.lengthOfMonth(); // 获取本月有多少天 + int thisMonth = localDate.getMonthValue(); // 获取当前是哪月 + + for (int i = 1; i <= daysInMonth; i++) { + LocalDate currentDate = LocalDate.of(localDate.getYear(), thisMonth, i); + + daysList.add(currentDate.toString()); + +// System.out.println("currentDate:" + currentDate.toString()); + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); +// System.out.println(i + "号是周 " + dayOfWeek.getValue()); + int weekValue = dayOfWeek.getValue(); + + String weekDayName = ""; + switch (weekValue) { + case 1: + weekDayName = "周一"; + break; + case 2: + weekDayName = "周二"; + break; + case 3: + weekDayName = "周三"; + break; + case 4: + weekDayName = "周四"; + break; + case 5: + weekDayName = "周五"; + break; + case 6: + weekDayName = "周六"; + break; + case 7: + weekDayName = "周日"; + break; + } + + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + Map weekMap2 = new HashMap(); + weekMap2.put("weekname", weekDayName); + String changeTypename= "" ; + if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 + changeTypename += "[公众假日]"; + }else if("2".equals(changeType)){ + changeTypename += "[调配工作日]"; + }else if("3".equals(changeType)){ + changeTypename += "[调配休息日]"; + } + weekMap2.put("changeType", changeTypename); + weekMap2.put("weekday", i+""); + weekMap2.put("weekdate", currentDate.toString()); + weekList.add(weekMap2); + + + if("1".equals(changeType) || "3".equals(changeType)){ + weekValue = 11; + } + + if(StringUtils.isNotBlank(changeType)){ + weekMap.put(currentDate.toString(), weekValue+""); + }else{ + weekMap.put(currentDate.toString(), weekValue+""); + } + } + } + + List> dt1DataList = new ArrayList>(); + for(int i=0;i hrmMap = hrmList.get(i); + String ry = hrmMap.get("id"); + String lastname = hrmMap.get("lastname"); + + Map dt1DataMap = new HashMap(); + Map ryMap = getDt1UserMap(ry,lastname); + dt1DataMap.put("ry",ryMap); + + List> scheduleList = queryShiftScheduleByUser(pbyf,activeGroupId,ry); + + dt1DataMap.put("schedule",scheduleList); + + List restList = getSchedulingRestData(); + Map countMap = queryCountWorkTime(restList,daysList,weekMap,scheduleList); + dt1DataMap.put("count",countMap); + + dt1DataList.add(dt1DataMap); + } +// out.println("dt1DataList"+ JSON.toJSON(dt1DataList)+"
"); + + + List> resultList = queryScheduleStatusByDay(daysList,holidayMap,yjl,workSchedule,hrmList,activeGroupId); + +// out.println("resultList"+ JSON.toJSON(resultList)+"
"); + + Map valueMap = getMainUserDate(hrmList); + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("data",valueMap); + jsonObject.put("dt1day",resultList); + jsonObject.put("dt1user",dt1DataList); + jsonObject.put("days",daysInMonth); + jsonObject.put("head",weekList); +%> + +<%=jsonObject.toJSONString() %> + +<%! + /*** + * + * @param hrmList + * @return + */ + public Map getMainUserDate(List> hrmList){ + String userids = ""; + List> specialobjList = new ArrayList>(); + for(int i=0;i hrmMap = hrmList.get(i); + String userid = Util.null2String(hrmMap.get("id")); + String lastname = Util.null2String(hrmMap.get("lastname")); + userids += StringUtils.isBlank(userids) ? userid : ","+userid ; + + Map specialobjMap = new HashMap(); + specialobjMap.put("id",userid); + specialobjMap.put("name",lastname); + specialobjList.add(specialobjMap); + } + + Map valueMap = new HashMap(); + valueMap.put("value",userids); + valueMap.put("specialobj",specialobjList); + return valueMap; + } + + /*** + * + * @param hrmList + * @return + */ + public List> getDt1UserDate(List> hrmList){ + List> dt1List = new ArrayList>(); + for(int i=0;i hrmMap = hrmList.get(i); + + String userid = Util.null2String(hrmMap.get("id")); + String lastname = Util.null2String(hrmMap.get("lastname")); + + Map dt1Map = new HashMap(); + dt1Map.put("id",userid); + dt1Map.put("name",lastname); + + List> specialobjList2 = new ArrayList>(); + Map specialobjMap2 = new HashMap(); + specialobjMap2.put("id",userid); + specialobjMap2.put("name",lastname); + specialobjList2.add(specialobjMap2); + + Map valueMap2 = new HashMap(); + valueMap2.put("value",userid); + valueMap2.put("specialobj",specialobjList2); + dt1Map.put("value",valueMap2); + + dt1List.add(dt1Map); + } + return dt1List; + } + + + + + + public String getWeekTypeByDate(String pbrq,String userid,String activeGroupId){ + + String dateType = "0"; + DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate currentDate = LocalDate.parse(pbrq, df); + + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); + int weekValue = dayOfWeek.getValue(); + + LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 + String monthStartDate = startDayOfMonth.toString(); + String monthEndDate = lastDayOfMonth.toString(); + + Map holidayMap = getHolidayByGroupId(monthStartDate,monthEndDate,activeGroupId); + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + + if("1".equals(changeType) || "3".equals(changeType)){ + dateType = "1"; + }else if(weekValue == 6 || weekValue == 7){ + dateType = "1"; + } + return dateType; + } + + /*** + * + * @param monthStartDate + * @param monthEndDate + * @return + */ + public Map getHolidayByGroupId(String monthStartDate,String monthEndDate,String activeGroupId){ + + Map holidayMap = new HashMap(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + + try { + if(StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){ + + String fixedScheduleGroupId = "5"; + + if(StringUtils.isNotBlank(fixedScheduleGroupId)){ + String sql =" select holidayDate,changeType from KQ_HolidaySet\n" + + " where groupid = " + fixedScheduleGroupId+ + " and holidayDate >='"+monthStartDate+"'\n" + + " and holidayDate <='"+monthEndDate+"' " ; + rs.execute(sql); + while (rs.next()){ + String holidayDate = Util.null2String(rs.getString("holidayDate")); + String changeType = Util.null2String(rs.getString("changeType")); +// String changeTypename = "" ; +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// changeTypename += "公众假日"; +// }else if("2".equals(changeType)){ +// changeTypename += "调配工作日"; +// }else if("3".equals(changeType)){ +// changeTypename += "调配休息日"; +// } + holidayMap.put(holidayDate,changeType); + +// if(weekMap.containsKey(holidayDate)){ +// String holidayDate_new = weekMap.get(holidayDate); +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// holidayDate_new += "[公众假日]"; +// }else if("1".equals(changeType)){ +// holidayDate_new += "[调配工作日]"; +// }else if("2".equals(changeType)){ +// holidayDate_new += "[调配休息日]"; +// } +// weekMap.put(holidayDate,holidayDate_new); +// } + } + } + } + }catch (Exception e){ + + } + return holidayMap; + } + + /*** + * + * @param userid + * @return + */ + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } + + + + + + + + public static List> queryListBySql(String sql){ + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + List> list = new ArrayList>(); + try{ + if(StringUtils.isNotBlank(sql)){ + Map map = new HashMap(); + rs.executeQuery(sql); + String[] column = rs.getColumnName(); + while (rs.next()){ + map = new HashMap(); + for(int i=0;i0){ + list.add(map); + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("queryListBySql-e:"+e); + } + return list; + } + + /*** + * + * @return + */ + public Map getDt1UserMap(String ry,String lastname){ + Map valueMap = new HashMap(); + if(StringUtils.isNotBlank(ry)){ + List> specialobjList = new ArrayList>(); + Map specialobjMap = new HashMap(); + specialobjMap.put("id",ry); + specialobjMap.put("name",lastname); + specialobjList.add(specialobjMap); + valueMap.put("id",ry); + valueMap.put("name",lastname); + valueMap.put("specialobj",specialobjList); + } + + return valueMap; + } + + + /*** + * + * @param pbyf + * @param groupid + * @param resourceid + * @return + */ + public List> queryShiftScheduleByUser(String pbyf,String groupid,String resourceid){ + BaseBean bb = new BaseBean(); + List> scheduleList = new ArrayList>(); + try{ + List> sqlList = new ArrayList>(); + if(StringUtils.isNotBlank(pbyf) && StringUtils.isNotBlank(resourceid)){ + String sql =" select t.serialid,k.serial,t.resourceid,t.kqdate\n" + + " from kq_shiftschedule t\n" + + " inner join kq_ShiftManagement k on k.id = t.serialid\n" + + " where left(t.kqdate,7)='"+pbyf+"' \n" + + " and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" + + " and resourceid = " + resourceid + + " order by kqdate "; + bb.writeLog("sql:"+sql); + sqlList = queryListBySql(sql); + } + + for(int i=0;i map = sqlList.get(i); + + String serialid = Util.null2String(map.get("serialid")); + String name = Util.null2String(map.get("serial")); + String kqdate = Util.null2String(map.get("kqdate")); + + String xh = ""; + if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){ + xh = kqdate.substring(8); + if(StringUtils.isNotBlank(xh)){ + if(xh.startsWith("0")){ + xh = xh.substring(1); + } + } + } + + if(StringUtils.isNotBlank(xh)){ + List> specialobjList = new ArrayList>(); + Map specialobjMap = new HashMap(); + specialobjMap.put("id",serialid); + specialobjMap.put("name",name); + specialobjList.add(specialobjMap); + + Map valueMap = new HashMap(); + valueMap.put("serialid",serialid); + valueMap.put("kqdate",kqdate); + valueMap.put("xh",xh); + + + + valueMap.put("specialobj",specialobjList); + + scheduleList.add(valueMap); + } + } + + }catch (Exception e){ + + } + return scheduleList; + } + + + public List getSchedulingRestData(){ + + List list = new ArrayList(); + RecordSet rs = new RecordSet(); + try{ + String sql =" select id " + + " from kq_ShiftManagement \n" + + " where is_rest = 1 \n" + + " and (isdelete is null or isdelete = 0) "; + + rs.executeQuery(sql); + while (rs.next()){ + String id = Util.null2String(rs.getString("id")); + list.add(id); + } + }catch (Exception e){ + + } + return list; + } + + /*** + * + * @param restList + * @param daysList + * @param weekMap + * @param serialList + */ + public Map queryCountWorkTime(List restList,List daysList,Map weekMap,List> serialList ){ + + BaseBean bb = new BaseBean(); + Map countMap = new HashMap<>(); + String worktime = "0"; + String totalworktime = "0"; + int restcount = 0; + int weekrestcount = 0; + + RecordSet rs = new RecordSet(); + try{ + String sql = ""; + for (int i = 0; i < serialList.size(); i++) { + Map serialMap = serialList.get(i); + String kqdate = Util.null2String(serialMap.get("kqdate")); + String serialid = Util.null2String(serialMap.get("serialid")); + if (daysList.contains(kqdate)) { + if (StringUtils.isNotBlank(serialid)) { + if (restList.contains(serialid)) { + restcount++; + } + + if(!restList.contains(serialid)){ + String sql2 = " select try_convert(int,worktime) as worktime from kq_ShiftManagement where id ="+serialid+" and (is_rest is null or is_rest = 0) " ; + sql += StringUtils.isBlank(sql) ? sql2 : " union all \n"+sql2 ; + } + } + + if (weekMap.containsKey(kqdate)) { + String value = weekMap.get(kqdate); + //6 = 周六 7 = 周日 11 = 公众假日、调配休息日 + if ("6".equals(value) || "7".equals(value) || "11".equals(value)) { + if (restList.contains(serialid)) { + weekrestcount++; + } + } + } + } + } + + if(StringUtils.isNotBlank(sql)){ + sql = " select round(sum(worktime)/60.0,2) as worktime,sum(worktime) as totalworktime from ("+sql+") w "; + rs.executeQuery(sql); + if(rs.next()){ + worktime = Util.null2String(rs.getString("worktime")); + totalworktime = Util.null2String(rs.getString("totalworktime")); + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("e:"+e); + } + + countMap.put("worktime",worktime); + countMap.put("totalworktime",totalworktime); + countMap.put("restcount",restcount+""); + countMap.put("weekrestcount",weekrestcount+""); + + return countMap; + } + + /*** + * + * @param daysList + * @param holidayMap + * @param yjl + * @param workSchedule + * @param hrmList + * @param groupid + * @return + */ + public List> queryScheduleStatusByDay(List daysList,Map holidayMap,String yjl,String[] workSchedule,List> hrmList,String groupid){ + + BaseBean bb = new BaseBean(); + List> resultList = new ArrayList>(); + + DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + RecordSet rs = new RecordSet(); + + try{ + List> workScheduleList = new ArrayList>(); + Map workScheduleMap = null; + for(int k=0;k0){ + String[] schedule = workSchedule[k].split("-"); + String scheduleStartTime = schedule[0]; + String scheduleEndTime = schedule[1]; + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + workScheduleMap = new HashMap(); + workScheduleMap.put("start",scheduleStartTime); + workScheduleMap.put("end",scheduleEndTime); + workScheduleList.add(workScheduleMap); + } + } + } + + String resourceids = ""; + for(int i=0;i hrmMap = hrmList.get(i); + String userid = Util.null2String(hrmMap.get("id")); + resourceids += StringUtils.isBlank(resourceids) ? userid : ","+userid ; + } + + for(String pbrq:daysList){ + String dateType = "0"; + if(StringUtils.isNotBlank(pbrq)){ + LocalDate currentDate = LocalDate.parse(pbrq, df); + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); + int weekValue = dayOfWeek.getValue(); + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + + if("1".equals(changeType) || "3".equals(changeType)){ + dateType = "1"; + }else if(weekValue == 6 || weekValue == 7){ + dateType = "1"; + } + } + + Map defaultScheduleMap = new HashMap(); + if(StringUtils.isNotBlank(yjl)){ + String sql = " select dysjd,pzrs from uf_pbjcsj where yjl = ? and pblx = ?" ; + rs.executeQuery(sql,new Object[]{yjl,dateType}); + while (rs.next()){ + int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd"))); + int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs"))); + + String sjd = ""; + if(dysd < workSchedule.length){ + sjd = workSchedule[dysd]; + if(StringUtils.isNotBlank(sjd)){ + defaultScheduleMap.put(sjd,pzrs); + } + } + } + } + + List> sqlList = new ArrayList>(); + if(StringUtils.isNotBlank(resourceids) && StringUtils.isNotBlank(pbrq)){ + + String sql =" select t.serialid,t.resourceid,t.kqdate \n" + + " from kq_shiftschedule t\n" + + " where t.kqdate='"+pbrq+"' \n" + + " and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" + + " and resourceid in( " + resourceids + ") "+ + " order by kqdate "; + sqlList = queryListBySql(sql); + } + + Map resultMap = queryScheduleStatusByUser(sqlList,workScheduleList,defaultScheduleMap,pbrq); + resultList.add(resultMap); + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("e:"+e); + } + + return resultList; + } + + /*** + * + * @param sqlList + * @param workScheduleList + * @param defaultScheduleMap + * @param kqdate + * @return + */ + public Map queryScheduleStatusByUser(List> sqlList,List> workScheduleList,Map defaultScheduleMap,String kqdate){ + + RecordSet rs = new RecordSet(); + + Map> userScheduleDayMap = new HashMap>(); + Map userScheduleMap = new HashMap(); + Map necessaryMap = new HashMap(); + String yxrys = "" ; + for(int i=0;i sqlMap = sqlList.get(i); + String resourceid = Util.null2String(sqlMap.get("resourceid")); + yxrys += StringUtils.isBlank(yxrys) ? resourceid :","+resourceid ; + } + if(StringUtils.isNotBlank(yxrys)) { + List userList = new ArrayList(); + String sql =" select h.id \n" + + " from hrmresource h \n" + + " inner join hrmjobtitles k on k.id = h.jobtitle\n" + + " where h.id in("+yxrys+")\n" + + " and k.jobtitlename in('店长','验光师')\n" + + " and h.status in(0,1,2,3,4)\n" + + " union \n" + + " select h.id \n" + + " from hrmresource h \n" + + " inner join cus_fielddata k on k.id = h.id\n" + + " where k.field39 = 2 \n" + + " and k.scopeid=3 \n" + + " and k.scope='HrmCustomFieldByInfoType' " + + " and h.id in("+yxrys+") and h.status in(0,1,2,3,4) " + + " union " + + " select h.id\n" + + " from hrmresource h \n" + + " inner join cus_fielddata k on k.id = h.id \n" + + " where k.scopeid=-1 " + + " and k.scope='HrmCustomFieldByInfoType'\n" + + " and substring(k.field1,charindex('_',k.field1)+1,len(k.field1)) in(select id from uf_gwjbsjb where jbmc in('配镜一级','配镜二级','配镜三级','配镜四级','配镜五级')) and charindex('_', k.field1) > 0 \n" + + " and h.status in(0,1,2,3,4) "+ + " and h.id in("+yxrys+") "; + + rs.executeQuery(sql); + while (rs.next()){ + String id = Util.null2String(rs.getString("id")); + userList.add(id); + } + + for(int i = 0;i sqlMap = sqlList.get(i); + String pbry = sqlMap.get("resourceid"); + String serialid = sqlMap.get("serialid"); + String startTime = ""; + String endTime = ""; + + sql = " select times,onoffworktype from kq_ShiftOnOffWorkSections where serialid = ? and (isdelete = 0 or isdelete is null) "; + rs.executeQuery(sql,new Object[]{serialid}); + while(rs.next()){ + String onoffworktype = Util.null2String(rs.getString("onoffworktype")); + if("start".equals(onoffworktype)){ + startTime = Util.null2String(rs.getString("times")); + }else if("end".equals(onoffworktype)){ + endTime = Util.null2String(rs.getString("times")); + } + } + + Map userSchedule_Map = new HashMap(); + if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){ + userSchedule_Map.put("startTime",startTime); + userSchedule_Map.put("endTime",endTime); + + for(int k=0;k workSchedule_Map = workScheduleList.get(k); + String scheduleStartTime = workSchedule_Map.get("start"); + String scheduleEndTime = workSchedule_Map.get("end"); + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + if(startTime.compareTo(scheduleStartTime) <=0 && endTime.compareTo(scheduleEndTime) >=0){ + + String defWorkSchedule = scheduleStartTime+"-"+scheduleEndTime ; + if(userScheduleMap.containsKey(defWorkSchedule)){ + int count = userScheduleMap.get(defWorkSchedule); + count++; + userScheduleMap.put(defWorkSchedule,count); + }else{ + userScheduleMap.put(defWorkSchedule,1); + } + + if(userList.contains(pbry)){ + necessaryMap.put(defWorkSchedule,1); + } + } + } + } + } + userScheduleDayMap.put(pbry,userSchedule_Map); + } + } + + int defaultcount = 0; + int datacount = 0; + Iterator> iterator = defaultScheduleMap.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); + int value =entry.getValue(); + String key = entry.getKey(); + if(userScheduleMap.containsKey(key)){ + int useValue = userScheduleMap.get(key); + if(useValue < value){ + datacount++; + } + }else{ + datacount++; + } + defaultcount++; + } + + + String xh = ""; + if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){ + xh = kqdate.substring(8); + if(StringUtils.isNotBlank(xh)){ + if(xh.startsWith("0")){ + xh = xh.substring(1); + } + } + } + Map resultMap = new HashMap<>(); + String status = ""; + if(defaultcount >0 && datacount == 0){ + if(necessaryMap.size() == 4){ + status = "0"; + }else{ + status = "1"; + } + } + resultMap.put("kqdate",kqdate); + resultMap.put("status",status); + resultMap.put("xh",xh); + + return resultMap; + } + +%> + + diff --git a/浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayDataByMonth2bak.jsp b/浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayDataByMonth2bak.jsp new file mode 100644 index 0000000..e6f09cb --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayDataByMonth2bak.jsp @@ -0,0 +1,849 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="weaver.common.DateUtil" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupBiz" %> +<%@ page import="java.time.LocalDate" %> +<%@ page import="java.time.format.DateTimeFormatter" %> +<%@ page import="java.time.DayOfWeek" %> +<%@ page import="java.time.temporal.TemporalAdjusters" %> +<%@ page import="java.util.*" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + + String[] workSchedule = {"09:00-11:00","11:00-16:00","16:00-20:00","20:00-21:30"}; + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } +// int userid = user.getUID(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + String cjr = request.getParameter("cjr"); + String pbyf = request.getParameter("pbyf"); + String yjl = request.getParameter("yjl"); //mdyj + String cjrbm = request.getParameter("cjrbm"); + + + String activeGroupId = getUserActiveGroupId(cjr+""); +// List> scheduleList = queryShiftScheduleByUser(pbyf,activeGroupId,cjr); +// out.println("scheduleList"+ JSON.toJSON(scheduleList)); + + List> hrmList = new ArrayList>(); + +// out.println("cjrbm:"+cjrbm+"
"); + if(StringUtils.isNotBlank(cjrbm)) { + String sql = "select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) "; + hrmList = queryListBySql(sql); + } + + int daysInMonth = 0; + Map holidayMap = new HashMap(); + List daysList = new ArrayList(); + Map weekMap = new HashMap(); + + List> weekList = new ArrayList>(); + + + if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7) { + LocalDate localDate = LocalDate.parse(pbyf + "-01"); // 获取当前日期 + LocalDate lastDayOfMonth = localDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + LocalDate firstDayOfMonth = localDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 + +// for (LocalDate date = firstDayOfMonth; !date.isAfter(lastDayOfMonth); date = date.plusDays(1)) { +// daysList.add(date.toString()); +// } + + String monthStartDate = firstDayOfMonth.toString(); + String monthEndDate = lastDayOfMonth.toString(); + holidayMap = getHolidayByGroupId(cjr, monthStartDate, monthEndDate,activeGroupId); + + daysInMonth = localDate.lengthOfMonth(); // 获取本月有多少天 + int thisMonth = localDate.getMonthValue(); // 获取当前是哪月 + + for (int i = 1; i <= daysInMonth; i++) { + LocalDate currentDate = LocalDate.of(localDate.getYear(), thisMonth, i); + + daysList.add(currentDate.toString()); + +// System.out.println("currentDate:" + currentDate.toString()); + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); +// System.out.println(i + "号是周 " + dayOfWeek.getValue()); + int weekValue = dayOfWeek.getValue(); + + String weekDayName = ""; + switch (weekValue) { + case 1: + weekDayName = "周一"; + break; + case 2: + weekDayName = "周二"; + break; + case 3: + weekDayName = "周三"; + break; + case 4: + weekDayName = "周四"; + break; + case 5: + weekDayName = "周五"; + break; + case 6: + weekDayName = "周六"; + break; + case 7: + weekDayName = "周日"; + break; + } + + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + Map weekMap2 = new HashMap(); + weekMap2.put("weekname", weekDayName); + weekMap2.put("changeType", changeType); + weekMap2.put("weekday", i+""); + weekMap2.put("weekdate", currentDate.toString()); + weekList.add(weekMap2); + + + if("1".equals(changeType) || "3".equals(changeType)){ + weekValue = 11; + } + + if(StringUtils.isNotBlank(changeType)){ + weekMap.put(currentDate.toString(), weekValue+""); + }else{ + weekMap.put(currentDate.toString(), weekValue+""); + } + } + } + + List> dt1DataList = new ArrayList>(); + for(int i=0;i hrmMap = hrmList.get(i); + String ry = hrmMap.get("id"); + String lastname = hrmMap.get("lastname"); + + Map dt1DataMap = new HashMap(); + Map ryMap = getDt1UserMap(ry,lastname); + dt1DataMap.put("ry",ryMap); + + List> scheduleList = queryShiftScheduleByUser(pbyf,activeGroupId,ry); + + dt1DataMap.put("schedule",scheduleList); + + List restList = getSchedulingRestData(); + Map countMap = queryCountWorkTime(restList,daysList,weekMap,scheduleList); + dt1DataMap.put("count",countMap); + + dt1DataList.add(dt1DataMap); + } +// out.println("dt1DataList"+ JSON.toJSON(dt1DataList)+"
"); + + + List> resultList = queryScheduleStatusByDay(daysList,holidayMap,yjl,workSchedule,hrmList,activeGroupId); + +// out.println("resultList"+ JSON.toJSON(resultList)+"
"); + + Map valueMap = getMainUserDate(hrmList); + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("data",valueMap); + jsonObject.put("dt1day",resultList); + jsonObject.put("dt1user",dt1DataList); + jsonObject.put("days",daysInMonth); + jsonObject.put("head",weekList); +%> + +<%=jsonObject.toJSONString() %> + +<%! + /*** + * + * @param hrmList + * @return + */ + public Map getMainUserDate(List> hrmList){ + String userids = ""; + List> specialobjList = new ArrayList>(); + for(int i=0;i hrmMap = hrmList.get(i); + String userid = Util.null2String(hrmMap.get("id")); + String lastname = Util.null2String(hrmMap.get("lastname")); + userids += StringUtils.isBlank(userids) ? userid : ","+userid ; + + Map specialobjMap = new HashMap(); + specialobjMap.put("id",userid); + specialobjMap.put("name",lastname); + specialobjList.add(specialobjMap); + } + + Map valueMap = new HashMap(); + valueMap.put("value",userids); + valueMap.put("specialobj",specialobjList); + return valueMap; + } + + /*** + * + * @param hrmList + * @return + */ + public List> getDt1UserDate(List> hrmList){ + List> dt1List = new ArrayList>(); + for(int i=0;i hrmMap = hrmList.get(i); + + String userid = Util.null2String(hrmMap.get("id")); + String lastname = Util.null2String(hrmMap.get("lastname")); + + Map dt1Map = new HashMap(); + dt1Map.put("id",userid); + dt1Map.put("name",lastname); + + List> specialobjList2 = new ArrayList>(); + Map specialobjMap2 = new HashMap(); + specialobjMap2.put("id",userid); + specialobjMap2.put("name",lastname); + specialobjList2.add(specialobjMap2); + + Map valueMap2 = new HashMap(); + valueMap2.put("value",userid); + valueMap2.put("specialobj",specialobjList2); + dt1Map.put("value",valueMap2); + + dt1List.add(dt1Map); + } + return dt1List; + } + + + + + + public String getWeekTypeByDate(String pbrq,String userid,String activeGroupId){ + + String dateType = "0"; + DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate currentDate = LocalDate.parse(pbrq, df); + + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); + int weekValue = dayOfWeek.getValue(); + + LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 + String monthStartDate = startDayOfMonth.toString(); + String monthEndDate = lastDayOfMonth.toString(); + + Map holidayMap = getHolidayByGroupId(monthStartDate,monthEndDate,activeGroupId); + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + + if("1".equals(changeType) || "3".equals(changeType)){ + dateType = "1"; + }else if(weekValue == 6 || weekValue == 7){ + dateType = "1"; + } + return dateType; + } + + /*** + * + * @param monthStartDate + * @param monthEndDate + * @return + */ + public Map getHolidayByGroupId(String monthStartDate,String monthEndDate,String activeGroupId){ + + Map holidayMap = new HashMap(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + + try { + if(StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){ + + String fixedScheduleGroupId = "5"; + + if(StringUtils.isNotBlank(fixedScheduleGroupId)){ + String sql =" select holidayDate,changeType from KQ_HolidaySet\n" + + " where groupid = " + fixedScheduleGroupId+ + " and holidayDate >='"+monthStartDate+"'\n" + + " and holidayDate <='"+monthEndDate+"' " ; + rs.execute(sql); + while (rs.next()){ + String holidayDate = Util.null2String(rs.getString("holidayDate")); + String changeType = Util.null2String(rs.getString("changeType")); +// String changeTypename = "" ; +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// changeTypename += "公众假日"; +// }else if("2".equals(changeType)){ +// changeTypename += "调配工作日"; +// }else if("3".equals(changeType)){ +// changeTypename += "调配休息日"; +// } + holidayMap.put(holidayDate,changeType); + +// if(weekMap.containsKey(holidayDate)){ +// String holidayDate_new = weekMap.get(holidayDate); +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// holidayDate_new += "[公众假日]"; +// }else if("1".equals(changeType)){ +// holidayDate_new += "[调配工作日]"; +// }else if("2".equals(changeType)){ +// holidayDate_new += "[调配休息日]"; +// } +// weekMap.put(holidayDate,holidayDate_new); +// } + } + } + } + }catch (Exception e){ + + } + return holidayMap; + } + + /*** + * + * @param userid + * @return + */ + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } + + + + + + + + public static List> queryListBySql(String sql){ + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + List> list = new ArrayList>(); + try{ + if(StringUtils.isNotBlank(sql)){ + Map map = new HashMap(); + rs.executeQuery(sql); + String[] column = rs.getColumnName(); + while (rs.next()){ + map = new HashMap(); + for(int i=0;i0){ + list.add(map); + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("queryListBySql-e:"+e); + } + return list; + } + + /*** + * + * @return + */ + public Map getDt1UserMap(String ry,String lastname){ + Map valueMap = new HashMap(); + if(StringUtils.isNotBlank(ry)){ + List> specialobjList = new ArrayList>(); + Map specialobjMap = new HashMap(); + specialobjMap.put("id",ry); + specialobjMap.put("name",lastname); + specialobjList.add(specialobjMap); + valueMap.put("id",ry); + valueMap.put("name",lastname); + valueMap.put("specialobj",specialobjList); + } + + return valueMap; + } + + + /*** + * + * @param pbyf + * @param groupid + * @param resourceid + * @return + */ + public List> queryShiftScheduleByUser(String pbyf,String groupid,String resourceid){ + BaseBean bb = new BaseBean(); + List> scheduleList = new ArrayList>(); + try{ + List> sqlList = new ArrayList>(); + if(StringUtils.isNotBlank(pbyf) && StringUtils.isNotBlank(resourceid)){ + String sql =" select t.serialid,k.serial,t.resourceid,t.kqdate\n" + + " from kq_shiftschedule t\n" + + " inner join kq_ShiftManagement k on k.id = t.serialid\n" + + " where left(t.kqdate,7)='"+pbyf+"' \n" + + " and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" + + " and resourceid = " + resourceid + + " order by kqdate "; + bb.writeLog("sql:"+sql); + sqlList = queryListBySql(sql); + } + + for(int i=0;i map = sqlList.get(i); + + String serialid = Util.null2String(map.get("serialid")); + String name = Util.null2String(map.get("serial")); + String kqdate = Util.null2String(map.get("kqdate")); + + String xh = ""; + if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){ + xh = kqdate.substring(8); + if(StringUtils.isNotBlank(xh)){ + if(xh.startsWith("0")){ + xh = xh.substring(1); + } + } + } + + if(StringUtils.isNotBlank(xh)){ + List> specialobjList = new ArrayList>(); + Map specialobjMap = new HashMap(); + specialobjMap.put("id",serialid); + specialobjMap.put("name",name); + specialobjList.add(specialobjMap); + + Map valueMap = new HashMap(); + valueMap.put("serialid",serialid); + valueMap.put("kqdate",kqdate); + valueMap.put("xh",xh); + + + + valueMap.put("specialobj",specialobjList); + + scheduleList.add(valueMap); + } + } + + }catch (Exception e){ + + } + return scheduleList; + } + + + public List getSchedulingRestData(){ + + List list = new ArrayList(); + RecordSet rs = new RecordSet(); + try{ + String sql =" select id " + + " from kq_ShiftManagement \n" + + " where is_rest = 1 \n" + + " and (isdelete is null or isdelete = 0) "; + + rs.executeQuery(sql); + while (rs.next()){ + String id = Util.null2String(rs.getString("id")); + list.add(id); + } + }catch (Exception e){ + + } + return list; + } + + /*** + * + * @param restList + * @param daysList + * @param weekMap + * @param serialList + */ + public Map queryCountWorkTime(List restList,List daysList,Map weekMap,List> serialList ){ + + BaseBean bb = new BaseBean(); + Map countMap = new HashMap<>(); + String worktime = "0"; + String totalworktime = "0"; + int restcount = 0; + int weekrestcount = 0; + + RecordSet rs = new RecordSet(); + try{ + String sql = ""; + for (int i = 0; i < serialList.size(); i++) { + Map serialMap = serialList.get(i); + String kqdate = Util.null2String(serialMap.get("kqdate")); + String serialid = Util.null2String(serialMap.get("serialid")); + if (daysList.contains(kqdate)) { + if (StringUtils.isNotBlank(serialid)) { + if (restList.contains(serialid)) { + restcount++; + } + + if(!restList.contains(serialid)){ + String sql2 = " select try_convert(int,worktime) as worktime from kq_ShiftManagement where id ="+serialid+" and (is_rest is null or is_rest = 0) " ; + sql += StringUtils.isBlank(sql) ? sql2 : " union all \n"+sql2 ; + } + } + + if (weekMap.containsKey(kqdate)) { + String value = weekMap.get(kqdate); + //6 = 周六 7 = 周日 11 = 公众假日、调配休息日 + if ("6".equals(value) || "7".equals(value) || "11".equals(value)) { + if (restList.contains(serialid)) { + weekrestcount++; + } + } + } + } + } + + if(StringUtils.isNotBlank(sql)){ + sql = " select round(sum(worktime)/60.0,2) as worktime,sum(worktime) as totalworktime from ("+sql+") w "; + rs.executeQuery(sql); + if(rs.next()){ + worktime = Util.null2String(rs.getString("worktime")); + totalworktime = Util.null2String(rs.getString("totalworktime")); + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("e:"+e); + } + + countMap.put("worktime",worktime); + countMap.put("totalworktime",totalworktime); + countMap.put("restcount",restcount+""); + countMap.put("weekrestcount",weekrestcount+""); + + return countMap; + } + + /*** + * + * @param daysList + * @param holidayMap + * @param yjl + * @param workSchedule + * @param hrmList + * @param groupid + * @return + */ + public List> queryScheduleStatusByDay(List daysList,Map holidayMap,String yjl,String[] workSchedule,List> hrmList,String groupid){ + + BaseBean bb = new BaseBean(); + List> resultList = new ArrayList>(); + + DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + RecordSet rs = new RecordSet(); + + try{ + List> workScheduleList = new ArrayList>(); + Map workScheduleMap = null; + for(int k=0;k0){ + String[] schedule = workSchedule[k].split("-"); + String scheduleStartTime = schedule[0]; + String scheduleEndTime = schedule[1]; + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + workScheduleMap = new HashMap(); + workScheduleMap.put("start",scheduleStartTime); + workScheduleMap.put("end",scheduleEndTime); + workScheduleList.add(workScheduleMap); + } + } + } + + String resourceids = ""; + for(int i=0;i hrmMap = hrmList.get(i); + String userid = Util.null2String(hrmMap.get("id")); + resourceids += StringUtils.isBlank(resourceids) ? userid : ","+userid ; + } + + for(String pbrq:daysList){ + String dateType = "0"; + if(StringUtils.isNotBlank(pbrq)){ + LocalDate currentDate = LocalDate.parse(pbrq, df); + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); + int weekValue = dayOfWeek.getValue(); + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + + if("1".equals(changeType) || "3".equals(changeType)){ + dateType = "1"; + }else if(weekValue == 6 || weekValue == 7){ + dateType = "1"; + } + } + + Map defaultScheduleMap = new HashMap(); + if(StringUtils.isNotBlank(yjl)){ + String sql = " select dysjd,pzrs from uf_pbjcsj where yjl = ? and pblx = ?" ; + rs.executeQuery(sql,new Object[]{yjl,dateType}); + while (rs.next()){ + int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd"))); + int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs"))); + + String sjd = ""; + if(dysd < workSchedule.length){ + sjd = workSchedule[dysd]; + if(StringUtils.isNotBlank(sjd)){ + defaultScheduleMap.put(sjd,pzrs); + } + } + } + } + + List> sqlList = new ArrayList>(); + if(StringUtils.isNotBlank(resourceids) && StringUtils.isNotBlank(pbrq)){ + + String sql =" select t.serialid,t.resourceid,t.kqdate \n" + + " from kq_shiftschedule t\n" + + " where t.kqdate='"+pbrq+"' \n" + + " and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" + + " and resourceid in( " + resourceids + ") "+ + " order by kqdate "; + sqlList = queryListBySql(sql); + } + + Map resultMap = queryScheduleStatusByUser(sqlList,workScheduleList,defaultScheduleMap,pbrq); + resultList.add(resultMap); + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("e:"+e); + } + + return resultList; + } + + /*** + * + * @param sqlList + * @param workScheduleList + * @param defaultScheduleMap + * @param kqdate + * @return + */ + public Map queryScheduleStatusByUser(List> sqlList,List> workScheduleList,Map defaultScheduleMap,String kqdate){ + + RecordSet rs = new RecordSet(); + + Map> userScheduleDayMap = new HashMap>(); + Map userScheduleMap = new HashMap(); + Map necessaryMap = new HashMap(); + String yxrys = "" ; + for(int i=0;i sqlMap = sqlList.get(i); + String resourceid = Util.null2String(sqlMap.get("resourceid")); + yxrys += StringUtils.isBlank(yxrys) ? resourceid :","+resourceid ; + } + if(StringUtils.isNotBlank(yxrys)) { + List userList = new ArrayList(); + String sql =" select h.id \n" + + " from hrmresource h \n" + + " inner join hrmjobtitles k on k.id = h.jobtitle\n" + + " where h.id in("+yxrys+")\n" + + " and k.jobtitlename in('店长','验光师')\n" + + " and h.status in(0,1,2,3,4)\n" + + " union \n" + + " select h.id \n" + + " from hrmresource h \n" + + " inner join cus_fielddata k on k.id = h.id\n" + + " where k.field39 = 2 \n" + + " and k.scopeid=3 \n" + + " and k.scope='HrmCustomFieldByInfoType' " + + " and h.id in("+yxrys+") and h.status in(0,1,2,3,4) " + + " union " + + " select h.id\n" + + " from hrmresource h \n" + + " inner join cus_fielddata k on k.id = h.id \n" + + " where k.scopeid=-1 " + + " and k.scope='HrmCustomFieldByInfoType'\n" + + " and substring(k.field1,charindex('_',k.field1)+1,len(k.field1)) in(select id from uf_gwjbsjb where jbmc in('配镜一级','配镜二级','配镜三级','配镜四级','配镜五级')) and charindex('_', k.field1) > 0 \n" + + " and h.status in(0,1,2,3,4) "+ + " and h.id in("+yxrys+") "; + + rs.executeQuery(sql); + while (rs.next()){ + String id = Util.null2String(rs.getString("id")); + userList.add(id); + } + + for(int i = 0;i sqlMap = sqlList.get(i); + String pbry = sqlMap.get("resourceid"); + String serialid = sqlMap.get("serialid"); + String startTime = ""; + String endTime = ""; + + sql = " select times,onoffworktype from kq_ShiftOnOffWorkSections where serialid = ? and (isdelete = 0 or isdelete is null) "; + rs.executeQuery(sql,new Object[]{serialid}); + while(rs.next()){ + String onoffworktype = Util.null2String(rs.getString("onoffworktype")); + if("start".equals(onoffworktype)){ + startTime = Util.null2String(rs.getString("times")); + }else if("end".equals(onoffworktype)){ + endTime = Util.null2String(rs.getString("times")); + } + } + + Map userSchedule_Map = new HashMap(); + if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){ + userSchedule_Map.put("startTime",startTime); + userSchedule_Map.put("endTime",endTime); + + for(int k=0;k workSchedule_Map = workScheduleList.get(k); + String scheduleStartTime = workSchedule_Map.get("start"); + String scheduleEndTime = workSchedule_Map.get("end"); + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + if(startTime.compareTo(scheduleStartTime) <=0 && endTime.compareTo(scheduleEndTime) >=0){ + + String defWorkSchedule = scheduleStartTime+"-"+scheduleEndTime ; + if(userScheduleMap.containsKey(defWorkSchedule)){ + int count = userScheduleMap.get(defWorkSchedule); + count++; + userScheduleMap.put(defWorkSchedule,count); + }else{ + userScheduleMap.put(defWorkSchedule,1); + } + + if(userList.contains(pbry)){ + necessaryMap.put(defWorkSchedule,1); + } + } + } + } + } + userScheduleDayMap.put(pbry,userSchedule_Map); + } + } + + int defaultcount = 0; + int datacount = 0; + Iterator> iterator = defaultScheduleMap.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); + int value =entry.getValue(); + String key = entry.getKey(); + if(userScheduleMap.containsKey(key)){ + int useValue = userScheduleMap.get(key); + if(useValue < value){ + datacount++; + } + }else{ + datacount++; + } + defaultcount++; + } + + + String xh = ""; + if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){ + xh = kqdate.substring(8); + if(StringUtils.isNotBlank(xh)){ + if(xh.startsWith("0")){ + xh = xh.substring(1); + } + } + } + Map resultMap = new HashMap<>(); + String status = ""; + if(defaultcount >0 && datacount == 0){ + if(necessaryMap.size() == 4){ + status = "0"; + }else{ + status = "1"; + } + } + resultMap.put("kqdate",kqdate); + resultMap.put("status",status); + resultMap.put("xh",xh); + + return resultMap; + } + +%> + + diff --git a/浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayDataByMonth3.jsp b/浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayDataByMonth3.jsp new file mode 100644 index 0000000..39979d6 --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/pblc/queryUserWorkdayDataByMonth3.jsp @@ -0,0 +1,599 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="weaver.common.DateUtil" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="com.alibaba.fastjson.JSONArray" %> +<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupBiz" %> +<%@ page import="java.time.LocalDate" %> +<%@ page import="java.time.format.DateTimeFormatter" %> +<%@ page import="java.time.DayOfWeek" %> +<%@ page import="java.time.temporal.TemporalAdjusters" %> +<%@ page import="java.util.*" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + + String[] workSchedule = {"09:00-11:00","11:00-16:00","16:00-20:00","20:00-21:30"}; + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } + int userid = user.getUID(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + String ry = request.getParameter("ry"); + String pbyf = request.getParameter("pbyf"); + String bp = request.getParameter("bp"); + String activeGroupId = getUserActiveGroupId(userid+""); + List> scheduleList = queryShiftScheduleByUser(pbyf,activeGroupId,ry); + + + String pbdata = request.getParameter("pbdata"); + String pbrq = request.getParameter("pbrq"); + String yjl = request.getParameter("yjl"); + + String dateType = "0"; + if(StringUtils.isNotBlank(pbrq)){ + dateType = getWeekTypeByDate(pbrq,userid+""); + } + + Map defaultScheduleMap = new HashMap(); + if(StringUtils.isNotBlank(yjl)){ + String sql = " select dysjd,pzrs from uf_pbjcsj where bp = ? and pblx = ?" ; + rs.executeQuery(sql,new Object[]{bp,dateType}); + while (rs.next()){ + int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd"))); + int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs"))); + + String sjd = ""; + if(dysd < workSchedule.length){ + sjd = workSchedule[dysd]; + if(StringUtils.isNotBlank(sjd)){ + defaultScheduleMap.put(sjd,pzrs); + } + } + } + } + + List> workScheduleList = new ArrayList>(); + Map workScheduleMap = null; + for(int k=0;k0){ + String[] schedule = workSchedule[k].split("-"); + String scheduleStartTime = schedule[0]; + String scheduleEndTime = schedule[1]; + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + workScheduleMap = new HashMap(); + workScheduleMap.put("start",""); + workScheduleMap.put("end",scheduleEndTime); + workScheduleList.add(workScheduleMap); + } + } + }else if(k==(workSchedule.length-1)){ + if(workSchedule[k].indexOf("-")>0){ + String[] schedule = workSchedule[k].split("-"); + String scheduleStartTime = schedule[0]; + String scheduleEndTime = schedule[1]; + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + workScheduleMap = new HashMap(); + workScheduleMap.put("start",scheduleStartTime); + workScheduleMap.put("end",""); + workScheduleList.add(workScheduleMap); + } + } + }else{ + if(workSchedule[k].indexOf("-")>0){ + String[] schedule = workSchedule[k].split("-"); + String scheduleStartTime = schedule[0]; + String scheduleEndTime = schedule[1]; + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + workScheduleMap = new HashMap(); + workScheduleMap.put("start",scheduleStartTime); + workScheduleMap.put("end",scheduleEndTime); + workScheduleList.add(workScheduleMap); + } + } + } + } + + Map> userScheduleDayMap = new HashMap>(); + + Map userScheduleMap = new HashMap(); + Map necessaryMap = new HashMap(); + if(StringUtils.isNotBlank(pbdata)) { + JSONArray jsonArray = JSONArray.parseArray(pbdata); + + String yxrys = "" ; + for(int i = 0;i"); + List userList = new ArrayList(); + String sql =" select h.id \n" + + " from hrmresource h \n" + + " inner join hrmjobtitles k on k.id = h.jobtitle\n" + + " where h.id in("+yxrys+")\n" + + " and k.jobtitlename in('店长','验光师')\n" + + " and h.status in(0,1,2,3,4)\n" + + " union \n" + + " select h.id \n" + + " from hrmresource h \n" + + " inner join cus_fielddata k on k.id = h.id\n" + + " where k.field39 = 2 \n" + + " and k.scopeid=3 \n" + + " and k.scope='HrmCustomFieldByInfoType' " + + " and h.id in("+yxrys+") and h.status in(0,1,2,3,4) " + + " union " + + " select h.id\n" + + " from hrmresource h \n" + + " inner join cus_fielddata k on k.id = h.id \n" + + " where k.scopeid=-1 " + + " and k.scope='HrmCustomFieldByInfoType'\n" + + " and substring(k.field1,charindex('_',k.field1)+1,len(k.field1)) in(select id from uf_gwjbsjb where jbmc in('配镜一级','配镜二级','配镜三级','配镜四级','配镜五级')) and charindex('_', k.field1) > 0 \n" + + " and h.status in(0,1,2,3,4) "+ + " and h.id in("+yxrys+") "; + + out.println("sql:"+sql+"
"); + rs.executeQuery(sql); + while (rs.next()){ + String id = Util.null2String(rs.getString("id")); + out.println("id:"+id+"
"); + userList.add(id); + } + + for(int i = 0;i userSchedule_Map = new HashMap(); + if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){ + userSchedule_Map.put("startTime",startTime); + userSchedule_Map.put("endTime",endTime); + + + for(int k=0;k workSchedule_Map = workScheduleList.get(k); + String scheduleStartTime = workSchedule_Map.get("start"); + String scheduleEndTime = workSchedule_Map.get("end"); + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + if(startTime.compareTo(scheduleStartTime) <=0 && endTime.compareTo(scheduleEndTime) >=0){ + + String defWorkSchedule = scheduleStartTime+"-"+scheduleEndTime ; + if(userScheduleMap.containsKey(defWorkSchedule)){ + int count = userScheduleMap.get(defWorkSchedule); + count++; + userScheduleMap.put(defWorkSchedule,count); + }else{ + userScheduleMap.put(defWorkSchedule,1); + } + + if(userList.contains(pbry)){ + necessaryMap.put(defWorkSchedule,1); + } + } + }else{ + if(StringUtils.isNotBlank(scheduleStartTime)){ + + if(endTime.compareTo(scheduleStartTime) >=0 ){ + String define_scheduleEndTime = "21:30"; + String defWorkSchedule = scheduleStartTime+"-"+define_scheduleEndTime ; + if(userScheduleMap.containsKey(defWorkSchedule)){ + int count = userScheduleMap.get(defWorkSchedule); + count++; + userScheduleMap.put(defWorkSchedule,count); + }else{ + userScheduleMap.put(defWorkSchedule,1); + } + + if(userList.contains(pbry)){ + necessaryMap.put(defWorkSchedule,1); + } + } + }else if(StringUtils.isNotBlank(scheduleEndTime)){ + + if(startTime.compareTo(scheduleEndTime) <=0){ + String define_scheduleStartTime = "09:00"; + String defWorkSchedule = define_scheduleStartTime+"-"+scheduleEndTime ; + if(userScheduleMap.containsKey(defWorkSchedule)){ + int count = userScheduleMap.get(defWorkSchedule); + count++; + userScheduleMap.put(defWorkSchedule,count); + }else{ + userScheduleMap.put(defWorkSchedule,1); + } + + if(userList.contains(pbry)){ + necessaryMap.put(defWorkSchedule,1); + } + } + + } + } + } + } + userScheduleDayMap.put(pbry,userSchedule_Map); + } + } + + int defaultcount = 0; + int datacount = 0; + Iterator> iterator = defaultScheduleMap.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); + int value =entry.getValue(); + String key = entry.getKey(); + if(userScheduleMap.containsKey(key)){ + int useValue = userScheduleMap.get(key); + if(useValue < value){ + datacount++; + } + }else{ + datacount++; + } + defaultcount++; + } + + out.println("necessaryMap:"+necessaryMap.size()); + + JSONObject jsonObject = new JSONObject(); + if(defaultcount >0 && datacount == 0){ + if(necessaryMap.size() == 4){ + jsonObject.put("pbcode","1"); + }else{ + jsonObject.put("pbcode","2"); + } + }else{ + jsonObject.put("pbcode","0"); + } + + jsonObject.put("pbinfo",userScheduleDayMap); +%> + +<%=jsonObject.toJSONString() %> + +<%! + /*** + * + * @param hrmList + * @return + */ + public Map getMainUserDate(List> hrmList){ + String userids = ""; + List> specialobjList = new ArrayList>(); + for(int i=0;i hrmMap = hrmList.get(i); + String userid = Util.null2String(hrmMap.get("id")); + String lastname = Util.null2String(hrmMap.get("lastname")); + userids += StringUtils.isBlank(userids) ? userid : ","+userid ; + + Map specialobjMap = new HashMap(); + specialobjMap.put("id",userid); + specialobjMap.put("name",lastname); + specialobjList.add(specialobjMap); + } + + Map valueMap = new HashMap(); + valueMap.put("value",userids); + valueMap.put("specialobj",specialobjList); + return valueMap; + } + + /*** + * + * @param hrmList + * @return + */ + public List> getDt1UserDate(List> hrmList){ + List> dt1List = new ArrayList>(); + for(int i=0;i hrmMap = hrmList.get(i); + + String userid = Util.null2String(hrmMap.get("id")); + String lastname = Util.null2String(hrmMap.get("lastname")); + + Map dt1Map = new HashMap(); + dt1Map.put("id",userid); + dt1Map.put("name",lastname); + + List> specialobjList2 = new ArrayList>(); + Map specialobjMap2 = new HashMap(); + specialobjMap2.put("id",userid); + specialobjMap2.put("name",lastname); + specialobjList2.add(specialobjMap2); + + Map valueMap2 = new HashMap(); + valueMap2.put("value",userid); + valueMap2.put("specialobj",specialobjList2); + dt1Map.put("value",valueMap2); + dt1List.add(dt1Map); + } + return dt1List; + } + + + + + + public String getWeekTypeByDate(String pbrq,String userid){ + + String dateType = "0"; + DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate currentDate = LocalDate.parse(pbrq, df); + + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); + int weekValue = dayOfWeek.getValue(); + + LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 + String monthStartDate = startDayOfMonth.toString(); + String monthEndDate = lastDayOfMonth.toString(); + Map holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate); + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + + if("1".equals(changeType) || "3".equals(changeType)){ + dateType = "1"; + }else if(weekValue == 6 || weekValue == 7){ + dateType = "1"; + } + return dateType; + } + + /*** + * + * @param userid + * @param monthStartDate + * @param monthEndDate + * @return + */ + public Map getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate){ + + Map holidayMap = new HashMap(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + + try { + if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){ +// String activeGroupId = getUserActiveGroupId(userid); +// bb.writeLog("activeGroupId:"+activeGroupId); + + String fixedScheduleGroupId = "5"; + + if(StringUtils.isNotBlank(fixedScheduleGroupId)){ + String sql =" select holidayDate,changeType from KQ_HolidaySet\n" + + " where groupid = " + fixedScheduleGroupId+ + " and holidayDate >='"+monthStartDate+"'\n" + + " and holidayDate <='"+monthEndDate+"' " ; + rs.execute(sql); + while (rs.next()){ + String holidayDate = Util.null2String(rs.getString("holidayDate")); + String changeType = Util.null2String(rs.getString("changeType")); +// String changeTypename = "" ; +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// changeTypename += "公众假日"; +// }else if("2".equals(changeType)){ +// changeTypename += "调配工作日"; +// }else if("3".equals(changeType)){ +// changeTypename += "调配休息日"; +// } + holidayMap.put(holidayDate,changeType); + +// if(weekMap.containsKey(holidayDate)){ +// String holidayDate_new = weekMap.get(holidayDate); +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// holidayDate_new += "[公众假日]"; +// }else if("1".equals(changeType)){ +// holidayDate_new += "[调配工作日]"; +// }else if("2".equals(changeType)){ +// holidayDate_new += "[调配休息日]"; +// } +// weekMap.put(holidayDate,holidayDate_new); +// } + } + } + } + }catch (Exception e){ + + } + return holidayMap; + } + + /*** + * + * @param userid + * @return + */ + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } + + + /*** + * + * @param pbyf + * @param groupid + * @param resourceid + * @return + */ + public List> queryShiftScheduleByUser(String pbyf,String groupid,String resourceid){ + BaseBean bb = new BaseBean(); + List> list = new ArrayList>(); + try{ + if(StringUtils.isNotBlank(pbyf) && StringUtils.isNotBlank(resourceid)){ + String sql =" select t.serialid,k.serial,t.resourceid,t.kqdate\n" + + " from kq_shiftschedule t\n" + + " inner join kq_ShiftManagement k on k.id = t.serialid\n" + + " where left(t.kqdate,7)='"+pbyf+"' \n" + + " and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" + + " and resourceid = " + resourceid + + " order by kqdate "; + + bb.writeLog("sql:"+sql); + list = queryListBySql(sql); + } + + List> scheduleList = new ArrayList>(); + for(int i=0;i map = list.get(i); + + String id = Util.null2String(map.get("serialid")); + String name = Util.null2String(map.get("serial")); + String kqdate = Util.null2String(map.get("kqdate")); + + String xh = ""; + if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){ + xh = kqdate.substring(8); + if(StringUtils.isNotBlank(xh)){ + if(xh.startsWith("0")){ + xh = xh.substring(1); + } + } + } + + if(StringUtils.isNotBlank(xh)){ + + } + + + Map scheduleMap = new HashMap(); + scheduleMap.put("kqdate",kqdate); + scheduleMap.put("kqdate",kqdate); + + List> specialobjList = new ArrayList>(); + Map specialobjMap = new HashMap(); + specialobjMap.put("id",id); + specialobjMap.put("name",name); + specialobjList.add(specialobjMap); + + Map valueMap2 = new HashMap(); + valueMap2.put("value",id); + valueMap2.put("specialobj",specialobjList); + scheduleMap.put("value",valueMap2); + scheduleList.add(scheduleMap); + } + + }catch (Exception e){ + + } + return list; + } + + + + + public static List> queryListBySql(String sql){ + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + List> list = new ArrayList>(); + try{ + if(StringUtils.isNotBlank(sql)){ + Map map = new HashMap(); + rs.executeQuery(sql); + String[] column = rs.getColumnName(); + while (rs.next()){ + map = new HashMap(); + for(int i=0;i0){ + list.add(map); + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("queryListBySql-e:"+e); + } + return list; + } + +%> + + diff --git a/浙文眼镜/interface/zw/workflow/pblc/testrs.jsp b/浙文眼镜/interface/zw/workflow/pblc/testrs.jsp new file mode 100644 index 0000000..b3de4dc --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/pblc/testrs.jsp @@ -0,0 +1,309 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="com.alibaba.fastjson.JSONArray" %> +<%@ page import="java.util.Map" %> +<%@ page import="java.util.List" %> +<%@ page import="java.util.ArrayList" %> +<%@ page import="java.time.LocalDate" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="java.util.HashMap" %> +<%@ page import="weaver.hrm.resource.ResourceComInfo" %> +<%@ page import="com.engine.kq.service.KQShiftScheduleService" %> +<%@ page import="com.engine.common.util.ServiceUtil" %> +<%@ page import="com.engine.kq.service.impl.KQShiftScheduleServiceImpl" %> +<%@ page import="com.engine.common.util.ParamUtil" %> +<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupBiz" %> +<%@ page import="weaver.common.DateUtil" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + ResourceComInfo resourceComInfo = new ResourceComInfo(); + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } + out.println("333333
"); + + String requestid = request.getParameter("requestid"); + out.println("requestid:"+requestid+"
"); + String workflowid = request.getParameter("workflowid"); + out.println("workflowid:"+workflowid+"
"); + String billtable = getFormtableByRequestId(requestid); + + out.println("billtable:"+billtable+"
"); + + RecordSet rs = new RecordSet(); + String mainid = ""; + String cjr = ""; + String pbyf = ""; + String cjrbm = ""; + String sql = " select id,cjr,pbyf,cjrbm from " + billtable + " where requestid=" + requestid; + out.println("sql:"+sql+"
"); + rs.execute(sql); + if (rs.next()) { + mainid = Util.null2String(rs.getString("id")); + cjr = Util.null2String(rs.getString("cjr")); + pbyf = Util.null2String(rs.getString("pbyf")); + cjrbm = Util.null2String(rs.getString("cjrbm")); + } + out.println("mainid:"+mainid+"
"); + out.println("pbyf:"+pbyf+"
"); + out.println("cjrbm:"+cjrbm+"
"); + + sql = " select t.requestid,r.currentnodetype,r.requestname " + + " from " + billtable + " t " + + " inner join workflow_requestbase r on r.requestid = t.requestid " + + " where t.pbyf ='" + pbyf + "' " + + " and t.cjrbm ='" + cjrbm + "' " + + " and r.currentnodetype in(1,2,3) " + + " and r.workflowid = " + workflowid + + " and t.requestid <> " + requestid; + + out.println("sql:"+sql+"
"); + + List> requestList = queryListBySql(sql); + out.println("requestList:"+requestList.size()+"
"); + if (!requestList.isEmpty() && requestList.size() > 0) { + Map requestMap = requestList.get(0); + String requestname = requestMap.get("requestname"); + String currentnodetype = requestMap.get("currentnodetype"); + String requesttypename = ""; + if ("1".equals(currentnodetype) || "2".equals(currentnodetype)) { + requesttypename = "正在审批"; + } else if ("3".equals(currentnodetype)) { + requesttypename = "已归档"; + } + out.println("已存在" + requesttypename + "流程:" + requestname + ""); + } else { + List> scheduleList = new ArrayList>(); + String userids = ""; + sql = " select yg from " + billtable + "_dt1 where mainid=" + mainid; + out.println("sql:"+sql+"
"); + + List> dt1List2 = queryListBySql(sql); + for (int i = 0; i < dt1List2.size(); i++) { + Map dt1Map = dt1List2.get(i); + String resourceid = Util.null2String(dt1Map.get("yg")); + userids += StringUtils.isBlank(userids) ? resourceid : "," + resourceid; + } + if (StringUtils.isNotBlank(userids)) { + sql = " select kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '" + pbyf + "' and resourceid in(" + userids + ") and (isdelete is null or isdelete = 0)"; + out.println("sql:"+sql+"
"); + scheduleList = queryListBySql(sql); + } + if (!scheduleList.isEmpty() && scheduleList.size() > 0) { + String lastnames = ""; + for(int i=0;i scheduleMap = scheduleList.get(i); + if(i<2){ + String resourceid = scheduleMap.get("resourceid"); + if(StringUtils.isNotBlank(resourceid)){ + String lastname = resourceComInfo.getLastname(resourceid); + lastnames += StringUtils.isBlank(lastnames) ? lastname : ","+lastname; + } + } + } + out.println(lastnames+"等已存在"+pbyf+"的排班数据,无法新增排班"); + } else { + int daysInMonth = 0; + if (StringUtils.isNotBlank(pbyf) && pbyf.length() == 7) { + LocalDate date = LocalDate.parse(pbyf + "-01"); // 获取当前日期 +// LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 +// LocalDate startDayOfMonth = date.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 +// String monthStartDate = startDayOfMonth.toString(); +// String monthEndDate = lastDayOfMonth.toString(); + daysInMonth = date.lengthOfMonth(); // 获取本月有多少天 + } + + if (StringUtils.isNotBlank(mainid)) { + + String groupid = getUserActiveGroupId(user.getUID()+""); + JSONObject datasJSON = new JSONObject(); + JSONArray datasArray = new JSONArray(); + sql = " select * from " + billtable + "_dt1 where mainid=" + mainid; + List> dt1List = queryListBySql(sql); + for (int i = 0; i < dt1List.size(); i++) { + Map dt1Map = dt1List.get(i); + String resourceid = Util.null2String(dt1Map.get("yg")); + if(StringUtils.isNotBlank(resourceid)){ + + JSONArray kqdata = new JSONArray(); + JSONObject userJSON = new JSONObject(); + userJSON.put("id",""); + String loginid = resourceComInfo.getLoginID(resourceid); + userJSON.put("serialid",loginid); + userJSON.put("oldValue",loginid); + userJSON.put("date","workcode"); + kqdata.add(userJSON); + for (int k = 1; k <= daysInMonth; k++) { + String bc = Util.null2String(dt1Map.get("bc" + k)); + if(StringUtils.isNotBlank(bc)){ + JSONObject bcJSON = new JSONObject(); + bcJSON.put("id", ""); + bcJSON.put("serialid", bc); + if (k < 10) { + bcJSON.put("date", pbyf + "-0" + k); + } else { + bcJSON.put("date", pbyf + "-" + k); + } + kqdata.add(bcJSON); + } + } + JSONObject dataJSON = new JSONObject(); + dataJSON.put("resourceid", resourceid); + dataJSON.put("kqdata", kqdata); + datasArray.add(dataJSON); + } + } + datasJSON.put("datas", datasArray); + datasJSON.put("groupId", groupid); + out.println("datasJSON:" + datasJSON.toJSONString() + "
"); + + Map params = new HashMap(); + params.put("data",datasJSON.toJSONString()); + Map apidatas = getService(user).save(params, user); + + out.println("apidatas:" + JSONObject.toJSONString(apidatas)+ "
"); + } + } + } + +%> + +<%! + /** + * + * @param requestid + * @return + */ + public String getFormtableByRequestId(String requestid){ + String formtable = "" ; + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + try{ + if(StringUtils.isNotBlank(requestid)){ + String sql =" select abs(formid) as formid from workflow_base t \n" + + " inner join workflow_requestbase h on h.workflowid = t.id \n" + + " where h.requestid= "+requestid ; + bb.writeLog("sql2:"+sql); + rs.executeQuery(sql); + if(rs.next()){ + String formid = Util.null2String(rs.getString("formid")); + if(StringUtils.isNotBlank(formid)){ + formtable = "formtable_main_"+formid ; + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("getFormtableByRequestId:"+e); + } + return formtable; + } + + + public static List> queryListBySql(String sql){ + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + List> list = new ArrayList>(); + try{ + if(StringUtils.isNotBlank(sql)){ + Map map = new HashMap(); + rs.executeQuery(sql); + String[] column = rs.getColumnName(); + while (rs.next()){ + map = new HashMap(); + for(int i=0;i0){ + list.add(map); + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("queryListBySql-e:"+e); + } + return list; + } +%> + +<%! + + private KQShiftScheduleService getService(User user) { + return (KQShiftScheduleService) ServiceUtil.getService(KQShiftScheduleServiceImpl.class, user); + } + + + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } + +%> \ No newline at end of file diff --git a/浙文眼镜/interface/zw/workflow/pblc/testrs3.jsp b/浙文眼镜/interface/zw/workflow/pblc/testrs3.jsp new file mode 100644 index 0000000..5cd875d --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/pblc/testrs3.jsp @@ -0,0 +1,69 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="java.util.Map" %> +<%@ page import="java.util.HashMap" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="weaver.systeminfo.SystemEnv" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } + Map map = new HashMap(); + if (!HrmUserVarify.checkUserRight("HrmKQGroup:Add", user)) { + map.put("status", "-1"); + map.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage())); + }else{ + map.put("status", "1"); + map.put("message", "22222"); + } + + out.println("list:"+JSONObject.toJSONString(map)); +%> + + +<%! + + /** + * + * @param requestid + * @return + */ + public static String getFormtableByRequestId(String requestid){ + String formtable = "" ; + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + try{ + if(StringUtils.isNotBlank(requestid)){ + String sql =" select abs(formid) from workflow_base t \n" + + " inner join workflow_requestbase h on h.workflowid = t.id \n" + + " where requestid= "+requestid ; + bb.writeLog("sql2:"+sql); + rs.executeQuery(sql); + if(rs.next()){ + String formid = Util.null2String(rs.getString("formid")); + if(StringUtils.isNotBlank(formid)){ + formtable = "formtable_main_"+formid ; + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("getFormtableByRequestId:"+e); + } + + return formtable; + } + +%> + + + + diff --git a/浙文眼镜/interface/zw/workflow/tblc/queryUserSerialByMonth.jsp b/浙文眼镜/interface/zw/workflow/tblc/queryUserSerialByMonth.jsp new file mode 100644 index 0000000..b3ca898 --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/tblc/queryUserSerialByMonth.jsp @@ -0,0 +1,840 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="weaver.common.DateUtil" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupBiz" %> +<%@ page import="java.time.LocalDate" %> +<%@ page import="java.time.format.DateTimeFormatter" %> +<%@ page import="java.time.DayOfWeek" %> +<%@ page import="java.time.temporal.TemporalAdjusters" %> +<%@ page import="java.util.*" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + String yg = request.getParameter("yg"); + String pbyf = request.getParameter("pbyf"); + String cjrbm = request.getParameter("cjrbm"); + + List> hrmList = new ArrayList>(); + if(StringUtils.isNotBlank(cjrbm)) { + String sql =" select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) and id not in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"')"+ + " union "+ + " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydhbm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) "+ + " union "+ + " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydsxrq >='"+pbyf+"-02' and bm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) " ; + + hrmList = queryListBySql(sql); + } + String userid = "" ; + if(hrmList !=null && hrmList.size() > 0){ + userid = hrmList.get(0).get("id"); + } + + String activeGroupId = getUserActiveGroupId(userid); + + List> scheduleList = new ArrayList>(); + if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7) { + LocalDate localDate = LocalDate.parse(pbyf + "-01"); // 获取当前日期 + LocalDate lastDayOfMonth = localDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + LocalDate firstDayOfMonth = localDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 + String monthStartDate = firstDayOfMonth.toString(); + String monthEndDate = lastDayOfMonth.toString(); + + String startDate = monthStartDate; + String endDate = monthEndDate ; + + String sql =" select convert(varchar,dateadd(day,-1,ydsxrq), 23) as ydsxrq " + + " from uf_ygddxx " + + " where left(ydsxrq,7) = '"+pbyf+"' "+ + " and xm = "+ yg + + " and bm= "+ cjrbm+ + " and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) "; + rs.executeQuery(sql); + if(rs.next()){ + String ydsxrq = Util.null2String(rs.getString("ydsxrq")); + if(StringUtils.isNotBlank(ydsxrq)){ + endDate = ydsxrq; + } + } + + sql =" select ydsxrq " + + " from uf_ygddxx " + + " where left(ydsxrq,7) = '"+pbyf+"' "+ + " and xm ="+ yg + + " and ydhbm="+cjrbm+ + " and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) "; + rs.executeQuery(sql); + if(rs.next()){ + String ydsxrq = Util.null2String(rs.getString("ydsxrq")); + if(StringUtils.isNotBlank(ydsxrq)){ + startDate = ydsxrq; + } + } + + sql =" select t.serialid,k.serial,t.resourceid,t.kqdate\n" + + " from kq_shiftschedule t\n" + + " inner join kq_ShiftManagement k on k.id = t.serialid\n" + + " where left(t.kqdate,7)='"+pbyf+"' \n" + + " and t.kqdate >='"+startDate+"' " + + " and t.kqdate <= '"+endDate+"'" + + " and t.groupid="+activeGroupId+" and (t.isDelete is null or t.isDelete = 0)\n" + + " and resourceid = " + yg + + " order by kqdate "; + + bb.writeLog("sql:"+sql); + List> sqlList = queryListBySql(sql); + + for(int i=0;i map = sqlList.get(i); + + String serialid = Util.null2String(map.get("serialid")); + String name = Util.null2String(map.get("serial")); + String kqdate = Util.null2String(map.get("kqdate")); + + String xh = ""; + if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){ + xh = kqdate.substring(8); + if(StringUtils.isNotBlank(xh)){ + if(xh.startsWith("0")){ + xh = xh.substring(1); + } + } + } + + if(StringUtils.isNotBlank(xh)){ + List> specialobjList = new ArrayList>(); + Map specialobjMap = new HashMap(); + specialobjMap.put("id",serialid); + specialobjMap.put("name",name); + specialobjList.add(specialobjMap); + + Map valueMap = new HashMap(); + valueMap.put("serialid",serialid); + valueMap.put("kqdate",kqdate); + valueMap.put("xh",xh); + valueMap.put("specialobj",specialobjList); + scheduleList.add(valueMap); + } + } + } + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("schedule",scheduleList); +%> + +<%=jsonObject.toJSONString() %> + +<%! + /*** + * + * @param hrmList + * @return + */ + public Map getMainUserDate(List> hrmList){ + String userids = ""; + List> specialobjList = new ArrayList>(); + for(int i=0;i hrmMap = hrmList.get(i); + String userid = Util.null2String(hrmMap.get("id")); + String lastname = Util.null2String(hrmMap.get("lastname")); + userids += StringUtils.isBlank(userids) ? userid : ","+userid ; + + Map specialobjMap = new HashMap(); + specialobjMap.put("id",userid); + specialobjMap.put("name",lastname); + specialobjList.add(specialobjMap); + } + + Map valueMap = new HashMap(); + valueMap.put("value",userids); + valueMap.put("specialobj",specialobjList); + return valueMap; + } + + /*** + * + * @param hrmList + * @return + */ + public List> getDt1UserDate(List> hrmList){ + List> dt1List = new ArrayList>(); + for(int i=0;i hrmMap = hrmList.get(i); + + String userid = Util.null2String(hrmMap.get("id")); + String lastname = Util.null2String(hrmMap.get("lastname")); + + Map dt1Map = new HashMap(); + dt1Map.put("id",userid); + dt1Map.put("name",lastname); + + List> specialobjList2 = new ArrayList>(); + Map specialobjMap2 = new HashMap(); + specialobjMap2.put("id",userid); + specialobjMap2.put("name",lastname); + specialobjList2.add(specialobjMap2); + + Map valueMap2 = new HashMap(); + valueMap2.put("value",userid); + valueMap2.put("specialobj",specialobjList2); + dt1Map.put("value",valueMap2); + + dt1List.add(dt1Map); + } + return dt1List; + } + + + + + + public String getWeekTypeByDate(String pbrq,String userid,String activeGroupId){ + + String dateType = "0"; + DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate currentDate = LocalDate.parse(pbrq, df); + + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); + int weekValue = dayOfWeek.getValue(); + + LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 + String monthStartDate = startDayOfMonth.toString(); + String monthEndDate = lastDayOfMonth.toString(); + Map holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate,activeGroupId); + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + + if("1".equals(changeType) || "3".equals(changeType)){ + dateType = "1"; + }else if(weekValue == 6 || weekValue == 7){ + dateType = "1"; + } + return dateType; + } + + /*** + * + * @param userid + * @param monthStartDate + * @param monthEndDate + * @return + */ + public Map getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate,String activeGroupId){ + + Map holidayMap = new HashMap(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + + try { + if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){ + if(StringUtils.isNotBlank(activeGroupId)){ + String sql =" select holidayDate,changeType from KQ_HolidaySet\n" + + " where groupid = " + activeGroupId+ + " and holidayDate >='"+monthStartDate+"'\n" + + " and holidayDate <='"+monthEndDate+"' " ; + rs.execute(sql); + while (rs.next()){ + String holidayDate = Util.null2String(rs.getString("holidayDate")); + String changeType = Util.null2String(rs.getString("changeType")); +// String changeTypename = "" ; +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// changeTypename += "公众假日"; +// }else if("2".equals(changeType)){ +// changeTypename += "调配工作日"; +// }else if("3".equals(changeType)){ +// changeTypename += "调配休息日"; +// } + holidayMap.put(holidayDate,changeType); + +// if(weekMap.containsKey(holidayDate)){ +// String holidayDate_new = weekMap.get(holidayDate); +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// holidayDate_new += "[公众假日]"; +// }else if("1".equals(changeType)){ +// holidayDate_new += "[调配工作日]"; +// }else if("2".equals(changeType)){ +// holidayDate_new += "[调配休息日]"; +// } +// weekMap.put(holidayDate,holidayDate_new); +// } + } + } + } + }catch (Exception e){ + + } + return holidayMap; + } + + /*** + * + * @param userid + * @return + */ + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } + + + + + + + + public static List> queryListBySql(String sql){ + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + List> list = new ArrayList>(); + try{ + if(StringUtils.isNotBlank(sql)){ + Map map = new HashMap(); + rs.executeQuery(sql); + String[] column = rs.getColumnName(); + while (rs.next()){ + map = new HashMap(); + for(int i=0;i0){ + list.add(map); + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("queryListBySql-e:"+e); + } + return list; + } + + /*** + * + * @return + */ + public Map getDt1UserMap(String ry,String lastname){ + Map valueMap = new HashMap(); + if(StringUtils.isNotBlank(ry)){ + List> specialobjList = new ArrayList>(); + Map specialobjMap = new HashMap(); + specialobjMap.put("id",ry); + specialobjMap.put("name",lastname); + specialobjList.add(specialobjMap); + valueMap.put("id",ry); + valueMap.put("name",lastname); + valueMap.put("specialobj",specialobjList); + } + + return valueMap; + } + + + /*** + * + * @param pbyf + * @param groupid + * @param resourceid + * @return + */ + public List> queryShiftScheduleByUser(String pbyf,String groupid,String resourceid,Map dateEffectiveMap){ + BaseBean bb = new BaseBean(); + List> scheduleList = new ArrayList>(); + try{ + List> sqlList = new ArrayList>(); + if(StringUtils.isNotBlank(pbyf) && StringUtils.isNotBlank(resourceid)){ + String startDate = "" ; + String endDate = ""; + if(dateEffectiveMap.containsKey(resourceid)){ + String effectiveDate = dateEffectiveMap.get(resourceid); + if(effectiveDate.contains(";")){ + String[] effective_Date = effectiveDate.split(";"); + startDate = effective_Date[0]; + endDate = effective_Date[1]; + } + } + + String sql =" select t.serialid,k.serial,t.resourceid,t.kqdate\n" + + " from kq_shiftschedule t\n" + + " inner join kq_ShiftManagement k on k.id = t.serialid\n" + + " where left(t.kqdate,7)='"+pbyf+"' \n" + + " and t.kqdate >='"+startDate+"' " + + " and t.kqdate <= '"+endDate+"'" + + " and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" + + " and resourceid = " + resourceid + + " order by kqdate "; + bb.writeLog("sql:"+sql); + sqlList = queryListBySql(sql); + } + + for(int i=0;i map = sqlList.get(i); + + String serialid = Util.null2String(map.get("serialid")); + String name = Util.null2String(map.get("serial")); + String kqdate = Util.null2String(map.get("kqdate")); + + String xh = ""; + if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){ + xh = kqdate.substring(8); + if(StringUtils.isNotBlank(xh)){ + if(xh.startsWith("0")){ + xh = xh.substring(1); + } + } + } + + if(StringUtils.isNotBlank(xh)){ + List> specialobjList = new ArrayList>(); + Map specialobjMap = new HashMap(); + specialobjMap.put("id",serialid); + specialobjMap.put("name",name); + specialobjList.add(specialobjMap); + + Map valueMap = new HashMap(); + valueMap.put("serialid",serialid); + valueMap.put("kqdate",kqdate); + valueMap.put("xh",xh); + + + + valueMap.put("specialobj",specialobjList); + + scheduleList.add(valueMap); + } + } + + }catch (Exception e){ + + } + return scheduleList; + } + + + public List getSchedulingRestData(){ + + List list = new ArrayList(); + RecordSet rs = new RecordSet(); + try{ + String sql =" select id " + + " from kq_ShiftManagement \n" + + " where is_rest = 1 \n" + + " and (isdelete is null or isdelete = 0) "; + + rs.executeQuery(sql); + while (rs.next()){ + String id = Util.null2String(rs.getString("id")); + list.add(id); + } + }catch (Exception e){ + + } + return list; + } + + /*** + * + * @param restList + * @param daysList + * @param weekMap + * @param serialList + */ + public Map queryCountWorkTime(List restList,List daysList,Map weekMap,List> serialList ){ + + BaseBean bb = new BaseBean(); + Map countMap = new HashMap<>(); + String worktime = "0"; + String totalworktime = "0"; + int restcount = 0; + int weekrestcount = 0; + + RecordSet rs = new RecordSet(); + try{ + String sql = ""; + for (int i = 0; i < serialList.size(); i++) { + Map serialMap = serialList.get(i); + String kqdate = Util.null2String(serialMap.get("kqdate")); + String serialid = Util.null2String(serialMap.get("serialid")); + if (daysList.contains(kqdate)) { + if (StringUtils.isNotBlank(serialid)) { + if (restList.contains(serialid)) { + restcount++; + } + + if(!restList.contains(serialid)){ + String sql2 = " select try_convert(int,worktime) as worktime from kq_ShiftManagement where id ="+serialid+" and (is_rest is null or is_rest = 0) " ; + sql += StringUtils.isBlank(sql) ? sql2 : " union all \n"+sql2 ; + } + } + + if (weekMap.containsKey(kqdate)) { + String value = weekMap.get(kqdate); + //6 = 周六 7 = 周日 11 = 公众假日、调配休息日 + if ("6".equals(value) || "7".equals(value) || "11".equals(value)) { + if (restList.contains(serialid)) { + weekrestcount++; + } + } + } + } + } + + if(StringUtils.isNotBlank(sql)){ + sql = " select round(sum(worktime)/60.0,2) as worktime,sum(worktime) as totalworktime from ("+sql+") w "; + rs.executeQuery(sql); + if(rs.next()){ + worktime = Util.null2String(rs.getString("worktime")); + totalworktime = Util.null2String(rs.getString("totalworktime")); + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("e:"+e); + } + + countMap.put("worktime",worktime); + countMap.put("totalworktime",totalworktime); + countMap.put("restcount",restcount+""); + countMap.put("weekrestcount",weekrestcount+""); + + return countMap; + } + + /*** + * + * @param daysList + * @param holidayMap + * @param yjl + * @param workSchedule + * @param hrmList + * @param groupid + * @return + */ + public List> queryScheduleStatusByDay(List daysList,Map holidayMap,String yjl,String[] workSchedule,List> hrmList,String groupid,Map dateEffectiveMap){ + + BaseBean bb = new BaseBean(); + List> resultList = new ArrayList>(); + + DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + RecordSet rs = new RecordSet(); + + try{ + List> workScheduleList = new ArrayList>(); + Map workScheduleMap = null; + for(int k=0;k0){ + String[] schedule = workSchedule[k].split("-"); + String scheduleStartTime = schedule[0]; + String scheduleEndTime = schedule[1]; + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + workScheduleMap = new HashMap(); + workScheduleMap.put("start",scheduleStartTime); + workScheduleMap.put("end",scheduleEndTime); + workScheduleList.add(workScheduleMap); + } + } + } + + + for(String pbrq:daysList){ + + String resourceids = ""; + for(int i=0;i hrmMap = hrmList.get(i); + String userid = Util.null2String(hrmMap.get("id")); + if(StringUtils.isNotBlank(userid)){ + if(dateEffectiveMap.containsKey(userid)){ + String effectiveDate = dateEffectiveMap.get(userid); + if(effectiveDate.contains(";")){ + String[] effective_Date = effectiveDate.split(";"); + if(pbrq.compareTo(effective_Date[0])>=0 && pbrq.compareTo(effective_Date[1])<=0){ + resourceids += StringUtils.isBlank(resourceids) ? userid : ","+userid ; + } + } + } + } + } + + String dateType = "0"; + if(StringUtils.isNotBlank(pbrq)){ + LocalDate currentDate = LocalDate.parse(pbrq, df); + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); + int weekValue = dayOfWeek.getValue(); + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + + if("1".equals(changeType) || "3".equals(changeType)){ + dateType = "1"; + }else if(weekValue == 6 || weekValue == 7){ + dateType = "1"; + } + } + + Map defaultScheduleMap = new HashMap(); + if(StringUtils.isNotBlank(yjl)){ + String sql = " select dysjd,pzrs from uf_pbjcsj where yjl = ? and pblx = ?" ; + rs.executeQuery(sql,new Object[]{yjl,dateType}); + while (rs.next()){ + int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd"))); + int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs"))); + + String sjd = ""; + if(dysd < workSchedule.length){ + sjd = workSchedule[dysd]; + if(StringUtils.isNotBlank(sjd)){ + defaultScheduleMap.put(sjd,pzrs); + } + } + } + } + + List> sqlList = new ArrayList>(); + if(StringUtils.isNotBlank(resourceids) && StringUtils.isNotBlank(pbrq)){ + + String sql =" select t.serialid,t.resourceid,t.kqdate \n" + + " from kq_shiftschedule t\n" + + " where t.kqdate='"+pbrq+"' \n" + + " and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" + + " and resourceid in( " + resourceids + ") "+ + " order by kqdate "; + sqlList = queryListBySql(sql); + } + + Map resultMap = queryScheduleStatusByUser(sqlList,workScheduleList,defaultScheduleMap,pbrq); + resultList.add(resultMap); + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("e:"+e); + } + + return resultList; + } + + /*** + * + * @param sqlList + * @param workScheduleList + * @param defaultScheduleMap + * @param kqdate + * @return + */ + public Map queryScheduleStatusByUser(List> sqlList,List> workScheduleList,Map defaultScheduleMap,String kqdate){ + + RecordSet rs = new RecordSet(); + + Map> userScheduleDayMap = new HashMap>(); + Map userScheduleMap = new HashMap(); + Map necessaryMap = new HashMap(); + String yxrys = "" ; + for(int i=0;i sqlMap = sqlList.get(i); + String resourceid = Util.null2String(sqlMap.get("resourceid")); + yxrys += StringUtils.isBlank(yxrys) ? resourceid :","+resourceid ; + } + if(StringUtils.isNotBlank(yxrys)) { + List userList = new ArrayList(); + String sql =" select h.id \n" + + " from hrmresource h \n" + + " inner join hrmjobtitles k on k.id = h.jobtitle\n" + + " where h.id in("+yxrys+")\n" + + " and k.jobtitlename in('店长','验光师')\n" + + " and h.status in(0,1,2,3,4)\n" + + " union \n" + + " select h.id \n" + + " from hrmresource h \n" + + " inner join cus_fielddata k on k.id = h.id\n" + + " where k.field39 = 2 \n" + + " and k.scopeid=3 \n" + + " and k.scope='HrmCustomFieldByInfoType' " + + " and h.id in("+yxrys+") and h.status in(0,1,2,3,4) " + + " union " + + " select h.id\n" + + " from hrmresource h \n" + + " inner join cus_fielddata k on k.id = h.id \n" + + " where k.scopeid=-1 " + + " and k.scope='HrmCustomFieldByInfoType'\n" + + " and substring(k.field1,charindex('_',k.field1)+1,len(k.field1)) in(select id from uf_gwjbsjb where jbmc in('配镜一级','配镜二级','配镜三级','配镜四级','配镜五级')) and charindex('_', k.field1) > 0 \n" + + " and h.status in(0,1,2,3,4) "+ + " and h.id in("+yxrys+") "; + + rs.executeQuery(sql); + while (rs.next()){ + String id = Util.null2String(rs.getString("id")); + userList.add(id); + } + + for(int i = 0;i sqlMap = sqlList.get(i); + String pbry = sqlMap.get("resourceid"); + String serialid = sqlMap.get("serialid"); + String startTime = ""; + String endTime = ""; + + sql = " select times,onoffworktype from kq_ShiftOnOffWorkSections where serialid = ? and (isdelete = 0 or isdelete is null) "; + rs.executeQuery(sql,new Object[]{serialid}); + while(rs.next()){ + String onoffworktype = Util.null2String(rs.getString("onoffworktype")); + if("start".equals(onoffworktype)){ + startTime = Util.null2String(rs.getString("times")); + }else if("end".equals(onoffworktype)){ + endTime = Util.null2String(rs.getString("times")); + } + } + + Map userSchedule_Map = new HashMap(); + if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){ + userSchedule_Map.put("startTime",startTime); + userSchedule_Map.put("endTime",endTime); + + for(int k=0;k workSchedule_Map = workScheduleList.get(k); + String scheduleStartTime = workSchedule_Map.get("start"); + String scheduleEndTime = workSchedule_Map.get("end"); + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + if(startTime.compareTo(scheduleStartTime) <=0 && endTime.compareTo(scheduleEndTime) >=0){ + + String defWorkSchedule = scheduleStartTime+"-"+scheduleEndTime ; + if(userScheduleMap.containsKey(defWorkSchedule)){ + int count = userScheduleMap.get(defWorkSchedule); + count++; + userScheduleMap.put(defWorkSchedule,count); + }else{ + userScheduleMap.put(defWorkSchedule,1); + } + + if(userList.contains(pbry)){ + necessaryMap.put(defWorkSchedule,1); + } + } + } + } + } + userScheduleDayMap.put(pbry,userSchedule_Map); + } + } + + int defaultcount = 0; + int datacount = 0; + Iterator> iterator = defaultScheduleMap.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); + int value =entry.getValue(); + String key = entry.getKey(); + if(userScheduleMap.containsKey(key)){ + int useValue = userScheduleMap.get(key); + if(useValue < value){ + datacount++; + } + }else{ + datacount++; + } + defaultcount++; + } + + + String xh = ""; + if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){ + xh = kqdate.substring(8); + if(StringUtils.isNotBlank(xh)){ + if(xh.startsWith("0")){ + xh = xh.substring(1); + } + } + } + Map resultMap = new HashMap<>(); + String status = "0"; + if(defaultcount >0 && datacount == 0){ + if(necessaryMap.size() == 4){ + status = "0"; + }else{ + status = "1"; + } + } + resultMap.put("kqdate",kqdate); + resultMap.put("status",status); + resultMap.put("xh",xh); + + return resultMap; + } + +%> + + diff --git a/浙文眼镜/interface/zw/workflow/tblc/queryUserWorkdayDataByMonth.jsp b/浙文眼镜/interface/zw/workflow/tblc/queryUserWorkdayDataByMonth.jsp new file mode 100644 index 0000000..bd923f3 --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/tblc/queryUserWorkdayDataByMonth.jsp @@ -0,0 +1,916 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="weaver.common.DateUtil" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupBiz" %> +<%@ page import="java.time.LocalDate" %> +<%@ page import="java.time.format.DateTimeFormatter" %> +<%@ page import="java.time.DayOfWeek" %> +<%@ page import="java.time.temporal.TemporalAdjusters" %> +<%@ page import="java.util.*" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + + String[] workSchedule = {"09:00-11:00","11:00-16:00","16:00-20:00","20:00-21:30"}; + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } +// int userid = user.getUID(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + String cjr = request.getParameter("cjr"); + String pbyf = request.getParameter("pbyf"); + String yjl = request.getParameter("yjl"); //mdyj + String cjrbm = request.getParameter("cjrbm"); + + + String activeGroupId = getUserActiveGroupId(cjr+""); +// List> scheduleList = queryShiftScheduleByUser(pbyf,activeGroupId,cjr); +// out.println("scheduleList"+ JSON.toJSON(scheduleList)); + + List> hrmList = new ArrayList>(); + +// out.println("cjrbm:"+cjrbm+"
"); + if(StringUtils.isNotBlank(cjrbm)) { +// String sql = "select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) "; + String sql =" select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) and id not in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"')"+ + " union "+ + " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydhbm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) "+ + " union "+ + " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydsxrq >='"+pbyf+"-02' and bm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) " ; + + hrmList = queryListBySql(sql); + } + + + int daysInMonth = 0; + Map holidayMap = new HashMap(); + List daysList = new ArrayList(); + Map weekMap = new HashMap(); + + List> weekList = new ArrayList>(); + + Map dateEffectiveMap = new HashMap(); + if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7) { + LocalDate localDate = LocalDate.parse(pbyf + "-01"); // 获取当前日期 + LocalDate lastDayOfMonth = localDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + LocalDate firstDayOfMonth = localDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 + + +// for (LocalDate date = firstDayOfMonth; !date.isAfter(lastDayOfMonth); date = date.plusDays(1)) { +// daysList.add(date.toString()); +// } + + String monthStartDate = firstDayOfMonth.toString(); + String monthEndDate = lastDayOfMonth.toString(); + for(int i=0;i hrmMap = hrmList.get(i); + String id = hrmMap.get("id"); + String startDate = monthStartDate; + String endDate = monthEndDate ; + + String sql =" select convert(varchar,dateadd(day,-1,ydsxrq), 23) as ydsxrq " + + " from uf_ygddxx " + + " where left(ydsxrq,7) = '"+pbyf+"' "+ + " and xm = "+ id + + " and bm= "+ cjrbm+ + " and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) "; + rs.executeQuery(sql); + if(rs.next()){ + String ydsxrq = Util.null2String(rs.getString("ydsxrq")); + if(StringUtils.isNotBlank(ydsxrq)){ + endDate = ydsxrq; + } + } + + sql =" select ydsxrq " + + " from uf_ygddxx " + + " where left(ydsxrq,7) = '"+pbyf+"' "+ + " and xm ="+ id + + " and ydhbm="+cjrbm+ + " and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) "; + rs.executeQuery(sql); + if(rs.next()){ + String ydsxrq = Util.null2String(rs.getString("ydsxrq")); + if(StringUtils.isNotBlank(ydsxrq)){ + startDate = ydsxrq; + } + } + dateEffectiveMap.put(id,startDate+";"+endDate); + } + + + holidayMap = getHolidayByGroupId(cjr, monthStartDate, monthEndDate,activeGroupId); + + daysInMonth = localDate.lengthOfMonth(); // 获取本月有多少天 + int thisMonth = localDate.getMonthValue(); // 获取当前是哪月 + + for (int i = 1; i <= daysInMonth; i++) { + LocalDate currentDate = LocalDate.of(localDate.getYear(), thisMonth, i); + + daysList.add(currentDate.toString()); + +// System.out.println("currentDate:" + currentDate.toString()); + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); +// System.out.println(i + "号是周 " + dayOfWeek.getValue()); + int weekValue = dayOfWeek.getValue(); + + String weekDayName = ""; + switch (weekValue) { + case 1: + weekDayName = "周一"; + break; + case 2: + weekDayName = "周二"; + break; + case 3: + weekDayName = "周三"; + break; + case 4: + weekDayName = "周四"; + break; + case 5: + weekDayName = "周五"; + break; + case 6: + weekDayName = "周六"; + break; + case 7: + weekDayName = "周日"; + break; + } + + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + Map weekMap2 = new HashMap(); + weekMap2.put("weekname", weekDayName); + weekMap2.put("changeType", changeType); + weekMap2.put("weekday", i+""); + weekMap2.put("weekdate", currentDate.toString()); + weekList.add(weekMap2); + + + if("1".equals(changeType) || "3".equals(changeType)){ + weekValue = 11; + } + + if(StringUtils.isNotBlank(changeType)){ + weekMap.put(currentDate.toString(), weekValue+""); + }else{ + weekMap.put(currentDate.toString(), weekValue+""); + } + } + } + + List> dt1DataList = new ArrayList>(); + for(int i=0;i hrmMap = hrmList.get(i); + String ry = hrmMap.get("id"); + String lastname = hrmMap.get("lastname"); + + Map dt1DataMap = new HashMap(); + Map ryMap = getDt1UserMap(ry,lastname); + dt1DataMap.put("ry",ryMap); + + List> scheduleList = queryShiftScheduleByUser(pbyf,activeGroupId,ry,dateEffectiveMap); + + dt1DataMap.put("schedule",scheduleList); + + List restList = getSchedulingRestData(); + Map countMap = queryCountWorkTime(restList,daysList,weekMap,scheduleList); + dt1DataMap.put("count",countMap); + + dt1DataList.add(dt1DataMap); + } +// out.println("dt1DataList"+ JSON.toJSON(dt1DataList)+"
"); + + + List> resultList = queryScheduleStatusByDay(daysList,holidayMap,yjl,workSchedule,hrmList,activeGroupId,dateEffectiveMap); + +// out.println("resultList"+ JSON.toJSON(resultList)+"
"); + + Map valueMap = getMainUserDate(hrmList); + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("data",valueMap); + jsonObject.put("dt1day",resultList); + jsonObject.put("dt1user",dt1DataList); + jsonObject.put("days",daysInMonth); + jsonObject.put("head",weekList); +%> + +<%=jsonObject.toJSONString() %> + +<%! + /*** + * + * @param hrmList + * @return + */ + public Map getMainUserDate(List> hrmList){ + String userids = ""; + List> specialobjList = new ArrayList>(); + for(int i=0;i hrmMap = hrmList.get(i); + String userid = Util.null2String(hrmMap.get("id")); + String lastname = Util.null2String(hrmMap.get("lastname")); + userids += StringUtils.isBlank(userids) ? userid : ","+userid ; + + Map specialobjMap = new HashMap(); + specialobjMap.put("id",userid); + specialobjMap.put("name",lastname); + specialobjList.add(specialobjMap); + } + + Map valueMap = new HashMap(); + valueMap.put("value",userids); + valueMap.put("specialobj",specialobjList); + return valueMap; + } + + /*** + * + * @param hrmList + * @return + */ + public List> getDt1UserDate(List> hrmList){ + List> dt1List = new ArrayList>(); + for(int i=0;i hrmMap = hrmList.get(i); + + String userid = Util.null2String(hrmMap.get("id")); + String lastname = Util.null2String(hrmMap.get("lastname")); + + Map dt1Map = new HashMap(); + dt1Map.put("id",userid); + dt1Map.put("name",lastname); + + List> specialobjList2 = new ArrayList>(); + Map specialobjMap2 = new HashMap(); + specialobjMap2.put("id",userid); + specialobjMap2.put("name",lastname); + specialobjList2.add(specialobjMap2); + + Map valueMap2 = new HashMap(); + valueMap2.put("value",userid); + valueMap2.put("specialobj",specialobjList2); + dt1Map.put("value",valueMap2); + + dt1List.add(dt1Map); + } + return dt1List; + } + + + + + + public String getWeekTypeByDate(String pbrq,String userid,String activeGroupId){ + + String dateType = "0"; + DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate currentDate = LocalDate.parse(pbrq, df); + + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); + int weekValue = dayOfWeek.getValue(); + + LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 + String monthStartDate = startDayOfMonth.toString(); + String monthEndDate = lastDayOfMonth.toString(); + Map holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate,activeGroupId); + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + + if("1".equals(changeType) || "3".equals(changeType)){ + dateType = "1"; + }else if(weekValue == 6 || weekValue == 7){ + dateType = "1"; + } + return dateType; + } + + /*** + * + * @param userid + * @param monthStartDate + * @param monthEndDate + * @return + */ + public Map getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate,String activeGroupId){ + + Map holidayMap = new HashMap(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + + try { + if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){ + if(StringUtils.isNotBlank(activeGroupId)){ + String sql =" select holidayDate,changeType from KQ_HolidaySet\n" + + " where groupid = " + activeGroupId+ + " and holidayDate >='"+monthStartDate+"'\n" + + " and holidayDate <='"+monthEndDate+"' " ; + rs.execute(sql); + while (rs.next()){ + String holidayDate = Util.null2String(rs.getString("holidayDate")); + String changeType = Util.null2String(rs.getString("changeType")); +// String changeTypename = "" ; +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// changeTypename += "公众假日"; +// }else if("2".equals(changeType)){ +// changeTypename += "调配工作日"; +// }else if("3".equals(changeType)){ +// changeTypename += "调配休息日"; +// } + holidayMap.put(holidayDate,changeType); + +// if(weekMap.containsKey(holidayDate)){ +// String holidayDate_new = weekMap.get(holidayDate); +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// holidayDate_new += "[公众假日]"; +// }else if("1".equals(changeType)){ +// holidayDate_new += "[调配工作日]"; +// }else if("2".equals(changeType)){ +// holidayDate_new += "[调配休息日]"; +// } +// weekMap.put(holidayDate,holidayDate_new); +// } + } + } + } + }catch (Exception e){ + + } + return holidayMap; + } + + /*** + * + * @param userid + * @return + */ + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } + + + + + + + + public static List> queryListBySql(String sql){ + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + List> list = new ArrayList>(); + try{ + if(StringUtils.isNotBlank(sql)){ + Map map = new HashMap(); + rs.executeQuery(sql); + String[] column = rs.getColumnName(); + while (rs.next()){ + map = new HashMap(); + for(int i=0;i0){ + list.add(map); + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("queryListBySql-e:"+e); + } + return list; + } + + /*** + * + * @return + */ + public Map getDt1UserMap(String ry,String lastname){ + Map valueMap = new HashMap(); + if(StringUtils.isNotBlank(ry)){ + List> specialobjList = new ArrayList>(); + Map specialobjMap = new HashMap(); + specialobjMap.put("id",ry); + specialobjMap.put("name",lastname); + specialobjList.add(specialobjMap); + valueMap.put("id",ry); + valueMap.put("name",lastname); + valueMap.put("specialobj",specialobjList); + } + + return valueMap; + } + + + /*** + * + * @param pbyf + * @param groupid + * @param resourceid + * @return + */ + public List> queryShiftScheduleByUser(String pbyf,String groupid,String resourceid,Map dateEffectiveMap){ + BaseBean bb = new BaseBean(); + List> scheduleList = new ArrayList>(); + try{ + List> sqlList = new ArrayList>(); + if(StringUtils.isNotBlank(pbyf) && StringUtils.isNotBlank(resourceid)){ + String startDate = "" ; + String endDate = ""; + if(dateEffectiveMap.containsKey(resourceid)){ + String effectiveDate = dateEffectiveMap.get(resourceid); + if(effectiveDate.contains(";")){ + String[] effective_Date = effectiveDate.split(";"); + startDate = effective_Date[0]; + endDate = effective_Date[1]; + } + } + + String sql =" select t.serialid,k.serial,t.resourceid,t.kqdate\n" + + " from kq_shiftschedule t\n" + + " inner join kq_ShiftManagement k on k.id = t.serialid\n" + + " where left(t.kqdate,7)='"+pbyf+"' \n" + + " and t.kqdate >='"+startDate+"' " + + " and t.kqdate <= '"+endDate+"'" + + " and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" + + " and resourceid = " + resourceid + + " order by kqdate "; + bb.writeLog("sql:"+sql); + sqlList = queryListBySql(sql); + } + + for(int i=0;i map = sqlList.get(i); + + String serialid = Util.null2String(map.get("serialid")); + String name = Util.null2String(map.get("serial")); + String kqdate = Util.null2String(map.get("kqdate")); + + String xh = ""; + if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){ + xh = kqdate.substring(8); + if(StringUtils.isNotBlank(xh)){ + if(xh.startsWith("0")){ + xh = xh.substring(1); + } + } + } + + if(StringUtils.isNotBlank(xh)){ + List> specialobjList = new ArrayList>(); + Map specialobjMap = new HashMap(); + specialobjMap.put("id",serialid); + specialobjMap.put("name",name); + specialobjList.add(specialobjMap); + + Map valueMap = new HashMap(); + valueMap.put("serialid",serialid); + valueMap.put("kqdate",kqdate); + valueMap.put("xh",xh); + + + + valueMap.put("specialobj",specialobjList); + + scheduleList.add(valueMap); + } + } + + }catch (Exception e){ + + } + return scheduleList; + } + + + public List getSchedulingRestData(){ + + List list = new ArrayList(); + RecordSet rs = new RecordSet(); + try{ + String sql =" select id " + + " from kq_ShiftManagement \n" + + " where is_rest = 1 \n" + + " and (isdelete is null or isdelete = 0) "; + + rs.executeQuery(sql); + while (rs.next()){ + String id = Util.null2String(rs.getString("id")); + list.add(id); + } + }catch (Exception e){ + + } + return list; + } + + /*** + * + * @param restList + * @param daysList + * @param weekMap + * @param serialList + */ + public Map queryCountWorkTime(List restList,List daysList,Map weekMap,List> serialList ){ + + BaseBean bb = new BaseBean(); + Map countMap = new HashMap<>(); + String worktime = "0"; + String totalworktime = "0"; + int restcount = 0; + int weekrestcount = 0; + + RecordSet rs = new RecordSet(); + try{ + String sql = ""; + for (int i = 0; i < serialList.size(); i++) { + Map serialMap = serialList.get(i); + String kqdate = Util.null2String(serialMap.get("kqdate")); + String serialid = Util.null2String(serialMap.get("serialid")); + if (daysList.contains(kqdate)) { + if (StringUtils.isNotBlank(serialid)) { + if (restList.contains(serialid)) { + restcount++; + } + + if(!restList.contains(serialid)){ + String sql2 = " select try_convert(int,worktime) as worktime from kq_ShiftManagement where id ="+serialid+" and (is_rest is null or is_rest = 0) " ; + sql += StringUtils.isBlank(sql) ? sql2 : " union all \n"+sql2 ; + } + } + + if (weekMap.containsKey(kqdate)) { + String value = weekMap.get(kqdate); + //6 = 周六 7 = 周日 11 = 公众假日、调配休息日 + if ("6".equals(value) || "7".equals(value) || "11".equals(value)) { + if (restList.contains(serialid)) { + weekrestcount++; + } + } + } + } + } + + if(StringUtils.isNotBlank(sql)){ + sql = " select round(sum(worktime)/60.0,2) as worktime,sum(worktime) as totalworktime from ("+sql+") w "; + rs.executeQuery(sql); + if(rs.next()){ + worktime = Util.null2String(rs.getString("worktime")); + totalworktime = Util.null2String(rs.getString("totalworktime")); + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("e:"+e); + } + + countMap.put("worktime",worktime); + countMap.put("totalworktime",totalworktime); + countMap.put("restcount",restcount+""); + countMap.put("weekrestcount",weekrestcount+""); + + return countMap; + } + + /*** + * + * @param daysList + * @param holidayMap + * @param yjl + * @param workSchedule + * @param hrmList + * @param groupid + * @return + */ + public List> queryScheduleStatusByDay(List daysList,Map holidayMap,String yjl,String[] workSchedule,List> hrmList,String groupid,Map dateEffectiveMap){ + + BaseBean bb = new BaseBean(); + List> resultList = new ArrayList>(); + + DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + RecordSet rs = new RecordSet(); + + try{ + List> workScheduleList = new ArrayList>(); + Map workScheduleMap = null; + for(int k=0;k0){ + String[] schedule = workSchedule[k].split("-"); + String scheduleStartTime = schedule[0]; + String scheduleEndTime = schedule[1]; + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + workScheduleMap = new HashMap(); + workScheduleMap.put("start",scheduleStartTime); + workScheduleMap.put("end",scheduleEndTime); + workScheduleList.add(workScheduleMap); + } + } + } + + + for(String pbrq:daysList){ + + String resourceids = ""; + for(int i=0;i hrmMap = hrmList.get(i); + String userid = Util.null2String(hrmMap.get("id")); + if(StringUtils.isNotBlank(userid)){ + if(dateEffectiveMap.containsKey(userid)){ + String effectiveDate = dateEffectiveMap.get(userid); + if(effectiveDate.contains(";")){ + String[] effective_Date = effectiveDate.split(";"); + if(pbrq.compareTo(effective_Date[0])>=0 && pbrq.compareTo(effective_Date[1])<=0){ + resourceids += StringUtils.isBlank(resourceids) ? userid : ","+userid ; + } + } + } + } + } + + String dateType = "0"; + if(StringUtils.isNotBlank(pbrq)){ + LocalDate currentDate = LocalDate.parse(pbrq, df); + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); + int weekValue = dayOfWeek.getValue(); + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + + if("1".equals(changeType) || "3".equals(changeType)){ + dateType = "1"; + }else if(weekValue == 6 || weekValue == 7){ + dateType = "1"; + } + } + + Map defaultScheduleMap = new HashMap(); + if(StringUtils.isNotBlank(yjl)){ + String sql = " select dysjd,pzrs from uf_pbjcsj where yjl = ? and pblx = ?" ; + rs.executeQuery(sql,new Object[]{yjl,dateType}); + while (rs.next()){ + int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd"))); + int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs"))); + + String sjd = ""; + if(dysd < workSchedule.length){ + sjd = workSchedule[dysd]; + if(StringUtils.isNotBlank(sjd)){ + defaultScheduleMap.put(sjd,pzrs); + } + } + } + } + + List> sqlList = new ArrayList>(); + if(StringUtils.isNotBlank(resourceids) && StringUtils.isNotBlank(pbrq)){ + + String sql =" select t.serialid,t.resourceid,t.kqdate \n" + + " from kq_shiftschedule t\n" + + " where t.kqdate='"+pbrq+"' \n" + + " and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" + + " and resourceid in( " + resourceids + ") "+ + " order by kqdate "; + sqlList = queryListBySql(sql); + } + + Map resultMap = queryScheduleStatusByUser(sqlList,workScheduleList,defaultScheduleMap,pbrq); + resultList.add(resultMap); + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("e:"+e); + } + + return resultList; + } + + /*** + * + * @param sqlList + * @param workScheduleList + * @param defaultScheduleMap + * @param kqdate + * @return + */ + public Map queryScheduleStatusByUser(List> sqlList,List> workScheduleList,Map defaultScheduleMap,String kqdate){ + + RecordSet rs = new RecordSet(); + + Map> userScheduleDayMap = new HashMap>(); + Map userScheduleMap = new HashMap(); + Map necessaryMap = new HashMap(); + String yxrys = "" ; + for(int i=0;i sqlMap = sqlList.get(i); + String resourceid = Util.null2String(sqlMap.get("resourceid")); + yxrys += StringUtils.isBlank(yxrys) ? resourceid :","+resourceid ; + } + if(StringUtils.isNotBlank(yxrys)) { + List userList = new ArrayList(); + String sql =" select h.id \n" + + " from hrmresource h \n" + + " inner join hrmjobtitles k on k.id = h.jobtitle\n" + + " where h.id in("+yxrys+")\n" + + " and k.jobtitlename in('店长','验光师')\n" + + " and h.status in(0,1,2,3,4)\n" + + " union \n" + + " select h.id \n" + + " from hrmresource h \n" + + " inner join cus_fielddata k on k.id = h.id\n" + + " where k.field39 = 2 \n" + + " and k.scopeid=3 \n" + + " and k.scope='HrmCustomFieldByInfoType' " + + " and h.id in("+yxrys+") and h.status in(0,1,2,3,4) " + + " union " + + " select h.id\n" + + " from hrmresource h \n" + + " inner join cus_fielddata k on k.id = h.id \n" + + " where k.scopeid=-1 " + + " and k.scope='HrmCustomFieldByInfoType'\n" + + " and substring(k.field1,charindex('_',k.field1)+1,len(k.field1)) in(select id from uf_gwjbsjb where jbmc in('配镜一级','配镜二级','配镜三级','配镜四级','配镜五级')) and charindex('_', k.field1) > 0 \n" + + " and h.status in(0,1,2,3,4) "+ + " and h.id in("+yxrys+") "; + + rs.executeQuery(sql); + while (rs.next()){ + String id = Util.null2String(rs.getString("id")); + userList.add(id); + } + + for(int i = 0;i sqlMap = sqlList.get(i); + String pbry = sqlMap.get("resourceid"); + String serialid = sqlMap.get("serialid"); + String startTime = ""; + String endTime = ""; + + sql = " select times,onoffworktype from kq_ShiftOnOffWorkSections where serialid = ? and (isdelete = 0 or isdelete is null) "; + rs.executeQuery(sql,new Object[]{serialid}); + while(rs.next()){ + String onoffworktype = Util.null2String(rs.getString("onoffworktype")); + if("start".equals(onoffworktype)){ + startTime = Util.null2String(rs.getString("times")); + }else if("end".equals(onoffworktype)){ + endTime = Util.null2String(rs.getString("times")); + } + } + + Map userSchedule_Map = new HashMap(); + if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){ + userSchedule_Map.put("startTime",startTime); + userSchedule_Map.put("endTime",endTime); + + for(int k=0;k workSchedule_Map = workScheduleList.get(k); + String scheduleStartTime = workSchedule_Map.get("start"); + String scheduleEndTime = workSchedule_Map.get("end"); + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + if(startTime.compareTo(scheduleStartTime) <=0 && endTime.compareTo(scheduleEndTime) >=0){ + + String defWorkSchedule = scheduleStartTime+"-"+scheduleEndTime ; + if(userScheduleMap.containsKey(defWorkSchedule)){ + int count = userScheduleMap.get(defWorkSchedule); + count++; + userScheduleMap.put(defWorkSchedule,count); + }else{ + userScheduleMap.put(defWorkSchedule,1); + } + + if(userList.contains(pbry)){ + necessaryMap.put(defWorkSchedule,1); + } + } + } + } + } + userScheduleDayMap.put(pbry,userSchedule_Map); + } + } + + int defaultcount = 0; + int datacount = 0; + Iterator> iterator = defaultScheduleMap.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); + int value =entry.getValue(); + String key = entry.getKey(); + if(userScheduleMap.containsKey(key)){ + int useValue = userScheduleMap.get(key); + if(useValue < value){ + datacount++; + } + }else{ + datacount++; + } + defaultcount++; + } + + + String xh = ""; + if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){ + xh = kqdate.substring(8); + if(StringUtils.isNotBlank(xh)){ + if(xh.startsWith("0")){ + xh = xh.substring(1); + } + } + } + Map resultMap = new HashMap<>(); + String status = "0"; + if(defaultcount >0 && datacount == 0){ + if(necessaryMap.size() == 4){ + status = "0"; + }else{ + status = "1"; + } + } + resultMap.put("kqdate",kqdate); + resultMap.put("status",status); + resultMap.put("xh",xh); + + return resultMap; + } + +%> + + diff --git a/浙文眼镜/interface/zw/workflow/tblc/queryUserWorkdayDataByMonth_test.jsp b/浙文眼镜/interface/zw/workflow/tblc/queryUserWorkdayDataByMonth_test.jsp new file mode 100644 index 0000000..7c7fbd1 --- /dev/null +++ b/浙文眼镜/interface/zw/workflow/tblc/queryUserWorkdayDataByMonth_test.jsp @@ -0,0 +1,939 @@ +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="weaver.common.DateUtil" %> +<%@ page import="weaver.hrm.User" %> +<%@ page import="weaver.hrm.HrmUserVarify" %> +<%@ page import="weaver.general.BaseBean" %> +<%@ page import="com.engine.kq.biz.KQGroupMemberComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupComInfo" %> +<%@ page import="com.engine.kq.biz.KQGroupBiz" %> +<%@ page import="java.time.LocalDate" %> +<%@ page import="java.time.format.DateTimeFormatter" %> +<%@ page import="java.time.DayOfWeek" %> +<%@ page import="java.time.temporal.TemporalAdjusters" %> +<%@ page import="java.util.*" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> +<% + + String[] workSchedule = {"09:00-11:00","11:00-16:00","16:00-20:00","20:00-21:30"}; + User user = HrmUserVarify.getUser(request, response); + if(user==null) { + response.sendRedirect("/login/Login.jsp"); + return; + } +// int userid = user.getUID(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + String cjr = request.getParameter("cjr"); + String pbyf = request.getParameter("pbyf"); + String yjl = request.getParameter("yjl"); //mdyj + String cjrbm = request.getParameter("cjrbm"); + String bp = request.getParameter("bp"); + + String activeGroupId = getUserActiveGroupId(cjr+""); +// List> scheduleList = queryShiftScheduleByUser(pbyf,activeGroupId,cjr); +// out.println("scheduleList"+ JSON.toJSON(scheduleList)); + + List> hrmList = new ArrayList>(); + +// out.println("cjrbm:"+cjrbm+"
"); + if(StringUtils.isNotBlank(cjrbm)) { +// String sql = "select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) "; + String sql =" select id,lastname from hrmresource where departmentid = "+cjrbm +" and status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) and id not in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"')"+ + " union "+ + " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydhbm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) "+ + " union "+ + " select id,lastname from hrmresource where status in(0,1,2,3) and id in(select xm from uf_ygddxx where left(ydsxrq,7) = '"+pbyf+"' and ydsxrq >='"+pbyf+"-02' and bm ="+cjrbm+") and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理')) " ; + out.print("sql:"+sql+"
"); + hrmList = queryListBySql(sql); + } + + int daysInMonth = 0; + Map holidayMap = new HashMap(); + List daysList = new ArrayList(); + Map weekMap = new HashMap(); + + List> weekList = new ArrayList>(); + + Map dateEffectiveMap = new HashMap(); + if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7) { + LocalDate localDate = LocalDate.parse(pbyf + "-01"); // 获取当前日期 + LocalDate lastDayOfMonth = localDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + LocalDate firstDayOfMonth = localDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 + + +// for (LocalDate date = firstDayOfMonth; !date.isAfter(lastDayOfMonth); date = date.plusDays(1)) { +// daysList.add(date.toString()); +// } + + String monthStartDate = firstDayOfMonth.toString(); + String monthEndDate = lastDayOfMonth.toString(); + for(int i=0;i hrmMap = hrmList.get(i); + String id = hrmMap.get("id"); + String startDate = monthStartDate; + String endDate = monthEndDate ; + + String sql =" select convert(varchar,dateadd(day,-1,ydsxrq), 23) as ydsxrq " + + " from uf_ygddxx " + + " where left(ydsxrq,7) = '"+pbyf+"' "+ + " and xm = "+ id + + " and bm= "+ cjrbm+ + " and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) "; + rs.executeQuery(sql); + if(rs.next()){ + String ydsxrq = Util.null2String(rs.getString("ydsxrq")); + if(StringUtils.isNotBlank(ydsxrq)){ + endDate = ydsxrq; + } + } + + sql =" select ydsxrq " + + " from uf_ygddxx " + + " where left(ydsxrq,7) = '"+pbyf+"' "+ + " and xm ="+ id + + " and ydhbm="+cjrbm+ + " and xm in( select id from hrmresource where status in(0,1,2,3) and jobtitle not in(select id from hrmjobtitles where jobtitlename in('营运经理'))) "; + rs.executeQuery(sql); + if(rs.next()){ + String ydsxrq = Util.null2String(rs.getString("ydsxrq")); + if(StringUtils.isNotBlank(ydsxrq)){ + startDate = ydsxrq; + } + } + + out.print("startDate:"+startDate+"
"); + out.print("endDate:"+endDate+"
"); + dateEffectiveMap.put(id,startDate+";"+endDate); + } + out.print("dateEffectiveMap:"+dateEffectiveMap.size()+"
"); + + holidayMap = getHolidayByGroupId(cjr, monthStartDate, monthEndDate,activeGroupId); + + daysInMonth = localDate.lengthOfMonth(); // 获取本月有多少天 + int thisMonth = localDate.getMonthValue(); // 获取当前是哪月 + + for (int i = 1; i <= daysInMonth; i++) { + LocalDate currentDate = LocalDate.of(localDate.getYear(), thisMonth, i); + + daysList.add(currentDate.toString()); + +// System.out.println("currentDate:" + currentDate.toString()); + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); +// System.out.println(i + "号是周 " + dayOfWeek.getValue()); + int weekValue = dayOfWeek.getValue(); + + String weekDayName = ""; + switch (weekValue) { + case 1: + weekDayName = "周一"; + break; + case 2: + weekDayName = "周二"; + break; + case 3: + weekDayName = "周三"; + break; + case 4: + weekDayName = "周四"; + break; + case 5: + weekDayName = "周五"; + break; + case 6: + weekDayName = "周六"; + break; + case 7: + weekDayName = "周日"; + break; + } + + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + Map weekMap2 = new HashMap(); + weekMap2.put("weekname", weekDayName); + weekMap2.put("changeType", changeType); + weekMap2.put("weekday", i+""); + weekMap2.put("weekdate", currentDate.toString()); + weekList.add(weekMap2); + + + if("1".equals(changeType) || "3".equals(changeType)){ + weekValue = 11; + } + + if(StringUtils.isNotBlank(changeType)){ + weekMap.put(currentDate.toString(), weekValue+""); + }else{ + weekMap.put(currentDate.toString(), weekValue+""); + } + } + } + + List> dt1DataList = new ArrayList>(); + for(int i=0;i hrmMap = hrmList.get(i); + String ry = hrmMap.get("id"); + String lastname = hrmMap.get("lastname"); + + Map dt1DataMap = new HashMap(); + Map ryMap = getDt1UserMap(ry,lastname); + dt1DataMap.put("ry",ryMap); + + List> scheduleList = queryShiftScheduleByUser(pbyf,activeGroupId,ry,dateEffectiveMap); + + dt1DataMap.put("schedule",scheduleList); + + List restList = getSchedulingRestData(); + Map countMap = queryCountWorkTime(restList,daysList,weekMap,scheduleList); + dt1DataMap.put("count",countMap); + + dt1DataList.add(dt1DataMap); + } +// out.println("dt1DataList"+ JSON.toJSON(dt1DataList)+"
"); + + + List> resultList = queryScheduleStatusByDay(daysList,holidayMap,bp,workSchedule,hrmList,activeGroupId,dateEffectiveMap); + +// out.println("resultList"+ JSON.toJSON(resultList)+"
"); + + Map valueMap = getMainUserDate(hrmList); + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("data",valueMap); + jsonObject.put("dt1day",resultList); + jsonObject.put("dt1user",dt1DataList); + jsonObject.put("days",daysInMonth); + jsonObject.put("head",weekList); +%> + +<%=jsonObject.toJSONString() %> + +<%! + /*** + * + * @param hrmList + * @return + */ + public Map getMainUserDate(List> hrmList){ + String userids = ""; + List> specialobjList = new ArrayList>(); + for(int i=0;i hrmMap = hrmList.get(i); + String userid = Util.null2String(hrmMap.get("id")); + String lastname = Util.null2String(hrmMap.get("lastname")); + userids += StringUtils.isBlank(userids) ? userid : ","+userid ; + + Map specialobjMap = new HashMap(); + specialobjMap.put("id",userid); + specialobjMap.put("name",lastname); + specialobjList.add(specialobjMap); + } + + Map valueMap = new HashMap(); + valueMap.put("value",userids); + valueMap.put("specialobj",specialobjList); + return valueMap; + } + + /*** + * + * @param hrmList + * @return + */ + public List> getDt1UserDate(List> hrmList){ + List> dt1List = new ArrayList>(); + for(int i=0;i hrmMap = hrmList.get(i); + + String userid = Util.null2String(hrmMap.get("id")); + String lastname = Util.null2String(hrmMap.get("lastname")); + + Map dt1Map = new HashMap(); + dt1Map.put("id",userid); + dt1Map.put("name",lastname); + + List> specialobjList2 = new ArrayList>(); + Map specialobjMap2 = new HashMap(); + specialobjMap2.put("id",userid); + specialobjMap2.put("name",lastname); + specialobjList2.add(specialobjMap2); + + Map valueMap2 = new HashMap(); + valueMap2.put("value",userid); + valueMap2.put("specialobj",specialobjList2); + dt1Map.put("value",valueMap2); + + dt1List.add(dt1Map); + } + return dt1List; + } + + + + + + public String getWeekTypeByDate(String pbrq,String userid,String activeGroupId){ + + String dateType = "0"; + DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate currentDate = LocalDate.parse(pbrq, df); + + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); + int weekValue = dayOfWeek.getValue(); + + LocalDate lastDayOfMonth = currentDate.with(TemporalAdjusters.lastDayOfMonth()); // 获取本月最后一天 + LocalDate startDayOfMonth = currentDate.with(TemporalAdjusters.firstDayOfMonth()); // 获取本月最后一天 + String monthStartDate = startDayOfMonth.toString(); + String monthEndDate = lastDayOfMonth.toString(); + Map holidayMap = getHolidayByGroupId(userid,monthStartDate,monthEndDate,activeGroupId); + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + + if("1".equals(changeType) || "3".equals(changeType)){ + dateType = "1"; + }else if(weekValue == 6 || weekValue == 7){ + dateType = "1"; + } + return dateType; + } + + /*** + * + * @param userid + * @param monthStartDate + * @param monthEndDate + * @return + */ + public Map getHolidayByGroupId(String userid,String monthStartDate,String monthEndDate,String activeGroupId){ + + Map holidayMap = new HashMap(); + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + + try { + if(StringUtils.isNotBlank(userid) && StringUtils.isNotBlank(monthStartDate) && StringUtils.isNotBlank(monthEndDate)){ + if(StringUtils.isNotBlank(activeGroupId)){ + String sql =" select holidayDate,changeType from KQ_HolidaySet\n" + + " where groupid = " + activeGroupId+ + " and holidayDate >='"+monthStartDate+"'\n" + + " and holidayDate <='"+monthEndDate+"' " ; + rs.execute(sql); + while (rs.next()){ + String holidayDate = Util.null2String(rs.getString("holidayDate")); + String changeType = Util.null2String(rs.getString("changeType")); +// String changeTypename = "" ; +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// changeTypename += "公众假日"; +// }else if("2".equals(changeType)){ +// changeTypename += "调配工作日"; +// }else if("3".equals(changeType)){ +// changeTypename += "调配休息日"; +// } + holidayMap.put(holidayDate,changeType); + +// if(weekMap.containsKey(holidayDate)){ +// String holidayDate_new = weekMap.get(holidayDate); +// if("1".equals(changeType)){ //1-公众假日 2-调配工作日 3-调配休息日 +// holidayDate_new += "[公众假日]"; +// }else if("1".equals(changeType)){ +// holidayDate_new += "[调配工作日]"; +// }else if("2".equals(changeType)){ +// holidayDate_new += "[调配休息日]"; +// } +// weekMap.put(holidayDate,holidayDate_new); +// } + } + } + } + }catch (Exception e){ + + } + return holidayMap; + } + + /*** + * + * @param userid + * @return + */ + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } + + + + + + + + public static List> queryListBySql(String sql){ + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + List> list = new ArrayList>(); + try{ + if(StringUtils.isNotBlank(sql)){ + Map map = new HashMap(); + rs.executeQuery(sql); + String[] column = rs.getColumnName(); + while (rs.next()){ + map = new HashMap(); + for(int i=0;i0){ + list.add(map); + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("queryListBySql-e:"+e); + } + return list; + } + + /*** + * + * @return + */ + public Map getDt1UserMap(String ry,String lastname){ + Map valueMap = new HashMap(); + if(StringUtils.isNotBlank(ry)){ + List> specialobjList = new ArrayList>(); + Map specialobjMap = new HashMap(); + specialobjMap.put("id",ry); + specialobjMap.put("name",lastname); + specialobjList.add(specialobjMap); + valueMap.put("id",ry); + valueMap.put("name",lastname); + valueMap.put("specialobj",specialobjList); + } + + return valueMap; + } + + + /*** + * + * @param pbyf + * @param groupid + * @param resourceid + * @return + */ + public List> queryShiftScheduleByUser(String pbyf,String groupid,String resourceid,Map dateEffectiveMap){ + BaseBean bb = new BaseBean(); + List> scheduleList = new ArrayList>(); + try{ + List> sqlList = new ArrayList>(); + if(StringUtils.isNotBlank(pbyf) && StringUtils.isNotBlank(resourceid)){ + String startDate = "" ; + String endDate = ""; + if(dateEffectiveMap.containsKey(resourceid)){ + String effectiveDate = dateEffectiveMap.get(resourceid); + if(effectiveDate.contains(";")){ + String[] effective_Date = effectiveDate.split(";"); + startDate = effective_Date[0]; + endDate = effective_Date[1]; + } + } + + bb.writeLog("queryShiftScheduleByUser-startDate:"+startDate); + bb.writeLog("queryShiftScheduleByUser-endDate:"+endDate); + + String sql =" select t.serialid,k.serial,t.resourceid,t.kqdate\n" + + " from kq_shiftschedule t\n" + + " inner join kq_ShiftManagement k on k.id = t.serialid\n" + + " where left(t.kqdate,7)='"+pbyf+"' \n" + + " and t.kqdate >='"+startDate+"' " + + " and t.kqdate <= '"+endDate+"'" + + " and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" + + " and resourceid = " + resourceid + + " order by kqdate "; + bb.writeLog("queryShiftScheduleByUser-sql:"+sql); + sqlList = queryListBySql(sql); + } + + for(int i=0;i map = sqlList.get(i); + + String serialid = Util.null2String(map.get("serialid")); + String name = Util.null2String(map.get("serial")); + String kqdate = Util.null2String(map.get("kqdate")); + + String xh = ""; + if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){ + xh = kqdate.substring(8); + if(StringUtils.isNotBlank(xh)){ + if(xh.startsWith("0")){ + xh = xh.substring(1); + } + } + } + + if(StringUtils.isNotBlank(xh)){ + List> specialobjList = new ArrayList>(); + Map specialobjMap = new HashMap(); + specialobjMap.put("id",serialid); + specialobjMap.put("name",name); + specialobjList.add(specialobjMap); + + Map valueMap = new HashMap(); + valueMap.put("serialid",serialid); + valueMap.put("kqdate",kqdate); + valueMap.put("xh",xh); + valueMap.put("specialobj",specialobjList); + scheduleList.add(valueMap); + } + } + }catch (Exception e){ + + } + return scheduleList; + } + + + public List getSchedulingRestData(){ + + List list = new ArrayList(); + RecordSet rs = new RecordSet(); + try{ + String sql =" select id " + + " from kq_ShiftManagement \n" + + " where is_rest = 1 \n" + + " and (isdelete is null or isdelete = 0) "; + + rs.executeQuery(sql); + while (rs.next()){ + String id = Util.null2String(rs.getString("id")); + list.add(id); + } + }catch (Exception e){ + + } + return list; + } + + /*** + * + * @param restList + * @param daysList + * @param weekMap + * @param serialList + */ + public Map queryCountWorkTime(List restList,List daysList,Map weekMap,List> serialList ){ + + BaseBean bb = new BaseBean(); + Map countMap = new HashMap<>(); + String worktime = "0"; + String totalworktime = "0"; + int restcount = 0; + int weekrestcount = 0; + + RecordSet rs = new RecordSet(); + try{ + String sql = ""; + for (int i = 0; i < serialList.size(); i++) { + Map serialMap = serialList.get(i); + String kqdate = Util.null2String(serialMap.get("kqdate")); + String serialid = Util.null2String(serialMap.get("serialid")); + if (daysList.contains(kqdate)) { + if (StringUtils.isNotBlank(serialid)) { + if (restList.contains(serialid)) { + restcount++; + } + + if(!restList.contains(serialid)){ + String sql2 = " select try_convert(int,worktime) as worktime from kq_ShiftManagement where id ="+serialid+" and (is_rest is null or is_rest = 0) " ; + sql += StringUtils.isBlank(sql) ? sql2 : " union all \n"+sql2 ; + } + } + + if (weekMap.containsKey(kqdate)) { + String value = weekMap.get(kqdate); + //6 = 周六 7 = 周日 11 = 公众假日、调配休息日 + if ("6".equals(value) || "7".equals(value) || "11".equals(value)) { + if (restList.contains(serialid)) { + weekrestcount++; + } + } + } + } + } + + if(StringUtils.isNotBlank(sql)){ + sql = " select round(sum(worktime)/60.0,2) as worktime,sum(worktime) as totalworktime from ("+sql+") w "; + rs.executeQuery(sql); + if(rs.next()){ + worktime = Util.null2String(rs.getString("worktime")); + totalworktime = Util.null2String(rs.getString("totalworktime")); + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("e:"+e); + } + + countMap.put("worktime",worktime); + countMap.put("totalworktime",totalworktime); + countMap.put("restcount",restcount+""); + countMap.put("weekrestcount",weekrestcount+""); + + return countMap; + } + + /*** + * + * @param daysList + * @param holidayMap + * @param bp + * @param workSchedule + * @param hrmList + * @param groupid + * @return + */ + public List> queryScheduleStatusByDay(List daysList,Map holidayMap,String bp,String[] workSchedule,List> hrmList,String groupid,Map dateEffectiveMap){ + + BaseBean bb = new BaseBean(); + List> resultList = new ArrayList>(); + + DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + RecordSet rs = new RecordSet(); + + try{ + List> workScheduleList = new ArrayList>(); + Map workScheduleMap = null; + for(int k=0;k0){ + String[] schedule = workSchedule[k].split("-"); + String scheduleStartTime = schedule[0]; + String scheduleEndTime = schedule[1]; + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + workScheduleMap = new HashMap(); + workScheduleMap.put("start",scheduleStartTime); + workScheduleMap.put("end",scheduleEndTime); + workScheduleList.add(workScheduleMap); + } + } + } + + + for(String pbrq:daysList){ + bb.writeLog("queryScheduleStatusByDay--pbrq:"+pbrq); + String resourceids = ""; + for(int i=0;i hrmMap = hrmList.get(i); + String userid = Util.null2String(hrmMap.get("id")); + if(StringUtils.isNotBlank(userid)){ +// if(dateEffectiveMap.containsKey(userid)){ +// String effectiveDate = dateEffectiveMap.get(userid); +// if(effectiveDate.contains(";")){ +// String[] effective_Date = effectiveDate.split(";"); +// if(pbrq.compareTo(effective_Date[0])>=0 && pbrq.compareTo(effective_Date[1])<=0){ +// resourceids += StringUtils.isBlank(resourceids) ? userid : ","+userid ; +// } +// } +// } + + resourceids += StringUtils.isBlank(resourceids) ? userid : ","+userid ; + } + } + + bb.writeLog("queryScheduleStatusByDay-resourceids:"+resourceids); + String dateType = "0"; + if(StringUtils.isNotBlank(pbrq)){ + LocalDate currentDate = LocalDate.parse(pbrq, df); + DayOfWeek dayOfWeek = currentDate.getDayOfWeek(); + int weekValue = dayOfWeek.getValue(); + + String changeType = "" ; + if(holidayMap.containsKey(currentDate.toString())){ + changeType = holidayMap.get(currentDate.toString()); + } + + if("1".equals(changeType) || "3".equals(changeType)){ + dateType = "1"; + }else if(weekValue == 6 || weekValue == 7){ + dateType = "1"; + } + } + + bb.writeLog("queryScheduleStatusByDay-dateType:"+dateType); + + Map defaultScheduleMap = new HashMap(); + if(StringUtils.isNotBlank(bp)){ + String sql = " select dysjd,pzrs from uf_pbjcsj where bprs = ? and pblx = ?" ; + rs.executeQuery(sql,new Object[]{bp,dateType}); + while (rs.next()){ + int dysd = Util.getIntValue(Util.null2String(rs.getString("dysjd"))); + int pzrs = Util.getIntValue(Util.null2String(rs.getString("pzrs"))); + + String sjd = ""; + if(dysd < workSchedule.length){ + sjd = workSchedule[dysd]; + if(StringUtils.isNotBlank(sjd)){ + defaultScheduleMap.put(sjd,pzrs); + } + } + } + } + + List> sqlList = new ArrayList>(); + if(StringUtils.isNotBlank(resourceids) && StringUtils.isNotBlank(pbrq)){ + + String sql =" select t.serialid,t.resourceid,t.kqdate \n" + + " from kq_shiftschedule t\n" + + " where t.kqdate='"+pbrq+"' \n" + + " and t.groupid="+groupid+" and (t.isDelete is null or t.isDelete = 0)\n" + + " and resourceid in( " + resourceids + ") "+ + " order by kqdate "; + sqlList = queryListBySql(sql); + } + + Map resultMap = queryScheduleStatusByUser(sqlList,workScheduleList,defaultScheduleMap,pbrq); + resultList.add(resultMap); + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("e:"+e); + } + + return resultList; + } + + /*** + * + * @param sqlList + * @param workScheduleList + * @param defaultScheduleMap + * @param kqdate + * @return + */ + public Map queryScheduleStatusByUser(List> sqlList,List> workScheduleList,Map defaultScheduleMap,String kqdate){ + + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + Map> userScheduleDayMap = new HashMap>(); + Map userScheduleMap = new HashMap(); + Map necessaryMap = new HashMap(); + String yxrys = "" ; + for(int i=0;i sqlMap = sqlList.get(i); + String resourceid = Util.null2String(sqlMap.get("resourceid")); + yxrys += StringUtils.isBlank(yxrys) ? resourceid :","+resourceid ; + } + + bb.writeLog("queryScheduleStatusByUser-yxrys:"+yxrys); + + if(StringUtils.isNotBlank(yxrys)) { + List userList = new ArrayList(); + String sql =" select h.id \n" + + " from hrmresource h \n" + + " inner join hrmjobtitles k on k.id = h.jobtitle\n" + + " where h.id in("+yxrys+")\n" + + " and k.jobtitlename in('店长','验光师')\n" + + " and h.status in(0,1,2,3,4)\n" + + " union \n" + + " select h.id \n" + + " from hrmresource h \n" + + " inner join cus_fielddata k on k.id = h.id\n" + + " where k.field39 = 2 \n" + + " and k.scopeid=3 \n" + + " and k.scope='HrmCustomFieldByInfoType' " + + " and h.id in("+yxrys+") and h.status in(0,1,2,3,4) " + + " union " + + " select h.id\n" + + " from hrmresource h \n" + + " inner join cus_fielddata k on k.id = h.id \n" + + " where k.scopeid=-1 " + + " and k.scope='HrmCustomFieldByInfoType'\n" + + " and substring(k.field1,charindex('_',k.field1)+1,len(k.field1)) in(select id from uf_gwjbsjb where jbmc in('配镜一级','配镜二级','配镜三级','配镜四级','配镜五级')) and charindex('_', k.field1) > 0 \n" + + " and h.status in(0,1,2,3,4) "+ + " and h.id in("+yxrys+") "; + + bb.writeLog("queryScheduleStatusByUser-sql:"+sql); + + rs.executeQuery(sql); + while (rs.next()){ + String id = Util.null2String(rs.getString("id")); + userList.add(id); + } + + for(int i = 0;i sqlMap = sqlList.get(i); + String pbry = sqlMap.get("resourceid"); + String serialid = sqlMap.get("serialid"); + String startTime = ""; + String endTime = ""; + + sql = " select times,onoffworktype from kq_ShiftOnOffWorkSections where serialid = ? and (isdelete = 0 or isdelete is null) "; + rs.executeQuery(sql,new Object[]{serialid}); + while(rs.next()){ + String onoffworktype = Util.null2String(rs.getString("onoffworktype")); + if("start".equals(onoffworktype)){ + startTime = Util.null2String(rs.getString("times")); + }else if("end".equals(onoffworktype)){ + endTime = Util.null2String(rs.getString("times")); + } + } + + bb.writeLog("queryScheduleStatusByUser-startTime:"+startTime); + bb.writeLog("queryScheduleStatusByUser-endTime:"+endTime); + + Map userSchedule_Map = new HashMap(); + if(StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime)){ + userSchedule_Map.put("startTime",startTime); + userSchedule_Map.put("endTime",endTime); + + for(int k=0;k workSchedule_Map = workScheduleList.get(k); + String scheduleStartTime = workSchedule_Map.get("start"); + String scheduleEndTime = workSchedule_Map.get("end"); + if(StringUtils.isNotBlank(scheduleStartTime) && StringUtils.isNotBlank(scheduleEndTime)){ + if(startTime.compareTo(scheduleStartTime) <=0 && endTime.compareTo(scheduleEndTime) >=0){ + + String defWorkSchedule = scheduleStartTime+"-"+scheduleEndTime ; + if(userScheduleMap.containsKey(defWorkSchedule)){ + int count = userScheduleMap.get(defWorkSchedule); + count++; + userScheduleMap.put(defWorkSchedule,count); + }else{ + userScheduleMap.put(defWorkSchedule,1); + } + + if(userList.contains(pbry)){ + necessaryMap.put(defWorkSchedule,1); + } + } + } + } + } + userScheduleDayMap.put(pbry,userSchedule_Map); + } + } + + userScheduleMap.forEach((key, value) -> bb.writeLog("queryScheduleStatusByUser--Key = " + key + ", Value = " + value)); + + int defaultcount = 0; + int datacount = 0; + Iterator> iterator = defaultScheduleMap.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry entry = iterator.next(); + int value =entry.getValue(); + String key = entry.getKey(); + bb.writeLog("defaultScheduleMap--value = "+value); + bb.writeLog("defaultScheduleMap--key = "+key); + + if(userScheduleMap.containsKey(key)){ + int useValue = userScheduleMap.get(key); + bb.writeLog("defaultScheduleMap--useValue = "+useValue); + if(useValue < value){ + datacount++; + } + }else{ + datacount++; + } + defaultcount++; + } + + bb.writeLog("queryScheduleStatusByUser--datacount = "+datacount); + bb.writeLog("queryScheduleStatusByUser--defaultcount = "+defaultcount); + + String xh = ""; + if(StringUtils.isNotBlank(kqdate) && kqdate.length() == 10){ + xh = kqdate.substring(8); + if(StringUtils.isNotBlank(xh)){ + if(xh.startsWith("0")){ + xh = xh.substring(1); + } + } + } + Map resultMap = new HashMap<>(); + String status = ""; + if(defaultcount >0 && datacount == 0){ + if(necessaryMap.size() == 4){ + status = "0"; + }else{ + status = "1"; + } + }else{ + bb.writeLog("queryScheduleStatusByUser--status = "+status); + } + resultMap.put("kqdate",kqdate); + resultMap.put("status",status); + resultMap.put("xh",xh); + + return resultMap; + } + +%> + + diff --git a/浙文眼镜/src/weaver/interfaces/zw/cron/EmployeeDataSnapshotCron.java b/浙文眼镜/src/weaver/interfaces/zw/cron/EmployeeDataSnapshotCron.java new file mode 100644 index 0000000..32d75f4 --- /dev/null +++ b/浙文眼镜/src/weaver/interfaces/zw/cron/EmployeeDataSnapshotCron.java @@ -0,0 +1,21 @@ +package weaver.interfaces.zw.cron; + +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.interfaces.schedule.BaseCronJob; + +public class EmployeeDataSnapshotCron extends BaseCronJob { + @Override + public void execute() { + updateEmployeeSnapshot(); + } + public void updateEmployeeSnapshot(){ + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + try{ + boolean istrue = rs.executeProc("HR_RYKZ",""); + }catch (Exception e){ + bb.writeLog("updateEmployeeSnapshot:"+e); + } + } +} diff --git a/浙文眼镜/src/weaver/interfaces/zw/cron/EmployeeDataSnapshotDayCron.java b/浙文眼镜/src/weaver/interfaces/zw/cron/EmployeeDataSnapshotDayCron.java new file mode 100644 index 0000000..e6a4dbb --- /dev/null +++ b/浙文眼镜/src/weaver/interfaces/zw/cron/EmployeeDataSnapshotDayCron.java @@ -0,0 +1,22 @@ +package weaver.interfaces.zw.cron; + +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.interfaces.schedule.BaseCronJob; + +public class EmployeeDataSnapshotDayCron extends BaseCronJob { + @Override + public void execute() { + updateEmployeeSnapshot(); + } + public void updateEmployeeSnapshot(){ + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + try{ + boolean istrue = rs.executeProc("HR_RYKZ_Day",""); + bb.writeLog("EmployeeDataSnapshotDayCron:"+istrue); + }catch (Exception e){ + bb.writeLog("EmployeeDataSnapshotDayCron:"+e); + } + } +} diff --git a/浙文眼镜/src/weaver/interfaces/zw/cron/EmployeeDataSnapshotMonthCron.java b/浙文眼镜/src/weaver/interfaces/zw/cron/EmployeeDataSnapshotMonthCron.java new file mode 100644 index 0000000..ba3b496 --- /dev/null +++ b/浙文眼镜/src/weaver/interfaces/zw/cron/EmployeeDataSnapshotMonthCron.java @@ -0,0 +1,22 @@ +package weaver.interfaces.zw.cron; + +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.interfaces.schedule.BaseCronJob; + +public class EmployeeDataSnapshotMonthCron extends BaseCronJob { + @Override + public void execute() { + updateEmployeeSnapshot(); + } + public void updateEmployeeSnapshot(){ + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + try{ + boolean istrue = rs.executeProc("HR_RYKZ",""); + bb.writeLog("EmployeeDataSnapshotMonthCron:"+istrue); + }catch (Exception e){ + bb.writeLog("EmployeeDataSnapshotMonthCron:"+e); + } + } +} diff --git a/浙文眼镜/src/weaver/interfaces/zw/cron/EmployeeTransferCron.java b/浙文眼镜/src/weaver/interfaces/zw/cron/EmployeeTransferCron.java new file mode 100644 index 0000000..a5adce1 --- /dev/null +++ b/浙文眼镜/src/weaver/interfaces/zw/cron/EmployeeTransferCron.java @@ -0,0 +1,62 @@ +package weaver.interfaces.zw.cron; + +import weaver.conn.RecordSet; +import weaver.interfaces.schedule.BaseCronJob; + +public class EmployeeTransferCron extends BaseCronJob { + @Override + public void execute() { + + } + + /* + ⑥更新“调动人”的【考勤组】为:新考勤组; + ⑦更新“调动人”的新考勤组中的“生效日期”=调动生效日期(如下图); + ⑧更新“调动人”的原考勤组中的“失效日期”=调动生效日期 - 1天; + ⑨如果“调动人”的二级部门是:四川一区(部门id=264)的,且“调动人”【职务】是督导、经理、总监的,要把“调动人”加入【四川一区】考勤组; + ⑩如果“调动人”的二级部门是:四川二区(部门id=258)的,且“调动人”【职务】是督导、经理、总监的,要把“调动人”加入【四川二区】考勤组; + ⑪更新“调动人”的矩阵: + >>如果“调动人”是“调出部门”的部门矩阵中的“店长/直接主管”,则更新“调出门店”的部门矩阵中的“店长/直接主管”为:职务交接人;即,更新部门矩阵中我是店长的数据为:职务交接人,别人顶替我; + >>如果“调动人”的“是否为新店店长==是”,则更新“调入门店”的部门矩阵中的“店长/直接主管”为:调动人;即,更新我为新门店的店长; + */ + + // ①更新“调动人”的【部门】为:调入门店; + public void updateDepartment(String ddr,String drmd){ + RecordSet rs = new RecordSet(); + String sql = " update hrmresource set departmentid = "+drmd+" where id = "+ddr; + rs.executeUpdate(sql); + + } + + // ②更新“调动人”的【岗位】为:调动后岗位; + public void updateJobTitle(){ + + } + + // ③更新“调动人”的【岗位等级】为:调动后岗级; + public void updateJobTitleGrade(){ + + } + + // ④更新“调动人”的【直接上级】为:新直接上级; + public void updateManager(){ + + } + + // ⑤更新“调动人”的所有下属的直接上级为:职务交接人,即:代替“调动人”当领导的; + public void updateSubordinate(){ + + } + + // ⑥更新“调动人”的【考勤组】为:新考勤组; + // ⑦更新“调动人”的新考勤组中的“生效日期”=调动生效日期(如下图); + // ⑧更新“调动人”的原考勤组中的“失效日期”=调动生效日期 - 1天; + + //⑨如果“调动人”的二级部门是:四川一区(部门id=264)的,且“调动人”【职务】是督导、经理、总监的,要把“调动人”加入【四川一区】考勤组; + //⑩如果“调动人”的二级部门是:四川二区(部门id=258)的,且“调动人”【职务】是督导、经理、总监的,要把“调动人”加入【四川二区】考勤组; + + + // ⑪更新“调动人”的矩阵: + // >>如果“调动人”是“调出部门”的部门矩阵中的“店长/直接主管”,则更新“调出门店”的部门矩阵中的“店长/直接主管”为:职务交接人;即,更新部门矩阵中我是店长的数据为:职务交接人,别人顶替我; + // >>如果“调动人”的“是否为新店店长==是”,则更新“调入门店”的部门矩阵中的“店长/直接主管”为:调动人;即,更新我为新门店的店长; +} diff --git a/浙文眼镜/src/weaver/interfaces/zw/utils/CommonUtil.java b/浙文眼镜/src/weaver/interfaces/zw/utils/CommonUtil.java new file mode 100644 index 0000000..c07e276 --- /dev/null +++ b/浙文眼镜/src/weaver/interfaces/zw/utils/CommonUtil.java @@ -0,0 +1,136 @@ +package weaver.interfaces.zw.utils; + +import weaver.general.BaseBean; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.Util; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class CommonUtil { + + /** + * + * @param sql + * @return + */ + public static List> queryListBySql(String sql){ + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + List> list = new ArrayList>(); + try{ + if(StringUtils.isNotBlank(sql)){ + Map map = new HashMap(); + rs.executeQuery(sql); + String[] column = rs.getColumnName(); + while (rs.next()){ + map = new HashMap(); + for(int i=0;i0){ + list.add(map); + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("queryListBySql-e:"+e); + } + return list; + } + + /*** + * + * @param sql + * @return + */ + public static Map queryMapBySql(String sql){ + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + Map map = new HashMap(); + try{ + if(StringUtils.isNotBlank(sql)){ + rs.executeQuery(sql); + String[] column = rs.getColumnName(); + if (rs.next()){ + for(int i=0;i> requestList = queryRequestList(billtable,cjrbm,pbyf,workflowid,requestid); + if(!requestList.isEmpty() && requestList.size() >0){ + String requestname = requestList.get(0).get("requestname"); + String cjrbmmc = departmentComInfo.getDepartmentname(cjrbm); + String currentnodetype = requestList.get(0).get("currentnodetype"); + String requesttypename = ""; + if ("1".equals(currentnodetype) || "2".equals(currentnodetype)) { + requesttypename = "正在审批"; + } else if ("3".equals(currentnodetype)) { + requesttypename = "已归档"; + } + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent(cjrbmmc+"已存在"+pbyf+"的排班申请"+requesttypename+"流程:<"+requestname+">,无法提交当前流程"); + return Action.FAILURE_AND_CONTINUE; + }else{ + + String message = ""; + int daysInMonth = 0; + if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7){ + LocalDate date = LocalDate.parse(pbyf + "-01"); // 获取当前日期 + daysInMonth = date.lengthOfMonth(); // 获取本月有多少天 + } + bb.writeLog("----mainid------"+mainid); + bb.writeLog("----daysInMonth------"+daysInMonth); + if(StringUtils.isNotBlank(mainid)) + { + int errcount = 0; + Map groupNameMap = queryGroupData(); + + sql = " select * from "+billtable+"_dt1 where mainid="+mainid; + bb.writeLog("----sql------"+sql); + List> dt1List = CommonUtil.queryListBySql(sql); + for(int i=0;i dt1Map = dt1List.get(i); + String resourceid = Util.null2String(dt1Map.get("yg")); + + Map> userGroupsMap = getUsergroupByDate(dt1Map, pbyf,daysInMonth); + for (Map.Entry> entry : userGroupsMap.entrySet()) { + String userActiveGroupId = entry.getKey(); + Set dateSet = entry.getValue(); + + bb.writeLog("----userActiveGroupId------"+userActiveGroupId); + bb.writeLog("----dateSet------"+dateSet.size()); + dateSet.forEach(element ->bb.writeLog("date:"+element)); + + String status = getUserScheduleData(dt1Map,pbyf,userActiveGroupId,dateSet,creatorUser,daysInMonth); + if(!"".equals(status)){ + message += resourceComInfo.getLastname(resourceid)+"在考勤组:<"+groupNameMap.get(userActiveGroupId)+">的排班异常;"; + errcount++; + } + } + } + + if(errcount > 0){ + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent(message); + return Action.FAILURE_AND_CONTINUE; + } + }else{ + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent("获取流程数据异常"); + return Action.FAILURE_AND_CONTINUE; + } + } + }catch (Exception e){ + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent("流程提交接口异常"); + return Action.FAILURE_AND_CONTINUE; + } + + return Action.SUCCESS; + } + + + public Map> getUsergroupByDate(Map dt1Map,String pbyf,int daysInMonth){ + BaseBean bb = new BaseBean(); + + Map> userGroupsMap = new HashMap>(); + + String resourceid = Util.null2String(dt1Map.get("yg")); + if(StringUtils.isNotBlank(resourceid)){ + List> userGroupList = getUserKqGroupData(resourceid); + for(int k=1;k<=daysInMonth;k++){ + String kqdate = ""; + if(k<10){ + kqdate = pbyf+"-0"+k; + }else{ + kqdate = pbyf+"-"+k; + } + String userActiveGroupId = ""; + for(int p = 0;p userGroupMap = userGroupList.get(p); + + String validatefrom = userGroupMap.get("validatefrom"); + String validateto = userGroupMap.get("validateto"); + bb.writeLog("resourceid:"+resourceid+" validatefrom:"+validatefrom); + bb.writeLog("resourceid:"+resourceid+" validateto:"+validateto); + + if(kqdate.compareTo(validatefrom) >= 0 && kqdate.compareTo(validateto) <=0){ + userActiveGroupId = userGroupMap.get("groupid"); + } + } + if(userGroupsMap.containsKey(userActiveGroupId)){ + Set dataSet = userGroupsMap.get(userActiveGroupId); + dataSet.add(kqdate); + userGroupsMap.put(userActiveGroupId,dataSet); + }else{ + Set dataSet = new HashSet(); + dataSet.add(kqdate); + userGroupsMap.put(userActiveGroupId,dataSet); + } + } + } + + return userGroupsMap; + } + + + public String getUserScheduleData(Map dt1Map,String pbyf,String userActiveGroupId,Set dateSet,User creatorUser,int daysInMonth){ + BaseBean bb = new BaseBean(); + String resourceid = Util.null2String(dt1Map.get("yg")); + + String status = ""; + Map scheduleMap = queryScheduleDataByActiveGroupId(resourceid,pbyf,userActiveGroupId); + + + JSONArray datasArray = new JSONArray(); + + JSONArray kqdata = new JSONArray(); + for(int k=1;k<=daysInMonth;k++){ + String kqdate = ""; + if(k<10){ + kqdate = pbyf+"-0"+k; + }else{ + kqdate = pbyf+"-"+k; + } + + if(StringUtils.isNotBlank(userActiveGroupId)){ + if(dateSet.contains(kqdate)){ + String serialid = Util.null2String(dt1Map.get("bc"+k)); + if(StringUtils.isNotBlank(serialid)){ + JSONObject bcJSON = new JSONObject(); + String id = ""; + if(scheduleMap.containsKey(resourceid+"_"+serialid+"_"+userActiveGroupId+"_"+kqdate)){ + id = scheduleMap.get(resourceid+"_"+serialid+"_"+userActiveGroupId+"_"+kqdate); + } + bb.writeLog(resourceid+":id:"+id); + bcJSON.put("id",id); + bcJSON.put("serialid",serialid); + bcJSON.put("date",kqdate); + kqdata.add(bcJSON); + } + } + } + } + + JSONObject dataJSON = new JSONObject(); + dataJSON.put("resourceid",resourceid); + dataJSON.put("kqdata",kqdata); + datasArray.add(dataJSON); + + JSONObject datasJSON = new JSONObject(); + datasJSON.put("datas",datasArray); + datasJSON.put("groupId", userActiveGroupId); + bb.writeLog("data:"+datasJSON.toJSONString()); + Map params = new HashMap(); + params.put("data",datasJSON.toJSONString()); + Map apidatas = getService(creatorUser).save(params, creatorUser); + bb.writeLog("apidatas:"+ JSONObject.toJSONString(apidatas)); + if(apidatas.containsKey("status")){ + status = Util.null2String(apidatas.get("status")); + } + return status; + } + + + public Map queryScheduleDataByActiveGroupId(String userid,String pbyf,String activeGroupid){ + Map dataMap = new HashMap(); + BaseBean bb = new BaseBean(); + try { + String sql = " select id,kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userid+") and isdelete =0 and groupid="+activeGroupid; + bb.writeLog("sql:"+sql); + List> scheduleList = CommonUtil.queryListBySql(sql); + for(int i=0;i scheduleMap = scheduleList.get(i); + String kqdate = scheduleMap.get("kqdate"); + String resourceid = scheduleMap.get("resourceid"); + String serialid = scheduleMap.get("serialid"); + String groupid = scheduleMap.get("groupid"); + String id = scheduleMap.get("id"); + + bb.writeLog("kqdate:"+kqdate); + bb.writeLog("resourceid:"+resourceid); + bb.writeLog("serialid:"+serialid); + bb.writeLog("groupid:"+groupid); + bb.writeLog("id:"+id); + dataMap.put(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate,id); + } + }catch (Exception e){ + + } + return dataMap; + } + + + /*** + * + * @param billtable + * @param cjrbm + * @param pbyf + * @param workflowid + * @param requestid + * @return + */ + public List> queryRequestList(String billtable,String cjrbm,String pbyf,String workflowid,String requestid){ + + List> requestList = new ArrayList>(); + try{ + String sql =" select t.id,r.requestid,r.requestname,r.currentnodetype " + + " from "+billtable+" t " + + " inner join workflow_requestbase r on r.requestid = t.requestid " + + " where t.pbyf ='"+pbyf+"' " + + " and t.cjrbm ='"+cjrbm+"' " + + " and r.currentnodetype in(1,2,3) " + + " and r.workflowid = "+workflowid + + " and t.requestid <> "+requestid; + requestList = CommonUtil.queryListBySql(sql); + }catch (Exception e){ + + } + return requestList; + } + + + private KQShiftScheduleService getService(User user) { + return (KQShiftScheduleService) ServiceUtil.getService(KQShiftScheduleServiceImpl.class, user); + } + + + + public List> getUserKqGroupData(String userid){ + + List> userGroupList = new ArrayList>(); + + try{ + if(StringUtils.isNotBlank(userid)){ + String sql =" select distinct resourceid, groupid,status,validatefrom,validateto FROM ( \n" + + " select a.id AS resourceid, b.groupid, a.status,b.validatefrom,b.validateto 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,b.validatefrom,b.validateto FROM HrmResource a, kq_groupmember b \n" + + " where a.subcompanyid1 = b.typevalue and b.type=2 and a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1') \n" + + " union all \n" + + " SELECT a.id AS resourceid, b.groupid, a.status,b.validatefrom,b.validateto FROM HrmResource a, kq_groupmember b \n" + + " WHERE a.departmentid = b.typevalue AND b.type=3 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1') \n" + + " UNION ALL \n" + + " SELECT a.id AS resourceid, b.groupid, a.status,b.validatefrom,b.validateto FROM HrmResource a, kq_groupmember b \n" + + " WHERE a.jobtitle = b.typevalue AND b.type=5 \n" + + " 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" + + " and (b.isdelete is null or b.isdelete <> '1') \n" + + " UNION ALL \n" + + " SELECT a.id AS resourceid, b.groupid, a.status,b.validatefrom,b.validateto 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\n" + + " where resourceid="+userid ; + userGroupList = queryListBySql(sql); + } + }catch (Exception e){ + + } + return userGroupList; + } + + + public List> queryListBySql(String sql){ + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + List> list = new ArrayList>(); + try{ + if(StringUtils.isNotBlank(sql)){ + Map map = new HashMap(); + rs.executeQuery(sql); + String[] column = rs.getColumnName(); + while (rs.next()){ + map = new HashMap(); + for(int i=0;i0){ + list.add(map); + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("queryListBySql-e:"+e); + } + return list; + } + + public Map queryGroupData(){ + Map groupNameMap = new HashMap(); + RecordSet rs = new RecordSet(); + String sql = " select id,groupname from kq_group "; + rs.executeQuery(sql); + while (rs.next()){ + String id = Util.null2String(rs.getString("id")); + String groupname = Util.null2String(rs.getString("groupname")); + groupNameMap.put(id,groupname); + } + return groupNameMap; + } + +} diff --git a/浙文眼镜/src/weaver/interfaces/zw/workflow/action/Htpblc2SchedulingEditActionbak.java b/浙文眼镜/src/weaver/interfaces/zw/workflow/action/Htpblc2SchedulingEditActionbak.java new file mode 100755 index 0000000..c635c9e --- /dev/null +++ b/浙文眼镜/src/weaver/interfaces/zw/workflow/action/Htpblc2SchedulingEditActionbak.java @@ -0,0 +1,496 @@ +package weaver.interfaces.zw.workflow.action; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.biz.KQGroupBiz; +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.biz.KQGroupMemberComInfo; +import com.engine.kq.service.KQShiftScheduleService; +import com.engine.kq.service.impl.KQShiftScheduleServiceImpl; +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.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.interfaces.workflow.action.Action; +import weaver.interfaces.zw.utils.CommonUtil; +import weaver.soa.workflow.request.RequestInfo; + +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author shil + * @date 2024/8/1 + * 流程生成排班 + */ +public class Htpblc2SchedulingEditActionbak implements Action { + + @Override + public String execute(RequestInfo requestInfo) { + BaseBean bb = new BaseBean(); + String requestid = requestInfo.getRequestid(); + String workflowid = requestInfo.getWorkflowid(); + String billtable = requestInfo.getRequestManager().getBillTableName(); + + int creator = requestInfo.getRequestManager().getCreater(); + bb.writeLog("creator:"+creator); + User creatorUser = new User(creator); + bb.writeLog("creatorUser:"+creatorUser.getLastname()); + + RecordSet rs = new RecordSet(); + bb.writeLog("----Htpblc2SchedulingEditAction------"); + DepartmentComInfo departmentComInfo = null; + ResourceComInfo resourceComInfo = null; + try { + departmentComInfo = new DepartmentComInfo(); + resourceComInfo = new ResourceComInfo(); + String mainid = "" ; + String cjr = "" ; + String pbyf = "" ; + String cjrbm = "" ; + String pbmd = ""; + String sql = " select id,cjr,pbyf,cjrbm,pbmd from "+billtable+" where requestid="+requestid; + rs.execute(sql); + if(rs.next()){ + mainid = Util.null2String(rs.getString("id")); + cjr = Util.null2String(rs.getString("cjr")); + pbyf = Util.null2String(rs.getString("pbyf")); + cjrbm = Util.null2String(rs.getString("cjrbm")); + pbmd = Util.null2String(rs.getString("pbmd")); + } + + List> requestList = queryRequestList(billtable,cjrbm,pbyf,workflowid,requestid); + if(!requestList.isEmpty() && requestList.size() >0){ + String requestname = requestList.get(0).get("requestname"); + String lcid = requestList.get(0).get("requestid"); + String cjrbmmc = departmentComInfo.getDepartmentname(cjrbm); + String currentnodetype = requestList.get(0).get("currentnodetype"); + String requesttypename = ""; + if ("1".equals(currentnodetype) || "2".equals(currentnodetype)) { + requesttypename = "正在审批"; + } else if ("3".equals(currentnodetype)) { + requesttypename = "已归档"; + } + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent(cjrbmmc+"已存在"+pbyf+"的排班申请"+requesttypename+"流程:<"+requestname+">,无法提交当前流程"); + return Action.FAILURE_AND_CONTINUE; + }else{ + + int daysInMonth = 0; + if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7){ + LocalDate date = LocalDate.parse(pbyf + "-01"); // 获取当前日期 + daysInMonth = date.lengthOfMonth(); // 获取本月有多少天 + } + bb.writeLog("----mainid------"+mainid); + if(StringUtils.isNotBlank(mainid)) + { + String cjrGroupid = getUserActiveGroupId(cjr); + bb.writeLog("cjrGroupid:"+cjrGroupid); + + Map scheduleMap = queryScheduleDataMap(billtable,mainid,pbyf); + + JSONObject datasJSON = new JSONObject(); + JSONArray datasArray = new JSONArray(); + + sql = " select * from "+billtable+"_dt1 where mainid="+mainid; + List> dt1List = CommonUtil.queryListBySql(sql); + for(int i=0;i dt1Map = dt1List.get(i); + String resourceid = Util.null2String(dt1Map.get("yg")); + + + + if(StringUtils.isNotBlank(resourceid)){ + List> userGroupList = getUserKqGroupData(resourceid); + JSONArray kqdata = new JSONArray(); + for(int k=1;k<=daysInMonth;k++){ + String serialid = Util.null2String(dt1Map.get("bc"+k)); + if(StringUtils.isNotBlank(serialid)){ + String kqdate = ""; + if(k<10){ + kqdate = pbyf+"-0"+k; + }else{ + kqdate = pbyf+"-"+k; + } + + String groupid = ""; + for(int n=0;n userGrupMap = userGroupList.get(n); + String validatefrom = userGrupMap.get("validatefrom"); + String validateto = userGrupMap.get("validateto"); + if(kqdate.compareTo(validatefrom)>=0 && kqdate.compareTo(validateto) < 0){ + groupid = userGrupMap.get("groupid"); + } + } + + if(StringUtils.isNotBlank(groupid)){ + if(cjrGroupid.equals(groupid)){ + JSONObject bcJSON = new JSONObject(); + String id = ""; + if(scheduleMap.containsKey(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate)){ + id = scheduleMap.get(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate); + } + bb.writeLog(resourceid+":id:"+id); + bcJSON.put("id",id); + bcJSON.put("serialid",serialid); + bcJSON.put("date",kqdate); + kqdata.add(bcJSON); + } + } + } + } + +// List> userGroupList = getUserKqGroupData(resourceid); +// Set groupSet = new HashSet(); +// for(int k=1;k<=daysInMonth;k++){ +// String kqdate = ""; +// if(k<10){ +// kqdate = pbyf+"-0"+k; +// }else{ +// kqdate = pbyf+"-"+k; +// } +// for(int n=0;n userGrupMap = userGroupList.get(n); +// String validatefrom = userGrupMap.get("validatefrom"); +// String validateto = userGrupMap.get("validateto"); +// if(kqdate.compareTo(validatefrom)>=0 && kqdate.compareTo(validateto) < 0){ +// String groupid = userGrupMap.get("groupid"); +// groupSet.add(groupid); +// } +// } +// } + +// for(String activeGroup : groupSet){ +// JSONObject datasJSON = new JSONObject(); +// JSONArray datasArray = new JSONArray(); +// +// JSONArray kqdata = new JSONArray(); +// for(int k=1;k<=daysInMonth;k++){ +// String serialid = Util.null2String(dt1Map.get("bc"+k)); +// if(StringUtils.isNotBlank(serialid)){ +// String kqdate = ""; +// if(k<10){ +// kqdate = pbyf+"-0"+k; +// }else{ +// kqdate = pbyf+"-"+k; +// } +// +// String groupid = ""; +// // resourceid, groupid,status,validatefrom,validateto +// +// +// for(int n=0;n userGrupMap = userGroupList.get(n); +// String validatefrom = userGrupMap.get("validatefrom"); +// String validateto = userGrupMap.get("validateto"); +// if(kqdate.compareTo(validatefrom)>=0 && kqdate.compareTo(validateto) < 0){ +// groupid = userGrupMap.get("groupid"); +// } +// } +// +// if(StringUtils.isNotBlank(groupid)){ +// JSONObject bcJSON = new JSONObject(); +// String id = ""; +// if(scheduleMap.containsKey(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate)){ +// id = scheduleMap.get(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate); +// } +// bb.writeLog(resourceid+":id:"+id); +// bcJSON.put("id",id); +// bcJSON.put("serialid",serialid); +// bcJSON.put("date",kqdate); +// kqdata.add(bcJSON); +// } +// } +// } +// } + + JSONObject dataJSON = new JSONObject(); + dataJSON.put("resourceid",resourceid); + dataJSON.put("kqdata",kqdata); + datasArray.add(dataJSON); + } + } + + datasJSON.put("datas",datasArray); + datasJSON.put("groupId", cjrGroupid); + + bb.writeLog("data:"+datasJSON.toJSONString()); + + Map params = new HashMap(); + params.put("data",datasJSON.toJSONString()); + Map apidatas = getService(creatorUser).save(params, creatorUser); + + bb.writeLog("apidatas:"+ JSONObject.toJSONString(apidatas)); + + if(apidatas.containsKey("status")){ + String status = Util.null2String(apidatas.get("status")); + if(!"1".equals(status)){ + String message = Util.null2String(apidatas.get("message")); + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent("排班接口异常:"+message); + return Action.FAILURE_AND_CONTINUE; + } + }else{ + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent("排班保存异常"); + return Action.FAILURE_AND_CONTINUE; + } + }else{ + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent("获取流程数据异常"); + return Action.FAILURE_AND_CONTINUE; + } + } + }catch (Exception e){ + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent("流程提交接口异常"); + return Action.FAILURE_AND_CONTINUE; + } + + return Action.SUCCESS; + } + + /** + * + * @param billtable + * @param mainid + * @return + */ + public List> queryScheduleData(String billtable,String mainid,String pbyf){ + + List> scheduleList = new ArrayList>(); + try { + String userids = "" ; + String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid; + List> dt1List = CommonUtil.queryListBySql(sql); + for(int i=0;i dt1Map = dt1List.get(i); + String resourceid = Util.null2String(dt1Map.get("yg")); + userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ; + } + if(StringUtils.isNotBlank(userids)){ + sql = " select id,kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and (isdelete is null or isdelete = 0)"; + scheduleList = CommonUtil.queryListBySql(sql); + } + + }catch (Exception e){ + + } + return scheduleList; + } + + + public Map queryScheduleDataMap(String billtable,String mainid,String pbyf){ + Map dataMap = new HashMap(); + List> scheduleList = new ArrayList>(); + BaseBean bb = new BaseBean(); + try { + String userids = "" ; + String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid; + List> dt1List = CommonUtil.queryListBySql(sql); + for(int i=0;i dt1Map = dt1List.get(i); + String resourceid = Util.null2String(dt1Map.get("yg")); + if(StringUtils.isNotBlank(resourceid)){ + userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ; + } + } + + if(StringUtils.isNotBlank(userids)){ + sql = " select id,kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and isdelete = 0 "; + bb.writeLog("sql:"+sql); + scheduleList = CommonUtil.queryListBySql(sql); + for(int i=0;i scheduleMap = scheduleList.get(i); + String kqdate = scheduleMap.get("kqdate"); + String resourceid = scheduleMap.get("resourceid"); + String serialid = scheduleMap.get("serialid"); + String groupid = scheduleMap.get("groupid"); + String id = scheduleMap.get("id"); + + bb.writeLog("kqdate:"+kqdate); + bb.writeLog("resourceid:"+resourceid); + bb.writeLog("serialid:"+serialid); + bb.writeLog("groupid:"+groupid); + bb.writeLog("id:"+id); + + dataMap.put(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate,id); + } + } + }catch (Exception e){ + + } + return dataMap; + } + + + /*** + * + * @param billtable + * @param cjrbm + * @param pbyf + * @param workflowid + * @param requestid + * @return + */ + public List> queryRequestList(String billtable,String cjrbm,String pbyf,String workflowid,String requestid){ + + List> requestList = new ArrayList>(); + try{ + String sql =" select t.id,r.requestid,r.requestname,r.currentnodetype " + + " from "+billtable+" t " + + " inner join workflow_requestbase r on r.requestid = t.requestid " + + " where t.pbyf ='"+pbyf+"' " + + " and t.cjrbm ='"+cjrbm+"' " + + " and r.currentnodetype in(1,2,3) " + + " and r.workflowid = "+workflowid + + " and t.requestid <> "+requestid; + requestList = CommonUtil.queryListBySql(sql); + }catch (Exception e){ + + } + return requestList; + } + + + private KQShiftScheduleService getService(User user) { + return (KQShiftScheduleService) ServiceUtil.getService(KQShiftScheduleServiceImpl.class, user); + } + + + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } + + + public List> getUserKqGroupData(String userid){ + + List> userGroupList = new ArrayList>(); + + try{ + if(StringUtils.isNotBlank(userid)){ + String sql =" select distinct resourceid, groupid,status,validatefrom,validateto FROM ( \n" + + " select a.id AS resourceid, b.groupid, a.status,b.validatefrom,b.validateto 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,b.validatefrom,b.validateto FROM HrmResource a, kq_groupmember b \n" + + " where a.subcompanyid1 = b.typevalue and b.type=2 and a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1') \n" + + " union all \n" + + " SELECT a.id AS resourceid, b.groupid, a.status,b.validatefrom,b.validateto FROM HrmResource a, kq_groupmember b \n" + + " WHERE a.departmentid = b.typevalue AND b.type=3 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1') \n" + + " UNION ALL \n" + + " SELECT a.id AS resourceid, b.groupid, a.status,b.validatefrom,b.validateto FROM HrmResource a, kq_groupmember b \n" + + " WHERE a.jobtitle = b.typevalue AND b.type=5 \n" + + " 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" + + " and (b.isdelete is null or b.isdelete <> '1') \n" + + " UNION ALL \n" + + " SELECT a.id AS resourceid, b.groupid, a.status,b.validatefrom,b.validateto 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\n" + + " where resourceid="+userid ; + userGroupList = queryListBySql(sql); + } + }catch (Exception e){ + + } + return userGroupList; + } + + + public List> queryListBySql(String sql){ + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + List> list = new ArrayList>(); + try{ + if(StringUtils.isNotBlank(sql)){ + Map map = new HashMap(); + rs.executeQuery(sql); + String[] column = rs.getColumnName(); + while (rs.next()){ + map = new HashMap(); + for(int i=0;i0){ + list.add(map); + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog("queryListBySql-e:"+e); + } + return list; + } + +} diff --git a/浙文眼镜/src/weaver/interfaces/zw/workflow/action/Httblc2SchedulingEditAction.java b/浙文眼镜/src/weaver/interfaces/zw/workflow/action/Httblc2SchedulingEditAction.java new file mode 100755 index 0000000..c398442 --- /dev/null +++ b/浙文眼镜/src/weaver/interfaces/zw/workflow/action/Httblc2SchedulingEditAction.java @@ -0,0 +1,331 @@ +package weaver.interfaces.zw.workflow.action; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.biz.KQGroupBiz; +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.biz.KQGroupMemberComInfo; +import com.engine.kq.service.KQShiftScheduleService; +import com.engine.kq.service.impl.KQShiftScheduleServiceImpl; +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.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.interfaces.workflow.action.Action; +import weaver.interfaces.zw.utils.CommonUtil; +import weaver.soa.workflow.request.RequestInfo; + +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author shil + * @date 2024/8/1 + * 流程生成排班 + */ +public class Httblc2SchedulingEditAction implements Action { + + @Override + public String execute(RequestInfo requestInfo) { + BaseBean bb = new BaseBean(); + String requestid = requestInfo.getRequestid(); + String workflowid = requestInfo.getWorkflowid(); + String billtable = requestInfo.getRequestManager().getBillTableName(); + + int creator = requestInfo.getRequestManager().getCreater(); + bb.writeLog("creator:"+creator); + User creatorUser = new User(creator); + bb.writeLog("creatorUser:"+creatorUser.getLastname()); + + RecordSet rs = new RecordSet(); + bb.writeLog("----Httblc2SchedulingEditAction------"); + try { + String mainid = "" ; + String cjr = "" ; + String pbyf = "" ; + String cjrbm = "" ; + String pbmd = ""; + String sql = " select id,cjr,pbyf,cjrbm,pbmd from "+billtable+" where requestid="+requestid; + rs.execute(sql); + if(rs.next()){ + mainid = Util.null2String(rs.getString("id")); + cjr = Util.null2String(rs.getString("cjr")); + pbyf = Util.null2String(rs.getString("pbyf")); + cjrbm = Util.null2String(rs.getString("cjrbm")); + pbmd = Util.null2String(rs.getString("pbmd")); + } + + + int daysInMonth = 0; + if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7){ + LocalDate date = LocalDate.parse(pbyf + "-01"); // 获取当前日期 + daysInMonth = date.lengthOfMonth(); // 获取本月有多少天 + } + bb.writeLog("----mainid------"+mainid); + if(StringUtils.isNotBlank(mainid)) + { + + + String cjrGroupid = getUserActiveGroupId(cjr); + bb.writeLog("cjrGroupid:"+cjrGroupid); + Map scheduleMap = queryScheduleDataMap(billtable,mainid,pbyf,cjrGroupid); + + JSONObject datasJSON = new JSONObject(); + JSONArray datasArray = new JSONArray(); + sql = " select * from "+billtable+"_dt1 where mainid="+mainid; + List> dt1List = CommonUtil.queryListBySql(sql); + for(int i=0;i dt1Map = dt1List.get(i); + String resourceid = Util.null2String(dt1Map.get("yg")); + if(StringUtils.isNotBlank(resourceid)){ + JSONArray kqdata = new JSONArray(); + for(int k=1;k<=daysInMonth;k++){ + String serialid = Util.null2String(dt1Map.get("bc"+k)); + if(StringUtils.isNotBlank(serialid)){ + JSONObject bcJSON = new JSONObject(); + String id = ""; + String kqdate = ""; + if(k<10){ + kqdate = pbyf+"-0"+k; + }else{ + kqdate = pbyf+"-"+k; + } + if(scheduleMap.containsKey(resourceid+"_"+serialid+"_"+cjrGroupid+"_"+kqdate)){ + id = scheduleMap.get(resourceid+"_"+serialid+"_"+cjrGroupid+"_"+kqdate); + } + + bb.writeLog(resourceid+":id:"+id); + bcJSON.put("id",id); + bcJSON.put("serialid",serialid); + bcJSON.put("date",kqdate); + kqdata.add(bcJSON); + } + } + + JSONObject dataJSON = new JSONObject(); + dataJSON.put("resourceid",resourceid); + dataJSON.put("kqdata",kqdata); + datasArray.add(dataJSON); + } + } + + datasJSON.put("datas",datasArray); + datasJSON.put("groupId", cjrGroupid); + + bb.writeLog("data:"+datasJSON.toJSONString()); + + Map params = new HashMap(); + params.put("data",datasJSON.toJSONString()); + Map apidatas = getService(creatorUser).save(params, creatorUser); + + bb.writeLog("apidatas:"+ JSONObject.toJSONString(apidatas)); + + if(apidatas.containsKey("status")){ + String status = Util.null2String(apidatas.get("status")); + if(!"1".equals(status)){ + String message = Util.null2String(apidatas.get("message")); + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent("排班接口异常:"+message); + return Action.FAILURE_AND_CONTINUE; + } + }else{ + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent("排班保存异常"); + return Action.FAILURE_AND_CONTINUE; + } + }else{ + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent("获取流程数据异常"); + return Action.FAILURE_AND_CONTINUE; + } + }catch (Exception e){ + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent("流程提交接口异常"); + return Action.FAILURE_AND_CONTINUE; + } + + return Action.SUCCESS; + } + + /** + * + * @param billtable + * @param mainid + * @return + */ + public List> queryScheduleData(String billtable,String mainid,String pbyf){ + + List> scheduleList = new ArrayList>(); + try { + String userids = "" ; + String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid; + List> dt1List = CommonUtil.queryListBySql(sql); + for(int i=0;i dt1Map = dt1List.get(i); + String resourceid = Util.null2String(dt1Map.get("yg")); + userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ; + } + if(StringUtils.isNotBlank(userids)){ + sql = " select id,kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and (isdelete is null or isdelete = 0)"; + scheduleList = CommonUtil.queryListBySql(sql); + } + + }catch (Exception e){ + + } + return scheduleList; + } + + + public Map queryScheduleDataMap(String billtable,String mainid,String pbyf,String activeGroupid){ + Map dataMap = new HashMap(); + List> scheduleList = new ArrayList>(); + BaseBean bb = new BaseBean(); + try { + String userids = "" ; + String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid; + List> dt1List = CommonUtil.queryListBySql(sql); + for(int i=0;i dt1Map = dt1List.get(i); + String resourceid = Util.null2String(dt1Map.get("yg")); + if(StringUtils.isNotBlank(resourceid)){ + userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ; + } + } + if(StringUtils.isNotBlank(userids)){ + sql = " select id,kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and isdelete =0 and groupid="+activeGroupid; + bb.writeLog("sql:"+sql); + scheduleList = CommonUtil.queryListBySql(sql); + for(int i=0;i scheduleMap = scheduleList.get(i); + String kqdate = scheduleMap.get("kqdate"); + String resourceid = scheduleMap.get("resourceid"); + String serialid = scheduleMap.get("serialid"); + String groupid = scheduleMap.get("groupid"); + String id = scheduleMap.get("id"); + + bb.writeLog("kqdate:"+kqdate); + bb.writeLog("resourceid:"+resourceid); + bb.writeLog("serialid:"+serialid); + bb.writeLog("groupid:"+groupid); + bb.writeLog("id:"+id); + + dataMap.put(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate,id); + } + } + + }catch (Exception e){ + + } + return dataMap; + } + + + /*** + * + * @param billtable + * @param cjrbm + * @param pbyf + * @param workflowid + * @param requestid + * @return + */ + public List> queryRequestList(String billtable,String cjrbm,String pbyf,String workflowid,String requestid){ + + List> requestList = new ArrayList>(); + try{ + String sql =" select t.id,r.requestid,r.requestname,r.currentnodetype " + + " from "+billtable+" t " + + " inner join workflow_requestbase r on r.requestid = t.requestid " + + " where t.pbyf ='"+pbyf+"' " + + " and t.cjrbm ='"+cjrbm+"' " + + " and r.currentnodetype in(1,2,3) " + + " and r.workflowid = "+workflowid + + " and t.requestid <> "+requestid; + requestList = CommonUtil.queryListBySql(sql); + }catch (Exception e){ + + } + return requestList; + } + + + private KQShiftScheduleService getService(User user) { + return (KQShiftScheduleService) ServiceUtil.getService(KQShiftScheduleServiceImpl.class, user); + } + + + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } +} diff --git a/浙文眼镜/src/weaver/interfaces/zw/workflow/action/Mdpblc2SchedulingEditAction.java b/浙文眼镜/src/weaver/interfaces/zw/workflow/action/Mdpblc2SchedulingEditAction.java new file mode 100755 index 0000000..d9b4d4d --- /dev/null +++ b/浙文眼镜/src/weaver/interfaces/zw/workflow/action/Mdpblc2SchedulingEditAction.java @@ -0,0 +1,351 @@ +package weaver.interfaces.zw.workflow.action; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.biz.KQGroupBiz; +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.biz.KQGroupMemberComInfo; +import com.engine.kq.service.KQShiftScheduleService; +import com.engine.kq.service.impl.KQShiftScheduleServiceImpl; +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.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.interfaces.workflow.action.Action; +import weaver.interfaces.zw.utils.CommonUtil; +import weaver.soa.workflow.request.RequestInfo; + +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author shil + * @date 2024/8/1 + * 流程生成排班 + */ +public class Mdpblc2SchedulingEditAction implements Action { + + @Override + public String execute(RequestInfo requestInfo) { + BaseBean bb = new BaseBean(); + String requestid = requestInfo.getRequestid(); + String workflowid = requestInfo.getWorkflowid(); + String billtable = requestInfo.getRequestManager().getBillTableName(); + + int creator = requestInfo.getRequestManager().getCreater(); + bb.writeLog("creator:"+creator); + User creatorUser = new User(creator); + bb.writeLog("creatorUser:"+creatorUser.getLastname()); + + RecordSet rs = new RecordSet(); + bb.writeLog("----Mdpblc2SchedulingEditAction------"); + DepartmentComInfo departmentComInfo = null; + try { + departmentComInfo = new DepartmentComInfo(); + String mainid = "" ; + String cjr = "" ; + String pbyf = "" ; + String cjrbm = "" ; + String pbmd = ""; + String sql = " select id,cjr,pbyf,cjrbm,pbmd from "+billtable+" where requestid="+requestid; + rs.execute(sql); + if(rs.next()){ + mainid = Util.null2String(rs.getString("id")); + cjr = Util.null2String(rs.getString("cjr")); + pbyf = Util.null2String(rs.getString("pbyf")); + cjrbm = Util.null2String(rs.getString("cjrbm")); + pbmd = Util.null2String(rs.getString("pbmd")); + } + + List> requestList = queryRequestList(billtable,cjrbm,pbyf,workflowid,requestid); + if(!requestList.isEmpty() && requestList.size() >0){ + String requestname = requestList.get(0).get("requestname"); + String lcid = requestList.get(0).get("requestid"); + String cjrbmmc = departmentComInfo.getDepartmentname(cjrbm); + String currentnodetype = requestList.get(0).get("currentnodetype"); + String requesttypename = ""; + if ("1".equals(currentnodetype) || "2".equals(currentnodetype)) { + requesttypename = "正在审批"; + } else if ("3".equals(currentnodetype)) { + requesttypename = "已归档"; + } + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent(cjrbmmc+"已存在"+pbyf+"的排班申请"+requesttypename+"流程:<"+requestname+">,无法提交当前流程"); + return Action.FAILURE_AND_CONTINUE; + }else{ + + int daysInMonth = 0; + if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7){ + LocalDate date = LocalDate.parse(pbyf + "-01"); // 获取当前日期 + daysInMonth = date.lengthOfMonth(); // 获取本月有多少天 + } + bb.writeLog("----mainid------"+mainid); + if(StringUtils.isNotBlank(mainid)) + { + String cjrGroupid = getUserActiveGroupId(cjr); + bb.writeLog("cjrGroupid:"+cjrGroupid); + + Map scheduleMap = queryScheduleDataMap(billtable,mainid,pbyf,cjrGroupid); + + JSONObject datasJSON = new JSONObject(); + JSONArray datasArray = new JSONArray(); + sql = " select * from "+billtable+"_dt1 where mainid="+mainid; + List> dt1List = CommonUtil.queryListBySql(sql); + for(int i=0;i dt1Map = dt1List.get(i); + String resourceid = Util.null2String(dt1Map.get("yg")); + + if(StringUtils.isNotBlank(resourceid)){ + JSONArray kqdata = new JSONArray(); + for(int k=1;k<=daysInMonth;k++){ + String serialid = Util.null2String(dt1Map.get("bc"+k)); + + if(StringUtils.isNotBlank(serialid)){ + + JSONObject bcJSON = new JSONObject(); + String id = ""; + String kqdate = ""; + if(k<10){ + kqdate = pbyf+"-0"+k; + }else{ + kqdate = pbyf+"-"+k; + } + if(scheduleMap.containsKey(resourceid+"_"+serialid+"_"+cjrGroupid+"_"+kqdate)){ + id = scheduleMap.get(resourceid+"_"+serialid+"_"+cjrGroupid+"_"+kqdate); + } + + bb.writeLog(resourceid+":id:"+id); + bcJSON.put("id",id); + bcJSON.put("serialid",serialid); + bcJSON.put("date",kqdate); + kqdata.add(bcJSON); + } + } + + JSONObject dataJSON = new JSONObject(); + dataJSON.put("resourceid",resourceid); + dataJSON.put("kqdata",kqdata); + datasArray.add(dataJSON); + } + } + + datasJSON.put("datas",datasArray); + datasJSON.put("groupId", cjrGroupid); + + bb.writeLog("data:"+datasJSON.toJSONString()); + + Map params = new HashMap(); + params.put("data",datasJSON.toJSONString()); + Map apidatas = getService(creatorUser).save(params, creatorUser); + + bb.writeLog("apidatas:"+ JSONObject.toJSONString(apidatas)); + + if(apidatas.containsKey("status")){ + String status = Util.null2String(apidatas.get("status")); + if(!"1".equals(status)){ + String message = Util.null2String(apidatas.get("message")); + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent("排班接口异常:"+message); + return Action.FAILURE_AND_CONTINUE; + } + }else{ + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent("排班保存异常"); + return Action.FAILURE_AND_CONTINUE; + } + }else{ + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent("获取流程数据异常"); + return Action.FAILURE_AND_CONTINUE; + } + } + }catch (Exception e){ + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent("流程提交接口异常"); + return Action.FAILURE_AND_CONTINUE; + } + + return Action.SUCCESS; + } + + /** + * + * @param billtable + * @param mainid + * @return + */ + public List> queryScheduleData(String billtable,String mainid,String pbyf){ + + List> scheduleList = new ArrayList>(); + try { + String userids = "" ; + String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid; + List> dt1List = CommonUtil.queryListBySql(sql); + for(int i=0;i dt1Map = dt1List.get(i); + String resourceid = Util.null2String(dt1Map.get("yg")); + userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ; + } + if(StringUtils.isNotBlank(userids)){ + sql = " select id,kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and (isdelete is null or isdelete = 0)"; + scheduleList = CommonUtil.queryListBySql(sql); + } + + }catch (Exception e){ + + } + return scheduleList; + } + + + public Map queryScheduleDataMap(String billtable,String mainid,String pbyf,String activeGroupid){ + Map dataMap = new HashMap(); + List> scheduleList = new ArrayList>(); + BaseBean bb = new BaseBean(); + try { + String userids = "" ; + String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid; + List> dt1List = CommonUtil.queryListBySql(sql); + for(int i=0;i dt1Map = dt1List.get(i); + String resourceid = Util.null2String(dt1Map.get("yg")); + if(StringUtils.isNotBlank(resourceid)){ + userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ; + } + } + if(StringUtils.isNotBlank(userids)){ + sql = " select id,kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and isdelete = 0 and groupid ="+activeGroupid; + bb.writeLog("sql:"+sql); + scheduleList = CommonUtil.queryListBySql(sql); + for(int i=0;i scheduleMap = scheduleList.get(i); + String kqdate = scheduleMap.get("kqdate"); + String resourceid = scheduleMap.get("resourceid"); + String serialid = scheduleMap.get("serialid"); + String groupid = scheduleMap.get("groupid"); + String id = scheduleMap.get("id"); + + bb.writeLog("kqdate:"+kqdate); + bb.writeLog("resourceid:"+resourceid); + bb.writeLog("serialid:"+serialid); + bb.writeLog("groupid:"+groupid); + bb.writeLog("id:"+id); + dataMap.put(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate,id); + } + } + + }catch (Exception e){ + + } + return dataMap; + } + + + /*** + * + * @param billtable + * @param cjrbm + * @param pbyf + * @param workflowid + * @param requestid + * @return + */ + public List> queryRequestList(String billtable,String cjrbm,String pbyf,String workflowid,String requestid){ + + List> requestList = new ArrayList>(); + try{ + String sql =" select t.id,r.requestid,r.requestname,r.currentnodetype " + + " from "+billtable+" t " + + " inner join workflow_requestbase r on r.requestid = t.requestid " + + " where t.pbyf ='"+pbyf+"' " + + " and t.cjrbm ='"+cjrbm+"' " + + " and r.currentnodetype in(1,2,3) " + + " and r.workflowid = "+workflowid + + " and t.requestid <> "+requestid; + requestList = CommonUtil.queryListBySql(sql); + }catch (Exception e){ + + } + return requestList; + } + + + private KQShiftScheduleService getService(User user) { + return (KQShiftScheduleService) ServiceUtil.getService(KQShiftScheduleServiceImpl.class, user); + } + + + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } +} diff --git a/浙文眼镜/src/weaver/interfaces/zw/workflow/action/Mdtblc2SchedulingEditAction.java b/浙文眼镜/src/weaver/interfaces/zw/workflow/action/Mdtblc2SchedulingEditAction.java new file mode 100755 index 0000000..448b43b --- /dev/null +++ b/浙文眼镜/src/weaver/interfaces/zw/workflow/action/Mdtblc2SchedulingEditAction.java @@ -0,0 +1,331 @@ +package weaver.interfaces.zw.workflow.action; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.biz.KQGroupBiz; +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.biz.KQGroupMemberComInfo; +import com.engine.kq.service.KQShiftScheduleService; +import com.engine.kq.service.impl.KQShiftScheduleServiceImpl; +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.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.interfaces.workflow.action.Action; +import weaver.interfaces.zw.utils.CommonUtil; +import weaver.soa.workflow.request.RequestInfo; + +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author shil + * @date 2024/8/1 + * 流程生成排班 + */ +public class Mdtblc2SchedulingEditAction implements Action { + + @Override + public String execute(RequestInfo requestInfo) { + BaseBean bb = new BaseBean(); + String requestid = requestInfo.getRequestid(); + String workflowid = requestInfo.getWorkflowid(); + String billtable = requestInfo.getRequestManager().getBillTableName(); + + int creator = requestInfo.getRequestManager().getCreater(); + bb.writeLog("creator:"+creator); + User creatorUser = new User(creator); + bb.writeLog("creatorUser:"+creatorUser.getLastname()); + + RecordSet rs = new RecordSet(); + bb.writeLog("----Mdtblc2SchedulingEditAction------"); + + try { + + String mainid = "" ; + String cjr = "" ; + String pbyf = "" ; + String cjrbm = "" ; + String pbmd = ""; + String sql = " select id,cjr,pbyf,cjrbm,pbmd from "+billtable+" where requestid="+requestid; + rs.execute(sql); + if(rs.next()){ + mainid = Util.null2String(rs.getString("id")); + cjr = Util.null2String(rs.getString("cjr")); + pbyf = Util.null2String(rs.getString("pbyf")); + cjrbm = Util.null2String(rs.getString("cjrbm")); + pbmd = Util.null2String(rs.getString("pbmd")); + } + + int daysInMonth = 0; + if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7){ + LocalDate date = LocalDate.parse(pbyf + "-01"); // 获取当前日期 + daysInMonth = date.lengthOfMonth(); // 获取本月有多少天 + } + bb.writeLog("----mainid------"+mainid); + if(StringUtils.isNotBlank(mainid)) + { + String cjrGroupid = getUserActiveGroupId(cjr); + bb.writeLog("cjrGroupid:"+cjrGroupid); + Map scheduleMap = queryScheduleDataMap(billtable,mainid,pbyf,cjrGroupid); + + JSONObject datasJSON = new JSONObject(); + JSONArray datasArray = new JSONArray(); + sql = " select * from "+billtable+"_dt1 where mainid="+mainid; + List> dt1List = CommonUtil.queryListBySql(sql); + for(int i=0;i dt1Map = dt1List.get(i); + String resourceid = Util.null2String(dt1Map.get("yg")); + if(StringUtils.isNotBlank(resourceid)){ + JSONArray kqdata = new JSONArray(); + for(int k=1;k<=daysInMonth;k++){ + String serialid = Util.null2String(dt1Map.get("bc"+k)); + + if(StringUtils.isNotBlank(serialid)){ + JSONObject bcJSON = new JSONObject(); + String id = ""; + String kqdate = ""; + if(k<10){ + kqdate = pbyf+"-0"+k; + }else{ + kqdate = pbyf+"-"+k; + } + if(scheduleMap.containsKey(resourceid+"_"+serialid+"_"+cjrGroupid+"_"+kqdate)){ + id = scheduleMap.get(resourceid+"_"+serialid+"_"+cjrGroupid+"_"+kqdate); + } + bb.writeLog(resourceid+":id:"+id); + + bcJSON.put("id",id); + bcJSON.put("serialid",serialid); + bcJSON.put("date",kqdate); + kqdata.add(bcJSON); + } + } + + JSONObject dataJSON = new JSONObject(); + dataJSON.put("resourceid",resourceid); + dataJSON.put("kqdata",kqdata); + datasArray.add(dataJSON); + } + } + + datasJSON.put("datas",datasArray); + datasJSON.put("groupId", cjrGroupid); + + bb.writeLog("data:"+datasJSON.toJSONString()); + + Map params = new HashMap(); + params.put("data",datasJSON.toJSONString()); + Map apidatas = getService(creatorUser).save(params, creatorUser); + + bb.writeLog("apidatas:"+ JSONObject.toJSONString(apidatas)); + + if(apidatas.containsKey("status")){ + String status = Util.null2String(apidatas.get("status")); + if(!"1".equals(status)){ + String message = Util.null2String(apidatas.get("message")); + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent("排班接口异常:"+message); + return Action.FAILURE_AND_CONTINUE; + } + }else{ + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent("排班保存异常"); + return Action.FAILURE_AND_CONTINUE; + } + }else{ + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent("获取流程数据异常"); + return Action.FAILURE_AND_CONTINUE; + } + }catch (Exception e){ + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent("流程提交接口异常"); + return Action.FAILURE_AND_CONTINUE; + } + + return Action.SUCCESS; + } + + /** + * + * @param billtable + * @param mainid + * @return + */ +// public List> queryScheduleData(String billtable,String mainid,String pbyf){ +// +// List> scheduleList = new ArrayList>(); +// try { +// String userids = "" ; +// String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid; +// List> dt1List = CommonUtil.queryListBySql(sql); +// for(int i=0;i dt1Map = dt1List.get(i); +// String resourceid = Util.null2String(dt1Map.get("yg")); +// userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ; +// } +// if(StringUtils.isNotBlank(userids)){ +// sql = " select id,kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and (isdelete is null or isdelete = 0)"; +// scheduleList = CommonUtil.queryListBySql(sql); +// } +// +// }catch (Exception e){ +// +// } +// return scheduleList; +// } + + + public Map queryScheduleDataMap(String billtable,String mainid,String pbyf,String activeGroupId){ + Map dataMap = new HashMap(); + List> scheduleList = new ArrayList>(); + BaseBean bb = new BaseBean(); + try { + String userids = "" ; + String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid; + List> dt1List = CommonUtil.queryListBySql(sql); + for(int i=0;i dt1Map = dt1List.get(i); + String resourceid = Util.null2String(dt1Map.get("yg")); + if(StringUtils.isNotBlank(resourceid)){ + userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ; + } + } + if(StringUtils.isNotBlank(userids)){ + sql = " select id,kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and isdelete = 0 and groupid="+activeGroupId; + bb.writeLog("sql:"+sql); + scheduleList = CommonUtil.queryListBySql(sql); + for(int i=0;i scheduleMap = scheduleList.get(i); + String kqdate = scheduleMap.get("kqdate"); + String resourceid = scheduleMap.get("resourceid"); + String serialid = scheduleMap.get("serialid"); + String groupid = scheduleMap.get("groupid"); + String id = scheduleMap.get("id"); + + bb.writeLog("kqdate:"+kqdate); + bb.writeLog("resourceid:"+resourceid); + bb.writeLog("serialid:"+serialid); + bb.writeLog("groupid:"+groupid); + bb.writeLog("id:"+id); + + dataMap.put(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate,id); + } + } + + }catch (Exception e){ + + } + return dataMap; + } + + + /*** + * + * @param billtable + * @param cjrbm + * @param pbyf + * @param workflowid + * @param requestid + * @return + */ + public List> queryRequestList(String billtable,String cjrbm,String pbyf,String workflowid,String requestid){ + + List> requestList = new ArrayList>(); + try{ + String sql =" select t.id,r.requestid,r.requestname,r.currentnodetype " + + " from "+billtable+" t " + + " inner join workflow_requestbase r on r.requestid = t.requestid " + + " where t.pbyf ='"+pbyf+"' " + + " and t.cjrbm ='"+cjrbm+"' " + + " and r.currentnodetype in(1,2,3) " + + " and r.workflowid = "+workflowid + + " and t.requestid <> "+requestid; + requestList = CommonUtil.queryListBySql(sql); + }catch (Exception e){ + + } + return requestList; + } + + + private KQShiftScheduleService getService(User user) { + return (KQShiftScheduleService) ServiceUtil.getService(KQShiftScheduleServiceImpl.class, user); + } + + + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } +} diff --git a/浙文眼镜/src/weaver/interfaces/zw/workflow/action/SchedulingDataCheckAction.java b/浙文眼镜/src/weaver/interfaces/zw/workflow/action/SchedulingDataCheckAction.java new file mode 100755 index 0000000..de541aa --- /dev/null +++ b/浙文眼镜/src/weaver/interfaces/zw/workflow/action/SchedulingDataCheckAction.java @@ -0,0 +1,261 @@ +package weaver.interfaces.zw.workflow.action; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.biz.KQGroupBiz; +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.biz.KQGroupMemberComInfo; +import com.engine.kq.service.KQShiftScheduleService; +import com.engine.kq.service.impl.KQShiftScheduleServiceImpl; +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.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.interfaces.workflow.action.Action; +import weaver.interfaces.zw.utils.CommonUtil; +import weaver.soa.workflow.request.RequestInfo; + +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author shil + * @date 2024/8/1 + * 流程生成排班 + */ +public class SchedulingDataCheckAction implements Action { + + @Override + public String execute(RequestInfo requestInfo) { + BaseBean bb = new BaseBean(); + String requestid = requestInfo.getRequestid(); + String workflowid = requestInfo.getWorkflowid(); + String billtable = requestInfo.getRequestManager().getBillTableName(); + RecordSet rs = new RecordSet(); + bb.writeLog("----SchedulingDataCheckAction------"); + try { + int uncount = 0; + String datas = ""; + String sql = " select * from "+billtable+" where requestid="+requestid; + bb.writeLog("SchedulingDataCheckAction-sql:"+sql); + rs.execute(sql); + if(rs.next()){ + String pbyf = rs.getString("pbyf"); + + for(int i=0;i<31;i++){ + String bc = "bcjg"+i; + String day = ""; + if(i<10){ + day = "0"+i ; + }else{ + day = ""+i ; + } + + String errDay = pbyf + "-"+ day; + String bcjg = Util.null2String(rs.getString(bc)); + bb.writeLog("errDay:"+errDay+" bcjg:"+bcjg); + if("1".equals(bcjg)){ + uncount++; + datas+= StringUtils.isBlank(datas) ? errDay : ","+errDay ; + } + } + } + if(uncount > 0){ + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent(datas+"等排班数据不合理,无法提交"); + return Action.FAILURE_AND_CONTINUE; + } + }catch (Exception e){ + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent("流程提交接口异常"); + return Action.FAILURE_AND_CONTINUE; + } + + return Action.SUCCESS; + } + + /** + * + * @param billtable + * @param mainid + * @return + */ + public List> queryScheduleData(String billtable,String mainid,String pbyf){ + + List> scheduleList = new ArrayList>(); + try { + String userids = "" ; + String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid; + List> dt1List = CommonUtil.queryListBySql(sql); + for(int i=0;i dt1Map = dt1List.get(i); + String resourceid = Util.null2String(dt1Map.get("yg")); + userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ; + } + if(StringUtils.isNotBlank(userids)){ + sql = " select id,kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and (isdelete is null or isdelete = 0)"; + scheduleList = CommonUtil.queryListBySql(sql); + } + + }catch (Exception e){ + + } + return scheduleList; + } + + + public Map queryScheduleDataMap(String billtable,String mainid,String pbyf){ + Map dataMap = new HashMap(); + List> scheduleList = new ArrayList>(); + BaseBean bb = new BaseBean(); + try { + String userids = "" ; + String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid; + List> dt1List = CommonUtil.queryListBySql(sql); + for(int i=0;i dt1Map = dt1List.get(i); + String resourceid = Util.null2String(dt1Map.get("yg")); + userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ; + } + if(StringUtils.isNotBlank(userids)){ + sql = " select id,kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and (isdelete is null or isdelete = 0)"; + + + bb.writeLog("sql:"+sql); + + scheduleList = CommonUtil.queryListBySql(sql); + for(int i=0;i scheduleMap = scheduleList.get(i); + String kqdate = scheduleMap.get("kqdate"); + String resourceid = scheduleMap.get("resourceid"); + String serialid = scheduleMap.get("serialid"); + String groupid = scheduleMap.get("groupid"); + String id = scheduleMap.get("id"); + + bb.writeLog("kqdate:"+kqdate); + bb.writeLog("resourceid:"+resourceid); + bb.writeLog("serialid:"+serialid); + bb.writeLog("groupid:"+groupid); + bb.writeLog("id:"+id); + + dataMap.put(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate,id); + } + } + + }catch (Exception e){ + + } + return dataMap; + } + + + /*** + * + * @param billtable + * @param cjrbm + * @param pbyf + * @param workflowid + * @param requestid + * @return + */ + public List> queryRequestList(String billtable,String cjrbm,String pbyf,String workflowid,String requestid){ + + List> requestList = new ArrayList>(); + try{ + String sql =" select t.id,r.requestid,r.requestname,r.currentnodetype " + + " from "+billtable+" t " + + " inner join workflow_requestbase r on r.requestid = t.requestid " + + " where t.pbyf ='"+pbyf+"' " + + " and t.cjrbm ='"+cjrbm+"' " + + " and r.currentnodetype in(1,2,3) " + + " and r.workflowid = "+workflowid + + " and t.requestid <> "+requestid; + requestList = CommonUtil.queryListBySql(sql); + }catch (Exception e){ + + } + return requestList; + } + + + private KQShiftScheduleService getService(User user) { + return (KQShiftScheduleService) ServiceUtil.getService(KQShiftScheduleServiceImpl.class, user); + } + + + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } + + + +} diff --git a/浙文眼镜/src/weaver/interfaces/zw/workflow/action/WorkflowToSchedulingAction.java b/浙文眼镜/src/weaver/interfaces/zw/workflow/action/WorkflowToSchedulingAction.java new file mode 100755 index 0000000..34cf5a7 --- /dev/null +++ b/浙文眼镜/src/weaver/interfaces/zw/workflow/action/WorkflowToSchedulingAction.java @@ -0,0 +1,317 @@ +package weaver.interfaces.zw.workflow.action; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.biz.KQGroupBiz; +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.biz.KQGroupMemberComInfo; +import com.engine.kq.service.KQShiftScheduleService; +import com.engine.kq.service.impl.KQShiftScheduleServiceImpl; +import com.weaver.general.BaseBean; +import org.apache.commons.lang3.StringUtils; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.RequestInfo; +import weaver.interfaces.zw.utils.CommonUtil; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author shil + * @date 2024/8/1 + * 流程生成排班 + */ +public class WorkflowToSchedulingAction implements Action { + + @Override + public String execute(RequestInfo requestInfo) { + BaseBean bb = new BaseBean(); + String requestid = requestInfo.getRequestid(); + String workflowid = requestInfo.getWorkflowid(); + String billtable = requestInfo.getRequestManager().getBillTableName(); + User user = requestInfo.getRequestManager().getUser(); + RecordSet rs = new RecordSet(); + bb.writeLog("----WorkflowToSchedulingAction------"); + DepartmentComInfo departmentComInfo = null; + ResourceComInfo resourceComInfo = null; + try { + departmentComInfo = new DepartmentComInfo(); + resourceComInfo = new ResourceComInfo(); + String mainid = "" ; + String cjr = "" ; + String pbyf = "" ; + String cjrbm = "" ; + String pbmd = ""; + String sql = " select id,cjr,pbyf,cjrbm,pbmd from "+billtable+" where requestid="+requestid; + rs.execute(sql); + if(rs.next()){ + mainid = Util.null2String(rs.getString("id")); + cjr = Util.null2String(rs.getString("cjr")); + pbyf = Util.null2String(rs.getString("pbyf")); + cjrbm = Util.null2String(rs.getString("cjrbm")); + pbmd = Util.null2String(rs.getString("pbmd")); + } + + List> requestList = queryRequestList(billtable,cjrbm,pbyf,workflowid,requestid); + if(!requestList.isEmpty() && requestList.size() >0){ + String requestname = requestList.get(0).get("requestname"); + String lcid = requestList.get(0).get("requestid"); + String cjrbmmc = departmentComInfo.getDepartmentname(cjrbm); + String currentnodetype = requestList.get(0).get("currentnodetype"); + String requesttypename = ""; + if ("1".equals(currentnodetype) || "2".equals(currentnodetype)) { + requesttypename = "正在审批"; + } else if ("3".equals(currentnodetype)) { + requesttypename = "已归档"; + } + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent(cjrbmmc+"已存在"+pbyf+"的排班申请"+requesttypename+"流程:<"+requestname+">,无法提交当前流程"); + return Action.FAILURE_AND_CONTINUE; + }else{ + List> scheduleList = queryScheduleData(billtable,mainid,pbyf); + if(!scheduleList.isEmpty() && scheduleList.size()>0){ + String lastnames = ""; + for(int i=0;i scheduleMap = scheduleList.get(i); + String resourceid = scheduleMap.get("resourceid"); + if(StringUtils.isNotBlank(resourceid)){ + if(i==0){ + String lastname = resourceComInfo.getLastname(resourceid); + lastnames += StringUtils.isBlank(lastnames) ? lastname : ","+lastname; + } + } + } + + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent(lastnames+"等人已存在"+pbyf+"的排班,无法提交排班流程"); + return Action.FAILURE_AND_CONTINUE; + }else{ + int daysInMonth = 0; + if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7){ + LocalDate date = LocalDate.parse(pbyf + "-01"); // 获取当前日期 + daysInMonth = date.lengthOfMonth(); // 获取本月有多少天 + } + bb.writeLog("----mainid------"+mainid); + if(StringUtils.isNotBlank(mainid)) + { + if(StringUtils.isNotBlank(pbmd)){ + if(pbmd.contains(",")){ + pbmd = pbmd.split(",")[0]; + } + }else{ + pbmd = cjr; + } + String groupid = getUserActiveGroupId(pbmd); + bb.writeLog("groupid:"+groupid); + + JSONObject datasJSON = new JSONObject(); + JSONArray datasArray = new JSONArray(); + sql = " select * from "+billtable+"_dt1 where mainid="+mainid; + List> dt1List = CommonUtil.queryListBySql(sql); + for(int i=0;i dt1Map = dt1List.get(i); + String resourceid = Util.null2String(dt1Map.get("yg")); + if(StringUtils.isNotBlank(resourceid)){ + JSONArray kqdata = new JSONArray(); + for(int k=1;k<=daysInMonth;k++){ + String bc = Util.null2String(dt1Map.get("bc"+k)); + JSONObject bcJSON = new JSONObject(); + bcJSON.put("id",""); + bcJSON.put("serialid",bc); + if(k<10){ + bcJSON.put("date",pbyf+"-0"+k); + }else{ + bcJSON.put("date",pbyf+"-"+k); + } + kqdata.add(bcJSON); + } + + JSONObject dataJSON = new JSONObject(); + dataJSON.put("resourceid",resourceid); + dataJSON.put("kqdata",kqdata); + datasArray.add(dataJSON); + } + } + + datasJSON.put("datas",datasArray); + datasJSON.put("groupId", groupid); + + bb.writeLog("data:"+datasJSON.toJSONString()); + + Map params = new HashMap(); + params.put("data",datasJSON.toJSONString()); + Map apidatas = getService(user).save(params, user); + + bb.writeLog("apidatas:"+ JSONObject.toJSONString(apidatas)); + + if(apidatas.containsKey("status")){ + String status = Util.null2String(apidatas.get("status")); + if(!"1".equals(status)){ + String message = Util.null2String(apidatas.get("message")); + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent(message); + return Action.FAILURE_AND_CONTINUE; + } + }else{ + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent("排班保存异常"); + return Action.FAILURE_AND_CONTINUE; + } + }else{ + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent("获取流程数据异常"); + return Action.FAILURE_AND_CONTINUE; + } + } + } + }catch (Exception e){ + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent("流程提交接口异常"); + return Action.FAILURE_AND_CONTINUE; + } + + return Action.SUCCESS; + } + + /** + * + * @param billtable + * @param mainid + * @return + */ + public List> queryScheduleData(String billtable,String mainid,String pbyf){ + + List> scheduleList = new ArrayList>(); + try { + String userids = "" ; + String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid; + List> dt1List = CommonUtil.queryListBySql(sql); + for(int i=0;i dt1Map = dt1List.get(i); + String resourceid = Util.null2String(dt1Map.get("yg")); + if(StringUtils.isNotBlank(resourceid)){ + userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ; + } + } + if(StringUtils.isNotBlank(userids)){ + sql = " select kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and (isdelete is null or isdelete = 0)"; + scheduleList = CommonUtil.queryListBySql(sql); + } + + }catch (Exception e){ + + } + return scheduleList; + } + + /*** + * + * @param billtable + * @param cjrbm + * @param pbyf + * @param workflowid + * @param requestid + * @return + */ + public List> queryRequestList(String billtable,String cjrbm,String pbyf,String workflowid,String requestid){ + + List> requestList = new ArrayList>(); + try{ + String sql =" select t.id,r.requestid,r.requestname,r.currentnodetype " + + " from "+billtable+" t " + + " inner join workflow_requestbase r on r.requestid = t.requestid " + + " where t.pbyf ='"+pbyf+"' " + + " and t.cjrbm ='"+cjrbm+"' " + + " and r.currentnodetype in(1,2,3) " + + " and r.workflowid = "+workflowid + + " and t.requestid <> "+requestid; + requestList = CommonUtil.queryListBySql(sql); + }catch (Exception e){ + + } + return requestList; + } + + + private KQShiftScheduleService getService(User user) { + return (KQShiftScheduleService) ServiceUtil.getService(KQShiftScheduleServiceImpl.class, user); + } + + + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } + + + +} diff --git a/浙文眼镜/src/weaver/interfaces/zw/workflow/action/WorkflowToSchedulingAddAction.java b/浙文眼镜/src/weaver/interfaces/zw/workflow/action/WorkflowToSchedulingAddAction.java new file mode 100755 index 0000000..de76af9 --- /dev/null +++ b/浙文眼镜/src/weaver/interfaces/zw/workflow/action/WorkflowToSchedulingAddAction.java @@ -0,0 +1,318 @@ +package weaver.interfaces.zw.workflow.action; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.biz.KQGroupBiz; +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.biz.KQGroupMemberComInfo; +import com.engine.kq.service.KQShiftScheduleService; +import com.engine.kq.service.impl.KQShiftScheduleServiceImpl; +import com.weaver.general.BaseBean; +import org.apache.commons.lang3.StringUtils; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.interfaces.workflow.action.Action; +import weaver.interfaces.zw.utils.CommonUtil; +import weaver.soa.workflow.request.RequestInfo; + +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author shil + * @date 2024/8/1 + * 流程生成排班 + */ +public class WorkflowToSchedulingAddAction implements Action { + + @Override + public String execute(RequestInfo requestInfo) { + BaseBean bb = new BaseBean(); + String requestid = requestInfo.getRequestid(); + String workflowid = requestInfo.getWorkflowid(); + String billtable = requestInfo.getRequestManager().getBillTableName(); + User user = requestInfo.getRequestManager().getUser(); + RecordSet rs = new RecordSet(); + bb.writeLog("----WorkflowToSchedulingAddAction------"); + DepartmentComInfo departmentComInfo = null; + ResourceComInfo resourceComInfo = null; + try { + departmentComInfo = new DepartmentComInfo(); + resourceComInfo = new ResourceComInfo(); + String mainid = "" ; + String cjr = "" ; + String pbyf = "" ; + String cjrbm = "" ; + String pbmd = ""; + String sql = " select id,cjr,pbyf,cjrbm,pbmd from "+billtable+" where requestid="+requestid; + rs.execute(sql); + if(rs.next()){ + mainid = Util.null2String(rs.getString("id")); + cjr = Util.null2String(rs.getString("cjr")); + pbyf = Util.null2String(rs.getString("pbyf")); + cjrbm = Util.null2String(rs.getString("cjrbm")); + pbmd = Util.null2String(rs.getString("pbmd")); + } + + List> requestList = queryRequestList(billtable,cjrbm,pbyf,workflowid,requestid); + if(!requestList.isEmpty() && requestList.size() >0){ + String requestname = requestList.get(0).get("requestname"); + String lcid = requestList.get(0).get("requestid"); + String cjrbmmc = departmentComInfo.getDepartmentname(cjrbm); + String currentnodetype = requestList.get(0).get("currentnodetype"); + String requesttypename = ""; + if ("1".equals(currentnodetype) || "2".equals(currentnodetype)) { + requesttypename = "正在审批"; + } else if ("3".equals(currentnodetype)) { + requesttypename = "已归档"; + } + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent(cjrbmmc+"已存在"+pbyf+"的排班申请"+requesttypename+"流程:<"+requestname+">,无法提交当前流程"); + return Action.FAILURE_AND_CONTINUE; + }else{ + List> scheduleList = queryScheduleData(billtable,mainid,pbyf); + if(!scheduleList.isEmpty() && scheduleList.size()>0){ + String lastnames = ""; + for(int i=0;i scheduleMap = scheduleList.get(i); + if(i<2){ + String resourceid = scheduleMap.get("resourceid"); + if(StringUtils.isNotBlank(resourceid)){ + String lastname = resourceComInfo.getLastname(resourceid); + lastnames += StringUtils.isBlank(lastnames) ? lastname : ","+lastname; + } + } + } + + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent(lastnames+"等人已存在"+pbyf+"的排班,无法提交排班流程"); + return Action.FAILURE_AND_CONTINUE; + }else{ + int daysInMonth = 0; + if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7){ + LocalDate date = LocalDate.parse(pbyf + "-01"); // 获取当前日期 + daysInMonth = date.lengthOfMonth(); // 获取本月有多少天 + } + bb.writeLog("----mainid------"+mainid); + if(StringUtils.isNotBlank(mainid)) + { + if(StringUtils.isNotBlank(pbmd)){ + if(pbmd.contains(",")){ + pbmd = pbmd.split(",")[0]; + } + }else{ + pbmd = cjr; + } + String groupid = getUserActiveGroupId(pbmd); + bb.writeLog("groupid:"+groupid); + + JSONObject datasJSON = new JSONObject(); + JSONArray datasArray = new JSONArray(); + sql = " select * from "+billtable+"_dt1 where mainid="+mainid; + List> dt1List = CommonUtil.queryListBySql(sql); + for(int i=0;i dt1Map = dt1List.get(i); + String resourceid = Util.null2String(dt1Map.get("yg")); + if(StringUtils.isNotBlank(resourceid)){ + JSONArray kqdata = new JSONArray(); + for(int k=1;k<=daysInMonth;k++){ + String bc = Util.null2String(dt1Map.get("bc"+k)); + JSONObject bcJSON = new JSONObject(); + bcJSON.put("id",""); + bcJSON.put("serialid",bc); + if(k<10){ + bcJSON.put("date",pbyf+"-0"+k); + }else{ + bcJSON.put("date",pbyf+"-"+k); + } + kqdata.add(bcJSON); + } + + JSONObject dataJSON = new JSONObject(); + dataJSON.put("resourceid",resourceid); + dataJSON.put("kqdata",kqdata); + datasArray.add(dataJSON); + } + } + + datasJSON.put("datas",datasArray); + datasJSON.put("groupId", groupid); + + bb.writeLog("data:"+datasJSON.toJSONString()); + + Map params = new HashMap(); + params.put("data",datasJSON.toJSONString()); + Map apidatas = getService(user).save(params, user); + + bb.writeLog("apidatas:"+ JSONObject.toJSONString(apidatas)); + + if(apidatas.containsKey("status")){ + String status = Util.null2String(apidatas.get("status")); + if(!"1".equals(status)){ + String message = Util.null2String(apidatas.get("message")); + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent(message); + return Action.FAILURE_AND_CONTINUE; + } + }else{ + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent("排班保存异常"); + return Action.FAILURE_AND_CONTINUE; + } + }else{ + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent("获取流程数据异常"); + return Action.FAILURE_AND_CONTINUE; + } + } + } + }catch (Exception e){ + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent("流程提交接口异常"); + return Action.FAILURE_AND_CONTINUE; + } + + return Action.SUCCESS; + } + + /** + * + * @param billtable + * @param mainid + * @return + */ + public List> queryScheduleData(String billtable,String mainid,String pbyf){ + + List> scheduleList = new ArrayList>(); + try { + String userids = "" ; + String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid; + List> dt1List = CommonUtil.queryListBySql(sql); + for(int i=0;i dt1Map = dt1List.get(i); + String resourceid = Util.null2String(dt1Map.get("yg")); + if(StringUtils.isNotBlank(resourceid)){ + userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ; + } + } + if(StringUtils.isNotBlank(userids)){ + sql = " select kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and (isdelete is null or isdelete = 0)"; + scheduleList = CommonUtil.queryListBySql(sql); + } + + }catch (Exception e){ + + } + return scheduleList; + } + + /*** + * + * @param billtable + * @param cjrbm + * @param pbyf + * @param workflowid + * @param requestid + * @return + */ + public List> queryRequestList(String billtable,String cjrbm,String pbyf,String workflowid,String requestid){ + + List> requestList = new ArrayList>(); + try{ + String sql =" select t.id,r.requestid,r.requestname,r.currentnodetype " + + " from "+billtable+" t " + + " inner join workflow_requestbase r on r.requestid = t.requestid " + + " where t.pbyf ='"+pbyf+"' " + + " and t.cjrbm ='"+cjrbm+"' " + + " and r.currentnodetype in(1,2,3) " + + " and r.workflowid = "+workflowid + + " and t.requestid <> "+requestid; + requestList = CommonUtil.queryListBySql(sql); + }catch (Exception e){ + + } + return requestList; + } + + + private KQShiftScheduleService getService(User user) { + return (KQShiftScheduleService) ServiceUtil.getService(KQShiftScheduleServiceImpl.class, user); + } + + + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } + + + +} diff --git a/浙文眼镜/src/weaver/interfaces/zw/workflow/action/WorkflowToSchedulingEditAction.java b/浙文眼镜/src/weaver/interfaces/zw/workflow/action/WorkflowToSchedulingEditAction.java new file mode 100755 index 0000000..5efc29b --- /dev/null +++ b/浙文眼镜/src/weaver/interfaces/zw/workflow/action/WorkflowToSchedulingEditAction.java @@ -0,0 +1,334 @@ +package weaver.interfaces.zw.workflow.action; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.biz.KQGroupBiz; +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.biz.KQGroupMemberComInfo; +import com.engine.kq.service.KQShiftScheduleService; +import com.engine.kq.service.impl.KQShiftScheduleServiceImpl; +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.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.interfaces.workflow.action.Action; +import weaver.interfaces.zw.utils.CommonUtil; +import weaver.soa.workflow.request.RequestInfo; + +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author shil + * @date 2024/8/1 + * 流程生成排班 + */ +public class WorkflowToSchedulingEditAction implements Action { + + @Override + public String execute(RequestInfo requestInfo) { + BaseBean bb = new BaseBean(); + String requestid = requestInfo.getRequestid(); + String workflowid = requestInfo.getWorkflowid(); + String billtable = requestInfo.getRequestManager().getBillTableName(); + User user = requestInfo.getRequestManager().getUser(); + RecordSet rs = new RecordSet(); + bb.writeLog("----WorkflowToSchedulingEditAction------"); + DepartmentComInfo departmentComInfo = null; + ResourceComInfo resourceComInfo = null; + try { + departmentComInfo = new DepartmentComInfo(); + resourceComInfo = new ResourceComInfo(); + String mainid = "" ; + String cjr = "" ; + String pbyf = "" ; + String cjrbm = "" ; + String pbmd = ""; + String sql = " select id,cjr,pbyf,cjrbm,pbmd from "+billtable+" where requestid="+requestid; + rs.execute(sql); + if(rs.next()){ + mainid = Util.null2String(rs.getString("id")); + cjr = Util.null2String(rs.getString("cjr")); + pbyf = Util.null2String(rs.getString("pbyf")); + cjrbm = Util.null2String(rs.getString("cjrbm")); + pbmd = Util.null2String(rs.getString("pbmd")); + } + + + int daysInMonth = 0; + if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7){ + LocalDate date = LocalDate.parse(pbyf + "-01"); // 获取当前日期 + daysInMonth = date.lengthOfMonth(); // 获取本月有多少天 + } + bb.writeLog("----mainid------"+mainid); + if(StringUtils.isNotBlank(mainid)) + { + if(StringUtils.isNotBlank(pbmd)){ + if(pbmd.contains(",")){ + pbmd = pbmd.split(",")[0]; + } + }else{ + pbmd = cjr; + } + bb.writeLog("pbmd:"+pbmd); + String groupid = getUserActiveGroupId(pbmd); + bb.writeLog("groupid:"+groupid); + Map scheduleMap = queryScheduleDataMap(billtable,mainid,pbyf,groupid); + JSONObject datasJSON = new JSONObject(); + JSONArray datasArray = new JSONArray(); + sql = " select * from "+billtable+"_dt1 where mainid="+mainid; + List> dt1List = CommonUtil.queryListBySql(sql); + for(int i=0;i dt1Map = dt1List.get(i); + String resourceid = Util.null2String(dt1Map.get("yg")); + if(StringUtils.isNotBlank(resourceid)){ + JSONArray kqdata = new JSONArray(); + for(int k=1;k<=daysInMonth;k++){ + String serialid = Util.null2String(dt1Map.get("bc"+k)); + JSONObject bcJSON = new JSONObject(); + + String id = ""; + String kqdate = ""; + if(k<10){ + kqdate = pbyf+"-0"+k; + }else{ + kqdate = pbyf+"-"+k; + } + if(scheduleMap.containsKey(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate)){ + id = scheduleMap.get(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate); + } + bb.writeLog("id:"+id); + bcJSON.put("id",id); + bcJSON.put("serialid",serialid); + bcJSON.put("date",kqdate); + kqdata.add(bcJSON); + } + + JSONObject dataJSON = new JSONObject(); + dataJSON.put("resourceid",resourceid); + dataJSON.put("kqdata",kqdata); + datasArray.add(dataJSON); + } + } + + datasJSON.put("datas",datasArray); + datasJSON.put("groupId", groupid); + + bb.writeLog("data:"+datasJSON.toJSONString()); + + Map params = new HashMap(); + params.put("data",datasJSON.toJSONString()); + Map apidatas = getService(user).save(params, user); + + bb.writeLog("apidatas:"+ JSONObject.toJSONString(apidatas)); + + if(apidatas.containsKey("status")){ + String status = Util.null2String(apidatas.get("status")); + if(!"1".equals(status)){ + String message = Util.null2String(apidatas.get("message")); + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent(message); + return Action.FAILURE_AND_CONTINUE; + } + }else{ + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent("排班保存异常"); + return Action.FAILURE_AND_CONTINUE; + } + }else{ + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent("获取流程数据异常"); + return Action.FAILURE_AND_CONTINUE; + } + }catch (Exception e){ + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent("流程提交接口异常"); + return Action.FAILURE_AND_CONTINUE; + } + + return Action.SUCCESS; + } + + /** + * + * @param billtable + * @param mainid + * @return + */ + public List> queryScheduleData(String billtable,String mainid,String pbyf){ + + List> scheduleList = new ArrayList>(); + try { + String userids = "" ; + String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid; + List> dt1List = CommonUtil.queryListBySql(sql); + for(int i=0;i dt1Map = dt1List.get(i); + String resourceid = Util.null2String(dt1Map.get("yg")); + userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ; + } + if(StringUtils.isNotBlank(userids)){ + sql = " select id,kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and (isdelete is null or isdelete = 0)"; + scheduleList = CommonUtil.queryListBySql(sql); + } + + }catch (Exception e){ + + } + return scheduleList; + } + + + public Map queryScheduleDataMap(String billtable,String mainid,String pbyf,String activeGroupid){ + Map dataMap = new HashMap(); + List> scheduleList = new ArrayList>(); + BaseBean bb = new BaseBean(); + try { + String userids = "" ; + String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid; + List> dt1List = CommonUtil.queryListBySql(sql); + for(int i=0;i dt1Map = dt1List.get(i); + String resourceid = Util.null2String(dt1Map.get("yg")); + if(StringUtils.isNotBlank(resourceid)){ + userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ; + } + } + if(StringUtils.isNotBlank(userids)){ + sql = " select id,kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and isdelete = 0 and groupid = "+activeGroupid; + bb.writeLog("sql:"+sql); + + scheduleList = CommonUtil.queryListBySql(sql); + for(int i=0;i scheduleMap = scheduleList.get(i); + String kqdate = scheduleMap.get("kqdate"); + String resourceid = scheduleMap.get("resourceid"); + String serialid = scheduleMap.get("serialid"); + String groupid = scheduleMap.get("groupid"); + String id = scheduleMap.get("id"); + + bb.writeLog("kqdate:"+kqdate); + bb.writeLog("resourceid:"+resourceid); + bb.writeLog("serialid:"+serialid); + bb.writeLog("groupid:"+groupid); + bb.writeLog("id:"+id); + + dataMap.put(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate,id); + } + } + + }catch (Exception e){ + + } + return dataMap; + } + + + /*** + * + * @param billtable + * @param cjrbm + * @param pbyf + * @param workflowid + * @param requestid + * @return + */ + public List> queryRequestList(String billtable,String cjrbm,String pbyf,String workflowid,String requestid){ + + List> requestList = new ArrayList>(); + try{ + String sql =" select t.id,r.requestid,r.requestname,r.currentnodetype " + + " from "+billtable+" t " + + " inner join workflow_requestbase r on r.requestid = t.requestid " + + " where t.pbyf ='"+pbyf+"' " + + " and t.cjrbm ='"+cjrbm+"' " + + " and r.currentnodetype in(1,2,3) " + + " and r.workflowid = "+workflowid + + " and t.requestid <> "+requestid; + requestList = CommonUtil.queryListBySql(sql); + }catch (Exception e){ + + } + return requestList; + } + + + private KQShiftScheduleService getService(User user) { + return (KQShiftScheduleService) ServiceUtil.getService(KQShiftScheduleServiceImpl.class, user); + } + + + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } +} diff --git a/浙文眼镜/src/weaver/interfaces/zw/workflow/action/WorkflowToSchedulingUpdateAction.java b/浙文眼镜/src/weaver/interfaces/zw/workflow/action/WorkflowToSchedulingUpdateAction.java new file mode 100755 index 0000000..4a03d91 --- /dev/null +++ b/浙文眼镜/src/weaver/interfaces/zw/workflow/action/WorkflowToSchedulingUpdateAction.java @@ -0,0 +1,350 @@ +package weaver.interfaces.zw.workflow.action; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.biz.KQGroupBiz; +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.biz.KQGroupMemberComInfo; +import com.engine.kq.service.KQShiftScheduleService; +import com.engine.kq.service.impl.KQShiftScheduleServiceImpl; +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.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.interfaces.workflow.action.Action; +import weaver.interfaces.zw.utils.CommonUtil; +import weaver.soa.workflow.request.RequestInfo; + +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author shil + * @date 2024/8/1 + * 流程生成排班 + */ +public class WorkflowToSchedulingUpdateAction implements Action { + + @Override + public String execute(RequestInfo requestInfo) { + BaseBean bb = new BaseBean(); + String requestid = requestInfo.getRequestid(); + String workflowid = requestInfo.getWorkflowid(); + String billtable = requestInfo.getRequestManager().getBillTableName(); + User user = requestInfo.getRequestManager().getUser(); + RecordSet rs = new RecordSet(); + bb.writeLog("----WorkflowToSchedulingUpdateAction------"); + DepartmentComInfo departmentComInfo = null; + ResourceComInfo resourceComInfo = null; + try { + departmentComInfo = new DepartmentComInfo(); + resourceComInfo = new ResourceComInfo(); + String mainid = "" ; + String cjr = "" ; + String pbyf = "" ; + String cjrbm = "" ; + String pbmd = ""; + String sql = " select id,cjr,pbyf,cjrbm,pbmd from "+billtable+" where requestid="+requestid; + rs.execute(sql); + if(rs.next()){ + mainid = Util.null2String(rs.getString("id")); + cjr = Util.null2String(rs.getString("cjr")); + pbyf = Util.null2String(rs.getString("pbyf")); + cjrbm = Util.null2String(rs.getString("cjrbm")); + pbmd = Util.null2String(rs.getString("pbmd")); + } + + List> requestList = queryRequestList(billtable,cjrbm,pbyf,workflowid,requestid); + if(!requestList.isEmpty() && requestList.size() >0){ + String requestname = requestList.get(0).get("requestname"); + String lcid = requestList.get(0).get("requestid"); + String cjrbmmc = departmentComInfo.getDepartmentname(cjrbm); + String currentnodetype = requestList.get(0).get("currentnodetype"); + String requesttypename = ""; + if ("1".equals(currentnodetype) || "2".equals(currentnodetype)) { + requesttypename = "正在审批"; + } else if ("3".equals(currentnodetype)) { + requesttypename = "已归档"; + } + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent(cjrbmmc+"已存在"+pbyf+"的排班申请"+requesttypename+"流程:<"+requestname+">,无法提交当前流程"); + return Action.FAILURE_AND_CONTINUE; + }else{ + + Map scheduleMap = queryScheduleDataMap(billtable,mainid,pbyf); + int daysInMonth = 0; + if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7){ + LocalDate date = LocalDate.parse(pbyf + "-01"); // 获取当前日期 + daysInMonth = date.lengthOfMonth(); // 获取本月有多少天 + } + bb.writeLog("----mainid------"+mainid); + if(StringUtils.isNotBlank(mainid)) + { + if(StringUtils.isNotBlank(pbmd)){ + if(pbmd.contains(",")){ + pbmd = pbmd.split(",")[0]; + } + }else{ + pbmd = cjr; + } + String groupid = getUserActiveGroupId(pbmd); + bb.writeLog("groupid:"+groupid); + + JSONObject datasJSON = new JSONObject(); + JSONArray datasArray = new JSONArray(); + sql = " select * from "+billtable+"_dt1 where mainid="+mainid; + List> dt1List = CommonUtil.queryListBySql(sql); + for(int i=0;i dt1Map = dt1List.get(i); + String resourceid = Util.null2String(dt1Map.get("yg")); + if(StringUtils.isNotBlank(resourceid)){ + JSONArray kqdata = new JSONArray(); + for(int k=1;k<=daysInMonth;k++){ + String serialid = Util.null2String(dt1Map.get("bc"+k)); + JSONObject bcJSON = new JSONObject(); + + String id = ""; + String kqdate = ""; + if(k<10){ + kqdate = pbyf+"-0"+k; + }else{ + kqdate = pbyf+"-"+k; + } + if(scheduleMap.containsKey(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate)){ + id = scheduleMap.get(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate); + } + bcJSON.put("id",id); + bcJSON.put("serialid",serialid); + bcJSON.put("date",kqdate); + kqdata.add(bcJSON); + } + + JSONObject dataJSON = new JSONObject(); + dataJSON.put("resourceid",resourceid); + dataJSON.put("kqdata",kqdata); + datasArray.add(dataJSON); + } + } + + datasJSON.put("datas",datasArray); + datasJSON.put("groupId", groupid); + + bb.writeLog("data:"+datasJSON.toJSONString()); + + Map params = new HashMap(); + params.put("data",datasJSON.toJSONString()); + Map apidatas = getService(user).save(params, user); + + bb.writeLog("apidatas:"+ JSONObject.toJSONString(apidatas)); + + if(apidatas.containsKey("status")){ + String status = Util.null2String(apidatas.get("status")); + if(!"1".equals(status)){ + String message = Util.null2String(apidatas.get("message")); + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent(message); + return Action.FAILURE_AND_CONTINUE; + } + }else{ + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent("排班保存异常"); + return Action.FAILURE_AND_CONTINUE; + } + }else{ + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent("获取流程数据异常"); + return Action.FAILURE_AND_CONTINUE; + } + } + }catch (Exception e){ + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent("流程提交接口异常"); + return Action.FAILURE_AND_CONTINUE; + } + + return Action.SUCCESS; + } + + /** + * + * @param billtable + * @param mainid + * @return + */ + public List> queryScheduleData(String billtable,String mainid,String pbyf){ + + List> scheduleList = new ArrayList>(); + try { + String userids = "" ; + String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid; + List> dt1List = CommonUtil.queryListBySql(sql); + for(int i=0;i dt1Map = dt1List.get(i); + String resourceid = Util.null2String(dt1Map.get("yg")); + userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ; + } + if(StringUtils.isNotBlank(userids)){ + sql = " select id,kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and (isdelete is null or isdelete = 0)"; + scheduleList = CommonUtil.queryListBySql(sql); + } + + }catch (Exception e){ + + } + return scheduleList; + } + + + public Map queryScheduleDataMap(String billtable,String mainid,String pbyf){ + Map dataMap = new HashMap(); + List> scheduleList = new ArrayList>(); + BaseBean bb = new BaseBean(); + try { + String userids = "" ; + String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid; + List> dt1List = CommonUtil.queryListBySql(sql); + for(int i=0;i dt1Map = dt1List.get(i); + String resourceid = Util.null2String(dt1Map.get("yg")); + userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ; + } + if(StringUtils.isNotBlank(userids)){ + sql = " select id,kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and (isdelete is null or isdelete = 0)"; + + + bb.writeLog("sql:"+sql); + + scheduleList = CommonUtil.queryListBySql(sql); + for(int i=0;i scheduleMap = scheduleList.get(i); + String kqdate = scheduleMap.get("kqdate"); + String resourceid = scheduleMap.get("resourceid"); + String serialid = scheduleMap.get("serialid"); + String groupid = scheduleMap.get("groupid"); + String id = scheduleMap.get("id"); + + bb.writeLog("kqdate:"+kqdate); + bb.writeLog("resourceid:"+resourceid); + bb.writeLog("serialid:"+serialid); + bb.writeLog("groupid:"+groupid); + bb.writeLog("id:"+id); + + dataMap.put(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate,id); + } + } + + }catch (Exception e){ + + } + return dataMap; + } + + + /*** + * + * @param billtable + * @param cjrbm + * @param pbyf + * @param workflowid + * @param requestid + * @return + */ + public List> queryRequestList(String billtable,String cjrbm,String pbyf,String workflowid,String requestid){ + + List> requestList = new ArrayList>(); + try{ + String sql =" select t.id,r.requestid,r.requestname,r.currentnodetype " + + " from "+billtable+" t " + + " inner join workflow_requestbase r on r.requestid = t.requestid " + + " where t.pbyf ='"+pbyf+"' " + + " and t.cjrbm ='"+cjrbm+"' " + + " and r.currentnodetype in(1,2,3) " + + " and r.workflowid = "+workflowid + + " and t.requestid <> "+requestid; + requestList = CommonUtil.queryListBySql(sql); + }catch (Exception e){ + + } + return requestList; + } + + + private KQShiftScheduleService getService(User user) { + return (KQShiftScheduleService) ServiceUtil.getService(KQShiftScheduleServiceImpl.class, user); + } + + + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } +} diff --git a/浙文眼镜/src/weaver/interfaces/zw/workflow/xygrzlc/NewEmployee2HrmResoyeceAction.java b/浙文眼镜/src/weaver/interfaces/zw/workflow/xygrzlc/NewEmployee2HrmResoyeceAction.java new file mode 100755 index 0000000..a6d384a --- /dev/null +++ b/浙文眼镜/src/weaver/interfaces/zw/workflow/xygrzlc/NewEmployee2HrmResoyeceAction.java @@ -0,0 +1,350 @@ +package weaver.interfaces.zw.workflow.xygrzlc; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.util.ServiceUtil; +import com.engine.kq.biz.KQGroupBiz; +import com.engine.kq.biz.KQGroupComInfo; +import com.engine.kq.biz.KQGroupMemberComInfo; +import com.engine.kq.service.KQShiftScheduleService; +import com.engine.kq.service.impl.KQShiftScheduleServiceImpl; +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.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.interfaces.workflow.action.Action; +import weaver.interfaces.zw.utils.CommonUtil; +import weaver.soa.workflow.request.RequestInfo; + +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author shil + * @date 2024/8/1 + * 流程生成排班 + */ +public class NewEmployee2HrmResoyeceAction implements Action { + + @Override + public String execute(RequestInfo requestInfo) { + BaseBean bb = new BaseBean(); + String requestid = requestInfo.getRequestid(); + String workflowid = requestInfo.getWorkflowid(); + String billtable = requestInfo.getRequestManager().getBillTableName(); + User user = requestInfo.getRequestManager().getUser(); + RecordSet rs = new RecordSet(); + bb.writeLog("----WorkflowToSchedulingAction------"); + DepartmentComInfo departmentComInfo = null; + ResourceComInfo resourceComInfo = null; + try { + departmentComInfo = new DepartmentComInfo(); + resourceComInfo = new ResourceComInfo(); + String mainid = "" ; + String cjr = "" ; + String pbyf = "" ; + String cjrbm = "" ; + String pbmd = ""; + String sql = " select id,cjr,pbyf,cjrbm,pbmd from "+billtable+" where requestid="+requestid; + rs.execute(sql); + if(rs.next()){ + mainid = Util.null2String(rs.getString("id")); + cjr = Util.null2String(rs.getString("cjr")); + pbyf = Util.null2String(rs.getString("pbyf")); + cjrbm = Util.null2String(rs.getString("cjrbm")); + pbmd = Util.null2String(rs.getString("pbmd")); + } + + List> requestList = queryRequestList(billtable,cjrbm,pbyf,workflowid,requestid); + if(!requestList.isEmpty() && requestList.size() >0){ + String requestname = requestList.get(0).get("requestname"); + String lcid = requestList.get(0).get("requestid"); + String cjrbmmc = departmentComInfo.getDepartmentname(cjrbm); + String currentnodetype = requestList.get(0).get("currentnodetype"); + String requesttypename = ""; + if ("1".equals(currentnodetype) || "2".equals(currentnodetype)) { + requesttypename = "正在审批"; + } else if ("3".equals(currentnodetype)) { + requesttypename = "已归档"; + } + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent(cjrbmmc+"已存在"+pbyf+"的排班申请"+requesttypename+"流程:<"+requestname+">,无法提交当前流程"); + return Action.FAILURE_AND_CONTINUE; + }else{ + + Map scheduleMap = queryScheduleDataMap(billtable,mainid,pbyf); + int daysInMonth = 0; + if(StringUtils.isNotBlank(pbyf) && pbyf.length() == 7){ + LocalDate date = LocalDate.parse(pbyf + "-01"); // 获取当前日期 + daysInMonth = date.lengthOfMonth(); // 获取本月有多少天 + } + bb.writeLog("----mainid------"+mainid); + if(StringUtils.isNotBlank(mainid)) + { + if(StringUtils.isNotBlank(pbmd)){ + if(pbmd.contains(",")){ + pbmd = pbmd.split(",")[0]; + } + }else{ + pbmd = cjr; + } + String groupid = getUserActiveGroupId(pbmd); + bb.writeLog("groupid:"+groupid); + + JSONObject datasJSON = new JSONObject(); + JSONArray datasArray = new JSONArray(); + sql = " select * from "+billtable+"_dt1 where mainid="+mainid; + List> dt1List = CommonUtil.queryListBySql(sql); + for(int i=0;i dt1Map = dt1List.get(i); + String resourceid = Util.null2String(dt1Map.get("yg")); + if(StringUtils.isNotBlank(resourceid)){ + JSONArray kqdata = new JSONArray(); + for(int k=1;k<=daysInMonth;k++){ + String serialid = Util.null2String(dt1Map.get("bc"+k)); + JSONObject bcJSON = new JSONObject(); + + String id = ""; + String kqdate = ""; + if(k<10){ + kqdate = pbyf+"-0"+k; + }else{ + kqdate = pbyf+"-"+k; + } + if(scheduleMap.containsKey(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate)){ + id = scheduleMap.get(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate); + } + bcJSON.put("id",id); + bcJSON.put("serialid",serialid); + bcJSON.put("date",kqdate); + kqdata.add(bcJSON); + } + + JSONObject dataJSON = new JSONObject(); + dataJSON.put("resourceid",resourceid); + dataJSON.put("kqdata",kqdata); + datasArray.add(dataJSON); + } + } + + datasJSON.put("datas",datasArray); + datasJSON.put("groupId", groupid); + + bb.writeLog("data:"+datasJSON.toJSONString()); + + Map params = new HashMap(); + params.put("data",datasJSON.toJSONString()); + Map apidatas = getService(user).save(params, user); + + bb.writeLog("apidatas:"+ JSONObject.toJSONString(apidatas)); + + if(apidatas.containsKey("status")){ + String status = Util.null2String(apidatas.get("status")); + if(!"1".equals(status)){ + String message = Util.null2String(apidatas.get("message")); + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent(message); + return Action.FAILURE_AND_CONTINUE; + } + }else{ + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent("排班保存异常"); + return Action.FAILURE_AND_CONTINUE; + } + }else{ + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent("获取流程数据异常"); + return Action.FAILURE_AND_CONTINUE; + } + } + }catch (Exception e){ + requestInfo.getRequestManager().setMessageid("1000"); + requestInfo.getRequestManager().setMessagecontent("流程提交接口异常"); + return Action.FAILURE_AND_CONTINUE; + } + + return Action.SUCCESS; + } + + /** + * + * @param billtable + * @param mainid + * @return + */ + public List> queryScheduleData(String billtable,String mainid,String pbyf){ + + List> scheduleList = new ArrayList>(); + try { + String userids = "" ; + String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid; + List> dt1List = CommonUtil.queryListBySql(sql); + for(int i=0;i dt1Map = dt1List.get(i); + String resourceid = Util.null2String(dt1Map.get("yg")); + userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ; + } + if(StringUtils.isNotBlank(userids)){ + sql = " select id,kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and (isdelete is null or isdelete = 0)"; + scheduleList = CommonUtil.queryListBySql(sql); + } + + }catch (Exception e){ + + } + return scheduleList; + } + + + public Map queryScheduleDataMap(String billtable,String mainid,String pbyf){ + Map dataMap = new HashMap(); + List> scheduleList = new ArrayList>(); + BaseBean bb = new BaseBean(); + try { + String userids = "" ; + String sql = " select yg from "+billtable+"_dt1 where mainid="+mainid; + List> dt1List = CommonUtil.queryListBySql(sql); + for(int i=0;i dt1Map = dt1List.get(i); + String resourceid = Util.null2String(dt1Map.get("yg")); + userids += StringUtils.isBlank(userids) ? resourceid : ","+resourceid ; + } + if(StringUtils.isNotBlank(userids)){ + sql = " select id,kqdate,resourceid,serialid,groupid from kq_shiftschedule where left(kqdate,7) = '"+pbyf+"' and resourceid in("+userids+") and (isdelete is null or isdelete = 0)"; + + + bb.writeLog("sql:"+sql); + + scheduleList = CommonUtil.queryListBySql(sql); + for(int i=0;i scheduleMap = scheduleList.get(i); + String kqdate = scheduleMap.get("kqdate"); + String resourceid = scheduleMap.get("resourceid"); + String serialid = scheduleMap.get("serialid"); + String groupid = scheduleMap.get("groupid"); + String id = scheduleMap.get("id"); + + bb.writeLog("kqdate:"+kqdate); + bb.writeLog("resourceid:"+resourceid); + bb.writeLog("serialid:"+serialid); + bb.writeLog("groupid:"+groupid); + bb.writeLog("id:"+id); + + dataMap.put(resourceid+"_"+serialid+"_"+groupid+"_"+kqdate,id); + } + } + + }catch (Exception e){ + + } + return dataMap; + } + + + /*** + * + * @param billtable + * @param cjrbm + * @param pbyf + * @param workflowid + * @param requestid + * @return + */ + public List> queryRequestList(String billtable,String cjrbm,String pbyf,String workflowid,String requestid){ + + List> requestList = new ArrayList>(); + try{ + String sql =" select t.id,r.requestid,r.requestname,r.currentnodetype " + + " from "+billtable+" t " + + " inner join workflow_requestbase r on r.requestid = t.requestid " + + " where t.pbyf ='"+pbyf+"' " + + " and t.cjrbm ='"+cjrbm+"' " + + " and r.currentnodetype in(1,2,3) " + + " and r.workflowid = "+workflowid + + " and t.requestid <> "+requestid; + requestList = CommonUtil.queryListBySql(sql); + }catch (Exception e){ + + } + return requestList; + } + + + private KQShiftScheduleService getService(User user) { + return (KQShiftScheduleService) ServiceUtil.getService(KQShiftScheduleServiceImpl.class, user); + } + + + public String getUserActiveGroupId(String userid){ + BaseBean bb = new BaseBean(); + + KQGroupMemberComInfo kqGroupMemberComInfo = null; + KQGroupComInfo kqGroupComInfo = null ; + String activeGroupId = ""; + try{ + kqGroupMemberComInfo = new KQGroupMemberComInfo(); + kqGroupComInfo = new KQGroupComInfo(); + + Map> groupMemberMap = getUserGroup(); + + String activeGroup = ""; + if(groupMemberMap.containsKey(userid)){ + List groupIds = groupMemberMap.get(userid); + bb.writeLog("groupIds:"+groupIds.size()); + + for(String i : groupIds){ + String isDelete = kqGroupComInfo.getIsdelete(i); + if(!"1".equals(isDelete)) { + String currentGroupId = Util.null2String(kqGroupMemberComInfo.getKQGroupId(userid, DateUtil.getCurrentDate())); + if (i.equals(currentGroupId)) { + activeGroupId = i; + } + } + } + } + }catch (Exception e){ + e.printStackTrace(); + bb.writeLog(e); + } + return activeGroupId; + } + + + /*** + * + * @return + */ + public Map> getUserGroup(){ + BaseBean bb = new BaseBean(); + Map> groupMemberMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String viewScope = "3"; + try { + KQGroupBiz kqGroupBiz = new KQGroupBiz(); + Map groupParams = new HashMap(); + if("3".equals(viewScope)){ + groupParams.put("isNoAccount", "1"); + } + rs.executeQuery(kqGroupBiz.getGroupMemberSql(groupParams)); + while (rs.next()) { + String id = rs.getString("resourceid"); + String gid = rs.getString("groupid"); + if (!groupMemberMap.containsKey(id)) + groupMemberMap.put(id, new ArrayList<>()); + groupMemberMap.get(id).add(gid); + } + } catch (Exception e) { + } + return groupMemberMap; + } +}