omron
commit
67faa86e01
@ -0,0 +1,82 @@
|
||||
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 JobActivitiesBrowserService extends BrowserService {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getBrowserData(Map<String, Object> params) throws Exception {
|
||||
Map<String, Object> apidatas = new HashMap<String, Object>();
|
||||
String jobactivitymark = Util.null2String(params.get("jobactivitymark"));
|
||||
String jobactivityname = Util.null2String(params.get("jobactivityname"));
|
||||
String sqlwhere = "where 1 = 1 ";
|
||||
String backfields = "";
|
||||
String fromSql = "";
|
||||
String orderby = "";
|
||||
if(!jobactivitymark.equals("")){
|
||||
sqlwhere += " and Jobactivitymark like '%";
|
||||
sqlwhere += Util.fromScreen2(jobactivitymark,user.getLanguage());
|
||||
sqlwhere += "%'";
|
||||
}
|
||||
if(!jobactivityname.equals("")){
|
||||
sqlwhere += " and jobactivityname like '%";
|
||||
sqlwhere += Util.fromScreen2(jobactivityname,user.getLanguage());
|
||||
sqlwhere += "%'";
|
||||
}
|
||||
|
||||
List<SplitTableColBean> cols = new ArrayList<SplitTableColBean>();
|
||||
backfields = " id, jobactivitymark, jobactivityname, jobgroupname ";
|
||||
fromSql = " ( SELECT " +
|
||||
" a.id, " +
|
||||
" a.jobactivitymark, " +
|
||||
" a.jobactivityname, " +
|
||||
" b.jobgroupname " +
|
||||
"FROM " +
|
||||
" HrmJobActivities a " +
|
||||
" LEFT JOIN HrmJobGroups b ON b.id = a.jobgroupid " +
|
||||
") t ";
|
||||
orderby = " id ";
|
||||
|
||||
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("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);
|
||||
|
||||
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, "jobactivitymark", true));
|
||||
conditions.add(conditionFactory.createCondition(ConditionType.INPUT, 15767, "jobactivityname"));
|
||||
conditions.add(conditionFactory.createCondition(ConditionType.INPUT, 805, "jobgroupname"));
|
||||
return apidatas;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.api.omron.controller;
|
||||
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
@Path("/omron/kqreportdev")
|
||||
public class KqReportController extends com.engine.omron.controller.KqReportController {
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.api.omron.controller;
|
||||
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
@Path("/omron/OverTimeWorkflow")
|
||||
public class OverTimeController extends com.engine.omron.controller.OverTimeController {
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,854 @@
|
||||
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 com.google.gson.Gson;
|
||||
import weaver.common.DateUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.TimeUtil;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
import weaver.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 = "";
|
||||
BaseBean basebean = new BaseBean();
|
||||
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("subcompany_bai")) {
|
||||
title = new HashMap<>();
|
||||
title.put("rowSpan", 3);
|
||||
title.put("width", 30 * 256);
|
||||
title.put("title","白班");
|
||||
titleList.add(title);
|
||||
}
|
||||
if(showColumns.contains("subcompany_ye")) {
|
||||
title = new HashMap<>();
|
||||
title.put("rowSpan", 3);
|
||||
title.put("width", 30 * 256);
|
||||
title.put("title","夜班");
|
||||
titleList.add(title);
|
||||
}
|
||||
if(showColumns.contains("subcompany_zhong")) {
|
||||
title = new HashMap<>();
|
||||
title.put("rowSpan", 3);
|
||||
title.put("width", 30 * 256);
|
||||
title.put("title","中班");
|
||||
titleList.add(title);
|
||||
}
|
||||
if(showColumns.contains("subcompany_wan")) {
|
||||
title = new HashMap<>();
|
||||
title.put("rowSpan", 3);
|
||||
title.put("width", 30 * 256);
|
||||
title.put("title","晚班");
|
||||
titleList.add(title);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
//考勤二开--增加说明行
|
||||
List<Object> newTitleList = new ArrayList<>();
|
||||
Map<String, Object> titlesMap = new HashMap<>();
|
||||
if (titleList.size() > 0) {
|
||||
String desc = "说明:";
|
||||
String acqDescSql = " select smnr from uf_kqhzbsmbd order by id desc";
|
||||
basebean.writeLog("acqDescSql: " + acqDescSql);
|
||||
rs.executeQuery(acqDescSql);
|
||||
while (rs.next()) {
|
||||
String temp = Util.null2String(rs.getString("smnr"));
|
||||
desc = desc + temp;
|
||||
}
|
||||
basebean.writeLog("desc: " + desc);
|
||||
titlesMap.put("flag","KqReport");
|
||||
titlesMap.put("title",desc);
|
||||
titlesMap.put("width",7680);
|
||||
titlesMap.put("colSpan",75);
|
||||
titlesMap.put("children",titleList);
|
||||
|
||||
newTitleList.add(titlesMap);
|
||||
}
|
||||
|
||||
sheet.put("titleList", newTitleList);
|
||||
// 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 b.resourceid in(" + resourceId + ") ";
|
||||
}
|
||||
|
||||
if (viewScope.equals("4")) {//我的下属
|
||||
if (allLevel.equals("1")) {//所有下属
|
||||
sqlWhere += " and a.managerstr like '%," + user.getUID() + ",%'";
|
||||
} else {
|
||||
sqlWhere += " and a.managerid=" + user.getUID();//直接下属
|
||||
}
|
||||
}
|
||||
if (!"1".equals(isNoAccount)) {
|
||||
sqlWhere += " and a.loginid is not null " + (rs.getDBType().equals("oracle") ? "" : " and a.loginid<>'' ");
|
||||
}
|
||||
|
||||
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());
|
||||
Map<String, Object> flowData = new KQReportBiz().getFlowData(params, user);
|
||||
//System.out.println("end" + DateUtil.getFullDate());
|
||||
rs.execute(sql);
|
||||
basebean.writeLog("sql: " + sql );
|
||||
//考勤二开--获取低于、高于标准时间的假期类型
|
||||
String lowType = basebean.getPropValue("omlKq_main", "dybzgzsjid");
|
||||
String upType = basebean.getPropValue("omlKq_main", "gybzgzsjid");
|
||||
|
||||
while (rs.next()) {
|
||||
data = new ArrayList<>();
|
||||
String id = rs.getString("id");
|
||||
basebean.writeLog("lsFieldDataKey: " + new Gson().toJson(lsFieldDataKey));
|
||||
for (int fieldDataKeyIdx =0;fieldDataKeyIdx<lsFieldDataKey.size();fieldDataKeyIdx++) {
|
||||
basebean.writeLog("---fieldName: " + lsFieldDataKey.get(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 = 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 = 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();
|
||||
basebean.writeLog("allLeaveRules: " + allLeaveRules.size());
|
||||
Map<String, Object> leaveRule = null;
|
||||
for (int i = 0; allLeaveRules != null && i < allLeaveRules.size(); i++) {
|
||||
leaveRule = allLeaveRules.get(i);
|
||||
//考勤二开--低于、高于两个类型的假期不在请假中显示
|
||||
if (leaveRule.get("id").equals(lowType) || leaveRule.get("id").equals(upType)) {
|
||||
basebean.writeLog("请假: " + leaveRule.get("id"));
|
||||
continue;
|
||||
}
|
||||
//end
|
||||
String flowType = Util.null2String("leaveType_" + leaveRule.get("id"));
|
||||
basebean.writeLog("----------------flowType: " + flowType);
|
||||
basebean.writeLog("----------------name: " + leaveRule.get("name"));
|
||||
|
||||
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)));
|
||||
}
|
||||
basebean.writeLog("----------------flowLeaveData: " + flowLeaveData);
|
||||
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("leaveType_" + lowType) || fieldName.equals("leaveType_" + upType)) {
|
||||
|
||||
basebean.writeLog("fieldName: " + fieldName );
|
||||
|
||||
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[] temp = fieldName.split("_");
|
||||
basebean.writeLog("temp[1]: " + temp[1] );
|
||||
if (leaveRule.get("id").equals(temp[1])) {
|
||||
basebean.writeLog("leaveRule: " + leaveRule );
|
||||
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)));
|
||||
}
|
||||
basebean.writeLog("flowLeaveData: " + flowLeaveData );
|
||||
data.add(flowLeaveData);
|
||||
}
|
||||
//end
|
||||
}
|
||||
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("subcompany")){
|
||||
|
||||
RecordSet rs2 = new RecordSet();
|
||||
//人员id
|
||||
String sql2 = "select b.serialtype,b.Statisticstype,a.* from kq_format_detail a\n" +
|
||||
"left join\n" +
|
||||
"kq_ShiftManagement b \n" +
|
||||
"on a.serialid = b.id\n" +
|
||||
"where kqdate >= ?\n" +
|
||||
"and kqdate <= ? and resourceid = ?";
|
||||
rs2.executeQuery(sql2,fromDate,toDate,id);
|
||||
BigDecimal subcompany_bai=new BigDecimal("0");
|
||||
BigDecimal subcompany_ye=new BigDecimal("0");
|
||||
BigDecimal subcompany_zhong=new BigDecimal("0");
|
||||
BigDecimal subcompany_wan=new BigDecimal("0");
|
||||
while (rs2.next()){
|
||||
//班次类型
|
||||
String serialtype = Util.null2String(rs2.getString("serialtype"));
|
||||
//统计方式
|
||||
String statisticstype = Util.null2String(rs2.getString("statisticstype"));
|
||||
//为空跳过
|
||||
if("".equals(serialtype)||"".equals(statisticstype)){
|
||||
continue;
|
||||
}
|
||||
BigDecimal count=new BigDecimal("0");
|
||||
//应该出勤时间
|
||||
String workmins = Util.null2String(rs2.getString("workmins"));
|
||||
//计算实际出勤时间(出差公出算出勤)=应出勤-旷工-请假-迟到-早退
|
||||
String absenteeismmins = Util.null2String(rs2.getString("absenteeismmins"));
|
||||
String leavemins = Util.null2String(rs2.getString("leavemins"));
|
||||
String belatemins = Util.null2String(rs2.getString("belatemins"));
|
||||
String gravebelatemins = Util.null2String(rs2.getString("gravebelatemins"));
|
||||
String leaveearlymins = Util.null2String(rs2.getString("leaveearlymins"));
|
||||
String graveleaveearlymins = Util.null2String(rs2.getString("graveleaveearlymins"));
|
||||
absenteeismmins = zro(absenteeismmins);
|
||||
leavemins = zro(leavemins);
|
||||
belatemins = zro(belatemins);
|
||||
gravebelatemins = zro(gravebelatemins);
|
||||
leaveearlymins = zro(leaveearlymins);
|
||||
graveleaveearlymins = zro(graveleaveearlymins);
|
||||
BigDecimal num0 = new BigDecimal(workmins);
|
||||
|
||||
BigDecimal num1 = new BigDecimal(absenteeismmins);
|
||||
BigDecimal num2 = new BigDecimal(leavemins);
|
||||
BigDecimal num3 = new BigDecimal(belatemins);
|
||||
BigDecimal num4 = new BigDecimal(gravebelatemins);
|
||||
BigDecimal num5 = new BigDecimal(leaveearlymins);
|
||||
BigDecimal num6 = new BigDecimal(graveleaveearlymins);
|
||||
//实际出勤时间
|
||||
BigDecimal result1 = num0.subtract(num1).subtract(num2).subtract(num3).subtract(num4).subtract(num5).subtract(num6);
|
||||
|
||||
//统计类型 0时数/1比例
|
||||
if("0".equals(statisticstype)){
|
||||
count = result1.doubleValue()>0?new BigDecimal(1):new BigDecimal(0);
|
||||
}else{ //实际时间/应时间
|
||||
count = result1.divide(num0, 2, BigDecimal.ROUND_HALF_UP);
|
||||
}
|
||||
|
||||
if("0".equals(serialtype)){
|
||||
subcompany_bai = subcompany_bai.add(count);
|
||||
}else if("1".equals(serialtype)){
|
||||
subcompany_ye = subcompany_ye.add(count);
|
||||
}else if("2".equals(serialtype)){
|
||||
subcompany_zhong = subcompany_zhong.add(count);
|
||||
}else if("3".equals(serialtype)){
|
||||
subcompany_wan = subcompany_wan.add(count);
|
||||
}
|
||||
}
|
||||
|
||||
if(showColumns.contains("subcompany_bai")){
|
||||
data.add(subcompany_bai.doubleValue());
|
||||
}
|
||||
if(showColumns.contains("subcompany_ye")){
|
||||
data.add(subcompany_ye.doubleValue());
|
||||
}
|
||||
if(showColumns.contains("subcompany_zhong")){
|
||||
data.add(subcompany_zhong.doubleValue());
|
||||
}
|
||||
if(showColumns.contains("subcompany_wan")){
|
||||
data.add(subcompany_wan.doubleValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(showColumns.contains("kqCalendar")) {
|
||||
Map<String, Object> detialDatas = kqReportBiz.getDetialDatas(id, fromDate, toDate, user);
|
||||
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);
|
||||
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) {
|
||||
BaseBean bb = new BaseBean();
|
||||
Map<String, Object> returnMap = new HashMap<>();
|
||||
List<Object> titleList = new ArrayList<>();
|
||||
Map<String, Object> title = null;
|
||||
//考勤二开--获取低于、高于标准时间的假期类型
|
||||
String lowType = bb.getPropValue("omlKq_main", "dybzgzsjid");
|
||||
String upType = bb.getPropValue("omlKq_main", "gybzgzsjid");
|
||||
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();
|
||||
List<Object> lsChildYsColumns = new ArrayList<>();
|
||||
List<Object> lsChildNoYsColumns = new ArrayList<>();
|
||||
int sumChildYsColumnWidth = 0;
|
||||
int sumChildNoYsColumnWidth = 0;
|
||||
for (int i = 0; leaveRules != null && i < leaveRules.size(); i++) {
|
||||
Map<String, Object> leaveRule = leaveRules.get(i);
|
||||
//考勤二开--低于、高于两个类型的假期不在请假中显示
|
||||
if (leaveRule.get("id").equals(lowType) || leaveRule.get("id").equals(upType)) {
|
||||
bb.writeLog("getChildColumnsInfo leaveRuleid: " + leaveRule);
|
||||
continue;
|
||||
}
|
||||
//end
|
||||
bb.writeLog("getChildColumnsInfo to do ");
|
||||
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);
|
||||
String ifyxjs = getIfyxj(Util.null2String(leaveRule.get("id")));
|
||||
writeLog("ifyxjs:"+ifyxjs);
|
||||
if("0".equals(ifyxjs)){
|
||||
lsChildNoYsColumns.add(title);
|
||||
sumChildNoYsColumnWidth+=65;
|
||||
}else{
|
||||
lsChildYsColumns.add(title);
|
||||
sumChildYsColumnWidth+=65;
|
||||
}
|
||||
}
|
||||
Map columnYs = new HashMap();
|
||||
columnYs.put("title","有薪假");
|
||||
columnYs.put("rowSpan",2);
|
||||
columnYs.put("width",sumChildYsColumnWidth+"");
|
||||
columnYs.put("children",lsChildYsColumns);
|
||||
titleList.add(columnYs);
|
||||
Map columnYsNo = new HashMap();
|
||||
columnYsNo.put("title","扣薪假");
|
||||
columnYsNo.put("rowSpan",2);
|
||||
columnYsNo.put("width",sumChildNoYsColumnWidth+"");
|
||||
columnYsNo.put("children",lsChildNoYsColumns);
|
||||
titleList.add(columnYsNo);
|
||||
writeLog("titleList:"+titleList.toString());
|
||||
writeLog("sumChildYsColumnWidth:"+sumChildYsColumnWidth+"sumChildNoYsColumnWidth:"+sumChildNoYsColumnWidth);
|
||||
}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;
|
||||
}
|
||||
|
||||
|
||||
public String zro(String V1)
|
||||
{
|
||||
if("".equals(V1)){
|
||||
return "0";
|
||||
}else {
|
||||
return V1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否有薪假
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
private String getIfyxj(String id){
|
||||
RecordSet rs = new RecordSet();
|
||||
String ifyxj = "";
|
||||
String sql ="select ifyxj from kq_LeaveRules where id = "+id;
|
||||
rs.execute(sql);
|
||||
if (rs.next()){
|
||||
ifyxj = Util.null2String(rs.getString("ifyxj"));
|
||||
}
|
||||
return ifyxj;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,585 @@
|
||||
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,b.subcompanyid, b.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 b.resourceid in("+resourceId+") ";
|
||||
}
|
||||
|
||||
if(viewScope.equals("4")){//我的下属
|
||||
if(allLevel.equals("1")){//所有下属
|
||||
sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'";
|
||||
}else{
|
||||
sqlWhere+=" and a.managerid="+user.getUID();//直接下属
|
||||
}
|
||||
}
|
||||
if (!"1".equals(isNoAccount)) {
|
||||
sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' ");
|
||||
}
|
||||
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);
|
||||
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 = subCompanyComInfo.getSubCompanyname(fieldValueID);
|
||||
if (fieldValue.length() == 0) {
|
||||
fieldValueID = resourceComInfo.getSubCompanyID(id);
|
||||
fieldValue = subCompanyComInfo.getSubCompanyname(fieldValueID);
|
||||
}
|
||||
data.put(fieldName + "Id", fieldValueID);
|
||||
data.put(fieldName, fieldValue);
|
||||
} else if (fieldName.equals("department")) {
|
||||
String fieldValueID = rs.getString("departmentid");
|
||||
fieldValue = departmentComInfo.getDepartmentname(fieldValueID);
|
||||
if (fieldValue.length() == 0) {
|
||||
fieldValueID = resourceComInfo.getDepartmentID(id);
|
||||
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()));
|
||||
}
|
||||
}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,278 @@
|
||||
package com.engine.kq.cmd.reportdetial;
|
||||
|
||||
import com.cloudstore.dev.api.util.Util_TableMap;
|
||||
import com.engine.common.biz.AbstractCommonCommand;
|
||||
import com.engine.common.entity.BizLogContext;
|
||||
import com.engine.core.interceptor.CommandContext;
|
||||
import com.engine.kq.biz.KQReportBiz;
|
||||
import com.engine.kq.util.PageUidFactory;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.TimeUtil;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
import weaver.systeminfo.SystemEnv;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/***
|
||||
* 应出勤明细
|
||||
*/
|
||||
public class GetSignInfoCmd extends AbstractCommonCommand<Map<String, Object>> {
|
||||
|
||||
public GetSignInfoCmd(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 dialogTitle = SystemEnv.getHtmlLabelName(391409,user.getLanguage());
|
||||
String resourceId = Util.null2String(params.get("resourceId"));
|
||||
String keyWord = Util.null2String(params.get("keyWord"));
|
||||
String fromDate = Util.null2String(params.get("fromDate"));
|
||||
String toDate = Util.null2String(params.get("toDate"));
|
||||
String typeselect =Util.null2String(params.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 viewScope = Util.null2String(params.get("viewScope"));
|
||||
String subCompanyId = Util.null2String(params.get("subCompanyId"));
|
||||
String departmentId = Util.null2String(params.get("departmentId"));
|
||||
String allLevel = Util.null2String(params.get("allLevel"));
|
||||
String isNoAccount = Util.null2String(params.get("isNoAccount"));
|
||||
String type = Util.null2String(params.get("type"));
|
||||
|
||||
// String backFields = " a.id, b.resourceid,a.departmentid, a.lastname, a.workcode, a.status, a.dsporder, kqdate, serialid,serialid as serialid1, serialid as serialid2," +
|
||||
// " workbegintime,workendtime,signintime,signouttime, attendanceMins, signMins ";
|
||||
// String sqlFrom = "from hrmresource a, kq_format_detail b ";
|
||||
// String sqlWhere = " where a.id = b.resourceid and (attendanceMins>0 or signMins>0)";
|
||||
// String orderby = " kqdate asc, workbegintime asc " ;
|
||||
// String tableString = "";
|
||||
//
|
||||
// String rightSql = new KQReportBiz().getReportRight("1",""+user.getUID(),"a");
|
||||
// if(rightSql.length()>0){
|
||||
// sqlWhere += rightSql;
|
||||
// }
|
||||
//
|
||||
// if (keyWord.length() > 0){
|
||||
// sqlWhere += " and lastname = "+keyWord;
|
||||
// }
|
||||
//
|
||||
// if (fromDate.length() > 0){
|
||||
// sqlWhere += " and kqdate >= '"+fromDate+"'";
|
||||
// }
|
||||
//
|
||||
// if (toDate.length() > 0){
|
||||
// sqlWhere += " and kqdate <= '"+toDate+"'";
|
||||
// }
|
||||
//
|
||||
// if(subCompanyId.length()>0){
|
||||
// sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") ";
|
||||
// }
|
||||
//
|
||||
// if(departmentId.length()>0){
|
||||
// sqlWhere +=" and a.departmentid in("+departmentId+") ";
|
||||
// }
|
||||
//
|
||||
// if (resourceId.length() > 0){
|
||||
// sqlWhere += " and b.resourceid in ( "+resourceId+")";
|
||||
// }
|
||||
//
|
||||
// if(viewScope.equals("4")){//我的下属
|
||||
// if(allLevel.equals("1")){//所有下属
|
||||
// sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'";
|
||||
// }else{
|
||||
// sqlWhere+=" and a.managerid="+user.getUID();//直接下属
|
||||
// }
|
||||
// }
|
||||
// if (!"1".equals(isNoAccount)) {
|
||||
// sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' ");
|
||||
// }
|
||||
//
|
||||
// if (type.equals("signdays")||type.equals("signmins")) {
|
||||
// sqlWhere += " and signmins >0 ";
|
||||
// }
|
||||
|
||||
//综合制考勤组人员去除双休日加班
|
||||
|
||||
|
||||
|
||||
//加班明细放入出勤明细 start
|
||||
String backFields = " u.id, u.resourceid,u.departmentid, u.lastname, u.workcode, u.status, u.dsporder, u.kqdate, u.serialid,u.serialid as serialid1, u.serialid as serialid2," +
|
||||
" u.workbegintime, u.workendtime, u.signintime, u.signouttime, u.attendanceMins ";
|
||||
String sqlFrom = "FROM " +
|
||||
" ( " +
|
||||
" ( " +
|
||||
" SELECT " +
|
||||
" a.subcompanyid1, " +
|
||||
" a.managerstr, " +
|
||||
" a.managerid, " +
|
||||
" a.loginid, " +
|
||||
" a.id, " +
|
||||
" b.resourceid, " +
|
||||
" a.departmentid, " +
|
||||
" a.lastname, " +
|
||||
" a.workcode, " +
|
||||
" a.status, " +
|
||||
" a.dsporder, " +
|
||||
" kqdate, " +
|
||||
" serialid, " +
|
||||
" serialid AS serialid1, " +
|
||||
" serialid AS serialid2, " +
|
||||
" workbegintime, " +
|
||||
" workendtime, " +
|
||||
" signintime, " +
|
||||
" signouttime, " +
|
||||
" attendanceMins, " +
|
||||
" signMins " +
|
||||
" FROM " +
|
||||
" hrmresource a, " +
|
||||
" kq_format_detail b " +
|
||||
" WHERE " +
|
||||
" a.id = b.resourceid " +
|
||||
" AND ( attendanceMins > 0 OR signMins > 0 ) " +
|
||||
" ) UNION ALL " +
|
||||
" ( " +
|
||||
" SELECT " +
|
||||
" a.subcompanyid1, " +
|
||||
" a.managerstr, " +
|
||||
" a.managerid, " +
|
||||
" a.loginid, " +
|
||||
" a.id, " +
|
||||
" cast(b.resourceid as int) as resourceid, " +
|
||||
" a.departmentid, " +
|
||||
" a.lastname, " +
|
||||
" a.workcode, " +
|
||||
" a.status, " +
|
||||
" a.dsporder, " +
|
||||
" b.belongdate AS kqdate, " +
|
||||
" null AS serialid, " +
|
||||
" null AS serialid1, " +
|
||||
" null AS serialid2, " +
|
||||
" b.fromtime AS workbegintime, " +
|
||||
" b.totime AS workendtime, " +
|
||||
" b.fromtime AS signintime, " +
|
||||
" b.totime AS signouttime, " +
|
||||
" cast ( cast (duration_min as float ) as int ) AS attendanceMins, " +
|
||||
" cast ( cast (duration_min as float ) as int ) AS signMins " +
|
||||
" FROM " +
|
||||
" hrmresource a, " +
|
||||
" kq_flow_overtime b " +
|
||||
" WHERE " +
|
||||
" a.id = b.resourceid " +
|
||||
" and b.changetype in (1,3) " +
|
||||
" and cast ( cast ( duration_min as float ) as int ) > 0 " +
|
||||
" ) " +
|
||||
" ) u";
|
||||
String sqlWhere = " where 1=1 ";
|
||||
String orderby = " u.kqdate asc, u.workbegintime asc " ;
|
||||
String tableString = "";
|
||||
|
||||
String rightSql = new KQReportBiz().getReportRight("1",""+user.getUID(),"u");
|
||||
|
||||
if(rightSql.length()>0){
|
||||
sqlWhere += rightSql;
|
||||
}
|
||||
|
||||
if (keyWord.length() > 0){
|
||||
sqlWhere += " and u.lastname = "+keyWord;
|
||||
}
|
||||
|
||||
if (fromDate.length() > 0){
|
||||
sqlWhere += " and u.kqdate >= '"+fromDate+"'";
|
||||
}
|
||||
|
||||
if (toDate.length() > 0){
|
||||
sqlWhere += " and u.kqdate <= '"+toDate+"'";
|
||||
}
|
||||
|
||||
if(subCompanyId.length()>0){
|
||||
sqlWhere +=" and u.subcompanyid1 in("+subCompanyId+") ";
|
||||
}
|
||||
|
||||
if(departmentId.length()>0){
|
||||
sqlWhere +=" and u.departmentid in("+departmentId+") ";
|
||||
}
|
||||
|
||||
if (resourceId.length() > 0){
|
||||
sqlWhere += " and u.resourceid in ( "+resourceId+")";
|
||||
}
|
||||
|
||||
if(viewScope.equals("4")){//我的下属
|
||||
if(allLevel.equals("1")){//所有下属
|
||||
sqlWhere+=" and u.managerstr like '%,"+user.getUID()+",%'";
|
||||
}else{
|
||||
sqlWhere+=" and u.managerid="+user.getUID();//直接下属
|
||||
}
|
||||
}
|
||||
if (!"1".equals(isNoAccount)) {
|
||||
sqlWhere += " and u.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and u.loginid<>'' ");
|
||||
}
|
||||
|
||||
if (type.equals("signdays")||type.equals("signmins")) {
|
||||
sqlWhere += " and u.signmins >0 ";
|
||||
}
|
||||
|
||||
BaseBean basebean = new BaseBean();
|
||||
basebean.writeLog("----begin----");
|
||||
basebean.writeLog("backFields: "+backFields);
|
||||
basebean.writeLog("sqlFrom: "+sqlFrom);
|
||||
basebean.writeLog("orderby: "+orderby);
|
||||
basebean.writeLog("sqlWhere: "+sqlWhere);
|
||||
basebean.writeLog("----end----");
|
||||
//end
|
||||
|
||||
|
||||
String pageUid = PageUidFactory.getHrmPageUid("KQReportDetialList");
|
||||
|
||||
tableString=""+
|
||||
"<table pageUid=\""+pageUid+"\" pagesize=\"10\" tabletype=\"none\">"+
|
||||
"<sql backfields=\""+backFields+"\" sqlform=\""+Util.toHtmlForSplitPage(sqlFrom)+"\" sqlprimarykey=\"u.id\" sqlorderby=\""+orderby+"\" sqlsortway=\"asc\" sqldistinct=\"true\" sqlwhere=\""+Util.toHtmlForSplitPage(sqlWhere)+"\"/>"+
|
||||
"<head>"+
|
||||
" <col width=\"8%\" text=\""+SystemEnv.getHtmlLabelName(413,user.getLanguage())+"\" column=\"lastname\" orderkey=\"lastname\"/>"+
|
||||
" <col width=\"8%\" text=\""+SystemEnv.getHtmlLabelName(714,user.getLanguage())+"\" column=\"workcode\" orderkey=\"workcode\"/>"+
|
||||
" <col width=\"15%\" text=\""+SystemEnv.getHtmlLabelName(124,user.getLanguage())+"\" column=\"departmentid\" orderkey=\"departmentid\" transmethod=\"weaver.hrm.company.DepartmentComInfo.getDepartmentname\"/>"+
|
||||
" <col width=\"9%\" text=\""+SystemEnv.getHtmlLabelName(602,user.getLanguage())+"\" column=\"status\" orderkey=\"status\" transmethod=\"weaver.hrm.resource.ResourceComInfo.getStatusName\" otherpara=\""+user.getLanguage()+"\"/>"+
|
||||
" <col width=\"10%\" text=\""+SystemEnv.getHtmlLabelName(97,user.getLanguage())+"\" column=\"kqdate\" orderkey=\"kqdate\"/>"+
|
||||
" <col width=\"15%\" text=\""+SystemEnv.getHtmlLabelName(390054,user.getLanguage())+"\" column=\"serialid\" orderkey=\"serialid\" transmethod=\"com.engine.kq.util.TransMethod.getSerailName\" otherpara=\"column:workbegintime+column:workendtime\"/>"+
|
||||
" <col width=\"15%\" text=\""+SystemEnv.getHtmlLabelName(390495,user.getLanguage())+"\" column=\"serialid1\" orderkey=\"signintime\" transmethod=\"com.engine.kq.util.TransMethod.getReportDetialSignInTime\" otherpara=\"column:signintime+column:kqdate+column:resourceid+"+user.getLanguage()+"\"/>"+
|
||||
" <col width=\"15%\" text=\""+SystemEnv.getHtmlLabelName(390496,user.getLanguage())+"\" column=\"serialid2\" orderkey=\"signouttime\" transmethod=\"com.engine.kq.util.TransMethod.getReportDetialSignOutTime\" otherpara=\"column:signouttime+column:kqdate+column:resourceid+"+user.getLanguage()+"\"/>"+
|
||||
" <col width=\"9%\" text=\""+SystemEnv.getHtmlLabelName(391040,user.getLanguage())+"\" column=\"attendanceMins\" orderkey=\"attendanceMins\" transmethod=\"com.engine.kq.util.TransMethod.getReportDetialMinToHour\" />"+
|
||||
// " <col width=\"9%\" text=\""+SystemEnv.getHtmlLabelName(504433,user.getLanguage())+"\" column=\"signMins\" orderkey=\"signMins\" transmethod=\"com.engine.kq.util.TransMethod.getReportDetialMinToHour\" />"+//二开
|
||||
"</head>"+
|
||||
"</table>";
|
||||
|
||||
//主要用于 显示定制列以及 表格 每页展示记录数选择
|
||||
String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom());
|
||||
Util_TableMap.setVal(sessionkey, tableString);
|
||||
|
||||
retmap.put("dialogTitle",dialogTitle);
|
||||
retmap.put("sessionkey", sessionkey);
|
||||
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,741 @@
|
||||
package com.engine.kq.util;
|
||||
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.ss.util.CellRangeAddressList;
|
||||
import org.apache.poi.ss.util.RegionUtil;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import weaver.common.DateUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.GCONST;
|
||||
import weaver.general.Util;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
public class ExcelUtil extends BaseBean {
|
||||
/*
|
||||
* 导出数据
|
||||
* */
|
||||
public Map export(Map<String, Object> workBook, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
Map<String, Object> returnMap = new HashMap<>();
|
||||
String createFile = "";
|
||||
try {
|
||||
SXSSFWorkbook workbook = new SXSSFWorkbook(); // 创建工作簿对象
|
||||
List<Object> lsSheet = (List<Object>) workBook.get("sheet");
|
||||
String fileName = Util.null2String(workBook.get("fileName"));
|
||||
if (fileName.length() == 0||true) fileName = "" + UUID.randomUUID();//解决lunix下中文文件无法生成问题
|
||||
for (int sheetNum = 0; sheetNum < lsSheet.size(); sheetNum++) {
|
||||
Map<String, Object> mySheet = (Map<String, Object>) lsSheet.get(sheetNum);
|
||||
String mySheetName = Util.null2String(mySheet.get("sheetName"));
|
||||
String sheetTitle = Util.null2String(mySheet.get("sheetTitle"));
|
||||
List<Object> sheetMemo = (List<Object>) mySheet.get("sheetMemo");
|
||||
List<Object> titleList = (List<Object>) mySheet.get("titleList");
|
||||
List<Object> dataList = (List<Object>) mySheet.get("dataList");
|
||||
List<Map<String, Object>> constraintList = (List<Map<String, Object>>) mySheet.get("constraintList");
|
||||
createFile = Util.null2String(mySheet.get("createFile"));
|
||||
|
||||
Sheet sheet = workbook.createSheet(mySheetName); // 创建工作表
|
||||
|
||||
int rowIdx = 0;
|
||||
// 产生表格标题行
|
||||
Row rowm = sheet.createRow(rowIdx);
|
||||
Cell cellTiltle = rowm.createCell(0);
|
||||
|
||||
CellStyle titleStyle = this.getTitleStyle(workbook);//获取列头样式对象
|
||||
CellStyle memoStyle = this.getMemoStyle(workbook);//获取备注样式对象
|
||||
CellStyle columnTopStyle = this.getColumnTopStyle(workbook);//获取列头样式对象
|
||||
CellStyle cellStyle = this.getCellStyle(workbook); //单元格样式对象
|
||||
|
||||
int mergedRegion = titleList.size() - 1;
|
||||
if (mergedRegion > 15) mergedRegion = 15;
|
||||
mergedRegion = getColLength(titleList);
|
||||
|
||||
CellRangeAddress region = new CellRangeAddress(rowIdx, ++rowIdx, 0, mergedRegion);
|
||||
RegionUtil.setBorderBottom(BorderStyle.THIN, region, sheet);
|
||||
RegionUtil.setBorderLeft(BorderStyle.THIN, region, sheet);
|
||||
RegionUtil.setBorderRight(BorderStyle.THIN, region, sheet);
|
||||
RegionUtil.setBorderTop(BorderStyle.THIN, region, sheet);
|
||||
sheet.addMergedRegion(region);
|
||||
cellTiltle.setCellStyle(titleStyle);
|
||||
cellTiltle.setCellValue(sheetTitle);
|
||||
|
||||
for (int i = 0; sheetMemo != null && i < sheetMemo.size(); i++) {
|
||||
rowm = sheet.createRow(++rowIdx);
|
||||
Cell cellMemo = rowm.createCell(0);
|
||||
region = new CellRangeAddress(rowIdx, ++rowIdx, 0, mergedRegion);
|
||||
RegionUtil.setBorderBottom(BorderStyle.THIN, region, sheet);
|
||||
RegionUtil.setBorderLeft(BorderStyle.THIN, region, sheet);
|
||||
RegionUtil.setBorderRight(BorderStyle.THIN, region, sheet);
|
||||
RegionUtil.setBorderTop(BorderStyle.THIN, region, sheet);
|
||||
sheet.addMergedRegion(region);
|
||||
cellMemo.setCellStyle(memoStyle);
|
||||
cellMemo.setCellValue(Util.null2String(sheetMemo.get(i)));
|
||||
}
|
||||
|
||||
// // 定义所需列数
|
||||
// int columnNum = titleList.size();
|
||||
// HSSFRow rowRowName = sheet.createRow(++rowIdx); // 在索引2的位置创建行(最顶端的行开始的第二行)
|
||||
//
|
||||
// // 将列头设置到sheet的单元格中
|
||||
// for (int n = 0; n < columnNum; n++) {
|
||||
// Map title = (Map) titleList.get(n);
|
||||
//
|
||||
// HSSFCell cellRowName = rowRowName.createCell(n); //创建列头对应个数的单元格
|
||||
// cellRowName.setCellType(HSSFCell.CELL_TYPE_STRING); //设置列头单元格的数据类型
|
||||
// HSSFRichTextString text = new HSSFRichTextString(Util.null2String(title.get("title")));
|
||||
// cellRowName.setCellValue(text); //设置列头单元格的值
|
||||
// cellRowName.setCellStyle(columnTopStyle); //设置列头单元格样式
|
||||
// if (n == 0) {
|
||||
// sheet.setColumnWidth(n, Util.getIntValue(Util.null2String(title.get("width"))));
|
||||
// } else {
|
||||
// sheet.setColumnWidth(n, Util.getIntValue(Util.null2String(title.get("width"))));
|
||||
// }
|
||||
// }
|
||||
|
||||
rowIdx = this.initDynamicTitle(sheet, titleList, columnTopStyle, rowIdx, workbook);
|
||||
|
||||
//将查询出的数据设置到sheet对应的单元格中
|
||||
for (int i = 0; dataList != null && i < dataList.size(); i++) {
|
||||
List<Object> obj = (List<Object>) dataList.get(i);//遍历每个对象
|
||||
Row row = sheet.createRow(i + rowIdx + 1);//创建所需的行数
|
||||
|
||||
for (int j = 0; j < obj.size(); j++) {
|
||||
Cell cell = null; //设置单元格的数据类型
|
||||
cell = row.createCell(j, CellType.STRING);
|
||||
cell.setCellValue(Util.null2String(obj.get(j))); //设置单元格的值
|
||||
cell.setCellStyle(cellStyle); //设置单元格样式
|
||||
}
|
||||
}
|
||||
|
||||
// int columnNum = this.getColumnLength(titleList);
|
||||
// //让列宽随着导出的列长自动适应
|
||||
// for (int colNum = 0; colNum < columnNum; colNum++) {
|
||||
// int columnWidth = sheet.getColumnWidth(colNum) / 256;
|
||||
// for (int rowNum = 0; rowNum < sheet.getLastRowNum(); rowNum++) {
|
||||
// HSSFRow currentRow;
|
||||
// //当前行未被使用过
|
||||
// if (sheet.getRow(rowNum) == null) {
|
||||
// currentRow = sheet.createRow(rowNum);
|
||||
// } else {
|
||||
// currentRow = sheet.getRow(rowNum);
|
||||
// }
|
||||
// if (currentRow.getCell(colNum) != null) {
|
||||
// //取得当前的单元格
|
||||
// HSSFCell currentCell = currentRow.getCell(colNum);
|
||||
// //如果当前单元格类型为字符串
|
||||
// if (currentCell.getCellTypeEnum() == CellType.STRING) {
|
||||
// int length = currentCell.getStringCellValue().getBytes().length;
|
||||
// if (columnWidth < length) {
|
||||
// //将单元格里面值大小作为列宽度
|
||||
// columnWidth = length;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// //再根据不同列单独做下处理
|
||||
// if (colNum == 0) {
|
||||
// sheet.setColumnWidth(colNum, (columnWidth - 2) * 256);
|
||||
// } else {
|
||||
// sheet.setColumnWidth(colNum, (columnWidth + 4) * 256);
|
||||
// }
|
||||
// }
|
||||
for (int i = 0; constraintList != null && i < constraintList.size(); i++) {
|
||||
Map<String, Object> constraint = constraintList.get(i);
|
||||
int firstRow = Util.getIntValue(Util.null2String(constraint.get("firstRow")), 0);
|
||||
int endRow = Util.getIntValue(Util.null2String(constraint.get("endRow")), 0);
|
||||
int firstCol = Util.getIntValue(Util.null2String(constraint.get("firstCol")), 0);
|
||||
int endCol = Util.getIntValue(Util.null2String(constraint.get("endCol")), 0);
|
||||
//设置下拉框数据
|
||||
String[] datas = (String[]) constraint.get("constraintDatas");
|
||||
String hiddenSheetName = "constraintDataSheet"+i;
|
||||
Sheet hiddenSheet = workbook.createSheet(hiddenSheetName);
|
||||
workbook.setSheetHidden(workbook.getSheetIndex(hiddenSheet), true);
|
||||
for (int j = 0; j< datas.length; j++) {
|
||||
hiddenSheet.createRow(j).createCell(0).setCellValue(datas[j]);
|
||||
}
|
||||
DataValidationHelper helper = sheet.getDataValidationHelper();
|
||||
String formulaId = hiddenSheetName + "!$A$1:$A$" + datas.length;
|
||||
DataValidationConstraint dataValidationConstraint = helper.createFormulaListConstraint(formulaId);
|
||||
CellRangeAddressList cellRangeAddressList = new CellRangeAddressList(firstRow, endRow, firstCol, endCol);
|
||||
DataValidation dataValidation = helper.createValidation(dataValidationConstraint, cellRangeAddressList);
|
||||
//处理Excel兼容性问题
|
||||
if (dataValidation instanceof DataValidation) {
|
||||
dataValidation.setSuppressDropDownArrow(true);
|
||||
dataValidation.setShowErrorBox(true);
|
||||
} else {
|
||||
dataValidation.setSuppressDropDownArrow(false);
|
||||
}
|
||||
sheet.addValidationData(dataValidation);
|
||||
}
|
||||
|
||||
|
||||
// for (int i = 0; constraintList != null && i < constraintList.size(); i++) {
|
||||
// Map<String, Object> constraint = constraintList.get(i);
|
||||
// int firstRow = Util.getIntValue(Util.null2String(constraint.get("firstRow")), 0);
|
||||
// int endRow = Util.getIntValue(Util.null2String(constraint.get("endRow")), 0);
|
||||
// int firstCol = Util.getIntValue(Util.null2String(constraint.get("firstCol")), 0);
|
||||
// int endCol = Util.getIntValue(Util.null2String(constraint.get("endCol")), 0);
|
||||
//
|
||||
// //设置下拉框数据
|
||||
// String[] datas = (String[]) constraint.get("constraintDatas");
|
||||
// DataValidationHelper helper = sheet.getDataValidationHelper();
|
||||
// DataValidationConstraint dataValidationConstraint = helper.createExplicitListConstraint(datas);
|
||||
// CellRangeAddressList cellRangeAddressList = new CellRangeAddressList(firstRow, endRow, firstCol, endCol);
|
||||
// DataValidation dataValidation = helper.createValidation(dataValidationConstraint, cellRangeAddressList);
|
||||
// //处理Excel兼容性问题
|
||||
// if (dataValidation instanceof DataValidation) {
|
||||
// dataValidation.setSuppressDropDownArrow(true);
|
||||
// dataValidation.setShowErrorBox(true);
|
||||
// } else {
|
||||
// dataValidation.setSuppressDropDownArrow(false);
|
||||
// }
|
||||
// sheet.addValidationData(dataValidation);
|
||||
// }
|
||||
}
|
||||
|
||||
if (workbook != null) {
|
||||
if (createFile.equals("1")) {
|
||||
String filePath = GCONST.getRootPath() + "/hrm/kq/tmpFile/";
|
||||
File file = new File(filePath);
|
||||
if (!file.exists()) {
|
||||
file.mkdirs();
|
||||
}
|
||||
|
||||
fileName = fileName +"("+DateUtil.getNowDateTimeStr()+")";
|
||||
String url = filePath + fileName + ".xlsx";
|
||||
String realUrl = "/hrm/kq/tmpFile/" + fileName + ".xlsx";
|
||||
FileOutputStream fOut = new FileOutputStream(url);
|
||||
workbook.write(fOut);
|
||||
fOut.flush();
|
||||
fOut.close();
|
||||
returnMap.put("url", realUrl);
|
||||
} else {
|
||||
response.reset();
|
||||
response.setContentType("application/vnd.ms-excel;charset=utf-8");
|
||||
//response.setCharacterEncoding("utf-8");
|
||||
String header = request.getHeader("User-Agent").toUpperCase();
|
||||
if (header.contains("MSIE") || header.contains("TRIDENT") || header.contains("EDGE")) {
|
||||
fileName = URLEncoder.encode(fileName, "utf-8");
|
||||
fileName = fileName.replace("+", "%20"); //IE下载文件名空格变+号问题
|
||||
} else {
|
||||
fileName = new String(fileName.getBytes("utf-8"), "ISO_8859_1");
|
||||
}
|
||||
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
|
||||
response.setContentType("application/msexcel");
|
||||
response.setContentType("application/x-msdownload");
|
||||
OutputStream responseOutput = response.getOutputStream();
|
||||
workbook.write(responseOutput);
|
||||
responseOutput.flush();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return returnMap;
|
||||
}
|
||||
|
||||
/*
|
||||
* 列头单元格样式
|
||||
*/
|
||||
private CellStyle getMemoStyle(SXSSFWorkbook workbook) {
|
||||
// 设置字体
|
||||
Font font = workbook.createFont();
|
||||
//设置字体大小
|
||||
font.setFontHeightInPoints((short) 10);
|
||||
//字体加粗
|
||||
font.setBold(true);
|
||||
//设置字体名字
|
||||
font.setFontName("宋体");
|
||||
//设置样式;
|
||||
CellStyle style = workbook.createCellStyle();
|
||||
//设置底边框;
|
||||
style.setBorderBottom(BorderStyle.THIN);
|
||||
//设置底边框颜色;
|
||||
style.setBottomBorderColor(IndexedColors.BLACK.index);
|
||||
//设置左边框;
|
||||
style.setBorderLeft(BorderStyle.THIN);
|
||||
//设置左边框颜色;
|
||||
style.setLeftBorderColor(IndexedColors.BLACK.index);
|
||||
//设置右边框;
|
||||
style.setBorderRight(BorderStyle.THIN);
|
||||
//设置右边框颜色;
|
||||
style.setRightBorderColor(IndexedColors.BLACK.index);
|
||||
//设置顶边框;
|
||||
style.setBorderTop(BorderStyle.THIN);
|
||||
//设置顶边框颜色;
|
||||
style.setTopBorderColor(IndexedColors.BLACK.index);
|
||||
//在样式用应用设置的字体;
|
||||
style.setFont(font);
|
||||
//设置自动换行;
|
||||
style.setWrapText(false);
|
||||
//设置水平对齐的样式为居中对齐;
|
||||
style.setAlignment(HorizontalAlignment.LEFT);
|
||||
//设置垂直对齐的样式为居中对齐;
|
||||
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
|
||||
return style;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 列头单元格样式
|
||||
*/
|
||||
private CellStyle getTitleStyle(SXSSFWorkbook workbook) {
|
||||
// 设置字体
|
||||
Font font = workbook.createFont();
|
||||
//设置字体大小
|
||||
font.setFontHeightInPoints((short) 14);
|
||||
//字体加粗
|
||||
font.setBold(true);
|
||||
//设置字体名字
|
||||
font.setFontName("宋体");
|
||||
//设置样式;
|
||||
CellStyle style = workbook.createCellStyle();
|
||||
//设置底边框;
|
||||
style.setBorderBottom(BorderStyle.THIN);
|
||||
//设置底边框颜色;
|
||||
style.setBottomBorderColor(IndexedColors.BLACK.index);
|
||||
//设置左边框;
|
||||
style.setBorderLeft(BorderStyle.THIN);
|
||||
//设置左边框颜色;
|
||||
style.setLeftBorderColor(IndexedColors.BLACK.index);
|
||||
//设置右边框;
|
||||
style.setBorderRight(BorderStyle.THIN);
|
||||
//设置右边框颜色;
|
||||
style.setRightBorderColor(IndexedColors.BLACK.index);
|
||||
//设置顶边框;
|
||||
style.setBorderTop(BorderStyle.THIN);
|
||||
//设置顶边框颜色;
|
||||
style.setTopBorderColor(IndexedColors.BLACK.index);
|
||||
//在样式用应用设置的字体;
|
||||
style.setFont(font);
|
||||
//设置自动换行;
|
||||
style.setWrapText(false);
|
||||
//设置水平对齐的样式为居中对齐;
|
||||
style.setAlignment(HorizontalAlignment.CENTER);
|
||||
//设置垂直对齐的样式为居中对齐;
|
||||
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
return style;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 列头单元格样式
|
||||
*/
|
||||
private CellStyle getNewColumnTopStyle(SXSSFWorkbook workbook) {
|
||||
// 设置字体
|
||||
Font font = workbook.createFont();
|
||||
//设置字体大小
|
||||
font.setFontHeightInPoints((short) 11);
|
||||
//字体加粗
|
||||
font.setBold(true);
|
||||
//设置字体名字
|
||||
font.setFontName("宋体");
|
||||
//设置样式;
|
||||
CellStyle style = workbook.createCellStyle();
|
||||
//设置底边框;
|
||||
style.setBorderBottom(BorderStyle.THIN);
|
||||
//设置底边框颜色;
|
||||
style.setBottomBorderColor(IndexedColors.BLACK.index);
|
||||
//设置左边框;
|
||||
style.setBorderLeft(BorderStyle.THIN);
|
||||
//设置左边框颜色;
|
||||
style.setLeftBorderColor(IndexedColors.BLACK.index);
|
||||
//设置右边框;
|
||||
style.setBorderRight(BorderStyle.THIN);
|
||||
//设置右边框颜色;
|
||||
style.setRightBorderColor(IndexedColors.BLACK.index);
|
||||
//设置顶边框;
|
||||
style.setBorderTop(BorderStyle.THIN);
|
||||
//设置顶边框颜色;
|
||||
style.setTopBorderColor(IndexedColors.BLACK.index);
|
||||
//在样式用应用设置的字体;
|
||||
style.setFont(font);
|
||||
//设置自动换行;
|
||||
style.setWrapText(true);
|
||||
//设置水平对齐的样式为左对齐;
|
||||
style.setAlignment(HorizontalAlignment.LEFT);
|
||||
//设置垂直对齐的样式为居中对齐;
|
||||
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
|
||||
return style;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 列头单元格样式
|
||||
*/
|
||||
private CellStyle getColumnTopStyle(SXSSFWorkbook workbook) {
|
||||
// 设置字体
|
||||
Font font = workbook.createFont();
|
||||
//设置字体大小
|
||||
font.setFontHeightInPoints((short) 11);
|
||||
//字体加粗
|
||||
font.setBold(true);
|
||||
//设置字体名字
|
||||
font.setFontName("宋体");
|
||||
//设置样式;
|
||||
CellStyle style = workbook.createCellStyle();
|
||||
//设置底边框;
|
||||
style.setBorderBottom(BorderStyle.THIN);
|
||||
//设置底边框颜色;
|
||||
style.setBottomBorderColor(IndexedColors.BLACK.index);
|
||||
//设置左边框;
|
||||
style.setBorderLeft(BorderStyle.THIN);
|
||||
//设置左边框颜色;
|
||||
style.setLeftBorderColor(IndexedColors.BLACK.index);
|
||||
//设置右边框;
|
||||
style.setBorderRight(BorderStyle.THIN);
|
||||
//设置右边框颜色;
|
||||
style.setRightBorderColor(IndexedColors.BLACK.index);
|
||||
//设置顶边框;
|
||||
style.setBorderTop(BorderStyle.THIN);
|
||||
//设置顶边框颜色;
|
||||
style.setTopBorderColor(IndexedColors.BLACK.index);
|
||||
//在样式用应用设置的字体;
|
||||
style.setFont(font);
|
||||
//设置自动换行;
|
||||
style.setWrapText(true);
|
||||
//设置水平对齐的样式为居中对齐;
|
||||
style.setAlignment(HorizontalAlignment.CENTER);
|
||||
//设置垂直对齐的样式为居中对齐;
|
||||
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
|
||||
return style;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* 列数据信息单元格样式
|
||||
*/
|
||||
private CellStyle getCellStyle(SXSSFWorkbook workbook) {
|
||||
// 设置字体
|
||||
Font font = workbook.createFont();
|
||||
//设置字体大小
|
||||
//font.setFontHeightInPoints((short)10);
|
||||
//字体加粗
|
||||
//font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
|
||||
//设置字体名字
|
||||
font.setFontName("宋体");
|
||||
//设置样式;
|
||||
CellStyle style = workbook.createCellStyle();
|
||||
//设置底边框;
|
||||
style.setBorderBottom(BorderStyle.THIN);
|
||||
//设置底边框颜色;
|
||||
style.setBottomBorderColor(IndexedColors.BLACK.index);
|
||||
//设置左边框;
|
||||
style.setBorderLeft(BorderStyle.THIN);
|
||||
//设置左边框颜色;
|
||||
style.setLeftBorderColor(IndexedColors.BLACK.index);
|
||||
//设置右边框;
|
||||
style.setBorderRight(BorderStyle.THIN);
|
||||
//设置右边框颜色;
|
||||
style.setRightBorderColor(IndexedColors.BLACK.index);
|
||||
//设置顶边框;
|
||||
style.setBorderTop(BorderStyle.THIN);
|
||||
//设置顶边框颜色;
|
||||
style.setTopBorderColor(IndexedColors.BLACK.index);
|
||||
//在样式用应用设置的字体;
|
||||
style.setFont(font);
|
||||
//设置自动换行;
|
||||
style.setWrapText(false);
|
||||
//设置水平对齐的样式为居中对齐;
|
||||
style.setAlignment(HorizontalAlignment.LEFT);
|
||||
//设置垂直对齐的样式为居中对齐;
|
||||
style.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
|
||||
return style;
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String groupid = "1";
|
||||
String filename = "c://33e2a90d-3347-490c-afff-21de0ef3e3af.xlsx";
|
||||
int startRow = 3;
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql = "";
|
||||
try {
|
||||
//必要的权限判断
|
||||
List<List> lsParams = null;
|
||||
List params = null;
|
||||
|
||||
Workbook workbook = WorkbookFactory.create(new FileInputStream(filename));
|
||||
for (int idx = 0; idx < workbook.getNumberOfSheets(); idx++) {
|
||||
Sheet sheet = workbook.getSheetAt(idx);
|
||||
Row row = null;
|
||||
Cell cell = null;
|
||||
lsParams = new ArrayList();
|
||||
for (int i = startRow; startRow <= sheet.getLastRowNum() && i <= sheet.getLastRowNum(); i++) {
|
||||
row = sheet.getRow(i);
|
||||
if (row == null) {
|
||||
continue;
|
||||
}
|
||||
params = new ArrayList();
|
||||
for (int cellIndex = 0; cellIndex < row.getLastCellNum(); cellIndex++) {
|
||||
cell = row.getCell((short) cellIndex);
|
||||
if (cell == null) continue;
|
||||
params.add(getCellValue(cell).trim());
|
||||
}
|
||||
params.add(groupid);
|
||||
if (Util.null2String(params.get(0)).length() > 0) {
|
||||
lsParams.add(params);
|
||||
}
|
||||
}
|
||||
if (idx == 0) {
|
||||
sql = "insert into kq_loaction (loactionname,longitude,latitude,address,groupid) values (?,?,?,?,?) ";
|
||||
} else {
|
||||
sql = "insert into kq_wifi (wifiname,mac,groupid) values (?,?,?) ";
|
||||
}
|
||||
rs.executeBatchSql(sql, lsParams);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
new BaseBean().writeLog(e);
|
||||
}
|
||||
}
|
||||
|
||||
public int initDynamicTitle(Sheet sheet, List<Object> columns, CellStyle columnTopStyle, int rowIdx, SXSSFWorkbook workbook) {
|
||||
int cur_rowIndx = rowIdx+1;
|
||||
//title 总行数
|
||||
int title_rows = cur_rowIndx+getRowNums(columns)-1;
|
||||
createHeaderRow(sheet, cur_rowIndx, 0,columns,columnTopStyle,title_rows, workbook);
|
||||
return title_rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建表头
|
||||
*/
|
||||
private int createHeaderRow(Sheet sheet, int index, int cellIndex,
|
||||
List<Object> columnName, CellStyle columnTopStyle, int title_rows, SXSSFWorkbook workbook) {
|
||||
Row row = sheet.getRow(index) == null ? sheet.createRow(index) : sheet.getRow(index);
|
||||
int rows = getRowNums(columnName);
|
||||
for (int i = 0, exportFieldTitleSize = columnName.size(); i < exportFieldTitleSize; i++) {
|
||||
Map<String,Object> column = (Map<String, Object>) columnName.get(i);
|
||||
String title = Util.null2String(column.get("title"));
|
||||
String flag = Util.null2String(column.get("flag"));//考勤二开
|
||||
if (flag.equals("KqReport")) {
|
||||
columnTopStyle = getNewColumnTopStyle(workbook);
|
||||
} else {
|
||||
columnTopStyle = getColumnTopStyle(workbook);
|
||||
}//end
|
||||
createStringCell(row, cellIndex, title, columnTopStyle);
|
||||
if (column.get("children") != null) {
|
||||
List<Object> childchildColumns = (List<Object>) column.get("children");
|
||||
// 保持原来的
|
||||
int tempCellIndex = cellIndex;
|
||||
cellIndex = createHeaderRow(sheet, rows == 1 ? index : index + 1, cellIndex, childchildColumns,columnTopStyle,
|
||||
title_rows, workbook);//考勤二开
|
||||
if (childchildColumns.size() > 1) {
|
||||
addMergedRegion(sheet, index, index, tempCellIndex, cellIndex - 1);
|
||||
}
|
||||
cellIndex--;
|
||||
}else{
|
||||
addMergedRegion(sheet, index, title_rows, cellIndex, cellIndex);
|
||||
}
|
||||
cellIndex++;
|
||||
}
|
||||
return cellIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并单元格
|
||||
* @param sheet
|
||||
* @param firstRow
|
||||
* @param lastRow
|
||||
* @param firstCol
|
||||
* @param lastCol
|
||||
*/
|
||||
public void addMergedRegion(Sheet sheet, int firstRow, int lastRow, int firstCol, int lastCol) {
|
||||
try {
|
||||
if(firstRow == lastRow && firstCol == lastCol){
|
||||
return ;
|
||||
}
|
||||
CellRangeAddress region = new CellRangeAddress(firstRow, lastRow, firstCol, lastCol);
|
||||
RegionUtil.setBorderBottom(BorderStyle.THIN, region, sheet);
|
||||
RegionUtil.setBorderLeft(BorderStyle.THIN, region, sheet);
|
||||
RegionUtil.setBorderRight(BorderStyle.THIN, region, sheet);
|
||||
RegionUtil.setBorderTop(BorderStyle.THIN, region, sheet);
|
||||
sheet.addMergedRegion(region);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 创建文本类型的Cell
|
||||
*/
|
||||
public void createStringCell(Row row, int cellIndex, String title, CellStyle columnTopStyle) {
|
||||
Cell cellRowName = row.createCell(cellIndex); //创建列头对应个数的单元格
|
||||
cellRowName.setCellType(CellType.STRING); //设置列头单元格的数据类型
|
||||
cellRowName.setCellValue(title); //设置列头单元格的值
|
||||
cellRowName.setCellStyle(columnTopStyle); //设置列头单元格样式
|
||||
}
|
||||
|
||||
public int initTitle(Sheet sheet, List<Object> columns, CellStyle columnTopStyle, int rowIdx) {
|
||||
List<Object> lsMergedRegion = new ArrayList<>();
|
||||
Map<String, Object> mergedRegion = null;
|
||||
int firstTitleRow = rowIdx + 1;
|
||||
int lastTitleRow = rowIdx + 2;
|
||||
Row rowRowName = sheet.createRow(++rowIdx); // 在索引2的位置创建行(最顶端的行开始的第二行)
|
||||
Row childRowRowName = null;
|
||||
// 定义所需列数
|
||||
Map<String, Object> column = null;
|
||||
List<Object> childColumn = null;
|
||||
int colIdx = 0;
|
||||
for (int i = 0; i < columns.size(); i++) {
|
||||
column = (Map<String, Object>) columns.get(i);
|
||||
childColumn = (List<Object>) column.get("children");
|
||||
Cell cellRowName = rowRowName.createCell(colIdx++); //创建列头对应个数的单元格
|
||||
cellRowName.setCellType(CellType.STRING); //设置列头单元格的数据类型
|
||||
cellRowName.setCellValue(Util.null2String(column.get("title"))); //设置列头单元格的值
|
||||
cellRowName.setCellStyle(columnTopStyle); //设置列头单元格样式
|
||||
|
||||
if (Util.getIntValue(Util.null2String(column.get("rowSpan"))) == 2) {
|
||||
if (childRowRowName == null) {
|
||||
childRowRowName = sheet.createRow(++rowIdx);
|
||||
}
|
||||
mergedRegion = new HashMap<String, Object>();
|
||||
mergedRegion.put("startRow", firstTitleRow);
|
||||
mergedRegion.put("overRow", lastTitleRow);
|
||||
mergedRegion.put("startCol", colIdx - 1);
|
||||
mergedRegion.put("overCol", colIdx - 1);
|
||||
lsMergedRegion.add(mergedRegion);
|
||||
}
|
||||
|
||||
if (childColumn != null) {
|
||||
colIdx--;
|
||||
mergedRegion = new HashMap<String, Object>();
|
||||
mergedRegion.put("startRow", firstTitleRow);
|
||||
mergedRegion.put("overRow", firstTitleRow);
|
||||
mergedRegion.put("startCol", colIdx);
|
||||
for (int j = 0; j < childColumn.size(); j++) {
|
||||
column = (Map<String, Object>) childColumn.get(j);
|
||||
cellRowName = childRowRowName.createCell(colIdx++); //创建列头对应个数的单元格
|
||||
cellRowName.setCellType(CellType.STRING); //设置列头单元格的数据类型
|
||||
cellRowName.setCellValue(Util.null2String(column.get("title"))); //设置列头单元格的值
|
||||
cellRowName.setCellStyle(columnTopStyle);
|
||||
}
|
||||
mergedRegion.put("overCol", colIdx - 1);
|
||||
if (childColumn.size() > 1) {
|
||||
lsMergedRegion.add(mergedRegion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < lsMergedRegion.size(); i++) {
|
||||
mergedRegion = (Map<String, Object>) lsMergedRegion.get(i);
|
||||
Integer startrow = Util.getIntValue(Util.null2String(mergedRegion.get("startRow")));
|
||||
Integer overrow = Util.getIntValue(Util.null2String(mergedRegion.get("overRow")));
|
||||
Integer startcol = Util.getIntValue(Util.null2String(mergedRegion.get("startCol")));
|
||||
Integer overcol = Util.getIntValue(Util.null2String(mergedRegion.get("overCol")));
|
||||
CellRangeAddress region = new CellRangeAddress(startrow, overrow, startcol, overcol);
|
||||
RegionUtil.setBorderBottom(BorderStyle.THIN, region, sheet);
|
||||
RegionUtil.setBorderLeft(BorderStyle.THIN, region, sheet);
|
||||
RegionUtil.setBorderRight(BorderStyle.THIN, region, sheet);
|
||||
RegionUtil.setBorderTop(BorderStyle.THIN, region, sheet);
|
||||
sheet.addMergedRegion(region);
|
||||
}
|
||||
return rowIdx;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取具体总共有多少列
|
||||
* @param columns
|
||||
* @return
|
||||
*/
|
||||
private int getColLength(List<Object> columns) {
|
||||
int length = -1;// 从0开始计算单元格的
|
||||
for(int i =0 ; i < columns.size() ; i++){
|
||||
Map<String,Object> column = (Map<String, Object>) columns.get(i);
|
||||
if (column.get("children") != null) {
|
||||
List<Object> childchildColumns = (List<Object>) column.get("children");
|
||||
length += getColLength(childchildColumns) + 1;
|
||||
} else {
|
||||
length++;
|
||||
}
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取具体总共有多少行
|
||||
*/
|
||||
public int getRowNums(List<Object> columns) {
|
||||
int cnt = 1;
|
||||
for (int i = 0; i < columns.size(); i++) {
|
||||
Map<String,Object> column = (Map<String, Object>) columns.get(i);
|
||||
if (column.get("children") != null) {
|
||||
List<Object> childchildColumns = (List<Object>) column.get("children");
|
||||
int tmpcnt = 1+getRowNums(childchildColumns);
|
||||
if(tmpcnt > cnt){
|
||||
cnt = tmpcnt;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(cnt > 1){
|
||||
return cnt;
|
||||
}else{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public int getColumnLength(List<Object> columns) {
|
||||
int columnLength = 0;
|
||||
Map<String, Object> column = null;
|
||||
for (int i = 0; i < columns.size(); i++) {
|
||||
column = (Map<String, Object>) columns.get(i);
|
||||
if (column.get("colSpan") != null) {
|
||||
columnLength += Util.getIntValue(Util.null2String(column.get("colSpan")));
|
||||
} else {
|
||||
columnLength++;
|
||||
}
|
||||
}
|
||||
return columnLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* /**
|
||||
* 获取excel单元格值
|
||||
*
|
||||
* @param cell 要读取的单元格对象
|
||||
* @return
|
||||
*/
|
||||
public static String getCellValue(Cell cell) {
|
||||
String cellValue = "";
|
||||
if (cell == null)
|
||||
return "";
|
||||
switch (cell.getCellType()) {
|
||||
case BOOLEAN: // 得到Boolean对象的方法
|
||||
cellValue = String.valueOf(cell.getBooleanCellValue());
|
||||
break;
|
||||
case NUMERIC:
|
||||
if (org.apache.poi.ss.usermodel.DateUtil.isCellDateFormatted(cell)) {// 先看是否是日期格式
|
||||
SimpleDateFormat sft = new SimpleDateFormat("yyyy-MM-dd");
|
||||
cellValue = String.valueOf(sft.format(cell.getDateCellValue())); // 读取日期格式
|
||||
} else {
|
||||
cellValue = String.valueOf(new Double(cell.getNumericCellValue())); // 读取数字
|
||||
if (cellValue.endsWith(".0"))
|
||||
cellValue = cellValue.substring(0, cellValue.indexOf("."));
|
||||
}
|
||||
break;
|
||||
case FORMULA: // 读取公式
|
||||
cellValue = cell.getCellFormula();
|
||||
break;
|
||||
case STRING: // 读取String
|
||||
cellValue = cell.getStringCellValue();
|
||||
break;
|
||||
}
|
||||
|
||||
return cellValue;
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.engine.omron.controller;
|
||||
|
||||
import com.engine.common.util.ParamUtil;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.omron.service.KqReportService;
|
||||
import com.engine.omron.service.impl.KqReportServiceImpl;
|
||||
import com.google.gson.Gson;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.Map;
|
||||
|
||||
public class KqReportController {
|
||||
|
||||
public KqReportService getKqReportService(User user) {
|
||||
return ServiceUtil.getService(KqReportServiceImpl.class,user);
|
||||
}
|
||||
|
||||
@Path("/getKqReportDesc")
|
||||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String getKqReportDesc(@Context HttpServletRequest request, @Context HttpServletResponse response){
|
||||
User user = HrmUserVarify.getUser(request,response);
|
||||
Map<String, Object> params = ParamUtil.request2Map(request);
|
||||
Map<String, Object> apiDatas = getKqReportService(user).getKqReportDesc(params);
|
||||
return new Gson().toJson(apiDatas);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.engine.omron.controller;
|
||||
|
||||
import com.engine.common.util.ParamUtil;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.omron.service.OverTimeService;
|
||||
import com.engine.omron.service.impl.OverTimeServiceImpl;
|
||||
import com.google.gson.Gson;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.Map;
|
||||
|
||||
public class OverTimeController {
|
||||
|
||||
public OverTimeService getOverTimeService(User user) {
|
||||
return ServiceUtil.getService(OverTimeServiceImpl.class,user);
|
||||
}
|
||||
|
||||
@Path("/checkOverTimeWorkflow")
|
||||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String checkOverTimeWorkflow(@Context HttpServletRequest request, @Context HttpServletResponse response){
|
||||
User user = HrmUserVarify.getUser(request,response);
|
||||
Map<String, Object> params = ParamUtil.request2Map(request);
|
||||
Map<String, Object> apiDatas = getOverTimeService(user).checkOverTimeWorkflow(params);
|
||||
return new Gson().toJson(apiDatas);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.engine.omron.service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface KqReportService {
|
||||
/**
|
||||
* 检查加班申请流程是否重复提交
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> getKqReportDesc(Map<String, Object> params);
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.engine.omron.service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface OverTimeService {
|
||||
/**
|
||||
* 检查加班申请流程是否重复提交
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> checkOverTimeWorkflow(Map<String, Object> params);
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package com.engine.omron.service.impl;
|
||||
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.omron.service.KqReportService;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class KqReportServiceImpl extends Service implements KqReportService {
|
||||
|
||||
BaseBean basebean = new BaseBean();
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getKqReportDesc(Map<String, Object> params) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
String desc = "";
|
||||
String acqDescSql = " select smnr from uf_kqhzbsmbd order by id desc";
|
||||
basebean.writeLog("getKqReportDesc: " + acqDescSql);
|
||||
rs.executeQuery(acqDescSql);
|
||||
while (rs.next()) {
|
||||
String temp = Util.null2String(rs.getString("smnr"));
|
||||
desc = desc + temp;
|
||||
}
|
||||
basebean.writeLog("desc: " + desc);
|
||||
result.put("code", 200);
|
||||
result.put("data", desc);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package com.engine.omron.service.impl;
|
||||
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.omron.service.OverTimeService;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.StringUtil;
|
||||
import weaver.general.Util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class OverTimeServiceImpl extends Service implements OverTimeService {
|
||||
|
||||
BaseBean basebean = new BaseBean();
|
||||
|
||||
@Override
|
||||
public Map<String, Object> checkOverTimeWorkflow(Map<String, Object> params) {
|
||||
basebean.writeLog("----------OverTimeServiceImpl checkOverTimeWorkflow Start----------");
|
||||
|
||||
Map<String, Object> result = new HashMap<String, Object>();
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
try {
|
||||
//申请人
|
||||
Integer applicant = Util.getIntValue(Util.null2String(params.get("applicant")));
|
||||
basebean.writeLog("applicant: " + applicant );
|
||||
|
||||
//申请月份
|
||||
String appMonth = Util.null2String(params.get("applicationMonth"));
|
||||
basebean.writeLog("appMonth: " + appMonth );
|
||||
|
||||
Integer requestId = Util.getIntValue(Util.null2String(params.get("requestId")));
|
||||
basebean.writeLog("requestId: " + requestId );
|
||||
|
||||
if ( applicant == -1 || applicant == 0 ) {
|
||||
result.put("code",500);
|
||||
result.put("msg","申请人不正确,请更换申请人!");
|
||||
return result;
|
||||
}
|
||||
|
||||
if ( applicant == 1 ) {
|
||||
result.put("code",500);
|
||||
result.put("msg","申请人为系统管理员,请确认是否需要更换申请人!");
|
||||
return result;
|
||||
}
|
||||
|
||||
if ( StringUtil.isEmpty(appMonth)) {
|
||||
result.put("code",500);
|
||||
result.put("msg","申请月份未填写,请先填写申请月份!");
|
||||
return result;
|
||||
}
|
||||
|
||||
String overtimeTableName = basebean.getPropValue("omlKq_main","overtimeTableName");
|
||||
basebean.writeLog("overtimeTableName: " + overtimeTableName );
|
||||
|
||||
if ( StringUtil.isEmpty( overtimeTableName)) {
|
||||
result.put("code",500);
|
||||
result.put("msg","请先配置加班申请表名至配置文件!");
|
||||
return result;
|
||||
}
|
||||
|
||||
Integer number = -1;
|
||||
|
||||
String checkOverTimeSql = "select count(*) as num from " + overtimeTableName + " where jbry = ? and sqyf = ? ";
|
||||
basebean.writeLog("checkOverTimeSql: " + checkOverTimeSql);
|
||||
|
||||
rs.executeQuery(checkOverTimeSql, applicant, appMonth);
|
||||
while ( rs.next()) {
|
||||
number = Util.getIntValue( Util.null2String( rs.getString("num")));
|
||||
}
|
||||
basebean.writeLog("number: " + number );
|
||||
|
||||
if ( number == 1 ) {//验证当前流程与已有流程是否为同一条
|
||||
if ( requestId > -1) {
|
||||
Integer checkReq = -1;
|
||||
String checkRequestIdSql = "select requestid from " + overtimeTableName + " where jbry = ? and sqyf = ? ";
|
||||
rs.executeQuery(checkRequestIdSql, applicant, appMonth);
|
||||
while (rs.next()) {
|
||||
checkReq = Util.getIntValue(Util.null2String(rs.getString("requestid")));
|
||||
}
|
||||
if ( checkReq > -1 && checkReq.equals(requestId) ) {//当前提交流程和流程表中的保存状态流程为同一条
|
||||
result.put("code",200);
|
||||
result.put("msg","可以提交该月份的加班申请。");
|
||||
return result;
|
||||
}
|
||||
} else {//流程为新建
|
||||
result.put("code",500);
|
||||
result.put("msg","该人员已经创建或者提交过该月份的加班申请,不可再提交!");
|
||||
return result;
|
||||
}
|
||||
|
||||
} else if ( number > 1 ) {
|
||||
result.put("code",500);
|
||||
result.put("msg","该人员已经提交过该月份的加班申请,不可再提交!");
|
||||
return result;
|
||||
}
|
||||
|
||||
result.put("code",200);
|
||||
result.put("msg","可以提交该月份的加班申请。");
|
||||
return result;
|
||||
}catch(Exception e){
|
||||
basebean.writeLog("OverTimeServiceImpl checkOverTimeWorkflow Exception: " + e);
|
||||
result.put("code",500);
|
||||
result.put("msg","检查异常");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package weaver.interfaces.omron.job;
|
||||
|
||||
import com.engine.kq.biz.KQOverTimeRuleCalBiz;
|
||||
import com.wbi.util.StringUtil;
|
||||
import weaver.common.DateUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 历史考勤数据变更班次后重新计算加班时长定时任务
|
||||
*/
|
||||
public class NewOverTimeJob extends BaseCronJob {
|
||||
BaseBean basebean = new BaseBean();
|
||||
@Override
|
||||
public void execute() {
|
||||
|
||||
try{
|
||||
basebean.writeLog("======================NewOverTimeJob Start======================");
|
||||
|
||||
RecordSet rs = new RecordSet();
|
||||
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.DAY_OF_MONTH, 1);
|
||||
Date firstDayOfMonthDate = calendar.getTime();
|
||||
|
||||
//当前月的第一天
|
||||
String fromDate = cn.hutool.core.date.DateUtil.format(firstDayOfMonthDate,"yyyy-MM-dd");
|
||||
basebean.writeLog("fromDate: "+fromDate);
|
||||
//当前日期
|
||||
String toDate = cn.hutool.core.date.DateUtil.format(new Date(),"yyyy-MM-dd");
|
||||
basebean.writeLog("toDate: "+toDate);
|
||||
|
||||
String eventtype = "历史考勤数据变更班次后重新计算加班时长";
|
||||
|
||||
//获取考勤人员
|
||||
List<String> resourceIds = new ArrayList<>();
|
||||
String getResSql = "select id from hrmresource where status in (0,1,2,3)";
|
||||
basebean.writeLog("getResSql: "+getResSql);
|
||||
|
||||
rs.executeQuery(getResSql);
|
||||
while (rs.next()) {
|
||||
String id = Util.null2String(rs.getString("id"));
|
||||
if (StringUtil.isNotBlank(id) ) {
|
||||
resourceIds.add(id);
|
||||
}
|
||||
}
|
||||
basebean.writeLog("resourceIds: "+resourceIds);
|
||||
|
||||
//根据人员循环执行
|
||||
for (String resourceid: resourceIds) {
|
||||
basebean.writeLog("===========人员重新计算加班start===========");
|
||||
basebean.writeLog("resourceid: "+resourceid);
|
||||
|
||||
KQOverTimeRuleCalBiz kqOverTimeRuleCalBiz = new KQOverTimeRuleCalBiz();
|
||||
kqOverTimeRuleCalBiz.buildOvertime(resourceid, fromDate, toDate, eventtype);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}catch (Exception e){
|
||||
basebean.writeLog("NewOverTimeJob Exception: " + e);
|
||||
basebean.writeLog("加班生成数据报错:KQOverTimeRuleCalBiz:");
|
||||
StringWriter errorsWriter = new StringWriter();
|
||||
e.printStackTrace(new PrintWriter(errorsWriter));
|
||||
basebean.writeLog(errorsWriter.toString());
|
||||
}
|
||||
|
||||
basebean.writeLog("======================NewOverTimeJob End======================");
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue