2254 lines
90 KiB
Java
2254 lines
90 KiB
Java
package com.engine.lingyue.util;
|
||
|
||
import com.engine.kq.biz.KQGroupMemberComInfo;
|
||
import com.engine.kq.biz.KQWorkTime;
|
||
import com.engine.kq.entity.KQGroupEntity;
|
||
import com.engine.kq.entity.WorkTimeEntity;
|
||
import org.apache.commons.lang.StringUtils;
|
||
import weaver.conn.RecordSet;
|
||
import weaver.general.Util;
|
||
import weaver.hrm.company.DepartmentComInfo;
|
||
import weaver.hrm.company.SubCompanyComInfo;
|
||
import weaver.hrm.resource.ResourceComInfo;
|
||
|
||
import java.math.BigDecimal;
|
||
import java.text.ParseException;
|
||
import java.text.SimpleDateFormat;
|
||
import java.time.LocalDate;
|
||
import java.time.format.DateTimeFormatter;
|
||
import java.util.*;
|
||
|
||
/**
|
||
* @Title
|
||
* @Author wangchaofa
|
||
* @CreateDate 2024/11/7
|
||
* @Version 1.0
|
||
* @Description
|
||
*/
|
||
public class KqUtil {
|
||
|
||
/**
|
||
* 计算两个时间字符串日期的相差天数
|
||
*
|
||
* @param sStartDate 字符串时间1
|
||
* @param sEndDate 字符串时间2
|
||
* @return 相差时间
|
||
*/
|
||
public static int getDays(String sStartDate, String sEndDate) {
|
||
int days = 0;
|
||
try {
|
||
if (!"".equals(sStartDate) && !"".equals(sEndDate)) {
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||
Date date1 = sdf.parse(sStartDate);
|
||
Date date2 = sdf.parse(sEndDate);
|
||
|
||
long Days = (date2.getTime() - date1.getTime()) / (24*3600*1000);
|
||
if(Days < 0){
|
||
days = 0;
|
||
}else{
|
||
days = (int)Days+1;
|
||
}
|
||
}
|
||
}catch (Exception e){
|
||
e.printStackTrace();
|
||
}
|
||
return days;
|
||
}
|
||
|
||
/**
|
||
* 计算天数
|
||
* @param date1 日期
|
||
* @param date2 日期
|
||
* @return 天数
|
||
*/
|
||
public static int calculateDays(Date date1, Date date2) {
|
||
Calendar cal1 = Calendar.getInstance();
|
||
cal1.setTime(date1);
|
||
Calendar cal2 = Calendar.getInstance();
|
||
cal2.setTime(date2);
|
||
int day1 = cal1.get(Calendar.DAY_OF_YEAR);
|
||
int day2 = cal2.get(Calendar.DAY_OF_YEAR);
|
||
int year1 = cal1.get(Calendar.YEAR);
|
||
int year2 = cal2.get(Calendar.YEAR);
|
||
if (year1 != year2) {//不同 年
|
||
int timeDistance = 0;
|
||
if (year1 < year2) {//后面日期年大于前面日期
|
||
for (int i = year1; i < year2; i++) {
|
||
if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0) {//闰年
|
||
timeDistance += 366;
|
||
} else {//不是闰年
|
||
timeDistance += 365;
|
||
}
|
||
}
|
||
} else {
|
||
for (int i = year2; i < year1; i++) {
|
||
if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0) {//闰年
|
||
timeDistance += 366;
|
||
} else {//不是闰年
|
||
timeDistance += 365;
|
||
timeDistance = 0 - timeDistance;
|
||
}
|
||
}
|
||
}
|
||
return timeDistance + (day2 - day1);
|
||
} else {//同一年
|
||
return day2 - day1;
|
||
}
|
||
}
|
||
|
||
/**
|
||
* @param a 任意数
|
||
* @return 是
|
||
*/
|
||
private static String isZero(String a) {
|
||
if (a==null || "".equals(a)) {
|
||
a = "0";
|
||
}
|
||
return a;
|
||
}
|
||
|
||
/**
|
||
* 大小比较
|
||
*
|
||
* @param a
|
||
* @param b
|
||
* @return -1 小于 0 等于 1 大于
|
||
*/
|
||
public static int floatCompare(String a, String b) {
|
||
a = isZero(a);
|
||
b = isZero(b);
|
||
BigDecimal bg1 = new BigDecimal(a);
|
||
BigDecimal bg2 = new BigDecimal(b);
|
||
return bg1.compareTo(bg2);
|
||
}
|
||
|
||
/**
|
||
* 方法描述 : 对两个字符串进行金额的相加
|
||
* @param a
|
||
* @param b
|
||
* @return
|
||
* String
|
||
*/
|
||
public static String floatAdd(String a, String b) {
|
||
a=a.equals("")?"0":a;
|
||
b=b.equals("")?"0":b;
|
||
BigDecimal bg1 = new BigDecimal(a);
|
||
BigDecimal bg2 = new BigDecimal(b);
|
||
BigDecimal bd = bg1.add(bg2);
|
||
return bd.toString();
|
||
}
|
||
|
||
/**
|
||
*
|
||
* 方法描述 : 对两个字符串进行金额的相减
|
||
* @param a
|
||
* @param b
|
||
* @return
|
||
* String
|
||
*/
|
||
public static String floatSubtract(String a, String b) {
|
||
a=a.equals("")?"0":a;
|
||
b=b.equals("")?"0":b;
|
||
BigDecimal bg1 = new BigDecimal(a);
|
||
BigDecimal bg2 = new BigDecimal(b);
|
||
BigDecimal bd = bg1.subtract(bg2);
|
||
return bd.toString();
|
||
}
|
||
|
||
/**
|
||
*
|
||
* 方法描述 : 对两个字符串进行金额的相乘
|
||
* @param a
|
||
* @param b
|
||
* @return
|
||
* String
|
||
*/
|
||
public static String floatMultiply(String a, String b) {
|
||
a=a.equals("")?"0":a;
|
||
b=b.equals("")?"0":b;
|
||
BigDecimal bg1 = new BigDecimal(a);
|
||
BigDecimal bg2 = new BigDecimal(b);
|
||
BigDecimal bd = bg1.multiply(bg2).setScale(4, BigDecimal.ROUND_HALF_UP);
|
||
return bd.toString();
|
||
}
|
||
|
||
/**
|
||
*
|
||
* 方法描述 : 对两个字符串进行金额的相除(默认保留两位小数)
|
||
* @param a
|
||
* @param b
|
||
* @return
|
||
* String
|
||
*/
|
||
public static String floatDivide(String a, String b) {
|
||
a=a.equals("")?"0":a;
|
||
b=b.equals("")?"0":b;
|
||
BigDecimal bg1 = new BigDecimal(a);
|
||
BigDecimal bg2 = new BigDecimal(b);
|
||
BigDecimal bd = bg1.divide(bg2, 2, BigDecimal.ROUND_HALF_UP);
|
||
return bd.toString();
|
||
}
|
||
|
||
/**
|
||
* 判断当月有几天
|
||
* @param Year int 2020
|
||
* @param Month int 8
|
||
* @return
|
||
*/
|
||
public static int getMonthDays(String Year, String Month) {
|
||
int year = Integer.parseInt(Year);
|
||
int month = Integer.parseInt(Month);
|
||
if (month == 2) {
|
||
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
|
||
return 29;
|
||
} else {
|
||
return 28;
|
||
}
|
||
} else if (month == 4 || month == 6 || month == 9 || month == 11) {
|
||
return 30;
|
||
} else {
|
||
return 31;
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 比较时间的大小
|
||
* @param a
|
||
* @param b
|
||
* @return
|
||
* @throws ParseException
|
||
*/
|
||
public static boolean compareDate(String a, String b){
|
||
boolean bool = false;
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||
try {
|
||
long t1 = sdf.parse(a).getTime();
|
||
long t2 = sdf.parse(b).getTime();
|
||
if (t1 >= t2) {
|
||
bool = true;
|
||
}
|
||
return bool;
|
||
}catch (Exception e){
|
||
e.printStackTrace();
|
||
}
|
||
return bool;
|
||
}
|
||
|
||
/**
|
||
* 获取 旷工天数(薪酬调整前)
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static double getAbsenteeismDaysBeforeSalaryBefore(String fromdate, String todate,String userid){
|
||
double result = 0.00;
|
||
RecordSet rs = new RecordSet();
|
||
// 薪资调整日期
|
||
String salaryAdjustDate = getSalaryAdjustDate(fromdate,todate,userid);
|
||
if(salaryAdjustDate != null && !"".equals(salaryAdjustDate)){
|
||
if(belongCalendar(salaryAdjustDate,fromdate,todate)) {
|
||
rs.executeQuery("select sum(absenteeism) as days from kq_format_total " +
|
||
" where resourceid = ? and kqdate >= ? and kqdate < ? ", userid, fromdate, salaryAdjustDate);
|
||
while (rs.next()) {
|
||
result = Util.getDoubleValue(rs.getString("days"), 0.00);
|
||
}
|
||
}
|
||
// else{
|
||
// rs.executeQuery("select sum(absenteeism) as days from kq_format_total " +
|
||
// " where resourceid = ? and kqdate >= ? and kqdate < ? ", userid, fromdate, todate);
|
||
// while (rs.next()) {
|
||
// result = Util.getDoubleValue(rs.getString("days"), 0.00);
|
||
// }
|
||
// }
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 旷工天数(薪酬调整后)
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static double getAbsenteeismDaysAfterSalaryAfter(String fromdate, String todate,String userid){
|
||
double result = 0.00;
|
||
RecordSet rs = new RecordSet();
|
||
// 薪资调整日期
|
||
String salaryAdjustDate = getSalaryAdjustDate(fromdate,todate,userid);
|
||
if(salaryAdjustDate != null && !"".equals(salaryAdjustDate)){
|
||
if(belongCalendar(salaryAdjustDate,fromdate,todate)) {
|
||
rs.executeQuery("select sum(absenteeism) as days from kq_format_total " +
|
||
" where resourceid = ? and kqdate >= ? and kqdate <= ? ", userid, salaryAdjustDate, todate);
|
||
while (rs.next()) {
|
||
result = Util.getDoubleValue(rs.getString("days"), 0.00);
|
||
}
|
||
}else{
|
||
rs.executeQuery("select sum(absenteeism) as days from kq_format_total " +
|
||
" where resourceid = ? and kqdate >= ? and kqdate <= ? ", userid, fromdate, todate);
|
||
while (rs.next()) {
|
||
result = Util.getDoubleValue(rs.getString("days"), 0.00);
|
||
}
|
||
}
|
||
}else{
|
||
rs.executeQuery("select sum(absenteeism) as days from kq_format_total "+
|
||
" where resourceid = ? and kqdate >= ? and kqdate <= ? ",userid,fromdate,todate);
|
||
while(rs.next()){
|
||
result = Util.getDoubleValue(rs.getString("days"),0.00);
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 旷工次数 调整前旷工天数+调整后旷工天数
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static double getAbsenteeismDays(String fromdate, String todate,String userid){
|
||
// 调整前旷工天数
|
||
double absenteeismDaysBeforeSalary = getAbsenteeismDaysBeforeSalaryBefore(fromdate,todate,userid);
|
||
// 调整后旷工天数
|
||
double absenteeismDaysAfterSalary = getAbsenteeismDaysAfterSalaryAfter(fromdate,todate,userid);
|
||
// 漏签、 计0.5天旷工
|
||
double forgotcheckabsenteeismdays = getForgotCheckAbsenteeismDaysAfter(fromdate,todate,userid);
|
||
// 严重迟到、严重早退 计0.5天旷工
|
||
double gravebelateleaveearlydays = getGraveBeLateLeaveEarlyDaysAfter(fromdate,todate,userid);
|
||
|
||
return absenteeismDaysBeforeSalary + absenteeismDaysAfterSalary + forgotcheckabsenteeismdays + gravebelateleaveearlydays;
|
||
}
|
||
|
||
/**
|
||
* 获取 旷工次数 标准旷工+标准漏签次数+标准严重迟到次数+标准严重早退次数
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static double getAbsenteeNumsSalary(String fromdate, String todate,String userid){
|
||
double result = 0.00;
|
||
RecordSet rs = new RecordSet();
|
||
// 旷工
|
||
rs.executeQuery("select sum(absenteeism) as days from kq_format_total " +
|
||
" where resourceid = ? and kqdate >= ? and kqdate <= ? ", userid, fromdate, todate);
|
||
while (rs.next()) {
|
||
double count = Util.getDoubleValue(rs.getString("days"), 0.00);
|
||
result = result + count;
|
||
}
|
||
// 漏签
|
||
rs.executeQuery("select sum(forgotCheck)+sum(forgotBeginWorkCheck) as count from kq_format_total "+
|
||
" where resourceid = ? and kqdate >= ? and kqdate <= ? ",userid,fromdate,todate);
|
||
while(rs.next()){
|
||
double count = Util.getDoubleValue(rs.getString("count"),0.00);
|
||
result = result + count;
|
||
}
|
||
//标准严重迟到次数 + 标准严重早退次数
|
||
rs.executeQuery("select sum(gravebelate)+sum(graveleaveearly) as count from kq_format_total "+
|
||
" where resourceid = ? and kqdate >= ? and kqdate <= ? ",userid,fromdate,todate);
|
||
while(rs.next()){
|
||
double count = Util.getDoubleValue(rs.getString("count"),0.00);
|
||
result = result + count;
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 产假天数(薪酬用)
|
||
* 职级为1和2:取标准产假天数
|
||
* 职级不是1和2:【周一到周五】产假天数+【周六周日】调配工作日产假天数-【周一到周五】调配休息日产假天数
|
||
* 2025-08-08 改成 如果不是职级 1和2 ,当天排了 非休息班次,产假,计数1天,否则 不计数
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static double getMaternityLeaveDaySalary(String fromdate, String todate,String userid){
|
||
double result = 0.00;
|
||
RecordSet rs = new RecordSet();
|
||
//职级
|
||
int positionRank = getPositionRank(getPositionRankId(fromdate,todate,userid));
|
||
// 产假
|
||
String maternity_leave_id = rs.getPropValue("hrm_kqreport","maternity_leave_id");
|
||
|
||
if (positionRank == 1 || positionRank == 2) {
|
||
result = Double.valueOf(getLeaveTypeDays(maternity_leave_id,fromdate,todate,userid));
|
||
}else{
|
||
result = Double.valueOf(getRestLeaveDaysSalary(maternity_leave_id,fromdate,todate,userid));
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 日期范围内 假期天数
|
||
* @param leaveType
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static String getLeaveTypeDays(String leaveType,String fromdate, String todate,String userid){
|
||
String result = "0";
|
||
RecordSet rs = new RecordSet();
|
||
|
||
String halfdays = "0";
|
||
String halfbackdays = "0";
|
||
|
||
// 假 时长
|
||
rs.executeQuery("select sum(duration) as count from kq_flow_split_leave where belongdate >= ? and belongdate <= ? and newleavetype in ("+ leaveType +") and resourceid = ? ",fromdate,todate,userid);
|
||
while(rs.next()){
|
||
halfdays = Util.null2o(rs.getString("count"));
|
||
}
|
||
|
||
// 销假时长
|
||
rs.executeQuery("select sum(duration) as count from kq_flow_split_leaveback where belongdate >= ? and belongdate <= ? and newleavetype in ("+ leaveType +") and resourceid = ? ",fromdate,todate,userid);
|
||
while(rs.next()){
|
||
halfbackdays = Util.null2o(rs.getString("count"));
|
||
}
|
||
|
||
result = floatSubtract(halfdays,halfbackdays);
|
||
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 工伤假天数(薪酬用)
|
||
* 职级为1和2:取标准工伤假假天数
|
||
* 职级不是1和2:【周一到周五】工伤假天数+【周六周日】调配工作日工伤假天数-【周一到周五】调配休息日工伤假天数
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static double getInjuryLeaveDaySalary(String fromdate, String todate,String userid){
|
||
double result = 0.00;
|
||
RecordSet rs = new RecordSet();
|
||
//职级
|
||
int positionRank = getPositionRank(getPositionRankId(fromdate,todate,userid));
|
||
// 产假
|
||
String injuryLeave_leave_id = rs.getPropValue("hrm_kqreport","injuryLeave_leave_id");
|
||
|
||
if (positionRank == 1 || positionRank == 2) {
|
||
result = Double.valueOf(getLeaveTypeDays(injuryLeave_leave_id,fromdate,todate,userid));
|
||
}else{
|
||
result = Double.valueOf(getLeaveDaysSalary(injuryLeave_leave_id,fromdate,todate,userid));
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 判断日期范围内是否 有产假
|
||
* @param leaveType
|
||
* @param fromdate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static boolean checkHasMaternityLeave(String leaveType,String fromdate,String userid){
|
||
boolean bool = false;
|
||
String result = "0";
|
||
RecordSet rs = new RecordSet();
|
||
|
||
String halfdays = "0";
|
||
String halfbackdays = "0";
|
||
|
||
// 假 时长
|
||
rs.executeQuery("select sum(duration) as count from kq_flow_split_leave where belongdate = ? and newleavetype in ("+ leaveType +") and resourceid = ? ",fromdate,userid);
|
||
while(rs.next()){
|
||
halfdays = Util.null2o(rs.getString("count"));
|
||
}
|
||
|
||
// 销假时长
|
||
rs.executeQuery("select sum(duration) as count from kq_flow_split_leaveback where belongdate = ? and newleavetype in ("+ leaveType +") and resourceid = ? ",fromdate,userid);
|
||
while(rs.next()){
|
||
halfbackdays = Util.null2o(rs.getString("count"));
|
||
}
|
||
|
||
result = floatSubtract(halfdays,halfbackdays);
|
||
if(floatCompare(result,"0") > 0){
|
||
bool = true;
|
||
}
|
||
return bool;
|
||
}
|
||
|
||
/**
|
||
* 获取 工伤假天数(薪酬用)
|
||
* @param leaveType
|
||
* @param fromDate
|
||
* @param toDate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static String getLeaveDaysSalary(String leaveType,String fromDate, String toDate,String userid){
|
||
String result = "0";
|
||
RecordSet rs = new RecordSet();
|
||
// 格式化日期
|
||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||
rs.executeQuery("select distinct groupid,kqdate from kq_format_total " +
|
||
" where resourceid = ? and kqdate >= ? and kqdate <= ?",userid,fromDate,toDate);
|
||
rs.next();
|
||
//考勤组 id
|
||
// String groupid = Util.null2String(rs.getString("groupid"));
|
||
|
||
String groupid = rs.getPropValue("hrm_kqreport","the_top_groupid");
|
||
|
||
// 周六或周日天数
|
||
String weekdays = "0";
|
||
// 周一到周五天数
|
||
String workdays = "0";
|
||
// 调配休息日天数
|
||
String allocateRestDays = "0";
|
||
// 调配工作日天数
|
||
String allocateWorkDays = "0";
|
||
|
||
String[] dateStartArr = parseDate(fromDate);
|
||
String[] dateEndtArr = parseDate(toDate);
|
||
LocalDate startDate = LocalDate.of(Integer.parseInt(dateStartArr[0]), Integer.parseInt(dateStartArr[1]), Integer.parseInt(dateStartArr[2]));
|
||
LocalDate endDate = LocalDate.of(Integer.parseInt(dateEndtArr[0]), Integer.parseInt(dateEndtArr[1]), Integer.parseInt(dateEndtArr[2]));
|
||
// 遍历日期范围
|
||
for (LocalDate date = startDate; !date.isAfter(endDate); date = date.plusDays(1)) {
|
||
// 输出格式化后的日期字符串
|
||
String dateString = date.format(formatter);
|
||
// 是 周六或 周日
|
||
if (isSaturdayOrSunday(dateString)) {
|
||
//是调配工作日、是公众假日
|
||
if (isAllocateWorkDay(groupid, dateString) || isAllocateHolidayDay(groupid, dateString)) {
|
||
String leaveDays = getLeaveTypeDays(leaveType,dateString,dateString,userid);
|
||
if(floatCompare(leaveDays,"0") > 0) {
|
||
allocateWorkDays = floatAdd(allocateWorkDays, leaveDays);
|
||
}
|
||
}
|
||
} else {
|
||
// 是 调配休息日
|
||
if(isAllocateRestDay(groupid,dateString)){
|
||
String leaveDays = getLeaveTypeDays(leaveType,dateString,dateString,userid);
|
||
if(floatCompare(leaveDays,"0") > 0) {
|
||
allocateRestDays = floatAdd(allocateRestDays, leaveDays);
|
||
}
|
||
}else {
|
||
String leaveDays = getLeaveTypeDays(leaveType, dateString, dateString, userid);
|
||
if (floatCompare(leaveDays, "0") > 0) {
|
||
workdays = floatAdd(workdays, leaveDays);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
result = floatAdd(result,floatAdd(workdays,allocateWorkDays));
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 产假天数(薪酬用)
|
||
* @param leaveType
|
||
* @param fromDate
|
||
* @param toDate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static String getRestLeaveDaysSalary(String leaveType,String fromDate, String toDate,String userid){
|
||
String result = "0";
|
||
RecordSet rs = new RecordSet();
|
||
// 格式化日期
|
||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||
rs.executeQuery("select distinct groupid,kqdate from kq_format_total " +
|
||
" where resourceid = ? and kqdate >= ? and kqdate <= ?",userid,fromDate,toDate);
|
||
rs.next();
|
||
//考勤组 id
|
||
// String groupid = Util.null2String(rs.getString("groupid"));
|
||
|
||
String groupid = rs.getPropValue("hrm_kqreport","the_top_groupid");
|
||
|
||
// 休息班次
|
||
String rest_serial_id = rs.getPropValue("hrm_kqreport","rest_serial_id");
|
||
|
||
// 周六或周日天数
|
||
String weekdays = "0";
|
||
// 周一到周五天数
|
||
String workdays = "0";
|
||
// 调配休息日天数
|
||
String allocateRestDays = "0";
|
||
// 调配工作日天数
|
||
String allocateWorkDays = "0";
|
||
|
||
String[] dateStartArr = parseDate(fromDate);
|
||
String[] dateEndtArr = parseDate(toDate);
|
||
LocalDate startDate = LocalDate.of(Integer.parseInt(dateStartArr[0]), Integer.parseInt(dateStartArr[1]), Integer.parseInt(dateStartArr[2]));
|
||
LocalDate endDate = LocalDate.of(Integer.parseInt(dateEndtArr[0]), Integer.parseInt(dateEndtArr[1]), Integer.parseInt(dateEndtArr[2]));
|
||
// 遍历日期范围
|
||
for (LocalDate date = startDate; !date.isAfter(endDate); date = date.plusDays(1)) {
|
||
// 输出格式化后的日期字符串
|
||
String dateString = date.format(formatter);
|
||
// // 是 周六或 周日
|
||
// if (isSaturdayOrSunday(dateString)) {
|
||
// //是调配工作日、是公众假日
|
||
// if (isAllocateWorkDay(groupid, dateString) || isAllocateHolidayDay(groupid, dateString)) {
|
||
// String leaveDays = getLeaveTypeDays(leaveType,dateString,dateString,userid);
|
||
// if(floatCompare(leaveDays,"0") > 0) {
|
||
// allocateWorkDays = floatAdd(allocateWorkDays, leaveDays);
|
||
// }
|
||
// }
|
||
// } else {
|
||
// // 是 调配休息日
|
||
// if(isAllocateRestDay(groupid,dateString)){
|
||
// String leaveDays = getLeaveTypeDays(leaveType,dateString,dateString,userid);
|
||
// if(floatCompare(leaveDays,"0") > 0) {
|
||
// allocateRestDays = floatAdd(allocateRestDays, leaveDays);
|
||
// }
|
||
// }else {
|
||
// String leaveDays = getLeaveTypeDays(leaveType, dateString, dateString, userid);
|
||
// if (floatCompare(leaveDays, "0") > 0) {
|
||
// workdays = floatAdd(workdays, leaveDays);
|
||
// }
|
||
// }
|
||
// }
|
||
KQWorkTime kqWorkTime = new KQWorkTime();
|
||
WorkTimeEntity workTimeEntity = kqWorkTime.getWorkTime(userid, dateString);
|
||
String searIdFrom = workTimeEntity.getSerialId();
|
||
if(searIdFrom != null && !"".equals(searIdFrom)){
|
||
//当天请了产假
|
||
if(checkHasMaternityLeave(leaveType,dateString,userid)) {
|
||
//非休息班次
|
||
if (!rest_serial_id.equals(searIdFrom)) {
|
||
result = floatAdd(result, "1");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
// result = floatAdd(result,floatAdd(workdays,allocateWorkDays));
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 每次漏签、严重迟到、严重早退 计0.5天旷工
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static double getForgotCheckAbsenteeismDaysBefore(String fromdate, String todate,String userid){
|
||
double result = 0.00;
|
||
RecordSet rs = new RecordSet();
|
||
rs.executeQuery("select sum(forgotCheck)+sum(forgotBeginWorkCheck) as count from kq_format_total "+
|
||
" where resourceid = ? and kqdate >= ? and kqdate <= ? ",userid,fromdate,todate);
|
||
while(rs.next()){
|
||
String count = Util.null2o(rs.getString("count"));
|
||
result = Double.valueOf(floatMultiply(count,"0.5"));
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 每次漏签、严重迟到、严重早退 计0.5天旷工
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static double getForgotCheckAbsenteeismDaysAfter(String fromdate, String todate,String userid){
|
||
double result = 0.00;
|
||
RecordSet rs = new RecordSet();
|
||
rs.executeQuery("select sum(forgotCheck)+sum(forgotBeginWorkCheck) as count from kq_format_total "+
|
||
" where resourceid = ? and kqdate >= ? and kqdate <= ? ",userid,fromdate,todate);
|
||
while(rs.next()){
|
||
String count = Util.null2o(rs.getString("count"));
|
||
result = Double.valueOf(floatMultiply(count,"0.5"));
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 每次严重迟到/早退 0.5天旷工
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static double getGraveBeLateLeaveEarlyDaysBefore(String fromdate, String todate,String userid){
|
||
double result = 0.00;
|
||
RecordSet rs = new RecordSet();
|
||
rs.executeQuery("select sum(gravebelate)+sum(graveleaveearly) as count from kq_format_total "+
|
||
" where resourceid = ? and kqdate >= ? and kqdate <= ? ",userid,fromdate,todate);
|
||
while(rs.next()){
|
||
String count = Util.null2o(rs.getString("count"));
|
||
result = Double.valueOf(floatMultiply(count,"0.5"));
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 每次严重迟到/早退 0.5天旷工
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static double getGraveBeLateLeaveEarlyDaysAfter(String fromdate, String todate,String userid){
|
||
double result = 0.00;
|
||
RecordSet rs = new RecordSet();
|
||
rs.executeQuery("select sum(gravebelate)+sum(graveleaveearly) as count from kq_format_total "+
|
||
" where resourceid = ? and kqdate >= ? and kqdate <= ? ",userid,fromdate,todate);
|
||
while(rs.next()){
|
||
String count = Util.null2o(rs.getString("count"));
|
||
result = Double.valueOf(floatMultiply(count,"0.5"));
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 旷工天数(薪酬调整前)总计 取薪酬调动日期调整前的旷工天数(旷工+漏签+严重迟到/早退)
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
// public static double getAbsenteeismDaysCountBeforeSalary(String fromdate, String todate,String userid){
|
||
// double result = 0.00;
|
||
// // 薪资调整日期
|
||
// String salaryAdjustDate = getSalaryAdjustDate(fromdate,todate,userid);
|
||
// if(salaryAdjustDate != null && !"".equals(salaryAdjustDate)){
|
||
// if(belongCalendar(salaryAdjustDate,fromdate,todate)) {
|
||
// // 薪酬调动日期调整前的旷工天数
|
||
// double absenteeismDaysBeforeSalary = getAbsenteeismDaysBeforeSalaryBefore(fromdate, salaryAdjustDate, userid);
|
||
// // 每次漏签计0.5天旷工
|
||
// double forgotDays = getForgotCheckAbsenteeismDaysBefore(fromdate, salaryAdjustDate, userid);
|
||
// // 每次 严重迟到/早退每次计0.5天旷工
|
||
// double belateearlydays = getGraveBeLateLeaveEarlyDaysBefore(fromdate, salaryAdjustDate, userid);
|
||
//
|
||
// result = Double.valueOf(floatAdd(String.valueOf(absenteeismDaysBeforeSalary), floatAdd(String.valueOf(forgotDays), String.valueOf(belateearlydays))));
|
||
// }else{
|
||
// // 薪酬调动日期调整前的旷工天数
|
||
// double absenteeismDaysBeforeSalary = getAbsenteeismDaysBeforeSalaryBefore(fromdate, todate, userid);
|
||
// // 每次漏签计0.5天旷工
|
||
// double forgotDays = getForgotCheckAbsenteeismDaysBefore(fromdate, todate, userid);
|
||
// // 每次 严重迟到/早退每次计0.5天旷工
|
||
// double belateearlydays = getGraveBeLateLeaveEarlyDaysBefore(fromdate, todate, userid);
|
||
//
|
||
// result = Double.valueOf(floatAdd(String.valueOf(absenteeismDaysBeforeSalary), floatAdd(String.valueOf(forgotDays), String.valueOf(belateearlydays))));
|
||
// }
|
||
// }
|
||
// return result;
|
||
// }
|
||
|
||
public static double getAbsenteeismDaysCountBeforeSalary(String fromdate, String todate,String userid){
|
||
double result = 0.00;
|
||
|
||
// 薪酬调动日期调整前的旷工天数
|
||
// double absenteeismDaysBeforeSalary = getAbsenteeismDaysAfterSalaryAfter(fromdate, todate, userid);
|
||
// 每次漏签计0.5天旷工
|
||
double forgotDays = getForgotCheckAbsenteeismDaysBefore(fromdate, todate, userid);
|
||
// 每次 严重迟到/早退每次计0.5天旷工
|
||
double belateearlydays = getGraveBeLateLeaveEarlyDaysBefore(fromdate, todate, userid);
|
||
|
||
// result = Double.valueOf(floatAdd(String.valueOf(absenteeismDaysBeforeSalary), floatAdd(String.valueOf(forgotDays), String.valueOf(belateearlydays))));
|
||
result = Double.valueOf(floatAdd(String.valueOf(forgotDays), String.valueOf(belateearlydays)));
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 旷工天数(薪酬调整后)总计 取薪酬调动日期调整前的旷工天数(旷工+漏签+严重迟到/早退)
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static double getAbsenteeismDaysCountAfterSalary(String fromdate, String todate,String userid){
|
||
double result = 0.00;
|
||
|
||
// 薪酬调动日期调整前的旷工天数
|
||
double absenteeismDaysBeforeSalary = getAbsenteeismDaysAfterSalaryAfter(fromdate, todate, userid);
|
||
// 每次漏签计0.5天旷工
|
||
double forgotDays = getForgotCheckAbsenteeismDaysBefore(fromdate, todate, userid);
|
||
// 每次 严重迟到/早退每次计0.5天旷工
|
||
double belateearlydays = getGraveBeLateLeaveEarlyDaysBefore(fromdate, todate, userid);
|
||
|
||
result = Double.valueOf(floatAdd(String.valueOf(absenteeismDaysBeforeSalary), floatAdd(String.valueOf(forgotDays), String.valueOf(belateearlydays))));
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 法定(公众假日)天数
|
||
* @param companystartdate
|
||
* @param fromDate
|
||
* @param toDate
|
||
* @param groupid
|
||
* @return
|
||
*/
|
||
public static String getPublicHolidays(String companystartdate,String fromDate, String toDate,String groupid,String userid){
|
||
String result = "0";
|
||
RecordSet rs = new RecordSet();
|
||
// 产假
|
||
String maternity_leave_id = rs.getPropValue("hrm_kqreport","maternity_leave_id");
|
||
// 工伤假
|
||
String injuryLeave_leave_id = rs.getPropValue("hrm_kqreport","injuryLeave_leave_id");
|
||
// 离职日期
|
||
String terminationdate = getTerminationDate(userid);
|
||
if(compareDate(toDate,terminationdate)){
|
||
toDate = terminationdate;
|
||
}
|
||
|
||
rs.executeQuery("select * from KQ_HolidaySet where holidayDate between ? and ? and changeType=1 and groupid = ?",fromDate,toDate,groupid);
|
||
while(rs.next()){
|
||
String holidayDate = Util.null2String(rs.getString("holidayDate"));
|
||
//产假天数
|
||
String maternityLeaveTypeDay = getLeaveTypeDays(maternity_leave_id, holidayDate, holidayDate, userid);
|
||
//工伤假天数
|
||
String injuryLeaveLeaveTypeDay = getLeaveTypeDays(injuryLeave_leave_id, holidayDate, holidayDate, userid);
|
||
if (compareDate(holidayDate, companystartdate)) {
|
||
result = floatAdd(result, "1");
|
||
}
|
||
if (floatCompare(maternityLeaveTypeDay, "0") == 1) {
|
||
result = floatSubtract(result, "1");
|
||
}
|
||
if (floatCompare(injuryLeaveLeaveTypeDay, "0") == 1) {
|
||
result = floatSubtract(result, "1");
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 工作信息里的 自定义字段的 值
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static String getWorkCusFieldValue(String userid,String fieldid){
|
||
String result = "";
|
||
RecordSet rs = new RecordSet();
|
||
rs.executeQuery("select "+ fieldid +" from cus_fielddata where scope='HrmCustomFieldByInfoType' and scopeid='3' and id=?",userid);
|
||
if(rs.next()){
|
||
result = Util.null2String(rs.getString(fieldid));
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 入职日期 = 人力资源表 companystartdate 字段
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static String getCompanyStartDate(String userid){
|
||
String result = "";
|
||
RecordSet rs = new RecordSet();
|
||
rs.executeQuery("select companystartdate from hrmresource where id = ?",userid);
|
||
if(rs.next()){
|
||
result = Util.null2String(rs.getString("companystartdate"));
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 转正日期
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static String getComfirmDate(String userid){
|
||
String result = "";
|
||
RecordSet rs = new RecordSet();
|
||
String zzrq_fieldid = rs.getPropValue("hrm_kqreport","zzrq_fieldid");
|
||
String zzrq = getWorkCusFieldValue(userid,zzrq_fieldid);
|
||
if(zzrq != null && !"".equals(zzrq)){
|
||
result = zzrq;
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 异动日期
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static String getTransactionDate(String fromdate,String todate,String userid){
|
||
String result = "";
|
||
RecordSet rs = new RecordSet();
|
||
rs.executeQuery("select top 1 ydsj from formtable_main_75 where ygxm = ? and ydsj >= ? and ydsj <= ? order by ydsj desc",userid,fromdate,todate);
|
||
if(rs.next()){
|
||
result = Util.null2String(rs.getString("ydsj"));
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 快照 里的 字段信息
|
||
* @param type
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static String getSnapShotData(String type,String fromdate,String todate,String userid){
|
||
String result = "";
|
||
RecordSet rs = new RecordSet();
|
||
rs.executeQuery("select "+type+" from hrsa_hrm_snapshot where employee_id = ? and cast(snapshot_time as DATE) between ? and ? ",userid,fromdate,todate);
|
||
if(rs.next()){
|
||
result = Util.null2String(rs.getString(type));
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 日期范围内是否有异动
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static boolean checkHasTransactionDate(String fromdate,String todate,String userid){
|
||
boolean result = false;
|
||
RecordSet rs = new RecordSet();
|
||
rs.executeQuery("select top 1 ydsj from formtable_main_75 where ygxm = ? and ydsj >= ? and ydsj <= ? order by ydsj desc",userid,fromdate,todate);
|
||
if(rs.next()){
|
||
result = true;
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 离职日期
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static String getTerminationDate(String userid){
|
||
String result = "";
|
||
RecordSet rs = new RecordSet();
|
||
String lzrq_fieldid = rs.getPropValue("hrm_kqreport","lzrq_fieldid");
|
||
String lzrq = getWorkCusFieldValue(userid,lzrq_fieldid);
|
||
if(lzrq != null && !"".equals(lzrq)){
|
||
result = lzrq;
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 片区
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static String getArea(String fromdate,String todate,String userid){
|
||
String result = "";
|
||
RecordSet rs = new RecordSet();
|
||
String area_fieldid = rs.getPropValue("hrm_kqreport","area_fieldid");
|
||
//日期范围内是否有异动
|
||
boolean hasTransaction = checkHasTransactionDate(fromdate,todate,userid);
|
||
if(hasTransaction){
|
||
String fieldid = getSnapShotData(area_fieldid,fromdate,todate,userid);
|
||
result = new SubCompanyComInfo().getSubCompanyname(fieldid);
|
||
}else {
|
||
// 片区
|
||
rs.executeQuery("select distinct " + area_fieldid + " from cus_fielddata where scope='HrmCustomFieldByInfoType' and scopeid=-1 and id = ?", userid);
|
||
if (rs.next()) {
|
||
String areaid = Util.null2String(rs.getString(area_fieldid));
|
||
if (areaid != null && !"".equals(areaid)) {
|
||
result = new SubCompanyComInfo().getSubCompanyname(areaid);
|
||
}
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 分部
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static String getSubcompany(String fromdate,String todate,String userid){
|
||
String result = "";
|
||
RecordSet rs = new RecordSet();
|
||
//日期范围内是否有异动
|
||
boolean hasTransaction = checkHasTransactionDate(fromdate,todate,userid);
|
||
if(hasTransaction){
|
||
String fieldid = getSnapShotData("SUBCOMPANYID1",fromdate,todate,userid);
|
||
result = new SubCompanyComInfo().getSubCompanyname(fieldid);
|
||
}else {
|
||
rs.executeQuery("select subcompanyid1 from hrmresource where id = ?", userid);
|
||
if (rs.next()) {
|
||
String subcomid = Util.null2String(rs.getString("subcompanyid1"));
|
||
result = new SubCompanyComInfo().getSubCompanyname(subcomid);
|
||
}
|
||
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 部门
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static String getDepartment(String fromdate,String todate,String userid){
|
||
String result = "";
|
||
RecordSet rs = new RecordSet();
|
||
//日期范围内是否有异动
|
||
boolean hasTransaction = checkHasTransactionDate(fromdate,todate,userid);
|
||
if(hasTransaction){
|
||
String fieldid = getSnapShotData("DEPARTMENTID",fromdate,todate,userid);
|
||
result = new DepartmentComInfo().getDepartmentname(fieldid);
|
||
}else {
|
||
rs.executeQuery("select departmentid from hrmresource where id = ?", userid);
|
||
if (rs.next()) {
|
||
String subcomid = Util.null2String(rs.getString("departmentid"));
|
||
result = new DepartmentComInfo().getDepartmentname(subcomid);
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 岗位名称
|
||
* @param areaid
|
||
* @return
|
||
*/
|
||
public static String getPositionName(String areaid){
|
||
String result = "";
|
||
RecordSet rs = new RecordSet();
|
||
rs.executeQuery("select * from uf_xcbz where id = ?",areaid);
|
||
if(rs.next()){
|
||
result = Util.null2String(rs.getString("gwmc"));
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 岗位名称
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static String getPosition(String fromdate,String todate,String userid){
|
||
String result = "";
|
||
RecordSet rs = new RecordSet();
|
||
String position_fieldid = rs.getPropValue("hrm_kqreport","position_fieldid");
|
||
//日期范围内是否有异动
|
||
boolean hasTransaction = checkHasTransactionDate(fromdate,todate,userid);
|
||
if(hasTransaction){
|
||
String fieldid = getSnapShotData("FIELD128",fromdate,todate,userid);
|
||
result = getPositionName(fieldid);
|
||
}else {
|
||
// 岗位名称
|
||
rs.executeQuery("select distinct " + position_fieldid + " from cus_fielddata where scope='HrmCustomFieldByInfoType' and scopeid=-1 and id = ?", userid);
|
||
if (rs.next()) {
|
||
String positionid = Util.null2String(rs.getString(position_fieldid));
|
||
if (positionid != null && !"".equals(positionid)) {
|
||
result = getPositionName(positionid);
|
||
}
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 职等职级 id
|
||
* @param userid
|
||
*/
|
||
public static int getPositionRankId(String fromdate,String todate,String userid){
|
||
int result = 0;
|
||
RecordSet rs = new RecordSet();
|
||
//日期范围内是否有异动
|
||
boolean hasTransaction = checkHasTransactionDate(fromdate,todate,userid);
|
||
if(hasTransaction){
|
||
String fieldid = getSnapShotData("FIELD1",fromdate,todate,userid);
|
||
if (fieldid != null && !"".equals(fieldid)) {
|
||
result = Integer.parseInt(fieldid.split("_")[1]);
|
||
}
|
||
}else {
|
||
rs.executeQuery("select field1 from cus_fielddata where scope='HrmCustomFieldByInfoType' and scopeid=-1 and field1 is not null and field1 <> '' and id = ?", userid);
|
||
if (rs.next()) {
|
||
String field1 = Util.null2String(rs.getString("field1"));
|
||
if (field1 != null && !"".equals(field1)) {
|
||
result = Integer.parseInt(field1.split("_")[1]);
|
||
}
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 岗位职级
|
||
* @param mxid
|
||
* @return
|
||
*/
|
||
public static int getPositionRank(int mxid){
|
||
int result = 0;
|
||
RecordSet rs = new RecordSet();
|
||
rs.executeQuery("select gwzj from uf_zdzj_new where id = ?",mxid);
|
||
if(rs.next()){
|
||
result = Util.getIntValue(rs.getString("gwzj"));
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 应出勤天数
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static double getWorkDays(String fromdate,String todate,String userid){
|
||
double result = 0.00;
|
||
int positionRank = getPositionRank(getPositionRankId(fromdate,todate,userid));
|
||
// 对于职级为1和2的员工,应出勤天数默认为当月自然日的总天数
|
||
// 对于不是这两个职级的员工,应出勤天数为:应出勤天数+法定节假日天数;若当月无法定节假日,就默认应出勤天数
|
||
if(positionRank == 1 || positionRank == 2 || positionRank == 0){
|
||
result = Double.valueOf(getDays(fromdate,todate));
|
||
}else{
|
||
result = Double.valueOf(getSpecialWorkDays(fromdate,todate,userid));
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 应出勤天数为:应出勤天数+法定节假日天数;若当月无法定节假日,就默认应出勤天数
|
||
* 周一到周五的天数 + 周六周日的调配工作日 - 周一到周五的调配休息日 + 周六周日的公众假日 = 最终的天数
|
||
* @param fromDate
|
||
* @param toDate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static String getSpecialWorkDays(String fromDate,String toDate,String userid){
|
||
String result = "0";
|
||
RecordSet rs = new RecordSet();
|
||
//
|
||
String groupid = rs.getPropValue("hrm_kqreport","the_top_groupid");
|
||
// 周六或周日天数
|
||
String weekdays = "0";
|
||
// 周一到周五天数
|
||
String workdays = "0";
|
||
// 调配休息日天数
|
||
String allocateRestDays = "0";
|
||
// 调配工作日天数
|
||
String allocateWorkDays = "0";
|
||
// 格式化日期
|
||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||
|
||
// rs.executeQuery("select distinct groupid,kqdate from kq_format_total " +
|
||
// " where resourceid = ? and kqdate >= ? and kqdate <= ?",userid,fromDate,toDate);
|
||
// while(rs.next()){
|
||
// //
|
||
// String dateString = Util.null2String(rs.getString("kqdate"));
|
||
// // 是 周六或 周日
|
||
// if (isSaturdayOrSunday(dateString)) {
|
||
// //是调配工作日
|
||
// if (isAllocateWorkDay(groupid, dateString)) {
|
||
// allocateWorkDays = floatAdd(allocateWorkDays,"1");
|
||
// }
|
||
// //是公众假日
|
||
// if(isAllocateHolidayDay(groupid, dateString)){
|
||
// allocateWorkDays = floatAdd(allocateWorkDays,"1");
|
||
// }
|
||
// } else {
|
||
// // 是 调配休息日
|
||
// if(isAllocateRestDay(groupid,dateString)){
|
||
// allocateRestDays = floatAdd(allocateRestDays,"1");
|
||
// }
|
||
// workdays = floatAdd(workdays,"1");
|
||
// }
|
||
// }
|
||
|
||
String[] dateStartArr = parseDate(fromDate);
|
||
String[] dateEndtArr = parseDate(toDate);
|
||
LocalDate startDate = LocalDate.of(Integer.parseInt(dateStartArr[0]), Integer.parseInt(dateStartArr[1]), Integer.parseInt(dateStartArr[2]));
|
||
LocalDate endDate = LocalDate.of(Integer.parseInt(dateEndtArr[0]), Integer.parseInt(dateEndtArr[1]), Integer.parseInt(dateEndtArr[2]));
|
||
// 遍历日期范围
|
||
for (LocalDate date = startDate; !date.isAfter(endDate); date = date.plusDays(1)) {
|
||
// 输出格式化后的日期字符串
|
||
String dateString = date.format(formatter);
|
||
// 是 周六或 周日
|
||
if (isSaturdayOrSunday(dateString)) {
|
||
//是调配工作日
|
||
if (isAllocateWorkDay(groupid, dateString)) {
|
||
allocateWorkDays = floatAdd(allocateWorkDays,"1");
|
||
}
|
||
//是公众假日
|
||
if(isAllocateHolidayDay(groupid, dateString)){
|
||
allocateWorkDays = floatAdd(allocateWorkDays,"1");
|
||
}
|
||
} else {
|
||
// 是 调配休息日
|
||
if(isAllocateRestDay(groupid,dateString)){
|
||
allocateRestDays = floatAdd(allocateRestDays,"1");
|
||
}
|
||
workdays = floatAdd(workdays,"1");
|
||
}
|
||
}
|
||
|
||
result = floatAdd(result,floatSubtract(floatAdd(workdays,allocateWorkDays),allocateRestDays));
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 薪酬调整日期、转正日期、入职日期
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static String getSalaryAdjustDate(String fromdate,String todate,String userid){
|
||
String result = "";
|
||
RecordSet rs = new RecordSet();
|
||
RecordSet rs1 = new RecordSet();
|
||
RecordSet rs2 = new RecordSet();
|
||
String txrq = "";
|
||
String zzrq = "";
|
||
String rzrq = "";
|
||
rs.executeQuery("select txrq from uf_ygxcda where yg = ? and txrq >= ? and txrq <= ? and dxyy != '入职' ",userid,fromdate,todate);
|
||
if(rs.next()){
|
||
txrq = Util.null2String(rs.getString("txrq"));
|
||
}
|
||
rs1.executeQuery("select shjg as zzrq from uf_ygzzxx where lczt = '2' and xm = ? ",userid);
|
||
if(rs1.next()){
|
||
zzrq = Util.null2String(rs1.getString("zzrq"));
|
||
}
|
||
rs2.executeQuery("select companystartdate from hrmresource where id = ?",userid);
|
||
if(rs2.next()){
|
||
rzrq = Util.null2String(rs2.getString("companystartdate"));
|
||
}
|
||
if(txrq != null && !"".equals(txrq)){
|
||
result = txrq;
|
||
}else if(zzrq != null && !"".equals(zzrq)){
|
||
result = zzrq;
|
||
}else if(rzrq != null && !"".equals(rzrq)){
|
||
result = rzrq;
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 指定假期的时长
|
||
* @param type
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static String getLeaveDaysBefore(int type,String fromdate,String todate,String userid){
|
||
String result = "0";
|
||
RecordSet rs = new RecordSet();
|
||
String halfdays = "0";
|
||
String halfbackdays = "0";
|
||
// 假期 时长
|
||
rs.executeQuery("select sum(duration) as count from kq_flow_split_leave where belongdate >= ? and belongdate < ? and newleavetype in ("+ type +") and resourceid = ? ",fromdate,todate,userid);
|
||
while(rs.next()){
|
||
halfdays = Util.null2o(rs.getString("count"));
|
||
}
|
||
// 销假时长
|
||
rs.executeQuery("select sum(duration) as count from kq_flow_split_leaveback where belongdate >= ? and belongdate < ? and newleavetype in ("+ type +") and resourceid = ? ",fromdate,todate,userid);
|
||
while(rs.next()){
|
||
halfbackdays = Util.null2o(rs.getString("count"));
|
||
}
|
||
result = floatSubtract(halfdays,halfbackdays);
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 指定假期的时长
|
||
* @param type
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static String getLeaveDaysAfter(int type,String fromdate,String todate,String userid){
|
||
String result = "0";
|
||
RecordSet rs = new RecordSet();
|
||
String halfdays = "0";
|
||
String halfbackdays = "0";
|
||
// 假期 时长
|
||
rs.executeQuery("select sum(duration) as count from kq_flow_split_leave where belongdate >= ? and belongdate <= ? and newleavetype in ("+ type +") and resourceid = ? ",fromdate,todate,userid);
|
||
while(rs.next()){
|
||
halfdays = Util.null2o(rs.getString("count"));
|
||
}
|
||
// 销假时长
|
||
rs.executeQuery("select sum(duration) as count from kq_flow_split_leaveback where belongdate >= ? and belongdate <= ? and newleavetype in ("+ type +") and resourceid = ? ",fromdate,todate,userid);
|
||
while(rs.next()){
|
||
halfbackdays = Util.null2o(rs.getString("count"));
|
||
}
|
||
result = floatSubtract(halfdays,halfbackdays);
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 哺乳假的假期的时长
|
||
* @param type
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static String getBreastfeedLeaveDays(int type,String fromdate,String todate,String userid){
|
||
String result = "0";
|
||
RecordSet rs1 = new RecordSet();
|
||
String breastfeeddays = "0";
|
||
String breastfeedbackdays = "0";
|
||
//班次id
|
||
String serialid = getSerialId(fromdate,todate,userid);
|
||
String serialHours = getHoursBySerial(serialid);
|
||
|
||
// 哺乳假 时长
|
||
rs1.executeQuery("select sum(duration) as count from kq_flow_split_leave where belongDate >= ? and belongdate <= ? and newleavetype in ("+ type +") and resourceid = ? group by resourceid",fromdate,todate,userid);
|
||
while(rs1.next()){
|
||
breastfeeddays = Util.null2o(rs1.getString("count"));
|
||
}
|
||
// 哺乳假 销假时长
|
||
rs1.executeQuery("select sum(duration) as count from kq_flow_split_leave where belongDate >= ? and belongdate <= ? and newleavetype in ("+ type +") and resourceid = ? group by resourceid",fromdate,todate,userid);
|
||
while(rs1.next()){
|
||
breastfeedbackdays = Util.null2o(rs1.getString("count"));
|
||
}
|
||
String breastdays = floatSubtract(breastfeeddays,breastfeedbackdays);
|
||
|
||
if(floatCompare(serialHours,"0") > 0) {
|
||
String breadt_days = floatDivide(breastdays, serialHours);
|
||
result = floatAdd(result, breadt_days);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取班次对应的工作时长 分钟数 转换为 小时
|
||
* @param serialid
|
||
* @return
|
||
*/
|
||
public static String getHoursBySerial(String serialid){
|
||
String result = "";
|
||
RecordSet rs = new RecordSet();
|
||
rs.executeQuery("select * from kq_ShiftManagement where id=?",serialid);
|
||
if(rs.next()) {
|
||
String worktime = Util.null2o(rs.getString("worktime"));
|
||
result = floatDivide(worktime,"60");
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 实际出勤天数(薪酬调整前)
|
||
* 对于职级为1和2的员工,实际出勤天数(标准)+带薪假(病、年、产、陪产、婚、丧、探亲、哺乳、调休)+迟到小时数(换算成班次所在天数)-每次漏签、严重迟到、严重早退 计0.5天旷工+休息班次
|
||
* 对于不是这两个职级的员工,实际出勤天数(标准)+带薪假(病、年、产、陪产、婚、丧、探亲、哺乳、调休)+迟到小时数(换算成班次所在天数)-每次漏签、严重迟到、严重早退 计0.5天旷工+公众假日(当前日期范围内要有班次的)
|
||
* 病假 按半天请假
|
||
* 年假 按半天请假
|
||
* 产假 按半天请假
|
||
* 陪产假 按半天请假
|
||
* 婚假 按半天请假
|
||
* 丧假 按半天请假
|
||
* 探亲假 按半天请假
|
||
* 哺乳假 按小时请假
|
||
* 调休假 按半天请假
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static double getAttendDaysBeforeSalary(String fromdate,String todate,String userid){
|
||
double result = 0.00;
|
||
RecordSet rs = new RecordSet();
|
||
String attendancedays = "0";
|
||
String publicHolidays = "0";
|
||
// 入职日期
|
||
String companystartdate = getCompanyStartDate(userid);
|
||
int positionRank = getPositionRank(getPositionRankId(fromdate,todate,userid));
|
||
// 薪资调整日期
|
||
String salaryAdjustDate = getSalaryAdjustDate(fromdate,todate,userid);
|
||
if(salaryAdjustDate != null && !"".equals(salaryAdjustDate)){
|
||
if(belongCalendarBefore(salaryAdjustDate,fromdate,todate)) {
|
||
// 实际出勤天数(标准)
|
||
rs.executeQuery("select sum(attendancedays)as days from kq_format_total " +
|
||
" where resourceid = ? and kqdate >= ? and kqdate < ? and attendanceMins is not null and attendanceMins > 0 and absenteeismmins = 0", userid, fromdate, salaryAdjustDate);
|
||
while (rs.next()) {
|
||
attendancedays = Util.null2o(rs.getString("days"));
|
||
}
|
||
rs.writeLog("========= 实际出勤天数(薪酬调整前) 实际出勤天数 ======== "+ attendancedays);
|
||
|
||
// 法定(公众假日)天数
|
||
rs.executeQuery("select distinct groupid from kq_format_total " +
|
||
" where resourceid = ? and kqdate >= ? and kqdate < ?", userid, fromdate, todate);
|
||
while (rs.next()) {
|
||
String groupid = Util.null2String(rs.getString("groupid"));
|
||
// 法定(公众假日)天数
|
||
publicHolidays = getPublicHolidays(companystartdate, fromdate, salaryAdjustDate, groupid, userid);
|
||
}
|
||
rs.writeLog("========= 实际出勤天数(薪酬调整前) 法定(公众假日)天数 ======== "+ publicHolidays);
|
||
|
||
// 休息班 天数
|
||
String restdays = getRestSerialDaysBefore(fromdate, salaryAdjustDate, userid);
|
||
|
||
rs.writeLog("========= 实际出勤天数(薪酬调整前) 休息班 天数 ======== "+ restdays);
|
||
|
||
// 假期 天数
|
||
String attendLeaveDays = getAttendLeaveDaysBefore(fromdate, salaryAdjustDate, userid);
|
||
|
||
rs.writeLog("========= 实际出勤天数(薪酬调整前) 假期 天数 ======== "+ attendLeaveDays);
|
||
|
||
String days = floatAdd(attendancedays, attendLeaveDays);
|
||
|
||
// // 迟到 天数
|
||
// String latedays = getLateDaysBefore(fromdate, salaryAdjustDate, userid);
|
||
// days = floatAdd(days, latedays);
|
||
//
|
||
// // 早退 天数
|
||
// String leaveearlydays = getLeaveEarlyDaysBefore(fromdate, salaryAdjustDate, userid);
|
||
// days = floatAdd(days, leaveearlydays);
|
||
|
||
// 每次漏签、 计0.5天旷工 天数
|
||
String forgotdays = String.valueOf(getAbsenteeismDaysCountBeforeSalary(fromdate, salaryAdjustDate, userid));
|
||
days = floatSubtract(days, forgotdays);
|
||
|
||
// // 严重迟到/严重早退 天数 计0.5天旷工 天数
|
||
// String gravelateleavedays = String.valueOf(getGraveBeLateLeaveEarlyDaysBefore(fromdate, salaryAdjustDate, userid));
|
||
// days = floatSubtract(days, gravelateleavedays);
|
||
|
||
// 对于职级为1和2的员工,实际出勤天数(标准)+带薪假(病、年、产、陪产、婚、丧、探亲、哺乳、调休)+迟到小时数(换算成班次所在天数)-漏签次数*0.5+休息班次
|
||
// 对于不是这两个职级的员工,实际出勤天数(标准)+带薪假(病、年、产、陪产、婚、丧、探亲、哺乳、调休)+迟到小时数(换算成班次所在天数)-漏签次数*0.5+公众假日(当前日期范围内要有班次的)
|
||
if (positionRank == 1 || positionRank == 2) {
|
||
result = Double.valueOf(floatAdd(days,restdays));
|
||
} else if (positionRank == 0) {
|
||
result = Double.valueOf(floatSubtract(attendLeaveDays, forgotdays));
|
||
} else {
|
||
result = Double.valueOf(floatAdd(days, publicHolidays));
|
||
}
|
||
}
|
||
}
|
||
if(result < 0){
|
||
result = 0.00;
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 实际出勤天数(薪酬调整后)
|
||
* 对于职级为1和2的员工,实际出勤天数(标准)+带薪假(病、年、产、陪产、婚、丧、探亲、哺乳、调休)+迟到小时数(换算成班次所在天数)-漏签次数*0.5+休息班次
|
||
* 对于不是这两个职级的员工,实际出勤天数(标准)+带薪假(病、年、产、陪产、婚、丧、探亲、哺乳、调休)+迟到小时数(换算成班次所在天数)-漏签次数*0.5+公众假日(当前日期范围内要有班次的)
|
||
* 病假 按半天请假
|
||
* 年假 按半天请假
|
||
* 产假 按半天请假
|
||
* 陪产假 按半天请假
|
||
* 婚假 按半天请假
|
||
* 丧假 按半天请假
|
||
* 探亲假 按半天请假
|
||
* 哺乳假 按小时请假
|
||
* 调休假 按半天请假
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static double getAttendDaysAfterSalary(String fromdate,String todate,String userid){
|
||
double result = 0.00;
|
||
RecordSet rs = new RecordSet();
|
||
String attendancedays = "0";
|
||
String publicHolidays = "0";
|
||
// 应出勤天数
|
||
double requiredworkdays = 0.00;
|
||
int positionRank = getPositionRank(getPositionRankId(fromdate,todate,userid));
|
||
// 入职日期
|
||
String companystartdate = getCompanyStartDate(userid);
|
||
String salaryattencedays = "0";
|
||
rs.executeQuery("select sum(attendancedays)as days from kq_format_total " +
|
||
" where resourceid = ? and kqdate >= ? and kqdate <= ? and attendanceMins is not null and attendanceMins > 0 and absenteeismmins = 0",userid,fromdate,todate);
|
||
while(rs.next()){
|
||
attendancedays = Util.null2o(rs.getString("days"));
|
||
}
|
||
// 应出勤天数
|
||
requiredworkdays = getWorkDays(fromdate, todate, userid);
|
||
// 薪资调整日期
|
||
String salaryAdjustDate = getSalaryAdjustDate(fromdate,todate,userid);
|
||
if(salaryAdjustDate != null && !"".equals(salaryAdjustDate)){
|
||
if(belongCalendar(salaryAdjustDate,fromdate,todate)) {
|
||
rs.executeQuery("select sum(attendancedays)as days from kq_format_total " +
|
||
" where resourceid = ? and kqdate >= ? and kqdate <= ? and attendanceMins is not null and attendanceMins > 0 and absenteeismmins = 0", userid, salaryAdjustDate, todate);
|
||
while (rs.next()) {
|
||
salaryattencedays = Util.null2o(rs.getString("days"));
|
||
}
|
||
// 法定(公众假日)天数
|
||
rs.executeQuery("select distinct groupid from kq_format_total " +
|
||
" where resourceid = ? and kqdate >= ? and kqdate <= ?", userid, fromdate, todate);
|
||
while (rs.next()) {
|
||
String groupid = Util.null2String(rs.getString("groupid"));
|
||
// 法定(公众假日)天数
|
||
publicHolidays = getPublicHolidays(companystartdate, salaryAdjustDate, todate, groupid, userid);
|
||
}
|
||
// 休息班 天数
|
||
String restdays = getRestSerialDaysAfter(salaryAdjustDate, todate, userid);
|
||
|
||
// 假期 天数
|
||
String attendLeaveDays = getAttendLeaveDaysAfter(salaryAdjustDate, todate, userid);
|
||
|
||
String days = floatAdd(salaryattencedays, attendLeaveDays);
|
||
|
||
// // 迟到 天数
|
||
// String latedays = getLateDaysAfter(salaryAdjustDate, todate, userid);
|
||
// days = floatAdd(days, latedays);
|
||
//
|
||
// // 早退 天数
|
||
// String leaveearlydays = getLeaveEarlyDaysAfter(fromdate, salaryAdjustDate, userid);
|
||
// days = floatAdd(days, leaveearlydays);
|
||
|
||
// 漏签 天数
|
||
String forgotdays = String.valueOf(getAbsenteeismDaysCountBeforeSalary(salaryAdjustDate, todate, userid));
|
||
days = floatSubtract(days, forgotdays);
|
||
|
||
// // 严重迟到/严重早退 天数
|
||
// String gravelateleavedays = String.valueOf(getGraveBeLateLeaveEarlyDaysAfter(salaryAdjustDate, todate, userid));
|
||
// days = floatSubtract(days, gravelateleavedays);
|
||
|
||
if (positionRank == 1 || positionRank == 2) {
|
||
result = Double.valueOf(floatAdd(days,restdays));
|
||
} else {
|
||
if(positionRank == 0){
|
||
result = Double.valueOf(days);
|
||
}else {
|
||
result = Double.valueOf(floatAdd(days, publicHolidays));
|
||
}
|
||
}
|
||
}else{
|
||
// 应出勤天数
|
||
requiredworkdays = getWorkDays(fromdate,todate,userid);
|
||
|
||
// 法定(公众假日)天数
|
||
rs.executeQuery("select distinct groupid from kq_format_total " +
|
||
" where resourceid = ? and kqdate >= ? and kqdate <= ?",userid,fromdate,todate);
|
||
while(rs.next()){
|
||
String groupid = Util.null2String(rs.getString("groupid"));
|
||
// 法定(公众假日)天数
|
||
publicHolidays = getPublicHolidays(companystartdate,fromdate,todate,groupid,userid);
|
||
}
|
||
// 休息班 天数
|
||
String restdays = getRestSerialDaysAfter(fromdate,todate,userid);
|
||
|
||
// 假期 天数
|
||
String attendLeaveDays = getAttendLeaveDaysAfter(fromdate,todate,userid);
|
||
|
||
String days = floatAdd(attendancedays,attendLeaveDays);
|
||
|
||
// // 迟到 天数
|
||
// String latedays = getLateDaysAfter(fromdate,todate,userid);
|
||
// days = floatAdd(days,latedays);
|
||
//
|
||
// // 早退 天数
|
||
// String leaveearlydays = getLeaveEarlyDaysAfter(fromdate,todate,userid);
|
||
// days = floatAdd(days,leaveearlydays);
|
||
|
||
// 漏签 天数
|
||
String forgotdays = String.valueOf(getAbsenteeismDaysCountBeforeSalary(fromdate,todate,userid));
|
||
days = floatSubtract(days,forgotdays);
|
||
|
||
// // 严重迟到/严重早退 天数
|
||
// String gravelateleavedays = String.valueOf(getGraveBeLateLeaveEarlyDaysAfter(fromdate,todate,userid));
|
||
// days = floatSubtract(days,gravelateleavedays);
|
||
|
||
if(positionRank == 1 || positionRank == 2){
|
||
result = Double.valueOf(floatAdd(days,restdays));
|
||
}else{
|
||
if(positionRank == 0){
|
||
result = Double.valueOf(days);
|
||
}else {
|
||
result = Double.valueOf(floatAdd(days, publicHolidays));
|
||
}
|
||
}
|
||
}
|
||
}else{
|
||
// 应出勤天数
|
||
requiredworkdays = getWorkDays(fromdate,todate,userid);
|
||
|
||
// 法定(公众假日)天数
|
||
rs.executeQuery("select distinct groupid from kq_format_total " +
|
||
" where resourceid = ? and kqdate >= ? and kqdate <= ?",userid,fromdate,todate);
|
||
while(rs.next()){
|
||
String groupid = Util.null2String(rs.getString("groupid"));
|
||
// 法定(公众假日)天数
|
||
publicHolidays = getPublicHolidays(companystartdate,fromdate,todate,groupid,userid);
|
||
}
|
||
// 休息班 天数
|
||
String restdays = getRestSerialDaysAfter(fromdate,todate,userid);
|
||
|
||
// 假期 天数
|
||
String attendLeaveDays = getAttendLeaveDaysAfter(fromdate,todate,userid);
|
||
|
||
String days = floatAdd(attendancedays,attendLeaveDays);
|
||
|
||
// // 迟到 天数
|
||
// String latedays = getLateDaysAfter(fromdate,todate,userid);
|
||
// days = floatAdd(days,latedays);
|
||
//
|
||
// // 早退 天数
|
||
// String leaveearlydays = getLeaveEarlyDaysAfter(fromdate,todate,userid);
|
||
// days = floatAdd(days,leaveearlydays);
|
||
|
||
// 漏签 天数
|
||
String forgotdays = String.valueOf(getAbsenteeismDaysCountBeforeSalary(fromdate,todate,userid));
|
||
days = floatSubtract(days,forgotdays);
|
||
|
||
// // 严重迟到/严重早退 天数
|
||
// String gravelateleavedays = String.valueOf(getGraveBeLateLeaveEarlyDaysAfter(fromdate,todate,userid));
|
||
// days = floatSubtract(days,gravelateleavedays);
|
||
|
||
if(positionRank == 1 || positionRank == 2){
|
||
result = Double.valueOf(floatAdd(days,restdays));
|
||
}else{
|
||
if(positionRank == 0){
|
||
result = Double.valueOf(days);
|
||
}else {
|
||
result = Double.valueOf(floatAdd(days, publicHolidays));
|
||
}
|
||
}
|
||
}
|
||
String result_int = String.valueOf((int)result);
|
||
String result_int1 = floatAdd(String.valueOf(result_int),"0.1");
|
||
String result_int5 = floatAdd(String.valueOf(result_int),"0.5");
|
||
String resultadd1 = floatAdd(String.valueOf(result_int),"1");
|
||
|
||
//实际出勤天数(薪酬调整前)
|
||
double attenddaysbeforesalary = getAttendDaysBeforeSalary(fromdate,todate,userid);
|
||
// 大于 应出勤天数
|
||
if(result > requiredworkdays){
|
||
result = requiredworkdays;
|
||
}else{
|
||
if(attenddaysbeforesalary+result > requiredworkdays){
|
||
double chae = attenddaysbeforesalary+result-requiredworkdays;
|
||
result = result - chae;
|
||
}
|
||
}
|
||
if(result < 0){
|
||
result = 0.00;
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 判断 当天是否请了产假
|
||
* @param date
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static boolean checkIsRestLeaveDay(String date,String userid){
|
||
boolean bool = false;
|
||
RecordSet rs = new RecordSet();
|
||
// 产假
|
||
String maternity_leave_id = rs.getPropValue("hrm_kqreport","maternity_leave_id");
|
||
rs.executeQuery("select id from kq_flow_split_leave where belongdate = ? and newleavetype in ("+ maternity_leave_id +") and resourceid = ? ",date,userid);
|
||
while(rs.next()){
|
||
bool = true;
|
||
}
|
||
return bool;
|
||
}
|
||
|
||
/**
|
||
* 获取 请假天数
|
||
*
|
||
* 病假 按半天请假
|
||
* 年假 按半天请假
|
||
* 产假 按半天请假
|
||
* 陪产假 按半天请假
|
||
* 婚假 按半天请假
|
||
* 丧假 按半天请假
|
||
* 探亲假 按半天请假
|
||
* 哺乳假 按小时请假
|
||
* 调休假 按半天请假
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static String getAttendLeaveDaysBefore(String fromdate,String todate,String userid){
|
||
String result = "0";
|
||
RecordSet rs = new RecordSet();
|
||
RecordSet rs1 = new RecordSet();
|
||
String halfdays = "0";
|
||
String halfbackdays = "0";
|
||
String breastfeeddays = "0";
|
||
String breastfeedbackdays = "0";
|
||
// 病假 年假 产假 陪产假 婚假 丧假 探亲假 调休假
|
||
String halfday_leave_ids = rs.getPropValue("hrm_kqreport","halfday_leave_ids");
|
||
// 哺乳假
|
||
String breastfeed_leave_id = rs.getPropValue("hrm_kqreport","breastfeed_leave_id");
|
||
|
||
// 病假 年假 陪产假 婚假 丧假 探亲假 时长
|
||
rs.executeQuery("select sum(duration) as count from kq_flow_split_leave where belongdate >= ? and belongdate < ? and newleavetype in ("+ halfday_leave_ids +") and resourceid = ? ",fromdate,todate,userid);
|
||
while(rs.next()){
|
||
halfdays = Util.null2o(rs.getString("count"));
|
||
}
|
||
|
||
// 病假 年假 陪产假 婚假 丧假 探亲假 销假时长
|
||
rs.executeQuery("select sum(duration) as count from kq_flow_split_leaveback where belongdate >= ? and belongdate < ? and newleavetype in ("+ halfday_leave_ids +") and resourceid = ? ",fromdate,todate,userid);
|
||
while(rs.next()){
|
||
halfbackdays = Util.null2o(rs.getString("count"));
|
||
}
|
||
|
||
result = floatSubtract(halfdays,halfbackdays);
|
||
|
||
// //班次id
|
||
// String serialid = getSerialId(fromdate,todate,userid);
|
||
// String serialHours = getHoursBySerial(serialid);
|
||
//
|
||
// // 哺乳假 时长
|
||
// rs1.executeQuery("select sum(duration) as count from kq_flow_split_leave where belongDate >= ? and belongdate < ? and newleavetype in ("+ breastfeed_leave_id +") and resourceid = ? group by resourceid",fromdate,todate,userid);
|
||
// while(rs1.next()){
|
||
// breastfeeddays = Util.null2o(rs1.getString("count"));
|
||
// }
|
||
// // 哺乳假 销假时长
|
||
// rs1.executeQuery("select sum(duration) as count from kq_flow_split_leave where belongDate >= ? and belongdate < ? and newleavetype in ("+ breastfeed_leave_id +") and resourceid = ? group by resourceid",fromdate,todate,userid);
|
||
// while(rs1.next()){
|
||
// breastfeedbackdays = Util.null2o(rs1.getString("count"));
|
||
// }
|
||
//
|
||
// String breastdays = floatSubtract(breastfeeddays,breastfeedbackdays);
|
||
//
|
||
// if(floatCompare(serialHours,"0") > 0){
|
||
// String breadt_days = floatDivide(breastdays,serialHours);
|
||
// result = floatAdd(result,breadt_days);
|
||
// }
|
||
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 请假天数
|
||
*
|
||
* 病假 按半天请假
|
||
* 年假 按半天请假
|
||
* 产假 按半天请假
|
||
* 陪产假 按半天请假
|
||
* 婚假 按半天请假
|
||
* 丧假 按半天请假
|
||
* 探亲假 按半天请假
|
||
* 哺乳假 按小时请假
|
||
* 调休假 按半天请假
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static String getAttendLeaveDaysAfter(String fromdate,String todate,String userid){
|
||
String result = "0";
|
||
RecordSet rs = new RecordSet();
|
||
RecordSet rs1 = new RecordSet();
|
||
String halfdays = "0";
|
||
String halfbackdays = "0";
|
||
String breastfeeddays = "0";
|
||
String breastfeedbackdays = "0";
|
||
// 病假 年假 产假 陪产假 婚假 丧假 探亲假 调休假
|
||
String halfday_leave_ids = rs.getPropValue("hrm_kqreport","halfday_leave_ids");
|
||
// 哺乳假
|
||
String breastfeed_leave_id = rs.getPropValue("hrm_kqreport","breastfeed_leave_id");
|
||
|
||
// 病假 年假 陪产假 婚假 丧假 探亲假 时长
|
||
rs.executeQuery("select sum(duration) as count from kq_flow_split_leave where belongdate >= ? and belongdate <= ? and newleavetype in ("+ halfday_leave_ids +") and resourceid = ? ",fromdate,todate,userid);
|
||
while(rs.next()){
|
||
halfdays = Util.null2o(rs.getString("count"));
|
||
}
|
||
|
||
// 病假 年假 陪产假 婚假 丧假 探亲假 销假时长
|
||
rs.executeQuery("select sum(duration) as count from kq_flow_split_leaveback where belongdate >= ? and belongdate <= ? and newleavetype in ("+ halfday_leave_ids +") and resourceid = ? ",fromdate,todate,userid);
|
||
while(rs.next()){
|
||
halfbackdays = Util.null2o(rs.getString("count"));
|
||
}
|
||
|
||
result = floatSubtract(halfdays,halfbackdays);
|
||
|
||
// //班次id
|
||
// String serialid = getSerialId(fromdate,todate,userid);
|
||
// String serialHours = getHoursBySerial(serialid);
|
||
//
|
||
// // 哺乳假 时长
|
||
// rs1.executeQuery("select sum(duration) as count from kq_flow_split_leave where belongDate >= ? and belongdate <= ? and newleavetype in ("+ breastfeed_leave_id +") and resourceid = ? group by resourceid",fromdate,todate,userid);
|
||
// while(rs1.next()){
|
||
// breastfeeddays = Util.null2o(rs1.getString("count"));
|
||
// }
|
||
// // 哺乳假 销假时长
|
||
// rs1.executeQuery("select sum(duration) as count from kq_flow_split_leaveback where belongDate >= ? and belongdate <= ? and newleavetype in ("+ breastfeed_leave_id +") and resourceid = ? group by resourceid",fromdate,todate,userid);
|
||
// while(rs1.next()){
|
||
// breastfeedbackdays = Util.null2o(rs1.getString("count"));
|
||
// }
|
||
//
|
||
// String breastdays = floatSubtract(breastfeeddays,breastfeedbackdays);
|
||
//
|
||
// if(floatCompare(serialHours,"0") > 0){
|
||
// String breadt_days = floatDivide(breastdays,serialHours);
|
||
// result = floatAdd(result,breadt_days);
|
||
// }
|
||
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取哺乳假分钟数
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static int getBreastMins(String fromdate,String todate,String userid){
|
||
int mins = 0;
|
||
RecordSet rs = new RecordSet();
|
||
RecordSet rs1 = new RecordSet();
|
||
// 哺乳假
|
||
String breastfeed_leave_id = rs1.getPropValue("hrm_kqreport","breastfeed_leave_id");
|
||
double breastfeeddays = 0;
|
||
double breastfeedbackdays = 0;
|
||
|
||
// 哺乳假 时长
|
||
rs.executeQuery("select sum(duration) as count from kq_flow_split_leave where belongDate >= ? and belongdate <= ? and newleavetype in ("+ breastfeed_leave_id +") and resourceid = ? group by resourceid",fromdate,todate,userid);
|
||
while(rs.next()){
|
||
breastfeeddays = Util.getDoubleValue(rs.getString("count"),0);
|
||
}
|
||
// 哺乳假 销假时长
|
||
rs1.executeQuery("select sum(duration) as count from kq_flow_split_leaveback where belongDate >= ? and belongdate <= ? and newleavetype in ("+ breastfeed_leave_id +") and resourceid = ? group by resourceid",fromdate,todate,userid);
|
||
while(rs1.next()){
|
||
breastfeedbackdays = Util.getDoubleValue(rs1.getString("count"),0);
|
||
}
|
||
double breastdays = breastfeeddays-breastfeedbackdays;
|
||
if(breastdays > 0){
|
||
mins = (int)breastdays * 60;
|
||
}
|
||
return mins;
|
||
}
|
||
/**
|
||
* 获取 假期天数(调薪前)
|
||
* @param leavetype
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static double getBeforeSalaryLeaveDays(int leavetype,String fromdate,String todate,String userid){
|
||
double result = 0.00;
|
||
// 薪资调整日期
|
||
String salaryAdjustDate = getSalaryAdjustDate(fromdate,todate,userid);
|
||
if(salaryAdjustDate != null && !"".equals(salaryAdjustDate)){
|
||
if(belongCalendar(salaryAdjustDate,fromdate,todate)) {
|
||
String leavedays = getLeaveDaysBefore(leavetype, fromdate, salaryAdjustDate, userid);
|
||
result = Double.valueOf(leavedays);
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 假期天数(调薪后)
|
||
* @param leavetype
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static double getAfterSalaryLeaveDays(int leavetype,String fromdate,String todate,String userid){
|
||
double result = 0.00;
|
||
// 薪资调整日期
|
||
String salaryAdjustDate = getSalaryAdjustDate(fromdate,todate,userid);
|
||
if(salaryAdjustDate != null && !"".equals(salaryAdjustDate)){
|
||
if(belongCalendar(salaryAdjustDate,fromdate,todate)) {
|
||
String leavedays = getLeaveDaysAfter(leavetype, salaryAdjustDate, todate, userid);
|
||
result = Double.valueOf(leavedays);
|
||
}else{
|
||
String leavedays = getLeaveDaysAfter(leavetype, fromdate, todate, userid);
|
||
result = Double.valueOf(leavedays);
|
||
}
|
||
}else{
|
||
String leavedays = getLeaveDaysAfter(leavetype,fromdate,todate,userid);
|
||
result = Double.valueOf(leavedays);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 迟到 天数
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static String getLateDaysBefore(String fromdate,String todate,String userid){
|
||
String result = "0";
|
||
RecordSet rs = new RecordSet();
|
||
String serialid = getSerialId(fromdate,todate,userid);
|
||
String serial_hours = getHoursBySerial(serialid);
|
||
// 迟到
|
||
rs.executeQuery("select sum(belatemins) as count from kq_format_total where kqdate >= ? and kqdate < ? and resourceid = ? ",fromdate,todate,userid);
|
||
while(rs.next()){
|
||
String latemins = Util.null2o(rs.getString("count"));
|
||
String latehours = floatDivide(latemins,"60");
|
||
if(floatCompare(serial_hours,"0") > 0){
|
||
result = floatDivide(latehours,serial_hours);
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 迟到 天数
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static String getLateDaysAfter(String fromdate,String todate,String userid){
|
||
String result = "0";
|
||
RecordSet rs = new RecordSet();
|
||
String serialid = getSerialId(fromdate,todate,userid);
|
||
String serial_hours = getHoursBySerial(serialid);
|
||
// 迟到
|
||
rs.executeQuery("select sum(belatemins) as count from kq_format_total where kqdate >= ? and kqdate <= ? and resourceid = ? ",fromdate,todate,userid);
|
||
while(rs.next()){
|
||
String latemins = Util.null2o(rs.getString("count"));
|
||
String latehours = floatDivide(latemins,"60");
|
||
if(floatCompare(serial_hours,"0") > 0){
|
||
result = floatDivide(latehours,serial_hours);
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 早退 天数
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static String getLeaveEarlyDaysBefore(String fromdate,String todate,String userid){
|
||
String result = "0";
|
||
RecordSet rs = new RecordSet();
|
||
String serialid = getSerialId(fromdate,todate,userid);
|
||
String serial_hours = getHoursBySerial(serialid);
|
||
// 早退
|
||
rs.executeQuery("select sum(leaveearlymins) as count from kq_format_total where kqdate >= ? and kqdate < ? and resourceid = ? ",fromdate,todate,userid);
|
||
while(rs.next()){
|
||
String latemins = Util.null2o(rs.getString("count"));
|
||
String latehours = floatDivide(latemins,"60");
|
||
if(floatCompare(serial_hours,"0") > 0){
|
||
result = floatDivide(latehours,serial_hours);
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 早退 天数
|
||
* @param fromdate
|
||
* @param todate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static String getLeaveEarlyDaysAfter(String fromdate,String todate,String userid){
|
||
String result = "0";
|
||
RecordSet rs = new RecordSet();
|
||
String serialid = getSerialId(fromdate,todate,userid);
|
||
String serial_hours = getHoursBySerial(serialid);
|
||
// 早退
|
||
rs.executeQuery("select sum(leaveearlymins) as count from kq_format_total where kqdate >= ? and kqdate <= ? and resourceid = ? ",fromdate,todate,userid);
|
||
while(rs.next()){
|
||
String latemins = Util.null2o(rs.getString("count"));
|
||
String latehours = floatDivide(latemins,"60");
|
||
if(floatCompare(serial_hours,"0") > 0){
|
||
result = floatDivide(latehours,serial_hours);
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 休息班次 天数
|
||
* @param fromDate
|
||
* @param toDate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static String getRestSerialDaysBefore(String fromDate, String toDate,String userid){
|
||
String result = "0";
|
||
RecordSet rs = new RecordSet();
|
||
KQGroupMemberComInfo groupMemberComInfo = new KQGroupMemberComInfo();
|
||
String rest_serial_id = rs.getPropValue("hrm_kqreport","rest_serial_id");
|
||
String rest2_serial_id = rs.getPropValue("hrm_kqreport","rest2_serial_id");
|
||
rs.executeQuery("select count(resourceid) as count from kq_format_total where kqdate >= ? and kqdate < ? and resourceid = ? and serialid = ?",fromDate,toDate,userid,rest_serial_id);
|
||
while(rs.next()){
|
||
result = Util.null2o(rs.getString("count"));
|
||
}
|
||
rs.executeQuery("select * from kq_format_total " +
|
||
" where resourceid = ? and kqdate >= ? and kqdate <= ? and serialid = ?",userid,fromDate,toDate,rest2_serial_id);
|
||
while(rs.next()) {
|
||
String groupid = Util.null2String(rs.getString("groupid"));
|
||
String kqdate = Util.null2String(rs.getString("kqdate"));
|
||
KQGroupEntity kqGroupEntity = groupMemberComInfo.getUserKQGroupInfo(userid,kqdate);
|
||
if(kqGroupEntity != null) {
|
||
String kqtype = kqGroupEntity.getKqtype();
|
||
//固定班制
|
||
if ("1".equals(kqtype)) {
|
||
if (isHolidayOrRelaxDay(groupid, kqdate)) {
|
||
result = floatAdd(result, "1");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 休息班次 天数
|
||
* @param fromDate
|
||
* @param toDate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static String getRestSerialDaysAfter(String fromDate, String toDate,String userid){
|
||
String result = "0";
|
||
RecordSet rs = new RecordSet();
|
||
KQGroupMemberComInfo groupMemberComInfo = new KQGroupMemberComInfo();
|
||
String rest_serial_id = rs.getPropValue("hrm_kqreport","rest_serial_id");
|
||
String rest2_serial_id = rs.getPropValue("hrm_kqreport","rest2_serial_id");
|
||
rs.executeQuery("select * from kq_format_detail where kqdate >= ? and kqdate <= ? and resourceid = ? and serialid = ? ",fromDate,toDate,userid,rest_serial_id);
|
||
while(rs.next()){
|
||
String kqdate = Util.null2String(rs.getString("kqdate"));
|
||
//不是请了产假
|
||
if(!checkIsRestLeaveDay(kqdate,userid)){
|
||
result = floatAdd(result, "1");
|
||
}
|
||
}
|
||
rs.executeQuery("select * from kq_format_total " +
|
||
" where resourceid = ? and kqdate >= ? and kqdate <= ? and serialid = ?",userid,fromDate,toDate,rest2_serial_id);
|
||
while(rs.next()) {
|
||
String groupid = Util.null2String(rs.getString("groupid"));
|
||
String kqdate = Util.null2String(rs.getString("kqdate"));
|
||
KQGroupEntity kqGroupEntity = groupMemberComInfo.getUserKQGroupInfo(userid,kqdate);
|
||
if(kqGroupEntity!=null){
|
||
String kqtype = kqGroupEntity.getKqtype();
|
||
//固定班制
|
||
if("1".equals(kqtype)) {
|
||
if (isHolidayOrRelaxDay(groupid, kqdate)) {
|
||
//不是请了产假
|
||
if(!checkIsRestLeaveDay(kqdate,userid)){
|
||
result = floatAdd(result, "1");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 班次id
|
||
* @param fromDate
|
||
* @param toDate
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static String getSerialId(String fromDate, String toDate,String userid){
|
||
String result = "";
|
||
RecordSet rs = new RecordSet();
|
||
rs.executeQuery("select distinct a.serialid from kq_format_total a,kq_ShiftManagement b " +
|
||
" where a.serialid=b.id and a.resourceid = ? and a.kqdate >= ? and a.kqdate <= ? and b.is_rest=0 ",userid,fromDate,toDate);
|
||
while(rs.next()){
|
||
result = Util.null2String(rs.getString("serialid"));
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 判断 指定天数 是否是 公众假日 true 是 false 否
|
||
* @param groupid
|
||
* @param date
|
||
* @return
|
||
*/
|
||
public static boolean isHolidayOrRelaxDay(String groupid,String date){
|
||
boolean bool = false;
|
||
RecordSet rs = new RecordSet();
|
||
rs.executeQuery("select * from kq_HolidaySet where groupid=? and holidayDate=?",groupid,date);
|
||
while(rs.next()){
|
||
// 1-公众假日 2-调配工作日 3-调配休息日
|
||
int changeType = Util.getIntValue(rs.getString("changeType"));
|
||
if(changeType == 1 || changeType == 3){
|
||
bool = true;
|
||
}
|
||
}
|
||
return bool;
|
||
}
|
||
|
||
/**
|
||
* 判断 指定天数 是否是 调配休息日 true 是 false 否
|
||
* @param groupid
|
||
* @param date
|
||
* @return
|
||
*/
|
||
public static boolean isAllocateRestDay(String groupid,String date){
|
||
boolean bool = false;
|
||
RecordSet rs = new RecordSet();
|
||
rs.executeQuery("select * from kq_HolidaySet where groupid=? and holidayDate=?",groupid,date);
|
||
while(rs.next()){
|
||
// 1-公众假日 2-调配工作日 3-调配休息日
|
||
int changeType = Util.getIntValue(rs.getString("changeType"));
|
||
if(changeType == 3){
|
||
bool = true;
|
||
}
|
||
}
|
||
return bool;
|
||
}
|
||
|
||
/**
|
||
* 判断 指定天数 是否是 调配工作日 true 是 false 否
|
||
* @param groupid
|
||
* @param date
|
||
* @return
|
||
*/
|
||
public static boolean isAllocateWorkDay(String groupid,String date){
|
||
boolean bool = false;
|
||
RecordSet rs = new RecordSet();
|
||
rs.executeQuery("select * from kq_HolidaySet where groupid=? and holidayDate=?",groupid,date);
|
||
while(rs.next()){
|
||
// 1-公众假日 2-调配工作日 3-调配休息日
|
||
int changeType = Util.getIntValue(rs.getString("changeType"));
|
||
if(changeType == 2){
|
||
bool = true;
|
||
}
|
||
}
|
||
return bool;
|
||
}
|
||
|
||
/**
|
||
* 判断 指定天数 是否是 调配工作日 true 是 false 否
|
||
* @param groupid
|
||
* @param date
|
||
* @return
|
||
*/
|
||
public static boolean isAllocateHolidayDay(String groupid,String date){
|
||
boolean bool = false;
|
||
RecordSet rs = new RecordSet();
|
||
rs.executeQuery("select * from kq_HolidaySet where groupid=? and holidayDate=?",groupid,date);
|
||
while(rs.next()){
|
||
// 1-公众假日 2-调配工作日 3-调配休息日
|
||
int changeType = Util.getIntValue(rs.getString("changeType"));
|
||
if(changeType == 1){
|
||
bool = true;
|
||
}
|
||
}
|
||
return bool;
|
||
}
|
||
|
||
private static String[] parseDate(String date){
|
||
if (StringUtils.isEmpty(date)) {
|
||
return new String[]{"1990", "1", "1"};
|
||
}
|
||
try {
|
||
String[] split = date.split("-");
|
||
List<String> list = new ArrayList<>(Arrays.asList(split));
|
||
// 只有年
|
||
if (list.size() == 1) {
|
||
// 添加月
|
||
list.add("1");
|
||
// 添加日
|
||
list.add("1");
|
||
}
|
||
// 只有年月
|
||
else if (list.size() == 2) {
|
||
list.add("1");
|
||
}
|
||
return list.toArray(new String[]{});
|
||
}catch (Exception e){
|
||
e.printStackTrace();
|
||
}
|
||
return null;
|
||
}
|
||
|
||
/**
|
||
* 判断 日期是否是 周六 或 周日
|
||
* @param dateString
|
||
* @return
|
||
*/
|
||
public static boolean isSaturdayOrSunday(String dateString) {
|
||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
||
Date date = null;
|
||
boolean flag = false;
|
||
try {
|
||
date = format.parse(dateString);
|
||
Calendar cal = Calendar.getInstance();
|
||
cal.setTime(date);
|
||
int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
|
||
if(dayOfWeek == Calendar.SATURDAY || dayOfWeek == Calendar.SUNDAY){
|
||
flag = true;
|
||
}
|
||
} catch (ParseException e) {
|
||
e.printStackTrace();
|
||
}
|
||
return flag;
|
||
}
|
||
|
||
/**
|
||
* 判断一个时间是否在一个时间段内
|
||
*
|
||
* @param nowTimee 指定时间
|
||
* @param beginTimee 开始时间
|
||
* @param endTimee 结束时间
|
||
*/
|
||
public static boolean belongCalendarBefore(String nowTimee, String beginTimee, String endTimee) {
|
||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
||
Date nowTime = null;
|
||
Date beginTime = null;
|
||
Date endTime = null;
|
||
boolean b = false;
|
||
try {
|
||
nowTime = format.parse(nowTimee);
|
||
beginTime = format.parse(beginTimee);
|
||
endTime = format.parse(endTimee);
|
||
|
||
Calendar date = Calendar.getInstance();
|
||
date.setTime(nowTime);
|
||
Calendar begin = Calendar.getInstance();
|
||
begin.setTime(beginTime);
|
||
Calendar end = Calendar.getInstance();
|
||
end.setTime(endTime);
|
||
|
||
if(nowTimee.equals(endTimee)){
|
||
b = true;
|
||
}else if(date.after(begin) && date.before(end)){//在时间段内
|
||
b = true;
|
||
}
|
||
} catch (Exception ex) {
|
||
ex.printStackTrace();
|
||
}
|
||
return b;
|
||
}
|
||
|
||
/**
|
||
* 判断一个时间是否在一个时间段内
|
||
*
|
||
* @param nowTimee 指定时间
|
||
* @param beginTimee 开始时间
|
||
* @param endTimee 结束时间
|
||
*/
|
||
public static boolean belongCalendar(String nowTimee, String beginTimee, String endTimee) {
|
||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
||
Date nowTime = null;
|
||
Date beginTime = null;
|
||
Date endTime = null;
|
||
boolean b = false;
|
||
try {
|
||
nowTime = format.parse(nowTimee);
|
||
beginTime = format.parse(beginTimee);
|
||
endTime = format.parse(endTimee);
|
||
|
||
Calendar date = Calendar.getInstance();
|
||
date.setTime(nowTime);
|
||
Calendar begin = Calendar.getInstance();
|
||
begin.setTime(beginTime);
|
||
Calendar end = Calendar.getInstance();
|
||
end.setTime(endTime);
|
||
|
||
if(nowTimee.equals(endTimee) || nowTimee.equals(beginTimee)){
|
||
b = true;
|
||
}else if(date.after(begin) && date.before(end)){//在时间段内
|
||
b = true;
|
||
}
|
||
} catch (Exception ex) {
|
||
ex.printStackTrace();
|
||
}
|
||
return b;
|
||
}
|
||
|
||
}
|