|
|
@@ -1,20 +1,26 @@
|
|
|
-package com.kingdee.shr.custom.ats.web.handler;
|
|
|
+package handler;
|
|
|
|
|
|
import com.kingdee.bos.BOSException;
|
|
|
import com.kingdee.bos.Context;
|
|
|
import com.kingdee.bos.dao.query.server.PagingHelper;
|
|
|
import com.kingdee.bos.db.TempTablePool;
|
|
|
+import com.kingdee.eas.hr.ats.AtsScheduleShiftResEnum;
|
|
|
import com.kingdee.eas.hr.ats.AtsUtil;
|
|
|
+import com.kingdee.eas.hr.ats.common.AtsTempTableUtil;
|
|
|
import com.kingdee.eas.hr.ats.util.AtsBaseUtils;
|
|
|
-import com.kingdee.eas.hr.ats.util.AtsDateUtils;
|
|
|
-import com.kingdee.eas.hr.ats.util.common.AtsCommonUtile;
|
|
|
+import com.kingdee.eas.hr.ats.util.AtsServerUtils;
|
|
|
import com.kingdee.eas.hr.ats.util.common.MLUtile;
|
|
|
+import com.kingdee.eas.hr.ats.vo.common.RangeDate;
|
|
|
+import com.kingdee.eas.hr.ats.vo.common.RangeMap;
|
|
|
import com.kingdee.eas.util.app.DbUtil;
|
|
|
import com.kingdee.jdbc.rowset.IRowSet;
|
|
|
+import com.kingdee.shr.ats.web.dynamic.util.AttendanceCalFilterUtil;
|
|
|
+import com.kingdee.shr.ats.web.filter.AtsItemsOfFastFilter;
|
|
|
import com.kingdee.shr.ats.web.handler.ScheduleShiftListHandler;
|
|
|
-import com.kingdee.shr.ats.web.util.WorkCalendarItemHelper;
|
|
|
+import com.kingdee.shr.ats.web.util.AttenceFilterUtil;
|
|
|
import com.kingdee.shr.base.syssetting.context.SHRContext;
|
|
|
import com.kingdee.shr.base.syssetting.exception.SHRWebException;
|
|
|
+import com.kingdee.shr.base.syssetting.web.json.JSONUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.log4j.Logger;
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
@@ -22,122 +28,382 @@ import org.springframework.ui.ModelMap;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.sql.SQLException;
|
|
|
+import java.text.DateFormat;
|
|
|
import java.text.MessageFormat;
|
|
|
import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @author 青梧
|
|
|
* @version 1.0
|
|
|
- * @description: TODO
|
|
|
+ * @description: 排班排序
|
|
|
* @date 2025/7/31 9:59
|
|
|
*/
|
|
|
public class ScheduleShiftListHandlerEx extends ScheduleShiftListHandler {
|
|
|
+ private final long oneDayTime = 86400000L;
|
|
|
private Context ctx = SHRContext.getInstance().getContext();
|
|
|
private int totalCount = 0;
|
|
|
private static Logger logger = Logger.getLogger(ScheduleShiftListHandlerEx.class);
|
|
|
|
|
|
- public ScheduleShiftListHandlerEx() {
|
|
|
- logger.error("ScheduleShiftListHandlerEx--init--");
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void getPersonShiftAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws BOSException, SHRWebException, SQLException, ParseException {
|
|
|
- logger.error("getPersonShiftAction--statrt--");
|
|
|
- super.getPersonShiftAction(request, response, modelMap);
|
|
|
- logger.error("getPersonShiftAction--end--");
|
|
|
- }
|
|
|
+ // public void getPersonShiftAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws BOSException, SHRWebException, SQLException, ParseException {
|
|
|
+ // Map paramsMap = this.getPageParams(request);
|
|
|
+ // int page = (Integer) paramsMap.get("page");
|
|
|
+ // int rows = (Integer) paramsMap.get("rows");
|
|
|
+ // Date beginDate = (Date) paramsMap.get("beginDate");
|
|
|
+ // Date endDate = (Date) paramsMap.get("endDate");
|
|
|
+ // Object[] params = new Object[4];
|
|
|
+ // params[0] = new java.sql.Date(beginDate.getTime());
|
|
|
+ // params[1] = new java.sql.Date(endDate.getTime());
|
|
|
+ // params[2] = new java.sql.Date(beginDate.getTime());
|
|
|
+ // params[3] = new java.sql.Date(endDate.getTime());
|
|
|
+ // DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ // String hrOrgSql = this.getCurrentRequestHROrgRangeInSQL(request);
|
|
|
+ // paramsMap.put("hrRangeSQL", hrOrgSql);
|
|
|
+ // String tempTableName = "";
|
|
|
+ // Map<String, String> map = new HashMap();
|
|
|
+ // String sessionId = request.getSession().getId();
|
|
|
+ // map.put("session", sessionId);
|
|
|
+ // String adminOrgUnit = (String) paramsMap.get("adminOrgUnit");
|
|
|
+ // map.put("adminOrgId", adminOrgUnit);
|
|
|
+ // map.put("adminOrgIncludeSub", (String) paramsMap.get("adminOrgIncludeSub"));
|
|
|
+ // map.put("adminRangeSQL", (String) paramsMap.get("adminRangeSQL"));
|
|
|
+ //
|
|
|
+ // try {
|
|
|
+ // tempTableName = AttenceFilterUtil.createTempTableForOrgAuthorityV85(map, this.ctx);
|
|
|
+ // paramsMap.put("adminOrgUnitTempName", tempTableName);
|
|
|
+ // Set<String> timeOriginalSets = new HashSet();
|
|
|
+ // Date tmpDate = (Date) beginDate.clone();
|
|
|
+ //
|
|
|
+ // while (tmpDate.getTime() <= endDate.getTime()) {
|
|
|
+ // timeOriginalSets.add(sdf.format(tmpDate));
|
|
|
+ // tmpDate.setTime(tmpDate.getTime() + 86400000L);
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // Map<String, Object> listMap = this.getPersonShiftListMap(request, paramsMap, rows, page, params, (String) null);
|
|
|
+ // List<Map<String, Object>> rowDataList = this.assembleGridByDate(beginDate, endDate, sdf, listMap, timeOriginalSets);
|
|
|
+ // Map<String, Object> gridDataMap = new LinkedHashMap();
|
|
|
+ // if (this.totalCount % rows == 0) {
|
|
|
+ // gridDataMap.put("total", this.totalCount / rows);
|
|
|
+ // } else {
|
|
|
+ // gridDataMap.put("total", this.totalCount / rows + 1);
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // gridDataMap.put("page", page);
|
|
|
+ // gridDataMap.put("records", this.totalCount);
|
|
|
+ // gridDataMap.put("rows", rowDataList);
|
|
|
+ // JSONUtils.writeJson(response, gridDataMap);
|
|
|
+ // } catch (Exception e) {
|
|
|
+ // e.printStackTrace();
|
|
|
+ // } finally {
|
|
|
+ // AtsTempTableUtil.releaseTable(this.ctx, tempTableName);
|
|
|
+ // AtsTempTableUtil.releaseTable(this.ctx, (String) paramsMap.get("tempPersonTable"));
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // private List<Map<String, Object>> assembleGridByDate(Date beginDate, Date endDate, DateFormat sdf, Map<String, Object> listMap, Set<String> timeOriginalSets) throws BOSException, SQLException, ParseException {
|
|
|
+ // List<Map<String, Object>> rowDataList = new ArrayList();
|
|
|
+ // if (listMap != null && !listMap.isEmpty()) {
|
|
|
+ // String personNumbers = this.getPersonNums(listMap);
|
|
|
+ // Map<String, List<RangeMap<Date, String>>> perWorkDate = this.getPerRangeDateMap(beginDate, endDate, personNumbers);
|
|
|
+ // String noValidFile = MLUtile.getRes(AtsScheduleShiftResEnum.NoValidFile, this.ctx);
|
|
|
+ //
|
|
|
+ // for (Map.Entry<String, Object> entry : listMap.entrySet()) {
|
|
|
+ // String key = (String) entry.getKey();
|
|
|
+ // List<Map> listValue = (List) entry.getValue();
|
|
|
+ // Map<String, Object> dataMap = new HashMap((Map) listValue.get(0));
|
|
|
+ // dataMap.put("key", key);
|
|
|
+ // rowDataList.add(dataMap);
|
|
|
+ // Set<String> timeSets = new HashSet(timeOriginalSets);
|
|
|
+ // List<Map> scheduleData = new ArrayList();
|
|
|
+ // dataMap.put("scheduleData", scheduleData);
|
|
|
+ // List<RangeMap<Date, String>> list = (List) perWorkDate.get(dataMap.get("personNum").toString());
|
|
|
+ //
|
|
|
+ // for (Map map : listValue) {
|
|
|
+ // String attendDate = (String) map.get("attendDate");
|
|
|
+ // if (null != attendDate) {
|
|
|
+ // Map personDateSchedule = new HashMap(4);
|
|
|
+ // personDateSchedule.put("attendDate", attendDate);
|
|
|
+ // personDateSchedule.put("dayType", map.get("dayType"));
|
|
|
+ // personDateSchedule.put("shiftName", map.get("shiftName"));
|
|
|
+ // personDateSchedule.put("expired", false);
|
|
|
+ // timeSets.remove(attendDate);
|
|
|
+ // scheduleData.add(personDateSchedule);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // String[] restDateSet = (String[]) timeSets.toArray(new String[0]);
|
|
|
+ //
|
|
|
+ // for (String attendDate : restDateSet) {
|
|
|
+ // Map personDateSchedule = new HashMap(4);
|
|
|
+ // personDateSchedule.put("attendDate", attendDate);
|
|
|
+ // personDateSchedule.put("dayType", "");
|
|
|
+ // boolean expired = !this.isPersonFileHisEffectDay(sdf.parse(attendDate), list);
|
|
|
+ // personDateSchedule.put("expired", String.valueOf(expired));
|
|
|
+ // personDateSchedule.put("shiftName", expired ? noValidFile : "");
|
|
|
+ // scheduleData.add(personDateSchedule);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // return rowDataList;
|
|
|
+ // } else {
|
|
|
+ // return rowDataList;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // private Map<String, List<RangeMap<Date, String>>> getPerRangeDateMap(Date beginDate, Date endDate, String personNumbers) throws BOSException, SQLException, ParseException {
|
|
|
+ // String personWorkSQL = "select person.FNumber number, his.FEFFDT effdt, his.FLEFFDT leffdt " + "from T_HR_ATS_AttendanceFileHIS his " + "INNER join T_bd_Person person on his.FProposerID = person.Fid " + "where his.FAttendFileState = '1' " + "and person.FNumber in (" + personNumbers + ") " + "and (" + "(his.FLEFFDT >= {ts '" + beginDate + "'} " + "and his.FEFFDT <= {ts '" + endDate + "'}) " + ")";
|
|
|
+ // Map<String, List<RangeMap<Date, String>>> perWorkDate = new HashMap();
|
|
|
+ // IRowSet rowSet = DbUtil.executeQuery(this.ctx, personWorkSQL);
|
|
|
+ //
|
|
|
+ // while (rowSet.next()) {
|
|
|
+ // String number = rowSet.getString("number");
|
|
|
+ // List<RangeMap<Date, String>> list = (List) perWorkDate.get(number);
|
|
|
+ // if (null == list) {
|
|
|
+ // list = new ArrayList();
|
|
|
+ // perWorkDate.put(number, list);
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // RangeMap<Date, String> map = new RangeMap();
|
|
|
+ // list.add(map);
|
|
|
+ // RangeDate rangeDate = new RangeDate(rowSet.getDate("effdt"), rowSet.getDate("leffdt"));
|
|
|
+ // map.put(rangeDate, "@_@");
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // return perWorkDate;
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // private String getPersonNums(Map<String, Object> listMap) {
|
|
|
+ // if (null != listMap && !listMap.isEmpty()) {
|
|
|
+ // Set<String> personSet = new HashSet();
|
|
|
+ //
|
|
|
+ // for (Object entry : listMap.values()) {
|
|
|
+ // List<Map> listValue = (List) entry;
|
|
|
+ // if (null != listValue && !listValue.isEmpty()) {
|
|
|
+ // for (Map map : listValue) {
|
|
|
+ // personSet.add((String) map.get("personNum"));
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // StringBuffer personNumbers = new StringBuffer();
|
|
|
+ //
|
|
|
+ // for (String personNum : personSet) {
|
|
|
+ // if (null != personNum && !"".equals(personNum)) {
|
|
|
+ // personNumbers.append(personNumbers.length() > 0 ? "," : "").append("'").append(personNum).append("'");
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // return personNumbers.toString();
|
|
|
+ // } else {
|
|
|
+ // return "";
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // private boolean isPersonFileHisEffectDay(Date parseDay, List<RangeMap<Date, String>> list) throws ParseException {
|
|
|
+ // if (null != list && !list.isEmpty()) {
|
|
|
+ // for (RangeMap<Date, String> map : list) {
|
|
|
+ // if (map.containKey(parseDay)) {
|
|
|
+ // return true;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // return false;
|
|
|
+ // } else {
|
|
|
+ // return false;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // private Map getPageParams(HttpServletRequest request) throws SHRWebException {
|
|
|
+ // Map map = new HashMap();
|
|
|
+ // int rows = 30;
|
|
|
+ // int page = 1;
|
|
|
+ // Map filterItems = AtsItemsOfFastFilter.generateBizFastFilterInfo(request);
|
|
|
+ // String advancedFilterSql = AtsItemsOfFastFilter.generateBizAdvancedFilterInfo(request);
|
|
|
+ // map.put("advancedFilterItems", advancedFilterSql);
|
|
|
+ // String billId = request.getParameter("billId");
|
|
|
+ // if (request.getParameter("rows") != null || request.getParameter("page") != null) {
|
|
|
+ // rows = Integer.parseInt(request.getParameter("rows"));
|
|
|
+ // page = Integer.parseInt(request.getParameter("page"));
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // Date beginDate = (Date) filterItems.get("beginDate");
|
|
|
+ // Date endDate = (Date) filterItems.get("endDate");
|
|
|
+ // if (beginDate == null || endDate == null) {
|
|
|
+ // String beginDateStr = request.getParameter("beginDate");
|
|
|
+ // String endDateStr = request.getParameter("endDate");
|
|
|
+ // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ //
|
|
|
+ // try {
|
|
|
+ // beginDate = sdf.parse(beginDateStr);
|
|
|
+ // endDate = sdf.parse(endDateStr);
|
|
|
+ // } catch (ParseException e) {
|
|
|
+ // e.printStackTrace();
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // String fastFilterItems = request.getParameter("fastFilterItems");
|
|
|
+ // if (!StringUtils.isEmpty(fastFilterItems)) {
|
|
|
+ // Map fastFilterMap = JSONUtils.convertJsonToObject(this.ctx, request.getParameter("fastFilterItems"));
|
|
|
+ // if (null != fastFilterMap && fastFilterMap.size() > 0) {
|
|
|
+ // for (Object key : fastFilterMap.keySet()) {
|
|
|
+ // if (null != fastFilterMap.get(key) && fastFilterMap.get(key) instanceof Map) {
|
|
|
+ // Map subMap = (Map) fastFilterMap.get(key);
|
|
|
+ // if ("hrOrgUnit".equalsIgnoreCase((String) key)) {
|
|
|
+ // map.put("hrOrgUnit", (String) subMap.get("values"));
|
|
|
+ // } else if ("adminOrgUnit".equalsIgnoreCase((String) key)) {
|
|
|
+ // boolean isIncludeSub = (Boolean) subMap.get("isIncludeSub");
|
|
|
+ // if (isIncludeSub) {
|
|
|
+ // AttendanceCalFilterUtil.putAdminOrgUnitInCludeSub(map, subMap);
|
|
|
+ // } else {
|
|
|
+ // map.put("adminOrgUnit", (String) subMap.get("values"));
|
|
|
+ // }
|
|
|
+ // } else if ("ISDEFAULTMANAGE".equalsIgnoreCase((String) key)) {
|
|
|
+ // map.put("ISDEFAULTMANAGE", (String) subMap.get("values"));
|
|
|
+ // } else if ("attendFile.isAttendance".equals(key)) {
|
|
|
+ // map.put(key, (String) subMap.get("values"));
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // String personNames = request.getParameter("personNames");
|
|
|
+ // if (org.apache.commons.lang.StringUtils.isNotBlank(personNames) && !AtsServerUtils.isValid(personNames)) {
|
|
|
+ // personNames = "";
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // String persons = "";
|
|
|
+ // String personsSql = "";
|
|
|
+ // String personsSqlParam = "";
|
|
|
+ // if (StringUtils.isNotEmpty(personNames)) {
|
|
|
+ // personNames = personNames.trim();
|
|
|
+ //
|
|
|
+ // for (String personName : personNames.split(",")) {
|
|
|
+ // if (StringUtils.isNotEmpty(personName)) {
|
|
|
+ // personName = personName.trim();
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // persons = persons + " or proposer.fname" + MLUtile.getMlFlag(this.ctx) + " like '%" + personName + "%'";
|
|
|
+ // personsSql = personsSql + " or proposer.fname" + MLUtile.getMlFlag(this.ctx) + " like ? ";
|
|
|
+ // personsSqlParam = personsSqlParam + "%" + personName + "%,";
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // if (StringUtils.isNotEmpty(personsSqlParam)) {
|
|
|
+ // personsSqlParam = personsSqlParam.substring(0, personsSqlParam.length() - 1);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // map.put("persons", persons);
|
|
|
+ // map.put("personsSql", personsSql);
|
|
|
+ // map.put("personsSqlParam", personsSqlParam);
|
|
|
+ // String personNumbers = request.getParameter("personNumbers");
|
|
|
+ // String personNumsFilter = "";
|
|
|
+ // String personNumsFilterSql = "";
|
|
|
+ // String personNumsFilterSqlParam = "";
|
|
|
+ // if (StringUtils.isNotEmpty(personNumbers)) {
|
|
|
+ // for (String personNumber : personNumbers.split(",")) {
|
|
|
+ // if (StringUtils.isNotEmpty(personNumber)) {
|
|
|
+ // personNumber = personNumber.trim();
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // personNumsFilter = personNumsFilter + " or proposer.fnumber like '%" + personNumber + "%'";
|
|
|
+ // personNumsFilterSql = personNumsFilterSql + " or proposer.fnumber like ? ";
|
|
|
+ // personNumsFilterSqlParam = personNumsFilterSqlParam + "%" + personNumber + "%,";
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // if (StringUtils.isNotEmpty(personNumsFilterSqlParam)) {
|
|
|
+ // personNumsFilterSqlParam = personNumsFilterSqlParam.substring(0, personNumsFilterSqlParam.length() - 1);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // map.put("personNumsFilter", personNumsFilter);
|
|
|
+ // map.put("personNumsFilterSql", personNumsFilterSql);
|
|
|
+ // map.put("personNumsFilterSqlParam", personNumsFilterSqlParam);
|
|
|
+ // String filterItem = request.getParameter("filterItems");
|
|
|
+ // if (StringUtils.isNotEmpty(filterItem)) {
|
|
|
+ // map.put("filterItems", filterItem);
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // try {
|
|
|
+ // String adminRangeSQL = this.getCurrentRequestAdminOrgRangeSQL(request);
|
|
|
+ // if (StringUtils.isNotEmpty(adminRangeSQL)) {
|
|
|
+ // map.put("adminRangeSQL", adminRangeSQL);
|
|
|
+ // }
|
|
|
+ // } catch (SHRWebException e) {
|
|
|
+ // e.printStackTrace();
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // String sidx = request.getParameter("sidx");
|
|
|
+ // String transverse = request.getParameter("transverse");
|
|
|
+ // if (StringUtils.isEmpty(sidx) && "1".equals(transverse)) {
|
|
|
+ // sidx = "attenddate";
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // if (StringUtils.isEmpty(sidx) && "0".equals(transverse)) {
|
|
|
+ // sidx = "personNum";
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // if (!StringUtils.isEmpty(sidx) && "1".equals(transverse) && "proposer_number".equalsIgnoreCase(sidx)) {
|
|
|
+ // sidx = "attenddate," + sidx;
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // if (!StringUtils.isEmpty(sidx) && "0".equals(transverse) && !"personNum".equalsIgnoreCase(sidx)) {
|
|
|
+ // sidx = "personNum," + sidx;
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // String sord = request.getParameter("sord");
|
|
|
+ // if (StringUtils.isEmpty(sord)) {
|
|
|
+ // sord = " asc ";
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // String iscal = request.getParameter("iscal");
|
|
|
+ // map.put("iscal", iscal);
|
|
|
+ // map.put("sidx", sidx);
|
|
|
+ // map.put("sord", sord);
|
|
|
+ // map.put("rows", rows);
|
|
|
+ // map.put("page", page);
|
|
|
+ // map.put("beginDate", beginDate);
|
|
|
+ // map.put("endDate", endDate);
|
|
|
+ // map.put("billId", billId);
|
|
|
+ // if (request.getParameter("fromCalDetail") != null && request.getParameter("fromCalDetail").equals("1")) {
|
|
|
+ // String personIds = request.getParameter("personIds");
|
|
|
+ // String attendDates = request.getParameter("attendDates");
|
|
|
+ // map.put("personIdsString", personIds);
|
|
|
+ // map.put("attendDatesString", attendDates);
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // return map;
|
|
|
+ // }
|
|
|
|
|
|
@Override
|
|
|
- public Map<String, Object> getPersonShiftListMap(HttpServletRequest request, Map paramsMap, int rows, int page, Object[] params, String flag) throws BOSException, SQLException, SHRWebException {
|
|
|
- logger.error("getPersonShiftListMap--statrt--");
|
|
|
- Map<Integer, String> dateTypeMap = (new WorkCalendarItemHelper()).getDateType();
|
|
|
- Set<String> timeSets = new HashSet();
|
|
|
- String sql = this.getPersonScheduleShiftListSql(request, paramsMap, rows, page, flag, params);
|
|
|
- IRowSet rowSet = null;
|
|
|
- rowSet = DbUtil.executeQuery(this.ctx, sql, params);
|
|
|
- Map<String, Object> listMap = new LinkedHashMap();
|
|
|
- List<Map> list;
|
|
|
- Map<String, Object> objectMap;
|
|
|
- if (rowSet != null) {
|
|
|
- for (; rowSet.next(); list.add(objectMap)) {
|
|
|
- String key = rowSet.getString("personNum") + "@_@" + rowSet.getString("ADMINORGUNIT_ID") + "@_@" + rowSet.getString("ATTADMINORGUNIT_ID") + "@_@" + rowSet.getString("hrOrgUnit_id");
|
|
|
- list = (List) listMap.get(key);
|
|
|
- objectMap = new HashMap();
|
|
|
- if (list == null) {
|
|
|
- list = new ArrayList();
|
|
|
- objectMap.put("key", key);
|
|
|
- objectMap.put("personNum", rowSet.getString("personNum"));
|
|
|
- objectMap.put("personName", rowSet.getString("personName"));
|
|
|
- objectMap.put("adminOrgUnit_displayName", rowSet.getString("adminOrgUnit_displayName"));
|
|
|
- objectMap.put("adminOrgName", rowSet.getString("hrOrgUnit_name"));
|
|
|
- objectMap.put("attAdminOrgUnit_displayName", rowSet.getString("attAdminOrgUnit_displayName"));
|
|
|
- objectMap.put("hrOrgUnit_displayName", rowSet.getString("hrOrgUnit_displayName"));
|
|
|
- objectMap.put("hrOrgUnit_name", rowSet.getString("hrOrgUnit_name"));
|
|
|
- objectMap.put("hrOrgName", rowSet.getString("hrOrgUnit_name"));
|
|
|
- objectMap.put("hrOrgUnit_id", rowSet.getString("hrOrgUnit_id"));
|
|
|
- objectMap.put("hrOrgUnitId", rowSet.getString("hrOrgUnit_id"));
|
|
|
- listMap.put(key, list);
|
|
|
- }
|
|
|
-
|
|
|
- objectMap.put("dayType", rowSet.getInt("dateType"));
|
|
|
- objectMap.put("shiftName", rowSet.getString("shiftName"));
|
|
|
- objectMap.put("attendDate", AtsCommonUtile.getDateFormat().format(rowSet.getDate("attendDate")));
|
|
|
- objectMap.put("matchDayType", rowSet.getInt("matchDayType"));
|
|
|
- objectMap.put("matchShiftId", rowSet.getString("matchShiftId"));
|
|
|
- objectMap.put("matchShiftName", rowSet.getString("matchShiftName"));
|
|
|
- if (StringUtils.isEmpty(rowSet.getString("dateType"))) {
|
|
|
- objectMap.put("dayType", objectMap.get("matchDayType"));
|
|
|
- objectMap.put("shiftName", objectMap.get("matchShiftName"));
|
|
|
- }
|
|
|
-
|
|
|
- String attendDate = AtsDateUtils.dateShortToString(rowSet.getDate("attendDate"));
|
|
|
- timeSets.remove(attendDate);
|
|
|
- if (!StringUtils.isEmpty((CharSequence) dateTypeMap.get(rowSet.getInt("dateType")))) {
|
|
|
- if (StringUtils.isEmpty(rowSet.getString("shiftName"))) {
|
|
|
- objectMap.put(attendDate, "[" + (String) dateTypeMap.get(rowSet.getInt("dateType")) + "]");
|
|
|
- } else {
|
|
|
- objectMap.put(attendDate, "[" + (String) dateTypeMap.get(rowSet.getInt("dateType")) + "]" + rowSet.getString("shiftName"));
|
|
|
- }
|
|
|
- } else {
|
|
|
- objectMap.put(attendDate, "");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- logger.error("getPersonShiftListMap--end--");
|
|
|
- return listMap;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
public String getPersonScheduleShiftListSql(HttpServletRequest request, Map paramsMap, int rs, int pg, String flag, Object[] params) throws SHRWebException, BOSException {
|
|
|
- logger.error("getPersonScheduleShiftListSql--statrt--");
|
|
|
String pageSql = this.getPersonScheduleShiftPageSql(request, paramsMap, rs, pg, flag, params);
|
|
|
StringBuffer sql = new StringBuffer();
|
|
|
- sql.append(" /*dialect*/ SELECT ").append(" person.FID, ").append(" person.PERSONNUM PERSONNUM, ").append(" person.PERSONNAME PERSONNAME, ").append(" person.personIndex PERSONINDEX, ").append(" hrOrgUnit.fdisplayName" + MLUtile.getMlFlag(this.ctx) + " HRORGUNIT_DISPLAYNAME, ").append(" hrOrgUnit.fname" + MLUtile.getMlFlag(this.ctx) + " HRORGUNIT_NAME, ").append(" hrOrgUnit.fid HRORGUNIT_ID, ").append(" adminOrgUnit.fdisplayName" + MLUtile.getMlFlag(this.ctx) + " ADMINORGUNIT_DISPLAYNAME, ").append(" attAdminOrgUnit.fdisplayName" + MLUtile.getMlFlag(this.ctx) + " ATTADMINORGUNIT_DISPLAYNAME, ").append(" scheduleShift.fattenddate ATTENDDATE, ").append(" scheduleShift.fileAdminOrgUnitId ADMINORGUNIT_ID, ").append(" scheduleShift.fAdminOrgUnitId ATTADMINORGUNIT_ID, ").append(" shift.fname" + MLUtile.getMlFlag(this.ctx) + " SHIFTNAME, ").append(" scheduleShift.fdaytype DATETYPE, ").append(" scheduleShift.fmatchDayType matchDayType, ").append(" scheduleShift.fmatchShift matchShiftId, ").append(" matchShift.fname" + MLUtile.getMlFlag(this.ctx) + " matchShiftName ").append(" FROM ( ");
|
|
|
+ sql.append(" /*dialect*/ SELECT ").append(" person.FID, ").append(" person.PERSONNUM PERSONNUM, ").append(" person.PERSONNAME PERSONNAME, ").append(" hrOrgUnit.fdisplayName" + MLUtile.getMlFlag(this.ctx) + " HRORGUNIT_DISPLAYNAME, ").append(" hrOrgUnit.fname" + MLUtile.getMlFlag(this.ctx) + " HRORGUNIT_NAME, ").append(" hrOrgUnit.fid HRORGUNIT_ID, ").append(" adminOrgUnit.fdisplayName" + MLUtile.getMlFlag(this.ctx) + " ADMINORGUNIT_DISPLAYNAME, ").append(" attAdminOrgUnit.fdisplayName" + MLUtile.getMlFlag(this.ctx) + " ATTADMINORGUNIT_DISPLAYNAME, ").append(" scheduleShift.fattenddate ATTENDDATE, ").append(" scheduleShift.fileAdminOrgUnitId ADMINORGUNIT_ID, ").append(" scheduleShift.fAdminOrgUnitId ATTADMINORGUNIT_ID, ").append(" shift.fname" + MLUtile.getMlFlag(this.ctx) + " SHIFTNAME, ").append(" scheduleShift.fdaytype DATETYPE, ").append(" scheduleShift.fmatchDayType matchDayType, ").append(" scheduleShift.fmatchShift matchShiftId, ").append(" matchShift.fname" + MLUtile.getMlFlag(this.ctx) + " matchShiftName ").append(" FROM ( ");
|
|
|
sql.append(pageSql);
|
|
|
sql.append(" ) person ").append(" INNER JOIN ( select scheduleShift.fdefaultshiftid,scheduleShift.fattenddate, ").append(" scheduleShift.fdaytype, ").append(" scheduleShift.fmatchDayType, ").append(" scheduleShift.fmatchShift, ").append(" scheduleShift.fproposerid, ").append(" scheduleShift.fHrOrgUnitId, ").append(" scheduleShift.fAdminOrgUnitId fAdminOrgUnitId, ").append(" ATTENDFILE.FADMINORGUNITID fileAdminOrgUnitId ").append(" FROM t_hr_ats_scheduleshift scheduleShift ").append(" inner JOIN T_HR_ATS_AttendanceFileHis ATTENDFILE ").append(" ON ( scheduleShift.FProposerID = attendFile.FProposerID ").append(" AND attendFile.feffdt <= scheduleShift.Fattenddate ").append(" AND attendFile.fLeffdt >= scheduleShift.Fattenddate ");
|
|
|
String isAttendance = (String) paramsMap.get("attendFile.isAttendance");
|
|
|
if (StringUtils.isNotEmpty(isAttendance)) {
|
|
|
sql.append(" AND attendFile.fisAttendance in (" + AtsUtil.getStrFromString(isAttendance) + ") ");
|
|
|
}
|
|
|
+
|
|
|
sql.append(") ").append(" where\tscheduleShift.fattenddate >= ? ").append(" AND scheduleShift.fattenddate <= ? ");
|
|
|
String hrOrgUnit = (String) paramsMap.get("hrOrgUnit");
|
|
|
if (StringUtils.isNotEmpty(hrOrgUnit)) {
|
|
|
sql.append(" AND scheduleShift.FHrOrgUnitID in (" + AtsUtil.getStrFromStringArr(hrOrgUnit.split(",")) + ") ");
|
|
|
}
|
|
|
+
|
|
|
sql.append(" ) scheduleShift ").append(" ON person.fid = scheduleShift.fproposerid and person.fHrOrgUnitId=scheduleShift.fHrOrgUnitId and person.attAdminOrgUnitID = scheduleShift.fAdminOrgUnitId and scheduleShift.fileAdminOrgUnitId = person.fAdminOrgUnitId ").append(" INNER JOIN T_ORG_Admin adminOrgUnit ON adminOrgUnit.fid = person.fAdminOrgUnitId ").append(" INNER JOIN T_ORG_HRO hrOrgUnit ON hrOrgUnit.Fid = person.fHrOrgUnitId ").append(" INNER JOIN T_ORG_Admin attAdminOrgUnit ON person.attAdminOrgUnitID = attAdminOrgUnit.FID ").append(" LEFT JOIN t_hr_ats_shift SHIFT ON scheduleShift.fdefaultshiftid = shift.fid ").append(" LEFT JOIN t_hr_ats_shift matchShift ON scheduleShift.fmatchShift = matchShift.fid ").append(" where scheduleShift.fattenddate >= ? ").append(" AND scheduleShift.fattenddate <= ? ");
|
|
|
if (paramsMap.get("sidx") != null && StringUtils.isNotEmpty(paramsMap.get("sidx").toString())) {
|
|
|
- sql.append(" ORDER BY PERSONINDEX," + paramsMap.get("sidx") + " " + paramsMap.get("sord"));
|
|
|
+ sql.append(" ORDER BY " + paramsMap.get("sidx") + " " + paramsMap.get("sord"));
|
|
|
}
|
|
|
- logger.error("getPersonScheduleShiftListSql--sql--" + sql.toString());
|
|
|
- logger.error("getPersonScheduleShiftListSql--end--");
|
|
|
+
|
|
|
return sql.toString();
|
|
|
}
|
|
|
|
|
|
private String getPersonScheduleShiftPageSql(HttpServletRequest request, Map paramsMap, int rows, int page, String flag, Object[] params) throws SHRWebException, BOSException {
|
|
|
- logger.error("getPersonScheduleShiftPageSql--statrt--");
|
|
|
-
|
|
|
int dbType = AtsBaseUtils.getDbType(this.ctx);
|
|
|
PagingHelper pageHelper = new PagingHelper();
|
|
|
String sql = this.getPersonScheduleShiftSql(request, paramsMap, flag);
|
|
|
@@ -158,6 +424,7 @@ public class ScheduleShiftListHandlerEx extends ScheduleShiftListHandler {
|
|
|
personSql.append(" SELECT * FROM ").append(tempPersonTable);
|
|
|
if (paramsMap.get("sidx") != null && StringUtils.isNotEmpty(paramsMap.get("sidx").toString())) {
|
|
|
// personSql.append(" ORDER BY PERSONNUM " + paramsMap.get("sord"));
|
|
|
+ //personIndex新增排序字段
|
|
|
personSql.append(" ORDER BY personIndex,PERSONNUM " + paramsMap.get("sord"));
|
|
|
}
|
|
|
|
|
|
@@ -169,12 +436,11 @@ public class ScheduleShiftListHandlerEx extends ScheduleShiftListHandler {
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- logger.error("getPersonScheduleShiftPageSql--end--");
|
|
|
+
|
|
|
return afterPagingSql;
|
|
|
} finally {
|
|
|
;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
private String createPersonTable(Context ctx, Map paramsMap, Object[] objects, String sql) throws BOSException {
|
|
|
@@ -199,14 +465,14 @@ public class ScheduleShiftListHandlerEx extends ScheduleShiftListHandler {
|
|
|
}
|
|
|
|
|
|
private String getPersonScheduleShiftSql(HttpServletRequest request, Map paramsMap, String flag) {
|
|
|
- logger.error("getPersonScheduleShiftSql--statrt--");
|
|
|
String adminOrgUnitTempName = (String) paramsMap.get("adminOrgUnitTempName");
|
|
|
String hrRangeSQL = (String) paramsMap.get("hrRangeSQL");
|
|
|
String billId = (String) paramsMap.get("billId");
|
|
|
String advancedFilterItems = (String) paramsMap.get("advancedFilterItems");
|
|
|
StringBuffer sql = new StringBuffer();
|
|
|
sql.append(" SELECT * FROM ( ");
|
|
|
- sql.append(" SELECT proposer.fid FID, ").append(" proposer.fname" + MLUtile.getMlFlag(this.ctx) + " PERSONNAME, ").append(" proposer.fnumber PERSONNUM, ").append("proposer.FINDEX personIndex, ").append(" scheduleShift.FHrOrgUnitID fHrOrgUnitId, ").append(" adminOrgUnit.fid FadminOrgUnitId, ").append(" scheduleShift.fadminOrgUnitid attAdminOrgUnitId ").append(" FROM t_bd_person PROPOSER ").append(" INNER JOIN t_hr_ats_scheduleshift SCHEDULESHIFT ON proposer.fid = scheduleShift.fproposerid ").append(" INNER JOIN T_HR_ATS_AttendanceFileHis ATTENDFILE ON ( scheduleShift.FProposerID = attendFile.FProposerID AND attendFile.feffdt <= scheduleShift.Fattenddate AND attendFile.fLeffdt >= scheduleShift.Fattenddate )").append(" INNER JOIN T_ORG_Admin ADMINORGUNIT ON adminOrgUnit.fid = attendFile.FADMINORGUNITID ");
|
|
|
+ //QW personIndex 新增排序字段
|
|
|
+ sql.append(" SELECT proposer.fid FID, ").append(" proposer.fname" + MLUtile.getMlFlag(this.ctx) + " PERSONNAME, ").append(" proposer.fnumber PERSONNUM, ").append(" proposer.FINDEX personIndex, ").append(" scheduleShift.Fattenddate attendDate, ").append(" scheduleShift.Fdaytype dayType, ").append(" scheduleShift.FmatchDayType matchDayType, ").append(" scheduleShift.FmatchShift matchShiftId, ").append(" matchShift.fname" + MLUtile.getMlFlag(this.ctx) + " matchShiftName, ").append(" scheduleShift.Fproposerid proposerId, ").append(" scheduleShift.FCardRuleID cardRuleId, ").append(" cardRule.fname" + MLUtile.getMlFlag(this.ctx) + " cardRuleName, ").append(" scheduleShift.FDefaultShiftID defaultShiftId, ").append(" defaultShift.fname" + MLUtile.getMlFlag(this.ctx) + " defaultShiftName, ").append(" scheduleShift.FHrOrgUnitID fHrOrgUnitId, ").append(" adminOrgUnit.fid FadminOrgUnitId, ").append(" scheduleShift.fadminOrgUnitid attAdminOrgUnitId ").append(" FROM t_bd_person PROPOSER ").append(" INNER JOIN t_hr_ats_scheduleshift SCHEDULESHIFT ON proposer.fid = scheduleShift.fproposerid ").append(" INNER JOIN T_HR_ATS_AttendanceFileHis ATTENDFILE ON ( scheduleShift.FProposerID = attendFile.FProposerID AND attendFile.feffdt <= scheduleShift.Fattenddate AND attendFile.fLeffdt >= scheduleShift.Fattenddate )").append(" INNER JOIN T_ORG_Admin ADMINORGUNIT ON adminOrgUnit.fid = attendFile.FADMINORGUNITID ");
|
|
|
if (StringUtils.isNotEmpty(advancedFilterItems)) {
|
|
|
sql.append(" INNER JOIN T_ORG_Admin attAdminOrgUnit on attAdminOrgUnit.Fid = scheduleShift.FAdminOrgUnitID");
|
|
|
sql.append(" INNER JOIN T_HR_ATS_AttencePolicy attendPolicy on attendPolicy.Fid = scheduleShift.FAttendPolicyID");
|
|
|
@@ -253,8 +519,7 @@ public class ScheduleShiftListHandlerEx extends ScheduleShiftListHandler {
|
|
|
}
|
|
|
|
|
|
sql.append(" ) tempTable ");
|
|
|
- sql.append(" GROUP BY FID, PERSONNAME, PERSONNUM, personIndex, FHRORGUNITID, FADMINORGUNITID, ATTADMINORGUNITID ");
|
|
|
- logger.error("getPersonScheduleShiftSql--end--");
|
|
|
+ sql.append(" GROUP BY FID, PERSONNAME, PERSONNUM, FHRORGUNITID, FADMINORGUNITID, ATTADMINORGUNITID ");
|
|
|
return sql.toString();
|
|
|
}
|
|
|
|