盛世科技

dev-shilei
chenwei 2 years ago
parent 5d187d80c1
commit 62d551a5c8

@ -14,7 +14,7 @@ import java.util.List;
import java.util.Map;
/**
*
*
*
* @author lvyi
*
@ -26,6 +26,10 @@ public class JobActivitiesBrowserService extends BrowserService {
Map<String, Object> apidatas = new HashMap<String, Object>();
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<SplitTableColBean> cols = new ArrayList<SplitTableColBean>();
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);

@ -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<String, Object> getBrowserData(Map<String, Object> params) throws Exception {
Map<String, Object> apidatas = new HashMap<String, Object>();
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<SplitTableColBean> cols = new ArrayList<SplitTableColBean>();
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<String, Object> getBrowserConditionInfo(Map<String, Object> params) throws Exception {
Map<String, Object> apidatas = new HashMap<String, Object>();
List<SearchConditionItem> conditions = new ArrayList<SearchConditionItem>();
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;
}
}

@ -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<String, Object> getBrowserData(Map<String, Object> params) throws Exception {
Map<String, Object> apidatas = new HashMap<String, Object>();
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<SplitTableColBean> cols = new ArrayList<SplitTableColBean>();
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<String, Object> getBrowserConditionInfo(Map<String, Object> params) throws Exception {
Map<String, Object> apidatas = new HashMap<String, Object>();
List<SearchConditionItem> conditions = new ArrayList<SearchConditionItem>();
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<String, Object> getMultBrowserDestData(Map<String, Object> params) throws Exception {
Map<String, Object> apidatas = new HashMap<String, Object>();
List<Map<String,Object>> datas = new ArrayList<Map<String,Object>>();
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<String,Object> item = new HashMap<String,Object>();
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<ListHeadBean> tableHeadColumns = new ArrayList<ListHeadBean>();
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<String, Object> browserAutoComplete(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> apidatas = new HashMap<String, Object>();
String q = Util.null2String(request.getParameter("q"));
List<String> sqlParams = new ArrayList<String>() ;
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<Map<String,String>> datas = new ArrayList<Map<String,String>>();
while(rs.next()){
Map<String,String> item = new HashMap<String,String>();
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;
}
}

@ -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<String, Object> getBrowserData(Map<String, Object> params) throws Exception {
// TODO Auto-generated method stub
Map<String, Object> apidatas = new HashMap<String, Object>();
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<SplitTableColBean> cols = new ArrayList<SplitTableColBean>();
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<String, Object> getBrowserConditionInfo(Map<String, Object> params) throws Exception {
Map<String, Object> apidatas = new HashMap<String, Object>();
List<SearchConditionItem> conditions = new ArrayList<SearchConditionItem>();
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<String, Object> getMultBrowserDestData(Map<String, Object> params) throws Exception {
Map<String, Object> apidatas = new HashMap<String, Object>();
List<Map<String,Object>> datas = new ArrayList<Map<String,Object>>();
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<String,Object> 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<ids.length;i++){
// String id = Util.null2String(ids[i]);
// if(id.length()==0)continue;
// Map<String,Object> item = new HashMap<String,Object>();
// item.put("id", id);
// item.put("locationname", Util.null2String(locationComInfo.getLocationname(id)));
// item.put("locationdesc", Util.null2String(locationComInfo.getLocationname(id)));
// datas.add(item);
// }
List<ListHeadBean> tableHeadColumns = new ArrayList<ListHeadBean>();
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;
}
}

@ -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<Map<String, Object>> {
public GetHrmSearchMoudleListCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
}
@Override
public BizLogContext getLogContext() {
return null;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> resultMap = new HashMap<String, Object>();
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<Map<String, Object>> lsMould = new ArrayList<Map<String, Object>>();
Map<String, Object> mouldInfo = null;
//默认显示【全部人员】查询模板
mouldInfo = new HashMap<String, Object>();
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<String, Object>();
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<String, Object>();
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<String, Object>();
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<String, Object>();
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;
}
}

File diff suppressed because it is too large Load Diff

@ -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<Map<String, Object>> {
BaseBean basebean = new BaseBean();
@Override
public Map<String, Object> execute(Command<Map<String, Object>> command) {
AddJobGroupCmd cmd = (AddJobGroupCmd) command;
User user = cmd.getUser();
Map<String, Object> params = cmd.getParams();
Map<String, Object> 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;
}
}

@ -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<Map<String, Object>> {
BaseBean basebean = new BaseBean();
@Override
public Map<String, Object> execute(Command<Map<String, Object>> command) {
EditJobGroupCmd cmd = (EditJobGroupCmd) command;
User user = cmd.getUser();
Map<String, Object> params = cmd.getParams();
Map<String, Object> 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;
}
}

@ -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<Map<String, Object>> {
@Override
public Map<String, Object> execute(Command<Map<String, Object>> command) {
GetHrmKQMonthReportInfoCmd cmd = (GetHrmKQMonthReportInfoCmd) command;
Map<String, Object> params = cmd.getParams();
Map<String, Object> 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<String, Object> resultMap = (Map<String, Object>) resultObj;
Map<String, Object> newResultMap = new HashMap<String, Object>();
newResultMap.put(lastmonth+"",resultMap.get(lastmonth+""));
newResultMap.put(month+"",resultMap.get(month+""));
result.put("result",newResultMap);
}
}
}else {
result = nextExecute(cmd);
}
return result;
}
}

@ -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<Map<String, Object>> {
@Override
public Map<String, Object> execute(Command<Map<String, Object>> command) {
GetJobDetailCmd cmd = (GetJobDetailCmd) command;
Map<String, Object> params = cmd.getParams();
Map<String, Object> 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;
}
}

@ -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<Map<String, Object>> {
@Override
public Map<String, Object> execute(Command<Map<String, Object>> command) {
GetJobGroupFormCmd cmd = (GetJobGroupFormCmd) command;
Map<String, Object> params = cmd.getParams();
Map<String, Object> result = nextExecute(cmd);
Object conditionObj = result.get("condition");
if ( conditionObj != null) {
List< Map<String ,Object>> condition = (List< Map<String ,Object>>) conditionObj;
Map<String, Object> con = condition.get(0);
Object itemsObj = con.get("items");
if ( itemsObj != null) {
List<SearchConditionItem> items = (List<SearchConditionItem>) 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;
}
}

@ -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));
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -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<Map<String, Object>> {
public GetAttendanceCardCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> retmap = new HashMap<String, Object>();
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<Map<String,String>> cardList = new ArrayList<>();
Map<String,String> cardMap = new HashMap<>();
KQReportBiz kqReportBiz = new KQReportBiz();
List<Object> reporsts = kqReportBiz.getKqDateInfo(resourceId, fromDate, toDate, false);
for(int i = 0 ; i < reporsts.size() ; i++) {
Map<String, Object> kqdateMap = (Map<String, Object>) reporsts.get(i);
String kqdate = Util.null2String(kqdateMap.get("kqdate"));
List<Object> checkInfoList = (List<Object>) kqdateMap.get("checkInfo");
//每一个工作时段里的考勤状态
for (int j = 0; j < checkInfoList.size(); j++) {
Map<String, Object> data = (Map<String, Object>) 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;
}
}

@ -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<Map<String, Object>> {
private HttpServletRequest request;
private HttpServletResponse response;
private List<String> lsFieldDataKey;
public ExportDailyExcelCmd(Map<String, Object> 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<String, Object> execute(CommandContext commandContext) {
Map<String, Object> retmap = new HashMap<String, Object>();
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<String> showColumns = Util.splitString2List(Util.null2String(jsonObj.get("showColumns")),",");
showColumns.add("lastname");
showColumns.add("kqdate");
showColumns.add("serialid");
showColumns.removeIf(showColumn->showColumn.trim().equals(""));
List<String> 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<String, Object> workbook = new LinkedHashMap<>();
List<Object> lsSheet = new ArrayList<>();
Map<String, Object> sheet = null;
List<Object> titleList = new ArrayList<>();
Map<String,Object> title = null;
List<List<Object>> dataList = new ArrayList<>();
List<Object> data = null;
List<Map<String,Object>> constraintList = null;
Map<String,Object> constraint = null;
sheet = new HashMap<>();
sheet.put("sheetName", SystemEnv.getHtmlLabelName( 390352, user.getLanguage()));
sheet.put("sheetTitle", SystemEnv.getHtmlLabelName( 390352, user.getLanguage()));
List<Map<String, Object>> leaveRules = kqLeaveRulesBiz.getAllLeaveRules();
Map<String,Object> mapChildColumnInfo = null;
List<Object> 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<Object>)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<String,String> serialdata = new HashMap<>();
boolean isneedcal = KQSettingsBiz.getKqformatAccurate();
params.put("isneedcal",isneedcal?"1":"0");
Map<String,Object> 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<String,Object> signDetailInfo = this.getSignDetailInfo(id,kqdate);
for (int fieldDataKeyIdx =0;fieldDataKeyIdx<lsFieldDataKey.size();fieldDataKeyIdx++) {
String fieldName = lsFieldDataKey.get(fieldDataKeyIdx);
String fieldid = KQReportFieldComInfo.field2Id.get(fieldName);
String fieldValue = "";
if(fieldName.equals("subcompany")){
String tmpSubcompanyId = Util.null2String(rs.getString("subcompanyid"));
if(tmpSubcompanyId.length()==0){
tmpSubcompanyId = Util.null2String(resourceComInfo.getSubCompanyID(id));
}
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));
}
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));
}
fieldValue = jobTitlesComInfo.getJobTitlesname(tmpJobtitleId);
} else if(fieldName.equals("serialid")){
String serialid = Util.null2String(rs.getString("serialid"));
if(serialid.length()>0){
// 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<Map<String, Object>> allLeaveRules = KQLeaveRulesBiz.getAllLeaveRules();
Map<String, Object> leaveRule = null;
for(int i=0;allLeaveRules!=null&&i<allLeaveRules.size();i++){
leaveRule = (Map<String, Object>)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<String,Object> 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<String,Object> getChildColumnsInfo(String parentid, User user){
Map<String,Object> returnMap = new HashMap<>();
List<Object> titleList = new ArrayList<>();
Map<String,Object> title = null;
if(parentid.equals("leave")){
KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz();
List<Map<String, Object>> leaveRules = kqLeaveRulesBiz.getAllLeaveRules();
for(int i=0;leaveRules!=null&&i<leaveRules.size();i++){
Map<String, Object> 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;i<overtimeChild.length;i++){
String id = overtimeChild[i];
title = new HashMap();
String fieldlabel = "";
if("overtime_nonleave".equalsIgnoreCase(id)){
fieldlabel = "125805";
title.put("title", SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage()));
title.put("rowSpan","2");
}else if("overtime_4leave".equalsIgnoreCase(id)){
fieldlabel = "125804";
title.put("title", SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage()));
title.put("rowSpan","2");
}else{
fieldlabel = "523";
title.put("showDetial","1");
String unitType = (KQOvertimeRulesBiz.getMinimumUnit()==3 || KQOvertimeRulesBiz.getMinimumUnit()==5 ||KQOvertimeRulesBiz.getMinimumUnit()==6)?"2":"1";
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());
}
}
title.put("title", SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage())+ "(" + unitTypeName + ")");
}
Map<String,Object> mapChildColumnInfo = getChildColumnsInfo(id, user);
int childWidth = 65;
List<Object> childColumns = (List<Object>)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<String, Object> getSignDetailInfo(String resourceId, String kqDate){
Map<String, Object> data = new HashMap<>();
Map<String,Object> 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;
}
}

@ -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<Map<String, Object>> {
private HttpServletRequest request;
private HttpServletResponse response;
private List<String> lsFieldDataKey;
public ExportExcelCmd(Map<String, Object> 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<String, Object> execute(CommandContext commandContext) {
Map<String, Object> retmap = new HashMap<String, Object>();
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<String> showColumns = Util.splitString2List(Util.null2String(jsonObj.get("showColumns")), ",");
showColumns.add("lastname");
showColumns.removeIf(showColumn->showColumn.trim().equals(""));
List<String> 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<String, Object> workbook = new LinkedHashMap<>();
List<Object> lsSheet = new ArrayList<>();
Map<String, Object> sheet = null;
List<Object> titleList = new ArrayList<>();
Map<String, Object> title = null;
List<List<Object>> dataList = new ArrayList<>();
List<Object> data = null;
List<Map<String, Object>> 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<Map<String, Object>> leaveRules = kqLeaveRulesBiz.getAllLeaveRules();
Map<String, Object> mapChildColumnInfo = null;
List<Object> 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<Object>) 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<String,Object> 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<String, Object> 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<lsFieldDataKey.size();fieldDataKeyIdx++) {
String fieldName = lsFieldDataKey.get(fieldDataKeyIdx);
String fieldid = KQReportFieldComInfo.field2Id.get(fieldName);
String fieldValue = "";
if (fieldName.equals("subcompany")) {
String tmpSubcompanyId = Util.null2String(rs.getString("subcompanyid"));
if (tmpSubcompanyId.length() == 0) {
tmpSubcompanyId = Util.null2String(resourceComInfo.getSubCompanyID(id));
}
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));
}
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));
}
fieldValue = jobTitlesComInfo.getJobTitlesname(tmpJobtitleId);
} else if (fieldName.equals("attendanceSerial")) {
List<String> 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++){
data.add(kqReportBiz.getSerialCount(id,fromDate,toDate,serialIds.get(i)));
}
}else{
data.add("");
}
continue;
} else if (fieldName.equals("leave")) {//请假
List<Map<String, Object>> allLeaveRules = kqLeaveRulesBiz.getAllLeaveRules();
Map<String, Object> 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<String> lsCascadekey = Util.splitString2List(kqReportFieldComInfo.getCascadekey(fieldid),",");
for(int i=0;i<lsCascadekey.size();i++){
if(Util.null2String(rs.getString(lsCascadekey.get(i))).length()>0){
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<String, Object> detialDatas = kqReportBiz.getDetialDatas(id, fromDate, toDate, user,flowData,true);
Map<String, Object> 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<String, Object>) 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<String, Object> 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<String, Object> getChildColumnsInfo(String parentid, User user) {
Map<String, Object> returnMap = new HashMap<>();
List<Object> titleList = new ArrayList<>();
Map<String, Object> title = null;
if (parentid.equals("attendanceSerial")) {//考勤班次
KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo();
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
List<String> 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<Map<String, Object>> leaveRules = kqLeaveRulesBiz.getAllLeaveRules();
for (int i = 0; leaveRules != null && i < leaveRules.size(); i++) {
Map<String, Object> 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;i<overtimeChild.length;i++){
String id = overtimeChild[i];
title = new HashMap();
String fieldlabel = "";
if("overtime_nonleave".equalsIgnoreCase(id)){
fieldlabel = "125805";
title.put("title", SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage()));
title.put("rowSpan","2");
}else if("overtime_4leave".equalsIgnoreCase(id)){
fieldlabel = "125804";
title.put("title", SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage()));
title.put("rowSpan","2");
}else{
fieldlabel = "523";
title.put("showDetial","1");
String unitType = (KQOvertimeRulesBiz.getMinimumUnit()==3 || KQOvertimeRulesBiz.getMinimumUnit()==5 ||KQOvertimeRulesBiz.getMinimumUnit()==6)?"2":"1";
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());
}
}
title.put("title", SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage())+ "(" + unitTypeName + ")");
}
Map<String,Object> mapChildColumnInfo = getChildColumnsInfo(id, user);
int childWidth = 65;
List<Object> childColumns = (List<Object>)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<Object> getCascadeKeyColumnsInfo(String cascadeKey, User user){
List<Object> titleList = new ArrayList<>();
Map<String, Object> title = null;
if(Util.null2String(cascadeKey).length()==0){
return titleList;
}
List<String> lsCascadeKey = Util.splitString2List(cascadeKey,",");
KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo();
for(int i=0;i<lsCascadeKey.size();i++){
kqReportFieldComInfo.setTofirstRow();
while (kqReportFieldComInfo.next()) {
if(!kqReportFieldComInfo.getReportType().equals("month"))continue;
if (kqReportFieldComInfo.getFieldname().equals(lsCascadeKey.get(i))){
title = new HashMap<>();
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;
}
}

@ -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<Map<String, Object>> {
private KQLog kqLog = new KQLog();
public GetKQDailyReportCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String,Object> retmap = new HashMap<String,Object>();
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<Map<String, Object>> leaveRules = kqLeaveRulesBiz.getAllLeaveRules();
List<Object> columns = new ArrayList();
Map<String,Object> column = null;
List<Object> datas = new ArrayList();
Map<String,Object> data = null;
Map<String,Object> mapChildColumnInfo = null;
List<Object> 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<Object>)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<String,Object> flowData = kqReportBiz.getDailyFlowData(params,user);
Map<String,String> 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<Map<String, Object>> allLeaveRules = KQLeaveRulesBiz.getAllLeaveRules();
Map<String, Object> leaveRule = null;
for (int i = 0; allLeaveRules != null && i < allLeaveRules.size(); i++) {
leaveRule = (Map<String, Object>) 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<Object> 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<String,Object> getChildColumnsInfo(String parentid, User user){
Map<String,Object> returnMap = new HashMap<>();
List<Object> lsChildColumns = new ArrayList<>();
Map column = null;
int sumChildColumnWidth = 0;
if(parentid.equals("leave")){
KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz();
List<Map<String, Object>> leaveRules = kqLeaveRulesBiz.getAllLeaveRules();
for(int i=0;leaveRules!=null&&i<leaveRules.size();i++){
Map<String, Object> 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;i<overtimeChild.length;i++){
String id = overtimeChild[i];
column = new HashMap();
String fieldlabel = "";
column.put("unit", "");
if("overtime_nonleave".equalsIgnoreCase(id)){
fieldlabel = "125805";
}else if("overtime_4leave".equalsIgnoreCase(id)){
fieldlabel = "125804";
}else{
fieldlabel = "523";
column.put("showDetial","1");
String unitType = (KQOvertimeRulesBiz.getMinimumUnit()==3 || KQOvertimeRulesBiz.getMinimumUnit()==5 ||KQOvertimeRulesBiz.getMinimumUnit()==6)?"2":"1";
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());
}
}
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<String,Object> mapChildColumnInfo = getChildColumnsInfo(id, user);
int childWidth = 65;
List<Object> childColumns = (List<Object>)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<String, Object> getSignDetailInfo(String resourceId, String kqDate){
Map<String, Object> data = new HashMap<>();
Map<String,Object> 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;
}
}

@ -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<Map<String, Object>> {
public GetKQReportCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String,Object> retmap = new HashMap<String,Object>();
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<Map<String, Object>> leaveRules = kqLeaveRulesBiz.getAllLeaveRules();
List<Object> columns = new ArrayList();
Map<String,Object> column = null;
List<Object> datas = new ArrayList();
Map<String,Object> data = null;
Map<String,Object> mapChildColumnInfo = null;
List<Object> 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<Object>)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<String,Object> 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<String,Object> 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<String> serialIds = null;
if(attendanceSerial.length()>0){
serialIds = Util.splitString2List(attendanceSerial,",");
}
for(int i=0;serialIds!=null&&i<serialIds.size();i++){
data.put(serialIds.get(i), kqReportBiz.getSerialCount(id,fromDate,toDate,serialIds.get(i)));
}
}else if(kqReportFieldComInfo.getParentid().equals("overtime")||kqReportFieldComInfo.getParentid().equals("overtime_nonleave")
||kqReportFieldComInfo.getParentid().equals("overtime_4leave")||fieldName.equals("businessLeave") || fieldName.equals("officialBusiness")){
if(fieldName.equals("overtimeTotal")){
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));
}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{
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id+"|"+fieldName)));
}
}else if (fieldName.equals("reissuecard")) {
int reissueCard = Util.getIntValue(Util.null2String(flowData.get(id + "|reissueCard" )));
reissueCard = reissueCard < 0 ? 0 : reissueCard;
fieldValue = String.valueOf(reissueCard);
} else {
fieldValue = Util.null2String(rs.getString(fieldName));
if(Util.null2String(kqReportFieldComInfo.getUnittype()).length()>0) {
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<Map<String, Object>> allLeaveRules = kqLeaveRulesBiz.getAllLeaveRules();
Map<String, Object> leaveRule = null;
for(int i=0;allLeaveRules!=null&&i<allLeaveRules.size();i++){
leaveRule = (Map<String, Object>)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<String,Object> 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<Object> 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<String,Object> getChildColumnsInfo(String parentid, User user){
Map<String,Object> returnMap = new HashMap<>();
List<Object> 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<String> 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++){
column = new HashMap();
column.put("title", kqShiftManagementComInfo.getSerial(serialIds.get(i)));
column.put("unit", "");
column.put("width", 65);
column.put("dataIndex", serialIds.get(i));
column.put("key", serialIds.get(i));
column.put("rowSpan", 2);
column.put("colSpan", 1);
sumChildColumnWidth+=65;
lsChildColumns.add(column);
}
}else if(parentid.equals("leave")){
KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz();
List<Map<String, Object>> leaveRules = kqLeaveRulesBiz.getAllLeaveRules();
for(int i=0;leaveRules!=null&&i<leaveRules.size();i++){
Map<String, Object> 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;i<overtimeChild.length;i++){
String id = overtimeChild[i];
column = new HashMap();
String fieldlabel = "";
column.put("unit", "");
if("overtime_nonleave".equalsIgnoreCase(id)){
fieldlabel = "125805";
}else if("overtime_4leave".equalsIgnoreCase(id)){
fieldlabel = "125804";
}else{
fieldlabel = "523";
column.put("showDetial","1");
String unitType = (KQOvertimeRulesBiz.getMinimumUnit()==3 || KQOvertimeRulesBiz.getMinimumUnit()==5 ||KQOvertimeRulesBiz.getMinimumUnit()==6)?"2":"1";
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());
}
}
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<String,Object> mapChildColumnInfo = getChildColumnsInfo(id, user);
int childWidth = 65;
List<Object> childColumns = (List<Object>)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<Object> getCascadeKeyColumnsInfo(String cascadeKey, User user){
List<Object> lsChildColumns = new ArrayList<>();
if(Util.null2String(cascadeKey).length()==0){
return lsChildColumns;
}
Map<String,Object> column = null;
List<String> lsCascadeKey = Util.splitString2List(cascadeKey,",");
KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo();
for(int i=0;i<lsCascadeKey.size();i++){
kqReportFieldComInfo.setTofirstRow();
while (kqReportFieldComInfo.next()) {
if(!kqReportFieldComInfo.getReportType().equals("month"))continue;
if (kqReportFieldComInfo.getFieldname().equals(lsCascadeKey.get(i))){
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());
column.put("isSystem", kqReportFieldComInfo.getIsSystem());
lsChildColumns.add(column);
}
}
}
return lsChildColumns;
}
@Override
public BizLogContext getLogContext() {
return null;
}
}

@ -43,5 +43,15 @@ public class EntryController {
return new Gson().toJson(resultDatas);
}
@POST
@Path("/grantNumber")
@Produces(MediaType.APPLICATION_JSON)
public String grantNumber(@Context HttpServletRequest request, @Context HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
Map<String, Object> params = ParamUtil.request2Map(request);
Map<String, Object> resultDatas = getEntryService(user).grantNumber(params);
return new Gson().toJson(resultDatas);
}
}

@ -13,4 +13,9 @@ public interface EntryService {
*/
Map<String, Object> checkEntryStatus(Map<String, Object> params);
/**
*
*/
Map<String, Object> grantNumber(Map<String, Object> params);
}

