1
0
Fork 0
dev
chenwei 1 year ago
commit 0d7251bd17

@ -0,0 +1,10 @@
package com.api.mingfeng.controller;
import javax.ws.rs.Path;
/**
* @author chenwnj
*/
@Path("/mingfeng/overtimewf")
public class OverTimeController extends com.engine.mingfeng.controller.OverTimeController {
}

@ -0,0 +1,12 @@
package com.api.mingfeng.controller;
import javax.ws.rs.Path;
/**
* @author chenwnj
* @date 2023/11/6
* @description
**/
@Path("/mingfeng/performan")
public class PerformanController extends com.engine.mingfeng.controller.PerformanController{
}

@ -0,0 +1,318 @@
package com.engine.kq.biz;
import com.alibaba.fastjson.JSON;
import com.engine.kq.entity.TimeScopeEntity;
import com.engine.kq.entity.WorkTimeEntity;
import com.engine.kq.log.KQLog;
import java.io.PrintWriter;
import java.io.StringWriter;
import weaver.common.DateUtil;
import weaver.conn.BatchRecordSet;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.systeminfo.SystemEnv;
import java.util.*;
/**
*
*/
public class KQFormatBiz extends BaseBean {
private String today = DateUtil.getCurrentDate();
protected KQLog kqLog = new KQLog();
/**
*
*
* @param lsFormatParams
*/
public void format(List<List<Object>> lsFormatParams) {
BatchRecordSet bRs = new BatchRecordSet();
String sql = "";
List<Object> params = null;
try {
if (KQSettingsBiz.getKqformatthread()) {
sql = " insert into kq_format_pool (resourceid, kqdate) values (?,?)";
if (KQSettingsBiz.getKqformatAccurate()){
sql = " insert into kq_format_pool (resourceid, kqdate, exectime) values (?,?,?)";
lsFormatParams = processFormatParams(lsFormatParams);
}
bRs.executeBatchSql(sql, lsFormatParams);
} else {
String resourceid = "";
String kqdate = "";
for (int i = 0; lsFormatParams != null && i < lsFormatParams.size(); i++) {
params = lsFormatParams.get(i);
resourceid = Util.null2String(params.get(0));
kqdate = Util.null2String(params.get(1));
new KQFormatData().formatKqDate(resourceid, kqdate);
}
}
} catch (Exception e) {
writeLog(" KQFormatData.formatKqDate lsFormatParams >>>>>>>>>" + e);
}
}
public void formatDateByKQDate(String kqdate) {
String sql = "";
RecordSet rs = new RecordSet();
List<List<Object>> lsFormatParams = new ArrayList<>();
List<Object> formatParams = null;
try {
if (DateUtil.timeInterval(kqdate, today) < 0) {
kqLog.info("今天之后的无需处理的数据kqdate==" + kqdate + "today==" + today);
return;//今天之后的无需处理
}
sql = " SELECT distinct resourceid FROM ( " +
new KQGroupBiz().getGroupMemberSql() + ") t ";
rs.executeQuery(sql);
while (rs.next()) {
String resourceid = rs.getString("resourceid");
if(Util.null2String(kqdate).length()!=10)return;
formatParams = new ArrayList<>();
formatParams.add(resourceid);
formatParams.add(kqdate);
lsFormatParams.add(formatParams);
}
this.format(lsFormatParams);
} catch (Exception e) {
writeLog(e);
kqLog.info(e);
}
}
public void formatDateByGroupId(String groupid, String kqdate) {
String sql = "";
RecordSet rs = new RecordSet();
List<List<Object>> lsFormatParams = new ArrayList<>();
List<Object> formatParams = null;
try {
if (DateUtil.timeInterval(kqdate, today) < 0) {
kqLog.info("今天之后的无需处理的数据groupid==" + groupid + "kqdate==" + kqdate + "today==" + today);
return;//今天之后的无需处理
}
KQGroupComInfo kqGroupComInfo = new KQGroupComInfo();
KQGroupBiz kqGroupBiz = new KQGroupBiz();
String kqtype = kqGroupComInfo.getKqtype(groupid);
if (kqtype.equals("2")) {//排班
sql = "select resourceid, kqdate from kq_shiftschedule where groupid=" + groupid + " and kqdate='" + kqdate + "' and (isdelete is null or isdelete <> '1') ";
} else {
sql = "select resourceid,'" + kqdate + "' from (" + kqGroupBiz.getGroupMemberSql(groupid) + ") t ";
}
rs.executeQuery(sql);
while (rs.next()) {
String resourceid = rs.getString("resourceid");
if(Util.null2String(kqdate).length()!=10)return;
formatParams = new ArrayList<>();
formatParams.add(resourceid);
formatParams.add(kqdate);
lsFormatParams.add(formatParams);
}
this.format(lsFormatParams);
} catch (Exception e) {
writeLog(e);
kqLog.info(e);
}
}
public void formatDate(String resourceid, String kqdate) {
List<List<Object>> lsFormatParams = new ArrayList<>();
List<Object> formatParams = null;
try {
if (DateUtil.timeInterval(kqdate, today) < 0) {
kqLog.info("今天之后的无需处理的数据resourceid==" + resourceid + "kqdate==" + kqdate + "today==" + today);
return;//今天之后的无需处理
}
if(Util.null2String(kqdate).length()!=10)return;
formatParams = new ArrayList<>();
formatParams.add(resourceid);
formatParams.add(kqdate);
lsFormatParams.add(formatParams);
this.format(lsFormatParams);
} catch (Exception e) {
writeLog(e);
kqLog.info(e);
}
}
public void delFormatData(String resourceid, String kqdate) {
RecordSet rs = new RecordSet();
String sql = "";
try {
sql = " delete from kq_format_detail where resourceid =? and kqdate = ? ";//删除非工作日数据
rs.executeUpdate(sql, resourceid, kqdate);
sql = " delete from kq_format_total where resourceid =? and kqdate = ? ";//删除非工作日数据
rs.executeUpdate(sql, resourceid, kqdate);
} catch (Exception e) {
writeLog(e);
kqLog.info(e);
}
}
public void clearFormatPool() {
RecordSet rs = new RecordSet();
String sql = "";
try {
//删除三天前的数据格式化数据
if (rs.getDBType().equals("sqlserver")) {
sql = " delete from kq_format_pool where status = 1 and datediff(day,created,getdate()) > 1";
} else if (rs.getDBType().equals("mysql")) {
sql = " delete from kq_format_pool where status = 1 and datediff(now(),created) > 1";
}
else if (rs.getDBType().equals("postgresql")) {
sql = " delete from kq_format_pool where status = 1 and datediff(now(),created) > 1";
}
else if (rs.getOrgindbtype().equals("st")) {
sql = " delete from kq_format_pool where status = 1 and to_number(trunc(sysdate) - trunc(created)) > 1";
} else {
sql = " delete from kq_format_pool where status = 1 and trunc(sysdate) - trunc(created) > 1";
}
rs.executeUpdate(sql);
} catch (Exception e) {
writeLog(e);
}
}
public Map<String,Object> getDefinedField(){
Map<String,Object> retMap = new HashMap<>();
String definedField = "";
String definedFieldSum = "";
String definedParam = "";
String definedParamSum = "";
KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo();
while (kqReportFieldComInfo.next()) {
if (!Util.null2String(kqReportFieldComInfo.getIsenable()).equals("1")) continue;
if (Util.null2String(kqReportFieldComInfo.getIsSystem()).equals("1")) continue;
if(KQReportFieldComInfo.cascadekey2fieldname.keySet().contains(kqReportFieldComInfo.getFieldname()))continue;
if(definedField.length()>0)definedField+=",";
definedField+=kqReportFieldComInfo.getFieldname();
if(definedFieldSum.length()>0)definedFieldSum+=",";
definedFieldSum+="sum("+kqReportFieldComInfo.getFieldname()+") as "+kqReportFieldComInfo.getFieldname();
if(definedParam.length()>0)definedParam+=",";
definedParam+="?";
if(definedParamSum.length()>0)definedParamSum+=",";
definedParamSum+="sum("+kqReportFieldComInfo.getFieldname()+")";
String[] cascadekeys = Util.splitString(Util.null2String(kqReportFieldComInfo.getCascadekey()),",");
for(int i=0;cascadekeys!=null&&i<cascadekeys.length;i++){
String fieldname = Util.null2String(cascadekeys[i]);
if(fieldname.length()==0)continue;
if(definedField.length()>0)definedField+=",";
definedField+=fieldname;
if(definedFieldSum.length()>0)definedFieldSum+=",";
definedFieldSum+="sum("+fieldname+") as "+fieldname;
if(definedParam.length()>0)definedParam+=",";
definedParam+="?";
if(definedParamSum.length()>0)definedParamSum+=",";
definedParamSum+="sum("+fieldname+")";
}
}
retMap.put("definedField",definedField);
retMap.put("definedFieldSum",definedFieldSum);
retMap.put("definedParam",definedParam);
retMap.put("definedParamSum",definedParamSum);
return retMap;
}
public boolean needCal(String workDate, String workTime){
boolean needCalForgotCheckMins = true;
if (KQSettingsBiz.getKqformatAccurate()) {
workTime = new KQTimesArrayComInfo().turn48to24Time(workTime);
if (workDate.length() > 0 && workTime.length() > 0) {
String currentFullTime = DateUtil.getFullDate();
String endTime = workDate + " " + workTime;
if (DateUtil.timeInterval(currentFullTime, endTime) > 0) {
//当前时间之后的状态无效计算
needCalForgotCheckMins = false;
}
}
}
return needCalForgotCheckMins;
}
public boolean needCal(String workDate, String workTime,String isneedcal){
boolean needCalForgotCheckMins = true;
boolean isneedformat = "1".equals(isneedcal);
if (isneedformat) {
workTime = new KQTimesArrayComInfo().turn48to24Time(workTime);
if (workDate.length() > 0 && workTime.length() > 0) {
String currentFullTime = DateUtil.getFullDate();
String endTime = workDate + " " + workTime;
if (DateUtil.timeInterval(currentFullTime, endTime) > 0) {
//当前时间之后的状态无效计算
needCalForgotCheckMins = false;
}
}
}
return needCalForgotCheckMins;
}
private List<List<Object>> processFormatParams(List<List<Object>> lsFormatParams) {
List<List<Object>> lsFormatParamsTmp = new ArrayList<>();
try {
KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo();
KQWorkTime kqWorkTime = new KQWorkTime();
List<Object> formatParams = null;
for(int i=0;i<lsFormatParams.size();i++){
formatParams = lsFormatParams.get(i);
String resourceId = Util.null2String(formatParams.get(0));
String kqDate = Util.null2String(formatParams.get(1));
formatParams = new ArrayList<>();
formatParams.add(resourceId);
formatParams.add(kqDate);
formatParams.add(new java.sql.Timestamp(DateUtil.getCalendar(DateUtil.getFullDate()).getTimeInMillis()));
lsFormatParamsTmp.add(formatParams);
String nextDate = DateUtil.addDate(kqDate, 1);//下一天日期
WorkTimeEntity workTime = kqWorkTime.getWorkTime(resourceId, kqDate);
List<TimeScopeEntity> lsWorkTime = new ArrayList<>();
if (workTime != null) {
lsWorkTime = workTime.getWorkTime();//工作时间
for (int j = 0; lsWorkTime != null && j < lsWorkTime.size(); j++) {
TimeScopeEntity workTimeScope = lsWorkTime.get(j);
String workBeginDateTime = workTimeScope.getBeginTimeAcross() ? nextDate : kqDate;
workBeginDateTime+=" "+kqTimesArrayComInfo.turn48to24Time(workTimeScope.getBeginTime())+":00:00";
String workEndDateTime = workTimeScope.getEndTimeAcross() ? nextDate : kqDate;
workEndDateTime+=" "+kqTimesArrayComInfo.turn48to24Time(workTimeScope.getEndTime())+":00:00";
formatParams = new ArrayList<>();
formatParams.add(resourceId);
formatParams.add(kqDate);
formatParams.add(new java.sql.Timestamp(DateUtil.getCalendar(workBeginDateTime).getTimeInMillis()));
lsFormatParamsTmp.add(formatParams);
formatParams = new ArrayList<>();
formatParams.add(resourceId);
formatParams.add(kqDate);
formatParams.add(new java.sql.Timestamp(DateUtil.getCalendar(workEndDateTime).getTimeInMillis()));
lsFormatParamsTmp.add(formatParams);
}
}else{
formatParams = new ArrayList<>();
formatParams.add(resourceId);
formatParams.add(kqDate);
lsFormatParamsTmp.add(formatParams);
}
}
}catch (Exception e) {
StringWriter errorsWriter = new StringWriter();
e.printStackTrace(new PrintWriter(errorsWriter));
kqLog.info(errorsWriter.toString());
}
return lsFormatParamsTmp;
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,677 @@
package com.engine.kq.cmd.report;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.kq.biz.*;
import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit;
import com.engine.kq.util.ExcelUtil;
import com.engine.kq.util.KQDurationCalculatorUtil;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.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 ExportDailyExcelCmd extends AbstractCommonCommand<Map<String, Object>> {
private HttpServletRequest request;
private HttpServletResponse response;
private List<String> lsFieldDataKey;
BaseBean bb = new BaseBean();
public ExportDailyExcelCmd(Map<String, Object> params, HttpServletRequest request, HttpServletResponse response, User user) {
this.user = user;
this.params = params;
this.request = request;
this.response = response;
this.lsFieldDataKey = new ArrayList<>();
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> retmap = new HashMap<String, Object>();
RecordSet rs = new RecordSet();
String sql = "";
try {
SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo();
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
ResourceComInfo resourceComInfo = new ResourceComInfo();
JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo();
ShiftManagementToolKit shiftManagementToolKit = new ShiftManagementToolKit();
KQWorkTime kqWorkTime = new KQWorkTime();
KQReportBiz kqReportBiz = new KQReportBiz();
KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz();
new KQReportBiz().insertKqReportExportLog(params, user);
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
String attendanceSerial = Util.null2String(jsonObj.get("attendanceSerial"));
String fromDate = Util.null2String(jsonObj.get("fromDate"));
String toDate = Util.null2String(jsonObj.get("toDate"));
String typeselect =Util.null2String(jsonObj.get("typeselect"));
if(typeselect.length()==0)typeselect = "3";
if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){
if(typeselect.equals("1")){
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
}else{
fromDate = TimeUtil.getDateByOption(typeselect,"0");
toDate = TimeUtil.getDateByOption(typeselect,"1");
}
}
//人员状态
String status = Util.null2String(jsonObj.get("status"));
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
String departmentId = Util.null2String(jsonObj.get("departmentId"));
String resourceId = Util.null2String(jsonObj.get("resourceId"));
String allLevel = Util.null2String(jsonObj.get("allLevel"));
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));
String viewScope = Util.null2String(jsonObj.get("viewScope"));
List<String> showColumns = Util.splitString2List(Util.null2String(jsonObj.get("showColumns")),",");
showColumns.add("lastname");
showColumns.add("kqdate");
showColumns.add("serialid");
showColumns.removeIf(showColumn->showColumn.trim().equals(""));
List<String> tmpShowColumns = new ArrayList<>();
for(String showColumn:showColumns){
tmpShowColumns.add(showColumn);
String cascadekey = "";
if(showColumn.equals("signin1")){
cascadekey = "signout1";
}else if(showColumn.equals("signin2")){
cascadekey = "signout2";
}else if(showColumn.equals("signin3")){
cascadekey = "signout3";
}else if(showColumn.equals("beLate")){
cascadekey = "beLateMins";
}else if(showColumn.equals("leaveEearly")){
cascadekey = "leaveEarlyMins";
}else if(showColumn.equals("graveBeLate")){
cascadekey = "graveBeLateMins";
}else if(showColumn.equals("graveLeaveEarly")){
cascadekey = "graveLeaveEarlyMins";
}else if(showColumn.equals("absenteeism")){
cascadekey = "absenteeismMins";
}else if(showColumn.equals("overtime")){
tmpShowColumns.add("overtime_4leave");
tmpShowColumns.add("overtime_nonleave");
tmpShowColumns.add("workingDayOvertime_nonleave");
tmpShowColumns.add("workingDayOvertime_4leave");
tmpShowColumns.add("restDayOvertime_nonleave");
tmpShowColumns.add("restDayOvertime_4leave");
tmpShowColumns.add("holidayOvertime_4leave");
tmpShowColumns.add("holidayOvertime_nonleave");
}
if(cascadekey.length()>0){
tmpShowColumns.add(cascadekey);
}
}
showColumns = tmpShowColumns;
String today = DateUtil.getCurrentDate();
if(DateUtil.compDate(today, toDate)>0){//结束如期不大于今天
toDate = today;
}
String rightSql = new KQReportBiz().getReportRight("2",""+user.getUID(),"a");
LinkedHashMap<String, Object> workbook = new LinkedHashMap<>();
List<Object> lsSheet = new ArrayList<>();
Map<String, Object> sheet = null;
List<Object> titleList = new ArrayList<>();
Map<String,Object> title = null;
List<List<Object>> dataList = new ArrayList<>();
List<Object> data = null;
List<Map<String,Object>> constraintList = null;
Map<String,Object> constraint = null;
sheet = new HashMap<>();
sheet.put("sheetName", SystemEnv.getHtmlLabelName( 390352, user.getLanguage()));
sheet.put("sheetTitle", SystemEnv.getHtmlLabelName( 390352, user.getLanguage()));
List<Map<String, Object>> leaveRules = kqLeaveRulesBiz.getAllLeaveRules();
Map<String,Object> mapChildColumnInfo = null;
List<Object> childColumns = null;
KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo();
while (kqReportFieldComInfo.next()){
if(Util.null2String(kqReportFieldComInfo.getParentid()).length()>0)continue;
if(!kqReportFieldComInfo.getReportType().equals("all") && !kqReportFieldComInfo.getReportType().equals("daily"))continue;
if (!showColumns.contains(kqReportFieldComInfo.getFieldname())&&!showColumns.contains(kqReportFieldComInfo.getParentid())) continue;
if("leave".equalsIgnoreCase(kqReportFieldComInfo.getFieldname())&&leaveRules.size()==0){
continue;
}
title = new HashMap<>();
String unitType = KQReportBiz.getUnitType(kqReportFieldComInfo, user);
if(unitType.length()>0){
title.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage())+ "(" + unitType + ")");
}else{
title.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage()));
}
title.put("width",30*256);
this.lsFieldDataKey.add(kqReportFieldComInfo.getFieldname());
mapChildColumnInfo = this.getChildColumnsInfo(kqReportFieldComInfo.getFieldname(),user);
childColumns = (List<Object>)mapChildColumnInfo.get("childColumns");
if(childColumns.size()>0) {//跨列width取子列的width
title.put("children", childColumns);
title.put("colSpan",childColumns.size());
}else{
title.put("rowSpan", 3);
}
titleList.add(title);
}
sheet.put("titleList", titleList);
// 没有权限的人最大只支持查询本季
Map<String, String> getRealDate = new KQReportBiz().realDate(fromDate, toDate, user, "2");
fromDate = getRealDate.get("fromDate");
toDate = getRealDate.get("toDate");
if("-1".equals(fromDate) || "-1".equals(toDate)) {
retmap.put("status", "1");
return retmap;
}
String forgotBeginWorkCheck_field = " b.forgotbeginworkcheck ";
if(rs.getDBType().equalsIgnoreCase("oracle")&&!Util.null2String(rs.getOrgindbtype()).equals("dm")&&!Util.null2String(rs.getOrgindbtype()).equals("st")) {
forgotBeginWorkCheck_field = " nvl(b.forgotBeginWorkCheck,0) ";
}else if((rs.getDBType()).equalsIgnoreCase("mysql")){
forgotBeginWorkCheck_field = " ifnull(b.forgotBeginWorkCheck,0) ";
}else {
forgotBeginWorkCheck_field = " isnull(b.forgotBeginWorkCheck,0) ";
}
String backFields = " a.id,a.lastname,a.subcompanyid1 as subcompanyid,a.departmentid, a.workcode,b.jobtitle,a.dsporder," +
" b.kqdate, b.workdays,b.workMins,b.serialid, b.attendancedays,b.attendanceMins,b.beLate," +
" b.beLateMins,b.graveBeLate,b.graveBeLateMins,b.leaveEearly,b.leaveEarlyMins,b.graveLeaveEarly," +
" b.graveLeaveEarlyMins,b.absenteeism,b.signdays,b.signmins, "+
" b.absenteeismMins ,(b.forgotCheck+"+forgotBeginWorkCheck_field+") forgotCheck ";
String sqlFrom = " from hrmresource a, kq_format_total b where a.id= b.resourceid and b.kqdate >='"+fromDate+"' and b.kqdate <='"+toDate+"'";
String sqlWhere = rightSql;
if(subCompanyId.length()>0){
sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") ";
}
if(departmentId.length()>0){
sqlWhere +=" and a.departmentid in("+departmentId+") ";
}
if(resourceId.length()>0){
sqlWhere +=" and a.id in("+resourceId+") ";
}
if(viewScope.equals("4")){//我的下属
if(allLevel.equals("1")){//所有下属
sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'";
}else{
sqlWhere+=" and a.managerid="+user.getUID();//直接下属
}
}
if (!"1".equals(isNoAccount)) {
sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' ");
}
if(status.length()>0){
if (!status.equals("8") && !status.equals("9")) {
sqlWhere += " and a.status = "+status+ "";
}else if (status.equals("8")) {
sqlWhere += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) ";
}
}
String orderBy = " order by a.dsporder asc, a.lastname asc , b.kqDate asc ";
String descOrderBy = " order by a.dsporder desc, a.lastname desc ";
sql = "select "+backFields + sqlFrom + sqlWhere+orderBy;
// #1475814-概述:满足考勤报分部部门显示及导出时显示全路径
String fullPathMainKey = "show_full_path";
KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo();
String isShowFullPath = Util.null2String(kqSettingsComInfo.getMain_val(fullPathMainKey),"0");
Map<String,String> serialdata = new HashMap<>();
boolean isneedcal = KQSettingsBiz.getKqformatAccurate();
params.put("isneedcal",isneedcal?"1":"0");
Map<String,Object> flowData = kqReportBiz.getDailyFlowData(params,user);
rs.execute(sql);
while (rs.next()) {
data = new ArrayList<>();
String id = rs.getString("id");
String kqdate = rs.getString("kqdate");
String tmpkey = id+"|"+kqdate+"|";
// Map<String,Object> signDetailInfo = this.getSignDetailInfo(id,kqdate);
for (int fieldDataKeyIdx =0;fieldDataKeyIdx<lsFieldDataKey.size();fieldDataKeyIdx++) {
String fieldName = lsFieldDataKey.get(fieldDataKeyIdx);
String fieldid = KQReportFieldComInfo.field2Id.get(fieldName);
String fieldValue = "";
if(fieldName.equals("subcompany")){
String tmpSubcompanyId = Util.null2String(rs.getString("subcompanyid"));
if(tmpSubcompanyId.length()==0){
tmpSubcompanyId = Util.null2String(resourceComInfo.getSubCompanyID(id));
}
fieldValue = "1".equals(isShowFullPath) ?
SubCompanyComInfo.getSubcompanyRealPath(tmpSubcompanyId, "/", "0") :
subCompanyComInfo.getSubCompanyname(tmpSubcompanyId);
// fieldValue = subCompanyComInfo.getSubCompanyname(tmpSubcompanyId);
}else if(fieldName.equals("department")){
String tmpDepartmentId = Util.null2String(rs.getString("departmentid"));
if(tmpDepartmentId.length()==0){
tmpDepartmentId = Util.null2String(resourceComInfo.getDepartmentID(id));
}
fieldValue = "1".equals(isShowFullPath) ?
departmentComInfo.getDepartmentRealPath(tmpDepartmentId, "/", "0") :
departmentComInfo.getDepartmentname(tmpDepartmentId);
// fieldValue = departmentComInfo.getDepartmentname(tmpDepartmentId);
}else if(fieldName.equals("jobtitle")){
String tmpJobtitleId = Util.null2String(rs.getString("jobtitle"));
if(tmpJobtitleId.length()==0){
tmpJobtitleId = Util.null2String(resourceComInfo.getJobTitle(id));
}
fieldValue = jobTitlesComInfo.getJobTitlesname(tmpJobtitleId);
} else if(fieldName.equals("serialid")){
String serialid = Util.null2String(rs.getString("serialid"));
if(serialid.length()>0){
// fieldValue = Util.formatMultiLang(shiftManagementToolKit.getShiftOnOffWorkSections(serialid, user.getLanguage()));
if(null != serialdata && serialdata.containsKey(serialid)){
fieldValue = serialdata.get(serialid);
}else{
String tmpserialname = Util.formatMultiLang(shiftManagementToolKit.getShiftOnOffWorkSections(serialid, user.getLanguage()));
fieldValue = tmpserialname;
serialdata.put(serialid,tmpserialname);
}
}
} else if(fieldName.equals("signin1")){
fieldValue = Util.null2String(flowData.get(tmpkey+"signintime1"));
data.add(fieldValue);
fieldValue = Util.null2String(flowData.get(tmpkey+"signinstatus1"));
data.add(fieldValue);
continue;
} else if(fieldName.equals("signin2")){
fieldValue = Util.null2String(flowData.get(tmpkey+"signintime2"));
data.add(fieldValue);
fieldValue = Util.null2String(flowData.get(tmpkey+"signinstatus2"));
data.add(fieldValue);
continue;
} else if(fieldName.equals("signin3")){
fieldValue = Util.null2String(flowData.get(tmpkey+"signintime3"));
data.add(fieldValue);
fieldValue = Util.null2String(flowData.get(tmpkey+"signinstatus3"));
data.add(fieldValue);
continue;
} else if(fieldName.equals("signout1")){
fieldValue = Util.null2String(flowData.get(tmpkey+"signouttime1"));
data.add(fieldValue);
fieldValue = Util.null2String(flowData.get(tmpkey+"signoutstatus1"));
data.add(fieldValue);
continue;
} else if(fieldName.equals("signout2")){
fieldValue = Util.null2String(flowData.get(tmpkey+"signouttime2"));
data.add(fieldValue);
fieldValue = Util.null2String(flowData.get(tmpkey+"signoutstatus2"));
data.add(fieldValue);
continue;
} else if(fieldName.equals("signout3")){
fieldValue = Util.null2String(flowData.get(tmpkey+"signouttime3"));
data.add(fieldValue);
fieldValue = Util.null2String(flowData.get(tmpkey+"signoutstatus3"));
data.add(fieldValue);
continue;
} else if(fieldName.equals("leave")){
//请假
List<Map<String, Object>> allLeaveRules = KQLeaveRulesBiz.getAllLeaveRules();
Map<String, Object> leaveRule = null;
for(int i=0;allLeaveRules!=null&&i<allLeaveRules.size();i++){
leaveRule = (Map<String, Object>)allLeaveRules.get(i);
String flowType = Util.null2String("leaveType_"+leaveRule.get("id"));
fieldValue = Util.null2String(flowData.get(id+"|"+kqdate+"|"+flowType));
String flowLeaveBackType = Util.null2String("leavebackType_" + leaveRule.get("id"));
String leavebackData = Util.null2s(Util.null2String(flowData.get(id + "|" + kqdate + "|" + flowLeaveBackType)), "0.0");
String b_flowLeaveData = "";
String flowLeaveData = "";
try {
//以防止出现精度问题
if (fieldValue.length() == 0) {
fieldValue = "0.0";
}
if (leavebackData.length() == 0) {
leavebackData = "0.0";
}
BigDecimal b_leaveData = new BigDecimal(fieldValue);
BigDecimal b_leavebackData = new BigDecimal(leavebackData);
b_flowLeaveData = b_leaveData.subtract(b_leavebackData).toString();
if(Util.getDoubleValue(b_flowLeaveData, -1) < 0){
b_flowLeaveData = "0.0";
}
} catch (Exception e) {
writeLog("ExportDailyExcelCmd:fieldValue" + fieldValue + ":leavebackData:" + leavebackData + ":" + e);
}
//考虑下冻结的数据
if (b_flowLeaveData.length() > 0) {
flowLeaveData = KQDurationCalculatorUtil.getDurationRound(b_flowLeaveData);
} else {
flowLeaveData = KQDurationCalculatorUtil.getDurationRound(Util.null2String(Util.getDoubleValue(fieldValue, 0.0) - Util.getDoubleValue(leavebackData, 0.0)));
}
fieldValue = flowLeaveData;
data.add(fieldValue);
}
}else if(fieldName.equals("overtime")){
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id +"|"+kqdate+ "|workingDayOvertime_nonleave")));
data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("workingDayOvertime_nonleave"))));
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id +"|"+kqdate+ "|restDayOvertime_nonleave")));
data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("restDayOvertime_nonleave"))));
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id +"|"+kqdate+ "|holidayOvertime_nonleave")));
data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("holidayOvertime_nonleave"))));
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id +"|"+kqdate+ "|workingDayOvertime_4leave")));
data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("workingDayOvertime_4leave"))));
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id +"|"+kqdate+ "|restDayOvertime_4leave")));
data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("restDayOvertime_4leave"))));
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id +"|"+kqdate+ "|holidayOvertime_4leave")));
data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("holidayOvertime_4leave"))));
double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|"+kqdate+"|workingDayOvertime_4leave")));
workingDayOvertime_4leave = workingDayOvertime_4leave<0?0:workingDayOvertime_4leave;
double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|"+kqdate+"|restDayOvertime_4leave")));
restDayOvertime_4leave = restDayOvertime_4leave<0?0:restDayOvertime_4leave;
double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|"+kqdate+"|holidayOvertime_4leave")));
holidayOvertime_4leave = holidayOvertime_4leave<0?0:holidayOvertime_4leave;
double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|"+kqdate+"|workingDayOvertime_nonleave")));
workingDayOvertime_nonleave = workingDayOvertime_nonleave<0?0:workingDayOvertime_nonleave;
double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|"+kqdate+"|restDayOvertime_nonleave")));
restDayOvertime_nonleave = restDayOvertime_nonleave<0?0:restDayOvertime_nonleave;
double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|"+kqdate+"|holidayOvertime_nonleave")));
holidayOvertime_nonleave = holidayOvertime_nonleave<0?0:holidayOvertime_nonleave;
fieldValue = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_4leave+restDayOvertime_4leave+holidayOvertime_4leave+
workingDayOvertime_nonleave+restDayOvertime_nonleave+holidayOvertime_nonleave));
data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("overtimeTotal"))));
continue;
}else if(fieldName.equals("businessLeave") || fieldName.equals("officialBusiness")){
String businessLeaveData = Util.null2s(Util.null2String(flowData.get(id+"|"+kqdate+"|"+fieldName)),"0.0");
String backType = fieldName+"_back";
String businessLeavebackData = Util.null2s(Util.null2String(flowData.get(id+"|"+kqdate+"|"+backType)),"0.0");
String businessLeave = "";
try{
//以防止出现精度问题
if(businessLeaveData.length() == 0){
businessLeaveData = "0.0";
}
if(businessLeavebackData.length() == 0){
businessLeavebackData = "0.0";
}
BigDecimal b_businessLeaveData = new BigDecimal(businessLeaveData);
BigDecimal b_businessLeavebackData = new BigDecimal(businessLeavebackData);
businessLeave = b_businessLeaveData.subtract(b_businessLeavebackData).toString();
if(Util.getDoubleValue(businessLeave, -1) < 0){
businessLeave = "0.0";
}
}catch (Exception e){
}
fieldValue = KQDurationCalculatorUtil.getDurationRound(businessLeave);
}else if(fieldName.equals("kqdate")){
fieldValue=kqdate+" "+com.engine.portal.util.DateUtil.getDayWeekOfDate1(DateUtil.parseToDate(kqdate));
} else if (fieldName.equals("reportEve")) {//考勤二开--日报转出差
bb.writeLog("reportEve start");
Integer temp = Util.getIntValue(Util.null2String(flowData.get("DailyReportEve|" + resourceId + "|" +kqdate)));
bb.writeLog("temp: " + temp);
if (temp ==1 ) {
data.add(temp);
} else {
data.add(0);
}
bb.writeLog("data: " + data);
continue;
} else {
fieldValue = Util.null2String(rs.getString(fieldName));
fieldValue = getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(fieldid));
}
if(!fieldName.equals("leave")) {
fieldValue = Util.formatMultiLang(fieldValue, "" + user.getLanguage());
data.add(fieldValue);
}
}
dataList.add(data);
}
sheet.put("dataList", dataList);
sheet.put("constraintList",constraintList);
sheet.put("createFile", "1");
lsSheet.add(sheet);
workbook.put("sheet", lsSheet);
String fileName = SystemEnv.getHtmlLabelName(390352, user.getLanguage())+" "+fromDate+" "+toDate;;
workbook.put("fileName", fileName);
ExcelUtil ExcelUtil = new ExcelUtil();
Map<String,Object> exportMap= ExcelUtil.export(workbook,request,response);
retmap.putAll(exportMap);
retmap.put("status", "1");
} catch (Exception e) {
retmap.put("status", "-1");
retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage()));
writeLog(e);
}
return retmap;
}
private Map<String,Object> getChildColumnsInfo(String parentid, User user){
Map<String,Object> returnMap = new HashMap<>();
List<Object> titleList = new ArrayList<>();
Map<String,Object> title = null;
if(parentid.equals("leave")){
KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz();
List<Map<String, Object>> leaveRules = kqLeaveRulesBiz.getAllLeaveRules();
for(int i=0;leaveRules!=null&&i<leaveRules.size();i++){
Map<String, Object> leaveRule = leaveRules.get(i);
String name = Util.formatMultiLang(Util.null2String(leaveRule.get("name")),""+user.getLanguage());
String unitType = Util.null2String(leaveRule.get("unitType"));
title = new HashMap<>();
title.put("title",name+"("+
((KQUnitBiz.isLeaveHour(unitType))?SystemEnv.getHtmlLabelName(391, user.getLanguage()):SystemEnv.getHtmlLabelName(1925, user.getLanguage()))+")");
title.put("width",30*256);
titleList.add(title);
}
}else if(parentid.equals("overtime")){
String[] overtimeChild = {"overtime_nonleave","overtime_4leave","overtimeTotal"};
for(int i=0;i<overtimeChild.length;i++){
String id = overtimeChild[i];
title = new HashMap();
String fieldlabel = "";
if("overtime_nonleave".equalsIgnoreCase(id)){
fieldlabel = "125805";
title.put("title", SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage()));
title.put("rowSpan","2");
}else if("overtime_4leave".equalsIgnoreCase(id)){
fieldlabel = "125804";
title.put("title", SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage()));
title.put("rowSpan","2");
}else{
fieldlabel = "523";
title.put("showDetial","1");
String unitType = (KQOvertimeRulesBiz.getMinimumUnit()==3 || KQOvertimeRulesBiz.getMinimumUnit()==5 ||KQOvertimeRulesBiz.getMinimumUnit()==6)?"2":"1";
String unitTypeName = "";
if(Util.null2String(unitType).length()>0){
if(unitType.equals("1")){
unitTypeName=SystemEnv.getHtmlLabelName(1925, user.getLanguage());
}else if(unitType.equals("2")){
unitTypeName=SystemEnv.getHtmlLabelName(391, user.getLanguage());
}else if(unitType.equals("3")){
unitTypeName=SystemEnv.getHtmlLabelName(18083, user.getLanguage());
}
}
title.put("title", SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage())+ "(" + unitTypeName + ")");
}
Map<String,Object> mapChildColumnInfo = getChildColumnsInfo(id, user);
int childWidth = 65;
List<Object> childColumns = (List<Object>)mapChildColumnInfo.get("childColumns");
if(childColumns.size()>0) {//跨列width取子列的width
title.put("children", childColumns);
childWidth = Util.getIntValue(Util.null2String(mapChildColumnInfo.get("sumChildColumnWidth")),65);
}
title.put("width", childWidth+"");
titleList.add(title);
}
} else{
KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo();
while (kqReportFieldComInfo.next()){
if(kqReportFieldComInfo.getParentid().equals(parentid)) {
if(!kqReportFieldComInfo.getReportType().equals("daily"))continue;
title = new HashMap<>();
title.put("title",SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage())+
(KQReportBiz.getUnitType(kqReportFieldComInfo, user).length()>0?"("+ KQReportBiz.getUnitType(kqReportFieldComInfo, user)+")":""));
title.put("width",30*256);
titleList.add(title);
}
}
}
returnMap.put("childColumns",titleList);
return returnMap;
}
public Map<String, Object> getSignDetailInfo(String resourceId, String kqDate){
Map<String, Object> data = new HashMap<>();
Map<String,Object> signStatusInfo = null;
RecordSet rs = new RecordSet();
String sql = "";
KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo();
try{
sql = " select kqdate,resourceid,serialid,serialnumber,workbegindate,workbegintime, " +
" workenddate,workendtime,workmins,signindate,signintime,signoutdate,signouttime, \n" +
" attendanceMins,belatemins,graveBeLateMins,leaveearlymins,graveLeaveEarlyMins,absenteeismmins,forgotcheckMins,forgotBeginWorkCheckMins," +
" leaveMins,leaveInfo,evectionMins,outMins,signinid,signoutid \n" +
" from kq_format_detail b \n" +
" where resourceid = " + resourceId + " and kqdate ='" + kqDate + "' \n" +
" order by serialnumber \n";
rs.execute(sql);
while (rs.next()) {
String resourceid = Util.null2String(rs.getString("resourceid"));
String kqdate = Util.null2String(rs.getString("kqdate"));
String serialid = Util.null2String(rs.getString("serialid"));
int serialnumber = rs.getInt("serialnumber")+1;
String workbegindate = Util.null2String(rs.getString("workbegindate")).trim();
String workbegintime = Util.null2String(rs.getString("workbegintime")).trim();
String workenddate = Util.null2String(rs.getString("workenddate")).trim();
String workendtime = Util.null2String(rs.getString("workendtime")).trim();
int workMins = rs.getInt("workMins");
String signintime = Util.null2String(rs.getString("signintime")).trim();
String signouttime = Util.null2String(rs.getString("signouttime")).trim();
int attendanceMins = rs.getInt("attendanceMins");
String beLateMins = Util.null2String(rs.getString("beLateMins")).trim();
String graveBeLateMins = Util.null2String(rs.getString("graveBeLateMins")).trim();
String leaveEarlyMins= Util.null2String(rs.getString("leaveEarlyMins")).trim();
String graveLeaveEarlyMins= Util.null2String(rs.getString("graveLeaveEarlyMins")).trim();
String absenteeismMins= Util.null2String(rs.getString("absenteeismMins")).trim();
String forgotCheckMins = Util.null2String(rs.getString("forgotcheckMins")).trim();
String forgotBeginWorkCheckMins = Util.null2String(rs.getString("forgotBeginWorkCheckMins")).trim();
String signinid = Util.null2String(rs.getString("signinid")).trim();
String signoutid = Util.null2String(rs.getString("signoutid")).trim();
int leaveMins = rs.getInt("leaveMins");
String leaveInfo = Util.null2String(rs.getString("leaveInfo"));
int evectionMins = rs.getInt("evectionMins");
int outMins = rs.getInt("outMins");
if(serialid.length()>0){
if (workbegintime.length() > 0) {
signStatusInfo = new HashMap();
signStatusInfo.put("workdate",workbegindate);
signStatusInfo.put("worktime",workbegintime);
signStatusInfo.put("beLateMins",beLateMins);
signStatusInfo.put("forgotBeginWorkCheckMins",forgotBeginWorkCheckMins);
signStatusInfo.put("graveBeLateMins",graveBeLateMins);
signStatusInfo.put("absenteeismMins",absenteeismMins);
signStatusInfo.put("leaveMins",leaveMins);
signStatusInfo.put("leaveInfo",leaveInfo);
signStatusInfo.put("evectionMins",evectionMins);
signStatusInfo.put("outMins",outMins);
data.put("signintime"+serialnumber, signintime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signintime);
data.put("signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on"));
}
if (workendtime.length() > 0) {
signStatusInfo = new HashMap();
signStatusInfo.put("workdate",workenddate);
signStatusInfo.put("worktime",kqTimesArrayComInfo.turn48to24Time(workendtime));
signStatusInfo.put("leaveEarlyMins",leaveEarlyMins);
signStatusInfo.put("graveLeaveEarlyMins",graveLeaveEarlyMins);
signStatusInfo.put("forgotCheckMins",forgotCheckMins);
signStatusInfo.put("forgotBeginWorkCheckMins",forgotBeginWorkCheckMins);
signStatusInfo.put("absenteeismMins",absenteeismMins);
signStatusInfo.put("leaveMins",leaveMins);
signStatusInfo.put("leaveInfo",leaveInfo);
signStatusInfo.put("evectionMins",evectionMins);
signStatusInfo.put("outMins",outMins);
data.put("signouttime"+serialnumber, signouttime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signouttime);
data.put("signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off"));
}
}else{
if(workMins>0){
//弹性工时打卡时间取自签到签退数据
}
signStatusInfo = new HashMap();
signStatusInfo.put("leaveMins",leaveMins);
signStatusInfo.put("leaveInfo",leaveInfo);
signStatusInfo.put("evectionMins",evectionMins);
signStatusInfo.put("outMins",outMins);
if(signinid.length() > 0){
data.put("signintime"+serialnumber, signintime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signintime);
data.put("signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on"));
if(signoutid.length() > 0){
data.put("signouttime"+serialnumber, signouttime.length()==0?SystemEnv.getHtmlLabelName(25994, user.getLanguage()):signouttime);
data.put("signoutstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"off"));
}
}else{
data.put("signinstatus"+serialnumber, KQReportBiz.getSignStatus(signStatusInfo,user,"on"));
}
}
}
}catch (Exception e){
writeLog(e);
}
return data;
}
private String getFieldValueByUnitType(String fieldValue,String unittype){
if (Util.null2String(unittype).length() > 0) {
if (fieldValue.length() == 0) {
fieldValue = "0";
} else {
if (unittype.equals("2")) {
fieldValue = KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(fieldValue) / 60.0)));
}
}
}
return fieldValue;
}
@Override
public BizLogContext getLogContext() {
return null;
}
}

@ -0,0 +1,626 @@
package com.engine.kq.cmd.report;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.kq.biz.*;
import com.engine.kq.util.ExcelUtil;
import com.engine.kq.util.KQDurationCalculatorUtil;
import com.engine.kq.util.UtilKQ;
import weaver.common.DateUtil;
import weaver.common.StringUtil;
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.text.DecimalFormat;
import java.util.*;
public class ExportExcelCmd extends AbstractCommonCommand<Map<String, Object>> {
private HttpServletRequest request;
private HttpServletResponse response;
private List<String> lsFieldDataKey;
BaseBean bb = new BaseBean();
public ExportExcelCmd(Map<String, Object> params, HttpServletRequest request, HttpServletResponse response, User user) {
this.user = user;
this.params = params;
this.request = request;
this.response = response;
this.lsFieldDataKey = new ArrayList<>();
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> retmap = new HashMap<String, Object>();
RecordSet rs = new RecordSet();
String sql = "";
try {
SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo();
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
ResourceComInfo resourceComInfo = new ResourceComInfo();
JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo();
KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz();
KQReportBiz kqReportBiz = new KQReportBiz();
new KQReportBiz().insertKqReportExportLog(params, user);
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
String attendanceSerial = Util.null2String(jsonObj.get("attendanceSerial"));
String fromDate = Util.null2String(jsonObj.get("fromDate"));
String toDate = Util.null2String(jsonObj.get("toDate"));
String typeselect = Util.null2String(jsonObj.get("typeselect"));
if (typeselect.length() == 0) typeselect = "3";
if (!typeselect.equals("") && !typeselect.equals("0") && !typeselect.equals("6")) {
if (typeselect.equals("1")) {
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
} else {
fromDate = TimeUtil.getDateByOption(typeselect, "0");
toDate = TimeUtil.getDateByOption(typeselect, "1");
}
}
//人员状态
String status = Util.null2String(jsonObj.get("status"));
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
String departmentId = Util.null2String(jsonObj.get("departmentId"));
String resourceId = Util.null2String(jsonObj.get("resourceId"));
String allLevel = Util.null2String(jsonObj.get("allLevel"));
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));
String viewScope = Util.null2String(jsonObj.get("viewScope"));
List<String> showColumns = Util.splitString2List(Util.null2String(jsonObj.get("showColumns")), ",");
showColumns.add("lastname");
showColumns.removeIf(showColumn->showColumn.trim().equals(""));
List<String> tmpShowColumns = new ArrayList<>();
for(String showColumn:showColumns){
tmpShowColumns.add(showColumn);
String cascadekey = "";
if(showColumn.equals("beLate")){
cascadekey = "beLateMins";
}else if(showColumn.equals("leaveEearly")){
cascadekey = "leaveEarlyMins";
}else if(showColumn.equals("graveBeLate")){
cascadekey = "graveBeLateMins";
}else if(showColumn.equals("graveLeaveEarly")){
cascadekey = "graveLeaveEarlyMins";
}else if(showColumn.equals("absenteeism")){
cascadekey = "absenteeismMins";
}else if(showColumn.equals("overtime")){
tmpShowColumns.add("overtime_4leave");
tmpShowColumns.add("overtime_nonleave");
tmpShowColumns.add("workingDayOvertime_nonleave");
tmpShowColumns.add("workingDayOvertime_4leave");
tmpShowColumns.add("restDayOvertime_nonleave");
tmpShowColumns.add("restDayOvertime_4leave");
tmpShowColumns.add("holidayOvertime_4leave");
tmpShowColumns.add("holidayOvertime_nonleave");
}
if(cascadekey.length()>0){
tmpShowColumns.add(cascadekey);
}
}
showColumns = tmpShowColumns;
String rightSql = new KQReportBiz().getReportRight("1", "" + user.getUID(), "a");
LinkedHashMap<String, Object> workbook = new LinkedHashMap<>();
List<Object> lsSheet = new ArrayList<>();
Map<String, Object> sheet = null;
List<Object> titleList = new ArrayList<>();
Map<String, Object> title = null;
List<List<Object>> dataList = new ArrayList<>();
List<Object> data = null;
List<Map<String, Object>> constraintList = null;
sheet = new HashMap<>();
sheet.put("sheetName", SystemEnv.getHtmlLabelName(390351, user.getLanguage()));
sheet.put("sheetTitle", SystemEnv.getHtmlLabelName(390351, user.getLanguage()));
boolean isEnd = false;
Calendar cal = DateUtil.getCalendar();
List<Map<String, Object>> leaveRules = kqLeaveRulesBiz.getAllLeaveRules();
Map<String, Object> mapChildColumnInfo = null;
List<Object> childColumns = null;
KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo();
while (kqReportFieldComInfo.next()) {
if (Util.null2String(kqReportFieldComInfo.getParentid()).length() > 0) continue;
if(kqReportFieldComInfo.getFieldname().equals("kqCalendar"))continue;
if(KQReportFieldComInfo.cascadekey2fieldname.keySet().contains(kqReportFieldComInfo.getFieldname()))continue;
if (!kqReportFieldComInfo.getReportType().equals("all") && !kqReportFieldComInfo.getReportType().equals("month"))
continue;
if (!showColumns.contains(kqReportFieldComInfo.getFieldname())&&!showColumns.contains(kqReportFieldComInfo.getParentid())) continue;
if("leave".equalsIgnoreCase(kqReportFieldComInfo.getFieldname())&&leaveRules.size()==0){
continue;
}
title = new HashMap<>();
String unitType = KQReportBiz.getUnitType(kqReportFieldComInfo, user);
if(unitType.length()>0){
title.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage())+ "(" + unitType + ")");
}else{
title.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage()));
}
title.put("width", 30 * 256);
this.lsFieldDataKey.add(kqReportFieldComInfo.getFieldname());
mapChildColumnInfo = this.getChildColumnsInfo(kqReportFieldComInfo.getFieldname(), user);
childColumns = (List<Object>) mapChildColumnInfo.get("childColumns");
if (childColumns.size() > 0) {//跨列width取子列的width
title.put("children", childColumns);
title.put("colSpan", childColumns.size());
} else {
title.put("rowSpan", 3);
}
titleList.add(title);
titleList.addAll(this.getCascadeKeyColumnsInfo(kqReportFieldComInfo.getCascadekey(),user));
}
String today = DateUtil.getCurrentDate();
// if (DateUtil.compDate(today, toDate) > 0) {//结束如期不大于今天
// toDate = today;
// }
if(showColumns.contains("kqCalendar")) {
childColumns = new ArrayList<>();
for (String date = fromDate; !isEnd; ) {
if (date.equals(toDate)) isEnd = true;
title = new HashMap<>();
title.put("title", UtilKQ.getWeekDayShort(DateUtil.getWeek(date)-1,user.getLanguage()) +"\r\n"+ DateUtil.geDayOfMonth(date));
title.put("width", 30 * 256);
childColumns.add(title);
cal.setTime(DateUtil.parseToDate(date));
date = DateUtil.getDate(cal.getTime(), 1);
}
title = new HashMap();
title.put("title", SystemEnv.getHtmlLabelName(386476, user.getLanguage()));
if (childColumns.size() > 0) {//跨列width取子列的width
title.put("children", childColumns);
title.put("colSpan", childColumns.size());
}
titleList.add(title);
}
sheet.put("titleList", titleList);
// 没有权限的人最大只支持查询本季
Map<String, String> getRealDate = new KQReportBiz().realDate(fromDate, toDate, user, "1");
fromDate = getRealDate.get("fromDate");
toDate = getRealDate.get("toDate");
if("-1".equals(fromDate) || "-1".equals(toDate)) {
retmap.put("status", "1");
return retmap;
}
String forgotBeginWorkCheck_field = " sum(b.forgotBeginWorkCheck) ";
if(rs.getDBType().equalsIgnoreCase("oracle")) {
forgotBeginWorkCheck_field = " sum(nvl(b.forgotBeginWorkCheck,0)) ";
}else if((rs.getDBType()).equalsIgnoreCase("mysql")){
forgotBeginWorkCheck_field = " sum(ifnull(b.forgotBeginWorkCheck,0)) ";
}else {
forgotBeginWorkCheck_field = " sum(isnull(b.forgotBeginWorkCheck,0)) ";
}
Map<String,Object> definedFieldInfo = new KQFormatBiz().getDefinedField();
String definedFieldSum = Util.null2String(definedFieldInfo.get("definedFieldSum"));
String backFields = " a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1 as subcompanyid,a.departmentid,a.jobtitle," +
" sum(b.workdays) as workdays,sum(b.workMins) as workMins,sum(b.attendancedays) as attendancedays," +
" sum(b.attendanceMins) as attendanceMins,sum(b.beLate) as beLate,sum(b.beLateMins) as beLateMins, " +
" sum(b.graveBeLate) as graveBeLate, sum(b.graveBeLateMins) as graveBeLateMins,sum(b.leaveEearly) as leaveEearly," +
" sum(b.leaveEarlyMins) as leaveEarlyMins, sum(b.graveLeaveEarly) as graveLeaveEarly, " +
" sum(b.graveLeaveEarlyMins) as graveLeaveEarlyMins,sum(b.absenteeism) as absenteeism, " +
" sum(b.signdays) as signdays,sum(b.signmins) as signmins, "+
" sum(b.absenteeismMins) as absenteeismMins, sum(b.forgotCheck)+"+forgotBeginWorkCheck_field+" as forgotCheck "+(definedFieldSum.length()>0?","+definedFieldSum+"":"");
if(rs.getDBType().equals("oracle")){
backFields = "/*+ index(kq_format_total IDX_KQ_FORMAT_TOTAL_KQDATE) */ "+backFields;
}
String sqlFrom = " from hrmresource a, kq_format_total b where a.id= b.resourceid and b.kqdate >='" + fromDate + "' and b.kqdate <='" + toDate + "'";
String sqlWhere = rightSql;
String groupBy = " group by a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1,a.departmentid,a.jobtitle ";
if (subCompanyId.length() > 0) {
sqlWhere += " and a.subcompanyid1 in(" + subCompanyId + ") ";
}
if (departmentId.length() > 0) {
sqlWhere += " and a.departmentid in(" + departmentId + ") ";
}
if (resourceId.length() > 0) {
sqlWhere += " and a.id in(" + resourceId + ") ";
}
if (viewScope.equals("4")) {//我的下属
if (allLevel.equals("1")) {//所有下属
sqlWhere += " and a.managerstr like '%," + user.getUID() + ",%'";
} else {
sqlWhere += " and a.managerid=" + user.getUID();//直接下属
}
}
if (!"1".equals(isNoAccount)) {
sqlWhere += " and a.loginid is not null " + (rs.getDBType().equals("oracle") ? "" : " and a.loginid<>'' ");
}
if(status.length()>0){
if (!status.equals("8") && !status.equals("9")) {
sqlWhere += " and a.status = "+status+ "";
}else if (status.equals("8")) {
sqlWhere += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) ";
}
}
String orderBy = " order by a.dsporder asc, a.lastname asc ";
String descOrderBy = " order by a.dsporder desc, a.lastname desc ";
sql = "select " + backFields + sqlFrom + sqlWhere + groupBy + orderBy;
//System.out.println("start" + DateUtil.getFullDate());
KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo();
String show_card_source = Util.null2String(kqSettingsComInfo.getMain_val("show_card_source"),"0");//是否显示打卡数据,以及打卡数据来源
params.put("show_card_source",show_card_source);
KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz();
int uintType = kqOvertimeRulesBiz.getMinimumUnit();//当前加班单位
double hoursToDay = kqOvertimeRulesBiz.getHoursToDay();//当前天跟小时计算关系
params.put("uintType",uintType);
params.put("hoursToDay",hoursToDay);
Map<String, Object> flowData = new KQReportBiz().getFlowData(params, user);
//System.out.println("end" + DateUtil.getFullDate());
// #1475814-概述:满足考勤报分部部门显示及导出时显示全路径
String fullPathMainKey = "show_full_path";
String isShowFullPath = Util.null2String(kqSettingsComInfo.getMain_val(fullPathMainKey),"0");
rs.execute(sql);
while (rs.next()) {
data = new ArrayList<>();
String id = rs.getString("id");
for (int fieldDataKeyIdx =0;fieldDataKeyIdx<lsFieldDataKey.size();fieldDataKeyIdx++) {
String fieldName = lsFieldDataKey.get(fieldDataKeyIdx);
String fieldid = KQReportFieldComInfo.field2Id.get(fieldName);
String fieldValue = "";
if (fieldName.equals("subcompany")) {
String tmpSubcompanyId = Util.null2String(rs.getString("subcompanyid"));
if (tmpSubcompanyId.length() == 0) {
tmpSubcompanyId = Util.null2String(resourceComInfo.getSubCompanyID(id));
}
fieldValue = "1".equals(isShowFullPath) ?
SubCompanyComInfo.getSubcompanyRealPath(tmpSubcompanyId, "/", "0") :
subCompanyComInfo.getSubCompanyname(tmpSubcompanyId);
// fieldValue = subCompanyComInfo.getSubCompanyname(tmpSubcompanyId);
} else if (fieldName.equals("department")) {
String tmpDepartmentId = Util.null2String(rs.getString("departmentid"));
if (tmpDepartmentId.length() == 0) {
tmpDepartmentId = Util.null2String(resourceComInfo.getDepartmentID(id));
}
fieldValue = "1".equals(isShowFullPath) ?
departmentComInfo.getDepartmentRealPath(tmpDepartmentId, "/", "0") :
departmentComInfo.getDepartmentname(tmpDepartmentId);
// fieldValue = departmentComInfo.getDepartmentname(tmpDepartmentId);
} else if (fieldName.equals("jobtitle")) {
String tmpJobtitleId = Util.null2String(rs.getString("jobtitle"));
if (tmpJobtitleId.length() == 0) {
tmpJobtitleId = Util.null2String(resourceComInfo.getJobTitle(id));
}
fieldValue = jobTitlesComInfo.getJobTitlesname(tmpJobtitleId);
} else if (fieldName.equals("attendanceSerial")) {
List<String> serialIds = null;
if (Util.null2String(jsonObj.get("attendanceSerial")).length() > 0) {
serialIds = Util.splitString2List(Util.null2String(jsonObj.get("attendanceSerial")), ",");
for(int i=0;serialIds!=null&&i<serialIds.size();i++){
data.add(kqReportBiz.getSerialCount(id,fromDate,toDate,serialIds.get(i)));
}
}else{
data.add("");
}
continue;
} else if (fieldName.equals("leave")) {//请假
List<Map<String, Object>> allLeaveRules = kqLeaveRulesBiz.getAllLeaveRules();
Map<String, Object> leaveRule = null;
for (int i = 0; allLeaveRules != null && i < allLeaveRules.size(); i++) {
leaveRule = allLeaveRules.get(i);
String flowType = Util.null2String("leaveType_" + leaveRule.get("id"));
String leaveData = Util.null2String(flowData.get(id + "|" + flowType));
String flowLeaveBackType = Util.null2String("leavebackType_" + leaveRule.get("id"));
String leavebackData = Util.null2s(Util.null2String(flowData.get(id + "|" + flowLeaveBackType)), "0.0");
String b_flowLeaveData = "";
String flowLeaveData = "";
try {
//以防止出现精度问题
if (leaveData.length() == 0) {
leaveData = "0.0";
}
if (leavebackData.length() == 0) {
leavebackData = "0.0";
}
BigDecimal b_leaveData = new BigDecimal(leaveData);
BigDecimal b_leavebackData = new BigDecimal(leavebackData);
b_flowLeaveData = b_leaveData.subtract(b_leavebackData).toString();
if(Util.getDoubleValue(b_flowLeaveData, -1) < 0){
b_flowLeaveData = "0.0";
}
} catch (Exception e) {
writeLog("GetKQReportCmd:leaveData" + leaveData + ":leavebackData:" + leavebackData + ":" + e);
}
if (b_flowLeaveData.length() > 0) {
flowLeaveData = KQDurationCalculatorUtil.getDurationRound(b_flowLeaveData);
} else {
flowLeaveData = KQDurationCalculatorUtil.getDurationRound(Util.null2String(Util.getDoubleValue(leaveData, 0.0) - Util.getDoubleValue(leavebackData, 0.0)));
}
data.add(flowLeaveData);
}
continue;
}else if(fieldName.equals("overtime")){
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|workingDayOvertime_nonleave")));
data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("workingDayOvertime_nonleave"))));
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|restDayOvertime_nonleave")));
data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("restDayOvertime_nonleave"))));
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|holidayOvertime_nonleave")));
data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("holidayOvertime_nonleave"))));
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|workingDayOvertime_4leave")));
data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("workingDayOvertime_4leave"))));
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|restDayOvertime_4leave")));
data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("restDayOvertime_4leave"))));
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|holidayOvertime_4leave")));
data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("holidayOvertime_4leave"))));
double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|workingDayOvertime_4leave")));
workingDayOvertime_4leave = workingDayOvertime_4leave<0?0:workingDayOvertime_4leave;
double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|restDayOvertime_4leave")));
restDayOvertime_4leave = restDayOvertime_4leave<0?0:restDayOvertime_4leave;
double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|holidayOvertime_4leave")));
holidayOvertime_4leave = holidayOvertime_4leave<0?0:holidayOvertime_4leave;
double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|workingDayOvertime_nonleave")));
workingDayOvertime_nonleave = workingDayOvertime_nonleave<0?0:workingDayOvertime_nonleave;
double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|restDayOvertime_nonleave")));
restDayOvertime_nonleave = restDayOvertime_nonleave<0?0:restDayOvertime_nonleave;
double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|holidayOvertime_nonleave")));
holidayOvertime_nonleave = holidayOvertime_nonleave<0?0:holidayOvertime_nonleave;
fieldValue = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_4leave+restDayOvertime_4leave+holidayOvertime_4leave+
workingDayOvertime_nonleave+restDayOvertime_nonleave+holidayOvertime_nonleave));
data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("overtimeTotal"))));
continue;
}else if (fieldName.equals("reportEve")) {//考勤二开--日报转出差
bb.writeLog("--reportEve start");
Integer temp = Util.getIntValue(Util.null2String(flowData.get("ReportEve|" + resourceId)));
bb.writeLog("--temp: " + temp);
if (temp <= 0 ) {
data.add(0);
} else {
data.add(temp);
}
bb.writeLog("--data: " + data);
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 {
fieldValue = Util.formatMultiLang(Util.null2String(rs.getString(fieldName)),""+user.getLanguage());
fieldValue = getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(fieldid));
}
fieldValue = Util.formatMultiLang(fieldValue,""+user.getLanguage());
data.add(fieldValue);
}
if(showColumns.contains("kqCalendar")) {
// Map<String, Object> detialDatas = kqReportBiz.getDetialDatas(id, fromDate, toDate, user,flowData,true);
Map<String, Object> detialDatas = kqReportBiz.getDetialDatas(id, fromDate, toDate, user,flowData,true,uintType,show_card_source);
isEnd = false;
for (String date = fromDate; !isEnd; ) {
if (date.equals(toDate)) isEnd = true;
if (DateUtil.compDate(today, date) > 0) {
data.add("");
} else {
if (detialDatas.get(id + "|" + date) != null) {
data.add(((Map<String, Object>) detialDatas.get(id + "|" + date)).get("text"));
} else {
data.add(SystemEnv.getHtmlLabelName(26593, user.getLanguage()));
}
}
cal.setTime(DateUtil.parseToDate(date));
date = DateUtil.getDate(cal.getTime(), 1);
}
}
dataList.add(data);
}
sheet.put("dataList", dataList);
sheet.put("constraintList", constraintList);
sheet.put("createFile", "1");
lsSheet.add(sheet);
workbook.put("sheet", lsSheet);
String fileName = SystemEnv.getHtmlLabelName(390351, user.getLanguage())+" "+fromDate+" "+toDate;
workbook.put("fileName", fileName);
ExcelUtil ExcelUtil = new ExcelUtil();
Map<String, Object> exportMap = ExcelUtil.export(workbook, request, response,true);
retmap.putAll(exportMap);
retmap.put("status", "1");
} catch (Exception e) {
retmap.put("status", "-1");
retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage()));
writeLog(e);
}
return retmap;
}
private Map<String, Object> getChildColumnsInfo(String parentid, User user) {
Map<String, Object> returnMap = new HashMap<>();
List<Object> titleList = new ArrayList<>();
Map<String, Object> title = null;
if (parentid.equals("attendanceSerial")) {//考勤班次
KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo();
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
List<String> serialIds = null;
if (Util.null2String(jsonObj.get("attendanceSerial")).length() > 0) {
serialIds = Util.splitString2List(Util.null2String(jsonObj.get("attendanceSerial")), ",");
}
for (int i = 0; serialIds != null && i < serialIds.size(); i++) {
title = new HashMap<>();
title.put("title", Util.formatMultiLang(kqShiftManagementComInfo.getSerial(serialIds.get(i)),""+user.getLanguage()));
title.put("width", 30 * 256);
titleList.add(title);
}
} else if (parentid.equals("leave")) {
KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz();
List<Map<String, Object>> leaveRules = kqLeaveRulesBiz.getAllLeaveRules();
for (int i = 0; leaveRules != null && i < leaveRules.size(); i++) {
Map<String, Object> leaveRule = leaveRules.get(i);
String name = Util.formatMultiLang(Util.null2String(leaveRule.get("name")),""+user.getLanguage());
String unitType = Util.null2String(leaveRule.get("unitType"));
String unitName = (KQUnitBiz.isLeaveHour(unitType)) ? SystemEnv.getHtmlLabelName(391, user.getLanguage()) : SystemEnv.getHtmlLabelName(1925, user.getLanguage());
title = new HashMap<>();
title.put("title", name + "(" + unitName + ")");
title.put("width", 30 * 256);
titleList.add(title);
}
}else if(parentid.equals("overtime")){
String[] overtimeChild = {"overtime_nonleave","overtime_4leave","overtimeTotal"};
for(int i=0;i<overtimeChild.length;i++){
String id = overtimeChild[i];
title = new HashMap();
String fieldlabel = "";
if("overtime_nonleave".equalsIgnoreCase(id)){
fieldlabel = "125805";
title.put("title", SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage()));
title.put("rowSpan","2");
}else if("overtime_4leave".equalsIgnoreCase(id)){
fieldlabel = "125804";
title.put("title", SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage()));
title.put("rowSpan","2");
}else{
fieldlabel = "523";
title.put("showDetial","1");
String unitType = (KQOvertimeRulesBiz.getMinimumUnit()==3 || KQOvertimeRulesBiz.getMinimumUnit()==5 ||KQOvertimeRulesBiz.getMinimumUnit()==6)?"2":"1";
String unitTypeName = "";
if(Util.null2String(unitType).length()>0){
if(unitType.equals("1")){
unitTypeName=SystemEnv.getHtmlLabelName(1925, user.getLanguage());
}else if(unitType.equals("2")){
unitTypeName=SystemEnv.getHtmlLabelName(391, user.getLanguage());
}else if(unitType.equals("3")){
unitTypeName=SystemEnv.getHtmlLabelName(18083, user.getLanguage());
}
}
title.put("title", SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage())+ "(" + unitTypeName + ")");
}
Map<String,Object> mapChildColumnInfo = getChildColumnsInfo(id, user);
int childWidth = 65;
List<Object> childColumns = (List<Object>)mapChildColumnInfo.get("childColumns");
if(childColumns.size()>0) {//跨列width取子列的width
title.put("children", childColumns);
childWidth = Util.getIntValue(Util.null2String(mapChildColumnInfo.get("sumChildColumnWidth")),65);
}
title.put("width", childWidth+"");
titleList.add(title);
}
} else {
KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo();
while (kqReportFieldComInfo.next()) {
if (kqReportFieldComInfo.getParentid().equals(parentid)) {
if(!kqReportFieldComInfo.getReportType().equals("month"))continue;
title = new HashMap<>();
title.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage()) + "(" + KQReportBiz.getUnitType(kqReportFieldComInfo, user) + ")");
title.put("width", 30 * 256);
titleList.add(title);
}
}
}
returnMap.put("childColumns", titleList);
return returnMap;
}
private List<Object> getCascadeKeyColumnsInfo(String cascadeKey, User user){
List<Object> titleList = new ArrayList<>();
Map<String, Object> title = null;
if(Util.null2String(cascadeKey).length()==0){
return titleList;
}
List<String> lsCascadeKey = Util.splitString2List(cascadeKey,",");
KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo();
for(int i=0;i<lsCascadeKey.size();i++){
kqReportFieldComInfo.setTofirstRow();
while (kqReportFieldComInfo.next()) {
if(!kqReportFieldComInfo.getReportType().equals("month"))continue;
if (kqReportFieldComInfo.getFieldname().equals(lsCascadeKey.get(i))){
title = new HashMap<>();
title.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage()) + "(" + KQReportBiz.getUnitType(kqReportFieldComInfo, user) + ")");
title.put("width", 30 * 256);
titleList.add(title);
}
}
}
return titleList;
}
private String getFieldValueByUnitType(String fieldValue,String unittype){
if (Util.null2String(unittype).length() > 0) {
if (fieldValue.length() == 0) {
fieldValue = "0";
} else {
if (unittype.equals("2")) {
fieldValue = KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(fieldValue) / 60.0)));
}
}
}
return fieldValue;
}
@Override
public BizLogContext getLogContext() {
return null;
}
}

@ -0,0 +1,623 @@
package com.engine.kq.cmd.report;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.kq.biz.*;
import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit;
import com.engine.kq.entity.WorkTimeEntity;
import com.engine.kq.log.KQLog;
import com.engine.kq.util.KQDurationCalculatorUtil;
import com.engine.kq.util.PageUidFactory;
import java.math.BigDecimal;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
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.util.*;
public class GetKQDailyReportCmd extends AbstractCommonCommand<Map<String, Object>> {
private KQLog kqLog = new KQLog();
public GetKQDailyReportCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String,Object> retmap = new HashMap<String,Object>();
RecordSet rs = new RecordSet();
String sql = "";
try{
String pageUid = PageUidFactory.getHrmPageUid("KQDailyReport");
SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo();
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
ResourceComInfo resourceComInfo = new ResourceComInfo();
JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo();
KQWorkTime kqWorkTime = new KQWorkTime();
ShiftManagementToolKit shiftManagementToolKit = new ShiftManagementToolKit();
KQReportBiz kqReportBiz = new KQReportBiz();
KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz();
String rightSql = new KQReportBiz().getReportRight("2",""+user.getUID(),"a");
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
String fromDate = Util.null2String(jsonObj.get("fromDate"));
String toDate = Util.null2String(jsonObj.get("toDate"));
String typeselect =Util.null2String(jsonObj.get("typeselect"));
if(typeselect.length()==0)typeselect = "3";
if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){
if(typeselect.equals("1")){
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
}else{
fromDate = TimeUtil.getDateByOption(typeselect,"0");
toDate = TimeUtil.getDateByOption(typeselect,"1");
}
}
//人员状态
String status = Util.null2String(jsonObj.get("status"));
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
String departmentId = Util.null2String(jsonObj.get("departmentId"));
String resourceId = Util.null2String(jsonObj.get("resourceId"));
String allLevel = Util.null2String(jsonObj.get("allLevel"));
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));
String viewScope = Util.null2String(jsonObj.get("viewScope"));
if(typeselect.length()==0)typeselect = "3";
int pageIndex = Util.getIntValue(Util.null2String(jsonObj.get("pageIndex")), 1);
int pageSize = KQReportBiz.getPageSize(Util.null2String(jsonObj.get("pageSize")),pageUid,user.getUID());
int count = 0;
int pageCount = 0;
int isHavePre = 0;
int isHaveNext = 0;
List<Map<String, Object>> leaveRules = kqLeaveRulesBiz.getAllLeaveRules();
List<Object> columns = new ArrayList();
Map<String,Object> column = null;
List<Object> datas = new ArrayList();
Map<String,Object> data = null;
Map<String,Object> mapChildColumnInfo = null;
List<Object> childColumns = null;
KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo();
while (kqReportFieldComInfo.next()){
if(Util.null2String(kqReportFieldComInfo.getParentid()).length()>0)continue;
boolean isDaily = kqReportFieldComInfo.getReportType().equals("daily");
if(!kqReportFieldComInfo.getReportType().equals("all") && !isDaily)continue;
if("leave".equalsIgnoreCase(kqReportFieldComInfo.getFieldname())&&leaveRules.size()==0){
continue;
}
column = new HashMap();
column.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage()));
column.put("unit", KQReportBiz.getUnitType(kqReportFieldComInfo, user));
column.put("dataIndex", kqReportFieldComInfo.getFieldname());
column.put("key", kqReportFieldComInfo.getFieldname());
mapChildColumnInfo = this.getChildColumnsInfo(kqReportFieldComInfo.getFieldname(),user);
childColumns = (List<Object>)mapChildColumnInfo.get("childColumns");
if(childColumns.size()>0) {//跨列width取子列的width
column.put("rowSpan", 1);
column.put("width", mapChildColumnInfo.get("sumChildColumnWidth"));
column.put("children", childColumns);
}else{
column.put("rowSpan", 3);
column.put("width", Util.getIntValue(kqReportFieldComInfo.getWidth()));
}
if(kqReportFieldComInfo.getReportType1().equals("daily")){
column.put("isdaily", "1");
}
column.put("showDetial",kqReportFieldComInfo.getShowDetial());
columns.add(column);
}
// String today = DateUtil.getCurrentDate();
// if(DateUtil.compDate(today, toDate)>0){//结束如期不大于今天
// toDate = today;
// if(DateUtil.compDate(today, fromDate)>0){
// fromDate = today;
// }
// }
String forgotBeginWorkCheck_field = " b.forgotbeginworkcheck ";
if(rs.getDBType().equalsIgnoreCase("oracle")&&!Util.null2String(rs.getOrgindbtype()).equals("dm")&&!Util.null2String(rs.getOrgindbtype()).equals("st")&&!Util.null2String(rs.getOrgindbtype()).equals("jc")) {
forgotBeginWorkCheck_field = " nvl(b.forgotBeginWorkCheck,0) ";
}else if((rs.getDBType()).equalsIgnoreCase("mysql")){
forgotBeginWorkCheck_field = " ifnull(b.forgotBeginWorkCheck,0) ";
}else {
forgotBeginWorkCheck_field = " isnull(b.forgotBeginWorkCheck,0) ";
}
String backFields = " a.id,a.lastname,a.subcompanyid1 as subcompanyid,a.departmentid, a.workcode,b.jobtitle,a.dsporder," +
" b.kqdate, b.workdays,b.workMins,b.serialid, b.attendancedays,b.attendanceMins," +
" b.beLate,b.beLateMins,b.graveBeLate,b.graveBeLateMins,b.leaveEearly,b.leaveEarlyMins," +
" b.signdays,b.signmins, "+
" b.graveLeaveEarly,b.graveLeaveEarlyMins,b.absenteeism ,b.absenteeismMins ,(b.forgotCheck+"+forgotBeginWorkCheck_field+") forgotCheck ";
String sqlFrom = " from hrmresource a, kq_format_total b where a.id= b.resourceid and b.kqdate >='"+fromDate+"' and b.kqdate <='"+toDate+"'";
String sqlWhere = rightSql;
if(subCompanyId.length()>0){
sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") ";
}
if(departmentId.length()>0){
sqlWhere +=" and a.departmentid in("+departmentId+") ";
}
if(resourceId.length()>0){
sqlWhere +=" and a.id in("+resourceId+") ";
}
if(viewScope.equals("4")){//我的下属
if(allLevel.equals("1")){//所有下属
sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'";
}else{
sqlWhere+=" and a.managerid="+user.getUID();//直接下属
}
}
if (!"1".equals(isNoAccount)) {
sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' ");
}
if(status.length()>0){
if (!status.equals("8") && !status.equals("9")) {
sqlWhere += " and a.status = "+status+ "";
}else if (status.equals("8")) {
sqlWhere += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) ";
}
}
sql = " select count(*) as c from ( select 1 as c "+sqlFrom+sqlWhere+") t";
rs.execute(sql);
if (rs.next()){
count = rs.getInt("c");
}
if (count <= 0) {
pageCount = 0;
}
pageCount = count / pageSize + ((count % pageSize > 0) ? 1 : 0);
isHaveNext = (pageIndex + 1 <= pageCount) ? 1 : 0;
isHavePre = (pageIndex - 1 >= 1) ? 1 : 0;
String orderBy = " order by a.dsporder asc, a.lastname asc, b.kqdate asc ";
String descOrderBy = " order by a.dsporder desc, a.lastname desc, b.kqdate desc ";
sql = backFields + sqlFrom + sqlWhere + orderBy;
if (pageIndex > 0 && pageSize > 0) {
if (rs.getDBType().equals("oracle")) {
sql = " select " + sql;
sql = "select * from ( select row_.*, rownum rownum_ from ( " + sql + " ) row_ where rownum <= "
+ (pageIndex * pageSize) + ") where rownum_ > " + ((pageIndex - 1) * pageSize);
} else if (rs.getDBType().equals("mysql")) {
sql = " select " + sql;
sql = "select t1.* from (" + sql + ") t1 limit " + ((pageIndex - 1) * pageSize) + "," + pageSize;
} else if (rs.getDBType().equals("postgresql")) {
sql = " select " + sql;
sql = "select t1.* from (" + sql + ") t1 limit " + pageSize+ " offset " + ((pageIndex - 1) * pageSize);
} else {
orderBy = " order by dsporder asc, lastname asc, kqdate asc ";
descOrderBy = " order by dsporder desc, lastname desc, kqdate desc ";
if (pageIndex > 1) {
int topSize = pageSize;
if (pageSize * pageIndex > count) {
topSize = count - (pageSize * (pageIndex - 1));
}
sql = " select top " + topSize + " * from ( select top " + topSize + " * from ( select top "
+ (pageIndex * pageSize) + sql+" ) tbltemp1 " + descOrderBy + ") tbltemp2 " + orderBy;
} else {
sql = " select top " + pageSize + sql;
}
}
} else {
sql = " select " + sql;
}
Map<String,Object> flowData = kqReportBiz.getDailyFlowData(params,user);
Map<String,String> serialdata = new HashMap<>();
// #1475814-概述:满足考勤报分部部门显示及导出时显示全路径
String fullPathMainKey = "show_full_path";
KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo();
String isShowFullPath = Util.null2String(kqSettingsComInfo.getMain_val(fullPathMainKey),"0");
rs.execute(sql);
while (rs.next()) {
String id = rs.getString("id");
String kqdate = rs.getString("kqdate");
WorkTimeEntity workTime = kqWorkTime.getWorkTime(id, kqdate);
data = new HashMap<>();
kqReportFieldComInfo.setTofirstRow();
while (kqReportFieldComInfo.next()) {
if (!Util.null2String(kqReportFieldComInfo.getIsdataColumn()).equals("1")) continue;
if (!kqReportFieldComInfo.getReportType().equals("all") && !kqReportFieldComInfo.getReportType().equals("daily"))
continue;
String fieldName = kqReportFieldComInfo.getFieldname();
String fieldValue = "";
if (fieldName.equals("subcompany")) {
String fieldValueID = rs.getString("subcompanyid");
fieldValue = "1".equals(isShowFullPath) ?
SubCompanyComInfo.getSubcompanyRealPath(fieldValueID, "/", "0") :
subCompanyComInfo.getSubCompanyname(fieldValueID);
//fieldValue = subCompanyComInfo.getSubCompanyname(fieldValueID);
if (fieldValue.length() == 0) {
fieldValueID = resourceComInfo.getSubCompanyID(id);
fieldValue = "1".equals(isShowFullPath) ?
SubCompanyComInfo.getSubcompanyRealPath(fieldValueID, "/", "0") :
subCompanyComInfo.getSubCompanyname(fieldValueID);
// fieldValue = subCompanyComInfo.getSubCompanyname(fieldValueID);
}
data.put(fieldName + "Id", fieldValueID);
data.put(fieldName, fieldValue);
} else if (fieldName.equals("department")) {
String fieldValueID = rs.getString("departmentid");
fieldValue = "1".equals(isShowFullPath) ?
departmentComInfo.getDepartmentRealPath(fieldValueID, "/", "0") :
departmentComInfo.getDepartmentname(fieldValueID);
//fieldValue = departmentComInfo.getDepartmentname(fieldValueID);
if (fieldValue.length() == 0) {
fieldValueID = resourceComInfo.getDepartmentID(id);
fieldValue = "1".equals(isShowFullPath) ?
departmentComInfo.getDepartmentRealPath(fieldValueID, "/", "0") :
departmentComInfo.getDepartmentname(fieldValueID);
// fieldValue = departmentComInfo.getDepartmentname(fieldValueID);
}
data.put(fieldName + "Id", fieldValueID);
data.put(fieldName, fieldValue);
} else if (fieldName.equals("jobtitle")) {
String fieldValueID = rs.getString("jobtitle");
fieldValue = jobTitlesComInfo.getJobTitlesname(rs.getString("jobtitle"));
if (fieldValue.length() == 0) {
fieldValueID = resourceComInfo.getJobTitle(id);
fieldValue = jobTitlesComInfo.getJobTitlesname(fieldValueID);
}
data.put(fieldName + "Id", fieldValueID);
data.put(fieldName, fieldValue);
} else if (kqReportFieldComInfo.getParentid().equals("overtime") || kqReportFieldComInfo.getParentid().equals("overtime_nonleave")
|| kqReportFieldComInfo.getParentid().equals("overtime_4leave") || fieldName.equals("businessLeave") || fieldName.equals("officialBusiness")) {
if (fieldName.equals("overtimeTotal")) {
double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|workingDayOvertime_4leave")));
workingDayOvertime_4leave = workingDayOvertime_4leave < 0 ? 0 : workingDayOvertime_4leave;
double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|restDayOvertime_4leave")));
restDayOvertime_4leave = restDayOvertime_4leave < 0 ? 0 : restDayOvertime_4leave;
double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|holidayOvertime_4leave")));
holidayOvertime_4leave = holidayOvertime_4leave < 0 ? 0 : holidayOvertime_4leave;
double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|workingDayOvertime_nonleave")));
workingDayOvertime_nonleave = workingDayOvertime_nonleave < 0 ? 0 : workingDayOvertime_nonleave;
double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|restDayOvertime_nonleave")));
restDayOvertime_nonleave = restDayOvertime_nonleave < 0 ? 0 : restDayOvertime_nonleave;
double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|holidayOvertime_nonleave")));
holidayOvertime_nonleave = holidayOvertime_nonleave < 0 ? 0 : holidayOvertime_nonleave;
fieldValue = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_4leave + restDayOvertime_4leave + holidayOvertime_4leave +
workingDayOvertime_nonleave + restDayOvertime_nonleave + holidayOvertime_nonleave));
} else {
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|" + kqdate + "|" + fieldName)));
}
data.put(fieldName, fieldValue);
} else if (fieldName.equals("serialid")) {
fieldValue = Util.null2String(rs.getString(fieldName));
if (fieldValue.length()>0) {//弹性工作制没有班次
// data.put("serialid", shiftManagementToolKit.getShiftOnOffWorkSections(fieldValue, user.getLanguage()));
if(null != serialdata && serialdata.containsKey(fieldValue)){
data.put("serialid", serialdata.get(fieldValue));
}else{
String tmpserialname = shiftManagementToolKit.getShiftOnOffWorkSections(fieldValue, user.getLanguage());
serialdata.put(fieldValue,tmpserialname);
data.put("serialid", tmpserialname);
}
}
}else if (fieldName.equals("reportEve")) {//考勤二开--日报转出差
Integer temp = Util.getIntValue(Util.null2String(flowData.get("DailyReportEve|" + resourceId + "|" +kqdate)));
if (temp ==1 ) {
data.put(fieldName, temp);
} else {
data.put(fieldName, 0);
}
}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,668 @@
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.log.KQLog;
import com.engine.kq.util.KQDurationCalculatorUtil;
import com.engine.kq.util.PageUidFactory;
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 java.math.BigDecimal;
import java.util.*;
public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
BaseBean bb = new BaseBean();
public GetKQReportCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String,Object> retmap = new HashMap<String,Object>();
RecordSet rs = new RecordSet();
String sql = "";
try{
String pageUid = PageUidFactory.getHrmPageUid("KQReport");
SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo();
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
ResourceComInfo resourceComInfo = new ResourceComInfo();
JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo();
KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz();
KQReportBiz kqReportBiz = new KQReportBiz();
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
String attendanceSerial = Util.null2String(jsonObj.get("attendanceSerial"));
String fromDate = Util.null2String(jsonObj.get("fromDate"));
String toDate = Util.null2String(jsonObj.get("toDate"));
String typeselect =Util.null2String(jsonObj.get("typeselect"));
if(typeselect.length()==0)typeselect = "3";
if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){
if(typeselect.equals("1")){
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
}else{
fromDate = TimeUtil.getDateByOption(typeselect,"0");
toDate = TimeUtil.getDateByOption(typeselect,"1");
}
}
//人员状态
String status = Util.null2String(jsonObj.get("status"));
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
String departmentId = Util.null2String(jsonObj.get("departmentId"));
String resourceId = Util.null2String(jsonObj.get("resourceId"));
String allLevel = Util.null2String(jsonObj.get("allLevel"));
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));
String viewScope = Util.null2String(jsonObj.get("viewScope"));
String isFromMyAttendance = Util.null2String(jsonObj.get("isFromMyAttendance"));//是否是来自我的考勤的请求,如果是,不加载考勤报表权限共享的限制,不然我的考勤会提示无权限
int pageIndex = Util.getIntValue(Util.null2String(jsonObj.get("pageIndex")), 1);
int pageSize = KQReportBiz.getPageSize(Util.null2String(jsonObj.get("pageSize")),pageUid,user.getUID());
int count = 0;
int pageCount = 0;
int isHavePre = 0;
int isHaveNext = 0;
String rightSql = kqReportBiz.getReportRight("1",""+user.getUID(),"a");
if(isFromMyAttendance.equals("1")){
rightSql = "";
}
List<Map<String, Object>> leaveRules = kqLeaveRulesBiz.getAllLeaveRules();
List<Object> columns = new ArrayList();
Map<String,Object> column = null;
List<Object> datas = new ArrayList();
Map<String,Object> data = null;
Map<String,Object> mapChildColumnInfo = null;
List<Object> childColumns = null;
KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo();
while (kqReportFieldComInfo.next()){
if(Util.null2String(kqReportFieldComInfo.getParentid()).length()>0)continue;
if(kqReportFieldComInfo.getFieldname().equals("kqCalendar"))continue;
if(KQReportFieldComInfo.cascadekey2fieldname.keySet().contains(kqReportFieldComInfo.getFieldname()))continue;
if(!kqReportFieldComInfo.getReportType().equals("all") && !kqReportFieldComInfo.getReportType().equals("month"))continue;
if("leave".equalsIgnoreCase(kqReportFieldComInfo.getFieldname())&&leaveRules.size()==0)continue;
column = new HashMap();
column.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage()));
column.put("unit", KQReportBiz.getUnitType(kqReportFieldComInfo, user));
column.put("dataIndex", kqReportFieldComInfo.getFieldname());
column.put("type", kqReportFieldComInfo.getFieldname());
column.put("key", kqReportFieldComInfo.getFieldname());
column.put("isSystem", kqReportFieldComInfo.getIsSystem());
mapChildColumnInfo = this.getChildColumnsInfo(kqReportFieldComInfo.getFieldname(),user);
childColumns = (List<Object>)mapChildColumnInfo.get("childColumns");
if(childColumns.size()>0) {//跨列width取子列的width
column.put("rowSpan", 1);
column.put("width", mapChildColumnInfo.get("sumChildColumnWidth"));
column.put("children", childColumns);
}else{
column.put("rowSpan", 3);
column.put("width", Util.getIntValue(kqReportFieldComInfo.getWidth()));
}
column.put("showDetial",kqReportFieldComInfo.getShowDetial());
columns.add(column);
columns.addAll(this.getCascadeKeyColumnsInfo(kqReportFieldComInfo.getCascadekey(),user));
}
boolean isEnd = false;
Calendar cal = DateUtil.getCalendar();
String today = DateUtil.getCurrentDate();
// if(DateUtil.compDate(today, toDate)>0){//结束日期不大于今天
// toDate = today;
// if(DateUtil.compDate(today, fromDate)>0){//结束日期不大于今天
// fromDate = today;
// }
// }
childColumns = new ArrayList<>();
for(String date=fromDate; !isEnd;) {
if(date.equals(toDate)) isEnd = true;
column = new HashMap();
column.put("title", DateUtil.geDayOfMonth(date));
column.put("dataIndex", date);
column.put("key", date);
column.put("type", date);
column.put("rowSpan", 1);
column.put("width", 90);
column.put("isCalendar", 1);
childColumns.add(column);
cal.setTime(DateUtil.parseToDate(date));
date = DateUtil.getDate(cal.getTime(), 1);
}
column = new HashMap();
column.put("title", SystemEnv.getHtmlLabelName(386476, user.getLanguage()));
column.put("dataIndex", "kqCalendar");
column.put("key", "kqCalendar");
if(childColumns.size()>0) {//跨列width取子列的width
column.put("rowSpan", 1);
column.put("width", childColumns.size()*90);
column.put("children", childColumns);
}
columns.add(column);
// 没有权限的人最大只支持查询本季
Map<String, String> getRealDate = new KQReportBiz().realDate(fromDate, toDate, user, "1");
fromDate = getRealDate.get("fromDate");
toDate = getRealDate.get("toDate");
String forgotBeginWorkCheck_field = " sum(b.forgotBeginWorkCheck) ";
if(rs.getDBType().equalsIgnoreCase("oracle")) {
forgotBeginWorkCheck_field = " sum(nvl(b.forgotBeginWorkCheck,0)) ";
}else if((rs.getDBType()).equalsIgnoreCase("mysql")){
forgotBeginWorkCheck_field = " sum(ifnull(b.forgotBeginWorkCheck,0)) ";
}else {
forgotBeginWorkCheck_field = " sum(isnull(b.forgotBeginWorkCheck,0)) ";
}
Map<String,Object> definedFieldInfo = new KQFormatBiz().getDefinedField();
String definedFieldSum = Util.null2String(definedFieldInfo.get("definedFieldSum"));
String backFields = " a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1 as subcompanyid,a.departmentid,a.jobtitle," +
" sum(b.workdays) as workdays,sum(b.workMins) as workMins,sum(b.attendancedays) as attendancedays," +
" sum(b.attendanceMins) as attendanceMins,sum(b.beLate) as beLate,sum(b.beLateMins) as beLateMins, " +
" sum(b.graveBeLate) as graveBeLate, sum(b.graveBeLateMins) as graveBeLateMins,sum(b.leaveEearly) as leaveEearly," +
" sum(b.leaveEarlyMins) as leaveEarlyMins, sum(b.graveLeaveEarly) as graveLeaveEarly, " +
" sum(b.graveLeaveEarlyMins) as graveLeaveEarlyMins,sum(b.absenteeism) as absenteeism, " +
" sum(b.signdays) as signdays,sum(b.signmins) as signmins, "+
" sum(b.absenteeismMins) as absenteeismMins, sum(b.forgotCheck)+"+forgotBeginWorkCheck_field+" as forgotCheck "+(definedFieldSum.length()>0?","+definedFieldSum+"":"");
if(rs.getDBType().equals("oracle")){
backFields = "/*+ index(kq_format_total IDX_KQ_FORMAT_TOTAL_KQDATE) */ "+backFields;
}
String sqlFrom = " from hrmresource a, kq_format_total b where a.id= b.resourceid and b.kqdate >='"+fromDate+"' and b.kqdate <='"+toDate+"'";
String sqlWhere = rightSql;
String groupBy = " group by a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1,a.departmentid,a.jobtitle ";
if(subCompanyId.length()>0){
sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") ";
}
if(departmentId.length()>0){
sqlWhere +=" and a.departmentid in("+departmentId+") ";
}
if(resourceId.length()>0){
sqlWhere +=" and a.id in("+resourceId+") ";
}
if(viewScope.equals("4")){//我的下属
if(allLevel.equals("1")){//所有下属
sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'";
}else{
sqlWhere+=" and a.managerid="+user.getUID();//直接下属
}
}
if (!"1".equals(isNoAccount)) {
sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' ");
}
if(status.length()>0){
if (!status.equals("8") && !status.equals("9")) {
sqlWhere += " and a.status = "+status+ "";
}else if (status.equals("8")) {
sqlWhere += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) ";
}
}
if("-1".equals(fromDate) || "-1".equals(toDate)) {
sqlWhere += " and 1=2 ";
}
sql = " select count(*) as c from ( select 1 as c "+sqlFrom+sqlWhere+groupBy+") t";
rs.execute(sql);
if (rs.next()){
count = rs.getInt("c");
}
if (count <= 0) {
pageCount = 0;
}
pageCount = count / pageSize + ((count % pageSize > 0) ? 1 : 0);
isHaveNext = (pageIndex + 1 <= pageCount) ? 1 : 0;
isHavePre = (pageIndex - 1 >= 1) ? 1 : 0;
String orderBy = " order by t.dsporder asc, t.lastname asc ";
String descOrderBy = " order by t.dsporder desc, t.lastname desc ";
//默认排序设置 start有性能问题先取消后面再看看有没有好的方式
// String orderBySql = "select * from kq_report_order where userId=? and sort=1 order by orders";
// rs.executeQuery(orderBySql, user.getUID());
// if (rs.getCounts() <= 0) {
// orderBySql = "select * from kq_report_order where userId=0 and sort=1 order by orders";
// rs.executeQuery(orderBySql);
// }
// while (rs.next()) {
// String dataIndex = rs.getString("dataIndex");
// String ascOrDesc = rs.getString("ascOrDesc");
// String ascOrDesc1 = (ascOrDesc.equals("")||ascOrDesc.equals("asc"))?"desc":"asc";
// if (dataIndex.equals("organization")) {
// orderBy += ",showOrderOfDeptTree " + ascOrDesc + ",dept_id " + ascOrDesc;
// descOrderBy += ",showOrderOfDeptTree " + ascOrDesc1 + ",dept_id " + ascOrDesc1;
// }
// if (dataIndex.equalsIgnoreCase("dspOrder") || dataIndex.equalsIgnoreCase("lastName")) {
// orderBy += "," + dataIndex + " " + ascOrDesc + ",id " + ascOrDesc;
// descOrderBy += "," + dataIndex + " " + ascOrDesc1 + ",id " + ascOrDesc1;
// } else if (dataIndex.equalsIgnoreCase("deptShowOrder") || dataIndex.equalsIgnoreCase("deptName")) {
// orderBy += "," + dataIndex + " " + ascOrDesc + ",dept_id " + ascOrDesc;
// descOrderBy += "," + dataIndex + " " + ascOrDesc1 + ",dept_id " + ascOrDesc1;
// } else if (dataIndex.equalsIgnoreCase("subcomShowOrder") || dataIndex.equalsIgnoreCase("subcomName")) {
// orderBy += "," + dataIndex + " " + ascOrDesc + ",subcom_id " + ascOrDesc;
// descOrderBy += "," + dataIndex + " " + ascOrDesc1 + ",subcom_id " + ascOrDesc1;
// }
// }
// orderBy = orderBy.startsWith(",") ? orderBy.substring(1) : orderBy;
// descOrderBy = descOrderBy.startsWith(",") ? descOrderBy.substring(1) : descOrderBy;
// orderBy = orderBy.equals("") ? " t.dspOrder,t.id " : orderBy;
// descOrderBy = descOrderBy.equals("") ? " t.dspOrder,t.id " : descOrderBy;
// orderBy = "order by "+orderBy;
sql = backFields + sqlFrom + sqlWhere + groupBy;
if (pageIndex > 0 && pageSize > 0) {
if (rs.getDBType().equals("oracle")) {
sql = " select * from (select " + sql+") t "+orderBy;
sql = "select * from ( select row_.*, rownum rownum_ from ( " + sql + " ) row_ where rownum <= "
+ (pageIndex * pageSize) + ") where rownum_ > " + ((pageIndex - 1) * pageSize);
} else if (rs.getDBType().equals("mysql")) {
sql = " select * from (select " + sql+") t "+orderBy;
sql = "select t1.* from (" + sql + ") t1 limit " + ((pageIndex - 1) * pageSize) + "," + pageSize;
}
else if (rs.getDBType().equals("postgresql")) {
sql = " select * from (select " + sql+") t "+orderBy;
sql = "select t1.* from (" + sql + ") t1 limit " +pageSize + " offset " + ((pageIndex - 1) * pageSize);
}
else {
orderBy = " order by dsporder asc, lastname asc ";
descOrderBy = " order by dsporder desc, lastname desc ";
if (pageIndex > 1) {
int topSize = pageSize;
if (pageSize * pageIndex > count) {
topSize = count - (pageSize * (pageIndex - 1));
}
sql = " select top " + topSize + " * from ( select top " + topSize + " * from ( select top "
+ (pageIndex * pageSize) + sql + orderBy+ " ) tbltemp1 " + descOrderBy + ") tbltemp2 " + orderBy;
} else {
sql = " select top " + pageSize + sql+orderBy;
}
}
} else {
sql = " select " + sql;
}
// #1475814-概述:满足考勤报分部部门显示及导出时显示全路径
String fullPathMainKey = "show_full_path";
KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo();
String isShowFullPath = Util.null2String(kqSettingsComInfo.getMain_val(fullPathMainKey),"0");
String show_card_source = Util.null2String(kqSettingsComInfo.getMain_val("show_card_source"),"0");//是否显示打卡数据,以及打卡数据来源
params.put("show_card_source",show_card_source);
KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz();
int uintType = kqOvertimeRulesBiz.getMinimumUnit();//当前加班单位
double hoursToDay = kqOvertimeRulesBiz.getHoursToDay();//当前天跟小时计算关系
params.put("uintType",uintType);
params.put("hoursToDay",hoursToDay);
Map<String,Object> flowData = kqReportBiz.getFlowData(params,user);
rs.execute(sql);
while (rs.next()) {
data = new HashMap<>();
kqReportFieldComInfo.setTofirstRow();
String id = rs.getString("id");
data.put("resourceId",id);
while (kqReportFieldComInfo.next()){
if(!Util.null2String(kqReportFieldComInfo.getIsdataColumn()).equals("1"))continue;
if(!kqReportFieldComInfo.getReportType().equals("all") && !kqReportFieldComInfo.getReportType().equals("month"))continue;
if("leave".equalsIgnoreCase(kqReportFieldComInfo.getFieldname())&&leaveRules.size()==0){
continue;
}
String fieldName = kqReportFieldComInfo.getFieldname();
String fieldValue = "";
if(fieldName.equals("subcompany")){
String tmpSubcompanyId = Util.null2String(rs.getString("subcompanyid"));
if(tmpSubcompanyId.length()==0){
tmpSubcompanyId = Util.null2String(resourceComInfo.getSubCompanyID(id));
}
data.put("subcompanyId",tmpSubcompanyId);
fieldValue = "1".equals(isShowFullPath) ?
SubCompanyComInfo.getSubcompanyRealPath(tmpSubcompanyId, "/", "0") :
subCompanyComInfo.getSubCompanyname(tmpSubcompanyId);
// fieldValue = subCompanyComInfo.getSubCompanyname(tmpSubcompanyId);
}else if(fieldName.equals("department")){
String tmpDepartmentId = Util.null2String(rs.getString("departmentid"));
if(tmpDepartmentId.length()==0){
tmpDepartmentId = Util.null2String(resourceComInfo.getDepartmentID(id));
}
data.put("departmentId",tmpDepartmentId);
fieldValue = "1".equals(isShowFullPath) ?
departmentComInfo.getDepartmentRealPath(tmpDepartmentId, "/", "0") :
departmentComInfo.getDepartmentname(tmpDepartmentId);
// fieldValue = departmentComInfo.getDepartmentname(tmpDepartmentId);
}else if(fieldName.equals("jobtitle")){
String tmpJobtitleId = Util.null2String(rs.getString("jobtitle"));
if(tmpJobtitleId.length()==0){
tmpJobtitleId = Util.null2String(resourceComInfo.getJobTitle(id));
}
data.put("jobtitleId",tmpJobtitleId);
fieldValue = jobTitlesComInfo.getJobTitlesname(tmpJobtitleId);
}else if(fieldName.equals("attendanceSerial")){
List<String> serialIds = null;
if(attendanceSerial.length()>0){
serialIds = Util.splitString2List(attendanceSerial,",");
}
for(int i=0;serialIds!=null&&i<serialIds.size();i++){
data.put(serialIds.get(i), kqReportBiz.getSerialCount(id,fromDate,toDate,serialIds.get(i)));
}
}else if(kqReportFieldComInfo.getParentid().equals("overtime")||kqReportFieldComInfo.getParentid().equals("overtime_nonleave")
||kqReportFieldComInfo.getParentid().equals("overtime_4leave")||fieldName.equals("businessLeave") || fieldName.equals("officialBusiness")){
if(fieldName.equals("overtimeTotal")){
double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|workingDayOvertime_4leave")));
workingDayOvertime_4leave = workingDayOvertime_4leave<0?0:workingDayOvertime_4leave;
double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|restDayOvertime_4leave")));
restDayOvertime_4leave = restDayOvertime_4leave<0?0:restDayOvertime_4leave;
double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|holidayOvertime_4leave")));
holidayOvertime_4leave = holidayOvertime_4leave<0?0:holidayOvertime_4leave;
double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|workingDayOvertime_nonleave")));
workingDayOvertime_nonleave = workingDayOvertime_nonleave<0?0:workingDayOvertime_nonleave;
double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|restDayOvertime_nonleave")));
restDayOvertime_nonleave = restDayOvertime_nonleave<0?0:restDayOvertime_nonleave;
double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|holidayOvertime_nonleave")));
holidayOvertime_nonleave = holidayOvertime_nonleave<0?0:holidayOvertime_nonleave;
fieldValue = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_4leave+restDayOvertime_4leave+holidayOvertime_4leave+
workingDayOvertime_nonleave+restDayOvertime_nonleave+holidayOvertime_nonleave));
}else if(fieldName.equals("businessLeave") || fieldName.equals("officialBusiness")){
String businessLeaveData = Util.null2s(Util.null2String(flowData.get(id+"|"+fieldName)),"0.0");
String backType = fieldName+"_back";
String businessLeavebackData = Util.null2s(Util.null2String(flowData.get(id+"|"+backType)),"0.0");
String businessLeave = "";
try{
//以防止出现精度问题
if(businessLeaveData.length() == 0){
businessLeaveData = "0.0";
}
if(businessLeavebackData.length() == 0){
businessLeavebackData = "0.0";
}
BigDecimal b_businessLeaveData = new BigDecimal(businessLeaveData);
BigDecimal b_businessLeavebackData = new BigDecimal(businessLeavebackData);
businessLeave = b_businessLeaveData.subtract(b_businessLeavebackData).toString();
if(Util.getDoubleValue(businessLeave, -1) < 0){
businessLeave = "0.0";
}
}catch (Exception e){
}
fieldValue = KQDurationCalculatorUtil.getDurationRound(businessLeave);
}else{
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id+"|"+fieldName)));
}
}else if (fieldName.equals("reportEve")) {//考勤二开--日报转出差
Integer temp = Util.getIntValue(Util.null2String(flowData.get("ReportEve|" + resourceId)));
if (temp <= 0 ) {
fieldValue = "0";
} else {
fieldValue = String.valueOf(temp);
}
} else {
fieldValue = Util.null2String(rs.getString(fieldName));
if(Util.null2String(kqReportFieldComInfo.getUnittype()).length()>0) {
if(fieldValue.length() == 0){
fieldValue="0";
}else{
if (kqReportFieldComInfo.getUnittype().equals("2")) {
fieldValue = KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(fieldValue) / 60.0)));
}
}
}
}
data.put(fieldName,fieldValue);
}
//请假
List<Map<String, Object>> allLeaveRules = kqLeaveRulesBiz.getAllLeaveRules();
Map<String, Object> leaveRule = null;
for(int i=0;allLeaveRules!=null&&i<allLeaveRules.size();i++){
leaveRule = (Map<String, Object>)allLeaveRules.get(i);
String flowType = Util.null2String("leaveType_"+leaveRule.get("id"));
String leaveData = Util.null2String(flowData.get(id+"|"+flowType));
String flowLeaveBackType = Util.null2String("leavebackType_"+leaveRule.get("id"));
String leavebackData = Util.null2s(Util.null2String(flowData.get(id+"|"+flowLeaveBackType)),"0.0");
String b_flowLeaveData = "";
String flowLeaveData = "";
try{
//以防止出现精度问题
if(leaveData.length() == 0){
leaveData = "0.0";
}
if(leavebackData.length() == 0){
leavebackData = "0.0";
}
BigDecimal b_leaveData = new BigDecimal(leaveData);
BigDecimal b_leavebackData = new BigDecimal(leavebackData);
b_flowLeaveData = b_leaveData.subtract(b_leavebackData).toString();
if(Util.getDoubleValue(b_flowLeaveData, -1) < 0){
b_flowLeaveData = "0.0";
}
}catch (Exception e){
writeLog("GetKQReportCmd:leaveData"+leaveData+":leavebackData:"+leavebackData+":"+e);
}
//考虑下冻结的数据
if(b_flowLeaveData.length() > 0){
flowLeaveData = KQDurationCalculatorUtil.getDurationRound(b_flowLeaveData);
}else{
flowLeaveData = KQDurationCalculatorUtil.getDurationRound(Util.null2String(Util.getDoubleValue(leaveData,0.0)-Util.getDoubleValue(leavebackData,0.0)));
}
data.put(flowType,flowLeaveData);
}
Map<String,Object> detialDatas = kqReportBiz.getDetialDatas(id,fromDate,toDate,user,flowData,false,uintType,show_card_source);
// new KQLog().info("id:"+id+":detialDatas:"+detialDatas);
isEnd = false;
for(String date=fromDate; !isEnd;) {
if(date.equals(toDate)) isEnd = true;
if(DateUtil.compDate(today, date)>0){
data.put(date,"");
}else{
// new KQLog().info("id:date:"+(id+"|"+date)+":detialDatas.get:"+detialDatas.get(id+"|"+date));
data.put(date,detialDatas.get(id+"|"+date)==null?SystemEnv.getHtmlLabelName(26593, user.getLanguage()):detialDatas.get(id+"|"+date));
}
cal.setTime(DateUtil.parseToDate(date));
date = DateUtil.getDate(cal.getTime(), 1);
}
datas.add(data);
}
List<Object> lsHolidays = KQHolidaySetBiz.getHolidaySetListByScope(""+user.getUID(),fromDate,toDate);
retmap.put("holidays", lsHolidays);
retmap.put("columns",columns);
retmap.put("datas",datas);
retmap.put("pagesize", pageSize);
retmap.put("pageindex", pageIndex);
retmap.put("count", count);
retmap.put("pagecount", pageCount);
retmap.put("ishavepre", isHavePre);
retmap.put("ishavenext", isHaveNext);
}catch (Exception e){
writeLog(e);
}
return retmap;
}
private Map<String,Object> getChildColumnsInfo(String parentid, User user){
Map<String,Object> returnMap = new HashMap<>();
List<Object> lsChildColumns = new ArrayList<>();
Map column = null;
int sumChildColumnWidth = 0;
if(parentid.equals("attendanceSerial")){//考勤班次
KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo();
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
List<String> serialIds = null;
if(Util.null2String(jsonObj.get("attendanceSerial")).length()>0){
serialIds = Util.splitString2List(Util.null2String(jsonObj.get("attendanceSerial")),",");
}
for(int i=0;serialIds!=null&&i<serialIds.size();i++){
column = new HashMap();
column.put("title", kqShiftManagementComInfo.getSerial(serialIds.get(i)));
column.put("unit", "");
column.put("width", 65);
column.put("dataIndex", serialIds.get(i));
column.put("key", serialIds.get(i));
column.put("rowSpan", 2);
column.put("colSpan", 1);
sumChildColumnWidth+=65;
lsChildColumns.add(column);
}
}else if(parentid.equals("leave")){
KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz();
List<Map<String, Object>> leaveRules = kqLeaveRulesBiz.getAllLeaveRules();
for(int i=0;leaveRules!=null&&i<leaveRules.size();i++){
Map<String, Object> leaveRule = leaveRules.get(i);
String id = "leaveType_"+Util.null2String(leaveRule.get("id"));
String name = Util.null2String(leaveRule.get("name"));
String unitType = Util.null2String(leaveRule.get("unitType"));
column = new HashMap();
column.put("title", name);
column.put("unit", KQUnitBiz.isLeaveHour(unitType) ?SystemEnv.getHtmlLabelName(391, user.getLanguage()):SystemEnv.getHtmlLabelName(1925, user.getLanguage()));
column.put("width", 65);
column.put("dataIndex", id);
column.put("key", id);
column.put("rowSpan", 2);
column.put("colSpan", 1);
column.put("showDetial","1");
sumChildColumnWidth+=65;
lsChildColumns.add(column);
}
}else if(parentid.equals("overtime")){
String[] overtimeChild = {"overtime_nonleave","overtime_4leave","overtimeTotal"};
for(int i=0;i<overtimeChild.length;i++){
String id = overtimeChild[i];
column = new HashMap();
String fieldlabel = "";
column.put("unit", "");
if("overtime_nonleave".equalsIgnoreCase(id)){
fieldlabel = "125805";
}else if("overtime_4leave".equalsIgnoreCase(id)){
fieldlabel = "125804";
}else{
fieldlabel = "523";
column.put("showDetial","1");
String unitType = (KQOvertimeRulesBiz.getMinimumUnit()==3 || KQOvertimeRulesBiz.getMinimumUnit()==5 ||KQOvertimeRulesBiz.getMinimumUnit()==6)?"2":"1";
String unitTypeName = "";
if(Util.null2String(unitType).length()>0){
if(unitType.equals("1")){
unitTypeName=SystemEnv.getHtmlLabelName(1925, user.getLanguage());
}else if(unitType.equals("2")){
unitTypeName=SystemEnv.getHtmlLabelName(391, user.getLanguage());
}else if(unitType.equals("3")){
unitTypeName=SystemEnv.getHtmlLabelName(18083, user.getLanguage());
}
}
column.put("unit", unitTypeName);
}
column.put("title", SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage()));
column.put("dataIndex", id);
column.put("key", id);
column.put("rowSpan", 1);
Map<String,Object> mapChildColumnInfo = getChildColumnsInfo(id, user);
int childWidth = 65;
List<Object> childColumns = (List<Object>)mapChildColumnInfo.get("childColumns");
if(childColumns.size()>0) {//跨列width取子列的width
column.put("children", childColumns);
childWidth = Util.getIntValue(Util.null2String(mapChildColumnInfo.get("sumChildColumnWidth")),65);
}
column.put("width", childWidth+"");
sumChildColumnWidth+=childWidth;
lsChildColumns.add(column);
}
}else{
KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo();
while (kqReportFieldComInfo.next()){
if(kqReportFieldComInfo.getParentid().equals(parentid)) {
if(!kqReportFieldComInfo.getReportType().equals("month"))continue;
column = new HashMap();
column.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage()));
column.put("unit", KQReportBiz.getUnitType(kqReportFieldComInfo, user));
column.put("width", Util.getIntValue(kqReportFieldComInfo.getWidth()));
column.put("dataIndex", kqReportFieldComInfo.getFieldname());
column.put("key", kqReportFieldComInfo.getFieldname());
column.put("rowSpan", 1);
column.put("colSpan", 1);
column.put("showDetial",kqReportFieldComInfo.getShowDetial());
sumChildColumnWidth+=Util.getIntValue(kqReportFieldComInfo.getWidth());
lsChildColumns.add(column);
}
}
}
returnMap.put("childColumns",lsChildColumns);
returnMap.put("sumChildColumnWidth",sumChildColumnWidth);
return returnMap;
}
private List<Object> getCascadeKeyColumnsInfo(String cascadeKey, User user){
List<Object> lsChildColumns = new ArrayList<>();
if(Util.null2String(cascadeKey).length()==0){
return lsChildColumns;
}
Map<String,Object> column = null;
List<String> lsCascadeKey = Util.splitString2List(cascadeKey,",");
KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo();
for(int i=0;i<lsCascadeKey.size();i++){
kqReportFieldComInfo.setTofirstRow();
while (kqReportFieldComInfo.next()) {
if(!kqReportFieldComInfo.getReportType().equals("month"))continue;
if (kqReportFieldComInfo.getFieldname().equals(lsCascadeKey.get(i))){
column = new HashMap();
column.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage()));
column.put("unit", KQReportBiz.getUnitType(kqReportFieldComInfo, user));
column.put("width", Util.getIntValue(kqReportFieldComInfo.getWidth()));
column.put("dataIndex", kqReportFieldComInfo.getFieldname());
column.put("key", kqReportFieldComInfo.getFieldname());
column.put("rowSpan", 1);
column.put("colSpan", 1);
column.put("showDetial",kqReportFieldComInfo.getShowDetial());
column.put("isSystem", kqReportFieldComInfo.getIsSystem());
lsChildColumns.add(column);
}
}
}
return lsChildColumns;
}
@Override
public BizLogContext getLogContext() {
return null;
}
}

@ -0,0 +1,741 @@
package com.engine.kq.util;
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.*;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.CellRangeAddressList;
import org.apache.poi.ss.util.RegionUtil;
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;
public class ExcelUtil extends BaseBean {
/*
*
* */
public Map export(Map<String, Object> workBook, HttpServletRequest request, HttpServletResponse response) throws Exception {
return export(workBook, request, response,false);
}
public Map export(Map<String, Object> workBook, HttpServletRequest request, HttpServletResponse response,boolean isWrap) 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,isWrap); //单元格样式对象
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);
//将查询出的数据设置到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 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,boolean isWrap) {
// 设置字体
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);
if(isWrap){
style.setWrapText(true);
}else{
style.setWrapText(false);
}
//设置水平对齐的样式为居中对齐;
style.setAlignment(HorizontalAlignment.LEFT);
//设置垂直对齐的样式为居中对齐;
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) {
int cur_rowIndx = rowIdx+1;
//title 总行数
int title_rows = cur_rowIndx+getRowNums(columns)-1;
createHeaderRow(sheet, cur_rowIndx, 0,columns,columnTopStyle,title_rows);
return title_rows;
}
/**
*
*/
private int createHeaderRow(Sheet sheet, int index, int cellIndex,
List<Object> columnName, CellStyle columnTopStyle, int title_rows) {
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"));
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);
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.mingfeng.controller;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.mingfeng.service.OverTimeService;
import com.engine.mingfeng.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("/getovertimetype")
@POST
@Produces(MediaType.APPLICATION_JSON)
public String getOverTimeType(@Context HttpServletRequest request, @Context HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
Map<String, Object> params = ParamUtil.request2Map(request);
Map<String, Object> resultDatas = getOverTimeService(user).getOverTimeType(params);
return new Gson().toJson(resultDatas);
}
}

@ -0,0 +1,39 @@
package com.engine.mingfeng.controller;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.mingfeng.service.PerformanService;
import com.engine.mingfeng.service.impl.PerformanServiceImpl;
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;
/**
* @author chenwnj
* @date 2023/11/6
* @description
**/
public class PerformanController {
public PerformanService getPerformanService(User user) {
return ServiceUtil.getService(PerformanServiceImpl.class,user);
}
@Path("/getperformaninfo")
@POST
@Produces(MediaType.APPLICATION_JSON)
public String getPerformanInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
Map<String, Object> params = ParamUtil.request2Map(request);
Map<String, Object> resultDatas = getPerformanService(user).getPerformanInfo(params);
return new Gson().toJson(resultDatas);
}
}

@ -0,0 +1,11 @@
package com.engine.mingfeng.service;
import java.util.Map;
public interface OverTimeService {
/**
*
*/
Map<String, Object> getOverTimeType(Map<String, Object> params);
}

@ -0,0 +1,15 @@
package com.engine.mingfeng.service;
import java.util.Map;
/**
* @author chenwnj
* @date 2023/11/6
* @description
**/
public interface PerformanService {
/**
*
*/
Map<String, Object> getPerformanInfo(Map<String, Object> params);
}

@ -0,0 +1,81 @@
package com.engine.mingfeng.service.impl;
import com.engine.core.impl.Service;
import com.engine.kq.biz.KQGroupMemberComInfo;
import com.engine.kq.biz.KQHolidaySetBiz;
import com.engine.kq.biz.KQWorkTime;
import com.engine.mingfeng.service.OverTimeService;
import org.apache.commons.lang.StringUtils;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class OverTimeServiceImpl extends Service implements OverTimeService {
BaseBean basebean = new BaseBean();
@Override
public Map<String, Object> getOverTimeType(Map<String, Object> params) {
basebean.writeLog("OverTimeServiceImpl getOverTimeType start");
Map<String, Object> result = new HashMap<>();
String resourceId = Util.null2String(params.get("resourceId"));
String kqDate = Util.null2String(params.get("kqDate"));
if (StringUtils.isEmpty(resourceId)) {
result.put("code",500);
result.put("msg","请输入加班申请人");
return result;
}
if (StringUtils.isEmpty(kqDate)) {
result.put("code",500);
result.put("msg","请输入加班开始日期");
return result;
}
int changeType = getChangeType(resourceId, kqDate);
if ( changeType == 1 || changeType == 2 || changeType == 3) {
changeType = changeType - 1;
result.put("code",200);
result.put("msg","加班类型获取成功");
result.put("data",changeType);
return result;
}
result.put("code",500);
result.put("msg","加班类型获取失败");
return result;
}
/**
* ID
*
* @param resourceId ID
* IDID
* @param date
* ()
* @return 1-2-3--1-
*/
public int getChangeType(String resourceId, String date) {
int changeType = -1;
/*获取考勤组的ID因为考勤组有有效期所以需要传入日期*/
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo();
String groupId = kqGroupMemberComInfo.getKQGroupId(resourceId, date);
/*该人员不存在于任意一个考勤组中,请为其设置考勤组*/
if(groupId.equals("")){
basebean.writeLog("该人员不存在于任意一个考勤组中请为其设置考勤组。resourceId=" + resourceId + ",date=" + date);
}
changeType = KQHolidaySetBiz.getChangeType(groupId, date);
if (changeType != 1 && changeType != 2 && changeType != 3) {
KQWorkTime kqWorkTime = new KQWorkTime();
changeType = kqWorkTime.isWorkDay(resourceId, date) ? 2 : 3;
}
return changeType;
}
}

@ -0,0 +1,97 @@
package com.engine.mingfeng.service.impl;
import com.engine.core.impl.Service;
import com.engine.mingfeng.service.PerformanService;
import org.apache.commons.lang3.StringUtils;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.User;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author chenwnj
* @date 2023/11/6
* @description
**/
public class PerformanServiceImpl extends Service implements PerformanService {
@Override
public Map<String, Object> getPerformanInfo(Map<String, Object> params) {
BaseBean bb = new BaseBean();
bb.writeLog("-----getPerformanInfo start-----");
Map<String, Object> result = new HashMap<>();
Map<String, Object> data = new HashMap<>();
RecordSet rs = new RecordSet();
try {
User user = getUser();
int userId = user.getUID();
bb.writeLog("userId: " + userId);
List<Map<String, Object>> performanInfos = new ArrayList<>();
if (userId>0) {
String acqPerformanSql = "select case lb when 0 then '业绩达成-材料' " +
" when 1 then '业绩达成-设备' " +
" when 2 then 'O2O' " +
" when 3 then 'GI 非标 - 个人' " +
" when 4 then '成本改善' END as lb , ndmb, ytddc, ytddcbl, ycpd from uf_jxzssj where xm = ?";
bb.writeLog("acqPerformanSql: " + acqPerformanSql);
rs.executeQuery(acqPerformanSql, userId);
while (rs.next()) {
String lb = Util.null2String(rs.getString("lb"));//年度目标
String ndmb = Util.null2String(rs.getString("ndmb"));//年度目标
String ytddc = Util.null2String(rs.getString("ytddc"));//YTD达成
String ytddcbl = Util.null2String(rs.getString("ytddcbl"));//YTD达成比例
String ycpd = Util.null2String(rs.getString("ycpd"));//异常情况
bb.writeLog("lb: " + lb);
bb.writeLog("ndmb: " + ndmb);
bb.writeLog("ytddc: " + ytddc);
bb.writeLog("ytddcbl: " + ytddcbl);
bb.writeLog("ycpd: " + ycpd);
if ( StringUtils.isNotBlank(ytddcbl)) {
int index = ytddcbl.indexOf("%");
if (index >= 0) {
ytddcbl = ytddcbl.substring(0, index );
}
}
bb.writeLog("ytddcbl: " + ytddcbl);
String wdc = "0";
if ( StringUtils.isNotBlank(ndmb) && StringUtils.isNotBlank(ytddc)) {
wdc = String.valueOf(Double.parseDouble(ndmb)-Double.parseDouble(ytddc));
}
bb.writeLog("wdc: " + wdc);
data = new HashMap<>();
data.put("lb",lb);
data.put("ndmb",ndmb);
data.put("ytddc",ytddc);
data.put("ytddcbl",ytddcbl);
data.put("wdc",wdc);
data.put("ycpd",ycpd);
performanInfos.add(data);
}
}
result.put("code",200);
result.put("msg","请求成功");
result.put("data", performanInfos);
} catch (Exception e) {
bb.writeLog("getPerformanInfo exception: " + e);
result.put("code",500);
result.put("msg","请求异常,请联系管理员");
}
bb.writeLog("-----getPerformanInfo end-----");
return result;
}
}

