Compare commits
50 Commits
Author | SHA1 | Date |
---|---|---|
|
a4cfa1d307 | 1 year ago |
|
fb8689160d | 1 year ago |
|
280bd6d7fe | 1 year ago |
|
8a94de0d05 | 1 year ago |
|
3727c0a5db | 1 year ago |
|
a5de914ee9 | 1 year ago |
|
2fa5df47ab | 1 year ago |
|
e445596114 | 1 year ago |
|
c4b72324cb | 1 year ago |
|
29e8b1151f | 1 year ago |
|
99f62328cf | 1 year ago |
|
36601a10fb | 1 year ago |
|
60ca792a56 | 1 year ago |
|
5015d873d6 | 1 year ago |
|
677e414802 | 1 year ago |
|
52e0d2f699 | 1 year ago |
|
04b390e056 | 1 year ago |
|
ac4574470e | 1 year ago |
|
7bef807a51 | 1 year ago |
|
33722523d3 | 1 year ago |
|
93a9d1f237 | 1 year ago |
|
9285635aee | 1 year ago |
|
623fc926d2 | 1 year ago |
|
e853bde2d5 | 1 year ago |
|
30ebc44bb8 | 1 year ago |
|
dd07f9838e | 1 year ago |
|
bf0c6a2b46 | 1 year ago |
|
39c8d460cb | 1 year ago |
|
08f0477879 | 1 year ago |
|
435ac5bbfa | 1 year ago |
|
43dad8ee44 | 1 year ago |
|
ccfbb426ac | 1 year ago |
|
15ab092f8b | 1 year ago |
|
2066506e17 | 1 year ago |
|
5337fba611 | 1 year ago |
|
60659fe90d | 1 year ago |
|
2a6faf096e | 1 year ago |
|
ae383628d5 | 1 year ago |
|
7cb5afa79d | 1 year ago |
|
98b6e1847f | 1 year ago |
|
7a0a3e889c | 1 year ago |
|
f581a7d9da | 1 year ago |
|
24212fc10b | 1 year ago |
|
c808c6d907 | 1 year ago |
|
d2cf61fbb7 | 1 year ago |
|
81ac13a7b2 | 1 year ago |
|
4faaec7639 | 1 year ago |
|
321a7878d2 | 1 year ago |
|
88991c41f1 | 1 year ago |
|
b1fc77100f | 1 year ago |
@ -0,0 +1,2 @@
|
||||
# 餐补信息记录模块ID
|
||||
cbxxjl_modeid=82
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,723 @@
|
||||
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.hostar.util.HostarUtil;
|
||||
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();
|
||||
|
||||
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
|
||||
String attendanceSerial = Util.null2String(jsonObj.get("attendanceSerial"));
|
||||
String fromDate = Util.null2String(jsonObj.get("fromDate"));
|
||||
String toDate = Util.null2String(jsonObj.get("toDate"));
|
||||
String typeselect = Util.null2String(jsonObj.get("typeselect"));
|
||||
if (typeselect.length() == 0) typeselect = "3";
|
||||
if (!typeselect.equals("") && !typeselect.equals("0") && !typeselect.equals("6")) {
|
||||
if (typeselect.equals("1")) {
|
||||
fromDate = TimeUtil.getCurrentDateString();
|
||||
toDate = TimeUtil.getCurrentDateString();
|
||||
} else {
|
||||
fromDate = TimeUtil.getDateByOption(typeselect, "0");
|
||||
toDate = TimeUtil.getDateByOption(typeselect, "1");
|
||||
}
|
||||
}
|
||||
//人员状态
|
||||
String status = Util.null2String(jsonObj.get("status"));
|
||||
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
|
||||
String departmentId = Util.null2String(jsonObj.get("departmentId"));
|
||||
String resourceId = Util.null2String(jsonObj.get("resourceId"));
|
||||
String allLevel = Util.null2String(jsonObj.get("allLevel"));
|
||||
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));
|
||||
String viewScope = Util.null2String(jsonObj.get("viewScope"));
|
||||
List<String> showColumns = Util.splitString2List(Util.null2String(jsonObj.get("showColumns")), ",");
|
||||
showColumns.add("lastname");
|
||||
showColumns.removeIf(showColumn->showColumn.trim().equals(""));
|
||||
|
||||
List<String> tmpShowColumns = new ArrayList<>();
|
||||
for(String showColumn:showColumns){
|
||||
tmpShowColumns.add(showColumn);
|
||||
String cascadekey = "";
|
||||
if(showColumn.equals("beLate")){
|
||||
cascadekey = "beLateMins";
|
||||
}else if(showColumn.equals("leaveEearly")){
|
||||
cascadekey = "leaveEarlyMins";
|
||||
}else if(showColumn.equals("graveBeLate")){
|
||||
cascadekey = "graveBeLateMins";
|
||||
}else if(showColumn.equals("graveLeaveEarly")){
|
||||
cascadekey = "graveLeaveEarlyMins";
|
||||
}else if(showColumn.equals("absenteeism")){
|
||||
cascadekey = "absenteeismMins";
|
||||
}else if(showColumn.equals("overtime")){
|
||||
tmpShowColumns.add("overtime_4leave");
|
||||
tmpShowColumns.add("overtime_nonleave");
|
||||
tmpShowColumns.add("workingDayOvertime_nonleave");
|
||||
tmpShowColumns.add("workingDayOvertime_4leave");
|
||||
tmpShowColumns.add("restDayOvertime_nonleave");
|
||||
tmpShowColumns.add("restDayOvertime_4leave");
|
||||
tmpShowColumns.add("holidayOvertime_4leave");
|
||||
tmpShowColumns.add("holidayOvertime_nonleave");
|
||||
}
|
||||
if(cascadekey.length()>0){
|
||||
tmpShowColumns.add(cascadekey);
|
||||
}
|
||||
}
|
||||
showColumns = tmpShowColumns;
|
||||
|
||||
String rightSql = new KQReportBiz().getReportRight("1", "" + user.getUID(), "a");
|
||||
|
||||
LinkedHashMap<String, Object> workbook = new LinkedHashMap<>();
|
||||
List<Object> lsSheet = new ArrayList<>();
|
||||
Map<String, Object> sheet = null;
|
||||
List<Object> titleList = new ArrayList<>();
|
||||
Map<String, Object> title = null;
|
||||
List<List<Object>> dataList = new ArrayList<>();
|
||||
List<Object> data = null;
|
||||
List<Map<String, Object>> constraintList = null;
|
||||
|
||||
sheet = new HashMap<>();
|
||||
sheet.put("sheetName", SystemEnv.getHtmlLabelName(390351, user.getLanguage()));
|
||||
sheet.put("sheetTitle", SystemEnv.getHtmlLabelName(390351, user.getLanguage()));
|
||||
boolean isEnd = false;
|
||||
Calendar cal = DateUtil.getCalendar();
|
||||
|
||||
List<Map<String, Object>> leaveRules = kqLeaveRulesBiz.getAllLeaveRules();
|
||||
Map<String, Object> mapChildColumnInfo = null;
|
||||
List<Object> childColumns = null;
|
||||
KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo();
|
||||
while (kqReportFieldComInfo.next()) {
|
||||
if (Util.null2String(kqReportFieldComInfo.getParentid()).length() > 0) continue;
|
||||
if(kqReportFieldComInfo.getFieldname().equals("kqCalendar"))continue;
|
||||
if(KQReportFieldComInfo.cascadekey2fieldname.keySet().contains(kqReportFieldComInfo.getFieldname()))continue;
|
||||
if (!kqReportFieldComInfo.getReportType().equals("all") && !kqReportFieldComInfo.getReportType().equals("month"))
|
||||
continue;
|
||||
if (!showColumns.contains(kqReportFieldComInfo.getFieldname())&&!showColumns.contains(kqReportFieldComInfo.getParentid())) continue;
|
||||
if("leave".equalsIgnoreCase(kqReportFieldComInfo.getFieldname())&&leaveRules.size()==0){
|
||||
continue;
|
||||
}
|
||||
title = new HashMap<>();
|
||||
String unitType = KQReportBiz.getUnitType(kqReportFieldComInfo, user);
|
||||
if(unitType.length()>0){
|
||||
title.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage())+ "(" + unitType + ")");
|
||||
}else{
|
||||
title.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage()));
|
||||
}
|
||||
title.put("width", 30 * 256);
|
||||
this.lsFieldDataKey.add(kqReportFieldComInfo.getFieldname());
|
||||
mapChildColumnInfo = this.getChildColumnsInfo(kqReportFieldComInfo.getFieldname(), user);
|
||||
childColumns = (List<Object>) mapChildColumnInfo.get("childColumns");
|
||||
if (childColumns.size() > 0) {//跨列width取子列的width
|
||||
title.put("children", childColumns);
|
||||
title.put("colSpan", childColumns.size());
|
||||
} else {
|
||||
title.put("rowSpan", 3);
|
||||
}
|
||||
titleList.add(title);
|
||||
|
||||
titleList.addAll(this.getCascadeKeyColumnsInfo(kqReportFieldComInfo.getCascadekey(),user));
|
||||
}
|
||||
|
||||
String today = DateUtil.getCurrentDate();
|
||||
// if (DateUtil.compDate(today, toDate) > 0) {//结束如期不大于今天
|
||||
// toDate = today;
|
||||
// }
|
||||
|
||||
if(showColumns.contains("kqCalendar")) {
|
||||
childColumns = new ArrayList<>();
|
||||
for (String date = fromDate; !isEnd; ) {
|
||||
if (date.equals(toDate)) isEnd = true;
|
||||
title = new HashMap<>();
|
||||
title.put("title", UtilKQ.getWeekDayShort(DateUtil.getWeek(date)-1,user.getLanguage()) +"\r\n"+ DateUtil.geDayOfMonth(date));
|
||||
title.put("width", 30 * 256);
|
||||
childColumns.add(title);
|
||||
cal.setTime(DateUtil.parseToDate(date));
|
||||
date = DateUtil.getDate(cal.getTime(), 1);
|
||||
}
|
||||
|
||||
title = new HashMap();
|
||||
title.put("title", SystemEnv.getHtmlLabelName(386476, user.getLanguage()));
|
||||
if (childColumns.size() > 0) {//跨列width取子列的width
|
||||
title.put("children", childColumns);
|
||||
title.put("colSpan", childColumns.size());
|
||||
}
|
||||
titleList.add(title);
|
||||
}
|
||||
sheet.put("titleList", titleList);
|
||||
|
||||
String forgotBeginWorkCheck_field = " sum(b.forgotBeginWorkCheck) ";
|
||||
|
||||
if(rs.getDBType().equalsIgnoreCase("oracle")) {
|
||||
forgotBeginWorkCheck_field = " sum(nvl(b.forgotBeginWorkCheck,0)) ";
|
||||
}else if((rs.getDBType()).equalsIgnoreCase("mysql")){
|
||||
forgotBeginWorkCheck_field = " sum(ifnull(b.forgotBeginWorkCheck,0)) ";
|
||||
}else {
|
||||
forgotBeginWorkCheck_field = " sum(isnull(b.forgotBeginWorkCheck,0)) ";
|
||||
}
|
||||
|
||||
Map<String,Object> definedFieldInfo = new KQFormatBiz().getDefinedField();
|
||||
String definedFieldSum = Util.null2String(definedFieldInfo.get("definedFieldSum"));
|
||||
String backFields = " (select sum(zm.cccb) from uf_cbxxjlb zm where zm.xm = a.id and zm.rq >= '" + fromDate + "' and zm.rq <= '" + toDate + "') as mealAllowance," +
|
||||
" (select sum(zm.zdcb) from uf_cbxxjlb zm where zm.xm = a.id and zm.rq >= '" + fromDate + "' and zm.rq <= '" + toDate + "') as statAllowance," +
|
||||
" (select sum(zm.jmybcb) from uf_cbxxjlb zm where zm.xm = a.id and zm.rq >= '" + fromDate + "' and zm.rq <= '" + toDate + "') as nightAllowance," +
|
||||
" (select sum(zm.hrzdcb) from uf_cbxxjlb zm where zm.xm = a.id and zm.rq >= '" + fromDate + "' and zm.rq <= '" + toDate + "') as otherStatAllowance," +
|
||||
" (select sum(zm.ybbz) from uf_cbxxjlb zm where zm.xm = a.id and zm.rq >= '" + fromDate + "' and zm.rq <= '" + toDate + "') as nightShiftSubsidy," +
|
||||
" 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(FLOOR( b.attendanceMins / 30 ) * 30 ) 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,sum(b.zeropoint) as zeropoint "+(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");
|
||||
|
||||
|
||||
/*考勤二开--驻点餐补start*/
|
||||
HostarUtil hostarUtil = new HostarUtil();
|
||||
Map<String, Double> attendanceMap = new HashMap<>();
|
||||
String acqAttendanceSql = "select a.id, b.attendanceMins, b.kqdate from hrmresource a, kq_format_total b where a.id= b.resourceid and b.kqdate >='"+fromDate+"' and b.kqdate <='"+toDate+"' "+sqlWhere;
|
||||
bb.writeLog("acqAttendanceSql: " + acqAttendanceSql);
|
||||
rs.executeQuery(acqAttendanceSql);
|
||||
while (rs.next()) {
|
||||
double attendanceMins = Util.getDoubleValue(Util.null2String(rs.getString("attendanceMins")));
|
||||
String id = Util.null2String(rs.getString("id"));
|
||||
String kqdate = Util.null2String(rs.getString("kqdate"));
|
||||
if (attendanceMins >= 0.00) {
|
||||
attendanceMap.put(id + "|DailyStatAllowance" +"|" + kqdate, attendanceMins);
|
||||
}
|
||||
}
|
||||
bb.writeLog("attendanceMap: " + attendanceMap);
|
||||
/*考勤二开--驻点餐补end*/
|
||||
|
||||
|
||||
rs.execute(sql);
|
||||
while (rs.next()) {
|
||||
data = new ArrayList<>();
|
||||
String id = rs.getString("id");
|
||||
for (int fieldDataKeyIdx =0;fieldDataKeyIdx<lsFieldDataKey.size();fieldDataKeyIdx++) {
|
||||
String fieldName = lsFieldDataKey.get(fieldDataKeyIdx);
|
||||
String fieldid = KQReportFieldComInfo.field2Id.get(fieldName);
|
||||
String fieldValue = "";
|
||||
if (fieldName.equals("subcompany")) {
|
||||
String tmpSubcompanyId = Util.null2String(rs.getString("subcompanyid"));
|
||||
if (tmpSubcompanyId.length() == 0) {
|
||||
tmpSubcompanyId = Util.null2String(resourceComInfo.getSubCompanyID(id));
|
||||
}
|
||||
|
||||
fieldValue = "1".equals(isShowFullPath) ?
|
||||
SubCompanyComInfo.getSubcompanyRealPath(tmpSubcompanyId, "/", "0") :
|
||||
subCompanyComInfo.getSubCompanyname(tmpSubcompanyId);
|
||||
|
||||
// fieldValue = subCompanyComInfo.getSubCompanyname(tmpSubcompanyId);
|
||||
} else if (fieldName.equals("department")) {
|
||||
String tmpDepartmentId = Util.null2String(rs.getString("departmentid"));
|
||||
if (tmpDepartmentId.length() == 0) {
|
||||
tmpDepartmentId = Util.null2String(resourceComInfo.getDepartmentID(id));
|
||||
}
|
||||
|
||||
fieldValue = "1".equals(isShowFullPath) ?
|
||||
departmentComInfo.getDepartmentRealPath(tmpDepartmentId, "/", "0") :
|
||||
departmentComInfo.getDepartmentname(tmpDepartmentId);
|
||||
|
||||
// fieldValue = departmentComInfo.getDepartmentname(tmpDepartmentId);
|
||||
} else if (fieldName.equals("jobtitle")) {
|
||||
String tmpJobtitleId = Util.null2String(rs.getString("jobtitle"));
|
||||
if (tmpJobtitleId.length() == 0) {
|
||||
tmpJobtitleId = Util.null2String(resourceComInfo.getJobTitle(id));
|
||||
}
|
||||
fieldValue = jobTitlesComInfo.getJobTitlesname(tmpJobtitleId);
|
||||
} else if (fieldName.equals("attendanceSerial")) {
|
||||
List<String> serialIds = null;
|
||||
if (Util.null2String(jsonObj.get("attendanceSerial")).length() > 0) {
|
||||
serialIds = Util.splitString2List(Util.null2String(jsonObj.get("attendanceSerial")), ",");
|
||||
for(int i=0;serialIds!=null&&i<serialIds.size();i++){
|
||||
data.add(kqReportBiz.getSerialCount(id,fromDate,toDate,serialIds.get(i)));
|
||||
}
|
||||
}else{
|
||||
data.add("");
|
||||
}
|
||||
continue;
|
||||
} else if (fieldName.equals("leave")) {//请假
|
||||
List<Map<String, Object>> allLeaveRules = kqLeaveRulesBiz.getAllLeaveRules();
|
||||
Map<String, Object> leaveRule = null;
|
||||
for (int i = 0; allLeaveRules != null && i < allLeaveRules.size(); i++) {
|
||||
leaveRule = allLeaveRules.get(i);
|
||||
String flowType = Util.null2String("leaveType_" + leaveRule.get("id"));
|
||||
String leaveData = Util.null2String(flowData.get(id + "|" + flowType));
|
||||
String flowLeaveBackType = Util.null2String("leavebackType_" + leaveRule.get("id"));
|
||||
String leavebackData = Util.null2s(Util.null2String(flowData.get(id + "|" + flowLeaveBackType)), "0.0");
|
||||
String b_flowLeaveData = "";
|
||||
String flowLeaveData = "";
|
||||
try {
|
||||
//以防止出现精度问题
|
||||
if (leaveData.length() == 0) {
|
||||
leaveData = "0.0";
|
||||
}
|
||||
if (leavebackData.length() == 0) {
|
||||
leavebackData = "0.0";
|
||||
}
|
||||
BigDecimal b_leaveData = new BigDecimal(leaveData);
|
||||
BigDecimal b_leavebackData = new BigDecimal(leavebackData);
|
||||
b_flowLeaveData = b_leaveData.subtract(b_leavebackData).toString();
|
||||
if(Util.getDoubleValue(b_flowLeaveData, -1) < 0){
|
||||
b_flowLeaveData = "0.0";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
writeLog("GetKQReportCmd:leaveData" + leaveData + ":leavebackData:" + leavebackData + ":" + e);
|
||||
}
|
||||
|
||||
if (b_flowLeaveData.length() > 0) {
|
||||
flowLeaveData = KQDurationCalculatorUtil.getDurationRound(b_flowLeaveData);
|
||||
} else {
|
||||
flowLeaveData = KQDurationCalculatorUtil.getDurationRound(Util.null2String(Util.getDoubleValue(leaveData, 0.0) - Util.getDoubleValue(leavebackData, 0.0)));
|
||||
}
|
||||
data.add(flowLeaveData);
|
||||
}
|
||||
continue;
|
||||
}else if(fieldName.equals("overtime")){
|
||||
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|workingDayOvertime_nonleave")));
|
||||
data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("workingDayOvertime_nonleave"))));
|
||||
|
||||
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|restDayOvertime_nonleave")));
|
||||
data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("restDayOvertime_nonleave"))));
|
||||
|
||||
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|holidayOvertime_nonleave")));
|
||||
data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("holidayOvertime_nonleave"))));
|
||||
|
||||
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|workingDayOvertime_4leave")));
|
||||
data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("workingDayOvertime_4leave"))));
|
||||
|
||||
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|restDayOvertime_4leave")));
|
||||
data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("restDayOvertime_4leave"))));
|
||||
|
||||
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|holidayOvertime_4leave")));
|
||||
data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("holidayOvertime_4leave"))));
|
||||
|
||||
double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|workingDayOvertime_4leave")));
|
||||
workingDayOvertime_4leave = workingDayOvertime_4leave<0?0:workingDayOvertime_4leave;
|
||||
double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|restDayOvertime_4leave")));
|
||||
restDayOvertime_4leave = restDayOvertime_4leave<0?0:restDayOvertime_4leave;
|
||||
double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|holidayOvertime_4leave")));
|
||||
holidayOvertime_4leave = holidayOvertime_4leave<0?0:holidayOvertime_4leave;
|
||||
|
||||
double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|workingDayOvertime_nonleave")));
|
||||
workingDayOvertime_nonleave = workingDayOvertime_nonleave<0?0:workingDayOvertime_nonleave;
|
||||
double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|restDayOvertime_nonleave")));
|
||||
restDayOvertime_nonleave = restDayOvertime_nonleave<0?0:restDayOvertime_nonleave;
|
||||
double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|holidayOvertime_nonleave")));
|
||||
holidayOvertime_nonleave = holidayOvertime_nonleave<0?0:holidayOvertime_nonleave;
|
||||
fieldValue = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_4leave+restDayOvertime_4leave+holidayOvertime_4leave+
|
||||
workingDayOvertime_nonleave+restDayOvertime_nonleave+holidayOvertime_nonleave));
|
||||
data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("overtimeTotal"))));
|
||||
continue;
|
||||
}else if(fieldName.equals("businessLeave") || fieldName.equals("officialBusiness")){
|
||||
String businessLeaveData = Util.null2s(Util.null2String(flowData.get(id+"|"+fieldName)),"0.0");
|
||||
String backType = fieldName+"_back";
|
||||
String businessLeavebackData = Util.null2s(Util.null2String(flowData.get(id+"|"+backType)),"0.0");
|
||||
String businessLeave = "";
|
||||
try{
|
||||
//以防止出现精度问题
|
||||
if(businessLeaveData.length() == 0){
|
||||
businessLeaveData = "0.0";
|
||||
}
|
||||
if(businessLeavebackData.length() == 0){
|
||||
businessLeavebackData = "0.0";
|
||||
}
|
||||
BigDecimal b_businessLeaveData = new BigDecimal(businessLeaveData);
|
||||
BigDecimal b_businessLeavebackData = new BigDecimal(businessLeavebackData);
|
||||
businessLeave = b_businessLeaveData.subtract(b_businessLeavebackData).toString();
|
||||
if(Util.getDoubleValue(businessLeave, -1) < 0){
|
||||
businessLeave = "0.0";
|
||||
}
|
||||
}catch (Exception e){
|
||||
}
|
||||
fieldValue = KQDurationCalculatorUtil.getDurationRound(businessLeave);
|
||||
// } else if ("mealAllowance".equals(fieldName)) {//考勤二开--出差餐补
|
||||
//// bb.writeLog("mealAllowance");
|
||||
// Map<String, Object> tempMap = hostarUtil.parseMapForFilter(flowData, "DailyMealAllow|" + resourceId);
|
||||
//// bb.writeLog("tempMap: " + tempMap);
|
||||
//
|
||||
// if ( !tempMap.isEmpty()) {
|
||||
// int tempValue = 0;
|
||||
// for (String key: tempMap.keySet()) {
|
||||
// int intValue = Util.getIntValue(Util.null2String(tempMap.get(key)));
|
||||
// tempValue = tempValue + (Math.max(intValue, 0));
|
||||
// }
|
||||
// fieldValue = String.valueOf(tempValue);
|
||||
// }
|
||||
//// bb.writeLog("fieldValue: " + fieldValue);
|
||||
// data.add(fieldValue);
|
||||
// continue;
|
||||
// } else if ("statAllowance".equals(fieldName)) {//考勤二开--驻点餐补
|
||||
//// bb.writeLog("statAllowance");
|
||||
//// bb.writeLog("flowData: " + flowData);
|
||||
// params.put("statUser", id);
|
||||
// bb.writeLog("params: " + params );
|
||||
//
|
||||
// Map<String, Object> temp = kqReportBiz.getStatAllowanceData(params, user);
|
||||
// if (temp == null || temp.size() == 0) {
|
||||
// data.add( "0");
|
||||
// } else {
|
||||
// Map<String, Object> tempMap = hostarUtil.parseMapForFilter(temp, id + "|StatAllowance");
|
||||
//
|
||||
//// Map<String, Object> tempMap = hostarUtil.parseMapForFilter(flowData, id + "|DailyStatAllowance");
|
||||
//// bb.writeLog("tempMap: " + tempMap);
|
||||
// if ( !tempMap.isEmpty()) {
|
||||
// double tempValue = 0.00;
|
||||
// for (String key: tempMap.keySet()) {
|
||||
// double doubleValue = Util.getDoubleValue(Util.null2String(tempMap.get(key)));
|
||||
// tempValue = tempValue + (Math.max(doubleValue, 0.00));
|
||||
// }
|
||||
// fieldValue = String.valueOf(tempValue);
|
||||
// }
|
||||
//// bb.writeLog("fieldValue: " + fieldValue);
|
||||
// data.add( fieldValue);
|
||||
// }
|
||||
// continue;
|
||||
// } else if ("nightAllowance".equals(fieldName)) {//考勤二开--精密夜班餐补
|
||||
//// bb.writeLog("nightAllowance");
|
||||
// Map<String, Object> tempMap = hostarUtil.parseMapForFilter(flowData, id + "|DailyNightShiftAllowanceData");
|
||||
//// bb.writeLog("tempMap: " + tempMap);
|
||||
// if ( !tempMap.isEmpty()) {
|
||||
// double tempValue = 0.00;
|
||||
// for (String key: tempMap.keySet()) {
|
||||
// double doubleValue = Util.getDoubleValue(Util.null2String(tempMap.get(key)));
|
||||
// tempValue = tempValue + (Math.max(doubleValue, 0.00));
|
||||
// }
|
||||
// fieldValue = String.valueOf(tempValue);
|
||||
// }
|
||||
//// bb.writeLog("fieldValue: " + fieldValue);
|
||||
// data.add(fieldValue);
|
||||
// continue;
|
||||
// } else if ("nightShiftSubsidy".equals(fieldName)) {//考勤二开--夜班补助
|
||||
// params.put("subUserId", id);
|
||||
// bb.writeLog("params: " + params );
|
||||
//
|
||||
// Map<String, Object> temp = kqReportBiz.getDailyNightShiftSubsidyData(params, user);
|
||||
// if (temp == null || temp.size() == 0) {
|
||||
// data.add( "0");
|
||||
// } else {
|
||||
// Map<String, Object> tempMap = hostarUtil.parseMapForFilter(temp, id + "|DailyNightShiftSubsidyData");
|
||||
//
|
||||
// if ( !tempMap.isEmpty()) {
|
||||
// int tempValue = 0;
|
||||
// for (String key: tempMap.keySet()) {
|
||||
// int intValue = Util.getIntValue(Util.null2String(tempMap.get(key)));
|
||||
// tempValue = tempValue + (Math.max(intValue, 0));
|
||||
// }
|
||||
// fieldValue = String.valueOf(tempValue);
|
||||
// }
|
||||
// data.add( fieldValue);
|
||||
// }
|
||||
// continue;
|
||||
// } else if ("otherStatAllowance".equals(fieldName)) {//考勤二开--鸿仁驻点餐补
|
||||
//// bb.writeLog("otherStatAllowance");
|
||||
// Map<String, Object> tempMap = hostarUtil.parseMapForFilter(flowData, id + "|DailyOtherStatAllowance");
|
||||
//// bb.writeLog("tempMap: " + tempMap);
|
||||
// if ( !tempMap.isEmpty()) {
|
||||
// double tempValue = 0.00;
|
||||
// for (String key: tempMap.keySet()) {
|
||||
// double doubleValue = Util.getDoubleValue(Util.null2String(tempMap.get(key)));
|
||||
// tempValue = tempValue + (doubleValue < 0.00 ? 0.00 : doubleValue);
|
||||
// }
|
||||
// fieldValue = String.valueOf(tempValue);
|
||||
// }
|
||||
//// bb.writeLog("fieldValue: " + fieldValue);
|
||||
// data.add(fieldValue);
|
||||
// continue;
|
||||
} 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,167 @@
|
||||
package weaver.interfaces.hostar.action;
|
||||
|
||||
import com.engine.kq.biz.KQFormatBiz;
|
||||
import com.engine.kq.wfset.util.SplitActionUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.common.DateUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.Property;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class OutSignSyncAction implements Action {
|
||||
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
@Override
|
||||
public String execute(RequestInfo requestInfo) {
|
||||
bb.writeLog("OutSignSyncAction-start");
|
||||
String startDate = "";
|
||||
String endDate = "";
|
||||
String resourceid = "";
|
||||
String nbtxr = "";
|
||||
String sjjsrq = "";
|
||||
|
||||
try {
|
||||
|
||||
Property[] properties = requestInfo.getMainTableInfo().getProperty();
|
||||
for (Property property : properties) {
|
||||
if ("ksrq".equals(property.getName())) {
|
||||
startDate = Util.null2String(property.getValue());
|
||||
}
|
||||
if ("yjjsrq".equals(property.getName())) {
|
||||
endDate = Util.null2String(property.getValue());
|
||||
}
|
||||
if ("sjccr".equals(property.getName())) {
|
||||
resourceid = Util.null2String(property.getValue());
|
||||
}
|
||||
if ("nbtxr".equals(property.getName())) {
|
||||
nbtxr = Util.null2String(property.getValue());
|
||||
}
|
||||
if ("sjjsrq".equals(property.getName())) {
|
||||
sjjsrq = Util.null2String(property.getValue());
|
||||
}
|
||||
}
|
||||
// 如果实际结束日期不为空,则用实际结束日期
|
||||
if (StringUtils.isNotBlank(sjjsrq)) {
|
||||
endDate = sjjsrq;
|
||||
}
|
||||
bb.writeLog("start to handle data.");
|
||||
if (StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate) && StringUtils.isNotBlank(resourceid)) {
|
||||
// 内部同行人也要考虑
|
||||
if (StringUtils.isNotBlank(nbtxr)) {
|
||||
resourceid = resourceid + "," + nbtxr;
|
||||
}
|
||||
RecordSet rs = new RecordSet();
|
||||
List<String> infos = new ArrayList<>();
|
||||
String acqOutSignSql = "select a.id, c.signinfo " +
|
||||
"from mobile_sign a " +
|
||||
"left join uf_outsigntype c " +
|
||||
"on c.outsignid = a.id " +
|
||||
"where operate_date >= '" + startDate + "' and operate_date <= '" + endDate + "' and operater in (?) ";
|
||||
rs.executeQuery(acqOutSignSql, resourceid);
|
||||
while (rs.next()) {
|
||||
String signinfo = Util.null2String(rs.getString("signinfo"));
|
||||
infos.add(signinfo);
|
||||
}
|
||||
bb.writeLog("infos is:" + infos);
|
||||
for (String inf : infos) {
|
||||
if (StringUtils.isNotEmpty(inf)) {
|
||||
Map<String, Object> in = mapStringToMap(inf);
|
||||
String userId = Util.null2String(in.get("userId"));
|
||||
String userType = Util.null2String(in.get("userType"));
|
||||
String signType = Util.null2String(in.get("signType"));
|
||||
String signDate = Util.null2String(in.get("signDate"));
|
||||
String signTime = Util.null2String(in.get("signTime"));
|
||||
String clientAddress = Util.null2String(in.get("clientAddress"));
|
||||
String isInCom = Util.null2String(in.get("isInCom"));
|
||||
String timeZone = Util.null2String(in.get("timeZone"));
|
||||
String belongdate = Util.null2String(in.get("belongdate"));
|
||||
String signfrom = Util.null2String(in.get("signfrom"));
|
||||
String longitude = Util.null2String(in.get("longitude"));
|
||||
String latitude = Util.null2String(in.get("latitude"));
|
||||
String address = Util.null2String(in.get("address"));
|
||||
String deviceInfo = Util.null2String(in.get("deviceInfo"));
|
||||
String belongdateIsNull = Util.null2String(in.get("belongdateIsNull"));
|
||||
|
||||
String punchSql = "insert into HrmScheduleSign(userId,userType,signType,signDate,signTime,clientAddress,isInCom,timeZone,belongdate,signfrom,longitude,latitude,addr,deviceInfo,isdev) " +
|
||||
" values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
boolean isok = rs.executeUpdate(punchSql, resourceid, userType, signType, signDate, signTime, clientAddress, isInCom,
|
||||
timeZone, belongdate, signfrom, longitude, latitude, address, deviceInfo, "1");
|
||||
bb.writeLog("isok: " + isok);
|
||||
//同步更新考勤数据到考勤报表
|
||||
if ("true".equals(belongdateIsNull)) {
|
||||
//外勤签到没有归属日期,遇到跨天班次打卡可能归属前一天,需要格式化前一天考勤
|
||||
bb.writeLog("PunchOutButtonCmd:userId:" + userId + ":belongdate:" + DateUtil.getYesterday());
|
||||
new KQFormatBiz().formatDate("" + userId, DateUtil.getYesterday());
|
||||
}
|
||||
bb.writeLog("PunchOutButtonCmd:userId:" + userId + ":belongdate:" + (belongdate.length() == 0 ? DateUtil.getCurrentDate() : belongdate));
|
||||
if (belongdate.length() == 0) {
|
||||
//外勤签到没有归属日期,遇到跨天班次打卡可能归属前一天,需要格式化前一天考勤
|
||||
new KQFormatBiz().formatDate("" + userId, DateUtil.getYesterday());
|
||||
}
|
||||
new KQFormatBiz().formatDate("" + userId, (belongdate.length() == 0 ? DateUtil.getCurrentDate() : belongdate));
|
||||
//外勤签到转的考勤 处理加班规则
|
||||
SplitActionUtil.pushOverTimeTasksAll(belongdate, belongdate, "" + userId);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
bb.writeLog("OutSignSyncAction Exception: " + e.getMessage());
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
return Action.SUCCESS;
|
||||
}
|
||||
|
||||
public static Map<String, Object> mapStringToMap(String str) {
|
||||
str = str.substring(1, str.length() - 1);
|
||||
List<String> strs = splitString(str);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
for (String string : strs) {
|
||||
String[] splits = string.split("=");
|
||||
String key = splits[0];
|
||||
String value = "";
|
||||
if (splits.length > 1) {
|
||||
value = splits[1];
|
||||
}
|
||||
// 去掉头部空格
|
||||
String key1 = key.trim();
|
||||
String value1 = value.trim();
|
||||
map.put(key1, value1);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public static List<String> splitString(String input) {
|
||||
List<String> result = new ArrayList<>();
|
||||
int braceLevel = 0;
|
||||
int startIndex = 0;
|
||||
|
||||
for (int i = 0; i < input.length(); i++) {
|
||||
char ch = input.charAt(i);
|
||||
if (ch == '{') {
|
||||
braceLevel++;
|
||||
} else if (ch == '}') {
|
||||
braceLevel--;
|
||||
} else if (ch == ',' && braceLevel == 0) {
|
||||
result.add(input.substring(startIndex, i));
|
||||
startIndex = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (startIndex < input.length()) {
|
||||
result.add(input.substring(startIndex));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
package weaver.interfaces.hostar.job;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.engine.hostar.thread.HandleCBDataThread;
|
||||
import com.engine.hostar.util.HostarUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.ThreadPoolUtil;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Title ecology-9
|
||||
* @Company 泛微软件
|
||||
* @CreateDate 2024/3/12
|
||||
* @Description 更新餐补信息记录数据定时任务
|
||||
* @Author AdminZm
|
||||
*/
|
||||
public class UpdateCbxxjlDataJob extends BaseCronJob {
|
||||
|
||||
BaseBean baseBean = new BaseBean();
|
||||
|
||||
private String ryParam;
|
||||
|
||||
private String startDate;
|
||||
|
||||
private String endDate;
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
baseBean.writeLog("UpdateCbxxjlDataJob start, param is:" + ryParam + "、" + startDate + "、" + endDate);
|
||||
try {
|
||||
String today = DateUtil.format(new Date(), "yyyy-MM-dd");
|
||||
if (StringUtils.isEmpty(endDate)) {
|
||||
endDate = today;
|
||||
}
|
||||
if (StringUtils.isEmpty(startDate)) {
|
||||
startDate = today;
|
||||
}
|
||||
String date1 = String.valueOf(startDate);
|
||||
String date2 = String.valueOf(endDate);
|
||||
List<String> allDates = getAllDates(date1, date2);
|
||||
baseBean.writeLog("UpdateCbxxjlDataJob allDatas:" + allDates);
|
||||
RecordSet rs = new RecordSet();
|
||||
List<String> userIds = new ArrayList<>();
|
||||
if (StringUtils.isEmpty(ryParam) || StringUtils.equals(ryParam, "null")) {
|
||||
baseBean.writeLog("1111.");
|
||||
rs.executeQuery("select id from hrmresource");
|
||||
while (rs.next()) {
|
||||
userIds.add(rs.getString("id"));
|
||||
}
|
||||
} else {
|
||||
baseBean.writeLog("2222.");
|
||||
rs.executeQuery("select id from hrmresource where workcode = ?", ryParam);
|
||||
while (rs.next()) {
|
||||
userIds.add(rs.getString("id"));
|
||||
}
|
||||
}
|
||||
baseBean.writeLog("userIds:" + userIds);
|
||||
if ((CollectionUtils.isEmpty(userIds) && userIds.isEmpty()) || (CollectionUtils.isEmpty(allDates) && allDates.isEmpty())) {
|
||||
baseBean.writeLog("no user or date.");
|
||||
return;
|
||||
}
|
||||
ExecutorService executorService = ThreadPoolUtil.getThreadPool(null, null);
|
||||
for (String userId : userIds) {
|
||||
for (String kqDate : allDates) {
|
||||
executorService.execute(new HandleCBDataThread(userId, kqDate));
|
||||
}
|
||||
}
|
||||
if (executorService.isTerminated()) {
|
||||
executorService.shutdown();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
baseBean.writeLog("UpdateCbxxjlDataJob error:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getAllDates(String startDate, String endDate) {
|
||||
List<String> result = new ArrayList<>();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
LocalDate start = LocalDate.parse(startDate, formatter);
|
||||
LocalDate end = LocalDate.parse(endDate, formatter);
|
||||
while (!start.isAfter(end)) {
|
||||
result.add(start.format(formatter));
|
||||
start = start.plusDays(1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue