|
|
|
@ -26,6 +26,7 @@ import weaver.systeminfo.SystemEnv;
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.time.temporal.TemporalAdjusters;
|
|
|
|
@ -346,6 +347,14 @@ public class ExportExcelCmd extends AbstractCommonCommand<Map<String, Object>> {
|
|
|
|
|
bb.writeLog("laborCompaniesMap: " + laborCompaniesMap);
|
|
|
|
|
/*考勤二开--劳务公司end*/
|
|
|
|
|
|
|
|
|
|
//考勤二开--请假时长
|
|
|
|
|
Map<String, Object> leaveInfos = getLeaveInfos(fromDate, toDate);
|
|
|
|
|
|
|
|
|
|
/*考勤二开--入离职时间start*/
|
|
|
|
|
Map<String, Map<String, String>> employAndResignDates = getAllEmployAndResignDateById();
|
|
|
|
|
/*考勤二开--入离职时间end*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rs.execute(sql);
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
data = new ArrayList<>();
|
|
|
|
@ -574,7 +583,60 @@ public class ExportExcelCmd extends AbstractCommonCommand<Map<String, Object>> {
|
|
|
|
|
}
|
|
|
|
|
data.add(fieldValue);
|
|
|
|
|
continue;
|
|
|
|
|
}else if(fieldName.equals("thisRemOt")){//当月加班剩余
|
|
|
|
|
} else if("absenceDuration".equals(fieldName)){//考勤二开--缺勤工时
|
|
|
|
|
//缺勤工时 = 请假+公休+入离职工时
|
|
|
|
|
bb.writeLog("absenceDuration start ");
|
|
|
|
|
//请假
|
|
|
|
|
double leaveMins = Math.max(Util.getDoubleValue(Util.null2String(leaveInfos.get(id))), 0.00);
|
|
|
|
|
bb.writeLog("absenceDuration leaveMins: " + leaveMins);
|
|
|
|
|
BigDecimal leaveHours = new BigDecimal(leaveMins).divide(new BigDecimal(60), 2, RoundingMode.HALF_UP);
|
|
|
|
|
|
|
|
|
|
//公休
|
|
|
|
|
int hodHours = Math.max(Util.getIntValue(Util.null2String(flowData.get("HoliDurationData|" + id))),0) * 8;
|
|
|
|
|
bb.writeLog("absenceDuration hodHours: " + hodHours);
|
|
|
|
|
|
|
|
|
|
//入离职工时
|
|
|
|
|
int absenceDays = 0;
|
|
|
|
|
absenceDays = getStartOrEndDays(id, fromDate, toDate, typeselect, employAndResignDates);
|
|
|
|
|
bb.writeLog("absenceDuration absenceDays: " + absenceDays);
|
|
|
|
|
|
|
|
|
|
fieldValue = new BigDecimal(hodHours).add(new BigDecimal(absenceDays).multiply(new BigDecimal(8))).add(leaveHours)
|
|
|
|
|
.setScale(2, RoundingMode.HALF_UP).toString();
|
|
|
|
|
bb.writeLog("absenceDuration fieldValue: " + fieldValue);
|
|
|
|
|
|
|
|
|
|
data.add(fieldValue);
|
|
|
|
|
continue;
|
|
|
|
|
} else if ("startOrEndDays".equals(fieldName)) {//考勤二开--入离职工时
|
|
|
|
|
int absenceDays = 0;
|
|
|
|
|
absenceDays = getStartOrEndDays(id, fromDate, toDate, typeselect, employAndResignDates);
|
|
|
|
|
fieldValue = String.valueOf(absenceDays);
|
|
|
|
|
|
|
|
|
|
data.add(fieldValue);
|
|
|
|
|
continue;
|
|
|
|
|
} else if ("workmins".equals(fieldName)) {//考勤二开--应出勤时长
|
|
|
|
|
//入离职工时
|
|
|
|
|
int absenceDays = 0;
|
|
|
|
|
absenceDays = getStartOrEndDays(id, fromDate, toDate, typeselect, employAndResignDates);
|
|
|
|
|
bb.writeLog("workMins absenceDays: " + absenceDays);
|
|
|
|
|
|
|
|
|
|
fieldValue = new BigDecimal(Math.max(Util.getDoubleValue(Util.null2String(rs.getString("workMins"))),0.00)).add(new BigDecimal(absenceDays).multiply(new BigDecimal(480))).divide(new BigDecimal(60), 2, RoundingMode.HALF_UP).toString();
|
|
|
|
|
bb.writeLog("workMins fieldValue: " + fieldValue);
|
|
|
|
|
|
|
|
|
|
data.add(fieldValue);
|
|
|
|
|
continue;
|
|
|
|
|
} else if ("workdays".equals(fieldName)) {//考勤二开--应出勤天数
|
|
|
|
|
|
|
|
|
|
//入离职工时
|
|
|
|
|
int absenceDays = 0;
|
|
|
|
|
absenceDays = getStartOrEndDays(id, fromDate, toDate, typeselect, employAndResignDates);
|
|
|
|
|
bb.writeLog("workdays absenceDays: " + absenceDays);
|
|
|
|
|
|
|
|
|
|
fieldValue = new BigDecimal(Math.max(Util.getDoubleValue(Util.null2String(rs.getString("workdays"))),0.00)).add(new BigDecimal(absenceDays)).setScale(2, RoundingMode.HALF_UP).toString();
|
|
|
|
|
bb.writeLog("workdays fieldValue: " + fieldValue);
|
|
|
|
|
|
|
|
|
|
data.add(fieldValue);
|
|
|
|
|
continue;
|
|
|
|
|
} else if(fieldName.equals("thisRemOt")){//当月加班剩余
|
|
|
|
|
if ("3".equals(typeselect) || "7".equals(typeselect)) {
|
|
|
|
|
Map<String, Object> allTiaoxius = getAllTiaoxius(id, fromDate, toDate);
|
|
|
|
|
|
|
|
|
@ -1105,6 +1167,190 @@ public class ExportExcelCmd extends AbstractCommonCommand<Map<String, Object>> {
|
|
|
|
|
result.put("lastDay", lastDayOfLastMonth.format(formatter));
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取请假时长
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Map<String, Object> getLeaveInfos(String startDate, String endDate){
|
|
|
|
|
|
|
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
String acqLeaveSql = "select resourceid, sum(d_mins) as mins from kq_flow_split_leave " +
|
|
|
|
|
"where belongdate >='"+startDate+"' and belongdate <='"+endDate+"' " +
|
|
|
|
|
"group by resourceid " +
|
|
|
|
|
"order by resourceid ";
|
|
|
|
|
bb.writeLog("getLeaveInfos acqLeaveSql: " + acqLeaveSql);
|
|
|
|
|
rs.executeQuery(acqLeaveSql);
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
String resourceid = Util.null2String(rs.getString("resourceid"));
|
|
|
|
|
String mins = Util.null2String(rs.getString("mins"));
|
|
|
|
|
result.put(resourceid, mins);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String acqLeaveBackSql = "select resourceid, sum(d_mins) as mins from kq_flow_split_leaveback " +
|
|
|
|
|
"where belongdate >='"+startDate+"' and belongdate <='"+endDate+"' " +
|
|
|
|
|
"group by resourceid " +
|
|
|
|
|
"order by resourceid ";
|
|
|
|
|
bb.writeLog("getLeaveInfos acqLeaveBackSql: " + acqLeaveBackSql);
|
|
|
|
|
rs.executeQuery(acqLeaveBackSql);
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
String resourceid = Util.null2String(rs.getString("resourceid"));
|
|
|
|
|
int mins = Math.max(Util.getIntValue(Util.null2String(rs.getString("mins"))), 0);
|
|
|
|
|
if (mins > 0) {
|
|
|
|
|
int temp = Math.max(Util.getIntValue(Util.null2String(result.get(resourceid))), 0);
|
|
|
|
|
int remins = Math.max(temp - mins, 0);
|
|
|
|
|
result.put(resourceid, remins);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bb.writeLog("getLeaveInfos result: " + result);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 获取入离职工时
|
|
|
|
|
* @param resourceId
|
|
|
|
|
* @param startDate
|
|
|
|
|
* @param endDate
|
|
|
|
|
* @param groupDate
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public int getAbsenceDays(String resourceId, String startDate, String endDate, String groupDate){
|
|
|
|
|
int days = 0;
|
|
|
|
|
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
|
|
|
|
|
LocalDate startDateL = LocalDate.parse(startDate, formatter);
|
|
|
|
|
LocalDate endDateL = LocalDate.parse(endDate, formatter);
|
|
|
|
|
|
|
|
|
|
List<String> dates = new ArrayList<>();
|
|
|
|
|
LocalDate currentDate = startDateL;
|
|
|
|
|
|
|
|
|
|
while (!currentDate.isAfter(endDateL)) {
|
|
|
|
|
dates.add("'"+currentDate.format(formatter)+"'");
|
|
|
|
|
currentDate = currentDate.plusDays(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String selDates = String.join(",", dates);
|
|
|
|
|
int size = dates.size();
|
|
|
|
|
|
|
|
|
|
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
|
|
|
|
String groupid = Util.null2String(kqGroupMemberComInfo.getKQGroupId(resourceId, groupDate));
|
|
|
|
|
String acqNumberSql = "select count(*) as number from KQ_HolidaySet where groupid = " + groupid +" and changeType in (1,3) " +
|
|
|
|
|
"and holidayDate in ("+selDates+")";
|
|
|
|
|
bb.writeLog("acqNumberSql: " + acqNumberSql);
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
rs.executeQuery(acqNumberSql);
|
|
|
|
|
int number = 0;
|
|
|
|
|
while (rs.next()) {
|
|
|
|
|
number = Math.max(Util.getIntValue(Util.null2String(rs.getString("number"))), 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
days = size - number;
|
|
|
|
|
|
|
|
|
|
return days;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 入离职工时
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public int getStartOrEndDays(String id, String fromDate, String toDate, String typeselect, Map<String, Map<String, String>> employAndResignDates){
|
|
|
|
|
int absenceDays = 0;
|
|
|
|
|
if ("3".equals(typeselect) || "7".equals(typeselect)) {
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
bb.writeLog("getStartOrEndDays employAndResignDates: " + JSONObject.toJSONString(employAndResignDates));
|
|
|
|
|
|
|
|
|
|
Map<String, String> tempMap = employAndResignDates.get(id);
|
|
|
|
|
String companystartdate = Util.null2String(tempMap.get("companystartdate"));
|
|
|
|
|
String resignDate = Util.null2String(tempMap.get("resignDate"));
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(companystartdate) && StringUtils.isBlank(resignDate)) {
|
|
|
|
|
String substring1 = companystartdate.substring(0, 7);
|
|
|
|
|
String substring2 = fromDate.substring(0, 7);
|
|
|
|
|
if (substring1.equals(substring2)) {
|
|
|
|
|
LocalDate companystartdateL = LocalDate.parse(companystartdate, formatter);
|
|
|
|
|
LocalDate localDate = companystartdateL.minusDays(1);
|
|
|
|
|
companystartdate = localDate.format(formatter);
|
|
|
|
|
|
|
|
|
|
absenceDays = getAbsenceDays(id, fromDate, companystartdate, toDate);
|
|
|
|
|
}
|
|
|
|
|
} else if (StringUtils.isBlank(companystartdate) && StringUtils.isNotBlank(resignDate)) {
|
|
|
|
|
String substring1 = resignDate.substring(0, 7);
|
|
|
|
|
String substring2 = toDate.substring(0, 7);
|
|
|
|
|
if (substring1.equals(substring2)) {
|
|
|
|
|
|
|
|
|
|
LocalDate resignDateL = LocalDate.parse(resignDate, formatter);
|
|
|
|
|
LocalDate localDate = resignDateL.plusDays(1);
|
|
|
|
|
resignDate = localDate.format(formatter);
|
|
|
|
|
|
|
|
|
|
absenceDays = getAbsenceDays(id, resignDate, toDate, fromDate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if (StringUtils.isNotBlank(companystartdate) && StringUtils.isNotBlank(resignDate)) {
|
|
|
|
|
String substring1 = companystartdate.substring(0, 7);
|
|
|
|
|
String substring2 = resignDate.substring(0, 7);
|
|
|
|
|
String substring3 = fromDate.substring(0, 7);
|
|
|
|
|
String substring4 = toDate.substring(0, 7);
|
|
|
|
|
if ( substring1.equals(substring2) && substring2.equals(substring3)
|
|
|
|
|
&& substring3.equals(substring4) ) {//考勤月入职且离职
|
|
|
|
|
LocalDate resignDateL = LocalDate.parse(resignDate, formatter);
|
|
|
|
|
LocalDate localDate = resignDateL.plusDays(1);
|
|
|
|
|
resignDate = localDate.format(formatter);
|
|
|
|
|
|
|
|
|
|
LocalDate companystartdateL = LocalDate.parse(companystartdate, formatter);
|
|
|
|
|
LocalDate localDate1 = companystartdateL.minusDays(1);
|
|
|
|
|
companystartdate = localDate1.format(formatter);
|
|
|
|
|
|
|
|
|
|
int temp1 = getAbsenceDays(id, fromDate, companystartdate, toDate);
|
|
|
|
|
int temp2 = getAbsenceDays(id, resignDate, toDate, fromDate);
|
|
|
|
|
absenceDays = temp1 + temp2;
|
|
|
|
|
} else if (substring1.equals(substring3) && !substring2.equals(substring3)) {//考勤月入职,非考勤月离职
|
|
|
|
|
LocalDate companystartdateL = LocalDate.parse(companystartdate, formatter);
|
|
|
|
|
LocalDate localDate = companystartdateL.minusDays(1);
|
|
|
|
|
companystartdate = localDate.format(formatter);
|
|
|
|
|
|
|
|
|
|
absenceDays = getAbsenceDays(id, fromDate, companystartdate, toDate);
|
|
|
|
|
} else if ( !substring1.equals(substring3) && substring2.equals(substring3)){//非考勤月入职,考勤月离职
|
|
|
|
|
LocalDate resignDateL = LocalDate.parse(resignDate, formatter);
|
|
|
|
|
LocalDate localDate = resignDateL.plusDays(1);
|
|
|
|
|
resignDate = localDate.format(formatter);
|
|
|
|
|
|
|
|
|
|
absenceDays = getAbsenceDays(id, resignDate, toDate, fromDate);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return absenceDays;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*获取人员入离职时间*/
|
|
|
|
|
private Map<String,Map<String,String>> getAllEmployAndResignDateById(){
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
Map<String,Map<String,String>> result = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
String companystartdate = "";//入职时间
|
|
|
|
|
String id = "";//人员
|
|
|
|
|
String created = "";//创建日期
|
|
|
|
|
String field30 = "";//离职时间
|
|
|
|
|
String sql = "select a.id, b.companystartdate,b.created,a.field30 from cus_fielddata a left join hrmresource b on" +
|
|
|
|
|
" a.id = b.id where a.scope='HrmCustomFieldByInfoType' and a.scopeid= 3 ";
|
|
|
|
|
rs.executeQuery(sql);
|
|
|
|
|
while (rs.next()){
|
|
|
|
|
id = Util.null2String(rs.getString("id"));
|
|
|
|
|
companystartdate = Util.null2String(rs.getString("companystartdate"));
|
|
|
|
|
created = Util.null2String(rs.getString("created"));
|
|
|
|
|
field30 = Util.null2String(rs.getString("field30"));
|
|
|
|
|
Map<String,String> map = new HashMap<>();
|
|
|
|
|
companystartdate = "".equals(companystartdate)?created:companystartdate;
|
|
|
|
|
map.put("companystartdate",companystartdate);
|
|
|
|
|
map.put("resignDate",field30);
|
|
|
|
|
result.put(id, map);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public BizLogContext getLogContext() {
|
|
|
|
|
return null;
|
|
|
|
|