@ -0,0 +1,961 @@
package weaver.interfaces.mfkj.job;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang.StringUtils;
import weaver.conn.RecordSet;
import weaver.formmode.setup.ModeRightInfo;
import weaver.general.BaseBean;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.interfaces.mfkj.util.HttpUtils;
import weaver.interfaces.schedule.BaseCronJob;
import java.util.*;
/**
* @Title
* @Author wangchaofa
* @CreateDate 2023/8/12
* @Version 1.0
* @Description
*/
public class SynResumeJob extends BaseCronJob {
BaseBean bb = new BaseBean();
@Override
public void execute() {
bb.writeLog("========== start to syn resume info ==========");
RecordSet rs = new RecordSet();
RecordSet rs1 = new RecordSet();
RecordSet rst = new RecordSet();
RecordSet rscheck = new RecordSet();
//企业编码
String corpCode = bb.getPropValue("syn_othersys_mfkj","corpCode");
//用户名称
String userName = bb.getPropValue("syn_othersys_mfkj","userName");
//加密密码
String password = bb.getPropValue("syn_othersys_mfkj","password");
//获取 token url
String token_url = bb.getPropValue("syn_othersys_mfkj","token_url");
//
String getUnEnterDuty_url = bb.getPropValue("syn_othersys_mfkj","getUnEnterDuty_url");
//uf_dy_token modeuuid
String token_uuid = bb.getPropValue("syn_othersys_mfkj","token_uuid");
JSONObject jsonObject = new JSONObject();
jsonObject.put("corpCode",corpCode);
jsonObject.put("userName",userName);
jsonObject.put("password",password);
Map<String,Object> tokenMap = new HashMap<>();
Map<String,String> headers = new HashMap<>();
String encode = "utf-8";
String token = "";
String expire = "";
Calendar cal1 = Calendar.getInstance();
long now_time = cal1.getTimeInMillis();
bb.writeLog("now_time",now_time);
try {
rst.executeQuery("select * from uf_dy_token where modeuuid='" + token_uuid + "'");
rst.next();
expire = Util.null2o(rst.getString("expire"));
token = Util.null2o(rst.getString("token"));
long timestamp = Long.parseLong(expire) * 1000;
//token已过期重新调用获取新的token
if (now_time > timestamp) {
tokenMap = HttpUtils.getTokenInfo(token_url, headers, jsonObject.toString(), encode);
if (tokenMap.size() > 0) {
token = (String) tokenMap.get("token");
expire = (String) tokenMap.get("expire");
//更新token和有效时间戳
rs1.executeUpdate("update uf_dy_token set token='" + token + "',expire='" + expire + "' where modeuuid='" + token_uuid + "'");
}
}
headers.put("Authorization", "Bearer "+token);
JSONObject json = new JSONObject();
json.put("rowSize","10");
json.put("cType","2,4,400");
json.put("vType","1");
//请求数据
String data = HttpUtils.getResumeInfo(getUnEnterDuty_url,headers,json.toString(),"UTF-8");
bb.writeLog("data: "+data);
JSONObject json_data = JSONObject.parseObject(data);
String resume = json_data.getString("resume");
JSONArray jsonArray = JSONArray.parseArray(resume);
bb.writeLog("resume: "+jsonArray);
for(int i=0;i<jsonArray.size();i++){
bb.writeLog("job sync index:",i);
String uuid = UUID.randomUUID().toString();
String currentdate = TimeUtil.getCurrentDateString();
String currenttime = TimeUtil.getOnlyCurrentTimeString();
String currentdatetime = currentdate+" "+currenttime;
int resume_formmodeid = Integer.parseInt(bb.getPropValue("syn_othersys_mfkj","resume_formmodeid"));
int creater = 1;
JSONObject jsonObject1 = jsonArray.getJSONObject(i);
bb.writeLog("jsonObject1: "+jsonObject1);
String resumeContent = jsonObject1.getString("resumeContent");
bb.writeLog("resumeContent: "+resumeContent);
JSONObject json_resumeContent = JSONObject.parseObject(resumeContent);
//外部职位信息
String responsibilities = "";
String externalPostId = Util.null2String(jsonObject1.getString("externalPostId"));
bb.writeLog("externalPostId: "+externalPostId);
if (StringUtils.isNotBlank(externalPostId)) {
//对应流程中获取岗位职责字段的值
String tableName = bb.getPropValue("syn_othersys_mfkj","recruitmentWorkflowName");
if (StringUtils.isNotBlank(tableName)) {
String acqResponSql = "select gwzz from " + tableName + " where requestid = ?";
rst.executeQuery(acqResponSql,externalPostId);
while (rst.next()) {
responsibilities = Util.null2String(rst.getString("gwzz"));
}
}
}
bb.writeLog("responsibilities: "+responsibilities);
String applyId = jsonObject1.getString("applyId");
bb.writeLog("applyId: "+applyId);
String resumeId = jsonObject1.getString("resumeId");
bb.writeLog("resumeId: "+resumeId);
//面试 评价
boolean interviewFlag = true;
String interviewEvaluation = jsonObject1.getString("interviewEvaluation");
bb.writeLog("interviewEvaluation: "+interviewEvaluation);
if (StringUtils.isBlank(interviewEvaluation)) {
interviewFlag = false;
}
JSONArray array_interviewEvaluation = JSONArray.parseArray(interviewEvaluation);
// 个人基本信息
String personalInformation = json_resumeContent.getString("personalInformation");
bb.writeLog("personalInformation: "+personalInformation);
JSONObject json_personalInformation = JSONObject.parseObject(personalInformation);
// 求职意向
String careerObjective = json_resumeContent.getString("careerObjective");
bb.writeLog("careerObjective: "+careerObjective);
JSONObject json_careerObjective = JSONObject.parseObject(careerObjective);
// 姓名
String name = Util.null2String(json_personalInformation.getString("name"));
//身份证号码
String sfzhm = Util.null2String(json_personalInformation.getString("iDNumber"));
// 英文名
String englishName = Util.null2String(json_personalInformation.getString("englishName"));
// 国籍
String nation = Util.null2String(json_personalInformation.getString("Nationality"));
// 国籍编码
String nationCode = Util.null2String(json_personalInformation.getString("nationCode"));
// 性别 0 男 1 女
String gender = Util.null2String(json_personalInformation.getString("gender"));
if("男".equals(gender)){
gender = "0";
}else{
gender = "1";
}
// 邮箱地址
String email = Util.null2String(json_personalInformation.getString("email"));
// 手机号码
String mobilePhone = Util.null2String(json_personalInformation.getString("mobilePhone"));
// 现住址
String currentCity = Util.null2String(json_personalInformation.getString("currentCity"));
// 身份证地址
String hukou = Util.null2String(json_personalInformation.getString("hukou"));
// 婚姻情况 0 未婚 1 已婚已育 2 已婚未育
// String maritalStatus = Util.null2String(json_personalInformation.getString("hunyuzhuangkuang"));
String maritalStatus = Util.null2String(json_personalInformation.getString("maritalAndFertilityStatus"));
if(maritalStatus.contains("未婚")){
maritalStatus = "0";
}else if(maritalStatus.contains("已育")){
maritalStatus = "1";
}else if(maritalStatus.contains("未育")){
maritalStatus = "2";
}
// 出生日期
String dateOfBirth = Util.null2String(json_personalInformation.getString("dateOfBirth"));
// 应聘职位
String desiredPosition = Util.null2String(json_careerObjective.getString("desiredPosition"));
bb.writeLog("desiredPosition: "+desiredPosition);
// 最快到岗时间
String dateAvailable = Util.null2String(json_personalInformation.getString("dateAvailable"));
// 家庭关系 明细 1
String familyRelationship = json_resumeContent.getString("familyRelationship");
bb.writeLog("familyRelationship: "+familyRelationship);
JSONArray array_familyRelationship = JSONArray.parseArray(familyRelationship);
// 教育经历 明细 2
String educationBackground = json_resumeContent.getString("educationBackground");
bb.writeLog("educationBackground: "+educationBackground);
JSONArray array_educationBackground = JSONArray.parseArray(educationBackground);
// 工作经历 明细 3
String workingExperience = json_resumeContent.getString("workingExperience");
bb.writeLog("workingExperience: "+workingExperience);
JSONArray array_workingExperience = JSONArray.parseArray(workingExperience);
// 过往经历证明 明细 4
String employeeBackground = json_resumeContent.getString("employeeBackground");
bb.writeLog("employeeBackground: "+employeeBackground);
JSONArray array_employeeBackground = JSONArray.parseArray(employeeBackground);
// 薪资要求 明细 5
String packageRequirements = json_resumeContent.getString("packageRequirements");
bb.writeLog("packageRequirements: "+packageRequirements);
JSONObject json_packageRequirements = JSONObject.parseObject(packageRequirements);
//语言能力 明细 6
String language = json_resumeContent.getString("language");
bb.writeLog("language: "+language);
JSONArray array_language = JSONArray.parseArray(language);
// 综合资料
String generalInformation = json_resumeContent.getString("generalInformation");
bb.writeLog("generalInformation: "+generalInformation);
JSONObject json_generalInformation = JSONObject.parseObject(generalInformation);
// 请简述你短期或长期工作目标 a
String gongzuomubiao = Util.null2String(json_generalInformation.getString("gongzuomubiao"));
// 请列明有助于您申请此职位的其他材料 b
String qitacailiao = Util.null2String(json_generalInformation.getString("qitacailiao"));
// 是否曾被起诉,或违反过有关国家法律 c 0 Y 1 N
String weifanfalv = Util.null2String(json_generalInformation.getString("weifanfalv"));
weifanfalv = "是".equals(weifanfalv) ? "0" : "1";
// 您是否有传染性疾病,精神病、高血压或心脏病等较重病史 d 0 Y 1 N
String chuanranjibing = Util.null2String(json_generalInformation.getString("chuanranjibing"));
chuanranjibing = "是".equals(chuanranjibing) ? "0" : "1";
// 请说明 d_2
String qingshuoming = Util.null2String(json_generalInformation.getString("qingshuoming"));
// 您是否有亲戚或朋友在本公司工作或工作过 e 0 Y 1 N
String qinqizaigognsi = Util.null2String(json_generalInformation.getString("qinqizaigognsi"));
qinqizaigognsi = "是".equals(qinqizaigognsi) ? "0" : "1";
// 是否与上家公司有培训协议 f 0 Y 1 N
String peixunxieyi = Util.null2String(json_generalInformation.getString("peixunxieyi"));
peixunxieyi = "是".equals(peixunxieyi) ? "0" : "1";
// 请详细说明 f_2
String qingxiangxishuoming1 = Util.null2String(json_generalInformation.getString("qingxiangxishuoming1"));
// 是否与上家公司有竞业限制责任 g 0 Y 1 N
String jingyexieyi = Util.null2String(json_generalInformation.getString("jingyexieyi"));
jingyexieyi = "是".equals(jingyexieyi) ? "0" : "1";
// 是否与前股雇主有尚未结束的劳动争议 h 0 Y 1 N
String laodongzhengyi = Util.null2String(json_generalInformation.getString("laodongzhengyi"));
laodongzhengyi = "是".equals(laodongzhengyi) ? "0" : "1";
rs.executeQuery("select * from uf_ygjlxxb where zwxm = ? and sjhm = ?",name,mobilePhone);
int billid = -1;
String insertSql = "INSERT INTO uf_ygjlxxb (gwzz, sfzhm, ypzw, zkdgsj, zwxm, ywxm, gj, " +
"xb, yxdz, sjhm, xzz, sfzdz," +
"hyqk, csrq, a, b, c, " +
"d, d2, e, f, g, g2," +
"h, applyid, resumeid, modedatacreater, modedatacreatedate, modedatacreatetime, formmodeid, modeuuid) " +
"VALUES (?, ?, ?, ?, ?, ?, ?, " +
"?, ?, ?, ?, ?," +
"?, ?, ?, ?, ?, " +
"?, ?, ?, ?, ?, ?," +
"?, ?, ?, ?, ?, ?, ?, ?)";
String insertSql_dt1 = "INSERT INTO uf_ygjlxxb_dt1 (mainid, xm, gx, lxfs, zy, dz, sfjjlxr) VALUES(?, ?, ?, ?, ?, ?, ?)";
String insertSql_dt2 = "INSERT INTO uf_ygjlxxb_dt2 (mainid, xx, zy, rxsj, bysj, xl, xllx, wyyz, yynl) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)";
String insertSql_dt3 = "INSERT INTO uf_ygjlxxb_dt3 (mainid, gzdw, gzkssj, gzjssj, zw, zhydxz, lzyy, gzdwdybs) VALUES(?, ?, ?, ?, ?, ?, ?, ?)";
String insertSql_dt4 = "INSERT INTO uf_ygjlxxb_dt4 (mainid, gzdw, zmr, zw, lxfs) VALUES(?, ?, ?, ?, ?)";
String insertSql_dt5 = "INSERT INTO uf_ygjlxxb_dt5 (mainid, mqxz, qwxzsq) VALUES(?, ?, ?)";
String insertSql_dt6 = "INSERT INTO uf_ygjlxxb_dt6 (mainid, wyyz, yynl) VALUES(?, ?, ?)";
//复试面试官~ 沟通表达~ 具体评价内容~ 专业能力~ 具体评价内容2~ 思维逻辑~ 具体评价内容3~ 职业规划~ 具体评价内容4~ 面试综合评价~ 面试总体评价~ 面试轮次~
String insertSql_dt7 = "INSERT INTO uf_ygjlxxb_dt7 (mainid, fsmsg, gtbd, jtpjnr, zynl, jtpjnr2, swlj, jtpjnr3, zygh, jtpjnr4, mszhpj, msztpj, mslc) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
//初试面试官 沟通表达 具体评价内容 专业能力 具体评价内容2 思维逻辑 具体评价内容3 职业规划 具体评价内容4 面试综合评价 面试总体评价 面试轮次
String insertSql_dt8 = "INSERT INTO uf_ygjlxxb_dt8 (mainid, csmsg, gtbd, jtpjnr, zynl, jtpjnr2, swlj, jtpjnr3, zygh, jtpjnr4, mszhpj, msztpj, mslc) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
//不存在,新增
if(!rs.next()){
bb.writeLog("不存在,新增");
//写入 主表
boolean exeRes = rst.executeUpdate(insertSql,new Object[]{responsibilities,sfzhm,desiredPosition,dateAvailable,name,englishName,nation,
gender,email,mobilePhone,currentCity,hukou,
maritalStatus,dateOfBirth,gongzuomubiao,qitacailiao,weifanfalv,
chuanranjibing,qingshuoming,qinqizaigognsi,peixunxieyi,jingyexieyi,qingxiangxishuoming1,
laodongzhengyi,applyId,resumeId, creater, currentdate,currenttime,resume_formmodeid,uuid});
bb.writeLog("insertSql",insertSql);
bb.writeLog("insertSql",new Object[]{responsibilities,sfzhm,desiredPosition,dateAvailable,name,englishName,nation,
gender,email,mobilePhone,currentCity,hukou,
maritalStatus,dateOfBirth,gongzuomubiao,qitacailiao,weifanfalv,
chuanranjibing,qingshuoming,qinqizaigognsi,peixunxieyi,jingyexieyi,qingxiangxishuoming1,
laodongzhengyi,applyId,resumeId, creater, currentdate,currenttime,resume_formmodeid,uuid});
bb.writeLog("exeRes",exeRes);
if (exeRes) {
//重构权限
rs1.executeQuery(" select id from uf_ygjlxxb where modeuuid=? ",new Object[]{uuid});
rs1.next();
billid = rs1.getInt("id");
ModeRightInfo moderight = new ModeRightInfo();
moderight.editModeDataShare(creater, resume_formmodeid, billid);
}
// 明细1
for(int j=0;j<array_familyRelationship.size();j++) {
JSONObject jsonObject_family = array_familyRelationship.getJSONObject(j);
// 姓名
String name1 = Util.null2String(jsonObject_family.getString("name"));
// 关系
String relationship = Util.null2String(jsonObject_family.getString("relationship"));
// 联系方式
String contactNumber = Util.null2String(jsonObject_family.getString("phone"));
// 职业
String jobTitle = Util.null2String(jsonObject_family.getString("occupation"));
// 地址
String address = Util.null2String(jsonObject_family.getString("address"));
// 是否紧急联系人 0 是 1 否
String emergencyContact = Util.null2String(jsonObject_family.getString("emergencyContact"));
if("是".equals(emergencyContact)){
emergencyContact = "0";
}else{
emergencyContact = "1";
}
// 写入 明细1
rst.executeUpdate(insertSql_dt1,new Object[]{billid,name1,relationship,contactNumber,jobTitle,address,emergencyContact});
}
// 明细2
for(int j=0;j<array_educationBackground.size();j++) {
JSONObject jsonObject_education = array_educationBackground.getJSONObject(j);
//学校
String schoolName = Util.null2String(jsonObject_education.getString("schoolName"));
//专业
String major = Util.null2String(jsonObject_education.getString("major"));
//入学时间
String startDate = Util.null2String(jsonObject_education.getString("startDate"));
//毕业时间
String endDate = Util.null2String(jsonObject_education.getString("endDate"));
//学历 0 初中及以下 1 中专 2 高中 3 大专 4 本科 5 硕士研究生 6 技校/职高 7 博士研究生
String diploma = Util.null2String(jsonObject_education.getString("diploma"));
if(diploma.contains("初中")){
diploma = "0";
}else if("中专".equals(diploma)){
diploma = "1";
}else if("高中".equals(diploma)){
diploma = "2";
}else if("大专".equals(diploma)){
diploma = "3";
}else if("本科".equals(diploma)){
diploma = "4";
}else if("硕士研究生".equals(diploma)){
diploma = "5";
}else if("技校/职高".equals(diploma)){
diploma = "6";
}else{
diploma = "7";
}
//学历类型 0 统招 1 自考 2 函授
String educationType = Util.null2String(jsonObject_education.getString("educationType"));
if("统招".equals(educationType)){
educationType = "0";
}else if("自考".equals(educationType)){
educationType = "1";
}else{
educationType = "2";
}
// 写入 明细2
rst.executeUpdate(insertSql_dt2,new Object[]{billid,schoolName,major,startDate,endDate,diploma,educationType,null,"0"});
}
// 明细3
for(int j=0;j<array_workingExperience.size();j++) {
JSONObject jsonObject_working = array_workingExperience.getJSONObject(j);
//工作单位
String companyName = Util.null2String(jsonObject_working.getString("companyName"));
//工作开始日期
String startDate = Util.null2String(jsonObject_working.getString("startDate"));
//工作结束日期
String endDate = Util.null2String(jsonObject_working.getString("endDate"));
//职位
String jobTitle = Util.null2String(jsonObject_working.getString("jobTitle"));
//最后月度薪资
String salaryMonthly = Util.null2String(jsonObject_working.getString("salaryMonthly"));
//离职原因
String reasonForQuit = Util.null2String(jsonObject_working.getString("reasonForQuit"));
//标识Key
String uniqueKey = Util.null2String(jsonObject_working.getString("uniqueKey"));
// 写入 明细3
rst.executeUpdate(insertSql_dt3,new Object[]{billid,companyName,startDate,endDate,jobTitle,salaryMonthly,reasonForQuit, uniqueKey});
}
// 明细4
for(int j=0;j<array_employeeBackground.size();j++) {
JSONObject jsonObject_employee = array_employeeBackground.getJSONObject(j);
//工作单位
String company = Util.null2String(jsonObject_employee.getString("company"));
//证明人
String referenceName = Util.null2String(jsonObject_employee.getString("referenceName"));
//职位
String position = Util.null2String(jsonObject_employee.getString("position"));
//联系电话
String contactNumber = Util.null2String(jsonObject_employee.getString("contactNumber"));
//写入 明细4
rst.executeUpdate(insertSql_dt4,new Object[]{billid,company,referenceName,position,contactNumber});
}
// 明细5
//目前薪资
String currentSalary = Util.null2String(json_packageRequirements.getString("currentSalary"));
//期望薪资
String expectedSalary = Util.null2String(json_packageRequirements.getString("expectedSalary"));
// 写入 明细5
rst.executeUpdate(insertSql_dt5,new Object[]{billid,currentSalary,expectedSalary});
// 明细6
for(int j=0;j<array_language.size();j++) {
JSONObject jsonObject_language = array_language.getJSONObject(j);
//外语语种
String languages = Util.null2String(jsonObject_language.getString("languages"));
//语言能力 0 很好 1 好 2 一般 3 较差
String languageAbility = Util.null2String(jsonObject_language.getString("languageAbility"));
if("很好".equals(languageAbility)){
languageAbility = "0";
}else if("好".equals(languageAbility)){
languageAbility = "1";
}else if("一般".equals(languageAbility)){
languageAbility = "2";
}else if("较差".equals(languageAbility)){
languageAbility = "3";
}
//写入 明细6
rst.executeUpdate(insertSql_dt6,new Object[]{billid,languages,languageAbility});
}
//明细7 复试 根据interviewType来确认初试和复试
if (interviewFlag) {
for(int j=0;j<array_interviewEvaluation.size();j++) {
JSONObject jsonObject_interviewEvaluation = array_interviewEvaluation.getJSONObject(j);
String round = jsonObject_interviewEvaluation.getString("round");//面试轮次
bb.writeLog("round: "+round);
String interviewType = jsonObject_interviewEvaluation.getString("interviewType");
bb.writeLog("interviewType: "+interviewType);
String interviewer = jsonObject_interviewEvaluation.getString("interviewer");
bb.writeLog("interviewer: "+interviewer);
// out.print("新增--明细7:interviewer"+interviewer);
JSONArray array_interviewer = JSONArray.parseArray(interviewer);
for(int k=0;k<array_interviewer.size();k++) {
JSONObject jsonObject_interview = array_interviewer.getJSONObject(k);
//加校验
String summarySheetOfInterview = jsonObject_interview.getString("summarySheetOfInterview");
String pingjia = jsonObject_interview.getString("pingjia");
String interviewEmail = jsonObject_interview.getString("interviewEmail");
if (StringUtils.isNotBlank(summarySheetOfInterview)
&& StringUtils.isNotBlank(pingjia)
&& StringUtils.isNotBlank(interviewEmail)) {
String msg_id = getUserid(interviewEmail);
bb.writeLog("msg_id: " + msg_id);
JSONObject json_summarySheetOfInterview = JSONObject.parseObject(summarySheetOfInterview);
JSONObject json_pingjia = JSONObject.parseObject(pingjia);
// if(!"1".equals(round)){
if ("复试".equals(interviewType)) {
String fsmsg = msg_id;
String fsdf = json_summarySheetOfInterview.getString("comprehensiveEvaluationOfInterview");//面试综合评价
String fspj = json_summarySheetOfInterview.getString("mianshizongtipingjia");//面试总体评价
String jtpjnr = json_pingjia.getString("pingjia1");//具体评价内容1
String jtpjnr2 = json_pingjia.getString("pingjia2");//具体评价内容2
String jtpjnr3 = json_pingjia.getString("pingjia3");//具体评价内容3
String jtpjnr4 = json_pingjia.getString("pingjia4");//具体评价内容4
String gtbd = json_pingjia.getString("communicationAndExpression");//沟通表达
String zynl = json_pingjia.getString("professionalCompetence");//专业能力
String swlj = json_pingjia.getString("thinkingLogic");//思维逻辑
String zygh = json_pingjia.getString("careerPlanning");//职业规划
bb.writeLog("insertSql_dt7: " + insertSql_dt7);
bb.writeLog("params: " + new Object[]{billid, fsmsg, gtbd, jtpjnr, zynl, jtpjnr2, swlj, jtpjnr3, zygh, jtpjnr4, fsdf, fspj, round}.toString());
// 写入 明细7
rst.executeUpdate(insertSql_dt7, new Object[]{billid, fsmsg, gtbd, jtpjnr, zynl, jtpjnr2, swlj, jtpjnr3, zygh, jtpjnr4, fsdf, fspj, round});
}
}
}
}
bb.writeLog("明细8: ");
//明细8 初试 根据interviewType来确认初试和复试
for(int j=0;j<array_interviewEvaluation.size();j++) {
JSONObject jsonObject_interviewEvaluation = array_interviewEvaluation.getJSONObject(j);
String round = jsonObject_interviewEvaluation.getString("round");
bb.writeLog("round: "+round);
String interviewType = jsonObject_interviewEvaluation.getString("interviewType");
bb.writeLog("interviewType: "+interviewType);
String interviewer = jsonObject_interviewEvaluation.getString("interviewer");
bb.writeLog("interviewer: "+interviewer);
JSONArray array_interviewer = JSONArray.parseArray(interviewer);
for(int k=0;k<array_interviewer.size();k++) {
JSONObject jsonObject_interview = array_interviewer.getJSONObject(k);
//summarySheetOfInterview
//加校验
String summarySheetOfInterview = jsonObject_interview.getString("summarySheetOfInterview");
bb.writeLog("summarySheetOfInterview: " + summarySheetOfInterview);
String pingjia = jsonObject_interview.getString("pingjia");
bb.writeLog("pingjia: " + pingjia);
String interviewEmail = jsonObject_interview.getString("interviewEmail");
bb.writeLog("interviewEmail: " + interviewEmail);
if (StringUtils.isNotBlank(summarySheetOfInterview)
&& StringUtils.isNotBlank(pingjia)
&& StringUtils.isNotBlank(interviewEmail)) {
String msg_id = getUserid(interviewEmail);
bb.writeLog("msg_id: " + msg_id);
JSONObject json_summarySheetOfInterview = JSONObject.parseObject(summarySheetOfInterview);
JSONObject json_pingjia = JSONObject.parseObject(pingjia);
if ("初试".equals(interviewType)) {
String csmsg = msg_id;
String mszhpj = json_summarySheetOfInterview.getString("comprehensiveEvaluationOfInterview");//面试综合评价
String msztpj = json_summarySheetOfInterview.getString("mianshizongtipingjia");//面试总体评价
String jtpjnr = json_pingjia.getString("pingjia1");//具体评价内容1
String jtpjnr2 = json_pingjia.getString("pingjia2");//具体评价内容2
String jtpjnr3 = json_pingjia.getString("pingjia3");//具体评价内容3
String jtpjnr4 = json_pingjia.getString("pingjia4");//具体评价内容4
String gtbd = json_pingjia.getString("communicationAndExpression");//沟通表达
String zynl = json_pingjia.getString("professionalCompetence");//专业能力
String swlj = json_pingjia.getString("thinkingLogic");//思维逻辑
String zygh = json_pingjia.getString("careerPlanning");//职业规划
bb.writeLog("insertSql_dt8: " + insertSql_dt8);
bb.writeLog("params: " + new Object[]{billid, csmsg, gtbd, jtpjnr, zynl, jtpjnr2, swlj, jtpjnr3, zygh, jtpjnr4, mszhpj, msztpj, round}.toString());
// 写入 明细8
//csmsg, gtbd, jtpjnr, zynl, jtpjnr2, swlj, jtpjnr3, zygh, jtpjnr4, mszhpj, msztpj, mslc
rst.executeUpdate(insertSql_dt8, new Object[]{billid, csmsg, gtbd, jtpjnr, zynl, jtpjnr2, swlj, jtpjnr3, zygh, jtpjnr4, mszhpj, msztpj, round});
}
}
}
}
}
}
// 更新
else{
bb.writeLog("更新: ");
billid = Util.getIntValue(rs.getString("id"));
bb.writeLog("billid: "+billid);
//更新 主表
String updateSql = "UPDATE uf_ygjlxxb SET sfzhm='"+sfzhm+"',ypzw='"+ desiredPosition +"', zkdgsj='"+ dateAvailable +"', zwxm='"+ name +"', ywxm='"+ englishName +"', gj='"+ nation +"', " +
"xb='"+ gender +"', yxdz='"+ email +"', sjhm='"+ mobilePhone +"', xzz='"+ currentCity +"', sfzdz='"+ hukou +"'," +
"hyqk='"+ maritalStatus +"', csrq='"+ dateOfBirth +"', a='"+ gongzuomubiao +"', b='"+ qitacailiao +"', c='"+ weifanfalv +"', " +
"d='"+ chuanranjibing +"', d2='"+ qingshuoming +"', e='"+ qinqizaigognsi +"', f='"+ peixunxieyi +"', g='"+ jingyexieyi +"', g2='"+ qingxiangxishuoming1 +"'," +
"h='"+ laodongzhengyi +"', " +
// "', csmsg='"+csmsg+"', csdf='"+csdf+"', cspj='"+cspj+"', fszhdf='"+fszhdf+"', " + 主表转明细表,废除
"applyid='"+ applyId +"',resumeId='"+ resumeId +"',modedatamodifier='"+ creater +"',modedatamodifydatetime='"+ currentdatetime +"', gwzz = '"+responsibilities+"' WHERE id="+ billid;
bb.writeLog("updateSql: "+updateSql);
//更新 主表
rst.executeUpdate(updateSql);
// 明细1
for(int j=0;j<array_familyRelationship.size();j++) {
JSONObject jsonObject_family = array_familyRelationship.getJSONObject(j);
// 姓名
String name1 = Util.null2String(jsonObject_family.getString("name"));
// 关系
String relationship = Util.null2String(jsonObject_family.getString("relationship"));
// 联系方式
String contactNumber = Util.null2String(jsonObject_family.getString("phone"));
// 职业
String jobTitle = Util.null2String(jsonObject_family.getString("occupation"));
// 地址
String address = Util.null2String(jsonObject_family.getString("address"));
// 是否紧急联系人 0 是 1 否
String emergencyContact = Util.null2String(jsonObject_family.getString("emergencyContact"));
if("是".equals(emergencyContact)){
emergencyContact = "0";
}else{
emergencyContact = "1";
}
String updateSql_dt1 = "UPDATE uf_ygjlxxb_dt1 SET gx='"+ relationship +"',lxfs='"+ contactNumber +"',zy='"+ jobTitle +"',dz='"+ address +"',sfjjlxr='"+ emergencyContact +"' WHERE xm='"+ name1 +"' and mainid="+billid;
// 更新 明细1
rst.executeUpdate(updateSql_dt1);
}
// 明细2
for(int j=0;j<array_educationBackground.size();j++) {
JSONObject jsonObject_education = array_educationBackground.getJSONObject(j);
//学校
String schoolName = Util.null2String(jsonObject_education.getString("schoolName"));
//专业
String major = Util.null2String(jsonObject_education.getString("major"));
//入学时间
String startDate = Util.null2String(jsonObject_education.getString("startDate"));
//毕业时间
String endDate = Util.null2String(jsonObject_education.getString("endDate"));
//学历 0 初中及以下 1 中专 2 高中 3 大专 4 本科 5 硕士研究生 6 技校/职高 7 博士研究生
String diploma = Util.null2String(jsonObject_education.getString("diploma"));
if(diploma.contains("初中")){
diploma = "0";
}else if("中专".equals(diploma)){
diploma = "1";
}else if("高中".equals(diploma)){
diploma = "2";
}else if("大专".equals(diploma)){
diploma = "3";
}else if("本科".equals(diploma)){
diploma = "4";
}else if("硕士研究生".equals(diploma)){
diploma = "5";
}else if("技校/职高".equals(diploma)){
diploma = "6";
}else{
diploma = "7";
}
//学历类型 0 统招 1 自考 2 函授
String educationType = Util.null2String(jsonObject_education.getString("educationType"));
if("统招".equals(educationType)){
educationType = "0";
}else if("自考".equals(educationType)){
educationType = "1";
}else{
educationType = "2";
}
String updateSql_dt2 = "UPDATE uf_ygjlxxb_dt2 SET zy='"+ major +"',rxsj='"+ startDate +"',bysj='"+ endDate +"',xl='"+ diploma +"',xllx='"+ educationType +"' where xx='"+ schoolName +"' and mainid="+billid;
//更新 明细2
rst.executeUpdate(updateSql_dt2);
}
// 明细3
//先获取所有工作经历的key
List<String> compKeys = new ArrayList<>();
String acqWorkExpSql = "select gzdwdybs from uf_ygjlxxb_dt3 where mainid = ? ";
bb.writeLog("acqWorkExpSql: "+acqWorkExpSql);
rst.executeQuery(acqWorkExpSql, billid);
while ( rst.next()) {
String gzdwdybs = Util.null2String(rst.getString("gzdwdybs"));
compKeys.add(gzdwdybs);
}
bb.writeLog("compKeys: "+compKeys);
for(int j=0;j<array_workingExperience.size();j++) {
JSONObject jsonObject_working = array_workingExperience.getJSONObject(j);
//工作单位
String companyName = Util.null2String(jsonObject_working.getString("companyName"));
bb.writeLog("companyName: "+companyName);
//工作开始日期
String startDate = Util.null2String(jsonObject_working.getString("startDate"));
bb.writeLog("startDate: "+startDate);
//工作结束日期
String endDate = Util.null2String(jsonObject_working.getString("endDate"));
bb.writeLog("endDate: "+endDate);
//职位
String jobTitle = Util.null2String(jsonObject_working.getString("jobTitle"));
bb.writeLog("jobTitle: "+jobTitle);
//最后月度薪资
String salaryMonthly = Util.null2String(jsonObject_working.getString("salaryMonthly"));
bb.writeLog("salaryMonthly: "+salaryMonthly);
//离职原因
String reasonForQuit = Util.null2String(jsonObject_working.getString("reasonForQuit"));
bb.writeLog("reasonForQuit: "+reasonForQuit);
//标识Key
String uniqueKey = Util.null2String(jsonObject_working.getString("uniqueKey"));
bb.writeLog("uniqueKey: "+uniqueKey);
if (compKeys.contains(uniqueKey)) {
String updateSql_dt3 = "UPDATE uf_ygjlxxb_dt3 SET gzkssj='"+ startDate +"',gzjssj='"+ endDate +"',zw='"+ jobTitle +"',zhydxz='"+ salaryMonthly +"',lzyy='"+ reasonForQuit +"', gzdw = '" + companyName +"' where gzdwdybs = '" + uniqueKey +"'";
bb.writeLog("updateSql_dt3: "+updateSql_dt3);
//更新 明细3
rst.executeUpdate(updateSql_dt3);
} else {
// 写入 明细3
rst.executeUpdate(insertSql_dt3,new Object[]{billid,companyName,startDate,endDate,jobTitle,salaryMonthly,reasonForQuit, uniqueKey});
}
}
// 明细4
for(int j=0;j<array_employeeBackground.size();j++) {
JSONObject jsonObject_employee = array_employeeBackground.getJSONObject(j);
//工作单位
String company = Util.null2String(jsonObject_employee.getString("company"));
//证明人
String referenceName = Util.null2String(jsonObject_employee.getString("referenceName"));
//职位
String position = Util.null2String(jsonObject_employee.getString("position"));
//联系电话
String contactNumber = Util.null2String(jsonObject_employee.getString("contactNumber"));
String updateSql_dt4 = "UPDATE uf_ygjlxxb_dt4 SET zmr='"+ referenceName +"',zw='"+ position +"',lxfs='"+ contactNumber +"' where gzdw='"+ company +"' and mainid="+billid;
//更新 明细4
rst.executeUpdate(updateSql_dt4);
}
// 明细5
//目前薪资
String currentSalary = Util.null2String(json_packageRequirements.getString("currentSalary"));
//期望薪资
String expectedSalary = Util.null2String(json_packageRequirements.getString("expectedSalary"));
String updateSql_dt5 = "UPDATE uf_ygjlxxb_dt5 SET mqxz='"+ currentSalary +"',qwxzsq='"+ expectedSalary +"' where mainid="+billid;
//更新 明细5
rst.executeUpdate(updateSql_dt5);
// 明细6
for(int j=0;j<array_language.size();j++) {
JSONObject jsonObject_language = array_language.getJSONObject(j);
//外语语种
String languages = Util.null2String(jsonObject_language.getString("languages"));
//语言能力 0 很好 1 好 2 一般 3 较差
String languageAbility = Util.null2String(jsonObject_language.getString("languageAbility"));
if("很好".equals(languageAbility)){
languageAbility = "0";
}else if("好".equals(languageAbility)){
languageAbility = "1";
}else if("一般".equals(languageAbility)){
languageAbility = "2";
}else if("较差".equals(languageAbility)){
languageAbility = "3";
}
String updateSql_dt6 = "UPDATE uf_ygjlxxb_dt6 SET wyyz='"+ languages +"',yynl='"+ languageAbility +"' where mainid="+billid;
//更新 明细6
rst.executeUpdate(updateSql_dt6);
}
bb.writeLog("明细7");
//明细7
if ( interviewFlag ) {
for(int j=0;j<array_interviewEvaluation.size();j++) {
JSONObject jsonObject_interviewEvaluation = array_interviewEvaluation.getJSONObject(j);
String round = jsonObject_interviewEvaluation.getString("round");//面试轮次
bb.writeLog("round: "+round);
String interviewType = jsonObject_interviewEvaluation.getString("interviewType");
bb.writeLog("interviewType: "+interviewType);
String interviewer = jsonObject_interviewEvaluation.getString("interviewer");
bb.writeLog("interviewer: "+interviewer);
JSONArray array_interviewer = JSONArray.parseArray(interviewer);
for(int k=0;k<array_interviewer.size();k++) {
JSONObject jsonObject_interview = array_interviewer.getJSONObject(k);
String isForCc = jsonObject_interview.getString("isForCc");
//加校验
String summarySheetOfInterview = jsonObject_interview.getString("summarySheetOfInterview");
String pingjia = jsonObject_interview.getString("pingjia");
String interviewEmail = jsonObject_interview.getString("interviewEmail");
if (StringUtils.isNotBlank(summarySheetOfInterview)
&& StringUtils.isNotBlank(pingjia)
&& StringUtils.isNotBlank(interviewEmail)) {
if (isForCc.equals("1")) {
String msg_id = getUserid(interviewEmail);
bb.writeLog("msg_id: " + msg_id);
JSONObject json_summarySheetOfInterview = JSONObject.parseObject(summarySheetOfInterview);
JSONObject json_pingjia = JSONObject.parseObject(pingjia);
if ("复试".equals(interviewType)) {
String fsmsg = msg_id;
String mszhpj = json_summarySheetOfInterview.getString("comprehensiveEvaluationOfInterview");//面试综合评价
String msztpj = json_summarySheetOfInterview.getString("mianshizongtipingjia");//面试总体评价
String jtpjnr = json_pingjia.getString("pingjia1");//具体评价内容1
String jtpjnr2 = json_pingjia.getString("pingjia2");//具体评价内容2
String jtpjnr3 = json_pingjia.getString("pingjia3");//具体评价内容3
String jtpjnr4 = json_pingjia.getString("pingjia4");//具体评价内容4
String gtbd = json_pingjia.getString("communicationAndExpression");//沟通表达
String zynl = json_pingjia.getString("professionalCompetence");//专业能力
String swlj = json_pingjia.getString("thinkingLogic");//思维逻辑
String zygh = json_pingjia.getString("careerPlanning");//职业规划
String updateSql_dt7 = "UPDATE uf_ygjlxxb_dt7 SET " +
"fsmsg='" + fsmsg + "', gtbd = '" + gtbd + "', jtpjnr='" + jtpjnr + "', zynl='" + zynl + "', jtpjnr2 = '" + jtpjnr2 + "'," +
"swlj = '" + swlj + "', jtpjnr3 = '" + jtpjnr3 + "',zygh = '" + zygh + "',jtpjnr4 = '" + jtpjnr4 + "',mszhpj = '" + mszhpj + "', " +
"msztpj = '" + msztpj + "', mslc = '" + round + "' " +
"where mainid=" + billid + " and mslc = '" + round + "' and fsmsg='" + fsmsg + "' ";
Integer numberDt7 = -1;
String checkDt7NumberSql = "select count(*) as number from uf_ygjlxxb_dt7 where mainid = ? and mslc = ? and fsmsg = ?";
bb.writeLog("checkDt7NumberSql: " + checkDt7NumberSql);
rscheck.executeQuery(checkDt7NumberSql, billid, round, fsmsg);
while (rscheck.next()) {
numberDt7 = Util.getIntValue(Util.null2String(rscheck.getString("number")));
}
bb.writeLog("numberDt7: " + numberDt7);
if (numberDt7 < 1) {
bb.writeLog("insertSql_dt7: " + insertSql_dt7);
rst.executeUpdate(insertSql_dt7, billid, fsmsg, gtbd, jtpjnr, zynl, jtpjnr2, swlj, jtpjnr3, zygh, jtpjnr4, mszhpj, msztpj, round);
} else {
// 写入 明细7
bb.writeLog("billid: " + billid);
bb.writeLog("updateSql_dt7: " + updateSql_dt7);
rst.executeUpdate(updateSql_dt7);
}
}
}
}
}
}
//明细8
for(int j=0;j<array_interviewEvaluation.size();j++) {
JSONObject jsonObject_interviewEvaluation = array_interviewEvaluation.getJSONObject(j);
String round = jsonObject_interviewEvaluation.getString("round");
String interviewType = jsonObject_interviewEvaluation.getString("interviewType");
String interviewer = jsonObject_interviewEvaluation.getString("interviewer");
JSONArray array_interviewer = JSONArray.parseArray(interviewer);
for(int k=0;k<array_interviewer.size();k++) {
JSONObject jsonObject_interview = array_interviewer.getJSONObject(k);
String isForCc = jsonObject_interview.getString("isForCc");
//加校验
String summarySheetOfInterview = jsonObject_interview.getString("summarySheetOfInterview");
String pingjia = jsonObject_interview.getString("pingjia");
String interviewEmail = jsonObject_interview.getString("interviewEmail");
if (StringUtils.isNotBlank(summarySheetOfInterview)
&& StringUtils.isNotBlank(pingjia)
&& StringUtils.isNotBlank(interviewEmail)) {
if (isForCc.equals("1")) {
String msg_id = getUserid(interviewEmail);
JSONObject json_summarySheetOfInterview = JSONObject.parseObject(summarySheetOfInterview);
JSONObject json_pingjia = JSONObject.parseObject(pingjia);
if ("初试".equals(interviewType)) {
String csmsg = msg_id;
String mszhpj = json_summarySheetOfInterview.getString("comprehensiveEvaluationOfInterview");//面试综合评价
String msztpj = json_summarySheetOfInterview.getString("mianshizongtipingjia");//面试总体评价
String jtpjnr = json_pingjia.getString("pingjia1");//具体评价内容1
String jtpjnr2 = json_pingjia.getString("pingjia2");//具体评价内容2
String jtpjnr3 = json_pingjia.getString("pingjia3");//具体评价内容3
String jtpjnr4 = json_pingjia.getString("pingjia4");//具体评价内容4
String gtbd = json_pingjia.getString("communicationAndExpression");//沟通表达
String zynl = json_pingjia.getString("professionalCompetence");//专业能力
String swlj = json_pingjia.getString("thinkingLogic");//思维逻辑
String zygh = json_pingjia.getString("careerPlanning");//职业规划
String updateSql_dt8 = "UPDATE uf_ygjlxxb_dt8 SET " +
"csmsg='" + csmsg + "', gtbd = '" + gtbd + "', jtpjnr='" + jtpjnr + "', zynl='" + zynl + "', jtpjnr2 = '" + jtpjnr2 + "'," +
"swlj = '" + swlj + "', jtpjnr3 = '" + jtpjnr3 + "',zygh = '" + zygh + "',jtpjnr4 = '" + jtpjnr4 + "',mszhpj = '" + mszhpj + "', " +
"msztpj = '" + msztpj + "', mslc = '" + round + "' " +
"where mainid=" + billid + " and mslc = '" + round + "' and csmsg='" + csmsg + "'";
Integer numberDt8 = -1;
String checkDt8NumberSql = "select count(*) as number from uf_ygjlxxb_dt8 where mainid = ? and mslc = ? and csmsg = ?";
bb.writeLog("checkDt8NumberSql: " + checkDt8NumberSql);
rscheck.executeQuery(checkDt8NumberSql, billid, round, csmsg);
while (rscheck.next()) {
numberDt8 = Util.getIntValue(Util.null2String(rscheck.getString("number")));
}
bb.writeLog("numberDt8: " + numberDt8);
if (numberDt8 < 1) {
rst.executeUpdate(insertSql_dt8, billid, csmsg, gtbd, jtpjnr, zynl, jtpjnr2, swlj, jtpjnr3, zygh, jtpjnr4, mszhpj, msztpj, round);
} else {
// 写入 明细8
bb.writeLog("==========================注意啦!!!==================");
bb.writeLog("billid: " + billid);
bb.writeLog("updateSql_dt8: " + updateSql_dt8);
rst.executeUpdate(updateSql_dt8);
bb.writeLog("==========================结束啦!!!==================");
}
}
}
}
}
}
}
}
}
}catch (Exception e){
e.printStackTrace();
bb.writeLog("SyResumeJob Exception: " + e);
}
bb.writeLog("========== end to syn resume info ==========");
}
public static String getUserid(String email){
String result = "";
RecordSet rs = new RecordSet();
rs.executeQuery("select * from hrmresource where email='"+ email +"'");
if(rs.next()){
result = Util.null2String(rs.getString("id"));
}
return result;
}
}