@ -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<String, Object> checkBlackList(Map<String, Object> params) {
Map<String, Object> 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<String, Object> grantNumber(Map<String, Object> params) {
Map<String, Object> 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;
}
}
}
}

@ -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));
}
}

@ -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<String, String> 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<String, String> heads = new HashMap<String, String>();
Map<String,Object> dataMap = new HashMap<String,Object>();
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<List<Object>> lsParams = new ArrayList<>();
List<String> 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<Map<String, Object>> items = JsonPath.read(tempBack, "$.data.items[*]");
for (Map<String, Object> 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<Object> 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<String,List<String>> overtimeMap = Maps.newHashMap();
List<String> overtimeList = Lists.newArrayList();
List<Object> formatParams = null;
List<List<Object>> lsFormatParams = new ArrayList<>();
List<Object> delParams = null;
List<List<Object>> lsDelParams = new ArrayList<>();
bb.writeLog("准备刷新报表数据");
//刷新报表数据
for(int i=0;lsFormatData!=null&&i<lsFormatData.size();i++){
formatParams = new ArrayList<>();
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<String> 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<KQTaskBean> tasks = new ArrayList<>();
for(Map.Entry<String, List<String>> mme: overtimeMap.entrySet()){
String resid = mme.getKey();
List<String> 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());
}
}
}

@ -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<String, String> headers) {
if (!MapUtils.isEmpty(headers)) {
for (Map.Entry<String, String> 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<String, String> 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<String, String> headers) throws IOException {
HttpGet httpget = new HttpGet(url);
prepareHeaders(httpget, headers);
return sendRequest(httpget);
}
public static String doPost(String url, Map<String, String> headers, Map<String, String> params) throws IOException {
HttpPost httpost = new HttpPost(url);
prepareHeaders(httpost, headers);
//组织请求参数
List<NameValuePair> paramList = new ArrayList<NameValuePair>();
if (params != null && params.size() > 0) {
Set<String> keySet = params.keySet();
for (String key : keySet) {
paramList.add(new BasicNameValuePair(key, params.get(key)));
}
}
UrlEncodedFormEntity entity = new UrlEncodedFormEntity((Iterable<? extends NameValuePair>) paramList, Consts.UTF_8);
entity.setContentType("application/x-www-form-urlencoded");
httpost.setEntity(entity);
return sendRequest(httpost);
}
public static byte[] doGetWithByteArrayResp(String url, Map<String, String> 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<String, String> headers, Map<String, String> params, List<MultipartFile> files, String requestFileName) throws IOException {
HttpPost httpost = new HttpPost(url);
prepareHeaders(httpost, headers);
//组织请求参数
if (params != null && params.size() > 0) {
List<NameValuePair> paramList = new ArrayList<NameValuePair>();
Set<String> 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<String> 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<String, String> 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<String, String> 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<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>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;
}
}
}
Loading…
Cancel
Save