|
|
|
@ -24,10 +24,12 @@ import weaver.interfaces.sskj.comInfo.PropBean;
|
|
|
|
|
import weaver.systeminfo.SystemEnv;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.time.temporal.TemporalAdjusters;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
import static com.api.formmode.cache.ModeExpandPageComInfo.groupid;
|
|
|
|
@ -331,6 +333,10 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
|
|
|
|
|
params.put("uintType",uintType);
|
|
|
|
|
params.put("hoursToDay",hoursToDay);
|
|
|
|
|
Map<String,Object> flowData = kqReportBiz.getFlowData(params,user);
|
|
|
|
|
|
|
|
|
|
//考勤二开--请假时长
|
|
|
|
|
Map<String, Object> leaveInfos = getLeaveInfos(fromDate, toDate);
|
|
|
|
|
|
|
|
|
|
/*考勤二开--转事假start*/
|
|
|
|
|
String calLeaveId = bb.getPropValue("project_sskj", "calLeaveId");
|
|
|
|
|
/*考勤二开--转事假end*/
|
|
|
|
@ -513,109 +519,55 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
|
|
|
|
|
fieldValue = String.valueOf(intValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}else if(fieldName.equals("thisRemOt")){//当月加班剩余
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
double overtimeDuration = workingDayOvertime_4leave+restDayOvertime_4leave+holidayOvertime_4leave+
|
|
|
|
|
workingDayOvertime_nonleave+restDayOvertime_nonleave+holidayOvertime_nonleave;
|
|
|
|
|
|
|
|
|
|
//请假时长统计
|
|
|
|
|
String leaveData = Util.null2String(flowData.get(id+"|leaveType_5"));
|
|
|
|
|
String leavebackData = Util.null2s(Util.null2String(flowData.get(id+"|leavebackType_5")),"0.0");
|
|
|
|
|
String b_flowLeaveData = "";
|
|
|
|
|
String flowLeaveData = "";
|
|
|
|
|
try{
|
|
|
|
|
//以防止出现精度问题
|
|
|
|
|
if(leaveData.length() == 0){
|
|
|
|
|
leaveData = "0.0";
|
|
|
|
|
}else if(kqReportFieldComInfo.getParentid().equals("thisRemOt")){//当月加班剩余
|
|
|
|
|
if ("3".equals(typeselect) || "7".equals(typeselect)) {
|
|
|
|
|
Map<String, Object> allTiaoxius = getAllTiaoxius(id, fromDate, toDate);
|
|
|
|
|
if("workRemot".equals(fieldName)){
|
|
|
|
|
double max = Math.max(Util.getDoubleValue(Util.null2String(allTiaoxius.get("2"))), 0.00);
|
|
|
|
|
|
|
|
|
|
fieldValue = String.valueOf(max);
|
|
|
|
|
data.put(fieldName,fieldValue);
|
|
|
|
|
}
|
|
|
|
|
if(leavebackData.length() == 0){
|
|
|
|
|
leavebackData = "0.0";
|
|
|
|
|
if("restRemot".equals(fieldName)){
|
|
|
|
|
double max = Math.max(Util.getDoubleValue(Util.null2String(allTiaoxius.get("3"))), 0.00);
|
|
|
|
|
|
|
|
|
|
fieldValue = String.valueOf(max);
|
|
|
|
|
data.put(fieldName,fieldValue);
|
|
|
|
|
}
|
|
|
|
|
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";
|
|
|
|
|
if("holiRemot".equals(fieldName)){
|
|
|
|
|
double max = Math.max(Util.getDoubleValue(Util.null2String(allTiaoxius.get("1"))), 0.00);
|
|
|
|
|
|
|
|
|
|
fieldValue = String.valueOf(max);
|
|
|
|
|
data.put(fieldName,fieldValue);
|
|
|
|
|
}
|
|
|
|
|
}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)));
|
|
|
|
|
}
|
|
|
|
|
double leaveDuration = Math.max(Util.getDoubleValue(Util.null2String(flowLeaveData)),0.00);
|
|
|
|
|
|
|
|
|
|
double temp = overtimeDuration - leaveDuration;
|
|
|
|
|
fieldValue = String.valueOf(temp);
|
|
|
|
|
|
|
|
|
|
} else if(fieldName.equals("lastRemOt")){//上月加班剩余
|
|
|
|
|
double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|workingDayOvertime_4leavelast")));
|
|
|
|
|
workingDayOvertime_4leave = workingDayOvertime_4leave<0?0:workingDayOvertime_4leave;
|
|
|
|
|
double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|restDayOvertime_4leavelast")));
|
|
|
|
|
restDayOvertime_4leave = restDayOvertime_4leave<0?0:restDayOvertime_4leave;
|
|
|
|
|
double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|holidayOvertime_4leavelast")));
|
|
|
|
|
holidayOvertime_4leave = holidayOvertime_4leave<0?0:holidayOvertime_4leave;
|
|
|
|
|
|
|
|
|
|
double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|workingDayOvertime_nonleavelast")));
|
|
|
|
|
workingDayOvertime_nonleave = workingDayOvertime_nonleave<0?0:workingDayOvertime_nonleave;
|
|
|
|
|
double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|restDayOvertime_nonleavelast")));
|
|
|
|
|
restDayOvertime_nonleave = restDayOvertime_nonleave<0?0:restDayOvertime_nonleave;
|
|
|
|
|
double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|holidayOvertime_nonleavelast")));
|
|
|
|
|
holidayOvertime_nonleave = holidayOvertime_nonleave<0?0:holidayOvertime_nonleave;
|
|
|
|
|
|
|
|
|
|
double overtimeDuration = workingDayOvertime_4leave+restDayOvertime_4leave+holidayOvertime_4leave+
|
|
|
|
|
workingDayOvertime_nonleave+restDayOvertime_nonleave+holidayOvertime_nonleave;
|
|
|
|
|
|
|
|
|
|
//请假时长统计
|
|
|
|
|
String leaveData = Util.null2String(flowData.get(id+"|lastleaveType_5"));
|
|
|
|
|
String leavebackData = Util.null2s(Util.null2String(flowData.get(id+"|lastleavebackType_5")),"0.0");
|
|
|
|
|
String b_flowLeaveData = "";
|
|
|
|
|
String flowLeaveData = "";
|
|
|
|
|
try{
|
|
|
|
|
//以防止出现精度问题
|
|
|
|
|
if(leaveData.length() == 0){
|
|
|
|
|
leaveData = "0.0";
|
|
|
|
|
}
|
|
|
|
|
if(leavebackData.length() == 0){
|
|
|
|
|
leavebackData = "0.0";
|
|
|
|
|
|
|
|
|
|
} else if(kqReportFieldComInfo.getParentid().equals("lastRemOt")){//上月加班剩余
|
|
|
|
|
if ("3".equals(typeselect) || "7".equals(typeselect)) {
|
|
|
|
|
Map<String, Object> allTiaoxius = getLastAllTiaoxius(id, fromDate, toDate);
|
|
|
|
|
if("lastWorkRemot".equals(fieldName)){
|
|
|
|
|
double max = Math.max(Util.getDoubleValue(Util.null2String(allTiaoxius.get("2"))), 0.00);
|
|
|
|
|
|
|
|
|
|
bb.writeLog("lastWorkRemot max: " + max);
|
|
|
|
|
fieldValue = String.valueOf(max);
|
|
|
|
|
data.put(fieldName,fieldValue);
|
|
|
|
|
}
|
|
|
|
|
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";
|
|
|
|
|
if("lastRestRemot".equals(fieldName)){
|
|
|
|
|
double max = Math.max(Util.getDoubleValue(Util.null2String(allTiaoxius.get("3"))), 0.00);
|
|
|
|
|
|
|
|
|
|
bb.writeLog("lastRestRemot max: " + max);
|
|
|
|
|
fieldValue = String.valueOf(max);
|
|
|
|
|
data.put(fieldName,fieldValue);
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
writeLog("GetKQReportCmd:leaveData"+leaveData+":leavebackData:"+leavebackData+":"+e);
|
|
|
|
|
}
|
|
|
|
|
if("lastHoliRemot".equals(fieldName)){
|
|
|
|
|
double max = Math.max(Util.getDoubleValue(Util.null2String(allTiaoxius.get("1"))), 0.00);
|
|
|
|
|
|
|
|
|
|
//考虑下冻结的数据
|
|
|
|
|
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)));
|
|
|
|
|
bb.writeLog("lastHoliRemot max: " + max);
|
|
|
|
|
fieldValue = String.valueOf(max);
|
|
|
|
|
data.put(fieldName,fieldValue);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
double leaveDuration = Math.max(Util.getDoubleValue(Util.null2String(flowLeaveData)),0.00);
|
|
|
|
|
|
|
|
|
|
double temp = overtimeDuration - leaveDuration;
|
|
|
|
|
fieldValue = String.valueOf(temp);
|
|
|
|
|
|
|
|
|
|
} else if(kqReportFieldComInfo.getParentid().equals("overtime")||kqReportFieldComInfo.getParentid().equals("overtime_nonleave")
|
|
|
|
|
||kqReportFieldComInfo.getParentid().equals("overtime_4leave")||fieldName.equals("businessLeave") || fieldName.equals("officialBusiness")){
|
|
|
|
@ -662,14 +614,36 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
|
|
|
|
|
}else{
|
|
|
|
|
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id+"|"+fieldName)));
|
|
|
|
|
}
|
|
|
|
|
} else if("holiDuration".equals(fieldName)){
|
|
|
|
|
} else if("holiDuration".equals(fieldName)){//考勤二开--公休工时
|
|
|
|
|
int intValue = Util.getIntValue(Util.null2String(flowData.get("HoliDurationData|" + id)));
|
|
|
|
|
if (intValue >= 0) {
|
|
|
|
|
data.put(fieldName,intValue);
|
|
|
|
|
} else {
|
|
|
|
|
data.put(fieldName,"0");
|
|
|
|
|
}
|
|
|
|
|
} else if ("resourceType".equals(fieldName)) {//考勤二开--员工类型显示
|
|
|
|
|
} 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);
|
|
|
|
|
bb.writeLog("absenceDuration absenceDays: " + absenceDays);
|
|
|
|
|
|
|
|
|
|
fieldValue = new BigDecimal(hodHours).add(new BigDecimal(absenceDays).multiply(new BigDecimal(8))).add(leaveHours)
|
|
|
|
|
.divide(new BigDecimal(8),2,RoundingMode.HALF_UP).toString();
|
|
|
|
|
bb.writeLog("absenceDuration fieldValue: " + fieldValue);
|
|
|
|
|
|
|
|
|
|
data.put(fieldName,fieldValue);
|
|
|
|
|
} else if ("resourceType".equals(fieldName)) {//考勤二开--员工类型显示
|
|
|
|
|
|
|
|
|
|
int emp = Util.getIntValue(Util.null2String(empTypes.get(id)));
|
|
|
|
|
|
|
|
|
@ -691,55 +665,7 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
|
|
|
|
|
data.put(fieldName, fieldValue);
|
|
|
|
|
} else if ("startOrEndDays".equals(fieldName)) {//考勤二开--入离职工时
|
|
|
|
|
int absenceDays = 0;
|
|
|
|
|
if ("3".equals(typeselect) || "7".equals(typeselect)) {
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
Map<String, String> employAndResignDates = getEmployAndResignDateById(id);
|
|
|
|
|
|
|
|
|
|
String companystartdate = Util.null2String(employAndResignDates.get("companystartdate"));
|
|
|
|
|
String resignDate = Util.null2String(employAndResignDates.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.plusDays(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)) {
|
|
|
|
|
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 companystartdateL = LocalDate.parse(companystartdate, formatter);
|
|
|
|
|
LocalDate localDate = companystartdateL.plusDays(1);
|
|
|
|
|
companystartdate = localDate.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.plusDays(1);
|
|
|
|
|
companystartdate = localDate.format(formatter);
|
|
|
|
|
|
|
|
|
|
absenceDays = getAbsenceDays(id, fromDate, companystartdate, toDate);
|
|
|
|
|
} else if ( !substring1.equals(substring3) && !substring2.equals(substring3)){//非考勤月入职,考勤月离职
|
|
|
|
|
absenceDays = getAbsenceDays(id, resignDate, toDate, fromDate);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
absenceDays = getStartOrEndDays(id, fromDate, toDate, typeselect);
|
|
|
|
|
fieldValue = String.valueOf(absenceDays);
|
|
|
|
|
|
|
|
|
|
data.put(fieldName, fieldValue);
|
|
|
|
@ -1204,6 +1130,7 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
|
|
|
|
|
"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"));
|
|
|
|
@ -1215,6 +1142,7 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
|
|
|
|
|
"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"));
|
|
|
|
@ -1226,7 +1154,192 @@ public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bb.writeLog("getLeaveInfos result: " + result);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 入离职工时
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public int getStartOrEndDays(String id, String fromDate, String toDate, String typeselect){
|
|
|
|
|
int absenceDays = 0;
|
|
|
|
|
if ("3".equals(typeselect) || "7".equals(typeselect)) {
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
Map<String, String> employAndResignDates = getEmployAndResignDateById(id);
|
|
|
|
|
|
|
|
|
|
String companystartdate = Util.null2String(employAndResignDates.get("companystartdate"));
|
|
|
|
|
String resignDate = Util.null2String(employAndResignDates.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)) {
|
|
|
|
|
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 companystartdateL = LocalDate.parse(companystartdate, formatter);
|
|
|
|
|
LocalDate localDate = companystartdateL.minusDays(1);
|
|
|
|
|
companystartdate = localDate.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)){//非考勤月入职,考勤月离职
|
|
|
|
|
absenceDays = getAbsenceDays(id, resignDate, toDate, fromDate);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return absenceDays;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取各种类型的调休时长
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Map<String, Object> getAllTiaoxius(String resourceid ,String fromdate, String todate) {
|
|
|
|
|
Map<String, Object> result = new HashMap<String, Object>();
|
|
|
|
|
String acqSql = "SELECT " +
|
|
|
|
|
" a.resourceid, " +
|
|
|
|
|
" SUM(tiaoxiuamount) AS tiaoxiuamounts, " +
|
|
|
|
|
" SUM(usedamount) AS usedamounts, " +
|
|
|
|
|
" GREATEST( sum(extraamount) + SUM(tiaoxiuamount) - SUM(usedamount), 0.00000) AS difference_amounts, " +
|
|
|
|
|
" COALESCE(datetype, b.changetype) AS grouping_date, " +
|
|
|
|
|
" CASE " +
|
|
|
|
|
" WHEN datetype IS NOT NULL THEN datetype " +
|
|
|
|
|
" ELSE b.changetype " +
|
|
|
|
|
" END AS displayed_date " +
|
|
|
|
|
"FROM " +
|
|
|
|
|
" kq_balanceofleave a " +
|
|
|
|
|
"LEFT JOIN " +
|
|
|
|
|
" kq_flow_overtime b ON b.tiaoxiuid = a.id " +
|
|
|
|
|
"WHERE " +
|
|
|
|
|
" a.leaverulesid = 5 " +
|
|
|
|
|
" AND a.effectiveDate >= '"+fromdate+"' " +
|
|
|
|
|
" AND a.effectiveDate <= '"+todate+"' " +
|
|
|
|
|
" AND a.expirationDate >= '"+todate+"' " +
|
|
|
|
|
" AND a.resourceid = "+resourceid+" " +
|
|
|
|
|
"GROUP BY " +
|
|
|
|
|
" a.resourceid, " +
|
|
|
|
|
" COALESCE(datetype, b.changetype) " +
|
|
|
|
|
"ORDER BY " +
|
|
|
|
|
" grouping_date;";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
rs.executeQuery(acqSql);
|
|
|
|
|
while (rs.next()){
|
|
|
|
|
String differenceAmounts = Util.null2String(rs.getString("difference_amounts"));
|
|
|
|
|
String displayedDate = Util.null2String(rs.getString("displayed_date"));
|
|
|
|
|
if (StringUtils.isNotBlank(differenceAmounts) && StringUtils.isNotBlank(displayedDate)) {
|
|
|
|
|
result.put(displayedDate, differenceAmounts);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取上月各种类型的调休时长
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Map<String, Object> getLastAllTiaoxius(String resourceid ,String fromdate, String todate) {
|
|
|
|
|
Map<String, Object> result = new HashMap<String, Object>();
|
|
|
|
|
Map<String, Object> lastMonthFirstAndLastDay = getLastMonthFirstAndLastDay(fromdate);
|
|
|
|
|
bb.writeLog("lastMonthFirstAndLastDay: " + lastMonthFirstAndLastDay);
|
|
|
|
|
|
|
|
|
|
if (lastMonthFirstAndLastDay != null && lastMonthFirstAndLastDay.size() > 0) {
|
|
|
|
|
String firstDay = Util.null2String(lastMonthFirstAndLastDay.get("firstDay"));
|
|
|
|
|
String lastDay = Util.null2String(lastMonthFirstAndLastDay.get("lastDay"));
|
|
|
|
|
if (StringUtils.isNotBlank(firstDay)) {
|
|
|
|
|
fromdate = firstDay;
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isNotBlank(lastDay)) {
|
|
|
|
|
todate = lastDay;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String acqSql = "SELECT " +
|
|
|
|
|
" a.resourceid, " +
|
|
|
|
|
" SUM(tiaoxiuamount) AS tiaoxiuamounts, " +
|
|
|
|
|
" SUM(usedamount) AS usedamounts, " +
|
|
|
|
|
" GREATEST( sum(extraamount) + SUM(tiaoxiuamount) - SUM(usedamount), 0.00000) AS difference_amounts, " +
|
|
|
|
|
" COALESCE(datetype, b.changetype) AS grouping_date, " +
|
|
|
|
|
" CASE " +
|
|
|
|
|
" WHEN datetype IS NOT NULL THEN datetype " +
|
|
|
|
|
" ELSE b.changetype " +
|
|
|
|
|
" END AS displayed_date " +
|
|
|
|
|
"FROM " +
|
|
|
|
|
" kq_balanceofleave a " +
|
|
|
|
|
"LEFT JOIN " +
|
|
|
|
|
" kq_flow_overtime b ON b.tiaoxiuid = a.id " +
|
|
|
|
|
"WHERE " +
|
|
|
|
|
" a.leaverulesid = 5 " +
|
|
|
|
|
" AND a.effectiveDate >= '"+fromdate+"' " +
|
|
|
|
|
" AND a.effectiveDate <= '"+todate+"' " +
|
|
|
|
|
" AND a.expirationDate >= '"+todate+"' " +
|
|
|
|
|
" AND a.resourceid = "+resourceid+" " +
|
|
|
|
|
"GROUP BY " +
|
|
|
|
|
" a.resourceid, " +
|
|
|
|
|
" COALESCE(datetype, b.changetype) " +
|
|
|
|
|
"ORDER BY " +
|
|
|
|
|
" grouping_date;";
|
|
|
|
|
bb.writeLog("acqSql: " + acqSql);
|
|
|
|
|
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
rs.executeQuery(acqSql);
|
|
|
|
|
while (rs.next()){
|
|
|
|
|
String differenceAmounts = Util.null2String(rs.getString("difference_amounts"));
|
|
|
|
|
String displayedDate = Util.null2String(rs.getString("displayed_date"));
|
|
|
|
|
if (StringUtils.isNotBlank(differenceAmounts) && StringUtils.isNotBlank(displayedDate)) {
|
|
|
|
|
result.put(displayedDate, differenceAmounts);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
bb.writeLog("result: " + result);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Map<String,Object> getLastMonthFirstAndLastDay(String dateString) {
|
|
|
|
|
|
|
|
|
|
Map<String,Object> result = new HashMap<String,Object>();
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
// 解析给定的日期字符串
|
|
|
|
|
LocalDate date = LocalDate.parse(dateString, formatter);
|
|
|
|
|
|
|
|
|
|
// 获取上个月的第一天
|
|
|
|
|
LocalDate firstDayOfLastMonth = date.with(TemporalAdjusters.firstDayOfMonth()).minusMonths(1);
|
|
|
|
|
|
|
|
|
|
// 获取上个月的最后一天
|
|
|
|
|
LocalDate lastDayOfLastMonth = date.with(TemporalAdjusters.lastDayOfMonth()).minusMonths(1);
|
|
|
|
|
|
|
|
|
|
// 格式化日期为字符串并返回
|
|
|
|
|
result.put("firstDay", firstDayOfLastMonth.format(formatter));
|
|
|
|
|
result.put("lastDay", lastDayOfLastMonth.format(formatter));
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|