@ -0,0 +1,518 @@
package weaver.interfaces.mfkj.util;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.engine.kq.util.KQDurationCalculatorUtil;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import weaver.general.BaseBean;
import weaver.general.TimeUtil;
import weaver.general.Util;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
import java.util.*;
/**
* @Title http
* @Author wangchaofa
* @CreateDate 2023/8/7
* @Version 1.0
* @Description
*/
public class HttpUtils extends BaseBean {
public static void main(String[] args) throws IOException{
String corpCode = "";
String userName = "";
String password = "";
Map<String,String> headers = new HashMap<>();
String url = "http://api.wintalent.cn/wt/api/2.0/getToken";
String url2 = "http://api.wintalent.cn/wt/api/2.0/auth/resume/getUnEnterDuty";
String url3 = "http://api.wintalent.cn/wt/api/2.0/auth/login/interview";
String data1 = "{\"corpCode\":\"MATFRON\",\"userName\":\"MATFRON\",\"password\":\"5FC46CE8934E3BDAB6C1ADC45695F66D\"}";
System.out.println(data1);
Map<String,Object> map = getTokenInfo(url,headers,data1,null);
System.out.println(map);
String token = (String) map.get("token");
String expire = (String) map.get("expire");
System.out.println(token);
System.out.println(expire);
headers.put("Authorization", "Bearer "+token);
JSONObject json1 = new JSONObject();
json1.put("email","jeff.zhang@matfron.com");
String urll = getLoginUrl(url3,headers,json1.toString(),"UTF-8");
System.out.println(urll);
JSONObject json = new JSONObject();
json.put("rowSize","10");
json.put("cType","2,4,400");
json.put("vType","1");
String data = getResumeInfo(url2,headers,json.toString(),"UTF-8");
System.out.println(data);
JSONObject json_data = JSONObject.parseObject(data);
String resume = json_data.getString("resume");
JSONArray jsonArray = JSONArray.parseArray(resume);
System.out.println(jsonArray);
for(int i=0;i<jsonArray.size();i++){
JSONObject jsonObject = jsonArray.getJSONObject(i);
System.out.println(jsonObject);
String resumeContent = jsonObject.getString("resumeContent");
System.out.println(resumeContent);
JSONObject json_resumeContent = JSONObject.parseObject(resumeContent);
String applyId = jsonObject.getString("applyId");
System.out.println(applyId);
// 个人基本信息
String personalInformation = json_resumeContent.getString("personalInformation");
System.out.println(personalInformation);
JSONObject json_personalInformation = JSONObject.parseObject(personalInformation);
// 求职意向
String careerObjective = json_resumeContent.getString("careerObjective");
System.out.println(careerObjective);
JSONObject json_careerObjective = JSONObject.parseObject(careerObjective);
// 家庭关系
String familyRelationship = json_resumeContent.getString("familyRelationship");
System.out.println(familyRelationship);
JSONArray array_familyRelationship = JSONArray.parseArray(familyRelationship);
// 明细1
for(int j=0;j<array_familyRelationship.size();j++) {
JSONObject jsonObject_family = array_familyRelationship.getJSONObject(j);
System.out.println(jsonObject_family);
// 姓名
String name = Util.null2String(jsonObject_family.getString("name"));
// 关系
String relationship = Util.null2String(jsonObject_family.getString("relationship"));
// 联系方式
String contactNumber = Util.null2String(jsonObject_family.getString("contactNumber"));
// 职业
String jobTitle = Util.null2String(jsonObject_family.getString("jobTitle"));
// 地址
String address = Util.null2String(jsonObject_family.getString("address"));
// 是否紧急联系人 0 是 1 否
String emergencyContact = Util.null2String(jsonObject_family.getString("emergencyContact"));
}
// 教育经历
String educationBackground = json_resumeContent.getString("educationBackground");
System.out.println(educationBackground);
JSONArray array_educationBackground = JSONArray.parseArray(educationBackground);
// 明细2
for(int j=0;j<array_educationBackground.size();j++) {
JSONObject jsonObject_education = array_educationBackground.getJSONObject(j);
System.out.println(jsonObject_education);
//学校
String schoolName = Util.null2String(jsonObject_education.getString("schoolName"));
//专业
String major = Util.null2String(jsonObject_education.getString("major"));
//入学时间
String startDate = Util.null2String(jsonObject_education.getString("startDate"));
//毕业时间
String endDate = Util.null2String(jsonObject_education.getString("endDate"));
//学历 0 初中及以下 1 中专 2 高中 3 大专 4 本科 5 硕士及以上
String diploma = Util.null2String(jsonObject_education.getString("diploma"));
//学历类型 0 统招 1 自考 2 函授
String educationType = Util.null2String(jsonObject_education.getString("educationType"));
}
// 工作经历
String workingExperience = json_resumeContent.getString("workingExperience");
System.out.println(workingExperience);
JSONArray array_workingExperience = JSONArray.parseArray(workingExperience);
// 明细3
for(int j=0;j<array_workingExperience.size();j++) {
JSONObject jsonObject_working = array_workingExperience.getJSONObject(j);
System.out.println(jsonObject_working);
//工作单位
String companyName = Util.null2String(jsonObject_working.getString("companyName"));
//工作开始日期
String startDate = Util.null2String(jsonObject_working.getString("startDate"));
//工作结束日期
String endDate = Util.null2String(jsonObject_working.getString("endDate"));
//职位
String jobTitle = Util.null2String(jsonObject_working.getString("jobTitle"));
//最后月度薪资
String salaryMonthly = Util.null2String(jsonObject_working.getString("salaryMonthly"));
//离职原因
String reasonForQuit = Util.null2String(jsonObject_working.getString("reasonForQuit"));
}
// 姓名
String name = Util.null2String(json_personalInformation.getString("name"));
// 英文名
String englishName = Util.null2String(json_personalInformation.getString("englishName"));
// 国籍
String nation = Util.null2String(json_personalInformation.getString("nation"));
// 国籍编码
String nationCode = Util.null2String(json_personalInformation.getString("nationCode"));
// 性别
String gender = Util.null2String(json_personalInformation.getString("gender"));
// 邮箱地址
String email = Util.null2String(json_personalInformation.getString("email"));
// 手机号码
String mobilePhone = Util.null2String(json_personalInformation.getString("mobilePhone"));
// 现住址
String currentCity = Util.null2String(json_personalInformation.getString("currentCity"));
// 身份证地址
String hukou = Util.null2String(json_personalInformation.getString("hukou"));
// 婚姻情况
String maritalStatus = Util.null2String(json_personalInformation.getString("maritalStatus"));
// 出生日期
String dateOfBirth = Util.null2String(json_personalInformation.getString("dateOfBirth"));
// 应聘职位
String desiredPosition = Util.null2String(json_careerObjective.getString("desiredPosition"));
// 最快到岗时间
String onBoardTime = Util.null2String(json_careerObjective.getString("onBoardTime"));
}
// Calendar cal1 = Calendar.getInstance();
//
// long now_time = cal1.getTimeInMillis();
// System.out.println(now_time);
//
// long timestamp = Long.parseLong(expire)*1000;
//
// if(now_time > timestamp){
// System.out.println("========= 过期了哦 ====================");
// }else{
// System.out.println("========= 哈哈,还没呢 ====================");
// }
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// Date date = new Date(timestamp);
// String strDate = sdf.format(date);
// System.out.println(strDate);
// net.sf.json.JSONObject json = new net.sf.json.JSONObject();
// json.put("key","8ua9ws89wls8w7s8nlws");
// json.put("secret","okmlksjudiausdywe7plikjsqz");
// json.put("name","青发集团数智化项目年度开发建设计划表-段红梅-2023-08-04");
// json.put("introduction","您有一条OA流程待办消息青发集团数智化项目年度开发建设计划表-段红梅-2023-08-04请及时办理");
// json.put("source","fanweidblctx");
// json.put("reType",2);
// json.put("accType","6");
// json.put("linkeds","[15712766101]");
// json.put("jumpUrl","http://27.223.8.42:7555/interface/qfkg/CustomMessage.jsp?type=1&requestid=102085");
// json.put("appJumpUrl","http://27.223.8.42:7555/interface/qfkg/CustomMessage.jsp?type=2&requestid=102085");
// json.put("wxJumpUrl","");
// json.put("isHandler",1);
// json.put("businessId","102085");
//
// System.out.println(json.toString());
//
// JSONArray jsonArray = new JSONArray();
// JSONObject jsonObject = new JSONObject();
// jsonObject.put("externalOrgKey","1001");
// jsonObject.put("orgName","上海铭沣科技股份有限公司");
// jsonObject.put("order","1");
//
// jsonArray.add(jsonObject);
//
// JSONObject jsonObject1 = new JSONObject();
// jsonObject1.put("externalOrgKey","IT");
// jsonObject1.put("orgName","IT部");
// jsonObject1.put("externalParentOrgKey","1001");
// jsonObject1.put("order","2");
//
// jsonArray.add(jsonObject1);
//
// JSONObject jsonObject2 = new JSONObject();
// jsonObject2.put("externalOrgKey","SC(Semi)");
// jsonObject2.put("orgName","半导体销售中心");
// jsonObject2.put("externalParentOrgKey","1001");
// jsonObject2.put("order","3");
//
// jsonArray.add(jsonObject2);
//
// System.out.println(jsonArray.toString());
//
// String currentdate = TimeUtil.getCurrentDateString();
// String currenttime = TimeUtil.getOnlyCurrentTimeString();
// String currentdatetime = currentdate+" "+currenttime;
// int formmodeid = 72;
// String uuid = UUID.randomUUID().toString();
//
// System.out.println(currentdate);
// System.out.println(currenttime);
// System.out.println(uuid);
//
//
// String aa = "23.244";
// System.out.println(KQDurationCalculatorUtil.getDurationRound(aa));
}
/**
*
* @param url
* @param headers
* @param stringJson
* @param encode
* @return
*/
public static Map<String,Object> getTokenInfo(String url, Map<String,String> headers, String stringJson, String encode){
Map<String,Object> result = new HashMap<>();
if(encode == null){
encode = "utf-8";
}
String content = null;
CloseableHttpResponse httpResponse = null;
CloseableHttpClient closeableHttpClient = null;
try {
closeableHttpClient = HttpClients.createDefault();
HttpPost httpost = new HttpPost(url);
//设置header
httpost.setHeader("Content-type", "application/json");
if (headers != null && headers.size() > 0) {
for (Map.Entry<String, String> entry : headers.entrySet()) {
httpost.setHeader(entry.getKey(),entry.getValue());
}
}
//组织请求参数
StringEntity stringEntity = new StringEntity(stringJson, encode);
httpost.setEntity(stringEntity);
//响应信息
httpResponse = closeableHttpClient.execute(httpost);
HttpEntity entity = httpResponse.getEntity();
content = EntityUtils.toString(entity, encode);
if(content != null && !"".equals(content)){
JSONObject json = JSONObject.parseObject(content);
String code = json.getString("state");
if("0".equals(code)){
JSONObject json1 = JSONObject.parseObject(json.toJSONString());
JSONObject json2 = JSONObject.parseObject(json1.getString("data"));
String token = json2.getString("token");
String expire = json2.getString("expire");
result.put("token",token);
result.put("expire",expire);
}
}
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
httpResponse.close();
} catch (IOException e) {
e.printStackTrace();
}
}
try { //关闭连接、释放资源
closeableHttpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
/**
*
* @param url
* @param headers
* @param stringJson
* @param encode
* @return
*/
public static boolean pushPostJsoninfo(String url, Map<String,String> headers, String stringJson, String encode){
boolean result = false;
if(encode == null){
encode = "utf-8";
}
String content = null;
CloseableHttpResponse httpResponse = null;
CloseableHttpClient closeableHttpClient = null;
try {
closeableHttpClient = HttpClients.createDefault();
HttpPost httpost = new HttpPost(url);
//设置header
httpost.setHeader("Content-type", "application/json");
if (headers != null && headers.size() > 0) {
for (Map.Entry<String, String> entry : headers.entrySet()) {
httpost.setHeader(entry.getKey(),entry.getValue());
}
}
//组织请求参数
StringEntity stringEntity = new StringEntity(stringJson, encode);
httpost.setEntity(stringEntity);
//响应信息
httpResponse = closeableHttpClient.execute(httpost);
HttpEntity entity = httpResponse.getEntity();
content = EntityUtils.toString(entity, encode);
if(content != null && !"".equals(content)){
JSONObject json = JSONObject.parseObject(content);
String code = json.getString("state");
if("0".equals(code)){
result = true;
}
}
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
httpResponse.close();
} catch (IOException e) {
e.printStackTrace();
}
}
try { //关闭连接、释放资源
closeableHttpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
/**
*
* @param url
* @param headers
* @param stringJson
* @param encode
* @return
*/
public static String getResumeInfo(String url, Map<String,String> headers, String stringJson, String encode){
String result = "";
if(encode == null){
encode = "utf-8";
}
String content = null;
CloseableHttpResponse httpResponse = null;
CloseableHttpClient closeableHttpClient = null;
try {
closeableHttpClient = HttpClients.createDefault();
HttpPost httpost = new HttpPost(url);
//设置header
httpost.setHeader("Content-type", "application/json");
if (headers != null && headers.size() > 0) {
for (Map.Entry<String, String> entry : headers.entrySet()) {
httpost.setHeader(entry.getKey(),entry.getValue());
}
}
//组织请求参数
StringEntity stringEntity = new StringEntity(stringJson, encode);
httpost.setEntity(stringEntity);
//响应信息
httpResponse = closeableHttpClient.execute(httpost);
HttpEntity entity = httpResponse.getEntity();
content = EntityUtils.toString(entity, encode);
if(content != null && !"".equals(content)){
JSONObject json = JSONObject.parseObject(content);
String code = json.getString("state");
if("0".equals(code)){
result = json.getString("data");
}
}
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
httpResponse.close();
} catch (IOException e) {
e.printStackTrace();
}
}
try { //关闭连接、释放资源
closeableHttpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
/**
* url
* @param url
* @param headers
* @param stringJson
* @param encode
* @return
*/
public static String getLoginUrl(String url, Map<String,String> headers, String stringJson, String encode){
String result = "";
if(encode == null){
encode = "utf-8";
}
String content = null;
CloseableHttpResponse httpResponse = null;
CloseableHttpClient closeableHttpClient = null;
try {
closeableHttpClient = HttpClients.createDefault();
HttpPost httpost = new HttpPost(url);
//设置header
httpost.setHeader("Content-type", "application/json");
if (headers != null && headers.size() > 0) {
for (Map.Entry<String, String> entry : headers.entrySet()) {
httpost.setHeader(entry.getKey(),entry.getValue());
}
}
//组织请求参数
StringEntity stringEntity = new StringEntity(stringJson, encode);
httpost.setEntity(stringEntity);
//响应信息
httpResponse = closeableHttpClient.execute(httpost);
HttpEntity entity = httpResponse.getEntity();
content = EntityUtils.toString(entity, encode);
if(content != null && !"".equals(content)){
JSONObject json = JSONObject.parseObject(content);
String code = json.getString("state");
if("0".equals(code)){
String data = json.getString("data");
JSONObject json_data = JSONObject.parseObject(data);
result = json_data.getString("url");
}
}
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
httpResponse.close();
} catch (IOException e) {
e.printStackTrace();
}
}
try { //关闭连接、释放资源
closeableHttpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
}

@ -0,0 +1,144 @@
package weaver.interfaces.mingfeng.action;
import cn.hutool.core.date.DateUtil;
import org.apache.commons.lang.StringUtils;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.tools.HrmDateCheck;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.MainTableInfo;
import weaver.soa.workflow.request.Property;
import weaver.soa.workflow.request.RequestInfo;
import java.time.LocalDate;
import java.time.Period;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;
import java.util.Date;
/**
*
*/
public class HrmInfosChangeAction implements Action {
@Override
public String execute(RequestInfo requestInfo) {
BaseBean basebean = new BaseBean();
RecordSet rs = new RecordSet();
try {
String actualWorkYearField = basebean.getPropValue("syn_othersys_mfkj","ActualWorkYear");//实际工龄
String actualWorkStartDateField =basebean.getPropValue("syn_othersys_mfkj","ActualWorkStartDate");//实际参加工作时间
Integer changeType = -1;
Integer resourceId = -1;
String[] workflowFieldsName = {"xghjtzz","xghhyzk","sjgl","xghxl","xghzzmm","xghgzkh"};
String[] hrmFieldsName = {"residentplace","maritalstatus",actualWorkYearField,"educationlevel","policy","accountid1"};
MainTableInfo mainTableInfo = requestInfo.getMainTableInfo();
Property[] properties = mainTableInfo.getProperty();
for ( Property property : properties ) {
if ( "xgxx".equals(property.getName())) {
changeType = Util.getIntValue(Util.null2String(property.getValue()));
basebean.writeLog("xgxx: ", changeType);
}
if ( "sqr".equals(property.getName())) {
resourceId = Util.getIntValue(Util.null2String(property.getValue()));
basebean.writeLog("resourceId: ", resourceId);
}
}
if ( changeType >-1 && changeType < 6 && resourceId > -1 ) {
String workflowFieldName = workflowFieldsName[changeType];
basebean.writeLog("workflowFieldName: ", workflowFieldName);
String workflowFieldValue = "";
for ( Property property : properties ) {
if ( workflowFieldName.equals(property.getName())) {
workflowFieldValue = Util.null2String(property.getValue());
basebean.writeLog("workflowFieldValue: ", workflowFieldValue);
}
}
if ( StringUtils.isNotBlank(workflowFieldValue)) {
String hrmFieldName = hrmFieldsName[changeType];
basebean.writeLog("hrmFieldName: ", hrmFieldName);
if ( StringUtils.isNotBlank(hrmFieldName)) {
if ( actualWorkYearField.equals(hrmFieldName)) {//实际工龄
basebean.writeLog("hrmFieldName is actualWorkYearField ");
//根据实际工龄,计算出实际参加工作日期
String actualWorkYear = workflowFieldValue;
basebean.writeLog("actualWorkYear: " + actualWorkYear);
String nowDate = DateUtil.format(new Date(),"yyyy-MM-dd");
basebean.writeLog("nowDate: " + nowDate);
//计算出实际天数
Double actualWorkYearDou = Double.parseDouble(workflowFieldValue);
long daysNumber = Math.round(actualWorkYearDou * 365.0);
Integer daysInt = Integer.parseInt(String.valueOf(-daysNumber));
//根据实际工作天数求出实际开始工作日期
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(Calendar.DAY_OF_MONTH, daysInt);
String startDateStr = DateUtil.format(cal.getTime(),"yyyy-MM-dd");
basebean.writeLog("startDateStr: " + startDateStr);
//确认该人员是否已经存在scopeID=3 and scope = 'HrmCustomFieldByInfoType' 的数据
boolean isExist =false;
String checkSql = "select count(*) as number from cus_fielddata where id = ? and scopeid = 3 and scope = 'HrmCustomFieldByInfoType'";
basebean.writeLog("checkSql: " + checkSql);
rs.executeQuery(checkSql,resourceId);
while (rs.next()) {
int number = Util.getIntValue(Util.null2String(rs.getString("number")));
if ( number >= 1) {
isExist = true;
}
}
basebean.writeLog("isExist: " + isExist);
if (isExist) {
String syncSql = "update cus_fielddata set " + actualWorkStartDateField + " =?, "+actualWorkYearField+" = ? where id = ? and scopeid = 3 and scope = 'HrmCustomFieldByInfoType'";
basebean.writeLog("syncSql: " + syncSql);
basebean.writeLog("resourceId: " + resourceId);
basebean.writeLog("workflowFieldValue: " + workflowFieldValue);
rs.executeUpdate(syncSql,startDateStr,workflowFieldValue,resourceId);
} else {
String addSql = " insert into cus_fielddata (id,scopeid,scope,"+actualWorkStartDateField+","+actualWorkYearField+") values (?,?,?,?,?)";
basebean.writeLog("syncSql: " + addSql);
basebean.writeLog("resourceId: " + resourceId);
basebean.writeLog("workflowFieldValue: " + workflowFieldValue);
rs.executeUpdate(addSql,resourceId,3,"HrmCustomFieldByInfoType",startDateStr,workflowFieldValue);
}
} else {
String changeValueSql = "update hrmresource set "+hrmFieldName+" = ? where id = ?";
basebean.writeLog("changeValueSql: ", changeValueSql);
rs.executeUpdate(changeValueSql,workflowFieldValue,resourceId);
}
}
}
}
} catch (Exception e) {
basebean.writeLog("HrmInfosChangeAction Exception: " + e);
return Action.SUCCESS;
}
return Action.SUCCESS;
}
}

@ -0,0 +1,103 @@
package weaver.interfaces.mingfeng.job;
import org.apache.commons.lang.StringUtils;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.interfaces.schedule.BaseCronJob;
import java.util.ArrayList;
import java.util.List;
public class ActualWorkYearJob extends BaseCronJob {
BaseBean basebean = new BaseBean();
@Override
public void execute() {
basebean.writeLog("----------ActualWorkYearJob Start----------");
RecordSet rs = new RecordSet();
//根据实际参加工作时间计算实际工龄
String actualWorkYearField = basebean.getPropValue("syn_othersys_mfkj","ActualWorkYear");//实际工龄
String actualWorkStartDateField =basebean.getPropValue("syn_othersys_mfkj","ActualWorkStartDate");//实际参加工作时间
List<String> resList = new ArrayList<String>();
String acqResSql = "select id from hrmresource";
rs.executeQuery(acqResSql);
while (rs.next()) {
String id = Util.null2String(rs.getString("id"));
if ( StringUtils.isNotBlank(id) ) {
resList.add(id);
}
}
if ( !resList.isEmpty()) {
for (String id : resList) {
calculateActualWorkYear( actualWorkStartDateField, actualWorkYearField, id, rs);
}
}
}
/**
*
*/
private void calculateActualWorkYear(String actualWorkStartDateField, String actualWorkYearField, String resourceId, RecordSet rs) {
String sql = "";
try{
if(Util.getIntValue(resourceId)<=0){
//无效的人员id
return;
}
String currentdate = DateUtil.getCurrentDate();
String actualWorkstartdate = "";
String status = "";
String dismissdate = "";
double actualWorkyear = 0;
sql = " select a.status ,b." + actualWorkStartDateField +" " +
"from HrmResource a " +
"left join cus_fielddata b " +
"on b.id = a.id and b.scopeid = 3 and scope = 'HrmCustomFieldByInfoType' " +
"where a.id = ?";
rs.executeQuery(sql,resourceId);
if(rs.next()){
actualWorkstartdate = Util.null2String(rs.getString(actualWorkStartDateField));
status = Util.null2String(rs.getString("status"));
}
if("5".equals(status)) {
sql = " SELECT MAX(changedate) as dismissdate FROM HrmStatusHistory WHERE resourceid= ? ";
rs.executeQuery(sql, resourceId);
if (rs.next()) {
dismissdate = rs.getString("dismissdate");
}
}
//离职人员只计算到离职日期
currentdate = dismissdate.length()>0?dismissdate:currentdate;
if( actualWorkstartdate.length()>0){
actualWorkstartdate = DateUtil.compDate(currentdate,actualWorkstartdate)>0?currentdate:actualWorkstartdate;
actualWorkyear = DateUtil.dayDiff(actualWorkstartdate,currentdate)/365.0;
}
actualWorkyear = Math.round(actualWorkyear * 100.0) / 100.0;
//更新工龄 司龄
sql = " UPDATE cus_fielddata SET " + actualWorkYearField + "=? where id = ? ";
rs.executeUpdate(sql,actualWorkyear,resourceId);
}catch (Exception e){
basebean.writeLog("ActualWorkYearJob calculateActualWorkYear Exception: " + e);
}
}
}

@ -0,0 +1,156 @@
package weaver.interfaces.mingfeng.job;
import cn.hutool.core.date.DateUtil;
import com.engine.kq.biz.KQFormatData;
import com.engine.kq.timer.KQQueue;
import com.engine.kq.timer.KQTaskBean;
import com.engine.kq.wfset.util.SplitActionUtil;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.apache.commons.lang.StringUtils;
import weaver.conn.RecordSet;
import weaver.formmode.setup.ModeRightInfo;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.interfaces.schedule.BaseCronJob;
import java.time.LocalDateTime;
import java.util.*;
public class SyncKqDatasJob extends BaseCronJob {
BaseBean basebean = new BaseBean();
@Override
public void execute() {
basebean.writeLog("---------------SyncKqDatasJob Start---------------");
RecordSet rs = new RecordSet();
RecordSet rsF = new RecordSet();
List<List> params = new ArrayList<>();
List<String> resIds = new ArrayList<>();
List<List> formParams = new ArrayList<>();
// 获取当前日期前一天的日期
LocalDateTime localDateTime = LocalDateTime.now().minusDays(1);
String yesterday = DateUtil.format(localDateTime,"yyyy-MM-dd");
basebean.writeLog("----yesterday: "+yesterday);
String acqKqDatasSql = "select 申请人, 日报日期, 开始时间, 结束时间, 日报类型, 创建日期 FROM ZDYVW_考勤打卡数据_销售日报 where 创建日期 = '" + yesterday + "'";
basebean.writeLog("----acqKqDatasSql: "+acqKqDatasSql);
String addFormDataSql = "insert into uf_reportsyncdata (resourceId, kqDate, startTime, endTime, reportType, " +
"formmodeid, modedatacreater, modedatacreatertype, modedatacreatedate, modedatacreatetime, MODEUUID) values (?,?,?,?,?,?,?,?,?,?,?)";
String reportSyncModeId = basebean.getPropValue("syn_othersys_mfkj", "reportSyncModeId");
Integer modedatacreater = 1;
Integer modedatacreatertype = 0;
String modedatacreatedate = DateUtil.format(new Date(), "yyyy-MM-dd");
String modedatacreatetime = DateUtil.format(new Date(), "HH:mm:ss");
rs.executeQuery(acqKqDatasSql);
while (rs.next()) {
String petitioner = Util.null2String(rs.getString("申请人"));
String paperDate = Util.null2String(rs.getString("日报日期"));
String startTime = Util.null2String(rs.getString("开始时间"));
String endTime = Util.null2String(rs.getString("结束时间"));
String reportType = Util.null2String(rs.getString("日报类型"));
String createDate = Util.null2String(rs.getString("创建日期"));
if ( StringUtils.isNotBlank(petitioner) && StringUtils.isNotBlank(paperDate) && StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime) ) {
resIds.add(petitioner + "|" + paperDate);
List<Object> paramIn = new ArrayList<>();
paramIn.add(petitioner);
paramIn.add("1");//内部人员
paramIn.add("1");//签到
paramIn.add(paperDate);//考勤日期
paramIn.add(startTime);//考勤时间 -- 签到
paramIn.add("1");//是否是有效考勤打卡 -- 1/有效
paramIn.add("OutDataSourceSyn");//考勤来源 -- OutDataSourceSyn外部考勤数据同步
paramIn.add("GMT+8");//多时区所在时区
paramIn.add(paperDate);//belongdate
params.add(paramIn);
List<Object> paramOut = new ArrayList<>();
paramOut.add(petitioner);
paramOut.add("1");//内部人员
paramOut.add("2");//签退
paramOut.add(paperDate);//考勤日期
paramOut.add(endTime);//考勤时间 -- 签退
paramOut.add("1");//是否是有效考勤打卡 -- 1/有效
paramOut.add("OutDataSourceSyn");//考勤来源 -- OutDataSourceSyn外部考勤数据同步
paramOut.add("GMT+8");//多时区所在时区
paramOut.add(paperDate);//belongdate
params.add(paramOut);
basebean.writeLog("---------------SyncKqDatasJob Start To insert formdata---------------");
//需求变更:将数据转存建模,考勤报表需要根据建模表中是否存在同步的数据判断日报转出差的字段是否计数
String uuid = UUID.randomUUID().toString();
boolean addFlag = rsF.executeUpdate(addFormDataSql, petitioner, paperDate, startTime, endTime, reportType,
reportSyncModeId, modedatacreater, modedatacreatertype, modedatacreatedate, modedatacreatetime, uuid );
if (addFlag) {
String billid = "-1";
String acqModeIdSql = "select id from uf_reportsyncdata where MODEUUID = ?";
rsF.executeQuery(acqModeIdSql, uuid);
while (rsF.next()) {
billid = Util.null2String(rsF.getString("id"));
}
modePerRecon(modedatacreater, reportSyncModeId, billid);
}
}
}
basebean.writeLog("----params: "+params);
basebean.writeLog("----resIds: "+resIds);
basebean.writeLog("---------------SyncKqDatasJob Start To InsertDatas---------------");
//插入考勤数据
String addDataSql = "insert into hrmschedulesign (userId,userType,signType,signDate,signTime,isInCom,signFrom,timeZone,belongdate)" +
" values (?,?,?,?,?,?,?,?,?)";
rs.executeBatchSql(addDataSql, params);
basebean.writeLog("---------------SyncKqDatasJob Start To KqFormat---------------");
//执行考勤格式化
Map<String, List<String>> overtimeMap = Maps.newHashMap();
KQFormatData kqFormatData = new KQFormatData();
for (String res:resIds) {
List<String> overtimeList = Lists.newArrayList();
String[] split = res.split("\\|");
String resid = split[0];
String kqdate = split[1];
overtimeList.add(kqdate);
overtimeMap.put(resid,overtimeList);
Map<String, Object> formatKqDataMap = kqFormatData.formatKqDate(resid, kqdate);
basebean.writeLog("formatKqDataResult------- resource: " + resid + " formatKqDataMap: " + formatKqDataMap );
}
basebean.writeLog("---------------SyncKqDatasJob Start To FormatOverTimeDatas---------------");
//处理加班生成
List<KQTaskBean> tasks = new ArrayList<>();
for(Map.Entry<String, List<String>> mme: overtimeMap.entrySet()){
String resid = mme.getKey();
List<String> overList = mme.getValue();
for(String date : overList){
SplitActionUtil.pushOverTimeTasks(date,date,resid,tasks);
}
}
if(!tasks.isEmpty()){
KQQueue.writeTasks(tasks);
}
basebean.writeLog("---------------SyncKqDatasJob End---------------");
}
/**
*
* @param userId
* @param jobGroupDesModeId
* @param billid
*/
public void modePerRecon(Integer userId, String jobGroupDesModeId, String billid) {
ModeRightInfo ModeRightInfo = new ModeRightInfo();
ModeRightInfo.setNewRight(true);
ModeRightInfo.editModeDataShare( userId, Integer.parseInt(jobGroupDesModeId), Integer.parseInt(billid));
}
}
Loading…
Cancel
Save