From 62d551a5c8aef67daa7b216960668f0ee0f7c436 Mon Sep 17 00:00:00 2001 From: chenwei <3291673014@qq.com> Date: Thu, 2 Nov 2023 09:11:15 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=9B=E4=B8=96=E7=A7=91=E6=8A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/JobActivitiesBrowserService.java | 22 +- .../service/impl/JobGroupsBrowserService.java | 83 + .../service/impl/JobTitlesBrowserService.java | 204 ++ .../service/impl/LocationBrowserService.java | 117 + .../cmd/search/GetHrmSearchMoudleListCmd.java | 107 + .../hrm/cmd/search/GetHrmSearchResultCmd.java | 2392 +++++++++++++++ .../sskj/AddJobGroupCmdInter.java | 59 + .../sskj/EditJobGroupCmdInter.java | 58 + .../sskj/GetHrmKQMonthReportInfoCmdInter.java | 76 + .../sskj/GetJobDetailCmdInter.java | 50 + .../sskj/GetJobGroupFormCmdInter.java | 59 + .../customization/sskj/util/JobGroupUtil.java | 164 + src/com/engine/kq/biz/KQFormatData.java | 1077 +++++++ src/com/engine/kq/biz/KQReportBiz.java | 2727 +++++++++++++++++ .../attendanceEvent/GetAttendanceCardCmd.java | 192 ++ .../kq/cmd/report/ExportDailyExcelCmd.java | 659 ++++ .../engine/kq/cmd/report/ExportExcelCmd.java | 608 ++++ .../kq/cmd/report/GetKQDailyReportCmd.java | 623 ++++ .../engine/kq/cmd/report/GetKQReportCmd.java | 650 ++++ .../sskj/controller/EntryController.java | 10 + src/com/engine/sskj/service/EntryService.java | 5 + .../sskj/service/impl/EntryServiceImpl.java | 164 +- src/com/engine/sskj/util/SskjUtil.java | 24 + .../interfaces/sskj/job/SyncZkKqDataJob.java | 201 ++ .../interfaces/sskj/util/HttpsUtil.java | 270 ++ 25 files changed, 10590 insertions(+), 11 deletions(-) create mode 100644 src/com/api/browser/service/impl/JobGroupsBrowserService.java create mode 100644 src/com/api/browser/service/impl/JobTitlesBrowserService.java create mode 100644 src/com/api/browser/service/impl/LocationBrowserService.java create mode 100644 src/com/api/hrm/cmd/search/GetHrmSearchMoudleListCmd.java create mode 100644 src/com/api/hrm/cmd/search/GetHrmSearchResultCmd.java create mode 100644 src/com/customization/sskj/AddJobGroupCmdInter.java create mode 100644 src/com/customization/sskj/EditJobGroupCmdInter.java create mode 100644 src/com/customization/sskj/GetHrmKQMonthReportInfoCmdInter.java create mode 100644 src/com/customization/sskj/GetJobDetailCmdInter.java create mode 100644 src/com/customization/sskj/GetJobGroupFormCmdInter.java create mode 100644 src/com/customization/sskj/util/JobGroupUtil.java create mode 100644 src/com/engine/kq/biz/KQFormatData.java create mode 100644 src/com/engine/kq/biz/KQReportBiz.java create mode 100644 src/com/engine/kq/cmd/attendanceEvent/GetAttendanceCardCmd.java create mode 100644 src/com/engine/kq/cmd/report/ExportDailyExcelCmd.java create mode 100644 src/com/engine/kq/cmd/report/ExportExcelCmd.java create mode 100644 src/com/engine/kq/cmd/report/GetKQDailyReportCmd.java create mode 100644 src/com/engine/kq/cmd/report/GetKQReportCmd.java create mode 100644 src/com/engine/sskj/util/SskjUtil.java create mode 100644 src/weaver/interfaces/sskj/job/SyncZkKqDataJob.java create mode 100644 src/weaver/interfaces/sskj/util/HttpsUtil.java diff --git a/src/com/api/browser/service/impl/JobActivitiesBrowserService.java b/src/com/api/browser/service/impl/JobActivitiesBrowserService.java index 2c74b73..44e759d 100644 --- a/src/com/api/browser/service/impl/JobActivitiesBrowserService.java +++ b/src/com/api/browser/service/impl/JobActivitiesBrowserService.java @@ -14,7 +14,7 @@ import java.util.List; import java.util.Map; /** - * 职务类别 + * 职务 * * @author lvyi * @@ -26,6 +26,10 @@ public class JobActivitiesBrowserService extends BrowserService { Map apidatas = new HashMap(); String jobactivitymark = Util.null2String(params.get("jobactivitymark")); String jobactivityname = Util.null2String(params.get("jobactivityname")); + //二开 + String jobType = Util.null2String(params.get("jobType")); + //end + String sqlwhere = "where 1 = 1 "; String backfields = ""; String fromSql = ""; @@ -40,24 +44,30 @@ public class JobActivitiesBrowserService extends BrowserService { sqlwhere += Util.fromScreen2(jobactivityname,user.getLanguage()); sqlwhere += "%'"; } + if(!jobType.equals("")){ + sqlwhere = sqlwhere + " and jobgroupid in ( " + jobType + " )"; + } List cols = new ArrayList(); - backfields = " id, jobactivitymark, jobactivityname, jobgroupname "; + //二开start + backfields = " id, jobactivitymark, jobactivityname, jobgroupname, jobgroupid "; fromSql = " ( SELECT " + " a.id, " + " a.jobactivitymark, " + " a.jobactivityname, " + - " b.jobgroupname " + + " b.jobgroupname," + + " b.id as jobgroupid " + "FROM " + " HrmJobActivities a " + " LEFT JOIN HrmJobGroups b ON b.id = a.jobgroupid " + ") t "; orderby = " id "; + //end cols.add(new SplitTableColBean("true", "id")); - cols.add(new SplitTableColBean("35%", SystemEnv.getHtmlLabelName(399, user.getLanguage()), "jobactivitymark", "jobactivitymark").setIsInputCol(BoolAttr.TRUE)); - cols.add(new SplitTableColBean("35%", SystemEnv.getHtmlLabelName(15767, user.getLanguage()), "jobactivityname", "jobactivityname")); - cols.add(new SplitTableColBean("30%", SystemEnv.getHtmlLabelName(805, user.getLanguage()), "jobgroupname", "jobgroupname"));//二开 +// cols.add(new SplitTableColBean("35%", SystemEnv.getHtmlLabelName(399, user.getLanguage()), "jobactivitymark", "jobactivitymark").setIsInputCol(BoolAttr.TRUE)); + cols.add(new SplitTableColBean("50%", SystemEnv.getHtmlLabelName(805, user.getLanguage()), "jobgroupname", "jobgroupname"));//二开 + cols.add(new SplitTableColBean("50%", SystemEnv.getHtmlLabelName(15767, user.getLanguage()), "jobactivityname", "jobactivityname").setIsInputCol(BoolAttr.TRUE)); SplitTableBean tableBean = new SplitTableBean(backfields, fromSql, sqlwhere, orderby, "id", cols); diff --git a/src/com/api/browser/service/impl/JobGroupsBrowserService.java b/src/com/api/browser/service/impl/JobGroupsBrowserService.java new file mode 100644 index 0000000..67206d0 --- /dev/null +++ b/src/com/api/browser/service/impl/JobGroupsBrowserService.java @@ -0,0 +1,83 @@ +package com.api.browser.service.impl; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SplitTableBean; +import com.api.browser.bean.SplitTableColBean; +import com.api.browser.service.BrowserService; +import com.api.browser.util.*; +import weaver.general.Util; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 职务类别 + * + * @author lvyi + * + */ +public class JobGroupsBrowserService extends BrowserService { + + @Override + public Map getBrowserData(Map params) throws Exception { + Map apidatas = new HashMap(); + String jobgroupremark = Util.null2String(params.get("jobgroupremark")); + String jobgroupname = Util.null2String(params.get("jobgroupname")); + String sqlwhere = "where 1 = 1 "; + String backfields = ""; + String fromSql = ""; + String orderby = ""; + if(!jobgroupremark.equals("")){ + sqlwhere += " and jobgroupremark like '%"; + sqlwhere += Util.fromScreen2(jobgroupremark,user.getLanguage()); + sqlwhere += "%'"; + } + if(!jobgroupname.equals("")){ + sqlwhere += " and jobgroupname like '%"; + sqlwhere += Util.fromScreen2(jobgroupname,user.getLanguage()); + sqlwhere += "%'"; + } + + List cols = new ArrayList(); + backfields = " t.id, t.jobgroupname, t.jobgroupremark, t.jobgroupdesc "; + fromSql = " (SELECT " + + " a.id, " + + " a.jobgroupname, " + + " a.jobgroupremark, " + + " b.jobgroupdesc " + + "FROM " + + " HrmJobGroups a " + + " LEFT JOIN uf_jobgroupdesc b ON b.jobgroup = a.id ) t"; + orderby = " id "; + + cols.add(new SplitTableColBean("true", "id")); +// SplitTableColBean splitTableColBean = new SplitTableColBean("35%", SystemEnv.getHtmlLabelName(399, user.getLanguage()), "jobgroupremark", "jobgroupremark"); + SplitTableColBean splitTableColBean = new SplitTableColBean("50%", SystemEnv.getHtmlLabelName(15767, user.getLanguage()), "jobgroupname", "jobgroupname"); + splitTableColBean.setOrderkey(""); + splitTableColBean.setIsInputCol(BoolAttr.TRUE); + cols.add(splitTableColBean.setIsInputCol(BoolAttr.TRUE)); + cols.add(new SplitTableColBean("50%", SystemEnv.getHtmlLabelName(433, user.getLanguage()), "jobgroupdesc", "jobgroupdesc"));//二开 + + SplitTableBean tableBean = new SplitTableBean(backfields, fromSql, sqlwhere, orderby, "id", cols); + + tableBean.setSqlsortway("ASC"); + //tableBean.setSqlisdistinct("true"); + apidatas.putAll(SplitTableUtil.makeListDataResult(tableBean)); + return apidatas; + } + + @Override + public Map getBrowserConditionInfo(Map params) throws Exception { + Map apidatas = new HashMap(); + List conditions = new ArrayList(); + apidatas.put(BrowserConstant.BROWSER_RESULT_CONDITIONS, conditions); + ConditionFactory conditionFactory = new ConditionFactory(user); + conditions.add(conditionFactory.createCondition(ConditionType.INPUT, 399, "jobgroupremark", true)); + conditions.add(conditionFactory.createCondition(ConditionType.INPUT, 15767, "jobgroupname")); + return apidatas; + } + +} diff --git a/src/com/api/browser/service/impl/JobTitlesBrowserService.java b/src/com/api/browser/service/impl/JobTitlesBrowserService.java new file mode 100644 index 0000000..452dd1d --- /dev/null +++ b/src/com/api/browser/service/impl/JobTitlesBrowserService.java @@ -0,0 +1,204 @@ +package com.api.browser.service.impl; + +import com.api.browser.bean.ListHeadBean; +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SplitTableBean; +import com.api.browser.bean.SplitTableColBean; +import com.api.browser.service.BrowserService; +import com.api.browser.util.*; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.systeminfo.SystemEnv; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 岗位 + * + * @author jhy Mar 27, 2017 + * + */ +public class JobTitlesBrowserService extends BrowserService { + + @Override + public Map getBrowserData(Map params) throws Exception { + Map apidatas = new HashMap(); + String jobtitlemark = Util.null2String(params.get("jobtitlemark")); + String jobtitlename = Util.null2String(params.get("jobtitlename")); + String jobtitlecode = Util.null2String(params.get("jobtitlecode")); + String jobactivityname = Util.null2String(params.get("jobactivityname")); + //二开-根据职务过滤start + String job = Util.null2String(params.get("job")); + //end + String sqlwhere = "where 1 = 1 "; + String backfields = ""; + String fromSql = ""; + String orderby = ""; + List cols = new ArrayList(); + SplitTableBean tableBean = null; + if ("278".equals(browserType)) { + backfields = "c.id,c.jobtitlemark,c.jobtitlename,a.jobgroupname,a.jobgroupremark,b.jobactivitymark"; + fromSql = "from HrmJobTitles c left join HrmJobActivities b on b.id = c.jobactivityid left join HrmJobGroups a on a.id = b.jobgroupid"; + orderby = "c.id"; + sqlwhere = " where (c.canceled is null or c.canceled <> 1)"; + String jobgroupid = Util.null2String(params.get("jobgroupid")); + String jobactivitieid = Util.null2String(params.get("jobactivitieid")); + if(!jobgroupid.equals("")){ + sqlwhere += " and a.id ="+jobgroupid; + } + if(!jobactivitieid.equals("")){ + sqlwhere += " and b.id= "+jobactivitieid; + } + if(!jobtitlemark.equals("")){ + sqlwhere += " and c.jobtitlemark like '%" + Util.fromScreen2(jobtitlemark,user.getLanguage()) +"%' "; + } + if(!jobtitlename.equals("")){ + sqlwhere += " and c.jobtitlename like '%" + Util.fromScreen2(jobtitlename,user.getLanguage()) +"%' "; + } + if (!jobtitlecode.equals("")) { + sqlwhere += " and c.jobtitlecode like '%" + Util.fromScreen2(jobtitlecode,user.getLanguage()) +"%' "; + } + + + cols.add(new SplitTableColBean("true", "id")); + cols.add(new SplitTableColBean("35%", SystemEnv.getHtmlLabelName(6086, user.getLanguage()), "jobtitlemark", "jobtitlemark", 1).setIsInputCol(BoolAttr.TRUE)); + cols.add(new SplitTableColBean("35%", SystemEnv.getHtmlLabelName(1915, user.getLanguage()), "jobactivitymark", "jobactivitymark")); + cols.add(new SplitTableColBean("30%", SystemEnv.getHtmlLabelName(805, user.getLanguage()), "jobgroupremark", "jobgroupremark")); + tableBean = new SplitTableBean(backfields, fromSql, sqlwhere, orderby, "c.id", cols); + } else { + backfields = " a.id as id,a.jobtitlemark as jobtitlemark,a.jobtitlename as jobtitlename, b.jobactivityname as jobactivityname, b.jobactivitymark as jobactivitymark , a.jobtitlecode as jobtitlecode"; + fromSql = " from HrmJobTitles a left join HrmJobActivities b on a.jobactivityid=b.id "; + orderby = " a.id "; + sqlwhere +=" and (a.canceled is null or a.canceled <> 1)"; + if (!"".equals(jobtitlemark)) { + sqlwhere += " and a.jobtitlemark like '%" + jobtitlemark + "%'"; + } + + if (!"".equals(jobtitlename)) { + sqlwhere += " and a.jobtitlename like '%" + jobtitlename + "%'"; + } + + if (!"".equals(jobtitlecode)) { + sqlwhere += " and a.jobtitlecode like '%" + jobtitlecode + "%'"; + } + + if (!"".equals(jobactivityname)) { + sqlwhere += " and jobactivityname like '%" + jobactivityname + "%'"; + } + + //二开-根据职务过滤start + if (!job.equals("")) { + sqlwhere += " and b.id in ( " + job + " )"; + } + //end + + cols.add(new SplitTableColBean("true", "id")); +// cols.add(new SplitTableColBean("25%", SystemEnv.getHtmlLabelName(15767, user.getLanguage()), "jobtitlename", "jobtitlename")); +// cols.add(new SplitTableColBean("25%", SystemEnv.getHtmlLabelName(399, user.getLanguage()), "jobtitlemark", "jobtitlemark").setIsInputCol(BoolAttr.TRUE)); +// cols.add(new SplitTableColBean("25%", SystemEnv.getHtmlLabelName(524944, user.getLanguage()), "jobtitlecode", "jobtitlecode")); +// cols.add(new SplitTableColBean("25%", SystemEnv.getHtmlLabelName(1915, user.getLanguage()), "jobactivitymark", "jobactivitymark")); + + //二开--取消简称和编号start + cols.add(new SplitTableColBean("50%", SystemEnv.getHtmlLabelName(1915, user.getLanguage()), "jobactivitymark", "jobactivitymark")); + cols.add(new SplitTableColBean("50%", SystemEnv.getHtmlLabelName(15767, user.getLanguage()), "jobtitlename", "jobtitlename").setIsInputCol(BoolAttr.TRUE)); + //end + + tableBean = new SplitTableBean(backfields, fromSql, sqlwhere, orderby, "a.id", cols); + } + + tableBean.setSqlsortway("ASC"); + tableBean.setSqlisdistinct("true"); + apidatas.putAll(SplitTableUtil.makeListDataResult(tableBean)); + return apidatas; + } + + @Override + public Map getBrowserConditionInfo(Map params) throws Exception { + Map apidatas = new HashMap(); + List conditions = new ArrayList(); + apidatas.put(BrowserConstant.BROWSER_RESULT_CONDITIONS, conditions); + ConditionFactory conditionFactory = new ConditionFactory(user); + if ("278".equals(browserType)) { + conditions.add(conditionFactory.createCondition(ConditionType.BROWSER, 805, "jobgroupid","281")); + conditions.add(conditionFactory.createCondition(ConditionType.BROWSER, 15855, "jobactivitieid","282")); + } + conditions.add(conditionFactory.createCondition(ConditionType.INPUT, 15767, "jobtitlename")); + conditions.add(conditionFactory.createCondition(ConditionType.INPUT, 399, "jobtitlemark",true)); + conditions.add(conditionFactory.createCondition(ConditionType.INPUT, 524944, "jobtitlecode")); + return apidatas; + } + + @Override + public Map getMultBrowserDestData(Map params) throws Exception { + Map apidatas = new HashMap(); + List> datas = new ArrayList>(); + String selectids = Util.null2String(params.get(BrowserConstant.BROWSER_MULT_DEST_SELECTIDS)); + if(user == null || "".equals(selectids)) return apidatas; + RecordSet rs = new RecordSet(); + String tempSql = " select c.id,c.jobtitlemark,c.jobtitlename,a.jobgroupname,a.jobgroupremark,b.jobactivitymark " + + " from HrmJobTitles c left join HrmJobActivities b on b.id = c.jobactivityid left join HrmJobGroups a on a.id = b.jobgroupid " + + " where c.id in ("+selectids+")"+ + " order by c.jobtitlemark "; + rs.executeSql(tempSql); + while(rs.next()){ + Map item = new HashMap(); + item.put("id", rs.getString("id")); + item.put("jobtitlemark", Util.null2String(rs.getString("jobtitlemark"))); + item.put("jobactivitymark", Util.null2String(rs.getString("jobactivitymark"))); + item.put("jobgroupremark", Util.null2String(rs.getString("jobgroupremark"))); + datas.add(item); + } + + List tableHeadColumns = new ArrayList(); + tableHeadColumns.add(new ListHeadBean("id",BoolAttr.TRUE)); + tableHeadColumns.add(new ListHeadBean("jobtitlemark","",1,BoolAttr.TRUE)); + tableHeadColumns.add(new ListHeadBean("jobactivitymark","")); + tableHeadColumns.add(new ListHeadBean("jobgroupremark","")); + + apidatas.put(BrowserConstant.BROWSER_RESULT_COLUMN, tableHeadColumns); + apidatas.put(BrowserConstant.BROWSER_RESULT_DATA, datas); + apidatas.put(BrowserConstant.BROWSER_RESULT_TYPE, BrowserDataType.LIST_ALL_DATA.getTypeid()); + return apidatas; + } + + @Override + public Map browserAutoComplete(HttpServletRequest request, HttpServletResponse response) throws Exception { + Map apidatas = new HashMap(); + String q = Util.null2String(request.getParameter("q")); + List sqlParams = new ArrayList() ; + String keyword = ""; + if(q.length()>0) keyword = "%" + q +"%"; + RecordSet rs=new RecordSet(); + String sqlwhere = "where 1 = 1 "; + String backfields = " a.id as id,a.jobtitlemark as jobtitlemark,a.jobtitlename as jobtitlename,a.jobtitlecode as jobtitlecode,b.jobactivityname as jobactivityname, b.jobactivitymark as jobactivitymark "; + String fromSql = " from HrmJobTitles a left join HrmJobActivities b on a.jobactivityid=b.id "; + String orderby = " order by a.id "; + sqlwhere +=" and (a.canceled is null or a.canceled <> 1)"; + if (!"".equals(keyword)) { + sqlwhere += " and (a.jobtitlemark like ? or a.jobtitlename like ? or a.ecology_pinyin_search like ? )"; + sqlParams.add(keyword); + sqlParams.add(keyword); + sqlParams.add(keyword); + } + String sql = "select "+backfields+fromSql+sqlwhere+orderby; + rs.executeQuery(sql,sqlParams); + List> datas = new ArrayList>(); + while(rs.next()){ + Map item = new HashMap(); + item.put("id", Util.null2String(rs.getString("id"))); + String name = Util.null2String(rs.getString("jobtitlemark")); + String jobtitlecode = Util.null2String(rs.getString("jobtitlecode")); + String title = name+"|"+jobtitlecode+"|"+Util.null2String(rs.getString("jobactivitymark")); + item.put("name", name); + item.put("title", title); + datas.add(item); + } + apidatas.put("datas",datas); + return apidatas; + } +} diff --git a/src/com/api/browser/service/impl/LocationBrowserService.java b/src/com/api/browser/service/impl/LocationBrowserService.java new file mode 100644 index 0000000..48fb34c --- /dev/null +++ b/src/com/api/browser/service/impl/LocationBrowserService.java @@ -0,0 +1,117 @@ +package com.api.browser.service.impl; + +import com.api.browser.bean.ListHeadBean; +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.bean.SplitTableBean; +import com.api.browser.bean.SplitTableColBean; +import com.api.browser.service.BrowserService; +import com.api.browser.util.*; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 办公地点 + * + * @author jhy Mar 28, 2017 + * + */ +public class LocationBrowserService extends BrowserService { + + @Override + public Map getBrowserData(Map params) throws Exception { + // TODO Auto-generated method stub + Map apidatas = new HashMap(); + String locationname = Util.null2String(params.get("locationname")); + String locationdesc = Util.null2String(params.get("locationdesc")); + String address = Util.null2String(params.get("address")); + String sqlwhere = " where 1 = 1 "; + if (!locationname.equals("")) { + sqlwhere += " and locationname like '%"; + sqlwhere += Util.fromScreen2(locationname, user.getLanguage()); + sqlwhere += "%'"; + } + if (!locationdesc.equals("")) { + sqlwhere += " and locationdesc like '%"; + sqlwhere += Util.fromScreen2(locationdesc, user.getLanguage()); + sqlwhere += "%'"; + } + if (!address.equals("")) { + sqlwhere += " and (address1 like '%"; + sqlwhere += Util.fromScreen2(address, user.getLanguage()); + sqlwhere += "%')"; + } + // 设置好搜索条件 + String backFields = " id ,locationname,locationdesc,address1 "; + String fromSql = " HrmLocations "; + String orderBy = " showOrder,id "; + + List cols = new ArrayList(); + cols.add(new SplitTableColBean("15%",SystemEnv.getHtmlLabelName(84, user.getLanguage()),"id","id")); +// cols.add(new SplitTableColBean("25%",SystemEnv.getHtmlLabelName(399, user.getLanguage()),"locationname","locationname")); + cols.add(new SplitTableColBean("35%",SystemEnv.getHtmlLabelName(15767, user.getLanguage()),"locationdesc","locationdesc").setIsInputCol(BoolAttr.TRUE)); + cols.add(new SplitTableColBean("50%",SystemEnv.getHtmlLabelName(110, user.getLanguage()),"address1","address1")); + + SplitTableBean tableBean = new SplitTableBean(backFields,fromSql,sqlwhere,orderBy,"id",cols); + tableBean.setSqlsortway("ASC"); + apidatas.putAll(SplitTableUtil.makeListDataResult(tableBean)); + return apidatas; + } + + + @Override + public Map getBrowserConditionInfo(Map params) throws Exception { + Map apidatas = new HashMap(); + List conditions = new ArrayList(); + ConditionFactory conditionFactory = new ConditionFactory(user); + conditions.add(conditionFactory.createCondition(ConditionType.INPUT, 399, "locationname",true)); + conditions.add(conditionFactory.createCondition(ConditionType.INPUT, 15767, "locationdesc")); + conditions.add(conditionFactory.createCondition(ConditionType.INPUT, 110, "address")); + apidatas.put(BrowserConstant.BROWSER_RESULT_CONDITIONS,conditions); + return apidatas; + } + + @Override + public Map getMultBrowserDestData(Map params) throws Exception { + Map apidatas = new HashMap(); + List> datas = new ArrayList>(); + String selectids = Util.null2String(params.get(BrowserConstant.BROWSER_MULT_DEST_SELECTIDS)); + if(user == null || "".equals(selectids)) return apidatas; + RecordSet rs = new RecordSet(); + String tempSql = "select id,locationname,locationdesc from HrmLocations where id in ("+selectids+")"; + rs.executeQuery(tempSql); + while(rs.next()){ + Map item = new HashMap<>(); + item.put("id", rs.getString("id")); + item.put("locationname", Util.null2String(rs.getString("locationname"))); + item.put("locationdesc", Util.null2String(rs.getString("locationdesc"))); + datas.add(item); + } +// LocationComInfo locationComInfo=new LocationComInfo(); +// String[] ids = Util.splitString(selectids, ","); +// for(int i=0;i item = new HashMap(); +// item.put("id", id); +// item.put("locationname", Util.null2String(locationComInfo.getLocationname(id))); +// item.put("locationdesc", Util.null2String(locationComInfo.getLocationname(id))); +// datas.add(item); +// } + + List tableHeadColumns = new ArrayList(); + tableHeadColumns.add(new ListHeadBean("id",BoolAttr.TRUE)); + tableHeadColumns.add(new ListHeadBean("locationname","",1,BoolAttr.TRUE)); + tableHeadColumns.add(new ListHeadBean("locationdesc","")); + + apidatas.put(BrowserConstant.BROWSER_RESULT_COLUMN, tableHeadColumns); + apidatas.put(BrowserConstant.BROWSER_RESULT_DATA, datas); + apidatas.put(BrowserConstant.BROWSER_RESULT_TYPE, BrowserDataType.LIST_ALL_DATA.getTypeid()); + return apidatas; + } +} diff --git a/src/com/api/hrm/cmd/search/GetHrmSearchMoudleListCmd.java b/src/com/api/hrm/cmd/search/GetHrmSearchMoudleListCmd.java new file mode 100644 index 0000000..9b1a3c5 --- /dev/null +++ b/src/com/api/hrm/cmd/search/GetHrmSearchMoudleListCmd.java @@ -0,0 +1,107 @@ +package com.api.hrm.cmd.search; + +import com.api.hrm.util.ServiceUtil; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 获取人员定制过的查询条件模板列表 + */ +public class GetHrmSearchMoudleListCmd extends AbstractCommonCommand> { + + public GetHrmSearchMoudleListCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map resultMap = new HashMap(); + try { + String userId = Util.null2String(params.get("userid")); + //左侧组织结构树选择的维度:默认为1--组织维度 + int virtualType = Util.getIntValue((String) params.get("virtualtype"), 1); + if (userId.length() == 0) { + userId = "" + user.getUID(); + } + + RecordSet rs = new RecordSet(); + List> lsMould = new ArrayList>(); + Map mouldInfo = null; + //默认显示【全部人员】查询模板 + mouldInfo = new HashMap(); + mouldInfo.put("typeid", "default_3"); + mouldInfo.put("title", SystemEnv.getHtmlLabelName(381958, user.getLanguage())); + mouldInfo.put("editable", false); + lsMould.add(mouldInfo); + + //仅当左侧组织结构树选择非虚拟维度时才存在以下查询模板 + if (virtualType > 0) { + //是否是系统管理员或分权管理员,如果不是,显示【同部门】查询模板 + if (!ServiceUtil.isAdmin(userId)) { + mouldInfo = new HashMap(); + mouldInfo.put("typeid", "default_1"); + mouldInfo.put("title", SystemEnv.getHtmlLabelName(18511, user.getLanguage())); + mouldInfo.put("editable", false); + lsMould.add(mouldInfo); + } + + //是否存在下属,若存在,显示【我的下属】查询模板 + rs.executeSql("select count(1) from hrmresource where managerid=" + userId); + if (rs.next()) { + if (rs.getInt(1) > 0) { + mouldInfo = new HashMap(); + mouldInfo.put("typeid", "default_2"); + mouldInfo.put("title", SystemEnv.getHtmlLabelName(15089, user.getLanguage())); + mouldInfo.put("editable", false); + lsMould.add(mouldInfo); + } + } + + //是否存在自定义的查询模板 + rs.executeSql("select id, mouldname from HrmSearchMould where userId=" + userId + " order by id "); + while (rs.next()) { + mouldInfo = new HashMap(); + mouldInfo.put("typeid", rs.getString("id")); + mouldInfo.put("title", rs.getString("mouldname")); + mouldInfo.put("editable", true); + lsMould.add(mouldInfo); + } + + //二开--通讯录给所有人增加同部门及其下级部门tab + BaseBean basebean = new BaseBean(); + String contactsTabId = basebean.getPropValue("project_sskj", "contactsTabId"); + String contactsTabName = SystemEnv.getHtmlLabelName(125591, user.getLanguage());//同部门以及下级部门 + mouldInfo = new HashMap(); + mouldInfo.put("typeid", contactsTabId); + mouldInfo.put("title", contactsTabName); + mouldInfo.put("editable", false); + lsMould.add(mouldInfo); + + } + resultMap.put("status", "1"); + resultMap.put("tabs", lsMould); + } catch (Exception e) { + resultMap.put("status", "-1"); + resultMap.put("message", ""+ SystemEnv.getHtmlLabelName(10004502,weaver.general.ThreadVarLanguage.getLang())+"tabs"+ SystemEnv.getHtmlLabelName(32104,weaver.general.ThreadVarLanguage.getLang())+""); + writeLog(e); + } + return resultMap; + } +} diff --git a/src/com/api/hrm/cmd/search/GetHrmSearchResultCmd.java b/src/com/api/hrm/cmd/search/GetHrmSearchResultCmd.java new file mode 100644 index 0000000..bb29e5a --- /dev/null +++ b/src/com/api/hrm/cmd/search/GetHrmSearchResultCmd.java @@ -0,0 +1,2392 @@ +package com.api.hrm.cmd.search; + +import com.alibaba.fastjson.JSON; +import com.api.hrm.util.PageUidFactory; +import com.cloudstore.dev.api.util.Util_TableMap; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.biz.EncryptConfigBiz; +import com.engine.common.entity.BizLogContext; +import com.engine.common.entity.EncryptShareSettingEntity; +import com.engine.common.enums.EncryptMould; +import com.engine.core.interceptor.CommandContext; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.file.Prop; +import weaver.general.BaseBean; +import weaver.general.PageIdConst; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.HrmUserVarify; +import weaver.hrm.User; +import weaver.hrm.appdetach.AppDetachComInfo; +import weaver.hrm.common.Tools; +import weaver.hrm.common.database.dialect.DbDialectFactory; +import weaver.hrm.common.database.dialect.DialectUtil; +import weaver.hrm.common.database.dialect.IDbDialectSql; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.companyvirtual.DepartmentVirtualComInfo; +import weaver.hrm.companyvirtual.SubCompanyVirtualComInfo; +import weaver.hrm.definedfield.HrmFieldGroupComInfo; +import weaver.hrm.definedfield.HrmFieldManager; +import weaver.hrm.privacy.PrivacyComInfo; +import weaver.hrm.resource.HrmListValidate; +import weaver.hrm.resource.ResourceBelongtoComInfo; +import weaver.hrm.tools.HrmValidate; +import weaver.rdeploy.portal.PortalUtil; +import weaver.systeminfo.SystemEnv; + +import javax.servlet.http.HttpServletRequest; +import java.util.*; + +/** + * 获取查询结果 + */ +public class GetHrmSearchResultCmd extends AbstractCommonCommand> { + + private static String DATE_SELECT = "select"; + private static String DATE_FROM = "from"; + private static String DATE_TO = "to"; + + private static HttpServletRequest request; + + public GetHrmSearchResultCmd(Map params, User user, HttpServletRequest request) { + this.user = user; + this.params = params; + this.request = request; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + try { + RecordSet RecordSet = new RecordSet(); + Set> paramSet = params.entrySet(); + for(Map.Entry me : paramSet){ + String key = Util.null2s(Util.null2String(me.getKey()),""); + String val = Util.null2s(Util.null2String(me.getValue()),""); + if(val.length() > 0 && key.length() > 0){ + //安全处理sql拼接 %; + params.put(key ,val.replace("%","")); + } + } + //满足QC1071823导入/导出需求 只显示标准字段并剔除隐私设置字段(电话号码、邮箱等) + boolean isExport = "1".equals(Util.null2String(params.get("isExport"))); + String groupId = Util.null2String(params.get("groupId"));//常用组ID(来自左侧常用组树) + String superid = Util.null2String(params.get("superid")); + String needRealPath = Util.null2String(params.get("needRealPath")); + String keyfield = Util.null2String(params.get("keyfield")); + String tabkey = Util.fromScreen2((String) params.get("tabkey"), user.getLanguage()); + String showAllLevel = Util.fromScreen2((String) params.get("showAllLevel"), user.getLanguage());//是否显示下级机构、(我的下属页签)是否显示下级下属 + String resourcename = Util.fromScreen2((String) params.get("resourcename"), user.getLanguage()); + if (resourcename.length() == 0) { + resourcename = Util.fromScreen2((String) params.get("lastname"), user.getLanguage()); + } + resourcename = resourcename.trim(); + String jobtitle = Util.fromScreen((String) params.get("jobtitle"), user.getLanguage()); + String activitydesc = Util.fromScreen2((String) params.get("activitydesc"), user.getLanguage()); + String jobgroup = Util.fromScreen((String) params.get("jobgroup"), user.getLanguage()); + String jobactivity = Util.fromScreen((String) params.get("jobactivity"), user.getLanguage()); + String costcenter = Util.fromScreen((String) params.get("costcenter"), user.getLanguage()); + String resourcetype = Util.fromScreen((String) params.get("resourcetype"), user.getLanguage()); + String status = Util.fromScreen((String) params.get("status"), user.getLanguage()); + String subcompanyid1 = Util.fromScreen((String) params.get("subcompanyid1"), user.getLanguage()); + if (subcompanyid1.length() == 0) { + subcompanyid1 = Util.fromScreen((String) params.get("subcompany"), user.getLanguage()); + } + String departmentid = Util.fromScreen((String) params.get("departmentid"), user.getLanguage()); + if (departmentid.length() == 0) { + departmentid = Util.fromScreen((String) params.get("department"), user.getLanguage()); + } + String location = Util.fromScreen((String) params.get("location"), user.getLanguage()); + String manager = Util.fromScreen((String) params.get("manager"), user.getLanguage()); + String assistant = Util.fromScreen((String) params.get("assistant"), user.getLanguage()); + String roles = Util.fromScreen((String) params.get("roles"), user.getLanguage()); + String seclevel = Util.fromScreen((String) params.get("seclevel"), user.getLanguage()); + String seclevelto = Util.fromScreen((String) params.get("seclevelto"), user.getLanguage()); + String joblevel = Util.fromScreen((String) params.get("joblevel"), user.getLanguage()); + String joblevelto = Util.fromScreen((String) params.get("joblevelto"), user.getLanguage()); + String workroom = Util.fromScreen2((String) params.get("workroom"), user.getLanguage()); + String telephone = Util.fromScreen((String) params.get("telephone"), user.getLanguage()); + String startdate = Util.fromScreen((String) params.get("startdate" + DATE_FROM), user.getLanguage()); + String startdateto = Util.fromScreen((String) params.get("startdate" + DATE_TO), user.getLanguage()); + String startdateselect = Util.fromScreen((String) params.get("startdate" + DATE_SELECT), user.getLanguage()); + if (!startdateselect.equals("") && !startdateselect.equals("0") && !startdateselect.equals("6")) { + startdate = TimeUtil.getDateByOption(startdateselect, "0"); + startdateto = TimeUtil.getDateByOption(startdateselect, "1"); + } + String enddate = Util.fromScreen((String) params.get("enddate" + DATE_FROM), user.getLanguage()); + String enddateto = Util.fromScreen((String) params.get("enddate" + DATE_TO), user.getLanguage()); + String enddateselect = Util.fromScreen((String) params.get("enddate" + DATE_SELECT), user.getLanguage()); + if (!enddateselect.equals("") && !enddateselect.equals("0") && !enddateselect.equals("6")) { + enddate = TimeUtil.getDateByOption(enddateselect, "0"); + enddateto = TimeUtil.getDateByOption(enddateselect, "1"); + } + //人员查询增加入职日期条件 + String companystartdate = Util.fromScreen((String) params.get("companystartdate" + DATE_FROM), user.getLanguage()); + String companystartdateto = Util.fromScreen((String) params.get("companystartdate" + DATE_TO), user.getLanguage()); + String companystartdateselect = Util.fromScreen((String) params.get("companystartdate" + DATE_SELECT), user.getLanguage()); + if (!companystartdateselect.equals("") && !companystartdateselect.equals("0") && !companystartdateselect.equals("6")) { + companystartdate = TimeUtil.getDateByOption(companystartdateselect, "0"); + companystartdateto = TimeUtil.getDateByOption(companystartdateselect, "1"); + } + String companyworkyear = Util.fromScreen((String) params.get("companyworkyear"), user.getLanguage()); + String companyworkyearto = Util.fromScreen((String) params.get("companyworkyearto"), user.getLanguage()); + + //人员查询增加参加工作日期条件 + String workstartdate = Util.fromScreen((String) params.get("workstartdate" + DATE_FROM), user.getLanguage()); + String workstartdateto = Util.fromScreen((String) params.get("workstartdate" + DATE_TO), user.getLanguage()); + String workstartdateselect = Util.fromScreen((String) params.get("workstartdate" + DATE_SELECT), user.getLanguage()); + if (!workstartdateselect.equals("") && !workstartdateselect.equals("0") && !workstartdateselect.equals("6")) { + workstartdate = TimeUtil.getDateByOption(workstartdateselect, "0"); + workstartdateto = TimeUtil.getDateByOption(workstartdateselect, "1"); + } + String workyear = Util.fromScreen((String) params.get("workyear"), user.getLanguage()); + String workyearto = Util.fromScreen((String) params.get("workyearto"), user.getLanguage()); + + String contractdate = Util.fromScreen((String) params.get("contractdate" + DATE_FROM), user.getLanguage()); + String contractdateto = Util.fromScreen((String) params.get("contractdate" + DATE_TO), user.getLanguage()); + String contractdateselect = Util.fromScreen((String) params.get("contractdate" + DATE_SELECT), user.getLanguage()); + if (!contractdateselect.equals("") && !contractdateselect.equals("0") && !contractdateselect.equals("6")) { + contractdate = TimeUtil.getDateByOption(contractdateselect, "0"); + contractdateto = TimeUtil.getDateByOption(contractdateselect, "1"); + } + String birthday = Util.fromScreen((String) params.get("birthday" + DATE_FROM), user.getLanguage()); + String birthdayto = Util.fromScreen((String) params.get("birthday" + DATE_TO), user.getLanguage()); + String birthdayselect = Util.fromScreen((String) params.get("birthday" + DATE_SELECT), user.getLanguage()); + if (!birthdayselect.equals("") && !birthdayselect.equals("0") && !birthdayselect.equals("6")) { + birthday = TimeUtil.getDateByOption(birthdayselect, "0"); + birthdayto = TimeUtil.getDateByOption(birthdayselect, "1"); + } + String age = Util.fromScreen((String) params.get("age"), user.getLanguage()); + String ageto = Util.fromScreen((String) params.get("ageto"), user.getLanguage()); + String sex = Util.fromScreen((String) params.get("sex"), user.getLanguage()); + int accounttype = Util.getIntValue((String) params.get("accounttype"), -1); + String resourceidfrom = Util.fromScreen((String) params.get("resourceidfrom"), user.getLanguage()); + String resourceidto = Util.fromScreen((String) params.get("resourceidto"), user.getLanguage()); + String workcode = Util.fromScreen((String) params.get("workcode"), user.getLanguage()); + String jobcall = Util.fromScreen((String) params.get("jobcall"), user.getLanguage()); + String mobile = Util.fromScreen((String) params.get("mobile"), user.getLanguage()); + String mobilecall = Util.fromScreen((String) params.get("mobilecall"), user.getLanguage()); + String fax = Util.fromScreen((String) params.get("fax"), user.getLanguage()); + String email = Util.fromScreen((String) params.get("email"), user.getLanguage()); + String folk = Util.fromScreen2((String) params.get("folk"), user.getLanguage()); + String nativeplace = Util.fromScreen2((String) params.get("nativeplace"), user.getLanguage()); + String regresidentplace = Util.fromScreen2((String) params.get("regresidentplace"), user.getLanguage()); + String maritalstatus = Util.fromScreen((String) params.get("maritalstatus"), user.getLanguage()); + String certificatenum = Util.fromScreen((String) params.get("certificatenum"), user.getLanguage()); + String tempresidentnumber = Util.fromScreen((String) params.get("tempresidentnumber"), user.getLanguage()); + String residentplace = Util.fromScreen2((String) params.get("residentplace"), user.getLanguage()); + String homeaddress = Util.fromScreen2((String) params.get("homeaddress"), user.getLanguage()); + String healthinfo = Util.fromScreen((String) params.get("healthinfo"), user.getLanguage()); + String heightfrom = Util.fromScreen((String) params.get("height"), user.getLanguage()); + String heightto = Util.fromScreen((String) params.get("heightto"), user.getLanguage()); + String weightfrom = Util.fromScreen((String) params.get("weight"), user.getLanguage()); + String weightto = Util.fromScreen((String) params.get("weightto"), user.getLanguage()); + String educationlevel = Util.fromScreen((String) params.get("educationlevel"), user.getLanguage()); + String educationlevelto = Util.fromScreen((String) params.get("educationlevelto"), user.getLanguage()); + String degree = Util.fromScreen2((String) params.get("degree"), user.getLanguage()); + String usekind = Util.fromScreen((String) params.get("usekind"), user.getLanguage()); + String policy = Util.fromScreen2((String) params.get("policy"), user.getLanguage()); + String bememberdatefrom = Util.fromScreen((String) params.get("bememberdate" + DATE_FROM), user.getLanguage()); + String bememberdateto = Util.fromScreen((String) params.get("bememberdate" + DATE_TO), user.getLanguage()); + String bememberdateselect = Util.fromScreen((String) params.get("bememberdate" + DATE_SELECT), user.getLanguage()); + if (!bememberdateselect.equals("") && !bememberdateselect.equals("0") && !bememberdateselect.equals("6")) { + bememberdatefrom = TimeUtil.getDateByOption(bememberdateselect, "0"); + bememberdateto = TimeUtil.getDateByOption(bememberdateselect, "1"); + } + String bepartydatefrom = Util.fromScreen((String) params.get("bepartydate" + DATE_FROM), user.getLanguage()); + String bepartydateto = Util.fromScreen((String) params.get("bepartydate" + DATE_TO), user.getLanguage()); + String bepartydateselect = Util.fromScreen((String) params.get("bepartydate" + DATE_SELECT), user.getLanguage()); + if (!bepartydateselect.equals("") && !bepartydateselect.equals("0") && !bepartydateselect.equals("6")) { + bepartydatefrom = TimeUtil.getDateByOption(bepartydateselect, "0"); + bepartydateto = TimeUtil.getDateByOption(bepartydateselect, "1"); + } + String islabouunion = Util.fromScreen((String) params.get("islabouunion"), user.getLanguage()); + String bankid1 = Util.fromScreen((String) params.get("bankid1"), user.getLanguage()); + String accountid1 = Util.fromScreen((String) params.get("accountid1"), user.getLanguage()); + String accumfundaccount = Util.fromScreen((String) params.get("accumfundaccount"), user.getLanguage()); + String loginid = Util.fromScreen((String) params.get("loginid"), user.getLanguage()); + String systemlanguage = Util.fromScreen((String) params.get("systemlanguage"), user.getLanguage()); + String classification = Util.null2String(params.get("classification"));//人员密级 + String datefield1 = Util.toScreenToEdit((String) params.get("datefield1"), user.getLanguage()); + String datefield1to = Util.toScreenToEdit((String) params.get("datefieldto1"), user.getLanguage()); + String datefield1select = Util.fromScreen((String) params.get("datefield1select"), user.getLanguage()); + if (!datefield1select.equals("") && !datefield1select.equals("0") && !datefield1select.equals("6")) { + datefield1 = TimeUtil.getDateByOption(datefield1select, "0"); + datefield1to = TimeUtil.getDateByOption(datefield1select, "1"); + } + String datefield2 = Util.toScreenToEdit((String) params.get("datefield2"), user.getLanguage()); + String datefield2to = Util.toScreenToEdit((String) params.get("datefieldto2"), user.getLanguage()); + String datefield2select = Util.fromScreen((String) params.get("datefield2select"), user.getLanguage()); + if (!datefield2select.equals("") && !datefield2select.equals("0") && !datefield2select.equals("6")) { + datefield2 = TimeUtil.getDateByOption(datefield2select, "0"); + datefield2to = TimeUtil.getDateByOption(datefield2select, "1"); + } + String datefield3 = Util.toScreenToEdit((String) params.get("datefield3"), user.getLanguage()); + String datefield3to = Util.toScreenToEdit((String) params.get("datefieldto3"), user.getLanguage()); + String datefield3select = Util.fromScreen((String) params.get("datefield3select"), user.getLanguage()); + if (!datefield3select.equals("") && !datefield3select.equals("0") && !datefield3select.equals("6")) { + datefield3 = TimeUtil.getDateByOption(datefield3select, "0"); + datefield3to = TimeUtil.getDateByOption(datefield3select, "1"); + } + String datefield4 = Util.toScreenToEdit((String) params.get("datefield4"), user.getLanguage()); + String datefield4to = Util.toScreenToEdit((String) params.get("datefieldto4"), user.getLanguage()); + String datefield4select = Util.fromScreen((String) params.get("datefield4select"), user.getLanguage()); + if (!datefield4select.equals("") && !datefield4select.equals("0") && !datefield4select.equals("6")) { + datefield4 = TimeUtil.getDateByOption(datefield4select, "0"); + datefield4to = TimeUtil.getDateByOption(datefield4select, "1"); + } + String datefield5 = Util.toScreenToEdit((String) params.get("datefield5"), user.getLanguage()); + String datefield5to = Util.toScreenToEdit((String) params.get("datefieldto5"), user.getLanguage()); + String datefield5select = Util.fromScreen((String) params.get("datefield5select"), user.getLanguage()); + if (!datefield5select.equals("") && !datefield5select.equals("0") && !datefield5select.equals("6")) { + datefield5 = TimeUtil.getDateByOption(datefield5select, "0"); + datefield5to = TimeUtil.getDateByOption(datefield5select, "1"); + } + String numberfield1 = Util.toScreenToEdit((String) params.get("numberfield1"), user.getLanguage()); + String numberfield1to = Util.toScreenToEdit((String) params.get("numberfieldto1"), user.getLanguage()); + String numberfield2 = Util.toScreenToEdit((String) params.get("numberfield2"), user.getLanguage()); + String numberfield2to = Util.toScreenToEdit((String) params.get("numberfieldto2"), user.getLanguage()); + String numberfield3 = Util.toScreenToEdit((String) params.get("numberfield3"), user.getLanguage()); + String numberfield3to = Util.toScreenToEdit((String) params.get("numberfieldto3"), user.getLanguage()); + String numberfield4 = Util.toScreenToEdit((String) params.get("numberfield4"), user.getLanguage()); + String numberfield4to = Util.toScreenToEdit((String) params.get("numberfieldto4"), user.getLanguage()); + String numberfield5 = Util.toScreenToEdit((String) params.get("numberfield5"), user.getLanguage()); + String numberfield5to = Util.toScreenToEdit((String) params.get("numberfieldto5"), user.getLanguage()); + String tff01name = Util.toScreenToEdit((String) params.get("textfield1"), user.getLanguage()); + String tff02name = Util.toScreenToEdit((String) params.get("textfield2"), user.getLanguage()); + String tff03name = Util.toScreenToEdit((String) params.get("textfield3"), user.getLanguage()); + String tff04name = Util.toScreenToEdit((String) params.get("textfield4"), user.getLanguage()); + String tff05name = Util.toScreenToEdit((String) params.get("textfield5"), user.getLanguage()); + String bff01name = Util.toScreenToEdit((String) params.get("tinyintfield1"), user.getLanguage()); + String bff02name = Util.toScreenToEdit((String) params.get("tinyintfield2"), user.getLanguage()); + String bff03name = Util.toScreenToEdit((String) params.get("tinyintfield3"), user.getLanguage()); + String bff04name = Util.toScreenToEdit((String) params.get("tinyintfield4"), user.getLanguage()); + String bff05name = Util.toScreenToEdit((String) params.get("tinyintfield5"), user.getLanguage()); + + String createdatefrom = Util.fromScreen((String) params.get("createdatefrom"), user.getLanguage()); + String createdateto = Util.fromScreen((String) params.get("createdateto"), user.getLanguage()); + String createdateselect = Util.fromScreen((String) params.get("createdateselect"), user.getLanguage()); + if (!createdateselect.equals("") && !createdateselect.equals("0") && !createdateselect.equals("6")) { + createdatefrom = TimeUtil.getDateByOption(createdateselect, "0"); + createdateto = TimeUtil.getDateByOption(createdateselect, "1"); + } + + String virtualtype = Util.null2String(params.get("virtualtype")); + if (virtualtype.length() == 0) { + virtualtype = Util.null2String(params.get("virtualCompanyid")); + } + String belongto = Util.fromScreen((String) params.get("belongto"), user.getLanguage()); + String nodetype = Util.fromScreen((String) params.get("type"), user.getLanguage()); + if (nodetype.equals("0") && virtualtype.length() == 0) {//总部 + virtualtype = Util.fromScreen((String) params.get("id"), user.getLanguage()); + } + + if (nodetype.equals("1") && subcompanyid1.length() == 0) {//分部 + subcompanyid1 = Util.fromScreen((String) params.get("id"), user.getLanguage()); + } + + if (nodetype.equals("2") && departmentid.length() == 0) {//部门 + departmentid = Util.fromScreen((String) params.get("id"), user.getLanguage()); + } + + int scopeId = 0; + Map customFieldMapBase = new HashMap(); + if (request != null) { + Enumeration en = request.getParameterNames(); + while (en.hasMoreElements()) { + String paramName = en.nextElement(); + if (paramName.indexOf("column_" + scopeId + "_") > -1 && !paramName.endsWith("_")) { + if (Util.splitString(paramName, "_")[2].indexOf("select") > -1) { + String dateselect = Util.fromScreen2((String) params.get(paramName), user.getLanguage()); + if (!dateselect.equals("") && !dateselect.equals("0") && !dateselect.equals("6")) { + customFieldMapBase.put(Util.splitString(paramName, "_")[2].replace("select", "from"), TimeUtil.getDateByOption(dateselect, "0")); + customFieldMapBase.put(Util.splitString(paramName, "_")[2].replace("select", "to"), TimeUtil.getDateByOption(dateselect, "1")); + continue; + } else { + continue; + } + } + customFieldMapBase.put(Util.splitString(paramName, "_")[2], Util.fromScreen2((String) params.get(paramName), user.getLanguage())); + } + } + } + + scopeId = 1; + Map customFieldMapPersonal = new HashMap(); + if (request != null) { + Enumeration en = request.getParameterNames(); + while (en.hasMoreElements()) { + String paramName = (String) en.nextElement(); + if (paramName.indexOf("column_" + scopeId + "_") > -1 && !paramName.endsWith("_")) { + if (Util.splitString(paramName, "_")[2].indexOf("select") > -1) { + String dateselect = Util.fromScreen2((String) params.get(paramName), user.getLanguage()); + if (!dateselect.equals("") && !dateselect.equals("0") && !dateselect.equals("6")) { + customFieldMapPersonal.put(Util.splitString(paramName, "_")[2].replace("select", "from"), TimeUtil.getDateByOption(dateselect, "0")); + customFieldMapPersonal.put(Util.splitString(paramName, "_")[2].replace("select", "to"), TimeUtil.getDateByOption(dateselect, "1")); + continue; + } else { + continue; + } + } + customFieldMapPersonal.put(Util.splitString(paramName, "_")[2], Util.fromScreen2((String) params.get(paramName), user.getLanguage())); + } + } + } + + scopeId = 3; + Map customFieldMapWork = new HashMap(); + if (request != null) { + Enumeration en = request.getParameterNames(); + while (en.hasMoreElements()) { + String paramName = (String) en.nextElement(); + if (paramName.indexOf("column_" + scopeId + "_") > -1 && !paramName.endsWith("_")) { + if (Util.splitString(paramName, "_")[2].indexOf("select") > -1) { + String dateselect = Util.fromScreen2((String) params.get(paramName), user.getLanguage()); + if (!dateselect.equals("") && !dateselect.equals("0") && !dateselect.equals("6")) { + customFieldMapWork.put(Util.splitString(paramName, "_")[2].replace("select", "from"), TimeUtil.getDateByOption(dateselect, "0")); + customFieldMapWork.put(Util.splitString(paramName, "_")[2].replace("select", "to"), TimeUtil.getDateByOption(dateselect, "1")); + continue; + } else { + continue; + } + } + customFieldMapWork.put(Util.splitString(paramName, "_")[2], Util.fromScreen2((String) params.get(paramName), user.getLanguage())); + } + } + } + + boolean isoracle = RecordSet.getDBType().toLowerCase().equals("oracle"); + String from = Util.fromScreen((String) params.get("from"), user.getLanguage()); + + String searchFrom = "";//搜索来做哪里:quick表示来自于快捷搜索; + + String strResult = " "; + int ishead = 0; + + Calendar today = Calendar.getInstance(); + String currentdate = Util.add0(today.get(Calendar.YEAR), 4) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + + String birthbyage = ""; + String birthbyageto = ""; + + int tempyear = Util.getIntValue(Util.add0(today.get(Calendar.YEAR), 4)); + + if (!age.equals("")) { + birthbyage = (tempyear - Util.getIntValue(age)) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + } + + if (!ageto.equals("")) { + birthbyageto = (tempyear - Util.getIntValue(ageto)) + "-" + + Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" + + Util.add0(today.get(Calendar.DAY_OF_MONTH), 2); + } + + //二开 + BaseBean basebean = new BaseBean(); + String contactsTabId = basebean.getPropValue("project_sskj", "contactsTabId"); + + if (tabkey.equals("default_123")) {//根据tabkey的值来查询同分部的人员 + if (ishead == 0) { + ishead = 1; + strResult = "where "; + RecordSet rs = new RecordSet(); + + String sql = " WITH allsub(id) as ( SELECT id FROM hrmsubcompany where id= "+user.getUserSubCompany1()+ + " union ALL select a.id FROM hrmsubcompany a,allsub b where a.supsubcomid = b.id) select * from allsub "; + rs.execute(sql); + Integer index = 0; + while (rs.next()) { + if (index == 0) { + strResult += " subcompanyid1= "+rs.getString("id"); + index++; + } else { + strResult += " or subcompanyid1= "+rs.getString("id"); + + } + } + + } else { + strResult += " and 1=1 "; + RecordSet rs = new RecordSet(); + + String sql = " WITH allsub(id) as ( SELECT id FROM hrmsubcompany where id= "+user.getUserSubCompany1()+ + " union ALL select a.id FROM hrmsubcompany a,allsub b where a.supsubcomid = b.id) select * from allsub "; + rs.execute(sql); + while (rs.next()) { + strResult += " or subcompanyid1= "+rs.getString("id"); + } + } + } else if (tabkey.equals("default_1")) { + if (ishead == 0) { + ishead = 1; + strResult = " where departmentid = " + user.getUserDepartment(); + } else { + strResult += " and departmentid = " + user.getUserDepartment(); + } + } else if (tabkey.equals("default_2")) { + if (showAllLevel.equals("1")) { + if (ishead == 0) { + ishead = 1; + strResult = " where managerstr like '%," + user.getUID() + ",%'"; + } else { + strResult += " and managerstr like '%," + user.getUID() + ",%'"; + } + } else { + if (ishead == 0) { + ishead = 1; + strResult = " where managerid = " + user.getUID(); + } else { + strResult += " and managerid = " + user.getUID(); + } + } + }else if (tabkey.equals("default_4")) { + ResourceBelongtoComInfo resourceBelongtoComInfo = new ResourceBelongtoComInfo(); + List lsUser = resourceBelongtoComInfo.getBelongtousers(superid); + + String ids = ""; + for (int i = 0; lsUser != null && i < lsUser.size(); i++) { + User user = (User) lsUser.get(i); + Integer idnew = user.getUID(); + if (ids.length() > 0) + ids += ","; + ids += idnew; + } + if (ishead == 0) { + ishead = 1; + strResult = " where id in (" + ids + ")"; + } else { + strResult += " and id in (" + ids + ")"; + } + + } else if (tabkey.equals(contactsTabId)) {//二开 + //获取人员的所在部门 + String department = Util.null2String(user.getUserDepartment()); + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + String subcomp = departmentComInfo.getSubcompanyid1(department); + List allChildDeptList = getAllChildDept(department, subcomp); + String allChildDept = String.join(",",allChildDeptList); + if (ishead == 0) { + ishead = 1; + strResult = " where departmentid in ( " + allChildDept +" ) "; + } else { + strResult += " and departmentid in ( " + allChildDept +" ) "; + } + } + + + if (!resourcename.equals("")) { + String encodeResourceName = resourcename;//weaver.common.StringUtil.string2Unicode(resourcename); + if (ishead == 0) { + ishead = 1; + strResult = " where"; + } else { + strResult += " and"; + } + String mysqlEscope = "/"; + if ("hrmResource".equals(searchFrom)) { + if (DialectUtil.isMySql()) { + strResult += " (lastname like '%" + Util.StringReplace(resourcename, "_", mysqlEscope + "_") + + "%' escape '" + mysqlEscope + "' or pinyinlastname like '%" + Util.StringReplace(resourcename.toLowerCase(), "_", mysqlEscope + "_") + + "%' escape '" + mysqlEscope + "' or lastname like '%" + Util.StringReplace(encodeResourceName, "_", mysqlEscope + "_") + + "%' or pinyinlastname like '%" + Util.StringReplace(encodeResourceName.toLowerCase(), "_", mysqlEscope + "_") + "%')"; + } else { + strResult += " (lastname like '%" + Util.StringReplace(resourcename, "_", "\\_") + + "%' escape '\\' or pinyinlastname like '%" + Util.StringReplace(resourcename.toLowerCase(), "_", "\\_") + + "%' escape '\\' or lastname like '%" + Util.StringReplace(encodeResourceName, "_", "\\_") + + "%' or pinyinlastname like '%" + Util.StringReplace(encodeResourceName.toLowerCase(), "_", "\\_") + "%')"; + } + + } else { + if (DialectUtil.isMySql()) { + strResult += " (lastname like '%" + Util.StringReplace(resourcename, "_", mysqlEscope + "_") + "%' escape '" + mysqlEscope + "' or pinyinlastname like '%" + + Util.StringReplace(resourcename.toLowerCase(), "_", mysqlEscope + "_") + + "%' escape '" + mysqlEscope + "' or mobile like '%" + Util.StringReplace(resourcename, "_", mysqlEscope + "_") + + "%' escape '" + mysqlEscope + "' or lastname like '%" + Util.StringReplace(encodeResourceName, "_", "_") + + "%' or pinyinlastname like '%" + Util.StringReplace(encodeResourceName.toLowerCase(), "_", mysqlEscope + "_") + + "%' or workcode like '%" + Util.StringReplace(encodeResourceName.toLowerCase(), "_", mysqlEscope + "_") + + "%' or mobile like '%" + Util.StringReplace(encodeResourceName, "_", mysqlEscope + "_") + "%')"; + } else { + strResult += " (lastname like '%" + Util.StringReplace(resourcename, "_", "\\_") + + "%' escape '\\' or pinyinlastname like '%" + Util.StringReplace(resourcename.toLowerCase(), "_", "\\_") + + "%' escape '\\' or mobile like '%" + Util.StringReplace(resourcename, "_", "\\_") + + "%' escape '\\' or lastname like '%" + Util.StringReplace(encodeResourceName, "_", "\\_") + + "%' or pinyinlastname like '%" + Util.StringReplace(encodeResourceName.toLowerCase(), "_", "\\_") + + "%' or workcode like '%" + Util.StringReplace(encodeResourceName.toLowerCase(), "_", "\\_") + + "%' or mobile like '%" + Util.StringReplace(encodeResourceName, "_", "\\_") + "%')"; + } + } + } + + if (!belongto.equals("") && !belongto.equals("0")) { + if (ishead == 0) { + ishead = 1; + strResult = " where belongto = " + belongto + " "; + } else { + strResult += " and belongto =" + belongto + " "; + } + } + + if (!jobtitle.equals("") && !jobtitle.equals("0")) { + if (ishead == 0) { + ishead = 1; + strResult = " where jobtitle in(select id from HrmJobTitles where jobtitlename like '%" + jobtitle + "%')"; + } else { + strResult += " and jobtitle in(select id from HrmJobTitles where jobtitlename like '%" + jobtitle + "%')"; + } + } + + if (!activitydesc.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where jobactivitydesc like '%" + activitydesc + "%' "; + } else { + strResult += " and jobactivitydesc like '%" + activitydesc + "%' "; + } + } + + if (!jobgroup.equals("") && !jobgroup.equals("0")) { + if (ishead == 0) { + ishead = 1; + strResult = " where jobtitle in( select id from HrmJobTitles where jobactivityid in( select id from HrmJobActivities where jobgroupid = " + jobgroup + ")) "; + } else { + strResult += " and jobtitle in( select id from HrmJobTitles where jobactivityid in( select id from HrmJobActivities where jobgroupid = " + jobgroup + ")) "; + } + } + + if (!jobactivity.equals("") && !jobactivity.equals("0")) { + if (ishead == 0) { + ishead = 1; + strResult = " where jobtitle in(select id from HrmJobTitles where jobactivityid = " + jobactivity + ") "; + } else { + strResult += " and jobtitle in(select id from HrmJobTitles where jobactivityid = " + jobactivity + ") "; + } + } + + if (!costcenter.equals("") && !costcenter.equals("0")) { + if (ishead == 0) { + ishead = 1; + strResult = " where costcenterid = " + costcenter; + } else { + strResult += " and costcenterid = " + costcenter; + } + } + + if (!resourcetype.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where resourcetype = '" + resourcetype + "' "; + } else { + strResult += " and resourcetype = '" + resourcetype + "' "; + } + } + + if (!subcompanyid1.equals("0") && !subcompanyid1.equals("")) { + try { + String subcompanyAll; + if (subcompanyid1.startsWith("-")) {//多维 + subcompanyAll = ""; + + String[] sub = subcompanyid1.split(","); + if (sub != null) { + for (int cx = 0; cx < sub.length; cx++) { + String subid_ = sub[cx]; + if (subid_ != null && !"".equals(subid_) && showAllLevel.equals("1")) { + subcompanyAll = SubCompanyVirtualComInfo.getAllChildSubcompanyId(subid_, subcompanyAll); + } + } + } + if (!"".equals(subcompanyAll)) { + subcompanyAll = subcompanyid1 + subcompanyAll.trim(); + } else { + subcompanyAll = subcompanyid1; + } + if (ishead == 0) { + ishead = 1; + strResult = " where EXISTS (SELECT * FROM hrmresourcevirtual WHERE hrmresource.id = resourceid AND hrmresourcevirtual.subcompanyid IN ( " + subcompanyAll + " ) )"; + } else { + strResult += " and EXISTS (SELECT * FROM hrmresourcevirtual WHERE hrmresource.id = resourceid AND hrmresourcevirtual.subcompanyid IN ( " + subcompanyAll + " ) )"; + } + } else { + subcompanyAll = ""; + + String[] sub = subcompanyid1.split(","); + if (sub != null) { + for (int cx = 0; cx < sub.length; cx++) { + String subid_ = sub[cx]; + if (subid_ != null && !"".equals(subid_) && showAllLevel.equals("1")) { + subcompanyAll = SubCompanyComInfo.getAllChildSubcompanyId(subid_, subcompanyAll); + } + } + } + if (!"".equals(subcompanyAll)) { + subcompanyAll = subcompanyid1 + subcompanyAll.trim(); + } else { + subcompanyAll = subcompanyid1; + } + String tmpSql = Tools.getOracleSQLIn(subcompanyAll, "subcompanyid1"); + if (ishead == 0) { + ishead = 1; + strResult = " where (" + tmpSql + ")"; + } else { + strResult += " and (" + tmpSql + ")"; + } + } + } catch (Exception e) { + writeLog(e.getMessage()); + } + } + + if (!departmentid.equals("") && !departmentid.equals("0")) { + try { + //组织图表的查询人员还是根据传入的分部,部门来显示 + if ("hrmorg".equalsIgnoreCase(from)) { + if (departmentid.startsWith("-")) {//多维 + + String tmpSql = Tools.getOracleSQLIn(departmentid, "hrmresourcevirtual.departmentid"); + if (ishead == 0) { + ishead = 1; + strResult = " where EXISTS (SELECT * FROM hrmresourcevirtual WHERE hrmresource.id = resourceid AND ( " + tmpSql + " ) )"; + } else { + strResult += " and EXISTS (SELECT * FROM hrmresourcevirtual WHERE hrmresource.id = resourceid AND ( " + tmpSql + " ) )"; + } + } else { + String tmpSql = Tools.getOracleSQLIn(departmentid, "departmentid"); + if (ishead == 0) { + ishead = 1; + strResult = " where (" + tmpSql + ")"; + } else { + strResult += " and (" + tmpSql + ")"; + } + } + } else { + String departmentAll; + if (departmentid.startsWith("-")) {//多维 + departmentAll = ""; + + String[] dep = departmentid.split(","); + if (dep != null) { + for (int cx = 0; cx < dep.length; cx++) { + String depid_ = dep[cx]; + if (depid_ != null && !"".equals(depid_) && showAllLevel.equals("1")) { + departmentAll = DepartmentVirtualComInfo.getAllChildDepartId(depid_, departmentAll); + } + } + } + if (!"".equals(departmentAll)) { + departmentAll = departmentid + departmentAll.trim(); + } else { + departmentAll = departmentid; + } + if (ishead == 0) { + ishead = 1; + strResult = " where EXISTS (SELECT * FROM hrmresourcevirtual WHERE hrmresource.id = resourceid AND hrmresourcevirtual.departmentid IN ( " + departmentAll + " ) )"; + } else { + strResult += " and EXISTS (SELECT * FROM hrmresourcevirtual WHERE hrmresource.id = resourceid AND hrmresourcevirtual.departmentid IN ( " + departmentAll + " ) )"; + } + } else { + + departmentAll = ""; + + String[] dep = departmentid.split(","); + if (dep != null) { + for (int cx = 0; cx < dep.length; cx++) { + String depid_ = dep[cx]; + if (depid_ != null && !"".equals(depid_) && showAllLevel.equals("1")) { + departmentAll = DepartmentComInfo.getAllChildDepartId(depid_, departmentAll); + } + } + } + if (!"".equals(departmentAll)) { + departmentAll = departmentid + departmentAll.trim(); + } else { + departmentAll = departmentid; + } + String tmpSql = Tools.getOracleSQLIn(departmentAll, "departmentid"); + if (ishead == 0) { + ishead = 1; + strResult = " where (" + tmpSql + ")"; + } else { + strResult += " and (" + tmpSql + ")"; + } + } + } + } catch (Exception e) { + writeLog(e.getMessage()); + } + } + + if (!groupId.equals("")) {//常用组查询条件(通讯录不需要增加权限查看,有公共组的共享范围就放出可查看人员) + boolean cansave = true; + // boolean cansave = HrmUserVarify.checkUserRight("CustomGroup:Edit", user); + String conditionSql = ""; + if(!cansave){ + conditionSql += " and groupid in (SELECT id FROM HrmGroup WHERE owner=" + user.getUID() + " AND TYPE=0 AND (canceled IS NULL OR canceled !='1'))"; + }else{ + conditionSql += " and groupid in (SELECT id FROM HrmGroup WHERE ((owner=" + user.getUID() + " AND TYPE=0) OR TYPE=1) AND (canceled IS NULL OR canceled !='1'))"; + } + if (ishead == 0) { + ishead = 1; + strResult = " where EXISTS (select 1 from HrmGroupMembers where hrmResource.id=userid and groupid=" + groupId + conditionSql + ") "; + } else { + strResult += " and EXISTS (select 1 from HrmGroupMembers where hrmResource.id=userid and groupid=" + groupId + conditionSql + ") "; + } + } + + if (!location.equals("") && !location.equals("0")) { + if (ishead == 0) { + ishead = 1; + strResult = " where locationid = " + location; + } else { + strResult += " and locationid = " + location; + } + } + + if (!manager.equals("") && !manager.equals("0")) { + if (ishead == 0) { + ishead = 1; + strResult = " where managerid = " + manager; + } else { + strResult += " and managerid = " + manager; + } + } + + if (!assistant.equals("") && !assistant.equals("0")) { + if (ishead == 0) { + ishead = 1; + strResult = " where assistantid = " + assistant; + } else { + strResult += " and assistantid = " + assistant; + } + } + + if (!roles.equals("") && !roles.equals("0")) { + String roleSql = " SELECT distinct resourceid FROM ( " + + " SELECT a.id AS resourceid, b.roleid , b.rolelevel FROM HrmResource a, HrmRoleMembers b " + + " WHERE (a.id=b.resourceid and b.resourcetype=1) " + + " UNION ALL " + + " SELECT a.id AS resourceid, b.roleid , b.rolelevel FROM HrmResourceManager a, HrmRoleMembers b " + + " WHERE (a.id=b.resourceid and b.resourcetype IN(7,8)) " + + " UNION ALL " + + " SELECT a.id AS resourceid, b.roleid , b.rolelevel FROM HrmResource a, HrmRoleMembers b " + + " WHERE (a.subcompanyid1 = b.resourceid AND a.seclevel>=b.seclevelfrom AND a.seclevel<=b.seclevelto AND b.resourcetype=2) " + + " UNION ALL " + + " SELECT a.id AS resourceid, b.roleid , b.rolelevel FROM HrmResource a, HrmRoleMembers b " + + " WHERE (a.departmentid = b.resourceid AND a.seclevel>=b.seclevelfrom AND a.seclevel<=b.seclevelto AND b.resourcetype=3) " + + " UNION ALL " + + " SELECT a.id AS resourceid, b.roleid , b.rolelevel FROM HrmResource a, HrmRoleMembers b " + + " WHERE (a.jobtitle = b.resourceid AND b.resourcetype=5 AND (b.jobtitlelevel=1 OR (b.jobtitlelevel=2 AND a.subcompanyid1 IN(b.subdepid)) OR (b.jobtitlelevel=3 AND a.departmentid IN(b.subdepid))))) t " + + " WHERE roleid in ( " + roles + ")"; + if (ishead == 0) { + ishead = 1; + strResult = " where HrmResource.id in( " + roleSql + ")"; + } else { + strResult += " and HrmResource.id in( " + "+roleSql+" + ")"; + } + } + + if (!seclevel.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where seclevel >= " + seclevel; + } else { + strResult += " and seclevel >= " + seclevel; + } + } + + if (!seclevelto.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where seclevel <= " + seclevelto; + } else { + strResult += " and seclevel <= " + seclevelto; + } + } + + if (!joblevel.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where joblevel >= " + joblevel; + } else { + strResult += " and joblevel >= " + joblevel; + } + } + + if (!joblevelto.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where joblevel <= " + joblevelto; + } else { + strResult += " and joblevel <= " + joblevelto; + } + } + + if (!workroom.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where workroom like '%" + workroom + "%'"; + } else { + strResult += " and workroom like '%" + workroom + "%'"; + } + } + + if (!telephone.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where telephone like '%" + telephone + "%'"; + } else { + strResult += " and telephone like '%" + telephone + "%'"; + } + } + + if (!startdate.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where startdate >= '" + startdate + "'"; + } else { + strResult += " and startdate >= '" + startdate + "'"; + } + } + + if (!startdateto.equals("")) { + if (!isoracle) { + if (ishead == 0) { + ishead = 1; + strResult = " where startdate <= '" + startdateto + "' and startdate<>''"; + } else { + strResult += " and startdate <= '" + startdateto + "' and startdate<>''"; + } + } else { //如果数据库为oracle的话 + if (ishead == 0) { + ishead = 1; + strResult = " where startdate <= '" + startdateto + "' and startdate is not null"; + } else { + strResult += " and startdate <= '" + startdateto + "' and startdate is not null"; + } + } + } + + //拼接入职日期查询条件 + if (!companystartdate.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where companystartdate >= '" + companystartdate + "'"; + } else { + strResult += " and companystartdate >= '" + companystartdate + "'"; + } + } + + if (!companystartdateto.equals("")) { + if (!isoracle) { + if (ishead == 0) { + ishead = 1; + strResult = " where companystartdate <= '" + companystartdateto + "' and companystartdate<>''"; + } else { + strResult += " and companystartdate <= '" + companystartdateto + "' and companystartdate<>''"; + } + } else { //如果数据库为oracle的话 + if (ishead == 0) { + ishead = 1; + strResult = " where companystartdate <= '" + companystartdateto + "' and companystartdate is not null"; + } else { + strResult += " and companystartdate <= '" + companystartdateto + "' and companystartdate is not null"; + } + } + } + + //拼接参加工作查询条件 + if (!workstartdate.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where workstartdate >= '" + workstartdate + "'"; + } else { + strResult += " and workstartdate >= '" + workstartdate + "'"; + } + } + + if (!companyworkyear.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where companyworkyear >= " + companyworkyear; + } else { + strResult += " and companyworkyear >= " + companyworkyear; + } + } + + if (!companyworkyearto.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where companyworkyear <= " + companyworkyearto; + } else { + strResult += " and companyworkyear <= " + companyworkyearto; + } + } + + if (!workstartdateto.equals("")) { + if (!isoracle) { + if (ishead == 0) { + ishead = 1; + strResult = " where workstartdate <= '" + workstartdateto + "' and workstartdate<>''"; + } else { + strResult += " and workstartdate <= '" + workstartdateto + "' and workstartdate<>''"; + } + } else { //如果数据库为oracle的话 + if (ishead == 0) { + ishead = 1; + strResult = " where workstartdate <= '" + workstartdateto + "' and workstartdate is not null"; + } else { + strResult += " and workstartdate <= '" + workstartdateto + "' and workstartdate is not null"; + } + } + } + + if (!workyear.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where workyear >= " + workyear; + } else { + strResult += " and workyear >= " + workyear; + } + } + + if (!workyearto.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where workyear <= " + workyearto; + } else { + strResult += " and workyear <= " + workyearto; + } + } + + if (!enddate.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where enddate >= '" + enddate + "'"; + } else { + strResult += " and enddate >= '" + enddate + "'"; + } + } + if (!enddateto.equals("")) { + if (!isoracle) { + if (ishead == 0) { + ishead = 1; + strResult = " where enddate <= '" + enddateto + "' and enddate<>''"; + } else { + strResult += " and enddate <= '" + enddateto + "' and enddate<>''"; + } + } else { //如果数据库为oracle的话 + if (ishead == 0) { + ishead = 1; + strResult = " where enddate <= '" + enddateto + "' and enddate is not null"; + } else { + strResult += " and enddate <= '" + enddateto + "' and enddate is not null"; + } + } + } + + + if (!contractdate.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where probationenddate >= '" + contractdate + "'"; + } else { + strResult += " and probationenddate >= '" + contractdate + "'"; + } + } + if (!contractdateto.equals("")) { + if (!isoracle) { + if (ishead == 0) { + ishead = 1; + strResult = " where probationenddate <= '" + contractdateto + "' and probationenddate<>''"; + } else { + strResult += " and probationenddate <= '" + contractdateto + "' and probationenddate<>''"; + } + } else { //如果数据库为oracle的话 + if (ishead == 0) { + ishead = 1; + strResult = " where probationenddate <= '" + contractdateto + "' and probationenddate is not null"; + } else { + strResult += " and probationenddate <= '" + contractdateto + "' and probationenddate is not null"; + } + } + } + + if (!createdatefrom.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where createdate >= '" + createdatefrom + "'"; + } else { + strResult += " and createdate >= '" + createdatefrom + "'"; + } + } + if (!createdateto.equals("")) { + if (!isoracle) { + if (ishead == 0) { + ishead = 1; + strResult = " where createdate <= '" + createdateto + "' and createdate<>''"; + } else { + strResult += " and createdate <= '" + createdateto + "' and createdate<>''"; + } + } else { //如果数据库为oracle的话 + if (ishead == 0) { + ishead = 1; + strResult = " where createdate <= '" + createdateto + "' and createdate is not null"; + } else { + strResult += " and createdate <= '" + createdateto + "' and createdate is not null"; + } + } + } + + if (!birthday.equals("")) { + if (!isoracle) { + if (ishead == 0) { + ishead = 1; + strResult = " where birthday >= '" + birthday + "' and birthday<>''"; + } else { + strResult += " and birthday >= '" + birthday + "' and birthday<>''"; + } + } else { //如果数据库为oracle的话 + if (ishead == 0) { + ishead = 1; + strResult = " where birthday >= '" + birthday + "' and birthday is not null"; + } else { + strResult += " and birthday >= '" + birthday + "' and birthday is not null"; + } + } + } + + if (!birthdayto.equals("")) { + if (!isoracle) { + if (ishead == 0) { + ishead = 1; + strResult = " where birthday <= '" + birthdayto + "' and birthday<>''"; + } else { + strResult += " and birthday <= '" + birthdayto + "' and birthday<>''"; + } + } else { //如果数据库为oracle的话 + if (ishead == 0) { + ishead = 1; + strResult = " where birthday <= '" + birthdayto + "' and birthday is not null"; + } else { + strResult += " and birthday <= '" + birthdayto + "' and birthday is not null"; + } + } + } + + if (!birthbyage.equals("")) { + if (!isoracle) { + if (ishead == 0) { + ishead = 1; + strResult = " where birthday <= '" + birthbyage + "' and birthday<>''"; + } else { + strResult += " and birthday <= '" + birthbyage + "' and birthday<>''"; + } + } else { //如果数据库为oracle的话 + if (ishead == 0) { + ishead = 1; + strResult = " where birthday <= '" + birthbyage + "' and birthday is not null"; + } else { + strResult += " and birthday <= '" + birthbyage + "' and birthday is not null"; + } + } + } + + if (!birthbyageto.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where birthday >= '" + birthbyageto + "' "; + } else { + strResult += " and birthday >= '" + birthbyageto + "' "; + } + } + + if (!sex.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where sex = '" + sex + "'"; + } else { + strResult += " and sex = '" + sex + "'"; + } + } + + if (accounttype != -1) { + if (ishead == 0) { + ishead = 1; + if (accounttype == 0) + strResult = " where (accounttype=0 OR accounttype IS NULL)"; + else + strResult = " where accounttype=1"; + } else { + if (accounttype == 0) + strResult += " and (accounttype=0 OR accounttype IS NULL)"; + else + strResult += " and accounttype=1"; + } + } + + if (!resourceidfrom.equals("") && !resourceidfrom.equals("0")) { + if (ishead == 0) { + ishead = 1; + strResult = " where id >= " + resourceidfrom; + } else { + strResult += " and id >= " + resourceidfrom; + } + } + + if (!resourceidto.equals("") && !resourceidto.equals("0")) { + if (ishead == 0) { + ishead = 1; + strResult = " where id <= " + resourceidto; + } else { + strResult += " and id <= " + resourceidto; + } + } + + if (!workcode.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where workcode like '%" + workcode + "%' "; + } else { + strResult += " and workcode like '%" + workcode + "%' "; + } + } + + if (!jobcall.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where jobcall = " + jobcall + " "; + } else { + strResult += " and jobcall = " + jobcall + " "; + } + } + + if (!mobile.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where mobile like '%" + mobile + "%' "; + } else { + strResult += " and mobile like '%" + mobile + "%' "; + } + } + + if (!mobilecall.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where mobilecall like '%" + mobilecall + "%' "; + } else { + strResult += " and mobilecall like '%" + mobilecall + "%' "; + } + } + + if (!fax.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where fax like '%" + fax + "%' "; + } else { + strResult += " and fax like '%" + fax + "%' "; + } + } + + if (!email.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where email like '%" + email + "%' "; + } else { + strResult += " and email like '%" + email + "%' "; + } + } + + if (!folk.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where folk like '%" + folk + "%' "; + } else { + strResult += " and folk like '%" + folk + "%' "; + } + } + + if (!nativeplace.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where nativeplace like '%" + nativeplace + "%' "; + } else { + strResult += " and nativeplace like '%" + nativeplace + "%' "; + } + } + + if (!regresidentplace.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where regresidentplace like '%" + regresidentplace + "%' "; + } else { + strResult += " and regresidentplace like '%" + regresidentplace + "%' "; + } + } + + if (!maritalstatus.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where maritalstatus = '" + maritalstatus + "' "; + } else { + strResult += " and maritalstatus = '" + maritalstatus + "' "; + } + } + + if (!certificatenum.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where certificatenum like '%" + certificatenum + "%' "; + } else { + strResult += " and certificatenum like '%" + certificatenum + "%' "; + } + } + + if (!tempresidentnumber.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where tempresidentnumber like '%" + tempresidentnumber + "%' "; + } else { + strResult += " and tempresidentnumber like '%" + tempresidentnumber + "%' "; + } + } + + if (!residentplace.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where residentplace like '%" + residentplace + "%' "; + } else { + strResult += " and residentplace like '%" + residentplace + "%' "; + } + } + + if (!homeaddress.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where homeaddress like '%" + homeaddress + "%' "; + } else { + strResult += " and homeaddress like '%" + homeaddress + "%' "; + } + } + + if (!healthinfo.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where healthinfo = '" + healthinfo + "' "; + } else { + strResult += " and healthinfo = '" + healthinfo + "' "; + } + } + + if (!heightfrom.equals("") && !heightfrom.equals("0")) { + if (ishead == 0) { + ishead = 1; + strResult = " where height >= " + heightfrom; + } else { + strResult += " and height >= " + heightfrom; + } + } + + if (!heightto.equals("") && !heightto.equals("0")) { + if (ishead == 0) { + ishead = 1; + strResult = " where height <= " + heightto; + } else { + strResult += " and height <= " + heightto; + } + } + + if (!weightfrom.equals("") && !weightfrom.equals("0")) { + if (ishead == 0) { + ishead = 1; + strResult = " where weight >= " + weightfrom; + } else { + strResult += " and weight >= " + weightfrom; + } + } + + if (!weightto.equals("") && !weightto.equals("0")) { + if (ishead == 0) { + ishead = 1; + strResult = " where weight <= " + weightto; + } else { + strResult += " and weight <= " + weightto; + } + } + + if (!educationlevel.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where educationlevel = " + educationlevel; + } else { + strResult += " and educationlevel = " + educationlevel; + } + } + + if (!educationlevelto.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where educationlevel <= " + educationlevelto; + } else { + strResult += " and educationlevel <= " + educationlevelto; + } + } + + if (!degree.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where degree like '%" + degree + "%' "; + } else { + strResult += " and degree like '%" + degree + "%' "; + } + } + + if (!usekind.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where usekind = " + usekind + " "; + } else { + strResult += " and usekind = " + usekind + " "; + } + } + + if (!policy.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where policy like '%" + policy + "%' "; + } else { + strResult += " and policy like '%" + policy + "%' "; + } + } + + + if (!bememberdatefrom.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where bememberdate >= '" + bememberdatefrom + "'"; + } else { + strResult += " and bememberdate >= '" + bememberdatefrom + "'"; + } + } + + + if (!bememberdateto.equals("")) { + if (!isoracle) { + if (ishead == 0) { + ishead = 1; + strResult = " where bememberdate <= '" + bememberdateto + "' and bememberdate<>''"; + } else { + strResult += " and bememberdate <= '" + bememberdateto + "' and bememberdate<>''"; + } + } else { //如果数据库为oracle的话 + if (ishead == 0) { + ishead = 1; + strResult = " where bememberdate <= '" + bememberdateto + "' and bememberdate is not null"; + } else { + strResult += " and bememberdate <= '" + bememberdateto + "' and bememberdate is not null"; + } + } + } + + if (!datefield1.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where datefield1 >= '" + datefield1 + "'"; + } else { + strResult += " and datefield1 >= '" + datefield1 + "'"; + } + } + if (!datefield2.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where datefield2 >= '" + datefield2 + "'"; + } else { + strResult += " and datefield2 >= '" + datefield2 + "'"; + } + } + if (!datefield3.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where datefield3 >= '" + datefield3 + "'"; + } else { + strResult += " and datefield3 >= '" + datefield3 + "'"; + } + } + if (!datefield4.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where datefield4 >= '" + datefield4 + "'"; + } else { + strResult += " and datefield4 >= '" + datefield4 + "'"; + } + } + if (!datefield5.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where datefield5 >= '" + datefield5 + "'"; + } else { + strResult += " and datefield5 >= '" + datefield5 + "'"; + } + } + if (!datefield1to.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where datefield1 <= '" + datefield1to + "'"; + } else { + strResult += " and datefield1 <= '" + datefield1to + "'"; + } + } + if (!datefield2to.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where datefield2 <= '" + datefield2to + "'"; + } else { + strResult += " and datefield2 <= '" + datefield2to + "'"; + } + } + if (!datefield3to.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where datefield3 <= '" + datefield3to + "'"; + } else { + strResult += " and datefield3 <= '" + datefield3to + "'"; + } + } + if (!datefield4to.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where datefield4 <= '" + datefield4to + "'"; + } else { + strResult += " and datefield4 <= '" + datefield4to + "'"; + } + } + if (!datefield5to.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where datefield5 <= '" + datefield5to + "'"; + } else { + strResult += " and datefield5 <= '" + datefield5to + "'"; + } + } + if (!numberfield1.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where numberfield1 >= " + numberfield1; + } else { + strResult += " and numberfield1 >= " + numberfield1; + } + } + + if (!numberfield1to.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where numberfield1 <= " + numberfield1to; + } else { + strResult += " and numberfield1 <= " + numberfield1to; + } + } + if (!numberfield2.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where numberfield2 >= " + numberfield2; + } else { + strResult += " and numberfield2 >= " + numberfield2; + } + } + + if (!numberfield2to.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where numberfield2 <= " + numberfield2to; + } else { + strResult += " and numberfield2 <= " + numberfield2to; + } + } + if (!numberfield3.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where numberfield3 >= " + numberfield3; + } else { + strResult += " and numberfield3 >= " + numberfield3; + } + } + + if (!numberfield3to.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where numberfield3 <= " + numberfield3to; + } else { + strResult += " and numberfield3 <= " + numberfield3to; + } + } + if (!numberfield4.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where numberfield4 >= " + numberfield4; + } else { + strResult += " and numberfield4 >= " + numberfield4; + } + } + + if (!numberfield4to.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where numberfield4 <= " + numberfield4to; + } else { + strResult += " and numberfield4 <= " + numberfield4to; + } + } + if (!numberfield5.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where numberfield5 >= " + numberfield5; + } else { + strResult += " and numberfield5 >= " + numberfield5; + } + } + + if (!numberfield5to.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where numberfield5 <= " + numberfield5to; + } else { + strResult += " and numberfield5 <= " + numberfield5to; + } + } + if (!tff01name.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where textfield1 like '%" + tff01name + "%' "; + } else { + strResult += " and textfield1 like '%" + tff01name + "%' "; + } + } + if (!tff02name.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where textfield2 like '%" + tff02name + "%' "; + } else { + strResult += " and textfield2 like '%" + tff02name + "%' "; + } + } + if (!tff03name.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where textfield3 like '%" + tff03name + "%' "; + } else { + strResult += " and textfield3 like '%" + tff03name + "%' "; + } + } + if (!tff04name.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where textfield4 like '%" + tff04name + "%' "; + } else { + strResult += " and textfield4 like '%" + tff04name + "%' "; + } + } + if (!tff05name.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where textfield5 like '%" + tff05name + "%' "; + } else { + strResult += " and textfield5 like '%" + tff05name + "%' "; + } + } + if (!bff01name.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where tinyintfield1 = " + bff01name + " "; + } else { + strResult += " and tinyintfield1 = " + bff01name + " "; + } + } + if (!bff02name.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where tinyintfield2 = " + bff02name + " "; + } else { + strResult += " and tinyintfield2 = " + bff02name + " "; + } + } + if (!bff03name.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where tinyintfield3 = " + bff03name + " "; + } else { + strResult += " and tinyintfield3 = " + bff03name + " "; + } + } + if (!bff04name.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where tinyintfield4 = " + bff04name + " "; + } else { + strResult += " and tinyintfield4 = " + bff04name + " "; + } + } + if (!bff05name.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where tinyintfield5 = " + bff05name + " "; + } else { + strResult += " and tinyintfield5 = " + bff05name + " "; + } + } + + if (!bepartydatefrom.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where bepartydate >= '" + bepartydatefrom + "'"; + } else { + strResult += " and bepartydate >= '" + bepartydatefrom + "'"; + } + } + /* + if(!bepartydateto.equals("")){ + if(ishead==0){ + ishead=1; + strResult = " where bepartydate <= '"+bepartydateto+"' and bepartydate<>''"; + }else{ + strResult += " and bepartydate <= '"+bepartydateto+"' and bepartydate<>''"; + } + } + */ + if (!bepartydateto.equals("")) { + if (!isoracle) { + if (ishead == 0) { + ishead = 1; + strResult = " where bepartydate <= '" + bepartydateto + "' and bepartydate <>''"; + } else { + strResult += " and bepartydate <= '" + bepartydateto + "' and bepartydate <>''"; + } + } else { //如果数据库为oracle的话 + if (ishead == 0) { + ishead = 1; + strResult = " where bepartydate <= '" + bepartydateto + "' and bepartydate is not null"; + } else { + strResult += " and bepartydate <= '" + bepartydateto + "' and bepartydate is not null"; + } + } + } + + if (!islabouunion.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where islabouunion = '" + islabouunion + "' "; + } else { + strResult += " and islabouunion = '" + islabouunion + "' "; + } + } + + if (!bankid1.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where bankid1 = " + bankid1 + " "; + } else { + strResult += " and bankid1 = " + bankid1 + " "; + } + } + + if (!accountid1.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where accountid1 like '%" + accountid1 + "%' "; + } else { + strResult += " and accountid1 like '%" + accountid1 + "%' "; + } + } + + if (!accumfundaccount.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where accumfundaccount like '%" + accumfundaccount + "%' "; + } else { + strResult += " and accumfundaccount like '%" + accumfundaccount + "%' "; + } + } + + if (!loginid.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where loginid like '%" + loginid + "%' "; + } else { + strResult += " and loginid like '%" + loginid + "%' "; + } + } + + if (!systemlanguage.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where systemlanguage = " + systemlanguage + " "; + } else { + strResult += " and systemlanguage = " + systemlanguage + " "; + } + } + + if (!status.equals("") && !status.equals("8") && !status.equals("9")) { + if (ishead == 0) { + ishead = 1; + strResult = " where status = " + status + " "; + } else { + strResult += " and status = " + status + " "; + } + } + + if (status.equals("8") || status.equals("")) { + if (ishead == 0) { + ishead = 1; + strResult = " where (status = 0 or status = 1 or status = 2 or status = 3) "; + } else { + strResult += " and (status = 0 or status = 1 or status = 2 or status = 3) "; + } + } + + + if (Util.getIntValue(virtualtype) < -1) { + if (ishead == 0) { + ishead = 1; + strResult = " where EXISTS ( SELECT * FROM hrmresourcevirtual WHERE hrmresource.id = hrmresourcevirtual.resourceid AND hrmresourcevirtual.virtualtype = " + virtualtype + " )"; + } else { + strResult += " and EXISTS ( SELECT * FROM hrmresourcevirtual WHERE hrmresource.id = hrmresourcevirtual.resourceid AND hrmresourcevirtual.virtualtype = " + virtualtype + " )"; + } + } + + if (customFieldMapBase.size() > 0) { + Set fieldidSet = customFieldMapBase.keySet(); + for (Iterator iter = fieldidSet.iterator(); iter.hasNext(); ) { + String fieldid = (String) iter.next(); + String value = (String) customFieldMapBase.get(fieldid); + String fieldhtmltype = ""; + String fielddbtype = ""; + String type = ""; + if (value.equals("")) continue; + if (ishead == 0) { + ishead = 1; + if (fieldid.indexOf("from") > 0) { + String realid = fieldid.substring(0, fieldid.indexOf("from")); + strResult = " where t0_field" + realid + ">='" + value + "'"; + } else if (fieldid.indexOf("to") > 0) { + String realid = fieldid.substring(0, fieldid.indexOf("to")); + strResult = " where t0_field" + realid + "<='" + value + "'"; + } else { + RecordSet rs = new RecordSet(); + rs.executeSql("select fieldhtmltype, fielddbtype, type from cus_formdict where id = " + fieldid); + if (rs.next()) { + fieldhtmltype = rs.getString("fieldhtmltype"); + fielddbtype = rs.getString("fielddbtype"); + type = rs.getString("type"); + } + if ("1".equals(fieldhtmltype) || "2".equals(fieldhtmltype) || "text".equals(fielddbtype)) { + strResult = " where t0_field" + fieldid + " like '%" + value + "%'"; + } else if (("3".equals(fieldhtmltype) && fielddbtype.toLowerCase().equals("text")) || "161".equals(type) || "162".equals(type)) { + strResult = " where 1=1 "; + strResult += " and ( 1=2 "; + //浏览框 id为逗号隔开的形式 + String[] vals = value.split(","); + for (String val : vals) { + if (val.length() == 0) continue; + if (isoracle) { + strResult += " or ','||cast(t0_field" + fieldid + " as VARCHAR2(4000))||',' like '%," + val + ",%'"; + } else if (DialectUtil.isMySql()) { + IDbDialectSql dialect = DbDialectFactory.get(rs.getDBType()); + String castCondition = dialect.castToChar("t0_field" + fieldid, 4000); + String dot = "','"; + String t0FieldConcat = dialect.concatStr(dot, castCondition, dot); + strResult += " or " + t0FieldConcat + " like '%," + val + ",%'"; + } else + strResult += " or ','+cast(t0_field" + fieldid + " as VARCHAR(4000))+',' like '%," + val + ",%'"; + } + strResult += " ) "; + } else { + strResult = " where t0_field" + fieldid + "='" + value + "'"; + } + } + } else { + if (fieldid.indexOf("from") > 0) { + String realid = fieldid.substring(0, fieldid.indexOf("from")); + strResult += " and t0_field" + realid + ">='" + value + "'"; + } else if (fieldid.indexOf("to") > 0) { + String realid = fieldid.substring(0, fieldid.indexOf("to")); + strResult += " and t0_field" + realid + "<='" + value + "'"; + } else { + RecordSet rs = new RecordSet(); + rs.executeSql("select fieldhtmltype, fielddbtype, type from cus_formdict where id = " + fieldid); + if (rs.next()) { + fieldhtmltype = rs.getString("fieldhtmltype"); + fielddbtype = rs.getString("fielddbtype"); + type = rs.getString("type"); + } + if ("1".equals(fieldhtmltype) || "2".equals(fieldhtmltype) || "text".equals(fielddbtype)) { + strResult += " and t0_field" + fieldid + " like '%" + value + "%'"; + } else if (("3".equals(fieldhtmltype) && fielddbtype.toLowerCase().equals("text")) || "161".equals(type) || "162".equals(type)) { + strResult += " and ( 1=2 "; + //浏览框 id为逗号隔开的形式 + String[] vals = value.split(","); + for (String val : vals) { + if (val.length() == 0) continue; + if (isoracle) { + strResult += " or ','||cast(t0_field" + fieldid + " as VARCHAR(4000))||',' like '%," + val + ",%'"; + } else if (DialectUtil.isMySql()) { + IDbDialectSql dialect = DbDialectFactory.get(rs.getDBType()); + String castCondition = dialect.castToChar("t0_field" + fieldid, 4000); + String dot = "','"; + String t0FieldConcat = dialect.concatStr(dot, castCondition, dot); + strResult += " or " + t0FieldConcat + " like '%," + val + ",%'"; + } else { + strResult += " or ','+cast(t0_field" + fieldid + " as NVARCHAR)+',' like '%," + val + ",%'"; + } + } + strResult += " ) "; + } else { + strResult += " and t0_field" + fieldid + "='" + value + "'"; + } + } + } + } + + } + + if (customFieldMapPersonal.size() > 0) { + Set fieldidSet = customFieldMapPersonal.keySet(); + for (Iterator iter = fieldidSet.iterator(); iter.hasNext(); ) { + String fieldid = (String) iter.next(); + String value = (String) customFieldMapPersonal.get(fieldid); + String fieldhtmltype = ""; + String fielddbtype = ""; + String type = ""; + if (value.equals("")) continue; + if (ishead == 0) { + ishead = 1; + if (fieldid.indexOf("from") > 0) { + String realid = fieldid.substring(0, fieldid.indexOf("from")); + strResult = " where t1_field" + realid + ">='" + value + "'"; + } else if (fieldid.indexOf("to") > 0) { + String realid = fieldid.substring(0, fieldid.indexOf("to")); + strResult = " where t1_field" + realid + "<='" + value + "'"; + } else { + RecordSet rs = new RecordSet(); + rs.executeSql("select fieldhtmltype, fielddbtype, type from cus_formdict where id = " + fieldid); + if (rs.next()) { + fieldhtmltype = rs.getString("fieldhtmltype"); + fielddbtype = rs.getString("fielddbtype"); + type = rs.getString("type"); + } + if ("1".equals(fieldhtmltype) || "2".equals(fieldhtmltype) || "text".equals(fielddbtype)) { + strResult = " where t1_field" + fieldid + " like '%" + value + "%'"; + } else if (("3".equals(fieldhtmltype) && fielddbtype.toLowerCase().equals("text")) || "161".equals(type) || "162".equals(type)) { + strResult += " and ( 1=2 "; + //浏览框 id为逗号隔开的形式 + String[] vals = value.split(","); + for (String val : vals) { + if (val.length() == 0) continue; + if (isoracle) { + strResult += " or ','||cast(t1_field" + fieldid + " as VARCHAR(4000))||',' like '%," + val + ",%'"; + } else if (DialectUtil.isMySql()) { + IDbDialectSql dialect = DbDialectFactory.get(rs.getDBType()); + String castCondition = dialect.castToChar("t1_field" + fieldid, 4000); + String dot = "','"; + String t0FieldConcat = dialect.concatStr(dot, castCondition, dot); + strResult += " or " + t0FieldConcat + " like '%," + val + ",%'"; + } else { + strResult += " or ','+cast(t1_field" + fieldid + " as NVARCHAR)+',' like '%," + val + ",%'"; + } + } + strResult += " ) "; + } else { + strResult = " where t1_field" + fieldid + "='" + value + "'"; + } + } + } else { + if (fieldid.indexOf("from") > 0) { + String realid = fieldid.substring(0, fieldid.indexOf("from")); + strResult += " and t1_field" + realid + ">='" + value + "'"; + } else if (fieldid.indexOf("to") > 0) { + String realid = fieldid.substring(0, fieldid.indexOf("to")); + strResult += " and t1_field" + realid + "<='" + value + "'"; + } else { + RecordSet rs = new RecordSet(); + rs.executeSql("select fieldhtmltype, fielddbtype, type from cus_formdict where id = " + fieldid); + if (rs.next()) { + fieldhtmltype = rs.getString("fieldhtmltype"); + fielddbtype = rs.getString("fielddbtype"); + type = rs.getString("type"); + } + if ("1".equals(fieldhtmltype) || "2".equals(fieldhtmltype) || "text".equals(fielddbtype)) { + strResult += " and t1_field" + fieldid + " like '%" + value + "%'"; + } else if (("3".equals(fieldhtmltype) && fielddbtype.toLowerCase().equals("text")) || "161".equals(type) || "162".equals(type)) { + strResult += " and ( 1=2 "; + //浏览框 id为逗号隔开的形式 + String[] vals = value.split(","); + for (String val : vals) { + if (val.length() == 0) continue; + if (isoracle) { + strResult += " or ','||cast(t1_field" + fieldid + " as VARCHAR(4000))||',' like '%," + val + ",%'"; + } else if (DialectUtil.isMySql()) { + IDbDialectSql dialect = DbDialectFactory.get(rs.getDBType()); + String castCondition = dialect.castToChar("t1_field" + fieldid, 4000); + String dot = "','"; + String t0FieldConcat = dialect.concatStr(dot, castCondition, dot); + strResult += " or " + t0FieldConcat + " like '%," + val + ",%'"; + } else { + strResult += " or ','+cast(t1_field" + fieldid + " as NVARCHAR)+',' like '%," + val + ",%'"; + } + } + strResult += " ) "; + } else { + strResult += " and t1_field" + fieldid + "='" + value + "'"; + } + } + } + } + + } + + if (customFieldMapWork.size() > 0) { + Set fieldidSet = customFieldMapWork.keySet(); + for (Iterator iter = fieldidSet.iterator(); iter.hasNext(); ) { + String fieldid = (String) iter.next(); + String value = (String) customFieldMapWork.get(fieldid); + String fieldhtmltype = ""; + String fielddbtype = ""; + String type = ""; + if (value.equals("")) continue; + if (ishead == 0) { + ishead = 1; + if (fieldid.indexOf("from") > 0) { + String realid = fieldid.substring(0, fieldid.indexOf("from")); + strResult = " where t3_field" + realid + ">='" + value + "'"; + } else if (fieldid.indexOf("to") > 0) { + String realid = fieldid.substring(0, fieldid.indexOf("to")); + strResult = " where t3_field" + realid + "<='" + value + "'"; + } else { + RecordSet rs = new RecordSet(); + rs.executeSql("select fieldhtmltype, fielddbtype, type from cus_formdict where id = " + fieldid); + if (rs.next()) { + fieldhtmltype = rs.getString("fieldhtmltype"); + fielddbtype = rs.getString("fielddbtype"); + type = rs.getString("type"); + } + if ("1".equals(fieldhtmltype) || "2".equals(fieldhtmltype) || "text".equals(fielddbtype)) { + strResult = " where t3_field" + fieldid + " like '%" + value + "%'"; + } else if (("3".equals(fieldhtmltype) && fielddbtype.toLowerCase().equals("text")) || "161".equals(type) || "162".equals(type)) { + strResult = " where 1=1 "; + strResult += " and ( 1=2 "; + //浏览框 id为逗号隔开的形式 + String[] vals = value.split(","); + for (String val : vals) { + if (val.length() == 0) continue; + if (isoracle) { + strResult += " or ','||cast(t3_field" + fieldid + " as VARCHAR(4000))||',' like '%," + val + ",%'"; + } else if (DialectUtil.isMySql()) { + IDbDialectSql dialect = DbDialectFactory.get(rs.getDBType()); + String castCondition = dialect.castToChar("t3_field" + fieldid, 4000); + String dot = "','"; + String t0FieldConcat = dialect.concatStr(dot, castCondition, dot); + strResult += " or " + t0FieldConcat + " like '%," + val + ",%'"; + } else { + strResult += " or ','+cast(t3_field" + fieldid + " as NVARCHAR)+',' like '%," + val + ",%'"; + } + } + strResult += " ) "; + } else { + strResult = " where t3_field" + fieldid + "='" + value + "'"; + } + } + } else { + if (fieldid.indexOf("from") > 0) { + String realid = fieldid.substring(0, fieldid.indexOf("from")); + strResult += " and t3_field" + realid + ">='" + value + "'"; + } else if (fieldid.indexOf("to") > 0) { + String realid = fieldid.substring(0, fieldid.indexOf("to")); + strResult += " and t3_field" + realid + "<='" + value + "'"; + } else { + RecordSet rs = new RecordSet(); + rs.executeSql("select fieldhtmltype, fielddbtype, type from cus_formdict where id = " + fieldid); + if (rs.next()) { + fieldhtmltype = rs.getString("fieldhtmltype"); + fielddbtype = rs.getString("fielddbtype"); + type = rs.getString("type"); + } + if ("1".equals(fieldhtmltype) || "2".equals(fieldhtmltype) || "text".equals(fielddbtype)) { + strResult += " and t3_field" + fieldid + " like '%" + value + "%'"; + } else if (("3".equals(fieldhtmltype) && fielddbtype.toLowerCase().equals("text")) || "161".equals(type) || "162".equals(type)) { + strResult += " and ( 1=2 "; + //浏览框 id为逗号隔开的形式 + String[] vals = value.split(","); + for (String val : vals) { + if (val.length() == 0) continue; + if (isoracle) { + strResult += " or ','||cast(t3_field" + fieldid + " as VARCHAR(4000))||',' like '%," + val + ",%'"; + } else if (DialectUtil.isMySql()) { + IDbDialectSql dialect = DbDialectFactory.get(rs.getDBType()); + String castCondition = dialect.castToChar("t3_field" + fieldid, 4000); + String dot = "','"; + String t0FieldConcat = dialect.concatStr(dot, castCondition, dot); + strResult += " or " + t0FieldConcat + " like '%," + val + ",%'"; + } else { + strResult += " or ','+cast(t3_field" + fieldid + " as NVARCHAR)+',' like '%," + val + ",%'"; + } + } + strResult += " ) "; + } else { + strResult += " and t3_field" + fieldid + "='" + value + "'"; + } + } + } + } + + } + + if (ishead == 0) { + ishead = 1; + strResult = " where status != 10"; + } else { + strResult += " and status != 10"; + } + + if (!classification.equals("")) { + strResult += " and classification in (" + classification + ")"; + } + + boolean flagaccount = weaver.general.GCONST.getMOREACCOUNTLANDING();//账号类型 + //默认显示的字段 其余都隐藏 + List lsFieldShow = new ArrayList(); + lsFieldShow.add("id"); + lsFieldShow.add("lastname"); + if (!PortalUtil.isuserdeploy()) { + lsFieldShow.add("subcompanyid1"); + } + lsFieldShow.add("departmentid"); + lsFieldShow.add("managerid"); + lsFieldShow.add("telephone"); + lsFieldShow.add("mobile"); + //判断是否有管理员同步过显示列定制 + RecordSet recordSet = new RecordSet(); + String showColSql = "select * from cloudstore_defcol where pageUid='920acb49-9262-4553-a9e5-dae1e17ebc89' and userId=0 and display=0 "; + recordSet.executeQuery(showColSql); + if (recordSet.getCounts() > 0) { + lsFieldShow = new ArrayList(); + lsFieldShow.add("id"); + } + while (recordSet.next()) { + String dataIndex = recordSet.getString("dataIndex").toLowerCase(); + if (!lsFieldShow.contains(dataIndex)) { + lsFieldShow.add(dataIndex); + } + } + writeLog("GetHrmSearchResultCmd>>>lsFieldShow="+ JSON.toJSONString(lsFieldShow)); + String tempstr = strResult; + AppDetachComInfo adci = new AppDetachComInfo(); + String appdetawhere = adci.getScopeSqlByHrmResourceSearch(user.getUID() + ""); + if (!"".equals(tempstr)) + tempstr += (appdetawhere != null && !"".equals(appdetawhere) ? (" and " + appdetawhere) : ""); + else tempstr = appdetawhere; + + String backfields = "*"; + String sqlWhere = " " + tempstr; + String fromSql = ""; + String tableString = ""; + String operateString = ""; + String orderby = ""; + //默认排序设置 start + String orderBySql = "select * from HrmSearchOrderByCol where userId=? and sort=1 order by orders"; + recordSet.executeQuery(orderBySql, user.getUID()); + if (recordSet.getCounts() <= 0) { + orderBySql = "select * from HrmSearchOrderByCol where userId=0 and sort=1 order by orders"; + recordSet.executeQuery(orderBySql); + } + while (recordSet.next()) { + String dataIndex = recordSet.getString("dataIndex"); + String ascOrDesc = recordSet.getString("ascOrDesc"); + if (dataIndex.equals("organization")) { + orderby += ",dept.showOrderOfDeptTree " + ascOrDesc; + } + if (dataIndex.equalsIgnoreCase("hrmresource.dspOrder") || dataIndex.equalsIgnoreCase("hrmresource.lastName")) { + orderby += "," + dataIndex + " " + ascOrDesc; + } else if (dataIndex.equalsIgnoreCase("dept.deptShowOrder") || dataIndex.equalsIgnoreCase("dept.deptName")) { + orderby += "," + dataIndex + " " + ascOrDesc; + } else if (dataIndex.equalsIgnoreCase("subcom.subcomShowOrder") || dataIndex.equalsIgnoreCase("subcom.subcomName")) { + orderby += "," + dataIndex + " " + ascOrDesc; + } + } + orderby = orderby.startsWith(",") ? orderby.substring(1) : orderby; + orderby = orderby.equals("") ? " hrmresource.dspOrder,hrmresource.id " : orderby; + //默认排序设置 end + HrmListValidate HrmListValidate = new HrmListValidate(); + + int[] scopeIds; + String pageId = ""; + String pageUid = ""; + if (HrmUserVarify.checkUserRight("HrmResourceEdit:Edit", user)) { + scopeIds = new int[]{-1, 1, 3}; + pageId = PageIdConst.HRM_ResourceSearchResultByManager; + pageUid = PageUidFactory.getHrmPageUid("SearchResourceManager"); + } else { + scopeIds = new int[]{-1}; + pageId = PageIdConst.HRM_ResourceSearchResult; + pageUid = PageUidFactory.getHrmPageUid("SearchResource"); + } + + String tabletype = "none"; + if (HrmValidate.hasEmessage(user)) { + tabletype = "checkbox"; + } + + PrivacyComInfo pc = new PrivacyComInfo(); + Map mapShowSets = pc.getMapShowSets(); + + String popedomOtherpara = String.valueOf(HrmValidate.hasEmessage(user) && HrmListValidate.isValidate(33)) + "_" +//发消息 + String.valueOf(HrmListValidate.isValidate(19)) + "_" +//发送邮件 + String.valueOf(HrmListValidate.isValidate(31)) + "_" +//发送短信 + String.valueOf(String.valueOf(HrmListValidate.isValidate(32))) + "_" +//新建日程 + String.valueOf(HrmUserVarify.checkUserRight("HrmResourceEdit:Edit", user)) + "_" + + String.valueOf(user.getUID()); + operateString = ""; + operateString += " "; + operateString += " "; + operateString += " "; + operateString += " "; + operateString += " "; + //operateString += " "; + operateString += " "; + operateString += ""; + String checkboxpopedompara = ""; + if ("checkbox".equals(tabletype)) { + checkboxpopedompara += " "; + } + + LinkedHashMap ht = new LinkedHashMap(); + HrmFieldManager hfm = null; + HrmFieldGroupComInfo hrmFieldGroupComInfo = new HrmFieldGroupComInfo(); + String[] backfield = new String[]{"id as t1_id", "id as t2_id", "id as t3_id"}; + + for (int i = 0; i < scopeIds.length; i++) { + scopeId = scopeIds[i]; + hfm = new HrmFieldManager("HrmCustomFieldByInfoType", scopeId); + hfm.getCustomFields(); + while (hfm.next()) { + if (!"1".equals(hrmFieldGroupComInfo.getIsShow(hfm.getGroupid() + "")) || !hfm.isUse()) continue; + if (hfm.getHtmlType().equals("6")) continue;//屏蔽附件上传 + String fieldNameTemp = hfm.getFieldname(); + if (fieldNameTemp.equals("loginid")) { + if (!HrmUserVarify.checkUserRight("HrmResourceEdit:Edit", user)) continue; + } + if (hfm.isBaseField(fieldNameTemp)) { +// if (hfm.getFieldname().indexOf("textfield") != -1) { +// ht.put("t" + i + "_" + hfm.getFieldname(), hfm.getLable()); +// }else{ + //导入导出不需要显示隐私设置字段 + if (isExport && mapShowSets != null && mapShowSets.get(fieldNameTemp) != null) { + continue; + } + ht.put(fieldNameTemp, hfm.getLable()); +// } + continue; + }else if(isExport){ + continue; + } + if (backfield[i].length() > 0) backfield[i] += ","; + if (fieldNameTemp.indexOf("field") != -1) { + backfield[i] += fieldNameTemp + " as t" + i + "_" + fieldNameTemp; + } else { + backfield[i] += fieldNameTemp; + } + if (ht.get(fieldNameTemp) == null) { + ht.put("t" + i + "_" + fieldNameTemp, hfm.getLable()); + } + } + } + //增加后台未开放定义,但是需要显示的列 + if (HrmUserVarify.checkUserRight("HrmResourceEdit:Edit", user)) { + ht.put("seclevel", "683"); + } + fromSql = " from HrmResource " + + " left join (SELECT " + backfield[0] + " FROM cus_fielddata WHERE scope='HrmCustomFieldByInfoType' AND scopeId=-1) t1 on hrmresource.id=t1_id " + + " left join (SELECT " + backfield[1] + " FROM cus_fielddata WHERE scope='HrmCustomFieldByInfoType' AND scopeId=1) t2 on hrmresource.id=t2_id " + + " left join (SELECT " + backfield[2] + " FROM cus_fielddata WHERE scope='HrmCustomFieldByInfoType' AND scopeId=3) t3 on hrmresource.id=t3_id " + + " left join (SELECT id AS dept_id,departmentname AS deptName,showOrder AS deptShowOrder,showOrderOfTree AS showOrderOfDeptTree FROM HrmDepartment) dept on hrmresource.departmentid = dept_id " + + " left join (SELECT id AS subcom_id,subcompanyname AS subcomName,showOrder AS subcomShowOrder,showOrderOfTree AS showOrderOfSubComTree FROM HrmSubCompany) subcom on hrmresource.subcompanyid1 = subcom_id "; + tableString = ""; + + String[] realPathArr = null; + if (needRealPath.length() > 0) { + realPathArr = needRealPath.split(","); + } + StringBuffer colString = new StringBuffer(); + Iterator iter = ht.entrySet().iterator(); + int count = 0; + while (iter.hasNext()) { + Map.Entry entry = (Map.Entry) iter.next(); + String fieldname = ((String) entry.getKey()).toLowerCase(); + String fieldlabel = (String) entry.getValue(); + String display = lsFieldShow.contains(fieldname) ? "true" : "false"; + if (fieldname.equals("dept_id") || fieldname.equals("deptName") || fieldname.equals("deptShowOrder") + || fieldname.equals("subcom_id") || fieldname.equals("subcomName") || fieldname.equals("subcomShowOrder")) { + //这几个字段只是参与排序的字段,不是显示列 + continue; + } + if (fieldname.equals("accounttype") && flagaccount) { + colString.append(""); + } else if (fieldname.equals("lastname")) { + colString.append(""); + colString.append(""); + } else if (fieldname.equals("sex")) { + colString.append(""); + } else if (fieldname.equals("departmentid")) { + String display4Dept = lsFieldShow.contains("departmentid") ? "true" : "false"; + String display4SubCom = lsFieldShow.contains("subcompanyid1") ? "true" : "false"; + String showDepartmentFullPath = Util.null2String(Prop.getInstance().getPropValue("Others", "showDepartmentFullPath"));// 是否显示全路径 + String showSubCompanyFullPath = Util.null2String(Prop.getInstance().getPropValue("Others", "showSubCompanyFullPath"));// 是否显示全路径 + String showDepartmentFullName = Util.null2String(Prop.getInstance().getPropValue("Others", "showDepartmentFullName"));// 是否显示全称 + String showSubCompanyFullName = Util.null2String(Prop.getInstance().getPropValue("Others", "showSubCompanyFullName"));//是否显示全称 + + if (virtualtype.startsWith("-")) { + if("1".equals(showDepartmentFullPath)){ + colString.append(""); + }else{ + colString.append(""); + } + if("1".equals(showSubCompanyFullPath)){ + colString.append(""); + }else{ + colString.append(""); + } + } else { + if (realPathArr != null && Arrays.asList(realPathArr).contains("department") || "1".equals(showDepartmentFullPath)) {//部门全路径 + colString.append(""); + }else if("1".equals(showDepartmentFullName)){ + colString.append(""); + }else{ + colString.append(""); + } + + if (!PortalUtil.isuserdeploy()) { + if (realPathArr != null && Arrays.asList(realPathArr).contains("subcompany") || "1".equals(showSubCompanyFullPath)) {//分部全路径 + colString.append(""); + } else if (showSubCompanyFullName.equals("1")) { + colString.append(""); + } else { + colString.append(""); + } + } + } + } else if (fieldname.equals("managerid")) { + colString.append(""); + } else if (fieldname.equals("jobtitle")) { + colString.append(""); + } else if (fieldname.equals("status")) { + colString.append(""); + } else if (fieldname.equals("jobactivity")) { + colString.append(""); + } else if (fieldname.equals("jobgroupid")) { + colString.append(""); + } else if (fieldname.equals("seclevel")) { + colString.append(""); + } else { + String width = "10%"; + if (fieldname.equals("telephone")) { + width = "15%"; + } + if (mapShowSets != null && mapShowSets.get(fieldname) != null) { + colString.append(""); + + } else { + colString.append(""); + } + } + } + colString.append(""); + String display = lsFieldShow.contains("orgid") ? "true" : "false"; + + colString.append(""); + if (HrmUserVarify.checkUserRight("HrmResourceWelfareEdit:Edit", user)) { + //工资账号户名 + colString.append(""); + //工资银行 + colString.append(""); + //工资账号 + colString.append(""); + //公积金帐户 + colString.append(""); + } + EncryptShareSettingEntity encryptShareSettingEntity = EncryptConfigBiz.getEncryptShareSetting(EncryptMould.HRM.getCode(),"ADDRESSBOOK"); + if(isExport){ + operateString= ""; + operateString = ""; + operateString+=" "; + operateString+=" "; + operateString+=""; + tabletype="none"; + checkboxpopedompara = " "; + + } + + String sql = "SELECT " + backfields + " " + fromSql + " " + sqlWhere + " ORDER BY " + orderby; + tableString = " " + + checkboxpopedompara + + " " + + operateString + + " " + + colString.toString() + + " " + + "
"; + + basebean.writeLog(" ----you know what is this --sql: " + sql); + writeLog("#$sql is _________________"+sql); + String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom()); + if (request != null) { + request.getSession().setAttribute("HrmResourceSearchResultExcelSql", sql); + } + Util_TableMap.setVal(sessionkey, tableString); + retmap.put("sessionkey", sessionkey); + } catch (Exception e) { + retmap.put("api_status", false); + retmap.put("api_errormsg", e.getMessage()); + e.printStackTrace(); + } + return retmap; + } + + public List getAllChildDept( String departmentId, String subcompanyId) { + RecordSet rs =new RecordSet(); + + List deptList = new ArrayList<>(); + String acqChilDeptSql = "select id from hrmdepartment where supdepid = ? and subcompanyid1 = ? and (canceled = 0 or canceled is null) "; + rs.executeQuery(acqChilDeptSql, departmentId, subcompanyId); + while ( rs.next()) { + String id = Util.null2String(rs.getString("id")); + if(StringUtils.isNotBlank(id) && !"0".equals(id)){ + deptList.add(id); + addChildDept(deptList, id, subcompanyId); + } + } + deptList.add(departmentId); + + return deptList; + } + + public List addChildDept( List deptList, String departmentId, String subcompanyId) { + RecordSet rs =new RecordSet(); + String acqChilDeptSql = "select id from hrmdepartment where supdepid = ? and subcompanyid1 = ? and (canceled = 0 or canceled is null) "; + rs.executeQuery(acqChilDeptSql, departmentId, subcompanyId); + while(rs.next()){ + String id = Util.null2String(rs.getString("id")); + if( StringUtils.isNotBlank(id)){ + deptList.add(id); + addChildDept(deptList, id, subcompanyId); + } + } + return deptList; + } + +} diff --git a/src/com/customization/sskj/AddJobGroupCmdInter.java b/src/com/customization/sskj/AddJobGroupCmdInter.java new file mode 100644 index 0000000..3d8e746 --- /dev/null +++ b/src/com/customization/sskj/AddJobGroupCmdInter.java @@ -0,0 +1,59 @@ +package com.customization.sskj; + +import com.customization.sskj.util.JobGroupUtil; +import com.engine.core.cfg.annotation.CommandDynamicProxy; +import com.engine.core.interceptor.AbstractCommandProxy; +import com.engine.core.interceptor.Command; +import com.engine.hrm.cmd.jobset.AddJobGroupCmd; +import com.engine.hrm.cmd.jobset.EditJobGroupCmd; +import org.apache.commons.lang.StringUtils; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; + +import java.util.Map; + +/** + * 编制岗位类别保存 + */ +@CommandDynamicProxy(target = AddJobGroupCmd.class, desc = "AddJobGroupCmd") +public class AddJobGroupCmdInter extends AbstractCommandProxy> { + + BaseBean basebean = new BaseBean(); + @Override + public Map execute(Command> command) { + + AddJobGroupCmd cmd = (AddJobGroupCmd) command; + User user = cmd.getUser(); + Map params = cmd.getParams(); + Map result = nextExecute(cmd); + + String sign = Util.null2String(result.get("sign")); + if ( !StringUtils.isEmpty(sign)) { + String jobgroupremark = Util.null2String(params.get("jobgroupremark")); + String jobGroupDesc = Util.null2String(params.get("jobgroupdesc")); + if ( !StringUtils.isEmpty(jobgroupremark)) { + JobGroupUtil jobGroupUtil = new JobGroupUtil(); + Map< String, Object> getResult = jobGroupUtil.getJobGroupId(jobgroupremark); + String code = Util.null2String( getResult.get("code")); + if ("200".equals(code)) { + String jobGroupId = Util.null2String(getResult.get("data")); + boolean addFlag = jobGroupUtil.addJobGroupDesc(jobGroupId, jobGroupDesc, user); + basebean.writeLog("AddJobGroupCmdInter addFlag: " + addFlag); + } else { + basebean.writeLog("AddJobGroupCmdInter code: " + code); + String msg = Util.null2String( getResult.get("msg")); + basebean.writeLog("AddJobGroupCmdInter msg: " + msg); + } + + } else { + basebean.writeLog("AddJobGroupCmdInter jobgroupremark is null"); + } + } else { + basebean.writeLog("AddJobGroupCmdInter sign: " + sign); + } + + + return result; + } +} diff --git a/src/com/customization/sskj/EditJobGroupCmdInter.java b/src/com/customization/sskj/EditJobGroupCmdInter.java new file mode 100644 index 0000000..f15cba0 --- /dev/null +++ b/src/com/customization/sskj/EditJobGroupCmdInter.java @@ -0,0 +1,58 @@ +package com.customization.sskj; + +import com.customization.sskj.util.JobGroupUtil; +import com.engine.core.cfg.annotation.CommandDynamicProxy; +import com.engine.core.interceptor.AbstractCommandProxy; +import com.engine.core.interceptor.Command; +import com.engine.hrm.cmd.jobset.EditJobGroupCmd; +import com.engine.hrm.cmd.jobset.GetJobDetailCmd; +import org.apache.commons.lang.StringUtils; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.hrm.User; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 编制岗位类别保存 + */ +@CommandDynamicProxy(target = EditJobGroupCmd.class, desc = "EditJobGroupCmd") +public class EditJobGroupCmdInter extends AbstractCommandProxy> { + + BaseBean basebean = new BaseBean(); + @Override + public Map execute(Command> command) { + + EditJobGroupCmd cmd = (EditJobGroupCmd) command; + User user = cmd.getUser(); + Map params = cmd.getParams(); + Map result = nextExecute(cmd); + + String sign = Util.null2String(result.get("sign")); + if ( !StringUtils.isEmpty(sign)) { + String id = Util.null2String(params.get("id")); + if ( !StringUtils.isEmpty(id)) { + JobGroupUtil jobGroupUtil = new JobGroupUtil(); + Integer number = jobGroupUtil.checkDesc(id); + if ( number == 0 ) { + String jobgroupdesc = Util.null2String(params.get("jobgroupdesc")); + boolean addFlag = jobGroupUtil.addJobGroupDesc(id, jobgroupdesc, user); + basebean.writeLog("EditJobGroupCmdInter addFlag: " + addFlag); + } else { + String jobgroupdesc = Util.null2String(params.get("jobgroupdesc")); + boolean modFlag = jobGroupUtil.modJobGroupDesc(id, jobgroupdesc, user); + basebean.writeLog("EditJobGroupCmdInter modFlag: " + modFlag); + } + } else { + basebean.writeLog("EditJobGroupCmdInter id is null"); + } + } else { + basebean.writeLog("EditJobGroupCmdInter sign: " + sign); + } + + + return result; + } +} diff --git a/src/com/customization/sskj/GetHrmKQMonthReportInfoCmdInter.java b/src/com/customization/sskj/GetHrmKQMonthReportInfoCmdInter.java new file mode 100644 index 0000000..74b18bc --- /dev/null +++ b/src/com/customization/sskj/GetHrmKQMonthReportInfoCmdInter.java @@ -0,0 +1,76 @@ +package com.customization.sskj; + +import cn.hutool.core.date.DateUtil; +import com.api.prj.cmd.task.GetTaskFormItemCmd; +import com.engine.core.cfg.annotation.CommandDynamicProxy; +import com.engine.core.interceptor.AbstractCommandProxy; +import com.engine.core.interceptor.Command; +import com.engine.kq.cmd.myattendance.GetHrmKQMonthReportInfoCmd; +import org.apache.commons.lang.StringUtils; +import weaver.general.Util; + +import java.time.LocalDate; +import java.time.YearMonth; +import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +@CommandDynamicProxy(target = GetHrmKQMonthReportInfoCmd.class, desc = "GetHrmKQMonthReportInfoCmd") +public class GetHrmKQMonthReportInfoCmdInter extends AbstractCommandProxy> { + @Override + public Map execute(Command> command) { + + GetHrmKQMonthReportInfoCmd cmd = (GetHrmKQMonthReportInfoCmd) command; + Map params = cmd.getParams(); + Map result = new HashMap<>(); + + String typevalue = Util.null2String(params.get("typevalue")); + if ( StringUtils.isNotBlank(typevalue)){ + if ( typevalue.length() == 7) { + typevalue = typevalue + "-01"; + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + + // 解析为LocalDate + LocalDate fullDate = LocalDate.parse(typevalue, dateFormatter);//入参日期 + LocalDate currentDate = LocalDate.now(); // 获取当前日期 + + // 将LocalDate对象转换为YearMonth对象 + YearMonth yearMonth1 = YearMonth.from(fullDate);//入参日期 + YearMonth yearMonth2 = YearMonth.from(currentDate);//当前日期 + + // 计算月份差值 + long monthsBetween = ChronoUnit.MONTHS.between(yearMonth1, yearMonth2); + + if (monthsBetween > 1 || monthsBetween < 0 ) { +// result.put("api_status",false); + result.put("result",null); + result.put("status","-1"); + result.put("title","我的打卡月历"); + return result; + } else { + result = nextExecute(cmd); + } + } else { + result = nextExecute(cmd); + Object resultObj = result.get("result"); + if (!Objects.isNull(resultObj)) { + LocalDate currentDate = LocalDate.now(); + int month = currentDate.getMonthValue(); + int lastmonth = month - 1; + Map resultMap = (Map) resultObj; + Map newResultMap = new HashMap(); + newResultMap.put(lastmonth+"",resultMap.get(lastmonth+"")); + newResultMap.put(month+"",resultMap.get(month+"")); + result.put("result",newResultMap); + } + } + + }else { + result = nextExecute(cmd); + } + + return result; + } +} diff --git a/src/com/customization/sskj/GetJobDetailCmdInter.java b/src/com/customization/sskj/GetJobDetailCmdInter.java new file mode 100644 index 0000000..44f983c --- /dev/null +++ b/src/com/customization/sskj/GetJobDetailCmdInter.java @@ -0,0 +1,50 @@ +package com.customization.sskj; + +import com.customization.sskj.util.JobGroupUtil; +import com.engine.core.cfg.annotation.CommandDynamicProxy; +import com.engine.core.interceptor.AbstractCommandProxy; +import com.engine.core.interceptor.Command; +import com.engine.hrm.cmd.jobset.GetJobDetailCmd; +import com.engine.kq.cmd.myattendance.GetHrmKQMonthReportInfoCmd; +import org.apache.commons.lang.StringUtils; +import weaver.general.Util; + +import java.time.LocalDate; +import java.time.YearMonth; +import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * 获取岗位类别 + */ +@CommandDynamicProxy(target = GetJobDetailCmd.class, desc = "GetJobDetailCmd") +public class GetJobDetailCmdInter extends AbstractCommandProxy> { + @Override + public Map execute(Command> command) { + + GetJobDetailCmd cmd = (GetJobDetailCmd) command; + Map params = cmd.getParams(); + Map result = nextExecute(cmd); + + Object datasObj = result.get("datas"); + if ( datasObj != null) { + String jobGroupDesc = ""; + String jobGroupId = Util.null2String(params.get("jobGroupid")); + if ( StringUtils.isNotBlank(jobGroupId)) { + JobGroupUtil jobGroupUtil = new JobGroupUtil(); + jobGroupDesc = jobGroupUtil.getDesc(jobGroupId); + } + List< Map< String, Object>> datas = (List< Map< String, Object>>) datasObj; + Map< String, Object> data = new HashMap<>(); + data.put("label", "类别描述"); + data.put("value", jobGroupDesc); + datas.add(data); + } + + return result; + } +} diff --git a/src/com/customization/sskj/GetJobGroupFormCmdInter.java b/src/com/customization/sskj/GetJobGroupFormCmdInter.java new file mode 100644 index 0000000..46a4c30 --- /dev/null +++ b/src/com/customization/sskj/GetJobGroupFormCmdInter.java @@ -0,0 +1,59 @@ +package com.customization.sskj; + +import com.api.browser.bean.SearchConditionItem; +import com.api.browser.util.ConditionType; +import com.customization.sskj.util.JobGroupUtil; +import com.engine.core.cfg.annotation.CommandDynamicProxy; +import com.engine.core.interceptor.AbstractCommandProxy; +import com.engine.core.interceptor.Command; +import com.engine.hrm.cmd.jobset.GetJobDetailCmd; +import com.engine.hrm.cmd.jobset.GetJobGroupFormCmd; +import org.apache.commons.lang.StringUtils; +import weaver.general.Util; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 获取岗位类别 + */ +@CommandDynamicProxy(target = GetJobGroupFormCmd.class, desc = "GetJobGroupFormCmd") +public class GetJobGroupFormCmdInter extends AbstractCommandProxy> { + @Override + public Map execute(Command> command) { + + GetJobGroupFormCmd cmd = (GetJobGroupFormCmd) command; + Map params = cmd.getParams(); + Map result = nextExecute(cmd); + + Object conditionObj = result.get("condition"); + if ( conditionObj != null) { + List< Map> condition = (List< Map>) conditionObj; + Map con = condition.get(0); + Object itemsObj = con.get("items"); + if ( itemsObj != null) { + List items = (List) itemsObj; + SearchConditionItem conditionItem = new SearchConditionItem(); + conditionItem.setConditionType(ConditionType.INPUT); + conditionItem.setLabel("类别描述"); + String[] domKey = new String[] {"jobgroupdesc"}; + conditionItem.setDomkey(domKey); + conditionItem.setViewAttr(2); + //判断是新建还是编辑 + String jobGroupId = Util.null2String(params.get("jobgroupid")); + if (StringUtils.isEmpty(jobGroupId)) { + conditionItem.setValue(""); + } else { + String jobGroupDesc = ""; + JobGroupUtil jobGroupUtil = new JobGroupUtil(); + jobGroupDesc = jobGroupUtil.getDesc(jobGroupId); + conditionItem.setValue(jobGroupDesc); + } + items.add(conditionItem); + } + } + + return result; + } +} diff --git a/src/com/customization/sskj/util/JobGroupUtil.java b/src/com/customization/sskj/util/JobGroupUtil.java new file mode 100644 index 0000000..5eed399 --- /dev/null +++ b/src/com/customization/sskj/util/JobGroupUtil.java @@ -0,0 +1,164 @@ +package com.customization.sskj.util; + +import cn.hutool.core.date.DateUtil; +import weaver.formmode.setup.ModeRightInfo; +import weaver.hrm.User; +import org.apache.commons.lang.StringUtils; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; + +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +/** + * 职务类别工具类 + * @author chenwnj + * @date 2023/10/19 + * @description + **/ +public class JobGroupUtil { + + BaseBean basebean = new BaseBean(); + + public Map< String, Object> getJobGroupId(String jobGroupMark) { + Map< String, Object> result = new HashMap<>(); + + if (StringUtils.isEmpty(jobGroupMark)) { + result.put("code", 500); + result.put("msg", "jobGroupMark is null"); + return result; + } + + RecordSet rs = new RecordSet(); + Integer id = -1; + String acqGroupIdSql = "select id from hrmjobgroups where jobgroupremark like '%" +jobGroupMark+ "%' "; + rs.executeQuery(acqGroupIdSql); + while (rs.next()) { + id = Util.getIntValue(Util.null2String(rs.getString("id"))); + } + result.put("code", 200); + result.put("data", id); + return result; + } + + /** + * 查询职务类别描述是否存在 + * @param jobGroup + * @return + */ + public Integer checkDesc(String jobGroup) { + if (StringUtils.isEmpty(jobGroup)) { + return -1; + } + + RecordSet rs = new RecordSet(); + Integer number = 0; + String cheDescSql = "select count(*) as number from uf_jobgroupDesc where jobgroup = ?"; + rs.executeQuery(cheDescSql, jobGroup); + while (rs.next()) { + number = Util.getIntValue(Util.null2String(rs.getString("number"))); + } + + return number; + } + + /** + * 获取职务类别描述 + * @param jobGroup + * @return + */ + public String getDesc(String jobGroup) { + String jobGroupDesc = ""; + + if (StringUtils.isEmpty(jobGroup)) { + return jobGroupDesc; + } + + RecordSet rs = new RecordSet(); + String acqDescSql = "select jobGroupDesc from uf_jobgroupDesc where jobgroup = ?"; + rs.executeQuery(acqDescSql, jobGroup); + while (rs.next()) { + jobGroupDesc = Util.null2String(rs.getString("jobGroupDesc")); + } + + return jobGroupDesc; + } + + /** + * 职务类别增加描述 + * @param jobGroup + * @param jobGroupDesc + * @param user + * @return + */ + public boolean addJobGroupDesc(String jobGroup, String jobGroupDesc, User user){ + boolean addFlag = false; + + if (StringUtils.isEmpty(jobGroup)) { + return addFlag; + } + + RecordSet recordSet = new RecordSet(); + String addDescSql = "insert into uf_jobgroupDesc (jobGroup, jobGroupDesc, formmodeid, modedatacreater, modedatacreatertype, modedatacreatedate, modedatacreatetime, MODEUUID) values (?,?,?,?,?,?,?,?)"; + + String jobGroupDesModeId = basebean.getPropValue("project_sskj", "jobGroupDesModeId"); + Integer modedatacreater = user.getUID(); + Integer modedatacreatertype = user.getType(); + String modedatacreatedate = DateUtil.format(new Date(), "yyyy-MM-dd"); + String modedatacreatetime = DateUtil.format(new Date(), "HH:mm:ss"); + String uuid = UUID.randomUUID().toString(); + + addFlag = recordSet.executeUpdate(addDescSql, jobGroup, jobGroupDesc, jobGroupDesModeId, modedatacreater, modedatacreatertype, modedatacreatedate, modedatacreatetime, uuid); + if (addFlag) { + String billid = "-1"; + String acqModeIdSql = "select id from uf_jobgroupDesc where MODEUUID = ?"; + recordSet.executeQuery(acqModeIdSql, uuid); + while (recordSet.next()) { + billid = Util.null2String(recordSet.getString("id")); + } + modePerRecon(modedatacreater, jobGroupDesModeId, billid); + } + + + return addFlag; + } + + /** + * 修改职务类别描述 + * @param jobGroup + * @param jobGroupDesc + * @param user + * @return + */ + public boolean modJobGroupDesc(String jobGroup, String jobGroupDesc, User user){ + boolean modFlag = false; + + if (StringUtils.isEmpty(jobGroup)) { + return modFlag; + } + + RecordSet recordSet = new RecordSet(); + String modDescSql = "update uf_jobgroupDesc set jobGroupDesc = ? where jobGroup = ? "; + + modFlag = recordSet.executeUpdate(modDescSql, jobGroupDesc, jobGroup); + + return modFlag; + } + + /** + * 建模权限重构 + * @param userId + * @param jobGroupDesModeId + * @param billid + */ + public void modePerRecon(Integer userId, String jobGroupDesModeId, String billid) { + ModeRightInfo ModeRightInfo = new ModeRightInfo(); + ModeRightInfo.setNewRight(true); + ModeRightInfo.editModeDataShare( userId, Integer.parseInt(jobGroupDesModeId), Integer.parseInt(billid)); + } + + +} diff --git a/src/com/engine/kq/biz/KQFormatData.java b/src/com/engine/kq/biz/KQFormatData.java new file mode 100644 index 0000000..024daee --- /dev/null +++ b/src/com/engine/kq/biz/KQFormatData.java @@ -0,0 +1,1077 @@ +package com.engine.kq.biz; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean; +import com.engine.kq.entity.KQShiftRuleEntity; +import com.engine.kq.entity.TimeScopeEntity; +import com.engine.kq.entity.WorkTimeEntity; +import com.engine.kq.enums.FlowReportTypeEnum; +import com.engine.kq.log.KQLog; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.googlecode.aviator.AviatorEvaluator; +import com.googlecode.aviator.Expression; +import org.apache.commons.lang3.StringUtils; +import weaver.common.DateUtil; +import weaver.conn.BatchRecordSet; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.InitServer; +import weaver.general.Util; + +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * 考勤数据格式化 + */ +public class KQFormatData extends BaseBean { + private String today = DateUtil.getCurrentDate(); + private KQLog kqLog = new KQLog(); + private boolean writeLog = false; + private LinkedHashMap logInfo = new LinkedHashMap<>(); + + /*** + * 该方法不允许直接调用 + * @param userId + * @param kqDate + * @return + */ + public Map formatKqDate(String userId, String kqDate) { + List> lsParam = new ArrayList<>(); + //非工作日处理 + List nonlsParam = null; + Map resultMap = new HashMap<>(); + BatchRecordSet bRs = new BatchRecordSet(); + KQGroupComInfo kqGroupComInfo = new KQGroupComInfo(); + RecordSet rs = new RecordSet(); + String sql = ""; + try { + kqLog.info("formatKqDate in userId=" + userId + "kqDate==" + kqDate); + if (DateUtil.timeInterval(kqDate, today) < 0) {//今天之后的无需处理 + kqLog.info("今天之后的无需处理的数据:resourceid=="+userId+"kqdate=="+kqDate+"today=="+today); + return resultMap; + } + String uuid = UUID.randomUUID().toString(); + KQFormatFreeData kqFormatFreeData = new KQFormatFreeData(); + KQWorkTime kqWorkTime = new KQWorkTime(); + kqWorkTime.setIsFormat(true); + String kqDateNext = DateUtil.addDate(kqDate, 1); + + KQFlowDataBiz kqFlowDataBiz = new KQFlowDataBiz.FlowDataParamBuilder().resourceidParam(userId).fromDateParam(kqDate).toDateParam(kqDateNext).build(); + Map workFlowInfo = new HashMap<>();//userid|date--工作流程 + kqFlowDataBiz.getAllFlowData(workFlowInfo,false); + WorkTimeEntity workTime = kqWorkTime.getWorkTime(userId, kqDate); + kqLog.info("userId:"+userId+":kqDate:"+kqDate+":formatKqDate workTime=" + JSONObject.toJSONString(workTime)+"::uuid::"+uuid); + kqLog.info("userId:"+userId+":kqDate:"+kqDate+":formatKqDate workFlowInfo=" + JSONObject.toJSONString(workFlowInfo)+"::uuid::"+uuid); + + if(this.writeLog) { + logInfo.put("userId",userId); + logInfo.put("kqDate",kqDate); + logInfo.put(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(16253,weaver.general.ThreadVarLanguage.getLang())+"",workTime); + logInfo.put(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(126871,weaver.general.ThreadVarLanguage.getLang())+"",workFlowInfo); + } + + new KQFormatBiz().delFormatData(userId, kqDate); + + String excludecount = Util.null2String(kqGroupComInfo.getExcludecount(workTime.getGroupId()));//是否参与考勤报表统计 + if (workTime.getIsExclude()) {//无需考勤人员没有异常状态 + if(!excludecount.equals("1")){ + kqLog.info("无需考勤人员没有异常状态 workTime.getIsExclude()="+workTime.getIsExclude()+"excludecount=="+excludecount); + return resultMap; + } + } + if( Util.null2String(workTime.getGroupId()).length()==0){ + //没有考勤组不需格式化 + return resultMap; + } + if (workTime == null || workTime.getWorkMins() == 0) { + kqLog.info("workTime == null || workTime.getWorkMins() == 0 插入空记录"); + nonlsParam = new ArrayList<>(); + formatNonWork(userId, kqDate,nonlsParam,workTime, workFlowInfo); + + if(!nonlsParam.isEmpty()){ + sql = " insert into kq_format_detail(resourceid,kqdate,groupid,serialnumber,signindate,signintime,signinid,signoutdate,signouttime,signoutid,leaveMins,leaveinfo,evectionMins,outMins)values(?,?,?,?,?,?,?,?,?,?,?,?,?,?) "; + rs.executeUpdate(sql, nonlsParam); + + sql = " insert into kq_format_total(resourceid,kqdate,subcompanyid,departmentid,jobtitle,groupid,serialid,workdays," + + " workmins,attendancedays,attendancemins,signdays,signmins,belate,belatemins,gravebelate,gravebelatemins,leaveeearly,leaveearlymins," + + " graveleaveearly,graveleaveearlymins,absenteeism,absenteeismmins,forgotcheck, forgotcheckMins,leaveMins,evectionMins,outMins)" + + " select a.resourceid,kqdate,b.subcompanyid1,b.departmentid,b.jobtitle,groupid,serialid," + + " case when sum(workmins)>0 then 1 end as workdays, sum(workmins) as workmins," + + " 0 as attendancedays, sum(attendanceMins) as attendanceMins," + + " 0 as signdays, sum(signmins) as signmins," + + " sum(case when belatemins> 0 then 1 else 0 end) as belate,sum(belatemins) as belatemins," + + " sum(case when graveBeLateMins> 0 then 1 else 0 end) as graveBeLate,sum(graveBeLateMins) as graveBeLateMins," + + " sum(case when leaveearlymins> 0 then 1 else 0 end) as leaveearly,sum(leaveearlymins) as leaveearlymins," + + " sum(case when graveLeaveEarlyMins> 0 then 1 else 0 end) as graveLeaveEarly,sum(graveLeaveEarlyMins) as graveLeaveEarlyMins," + + " sum(case when absenteeismmins> 0 then 1 else 0 end) as absenteeism,sum(absenteeismmins) as absenteeismmins," + + " sum(case when forgotcheckmins> 0 then 1 else 0 end) as forgotcheck,sum(forgotcheckmins) as forgotcheckmins, " + + " sum(leaveMins) as leaveMins, sum(evectionMins) as evectionMins, sum(outMins) as outMins" + + " from kq_format_detail a, hrmresource b" + + " where a.resourceid = b.id and resourceid =? and kqdate=?" + + " group by resourceid,kqdate,b.subcompanyid1,b.departmentid,b.jobtitle,groupid,serialid,workmins"; + rs.executeUpdate(sql, userId, kqDate); + } + }else{ + Map definedFieldInfo = new KQFormatBiz().getDefinedField(); + String definedField = ""; + String definedParam = ""; + String definedParamSum = ""; + if (workTime.getKQType().equals("3")) {//自由工时 + lsParam.addAll(kqFormatFreeData.format(userId, kqDate, workFlowInfo)); + } else { + definedField = Util.null2String(definedFieldInfo.get("definedField")); + definedParam = Util.null2String(definedFieldInfo.get("definedParam")); + definedParamSum = Util.null2String(definedFieldInfo.get("definedParamSum")); + lsParam.addAll(format(userId, kqDate, workTime, workFlowInfo,uuid)); + } + + if (lsParam.size() > 0) { + sql = " insert into kq_format_detail( " + + " resourceid,kqdate,groupid,serialid,serialnumber,workbegindate,workbegintime,workenddate,workendtime,workmins," + + " signindate,signintime,signinid,signoutdate,signouttime,signoutid,signMins," + + " attendanceMins,belatemins,graveBeLateMins,leaveearlymins,graveLeaveEarlyMins,absenteeismmins,forgotcheckMins," + + " leaveMins,leaveinfo,evectionMins,outMins,forgotbeginworkcheckmins,otherinfo"+(definedField.length()>0?","+definedField+"":"")+") " + + " values(?,?,?,?,?,?,?,?,?,?, ?,?,?,?,?,?,?, ?,?,?,?,?,?,?,?,?,?,?,?,?"+(definedField.length()>0?","+definedParam+"":"")+")"; + for (int i = 0; i < lsParam.size(); i++) { + List param = lsParam.get(i); + boolean isok = rs.executeUpdate(sql, param); + kqLog.info("插入记录:userId:"+userId+":kqDate:"+kqDate+":param:"+JSON.toJSONString(param)+":isok:"+isok+"::uuid::"+uuid); + } + + sql = " insert into kq_format_total(resourceid,kqdate,subcompanyid,departmentid,jobtitle,groupid,serialid,workdays,workmins," + + " attendancedays,attendancemins,signdays,signmins,belate,belatemins,gravebelate,gravebelatemins,leaveeearly,leaveearlymins,graveleaveearly," + + " graveleaveearlymins,absenteeism,absenteeismmins,forgotcheck,forgotcheckmins," + + " leaveMins,evectionMins,outMins,forgotbeginworkcheck,forgotbeginworkcheckmins"+(definedField.length()>0?","+definedField+"":"")+") " + + " select a.resourceid,kqdate,b.subcompanyid1,b.departmentid,b.jobtitle,groupid,serialid," + + " case when sum(workmins)>0 then 1 end as workdays, sum(workmins) as workmins," + + " cast(sum(attendanceMins)AS decimal(10, 2))/sum(workmins) as attendancedays, sum(attendanceMins) as attendanceMins," + + " cast(sum(signmins)AS decimal(10, 2))/sum(workmins) as signdays, sum(signmins) as signmins," + + " sum(case when belatemins> 0 then 1 else 0 end) as belate,sum(belatemins) as belatemins," + + " sum(case when graveBeLateMins> 0 then 1 else 0 end) as graveBeLate,sum(graveBeLateMins) as graveBeLateMins," + + " sum(case when leaveearlymins> 0 then 1 else 0 end) as leaveearly,sum(leaveearlymins) as leaveearlymins," + + " sum(case when graveLeaveEarlyMins> 0 then 1 else 0 end) as graveLeaveEarly,sum(graveLeaveEarlyMins) as graveLeaveEarlyMins, " + + " sum(case when absenteeismmins> 0 then 1 else 0 end) as absenteeism,sum(absenteeismmins) as absenteeismmins," + + " sum(case when forgotcheckmins> 0 then 1 else 0 end) as forgotcheck,sum(forgotcheckmins) as forgotcheckmins,sum(leaveMins) as leaveMins," + + " sum(evectionMins) as evectionMins,sum(outMins) as outMins, " + + " sum(case when forgotbeginworkcheckmins> 0 then 1 else 0 end) as forgotbeginworkcheck,sum(forgotbeginworkcheckmins) as forgotbeginworkcheckmins " + + (definedField.length()>0?","+definedParamSum+"":"")+ + " from kq_format_detail a, hrmresource b" + + " where a.resourceid = b.id and resourceid = ? and kqdate=?" + + " group by resourceid,kqdate,b.subcompanyid1,b.departmentid,b.jobtitle,groupid,serialid"; + rs.executeUpdate(sql, userId, kqDate); + } + } + }catch (Exception e) { + writeLog(e); + kqLog.info(e); + } + return resultMap; + } + + public List> format(String userId, String kqDate, WorkTimeEntity workTime, + Map workFlowInfo, String uuid) { + List> lsParam = new ArrayList<>(); + List params = null; + try { + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + String nosign_is_absent = Util.null2String(kqSettingsComInfo.getMain_val("nosign_is_absent"),"1"); + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + KQFormatShiftRule kqFormatShiftRule = new KQFormatShiftRule(); + String preDate = DateUtil.addDate(kqDate, -1);//上一天日期 + String nextDate = DateUtil.addDate(kqDate, 1);//下一天日期 + String dateKey = userId + "|" + kqDate; + String nextDateKey = userId + "|" + nextDate; + ArrayList hostIps = InitServer.getRealIp(); + kqLog.info("format in >>>>>userId" + userId + "kqDate==" + kqDate+":hostIps:"+hostIps+":uuid::"+uuid); + boolean oneSign = false; + List lsSignTime = new ArrayList<>(); + List lsWorkTime = new ArrayList<>(); + List lsRestTime = new ArrayList<>(); + List workFlow = null; + + if (workTime != null) { + lsSignTime = workTime.getSignTime();//允许打卡时间 + lsWorkTime = workTime.getWorkTime();//工作时间 + lsRestTime = workTime.getRestTime();//休息时段时间 + oneSign = lsWorkTime!=null&&lsWorkTime.size()==1; + } + + int[] dayMins = new int[2880];//一天所有分钟数 + Arrays.fill(dayMins, -1); + // 一天4次打卡单独做判断,如果是上午下班打卡和下午上班打卡时间重叠,那么上午的下班卡取最早的,下午的上班卡取最晚的。用shiftCount是否等于-1判断,-1就走标准不重叠。2就表示重叠走新的逻辑 + int shiftCount = lsWorkTime == null ? 0 : lsWorkTime.size(); + int shiftI = 0; + String signEndDateTimeZero = ""; + for (int i = 0; lsWorkTime != null && i < lsWorkTime.size(); i++) { + shiftI = i; + TimeScopeEntity signTimeScope = lsSignTime.get(i); + TimeScopeEntity workTimeScope = lsWorkTime.get(i); + String signBeginDateTime = signTimeScope.getBeginTimeAcross() ? nextDate : kqDate; + if(signTimeScope.isBeginTimePreAcross()){ + signBeginDateTime = preDate; + } + signBeginDateTime+=" "+kqTimesArrayComInfo.turn48to24Time(signTimeScope.getBeginTime())+":00"; + String signEndDateTime = signTimeScope.getEndTimeAcross() ? nextDate : kqDate; + signEndDateTime+=" "+kqTimesArrayComInfo.turn48to24Time(signTimeScope.getEndTime())+":59"; + if (shiftCount == 2 && shiftI == 0) { + signEndDateTimeZero = signEndDateTime; + } + if (shiftCount == 2 && shiftI == 1) { + shiftCount = signBeginDateTime.compareTo(signEndDateTimeZero) <= 0 ? shiftCount : -1; + } + } + for (int i = 0; lsWorkTime != null && i < lsWorkTime.size(); i++) { + shiftI = i; + params = new ArrayList<>(); + TimeScopeEntity signTimeScope = lsSignTime.get(i); + TimeScopeEntity workTimeScope = lsWorkTime.get(i); + //TimeScopeEntity restTimeScope = lsRestTime.isEmpty()?null:lsRestTime.get(i); + String workBeginTime = Util.null2String(workTimeScope.getBeginTime()); + String ori_workBeginTime = workBeginTime; + int workBeginIdx = kqTimesArrayComInfo.getArrayindexByTimes(workBeginTime); + boolean workBenginTimeAcross = workTimeScope.getBeginTimeAcross(); + String workEndTime = Util.null2String(workTimeScope.getEndTime()); + String ori_workEndTime = workEndTime; + int workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(workEndTime); + boolean workEndTimeAcross = workTimeScope.getEndTimeAcross(); + int workMins = workTimeScope.getWorkMins(); + + String workBeginDate = workBenginTimeAcross ? nextDate : kqDate; + String workEndDate = workEndTimeAcross ? nextDate : kqDate; + + Arrays.fill(dayMins, workBeginIdx, workEndIdx, 1);//工作时段标识 1 + + int beginIdx = 0; + int endIdx = 0; + int checkIn = 0; + int checkOut = 0; + String signInId = ""; + String signInDate = ""; + String signInTime = ""; + String signOutId = ""; + String signOutDate = ""; + String signOutTime = ""; + int earlyInMins = 0;//早到分钟数 + int lateOutMins = 0;//晚走分钟数 + int signMins = 0;//签到签退时长 + int tmpAttendanceMins = 0;//出勤分钟数(流程抵扣来的) + int attendanceMins = 0; + int beLateMins = 0; + int graveBeLateMins = 0; + int leaveEarlyMins = 0; + int graveLeaveEarlyMins = 0; + int absenteeismMins = 0; + int leaveMins = 0;//请假时长 + Map leaveInfo = new HashMap<>();//请假信息 + Map otherinfo = new HashMap<>();//存一些用得到的信息 + int evectionMins = 0;//出差时长 + int outMins = 0;//公出时长 + int otherMins = 0;//异常流程时长 + int forgotCheckMins = 0; + int forgotBeginWorkCheckMins = 0;//上班漏签 + int signInTimeIndx = -1; + int flowSignInTimeIndx = -1; + int signInTimeOutdx = -1; + //用来计算实际打卡时长用的 + int signInTimeIndx4Sign = -1; + int signInTimeOutdx4Sign = -1; + + String signBeginDateTime = signTimeScope.getBeginTimeAcross() ? nextDate : kqDate; + if(signTimeScope.isBeginTimePreAcross()){ + signBeginDateTime = preDate; + } + signBeginDateTime+=" "+kqTimesArrayComInfo.turn48to24Time(signTimeScope.getBeginTime())+":00"; + String signEndDateTime = signTimeScope.getEndTimeAcross() ? nextDate : kqDate; + signEndDateTime+=" "+kqTimesArrayComInfo.turn48to24Time(signTimeScope.getEndTime())+":59"; + String workBeginDateTime = workTimeScope.getBeginTimeAcross() ? nextDate : kqDate; + workBeginDateTime+=" "+kqTimesArrayComInfo.turn48to24Time(workTimeScope.getBeginTime())+":00"; + String workEndDateTime = workTimeScope.getEndTimeAcross() ? nextDate : kqDate; + workEndDateTime+=" "+kqTimesArrayComInfo.turn48to24Time(workTimeScope.getEndTime())+":00"; + + kqLog.info("signBeginDateTime" + signBeginDateTime+"::userId" + userId + "kqDate==" + kqDate+":hostIps:"+hostIps+":uuid::"+uuid); + kqLog.info("signEndDateTime" + signEndDateTime+"::userId" + userId + "kqDate==" + kqDate+":hostIps:"+hostIps+":uuid::"+uuid); + kqLog.info("workBeginDateTime" + workBeginDateTime+"::userId" + userId + "kqDate==" + kqDate+":hostIps:"+hostIps+":uuid::"+uuid); + kqLog.info("workEndDateTime" + workEndDateTime+"::userId" + userId + "kqDate==" + kqDate+":hostIps:"+hostIps+":uuid::"+uuid); + + Map shifRuleMap = Maps.newHashMap(); + if(oneSign){ + //个性化设置只支持一天一次上下班 + ShiftInfoBean shiftInfoBean = new ShiftInfoBean(); + shiftInfoBean.setSplitDate(kqDate); + shiftInfoBean.setShiftRuleMap(workTime.getShiftRuleInfo()); + shiftInfoBean.setSignTime(lsSignTime); + shiftInfoBean.setWorkTime(lsWorkTime); + List logList = Lists.newArrayList(); + KQShiftRuleInfoBiz.getShiftRuleInfo(shiftInfoBean, userId, shifRuleMap,logList); + if(!shifRuleMap.isEmpty()){ + if(!logList.isEmpty()){ + otherinfo.put("logList", logList); + } + otherinfo.put("shiftRule", shifRuleMap); + if(shifRuleMap.containsKey("shift_beginworktime")){ + String shift_beginworktime = Util.null2String(shifRuleMap.get("shift_beginworktime")); + if(shift_beginworktime.length() > 0){ + workBeginTime = Util.null2String(shift_beginworktime); + workBeginIdx = kqTimesArrayComInfo.getArrayindexByTimes(workBeginTime); + workTimeScope.setBeginTime(workBeginTime); + workTimeScope.setBeginTimeAcross(workBeginIdx>=1440?true:false); + } + } + if(shifRuleMap.containsKey("shift_endworktime")){ + String shift_endworktime = Util.null2String(shifRuleMap.get("shift_endworktime")); + if(shift_endworktime.length() > 0){ + workEndTime = Util.null2String(shift_endworktime); + workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(workEndTime); + workTimeScope.setEndTime(workEndTime); + workTimeScope.setEndTimeAcross(workEndIdx>=1440?true:false); + } + } + } + kqLog.info("个性化之后 signBeginDateTime" + signBeginDateTime); + kqLog.info("个性化之后 signEndDateTime" + signEndDateTime); + kqLog.info("个性化之后 workBeginDateTime" + workBeginDateTime); + kqLog.info("个性化之后 workEndDateTime" + workEndDateTime); + } + + List lsCheckInfo = new KQFormatSignData().getSignInfo(userId,signTimeScope,workTimeScope,kqDate,preDate,nextDate,kqTimesArrayComInfo,hostIps,uuid,shiftCount,shiftI); + kqLog.info("lsCheckInfo" + JSONObject.toJSONString(lsCheckInfo)+"::userId" + userId + "kqDate==" + kqDate+":hostIps:"+hostIps+":uuid::"+uuid); + if(this.writeLog) { + logInfo.put(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005297,weaver.general.ThreadVarLanguage.getLang())+"",signBeginDateTime); + logInfo.put(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005298,weaver.general.ThreadVarLanguage.getLang())+"",signEndDateTime); + logInfo.put(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(1940,weaver.general.ThreadVarLanguage.getLang())+"",workBeginDateTime); + logInfo.put(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005299,weaver.general.ThreadVarLanguage.getLang())+"",workEndDateTime); + logInfo.put(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005300,weaver.general.ThreadVarLanguage.getLang())+"",lsCheckInfo); + } + for (int j = 0; lsCheckInfo != null && j < lsCheckInfo.size(); j++) { + Map checkInfo = (Map) lsCheckInfo.get(j); + String signStatus = Util.null2String(checkInfo.get("signStatus")); + String signId = Util.null2String(checkInfo.get("signId")); + String signDate = Util.null2String(checkInfo.get("signDate")); + String signTime = Util.null2String(checkInfo.get("signTime")); + String deduct_signintime = Util.null2String(checkInfo.get("deduct_signintime")); + String deduct_signofftime = Util.null2String(checkInfo.get("deduct_signofftime")); + String flow_signInTime = ""; + String flow_signOutTime = ""; + if(kqDate.compareTo(signDate) < 0) { + endIdx+=1440; + } + if (signTime.length() > 8) { + signTime = signTime.substring(0, 8); + } + if (checkInfo.get("signType").equals("1")) {//签到 + checkIn++; + //如果流程抵扣存在,打卡时长也存在,那么相互比较得到出勤时长和打卡时长 暂不这样处理,还是按照漏签的逻辑来处理 + if(signTime.length() > 0){ + signInTimeIndx4Sign = kqTimesArrayComInfo.getArrayindexByTimes(signTime); + } + signInId = signId; + signInDate = signDate; + signInTime = signTime; + signInTimeIndx = kqTimesArrayComInfo.getArrayindexByTimes(signInTime); + if(deduct_signintime.length() > 0){ + if(signTime.length() > 0){ + if(deduct_signintime.compareTo(signTime) < 0){ + flow_signInTime = deduct_signintime; + } + }else{ + flow_signInTime = deduct_signintime; + } + } + if(flow_signInTime.length() > 0){ + flowSignInTimeIndx = kqTimesArrayComInfo.getArrayindexByTimes(flow_signInTime); + } + if(kqDate.compareTo(signDate) < 0) { + signInTimeIndx += 1440; + flowSignInTimeIndx += 1440; + }else if(kqDate.compareTo(signDate) > 0){ + signInTimeIndx -= 1440; + signInTimeIndx = signInTimeIndx < 0 ? 0 : signInTimeIndx; + flowSignInTimeIndx -= 1440; + flowSignInTimeIndx = flowSignInTimeIndx < 0 ? 0 : flowSignInTimeIndx; + } + if(oneSign){ + if(workBeginIdx>signInTimeIndx) { + earlyInMins = workBeginIdx-signInTimeIndx; + } + } + } else if (checkInfo.get("signType").equals("2")) {//签退 + checkOut++; + //如果流程抵扣存在,打卡时长也存在,那么相互比较得到出勤时长和打卡时长 暂不这样处理,还是按照漏签的逻辑来处理 + if(signTime.length() > 0){ + signInTimeOutdx4Sign = kqTimesArrayComInfo.getArrayindexByTimes(signTime); + } + signOutId = signId; + signOutDate = signDate; + signOutTime = signTime; + signInTimeOutdx = kqTimesArrayComInfo.getArrayindexByTimes(signOutTime); + if(deduct_signofftime.length() > 0){ + if(signTime.length() > 0){ + if(deduct_signofftime.compareTo(signTime) > 0){ + flow_signOutTime = deduct_signofftime; + } + }else{ + flow_signOutTime = deduct_signofftime; + } + } + if(flow_signOutTime.length() > 0){ + signInTimeOutdx = kqTimesArrayComInfo.getArrayindexByTimes(flow_signOutTime); + } + if(kqDate.compareTo(signDate) < 0){ + signInTimeOutdx+=1440; + }else if(kqDate.compareTo(signDate) > 0){ + signInTimeOutdx -= 1440; + signInTimeOutdx = signInTimeOutdx < 0 ? 0 : signInTimeOutdx; + } + if(oneSign){ + if(signInTimeOutdx>workEndIdx) { + lateOutMins = signInTimeOutdx-workEndIdx; + } + } + } + if (checkInfo.get("signType").equals("1")) {//签到 + if(signTime.length() > 0){ + String signMinTime = signTime.substring(0,5)+":00"; + endIdx = kqTimesArrayComInfo.getArrayindexByTimes(signTime); + if(signTime.compareTo(signMinTime) > 0){ + //如果签到时间是带秒的且是迟到,那么签到时间多一秒和多一分钟是一样的 + endIdx += 1; + signInTimeIndx = signInTimeIndx + 1;//如果是带秒的打卡数据不应该影响流程抵扣的数据的下标 + } + if(kqDate.compareTo(signDate) < 0){ + endIdx+=1440; + }else if(kqDate.compareTo(signDate) > 0){ + endIdx -= 1440; + endIdx = endIdx < 0 ? 0 : endIdx; + } + if (endIdx > workBeginIdx) { + if(flow_signInTime.length() > 0){ + if(flowSignInTimeIndx > workBeginIdx){ + //增加一个判断,流程抵扣打卡如果开启了并且有抵扣上班打卡,那么也就不是迟到了 + Arrays.fill(dayMins, workBeginIdx, endIdx, 2);//迟到时段标识 2 + } + }else{ + Arrays.fill(dayMins, workBeginIdx, endIdx, 2);//迟到时段标识 2 + } + } + } + } else if (checkInfo.get("signType").equals("2")) {//签退 + if(signTime.length() > 0){ + beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(signTime); + if(StringUtils.isNotBlank(signDate) && signDate.compareTo(kqDate) > 0){ + beginIdx+=1440; + }else if(kqDate.compareTo(signDate) > 0){ + beginIdx -= 1440; + beginIdx = beginIdx < 0 ? 0 : beginIdx; + } + if (workEndIdx > beginIdx) { + if(flow_signOutTime.length() > 0){ + if (workEndIdx > signInTimeOutdx) { + //增加一个判断,流程抵扣打卡如果开启了并且有抵扣下班打卡,那么也就不是早退了 + Arrays.fill(dayMins, beginIdx, workEndIdx, 3);//早退时段标识 3 + } + }else{ + + Arrays.fill(dayMins, beginIdx, workEndIdx, 3);//早退时段标识 3 + } + } + } + } + } + + //打卡时长=签退时间-签到时间(有签到签退才计算) + if(checkIn==1&&checkOut==1){ + if(signInTimeIndx4Sign > -1 && signInTimeOutdx4Sign > -1){ + if(DateUtil.dayDiff(signInDate,signOutDate)==0){//同一天签到和签退 + signMins=signInTimeOutdx4Sign - signInTimeIndx4Sign; + }else if(DateUtil.dayDiff(signInDate,signOutDate)==1) {//第一天签到,第二天签退 + if(signInTimeOutdx4Sign workBeginIdx) { + Arrays.fill(dayMins, workBeginIdx, workEndIdx, 4);//旷工时段标识 4 + } + } + + if (checkOut == 0 && checkIn > 0) {//漏签(有签到无签退) + if(signInTimeIndx > -1){ + if (workEndIdx > signInTimeIndx) { + //漏签就是从本次时段内的打卡到下班点 + //上班漏签应该是从签到到签到结束时间,不过这里可以不用管,只是一个次数 + Arrays.fill(dayMins, signInTimeIndx, workEndIdx, 6);//上班漏签时段标识 6 + } else { + //签到晚于本次时段结束时间,也算漏签 + forgotCheckMins++; + } + }else if(flowSignInTimeIndx > -1){ + if (workEndIdx > flowSignInTimeIndx) { + //漏签就是从本次时段内的打卡到下班点 + //上班漏签应该是从签到到签到结束时间,不过这里可以不用管,只是一个次数 + Arrays.fill(dayMins, flowSignInTimeIndx, workEndIdx, 6);//上班漏签时段标识 6 + } else { + //签到晚于本次时段结束时间,也算漏签 + forgotCheckMins++; + } + } + } + + if (checkIn == 0 && checkOut > 0) {//漏签(有签退无签到) + if(signInTimeOutdx > 0){ + if(workBeginIdx < signInTimeOutdx) { + //下班漏签应该是从签退到签退开始时间,不过这里可以不用管,只是一个次数 + Arrays.fill(dayMins, workBeginIdx, signInTimeOutdx, 66);//下班漏签时段标识 66,66呼应前面的漏签的6 + }else{ + //这种数据理论上不会存在,也记下吧 + forgotBeginWorkCheckMins++; + } + } + } + + if (workFlowInfo.get(dateKey) != null) { + workFlow = (List) workFlowInfo.get(dateKey); + } + + for (int j = 0; workFlow != null && j < workFlow.size(); j++) { + Map data = (Map) workFlow.get(j); + String flowType = Util.null2String(data.get("flowtype")); + String newLeaveType = Util.null2String(data.get("newleavetype")); + String signtype = Util.null2String(data.get("signtype")); + String serial = Util.null2String(data.get("serial")); + String requestId = Util.null2String(data.get("requestId")); + beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(Util.null2String(data.get("begintime"))); + endIdx = kqTimesArrayComInfo.getArrayindexByTimes(Util.null2String(data.get("endtime"))); + if (beginIdx >= endIdx) { + continue; + } + + if(flowType.equals(FlowReportTypeEnum.EVECTION.getFlowType())){ + Arrays.fill(dayMins, beginIdx, endIdx, 7);//出差抵扣时段标识 7 + }else if(flowType.equals(FlowReportTypeEnum.OUT.getFlowType())){ + Arrays.fill(dayMins, beginIdx, endIdx, 8);//公出抵扣时段标识 8 + }else if(flowType.equalsIgnoreCase(FlowReportTypeEnum.LEAVE.getFlowType())){ + if (endIdx > beginIdx) { + Arrays.fill(dayMins, beginIdx, endIdx, 5);//流程抵扣时段标识 5 + int tmpBeginIdx = beginIdx; + int tmpEndIdx = endIdx; + Integer val = 0; + + if(beginIdx>=workEndIdx){ + continue; + } + if(endIdx<=workBeginIdx){ + continue; + } + + if(leaveInfo.get(newLeaveType)==null){ + leaveInfo.put(newLeaveType,val); + }else{ + val = (Integer) leaveInfo.get(newLeaveType); + } + + if(beginIdxworkEndIdx) { + tmpEndIdx=endIdx; + } + if(tmpEndIdx>tmpBeginIdx){ + leaveInfo.put(newLeaveType,val+(tmpEndIdx-tmpBeginIdx)); + } + } + }else{ + if (endIdx > beginIdx) { + Arrays.fill(dayMins, beginIdx, endIdx, 99);//异常流程抵扣时段标识99 + } + } + } + + + if (workEndTimeAcross && false) {//跨天需要加入一天的流程 + workFlow = null; + if (workFlowInfo.get(nextDateKey) != null) { + workFlow = (List) workFlowInfo.get(nextDateKey); + } + + for (int j = 0; workFlow != null && j < workFlow.size(); j++) { + Map data = (Map) workFlow.get(j); + String flowType = Util.null2String(data.get("flowtype")); + beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(Util.null2String(data.get("begintime")))+1440; + endIdx = kqTimesArrayComInfo.getArrayindexByTimes(Util.null2String(data.get("endtime")))+1440; + if(endIdx>=2880){ + endIdx = 2880; + } + if(flowType.equals(FlowReportTypeEnum.EVECTION.getFlowType())){ + Arrays.fill(dayMins, beginIdx, endIdx, 7);//出差抵扣时段标识 7 + }else if(flowType.equals(FlowReportTypeEnum.OUT.getFlowType())){ + Arrays.fill(dayMins, beginIdx, endIdx, 8);//公出抵扣时段标识 8 + }else if(flowType.equalsIgnoreCase(FlowReportTypeEnum.LEAVE.getFlowType())){ + if (endIdx > beginIdx) { + Arrays.fill(dayMins, beginIdx, endIdx, 5);//流程抵扣时段标识 5 + + } + }else{ + if (endIdx > beginIdx) { + Arrays.fill(dayMins, beginIdx, endIdx, 99);//异常流程抵扣时段标识99 + } + } + } + } + + if(lsRestTime != null && !lsRestTime.isEmpty()){ + for(int k = 0 ; k < lsRestTime.size(); k++){ + TimeScopeEntity restTimeScope = lsRestTime.get(k); + if (restTimeScope!=null) { + String restBeginTime = Util.null2String(restTimeScope.getBeginTime()); + String restEndTime = Util.null2String(restTimeScope.getEndTime()); + beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(restBeginTime); + endIdx = kqTimesArrayComInfo.getArrayindexByTimes(restEndTime); + if (endIdx > beginIdx) { + Arrays.fill(dayMins, beginIdx, endIdx, -11);//休息时间 + } + } + } + int all_rest_cnt = kqTimesArrayComInfo.getCnt(dayMins, workBeginIdx, workEndIdx, -11); + if(all_rest_cnt >= 0){ + workMins = workMins-(all_rest_cnt); + } + } + + for (int j = workBeginIdx; j < workEndIdx; j++) { + switch (dayMins[j]) { + case 1: + tmpAttendanceMins++; + break; + case 2: + beLateMins++; + break; + case 3: + leaveEarlyMins++; + break; + case 4: + absenteeismMins++; + break; + case 5: + leaveMins++; + break; + case 6: + forgotCheckMins++; + break; + case 7: + evectionMins++; + break; + case 8: + outMins++; + break; + case 66: + forgotBeginWorkCheckMins++; + break; + case 99: + otherMins++; + break; + default: + break; + } + } + + if(forgotCheckMins == 1 && beLateMins==0 && tmpAttendanceMins==0){//forgotCheckMins==1表示下班后漏签,不是迟到,流程已完全抵扣异常 + forgotCheckMins = 0; + } + + KQShiftRuleEntity kqShiftRuleEntity = new KQShiftRuleEntity(); + kqShiftRuleEntity.setUserId(userId); + kqShiftRuleEntity.setKqDate(kqDate); + kqShiftRuleEntity.setBelatemins(beLateMins); + kqShiftRuleEntity.setLeaveearlymins(leaveEarlyMins); + kqShiftRuleEntity.setAbsenteeismmins(absenteeismMins); + kqShiftRuleEntity.setForgotcheckmins(forgotCheckMins); + kqShiftRuleEntity.setForgotBeginWorkCheckMins(forgotBeginWorkCheckMins); + kqShiftRuleEntity.setEarlyInMins(earlyInMins); + kqShiftRuleEntity.setLateOutMins(lateOutMins); + kqLog.info("人性化规则处理前数据" + JSONObject.toJSONString(kqShiftRuleEntity)); + if(this.writeLog) { + logInfo.put(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005301,weaver.general.ThreadVarLanguage.getLang())+"",kqShiftRuleEntity); + } + //人性化规则 + kqShiftRuleEntity = kqFormatShiftRule.doShiftRule(workTime,kqShiftRuleEntity); + kqLog.info("人性化规则处理后数据" + JSONObject.toJSONString(kqShiftRuleEntity)); + if(this.writeLog) { + logInfo.put(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005302,weaver.general.ThreadVarLanguage.getLang())+"",kqShiftRuleEntity); + } + beLateMins = kqShiftRuleEntity.getBelatemins(); + graveBeLateMins = kqShiftRuleEntity.getGravebelatemins(); + leaveEarlyMins = kqShiftRuleEntity.getLeaveearlymins(); + graveLeaveEarlyMins = kqShiftRuleEntity.getGraveleaveearlymins(); + absenteeismMins = kqShiftRuleEntity.getAbsenteeismmins(); + forgotCheckMins = kqShiftRuleEntity.getForgotcheckmins(); + forgotBeginWorkCheckMins = kqShiftRuleEntity.getForgotBeginWorkCheckMins(); + + boolean isondutyfreecheck =false; + boolean isoffdutyfreecheck =false; + Map model_ShiftRule = kqFormatShiftRule.getModel_ShiftRule(i, workTime.getSerialId()); + Iterator iter = model_ShiftRule.entrySet().iterator(); + while (iter.hasNext()) { + Map.Entry entry = (Map.Entry) iter.next(); + String key = Util.null2String(entry.getKey()); + String value = Util.null2String(entry.getValue()); + if(key.equals("start")&&value.equals("1")){ + isondutyfreecheck = true; + } + if(key.equals("end")&&value.equals("1")){ + isoffdutyfreecheck = true; + } + } + boolean beforeBegin = !new KQFormatBiz().needCal(workBeginDate,workBeginTime); + if(beforeBegin) {//还未到上班时间,不用计算任何状态 + kqLog.writeLog("还未到上班时间,不用计算任何状态"); + beLateMins = 0; + graveBeLateMins = 0; + leaveEarlyMins = 0; + graveLeaveEarlyMins = 0; + absenteeismMins = 0; + forgotCheckMins = 0; + forgotBeginWorkCheckMins = 0; + }else if(!new KQFormatBiz().needCal(workEndDate,workEndTime)) {//还未到下班时间 + kqLog.writeLog("还未到上班时间"); + leaveEarlyMins = 0; + graveLeaveEarlyMins = 0; + forgotCheckMins = 0; + } + + if (workTime.getIsExclude()) {//无需考勤人员没有异常状态 + beLateMins = 0; + graveBeLateMins = 0; + leaveEarlyMins = 0; + graveLeaveEarlyMins = 0; + absenteeismMins = 0; + forgotCheckMins = 0; + forgotBeginWorkCheckMins = 0; + } + //允许下班不打卡 ,如果上班也没有打卡,那么算上班旷工0.5天 + if (isoffdutyfreecheck) { + if (checkIn == 0) {//(无签到),就会有上班漏签,如果有下班卡,那么上班漏签 + if(forgotBeginWorkCheckMins==0&&absenteeismMins>0){ + forgotBeginWorkCheckMins= absenteeismMins ; + } + } + absenteeismMins = 0; + forgotCheckMins = 0; + } + //允许上班不打卡,如果下班也没有打卡,那么算漏签 + if(isondutyfreecheck){ + if (checkOut == 0) {//(无签退) + if(forgotCheckMins==0&&absenteeismMins>0){ + forgotCheckMins= absenteeismMins ; + } + } + absenteeismMins = 0; + forgotBeginWorkCheckMins = 0; + } + if(isondutyfreecheck&&isoffdutyfreecheck){ + absenteeismMins = 0; + forgotCheckMins = 0; + forgotBeginWorkCheckMins = 0; + } + + //考勤二开--取消漏签,改为旷工(规则:工作时长就是480,直接全天旷工)start + if ( forgotCheckMins > 0) { + absenteeismMins = 480; + forgotCheckMins = 0; + attendanceMins = 0; + } else { + //计算实际出勤时间(出差公出算出勤)=应出勤-旷工-请假-迟到-早退 + attendanceMins = workMins - absenteeismMins-leaveMins-beLateMins-graveBeLateMins-leaveEarlyMins-graveLeaveEarlyMins; + // 如果没有开启"漏签是否算实际出勤"开关,则漏签不算实际出勤时长 + if("0".equals(nosign_is_absent)) { + attendanceMins = attendanceMins-forgotCheckMins-forgotBeginWorkCheckMins; + } + if(beforeBegin || attendanceMins < 0) {//还未到上班时间,不用计算任何状体 + attendanceMins = 0; + } + } + +// //计算实际出勤时间(出差公出算出勤)=应出勤-旷工-请假-迟到-早退 +// attendanceMins = workMins - absenteeismMins-leaveMins-beLateMins-graveBeLateMins-leaveEarlyMins-graveLeaveEarlyMins; +// // 如果没有开启"漏签是否算实际出勤"开关,则漏签不算实际出勤时长 +// if("0".equals(nosign_is_absent)) { +// attendanceMins = attendanceMins-forgotCheckMins-forgotBeginWorkCheckMins; +// } +// if(beforeBegin || attendanceMins < 0) {//还未到上班时间,不用计算任何状体 +// attendanceMins = 0; +// } + //end + + kqLog.info("实际出勤计算公式" + "实际出勤=应出勤- 旷工-请假-迟到-早退 userId" + userId + "kqDate==" + kqDate+":hostIps:"+hostIps+":uuid::"+uuid); + kqLog.info("实际出勤计算结果" + attendanceMins + "=" + workMins + "- " + absenteeismMins + "-" + leaveMins + "-" + (beLateMins + graveBeLateMins) + "-" + (leaveEarlyMins - graveLeaveEarlyMins)+" userId" + userId + "kqDate==" + kqDate+":hostIps:"+hostIps+":uuid::"+uuid); + if(this.writeLog) { + logInfo.put(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005303,weaver.general.ThreadVarLanguage.getLang())+"",""+weaver.systeminfo.SystemEnv.getHtmlLabelName(130566,weaver.general.ThreadVarLanguage.getLang())+"="+weaver.systeminfo.SystemEnv.getHtmlLabelName(132056,weaver.general.ThreadVarLanguage.getLang())+"- "+weaver.systeminfo.SystemEnv.getHtmlLabelName(20085,weaver.general.ThreadVarLanguage.getLang())+"-"+weaver.systeminfo.SystemEnv.getHtmlLabelName(670,weaver.general.ThreadVarLanguage.getLang())+"-"+weaver.systeminfo.SystemEnv.getHtmlLabelName(20081,weaver.general.ThreadVarLanguage.getLang())+"-"+weaver.systeminfo.SystemEnv.getHtmlLabelName(20082,weaver.general.ThreadVarLanguage.getLang())+""); + logInfo.put(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005304,weaver.general.ThreadVarLanguage.getLang())+"",attendanceMins+"="+workMins+"- "+absenteeismMins+"-"+leaveMins+"-"+(beLateMins+graveBeLateMins)+"-"+(leaveEarlyMins-graveLeaveEarlyMins)); + } + //判断当天考勤状态 +// if (beLateMins > 0) { +// status = ButtonStatusEnum.BELATE.getStatusCode(); +// } else if (leaveEarlyMins > 0) { +// status = ButtonStatusEnum.LEAVEERALY.getStatusCode(); +// } else if (absenteeismMins > 0) { +// status = ButtonStatusEnum.ABSENT.getStatusCode(); +// } else if (forgotCheckMins > 0) { +// status = ButtonStatusEnum.NOSIGN.getStatusCode(); +// } else { +// status = ButtonStatusEnum.NORMAL.getStatusCode(); +// } + + String groupid = Util.null2String(workTime.getGroupId()); + String serialid = Util.null2String(workTime.getSerialId()); + + + params.add(userId); + params.add(kqDate); + params.add(groupid.length() == 0 ? null : groupid); + params.add(serialid.length() == 0 ? null : serialid); + params.add(i); + params.add(workBeginDate); + params.add(kqTimesArrayComInfo.turn48to24Time(ori_workBeginTime)); + params.add(workEndDate); + params.add(kqTimesArrayComInfo.turn48to24Time(ori_workEndTime)); + params.add(workMins); + params.add(signInDate); + params.add(signInTime); + params.add(signInId.length() == 0 ? null : signInId); + params.add(signOutDate); + params.add(signOutTime); + params.add(signOutId.length() == 0 ? null : signOutId); + kqLog.info("format in >>>>>userId" + userId + "kqDate==" + kqDate+":hostIps:"+hostIps+":uuid::"+uuid + +":signInDate:"+signInDate+":signInTime::"+signInTime+":signOutDate:"+signOutDate+":signOutTime::"+signOutTime); + params.add(signMins); + params.add(attendanceMins); + params.add(beLateMins); + params.add(graveBeLateMins); + params.add(leaveEarlyMins); + params.add(graveLeaveEarlyMins); + params.add(absenteeismMins); + params.add(forgotCheckMins); + params.add(leaveMins); + params.add(JSONObject.toJSONString(leaveInfo)); + params.add(evectionMins); + params.add(outMins); + params.add(forgotBeginWorkCheckMins); + params.add(JSONObject.toJSONString(otherinfo)); + + Map definedFieldInfo = new KQFormatBiz().getDefinedField(); + String[] definedFields = Util.splitString(Util.null2String(definedFieldInfo.get("definedField")),","); + KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo(); + for (int tmpIdx = 0; tmpIdx env = new HashMap<>(); + String keyname = ""; + while (matcher.find()) { + String key = matcher.group(0); + keyname = key.substring(2, key.length() - 1).trim(); + expression = matcher.replaceAll(keyname); + env.put(keyname, keyname.equals("beLateMins")?beLateMins:leaveEarlyMins); + } + Expression compiledExp = AviatorEvaluator.compile(expression,true); + String value = Util.null2String(compiledExp.execute(env)); + params.add(value); + if(value.equals("1")) { + params.add(keyname.equals("beLateMins") ? beLateMins : leaveEarlyMins); + }else{ + params.add("0"); + } + } + kqLog.info("format in >>>>>userId" + userId + "kqDate==" + kqDate+":hostIps:"+hostIps+":uuid::"+uuid + +":params:"+JSON.toJSONString(params)); + lsParam.add(params); + } + } catch (Exception e) { + writeLog(e); + kqLog.info(e); + } + return lsParam; + } + + public void setWriteLog(boolean writeLog) { + this.writeLog = writeLog; + } + + public Map getLogInfo() { + return logInfo; + } + + public void formatDateByKQDate(String kqdate) { + KQFormatBiz kqFormatBiz = new KQFormatBiz(); + kqFormatBiz.formatDateByKQDate(kqdate); + } + + public void formatDateByGroupId(String groupid, String kqdate) { + KQFormatBiz kqFormatBiz = new KQFormatBiz(); + kqFormatBiz.formatDateByGroupId(groupid, kqdate); + } + + public void formatDate(String resourceid, String kqdate) { + KQFormatBiz kqFormatBiz = new KQFormatBiz(); + kqFormatBiz.formatDate(resourceid, kqdate); + } + + public void delFormatData(String resourceid, String kqdate) { + KQFormatBiz kqFormatBiz = new KQFormatBiz(); + kqFormatBiz.delFormatData(resourceid, kqdate); + } + + /** + * 非工作日格式化考勤报表 + * @param userId + * @param kqDate + * @param nonlsParam + * @param workTime + * @param workFlowInfo + */ + public void formatNonWork(String userId, String kqDate, List nonlsParam, WorkTimeEntity workTime, Map workFlowInfo) { + String signInId = ""; + String signInDate = ""; + String signInTime = ""; + String signOutId = ""; + String signOutDate = ""; + String signOutTime = ""; + int beginIdx = 0; + int endIdx = 0; + int leaveMins = 0;//请假时长 + Map leaveInfo = new HashMap<>();//请假信息 + int evectionMins = 0;//出差时长 + int outMins = 0;//公出时长 + int otherMins = 0;//异常流程时长 + int[] dayMins = new int[2880];//一天所有分钟数 + List workFlow = null; + String dateKey = userId + "|" + kqDate; + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + + String preDate = DateUtil.addDate(kqDate, -1);//上一天日期 + String nextDate = DateUtil.addDate(kqDate, 1);//下一天日期 + WorkTimeEntity pre_workTime = new KQWorkTime().getWorkTime(userId, preDate); + List pre_lsSignTime = new ArrayList<>(); + + if (pre_workTime != null) { + pre_lsSignTime = pre_workTime.getSignTime();//允许打卡时间 + pre_lsSignTime = pre_lsSignTime != null ? pre_lsSignTime : new ArrayList<>(); + } + WorkTimeEntity next_workTime = new KQWorkTime().getWorkTime(userId, nextDate); + List next_lsSignTime = new ArrayList<>(); + + if (next_workTime != null) { + next_lsSignTime = next_workTime.getSignTime();//允许打卡时间 + next_lsSignTime = next_lsSignTime != null ? next_lsSignTime : new ArrayList<>(); + } + + List lsCheckInfo = new KQFormatSignData().getNonWorkSignInfo(userId,preDate,kqDate,pre_lsSignTime,next_lsSignTime); + + for (int j = 0; lsCheckInfo != null && j < lsCheckInfo.size(); j++) { + Map checkInfo = (Map) lsCheckInfo.get(j); + String signStatus = Util.null2String(checkInfo.get("signStatus")); + String signId = Util.null2String(checkInfo.get("signId")); + String signDate = Util.null2String(checkInfo.get("signDate")); + String signTime = Util.null2String(checkInfo.get("signTime")); + if (checkInfo.get("signType").equals("1")) {//签到 + signInId = signId; + signInDate = signDate; + signInTime = signTime; + } else if (checkInfo.get("signType").equals("2")) {//签退 + signOutId = signId; + signOutDate = signDate; + signOutTime = signTime; + } + } + + if (workFlowInfo.get(dateKey) != null) { + workFlow = (List) workFlowInfo.get(dateKey); + } + + for (int j = 0; workFlow != null && j < workFlow.size(); j++) { + Map data = (Map) workFlow.get(j); + String flowType = Util.null2String(data.get("flowtype")); + String newLeaveType = Util.null2String(data.get("newleavetype")); + beginIdx = kqTimesArrayComInfo.getArrayindexByTimes(Util.null2String(data.get("begintime"))); + endIdx = kqTimesArrayComInfo.getArrayindexByTimes(Util.null2String(data.get("endtime"))); + if(flowType.equals(FlowReportTypeEnum.EVECTION.getFlowType())){ + Arrays.fill(dayMins, beginIdx, endIdx, 7);//出差抵扣时段标识 7 + }else if(flowType.equals(FlowReportTypeEnum.OUT.getFlowType())){ + Arrays.fill(dayMins, beginIdx, endIdx, 8);//公出抵扣时段标识 8 + }else if(flowType.equalsIgnoreCase(FlowReportTypeEnum.LEAVE.getFlowType())){ + if (endIdx > beginIdx) { + Arrays.fill(dayMins, beginIdx, endIdx, 5);//流程抵扣时段标识 5 + int tmpBeginIdx = beginIdx; + int tmpEndIdx = endIdx; + Integer val = 0; + if(leaveInfo.get(newLeaveType)==null){ + leaveInfo.put(newLeaveType,val); + }else{ + val = (Integer) leaveInfo.get(newLeaveType); + } + if(tmpEndIdx>tmpBeginIdx){ + leaveInfo.put(newLeaveType,val+(tmpEndIdx-tmpBeginIdx)); + } + } + }else{ + if (endIdx > beginIdx) { + Arrays.fill(dayMins, beginIdx, endIdx, 99);//异常流程抵扣时段标识99 + } + } + } + + for (int j = 0; j < 2880; j++) { + switch (dayMins[j]) { + case 5: + leaveMins++; + break; + case 7: + evectionMins++; + break; + case 8: + outMins++; + break; + case 99: + otherMins++; + break; + default: + break; + } + } + + nonlsParam.add(userId); + nonlsParam.add(kqDate); + nonlsParam.add(workTime.getGroupId()); + nonlsParam.add(0); + nonlsParam.add(signInDate); + nonlsParam.add(signInTime); + nonlsParam.add(signInId.length() == 0 ? null : signInId); + nonlsParam.add(signOutDate); + nonlsParam.add(signOutTime); + nonlsParam.add(signOutId.length() == 0 ? null : signOutId); + nonlsParam.add(leaveMins); + nonlsParam.add(JSONObject.toJSONString(leaveInfo)); + nonlsParam.add(evectionMins); + nonlsParam.add(outMins); + } +} diff --git a/src/com/engine/kq/biz/KQReportBiz.java b/src/com/engine/kq/biz/KQReportBiz.java new file mode 100644 index 0000000..6e1899a --- /dev/null +++ b/src/com/engine/kq/biz/KQReportBiz.java @@ -0,0 +1,2727 @@ +package com.engine.kq.biz; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.engine.kq.cmd.attendanceButton.ButtonStatusEnum; +import com.engine.kq.enums.KqSplitFlowTypeEnum; +import com.engine.kq.log.KQLog; +import com.engine.kq.util.KQDurationCalculatorUtil; +import com.engine.kq.util.KQTransMethod; +import org.apache.commons.lang3.StringUtils; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.util.*; +import java.util.Map.Entry; + +public class KQReportBiz extends BaseBean { + + private static DecimalFormat df = new DecimalFormat("0.00"); + + private DecimalFormatSymbols symbols = new DecimalFormatSymbols(); + + BaseBean basebean = new BaseBean(); + + + public String format(double value) { +// DecimalFormatSymbols symbols = new DecimalFormatSymbols(); + symbols.setDecimalSeparator('.'); + df.setMaximumFractionDigits(5); + df.setDecimalFormatSymbols(symbols); + return df.format(value); + } + + + private KQLog kqLog = new KQLog(); + /** + * 初始化当天考勤数据 + */ + public void initKQReportData(){ + String date = DateUtil.getCurrentDate(); + RecordSet rs = new RecordSet(); + String sql = ""; + try{ + boolean hasInit = false; + sql = "select 1 from kq_report_check where check_date = ? "; + rs.executeQuery(sql,date); + if(rs.next()) { + hasInit = true; + } + + String beforeyesterday = DateUtil.addDate(date,-2); + String yesterday = DateUtil.addDate(date,-1); + if(!hasInit){ + //这里做过功能是每天都刷下考勤缓存 因为这个缓存也是异步的,一点都不稳定 + kqLog.info("begin do KQOneStopUp refreshCominfo invoke ..."); + new KQOneStopUp().refreshCominfo(); + kqLog.info("end do KQOneStopUp refreshCominfo invoke ..."); + + KQFormatBiz kqFormatBiz = new KQFormatBiz(); + kqFormatBiz.clearFormatPool(); + //格式化上上天数据 + kqFormatBiz.formatDateByKQDate(beforeyesterday); + //格式化上一天数据 + kqFormatBiz.formatDateByKQDate(yesterday); + //初始化今天数据 + kqFormatBiz.formatDateByKQDate(date); + + sql = " insert into kq_report_check(check_date) values (?)"; + rs.executeUpdate(sql,date); + + writeLog(date+"执行考勤报表数据格式化成功!"); + } + }catch (Exception e){ + writeLog(e); + } + } + + public Map getModel_ShiftRule(String i,String serialId) { + RecordSet rs = new RecordSet(); + HashMap sectionMap = new HashMap<>(); + String getStartWorkSections = "select * from kq_ShiftOnOffWorkSections where SERIALID=? and record=? "; + rs.executeQuery(getStartWorkSections,serialId,i); + while (rs.next()) { + String onoffworktype = Util.null2String(rs.getString("onoffworktype")); + String clockinnot = Util.null2s(Util.null2String(rs.getString("clockinnot")), "0"); + sectionMap.put(onoffworktype, clockinnot); + } + return sectionMap; + } + + /*** + * 获取考勤状态 + * @param resourceId + * @param fromdate + * @param todate + * @param isAll + * @return + */ + public List getKqDateInfo(String resourceId, String fromdate, String todate, boolean isAll) { + List kqdates = new ArrayList<>(); + RecordSet rs = new RecordSet(); + String sql = ""; + try { + Map kqdate = null; + List datas = null; + Map data = null; + sql = " select kqdate,serialid, workbegindate, workbegintime,workenddate, workendtime," + + " signintime,signouttime,beLateMins,graveBeLateMins,leaveEarlyMins,graveLeaveEarlyMins," + + " absenteeismMins, forgotCheckMins,forgotBeginWorkCheckMins,otherinfo,serialnumber "+ + " from kq_format_detail " + + " where resourceid=? and kqdate>=? and kqdate<=? "; + if(!isAll){ + if(rs.getDBType().equalsIgnoreCase("oracle") || Util.null2String(rs.getOrgindbtype()).equals("dm") || Util.null2String(rs.getOrgindbtype()).equals("st")) { + sql += " and nvl(beLateMins,0)+nvl(graveBeLateMins,0)+nvl(leaveEarlyMins,0)+nvl(graveLeaveEarlyMins,0)+nvl(absenteeismMins,0)+nvl(forgotCheckMins,0)+nvl(forgotBeginWorkCheckMins,0)>0 "; + }else if((rs.getDBType()).equalsIgnoreCase("mysql")){ + sql += " and ifnull(beLateMins,0)+ifnull(graveBeLateMins,0)+ifnull(leaveEarlyMins,0)+ifnull(graveLeaveEarlyMins,0)+ifnull(absenteeismMins,0)+ifnull(forgotCheckMins,0)+ifnull(forgotBeginWorkCheckMins,0)>0 "; + }else { + sql += " and isnull(beLateMins,0)+isnull(graveBeLateMins,0)+isnull(leaveEarlyMins,0)+isnull(graveLeaveEarlyMins,0)+isnull(absenteeismMins,0)+isnull(forgotCheckMins,0)+isnull(forgotBeginWorkCheckMins,0)>0 "; + } + } + sql += " order by kqdate "; + + rs.executeQuery(sql,resourceId,fromdate, todate); + while(rs.next()){ + String serialnumber = Util.null2String(rs.getString("serialnumber")); + String serialid = Util.null2String(rs.getString("serialid")); + String workbegindate = Util.null2String(rs.getString("workbegindate")); + String workbegintime = Util.null2String(rs.getString("workbegintime")); + String workenddate = Util.null2String(rs.getString("workenddate")); + String workendtime = Util.null2String(rs.getString("workendtime")); + String signintime = Util.null2String(rs.getString("signintime")); + String signouttime = Util.null2String(rs.getString("signouttime")); + int beLateMins = rs.getInt("beLateMins"); + int graveBeLateMins = rs.getInt("graveBeLateMins"); + int leaveEarlyMins = rs.getInt("leaveEarlyMins"); + int graveLeaveEarlyMins = rs.getInt("graveLeaveEarlyMins"); + int absenteeismMins = rs.getInt("absenteeismMins"); + int forgotCheckMins = rs.getInt("forgotCheckMins"); + int forgotBeginWorkCheckMins = rs.getInt("forgotBeginWorkCheckMins"); + String otherinfo = Util.null2String(rs.getString("otherinfo")); + + String shift_begindate = ""; + String shift_beginworktime = ""; + String shift_enddate = ""; + String shift_endworktime = ""; + if(otherinfo.length() > 0){ + JSONObject otherinfo_object = JSONObject.parseObject(otherinfo); + if(otherinfo_object != null && !otherinfo_object.isEmpty()){ + JSONObject shiftRule = (JSONObject) otherinfo_object.get("shiftRule"); + if(shiftRule != null && !shiftRule.isEmpty()){ + shift_begindate = Util.null2String(shiftRule.get("shift_begindate")); + shift_beginworktime = Util.null2String(shiftRule.get("shift_beginworktime")); + shift_enddate = Util.null2String(shiftRule.get("shift_enddate")); + shift_endworktime = Util.null2String(shiftRule.get("shift_endworktime")); + if(shift_begindate.length() > 0){ + workbegindate = shift_begindate; + } + if(shift_beginworktime.length() > 0){ + workbegintime = shift_beginworktime; + } + if(shift_enddate.length() > 0){ + workenddate = shift_enddate; + } + if(shift_endworktime.length() > 0){ + workendtime = shift_endworktime; + } + } + } + } + + kqdate = new HashMap<>(); + datas = new ArrayList<>(); + kqdate.put("kqdate",Util.null2String(rs.getString("kqdate"))); + if(workbegindate.length()>0){ + data = new HashMap<>(); + data.put("workbegindate",workbegindate); + data.put("workbegintime",workbegintime); + data.put("signintime",signintime); + + data.put("workenddate",workenddate); + data.put("workendtime",workendtime); + data.put("signouttime",signouttime); + String status = ""; + if(beLateMins>0||graveBeLateMins>0){ + status = ButtonStatusEnum.BELATE.getStatusCode(); + } + if(forgotBeginWorkCheckMins>0){ + if(status.length()>0)status+=","; + status += ButtonStatusEnum.NOSIGN_ON.getStatusCode(); + } + if(leaveEarlyMins>0||graveLeaveEarlyMins>0){ + if(status.length()>0)status+=","; + status += ButtonStatusEnum.LEAVEERALY.getStatusCode(); + } + if(absenteeismMins>0){ + int isondutyfreecheck =0; + int isoffdutyfreecheck =0; + Map model_ShiftRule = getModel_ShiftRule(serialnumber, serialid); + Iterator iter = model_ShiftRule.entrySet().iterator(); + while (iter.hasNext()) { + Entry entry = (Entry) iter.next(); + String key = Util.null2String(entry.getKey()); + String value = Util.null2String(entry.getValue()); + if(key.equals("start")&&value.equals("1")){ + isondutyfreecheck = 1; + } + if(key.equals("end")&&value.equals("1")){ + isoffdutyfreecheck = 1; + } + } + data.put("start",isondutyfreecheck); + data.put("end",isoffdutyfreecheck); + if(status.length()>0)status+=","; + status += ButtonStatusEnum.ABSENT.getStatusCode(); + } + if(forgotCheckMins>0){ + if(status.length()>0)status+=","; + status += ButtonStatusEnum.NOSIGN.getStatusCode(); + } + data.put("status",status); + datas.add(data); + } + + kqdate.put("checkInfo",datas); + kqdates.add(kqdate); + } + } catch (Exception e) { + writeLog(e); + } + return kqdates; + } + + /** + * 获取报表权限 + * @param reportType 报表类型 + * @param userId 用户id + * @param tableExt 别名 + * @return + */ + public String getReportRight(String reportType, String userId, String tableExt){ + String rightSql = ""; + String sql = ""; + RecordSet rs = new RecordSet(); + try{ + List userAllUserIds = new ArrayList<>(); + List userAllDeptIds = new ArrayList<>(); + List userAllSubCompanyIds = new ArrayList<>(); + List userAllJobtitleIds = new ArrayList<>(); + boolean forAllUser = false; + sql = " select sharelevel,subcomid, deptid,userid,jobtitleid,foralluser from kq_reportshare where resourceid=? "; + if(reportType.length()>0 ){ + sql += " and (reportname =0 or reportname =" + reportType+")"; + } + rs.executeQuery(sql,userId); + while(rs.next()){ + int sharelevel = rs.getInt("sharelevel"); + if(sharelevel==0){//分部 + if(Util.null2String(rs.getString("subcomid")).length()>0){ + userAllSubCompanyIds.add(rs.getString("subcomid")); + } + }else if(sharelevel==1){//部门 + if(Util.null2String(rs.getString("deptid")).length()>0) { + userAllDeptIds.add(rs.getString("deptid")); + } + }else if(sharelevel==2){//人员 + if(Util.null2String(rs.getString("userid")).length()>0) { + userAllUserIds.add(rs.getString("userid")); + } + }else if(sharelevel==3){//岗位 + if(Util.null2String(rs.getString("jobtitleid")).length()>0) { + userAllJobtitleIds.add(rs.getString("jobtitleid")); + } + }else if(sharelevel==4){//所有人 + forAllUser = true; + userAllUserIds.clear(); + userAllDeptIds.clear(); + userAllSubCompanyIds.clear(); + userAllJobtitleIds.clear(); + break; + } + } + + if(!forAllUser) { + for (int sharelevel = 0; sharelevel < 4; sharelevel++) { + if (sharelevel == 0) {//分部 + if (userAllSubCompanyIds.size() > 0) { + if(rightSql.length()>0)rightSql+= " or "; + rightSql += tableExt+".subcompanyid1 in(" + String.join(",", userAllSubCompanyIds) + ")"; + } + } else if (sharelevel == 1) {//部门 + if (userAllDeptIds.size() > 0) { + if(rightSql.length()>0)rightSql+= " or "; + rightSql += tableExt+".departmentid in(" + String.join(",", userAllDeptIds) + ")"; + } + } else if (sharelevel == 2) {//人员 + if (userAllUserIds.size() > 0) { + if(rightSql.length()>0)rightSql+= " or "; + rightSql += tableExt+".id in(" + String.join(",", userAllUserIds) + ")"; + } + } else if (sharelevel == 3) {//岗位 + if (userAllJobtitleIds.size() > 0) { + if(rightSql.length()>0)rightSql+= " or "; + rightSql += tableExt+".jobtitle in(" + String.join(",", userAllJobtitleIds) + ")"; + } + } + } + + //可以看自己和下属的考勤 + String selfSql = " ("+tableExt+".id = "+userId+" or "+tableExt+".managerstr like '%,"+userId+",%')"; + if(rightSql.length()>0){ + rightSql = " and ((" +rightSql+") or "+selfSql+" ) "; + }else{ + rightSql = " and "+selfSql; + } + + } + }catch (Exception e){ + writeLog(e); + } + return rightSql; + } + + public static String getUnitType(KQReportFieldComInfo kqReportFieldComInfo, User user){ + String unitTypeName = ""; + String unitType = Util.null2String(kqReportFieldComInfo.getUnittype()); + String parentid = Util.null2String( kqReportFieldComInfo.getParentid()); + String fieldName = Util.null2String(kqReportFieldComInfo.getFieldname()); + if(kqReportFieldComInfo.getIsLeaveType().equals("1")){ + if(fieldName.equals("businessLeave")){ + unitType = KQTravelRulesBiz.getMinimumUnit().equals("3")?"2":"1";//单位类型 + }else if(fieldName.equals("officialBusiness")){ + unitType = KQExitRulesBiz.getMinimumUnit().equals("3")?"2":"1";//单位类型 + }else if(parentid.equals("overtime") || parentid.equals("overtime_nonleave") || parentid.equals("overtime_4leave")){ + unitType = (KQOvertimeRulesBiz.getMinimumUnit()==3 || KQOvertimeRulesBiz.getMinimumUnit()==5 ||KQOvertimeRulesBiz.getMinimumUnit()==6)?"2":"1";//单位类型 + } + } + if(Util.null2String(unitType).length()>0){ + if(unitType.equals("1")){ + unitTypeName=SystemEnv.getHtmlLabelName(1925, user.getLanguage()); + }else if(unitType.equals("2")){ + unitTypeName=SystemEnv.getHtmlLabelName(391, user.getLanguage()); + }else if(unitType.equals("3")){ + unitTypeName=SystemEnv.getHtmlLabelName(18083, user.getLanguage()); + } + } + return unitTypeName; + } + + /** + * 为每日统计报表做流程数据查询 + * @param params + * @param user + * @return + */ + public Map getDailyFlowData(Map params, User user){ + Map datas = new HashMap<>();; + try{ + datas.putAll(getDailyFlowLeaveData(params,user)); + datas.putAll(getDailyFlowEvectionOutData(params,user)); + datas.putAll(getDailyFlowOverTimeData(params,user)); + datas.putAll(getDailyFlowLeaveBackData(params,user)); + + datas.putAll(getSignDetailInfoData(params,user)); + //考勤二开--增加补卡字段 + basebean.writeLog("getDailyFlowData to do "); + datas.putAll(getDailyReissueCardData(params,user)); + + + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + public Map getFlowData(Map params, User user){ + Map datas = new HashMap<>();; + try{ + datas.putAll(getFlowLeaveData(params,user)); + datas.putAll(getFlowEvectionOutData(params,user)); + datas.putAll(getFlowOverTimeDataNew(params,user)); + datas.putAll(getFlowOtherData(params,user)); + datas.putAll(getFlowLeaveBackData(params,user)); + datas.putAll(getFlowProcessChangeData(params,user)); + + datas.putAll(getCardMap(params,user)); + datas.putAll(getOverTime(params,user)); + + //考勤二开--增加补卡start + datas.putAll(getReissueCardData(params,user)); + //end + + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + /** + * 获取补卡汇总数据 + * @param params + * @param user + * @return + */ + public Map getReissueCardData(Map params, User user){ + Map datas = new HashMap<>(); + BaseBean basebean = new BaseBean(); + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(subCompanyId.length()>0){ + sqlWhere +=" and d.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and d.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and d.resourceid in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and d.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and d.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and d.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and d.loginid<>'' "); + } + String reissueCardTableName = basebean.getPropValue("project_sskj", "ReissueCard"); + sql = "select resourceid,COUNT(*) as number " + + "from ( " + + "select d.resourceid,d.lastname,d.subcompanyid1,d.departmentid,d.managerstr,d.managerid,d.loginid,d.detail_signdate " + + "from ( " + + "select b.id as resourceid,b.lastname,b.subcompanyid1,b.departmentid,b.managerstr,b.managerid,b.loginid,c.detail_signdate " + + "from "+reissueCardTableName+" a " + + "left join hrmresource b " + + "on a.sqr = b.id " + + "left join "+reissueCardTableName+"_dt1 c " + + "on c.mainid = a.id " + + "where a.yy = 0 " + + ") d " + + "where d.detail_signdate >='"+fromDate+ "' and d.detail_signdate <='"+toDate+ "' " + sqlWhere + + ")e " + + "group by resourceid"; + rs.execute(sql); + basebean.writeLog("getReissueCardData sql:" + sql); + while (rs.next()) { + String resourceid = Util.null2String(rs.getString("resourceid")); + String number = Util.null2String(rs.getString("number")); + if ( StringUtils.isNotBlank(resourceid)) { + datas.put(resourceid+"|"+"reissueCard",number); + } + } + }catch (Exception e){ + writeLog(e); + } + basebean.writeLog("getReissueCardData datas:" + datas); + return datas; + } + + /** + * 获取补卡数据 + * @param params + * @param user + * @return + */ + public Map getDailyReissueCardData(Map params, User user){ + Map datas = new HashMap<>(); + + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(subCompanyId.length()>0){ + sqlWhere +=" and d.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and d.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and d.resourceid in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and d.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and d.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and d.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and d.loginid<>'' "); + } + String reissueCardTableName = basebean.getPropValue("project_sskj", "ReissueCard"); + sql = "select resourceid,detail_signdate,COUNT(*) as number " + + "from ( " + + "select d.resourceid,d.lastname,d.subcompanyid1,d.departmentid,d.managerstr,d.managerid,d.loginid,d.detail_signdate " + + "from ( " + + "select b.id as resourceid,b.lastname,b.subcompanyid1,b.departmentid,b.managerstr,b.managerid,b.loginid,c.detail_signdate " + + "from "+reissueCardTableName+" a " + + "left join hrmresource b " + + "on a.sqr = b.id " + + "left join "+reissueCardTableName+"_dt1 c " + + "on c.mainid = a.id " + + "where a.yy = 0 " + + ") d " + + "where d.detail_signdate >='"+fromDate+ "' and d.detail_signdate <='"+toDate+ "' " + sqlWhere + + ")e " + + "group by resourceid,detail_signdate"; + + basebean.writeLog("getDailyReissueCardData sql:" + sql); + rs.execute(sql); + while (rs.next()) { + String resourceid = Util.null2String(rs.getString("resourceid")); + String detailSigndate = Util.null2String(rs.getString("detail_signdate")); + String number = Util.null2String(rs.getString("number")); + if ( StringUtils.isNotBlank(resourceid) && StringUtils.isNotBlank(detailSigndate)) { + datas.put(resourceid+"|"+detailSigndate+"|"+"reissueCard",number); + } + } + }catch (Exception e){ + writeLog(e); + } + basebean.writeLog("getDailyReissueCardData datas:" + datas); + return datas; + } + + /** + * 获取出差和公出数据 + * @param params + * @param user + * @return + */ + public Map getFlowEvectionOutData(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + String[] tables = new String[]{KqSplitFlowTypeEnum.EVECTION.getTablename(),//出差 + KqSplitFlowTypeEnum.OUT.getTablename()};//公出 + + String minimumUnit = "";//单位类型 + double proportion = 0.00;//换算关系 + + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and b.resourceid in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + + for(String table : tables){ + sql = " select resourceid, durationrule, sum(duration) as val from hrmresource a, "+table+" b "+ + " where a.id = b.resourceid and (b.status is null or b.status<>1) and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' "+sqlWhere+ + " group by resourceid, durationrule "; + rs.execute(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + double value = rs.getDouble("val"); + String durationrule = rs.getString("durationrule"); + + String flowType = ""; + if(KqSplitFlowTypeEnum.EVECTION.getTablename().equals(table)){ + flowType = "businessLeave"; + minimumUnit = KQTravelRulesBiz.getMinimumUnit();//单位类型 + proportion = Util.getDoubleValue(KQTravelRulesBiz.getHoursToDay());//换算关系 + + }else if(KqSplitFlowTypeEnum.OUT.getTablename().equals(table)){ + flowType = "officialBusiness"; + minimumUnit = KQExitRulesBiz.getMinimumUnit();//单位类型 + proportion = Util.getDoubleValue(KQExitRulesBiz.getHoursToDay());//换算关系 + } + + if(KQUnitBiz.isLeaveHour(minimumUnit)){//按小时 + if(!KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value*proportion; + } + }else{//按天 + if(KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value/proportion; + } + } + + String key = resourceid+"|"+flowType; + if(datas.containsKey(key)){ + value += Util.getDoubleValue(Util.null2String(datas.get(key))); + } + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + datas.put(key, format(value)); + } + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + /** + * 获取每日的出差和公出数据 + * @param params + * @param user + * @return + */ + public Map getDailyFlowEvectionOutData(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + String[] tables = new String[]{KqSplitFlowTypeEnum.EVECTION.getTablename(),//出差 + KqSplitFlowTypeEnum.OUT.getTablename()};//公出 + + String minimumUnit = "";//单位类型 + double proportion = 0.00;//换算关系 + + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and b.resourceid in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + + for(String table : tables){ + sql = " select resourceid, durationrule, sum(duration) as val,belongdate from hrmresource a, "+table+" b "+ + " where a.id = b.resourceid and (b.status is null or b.status<>1) and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' "+sqlWhere+ + " group by resourceid, durationrule,belongdate "; + rs.execute(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + String belongdate = rs.getString("belongdate"); + double value = rs.getDouble("val"); + String durationrule = rs.getString("durationrule"); + + String flowType = ""; + if(KqSplitFlowTypeEnum.EVECTION.getTablename().equals(table)){ + flowType = "businessLeave"; + minimumUnit = KQTravelRulesBiz.getMinimumUnit();//单位类型 + proportion = Util.getDoubleValue(KQTravelRulesBiz.getHoursToDay());//换算关系 + }else if(KqSplitFlowTypeEnum.OUT.getTablename().equals(table)){ + flowType = "officialBusiness"; + minimumUnit = KQExitRulesBiz.getMinimumUnit();//单位类型 + proportion = Util.getDoubleValue(KQExitRulesBiz.getHoursToDay());//换算关系 + } + + if(KQUnitBiz.isLeaveHour(minimumUnit)){//按小时 + if(!KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value*proportion; + } + }else{//按天 + if(KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value/proportion; + } + } + + String key = resourceid+"|"+belongdate+"|"+flowType; + if(datas.containsKey(key)){ + value += Util.getDoubleValue(Util.null2String(datas.get(key))); + } + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + datas.put(key, format(value)); + } + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + /** + * 获取请假数据 + * @param params + * @param user + * @return + */ + public Map getFlowLeaveData(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and b.resourceid in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + + sql = " select resourceid, newleavetype, durationrule, sum(duration) as val from hrmresource a, "+KqSplitFlowTypeEnum.LEAVE.getTablename()+" b "+ + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere + + " group by resourceid, newleavetype, durationrule "; + rs.execute(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + String newleavetype = rs.getString("newleavetype"); + String durationrule = rs.getString("durationrule"); + double value = rs.getDouble("val")<0?0:rs.getDouble("val"); + + double proportion = Util.getDoubleValue(kqLeaveRulesComInfo.getProportion(newleavetype)); + if(KQUnitBiz.isLeaveHour(newleavetype, kqLeaveRulesComInfo)){//按小时 + if(!KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value*proportion; + } + }else{//按天 + if(KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value/proportion; + } + } + + String key = resourceid+"|leaveType_"+newleavetype; + if(datas.containsKey(key)){ + value += Util.getDoubleValue(Util.null2String(datas.get(key))); + } + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + datas.put(key,format(value)); + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + + //获取打卡数据用于判断外勤,补卡等信息=============================== + public Map getCardMap(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + //rs.writeLog("getCardMap="+ JSONObject.toJSONString(params)); + try{ + String show_card_source = Util.null2String(params.get("show_card_source")); + if(!"1".equals(show_card_source)){//下面的日历都是实时拼接,这里还是控制下数据库的交互次数,虽然用起来没啥用-.- + return datas; + } + + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + KQTransMethod kqTransMethod = new KQTransMethod(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + rs.writeLog("jsonObj="+ jsonObj.toJSONString()); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and a.id in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + //em7外勤、云桥外勤数据同步、钉钉外勤打卡、微信外勤转考勤(补卡先留一个口子,以防客户要) +// sqlWhere += " and (signfrom like 'card%' or signfrom='e9_mobile_out' or signfrom='EMSyn_out' or signfrom='DingTalk_out' or signfrom='Wechat_out') "; + + sql = " select a.id,b.signdate,b.id as signid,b.signfrom from hrmresource a, hrmschedulesign b "+ + " where a.id = b.userid and b.signdate >='"+fromDate+"' and b.signdate <='"+toDate+"' " +sqlWhere + + " order by a.id,b.signdate "; + rs.execute(sql); +// kqLog.info("card.sql="+sql); + while (rs.next()) { + String resourceid = Util.null2String(rs.getString("id")); + String signdate = Util.null2String(rs.getString("signdate")); + String signid = Util.null2String(rs.getString("signid")); + String signfrom = Util.null2String(rs.getString("signfrom")); + String signFromShow = kqTransMethod.getSignFromShow(signfrom, ""+user.getLanguage()); + String key = resourceid+"|"+signdate; + + datas.put(signid,signFromShow); + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + +//获取打卡数据用于判断外勤,补卡等信息=============================== + + /** + * 获取销假数据 + * @param params + * @param user + * @return + */ + public Map getFlowLeaveBackData(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and b.resourceid in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + + sql = " select resourceid, newleavetype, durationrule, sum(duration) as val from hrmresource a, "+KqSplitFlowTypeEnum.LEAVEBACK.getTablename()+" b "+ + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere + + " group by resourceid, newleavetype, durationrule "; + rs.execute(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + String newleavetype = rs.getString("newleavetype"); + String durationrule = rs.getString("durationrule"); + double value = rs.getDouble("val")<0?0:rs.getDouble("val"); + + double proportion = Util.getDoubleValue(kqLeaveRulesComInfo.getProportion(newleavetype)); + if(KQUnitBiz.isLeaveHour(newleavetype,kqLeaveRulesComInfo)){//按小时 + if(!KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value*proportion; + } + }else{//按天 + if(KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value/proportion; + } + } + + String key = resourceid+"|leavebackType_"+newleavetype; + if(datas.containsKey(key)){ + value += Util.getDoubleValue(Util.null2String(datas.get(key))); + } + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + datas.put(key,format(value)); + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + /** + * 获取考勤变更流程数据 + * @param params + * @param user + * @return + */ + public Map getFlowProcessChangeData(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + String minimumUnit = "";//单位类型 + double proportion = 0.00;//换算关系 + + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and b.resourceid in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + + sql = " select resourceid, durationrule, changetype,sum(duration) as val from hrmresource a, "+KqSplitFlowTypeEnum.PROCESSCHANGE.getTablename()+" b "+ + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' "+sqlWhere+ + " group by resourceid, durationrule,changetype "; + rs.execute(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + int changetype = Util.getIntValue(rs.getString("changetype")); + + String flowType = ""; + if(KqSplitFlowTypeEnum.EVECTION.getFlowtype() == changetype){ + flowType = "businessLeave_back"; + proportion = Util.getDoubleValue(KQTravelRulesBiz.getHoursToDay());//换算关系 + minimumUnit = KQTravelRulesBiz.getMinimumUnit(); + }else if(KqSplitFlowTypeEnum.OUT.getFlowtype() == changetype){ + flowType = "officialBusiness_back"; + minimumUnit = KQExitRulesBiz.getMinimumUnit(); + proportion = Util.getDoubleValue(KQExitRulesBiz.getHoursToDay());//换算关系 + } + double value = rs.getDouble("val")<0?0:rs.getDouble("val"); + String durationrule = rs.getString("durationrule"); + + if(KQUnitBiz.isLeaveHour(minimumUnit)){//按小时 + if(!KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value*proportion; + } + }else{//按天 + if(KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value/proportion; + } + } + + String key = resourceid+"|"+flowType; + if(datas.containsKey(key)){ + value += Util.getDoubleValue(Util.null2String(datas.get(key))); + } + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + datas.put(key, format(value)); + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + /** + * 获取每日请假数据 + * @param params + * @param user + * @return + */ + public Map getDailyFlowLeaveData(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and b.resourceid in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + + sql = " select resourceid, newleavetype, durationrule, sum(duration) as val,belongdate from hrmresource a, "+KqSplitFlowTypeEnum.LEAVE.getTablename()+" b "+ + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere + + " group by resourceid, newleavetype, durationrule,belongdate "; + rs.execute(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + String belongdate = rs.getString("belongdate"); + String newleavetype = rs.getString("newleavetype"); + String durationrule = rs.getString("durationrule"); + double value = rs.getDouble("val")<0?0:rs.getDouble("val"); + + double proportion = Util.getDoubleValue(kqLeaveRulesComInfo.getProportion(newleavetype)); + if(KQUnitBiz.isLeaveHour(newleavetype,kqLeaveRulesComInfo)){//按小时 + if(!KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value*proportion; + } + }else{//按天 + if(KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value/proportion; + } + } + + String key = resourceid+"|"+belongdate+"|leaveType_"+newleavetype; + if(datas.containsKey(key)){ + value += Util.getDoubleValue(Util.null2String(datas.get(key))); + } + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + datas.put(key,format(value)); + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + + public Map getSignDetailInfoData(Map params, User user){ + Map data = new HashMap<>(); + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String isneedcal = Util.null2String(params.get("isneedcal")); + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and b.resourceid in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + + //================================= +// Map data = new HashMap<>(); + Map signStatusInfo = null; + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + sql = " select kqdate,resourceid,serialid,serialnumber,workbegindate,workbegintime, " + + " workenddate,workendtime,workmins,signindate,signintime,signoutdate,signouttime, \n" + + " attendanceMins,belatemins,graveBeLateMins,leaveearlymins,graveLeaveEarlyMins,absenteeismmins,forgotcheckMins,forgotBeginWorkCheckMins," + + " leaveMins,leaveInfo,evectionMins,outMins,signinid,signoutid \n" + + " from hrmresource a,kq_format_detail b \n" + + " where a.id = b.resourceid " +sqlWhere+ + " and b.kqdate >='" + fromDate + "' and b.kqdate<='"+toDate+"' \n" + + " order by b.serialnumber \n"; + rs.execute(sql); + while (rs.next()) { + String resourceid = Util.null2String(rs.getString("resourceid")); + String kqdate = Util.null2String(rs.getString("kqdate")); + String serialid = Util.null2String(rs.getString("serialid")); + int serialnumber = rs.getInt("serialnumber")+1; + String workbegindate = Util.null2String(rs.getString("workbegindate")).trim(); + String workbegintime = Util.null2String(rs.getString("workbegintime")).trim(); + String workenddate = Util.null2String(rs.getString("workenddate")).trim(); + String workendtime = Util.null2String(rs.getString("workendtime")).trim(); + int workMins = rs.getInt("workMins"); + String signintime = Util.null2String(rs.getString("signintime")).trim(); + String signouttime = Util.null2String(rs.getString("signouttime")).trim(); + int attendanceMins = rs.getInt("attendanceMins"); + String beLateMins = Util.null2String(rs.getString("beLateMins")).trim(); + String graveBeLateMins = Util.null2String(rs.getString("graveBeLateMins")).trim(); + String leaveEarlyMins= Util.null2String(rs.getString("leaveEarlyMins")).trim(); + String graveLeaveEarlyMins= Util.null2String(rs.getString("graveLeaveEarlyMins")).trim(); + String absenteeismMins= Util.null2String(rs.getString("absenteeismMins")).trim(); + String forgotCheckMins = Util.null2String(rs.getString("forgotcheckMins")).trim(); + String forgotBeginWorkCheckMins = Util.null2String(rs.getString("forgotBeginWorkCheckMins")).trim(); + String signinid = Util.null2String(rs.getString("signinid")).trim(); + String signoutid = Util.null2String(rs.getString("signoutid")).trim(); + int leaveMins = rs.getInt("leaveMins"); + String leaveInfo = Util.null2String(rs.getString("leaveInfo")); + int evectionMins = rs.getInt("evectionMins"); + int outMins = rs.getInt("outMins"); + + String tmpkey = resourceid+"|"+kqdate+"|"; + + + if(serialid.length()>0){ + if (workbegintime.length() > 0) { + signStatusInfo = new HashMap(); + signStatusInfo.put("workdate",workbegindate); + signStatusInfo.put("worktime",workbegintime); + signStatusInfo.put("beLateMins",beLateMins); + signStatusInfo.put("forgotBeginWorkCheckMins",forgotBeginWorkCheckMins); + signStatusInfo.put("graveBeLateMins",graveBeLateMins); + signStatusInfo.put("absenteeismMins",absenteeismMins); + signStatusInfo.put("leaveMins",leaveMins); + signStatusInfo.put("leaveInfo",leaveInfo); + signStatusInfo.put("evectionMins",evectionMins); + signStatusInfo.put("outMins",outMins); + signStatusInfo.put("isneedcal",isneedcal); + + data.put(tmpkey+"signintime"+serialnumber, signintime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signintime); + data.put(tmpkey+"signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on")); + } + + if (workendtime.length() > 0) { + signStatusInfo = new HashMap(); + signStatusInfo.put("workdate",workenddate); + signStatusInfo.put("worktime",kqTimesArrayComInfo.turn48to24Time(workendtime)); + signStatusInfo.put("leaveEarlyMins",leaveEarlyMins); + signStatusInfo.put("graveLeaveEarlyMins",graveLeaveEarlyMins); + signStatusInfo.put("forgotCheckMins",forgotCheckMins); + signStatusInfo.put("forgotBeginWorkCheckMins",forgotBeginWorkCheckMins); + signStatusInfo.put("absenteeismMins",absenteeismMins); + signStatusInfo.put("leaveMins",leaveMins); + signStatusInfo.put("leaveInfo",leaveInfo); + signStatusInfo.put("evectionMins",evectionMins); + signStatusInfo.put("outMins",outMins); + signStatusInfo.put("isneedcal",isneedcal); + + data.put(tmpkey+"signouttime"+serialnumber, signouttime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signouttime); + data.put(tmpkey+"signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off")); + } + }else{ + if(workMins>0){ + //弹性工时打卡时间取自签到签退数据 + } + signStatusInfo = new HashMap(); + signStatusInfo.put("leaveMins",leaveMins); + signStatusInfo.put("leaveInfo",leaveInfo); + signStatusInfo.put("evectionMins",evectionMins); + signStatusInfo.put("outMins",outMins); + signStatusInfo.put("isneedcal",isneedcal); + + if(signinid.length() > 0){ + data.put(tmpkey+"signintime"+serialnumber, signintime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signintime); + data.put(tmpkey+"signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on")); + if(signoutid.length() > 0){ + data.put(tmpkey+"signouttime"+serialnumber, signouttime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signouttime); + data.put(tmpkey+"signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off")); + } + }else{ + data.put(tmpkey+"signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on")); + } + } + } + }catch (Exception e){ + writeLog(e); + } + return data; + } + + /** + * 获取每日销假数据 + * @param params + * @param user + * @return + */ + public Map getDailyFlowLeaveBackData(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and b.resourceid in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + + sql = " select resourceid, newleavetype, durationrule, sum(duration) as val,belongdate from hrmresource a, "+KqSplitFlowTypeEnum.LEAVEBACK.getTablename()+" b "+ + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere + + " group by resourceid, newleavetype, durationrule,belongdate "; + rs.execute(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + String belongdate = rs.getString("belongdate"); + String newleavetype = rs.getString("newleavetype"); + String durationrule = rs.getString("durationrule"); + double value = rs.getDouble("val")<0?0:rs.getDouble("val"); + + double proportion = Util.getDoubleValue(kqLeaveRulesComInfo.getProportion(newleavetype)); + if(KQUnitBiz.isLeaveHour(newleavetype,kqLeaveRulesComInfo)){//按小时 + if(!KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value*proportion; + } + }else{//按天 + if(KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value/proportion; + } + } + + String key = resourceid+"|"+belongdate+"|leavebackType_"+newleavetype; + if(datas.containsKey(key)){ + value += Util.getDoubleValue(Util.null2String(datas.get(key))); + } + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + datas.put(key,format(value)); + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + /** + * 获取实际加班数据,包括流程,打卡生成的 + * @return + */ + public Map getFlowOverTimeDataNew(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and a.id in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + + int uintType = kqOvertimeRulesBiz.getMinimumUnit();//当前加班单位 + double hoursToDay = kqOvertimeRulesBiz.getHoursToDay();//当前天跟小时计算关系 + + String valueField = ""; + + sql = " select resourceid,changeType, sum(cast(duration_min as decimal(18,4))) as val,paidLeaveEnable "+ + " from hrmresource a, kq_flow_overtime b "+ + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere+ + " group by resourceid,changeType,paidLeaveEnable "; + rs.execute(sql); + kqLog.info("getFlowOverTimeDataNew:sql:"+sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + String paidLeaveEnable = rs.getString("paidLeaveEnable"); + int changeType =rs.getInt("changeType");//1-节假日、2-工作日、3-休息日 + double value = rs.getDouble("val")<0?0:rs.getDouble("val"); + if(uintType==3 || uintType== 5 || uintType== 6){//按小时计算 + value = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(value/(60.0)+"")); + }else{//按天计算 + value = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(value/(60.0*hoursToDay)+"")); + } + String flowType = ""; + if(changeType==1){ + flowType = "holidayOvertime"; + }else if(changeType==2){ + flowType = "workingDayOvertime"; + }else if(changeType==3){ + flowType = "restDayOvertime"; + } + if("1".equalsIgnoreCase(paidLeaveEnable)){ + //1表示关联调休 + flowType += "_4leave"; + }else{ + //0表示不关联调休 + flowType += "_nonleave"; + } + String key = resourceid+"|"+flowType; + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + if(datas.containsKey(key)){ + double tmpVal = Util.getDoubleValue(Util.null2String(datas.get(key)),0.0); + tmpVal += value; + datas.put(key,format(tmpVal)); + }else{ + datas.put(key,format(value)); + } + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + + /** + * 获取加班数据 + * @return + */ + public Map getFlowOverTimeData(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(subCompanyId.length()>0){ + sqlWhere +=" and b.subcompanyid in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and b.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and b.resourceid in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + + int uintType = kqOvertimeRulesBiz.getMinimumUnit();//当前加班单位 + double hoursToDay = kqOvertimeRulesBiz.getHoursToDay();//当前天跟小时计算关系 + + String valueField = ""; + if(uintType==3 || uintType== 5 || uintType== 6){//按小时计算 + valueField = "sum( case when durationrule='3' then duration else duration*"+hoursToDay+" end) as val"; + }else{//按天计算 + valueField = "sum( case when durationrule='3' then duration/"+hoursToDay+" else duration end) as val"; + } + + sql = " select resourceid,changeType, " +valueField+ + " from hrmresource a, "+KqSplitFlowTypeEnum.OVERTIME.getTablename()+" b "+ + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere+ + " group by resourceid,changeType,durationrule "; + rs.execute(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + int changeType =rs.getInt("changeType");//1-节假日、2-工作日、3-休息日 + double value = rs.getDouble("val")<0?0:rs.getDouble("val"); + String flowType = ""; + if(changeType==1){ + flowType = "holidayOvertime"; + }else if(changeType==2){ + flowType = "workingDayOvertime"; + }else if(changeType==3){ + flowType = "restDayOvertime"; + } + String key = resourceid+"|"+flowType; + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + if(datas.containsKey(key)){ + double tmpVal = Util.getDoubleValue(Util.null2String(datas.get(key)),0.0); + tmpVal += value; + datas.put(key,format(tmpVal)); + }else{ + datas.put(key,format(value)); + } + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + /** + * 获取每日加班数据 + * @return + */ + public Map getDailyFlowOverTimeData(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and a.id in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + + int uintType = kqOvertimeRulesBiz.getMinimumUnit();//当前加班单位 + double hoursToDay = kqOvertimeRulesBiz.getHoursToDay();//当前天跟小时计算关系 + + String valueField = ""; + if(uintType==3 || uintType== 5 || uintType== 6){//按小时计算 + valueField = "sum( case when durationrule='3' then duration else duration*"+hoursToDay+" end) as val"; + }else{//按天计算 + valueField = "sum( case when durationrule='3' then duration/"+hoursToDay+" else duration end) as val"; + } + + sql = " select resourceid,changeType,belongdate,paidLeaveEnable, sum(cast(duration_min as decimal(18,4))) as val "+ + " from hrmresource a, kq_flow_overtime b "+ + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere+ + " group by resourceid,changeType,paidLeaveEnable,belongdate "; + rs.execute(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + String belongdate = rs.getString("belongdate"); + String paidLeaveEnable = rs.getString("paidLeaveEnable"); + int changeType =rs.getInt("changeType");//1-节假日、2-工作日、3-休息日 + double value = rs.getDouble("val")<0?0:rs.getDouble("val"); + if(uintType==3 || uintType== 5 || uintType== 6){//按小时计算 + value = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(value/(60.0)+"")); + }else{//按天计算 + value = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(value/(60.0*hoursToDay)+"")); + } + String flowType = ""; + if(changeType==1){ + flowType = "holidayOvertime"; + }else if(changeType==2){ + flowType = "workingDayOvertime"; + }else if(changeType==3){ + flowType = "restDayOvertime"; + } + if("1".equalsIgnoreCase(paidLeaveEnable)){ + //1表示关联调休 + flowType += "_4leave"; + }else{ + //0表示不关联调休 + flowType += "_nonleave"; + } + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + datas.put(resourceid+"|"+belongdate+"|"+flowType,format(value)); + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + /** + * 异常冲抵 + * @return + */ + public Map getFlowOtherData(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + String minimumUnit = "";//单位类型 + double proportion = 0.00;//换算关系 + + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and b.resourceid in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + + sql = " select resourceid, durationrule, sum(duration) as val from hrmresource a, "+KqSplitFlowTypeEnum.OTHER.getTablename()+" b "+ + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' "+sqlWhere+ + " group by resourceid, durationrule "; + rs.execute(sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + double value = rs.getDouble("val")<0?0:rs.getDouble("val"); + String durationrule = rs.getString("durationrule"); + + if(KQUnitBiz.isLeaveHour(minimumUnit)){//按小时 + if(!KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value*proportion; + } + }else{//按天 + if(KQUnitBiz.isLeaveHour(durationrule)){ + if(proportion>0) value = value/proportion; + } + } + + String key = resourceid+"|leaveDeduction"; + if(datas.containsKey(key)){ + value += Util.getDoubleValue(Util.null2String(datas.get(key))); + } + //df.format 默认是不四舍五入的 0.125这样的就会直接变成0.12了 + df.setMaximumFractionDigits(5); + datas.put(key, format(value)); + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } + + /** + *日报表数据 + * @param resourceId + * @param fromDate + * @param toDate + * @return + */ + public Map getDetialDatas(String resourceId,String fromDate, String toDate, User user){ + return getDetialDatas(resourceId,fromDate,toDate,user,new HashMap(),false,0,"0"); + } + public Map getDetialDatas(String resourceId,String fromDate, String toDate, User user, + Map flowData,boolean isWrap,int uintType,String show_card_source){ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + Map datas = new HashMap<>(); + Map data = null; + Map tmpdatas = new HashMap<>(); + Map tmpdatass = new HashMap<>(); + Map tmpdata = null; + Map tmpmap = null; + + Map tmpstatusdata = new HashMap<>(); + Map tmpstatus = null; + RecordSet rs = new RecordSet(); + String sql = ""; + + //add + String unit = "小时"; + if(uintType==1 || uintType== 2 || uintType== 4){//按天计算 + unit = "天"; + } + //kqLog.info("detail.flowdata="+JSONObject.toJSONString(flowData)); + + try { + sql = " select resourceid, kqdate, workMins,attendanceMins,signindate,signintime,signoutdate,signouttime,signinid,signoutid, belatemins, graveBeLateMins, leaveearlymins, graveLeaveEarlyMins, absenteeismmins, forgotcheckMins, forgotBeginWorkCheckMins, "+ + " leaveMins,leaveInfo,evectionMins,outMins " + + " from kq_format_detail " + + " where resourceid = ? and kqdate>=? and kqdate<=? "+ + " order by resourceid, kqdate, serialnumber "; + rs.executeQuery(sql,resourceId, fromDate,toDate); + while (rs.next()) { + String key = rs.getString("resourceid") + "|" + rs.getString("kqdate"); + int workMins = rs.getInt("workMins"); + + String attendanceMins = rs.getString("attendanceMins"); +// String chuqin = "出勤:"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(attendanceMins) / 60.0)))+"小时"; + String overtimekey = key+"|overtime"; + String overtime = Util.null2String(flowData.get(overtimekey)); + boolean hasovertime = Util.getDoubleValue(overtime)>0; + overtime = hasovertime?(SystemEnv.getHtmlLabelName(6151, user.getLanguage())+":"+overtime+unit):"";//显示加班 + + String signinid = ""; + String signoutid = ""; + String signintime = ""; + String signouttime = ""; + if("1".equals(show_card_source)){ + String nosign = SystemEnv.getHtmlLabelName(25994, user.getLanguage());//未打卡 + signinid = Util.null2String(rs.getString("signinid")).trim(); + signintime = Util.null2String(rs.getString("signintime")).trim(); + String tmpin = SystemEnv.getHtmlLabelName(21974, user.getLanguage())+":"; + if(signinid.length()>0){ + String signinfrom = Util.null2String(flowData.get(signinid)); + signintime = tmpin+signintime+" "+signinfrom; + }else{ + signintime = tmpin+nosign; + } +// signintime = isWrap?"\r\n"+signintime:"
"+signintime; + + signoutid = Util.null2String(rs.getString("signoutid")).trim(); + signouttime = Util.null2String(rs.getString("signouttime")).trim(); + String tmpout = SystemEnv.getHtmlLabelName(21975, user.getLanguage())+":"; + if(signoutid.length()>0){ + String signoutfrom = Util.null2String(flowData.get(signoutid)); + signouttime = tmpout+signouttime+" "+signoutfrom; + }else{ + signouttime = tmpout+nosign; + } + signouttime = isWrap?"\r\n"+signouttime:"
"+signouttime; + } + + int beLateMins = rs.getInt("beLateMins"); + int leaveEarlyMins = rs.getInt("leaveEarlyMins"); + int graveBeLateMins = rs.getInt("graveBeLateMins"); + int absenteeismMins = rs.getInt("absenteeismMins"); + int graveLeaveEarlyMins = rs.getInt("graveLeaveEarlyMins"); + int forgotCheckMins = rs.getInt("forgotCheckMins"); + int forgotBeginWorkCheckMins = rs.getInt("forgotBeginWorkCheckMins"); + int leaveMins = rs.getInt("leaveMins"); + String leaveInfo = rs.getString("leaveInfo"); + int evectionMins = rs.getInt("evectionMins"); + int outMins = rs.getInt("outMins"); + String text = ""; + String tmptext =""; + String flag ="true"; + if(datas.get(key)==null){ + data = new HashMap<>(); + }else{ + data = (Map)datas.get(key); + tmptext = Util.null2String(data.get("text")); + } + tmpdata = new HashMap<>(); + if(tmpdatas.get(key)!=null){ + tmpmap = (Map)tmpdatas.get(key); + flag = Util.null2String(tmpmap.get("text")); + } + + String yichang =""; + if(tmpstatusdata.get(key)!=null){ + yichang = Util.null2String(tmpstatusdata.get(key)); + } + String sign =""; + String signkey = key+"|text"; + if(tmpstatusdata.get(signkey)!=null){ + sign = Util.null2String(tmpstatusdata.get(signkey)); + } + + if (workMins<=0) { + if(text.length()>0) text +=" "; + text += SystemEnv.getHtmlLabelName(26593, user.getLanguage()); + //休息日处理 + if(signinid.length()>0){ + text += (isWrap?"\r\n":"
")+signintime; + } + if(signoutid.length()>0){ + text += signouttime; + } + if(sign.length()>0) sign += isWrap?"\r\n":"
"; + sign += text; + } else { + //处理打卡数据================== + if(text.length()>0) text+= isWrap?"\r\n":"
"; + text += signintime; + text += signouttime; + if(sign.length()>0) sign+= isWrap?"\r\n":"
"; + sign += text; + //处理打卡数据================== + + if (absenteeismMins > 0) {//旷工 + if(text.length()>0) text+=" "; + text += SystemEnv.getHtmlLabelName(20085, user.getLanguage()); +// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+absenteeismMins) / 60.0)))+"小时"; + if(yichang.indexOf(SystemEnv.getHtmlLabelName(20085, user.getLanguage()))==-1){ + if(yichang.length()>0) yichang+= isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(20085, user.getLanguage()); + } + }else { + if (beLateMins > 0) {//迟到 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20081, user.getLanguage()); +// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+beLateMins) / 60.0)))+"小时"; + if(yichang.indexOf(SystemEnv.getHtmlLabelName(20081, user.getLanguage()))==-1) { + if (yichang.length() > 0) yichang += isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(20081, user.getLanguage()); + } + } + if (graveBeLateMins > 0) {//严重迟到 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(500546, user.getLanguage()); +// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+graveBeLateMins) / 60.0)))+"小时"; + if(yichang.indexOf(SystemEnv.getHtmlLabelName(500546, user.getLanguage()))==-1) { + if (yichang.length() > 0) yichang += isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(500546, user.getLanguage()); + } + } + if (leaveEarlyMins > 0) {//早退 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20082, user.getLanguage()); +// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+leaveEarlyMins) / 60.0)))+"小时"; + if(yichang.indexOf(SystemEnv.getHtmlLabelName(20082, user.getLanguage()))==-1) { + if (yichang.length() > 0) yichang += isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(20082, user.getLanguage()); + } + } + if (graveLeaveEarlyMins > 0) {//严重早退 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(500547, user.getLanguage()); +// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+graveLeaveEarlyMins) / 60.0)))+"小时"; + if(yichang.indexOf(SystemEnv.getHtmlLabelName(500547, user.getLanguage()))==-1) { + if (yichang.length() > 0) yichang += isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(500547, user.getLanguage()); + } + } + if (forgotCheckMins > 0) {//漏签 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + if(yichang.indexOf(SystemEnv.getHtmlLabelName(20086, user.getLanguage()))==-1) { + if (yichang.length() > 0) yichang += isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + } + } + if (forgotBeginWorkCheckMins > 0) {//漏签 + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + if(yichang.indexOf(SystemEnv.getHtmlLabelName(20086, user.getLanguage()))==-1) { + if (yichang.length() > 0) yichang += isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + } + } + } + } + if (leaveMins > 0) {//请假 + Map jsonObject = null; + if(leaveInfo.length()>0){ + jsonObject = JSON.parseObject(leaveInfo); + for (Entry entry : jsonObject.entrySet()) { + String newLeaveType = entry.getKey(); + String tmpLeaveMins = Util.null2String(entry.getValue()); + if(text.indexOf(kqLeaveRulesComInfo.getLeaveName(newLeaveType))==-1){ + if (text.length() > 0) text += " "; + //text += kqLeaveRulesComInfo.getLeaveName(newLeaveType)+tmpLeaveMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); + text += Util.formatMultiLang( kqLeaveRulesComInfo.getLeaveName(newLeaveType),""+user.getLanguage()); +// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+leaveMins) / 60.0)))+"小时"; + if(yichang.length()>0) yichang+= isWrap?"\r\n":"
"; + yichang += Util.formatMultiLang( kqLeaveRulesComInfo.getLeaveName(newLeaveType),""+user.getLanguage()); + } + } + }else{ + if(text.indexOf(SystemEnv.getHtmlLabelName(670, user.getLanguage()))==-1) { + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(670, user.getLanguage()); + } + } + } + if (evectionMins > 0) {//出差 + if(text.indexOf(SystemEnv.getHtmlLabelName(20084, user.getLanguage()))==-1) { + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20084, user.getLanguage()); +// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+evectionMins) / 60.0)))+"小时"; + if(yichang.length()>0) yichang+= isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(20084, user.getLanguage()); + } + } + if (outMins > 0) {//公出 + if(text.indexOf(SystemEnv.getHtmlLabelName(24058, user.getLanguage()))==-1) { + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(24058, user.getLanguage()); +// text += ":"+KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(""+outMins) / 60.0)))+"小时"; + if(yichang.length()>0) yichang+= isWrap?"\r\n":"
"; + yichang += SystemEnv.getHtmlLabelName(24058, user.getLanguage()); + } + } + + if(text.length()==0) { + text = "√"; + }else{ + flag = "false";//有其他的异常状态,则表示为false,不需要处理直接全部显示即可 + } + text += overtime; + + + //需要处理下打卡时间和异常状态显示的顺序--start + tmpstatusdata.put(key, yichang); + tmpstatusdata.put(signkey, sign); + boolean hasyichang = tmpstatusdata.get(key).length()>0; + if(tmptext.length()>0){ +// text = tmpstatusdata.get(signkey)+(isWrap?"\r\n":"
")+tmpstatusdata.get(key)+(isWrap?"\r\n":"
"+overtime); + text = tmpstatusdata.get(signkey); + if(hasyichang){ + if(text.length()>0){ + text += (isWrap?"\r\n":"
")+tmpstatusdata.get(key); + }else{ + text += tmpstatusdata.get(key); + } + } + if(hasovertime){ + text += (isWrap?"\r\n":"
")+overtime; + } + }else{ + text = tmpstatusdata.get(signkey); + if(hasyichang){ + if(text.length()>0){ + text += (isWrap?"\r\n":"
")+tmpstatusdata.get(key); + }else{ + text += tmpstatusdata.get(key); + } + } + if(hasovertime){ + text += (isWrap?"\r\n":"
")+overtime; + } + } + //需要处理下打卡时间和异常状态显示的顺序--end + tmpdatass.put(key, (isWrap?"\r\n":"
")+overtime); +// text = tmptext.length()>0?tmptext+" "+text:text;//显示所有的状态 + data.put("text", text); + datas.put(key, data); + + //add + tmpdata.put("text", flag); + tmpdatas.put(key, tmpdata); + //end + } + //全部搞一遍 + if(tmpdatas != null){ +// writeLog(n+">>>tmpdatas="+JSONObject.toJSONString(tmpdatas)); + Map data1 = null; + for(Entry entry : tmpdatas.entrySet()){ + String mapKey = Util.null2String(entry.getKey()); + Map mapValue = (Map)entry.getValue(); + String flag = Util.null2String(mapValue.get("text")); + if("true".equals(flag)){//需要加工的数据 + String overtime = String.valueOf(tmpdatass.get(mapKey)); + data1 = new HashMap<>(); + data1.put("text", "√"+overtime); + datas.put(mapKey, data1); + } + } +// writeLog("datas="+JSONObject.toJSONString(datas)); + } + }catch (Exception e){ + writeLog(e); + } + // 最后针对数据再处理一遍,不然出现2023-01-02: "休息" 形式的错误,导致页面记载报错,应该是2023-01-01: {text: "休息"}格式 + boolean isEnd = false; + for(String currentDate = fromDate; !isEnd;) { + if (currentDate.equals(toDate)) isEnd = true; + String dailyValue = Util.null2String(datas.get(currentDate)); + if(!"".equals(dailyValue) && !dailyValue.contains("text")) { + Map innerMap2 = new HashMap<>(); + innerMap2.put("text", dailyValue); + datas.put(currentDate, innerMap2); + } + currentDate = DateUtil.addDate(currentDate, 1); + } + + return datas; + } + +// public String getSignStatus(Map data, User user){ +// String result = ""; +// String signtype = Util.null2String(data.get("signtype"));//上班 下班 +// String worktime = Util.null2String(data.get("worktime"));//工作时间 +// String signtime = Util.null2String(data.get("signtime"));//签到时间 +// String abnormalMins = Util.null2String(data.get("abnormalMins"));//异常分钟数 +// String forgotCheck = Util.null2String(data.get("forgotCheck"));//漏签 +// if(worktime.length()>0){ +// if(signtime.length()>0){ +// if(Util.getDoubleValue(abnormalMins)>0){ +// result =SystemEnv.getHtmlLabelName(signtype.equals("1")?20081:20082, user.getLanguage())+abnormalMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage());//迟到 早退 +// }else{ +// result =SystemEnv.getHtmlLabelName(225, user.getLanguage());//正常 +// } +// }else if(forgotCheck.equals("1")){ +// result =SystemEnv.getHtmlLabelName(20086, user.getLanguage());//漏签 +// } +// }else{ +// result = ""; +// } +// +// return result; +// } + + public int getSerialCount(String resourceId, String fromDate, String toDate, String serialId){ + RecordSet rs = new RecordSet(); + String sql = ""; + int serialCount = 0; + try{ + sql = "select count(1) from hrmresource a, kq_format_total b where a.id= b.resourceid and b.resourceid = ? and b.kqdate >=? and b.kqdate <=? and b.serialId = ? "; + rs.executeQuery(sql,resourceId,fromDate,toDate, serialId); + if(rs.next()){ + serialCount = rs.getInt(1); + } + }catch (Exception e){ + writeLog(e); + } + return serialCount; + } + + public static String getSignStatus(Map signInfo, User user){ + return getSignStatus(signInfo,user,""); + } + + public static String getSignStatus(Map signInfo, User user,String onOrOff){ + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + String text = ""; + String isneedcal = Util.null2String(signInfo.get("isneedcal")); + String workdate = Util.null2String(signInfo.get("workdate")); + String worktime = Util.null2String(signInfo.get("worktime")); + if(!new KQFormatBiz().needCal(workdate,worktime,isneedcal)) {//还未到时间无需计算 + return text; + } + int absenteeismMins = Util.getIntValue(Util.null2String(signInfo.get("absenteeismMins"))); + int beLateMins = Util.getIntValue(Util.null2String(signInfo.get("beLateMins"))); + int graveBeLateMins = Util.getIntValue(Util.null2String(signInfo.get("graveBeLateMins"))); + int leaveEarlyMins = Util.getIntValue(Util.null2String(signInfo.get("leaveEarlyMins"))); + int graveLeaveEarlyMins = Util.getIntValue(Util.null2String(signInfo.get("graveLeaveEarlyMins"))); + int forgotCheckMins = Util.getIntValue(Util.null2String(signInfo.get("forgotCheckMins"))); + int forgotBeginWorkCheckMins = Util.getIntValue(Util.null2String(signInfo.get("forgotBeginWorkCheckMins"))); + int leaveMins = Util.getIntValue(Util.null2String(signInfo.get("leaveMins"))); + String leaveInfo = Util.null2String(signInfo.get("leaveInfo")); + int evectionMins = Util.getIntValue(Util.null2String(signInfo.get("evectionMins"))); + int outMins = Util.getIntValue(Util.null2String(signInfo.get("outMins"))); + + if(worktime.length()>0){ + if (absenteeismMins > 0) {//旷工 + text = SystemEnv.getHtmlLabelName(20085, user.getLanguage())+absenteeismMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); + }else { + if (beLateMins > 0) {//迟到 + text = SystemEnv.getHtmlLabelName(20081, user.getLanguage())+beLateMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); + } + if (graveBeLateMins > 0) {//严重迟到 + text = SystemEnv.getHtmlLabelName(500546, user.getLanguage())+graveBeLateMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); + } + if (leaveEarlyMins > 0) {//早退 + text = SystemEnv.getHtmlLabelName(20082, user.getLanguage())+leaveEarlyMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); + } + if (graveLeaveEarlyMins > 0) {//严重早退 + text = SystemEnv.getHtmlLabelName(500547, user.getLanguage())+graveLeaveEarlyMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); + } + if (forgotCheckMins > 0) {//漏签 + text = SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + } + if(onOrOff.length() > 0 && "on".equalsIgnoreCase(onOrOff)){ + if (forgotBeginWorkCheckMins > 0) {//漏签 + text = SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + } + } + } + + if (leaveMins > 0) {//请假 + Map jsonObject = null; + if(leaveInfo.length()>0){ + jsonObject = JSON.parseObject(leaveInfo); + for (Entry entry : jsonObject.entrySet()) { + String newLeaveType = entry.getKey(); + String tmpLeaveMins = Util.null2String(entry.getValue()); + if(text.indexOf(kqLeaveRulesComInfo.getLeaveName(newLeaveType))==-1){ + if (text.length() > 0) text += " "; + //text += kqLeaveRulesComInfo.getLeaveName(newLeaveType)+tmpLeaveMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); + text += Util.formatMultiLang(kqLeaveRulesComInfo.getLeaveName(newLeaveType),""+user.getLanguage()); + } + } + }else{ + if(text.indexOf(SystemEnv.getHtmlLabelName(670, user.getLanguage()))==-1) { + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(670, user.getLanguage()); + } + } + } + if (evectionMins > 0) {//出差 + if(text.indexOf(SystemEnv.getHtmlLabelName(20084, user.getLanguage()))==-1) { + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20084, user.getLanguage()); + } + } + if (outMins > 0) {//公出 + if(text.indexOf(SystemEnv.getHtmlLabelName(24058, user.getLanguage()))==-1) { + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(24058, user.getLanguage()); + } + } + if(text.equals("")){ + boolean needCal = new KQFormatBiz().needCal(workdate,worktime); + text = needCal?SystemEnv.getHtmlLabelName(225, user.getLanguage()):""; + } + }else{ + if (leaveMins > 0) {//请假 + Map jsonObject = null; + if(leaveInfo.length()>0){ + jsonObject = JSON.parseObject(leaveInfo); + for (Entry entry : jsonObject.entrySet()) { + String newLeaveType = entry.getKey(); + String tmpLeaveMins = Util.null2String(entry.getValue()); + if(text.indexOf(kqLeaveRulesComInfo.getLeaveName(newLeaveType))==-1){ + if (text.length() > 0) text += " "; + //text += kqLeaveRulesComInfo.getLeaveName(newLeaveType)+tmpLeaveMins+SystemEnv.getHtmlLabelName(15049, user.getLanguage()); + text += Util.formatMultiLang(kqLeaveRulesComInfo.getLeaveName(newLeaveType)); + } + } + }else{ + if(text.indexOf(SystemEnv.getHtmlLabelName(670, user.getLanguage()))==-1) { + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(670, user.getLanguage()); + } + } + } + if (evectionMins > 0) {//出差 + if(text.indexOf(SystemEnv.getHtmlLabelName(20084, user.getLanguage()))==-1) { + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(20084, user.getLanguage()); + } + } + if (outMins > 0) {//公出 + if(text.indexOf(SystemEnv.getHtmlLabelName(24058, user.getLanguage()))==-1) { + if (text.length() > 0) text += " "; + text += SystemEnv.getHtmlLabelName(24058, user.getLanguage()); + } + } + } + return text; + } + + /** + * 获取打卡状态(不包含具体分钟数) + * @param signInfo + * @param user + * @param onOrOff + * @return + */ + public static String getSignStatus2(Map signInfo, User user, String onOrOff) { + KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo(); + String text = ""; + String worktime = Util.null2String(signInfo.get("worktime")); + int absenteeismMins = Util.getIntValue(Util.null2String(signInfo.get("absenteeismMins"))); + int beLateMins = Util.getIntValue(Util.null2String(signInfo.get("beLateMins"))); + int graveBeLateMins = Util.getIntValue(Util.null2String(signInfo.get("graveBeLateMins"))); + int leaveEarlyMins = Util.getIntValue(Util.null2String(signInfo.get("leaveEarlyMins"))); + int graveLeaveEarlyMins = Util.getIntValue(Util.null2String(signInfo.get("graveLeaveEarlyMins"))); + int forgotCheckMins = Util.getIntValue(Util.null2String(signInfo.get("forgotCheckMins"))); + int forgotBeginWorkCheckMins = Util.getIntValue(Util.null2String(signInfo.get("forgotBeginWorkCheckMins"))); + int leaveMins = Util.getIntValue(Util.null2String(signInfo.get("leaveMins"))); + String leaveInfo = Util.null2String(signInfo.get("leaveInfo")); + int evectionMins = Util.getIntValue(Util.null2String(signInfo.get("evectionMins"))); + int outMins = Util.getIntValue(Util.null2String(signInfo.get("outMins"))); + + if (worktime.length() > 0) { + if (absenteeismMins > 0) {//旷工 + text = SystemEnv.getHtmlLabelName(20085, user.getLanguage()); + } else { + if (beLateMins > 0) {//迟到 + text = SystemEnv.getHtmlLabelName(20081, user.getLanguage()); + } + if (graveBeLateMins > 0) {//严重迟到 + text = SystemEnv.getHtmlLabelName(500546, user.getLanguage()); + } + if (leaveEarlyMins > 0) {//早退 + text = SystemEnv.getHtmlLabelName(20082, user.getLanguage()); + } + if (graveLeaveEarlyMins > 0) {//严重早退 + text = SystemEnv.getHtmlLabelName(500547, user.getLanguage()); + } + if (forgotCheckMins > 0) {//漏签 + text = SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + } + if (onOrOff.length() > 0 && "on".equalsIgnoreCase(onOrOff)) { + if (forgotBeginWorkCheckMins > 0) {//漏签 + text = SystemEnv.getHtmlLabelName(20086, user.getLanguage()); + } + } + } + if (text.equals("") && leaveMins <= 0 && evectionMins <= 0 && outMins <= 0) { + text = SystemEnv.getHtmlLabelName(225, user.getLanguage()); + } + } + return text; + } + + public static boolean getShowFlowText(String leaveInfo,String onOrOff){ + Map jsonObject = null; + jsonObject = JSON.parseObject(leaveInfo); + String flow_signtype = ""; + for (Entry entry : jsonObject.entrySet()) { + String tmpSignType = Util.null2String(entry.getValue()); + flow_signtype += ","+tmpSignType; + } + if(flow_signtype.length() == 0){ + return true; + } + return isShowFlowText(flow_signtype,onOrOff); + } + + public static boolean isShowFlowText(String flow_signtype,String onOrOff){ + boolean showFlowText = true; + + if(flow_signtype.length() > 0){ + flow_signtype = flow_signtype.substring(1); + if("on".equalsIgnoreCase(onOrOff)){ + if((","+flow_signtype+",").indexOf(",1,") > -1){ + //抵扣了上班卡 + }else{ + //上班状态,但是没有上班抵扣流程 + showFlowText = false; + } + } + if("off".equalsIgnoreCase(onOrOff)){ + if((","+flow_signtype+",").indexOf(",2,") > -1){ + //抵扣了下班卡 + }else{ + //下班状态,但是没有下班抵扣流程 + showFlowText = false; + } + } + } + return showFlowText; + } + + public static int getPageSize(String pageSize, String pageUid, int userid){ + String sql = ""; + RecordSet rs = new RecordSet(); + int iPageSize= Util.getIntValue(pageSize,10); + if(iPageSize<10)iPageSize=10; + try{ + if(pageSize.length()>0){ + boolean flag = false; + sql = "select count(1) from ecology_pagesize where pageid = '"+pageUid+"' and userid ="+userid; + rs.executeQuery(sql); + if(rs.next()){ + if(rs.getInt(1)>0){ + flag = true; + } + } + if(flag){ + sql = "update ecology_pagesize set pagesize ="+pageSize+" where pageid = '"+pageUid+"' and userid ="+userid; + rs.executeUpdate(sql); + }else{ + sql = "insert into ecology_pagesize (pageid,pagesize,userid) values ('"+pageUid+"',"+pageSize+","+userid+")"; + rs.executeUpdate(sql); + } + }else{ + sql = "select pageSize from ecology_pagesize where pageid = '"+pageUid+"' and userid ="+userid; + rs.executeQuery(sql); + if(rs.next()){ + iPageSize = rs.getInt("pageSize"); + } + } + }catch (Exception e){ + new BaseBean().writeLog("KQReportBiz.getPageSize"+e); + } + + return iPageSize; + } + + //经常遇到申请变更流程或销假流程提示未归档,不胜其烦,所以搞一下 + public void reflow(String requestid){ + try { + requestid = Util.null2String(requestid); + String workflowid = ""; + String currentnodetype = ""; + if(requestid.length() == 0){ + return; + } + RecordSet rs2 = new RecordSet(); + String sql = "select requestid,workflowid,currentnodetype from workflow_requestbase where requestid = '"+requestid+"'"; + rs2.executeQuery(sql); + if(rs2.next()){ + workflowid = Util.null2String(rs2.getString("workflowid")); + currentnodetype = Util.null2String(rs2.getString("currentnodetype")); + } + + boolean isForce1 = false; + boolean isUpgrade1 = false; + if(requestid.length() == 0){ + return ; + } + if(workflowid.length() == 0){ + return ; + } + if(!"3".equals(currentnodetype)){ + return ; + } + long start = System.currentTimeMillis(); + + KQFlowActiontBiz kqFlowActiontBiz = new KQFlowActiontBiz(); + RecordSet rs = new RecordSet(); + RecordSet rs1 = new RecordSet(); + String proc_set_sql = "select * from kq_att_proc_set where field001 = ? "; + rs.executeQuery(proc_set_sql, workflowid); + if(rs.next()){ + String proc_set_id = rs.getString("id"); + //得到这个考勤流程设置是否使用明细 + String usedetails = rs.getString("usedetail"); + + int kqtype = Util.getIntValue(rs.getString("field006")); + + Map map = new HashMap(); + if(Util.getIntValue(requestid) > 0){ + map.put("requestId", "and t.requestId = " + requestid); + } + String tablename = ""; + if(kqtype == KqSplitFlowTypeEnum.LEAVE.getFlowtype()){ + tablename = KqSplitFlowTypeEnum.LEAVE.getTablename(); + }else if(kqtype == KqSplitFlowTypeEnum.EVECTION.getFlowtype()){ + tablename = KqSplitFlowTypeEnum.EVECTION.getTablename(); + }else if(kqtype == KqSplitFlowTypeEnum.OUT.getFlowtype()){ + tablename = KqSplitFlowTypeEnum.OUT.getTablename();; + }else if(kqtype == KqSplitFlowTypeEnum.OVERTIME.getFlowtype()){ + tablename = KqSplitFlowTypeEnum.OVERTIME.getTablename();; + }else if(kqtype == KqSplitFlowTypeEnum.SHIFT.getFlowtype()){ + tablename = KqSplitFlowTypeEnum.SHIFT.getTablename();; + }else if(kqtype == KqSplitFlowTypeEnum.OTHER.getFlowtype()){ + tablename = KqSplitFlowTypeEnum.OTHER.getTablename();; + }else if(kqtype == KqSplitFlowTypeEnum.CARD.getFlowtype()){ + tablename = KqSplitFlowTypeEnum.CARD.getTablename();; + return; + }else if(kqtype == KqSplitFlowTypeEnum.LEAVEBACK.getFlowtype()){ + tablename = KqSplitFlowTypeEnum.LEAVEBACK.getTablename();; + }else{ + return; + } + if(null != tablename && tablename.length() > 0){ + String tmpsql = "select * from "+tablename+" where requestId="+requestid; + rs1.executeQuery(tmpsql); + if(rs1.next()){ + return;//表示已经产生了拆分数据 + } + } + + //先根据requestid删除中间表里的数据,再做啥插入操作 + String delSql = "delete from "+tablename+" where requestid = "+requestid; + rs1.executeUpdate(delSql); + if(kqtype == KqSplitFlowTypeEnum.OVERTIME.getFlowtype()) { + delSql = "delete from kq_flow_overtime where requestid = "+requestid; + rs1.executeUpdate(delSql); + } + + Map result = kqFlowActiontBiz.handleKQFlowAction(proc_set_id, usedetails, Util.getIntValue(requestid), kqtype, Util.getIntValue(workflowid), isForce1,isUpgrade1,map); + + if(!result.isEmpty()){ + + } + } + long end = System.currentTimeMillis(); + }catch (Exception e){ + e.printStackTrace();; + } + } + + + //add + public Map getOverTime(Map params, User user){ + Map datas = new HashMap<>();; + RecordSet rs = new RecordSet(); + String sql = ""; + String sqlWhere = " "; + try{ + KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and a.id in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + + int uintType = Util.getIntValue(Util.null2String(params.get("uintType")));//当前加班单位 + double hoursToDay = Util.getDoubleValue(Util.null2String(params.get("hoursToDay")));//当前天跟小时计算关系 + + String valueField = ""; + + sql = " select resourceid,belongdate,paidLeaveEnable,duration_min "+ + " from hrmresource a, kq_flow_overtime b "+ + " where a.id = b.resourceid and belongdate >='"+fromDate+"' and belongdate <='"+toDate+"' " +sqlWhere+ + " order by resourceid,belongdate "; + rs.execute(sql); +// kqLog.info("getOverTime:sql:"+sql); + while (rs.next()) { + String resourceid = rs.getString("resourceid"); + String belongdate = rs.getString("belongdate"); + String paidLeaveEnable = rs.getString("paidLeaveEnable"); +// int changeType =rs.getInt("changeType");//1-节假日、2-工作日、3-休息日 + double value = rs.getDouble("duration_min")<0?0:rs.getDouble("duration_min"); + if(uintType==3 || uintType== 5 || uintType== 6){//按小时计算 + value = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(value/(60.0)+"")); + }else{//按天计算 + value = Util.getDoubleValue(KQDurationCalculatorUtil.getDurationRound(value/(60.0*hoursToDay)+"")); + } + String key = resourceid+"|"+belongdate+"|overtime"; + if(value>0){ + df.setMaximumFractionDigits(5); + if(datas.containsKey(key)){ + double tmpVal = Util.getDoubleValue(Util.null2String(datas.get(key)),0.0); + tmpVal += value; + datas.put(key,format(tmpVal)); + }else{ + datas.put(key,format(value)); + } + +// if(datas.containsKey(key)){ +// datas.put(key,"加班"); +//// datas.put(key,SystemEnv.getHtmlLabelName(6151, user.getLanguage())); +// }else{ +// datas.put(key,"加班"); +// } + } + } + }catch (Exception e){ + writeLog(e); + } + return datas; + } +} diff --git a/src/com/engine/kq/cmd/attendanceEvent/GetAttendanceCardCmd.java b/src/com/engine/kq/cmd/attendanceEvent/GetAttendanceCardCmd.java new file mode 100644 index 0000000..93c1ade --- /dev/null +++ b/src/com/engine/kq/cmd/attendanceEvent/GetAttendanceCardCmd.java @@ -0,0 +1,192 @@ +package com.engine.kq.cmd.attendanceEvent; + +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.KQReportBiz; +import com.engine.kq.biz.KQTimesArrayComInfo; +import com.engine.kq.cmd.attendanceButton.ButtonStatusEnum; +import weaver.conn.RecordSet; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 获取补卡信息 + */ +public class GetAttendanceCardCmd extends AbstractCommonCommand> { + + public GetAttendanceCardCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + try{ + String resourceId = Util.null2String(params.get("resourceId")); + String fromDate = Util.null2String(params.get("fromDate")); + String toDate = Util.null2String(params.get("toDate")); + + DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + LocalDate fromLocalDate = LocalDate.parse(fromDate); + LocalDate toLocalDate = LocalDate.parse(toDate); + + if(fromLocalDate.isAfter(toLocalDate)){ + retmap.put("status", "-1"); + return retmap; + } + + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + + List> cardList = new ArrayList<>(); + Map cardMap = new HashMap<>(); + + KQReportBiz kqReportBiz = new KQReportBiz(); + + List reporsts = kqReportBiz.getKqDateInfo(resourceId, fromDate, toDate, false); + for(int i = 0 ; i < reporsts.size() ; i++) { + Map kqdateMap = (Map) reporsts.get(i); + String kqdate = Util.null2String(kqdateMap.get("kqdate")); + List checkInfoList = (List) kqdateMap.get("checkInfo"); + //每一个工作时段里的考勤状态 + for (int j = 0; j < checkInfoList.size(); j++) { + Map data = (Map) checkInfoList.get(j); + String status = Util.null2String(data.get("status")); + String workbegindate = Util.null2String(data.get("workbegindate")); + String workenddate = Util.null2String(data.get("workenddate")); + String signintime = Util.null2String(data.get("signintime")); + String signouttime = Util.null2String(data.get("signouttime")); + String workbegintime = Util.null2String(data.get("workbegintime")); + String workendtime = Util.null2String(data.get("workendtime")); + String start = Util.null2String(data.get("start")); + String end = Util.null2String(data.get("end")); + + int workbegintime_index = kqTimesArrayComInfo.getArrayindexByTimes(workbegintime); + int workbegintime_index_n = workbegintime_index > KQTimesArrayComInfo.getOneDayArraySize() ? workbegintime_index-KQTimesArrayComInfo.getOneDayArraySize() : workbegintime_index; + workbegintime = kqTimesArrayComInfo.getTimesByArrayindex(workbegintime_index_n); + + int workendtime_index = kqTimesArrayComInfo.getArrayindexByTimes(workendtime); + int workendtime_index_n = workendtime_index > KQTimesArrayComInfo.getOneDayArraySize() ? workendtime_index-KQTimesArrayComInfo.getOneDayArraySize() : workendtime_index; + workendtime = kqTimesArrayComInfo.getTimesByArrayindex(workendtime_index_n); + String scheduletime = workbegintime + "-" + workendtime; + + String[] status_s = status.split(","); + if(status_s != null && status.length() > 0){ + for(int s = 0 ; s < status_s.length ; s++){ + String tmp_status = status_s[s]; + cardMap = new HashMap<>(); + if (ButtonStatusEnum.BELATE.getStatusCode().equalsIgnoreCase(tmp_status)) { + //考勤二开--迟到早退不允许补卡start + continue; + //end +// //迟到 +// cardMap = new HashMap<>(); +// cardMap.put("signdate", workbegindate); +// cardMap.put("scheduletime", scheduletime); +// cardMap.put("atteStatus", SystemEnv.getHtmlLabelName(10000805, Util.getIntValue(user.getLanguage()))+signintime); +// //下拉框0是签到,1是签退 +// cardMap.put("signtype", "0"); +// cardMap.put("signtime", workbegintime); +// cardList.add(cardMap); + } + if (ButtonStatusEnum.LEAVEERALY.getStatusCode().equalsIgnoreCase(tmp_status)) { + //考勤二开--迟到早退不允许补卡start + continue; + //end +// //早退 +// cardMap = new HashMap<>(); +// cardMap.put("signdate", workenddate); +// cardMap.put("scheduletime", scheduletime); +// cardMap.put("atteStatus", SystemEnv.getHtmlLabelName(10000806, Util.getIntValue(user.getLanguage()))+signouttime); +// //下拉框0是签到,1是签退 +// cardMap.put("signtype", "1"); +// cardMap.put("signtime", workendtime); +// cardList.add(cardMap); + } + if (ButtonStatusEnum.ABSENT.getStatusCode().equalsIgnoreCase(tmp_status)) { + //旷工 + + if(!start.equals("1")) { + cardMap = new HashMap<>(); + cardMap.put("signdate", workbegindate); + cardMap.put("scheduletime", scheduletime); + String atteStatus0 = SystemEnv.getHtmlLabelName(20085, Util.getIntValue(user.getLanguage())); + if (signintime.length() > 0) { + atteStatus0 += SystemEnv.getHtmlLabelName(10000807, Util.getIntValue(user.getLanguage())) + signintime; + } + + cardMap.put("atteStatus", atteStatus0); + //下拉框0是上班,1是下班 + cardMap.put("signtype", "0"); + cardMap.put("signtime", workbegintime); + cardList.add(cardMap); + } + if(!end.equals("1")) { + cardMap = new HashMap<>(); + cardMap.put("signdate", workenddate); + cardMap.put("scheduletime", scheduletime); + String atteStatus1 = SystemEnv.getHtmlLabelName(20085, Util.getIntValue(user.getLanguage())); + if (signouttime.length() > 0) { + atteStatus1 += SystemEnv.getHtmlLabelName(10000808, Util.getIntValue(user.getLanguage())) + signouttime; + } + cardMap.put("atteStatus", atteStatus1); + //下拉框0是上班,1是下班 + cardMap.put("signtype", "1"); + cardMap.put("signtime", workendtime); + cardList.add(cardMap); + } + } + if (ButtonStatusEnum.NOSIGN.getStatusCode().equalsIgnoreCase(tmp_status)) { + //漏签 + cardMap = new HashMap<>(); + cardMap.put("signdate", workenddate); + cardMap.put("scheduletime", scheduletime); + cardMap.put("atteStatus", SystemEnv.getHtmlLabelName(20086, Util.getIntValue(user.getLanguage()))); + //下拉框0是上班,1是下班 + cardMap.put("signtype", "1"); + cardMap.put("signtime", workendtime); + cardList.add(cardMap); + } + if (ButtonStatusEnum.NOSIGN_ON.getStatusCode().equalsIgnoreCase(tmp_status)) { + //上班漏签 + cardMap = new HashMap<>(); + cardMap.put("signdate", workbegindate); + cardMap.put("scheduletime", scheduletime); + cardMap.put("atteStatus", SystemEnv.getHtmlLabelName(20086, Util.getIntValue(user.getLanguage()))); + //下拉框0是上班,1是下班 + cardMap.put("signtype", "0"); + cardMap.put("signtime", workbegintime); + cardList.add(cardMap); + } + } + } + } + } + + retmap.put("cardlist", cardList); + retmap.put("status", "1"); + + }catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage())); + writeLog(e); + } + return retmap; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/report/ExportDailyExcelCmd.java b/src/com/engine/kq/cmd/report/ExportDailyExcelCmd.java new file mode 100644 index 0000000..5b4f3c7 --- /dev/null +++ b/src/com/engine/kq/cmd/report/ExportDailyExcelCmd.java @@ -0,0 +1,659 @@ +package com.engine.kq.cmd.report; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.*; +import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit; +import com.engine.kq.util.ExcelUtil; +import com.engine.kq.util.KQDurationCalculatorUtil; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.job.JobTitlesComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.math.BigDecimal; +import java.util.*; + +public class ExportDailyExcelCmd extends AbstractCommonCommand> { + + private HttpServletRequest request; + private HttpServletResponse response; + private List lsFieldDataKey; + + public ExportDailyExcelCmd(Map params, HttpServletRequest request, HttpServletResponse response, User user) { + this.user = user; + this.params = params; + this.request = request; + this.response = response; + this.lsFieldDataKey = new ArrayList<>(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + String sql = ""; + try { + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + ResourceComInfo resourceComInfo = new ResourceComInfo(); + JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo(); + ShiftManagementToolKit shiftManagementToolKit = new ShiftManagementToolKit(); + KQWorkTime kqWorkTime = new KQWorkTime(); + KQReportBiz kqReportBiz = new KQReportBiz(); + KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz(); + + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String attendanceSerial = Util.null2String(jsonObj.get("attendanceSerial")); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + //人员状态 + String status = Util.null2String(jsonObj.get("status")); + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + List showColumns = Util.splitString2List(Util.null2String(jsonObj.get("showColumns")),","); + showColumns.add("lastname"); + showColumns.add("kqdate"); + showColumns.add("serialid"); + showColumns.removeIf(showColumn->showColumn.trim().equals("")); + + List tmpShowColumns = new ArrayList<>(); + for(String showColumn:showColumns){ + tmpShowColumns.add(showColumn); + String cascadekey = ""; + if(showColumn.equals("signin1")){ + cascadekey = "signout1"; + }else if(showColumn.equals("signin2")){ + cascadekey = "signout2"; + }else if(showColumn.equals("signin3")){ + cascadekey = "signout3"; + }else if(showColumn.equals("beLate")){ + cascadekey = "beLateMins"; + }else if(showColumn.equals("leaveEearly")){ + cascadekey = "leaveEarlyMins"; + }else if(showColumn.equals("graveBeLate")){ + cascadekey = "graveBeLateMins"; + }else if(showColumn.equals("graveLeaveEarly")){ + cascadekey = "graveLeaveEarlyMins"; + }else if(showColumn.equals("absenteeism")){ + cascadekey = "absenteeismMins"; + }else if(showColumn.equals("overtime")){ + tmpShowColumns.add("overtime_4leave"); + tmpShowColumns.add("overtime_nonleave"); + tmpShowColumns.add("workingDayOvertime_nonleave"); + tmpShowColumns.add("workingDayOvertime_4leave"); + tmpShowColumns.add("restDayOvertime_nonleave"); + tmpShowColumns.add("restDayOvertime_4leave"); + tmpShowColumns.add("holidayOvertime_4leave"); + tmpShowColumns.add("holidayOvertime_nonleave"); + } + if(cascadekey.length()>0){ + tmpShowColumns.add(cascadekey); + } + } + showColumns = tmpShowColumns; + + String today = DateUtil.getCurrentDate(); + if(DateUtil.compDate(today, toDate)>0){//结束如期不大于今天 + toDate = today; + } + + String rightSql = new KQReportBiz().getReportRight("2",""+user.getUID(),"a"); + + LinkedHashMap workbook = new LinkedHashMap<>(); + List lsSheet = new ArrayList<>(); + Map sheet = null; + List titleList = new ArrayList<>(); + Map title = null; + List> dataList = new ArrayList<>(); + List data = null; + List> constraintList = null; + Map constraint = null; + + sheet = new HashMap<>(); + sheet.put("sheetName", SystemEnv.getHtmlLabelName( 390352, user.getLanguage())); + sheet.put("sheetTitle", SystemEnv.getHtmlLabelName( 390352, user.getLanguage())); + + List> leaveRules = kqLeaveRulesBiz.getAllLeaveRules(); + Map mapChildColumnInfo = null; + List childColumns = null; + KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo(); + while (kqReportFieldComInfo.next()){ + if(Util.null2String(kqReportFieldComInfo.getParentid()).length()>0)continue; + if(!kqReportFieldComInfo.getReportType().equals("all") && !kqReportFieldComInfo.getReportType().equals("daily"))continue; + if (!showColumns.contains(kqReportFieldComInfo.getFieldname())&&!showColumns.contains(kqReportFieldComInfo.getParentid())) continue; + if("leave".equalsIgnoreCase(kqReportFieldComInfo.getFieldname())&&leaveRules.size()==0){ + continue; + } + title = new HashMap<>(); + String unitType = KQReportBiz.getUnitType(kqReportFieldComInfo, user); + if(unitType.length()>0){ + title.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage())+ "(" + unitType + ")"); + }else{ + title.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage())); + } + title.put("width",30*256); + this.lsFieldDataKey.add(kqReportFieldComInfo.getFieldname()); + mapChildColumnInfo = this.getChildColumnsInfo(kqReportFieldComInfo.getFieldname(),user); + childColumns = (List)mapChildColumnInfo.get("childColumns"); + if(childColumns.size()>0) {//跨列width取子列的width + title.put("children", childColumns); + title.put("colSpan",childColumns.size()); + }else{ + title.put("rowSpan", 3); + } + titleList.add(title); + } + sheet.put("titleList", titleList); + + String forgotBeginWorkCheck_field = " b.forgotbeginworkcheck "; + + if(rs.getDBType().equalsIgnoreCase("oracle")&&!Util.null2String(rs.getOrgindbtype()).equals("dm")&&!Util.null2String(rs.getOrgindbtype()).equals("st")) { + forgotBeginWorkCheck_field = " nvl(b.forgotBeginWorkCheck,0) "; + }else if((rs.getDBType()).equalsIgnoreCase("mysql")){ + forgotBeginWorkCheck_field = " ifnull(b.forgotBeginWorkCheck,0) "; + }else { + forgotBeginWorkCheck_field = " isnull(b.forgotBeginWorkCheck,0) "; + } + + String backFields = " a.id,a.lastname,a.subcompanyid1 as subcompanyid,a.departmentid, a.workcode,b.jobtitle,a.dsporder," + + " b.kqdate, b.workdays,b.workMins,b.serialid, b.attendancedays,b.attendanceMins,b.beLate," + + " b.beLateMins,b.graveBeLate,b.graveBeLateMins,b.leaveEearly,b.leaveEarlyMins,b.graveLeaveEarly," + + " b.graveLeaveEarlyMins,b.absenteeism,b.signdays,b.signmins, "+ + " b.absenteeismMins ,(b.forgotCheck+"+forgotBeginWorkCheck_field+") forgotCheck "; + String sqlFrom = " from hrmresource a, kq_format_total b where a.id= b.resourceid and b.kqdate >='"+fromDate+"' and b.kqdate <='"+toDate+"'"; + String sqlWhere = rightSql; + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and a.id in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + + if(status.length()>0){ + if (!status.equals("8") && !status.equals("9")) { + sqlWhere += " and a.status = "+status+ ""; + }else if (status.equals("8")) { + sqlWhere += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) "; + } + } + + String orderBy = " order by a.dsporder asc, a.lastname asc , b.kqDate asc "; + String descOrderBy = " order by a.dsporder desc, a.lastname desc "; + sql = "select "+backFields + sqlFrom + sqlWhere+orderBy; + + // #1475814-概述:满足考勤报分部部门显示及导出时显示全路径 + String fullPathMainKey = "show_full_path"; + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + String isShowFullPath = Util.null2String(kqSettingsComInfo.getMain_val(fullPathMainKey),"0"); + + Map serialdata = new HashMap<>(); + boolean isneedcal = KQSettingsBiz.getKqformatAccurate(); + params.put("isneedcal",isneedcal?"1":"0"); + Map flowData = kqReportBiz.getDailyFlowData(params,user); + rs.execute(sql); + while (rs.next()) { + data = new ArrayList<>(); + String id = rs.getString("id"); + String kqdate = rs.getString("kqdate"); + String tmpkey = id+"|"+kqdate+"|"; +// Map signDetailInfo = this.getSignDetailInfo(id,kqdate); + + for (int fieldDataKeyIdx =0;fieldDataKeyIdx0){ +// fieldValue = Util.formatMultiLang(shiftManagementToolKit.getShiftOnOffWorkSections(serialid, user.getLanguage())); + + if(null != serialdata && serialdata.containsKey(serialid)){ + fieldValue = serialdata.get(serialid); + }else{ + String tmpserialname = Util.formatMultiLang(shiftManagementToolKit.getShiftOnOffWorkSections(serialid, user.getLanguage())); + fieldValue = tmpserialname; + serialdata.put(serialid,tmpserialname); + } + } + } else if(fieldName.equals("signin1")){ + fieldValue = Util.null2String(flowData.get(tmpkey+"signintime1")); + data.add(fieldValue); + fieldValue = Util.null2String(flowData.get(tmpkey+"signinstatus1")); + data.add(fieldValue); + continue; + } else if(fieldName.equals("signin2")){ + fieldValue = Util.null2String(flowData.get(tmpkey+"signintime2")); + data.add(fieldValue); + fieldValue = Util.null2String(flowData.get(tmpkey+"signinstatus2")); + data.add(fieldValue); + continue; + } else if(fieldName.equals("signin3")){ + fieldValue = Util.null2String(flowData.get(tmpkey+"signintime3")); + data.add(fieldValue); + fieldValue = Util.null2String(flowData.get(tmpkey+"signinstatus3")); + data.add(fieldValue); + continue; + } else if(fieldName.equals("signout1")){ + fieldValue = Util.null2String(flowData.get(tmpkey+"signouttime1")); + data.add(fieldValue); + fieldValue = Util.null2String(flowData.get(tmpkey+"signoutstatus1")); + data.add(fieldValue); + continue; + } else if(fieldName.equals("signout2")){ + fieldValue = Util.null2String(flowData.get(tmpkey+"signouttime2")); + data.add(fieldValue); + fieldValue = Util.null2String(flowData.get(tmpkey+"signoutstatus2")); + data.add(fieldValue); + continue; + } else if(fieldName.equals("signout3")){ + fieldValue = Util.null2String(flowData.get(tmpkey+"signouttime3")); + data.add(fieldValue); + fieldValue = Util.null2String(flowData.get(tmpkey+"signoutstatus3")); + data.add(fieldValue); + continue; + } else if(fieldName.equals("leave")){ + //请假 + List> allLeaveRules = KQLeaveRulesBiz.getAllLeaveRules(); + Map leaveRule = null; + for(int i=0;allLeaveRules!=null&&i)allLeaveRules.get(i); + String flowType = Util.null2String("leaveType_"+leaveRule.get("id")); + fieldValue = Util.null2String(flowData.get(id+"|"+kqdate+"|"+flowType)); + String flowLeaveBackType = Util.null2String("leavebackType_" + leaveRule.get("id")); + String leavebackData = Util.null2s(Util.null2String(flowData.get(id + "|" + kqdate + "|" + flowLeaveBackType)), "0.0"); + String b_flowLeaveData = ""; + String flowLeaveData = ""; + try { + //以防止出现精度问题 + if (fieldValue.length() == 0) { + fieldValue = "0.0"; + } + if (leavebackData.length() == 0) { + leavebackData = "0.0"; + } + BigDecimal b_leaveData = new BigDecimal(fieldValue); + BigDecimal b_leavebackData = new BigDecimal(leavebackData); + b_flowLeaveData = b_leaveData.subtract(b_leavebackData).toString(); + if(Util.getDoubleValue(b_flowLeaveData, -1) < 0){ + b_flowLeaveData = "0.0"; + } + + } catch (Exception e) { + writeLog("ExportDailyExcelCmd:fieldValue" + fieldValue + ":leavebackData:" + leavebackData + ":" + e); + } + //考虑下冻结的数据 + if (b_flowLeaveData.length() > 0) { + flowLeaveData = KQDurationCalculatorUtil.getDurationRound(b_flowLeaveData); + } else { + flowLeaveData = KQDurationCalculatorUtil.getDurationRound(Util.null2String(Util.getDoubleValue(fieldValue, 0.0) - Util.getDoubleValue(leavebackData, 0.0))); + } + fieldValue = flowLeaveData; + + data.add(fieldValue); + } + }else if(fieldName.equals("overtime")){ + fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id +"|"+kqdate+ "|workingDayOvertime_nonleave"))); + data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("workingDayOvertime_nonleave")))); + + fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id +"|"+kqdate+ "|restDayOvertime_nonleave"))); + data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("restDayOvertime_nonleave")))); + + fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id +"|"+kqdate+ "|holidayOvertime_nonleave"))); + data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("holidayOvertime_nonleave")))); + + fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id +"|"+kqdate+ "|workingDayOvertime_4leave"))); + data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("workingDayOvertime_4leave")))); + + fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id +"|"+kqdate+ "|restDayOvertime_4leave"))); + data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("restDayOvertime_4leave")))); + + fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id +"|"+kqdate+ "|holidayOvertime_4leave"))); + data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("holidayOvertime_4leave")))); + + double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|"+kqdate+"|workingDayOvertime_4leave"))); + workingDayOvertime_4leave = workingDayOvertime_4leave<0?0:workingDayOvertime_4leave; + double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|"+kqdate+"|restDayOvertime_4leave"))); + restDayOvertime_4leave = restDayOvertime_4leave<0?0:restDayOvertime_4leave; + double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|"+kqdate+"|holidayOvertime_4leave"))); + holidayOvertime_4leave = holidayOvertime_4leave<0?0:holidayOvertime_4leave; + + double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|"+kqdate+"|workingDayOvertime_nonleave"))); + workingDayOvertime_nonleave = workingDayOvertime_nonleave<0?0:workingDayOvertime_nonleave; + double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|"+kqdate+"|restDayOvertime_nonleave"))); + restDayOvertime_nonleave = restDayOvertime_nonleave<0?0:restDayOvertime_nonleave; + double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|"+kqdate+"|holidayOvertime_nonleave"))); + holidayOvertime_nonleave = holidayOvertime_nonleave<0?0:holidayOvertime_nonleave; + fieldValue = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_4leave+restDayOvertime_4leave+holidayOvertime_4leave+ + workingDayOvertime_nonleave+restDayOvertime_nonleave+holidayOvertime_nonleave)); + data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("overtimeTotal")))); + continue; + }else if(fieldName.equals("businessLeave") || fieldName.equals("officialBusiness")){ + String businessLeaveData = Util.null2s(Util.null2String(flowData.get(id+"|"+kqdate+"|"+fieldName)),"0.0"); + String backType = fieldName+"_back"; + String businessLeavebackData = Util.null2s(Util.null2String(flowData.get(id+"|"+kqdate+"|"+backType)),"0.0"); + String businessLeave = ""; + try{ + //以防止出现精度问题 + if(businessLeaveData.length() == 0){ + businessLeaveData = "0.0"; + } + if(businessLeavebackData.length() == 0){ + businessLeavebackData = "0.0"; + } + BigDecimal b_businessLeaveData = new BigDecimal(businessLeaveData); + BigDecimal b_businessLeavebackData = new BigDecimal(businessLeavebackData); + businessLeave = b_businessLeaveData.subtract(b_businessLeavebackData).toString(); + if(Util.getDoubleValue(businessLeave, -1) < 0){ + businessLeave = "0.0"; + } + }catch (Exception e){ + } + fieldValue = KQDurationCalculatorUtil.getDurationRound(businessLeave); + }else if(fieldName.equals("kqdate")){ + fieldValue=kqdate+" "+com.engine.portal.util.DateUtil.getDayWeekOfDate1(DateUtil.parseToDate(kqdate)); + }else if (fieldName.equals("reissuecard")) { + double reissueCard = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|reissueCard" ))); + reissueCard = reissueCard < 0 ? 0 : reissueCard; + data.add(reissueCard); + } else { + fieldValue = Util.null2String(rs.getString(fieldName)); + fieldValue = getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(fieldid)); + } + + if(!fieldName.equals("leave")) { + fieldValue = Util.formatMultiLang(fieldValue, "" + user.getLanguage()); + data.add(fieldValue); + } + } + dataList.add(data); + } + sheet.put("dataList", dataList); + sheet.put("constraintList",constraintList); + sheet.put("createFile", "1"); + lsSheet.add(sheet); + + workbook.put("sheet", lsSheet); + String fileName = SystemEnv.getHtmlLabelName(390352, user.getLanguage())+" "+fromDate+" "+toDate;; + workbook.put("fileName", fileName); + ExcelUtil ExcelUtil = new ExcelUtil(); + Map exportMap= ExcelUtil.export(workbook,request,response); + retmap.putAll(exportMap); + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + return retmap; + } + + private Map getChildColumnsInfo(String parentid, User user){ + Map returnMap = new HashMap<>(); + List titleList = new ArrayList<>(); + Map title = null; + if(parentid.equals("leave")){ + KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz(); + List> leaveRules = kqLeaveRulesBiz.getAllLeaveRules(); + for(int i=0;leaveRules!=null&&i leaveRule = leaveRules.get(i); + String name = Util.formatMultiLang(Util.null2String(leaveRule.get("name")),""+user.getLanguage()); + String unitType = Util.null2String(leaveRule.get("unitType")); + title = new HashMap<>(); + title.put("title",name+"("+ + ((KQUnitBiz.isLeaveHour(unitType))?SystemEnv.getHtmlLabelName(391, user.getLanguage()):SystemEnv.getHtmlLabelName(1925, user.getLanguage()))+")"); + title.put("width",30*256); + titleList.add(title); + + } + }else if(parentid.equals("overtime")){ + String[] overtimeChild = {"overtime_nonleave","overtime_4leave","overtimeTotal"}; + for(int i=0;i0){ + if(unitType.equals("1")){ + unitTypeName=SystemEnv.getHtmlLabelName(1925, user.getLanguage()); + }else if(unitType.equals("2")){ + unitTypeName=SystemEnv.getHtmlLabelName(391, user.getLanguage()); + }else if(unitType.equals("3")){ + unitTypeName=SystemEnv.getHtmlLabelName(18083, user.getLanguage()); + } + } + title.put("title", SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage())+ "(" + unitTypeName + ")"); + } + Map mapChildColumnInfo = getChildColumnsInfo(id, user); + int childWidth = 65; + List childColumns = (List)mapChildColumnInfo.get("childColumns"); + if(childColumns.size()>0) {//跨列width取子列的width + title.put("children", childColumns); + childWidth = Util.getIntValue(Util.null2String(mapChildColumnInfo.get("sumChildColumnWidth")),65); + } + title.put("width", childWidth+""); + titleList.add(title); + } + } else{ + KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo(); + while (kqReportFieldComInfo.next()){ + if(kqReportFieldComInfo.getParentid().equals(parentid)) { + if(!kqReportFieldComInfo.getReportType().equals("daily"))continue; + title = new HashMap<>(); + title.put("title",SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage())+ + (KQReportBiz.getUnitType(kqReportFieldComInfo, user).length()>0?"("+ KQReportBiz.getUnitType(kqReportFieldComInfo, user)+")":"")); + title.put("width",30*256); + titleList.add(title); + } + } + } + returnMap.put("childColumns",titleList); + return returnMap; + } + + public Map getSignDetailInfo(String resourceId, String kqDate){ + Map data = new HashMap<>(); + Map signStatusInfo = null; + RecordSet rs = new RecordSet(); + String sql = ""; + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + try{ + sql = " select kqdate,resourceid,serialid,serialnumber,workbegindate,workbegintime, " + + " workenddate,workendtime,workmins,signindate,signintime,signoutdate,signouttime, \n" + + " attendanceMins,belatemins,graveBeLateMins,leaveearlymins,graveLeaveEarlyMins,absenteeismmins,forgotcheckMins,forgotBeginWorkCheckMins," + + " leaveMins,leaveInfo,evectionMins,outMins,signinid,signoutid \n" + + " from kq_format_detail b \n" + + " where resourceid = " + resourceId + " and kqdate ='" + kqDate + "' \n" + + " order by serialnumber \n"; + rs.execute(sql); + while (rs.next()) { + String resourceid = Util.null2String(rs.getString("resourceid")); + String kqdate = Util.null2String(rs.getString("kqdate")); + String serialid = Util.null2String(rs.getString("serialid")); + int serialnumber = rs.getInt("serialnumber")+1; + String workbegindate = Util.null2String(rs.getString("workbegindate")).trim(); + String workbegintime = Util.null2String(rs.getString("workbegintime")).trim(); + String workenddate = Util.null2String(rs.getString("workenddate")).trim(); + String workendtime = Util.null2String(rs.getString("workendtime")).trim(); + int workMins = rs.getInt("workMins"); + String signintime = Util.null2String(rs.getString("signintime")).trim(); + String signouttime = Util.null2String(rs.getString("signouttime")).trim(); + int attendanceMins = rs.getInt("attendanceMins"); + String beLateMins = Util.null2String(rs.getString("beLateMins")).trim(); + String graveBeLateMins = Util.null2String(rs.getString("graveBeLateMins")).trim(); + String leaveEarlyMins= Util.null2String(rs.getString("leaveEarlyMins")).trim(); + String graveLeaveEarlyMins= Util.null2String(rs.getString("graveLeaveEarlyMins")).trim(); + String absenteeismMins= Util.null2String(rs.getString("absenteeismMins")).trim(); + String forgotCheckMins = Util.null2String(rs.getString("forgotcheckMins")).trim(); + String forgotBeginWorkCheckMins = Util.null2String(rs.getString("forgotBeginWorkCheckMins")).trim(); + String signinid = Util.null2String(rs.getString("signinid")).trim(); + String signoutid = Util.null2String(rs.getString("signoutid")).trim(); + int leaveMins = rs.getInt("leaveMins"); + String leaveInfo = Util.null2String(rs.getString("leaveInfo")); + int evectionMins = rs.getInt("evectionMins"); + int outMins = rs.getInt("outMins"); + + + if(serialid.length()>0){ + if (workbegintime.length() > 0) { + signStatusInfo = new HashMap(); + signStatusInfo.put("workdate",workbegindate); + signStatusInfo.put("worktime",workbegintime); + signStatusInfo.put("beLateMins",beLateMins); + signStatusInfo.put("forgotBeginWorkCheckMins",forgotBeginWorkCheckMins); + signStatusInfo.put("graveBeLateMins",graveBeLateMins); + signStatusInfo.put("absenteeismMins",absenteeismMins); + signStatusInfo.put("leaveMins",leaveMins); + signStatusInfo.put("leaveInfo",leaveInfo); + signStatusInfo.put("evectionMins",evectionMins); + signStatusInfo.put("outMins",outMins); + + data.put("signintime"+serialnumber, signintime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signintime); + data.put("signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on")); + } + + if (workendtime.length() > 0) { + signStatusInfo = new HashMap(); + signStatusInfo.put("workdate",workenddate); + signStatusInfo.put("worktime",kqTimesArrayComInfo.turn48to24Time(workendtime)); + signStatusInfo.put("leaveEarlyMins",leaveEarlyMins); + signStatusInfo.put("graveLeaveEarlyMins",graveLeaveEarlyMins); + signStatusInfo.put("forgotCheckMins",forgotCheckMins); + signStatusInfo.put("forgotBeginWorkCheckMins",forgotBeginWorkCheckMins); + signStatusInfo.put("absenteeismMins",absenteeismMins); + signStatusInfo.put("leaveMins",leaveMins); + signStatusInfo.put("leaveInfo",leaveInfo); + signStatusInfo.put("evectionMins",evectionMins); + signStatusInfo.put("outMins",outMins); + + data.put("signouttime"+serialnumber, signouttime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signouttime); + data.put("signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off")); + } + }else{ + if(workMins>0){ + //弹性工时打卡时间取自签到签退数据 + } + signStatusInfo = new HashMap(); + signStatusInfo.put("leaveMins",leaveMins); + signStatusInfo.put("leaveInfo",leaveInfo); + signStatusInfo.put("evectionMins",evectionMins); + signStatusInfo.put("outMins",outMins); + + if(signinid.length() > 0){ + data.put("signintime"+serialnumber, signintime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signintime); + data.put("signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on")); + if(signoutid.length() > 0){ + data.put("signouttime"+serialnumber, signouttime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signouttime); + data.put("signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off")); + } + }else{ + data.put("signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on")); + } + } + } + }catch (Exception e){ + writeLog(e); + } + return data; + } + + private String getFieldValueByUnitType(String fieldValue,String unittype){ + if (Util.null2String(unittype).length() > 0) { + if (fieldValue.length() == 0) { + fieldValue = "0"; + } else { + if (unittype.equals("2")) { + fieldValue = KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(fieldValue) / 60.0))); + } + } + } + return fieldValue; + } + + @Override + public BizLogContext getLogContext() { + return null; + } +} diff --git a/src/com/engine/kq/cmd/report/ExportExcelCmd.java b/src/com/engine/kq/cmd/report/ExportExcelCmd.java new file mode 100644 index 0000000..1fbdd45 --- /dev/null +++ b/src/com/engine/kq/cmd/report/ExportExcelCmd.java @@ -0,0 +1,608 @@ +package com.engine.kq.cmd.report; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.*; +import com.engine.kq.util.ExcelUtil; +import com.engine.kq.util.KQDurationCalculatorUtil; +import com.engine.kq.util.UtilKQ; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.job.JobTitlesComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.math.BigDecimal; +import java.util.*; + +public class ExportExcelCmd extends AbstractCommonCommand> { + + private HttpServletRequest request; + private HttpServletResponse response; + private List lsFieldDataKey; + + public ExportExcelCmd(Map params, HttpServletRequest request, HttpServletResponse response, User user) { + this.user = user; + this.params = params; + this.request = request; + this.response = response; + this.lsFieldDataKey = new ArrayList<>(); + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + String sql = ""; + try { + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + ResourceComInfo resourceComInfo = new ResourceComInfo(); + JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo(); + KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz(); + KQReportBiz kqReportBiz = new KQReportBiz(); + + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String attendanceSerial = Util.null2String(jsonObj.get("attendanceSerial")); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect = Util.null2String(jsonObj.get("typeselect")); + if (typeselect.length() == 0) typeselect = "3"; + if (!typeselect.equals("") && !typeselect.equals("0") && !typeselect.equals("6")) { + if (typeselect.equals("1")) { + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + } else { + fromDate = TimeUtil.getDateByOption(typeselect, "0"); + toDate = TimeUtil.getDateByOption(typeselect, "1"); + } + } + //人员状态 + String status = Util.null2String(jsonObj.get("status")); + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + List showColumns = Util.splitString2List(Util.null2String(jsonObj.get("showColumns")), ","); + showColumns.add("lastname"); + showColumns.removeIf(showColumn->showColumn.trim().equals("")); + + List tmpShowColumns = new ArrayList<>(); + for(String showColumn:showColumns){ + tmpShowColumns.add(showColumn); + String cascadekey = ""; + if(showColumn.equals("beLate")){ + cascadekey = "beLateMins"; + }else if(showColumn.equals("leaveEearly")){ + cascadekey = "leaveEarlyMins"; + }else if(showColumn.equals("graveBeLate")){ + cascadekey = "graveBeLateMins"; + }else if(showColumn.equals("graveLeaveEarly")){ + cascadekey = "graveLeaveEarlyMins"; + }else if(showColumn.equals("absenteeism")){ + cascadekey = "absenteeismMins"; + }else if(showColumn.equals("overtime")){ + tmpShowColumns.add("overtime_4leave"); + tmpShowColumns.add("overtime_nonleave"); + tmpShowColumns.add("workingDayOvertime_nonleave"); + tmpShowColumns.add("workingDayOvertime_4leave"); + tmpShowColumns.add("restDayOvertime_nonleave"); + tmpShowColumns.add("restDayOvertime_4leave"); + tmpShowColumns.add("holidayOvertime_4leave"); + tmpShowColumns.add("holidayOvertime_nonleave"); + } + if(cascadekey.length()>0){ + tmpShowColumns.add(cascadekey); + } + } + showColumns = tmpShowColumns; + + String rightSql = new KQReportBiz().getReportRight("1", "" + user.getUID(), "a"); + + LinkedHashMap workbook = new LinkedHashMap<>(); + List lsSheet = new ArrayList<>(); + Map sheet = null; + List titleList = new ArrayList<>(); + Map title = null; + List> dataList = new ArrayList<>(); + List data = null; + List> constraintList = null; + + sheet = new HashMap<>(); + sheet.put("sheetName", SystemEnv.getHtmlLabelName(390351, user.getLanguage())); + sheet.put("sheetTitle", SystemEnv.getHtmlLabelName(390351, user.getLanguage())); + boolean isEnd = false; + Calendar cal = DateUtil.getCalendar(); + + List> leaveRules = kqLeaveRulesBiz.getAllLeaveRules(); + Map mapChildColumnInfo = null; + List childColumns = null; + KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo(); + while (kqReportFieldComInfo.next()) { + if (Util.null2String(kqReportFieldComInfo.getParentid()).length() > 0) continue; + if(kqReportFieldComInfo.getFieldname().equals("kqCalendar"))continue; + if(KQReportFieldComInfo.cascadekey2fieldname.keySet().contains(kqReportFieldComInfo.getFieldname()))continue; + if (!kqReportFieldComInfo.getReportType().equals("all") && !kqReportFieldComInfo.getReportType().equals("month")) + continue; + if (!showColumns.contains(kqReportFieldComInfo.getFieldname())&&!showColumns.contains(kqReportFieldComInfo.getParentid())) continue; + if("leave".equalsIgnoreCase(kqReportFieldComInfo.getFieldname())&&leaveRules.size()==0){ + continue; + } + title = new HashMap<>(); + String unitType = KQReportBiz.getUnitType(kqReportFieldComInfo, user); + if(unitType.length()>0){ + title.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage())+ "(" + unitType + ")"); + }else{ + title.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage())); + } + title.put("width", 30 * 256); + this.lsFieldDataKey.add(kqReportFieldComInfo.getFieldname()); + mapChildColumnInfo = this.getChildColumnsInfo(kqReportFieldComInfo.getFieldname(), user); + childColumns = (List) mapChildColumnInfo.get("childColumns"); + if (childColumns.size() > 0) {//跨列width取子列的width + title.put("children", childColumns); + title.put("colSpan", childColumns.size()); + } else { + title.put("rowSpan", 3); + } + titleList.add(title); + + titleList.addAll(this.getCascadeKeyColumnsInfo(kqReportFieldComInfo.getCascadekey(),user)); + } + + String today = DateUtil.getCurrentDate(); +// if (DateUtil.compDate(today, toDate) > 0) {//结束如期不大于今天 +// toDate = today; +// } + + if(showColumns.contains("kqCalendar")) { + childColumns = new ArrayList<>(); + for (String date = fromDate; !isEnd; ) { + if (date.equals(toDate)) isEnd = true; + title = new HashMap<>(); + title.put("title", UtilKQ.getWeekDayShort(DateUtil.getWeek(date)-1,user.getLanguage()) +"\r\n"+ DateUtil.geDayOfMonth(date)); + title.put("width", 30 * 256); + childColumns.add(title); + cal.setTime(DateUtil.parseToDate(date)); + date = DateUtil.getDate(cal.getTime(), 1); + } + + title = new HashMap(); + title.put("title", SystemEnv.getHtmlLabelName(386476, user.getLanguage())); + if (childColumns.size() > 0) {//跨列width取子列的width + title.put("children", childColumns); + title.put("colSpan", childColumns.size()); + } + titleList.add(title); + } + sheet.put("titleList", titleList); + + String forgotBeginWorkCheck_field = " sum(b.forgotBeginWorkCheck) "; + + if(rs.getDBType().equalsIgnoreCase("oracle")) { + forgotBeginWorkCheck_field = " sum(nvl(b.forgotBeginWorkCheck,0)) "; + }else if((rs.getDBType()).equalsIgnoreCase("mysql")){ + forgotBeginWorkCheck_field = " sum(ifnull(b.forgotBeginWorkCheck,0)) "; + }else { + forgotBeginWorkCheck_field = " sum(isnull(b.forgotBeginWorkCheck,0)) "; + } + + Map definedFieldInfo = new KQFormatBiz().getDefinedField(); + String definedFieldSum = Util.null2String(definedFieldInfo.get("definedFieldSum")); + String backFields = " a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1 as subcompanyid,a.departmentid,a.jobtitle," + + " sum(b.workdays) as workdays,sum(b.workMins) as workMins,sum(b.attendancedays) as attendancedays," + + " sum(b.attendanceMins) as attendanceMins,sum(b.beLate) as beLate,sum(b.beLateMins) as beLateMins, " + + " sum(b.graveBeLate) as graveBeLate, sum(b.graveBeLateMins) as graveBeLateMins,sum(b.leaveEearly) as leaveEearly," + + " sum(b.leaveEarlyMins) as leaveEarlyMins, sum(b.graveLeaveEarly) as graveLeaveEarly, " + + " sum(b.graveLeaveEarlyMins) as graveLeaveEarlyMins,sum(b.absenteeism) as absenteeism, " + + " sum(b.signdays) as signdays,sum(b.signmins) as signmins, "+ + " sum(b.absenteeismMins) as absenteeismMins, sum(b.forgotCheck)+"+forgotBeginWorkCheck_field+" as forgotCheck "+(definedFieldSum.length()>0?","+definedFieldSum+"":""); + if(rs.getDBType().equals("oracle")){ + backFields = "/*+ index(kq_format_total IDX_KQ_FORMAT_TOTAL_KQDATE) */ "+backFields; + } + String sqlFrom = " from hrmresource a, kq_format_total b where a.id= b.resourceid and b.kqdate >='" + fromDate + "' and b.kqdate <='" + toDate + "'"; + String sqlWhere = rightSql; + String groupBy = " group by a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1,a.departmentid,a.jobtitle "; + if (subCompanyId.length() > 0) { + sqlWhere += " and a.subcompanyid1 in(" + subCompanyId + ") "; + } + + if (departmentId.length() > 0) { + sqlWhere += " and a.departmentid in(" + departmentId + ") "; + } + + if (resourceId.length() > 0) { + sqlWhere += " and a.id in(" + resourceId + ") "; + } + + if (viewScope.equals("4")) {//我的下属 + if (allLevel.equals("1")) {//所有下属 + sqlWhere += " and a.managerstr like '%," + user.getUID() + ",%'"; + } else { + sqlWhere += " and a.managerid=" + user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null " + (rs.getDBType().equals("oracle") ? "" : " and a.loginid<>'' "); + } + + if(status.length()>0){ + if (!status.equals("8") && !status.equals("9")) { + sqlWhere += " and a.status = "+status+ ""; + }else if (status.equals("8")) { + sqlWhere += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) "; + } + } + + String orderBy = " order by a.dsporder asc, a.lastname asc "; + String descOrderBy = " order by a.dsporder desc, a.lastname desc "; + sql = "select " + backFields + sqlFrom + sqlWhere + groupBy + orderBy; + + //System.out.println("start" + DateUtil.getFullDate()); + + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + String show_card_source = Util.null2String(kqSettingsComInfo.getMain_val("show_card_source"),"0");//是否显示打卡数据,以及打卡数据来源 + params.put("show_card_source",show_card_source); + KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz(); + int uintType = kqOvertimeRulesBiz.getMinimumUnit();//当前加班单位 + double hoursToDay = kqOvertimeRulesBiz.getHoursToDay();//当前天跟小时计算关系 + params.put("uintType",uintType); + params.put("hoursToDay",hoursToDay); + Map flowData = new KQReportBiz().getFlowData(params, user); + //System.out.println("end" + DateUtil.getFullDate()); + + // #1475814-概述:满足考勤报分部部门显示及导出时显示全路径 + String fullPathMainKey = "show_full_path"; + String isShowFullPath = Util.null2String(kqSettingsComInfo.getMain_val(fullPathMainKey),"0"); + + + rs.execute(sql); + while (rs.next()) { + data = new ArrayList<>(); + String id = rs.getString("id"); + for (int fieldDataKeyIdx =0;fieldDataKeyIdx serialIds = null; + if (Util.null2String(jsonObj.get("attendanceSerial")).length() > 0) { + serialIds = Util.splitString2List(Util.null2String(jsonObj.get("attendanceSerial")), ","); + for(int i=0;serialIds!=null&&i> allLeaveRules = kqLeaveRulesBiz.getAllLeaveRules(); + Map leaveRule = null; + for (int i = 0; allLeaveRules != null && i < allLeaveRules.size(); i++) { + leaveRule = allLeaveRules.get(i); + String flowType = Util.null2String("leaveType_" + leaveRule.get("id")); + String leaveData = Util.null2String(flowData.get(id + "|" + flowType)); + String flowLeaveBackType = Util.null2String("leavebackType_" + leaveRule.get("id")); + String leavebackData = Util.null2s(Util.null2String(flowData.get(id + "|" + flowLeaveBackType)), "0.0"); + String b_flowLeaveData = ""; + String flowLeaveData = ""; + try { + //以防止出现精度问题 + if (leaveData.length() == 0) { + leaveData = "0.0"; + } + if (leavebackData.length() == 0) { + leavebackData = "0.0"; + } + BigDecimal b_leaveData = new BigDecimal(leaveData); + BigDecimal b_leavebackData = new BigDecimal(leavebackData); + b_flowLeaveData = b_leaveData.subtract(b_leavebackData).toString(); + if(Util.getDoubleValue(b_flowLeaveData, -1) < 0){ + b_flowLeaveData = "0.0"; + } + } catch (Exception e) { + writeLog("GetKQReportCmd:leaveData" + leaveData + ":leavebackData:" + leavebackData + ":" + e); + } + + if (b_flowLeaveData.length() > 0) { + flowLeaveData = KQDurationCalculatorUtil.getDurationRound(b_flowLeaveData); + } else { + flowLeaveData = KQDurationCalculatorUtil.getDurationRound(Util.null2String(Util.getDoubleValue(leaveData, 0.0) - Util.getDoubleValue(leavebackData, 0.0))); + } + data.add(flowLeaveData); + } + continue; + }else if(fieldName.equals("overtime")){ + fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|workingDayOvertime_nonleave"))); + data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("workingDayOvertime_nonleave")))); + + fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|restDayOvertime_nonleave"))); + data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("restDayOvertime_nonleave")))); + + fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|holidayOvertime_nonleave"))); + data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("holidayOvertime_nonleave")))); + + fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|workingDayOvertime_4leave"))); + data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("workingDayOvertime_4leave")))); + + fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|restDayOvertime_4leave"))); + data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("restDayOvertime_4leave")))); + + fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|holidayOvertime_4leave"))); + data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("holidayOvertime_4leave")))); + + double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|workingDayOvertime_4leave"))); + workingDayOvertime_4leave = workingDayOvertime_4leave<0?0:workingDayOvertime_4leave; + double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|restDayOvertime_4leave"))); + restDayOvertime_4leave = restDayOvertime_4leave<0?0:restDayOvertime_4leave; + double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|holidayOvertime_4leave"))); + holidayOvertime_4leave = holidayOvertime_4leave<0?0:holidayOvertime_4leave; + + double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|workingDayOvertime_nonleave"))); + workingDayOvertime_nonleave = workingDayOvertime_nonleave<0?0:workingDayOvertime_nonleave; + double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|restDayOvertime_nonleave"))); + restDayOvertime_nonleave = restDayOvertime_nonleave<0?0:restDayOvertime_nonleave; + double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|holidayOvertime_nonleave"))); + holidayOvertime_nonleave = holidayOvertime_nonleave<0?0:holidayOvertime_nonleave; + fieldValue = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_4leave+restDayOvertime_4leave+holidayOvertime_4leave+ + workingDayOvertime_nonleave+restDayOvertime_nonleave+holidayOvertime_nonleave)); + data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("overtimeTotal")))); + continue; + }else if(fieldName.equals("businessLeave") || fieldName.equals("officialBusiness")){ + String businessLeaveData = Util.null2s(Util.null2String(flowData.get(id+"|"+fieldName)),"0.0"); + String backType = fieldName+"_back"; + String businessLeavebackData = Util.null2s(Util.null2String(flowData.get(id+"|"+backType)),"0.0"); + String businessLeave = ""; + try{ + //以防止出现精度问题 + if(businessLeaveData.length() == 0){ + businessLeaveData = "0.0"; + } + if(businessLeavebackData.length() == 0){ + businessLeavebackData = "0.0"; + } + BigDecimal b_businessLeaveData = new BigDecimal(businessLeaveData); + BigDecimal b_businessLeavebackData = new BigDecimal(businessLeavebackData); + businessLeave = b_businessLeaveData.subtract(b_businessLeavebackData).toString(); + if(Util.getDoubleValue(businessLeave, -1) < 0){ + businessLeave = "0.0"; + } + }catch (Exception e){ + } + fieldValue = KQDurationCalculatorUtil.getDurationRound(businessLeave); + } else if(Util.null2String(kqReportFieldComInfo.getCascadekey(fieldid)).length()>0){ + fieldValue = Util.formatMultiLang(Util.null2String(rs.getString(fieldName)),""+user.getLanguage()); + data.add(fieldValue); + + List lsCascadekey = Util.splitString2List(kqReportFieldComInfo.getCascadekey(fieldid),","); + for(int i=0;i0){ + fieldid = KQReportFieldComInfo.field2Id.get(lsCascadekey.get(i)); + fieldValue = getFieldValueByUnitType(rs.getString(lsCascadekey.get(i)),kqReportFieldComInfo.getUnittype(fieldid)); + }else{ + fieldValue = "0"; + } + data.add(fieldValue); + } + continue; + } else if (fieldName.equals("reissuecard")) { + int reissueCard = Util.getIntValue(Util.null2String(flowData.get(id + "|reissueCard" ))); + reissueCard = reissueCard < 0 ? 0 : reissueCard; + fieldValue = String.valueOf(reissueCard); + data.add(fieldValue); + continue; + } else { + fieldValue = Util.formatMultiLang(Util.null2String(rs.getString(fieldName)),""+user.getLanguage()); + fieldValue = getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(fieldid)); + } + fieldValue = Util.formatMultiLang(fieldValue,""+user.getLanguage()); + data.add(fieldValue); + } + if(showColumns.contains("kqCalendar")) { +// Map detialDatas = kqReportBiz.getDetialDatas(id, fromDate, toDate, user,flowData,true); + Map detialDatas = kqReportBiz.getDetialDatas(id, fromDate, toDate, user,flowData,true,uintType,show_card_source); + isEnd = false; + for (String date = fromDate; !isEnd; ) { + if (date.equals(toDate)) isEnd = true; + if (DateUtil.compDate(today, date) > 0) { + data.add(""); + } else { + if (detialDatas.get(id + "|" + date) != null) { + data.add(((Map) detialDatas.get(id + "|" + date)).get("text")); + } else { + data.add(SystemEnv.getHtmlLabelName(26593, user.getLanguage())); + } + } + cal.setTime(DateUtil.parseToDate(date)); + date = DateUtil.getDate(cal.getTime(), 1); + } + } + dataList.add(data); + } + sheet.put("dataList", dataList); + sheet.put("constraintList", constraintList); + sheet.put("createFile", "1"); + lsSheet.add(sheet); + + workbook.put("sheet", lsSheet); + String fileName = SystemEnv.getHtmlLabelName(390351, user.getLanguage())+" "+fromDate+" "+toDate; + workbook.put("fileName", fileName); + ExcelUtil ExcelUtil = new ExcelUtil(); + Map exportMap = ExcelUtil.export(workbook, request, response,true); + retmap.putAll(exportMap); + retmap.put("status", "1"); + } catch (Exception e) { + retmap.put("status", "-1"); + retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage())); + writeLog(e); + } + return retmap; + } + + private Map getChildColumnsInfo(String parentid, User user) { + Map returnMap = new HashMap<>(); + List titleList = new ArrayList<>(); + Map title = null; + if (parentid.equals("attendanceSerial")) {//考勤班次 + KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + List serialIds = null; + if (Util.null2String(jsonObj.get("attendanceSerial")).length() > 0) { + serialIds = Util.splitString2List(Util.null2String(jsonObj.get("attendanceSerial")), ","); + } + for (int i = 0; serialIds != null && i < serialIds.size(); i++) { + title = new HashMap<>(); + title.put("title", Util.formatMultiLang(kqShiftManagementComInfo.getSerial(serialIds.get(i)),""+user.getLanguage())); + title.put("width", 30 * 256); + titleList.add(title); + } + } else if (parentid.equals("leave")) { + KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz(); + List> leaveRules = kqLeaveRulesBiz.getAllLeaveRules(); + for (int i = 0; leaveRules != null && i < leaveRules.size(); i++) { + Map leaveRule = leaveRules.get(i); + String name = Util.formatMultiLang(Util.null2String(leaveRule.get("name")),""+user.getLanguage()); + String unitType = Util.null2String(leaveRule.get("unitType")); + String unitName = (KQUnitBiz.isLeaveHour(unitType)) ? SystemEnv.getHtmlLabelName(391, user.getLanguage()) : SystemEnv.getHtmlLabelName(1925, user.getLanguage()); + title = new HashMap<>(); + title.put("title", name + "(" + unitName + ")"); + title.put("width", 30 * 256); + titleList.add(title); + } + }else if(parentid.equals("overtime")){ + String[] overtimeChild = {"overtime_nonleave","overtime_4leave","overtimeTotal"}; + for(int i=0;i0){ + if(unitType.equals("1")){ + unitTypeName=SystemEnv.getHtmlLabelName(1925, user.getLanguage()); + }else if(unitType.equals("2")){ + unitTypeName=SystemEnv.getHtmlLabelName(391, user.getLanguage()); + }else if(unitType.equals("3")){ + unitTypeName=SystemEnv.getHtmlLabelName(18083, user.getLanguage()); + } + } + title.put("title", SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage())+ "(" + unitTypeName + ")"); + } + + Map mapChildColumnInfo = getChildColumnsInfo(id, user); + int childWidth = 65; + List childColumns = (List)mapChildColumnInfo.get("childColumns"); + if(childColumns.size()>0) {//跨列width取子列的width + title.put("children", childColumns); + childWidth = Util.getIntValue(Util.null2String(mapChildColumnInfo.get("sumChildColumnWidth")),65); + } + title.put("width", childWidth+""); + titleList.add(title); + } + } else { + KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo(); + while (kqReportFieldComInfo.next()) { + if (kqReportFieldComInfo.getParentid().equals(parentid)) { + if(!kqReportFieldComInfo.getReportType().equals("month"))continue; + title = new HashMap<>(); + title.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage()) + "(" + KQReportBiz.getUnitType(kqReportFieldComInfo, user) + ")"); + title.put("width", 30 * 256); + titleList.add(title); + } + } + } + returnMap.put("childColumns", titleList); + return returnMap; + } + + private List getCascadeKeyColumnsInfo(String cascadeKey, User user){ + List titleList = new ArrayList<>(); + Map title = null; + if(Util.null2String(cascadeKey).length()==0){ + return titleList; + } + List lsCascadeKey = Util.splitString2List(cascadeKey,","); + KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo(); + for(int i=0;i(); + title.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage()) + "(" + KQReportBiz.getUnitType(kqReportFieldComInfo, user) + ")"); + title.put("width", 30 * 256); + titleList.add(title); + } + } + } + return titleList; + } + + private String getFieldValueByUnitType(String fieldValue,String unittype){ + if (Util.null2String(unittype).length() > 0) { + if (fieldValue.length() == 0) { + fieldValue = "0"; + } else { + if (unittype.equals("2")) { + fieldValue = KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(fieldValue) / 60.0))); + } + } + } + return fieldValue; + } + @Override + public BizLogContext getLogContext() { + return null; + } +} diff --git a/src/com/engine/kq/cmd/report/GetKQDailyReportCmd.java b/src/com/engine/kq/cmd/report/GetKQDailyReportCmd.java new file mode 100644 index 0000000..45553f4 --- /dev/null +++ b/src/com/engine/kq/cmd/report/GetKQDailyReportCmd.java @@ -0,0 +1,623 @@ +package com.engine.kq.cmd.report; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.*; +import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit; +import com.engine.kq.entity.WorkTimeEntity; +import com.engine.kq.log.KQLog; +import com.engine.kq.util.KQDurationCalculatorUtil; +import com.engine.kq.util.PageUidFactory; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.job.JobTitlesComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class GetKQDailyReportCmd extends AbstractCommonCommand> { + + private KQLog kqLog = new KQLog(); + + public GetKQDailyReportCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + String sql = ""; + try{ + String pageUid = PageUidFactory.getHrmPageUid("KQDailyReport"); + + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + ResourceComInfo resourceComInfo = new ResourceComInfo(); + JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo(); + KQWorkTime kqWorkTime = new KQWorkTime(); + ShiftManagementToolKit shiftManagementToolKit = new ShiftManagementToolKit(); + KQReportBiz kqReportBiz = new KQReportBiz(); + KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz(); + + String rightSql = new KQReportBiz().getReportRight("2",""+user.getUID(),"a"); + + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + //人员状态 + String status = Util.null2String(jsonObj.get("status")); + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + if(typeselect.length()==0)typeselect = "3"; + int pageIndex = Util.getIntValue(Util.null2String(jsonObj.get("pageIndex")), 1); + int pageSize = KQReportBiz.getPageSize(Util.null2String(jsonObj.get("pageSize")),pageUid,user.getUID()); + int count = 0; + int pageCount = 0; + int isHavePre = 0; + int isHaveNext = 0; + + List> leaveRules = kqLeaveRulesBiz.getAllLeaveRules(); + List columns = new ArrayList(); + Map column = null; + List datas = new ArrayList(); + Map data = null; + Map mapChildColumnInfo = null; + List childColumns = null; + KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo(); + while (kqReportFieldComInfo.next()){ + if(Util.null2String(kqReportFieldComInfo.getParentid()).length()>0)continue; + boolean isDaily = kqReportFieldComInfo.getReportType().equals("daily"); + if(!kqReportFieldComInfo.getReportType().equals("all") && !isDaily)continue; + if("leave".equalsIgnoreCase(kqReportFieldComInfo.getFieldname())&&leaveRules.size()==0){ + continue; + } + column = new HashMap(); + column.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage())); + column.put("unit", KQReportBiz.getUnitType(kqReportFieldComInfo, user)); + column.put("dataIndex", kqReportFieldComInfo.getFieldname()); + column.put("key", kqReportFieldComInfo.getFieldname()); + mapChildColumnInfo = this.getChildColumnsInfo(kqReportFieldComInfo.getFieldname(),user); + childColumns = (List)mapChildColumnInfo.get("childColumns"); + if(childColumns.size()>0) {//跨列width取子列的width + column.put("rowSpan", 1); + column.put("width", mapChildColumnInfo.get("sumChildColumnWidth")); + column.put("children", childColumns); + }else{ + column.put("rowSpan", 3); + column.put("width", Util.getIntValue(kqReportFieldComInfo.getWidth())); + } + if(kqReportFieldComInfo.getReportType1().equals("daily")){ + column.put("isdaily", "1"); + } + column.put("showDetial",kqReportFieldComInfo.getShowDetial()); + columns.add(column); + } + +// String today = DateUtil.getCurrentDate(); +// if(DateUtil.compDate(today, toDate)>0){//结束如期不大于今天 +// toDate = today; +// if(DateUtil.compDate(today, fromDate)>0){ +// fromDate = today; +// } +// } + String forgotBeginWorkCheck_field = " b.forgotbeginworkcheck "; + + if(rs.getDBType().equalsIgnoreCase("oracle")&&!Util.null2String(rs.getOrgindbtype()).equals("dm")&&!Util.null2String(rs.getOrgindbtype()).equals("st")&&!Util.null2String(rs.getOrgindbtype()).equals("jc")) { + forgotBeginWorkCheck_field = " nvl(b.forgotBeginWorkCheck,0) "; + }else if((rs.getDBType()).equalsIgnoreCase("mysql")){ + forgotBeginWorkCheck_field = " ifnull(b.forgotBeginWorkCheck,0) "; + }else { + forgotBeginWorkCheck_field = " isnull(b.forgotBeginWorkCheck,0) "; + } + + String backFields = " a.id,a.lastname,a.subcompanyid1 as subcompanyid,a.departmentid, a.workcode,b.jobtitle,a.dsporder," + + " b.kqdate, b.workdays,b.workMins,b.serialid, b.attendancedays,b.attendanceMins," + + " b.beLate,b.beLateMins,b.graveBeLate,b.graveBeLateMins,b.leaveEearly,b.leaveEarlyMins," + + " b.signdays,b.signmins, "+ + " b.graveLeaveEarly,b.graveLeaveEarlyMins,b.absenteeism ,b.absenteeismMins ,(b.forgotCheck+"+forgotBeginWorkCheck_field+") forgotCheck "; + String sqlFrom = " from hrmresource a, kq_format_total b where a.id= b.resourceid and b.kqdate >='"+fromDate+"' and b.kqdate <='"+toDate+"'"; + String sqlWhere = rightSql; + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and a.id in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + if(status.length()>0){ + if (!status.equals("8") && !status.equals("9")) { + sqlWhere += " and a.status = "+status+ ""; + }else if (status.equals("8")) { + sqlWhere += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) "; + } + } + + sql = " select count(*) as c from ( select 1 as c "+sqlFrom+sqlWhere+") t"; + rs.execute(sql); + if (rs.next()){ + count = rs.getInt("c"); + } + + if (count <= 0) { + pageCount = 0; + } + + pageCount = count / pageSize + ((count % pageSize > 0) ? 1 : 0); + + isHaveNext = (pageIndex + 1 <= pageCount) ? 1 : 0; + + isHavePre = (pageIndex - 1 >= 1) ? 1 : 0; + + String orderBy = " order by a.dsporder asc, a.lastname asc, b.kqdate asc "; + String descOrderBy = " order by a.dsporder desc, a.lastname desc, b.kqdate desc "; + sql = backFields + sqlFrom + sqlWhere + orderBy; + + if (pageIndex > 0 && pageSize > 0) { + if (rs.getDBType().equals("oracle")) { + sql = " select " + sql; + sql = "select * from ( select row_.*, rownum rownum_ from ( " + sql + " ) row_ where rownum <= " + + (pageIndex * pageSize) + ") where rownum_ > " + ((pageIndex - 1) * pageSize); + } else if (rs.getDBType().equals("mysql")) { + sql = " select " + sql; + sql = "select t1.* from (" + sql + ") t1 limit " + ((pageIndex - 1) * pageSize) + "," + pageSize; + } + else if (rs.getDBType().equals("postgresql")) { + sql = " select " + sql; + sql = "select t1.* from (" + sql + ") t1 limit " + pageSize+ " offset " + ((pageIndex - 1) * pageSize); + } + else { + orderBy = " order by dsporder asc, lastname asc, kqdate asc "; + descOrderBy = " order by dsporder desc, lastname desc, kqdate desc "; + if (pageIndex > 1) { + int topSize = pageSize; + if (pageSize * pageIndex > count) { + topSize = count - (pageSize * (pageIndex - 1)); + } + sql = " select top " + topSize + " * from ( select top " + topSize + " * from ( select top " + + (pageIndex * pageSize) + sql+" ) tbltemp1 " + descOrderBy + ") tbltemp2 " + orderBy; + } else { + sql = " select top " + pageSize + sql; + } + } + } else { + sql = " select " + sql; + } + Map flowData = kqReportBiz.getDailyFlowData(params,user); + Map serialdata = new HashMap<>(); + + // #1475814-概述:满足考勤报分部部门显示及导出时显示全路径 + String fullPathMainKey = "show_full_path"; + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + String isShowFullPath = Util.null2String(kqSettingsComInfo.getMain_val(fullPathMainKey),"0"); + + rs.execute(sql); + while (rs.next()) { + String id = rs.getString("id"); + String kqdate = rs.getString("kqdate"); + WorkTimeEntity workTime = kqWorkTime.getWorkTime(id, kqdate); + data = new HashMap<>(); + kqReportFieldComInfo.setTofirstRow(); + while (kqReportFieldComInfo.next()) { + if (!Util.null2String(kqReportFieldComInfo.getIsdataColumn()).equals("1")) continue; + if (!kqReportFieldComInfo.getReportType().equals("all") && !kqReportFieldComInfo.getReportType().equals("daily")) + continue; + String fieldName = kqReportFieldComInfo.getFieldname(); + String fieldValue = ""; + if (fieldName.equals("subcompany")) { + String fieldValueID = rs.getString("subcompanyid"); + fieldValue = "1".equals(isShowFullPath) ? + SubCompanyComInfo.getSubcompanyRealPath(fieldValueID, "/", "0") : + subCompanyComInfo.getSubCompanyname(fieldValueID); + + //fieldValue = subCompanyComInfo.getSubCompanyname(fieldValueID); + + if (fieldValue.length() == 0) { + fieldValueID = resourceComInfo.getSubCompanyID(id); + + fieldValue = "1".equals(isShowFullPath) ? + SubCompanyComInfo.getSubcompanyRealPath(fieldValueID, "/", "0") : + subCompanyComInfo.getSubCompanyname(fieldValueID); + + // fieldValue = subCompanyComInfo.getSubCompanyname(fieldValueID); + } + data.put(fieldName + "Id", fieldValueID); + data.put(fieldName, fieldValue); + } else if (fieldName.equals("department")) { + String fieldValueID = rs.getString("departmentid"); + fieldValue = "1".equals(isShowFullPath) ? + departmentComInfo.getDepartmentRealPath(fieldValueID, "/", "0") : + departmentComInfo.getDepartmentname(fieldValueID); + //fieldValue = departmentComInfo.getDepartmentname(fieldValueID); + + if (fieldValue.length() == 0) { + fieldValueID = resourceComInfo.getDepartmentID(id); + + fieldValue = "1".equals(isShowFullPath) ? + departmentComInfo.getDepartmentRealPath(fieldValueID, "/", "0") : + departmentComInfo.getDepartmentname(fieldValueID); + + // fieldValue = departmentComInfo.getDepartmentname(fieldValueID); + } + data.put(fieldName + "Id", fieldValueID); + data.put(fieldName, fieldValue); + } else if (fieldName.equals("jobtitle")) { + String fieldValueID = rs.getString("jobtitle"); + fieldValue = jobTitlesComInfo.getJobTitlesname(rs.getString("jobtitle")); + if (fieldValue.length() == 0) { + fieldValueID = resourceComInfo.getJobTitle(id); + fieldValue = jobTitlesComInfo.getJobTitlesname(fieldValueID); + } + data.put(fieldName + "Id", fieldValueID); + data.put(fieldName, fieldValue); + } else if (kqReportFieldComInfo.getParentid().equals("overtime") || kqReportFieldComInfo.getParentid().equals("overtime_nonleave") + || kqReportFieldComInfo.getParentid().equals("overtime_4leave") || fieldName.equals("businessLeave") || fieldName.equals("officialBusiness")) { + if (fieldName.equals("overtimeTotal")) { + double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|workingDayOvertime_4leave"))); + workingDayOvertime_4leave = workingDayOvertime_4leave < 0 ? 0 : workingDayOvertime_4leave; + double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|restDayOvertime_4leave"))); + restDayOvertime_4leave = restDayOvertime_4leave < 0 ? 0 : restDayOvertime_4leave; + double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|holidayOvertime_4leave"))); + holidayOvertime_4leave = holidayOvertime_4leave < 0 ? 0 : holidayOvertime_4leave; + + double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|workingDayOvertime_nonleave"))); + workingDayOvertime_nonleave = workingDayOvertime_nonleave < 0 ? 0 : workingDayOvertime_nonleave; + double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|restDayOvertime_nonleave"))); + restDayOvertime_nonleave = restDayOvertime_nonleave < 0 ? 0 : restDayOvertime_nonleave; + double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|holidayOvertime_nonleave"))); + holidayOvertime_nonleave = holidayOvertime_nonleave < 0 ? 0 : holidayOvertime_nonleave; + + fieldValue = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_4leave + restDayOvertime_4leave + holidayOvertime_4leave + + workingDayOvertime_nonleave + restDayOvertime_nonleave + holidayOvertime_nonleave)); + } else { + fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|" + kqdate + "|" + fieldName))); + } + data.put(fieldName, fieldValue); + } else if (fieldName.equals("serialid")) { + fieldValue = Util.null2String(rs.getString(fieldName)); + if (fieldValue.length()>0) {//弹性工作制没有班次 +// data.put("serialid", shiftManagementToolKit.getShiftOnOffWorkSections(fieldValue, user.getLanguage())); + + if(null != serialdata && serialdata.containsKey(fieldValue)){ + data.put("serialid", serialdata.get(fieldValue)); + }else{ + String tmpserialname = shiftManagementToolKit.getShiftOnOffWorkSections(fieldValue, user.getLanguage()); + serialdata.put(fieldValue,tmpserialname); + data.put("serialid", tmpserialname); + } + } + }else if (fieldName.equals("reissuecard")) { + int reissueCard = Util.getIntValue(Util.null2String(flowData.get(id + "|" + kqdate + "|reissueCard" ))); + reissueCard = reissueCard < 0 ? 0 : reissueCard; + data.put(fieldName, reissueCard); + }else { + fieldValue = Util.null2String(rs.getString(fieldName)); + if (kqReportFieldComInfo.getUnittype().equals("2") && fieldValue.length() > 0) { + fieldValue = KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(fieldValue) / 60.0))); + } + data.put(fieldName, fieldValue); + } + } + data.putAll(this.getSignDetailInfo(id, kqdate)); + + //请假 + List> allLeaveRules = KQLeaveRulesBiz.getAllLeaveRules(); + Map leaveRule = null; + for (int i = 0; allLeaveRules != null && i < allLeaveRules.size(); i++) { + leaveRule = (Map) allLeaveRules.get(i); + String flowType = Util.null2String("leaveType_" + leaveRule.get("id")); + String leaveData = Util.null2String(flowData.get(id + "|" + kqdate + "|" + flowType)); + String flowLeaveBackType = Util.null2String("leavebackType_" + leaveRule.get("id")); + String leavebackData = Util.null2s(Util.null2String(flowData.get(id + "|" + kqdate + "|" + flowLeaveBackType)), "0.0"); + String b_flowLeaveData = ""; + String flowLeaveData = ""; + try { + //以防止出现精度问题 + if (leaveData.length() == 0) { + leaveData = "0.0"; + } + if (leavebackData.length() == 0) { + leavebackData = "0.0"; + } + BigDecimal b_leaveData = new BigDecimal(leaveData); + BigDecimal b_leavebackData = new BigDecimal(leavebackData); + b_flowLeaveData = b_leaveData.subtract(b_leavebackData).toString(); + if(Util.getDoubleValue(b_flowLeaveData, -1) < 0){ + b_flowLeaveData = "0.0"; + } + + } catch (Exception e) { + kqLog.info("GetKQReportCmd:leaveData" + leaveData + ":leavebackData:" + leavebackData + ":" + e); + } + + //考虑下冻结的数据 + if (b_flowLeaveData.length() > 0) { + flowLeaveData = KQDurationCalculatorUtil.getDurationRound(b_flowLeaveData); + } else { + flowLeaveData = KQDurationCalculatorUtil.getDurationRound(Util.null2String(Util.getDoubleValue(leaveData, 0.0) - Util.getDoubleValue(leavebackData, 0.0))); + } + data.put(flowType, flowLeaveData); + } + + data.put("resourceId", id); + data.put("kqdate", kqdate); + datas.add(data); + } + + List lsHolidays = KQHolidaySetBiz.getHolidaySetListByScope(""+user.getUID(),fromDate,toDate); + retmap.put("holidays", lsHolidays); + retmap.put("columns",columns); + retmap.put("datas",datas); + retmap.put("pagesize", pageSize); + retmap.put("pageindex", pageIndex); + retmap.put("count", count); + retmap.put("pagecount", pageCount); + retmap.put("ishavepre", isHavePre); + retmap.put("ishavenext", isHaveNext); + }catch (Exception e){ + writeLog(e); + } + return retmap; + } + + + private String getUnitType(String unitType, User user){ + String unitTypeName = ""; + if(Util.null2String(unitType).length()>0){ + if(unitType.equals("1")){ + unitTypeName=SystemEnv.getHtmlLabelName(1925, user.getLanguage()); + }else if(unitType.equals("2")){ + unitTypeName=SystemEnv.getHtmlLabelName(391, user.getLanguage()); + }else if(unitType.equals("3")){ + unitTypeName=SystemEnv.getHtmlLabelName(18083, user.getLanguage()); + } + } + return unitTypeName; + } + + private Map getChildColumnsInfo(String parentid, User user){ + Map returnMap = new HashMap<>(); + List lsChildColumns = new ArrayList<>(); + Map column = null; + int sumChildColumnWidth = 0; + if(parentid.equals("leave")){ + KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz(); + List> leaveRules = kqLeaveRulesBiz.getAllLeaveRules(); + for(int i=0;leaveRules!=null&&i leaveRule = leaveRules.get(i); + String id = "leaveType_"+Util.null2String(leaveRule.get("id")); + String name = Util.null2String(leaveRule.get("name")); + String unitType = Util.null2String(leaveRule.get("unitType")); + column = new HashMap(); + column.put("title", name); + column.put("unit", KQUnitBiz.isLeaveHour(unitType) ?SystemEnv.getHtmlLabelName(391, user.getLanguage()):SystemEnv.getHtmlLabelName(1925, user.getLanguage())); + column.put("width", 65); + column.put("dataIndex", id); + column.put("key", id); + column.put("rowSpan", 2); + column.put("colSpan", 1); + column.put("showDetial","1"); + sumChildColumnWidth+=65; + lsChildColumns.add(column); + } + }else if(parentid.equals("overtime")){ + String[] overtimeChild = {"overtime_nonleave","overtime_4leave","overtimeTotal"}; + for(int i=0;i0){ + if(unitType.equals("1")){ + unitTypeName=SystemEnv.getHtmlLabelName(1925, user.getLanguage()); + }else if(unitType.equals("2")){ + unitTypeName=SystemEnv.getHtmlLabelName(391, user.getLanguage()); + }else if(unitType.equals("3")){ + unitTypeName=SystemEnv.getHtmlLabelName(18083, user.getLanguage()); + } + } + column.put("unit", unitTypeName); + } + column.put("title", SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage())); + column.put("dataIndex", id); + column.put("key", id); + column.put("rowSpan", 1); + Map mapChildColumnInfo = getChildColumnsInfo(id, user); + int childWidth = 65; + List childColumns = (List)mapChildColumnInfo.get("childColumns"); + if(childColumns.size()>0) {//跨列width取子列的width + column.put("children", childColumns); + childWidth = Util.getIntValue(Util.null2String(mapChildColumnInfo.get("sumChildColumnWidth")),65); + } + column.put("width", childWidth+""); + sumChildColumnWidth+=childWidth; + lsChildColumns.add(column); + } + }else{ + KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo(); + while (kqReportFieldComInfo.next()){ + if(kqReportFieldComInfo.getParentid().equals(parentid)) { + if(!kqReportFieldComInfo.getReportType().equals("daily"))continue; + column = new HashMap(); + column.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage())); + column.put("unit", KQReportBiz.getUnitType(kqReportFieldComInfo, user)); + column.put("width", Util.getIntValue(kqReportFieldComInfo.getWidth())); + column.put("dataIndex", kqReportFieldComInfo.getFieldname()); + column.put("key", kqReportFieldComInfo.getFieldname()); + column.put("rowSpan", 2); + column.put("colSpan", 1); + column.put("isdaily", kqReportFieldComInfo.getReportType1().equals("daily")?"1":"0"); + sumChildColumnWidth+=Util.getIntValue(kqReportFieldComInfo.getWidth()); + lsChildColumns.add(column); + } + } + } + returnMap.put("childColumns",lsChildColumns); + returnMap.put("sumChildColumnWidth",sumChildColumnWidth); + return returnMap; + } + + public Map getSignDetailInfo(String resourceId, String kqDate){ + Map data = new HashMap<>(); + Map signStatusInfo = null; + RecordSet rs = new RecordSet(); + String sql = ""; + KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo(); + try{ + sql = " select kqdate,resourceid,serialid,serialnumber,workbegindate,workbegintime, " + + " workenddate,workendtime,workmins,signindate,signintime,signoutdate,signouttime, \n" + + " attendanceMins,belatemins,graveBeLateMins,leaveearlymins,graveLeaveEarlyMins,absenteeismmins,forgotcheckMins,forgotBeginWorkCheckMins," + + " leaveMins,leaveInfo,evectionMins,outMins,signinid,signoutid \n" + + " from kq_format_detail b \n" + + " where resourceid = " + resourceId + " and kqdate ='" + kqDate + "' \n" + + " order by serialnumber \n"; + rs.execute(sql); + while (rs.next()) { + String resourceid = Util.null2String(rs.getString("resourceid")); + String kqdate = Util.null2String(rs.getString("kqdate")); + String serialid = Util.null2String(rs.getString("serialid")); + int serialnumber = rs.getInt("serialnumber")+1; + String workbegindate = Util.null2String(rs.getString("workbegindate")).trim(); + String workbegintime = Util.null2String(rs.getString("workbegintime")).trim(); + String workenddate = Util.null2String(rs.getString("workenddate")).trim(); + String workendtime = Util.null2String(rs.getString("workendtime")).trim(); + int workMins = rs.getInt("workMins"); + String signintime = Util.null2String(rs.getString("signintime")).trim(); + String signouttime = Util.null2String(rs.getString("signouttime")).trim(); + int attendanceMins = rs.getInt("attendanceMins"); + String beLateMins = Util.null2String(rs.getString("beLateMins")).trim(); + String graveBeLateMins = Util.null2String(rs.getString("graveBeLateMins")).trim(); + String leaveEarlyMins= Util.null2String(rs.getString("leaveEarlyMins")).trim(); + String graveLeaveEarlyMins= Util.null2String(rs.getString("graveLeaveEarlyMins")).trim(); + String absenteeismMins= Util.null2String(rs.getString("absenteeismMins")).trim(); + String forgotCheckMins = Util.null2String(rs.getString("forgotcheckMins")).trim(); + String forgotBeginWorkCheckMins = Util.null2String(rs.getString("forgotBeginWorkCheckMins")).trim(); + String signinid = Util.null2String(rs.getString("signinid")).trim(); + String signoutid = Util.null2String(rs.getString("signoutid")).trim(); + int leaveMins = rs.getInt("leaveMins"); + String leaveInfo = Util.null2String(rs.getString("leaveInfo")); + int evectionMins = rs.getInt("evectionMins"); + int outMins = rs.getInt("outMins"); + + + if(serialid.length()>0){ + if (workbegintime.length() > 0) { + signStatusInfo = new HashMap(); + signStatusInfo.put("workdate",workbegindate); + signStatusInfo.put("worktime",workbegintime); + signStatusInfo.put("beLateMins",beLateMins); + signStatusInfo.put("forgotBeginWorkCheckMins",forgotBeginWorkCheckMins); + signStatusInfo.put("graveBeLateMins",graveBeLateMins); + signStatusInfo.put("absenteeismMins",absenteeismMins); + signStatusInfo.put("leaveMins",leaveMins); + signStatusInfo.put("leaveInfo",leaveInfo); + signStatusInfo.put("evectionMins",evectionMins); + signStatusInfo.put("outMins",outMins); + + data.put("signintime"+serialnumber, signintime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signintime); + data.put("signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on")); + } + + if (workendtime.length() > 0) { + signStatusInfo = new HashMap(); + signStatusInfo.put("workdate",workenddate); + signStatusInfo.put("worktime",kqTimesArrayComInfo.turn48to24Time(workendtime)); + signStatusInfo.put("leaveEarlyMins",leaveEarlyMins); + signStatusInfo.put("graveLeaveEarlyMins",graveLeaveEarlyMins); + signStatusInfo.put("forgotCheckMins",forgotCheckMins); + signStatusInfo.put("forgotBeginWorkCheckMins",forgotBeginWorkCheckMins); + signStatusInfo.put("absenteeismMins",absenteeismMins); + signStatusInfo.put("leaveMins",leaveMins); + signStatusInfo.put("leaveInfo",leaveInfo); + signStatusInfo.put("evectionMins",evectionMins); + signStatusInfo.put("outMins",outMins); + + data.put("signouttime"+serialnumber, signouttime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signouttime); + data.put("signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off")); + } + }else{ + if(workMins>0){ + //弹性工时打卡时间取自签到签退数据 + } + signStatusInfo = new HashMap(); + signStatusInfo.put("leaveMins",leaveMins); + signStatusInfo.put("leaveInfo",leaveInfo); + signStatusInfo.put("evectionMins",evectionMins); + signStatusInfo.put("outMins",outMins); + + if(signinid.length() > 0){ + data.put("signintime"+serialnumber, signintime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signintime); + data.put("signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on")); + if(signoutid.length() > 0){ + data.put("signouttime"+serialnumber, signouttime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signouttime); + data.put("signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off")); + } + }else{ + data.put("signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on")); + } + } + } + }catch (Exception e){ + writeLog(e); + } + return data; + } + + @Override + public BizLogContext getLogContext() { + return null; + } + +} diff --git a/src/com/engine/kq/cmd/report/GetKQReportCmd.java b/src/com/engine/kq/cmd/report/GetKQReportCmd.java new file mode 100644 index 0000000..03a2879 --- /dev/null +++ b/src/com/engine/kq/cmd/report/GetKQReportCmd.java @@ -0,0 +1,650 @@ +package com.engine.kq.cmd.report; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.engine.common.biz.AbstractCommonCommand; +import com.engine.common.entity.BizLogContext; +import com.engine.core.interceptor.CommandContext; +import com.engine.kq.biz.*; +import com.engine.kq.util.KQDurationCalculatorUtil; +import com.engine.kq.util.PageUidFactory; +import weaver.common.DateUtil; +import weaver.conn.RecordSet; +import weaver.general.TimeUtil; +import weaver.general.Util; +import weaver.hrm.User; +import weaver.hrm.company.DepartmentComInfo; +import weaver.hrm.company.SubCompanyComInfo; +import weaver.hrm.job.JobTitlesComInfo; +import weaver.hrm.resource.ResourceComInfo; +import weaver.systeminfo.SystemEnv; + +import java.math.BigDecimal; +import java.util.*; + +public class GetKQReportCmd extends AbstractCommonCommand> { + + public GetKQReportCmd(Map params, User user) { + this.user = user; + this.params = params; + } + + @Override + public Map execute(CommandContext commandContext) { + Map retmap = new HashMap(); + RecordSet rs = new RecordSet(); + String sql = ""; + try{ + String pageUid = PageUidFactory.getHrmPageUid("KQReport"); + + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + DepartmentComInfo departmentComInfo = new DepartmentComInfo(); + ResourceComInfo resourceComInfo = new ResourceComInfo(); + JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo(); + KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz(); + KQReportBiz kqReportBiz = new KQReportBiz(); + + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + String attendanceSerial = Util.null2String(jsonObj.get("attendanceSerial")); + String fromDate = Util.null2String(jsonObj.get("fromDate")); + String toDate = Util.null2String(jsonObj.get("toDate")); + String typeselect =Util.null2String(jsonObj.get("typeselect")); + if(typeselect.length()==0)typeselect = "3"; + if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){ + if(typeselect.equals("1")){ + fromDate = TimeUtil.getCurrentDateString(); + toDate = TimeUtil.getCurrentDateString(); + }else{ + fromDate = TimeUtil.getDateByOption(typeselect,"0"); + toDate = TimeUtil.getDateByOption(typeselect,"1"); + } + } + //人员状态 + String status = Util.null2String(jsonObj.get("status")); + String subCompanyId = Util.null2String(jsonObj.get("subCompanyId")); + String departmentId = Util.null2String(jsonObj.get("departmentId")); + String resourceId = Util.null2String(jsonObj.get("resourceId")); + String allLevel = Util.null2String(jsonObj.get("allLevel")); + String isNoAccount = Util.null2String(jsonObj.get("isNoAccount")); + String viewScope = Util.null2String(jsonObj.get("viewScope")); + String isFromMyAttendance = Util.null2String(jsonObj.get("isFromMyAttendance"));//是否是来自我的考勤的请求,如果是,不加载考勤报表权限共享的限制,不然我的考勤会提示无权限 + int pageIndex = Util.getIntValue(Util.null2String(jsonObj.get("pageIndex")), 1); + int pageSize = KQReportBiz.getPageSize(Util.null2String(jsonObj.get("pageSize")),pageUid,user.getUID()); + int count = 0; + int pageCount = 0; + int isHavePre = 0; + int isHaveNext = 0; + + + String rightSql = kqReportBiz.getReportRight("1",""+user.getUID(),"a"); + if(isFromMyAttendance.equals("1")){ + rightSql = ""; + } + + List> leaveRules = kqLeaveRulesBiz.getAllLeaveRules(); + List columns = new ArrayList(); + Map column = null; + List datas = new ArrayList(); + Map data = null; + Map mapChildColumnInfo = null; + List childColumns = null; + KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo(); + while (kqReportFieldComInfo.next()){ + if(Util.null2String(kqReportFieldComInfo.getParentid()).length()>0)continue; + if(kqReportFieldComInfo.getFieldname().equals("kqCalendar"))continue; + if(KQReportFieldComInfo.cascadekey2fieldname.keySet().contains(kqReportFieldComInfo.getFieldname()))continue; + if(!kqReportFieldComInfo.getReportType().equals("all") && !kqReportFieldComInfo.getReportType().equals("month"))continue; + if("leave".equalsIgnoreCase(kqReportFieldComInfo.getFieldname())&&leaveRules.size()==0)continue; + + column = new HashMap(); + column.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage())); + column.put("unit", KQReportBiz.getUnitType(kqReportFieldComInfo, user)); + column.put("dataIndex", kqReportFieldComInfo.getFieldname()); + column.put("type", kqReportFieldComInfo.getFieldname()); + column.put("key", kqReportFieldComInfo.getFieldname()); + column.put("isSystem", kqReportFieldComInfo.getIsSystem()); + mapChildColumnInfo = this.getChildColumnsInfo(kqReportFieldComInfo.getFieldname(),user); + childColumns = (List)mapChildColumnInfo.get("childColumns"); + if(childColumns.size()>0) {//跨列width取子列的width + column.put("rowSpan", 1); + column.put("width", mapChildColumnInfo.get("sumChildColumnWidth")); + column.put("children", childColumns); + }else{ + column.put("rowSpan", 3); + column.put("width", Util.getIntValue(kqReportFieldComInfo.getWidth())); + } + column.put("showDetial",kqReportFieldComInfo.getShowDetial()); + columns.add(column); + columns.addAll(this.getCascadeKeyColumnsInfo(kqReportFieldComInfo.getCascadekey(),user)); + } + + boolean isEnd = false; + Calendar cal = DateUtil.getCalendar(); + String today = DateUtil.getCurrentDate(); +// if(DateUtil.compDate(today, toDate)>0){//结束日期不大于今天 +// toDate = today; +// if(DateUtil.compDate(today, fromDate)>0){//结束日期不大于今天 +// fromDate = today; +// } +// } + + childColumns = new ArrayList<>(); + for(String date=fromDate; !isEnd;) { + if(date.equals(toDate)) isEnd = true; + column = new HashMap(); + column.put("title", DateUtil.geDayOfMonth(date)); + column.put("dataIndex", date); + column.put("key", date); + column.put("type", date); + column.put("rowSpan", 1); + column.put("width", 90); + column.put("isCalendar", 1); + childColumns.add(column); + cal.setTime(DateUtil.parseToDate(date)); + date = DateUtil.getDate(cal.getTime(), 1); + } + + column = new HashMap(); + column.put("title", SystemEnv.getHtmlLabelName(386476, user.getLanguage())); + column.put("dataIndex", "kqCalendar"); + column.put("key", "kqCalendar"); + if(childColumns.size()>0) {//跨列width取子列的width + column.put("rowSpan", 1); + column.put("width", childColumns.size()*90); + column.put("children", childColumns); + } + columns.add(column); + + String forgotBeginWorkCheck_field = " sum(b.forgotBeginWorkCheck) "; + + if(rs.getDBType().equalsIgnoreCase("oracle")) { + forgotBeginWorkCheck_field = " sum(nvl(b.forgotBeginWorkCheck,0)) "; + }else if((rs.getDBType()).equalsIgnoreCase("mysql")){ + forgotBeginWorkCheck_field = " sum(ifnull(b.forgotBeginWorkCheck,0)) "; + }else { + forgotBeginWorkCheck_field = " sum(isnull(b.forgotBeginWorkCheck,0)) "; + } + + Map definedFieldInfo = new KQFormatBiz().getDefinedField(); + String definedFieldSum = Util.null2String(definedFieldInfo.get("definedFieldSum")); + + String backFields = " a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1 as subcompanyid,a.departmentid,a.jobtitle," + + " sum(b.workdays) as workdays,sum(b.workMins) as workMins,sum(b.attendancedays) as attendancedays," + + " sum(b.attendanceMins) as attendanceMins,sum(b.beLate) as beLate,sum(b.beLateMins) as beLateMins, " + + " sum(b.graveBeLate) as graveBeLate, sum(b.graveBeLateMins) as graveBeLateMins,sum(b.leaveEearly) as leaveEearly," + + " sum(b.leaveEarlyMins) as leaveEarlyMins, sum(b.graveLeaveEarly) as graveLeaveEarly, " + + " sum(b.graveLeaveEarlyMins) as graveLeaveEarlyMins,sum(b.absenteeism) as absenteeism, " + + " sum(b.signdays) as signdays,sum(b.signmins) as signmins, "+ + " sum(b.absenteeismMins) as absenteeismMins, sum(b.forgotCheck)+"+forgotBeginWorkCheck_field+" as forgotCheck "+(definedFieldSum.length()>0?","+definedFieldSum+"":""); + + if(rs.getDBType().equals("oracle")){ + backFields = "/*+ index(kq_format_total IDX_KQ_FORMAT_TOTAL_KQDATE) */ "+backFields; + } + String sqlFrom = " from hrmresource a, kq_format_total b where a.id= b.resourceid and b.kqdate >='"+fromDate+"' and b.kqdate <='"+toDate+"'"; + String sqlWhere = rightSql; + String groupBy = " group by a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1,a.departmentid,a.jobtitle "; + if(subCompanyId.length()>0){ + sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") "; + } + + if(departmentId.length()>0){ + sqlWhere +=" and a.departmentid in("+departmentId+") "; + } + + if(resourceId.length()>0){ + sqlWhere +=" and a.id in("+resourceId+") "; + } + + if(viewScope.equals("4")){//我的下属 + if(allLevel.equals("1")){//所有下属 + sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'"; + }else{ + sqlWhere+=" and a.managerid="+user.getUID();//直接下属 + } + } + if (!"1".equals(isNoAccount)) { + sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' "); + } + + if(status.length()>0){ + if (!status.equals("8") && !status.equals("9")) { + sqlWhere += " and a.status = "+status+ ""; + }else if (status.equals("8")) { + sqlWhere += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) "; + } + } + + sql = " select count(*) as c from ( select 1 as c "+sqlFrom+sqlWhere+groupBy+") t"; + rs.execute(sql); + if (rs.next()){ + count = rs.getInt("c"); + } + + if (count <= 0) { + pageCount = 0; + } + + pageCount = count / pageSize + ((count % pageSize > 0) ? 1 : 0); + + isHaveNext = (pageIndex + 1 <= pageCount) ? 1 : 0; + + isHavePre = (pageIndex - 1 >= 1) ? 1 : 0; + + String orderBy = " order by t.dsporder asc, t.lastname asc "; + String descOrderBy = " order by t.dsporder desc, t.lastname desc "; + + //默认排序设置 start,有性能问题,先取消,后面再看看有没有好的方式 +// String orderBySql = "select * from kq_report_order where userId=? and sort=1 order by orders"; +// rs.executeQuery(orderBySql, user.getUID()); +// if (rs.getCounts() <= 0) { +// orderBySql = "select * from kq_report_order where userId=0 and sort=1 order by orders"; +// rs.executeQuery(orderBySql); +// } +// while (rs.next()) { +// String dataIndex = rs.getString("dataIndex"); +// String ascOrDesc = rs.getString("ascOrDesc"); +// String ascOrDesc1 = (ascOrDesc.equals("")||ascOrDesc.equals("asc"))?"desc":"asc"; +// if (dataIndex.equals("organization")) { +// orderBy += ",showOrderOfDeptTree " + ascOrDesc + ",dept_id " + ascOrDesc; +// descOrderBy += ",showOrderOfDeptTree " + ascOrDesc1 + ",dept_id " + ascOrDesc1; +// } +// if (dataIndex.equalsIgnoreCase("dspOrder") || dataIndex.equalsIgnoreCase("lastName")) { +// orderBy += "," + dataIndex + " " + ascOrDesc + ",id " + ascOrDesc; +// descOrderBy += "," + dataIndex + " " + ascOrDesc1 + ",id " + ascOrDesc1; +// } else if (dataIndex.equalsIgnoreCase("deptShowOrder") || dataIndex.equalsIgnoreCase("deptName")) { +// orderBy += "," + dataIndex + " " + ascOrDesc + ",dept_id " + ascOrDesc; +// descOrderBy += "," + dataIndex + " " + ascOrDesc1 + ",dept_id " + ascOrDesc1; +// } else if (dataIndex.equalsIgnoreCase("subcomShowOrder") || dataIndex.equalsIgnoreCase("subcomName")) { +// orderBy += "," + dataIndex + " " + ascOrDesc + ",subcom_id " + ascOrDesc; +// descOrderBy += "," + dataIndex + " " + ascOrDesc1 + ",subcom_id " + ascOrDesc1; +// } +// } +// orderBy = orderBy.startsWith(",") ? orderBy.substring(1) : orderBy; +// descOrderBy = descOrderBy.startsWith(",") ? descOrderBy.substring(1) : descOrderBy; +// orderBy = orderBy.equals("") ? " t.dspOrder,t.id " : orderBy; +// descOrderBy = descOrderBy.equals("") ? " t.dspOrder,t.id " : descOrderBy; +// orderBy = "order by "+orderBy; + + sql = backFields + sqlFrom + sqlWhere + groupBy; + + if (pageIndex > 0 && pageSize > 0) { + if (rs.getDBType().equals("oracle")) { + sql = " select * from (select " + sql+") t "+orderBy; + sql = "select * from ( select row_.*, rownum rownum_ from ( " + sql + " ) row_ where rownum <= " + + (pageIndex * pageSize) + ") where rownum_ > " + ((pageIndex - 1) * pageSize); + } else if (rs.getDBType().equals("mysql")) { + sql = " select * from (select " + sql+") t "+orderBy; + sql = "select t1.* from (" + sql + ") t1 limit " + ((pageIndex - 1) * pageSize) + "," + pageSize; + } + else if (rs.getDBType().equals("postgresql")) { + sql = " select * from (select " + sql+") t "+orderBy; + sql = "select t1.* from (" + sql + ") t1 limit " +pageSize + " offset " + ((pageIndex - 1) * pageSize); + } + else { + orderBy = " order by dsporder asc, lastname asc "; + descOrderBy = " order by dsporder desc, lastname desc "; + if (pageIndex > 1) { + int topSize = pageSize; + if (pageSize * pageIndex > count) { + topSize = count - (pageSize * (pageIndex - 1)); + } + sql = " select top " + topSize + " * from ( select top " + topSize + " * from ( select top " + + (pageIndex * pageSize) + sql + orderBy+ " ) tbltemp1 " + descOrderBy + ") tbltemp2 " + orderBy; + } else { + sql = " select top " + pageSize + sql+orderBy; + } + } + } else { + sql = " select " + sql; + } + + + // #1475814-概述:满足考勤报分部部门显示及导出时显示全路径 + String fullPathMainKey = "show_full_path"; + KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo(); + String isShowFullPath = Util.null2String(kqSettingsComInfo.getMain_val(fullPathMainKey),"0"); + + String show_card_source = Util.null2String(kqSettingsComInfo.getMain_val("show_card_source"),"0");//是否显示打卡数据,以及打卡数据来源 + params.put("show_card_source",show_card_source); + KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz(); + int uintType = kqOvertimeRulesBiz.getMinimumUnit();//当前加班单位 + double hoursToDay = kqOvertimeRulesBiz.getHoursToDay();//当前天跟小时计算关系 + params.put("uintType",uintType); + params.put("hoursToDay",hoursToDay); + Map flowData = kqReportBiz.getFlowData(params,user); + + + rs.execute(sql); + while (rs.next()) { + data = new HashMap<>(); + kqReportFieldComInfo.setTofirstRow(); + String id = rs.getString("id"); + data.put("resourceId",id); + while (kqReportFieldComInfo.next()){ + if(!Util.null2String(kqReportFieldComInfo.getIsdataColumn()).equals("1"))continue; + if(!kqReportFieldComInfo.getReportType().equals("all") && !kqReportFieldComInfo.getReportType().equals("month"))continue; + if("leave".equalsIgnoreCase(kqReportFieldComInfo.getFieldname())&&leaveRules.size()==0){ + continue; + } + String fieldName = kqReportFieldComInfo.getFieldname(); + String fieldValue = ""; + if(fieldName.equals("subcompany")){ + String tmpSubcompanyId = Util.null2String(rs.getString("subcompanyid")); + if(tmpSubcompanyId.length()==0){ + tmpSubcompanyId = Util.null2String(resourceComInfo.getSubCompanyID(id)); + } + data.put("subcompanyId",tmpSubcompanyId); + + fieldValue = "1".equals(isShowFullPath) ? + SubCompanyComInfo.getSubcompanyRealPath(tmpSubcompanyId, "/", "0") : + subCompanyComInfo.getSubCompanyname(tmpSubcompanyId); + + // fieldValue = subCompanyComInfo.getSubCompanyname(tmpSubcompanyId); + }else if(fieldName.equals("department")){ + String tmpDepartmentId = Util.null2String(rs.getString("departmentid")); + if(tmpDepartmentId.length()==0){ + tmpDepartmentId = Util.null2String(resourceComInfo.getDepartmentID(id)); + } + data.put("departmentId",tmpDepartmentId); + + fieldValue = "1".equals(isShowFullPath) ? + departmentComInfo.getDepartmentRealPath(tmpDepartmentId, "/", "0") : + departmentComInfo.getDepartmentname(tmpDepartmentId); + + // fieldValue = departmentComInfo.getDepartmentname(tmpDepartmentId); + }else if(fieldName.equals("jobtitle")){ + String tmpJobtitleId = Util.null2String(rs.getString("jobtitle")); + if(tmpJobtitleId.length()==0){ + tmpJobtitleId = Util.null2String(resourceComInfo.getJobTitle(id)); + } + data.put("jobtitleId",tmpJobtitleId); + fieldValue = jobTitlesComInfo.getJobTitlesname(tmpJobtitleId); + }else if(fieldName.equals("attendanceSerial")){ + List serialIds = null; + if(attendanceSerial.length()>0){ + serialIds = Util.splitString2List(attendanceSerial,","); + } + for(int i=0;serialIds!=null&&i0) { + if(fieldValue.length() == 0){ + fieldValue="0"; + }else{ + if (kqReportFieldComInfo.getUnittype().equals("2")) { + fieldValue = KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(fieldValue) / 60.0))); + } + } + } + } + data.put(fieldName,fieldValue); + } + + //请假 + List> allLeaveRules = kqLeaveRulesBiz.getAllLeaveRules(); + Map leaveRule = null; + for(int i=0;allLeaveRules!=null&&i)allLeaveRules.get(i); + String flowType = Util.null2String("leaveType_"+leaveRule.get("id")); + String leaveData = Util.null2String(flowData.get(id+"|"+flowType)); + String flowLeaveBackType = Util.null2String("leavebackType_"+leaveRule.get("id")); + String leavebackData = Util.null2s(Util.null2String(flowData.get(id+"|"+flowLeaveBackType)),"0.0"); + String b_flowLeaveData = ""; + String flowLeaveData = ""; + try{ + //以防止出现精度问题 + if(leaveData.length() == 0){ + leaveData = "0.0"; + } + if(leavebackData.length() == 0){ + leavebackData = "0.0"; + } + BigDecimal b_leaveData = new BigDecimal(leaveData); + BigDecimal b_leavebackData = new BigDecimal(leavebackData); + b_flowLeaveData = b_leaveData.subtract(b_leavebackData).toString(); + if(Util.getDoubleValue(b_flowLeaveData, -1) < 0){ + b_flowLeaveData = "0.0"; + } + }catch (Exception e){ + writeLog("GetKQReportCmd:leaveData"+leaveData+":leavebackData:"+leavebackData+":"+e); + } + + //考虑下冻结的数据 + if(b_flowLeaveData.length() > 0){ + flowLeaveData = KQDurationCalculatorUtil.getDurationRound(b_flowLeaveData); + }else{ + flowLeaveData = KQDurationCalculatorUtil.getDurationRound(Util.null2String(Util.getDoubleValue(leaveData,0.0)-Util.getDoubleValue(leavebackData,0.0))); + } + data.put(flowType,flowLeaveData); + } + + Map detialDatas = kqReportBiz.getDetialDatas(id,fromDate,toDate,user,flowData,false,uintType,show_card_source); +// new KQLog().info("id:"+id+":detialDatas:"+detialDatas); + isEnd = false; + for(String date=fromDate; !isEnd;) { + if(date.equals(toDate)) isEnd = true; + if(DateUtil.compDate(today, date)>0){ + data.put(date,""); + }else{ +// new KQLog().info("id:date:"+(id+"|"+date)+":detialDatas.get:"+detialDatas.get(id+"|"+date)); + data.put(date,detialDatas.get(id+"|"+date)==null?SystemEnv.getHtmlLabelName(26593, user.getLanguage()):detialDatas.get(id+"|"+date)); + } + cal.setTime(DateUtil.parseToDate(date)); + date = DateUtil.getDate(cal.getTime(), 1); + } + datas.add(data); + } + + List lsHolidays = KQHolidaySetBiz.getHolidaySetListByScope(""+user.getUID(),fromDate,toDate); + retmap.put("holidays", lsHolidays); + + retmap.put("columns",columns); + retmap.put("datas",datas); + retmap.put("pagesize", pageSize); + retmap.put("pageindex", pageIndex); + retmap.put("count", count); + retmap.put("pagecount", pageCount); + retmap.put("ishavepre", isHavePre); + retmap.put("ishavenext", isHaveNext); + }catch (Exception e){ + writeLog(e); + } + return retmap; + } + + private Map getChildColumnsInfo(String parentid, User user){ + Map returnMap = new HashMap<>(); + List lsChildColumns = new ArrayList<>(); + Map column = null; + int sumChildColumnWidth = 0; + if(parentid.equals("attendanceSerial")){//考勤班次 + KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo(); + JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data"))); + List serialIds = null; + if(Util.null2String(jsonObj.get("attendanceSerial")).length()>0){ + serialIds = Util.splitString2List(Util.null2String(jsonObj.get("attendanceSerial")),","); + } + for(int i=0;serialIds!=null&&i> leaveRules = kqLeaveRulesBiz.getAllLeaveRules(); + for(int i=0;leaveRules!=null&&i leaveRule = leaveRules.get(i); + String id = "leaveType_"+Util.null2String(leaveRule.get("id")); + String name = Util.null2String(leaveRule.get("name")); + String unitType = Util.null2String(leaveRule.get("unitType")); + column = new HashMap(); + column.put("title", name); + column.put("unit", KQUnitBiz.isLeaveHour(unitType) ?SystemEnv.getHtmlLabelName(391, user.getLanguage()):SystemEnv.getHtmlLabelName(1925, user.getLanguage())); + column.put("width", 65); + column.put("dataIndex", id); + column.put("key", id); + column.put("rowSpan", 2); + column.put("colSpan", 1); + column.put("showDetial","1"); + sumChildColumnWidth+=65; + lsChildColumns.add(column); + } + }else if(parentid.equals("overtime")){ + String[] overtimeChild = {"overtime_nonleave","overtime_4leave","overtimeTotal"}; + for(int i=0;i0){ + if(unitType.equals("1")){ + unitTypeName=SystemEnv.getHtmlLabelName(1925, user.getLanguage()); + }else if(unitType.equals("2")){ + unitTypeName=SystemEnv.getHtmlLabelName(391, user.getLanguage()); + }else if(unitType.equals("3")){ + unitTypeName=SystemEnv.getHtmlLabelName(18083, user.getLanguage()); + } + } + column.put("unit", unitTypeName); + } + column.put("title", SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage())); + column.put("dataIndex", id); + column.put("key", id); + column.put("rowSpan", 1); + Map mapChildColumnInfo = getChildColumnsInfo(id, user); + int childWidth = 65; + List childColumns = (List)mapChildColumnInfo.get("childColumns"); + if(childColumns.size()>0) {//跨列width取子列的width + column.put("children", childColumns); + childWidth = Util.getIntValue(Util.null2String(mapChildColumnInfo.get("sumChildColumnWidth")),65); + } + column.put("width", childWidth+""); + sumChildColumnWidth+=childWidth; + lsChildColumns.add(column); + } + }else{ + KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo(); + while (kqReportFieldComInfo.next()){ + if(kqReportFieldComInfo.getParentid().equals(parentid)) { + if(!kqReportFieldComInfo.getReportType().equals("month"))continue; + column = new HashMap(); + column.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage())); + column.put("unit", KQReportBiz.getUnitType(kqReportFieldComInfo, user)); + column.put("width", Util.getIntValue(kqReportFieldComInfo.getWidth())); + column.put("dataIndex", kqReportFieldComInfo.getFieldname()); + column.put("key", kqReportFieldComInfo.getFieldname()); + column.put("rowSpan", 1); + column.put("colSpan", 1); + column.put("showDetial",kqReportFieldComInfo.getShowDetial()); + sumChildColumnWidth+=Util.getIntValue(kqReportFieldComInfo.getWidth()); + lsChildColumns.add(column); + } + } + } + returnMap.put("childColumns",lsChildColumns); + returnMap.put("sumChildColumnWidth",sumChildColumnWidth); + return returnMap; + } + + private List getCascadeKeyColumnsInfo(String cascadeKey, User user){ + List lsChildColumns = new ArrayList<>(); + if(Util.null2String(cascadeKey).length()==0){ + return lsChildColumns; + } + Map column = null; + List lsCascadeKey = Util.splitString2List(cascadeKey,","); + KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo(); + for(int i=0;i params = ParamUtil.request2Map(request); + Map resultDatas = getEntryService(user).grantNumber(params); + return new Gson().toJson(resultDatas); + } + } diff --git a/src/com/engine/sskj/service/EntryService.java b/src/com/engine/sskj/service/EntryService.java index e5de4f2..b3bca24 100644 --- a/src/com/engine/sskj/service/EntryService.java +++ b/src/com/engine/sskj/service/EntryService.java @@ -13,4 +13,9 @@ public interface EntryService { */ Map checkEntryStatus(Map params); + /** + * 检查入职办理时选中的人员是否待入职状态 + */ + Map grantNumber(Map params); + } diff --git a/src/com/engine/sskj/service/impl/EntryServiceImpl.java b/src/com/engine/sskj/service/impl/EntryServiceImpl.java index 481f9f5..8aa4bed 100644 --- a/src/com/engine/sskj/service/impl/EntryServiceImpl.java +++ b/src/com/engine/sskj/service/impl/EntryServiceImpl.java @@ -1,17 +1,19 @@ package com.engine.sskj.service.impl; +import cn.hutool.core.date.DateUtil; import com.engine.core.impl.Service; import com.engine.sskj.service.EntryService; +import com.engine.sskj.util.SskjUtil; import org.apache.commons.lang.StringUtils; import weaver.conn.RecordSet; +import weaver.general.BaseBean; import weaver.general.Util; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; public class EntryServiceImpl extends Service implements EntryService { + + BaseBean basebean = new BaseBean(); @Override public Map checkBlackList(Map params) { Map result = new HashMap<>(); @@ -30,7 +32,7 @@ public class EntryServiceImpl extends Service implements EntryService { String[] idNumbersArr = idNumbers.split(","); for (String idNumber:idNumbersArr) { Integer number = -1; - String checkSql = "select count(*) as number from uf_entryblacklist where sfzh = ? "; + String checkSql = "select count(*) as number from uf_hmd where sfzh = ? "; rs.executeQuery(checkSql,idNumber); while (rs.next()) { number = Util.getIntValue(Util.null2String(rs.getString("number"))); @@ -94,4 +96,156 @@ public class EntryServiceImpl extends Service implements EntryService { result.put("msg","均可办理入职"); return result; } + + @Override + public Map grantNumber(Map params) { + + Map result = new HashMap<>(); + RecordSet rs = new RecordSet(); + + String serviceCompany = Util.null2String(params.get("serviceCompany")); + String entryType = Util.null2String(params.get("entryType")); + + if ( StringUtils.isEmpty(entryType)) { + result.put("code",500); + result.put("msg","入职类型未确认,不可分发编号"); + return result; + } + + if ( "6".equals(entryType) && StringUtils.isEmpty(serviceCompany)) { + result.put("code",500); + result.put("msg","请先选择劳务公司"); + return result; + } + + if ( "6".equals(entryType)) {//劳务外包 + //获取劳务公司代码 + String compCode = ""; + String acqOutCompSql = "select gsdm from uf_lwgs where id = ? "; + rs.executeQuery(acqOutCompSql, serviceCompany); + while (rs.next()) { + compCode = Util.null2String(rs.getString("gsdm")); + if ( StringUtils.isBlank(compCode)) { + result.put("code",500); + result.put("msg","请先维护劳务公司代码"); + return result; + } + } + //获取该劳务公司最大流水号 + String maxNum = ""; + String entryMonth = DateUtil.format(new Date(),"yyyyMM"); + String acqMaxNumSql = "select maxNum from uf_OutEmpNum where outComp = ? and entryDate = ?"; + rs.executeQuery(acqMaxNumSql, serviceCompany, entryMonth); + while (rs.next()) { + maxNum = Util.null2String( rs.getString("maxNum")); + } + if ( StringUtils.isBlank(maxNum)) {//该公司该月没有生成最大流程号 + SskjUtil sskjUtil =new SskjUtil(); + maxNum = "001"; + String addMaxNumSql = "insert into uf_OutEmpNum ( outComp, entryDate, maxNum, formmodeid, modedatacreater, modedatacreatertype, modedatacreatedate, modedatacreatetime, MODEUUID)" + + " values (?,?,?,?,?,?,?,?,?)"; + String outEmpNumModeId = basebean.getPropValue("project_sskj", "outEmpNumModeId"); + Integer modedatacreater = user.getUID(); + Integer modedatacreatertype = user.getType(); + String modedatacreatedate = DateUtil.format(new Date(), "yyyy-MM-dd"); + String modedatacreatetime = DateUtil.format(new Date(), "HH:mm:ss"); + String uuid = UUID.randomUUID().toString(); + + boolean addFlag = rs.executeUpdate(addMaxNumSql, serviceCompany, entryMonth, maxNum, outEmpNumModeId, modedatacreater, modedatacreatertype, modedatacreatedate, + modedatacreatetime, uuid); + if (addFlag) { + String billid = "-1"; + String acqModeIdSql = "select id from uf_OutEmpNum where MODEUUID = ?"; + rs.executeQuery(acqModeIdSql, uuid); + while (rs.next()) { + billid = Util.null2String(rs.getString("id")); + } + sskjUtil.modePerRecon(modedatacreater, outEmpNumModeId, billid); + } + result.put("code",200); + result.put("data",compCode + entryMonth + maxNum); + return result; + } else { + Integer maxNumInt = Integer.valueOf(maxNum); + maxNumInt = maxNumInt + 1; + maxNum = String.valueOf(maxNumInt); + if (maxNum.length() == 1 ) { + maxNum = "00" + maxNum; + } + if (maxNum.length() == 2 ) { + maxNum = "0" + maxNum; + } + String modMaxNumSql = "update uf_OutEmpNum set maxNum = ? where outComp = ? and entryDate = ?"; + rs.executeUpdate(modMaxNumSql, maxNum, serviceCompany, entryMonth); + result.put("code",200); + result.put("data",compCode + entryMonth + maxNum); + return result; + } + + } else {//非劳务外包 + //获取最大流水号 + String maxNum = ""; + String entryMonth = DateUtil.format(new Date(),"yyyyMM"); + String acqMaxNumSql = "select maxNum from uf_NoOutEmpNum where entryDate = ?"; + rs.executeQuery(acqMaxNumSql, entryMonth); + while (rs.next()) { + maxNum = Util.null2String( rs.getString("maxNum")); + } + basebean.writeLog("maxNum:" + maxNum); + if ( StringUtils.isBlank(maxNum)) {//该月没有生成最大流程号 + SskjUtil sskjUtil =new SskjUtil(); + maxNum = "001"; + basebean.writeLog("非外包,没有流水"); + basebean.writeLog("maxNum:" + maxNum); + + String addMaxNumSql = "insert into uf_NoOutEmpNum ( entryDate, maxNum, formmodeid, modedatacreater, modedatacreatertype, modedatacreatedate, modedatacreatetime, MODEUUID)" + + " values (?,?,?,?,?,?,?,?,?)"; + String noOutEmpNumModeId = basebean.getPropValue("project_sskj", "noOutEmpNumModeId"); + Integer modedatacreater = user.getUID(); + Integer modedatacreatertype = user.getType(); + String modedatacreatedate = DateUtil.format(new Date(), "yyyy-MM-dd"); + String modedatacreatetime = DateUtil.format(new Date(), "HH:mm:ss"); + String uuid = UUID.randomUUID().toString(); + basebean.writeLog("addMaxNumSql:" + addMaxNumSql); + + boolean addFlag = rs.executeUpdate(addMaxNumSql, entryMonth, maxNum, noOutEmpNumModeId, modedatacreater, modedatacreatertype, modedatacreatedate, + modedatacreatetime, uuid); + basebean.writeLog("addFlag:" + addFlag); + if (addFlag) { + String billid = "-1"; + String acqModeIdSql = "select id from uf_NoOutEmpNum where MODEUUID = ?"; + rs.executeQuery(acqModeIdSql, uuid); + while (rs.next()) { + billid = Util.null2String(rs.getString("id")); + } + basebean.writeLog("billid:" + billid); + sskjUtil.modePerRecon(modedatacreater, noOutEmpNumModeId, billid); + } + result.put("code",200); + result.put("data","SSKJ" + entryMonth + maxNum); + return result; + } else { + Integer maxNumInt = Integer.valueOf(maxNum); + basebean.writeLog("maxNumInt:" + maxNumInt); + maxNumInt = maxNumInt + 1; + basebean.writeLog("maxNumInt:" + maxNumInt); + maxNum = String.valueOf(maxNumInt); + basebean.writeLog("maxNum:" + maxNum); + if (maxNum.length() == 1 ) { + maxNum = "00" + maxNum; + } + if (maxNum.length() == 2 ) { + maxNum = "0" + maxNum; + } + basebean.writeLog("非外包,已有流水"); + basebean.writeLog("maxNum:" + maxNum); + String modMaxNumSql = "update uf_NoOutEmpNum set maxNum = ? where entryDate = ?"; + boolean b = rs.executeUpdate(modMaxNumSql, maxNum, entryMonth); + basebean.writeLog("b:" + b); + result.put("code",200); + result.put("data","SSKJ" + entryMonth + maxNum); + return result; + } + } + } } diff --git a/src/com/engine/sskj/util/SskjUtil.java b/src/com/engine/sskj/util/SskjUtil.java new file mode 100644 index 0000000..4fc547b --- /dev/null +++ b/src/com/engine/sskj/util/SskjUtil.java @@ -0,0 +1,24 @@ +package com.engine.sskj.util; + +import weaver.formmode.setup.ModeRightInfo; + +/** + * @author chenwnj + * @date 2023/10/20 + * @description + **/ +public class SskjUtil { + + /** + * 建模权限重构 + * @param userId + * @param jobGroupDesModeId + * @param billid + */ + public void modePerRecon(Integer userId, String jobGroupDesModeId, String billid) { + ModeRightInfo ModeRightInfo = new ModeRightInfo(); + ModeRightInfo.setNewRight(true); + ModeRightInfo.editModeDataShare( userId, Integer.parseInt(jobGroupDesModeId), Integer.parseInt(billid)); + } + +} diff --git a/src/weaver/interfaces/sskj/job/SyncZkKqDataJob.java b/src/weaver/interfaces/sskj/job/SyncZkKqDataJob.java new file mode 100644 index 0000000..3a7a583 --- /dev/null +++ b/src/weaver/interfaces/sskj/job/SyncZkKqDataJob.java @@ -0,0 +1,201 @@ +package weaver.interfaces.sskj.job; + +import cn.hutool.core.date.DateUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.engine.kq.biz.KQFormatBiz; +import com.engine.kq.timer.KQQueue; +import com.engine.kq.timer.KQTaskBean; +import com.engine.kq.wfset.util.SplitActionUtil; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.jayway.jsonpath.Configuration; +import com.jayway.jsonpath.JsonPath; +import org.apache.commons.lang3.StringUtils; +import weaver.conn.BatchRecordSet; +import weaver.conn.RecordSet; +import weaver.general.BaseBean; +import weaver.general.Util; +import weaver.interfaces.schedule.BaseCronJob; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.*; + +import static weaver.interfaces.sskj.util.HttpsUtil.doPostJsonRequest; + + +/** + * Created with IntelliJ IDEA. + * 获取中控的考勤数据同步至OA + * @Auther: chenxu + * @Date: 2023/02/27/14:03 + * @Description: + */ +public class SyncZkKqDataJob extends BaseCronJob { + + @Override + public void execute() { + new BaseBean(); + BaseBean bb = new BaseBean(); + bb.writeLog("获取中控的考勤数据同步至OA!!!"); + try { + //获取所有在职人员的id和workcode + Map idWorkcodeMap = new HashMap<>(); + RecordSet rs = new RecordSet(); + String acqResSql = "SELECT id,workcode FROM HRMRESOURCE WHERE status in (0,1,2,3)"; + rs.executeQuery(acqResSql); + while (rs.next()){ + String userId = Util.null2String(rs.getString("id")); + String workcode = Util.null2String(rs.getString("workcode")); + if ( StringUtils.isNotBlank(userId) && StringUtils.isNotBlank(workcode)) { + idWorkcodeMap.put(workcode,userId); + } + } + //获取开始时间结束时间 + Calendar beforeTime = Calendar.getInstance(); + beforeTime.add(Calendar.MINUTE, -5);// 5分钟之前的时间 + Date beforeD = beforeTime.getTime(); + String startTime = DateUtil.format(beforeD,"yyyy-MM-dd HH:mm:ss"); + Date now = new Date(); + String endTime = DateUtil.format(now,"yyyy-MM-dd HH:mm:ss"); + + bb.writeLog("startTime:"+startTime); + bb.writeLog("endTime:"+endTime); + String url = bb.getPropValue("project_sskj", "zkKqUrl"); +// String url = "http://172.16.50.12:8080/api/v2/transaction/get/?key=28688gxdq7wggprje-nxfdqoqetxe5jscuj0h2bhx2jn"; + bb.writeLog("url:"+url); + Map heads = new HashMap(); + Map dataMap = new HashMap(); + dataMap.put("starttime",startTime); + dataMap.put("endtime",endTime); + bb.writeLog("获取中控的考勤数据入参dataMap:"+JSONObject.toJSONString(dataMap)); + String back = doPostJsonRequest(url,heads, JSON.toJSONString(dataMap)); + bb.writeLog("urlBack:"+back); + bb.writeLog("获取中控的考勤数据--response:"+back); + List> lsParams = new ArrayList<>(); + List lsFormatData = new ArrayList<>(); + Object tempBack = Configuration.defaultConfiguration().jsonProvider().parse(back); + Integer ret = JsonPath.read(tempBack, "$.ret"); + if ( ret == 0) { + Integer count = Util.getIntValue(Util.null2String(JsonPath.read(tempBack, "$.data.count").toString())); + if ( count > 0 ) { + List> items = JsonPath.read(tempBack, "$.data.items[*]"); + for (Map item : items) { + String pin = Util.null2String(item.get("pin")); + String checktime = Util.null2String(item.get("checktime")); + DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date date = df.parse(checktime); + DateFormat df2 = new SimpleDateFormat("yyyy-MM-dd"); + DateFormat df3 = new SimpleDateFormat("HH:mm:ss"); + Integer isimport = 1; + String userid = idWorkcodeMap.get(pin); + Integer usertype = 1; + String signDate = df2.format(date); + String signTime = df3.format(date); + Integer isincom = 1; + String signfrom = "OutDataSourceSyn"; + String addr = ""; + List params = new ArrayList<>(); + params.add(userid); + params.add(usertype); + params.add(signDate); + params.add(signTime); + params.add(""); + params.add(isincom); + params.add(isimport); + params.add(signfrom); + params.add(""); + params.add(""); + params.add(addr); + params.add("中控考勤机"); + lsParams.add(params); + String formatData = userid + "|" + signDate + "|" + signTime; + if (!lsFormatData.contains(formatData)) { + lsFormatData.add(formatData); + } + } + } + } + bb.writeLog("lsParams:"+JSON.toJSONString(lsParams)); + bb.writeLog("lsFormatData:"+JSON.toJSONString(lsFormatData)); + + Map> overtimeMap = Maps.newHashMap(); + List overtimeList = Lists.newArrayList(); + List formatParams = null; + List> lsFormatParams = new ArrayList<>(); + List delParams = null; + List> lsDelParams = new ArrayList<>(); + + bb.writeLog("准备刷新报表数据"); + //刷新报表数据 + for(int i=0;lsFormatData!=null&&i(); + String[] formatData = Util.splitString(lsFormatData.get(i),"|"); + String date_1 = weaver.common.DateUtil.addDate(formatData[1], -1); + formatParams.add(formatData[0]); + formatParams.add(date_1); + lsFormatParams.add(formatParams); + + formatParams = new ArrayList<>(); + formatParams.add(formatData[0]); + formatParams.add(formatData[1]); + lsFormatParams.add(formatParams); + + delParams = new ArrayList<>(); + delParams.add(formatData[0]); + delParams.add(formatData[1]); + delParams.add(formatData[2]); + lsDelParams.add(delParams); + + String resourceId = formatData[0]; + String kqdate = formatData[1]; + if(overtimeMap.containsKey(resourceId)){ + List tmp_overtimeList = overtimeMap.get(resourceId); + if(!tmp_overtimeList.contains(kqdate)){ + tmp_overtimeList.add(kqdate); + } + }else{ + if(!overtimeList.contains(kqdate)){ + overtimeList.add(kqdate); + } + overtimeMap.put(resourceId, overtimeList); + } + } + + String sql = ""; + BatchRecordSet bRs = new BatchRecordSet(); + bb.writeLog("开始同步数据"); + + //删除本次同步数据 + sql = " delete from hrmschedulesign where signfrom='OutDataSourceSyn' and userid =? and signdate = ? and signtime = ? "; + bRs.executeBatchSql(sql, lsDelParams); + + sql = " insert into HrmScheduleSign (userid, usertype, signdate, signtime, clientaddress, isincom, isimport, signfrom, longitude, latitude, addr,memo) " + + " values(?,?,?,?,?,?,?,?,?,?,?,?)"; + bRs.executeBatchSql(sql,lsParams); + + new KQFormatBiz().format(lsFormatParams); + + bb.writeLog("开始处理加班生成"); + //处理加班生成 + List tasks = new ArrayList<>(); + for(Map.Entry> mme: overtimeMap.entrySet()){ + String resid = mme.getKey(); + List overList = mme.getValue(); + for(String date : overList){ + SplitActionUtil.pushOverTimeTasks(date,date,resid,tasks); + } + } + if(!tasks.isEmpty()){ + KQQueue.writeTasks(tasks); + } + + } catch (Exception e) { + e.printStackTrace(); + bb.writeLog(e); + bb.writeLog("获取中控的考勤数据同步至OA--error"+e.getMessage()); + } + } + +} diff --git a/src/weaver/interfaces/sskj/util/HttpsUtil.java b/src/weaver/interfaces/sskj/util/HttpsUtil.java new file mode 100644 index 0000000..df749b9 --- /dev/null +++ b/src/weaver/interfaces/sskj/util/HttpsUtil.java @@ -0,0 +1,270 @@ +package weaver.interfaces.sskj.util; + + + + +import org.apache.commons.collections.MapUtils; +import org.apache.http.Consts; +import org.apache.http.HttpEntity; +import org.apache.http.NameValuePair; +import org.apache.http.StatusLine; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.*; +import org.apache.http.config.Registry; +import org.apache.http.config.RegistryBuilder; +import org.apache.http.conn.HttpClientConnectionManager; +import org.apache.http.conn.socket.ConnectionSocketFactory; +import org.apache.http.conn.socket.PlainConnectionSocketFactory; +import org.apache.http.conn.ssl.NoopHostnameVerifier; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.apache.http.entity.mime.HttpMultipartMode; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.protocol.HTTP; +import org.apache.http.util.EntityUtils; +import org.springframework.web.multipart.MultipartFile; + +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; +import java.io.IOException; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; +import java.security.cert.CertificateException; +import java.util.*; + + +public class HttpsUtil { + + private static CloseableHttpClient httpclient = HttpClientBuilder.create().setConnectionManager(poolingConnectionManager()).build(); + + public static HttpClientConnectionManager poolingConnectionManager() { + PoolingHttpClientConnectionManager poolingConnectionManager = new PoolingHttpClientConnectionManager(); + // 连接池最大连接数 + poolingConnectionManager.setMaxTotal(1000); + // 每个主机的并发 + poolingConnectionManager.setDefaultMaxPerRoute(100); + return poolingConnectionManager; + } + + private static RequestConfig requestConfig = RequestConfig.custom() + .setConnectTimeout(1000) + // 从连接池中获取到连接的最长时间 + .setConnectionRequestTimeout(500) + // 数据传输的最长时间,联合差补需要同步较长时间 + .setSocketTimeout(60000) + .build(); + + + private static void prepareHeaders(HttpRequestBase httpRequest, Map headers) { + if (!MapUtils.isEmpty(headers)) { + for (Map.Entry entry : headers.entrySet()) { + httpRequest.addHeader(entry.getKey(), entry.getValue()); + } + } + } + + private static String sendRequest(HttpRequestBase httpRequest) throws IOException { + String result = null; + CloseableHttpClient httpclient = creteClient(); + try (CloseableHttpResponse resp = httpclient.execute(httpRequest)) { + HttpEntity entity = resp.getEntity(); + result = (entity == null ? null : EntityUtils.toString(entity, Consts.UTF_8)); + StatusLine statusLine = resp.getStatusLine(); + if (statusLine.getStatusCode() >= 300) { + EntityUtils.consume(entity); +// String errorMsg = Strings.lenientFormat("Http status abnormal-status code is %s, response is %s", resp.getStatusLine().getStatusCode(), result); + } + } + return result; + } + + public static String doPostJsonRequest(String url, Map headers, String jsonStr) throws IOException { + HttpPost httpost = new HttpPost(url); + prepareHeaders(httpost, headers); + StringEntity entity = new StringEntity(jsonStr, Consts.UTF_8); +// entity.setContentEncoding("UTF-8"); + entity.setContentType("application/json"); + httpost.setEntity(entity); + return sendRequest(httpost); + } + + public static String doGet(String url, Map headers) throws IOException { + HttpGet httpget = new HttpGet(url); + prepareHeaders(httpget, headers); + return sendRequest(httpget); + } + + public static String doPost(String url, Map headers, Map params) throws IOException { + HttpPost httpost = new HttpPost(url); + prepareHeaders(httpost, headers); + //组织请求参数 + List paramList = new ArrayList(); + if (params != null && params.size() > 0) { + Set keySet = params.keySet(); + for (String key : keySet) { + paramList.add(new BasicNameValuePair(key, params.get(key))); + } + } + UrlEncodedFormEntity entity = new UrlEncodedFormEntity((Iterable) paramList, Consts.UTF_8); + entity.setContentType("application/x-www-form-urlencoded"); + httpost.setEntity(entity); + return sendRequest(httpost); + } + + + public static byte[] doGetWithByteArrayResp(String url, Map headers) throws IOException { + HttpGet httpGet = new HttpGet(url); + httpGet.setConfig(requestConfig); + prepareHeaders(httpGet, headers); + return sendRequestWithByteArrayResp(httpGet); + } + + + + private static byte[] sendRequestWithByteArrayResp(HttpRequestBase httpRequest) throws IOException { + httpRequest.addHeader(HTTP.CONTENT_ENCODING, "UTF-8"); + byte[] result = null; + CloseableHttpClient httpclient = creteClient(); + try (CloseableHttpResponse resp = httpclient.execute(httpRequest)) { + HttpEntity entity = resp.getEntity(); + result = (entity == null ? null : EntityUtils.toByteArray(entity)); +// StatusLine statusLine = resp.getStatusLine(); +// if (statusLine.getStatusCode() >= 300) { +// EntityUtils.consume(entity); +// String errorMsg = Strings.lenientFormat("Http status abnormal-status code is %s, response is %s", resp.getStatusLine().getStatusCode(), result); +// throw new HttpResponseException(statusLine.getStatusCode(), statusLine.getReasonPhrase()); +// } + } + return result; + } + + + /** + * 文件上传 + * + * @param url 请求路径 + * @param headers 请求头部 + * @param params 请求参数 + * @param files 附件 + * @param requestFileName 附件接受名称 + * @return + * @throws IOException + */ + public static String doPostFormMultipart(String url, Map headers, Map params, List files, String requestFileName) throws IOException { + HttpPost httpost = new HttpPost(url); + prepareHeaders(httpost, headers); + //组织请求参数 + if (params != null && params.size() > 0) { + List paramList = new ArrayList(); + Set keySet = params.keySet(); + for (String key : keySet) { + paramList.add(new BasicNameValuePair(key, params.get(key))); + } + } + MultipartEntityBuilder mEntityBuilder = MultipartEntityBuilder.create(); + mEntityBuilder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); + mEntityBuilder.setCharset(Consts.UTF_8); + + // 普通参数 + ContentType contentType = ContentType.create("text/plain", Consts.UTF_8);//解决中文乱码 + if (params != null && params.size() > 0) { + Set keySet = params.keySet(); + for (String key : keySet) { + mEntityBuilder.addTextBody(key, params.get(key), contentType); + } + } + //二进制参数 + if (files != null && files.size() > 0) { + for (MultipartFile file : files) { + mEntityBuilder.addBinaryBody(requestFileName, file.getInputStream(), ContentType.create("multipart/form-data", Consts.UTF_8), file.getName()); + } + } + httpost.setEntity(mEntityBuilder.build()); + return sendRequest(httpost); + } + + + public static String doPutJsonRequest(String url, Map headers, String jsonStr) throws IOException { + HttpPut httpPut = new HttpPut(url); + prepareHeaders(httpPut, headers); + StringEntity entity = new StringEntity(jsonStr, Consts.UTF_8); + entity.setContentType("application/json"); + httpPut.setEntity(entity); + return sendRequest(httpPut); + } + + + public static String doDelete(String url, Map headers) throws IOException { + HttpDelete httpDelete = new HttpDelete(url); + prepareHeaders(httpDelete, headers); + return sendRequest(httpDelete); + + } + + + /** + * 绕过验证 + * + * @return + * @throws NoSuchAlgorithmException + * @throws KeyManagementException + */ + public static SSLContext createIgnoreVerifySSL() throws NoSuchAlgorithmException, KeyManagementException { + SSLContext sc = SSLContext.getInstance("SSLv3"); + + // 实现一个X509TrustManager接口,用于绕过验证,不用修改里面的方法 + X509TrustManager trustManager = new X509TrustManager() { + @Override + public void checkClientTrusted( + java.security.cert.X509Certificate[] paramArrayOfX509Certificate, + String paramString) throws CertificateException { + } + + @Override + public void checkServerTrusted( + java.security.cert.X509Certificate[] paramArrayOfX509Certificate, + String paramString) throws CertificateException { + } + + @Override + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return null; + } + }; + + sc.init(null, new TrustManager[]{trustManager}, null); + return sc; + } + + + public static CloseableHttpClient creteClient() { + //采用绕过验证的方式处理https请求 + try { + SSLContext sslcontext = createIgnoreVerifySSL(); + // 设置协议http和https对应的处理socket链接工厂的对象 + Registry socketFactoryRegistry = RegistryBuilder.create() + .register("http", PlainConnectionSocketFactory.INSTANCE) + .register("https", new SSLConnectionSocketFactory(sslcontext, NoopHostnameVerifier.INSTANCE)) + .build(); + PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry); + HttpClients.custom().setConnectionManager(connManager); + + //创建自定义的httpclient对象 + CloseableHttpClient client = HttpClients.custom().setConnectionManager(connManager).build(); + return client; + } catch (Exception e) { + return null; + } + + } + + +}