3008 lines
176 KiB
Plaintext
3008 lines
176 KiB
Plaintext
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
|
||
<%@page import="weaver.general.Util"%>
|
||
<%@ page import="java.util.*" %>
|
||
<%@ page import="weaver.hrm.resource.ResourceComInfo" %>
|
||
<%@ page import="weaver.common.DateUtil" %>
|
||
<%@ page import="java.time.format.DateTimeFormatter" %>
|
||
<%@ page import="java.time.LocalDate" %>
|
||
<%@ page import="com.engine.kq.biz.chain.cominfo.ShiftInfoCominfoBean" %>
|
||
<%@ page import="com.engine.kq.biz.*" %>
|
||
<%@ page import="com.alibaba.fastjson.JSON" %>
|
||
<%@ page import="com.alibaba.fastjson.serializer.SerializerFeature" %>
|
||
<%@ page import="com.google.common.collect.Maps" %>
|
||
<%@ page import="weaver.attendance.service.OvertimeRuleComputingModeService" %>
|
||
<%@ page import="java.io.StringWriter" %>
|
||
<%@ page import="java.io.PrintWriter" %>
|
||
<%@ page import="com.engine.kq.entity.*" %>
|
||
<%@ page import="com.engine.kq.timer.KQOvertimeCardBean" %>
|
||
<%@ page import="com.engine.kq.wfset.bean.SplitBean" %>
|
||
<%@ page import="com.google.common.collect.Lists" %>
|
||
<%@ page import="weaver.conn.RecordSet" %>
|
||
<%@ page import="com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean" %>
|
||
<%@ page import="com.engine.kq.util.KQDurationCalculatorUtil" %>
|
||
<%@ page import="java.util.stream.Collectors" %>
|
||
<%@ page import="com.engine.kq.wfset.bean.OvertimeBalanceTimeBean" %>
|
||
<%@ page import="com.engine.kq.log.KQLog" %>
|
||
<%@ page import="java.text.SimpleDateFormat" %>
|
||
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page" />
|
||
<%
|
||
int sum = 0;
|
||
String userid = Util.null2String(request.getParameter("userid"));
|
||
String fromdate = Util.null2String(request.getParameter("fromdate"));
|
||
String todate = Util.null2String(request.getParameter("todate"));
|
||
|
||
Map<String,Object> serialInfoMap = getSerialInfo(userid,fromdate,false);
|
||
|
||
int commode = getComputingMode(userid,fromdate);
|
||
|
||
Map<String, Object> lsCheckInfoMaps = buildOvertime(userid, fromdate, todate, "考勤打卡生成加班.");
|
||
|
||
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||
|
||
LocalDate localFromDate = LocalDate.parse(fromdate);
|
||
LocalDate localToDate = LocalDate.parse(todate);
|
||
LocalDate preFromDate = localFromDate.minusDays(1);
|
||
LocalDate nextToDate = localToDate.plusDays(1);
|
||
|
||
String dates = "";
|
||
long betweenDays = nextToDate.toEpochDay() - preFromDate.toEpochDay();
|
||
for (int i = 0; i <= betweenDays; i++) {
|
||
LocalDate curLocalDate = preFromDate.plusDays(i);
|
||
String splitDate = curLocalDate.format(dateFormatter);
|
||
|
||
dates += splitDate +",";
|
||
}
|
||
|
||
|
||
Map<String,List<SplitBean>> splitBeanMaps = Maps.newHashMap();
|
||
|
||
Map<String,List<SplitBean>> maps = getOverTimeFlowData(userid,fromdate,todate,splitBeanMaps,dateFormatter);
|
||
|
||
|
||
%>
|
||
|
||
<%!
|
||
|
||
KQLog kqLog = new KQLog();
|
||
|
||
public static int getComputingMode(String resourceId, String date) {
|
||
int computingMode = -1;
|
||
KQOvertimeRulesDetailEntity kqOvertimeRulesDetail = new KQOvertimeRulesDetailEntity();
|
||
kqOvertimeRulesDetail = getOvertimeRulesDetail(resourceId, date);
|
||
computingMode = kqOvertimeRulesDetail.getComputingMode();
|
||
return computingMode;
|
||
}
|
||
|
||
/**
|
||
* 判断是否开启了调休
|
||
* @param kqOvertimeRulesDetailEntity
|
||
* @param overtime_type
|
||
* @return
|
||
*/
|
||
public int getPaidLeaveEnable(KQOvertimeRulesDetailEntity kqOvertimeRulesDetailEntity,
|
||
String overtime_type) {
|
||
int paidLeaveEnable = -1;
|
||
if (kqOvertimeRulesDetailEntity != null){
|
||
paidLeaveEnable = kqOvertimeRulesDetailEntity.getPaidLeaveEnable();
|
||
paidLeaveEnable = paidLeaveEnable == 1?1:0;
|
||
}
|
||
int paidLeaveEnableType = kqOvertimeRulesDetailEntity.getPaidLeaveEnableType();
|
||
if(2 == paidLeaveEnableType){
|
||
// logOvertimeMap(overtimeLogMap, overtime_type, flow_cross_key+"|关联调休与否来自于流程选择,加班类型下拉框值|overtime_type");
|
||
if("0".equalsIgnoreCase(overtime_type)){
|
||
paidLeaveEnable = 1;
|
||
}else if("1".equalsIgnoreCase(overtime_type)){
|
||
paidLeaveEnable = 0;
|
||
}else{
|
||
paidLeaveEnable = 0;
|
||
}
|
||
}
|
||
return paidLeaveEnable;
|
||
}
|
||
|
||
/**
|
||
* 加班补偿规则里,按照加班时段补偿方式需要获取每一个时间区间内的加班时长
|
||
* @param timepointList
|
||
* @param overtimeBalanceTimeBeans
|
||
* @param kqTimesArrayComInfo
|
||
* @param initArrays
|
||
* @param toTime_index
|
||
* @param fromTime_index
|
||
* @param arrayIndexValue
|
||
*/
|
||
public void get_overtimeBalanceTimeBeans(List<String> timepointList,
|
||
List<OvertimeBalanceTimeBean> overtimeBalanceTimeBeans,
|
||
KQTimesArrayComInfo kqTimesArrayComInfo, int[] initArrays,
|
||
int toTime_index,int fromTime_index,int arrayIndexValue) {
|
||
//如果 [按加班的时间段设置转调休时长] 是这种方式,还需要根据时间点来判断时间区间内的加班时长,艹
|
||
for(int k = 0 ; k < timepointList.size() ; k++){
|
||
OvertimeBalanceTimeBean overtimeBalanceTimeBean = new OvertimeBalanceTimeBean();
|
||
String start_pointtime = timepointList.get(k);
|
||
int start_pointtime_index = kqTimesArrayComInfo.getArrayindexByTimes(start_pointtime);
|
||
if(k == 0){
|
||
if(start_pointtime_index > fromTime_index){
|
||
int timepoint_curMins = kqTimesArrayComInfo.getCnt(initArrays, fromTime_index,start_pointtime_index,arrayIndexValue);
|
||
OvertimeBalanceTimeBean ori_overtimeBalanceTimeBean = new OvertimeBalanceTimeBean();
|
||
ori_overtimeBalanceTimeBean.setTimepoint(kqTimesArrayComInfo.getTimesByArrayindex(start_pointtime_index));
|
||
ori_overtimeBalanceTimeBean.setTimepoint_start(kqTimesArrayComInfo.getTimesByArrayindex(fromTime_index));
|
||
ori_overtimeBalanceTimeBean.setTimepoint_end(kqTimesArrayComInfo.getTimesByArrayindex(start_pointtime_index));
|
||
ori_overtimeBalanceTimeBean.setTimepoint_mins(timepoint_curMins);
|
||
ori_overtimeBalanceTimeBean.setNeedTX(false);
|
||
overtimeBalanceTimeBeans.add(ori_overtimeBalanceTimeBean);
|
||
}
|
||
}
|
||
if(start_pointtime_index > toTime_index){
|
||
continue;
|
||
}
|
||
overtimeBalanceTimeBean.setList_index(k);
|
||
int start_index = -1;
|
||
int end_index = -1;
|
||
if(k == timepointList.size()-1){
|
||
start_index = start_pointtime_index;
|
||
end_index = toTime_index;
|
||
}else{
|
||
if(k+1 < timepointList.size()){
|
||
String end_pointtime = timepointList.get(k+1);
|
||
start_index = start_pointtime_index;
|
||
end_index = kqTimesArrayComInfo.getArrayindexByTimes(end_pointtime);
|
||
}
|
||
}
|
||
if(start_index < end_index){
|
||
int timepoint_curMins = kqTimesArrayComInfo.getCnt(initArrays, start_index,end_index,arrayIndexValue);
|
||
overtimeBalanceTimeBean.setTimepoint(kqTimesArrayComInfo.getTimesByArrayindex(start_index));
|
||
overtimeBalanceTimeBean.setTimepoint_start(kqTimesArrayComInfo.getTimesByArrayindex(start_index));
|
||
overtimeBalanceTimeBean.setTimepoint_end(kqTimesArrayComInfo.getTimesByArrayindex(end_index));
|
||
overtimeBalanceTimeBean.setTimepoint_mins(timepoint_curMins);
|
||
overtimeBalanceTimeBean.setNeedTX(true);
|
||
overtimeBalanceTimeBeans.add(overtimeBalanceTimeBean);
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 加班单位
|
||
* @param d_mins
|
||
* @return
|
||
*/
|
||
public double getD_MinsByUnit(double d_mins) {
|
||
Map<String,String> map = KQOvertimeRulesBiz.getMinimumUnitAndConversion();
|
||
if(!map.isEmpty()){
|
||
double conversionMins = 0.0;
|
||
int minimumUnit = Util.getIntValue(Util.null2String(map.get("minimumUnit")),-1);
|
||
int overtimeConversion = Util.getIntValue(Util.null2String(map.get("overtimeConversion")),-1);
|
||
if(5 == minimumUnit || 6 == minimumUnit){
|
||
int halfHourInt = 30;
|
||
int wholeHourInt = 60;
|
||
if(5 == minimumUnit){
|
||
conversionMins = getConversionMins(halfHourInt,d_mins,overtimeConversion);
|
||
}else {
|
||
conversionMins = getConversionMins(wholeHourInt,d_mins,overtimeConversion);
|
||
}
|
||
return conversionMins;
|
||
}
|
||
}
|
||
return d_mins;
|
||
}
|
||
|
||
/**
|
||
* 根据转换规则得到转换后的加班时长
|
||
* @param halfHourInt
|
||
* @param d_mins
|
||
* @param overtimeConversion
|
||
* @return
|
||
*/
|
||
public double getConversionMins(int halfHourInt, double d_mins, int overtimeConversion) {
|
||
double conversionMins = 0.0;
|
||
int step = (int) (d_mins/halfHourInt);
|
||
double leftMins = d_mins - halfHourInt*step;
|
||
//半小时
|
||
if(1 == overtimeConversion){
|
||
// 四舍五入
|
||
if(leftMins >= halfHourInt/2){
|
||
conversionMins = halfHourInt*step+halfHourInt;
|
||
}else{
|
||
conversionMins = halfHourInt*step;
|
||
}
|
||
}else if(2 == overtimeConversion){
|
||
// 向上取整
|
||
if(leftMins > 0){
|
||
conversionMins = halfHourInt*step+halfHourInt;
|
||
}else{
|
||
conversionMins = halfHourInt*step;
|
||
}
|
||
}else if(3 == overtimeConversion){
|
||
// 向下取整
|
||
if(leftMins < halfHourInt){
|
||
conversionMins = halfHourInt*step;
|
||
}else{
|
||
conversionMins = halfHourInt*step;
|
||
}
|
||
}
|
||
return conversionMins;
|
||
}
|
||
|
||
|
||
/**
|
||
* 按加班的时间段设置转调休时长
|
||
* @param kqOvertimeRulesDetailEntity
|
||
* @return
|
||
*/
|
||
public List<String> get_timepointList(KQOvertimeRulesDetailEntity kqOvertimeRulesDetailEntity) {
|
||
List<String> timepointList = Lists.newArrayList();
|
||
KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz();
|
||
int ruleDetailid = kqOvertimeRulesDetailEntity.getId();
|
||
int paidLeaveEnableType = kqOvertimeRulesDetailEntity.getPaidLeaveEnableType();
|
||
if(1 == paidLeaveEnableType){
|
||
int paidLeaveEnableDefaultType = kqOvertimeRulesDetailEntity.getPaidLeaveEnableDefaultType();
|
||
|
||
if(paidLeaveEnableDefaultType == 3){
|
||
Map<String,List<String>> balanceTimethDetailMap = kqOvertimeRulesBiz.getBalanceTimeDetailMap(ruleDetailid);
|
||
if(balanceTimethDetailMap != null && !balanceTimethDetailMap.isEmpty()){
|
||
timepointList = balanceTimethDetailMap.get("timepointList");
|
||
}
|
||
}
|
||
}else if(2 == paidLeaveEnableType){
|
||
int paidLeaveEnableFlowType = kqOvertimeRulesDetailEntity.getPaidLeaveEnableFlowType();
|
||
|
||
if(paidLeaveEnableFlowType == 3){
|
||
Map<String,List<String>> balanceTimethDetailMap = kqOvertimeRulesBiz.getBalanceTimeDetailMap(ruleDetailid);
|
||
if(balanceTimethDetailMap != null && !balanceTimethDetailMap.isEmpty()){
|
||
timepointList = balanceTimethDetailMap.get("timepointList");
|
||
}
|
||
}
|
||
}
|
||
return timepointList;
|
||
}
|
||
|
||
/**
|
||
* 把指定的打卡区间内的上下班时间和休息时间去除
|
||
* @param resourceid
|
||
* @param splitDate
|
||
* @param isNextDay 是否是处理处理明日的,如果是true的话,上下班时间和休息时间都要+1440
|
||
* @param kqTimesArrayComInfo
|
||
* @param overtimeLogMap
|
||
* @param kqOvertimeRulesDetailEntity
|
||
* @param initArrays
|
||
* @param signinTimeIndex
|
||
*/
|
||
public void clearWorkAndRestTime(Map<String,String> signinoffMap,String resourceid, String splitDate, boolean isNextDay,
|
||
KQTimesArrayComInfo kqTimesArrayComInfo,
|
||
Map<String, Object> overtimeLogMap,
|
||
KQOvertimeRulesDetailEntity kqOvertimeRulesDetailEntity, int[] initArrays,
|
||
int signinTimeIndex) {
|
||
|
||
KQWorkTime kqWorkTime = new KQWorkTime();
|
||
WorkTimeEntity workTime = kqWorkTime.getWorkTime(resourceid, splitDate);
|
||
if (workTime == null || workTime.getWorkMins() == 0) {
|
||
}else{
|
||
if (workTime.getKQType().equals("3")) {//自由工时
|
||
//目前自由工时不加班
|
||
} else {
|
||
boolean oneSign = false;
|
||
List<TimeScopeEntity> lsSignTime = new ArrayList<>();
|
||
List<TimeScopeEntity> lsWorkTime = new ArrayList<>();
|
||
List<TimeScopeEntity> lsRestTime = new ArrayList<>();
|
||
if (workTime != null) {
|
||
lsSignTime = workTime.getSignTime();//允许打卡时间
|
||
lsWorkTime = workTime.getWorkTime();//工作时间
|
||
lsRestTime = workTime.getRestTime();//休息时段时间
|
||
oneSign = lsWorkTime!=null&&lsWorkTime.size()==1;
|
||
|
||
if(lsWorkTime != null && !lsWorkTime.isEmpty()){
|
||
for (int i = 0; lsWorkTime != null && i < lsWorkTime.size(); i++) {
|
||
TimeScopeEntity workTimeScope = lsWorkTime.get(i);
|
||
if(oneSign){
|
||
boolean is_flow_humanized = KQSettingsBiz.is_flow_humanized();
|
||
if(is_flow_humanized){
|
||
String workBeginTime = Util.null2String(workTimeScope.getBeginTime());
|
||
String ori_workBeginTime = workBeginTime;
|
||
int workBeginIdx = kqTimesArrayComInfo.getArrayindexByTimes(workBeginTime);
|
||
boolean workBenginTimeAcross = workTimeScope.getBeginTimeAcross();
|
||
String workEndTime = Util.null2String(workTimeScope.getEndTime());
|
||
String ori_workEndTime = workEndTime;
|
||
int workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(workEndTime);
|
||
boolean workEndTimeAcross = workTimeScope.getEndTimeAcross();
|
||
|
||
Map<String, String> shifRuleMap = Maps.newHashMap();
|
||
//个性化设置只支持一天一次上下班
|
||
ShiftInfoBean shiftInfoBean = new ShiftInfoBean();
|
||
shiftInfoBean.setSplitDate(splitDate);
|
||
shiftInfoBean.setShiftRuleMap(workTime.getShiftRuleInfo());
|
||
shiftInfoBean.setSignTime(lsSignTime);
|
||
shiftInfoBean.setWorkTime(lsWorkTime);
|
||
List<String> logList = Lists.newArrayList();
|
||
KQShiftRuleInfoBiz.getShiftRuleInfo(shiftInfoBean, resourceid, shifRuleMap,logList);
|
||
if(!shifRuleMap.isEmpty()){
|
||
if(shifRuleMap.containsKey("shift_beginworktime")){
|
||
String shift_beginworktime = Util.null2String(shifRuleMap.get("shift_beginworktime"));
|
||
if(shift_beginworktime.length() > 0){
|
||
workBeginTime = Util.null2String(shift_beginworktime);
|
||
workBeginIdx = kqTimesArrayComInfo.getArrayindexByTimes(workBeginTime);
|
||
workTimeScope.setBeginTime(workBeginTime);
|
||
workTimeScope.setBeginTimeAcross(workBeginIdx>=1440?true:false);
|
||
}
|
||
}
|
||
if(shifRuleMap.containsKey("shift_endworktime")){
|
||
String shift_endworktime = Util.null2String(shifRuleMap.get("shift_endworktime"));
|
||
if(shift_endworktime.length() > 0){
|
||
workEndTime = Util.null2String(shift_endworktime);
|
||
workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(workEndTime);
|
||
workTimeScope.setEndTime(workEndTime);
|
||
workTimeScope.setEndTimeAcross(workEndIdx>=1440?true:false);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
//目前只处理上班前和下班后的加班数据,上班中间的数据不处理,所以从第一次上班时间到最后下班时间都是无效的加班打卡
|
||
TimeScopeEntity first_TimeScopeEntity = lsWorkTime.get(0);
|
||
TimeScopeEntity last_TimeScopeEntity = lsWorkTime.get(lsWorkTime.size()-1);
|
||
|
||
String begintime = first_TimeScopeEntity.getBeginTime();
|
||
String endtime = last_TimeScopeEntity.getEndTime();
|
||
int begintimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(begintime);
|
||
int endtimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(endtime);
|
||
if(isNextDay){
|
||
begintimeIndex = begintimeIndex + 1440;
|
||
endtimeIndex = endtimeIndex + 1440;
|
||
if(begintimeIndex >= initArrays.length){
|
||
begintimeIndex = initArrays.length-1;
|
||
}
|
||
if(endtimeIndex >= initArrays.length){
|
||
endtimeIndex = initArrays.length-1;
|
||
}
|
||
}
|
||
String workTimeLogInfo = "begintime:"+begintime+":endtime:"+endtime+":isNextDay:"+isNextDay;
|
||
logOvertimeMap(overtimeLogMap, workTimeLogInfo, "工作日的上下班时间|workTimeLogInfo");
|
||
signinoffMap.put("begintimeIndex777",""+begintimeIndex);
|
||
signinoffMap.put("endtimeIndex777",""+begintimeIndex);
|
||
if(begintimeIndex < endtimeIndex){
|
||
Arrays.fill(initArrays, begintimeIndex, endtimeIndex, -2);
|
||
}
|
||
if(!isNextDay){
|
||
if(kqOvertimeRulesDetailEntity != null){
|
||
int startTime = kqOvertimeRulesDetailEntity.getStartTime();
|
||
if(startTime > -1){
|
||
int after_endtimeIndex = endtimeIndex + startTime;
|
||
signinoffMap.put("after_endtimeIndex555",""+after_endtimeIndex);
|
||
signinoffMap.put("endtimeIndex555",""+endtimeIndex);
|
||
if(after_endtimeIndex > endtimeIndex){
|
||
Arrays.fill(initArrays, endtimeIndex, after_endtimeIndex, -2);
|
||
}
|
||
}
|
||
int has_cut_point = kqOvertimeRulesDetailEntity.getHas_cut_point();
|
||
if(has_cut_point == 1){
|
||
int before_startTime = kqOvertimeRulesDetailEntity.getBefore_startTime();
|
||
if(before_startTime > -1){
|
||
int before_begintimeIndex = begintimeIndex - before_startTime;
|
||
signinoffMap.put("signinTimeIndex666",""+signinTimeIndex);
|
||
signinoffMap.put("before_begintimeIndex666",""+before_begintimeIndex);
|
||
if(before_begintimeIndex > signinTimeIndex){
|
||
Arrays.fill(initArrays, signinTimeIndex, before_begintimeIndex, -2);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if(lsRestTime != null && !lsRestTime.isEmpty()){
|
||
String restTimeLogInfo = JSON.toJSONString(lsRestTime);
|
||
logOvertimeMap(overtimeLogMap, restTimeLogInfo, "工作日的休息时间|restTimeLogInfo");
|
||
for(int p = 0 ; p < lsRestTime.size(); p++){
|
||
TimeScopeEntity rest_TimeScopeEntity = lsRestTime.get(p);
|
||
String begintime = rest_TimeScopeEntity.getBeginTime();
|
||
String endtime = rest_TimeScopeEntity.getEndTime();
|
||
int begintimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(begintime);
|
||
int endtimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(endtime);
|
||
if(isNextDay){
|
||
begintimeIndex = begintimeIndex + 1440;
|
||
endtimeIndex = endtimeIndex + 1440;
|
||
if(begintimeIndex >= initArrays.length){
|
||
begintimeIndex = initArrays.length-1;
|
||
}
|
||
if(endtimeIndex >= initArrays.length){
|
||
endtimeIndex = initArrays.length-1;
|
||
}
|
||
}
|
||
signinoffMap.put("begintimeIndex888",""+begintimeIndex);
|
||
signinoffMap.put("endtimeIndex888",""+endtimeIndex);
|
||
if(begintimeIndex < endtimeIndex){
|
||
Arrays.fill(initArrays, begintimeIndex, endtimeIndex, -2);
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 得到有效的打卡区间,这个区间肯定已经是去除了上下班时间和休息时间还有重复打卡的部分
|
||
* @param cross_time_list
|
||
* @param initArrays
|
||
* @param fromIndex
|
||
* @param toIndex
|
||
* @param cross_from_index
|
||
* @param cross_to_index
|
||
*/
|
||
public void get_cross_time_list(List<Integer> cross_time_list, int[] initArrays,
|
||
int fromIndex, int toIndex,int cross_from_index,int cross_to_index) {
|
||
for(int i = fromIndex ; i < toIndex+1 ; i++){
|
||
if(cross_time_list.isEmpty()){
|
||
if(initArrays[i] == cross_from_index){
|
||
cross_time_list.add(i);
|
||
}
|
||
}else{
|
||
if(cross_time_list.size() % 2 != 0){
|
||
if(initArrays[i] == cross_to_index){
|
||
cross_time_list.add(i);
|
||
}
|
||
}else{
|
||
if(initArrays[i] == cross_from_index){
|
||
cross_time_list.add(i);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if(cross_time_list.size() % 2 != 0){
|
||
cross_time_list.add(toIndex);
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* 打卡的时长计算,流程+打卡 和纯打卡的可以拿来共用
|
||
* needHasOverTime 是否需要按照打卡区间排除重复打卡的数据,第二种流程和打卡比较时长的不需要这个方式
|
||
*/
|
||
public Map<String,String> buildOvertimeCard(KQOvertimeCardBean kqOvertimeCardBean,
|
||
String resourceid, String splitDate, KQTimesArrayComInfo kqTimesArrayComInfo,
|
||
Map<String, List<String[]>> restTimeMap, String changeType_key, int[] initArrays,
|
||
List<Map<String, String>> hasOverTimeList,
|
||
Map<String, KQOvertimeRulesDetailEntity> overRulesDetailMap, boolean needHasOverTime,
|
||
Map<String, Object> overtimeLogMap) throws Exception{
|
||
Map<String,String> signinoffMap = Maps.newHashMap();
|
||
|
||
String signinDate = kqOvertimeCardBean.getSigninDate();
|
||
String signinTime = kqOvertimeCardBean.getSigninTime();
|
||
String signoutDate = kqOvertimeCardBean.getSignoutDate();
|
||
String signoutTime = kqOvertimeCardBean.getSignoutTime();
|
||
|
||
if(hasOverTimeList.isEmpty()){
|
||
getHasOverTimeData(resourceid,splitDate,hasOverTimeList);
|
||
}
|
||
|
||
if(signinDate.compareTo(splitDate) > 0){
|
||
signinTime = kqTimesArrayComInfo.turn24to48Time(signinTime);
|
||
if(signinTime.length() > 0){
|
||
signinTime = signinTime+ ":00";
|
||
}
|
||
}
|
||
if(signoutDate.compareTo(splitDate) > 0){
|
||
signoutTime = kqTimesArrayComInfo.turn24to48Time(signoutTime);
|
||
if(signoutTime.length() > 0){
|
||
signoutTime = signoutTime+ ":00";
|
||
}
|
||
}
|
||
if(signinTime.length() == 0 || signoutTime.length() == 0){
|
||
return signinoffMap;
|
||
}
|
||
signinoffMap.put("1_splitDate",splitDate);
|
||
int signinTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(signinTime);
|
||
int signoutTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(signoutTime);
|
||
|
||
signinoffMap.put("signinTime", signinTime);
|
||
signinoffMap.put("signoutTime", signoutTime);
|
||
signinoffMap.put("signinDate", signinDate);
|
||
signinoffMap.put("signoutDate", signoutDate);
|
||
|
||
signinoffMap.put("signinTimeIndex111", ""+signinTimeIndex);
|
||
signinoffMap.put("signoutTimeIndex111", ""+signoutTimeIndex);
|
||
// signinoffMap.put("initArrays", Arrays.toString(initArrays));
|
||
//先把打卡数据都列出来 置位1
|
||
if(signinTimeIndex < signoutTimeIndex){
|
||
Arrays.fill(initArrays, signinTimeIndex, signoutTimeIndex,1);
|
||
}
|
||
KQOvertimeRulesDetailEntity kqOvertimeRulesDetailEntity = overRulesDetailMap.get(changeType_key);
|
||
if(restTimeMap.containsKey(changeType_key)){
|
||
List<String[]> restTimeList = restTimeMap.get(changeType_key);
|
||
logOvertimeMap(overtimeLogMap, restTimeList, "非工作时间设置的排除休息时间区间|restTimeList");
|
||
//再把休息时间填充上去
|
||
if(!restTimeList.isEmpty()){
|
||
int restTimeType = 1;
|
||
if(kqOvertimeRulesDetailEntity != null){
|
||
restTimeType = kqOvertimeRulesDetailEntity.getRestTimeType();
|
||
}
|
||
if(restTimeType == 1){
|
||
for(int j =0 ; j < restTimeList.size() ; j++){
|
||
String[] restTimes = restTimeList.get(j);
|
||
if(restTimes.length == 2){
|
||
int restStart = kqTimesArrayComInfo.getArrayindexByTimes(restTimes[0]);
|
||
int restEnd = kqTimesArrayComInfo.getArrayindexByTimes(restTimes[1]);
|
||
if(restEnd == 1439){
|
||
//针对跨天的休息时段单独处理排除掉23:59-00:00的时间
|
||
restEnd = 1440;
|
||
}
|
||
int hasRestMins = kqTimesArrayComInfo.getCnt(initArrays, restStart,restEnd,1);
|
||
if(hasRestMins == 0) {
|
||
restStart = kqTimesArrayComInfo.turn24to48TimeIndex(restStart);
|
||
restEnd = kqTimesArrayComInfo.turn24to48TimeIndex(restEnd);
|
||
}
|
||
signinoffMap.put("restStart222", ""+restStart);
|
||
signinoffMap.put("restEnd222", ""+restEnd);
|
||
if(restStart < restEnd){
|
||
Arrays.fill(initArrays, restStart, restEnd, -2);
|
||
}
|
||
}
|
||
}
|
||
}else{
|
||
}
|
||
}
|
||
}
|
||
|
||
boolean isNextDay = false;
|
||
clearWorkAndRestTime(signinoffMap,resourceid,splitDate,isNextDay,kqTimesArrayComInfo,overtimeLogMap,kqOvertimeRulesDetailEntity,initArrays,signinTimeIndex);
|
||
isNextDay = true;
|
||
clearWorkAndRestTime(signinoffMap,resourceid,DateUtil.addDate(splitDate, 1),isNextDay, kqTimesArrayComInfo,
|
||
overtimeLogMap, kqOvertimeRulesDetailEntity, initArrays, signinTimeIndex);
|
||
|
||
if(!hasOverTimeList.isEmpty() && needHasOverTime){
|
||
if(hasOverTimeList != null && !hasOverTimeList.isEmpty()){
|
||
for(int p = 0 ; p < hasOverTimeList.size(); p++){
|
||
Map<String,String> hasOverTimeMap = hasOverTimeList.get(p);
|
||
String duration_min = Util.null2String(hasOverTimeMap.get("duration_min"));
|
||
String fromdate = Util.null2String(hasOverTimeMap.get("fromdate"));
|
||
String fromtime = Util.null2String(hasOverTimeMap.get("fromtime"));
|
||
String todate = Util.null2String(hasOverTimeMap.get("todate"));
|
||
String totime = Util.null2String(hasOverTimeMap.get("totime"));
|
||
if(fromdate.compareTo(splitDate) > 0){
|
||
fromtime = kqTimesArrayComInfo.turn24to48Time(fromtime);
|
||
}
|
||
if(todate.compareTo(splitDate) > 0){
|
||
totime = kqTimesArrayComInfo.turn24to48Time(totime);
|
||
}
|
||
int begintimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(fromtime);
|
||
int endtimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(totime);
|
||
signinoffMap.put("begintimeIndex333", ""+begintimeIndex);
|
||
signinoffMap.put("endtimeIndex333", ""+endtimeIndex);
|
||
if(begintimeIndex < endtimeIndex){
|
||
Arrays.fill(initArrays, begintimeIndex, endtimeIndex, -2);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
signinoffMap.put("2_splitDate",splitDate);
|
||
return signinoffMap;
|
||
}
|
||
|
||
/**
|
||
* 获取已经生成过的加班数据
|
||
* @param resourceid
|
||
* @param belongdate
|
||
* @param hasOverTimeList
|
||
*/
|
||
public void getHasOverTimeData(String resourceid, String belongdate,List<Map<String,String>> hasOverTimeList) {
|
||
RecordSet rs = new RecordSet();
|
||
|
||
String sql = " select * from kq_flow_overtime where resourceid = ? and belongdate = ? ";
|
||
rs.executeQuery(sql,resourceid,belongdate);
|
||
while (rs.next()){
|
||
String requestid =rs.getString("requestid");
|
||
String fromdate =rs.getString("fromdate");
|
||
String fromtime =rs.getString("fromtime");
|
||
String todate =rs.getString("todate");
|
||
String totime =rs.getString("totime");
|
||
String duration_min =Util.null2String(rs.getString("duration_min"));
|
||
String flow_dataid =Util.null2String(rs.getString("flow_dataid"));
|
||
String ori_belongdate =Util.null2String(rs.getString("ori_belongdate"));
|
||
//流程+打卡的时候,存的对应的流程数据
|
||
String fromdate_flow =rs.getString("fromdatedb");
|
||
String fromtime_flow =rs.getString("fromtimedb");
|
||
String todate_flow =rs.getString("todatedb");
|
||
String totime_flow =rs.getString("totimedb");
|
||
Map<String,String> hasOverTimeMap = Maps.newHashMap();
|
||
hasOverTimeMap.put("resourceid", resourceid);
|
||
hasOverTimeMap.put("belongdate", belongdate);
|
||
hasOverTimeMap.put("requestid", requestid);
|
||
hasOverTimeMap.put("fromdate", fromdate);
|
||
hasOverTimeMap.put("fromtime", fromtime);
|
||
hasOverTimeMap.put("todate", todate);
|
||
hasOverTimeMap.put("totime", totime);
|
||
hasOverTimeMap.put("fromdate_flow", fromdate_flow);
|
||
hasOverTimeMap.put("fromtime_flow", fromtime_flow);
|
||
hasOverTimeMap.put("todate_flow", todate_flow);
|
||
hasOverTimeMap.put("totime_flow", totime_flow);
|
||
hasOverTimeMap.put("duration_min", duration_min);
|
||
hasOverTimeMap.put("flow_dataid", flow_dataid);
|
||
hasOverTimeMap.put("ori_belongdate", ori_belongdate);
|
||
|
||
hasOverTimeList.add(hasOverTimeMap);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 获取加班流程数据
|
||
* @param resourceid
|
||
* @param fromDate
|
||
* @param toDate
|
||
* @param splitBeanMaps
|
||
* @param dateFormatter
|
||
*/
|
||
public Map<String, List<SplitBean>> getOverTimeFlowData(String resourceid, String fromDate, String toDate,
|
||
Map<String, List<SplitBean>> splitBeanMaps,
|
||
DateTimeFormatter dateFormatter) {
|
||
LocalDate localFromDate = LocalDate.parse(fromDate);
|
||
LocalDate preFromDate = localFromDate.minusDays(1);
|
||
LocalDate localToDate = LocalDate.parse(toDate);
|
||
long betweenDays = localToDate.toEpochDay() - preFromDate.toEpochDay();
|
||
for (int k = 0; k <= betweenDays; k++) {
|
||
LocalDate curLocalDate = preFromDate.plusDays(k);
|
||
String splitDate = curLocalDate.format(dateFormatter);
|
||
String key = resourceid+"_"+splitDate;
|
||
String order_sql = " order by belongdate,fromtime ";
|
||
KQFlowDataBiz kqFlowDataBiz = new KQFlowDataBiz.FlowDataParamBuilder().belongDateParam(splitDate).resourceidParam(resourceid).orderby_sqlParam(order_sql).build();
|
||
Map<String,Object> flowMaps = Maps.newHashMap();
|
||
List<SplitBean> splitBeans = kqFlowDataBiz.getOverTimeData(flowMaps);
|
||
if(!splitBeans.isEmpty()){
|
||
splitBeanMaps.put(key, splitBeans);
|
||
}
|
||
}
|
||
return splitBeanMaps;
|
||
}
|
||
|
||
/**
|
||
* 判断某天的加班结束时间是否等于班次开始时间、加班开始时间是否等于班次结束时间
|
||
* @param resourceId
|
||
* @param kqDate
|
||
* @return
|
||
*/
|
||
|
||
|
||
/**
|
||
* 生成加班数据
|
||
* @param resourceid
|
||
* @param fromDate
|
||
* @param toDate
|
||
* @param eventtype
|
||
*/
|
||
public Map<String, Object> buildOvertime(String resourceid, String fromDate, String toDate, String eventtype){
|
||
String nums = "";
|
||
Map<String, Object> result = new HashMap<>();
|
||
Map<String,Integer> computingModeMap = Maps.newHashMap();
|
||
try{
|
||
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||
|
||
KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo();
|
||
Map<String,Integer> changeTypeMap = Maps.newHashMap();
|
||
Map<String, KQOvertimeRulesDetailEntity> overRulesDetailMap = Maps.newHashMap();
|
||
Map<String, List<String[]>> restTimeMap = Maps.newHashMap();
|
||
|
||
//先获取一些前提数据,加班規則和假期規則
|
||
getOverTimeDataMap(resourceid, fromDate, toDate, dateFormatter,changeTypeMap,overRulesDetailMap,restTimeMap,computingModeMap);
|
||
Map<String,Object> eventLogMap = Maps.newHashMap();
|
||
eventLogMap.put("fromDate", fromDate);
|
||
eventLogMap.put("toDate", toDate);
|
||
eventLogMap.put("eventtype", eventtype);
|
||
KQOvertimeLogBiz kqEventLogBiz = new KQOvertimeLogBiz();
|
||
String logKey = "|key|"+resourceid+"_"+fromDate+"_"+toDate;
|
||
String uuid = kqEventLogBiz.logEvent(resourceid,eventLogMap,"buildOvertime|生成加班调休"+logKey);
|
||
|
||
LocalDate localFromDate = LocalDate.parse(fromDate);
|
||
LocalDate localToDate = LocalDate.parse(toDate);
|
||
LocalDate preFromDate = localFromDate.minusDays(1);
|
||
LocalDate nextToDate = localToDate.plusDays(1);
|
||
//之前是考虑外部考勤数据导入跨天打卡,判断归属的问题,向前算一天,现在不管了,都是默认只处理当天的
|
||
if(eventtype.indexOf("#flow,") > -1 || eventtype.indexOf("punchcard") > -1 || true){
|
||
//如果是正常走的加班流程,就是流程开始日期和结束日期,只有补卡,打卡,同步的时候才需要处理一下前一天和后一天的数据
|
||
preFromDate = localFromDate;
|
||
nextToDate = localToDate;
|
||
}
|
||
long betweenDays = nextToDate.toEpochDay() - preFromDate.toEpochDay();
|
||
OvertimeRuleComputingModeService modeService = new OvertimeRuleComputingModeService();
|
||
Map<Integer, String> cusModeMap = modeService.getNewComputingMode(7);
|
||
for (int i = 0; i <= betweenDays; i++) {
|
||
LocalDate curLocalDate = preFromDate.plusDays(i);
|
||
String splitDate = curLocalDate.format(dateFormatter);
|
||
String key = resourceid + "_" + splitDate;
|
||
String change_key = splitDate + "_" + resourceid;
|
||
int changeType = Util.getIntValue("" + changeTypeMap.get(change_key), -1);
|
||
String changeType_key = splitDate + "_" + changeType;
|
||
int computingMode = Util.getIntValue(""+computingModeMap.get(changeType_key),-1);
|
||
nums += computingMode + ",";
|
||
|
||
if(computingMode == 2){
|
||
// 需审批,以打卡为准,但是不能超过审批时长
|
||
// doComputingMode2(resourceid,splitDate,dateFormatter,changeTypeMap,overRulesDetailMap,restTimeMap,computingModeMap,kqTimesArrayComInfo,uuid);
|
||
} else if(computingMode == 3){
|
||
// 无需审批,根据打卡时间计算加班时长
|
||
result = doComputingMode3(resourceid,splitDate,dateFormatter,changeTypeMap,overRulesDetailMap,restTimeMap,computingModeMap,kqTimesArrayComInfo,uuid);
|
||
} else if(computingMode == 4){
|
||
// 需审批,以打卡为准,取流程和打卡的交集
|
||
result = doComputingMode4(resourceid,splitDate,dateFormatter,changeTypeMap,overRulesDetailMap,restTimeMap,computingModeMap,kqTimesArrayComInfo,uuid);
|
||
}
|
||
// else if(cusModeMap.containsKey(computingMode)) {
|
||
// modeService.doComputingMode(computingMode, resourceid, splitDate, changeTypeMap, overRulesDetailMap, restTimeMap, computingModeMap, uuid);
|
||
// }
|
||
}
|
||
result.put("computingMode",""+nums);
|
||
}catch (Exception e){
|
||
StringWriter errorsWriter = new StringWriter();
|
||
e.printStackTrace(new PrintWriter(errorsWriter));
|
||
kqLog.writeLog(e);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 根据人和日期获取加班规则里的信息
|
||
* @param resourceid
|
||
* @param fromDate
|
||
* @param toDate
|
||
* @param dateFormatter
|
||
* @param changeTypeMap
|
||
* @param overRulesDetailMap
|
||
* @param restTimeMap
|
||
* @param computingModeMap
|
||
*/
|
||
public void getOverTimeDataMap(String resourceid, String fromDate, String toDate,
|
||
DateTimeFormatter dateFormatter, Map<String, Integer> changeTypeMap,
|
||
Map<String, KQOvertimeRulesDetailEntity> overRulesDetailMap,Map<String,List<String[]>> restTimeMap,Map<String,Integer> computingModeMap){
|
||
|
||
LocalDate localFromDate = LocalDate.parse(fromDate);
|
||
LocalDate localToDate = LocalDate.parse(toDate);
|
||
LocalDate preFromDate = localFromDate.minusDays(2);
|
||
LocalDate nextToDate = localToDate.plusDays(1);
|
||
long betweenDays = nextToDate.toEpochDay() - preFromDate.toEpochDay();
|
||
for (int i = 0; i <= betweenDays; i++) {
|
||
LocalDate curLocalDate = preFromDate.plusDays(i);
|
||
String splitDate = curLocalDate.format(dateFormatter);
|
||
getOverTimeData(resourceid, splitDate,changeTypeMap,overRulesDetailMap,restTimeMap,computingModeMap);
|
||
}
|
||
}
|
||
|
||
public static void getOverTimeData(String resourceId, String date,
|
||
Map<String,Integer> changeTypeMap,Map<String,KQOvertimeRulesDetailEntity> overRulesDetailMap,Map<String,List<String[]>> restTimeMap,Map<String,Integer> computingModeMap) {
|
||
int changeType = -1;
|
||
|
||
/*获取考勤组的ID,因为考勤组有有效期,所以需要传入日期*/
|
||
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||
String groupId = Util.null2s(kqGroupMemberComInfo.getKQGroupId(resourceId, date),"");
|
||
|
||
/*该人员不存在于任意一个考勤组中,请为其设置考勤组*/
|
||
if(groupId.length() == 0){
|
||
// logger.writeLog("该人员不存在于任意一个考勤组中,请为其设置考勤组。resourceId=" + resourceId + ",date=" + date);
|
||
return ;
|
||
}
|
||
|
||
//查询员工在指定日期时的班次
|
||
String shiftId = "";
|
||
ShiftInfoCominfoBean shiftBean = new KQWorkTime().getShiftInfoCominfoBeanIncludeHoliday(resourceId, date);
|
||
if(shiftBean != null) {
|
||
shiftId = shiftBean.getSerialid();
|
||
}
|
||
if(shiftId.length() == 0){
|
||
// logger.writeLog("该人员在指定日期没有排班班次,请为其设置。resourceId=" + resourceId + ",date=" + date+", groupId="+groupId);
|
||
}
|
||
|
||
changeType = KQHolidaySetBiz.getChangeType(groupId, date);
|
||
if (changeType != 1 && changeType != 2 && changeType != 3) {
|
||
KQWorkTime kqWorkTime = new KQWorkTime();
|
||
changeType = kqWorkTime.isWorkDay(resourceId, date) ? 2 : 3;
|
||
}
|
||
String change_key = date+"_"+resourceId;
|
||
changeTypeMap.put(change_key, changeType);
|
||
|
||
List<String[]> restTimeList = new ArrayList<String[]>();
|
||
int overtimeRuleId = 0;//加班规则的ID
|
||
RecordSet recordSet = new RecordSet();
|
||
String sql = "select id from kq_OvertimeRules where (isDelete is null or isDelete !=1) ";
|
||
if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) {
|
||
sql += " and ','+shiftIds+',' like '%," + shiftId + ",%'";
|
||
} else if (recordSet.getDBType().equalsIgnoreCase("mysql")) {
|
||
sql += " and concat(',',shiftIds,',') like '%," + shiftId + ",%'";
|
||
} else {
|
||
sql += " and ','||shiftIds||',' like '%," + shiftId + ",%'";
|
||
}
|
||
recordSet.executeQuery(sql);
|
||
if (recordSet.next()) {
|
||
overtimeRuleId = recordSet.getInt("id");
|
||
|
||
sql = "select * from kq_OvertimeRulesDetail where ruleId=" + overtimeRuleId + " and dayType=" + changeType;
|
||
recordSet.executeQuery(sql);
|
||
if (recordSet.next()) {
|
||
int id = recordSet.getInt("id");
|
||
int ruleId = recordSet.getInt("ruleId");
|
||
int dayType = recordSet.getInt("dayType");
|
||
int overtimeEnable = recordSet.getInt("overtimeEnable");
|
||
int computingMode = recordSet.getInt("computingMode");
|
||
int startTime = recordSet.getInt("startTime");
|
||
int minimumLen = recordSet.getInt("minimumLen");
|
||
int paidLeaveEnable = recordSet.getInt("paidLeaveEnable");
|
||
double lenOfOvertime = Util.getDoubleValue(recordSet.getString("lenOfOvertime"), 1.00);
|
||
double lenOfLeave = Util.getDoubleValue(recordSet.getString("lenOfLeave"), 1.00);
|
||
int hasRestTime = Util.getIntValue(recordSet.getString("hasRestTime"));
|
||
int before_startTime = recordSet.getInt("before_startTime");
|
||
|
||
int paidLeaveEnableType = recordSet.getInt("paidLeaveEnableType");
|
||
int paidLeaveEnableDefaultType = recordSet.getInt("paidLeaveEnableDefaultType");
|
||
int paidLeaveEnableFlowType = recordSet.getInt("paidLeaveEnableFlowType");
|
||
int restTimeType = recordSet.getInt("restTimeType");
|
||
int has_cut_point = Util.getIntValue(Util.null2s(recordSet.getString("has_cut_point"),"0"),0);
|
||
if(paidLeaveEnableType <= 0){
|
||
paidLeaveEnableType = 1;
|
||
}
|
||
if(paidLeaveEnableDefaultType <= 0){
|
||
paidLeaveEnableDefaultType = 1;
|
||
}
|
||
if(paidLeaveEnableFlowType <= 0){
|
||
paidLeaveEnableFlowType = 1;
|
||
}
|
||
if(paidLeaveEnableType == 1 && paidLeaveEnable == 0){
|
||
//如果就没有开启关联调休,那么默认的加班转调休方式就是第一种
|
||
paidLeaveEnableDefaultType = 1;
|
||
}
|
||
if(restTimeType <= 0){
|
||
restTimeType = 1;
|
||
}
|
||
String cut_point = Util.null2s(recordSet.getString("cut_point"),"");
|
||
String key = date+"_"+changeType;
|
||
|
||
KQOvertimeRulesDetailEntity kqOvertimeRulesDetail = new KQOvertimeRulesDetailEntity();
|
||
kqOvertimeRulesDetail.setRuleId(ruleId);
|
||
kqOvertimeRulesDetail.setDayType(dayType);
|
||
kqOvertimeRulesDetail.setOvertimeEnable(overtimeEnable);
|
||
kqOvertimeRulesDetail.setComputingMode(computingMode);
|
||
kqOvertimeRulesDetail.setStartTime(startTime);
|
||
kqOvertimeRulesDetail.setMinimumLen(minimumLen);
|
||
kqOvertimeRulesDetail.setPaidLeaveEnable(paidLeaveEnable);
|
||
kqOvertimeRulesDetail.setLenOfOvertime(lenOfOvertime);
|
||
kqOvertimeRulesDetail.setLenOfLeave(lenOfLeave);
|
||
kqOvertimeRulesDetail.setHasRestTime(hasRestTime);
|
||
kqOvertimeRulesDetail.setBefore_startTime(before_startTime);
|
||
kqOvertimeRulesDetail.setCut_point(cut_point);
|
||
kqOvertimeRulesDetail.setHas_cut_point(has_cut_point);
|
||
kqOvertimeRulesDetail.setId(id);
|
||
kqOvertimeRulesDetail.setPaidLeaveEnableType(paidLeaveEnableType);
|
||
kqOvertimeRulesDetail.setPaidLeaveEnableDefaultType(paidLeaveEnableDefaultType);
|
||
kqOvertimeRulesDetail.setPaidLeaveEnableFlowType(paidLeaveEnableFlowType);
|
||
kqOvertimeRulesDetail.setRestTimeType(restTimeType);
|
||
overRulesDetailMap.put(key, kqOvertimeRulesDetail);
|
||
computingModeMap.put(key, computingMode);
|
||
|
||
/**
|
||
* 因为休息时段可以设置次日的数据,所以获取某一天的休息时段的时候,需要先考虑上一个日期所设置的次日的休息时段
|
||
*/
|
||
String lastDay = weaver.wechat.util.DateUtil.addDay(date, -1, "yyyy-MM-dd");
|
||
KQOvertimeRulesDetailEntity pre_kqOvertimeRulesDetail = getOvertimeRulesDetail(resourceId, lastDay);
|
||
int pre_overtimeEnable = pre_kqOvertimeRulesDetail.getOvertimeEnable();
|
||
int pre_hasRestTime = pre_kqOvertimeRulesDetail.getHasRestTime();
|
||
if (pre_overtimeEnable == 1 && pre_hasRestTime == 1) {
|
||
int pre_dayType = pre_kqOvertimeRulesDetail.getDayType();
|
||
int pre_ruleId = pre_kqOvertimeRulesDetail.getRuleId();
|
||
|
||
sql = "select * from kq_OvertimeRestTime where ruleId=" + pre_ruleId + " and dayType=" + pre_dayType;
|
||
RecordSet recordSet1 = new RecordSet();
|
||
recordSet1.executeQuery(sql);
|
||
while (recordSet1.next()) {
|
||
String startType = recordSet1.getString("startType");
|
||
String startTime1 = recordSet1.getString("startTime");
|
||
String endType = recordSet1.getString("endType");
|
||
String endTime = recordSet1.getString("endTime");
|
||
|
||
if (startType.equals("0") && endType.equals("1")) {
|
||
String[] str = new String[]{"00:00", endTime};
|
||
restTimeList.add(str);
|
||
} else if (startType.equals("1") && endType.equals("1")) {
|
||
String[] str = new String[]{startTime1, endTime};
|
||
restTimeList.add(str);
|
||
}
|
||
}
|
||
}
|
||
|
||
overtimeEnable = kqOvertimeRulesDetail.getOvertimeEnable();
|
||
hasRestTime = kqOvertimeRulesDetail.getHasRestTime();
|
||
restTimeType = kqOvertimeRulesDetail.getRestTimeType();
|
||
if (overtimeEnable == 1 && hasRestTime == 1) {
|
||
if(restTimeType == 1){
|
||
sql = "select * from kq_OvertimeRestTime where ruleId=" + ruleId + " and dayType=" + dayType;
|
||
RecordSet recordSet1 = new RecordSet();
|
||
recordSet1.executeQuery(sql);
|
||
while (recordSet1.next()) {
|
||
String startType = recordSet1.getString("startType");
|
||
String startTime1 = recordSet1.getString("startTime");
|
||
String endType = recordSet1.getString("endType");
|
||
String endTime = recordSet1.getString("endTime");
|
||
|
||
if (startType.equals("0") && endType.equals("0")) {
|
||
String[] str = new String[]{startTime1, endTime};
|
||
restTimeList.add(str);
|
||
} else if (startType.equals("0") && endType.equals("1")) {
|
||
String[] str = new String[]{startTime1, "24:00"};
|
||
restTimeList.add(str);
|
||
}
|
||
}
|
||
}else{
|
||
sql = "select * from kq_OvertimeRestlength where ruleId=" + ruleId + " and dayType=" + dayType+" order by dsporder ";
|
||
RecordSet recordSet1 = new RecordSet();
|
||
recordSet1.executeQuery(sql);
|
||
while (recordSet1.next()) {
|
||
String overlength = Util.null2String(recordSet1.getString("overlength"));
|
||
String cutlength = Util.null2String(recordSet1.getString("cutlength"));
|
||
if(overlength.length() > 0 && cutlength.length() > 0){
|
||
String[] str = new String[]{overlength, cutlength};
|
||
restTimeList.add(str);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
restTimeMap.put(key, restTimeList);
|
||
}
|
||
|
||
|
||
} else {
|
||
// logger.writeLog("该人员所在的考勤组班次(ID="+shiftId+")没有设置过任何加班规则,请为其设置加班规则。resourceId=" + resourceId + ",date="+date+",changeType=" + changeType);
|
||
}
|
||
|
||
return ;
|
||
}
|
||
|
||
private static KQOvertimeRulesDetailEntity getOvertimeRulesDetail(String resourceId, String date) {
|
||
KQOvertimeRulesDetailEntity kqOvertimeRulesDetail = new KQOvertimeRulesDetailEntity();
|
||
try {
|
||
/*获取考勤组的ID,因为考勤组有有效期,所以需要传入日期*/
|
||
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||
String groupIds = kqGroupMemberComInfo.getKQGroupId(resourceId, date);
|
||
if (groupIds.equals("")) {
|
||
/*该人员不存在于任意一个考勤组中,请为其设置考勤组*/
|
||
// logger.writeLog("该人员不存在于任意一个考勤组中,请为其设置考勤组。resourceId=" + resourceId + ",date=" + date);
|
||
}
|
||
|
||
int changeType = getChangeType(resourceId, date);
|
||
/*获取当前日期的日期类型错误*/
|
||
if (changeType != 1 && changeType != 2 && changeType != 3) {
|
||
// logger.writeLog("获取当前日期的日期类型错误。resourceId=" + resourceId + ",date=" + date + ",changeType=" + changeType);
|
||
}
|
||
|
||
//查询员工在指定日期时的班次
|
||
String shiftId = "";
|
||
ShiftInfoCominfoBean shiftBean = new KQWorkTime().getShiftInfoCominfoBeanIncludeHoliday(resourceId, date);
|
||
if(shiftBean != null) {
|
||
shiftId = shiftBean.getSerialid();
|
||
}
|
||
if(shiftId.length() == 0){
|
||
// logger.writeLog("该人员在指定日期没有排班班次,请为其设置。resourceId=" + resourceId + ",date=" + date+", groupId="+groupIds);
|
||
}
|
||
|
||
RecordSet recordSet = new RecordSet();
|
||
int overtimeRuleId = 0;//加班规则的ID
|
||
String sql = "select id from kq_OvertimeRules where (isDelete is null or isDelete !=1) ";
|
||
if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) {
|
||
sql += " and ','+shiftIds+',' like '%," + shiftId + ",%'";
|
||
} else if (recordSet.getDBType().equalsIgnoreCase("mysql")) {
|
||
sql += " and concat(',',shiftIds,',') like '%," + shiftId + ",%'";
|
||
} else {
|
||
sql += " and ','||shiftIds||',' like '%," + shiftId + ",%'";
|
||
}
|
||
recordSet.executeQuery(sql);
|
||
if (recordSet.next()) {
|
||
overtimeRuleId = recordSet.getInt("id");
|
||
|
||
sql = "select * from kq_OvertimeRulesDetail where ruleId=" + overtimeRuleId + " and dayType=" + changeType;
|
||
recordSet.executeQuery(sql);
|
||
if (recordSet.next()) {
|
||
int ruleId = recordSet.getInt("ruleId");
|
||
int dayType = recordSet.getInt("dayType");
|
||
int overtimeEnable = recordSet.getInt("overtimeEnable");
|
||
int computingMode = recordSet.getInt("computingMode");
|
||
int startTime = recordSet.getInt("startTime");
|
||
int minimumLen = recordSet.getInt("minimumLen");
|
||
int paidLeaveEnable = recordSet.getInt("paidLeaveEnable");
|
||
double lenOfOvertime = Util.getDoubleValue(recordSet.getString("lenOfOvertime"), 1.00);
|
||
double lenOfLeave = Util.getDoubleValue(recordSet.getString("lenOfLeave"), 1.00);
|
||
int hasRestTime = Util.getIntValue(recordSet.getString("hasRestTime"));
|
||
|
||
kqOvertimeRulesDetail.setRuleId(ruleId);
|
||
kqOvertimeRulesDetail.setDayType(dayType);
|
||
kqOvertimeRulesDetail.setOvertimeEnable(overtimeEnable);
|
||
kqOvertimeRulesDetail.setComputingMode(computingMode);
|
||
kqOvertimeRulesDetail.setStartTime(startTime);
|
||
kqOvertimeRulesDetail.setMinimumLen(minimumLen);
|
||
kqOvertimeRulesDetail.setPaidLeaveEnable(paidLeaveEnable);
|
||
kqOvertimeRulesDetail.setLenOfOvertime(lenOfOvertime);
|
||
kqOvertimeRulesDetail.setLenOfLeave(lenOfLeave);
|
||
kqOvertimeRulesDetail.setHasRestTime(hasRestTime);
|
||
}
|
||
} else {
|
||
// logger.writeLog("该人员所属的考勤组没有设置过任何加班规则,请为其设置加班规则。resourceId=" + resourceId + ",date="+date+",changeType=" + changeType);
|
||
}
|
||
} catch (Exception e) {
|
||
// logger.writeLog("根据人员ID获取加班规则的规则内容出错。resourceId=" + resourceId + ",date=" + date);
|
||
e.printStackTrace();
|
||
}
|
||
return kqOvertimeRulesDetail;
|
||
}
|
||
|
||
public static int getChangeType(String resourceId, String date) {
|
||
int changeType = -1;
|
||
|
||
/*获取考勤组的ID,因为考勤组有有效期,所以需要传入日期*/
|
||
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo();
|
||
String groupId = kqGroupMemberComInfo.getKQGroupId(resourceId, date);
|
||
|
||
/*该人员不存在于任意一个考勤组中,请为其设置考勤组*/
|
||
if(groupId.equals("")){
|
||
// logger.writeLog("该人员不存在于任意一个考勤组中,请为其设置考勤组。resourceId=" + resourceId + ",date=" + date);
|
||
}
|
||
|
||
changeType = KQHolidaySetBiz.getChangeType(groupId, date);
|
||
if (changeType != 1 && changeType != 2 && changeType != 3) {
|
||
KQWorkTime kqWorkTime = new KQWorkTime();
|
||
changeType = kqWorkTime.isWorkDay(resourceId, date) ? 2 : 3;
|
||
}
|
||
return changeType;
|
||
}
|
||
|
||
public TimeScopeEntity formatTimeScope(List<Object> timeScope, boolean needWorkMins){
|
||
KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo();
|
||
TimeScopeEntity timeScopeEntity = null;
|
||
for(int i=0;timeScope!=null && i<timeScope.size();i++){
|
||
Map<String,Object> obj = (Map<String,Object>)timeScope.get(i);
|
||
String bengintime_end = Util.null2String(obj.get("bengintime_end"));
|
||
String bengintime_end_across = Util.null2String(obj.get("bengintime_end_across"));
|
||
String endtime_start = Util.null2String(obj.get("endtime_start"));
|
||
String endtime_start_across = Util.null2String(obj.get("endtime_start_across"));
|
||
String bengintime_pre_across = Util.null2String(obj.get("bengintime_pre_across"));
|
||
timeScopeEntity = new TimeScopeEntity();
|
||
timeScopeEntity.setBeginTime(Util.null2String(obj.get("bengintime")));
|
||
timeScopeEntity.setBeginTimeAcross(Util.null2String(obj.get("bengintime_across")).equals("1"));//标记是否跨天
|
||
timeScopeEntity.setEndTime(Util.null2String(obj.get("endtime")));
|
||
timeScopeEntity.setEndTimeAcross(Util.null2String(obj.get("endtime_across")).equals("1"));//标记是否跨天
|
||
timeScopeEntity.setBeginTimePreAcross("1".equalsIgnoreCase(bengintime_pre_across));
|
||
|
||
if(needWorkMins) {
|
||
int workBeginIdx = kqTimesArrayComInfo.getArrayindexByTimes(timeScopeEntity.getBeginTime());
|
||
int workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(timeScopeEntity.getEndTime());
|
||
timeScopeEntity.setWorkMins(workEndIdx - workBeginIdx);
|
||
}
|
||
if((bengintime_end != null && bengintime_end.length() >0) || (endtime_start != null && endtime_start.length() > 0)){
|
||
TimeSignScopeEntity timeSignScopeEntity = new TimeSignScopeEntity();
|
||
timeSignScopeEntity.setBeginTimeEnd(bengintime_end);
|
||
timeSignScopeEntity.setBeginTimeEndAcross("1".equalsIgnoreCase(bengintime_end_across));
|
||
timeSignScopeEntity.setEndTimeStart(endtime_start);
|
||
timeSignScopeEntity.setEndTimeStartAcross("1".equalsIgnoreCase(endtime_start_across));
|
||
timeSignScopeEntity.setBeginTimePreAcross("1".equalsIgnoreCase(bengintime_pre_across));
|
||
timeScopeEntity.setTimeSignScopeEntity(timeSignScopeEntity);
|
||
}
|
||
}
|
||
return timeScopeEntity;
|
||
}
|
||
|
||
private synchronized void doComputingMode2(String resourceid, String splitDate,
|
||
DateTimeFormatter dateFormatter, Map<String, Integer> changeTypeMap,
|
||
Map<String, KQOvertimeRulesDetailEntity> overRulesDetailMap,
|
||
Map<String, List<String[]>> restTimeMap, Map<String, Integer> computingModeMap,
|
||
KQTimesArrayComInfo kqTimesArrayComInfo, String main_uuid) throws Exception{
|
||
String key = resourceid+"_"+splitDate;
|
||
//加班日志记录类
|
||
KQWorkTime kqWorkTime = new KQWorkTime();
|
||
WorkTimeEntity workTimeEntity = kqWorkTime.getWorkTime(resourceid, splitDate);
|
||
Map<String,Object> workTimeEntityLogMap = Maps.newHashMap();
|
||
workTimeEntityLogMap.put("resourceid", resourceid);
|
||
workTimeEntityLogMap.put("splitDate", splitDate);
|
||
workTimeEntityLogMap.put("workTimeEntity", workTimeEntity);
|
||
KQOvertimeLogBiz kqEventLogBiz = new KQOvertimeLogBiz();
|
||
String uuid = kqEventLogBiz.logDetailWorkTimeEntity(resourceid,workTimeEntityLogMap,main_uuid,"doComputingMode2|加班计算,需审批,以打卡为准,但是不能超过审批时长的加班时长|key|"+key);
|
||
Map<String,Object> overtimeLogMap = Maps.newLinkedHashMap();
|
||
|
||
Map<String,Object> eventMap = Maps.newHashMap();
|
||
Map<String, KQOvertimeCardBean> lsCheckInfoMaps = Maps.newLinkedHashMap();
|
||
//获取加班打卡数据
|
||
getOverTimeCardDataMap(resourceid, splitDate, splitDate, dateFormatter,kqTimesArrayComInfo,overRulesDetailMap,changeTypeMap,lsCheckInfoMaps,
|
||
eventMap);
|
||
|
||
kqEventLogBiz.logDetailOvertimeMap(resourceid,overtimeLogMap,uuid);
|
||
kqEventLogBiz.logDetailEvent(resourceid,eventMap,uuid,"doComputingMode2|对应的加班流程数据|key|"+key);
|
||
}
|
||
|
||
private Map<String,Object> doComputingMode3(String resourceid, String splitDate,
|
||
DateTimeFormatter dateFormatter, Map<String, Integer> changeTypeMap,
|
||
Map<String, KQOvertimeRulesDetailEntity> overRulesDetailMap,
|
||
Map<String, List<String[]>> restTimeMap, Map<String, Integer> computingModeMap,
|
||
KQTimesArrayComInfo kqTimesArrayComInfo, String main_uuid) throws Exception{
|
||
Map<String,Object> result = new HashMap<>();
|
||
|
||
String key = resourceid+"_"+splitDate;
|
||
//加班日志记录类
|
||
KQWorkTime kqWorkTime = new KQWorkTime();
|
||
WorkTimeEntity workTimeEntity = kqWorkTime.getWorkTime(resourceid, splitDate);
|
||
Map<String,Object> workTimeEntityLogMap = Maps.newHashMap();
|
||
workTimeEntityLogMap.put("resourceid", resourceid);
|
||
workTimeEntityLogMap.put("splitDate", splitDate);
|
||
workTimeEntityLogMap.put("workTimeEntity", workTimeEntity);
|
||
KQOvertimeLogBiz kqEventLogBiz = new KQOvertimeLogBiz();
|
||
String uuid = kqEventLogBiz.logDetailWorkTimeEntity(resourceid,workTimeEntityLogMap,main_uuid,"doComputingMode3|加班计算,无需审批,根据打卡时间计算加班时长|key|"+key);
|
||
Map<String,Object> overtimeLogMap = Maps.newLinkedHashMap();
|
||
|
||
Map<String,Object> eventMap = Maps.newHashMap();
|
||
Map<String, KQOvertimeCardBean> lsCheckInfoMaps = Maps.newLinkedHashMap();
|
||
|
||
result.put("999_splitDate",splitDate);
|
||
//获取加班打卡数据
|
||
getOverTimeCardDataMap(resourceid, splitDate, splitDate, dateFormatter,kqTimesArrayComInfo,overRulesDetailMap,changeTypeMap,lsCheckInfoMaps,
|
||
eventMap);
|
||
kqEventLogBiz.logDetailEvent(resourceid,eventMap,uuid,"doComputingMode3|对应的打卡数据|key|"+key);
|
||
|
||
if(lsCheckInfoMaps.isEmpty()){
|
||
logOvertimeMap(overtimeLogMap, "没有打卡数据", "打卡和上下班数据|KQOvertimeCardBean");
|
||
kqEventLogBiz.logDetailOvertimeMap(resourceid,overtimeLogMap,uuid);
|
||
// return;
|
||
}
|
||
result.put("999_lsCheckInfoMaps",lsCheckInfoMaps);
|
||
Iterator<Map.Entry<String, KQOvertimeCardBean>> iterator = lsCheckInfoMaps.entrySet().iterator();
|
||
while (iterator.hasNext()) {
|
||
Map.Entry<String, KQOvertimeCardBean> next = iterator.next();
|
||
String mapKey = next.getKey();
|
||
KQOvertimeCardBean kqOvertimeCardBean = next.getValue();
|
||
String[] mapKeys = mapKey.split("_");
|
||
if (mapKeys.length != 2) {
|
||
continue;
|
||
}
|
||
String realSplitDate = mapKeys[1];
|
||
result.put("realSplitDate"+realSplitDate,realSplitDate);
|
||
String change_key = realSplitDate+"_"+resourceid;
|
||
int changeType = Util.getIntValue(""+changeTypeMap.get(change_key),-1);
|
||
String changeType_key = realSplitDate+"_"+changeType;
|
||
String changetypeName = 1==changeType ? "节假日" : (2 == changeType ? "工作日" : (3 == changeType ? "休息日" : "异常"));
|
||
String changetypeLogInfo = change_key+"|changeType|"+changeType+"|"+changetypeName;
|
||
logOvertimeMap(overtimeLogMap, changetypeLogInfo, "加班日期属性|changetypeLogInfo");
|
||
|
||
clearOvertimeTX(resourceid, realSplitDate,overtimeLogMap, splitDate);
|
||
|
||
logOvertimeMap(overtimeLogMap, kqOvertimeCardBean, "打卡和上下班数据|KQOvertimeCardBean");
|
||
|
||
KQOvertimeRulesDetailEntity kqOvertimeRulesDetailEntity = overRulesDetailMap.get(changeType_key);
|
||
if(kqOvertimeRulesDetailEntity == null){
|
||
String overRuleInfo = "changeType_key:"+changeType_key+":kqOvertimeRulesDetailEntity:"+kqOvertimeRulesDetailEntity;
|
||
logOvertimeMap(overtimeLogMap, overRuleInfo, mapKey+"|"+"加班规则为null|kqOvertimeRulesDetailEntity");
|
||
continue;
|
||
}
|
||
int overtimeEnable = kqOvertimeRulesDetailEntity.getOvertimeEnable();
|
||
if(overtimeEnable != 1){
|
||
String overtimeEnableInfo = "overtimeEnable:"+overtimeEnable;
|
||
logOvertimeMap(overtimeLogMap, overtimeEnableInfo, mapKey+"|"+"未开启加班规则|overtimeEnable");
|
||
continue;
|
||
}
|
||
if(kqOvertimeCardBean != null){
|
||
|
||
int[] initArrays = kqTimesArrayComInfo.getInitArr();
|
||
Map<String,String> signinoffMap = buildOvertimeCard(kqOvertimeCardBean, resourceid, realSplitDate, kqTimesArrayComInfo, restTimeMap, changeType_key,initArrays,Lists.newArrayList(),overRulesDetailMap,
|
||
true, overtimeLogMap);
|
||
logOvertimeMap(overtimeLogMap, signinoffMap, "获取上下班打卡数据|signinoffMap");
|
||
|
||
String signinTime = Util.null2String(signinoffMap.get("signinTime"));
|
||
String signoutTime = Util.null2String(signinoffMap.get("signoutTime"));
|
||
String signinDate = Util.null2String(signinoffMap.get("signinDate"));
|
||
String signoutDate = Util.null2String(signinoffMap.get("signoutDate"));
|
||
int signinTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(signinTime);
|
||
int signoutTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(signoutTime);
|
||
String flow_cross_key = mapKey+"|"+"加班计算区间|"+signinTime+"-"+signoutTime;
|
||
|
||
|
||
if(signinTimeIndex < signoutTimeIndex){
|
||
int over_count = kqTimesArrayComInfo.getCnt(initArrays, signinTimeIndex, signoutTimeIndex, 1);
|
||
result.put("over_count"+realSplitDate,over_count);
|
||
String countLogInfo = "signinTimeIndex:"+signinTimeIndex+":signoutTimeIndex:"+signoutTimeIndex+":over_count:"+over_count;
|
||
logOvertimeMap(overtimeLogMap, countLogInfo, mapKey+"|"+"打卡区间,得到打卡时长|over_count");
|
||
if(over_count > 0){
|
||
//表示加班打卡是存在的
|
||
int restTimeType = 1;
|
||
if(kqOvertimeRulesDetailEntity != null){
|
||
int minimumLen = kqOvertimeRulesDetailEntity.getMinimumLen();
|
||
if(over_count < minimumLen){
|
||
continue;
|
||
}
|
||
logOvertimeMap(overtimeLogMap, JSON.toJSONString(kqOvertimeRulesDetailEntity), mapKey+"|"+"加班规则|KQOvertimeRulesDetailEntity");
|
||
//我这个方法是针对每次生成的加班数据做排除休息时长的处理
|
||
restTimeType = kqOvertimeRulesDetailEntity.getRestTimeType();
|
||
if(restTimeType == 2){
|
||
over_count = new KQOverTimeFlowBiz().handle_restlength(over_count,restTimeMap,changeType_key);
|
||
}
|
||
}
|
||
if(over_count <= 0){
|
||
logOvertimeMap(overtimeLogMap, "没有打卡数据", mapKey+"|"+"打卡时长|over_count");
|
||
continue;
|
||
}
|
||
logOvertimeMap(overtimeLogMap, over_count, mapKey+"|"+"经历过休息时间之后的加班时长|over_rest_count");
|
||
|
||
int mins = over_count;
|
||
double double_mins = getD_MinsByUnit((1.0*mins));
|
||
mins = (int)double_mins;
|
||
|
||
RecordSet rs = new RecordSet();
|
||
String overtime_uuid = UUID.randomUUID().toString();
|
||
String tiaoxiuId = "";
|
||
String workingHours = "";
|
||
int computingMode = 3;
|
||
|
||
Map<String,Object> otherParam = Maps.newHashMap();
|
||
int unit = KQOvertimeRulesBiz.getMinimumUnit();
|
||
|
||
int paidLeaveEnable = kqOvertimeRulesDetailEntity.getPaidLeaveEnable();
|
||
int paidLeaveEnableType = kqOvertimeRulesDetailEntity.getPaidLeaveEnableType();
|
||
boolean needSplitByTime = false;//getNeedSplitByTime(kqOvertimeRulesDetailEntity, paidLeaveEnable);
|
||
result.put("needSplitByTime",needSplitByTime);
|
||
if(needSplitByTime){
|
||
// 按照加班时长转调休的 时长设置
|
||
List<String> timepointList = null;
|
||
if(kqOvertimeRulesDetailEntity != null){
|
||
timepointList = get_timepointList(kqOvertimeRulesDetailEntity);
|
||
logOvertimeMap(overtimeLogMap, timepointList, flow_cross_key+"|如果要生成调休且是根据时间区间来转调休,返回对应的时间区间|timepointList");
|
||
}
|
||
|
||
List<OvertimeBalanceTimeBean> overtimeBalanceTimeBeans = Lists.newArrayList();
|
||
if(timepointList != null && !timepointList.isEmpty()){
|
||
int[] time_initArrays = kqTimesArrayComInfo.getInitArr();
|
||
for(int t = signinTimeIndex;t < signoutTimeIndex; t++){
|
||
time_initArrays[t] = initArrays[t];
|
||
}
|
||
get_overtimeBalanceTimeBeans(timepointList,overtimeBalanceTimeBeans,kqTimesArrayComInfo,time_initArrays,signoutTimeIndex,signinTimeIndex,1);
|
||
}
|
||
String overtimeBalanceTimeBeansLogInfo = "";
|
||
if(overtimeBalanceTimeBeans == null || overtimeBalanceTimeBeans.isEmpty()){
|
||
}else{
|
||
overtimeBalanceTimeBeansLogInfo = JSON.toJSONString(overtimeBalanceTimeBeans);
|
||
}
|
||
logOvertimeMap(overtimeLogMap, overtimeBalanceTimeBeansLogInfo, flow_cross_key+"|如果要生成调休且是根据时间区间来转调休,返回对应的时间区间对应的时长|overtimeBalanceTimeBeans");
|
||
|
||
if(overtimeBalanceTimeBeans != null && !overtimeBalanceTimeBeans.isEmpty()){
|
||
String bean_cross_fromtime = signinTime;
|
||
String bean_cross_totime = signoutTime;
|
||
for(int timeIndex = 0 ; timeIndex < overtimeBalanceTimeBeans.size() ;timeIndex++) {
|
||
OvertimeBalanceTimeBean overtimeBalanceTimeBean = overtimeBalanceTimeBeans.get(timeIndex);
|
||
String timePointStart = overtimeBalanceTimeBean.getTimepoint_start();
|
||
String timePointEnd = overtimeBalanceTimeBean.getTimepoint_end();
|
||
int timePointStart_index = kqTimesArrayComInfo.getArrayindexByTimes(timePointStart);
|
||
int timePointEnd_index = kqTimesArrayComInfo.getArrayindexByTimes(timePointEnd);
|
||
if(timePointStart_index > signinTimeIndex){
|
||
bean_cross_fromtime = kqTimesArrayComInfo.getTimesByArrayindex(timePointStart_index);
|
||
}else{
|
||
bean_cross_fromtime = signinTime;
|
||
}
|
||
if(timePointEnd_index < signoutTimeIndex){
|
||
bean_cross_totime = kqTimesArrayComInfo.getTimesByArrayindex(timePointEnd_index);
|
||
}else{
|
||
bean_cross_totime = signoutTime;
|
||
}
|
||
int timepoint_mins = overtimeBalanceTimeBean.getTimepoint_mins();
|
||
if(timepoint_mins == 0){
|
||
continue;
|
||
}
|
||
mins = timepoint_mins;
|
||
otherParam.put("OvertimeBalanceTimeBean", overtimeBalanceTimeBean);
|
||
otherParam.put("overtimeLogMap", overtimeLogMap);
|
||
String timepoint_key = flow_cross_key+"|调休按照分段计算加班时间("+signinTime+"-"+signoutTime+")";
|
||
otherParam.put("timepoint_key", timepoint_key);
|
||
logOvertimeMap(overtimeLogMap, mins, timepoint_key+"最终生成的加班分钟数|overtime_mins");
|
||
|
||
tiaoxiuId = KQBalanceOfLeaveBiz.addExtraAmountByDis5(resourceid,realSplitDate,mins+"","0",workingHours,"","",realSplitDate,otherParam);
|
||
if(Util.getIntValue(tiaoxiuId) > 0){
|
||
kqLog.info("de.jsp doComputingMode3 生成调休成功,调休id:"+tiaoxiuId+":resourceid:"+resourceid+":realSplitDate:"+realSplitDate);
|
||
}else{
|
||
kqLog.info("de.jsp doComputingMode3 生成调休失败,调休id:"+tiaoxiuId+":resourceid:"+resourceid+":realSplitDate:"+realSplitDate);
|
||
}
|
||
overtime_uuid = UUID.randomUUID().toString();
|
||
|
||
Map<String,Object> overMap = Maps.newHashMap();
|
||
|
||
overMap.put("resourceid",resourceid);
|
||
overMap.put("requestid","");
|
||
overMap.put("fromdate",signinDate);
|
||
overMap.put("fromtime",signinTime);
|
||
overMap.put("todate",signoutDate);
|
||
overMap.put("totime",signoutTime);
|
||
overMap.put("duration_min",mins);
|
||
overMap.put("belongdate",realSplitDate);
|
||
overMap.put("fromdatedb","");
|
||
overMap.put("fromtimedb","");
|
||
overMap.put("todatedb","");
|
||
overMap.put("totimedb","");
|
||
overMap.put("ori_belongdate",splitDate);
|
||
|
||
result.put("3_overMap_0",overMap);
|
||
|
||
String flow_overtime_sql = "insert into kq_flow_overtime (requestid,resourceid,fromdate,fromtime,todate,totime,duration_min,expiringdate,belongdate,"
|
||
+ "workMins,durationrule,changetype,paidLeaveEnable,computingMode,tiaoxiuId,uuid,fromdatedb,fromtimedb,todatedb,totimedb,flow_mins,ori_belongdate)"+
|
||
" values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) ";
|
||
signinTime = kqTimesArrayComInfo.turn48to24Time(signinTime);
|
||
signoutTime = kqTimesArrayComInfo.turn48to24Time(signoutTime);
|
||
|
||
boolean bool = checkIsBeforeOvertime(resourceid,realSplitDate,computingMode,
|
||
signinDate,signinTime,signoutDate,signoutTime,
|
||
"","","","",splitDate);
|
||
|
||
result.put("checkIsBeforeOvertime",bool);
|
||
|
||
//不是 班前加班的。就不插入了
|
||
if(!bool){
|
||
boolean isUp = rs.executeUpdate(flow_overtime_sql, "",resourceid,signinDate,signinTime,signoutDate,signoutTime,mins,"",realSplitDate,
|
||
"",unit,changeType,paidLeaveEnable,computingMode,tiaoxiuId,overtime_uuid,"","","","",0,splitDate);
|
||
|
||
String overtimeid = get_overtime_uuid(overtime_uuid);
|
||
kqEventLogBiz.updateOvertimeId(uuid, overtimeid);
|
||
}
|
||
|
||
}
|
||
}
|
||
}else{
|
||
|
||
logOvertimeMap(overtimeLogMap, mins, flow_cross_key+"|最终生成的加班分钟数|overtime_mins");
|
||
tiaoxiuId = KQBalanceOfLeaveBiz.addExtraAmountByDis5(resourceid,realSplitDate,mins+"","0",workingHours,"","",realSplitDate,otherParam);
|
||
if(Util.getIntValue(tiaoxiuId) > 0){
|
||
kqLog.info("de.jsp doComputingMode3 生成调休成功,调休id:"+tiaoxiuId+":resourceid:"+resourceid+":realSplitDate:"+realSplitDate);
|
||
}else{
|
||
kqLog.info("de.jsp doComputingMode3 生成调休失败,调休id:"+tiaoxiuId+":resourceid:"+resourceid+":realSplitDate:"+realSplitDate);
|
||
}
|
||
|
||
signinTime = kqTimesArrayComInfo.turn48to24Time(signinTime);
|
||
signoutTime = kqTimesArrayComInfo.turn48to24Time(signoutTime);
|
||
|
||
Map<String,Object> overMap = Maps.newHashMap();
|
||
|
||
overMap.put("resourceid",resourceid);
|
||
overMap.put("requestid","");
|
||
overMap.put("fromdate",signinDate);
|
||
overMap.put("fromtime",signinTime);
|
||
overMap.put("todate",signoutDate);
|
||
overMap.put("totime",signoutTime);
|
||
overMap.put("duration_min",mins);
|
||
overMap.put("belongdate",realSplitDate);
|
||
overMap.put("fromdatedb","");
|
||
overMap.put("fromtimedb","");
|
||
overMap.put("todatedb","");
|
||
overMap.put("totimedb","");
|
||
overMap.put("ori_belongdate",splitDate);
|
||
|
||
result.put("3_overMap_1",overMap);
|
||
|
||
String flow_overtime_sql = "insert into kq_flow_overtime (requestid,resourceid,fromdate,fromtime,todate,totime,duration_min,expiringdate,belongdate,"
|
||
+ "workMins,durationrule,changetype,paidLeaveEnable,computingMode,tiaoxiuId,uuid,fromdatedb,fromtimedb,todatedb,totimedb,flow_mins,ori_belongdate)"+
|
||
" values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) ";
|
||
signinTime = kqTimesArrayComInfo.turn48to24Time(signinTime);
|
||
signoutTime = kqTimesArrayComInfo.turn48to24Time(signoutTime);
|
||
|
||
boolean bool = checkIsBeforeOvertime(resourceid,realSplitDate,computingMode,
|
||
signinDate,signinTime,signoutDate,signoutTime,
|
||
"","","","",splitDate);
|
||
result.put("checkIsBeforeOvertime",bool);
|
||
|
||
// bool:true 代表是 班前加班的。加班结束时间=班次开始时间 就不插入了
|
||
if(!bool) {
|
||
boolean isUp = rs.executeUpdate(flow_overtime_sql, "",resourceid,signinDate,signinTime,signoutDate,signoutTime,mins,"",realSplitDate,
|
||
"",unit,changeType,paidLeaveEnable,computingMode,tiaoxiuId,overtime_uuid,"","","","",0,splitDate);
|
||
String overtimeid = get_overtime_uuid(overtime_uuid);
|
||
kqEventLogBiz.updateOvertimeId(uuid, overtimeid);
|
||
}
|
||
}
|
||
|
||
}
|
||
}else{
|
||
logOvertimeMap(overtimeLogMap, "打卡区间不正确|"+flow_cross_key, mapKey+"|"+"打卡区间,得到打卡时长|over_count");
|
||
}
|
||
}else{
|
||
logOvertimeMap(overtimeLogMap, "打卡数据KQOvertimeCardBean为null", mapKey+"|"+"打卡和上下班数据|KQOvertimeCardBean");
|
||
}
|
||
}
|
||
kqEventLogBiz.logDetailOvertimeMap(resourceid,overtimeLogMap,uuid);
|
||
kqEventLogBiz.logDetailEvent(resourceid,eventMap,uuid,"doComputingMode3|对应的加班流程数据|key|"+key);
|
||
|
||
return result;
|
||
}
|
||
|
||
private Map<String, Object> doComputingMode4(String resourceid, String splitDate,
|
||
DateTimeFormatter dateFormatter, Map<String, Integer> changeTypeMap,
|
||
Map<String, KQOvertimeRulesDetailEntity> overRulesDetailMap,
|
||
Map<String, List<String[]>> restTimeMap, Map<String, Integer> computingModeMap,
|
||
KQTimesArrayComInfo kqTimesArrayComInfo, String main_uuid) throws Exception{
|
||
|
||
Map<String,Object> result = new HashMap<>();
|
||
|
||
String key = resourceid+"_"+splitDate;
|
||
//加班日志记录类
|
||
KQWorkTime kqWorkTime = new KQWorkTime();
|
||
WorkTimeEntity workTimeEntity = kqWorkTime.getWorkTime(resourceid, splitDate);
|
||
Map<String,Object> workTimeEntityLogMap = Maps.newHashMap();
|
||
workTimeEntityLogMap.put("resourceid", resourceid);
|
||
workTimeEntityLogMap.put("splitDate", splitDate);
|
||
workTimeEntityLogMap.put("workTimeEntity", workTimeEntity);
|
||
KQOvertimeLogBiz kqEventLogBiz = new KQOvertimeLogBiz();
|
||
String uuid = kqEventLogBiz.logDetailWorkTimeEntity(resourceid,workTimeEntityLogMap,main_uuid,"doComputingMode4|加班计算,需审批,以打卡为准,取流程和打卡的交集|key|"+key);
|
||
Map<String,Object> overtimeLogMap = Maps.newLinkedHashMap();
|
||
|
||
Map<String,Object> eventMap = Maps.newLinkedHashMap();
|
||
Map<String, KQOvertimeCardBean> lsCheckInfoMaps = Maps.newLinkedHashMap();
|
||
//获取加班打卡数据
|
||
getOverTimeCardDataMap(resourceid, splitDate, splitDate, dateFormatter,kqTimesArrayComInfo,overRulesDetailMap,changeTypeMap,lsCheckInfoMaps,eventMap);
|
||
|
||
if(lsCheckInfoMaps.isEmpty()){
|
||
logOvertimeMap(overtimeLogMap, "没有打卡数据", "打卡和上下班数据|KQOvertimeCardBean");
|
||
kqEventLogBiz.logDetailOvertimeMap(resourceid,overtimeLogMap,uuid);
|
||
kqEventLogBiz.logDetailEvent(resourceid,eventMap,uuid,"doComputingMode4|对应的加班流程数据|key|"+key);
|
||
// return;
|
||
}
|
||
RecordSet rs = new RecordSet();
|
||
|
||
|
||
Iterator<Map.Entry<String, KQOvertimeCardBean>> iterator = lsCheckInfoMaps.entrySet().iterator();
|
||
while (iterator.hasNext()) {
|
||
Map.Entry<String, KQOvertimeCardBean> next = iterator.next();
|
||
String mapKey = next.getKey();
|
||
KQOvertimeCardBean kqOvertimeCardBean = next.getValue();
|
||
String[] mapKeys = mapKey.split("_");
|
||
if (mapKeys.length != 2) {
|
||
continue;
|
||
}
|
||
String realSplitDate = mapKeys[1];
|
||
|
||
Map<String,List<SplitBean>> splitBeanMaps = Maps.newHashMap();
|
||
//获取加班流程数据
|
||
getOverTimeFlowData(resourceid,realSplitDate,realSplitDate,splitBeanMaps,dateFormatter);
|
||
|
||
String change_key = realSplitDate+"_"+resourceid;
|
||
int changeType = Util.getIntValue(""+changeTypeMap.get(change_key),-1);
|
||
String changeType_key = realSplitDate+"_"+changeType;
|
||
String changetypeName = 1==changeType ? "节假日" : (2 == changeType ? "工作日" : (3 == changeType ? "休息日" : "异常"));
|
||
String changetypeLogInfo = change_key+"|changeType|"+changeType+"|"+changetypeName;
|
||
logOvertimeMap(overtimeLogMap, changetypeLogInfo, mapKey+"|"+"加班日期属性|changetypeLogInfo");
|
||
|
||
clearOvertimeTX(resourceid, realSplitDate,overtimeLogMap,splitDate);
|
||
|
||
logOvertimeMap(overtimeLogMap, kqOvertimeCardBean, mapKey+"|"+"打卡和上下班数据|KQOvertimeCardBean");
|
||
|
||
KQOvertimeRulesDetailEntity kqOvertimeRulesDetailEntity = overRulesDetailMap.get(changeType_key);
|
||
if(kqOvertimeRulesDetailEntity == null){
|
||
String overRuleInfo = "changeType_key:"+changeType_key+":kqOvertimeRulesDetailEntity:"+kqOvertimeRulesDetailEntity;
|
||
logOvertimeMap(overtimeLogMap, overRuleInfo, mapKey+"|"+"加班规则为null|kqOvertimeRulesDetailEntity");
|
||
continue;
|
||
}
|
||
int overtimeEnable = kqOvertimeRulesDetailEntity.getOvertimeEnable();
|
||
if(overtimeEnable != 1){
|
||
String overtimeEnableInfo = "overtimeEnable:"+overtimeEnable;
|
||
logOvertimeMap(overtimeLogMap, overtimeEnableInfo, mapKey+"|"+"未开启加班规则|overtimeEnable");
|
||
continue;
|
||
}
|
||
|
||
if(kqOvertimeCardBean != null){
|
||
int[] initArrays = kqTimesArrayComInfo.getInitArr();
|
||
List<Map<String, String>> hasOverTime4SignList = Lists.newArrayList();
|
||
getHasOverTimeData(resourceid,realSplitDate,hasOverTime4SignList);
|
||
Map<String,String> signinoffMap = buildOvertimeCard(kqOvertimeCardBean, resourceid, realSplitDate, kqTimesArrayComInfo, restTimeMap, changeType_key,initArrays,hasOverTime4SignList,
|
||
overRulesDetailMap,true,overtimeLogMap);
|
||
logOvertimeMap(overtimeLogMap, signinoffMap, mapKey+"|"+"获取上下班打卡数据|signinoffMap");
|
||
|
||
String signinTime = Util.null2String(signinoffMap.get("signinTime"));
|
||
String signoutTime = Util.null2String(signinoffMap.get("signoutTime"));
|
||
String signinDate = Util.null2String(signinoffMap.get("signinDate"));
|
||
String signoutDate = Util.null2String(signinoffMap.get("signoutDate"));
|
||
int signinTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(signinTime);
|
||
int signoutTimeIndex = kqTimesArrayComInfo.getArrayindexByTimes(signoutTime);
|
||
|
||
if(signinTimeIndex < signoutTimeIndex){
|
||
//先覆盖打卡 打卡区间都是1
|
||
kqLog.writeLog("de.jsp initArrays " + Arrays.toString(initArrays));
|
||
kqLog.writeLog("de.jsp signinTimeIndex " + signinTimeIndex);
|
||
kqLog.writeLog("de.jsp signoutTimeIndex " + signoutTimeIndex);
|
||
int over_count = kqTimesArrayComInfo.getCnt(initArrays, signinTimeIndex, signoutTimeIndex, 1);
|
||
String overCountLogInfo = "signinTimeIndex:"+signinTimeIndex+":signoutTimeIndex:"+signoutTimeIndex+":over_count:"+over_count;
|
||
logOvertimeMap(overtimeLogMap, overCountLogInfo, mapKey+"|"+"打卡区间,得到打卡时长|over_count");
|
||
kqLog.writeLog("de.jsp " + mapKey+"|"+"打卡区间,得到打卡时长|over_count " + over_count);
|
||
if(over_count > 0){
|
||
int restTimeType = 1;
|
||
String kqOvertimeRulesDetailEntityLogInfo = kqOvertimeRulesDetailEntity==null ? "" :JSON.toJSONString(kqOvertimeRulesDetailEntity);
|
||
logOvertimeMap(overtimeLogMap, kqOvertimeRulesDetailEntityLogInfo, mapKey+"|具体这个人这一天对应的加班规则|KQOvertimeRulesDetailEntity");
|
||
int minimumLen = -1;
|
||
if(kqOvertimeRulesDetailEntity != null){
|
||
minimumLen = kqOvertimeRulesDetailEntity.getMinimumLen();
|
||
kqLog.writeLog("de.jsp minimumLen " + minimumLen);
|
||
if(over_count < minimumLen){
|
||
String minInfo = "over_count:"+over_count+":minimumLen:"+minimumLen;
|
||
logOvertimeMap(overtimeLogMap, minInfo, mapKey+"|打卡时长小于最小加班时长|over_count<minimumUnit");
|
||
continue;
|
||
}
|
||
}
|
||
if(splitBeanMaps.containsKey(mapKey)) {
|
||
List<SplitBean> splitBeans = splitBeanMaps.get(mapKey);
|
||
kqLog.writeLog("de.jsp splitBeanMaps.containsKey(mapKey) "+ splitBeanMaps.containsKey(mapKey));
|
||
String flowinfo = "";
|
||
if(splitBeans != null && !splitBeans.isEmpty()){
|
||
flowinfo = JSON.toJSONString(splitBeans, SerializerFeature.DisableCheckSpecialChar,SerializerFeature.DisableCircularReferenceDetect);
|
||
}
|
||
eventMap.put(mapKey+"|"+"加班流程数据|flowinfo", flowinfo);
|
||
|
||
if(splitBeans == null || splitBeans.isEmpty()){
|
||
// return;
|
||
}
|
||
kqLog.writeLog("de.jsp splitBeans "+ splitBeanMaps);
|
||
for (int m = 0; m < splitBeans.size(); m++) {
|
||
SplitBean splitBean = splitBeans.get(m);
|
||
String dataid = splitBean.getDataId();
|
||
String detailid = splitBean.getDetailId();
|
||
String flow_fromdate = splitBean.getFromDate();
|
||
String flow_fromtime = splitBean.getFromTime();
|
||
String flow_todate = splitBean.getToDate();
|
||
String flow_totime = splitBean.getToTime();
|
||
String fromdatedb = splitBean.getFromdatedb();
|
||
String fromtimedb = splitBean.getFromtimedb();
|
||
String todatedb = splitBean.getTodatedb();
|
||
String totimedb = splitBean.getTotimedb();
|
||
String requestid = splitBean.getRequestId();
|
||
double d_mins = splitBean.getD_Mins();
|
||
if(d_mins <= 0){
|
||
continue;
|
||
}
|
||
String flow_key = mapKey+"|"+"flow_fromdate|"+flow_fromdate+"|flow_todate|"+flow_todate
|
||
+"|flow_fromtime|"+flow_fromtime+"|flow_totime|"+flow_totime;
|
||
List<Integer> cross_time_list = Lists.newArrayList();
|
||
kqLog.writeLog("de.jsp flow_key "+ flow_key);
|
||
get_cross_time_list(cross_time_list,initArrays,signinTimeIndex,signoutTimeIndex,1,-2);
|
||
kqLog.writeLog("de.jsp signinTimeIndex "+ signinTimeIndex);
|
||
kqLog.writeLog("de.jsp signoutTimeIndex "+ signoutTimeIndex);
|
||
kqLog.writeLog("de.jsp initArrays "+ Arrays.toString(initArrays));
|
||
kqLog.writeLog("de.jsp initArrays.length "+ initArrays.length);
|
||
logOvertimeMap(overtimeLogMap, cross_time_list, flow_key+"|cross_time_list");
|
||
int[] initArrays_flow = Arrays.copyOfRange(initArrays,0,initArrays.length);
|
||
if(flow_fromdate.compareTo(realSplitDate) > 0){
|
||
flow_fromtime = kqTimesArrayComInfo.turn24to48Time(flow_fromtime);
|
||
}
|
||
if(flow_todate.compareTo(realSplitDate) > 0){
|
||
flow_totime = kqTimesArrayComInfo.turn24to48Time(flow_totime);
|
||
}
|
||
kqLog.writeLog("de.jsp flow_fromtime "+ flow_fromtime);
|
||
kqLog.writeLog("de.jsp flow_totime "+ flow_totime);
|
||
|
||
int flow_fromIndex = kqTimesArrayComInfo.getArrayindexByTimes(flow_fromtime);
|
||
int flow_toIndex = kqTimesArrayComInfo.getArrayindexByTimes(flow_totime);
|
||
|
||
kqLog.writeLog("de.jsp flow_fromIndex "+ flow_fromIndex);
|
||
kqLog.writeLog("de.jsp flow_toIndex "+ flow_toIndex);
|
||
|
||
result.put("flow_fromIndex444",""+flow_fromIndex);
|
||
result.put("flow_toIndex444",""+flow_toIndex);
|
||
//在已经打卡的区间1上覆盖2,那么在有效打卡范围内是2的就是交集的部分
|
||
Arrays.fill(initArrays_flow, flow_fromIndex, flow_toIndex,2);
|
||
|
||
int across_mins = 0;
|
||
for(int i = 0 ; i < cross_time_list.size() ;) {
|
||
int cross_fromtime_index = cross_time_list.get(i);
|
||
int cross_totime_index = cross_time_list.get(i + 1);
|
||
//前面打卡区间段已经都被流程给覆盖了,所以取获取打卡区间段内有多少流程的标识2,就是交叉部分了
|
||
int flow_count = kqTimesArrayComInfo.getCnt(initArrays_flow, cross_fromtime_index, cross_totime_index, 2);
|
||
logOvertimeMap(overtimeLogMap, flow_count, flow_key+"|取打卡和流程相交的时长|flow_count");
|
||
|
||
if(flow_count > 0){
|
||
List<Integer> flow_cross_time_list = Lists.newArrayList();
|
||
// 找到2表示找到流程开始的点了,找到1表示找到流程结束的点了
|
||
get_cross_time_list(flow_cross_time_list,initArrays_flow,cross_fromtime_index,cross_totime_index,2,1);
|
||
|
||
logOvertimeMap(overtimeLogMap, flow_cross_time_list, flow_key+"|取打卡和流程相交的区间|flow_cross_time_list");
|
||
for(int j = 0 ; j < flow_cross_time_list.size() ;){
|
||
int flow_cross_fromtime_index = flow_cross_time_list.get(j);
|
||
int flow_cross_totime_index = flow_cross_time_list.get(j+1);
|
||
|
||
int mins = flow_cross_totime_index-flow_cross_fromtime_index;
|
||
if(mins <= 0){
|
||
String crossInfo = "flow_cross_fromtime_index:"+flow_cross_fromtime_index+":flow_cross_totime_index:"+flow_cross_totime_index+":mins:"+mins;
|
||
logOvertimeMap(overtimeLogMap, crossInfo, flow_key+"|打卡时长小于最小加班时长|crossInfo");
|
||
continue;
|
||
}
|
||
across_mins += mins;
|
||
|
||
String flow_cross_key = "加班计算区间|"+kqTimesArrayComInfo.getTimesByArrayindex(flow_cross_fromtime_index)+"-"+kqTimesArrayComInfo.getTimesByArrayindex(flow_cross_totime_index);
|
||
logOvertimeMap(overtimeLogMap, mins, flow_cross_key+"|原始加班区间生成的加班时长|mins");
|
||
|
||
String cross_fromtime = kqTimesArrayComInfo.getTimesByArrayindex(flow_cross_fromtime_index);
|
||
String cross_totime = kqTimesArrayComInfo.getTimesByArrayindex(flow_cross_totime_index);
|
||
String cross_fromdate = realSplitDate;
|
||
String cross_todate = realSplitDate;
|
||
|
||
boolean needSplitByTime = false;
|
||
if(needSplitByTime){
|
||
// 按照加班时长转调休的 时长设置 这个逻辑如果后面要开启来可以直接用的
|
||
List<String> timepointList = null;
|
||
if(kqOvertimeRulesDetailEntity != null){
|
||
timepointList = get_timepointList(kqOvertimeRulesDetailEntity);
|
||
logOvertimeMap(overtimeLogMap, timepointList, flow_cross_key+"|如果要生成调休且是根据时间区间来转调休,返回对应的时间区间|timepointList");
|
||
}
|
||
|
||
List<OvertimeBalanceTimeBean> overtimeBalanceTimeBeans = Lists.newArrayList();
|
||
if(timepointList != null && !timepointList.isEmpty()){
|
||
int[] time_initArrays = kqTimesArrayComInfo.getInitArr();
|
||
for(int t = flow_cross_fromtime_index;t < flow_cross_totime_index; t++){
|
||
time_initArrays[t] = initArrays_flow[t];
|
||
}
|
||
get_overtimeBalanceTimeBeans(timepointList,overtimeBalanceTimeBeans,kqTimesArrayComInfo,time_initArrays,flow_cross_totime_index,flow_cross_fromtime_index,2);
|
||
}
|
||
String overtimeBalanceTimeBeansLogInfo = "";
|
||
if(overtimeBalanceTimeBeans == null || overtimeBalanceTimeBeans.isEmpty()){
|
||
}else{
|
||
overtimeBalanceTimeBeansLogInfo = JSON.toJSONString(overtimeBalanceTimeBeans);
|
||
}
|
||
logOvertimeMap(overtimeLogMap, overtimeBalanceTimeBeansLogInfo, flow_cross_key+"|如果要生成调休且是根据时间区间来转调休,返回对应的时间区间对应的时长|overtimeBalanceTimeBeans");
|
||
|
||
if(overtimeBalanceTimeBeans != null && !overtimeBalanceTimeBeans.isEmpty()){
|
||
String bean_cross_fromtime = cross_fromtime;
|
||
String bean_cross_totime = cross_totime;
|
||
for(int timeIndex = 0 ; timeIndex < overtimeBalanceTimeBeans.size() ;timeIndex++){
|
||
OvertimeBalanceTimeBean overtimeBalanceTimeBean = overtimeBalanceTimeBeans.get(timeIndex);
|
||
String timePointStart = overtimeBalanceTimeBean.getTimepoint_start();
|
||
String timePointEnd = overtimeBalanceTimeBean.getTimepoint_end();
|
||
boolean isNeedTX = overtimeBalanceTimeBean.isNeedTX();
|
||
int timePointStart_index = kqTimesArrayComInfo.getArrayindexByTimes(timePointStart);
|
||
int timePointEnd_index = kqTimesArrayComInfo.getArrayindexByTimes(timePointEnd);
|
||
if(timePointStart_index > flow_cross_fromtime_index){
|
||
bean_cross_fromtime = kqTimesArrayComInfo.getTimesByArrayindex(timePointStart_index);
|
||
}else{
|
||
bean_cross_fromtime = cross_fromtime;
|
||
}
|
||
if(timePointEnd_index < flow_cross_totime_index){
|
||
bean_cross_totime = kqTimesArrayComInfo.getTimesByArrayindex(timePointEnd_index);
|
||
}else{
|
||
bean_cross_totime = cross_totime;
|
||
}
|
||
int timepoint_mins = overtimeBalanceTimeBean.getTimepoint_mins();
|
||
if(timepoint_mins == 0){
|
||
continue;
|
||
}
|
||
mins = timepoint_mins;
|
||
}
|
||
}
|
||
}else{
|
||
}
|
||
j =j + 2;
|
||
} }else{
|
||
|
||
}
|
||
i = i +2;
|
||
}
|
||
|
||
if(kqOvertimeRulesDetailEntity != null){
|
||
//我这个方法是针对每次生成的加班数据做排除休息时长的处理
|
||
restTimeType = kqOvertimeRulesDetailEntity.getRestTimeType();
|
||
if(restTimeType == 2){
|
||
across_mins = new KQOverTimeFlowBiz().handle_restlength(across_mins,restTimeMap,changeType_key);
|
||
}
|
||
}
|
||
int card_mins = over_count;
|
||
double double_mins = getD_MinsByUnit((1.0*across_mins));
|
||
across_mins = (int)double_mins;
|
||
if(across_mins <= 0){
|
||
logOvertimeMap(overtimeLogMap, across_mins, flow_key+"|经过单位换算之后时长为0|across_mins");
|
||
continue;
|
||
}
|
||
if(across_mins < minimumLen){
|
||
String minInfo = "across_mins:"+across_mins+":minimumLen:"+minimumLen;
|
||
logOvertimeMap(overtimeLogMap, minInfo, flow_key+"|打卡时长小于最小加班时长|over_count<minimumUnit");
|
||
continue;
|
||
|
||
}
|
||
|
||
String overtime_uuid = UUID.randomUUID().toString();
|
||
String tiaoxiuId = "";
|
||
String flow_dataid = dataid+"_"+detailid;
|
||
int computingMode = 4;
|
||
|
||
int unit = KQOvertimeRulesBiz.getMinimumUnit();
|
||
String workingHours = "";
|
||
String overtime_type = splitBean.getOvertime_type();
|
||
Map<String,Object> otherParam = Maps.newHashMap();
|
||
otherParam.put("overtime_type", overtime_type);
|
||
int paidLeaveEnableType = kqOvertimeRulesDetailEntity.getPaidLeaveEnableType();
|
||
if(2 == paidLeaveEnableType){
|
||
logOvertimeMap(overtimeLogMap, overtime_type, flow_key+"|关联调休与否来自于流程选择,加班类型下拉框值|overtime_type");
|
||
}
|
||
|
||
int paidLeaveEnable = getPaidLeaveEnable(kqOvertimeRulesDetailEntity, overtime_type);
|
||
//目前不处理按照时间段生成调休
|
||
boolean needSplitByTime = false;//getNeedSplitByTime(kqOvertimeRulesDetailEntity, paidLeaveEnable);
|
||
if(needSplitByTime){
|
||
|
||
}else{
|
||
otherParam.put("overtimeLogMap", overtimeLogMap);
|
||
logOvertimeMap(overtimeLogMap, across_mins, flow_key+"|最终生成的加班分钟数|overtime_mins");
|
||
tiaoxiuId = KQBalanceOfLeaveBiz.addExtraAmountByDis5(resourceid,realSplitDate,across_mins+"","0",workingHours,requestid,"1",realSplitDate,otherParam);
|
||
if(Util.getIntValue(tiaoxiuId) > 0){
|
||
kqLog.info("de.jsp doComputingMode4 生成调休成功,调休id:"+tiaoxiuId+":resourceid:"+resourceid+":realSplitDate:"+realSplitDate+";across_mins="+across_mins);
|
||
result.put("MESSAGE","doComputingMode4 生成调休成功,调休id:"+tiaoxiuId+":resourceid:"+resourceid+":realSplitDate:"+realSplitDate+";across_mins="+across_mins);
|
||
}else{
|
||
kqLog.info("de.jsp doComputingMode4 生成调休失败,调休id:"+tiaoxiuId+":resourceid:"+resourceid+":realSplitDate:"+realSplitDate+";across_mins="+across_mins);
|
||
result.put("MESSAGE","doComputingMode4 生成调休失败,调休id:"+tiaoxiuId+":resourceid:"+resourceid+":realSplitDate:"+realSplitDate+";across_mins="+across_mins);
|
||
}
|
||
logOvertimeMap(overtimeLogMap, tiaoxiuId, flow_key+"|最终生成的调休id|tiaoxiuId");
|
||
|
||
|
||
Map<String,Object> overMap = Maps.newHashMap();
|
||
|
||
overMap.put("resourceid",resourceid);
|
||
overMap.put("requestid",requestid);
|
||
overMap.put("fromdate",signinDate);
|
||
overMap.put("fromtime",signinTime);
|
||
overMap.put("todate",signoutDate);
|
||
overMap.put("totime",signoutTime);
|
||
overMap.put("duration_min",across_mins);
|
||
overMap.put("belongdate",realSplitDate);
|
||
overMap.put("fromdatedb",fromdatedb);
|
||
overMap.put("fromtimedb",fromtimedb);
|
||
overMap.put("todatedb",todatedb);
|
||
overMap.put("totimedb",totimedb);
|
||
overMap.put("ori_belongdate",splitDate);
|
||
|
||
result.put("4_overMap_0",overMap);
|
||
|
||
String flow_overtime_sql = "insert into kq_flow_overtime (requestid,resourceid,fromdate,fromtime,todate,totime,duration_min,expiringdate,belongdate,"
|
||
+ "workMins,durationrule,changetype,paidLeaveEnable,computingMode,tiaoxiuId,uuid,fromdatedb,fromtimedb,todatedb,totimedb,flow_mins,card_mins,ori_belongdate,flow_dataid)"+
|
||
" values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) ";
|
||
signinTime = kqTimesArrayComInfo.turn48to24Time(signinTime);
|
||
signoutTime = kqTimesArrayComInfo.turn48to24Time(signoutTime);
|
||
if(signinTime.length() == 5){
|
||
signinTime = signinTime+":00";
|
||
}
|
||
if(signoutTime.length() == 5){
|
||
signoutTime = signoutTime+":00";
|
||
}
|
||
|
||
boolean bool = checkIsBeforeOvertime(resourceid,realSplitDate,computingMode,
|
||
signinDate,signinTime,signoutDate,signoutTime,
|
||
fromdatedb,fromtimedb,todatedb,totimedb,splitDate);
|
||
|
||
boolean booll = checkIsAfterOvertime(resourceid,realSplitDate,computingMode,
|
||
signinDate,signinTime,signoutDate,signoutTime,
|
||
fromdatedb,fromtimedb,todatedb,totimedb,splitDate);
|
||
|
||
result.put("checkIsBeforeOvertime",bool);
|
||
result.put("checkIsAfterOvertime",booll);
|
||
//不是 班前加班的。就不插入了
|
||
if(!bool){
|
||
//是班后加班的,归属日期改为前一天也就是原归属日期
|
||
if(booll){
|
||
realSplitDate = splitDate;
|
||
}
|
||
boolean isUp = rs.executeUpdate(flow_overtime_sql, requestid,resourceid,signinDate,signinTime,signoutDate,signoutTime,across_mins,"",realSplitDate,
|
||
"",unit,changeType,paidLeaveEnable,computingMode,tiaoxiuId,overtime_uuid,fromdatedb,fromtimedb,todatedb,totimedb,d_mins,card_mins,splitDate,flow_dataid);
|
||
|
||
String overtimeid = get_overtime_uuid(overtime_uuid);
|
||
result.put("overtimeid",overtimeid);
|
||
kqEventLogBiz.updateOvertimeId(uuid, overtimeid);
|
||
}
|
||
|
||
}
|
||
}
|
||
}else{
|
||
result.put("thisino","加班流程为空,啥也没干");
|
||
//有打卡没有流程
|
||
logOvertimeMap(overtimeLogMap, mapKey, mapKey+"|"+"加班流程为空");
|
||
result.put("MESSAGE",mapKey+"|"+"加班流程为空");
|
||
}
|
||
}else{
|
||
logOvertimeMap(overtimeLogMap, overCountLogInfo, mapKey+"|"+"打卡数据时长为0");
|
||
result.put("MESSAGE",mapKey+"|"+"打卡数据时长为0");
|
||
}
|
||
}else{
|
||
String overCountLogInfo = "signinTimeIndex:"+signinTimeIndex+":signoutTimeIndex:"+signoutTimeIndex;
|
||
logOvertimeMap(overtimeLogMap, overCountLogInfo, mapKey+"|"+"打卡数据异常");
|
||
result.put("MESSAGE",mapKey+"|"+"打卡数据异常");
|
||
}
|
||
}else{
|
||
logOvertimeMap(overtimeLogMap, "打卡数据KQOvertimeCardBean为null", mapKey+"|"+"打卡和上下班数据|KQOvertimeCardBean");
|
||
result.put("MESSAGE",mapKey+"|"+"打卡和上下班数据|KQOvertimeCardBean");
|
||
}
|
||
}
|
||
kqEventLogBiz.logDetailOvertimeMap(resourceid,overtimeLogMap,uuid);
|
||
kqEventLogBiz.logDetailEvent(resourceid,eventMap,uuid,"doComputingMode4|对应的加班流程数据|key|"+key);
|
||
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取生成的加班id
|
||
* @param overtime_uuid
|
||
* @return
|
||
*/
|
||
public String get_overtime_uuid(String overtime_uuid) {
|
||
RecordSet rs = new RecordSet();
|
||
String sql = "select * from kq_flow_overtime where uuid='"+overtime_uuid+"' ";
|
||
rs.executeQuery(sql);
|
||
if(rs.next()){
|
||
return rs.getString("id");
|
||
}
|
||
return "";
|
||
}
|
||
|
||
/**
|
||
* 判断某天的加班结束时间是否等于班次开始时间、加班开始时间是否等于班次结束时间
|
||
* @param resourceId
|
||
* @param kqDate
|
||
* @return
|
||
*/
|
||
public boolean checkIsSpecial(String resourceId,String kqDate,String signintime,String signouttime){
|
||
boolean bool = false;
|
||
RecordSet rs = new RecordSet();
|
||
RecordSet rs1 = new RecordSet();
|
||
rs.executeQuery("select * from kq_format_detail where resourceid = " + resourceId + " and kqdate ='" + kqDate + "'");
|
||
while(rs.next()){
|
||
String resourceid = Util.null2String(rs.getString("resourceid"));
|
||
String kqdate = Util.null2String(rs.getString("kqdate"));
|
||
String groupid = Util.null2String(rs.getString("groupid"));
|
||
String serialid = Util.null2String(rs.getString("serialid"));
|
||
String workbegindate = Util.null2String(rs.getString("workbegindate")).trim();
|
||
String workbegintime = Util.null2String(rs.getString("workbegintime")).trim();
|
||
String workenddate = Util.null2String(rs.getString("workenddate")).trim();
|
||
String workendtime = Util.null2String(rs.getString("workendtime")).trim();
|
||
|
||
if(signouttime.equals(workbegintime)){
|
||
bool = true;
|
||
}
|
||
if(signintime.equals(workendtime)){
|
||
bool = true;
|
||
}
|
||
|
||
}
|
||
return bool;
|
||
}
|
||
|
||
public void getOverTimeCardDataMap(String resourceid, String fromDate, String toDate,
|
||
DateTimeFormatter dateFormatter,
|
||
KQTimesArrayComInfo kqTimesArrayComInfo,
|
||
Map<String, KQOvertimeRulesDetailEntity> overRulesDetailMap,
|
||
Map<String, Integer> changeTypeMap, Map<String, KQOvertimeCardBean> lsCheckInfoMaps,
|
||
Map<String, Object> eventMap) throws Exception{
|
||
|
||
KQOverTimeFlowBiz kqOverTimeFlowBiz = new KQOverTimeFlowBiz();
|
||
|
||
List<Object> lsCheckInfos = Lists.newArrayList();
|
||
Map<String,String> result = getSignData(resourceid, fromDate, dateFormatter,eventMap,lsCheckInfos,changeTypeMap,overRulesDetailMap);
|
||
// return result;
|
||
|
||
//获取一下当天的上班时间
|
||
String firstworkDate = Util.null2String(result.get("firstworkDate"));
|
||
String firstworkTime = Util.null2String(result.get("firstworkTime"));
|
||
int pre_has_cut_point = Util.getIntValue(Util.null2String(result.get("pre_has_cut_point")));
|
||
String pre_cut_point = Util.null2String(result.get("pre_cut_point"));
|
||
int has_cut_point = Util.getIntValue(Util.null2String(result.get("has_cut_point")));
|
||
String cut_point = Util.null2String(result.get("cut_point"));
|
||
int before_startTime = Util.getIntValue(Util.null2String(result.get("before_startTime")));
|
||
int preChangeType = Util.getIntValue(Util.null2String(result.get("preChangeType")));
|
||
int changeType = Util.getIntValue(Util.null2String(result.get("changeType")));
|
||
|
||
LocalDate localbelongDate = LocalDate.parse(fromDate);
|
||
String splitDate = localbelongDate.format(dateFormatter);
|
||
LocalDate preLocalDate = localbelongDate.minusDays(1);
|
||
String preSplitDate = preLocalDate.format(dateFormatter);
|
||
String nextSplitDate = localbelongDate.plusDays(1).format(dateFormatter);
|
||
|
||
String preKey = resourceid+"_"+preSplitDate;
|
||
String key = resourceid+"_"+splitDate;
|
||
String nextkey = resourceid+"_"+nextSplitDate;
|
||
|
||
eventMap.put("lsCheckInfos", lsCheckInfos);
|
||
if(!lsCheckInfos.isEmpty()){
|
||
Map<String, Object> signMap = (Map<String, Object>) lsCheckInfos.get(0);
|
||
String signindate = "";
|
||
String signintime = "";
|
||
String signoutdate = "";
|
||
String signouttime = "";
|
||
|
||
if(signMap != null && !signMap.isEmpty()){
|
||
signindate = Util.null2String(signMap.get("signindate"));
|
||
signintime = Util.null2String(signMap.get("signintime"));
|
||
signoutdate = Util.null2String(signMap.get("signoutdate"));
|
||
signouttime = Util.null2String(signMap.get("signouttime"));
|
||
if(lsCheckInfos.size() > 1){
|
||
Map<String, Object> lastSignMap = (Map<String, Object>) lsCheckInfos.get(lsCheckInfos.size()-1);
|
||
signoutdate = Util.null2String(lastSignMap.get("signoutdate"));
|
||
signouttime = Util.null2String(lastSignMap.get("signouttime"));
|
||
}
|
||
}
|
||
KQOvertimeCardBean kqOvertimeBean = new KQOvertimeCardBean();
|
||
kqOvertimeBean.setSigninDate(signindate);
|
||
kqOvertimeBean.setSigninTime(signintime);
|
||
kqOvertimeBean.setSignoutDate(signoutdate);
|
||
kqOvertimeBean.setSignoutTime(signouttime);
|
||
eventMap.put("has_cut_point", has_cut_point);
|
||
if(pre_has_cut_point == 0){
|
||
//未设置打卡归属
|
||
if(preChangeType == 2){
|
||
eventMap.put("preChangeType", preChangeType);
|
||
//如果前一天是工作日
|
||
String pre_overtime_cut_point = "";
|
||
ShiftInfoBean pre_shiftInfoBean = KQDurationCalculatorUtil
|
||
.getWorkTime(resourceid, preSplitDate, false);
|
||
if(pre_shiftInfoBean != null){
|
||
List<int[]> workLongTimeIndex = pre_shiftInfoBean.getWorkLongTimeIndex();
|
||
List<int[]> real_workLongTimeIndex = Lists.newArrayList();
|
||
SplitBean splitBean = new SplitBean();
|
||
splitBean.setResourceId(resourceid);
|
||
kqOverTimeFlowBiz.get_real_workLongTimeIndex(workLongTimeIndex,real_workLongTimeIndex,pre_shiftInfoBean,kqTimesArrayComInfo,splitBean);
|
||
|
||
if(real_workLongTimeIndex != null && !real_workLongTimeIndex.isEmpty()){
|
||
pre_overtime_cut_point = kqTimesArrayComInfo.getTimesByArrayindex(real_workLongTimeIndex.get(0)[0]);
|
||
}
|
||
eventMap.put("pre_overtime_cut_point", pre_overtime_cut_point);
|
||
if(pre_overtime_cut_point.length() >= 0){
|
||
rePutCheckInfoMap(lsCheckInfoMaps, kqOvertimeBean, preKey, key, pre_overtime_cut_point, splitDate,eventMap);
|
||
}
|
||
}else{
|
||
String errorMsg = "前一天是工作日但是前一天的ShiftInfoBean班次获取不到信息";
|
||
eventMap.put("errorMsg", errorMsg);
|
||
}
|
||
}else {
|
||
eventMap.put("changeType", changeType);
|
||
if(changeType == 2){
|
||
eventMap.put("firstworkTime", firstworkTime);
|
||
if(has_cut_point == 1 && before_startTime > 0){
|
||
firstworkTime = kqTimesArrayComInfo.getTimesByArrayindex(kqTimesArrayComInfo.getArrayindexByTimes(firstworkTime)-before_startTime);
|
||
}
|
||
//如果前一天是非工作日,今天是工作日的话
|
||
rePutCheckInfoMap(lsCheckInfoMaps, kqOvertimeBean, preKey, key, firstworkTime, splitDate,
|
||
eventMap);
|
||
}else{
|
||
//如果前一天是非工作日,今天是非工作日的话,那就是打卡获取的是啥就是啥
|
||
lsCheckInfoMaps.put(key, kqOvertimeBean);
|
||
}
|
||
}
|
||
}else{
|
||
String pre_splittime = "";
|
||
List<Object> pre_lsCheckInfos = Lists.newArrayList();
|
||
getSignData(resourceid, preSplitDate, dateFormatter, eventMap, pre_lsCheckInfos, changeTypeMap, overRulesDetailMap);
|
||
if(!pre_lsCheckInfos.isEmpty()){
|
||
Map<String, Object> preSignMap = (Map<String, Object>) pre_lsCheckInfos.get(0);
|
||
String pre_signindate = "";
|
||
String pre_signintime = "";
|
||
String pre_signoutdate = "";
|
||
String pre_signouttime = "";
|
||
if(preSignMap != null && !preSignMap.isEmpty()){
|
||
pre_signindate = Util.null2String(preSignMap.get("signindate"));
|
||
pre_signintime = Util.null2String(preSignMap.get("signintime"));
|
||
pre_signoutdate = Util.null2String(preSignMap.get("signoutdate"));
|
||
pre_signouttime = Util.null2String(preSignMap.get("signouttime"));
|
||
if(pre_signindate.length() > 0 && pre_signintime.length() > 0){
|
||
pre_splittime = pre_signindate+" "+pre_signintime;
|
||
}else if(pre_signoutdate.length() > 0 && pre_signouttime.length() > 0){
|
||
pre_splittime = pre_signoutdate+" "+pre_signouttime;
|
||
}
|
||
}
|
||
}
|
||
eventMap.put("pre_cut_point", pre_cut_point);
|
||
//设置了打卡归属 那么一天的打卡就可能被前一天给拆成两部分和后一天的打卡归属给拆分成两部分
|
||
rePutCheckInfoCutPointMap(lsCheckInfoMaps, kqOvertimeBean, preKey, key, pre_cut_point, splitDate,
|
||
eventMap,cut_point,nextSplitDate,nextkey,has_cut_point,pre_splittime);
|
||
}
|
||
}
|
||
}
|
||
|
||
public void rePutCheckInfoCutPointMap(Map<String, KQOvertimeCardBean> lsCheckInfoMaps,
|
||
KQOvertimeCardBean kqOvertimeBean, String preKey, String key, String pre_cut_point,
|
||
String splitDate, Map<String, Object> eventMap, String cut_point, String nextDate,
|
||
String nextkey, int has_cut_point, String pre_splitdatetime) {
|
||
String preDate = DateUtil.addDate(splitDate, -1);
|
||
KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo();
|
||
|
||
String pre_cut_points = pre_cut_point+":00";
|
||
String pre_date_cut_point = splitDate+" "+pre_cut_points;
|
||
|
||
String cut_points = cut_point+":00";
|
||
String cur_date_cut_point = nextDate+" "+cut_points;
|
||
|
||
String signindate = kqOvertimeBean.getSigninDate();
|
||
String signoutdate = kqOvertimeBean.getSignoutDate();
|
||
String signintime = kqOvertimeBean.getSigninTime();
|
||
String signouttime = kqOvertimeBean.getSignoutTime();
|
||
String signindatetime = kqOvertimeBean.getSigninDate()+" "+kqOvertimeBean.getSigninTime();
|
||
String signoutdatetime = "";
|
||
if(kqOvertimeBean.getSignoutDate().length() > 0 && kqOvertimeBean.getSignoutTime().length() > 0){
|
||
//如果是休息日的话,可能存在没有上班时间的情况
|
||
signoutdatetime = kqOvertimeBean.getSignoutDate()+" "+kqOvertimeBean.getSignoutTime();
|
||
}
|
||
String pre_splittime_date = "";
|
||
String pre_splittime_time = "";
|
||
if(pre_splitdatetime.length() > 0){
|
||
String[] pre_splittimes = pre_splitdatetime.split(" ");
|
||
if(pre_splittimes.length == 2){
|
||
pre_splittime_date = pre_splittimes[0];
|
||
pre_splittime_time = pre_splittimes[1];
|
||
}
|
||
}
|
||
|
||
String timeInfo = "date_cut_point:"+pre_date_cut_point+":signoutdatetime:"+signoutdatetime+":signindatetime:"+signindatetime;
|
||
String timeCompare1 = "date_cut_point.compareTo(signoutdatetime):"+pre_date_cut_point.compareTo(signoutdatetime);
|
||
String timeCompare2 = "date_cut_point.compareTo(signindatetime):"+pre_date_cut_point.compareTo(signindatetime);
|
||
eventMap.put("timeInfo", timeInfo);
|
||
eventMap.put("timeCompare1", timeCompare1);
|
||
eventMap.put("timeCompare2", timeCompare2);
|
||
if(pre_date_cut_point.compareTo(signindatetime) > 0){
|
||
//如果归属大于签到时间,小于签退时间,表示归属之前是属于前一天的,归属之后的是属于今天的
|
||
//开启了归属之后,归属点之前的打卡就属于前一天的签退卡了,相当于是从前一天的下班时间到这个卡都算是前一天的加班卡,和不开归属的时候不一样
|
||
KQOvertimeCardBean preKqOvertimeBean = new KQOvertimeCardBean();
|
||
if(pre_splittime_date.length() > 0 && pre_splittime_time.length() > 0){
|
||
preKqOvertimeBean.setSigninDate(pre_splittime_date);
|
||
preKqOvertimeBean.setSigninTime(pre_splittime_time);
|
||
preKqOvertimeBean.setSignoutDate(signindate);
|
||
preKqOvertimeBean.setSignoutTime(signintime);
|
||
preKqOvertimeBean.setBelongDate(preDate);
|
||
lsCheckInfoMaps.put(preKey, preKqOvertimeBean);
|
||
}
|
||
if(signoutdatetime.length() > 0 && signoutdatetime.compareTo(pre_date_cut_point) > 0){
|
||
KQOvertimeCardBean curOvertimeBean = new KQOvertimeCardBean();
|
||
curOvertimeBean.setSigninDate(splitDate);
|
||
curOvertimeBean.setSigninTime(pre_cut_points);
|
||
curOvertimeBean.setSignoutDate(signoutdate);
|
||
curOvertimeBean.setSignoutTime(signouttime);
|
||
curOvertimeBean.setBelongDate(splitDate);
|
||
lsCheckInfoMaps.put(key, curOvertimeBean);
|
||
}
|
||
|
||
}else if(signoutdatetime.length() > 0 && pre_date_cut_point.compareTo(signoutdatetime) > 0){
|
||
//如果归属大于签退时间 表示这个时间都是属于前一天的
|
||
lsCheckInfoMaps.put(preKey, kqOvertimeBean);
|
||
}else {
|
||
lsCheckInfoMaps.put(key, kqOvertimeBean);
|
||
}
|
||
if(signoutdate.length() > 0){
|
||
if(signoutdate.compareTo(splitDate) > 0){
|
||
if(1 == has_cut_point){
|
||
//如果签退大于签到 表示打卡跨天
|
||
if(cur_date_cut_point.compareTo(signoutdatetime) < 0){
|
||
String hasSigninDate = signindate;
|
||
String hasSigninTime = signintime;
|
||
if(lsCheckInfoMaps.containsKey(key)){
|
||
KQOvertimeCardBean hasOvertimeBean = lsCheckInfoMaps.get(key);
|
||
hasSigninDate = hasOvertimeBean.getSigninDate();
|
||
hasSigninTime = hasOvertimeBean.getSigninTime();
|
||
}
|
||
KQOvertimeCardBean curOvertimeBean = new KQOvertimeCardBean();
|
||
curOvertimeBean.setSigninDate(hasSigninDate);
|
||
curOvertimeBean.setSigninTime(hasSigninTime);
|
||
curOvertimeBean.setSignoutDate(nextDate);
|
||
curOvertimeBean.setSignoutTime(cut_points);
|
||
curOvertimeBean.setBelongDate(splitDate);
|
||
lsCheckInfoMaps.put(key, curOvertimeBean);
|
||
|
||
KQOvertimeCardBean nextOvertimeBean = new KQOvertimeCardBean();
|
||
nextOvertimeBean.setSigninDate(nextDate);
|
||
nextOvertimeBean.setSigninTime(cut_points);
|
||
nextOvertimeBean.setSignoutDate(signoutdate);
|
||
nextOvertimeBean.setSignoutTime(signouttime);
|
||
nextOvertimeBean.setBelongDate(nextDate);
|
||
lsCheckInfoMaps.put(nextkey, nextOvertimeBean);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
public void rePutCheckInfoMap(Map<String, KQOvertimeCardBean> lsCheckInfoMaps,
|
||
KQOvertimeCardBean kqOvertimeBean,
|
||
String preKey, String key, String overtime_cut_point, String splitDate,
|
||
Map<String, Object> eventMap){
|
||
|
||
String preDate = DateUtil.addDate(splitDate, -1);
|
||
String overtime_cut_points = overtime_cut_point+":00";
|
||
String date_cut_point = splitDate+" "+overtime_cut_points;
|
||
String signindate = kqOvertimeBean.getSigninDate();
|
||
String signoutdate = kqOvertimeBean.getSignoutDate();
|
||
String signintime = kqOvertimeBean.getSigninTime();
|
||
String signouttime = kqOvertimeBean.getSignoutTime();
|
||
String signindatetime = kqOvertimeBean.getSigninDate()+" "+kqOvertimeBean.getSigninTime();
|
||
String signoutdatetime = "";
|
||
if(kqOvertimeBean.getSignoutDate().length() > 0 && kqOvertimeBean.getSignoutTime().length() > 0){
|
||
//如果是休息日的话,可能存在没有上班时间的情况
|
||
signoutdatetime = kqOvertimeBean.getSignoutDate()+" "+kqOvertimeBean.getSignoutTime();
|
||
}
|
||
|
||
String timeInfo = "date_cut_point:"+date_cut_point+":signoutdatetime:"+signoutdatetime+":signindatetime:"+signindatetime;
|
||
String timeCompare1 = "date_cut_point.compareTo(signoutdatetime):"+date_cut_point.compareTo(signoutdatetime);
|
||
String timeCompare2 = "date_cut_point.compareTo(signindatetime):"+date_cut_point.compareTo(signindatetime);
|
||
eventMap.put("timeInfo", timeInfo);
|
||
eventMap.put("timeCompare1", timeCompare1);
|
||
eventMap.put("timeCompare2", timeCompare2);
|
||
if(date_cut_point.compareTo(signindatetime) > 0){
|
||
//如果归属大于签到时间,小于签退时间,表示归属之前是属于前一天的,归属之后的是属于今天的
|
||
//不开启了归属的时候,根据打卡的性质来判断,如果是签到卡,那么签到时间到前一天上班时间,这段区间内算是前一天的加班卡,和开启了归属不一样
|
||
KQOvertimeCardBean preKqOvertimeBean = new KQOvertimeCardBean();
|
||
preKqOvertimeBean.setSigninDate(signindate);
|
||
preKqOvertimeBean.setSigninTime(signintime);
|
||
preKqOvertimeBean.setSignoutDate(splitDate);
|
||
preKqOvertimeBean.setSignoutTime(overtime_cut_points);
|
||
preKqOvertimeBean.setBelongDate(preDate);
|
||
preKqOvertimeBean.setHas_cut_point("0");
|
||
lsCheckInfoMaps.put(preKey, preKqOvertimeBean);
|
||
|
||
if(signoutdatetime.length() > 0 && signoutdatetime.compareTo(date_cut_point) > 0){
|
||
KQOvertimeCardBean curOvertimeBean = new KQOvertimeCardBean();
|
||
curOvertimeBean.setSigninDate(splitDate);
|
||
curOvertimeBean.setSigninTime(overtime_cut_points);
|
||
curOvertimeBean.setSignoutDate(signoutdate);
|
||
curOvertimeBean.setSignoutTime(signouttime);
|
||
curOvertimeBean.setBelongDate(splitDate);
|
||
curOvertimeBean.setHas_cut_point("0");
|
||
lsCheckInfoMaps.put(key, curOvertimeBean);
|
||
}
|
||
}else if(signoutdatetime.length() > 0 && date_cut_point.compareTo(signoutdatetime) > 0){
|
||
//如果归属大于签退时间 表示这个时间都是属于前一天的
|
||
lsCheckInfoMaps.put(preKey, kqOvertimeBean);
|
||
}else{
|
||
//如果归属 小于签到时间,则都属于今天
|
||
lsCheckInfoMaps.put(key, kqOvertimeBean);
|
||
}
|
||
}
|
||
|
||
public void logOvertimeMap(Map<String, Object> overtimeLogMap,Object params, String keys){
|
||
if(overtimeLogMap != null){
|
||
overtimeLogMap.put(keys, params);
|
||
}
|
||
}
|
||
|
||
public void clearOvertimeTX(String resourceid, String belongdate,
|
||
Map<String, Object> overtimeLogMap, String splitDate) {
|
||
List<String> all_tiaoxiuidList = Lists.newArrayList();
|
||
String all_tiaoxiuids = "";
|
||
RecordSet rs = new RecordSet();
|
||
String sql = "select * from kq_flow_overtime where resourceid = ? and belongdate=? and ori_belongdate=? ";
|
||
rs.executeQuery(sql,resourceid, belongdate,splitDate);
|
||
while (rs.next()){
|
||
String tiaoxiuid = Util.null2String(rs.getString("tiaoxiuid"),"");
|
||
if(tiaoxiuid.length() > 0 && Util.getIntValue(tiaoxiuid) > 0){
|
||
all_tiaoxiuids += ","+tiaoxiuid;
|
||
all_tiaoxiuidList.add(tiaoxiuid);
|
||
}
|
||
}
|
||
logOvertimeMap(overtimeLogMap, all_tiaoxiuids, "需要重新生成的调休|all_tiaoxiuids");
|
||
if(all_tiaoxiuids.length() > 0){
|
||
all_tiaoxiuids = all_tiaoxiuids.substring(1);
|
||
|
||
Map<String,String> tiaoxiuamountMap = Maps.newLinkedHashMap();
|
||
String selSql = "select * from kq_balanceofleave where "+Util.getSubINClause(all_tiaoxiuids, "id", "in");
|
||
rs.executeQuery(selSql);
|
||
while (rs.next()){
|
||
String id = rs.getString("id");
|
||
String tiaoxiuamount = rs.getString("tiaoxiuamount");
|
||
tiaoxiuamountMap.put(id, tiaoxiuamount);
|
||
}
|
||
if(!tiaoxiuamountMap.isEmpty()){
|
||
logOvertimeMap(overtimeLogMap, tiaoxiuamountMap, "先记录下之前的加班生成的调休数据|tiaoxiuamountMap");
|
||
}
|
||
String tiaoxiuidis0 = "";
|
||
String delSql0 = "select * from kq_balanceofleave where "+Util.getSubINClause(all_tiaoxiuids, "id", "in")+" and "
|
||
+ " baseamount =0 and extraamount=0 and usedamount=0 and baseamount2=0 and extraamount2=0 and usedamount2=0 ";
|
||
if(rs.getDBType().equalsIgnoreCase("oracle")) {
|
||
delSql0 = "select * from kq_balanceofleave where "+Util.getSubINClause(all_tiaoxiuids, "id", "in")+" and "
|
||
+ " nvl(baseamount,0) =0 and nvl(extraamount,0)=0 and nvl(usedamount,0)=0 and nvl(baseamount2,0)=0 "
|
||
+ " and nvl(extraamount2,0)=0 and nvl(usedamount2,0)=0 ";
|
||
}else if((rs.getDBType()).equalsIgnoreCase("mysql")){
|
||
delSql0 = "select * from kq_balanceofleave where "+Util.getSubINClause(all_tiaoxiuids, "id", "in")+" and "
|
||
+ " ifnull(baseamount,0) =0 and ifnull(extraamount,0)=0 and ifnull(usedamount,0)=0 and ifnull(baseamount2,0)=0 "
|
||
+ " and ifnull(extraamount2,0)=0 and ifnull(usedamount2,0)=0 ";
|
||
}else {
|
||
delSql0 = "select * from kq_balanceofleave where "+Util.getSubINClause(all_tiaoxiuids, "id", "in")+" and "
|
||
+ " isnull(baseamount,0) =0 and isnull(extraamount,0)=0 and isnull(usedamount,0)=0 and isnull(baseamount2,0)=0 "
|
||
+ " and isnull(extraamount2,0)=0 and isnull(usedamount2,0)=0 ";
|
||
}
|
||
rs.executeQuery(delSql0);
|
||
while (rs.next()){
|
||
String tiaoxiuid = Util.null2String(rs.getString("id"),"");
|
||
if(tiaoxiuid.length() > 0 && Util.getIntValue(tiaoxiuid) > 0){
|
||
tiaoxiuidis0 += ","+tiaoxiuid;
|
||
all_tiaoxiuidList.remove(tiaoxiuid);
|
||
}
|
||
}
|
||
String delSql = "";
|
||
if(tiaoxiuidis0.length() > 0){
|
||
delSql = "delete from kq_balanceofleave where "+Util.getSubINClause(tiaoxiuidis0, "id", "in");
|
||
boolean flag= rs.executeUpdate(delSql);
|
||
if (!flag) {
|
||
kqLog.info("加班流程删除之前的调休数据失败:数据库更新失败" );
|
||
}
|
||
}
|
||
String clearSql = "";
|
||
boolean isclearOk = false;
|
||
if(!all_tiaoxiuidList.isEmpty()){
|
||
String clear_tiaoxiuids = all_tiaoxiuidList.stream().collect(Collectors.joining(","));
|
||
clearSql = "update kq_balanceofleave set tiaoxiuamount=0.0 where "+Util.getSubINClause(clear_tiaoxiuids, "id", "in");
|
||
isclearOk = rs.executeUpdate(clearSql);
|
||
}
|
||
|
||
String delUsageSql = "delete from kq_usagehistory where "+Util.getSubINClause(all_tiaoxiuids, "balanceofleaveid", "in");
|
||
boolean isdelUsageOk = rs.executeUpdate(delUsageSql);
|
||
Map<String,Object> logSqlMap = Maps.newLinkedHashMap();
|
||
logSqlMap.put("tiaoxiuidis0",tiaoxiuidis0);
|
||
logSqlMap.put("all_tiaoxiuidList",all_tiaoxiuidList);
|
||
logSqlMap.put("delSql",delSql);
|
||
logSqlMap.put("clearSql",clearSql);
|
||
logSqlMap.put("isclearOk",isclearOk);
|
||
logSqlMap.put("delUsageSql",delUsageSql);
|
||
logSqlMap.put("isdelUsageOk",isdelUsageOk);
|
||
logOvertimeMap(overtimeLogMap, logSqlMap, "需要重新生成的调休对应的信息|logSqlMap");
|
||
}
|
||
String delSql = "delete from kq_flow_overtime where resourceid = ? and belongdate=? and ori_belongdate=?";
|
||
boolean isDelOk = rs.executeUpdate(delSql,resourceid, belongdate,splitDate);
|
||
// String delSql = "delete from kq_flow_overtime where resourceid = ? and belongdate=?";
|
||
// boolean isDelOk = rs.executeUpdate(delSql,resourceid, belongdate);
|
||
String delSqlLog = delSql+":resourceid:"+resourceid+":belongdate:"+belongdate+":splitDate:"+splitDate+":isDelOk:"+isDelOk;
|
||
logOvertimeMap(overtimeLogMap, delSqlLog, "删除加班中间表数据|delSql");
|
||
|
||
}
|
||
|
||
public Map<String, String> getSignData(String resourceid, String belongDate,
|
||
DateTimeFormatter dateFormatter, Map<String, Object> eventMap,
|
||
List<Object> lsCheckInfos, Map<String, Integer> changeTypeMap,
|
||
Map<String, KQOvertimeRulesDetailEntity> overRulesDetailMap) throws Exception{
|
||
Map<String,String> result = Maps.newHashMap();
|
||
String firstworkDate = "";
|
||
String firstworkTime = "";
|
||
|
||
KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo();
|
||
LocalDate localbelongDate = LocalDate.parse(belongDate);
|
||
String splitDate = localbelongDate.format(dateFormatter);
|
||
LocalDate preLocalDate = localbelongDate.minusDays(1);
|
||
String preSplitDate = preLocalDate.format(dateFormatter);
|
||
String nextSplitDate = localbelongDate.plusDays(1).format(dateFormatter);
|
||
|
||
String change_key = splitDate+"_"+resourceid;
|
||
String preChange_key = preSplitDate+"_"+resourceid;
|
||
String nextChange_key = nextSplitDate+"_"+resourceid;
|
||
int changeType = Util.getIntValue(""+changeTypeMap.get(change_key),-1);
|
||
int preChangeType = Util.getIntValue(""+changeTypeMap.get(preChange_key),-1);
|
||
int nextChangeType = Util.getIntValue(""+changeTypeMap.get(nextChange_key),-1);
|
||
String changeType_key = splitDate+"_"+changeType;
|
||
String preChangeType_key = preSplitDate+"_"+preChangeType;
|
||
String nextChangeType_key = nextSplitDate+"_"+nextChangeType;
|
||
|
||
KQOvertimeRulesDetailEntity curKqOvertimeRulesDetailEntity = overRulesDetailMap.get(changeType_key);
|
||
KQOvertimeRulesDetailEntity preKqOvertimeRulesDetailEntity = overRulesDetailMap.get(preChangeType_key);
|
||
KQOvertimeRulesDetailEntity nextKqOvertimeRulesDetailEntity = overRulesDetailMap.get(preChangeType_key);
|
||
|
||
int pre_has_cut_point = 0;
|
||
String pre_cut_point = "";
|
||
if(preKqOvertimeRulesDetailEntity != null){
|
||
pre_has_cut_point = preKqOvertimeRulesDetailEntity.getHas_cut_point();
|
||
pre_cut_point = preKqOvertimeRulesDetailEntity.getCut_point();
|
||
}
|
||
int has_cut_point = 0;
|
||
String cut_point = "";
|
||
int before_startTime = -1;
|
||
if(curKqOvertimeRulesDetailEntity != null){
|
||
has_cut_point = curKqOvertimeRulesDetailEntity.getHas_cut_point();
|
||
cut_point = curKqOvertimeRulesDetailEntity.getCut_point();
|
||
before_startTime =curKqOvertimeRulesDetailEntity.getBefore_startTime();
|
||
}
|
||
|
||
result.put("pre_has_cut_point", ""+pre_has_cut_point);
|
||
result.put("pre_cut_point", pre_cut_point);
|
||
result.put("has_cut_point", ""+has_cut_point);
|
||
result.put("cut_point", cut_point);
|
||
result.put("before_startTime", ""+before_startTime);
|
||
result.put("preChangeType", ""+preChangeType);
|
||
result.put("changeType", ""+changeType);
|
||
|
||
KQWorkTime kqWorkTime = new KQWorkTime();
|
||
WorkTimeEntity workTime = kqWorkTime.getWorkTime(resourceid, splitDate);
|
||
|
||
LocalDate pre_curLocalDate = localbelongDate.minusDays(1);
|
||
String preDate = pre_curLocalDate.format(dateFormatter);
|
||
LocalDate next_curLocalDate = localbelongDate.plusDays(1);
|
||
String nextDate = next_curLocalDate.format(dateFormatter);
|
||
|
||
if (workTime == null || (workTime.getWorkMins() == 0 && workTime.getRestShift() != 1)) {
|
||
Map<String, Object> signMap = getRestSignInfo(resourceid,splitDate,preDate,nextDate,curKqOvertimeRulesDetailEntity,eventMap,preKqOvertimeRulesDetailEntity);
|
||
if(signMap != null && !signMap.isEmpty()){
|
||
lsCheckInfos.add(signMap);
|
||
}
|
||
}else{
|
||
if (workTime.getKQType().equals("3")) {//自由工时
|
||
//目前自由工时不加班
|
||
} else {
|
||
boolean oneSign = false;
|
||
List<TimeScopeEntity> lsSignTime = new ArrayList<>();
|
||
List<TimeScopeEntity> lsWorkTime = new ArrayList<>();
|
||
List<TimeScopeEntity> lsRestTime = new ArrayList<>();
|
||
oneSign = lsWorkTime!=null&&lsWorkTime.size()==1;
|
||
boolean need_middle_time = false;
|
||
|
||
if (workTime != null) {
|
||
lsSignTime = workTime.getSignTime();//允许打卡时间
|
||
lsWorkTime = workTime.getWorkTime();//工作时间
|
||
result.put("lsWorkTime_size", ""+lsWorkTime.size());
|
||
lsRestTime = workTime.getRestTime();//休息时段时间
|
||
oneSign = lsWorkTime!=null&&lsWorkTime.size()==1;
|
||
for (int i = 0; lsWorkTime != null && i < lsWorkTime.size(); i++) {
|
||
TimeScopeEntity signTimeScope = lsSignTime.get(i);
|
||
TimeScopeEntity workTimeScope = lsWorkTime.get(i);
|
||
if(i == 0){
|
||
firstworkDate = splitDate;
|
||
firstworkTime = workTimeScope.getBeginTime();
|
||
}
|
||
if(!oneSign){
|
||
if(!need_middle_time){
|
||
//多次打卡的时候,中间打卡不算加班
|
||
if(i != 0 && i != lsWorkTime.size()-1){
|
||
continue;
|
||
}
|
||
}
|
||
}else {
|
||
boolean is_flow_humanized = KQSettingsBiz.is_flow_humanized();
|
||
if(is_flow_humanized){
|
||
String workBeginTime = Util.null2String(workTimeScope.getBeginTime());
|
||
String ori_workBeginTime = workBeginTime;
|
||
int workBeginIdx = kqTimesArrayComInfo.getArrayindexByTimes(workBeginTime);
|
||
boolean workBenginTimeAcross = workTimeScope.getBeginTimeAcross();
|
||
String workEndTime = Util.null2String(workTimeScope.getEndTime());
|
||
String ori_workEndTime = workEndTime;
|
||
int workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(workEndTime);
|
||
boolean workEndTimeAcross = workTimeScope.getEndTimeAcross();
|
||
|
||
Map<String, String> shifRuleMap = Maps.newHashMap();
|
||
//个性化设置只支持一天一次上下班
|
||
ShiftInfoBean shiftInfoBean = new ShiftInfoBean();
|
||
shiftInfoBean.setSplitDate(splitDate);
|
||
shiftInfoBean.setShiftRuleMap(workTime.getShiftRuleInfo());
|
||
shiftInfoBean.setSignTime(lsSignTime);
|
||
shiftInfoBean.setWorkTime(lsWorkTime);
|
||
List<String> logList = Lists.newArrayList();
|
||
KQShiftRuleInfoBiz.getShiftRuleInfo(shiftInfoBean, resourceid, shifRuleMap,logList);
|
||
if(!shifRuleMap.isEmpty()){
|
||
if(shifRuleMap.containsKey("shift_beginworktime")){
|
||
String shift_beginworktime = Util.null2String(shifRuleMap.get("shift_beginworktime"));
|
||
if(shift_beginworktime.length() > 0){
|
||
workBeginTime = Util.null2String(shift_beginworktime);
|
||
workBeginIdx = kqTimesArrayComInfo.getArrayindexByTimes(workBeginTime);
|
||
workTimeScope.setBeginTime(workBeginTime);
|
||
workTimeScope.setBeginTimeAcross(workBeginIdx>=1440?true:false);
|
||
if(i == 0){
|
||
firstworkDate = workBeginIdx>=1440 ? nextDate : splitDate;
|
||
firstworkTime = workBeginTime;
|
||
}
|
||
}
|
||
}
|
||
if(shifRuleMap.containsKey("shift_endworktime")){
|
||
String shift_endworktime = Util.null2String(shifRuleMap.get("shift_endworktime"));
|
||
if(shift_endworktime.length() > 0){
|
||
workEndTime = Util.null2String(shift_endworktime);
|
||
workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(workEndTime);
|
||
workTimeScope.setEndTime(workEndTime);
|
||
workTimeScope.setEndTimeAcross(workEndIdx>=1440?true:false);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
Map<String, Object> signMap = getSignInfo(resourceid,signTimeScope,workTimeScope,splitDate,preDate,nextDate,kqTimesArrayComInfo,eventMap,i,result);
|
||
if(signMap != null && !signMap.isEmpty()){
|
||
//目前一天多次打卡的话,只获取第一次和最后一次打卡
|
||
lsCheckInfos.add(signMap);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
if(firstworkDate.length() > 0 && firstworkTime.length() > 0){
|
||
result.put("firstworkDate", firstworkDate);
|
||
result.put("firstworkTime", firstworkTime);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
public Map<String, Object> getSignInfo(String userId, TimeScopeEntity signTimeScope,
|
||
TimeScopeEntity workTimeScope, String kqDate, String preDate,
|
||
String nextDate, KQTimesArrayComInfo kqTimesArrayComInfo,Map<String, Object> eventMap,
|
||
int index,Map<String,String> result) {
|
||
Map<String, Object> signMap = Maps.newHashMap();
|
||
KQFormatSignData kqFormatSignData = new KQFormatSignData();
|
||
List<Object> lsCheckInfo = new ArrayList<>();
|
||
Map<String, Object> checkInfo = null;
|
||
String base_sql = "";
|
||
RecordSet rs = new RecordSet();
|
||
String dbtype = rs.getDBType();
|
||
|
||
int has_cut_point = Util.getIntValue(Util.null2String(result.get("has_cut_point")));
|
||
String cut_point = Util.null2String(result.get("cut_point"));
|
||
|
||
int pre_has_cut_point = Util.getIntValue(Util.null2String(result.get("pre_has_cut_point")));
|
||
String pre_cut_point = Util.null2String(result.get("pre_cut_point"));
|
||
int lsWorkTime_size = Util.getIntValue(Util.null2String(result.get("lsWorkTime_size")));
|
||
|
||
//流程抵扣打卡不处理
|
||
Map<String,String> flow_deduct_card_map = Maps.newHashMap();
|
||
|
||
List<Map<String,String>> sqlConditions = kqFormatSignData.getCanSignInfo(signTimeScope,kqDate,preDate,nextDate,kqTimesArrayComInfo);
|
||
base_sql = kqFormatSignData.signSignSql(rs);
|
||
|
||
if(sqlConditions != null && !sqlConditions.isEmpty()){
|
||
for (int i = 0; i < sqlConditions.size(); i++) {
|
||
Map<String,String> sqlMap = sqlConditions.get(i);
|
||
String sql = "";
|
||
String orderSql = "";
|
||
int idx = 0;
|
||
String signBeginDateTime = Util.null2String(sqlMap.get("signBeginDateTime"));
|
||
String signEndDateTime = Util.null2String(sqlMap.get("signEndDateTime"));
|
||
if(index == lsWorkTime_size-1 && i == sqlConditions.size()-1){
|
||
//最后一次的打卡范围会被打卡临界点给修改
|
||
if(has_cut_point == 1){
|
||
String cut_point_datettime = nextDate+" "+cut_point+":59";
|
||
signEndDateTime = cut_point_datettime;
|
||
}
|
||
}
|
||
if(index == 0 && i == 0){
|
||
//第一次的打卡范围会被打卡临界点给修改
|
||
if(pre_has_cut_point == 1){
|
||
String cut_point_datettime = kqDate+" "+pre_cut_point+":00";
|
||
signBeginDateTime = cut_point_datettime;
|
||
}
|
||
}
|
||
String type = Util.null2String(sqlMap.get("type"));
|
||
if(type.length() > 0){
|
||
if("signoff".equalsIgnoreCase(type)){
|
||
orderSql = " order by signdate desc, signtime desc ";
|
||
}else if("signin".equalsIgnoreCase(type)){
|
||
orderSql = " order by signdate asc, signtime asc ";
|
||
}
|
||
if("oracle".equalsIgnoreCase(dbtype)){
|
||
sql = "select * from ("+base_sql+" "+orderSql+") a where rownum=1";
|
||
}else if("mysql".equalsIgnoreCase(dbtype)){
|
||
sql = "select * from ("+base_sql+" "+orderSql+") a limit 0,1";
|
||
}
|
||
else if("postgresql".equalsIgnoreCase(dbtype)){
|
||
sql = "select * from ("+base_sql+" "+orderSql+") a limit 1 offset 0";
|
||
}
|
||
else if("sqlserver".equalsIgnoreCase(dbtype)){
|
||
sql = "select top 1 * from ("+base_sql+") a "+" "+orderSql;
|
||
}else{
|
||
sql = "select * from ("+base_sql+" "+orderSql+") a where rownum=1";
|
||
}
|
||
}else{
|
||
orderSql = " order by signdate asc, signtime asc ";
|
||
sql = base_sql+" "+orderSql;
|
||
}
|
||
rs.executeQuery(sql, userId, signBeginDateTime, signEndDateTime);
|
||
String work_card_sql = "index:"+index+":idx:"+idx+"|sql:"+sql+"|resourceid|"+userId+"|signBeginDateTime|"+signBeginDateTime+"|signEndDateTime|"+signEndDateTime;
|
||
|
||
eventMap.put("工作日打卡sql|work_card_sql_"+index, work_card_sql);
|
||
eventMap.put("工作日打卡sql结果|work_card_sql_getCounts_"+index, rs.getCounts());
|
||
while (rs.next()) {
|
||
String signId = Util.null2String(rs.getString("id"));
|
||
String signdate = Util.null2String(rs.getString("signdate"));
|
||
String signtime = Util.null2String(rs.getString("signtime"));
|
||
|
||
checkInfo = new HashMap<>();
|
||
checkInfo.put("signId", signId);//签到签退标识
|
||
checkInfo.put("signDate", signdate);//签到签退日期
|
||
checkInfo.put("signTime", signtime);//签到签退时间
|
||
checkInfo.put("type", type);//是否有打卡归属,type有值就是有打卡归属
|
||
idx++;
|
||
if(type.length() > 0){
|
||
if("signin".equalsIgnoreCase(type)){
|
||
checkInfo.put("signType", "1");
|
||
lsCheckInfo.add(checkInfo);
|
||
}else {
|
||
checkInfo.put("signType", "2");
|
||
lsCheckInfo.add(checkInfo);
|
||
}
|
||
}else{
|
||
if(idx==1){//第一条算签到
|
||
checkInfo.put("signType", "1");
|
||
lsCheckInfo.add(checkInfo);
|
||
}else if(idx==rs.getCounts()){//最后一条算签退
|
||
checkInfo.put("signType", "2");
|
||
lsCheckInfo.add(checkInfo);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if(lsCheckInfo != null && !lsCheckInfo.isEmpty()){
|
||
if(lsCheckInfo.size() == 1){
|
||
Map<String, Object> checkInfoMap = (Map<String, Object>) lsCheckInfo.get(0);
|
||
String type = Util.null2String(checkInfoMap.get("type"));
|
||
if("signin".equalsIgnoreCase(type)){
|
||
signMap.put("signindate", checkInfoMap.get("signDate"));
|
||
signMap.put("signintime", checkInfoMap.get("signTime"));
|
||
signMap.put("signoutdate", workTimeScope.getBeginTimeAcross()?nextDate:kqDate);
|
||
signMap.put("signouttime", workTimeScope.getBeginTime()+":00");
|
||
}else if("signoff".equalsIgnoreCase(type)){
|
||
signMap.put("signindate", workTimeScope.getEndTimeAcross()?nextDate:kqDate);
|
||
signMap.put("signintime", workTimeScope.getEndTime()+":00");
|
||
signMap.put("signoutdate", checkInfoMap.get("signDate"));
|
||
signMap.put("signouttime", checkInfoMap.get("signTime"));
|
||
}else{
|
||
signMap.put("signindate", checkInfoMap.get("signDate"));
|
||
signMap.put("signintime", checkInfoMap.get("signTime"));
|
||
signMap.put("signoutdate", workTimeScope.getBeginTimeAcross()?nextDate:kqDate);
|
||
signMap.put("signouttime", workTimeScope.getBeginTime()+":00");
|
||
}
|
||
}else{
|
||
Map<String, Object> begin_signMap = (Map<String, Object>) lsCheckInfo.get(0);
|
||
Map<String, Object> end_signMap = (Map<String, Object>) lsCheckInfo.get(lsCheckInfo.size()-1);
|
||
signMap.put("signindate", begin_signMap.get("signDate"));
|
||
signMap.put("signintime", begin_signMap.get("signTime"));
|
||
signMap.put("signoutdate", end_signMap.get("signDate"));
|
||
signMap.put("signouttime", end_signMap.get("signTime"));
|
||
}
|
||
}
|
||
return signMap;
|
||
}
|
||
|
||
private Map<String, Object> getRestSignInfo(String resourceid, String splitDate, String preDate,
|
||
String nextDate,
|
||
KQOvertimeRulesDetailEntity curKqOvertimeRulesDetailEntity,
|
||
Map<String, Object> eventMap,
|
||
KQOvertimeRulesDetailEntity preKqOvertimeRulesDetailEntity) {
|
||
Map<String, Object> signMap = Maps.newHashMap();
|
||
WorkTimeEntity pre_workTime = new KQWorkTime().getWorkTime(resourceid, preDate);
|
||
List<TimeScopeEntity> pre_lsSignTime = new ArrayList<>();
|
||
|
||
if (pre_workTime != null) {
|
||
pre_lsSignTime = pre_workTime.getSignTime();//允许打卡时间
|
||
pre_lsSignTime = pre_lsSignTime != null ? pre_lsSignTime : new ArrayList<>();
|
||
}
|
||
WorkTimeEntity next_workTime = new KQWorkTime().getWorkTime(resourceid, nextDate);
|
||
List<TimeScopeEntity> next_lsSignTime = new ArrayList<>();
|
||
|
||
if (next_workTime != null) {
|
||
next_lsSignTime = next_workTime.getSignTime();//允许打卡时间
|
||
next_lsSignTime = next_lsSignTime != null ? next_lsSignTime : new ArrayList<>();
|
||
}
|
||
|
||
signMap = getNonWorkSignInfo(resourceid,nextDate,splitDate,pre_lsSignTime,next_lsSignTime,curKqOvertimeRulesDetailEntity,eventMap,preKqOvertimeRulesDetailEntity);
|
||
|
||
return signMap;
|
||
}
|
||
|
||
public Map<String, Object> getNonWorkSignInfo(String resourceid, String nextDate, String kqDate,
|
||
List<TimeScopeEntity> pre_lsSignTime,
|
||
List<TimeScopeEntity> next_lsSignTime,
|
||
KQOvertimeRulesDetailEntity curKqOvertimeRulesDetailEntity,
|
||
Map<String, Object> eventMap,
|
||
KQOvertimeRulesDetailEntity preKqOvertimeRulesDetailEntity) {
|
||
Map<String, Object> signMap = Maps.newHashMap();
|
||
KQFormatSignData kqFormatSignData = new KQFormatSignData();
|
||
List<Object> lsCheckInfo = new ArrayList<>();
|
||
Map<String, Object> checkInfo = null;
|
||
RecordSet rs = new RecordSet();
|
||
String pre_Worktime4Today = "";
|
||
if(!pre_lsSignTime.isEmpty()){
|
||
TimeScopeEntity pre_signTimeScope = pre_lsSignTime.get(pre_lsSignTime.size()-1);
|
||
if(pre_signTimeScope.getEndTimeAcross()){
|
||
pre_Worktime4Today = pre_signTimeScope.getEndTime();
|
||
}
|
||
}
|
||
String next_Worktime4Today = "";
|
||
if(!next_lsSignTime.isEmpty()){
|
||
TimeScopeEntity next_signTimeScope = next_lsSignTime.get(next_lsSignTime.size()-1);
|
||
if(next_signTimeScope.isBeginTimePreAcross()){
|
||
next_Worktime4Today = next_signTimeScope.getBeginTime();
|
||
}
|
||
}
|
||
String signBeginDateTime = kqDate+" 00:00:00";
|
||
String signEndDateTime = kqDate+" 23:59:59";
|
||
//有这么一种情况,比如前一天是工作日,最晚签退是2点,然后工作日的归属是设置的5点,那么如果4点打一个卡的话,其实是需要生成加班的,因为4带你这个卡是昨日的签退
|
||
String ore_signBeginDateTime = signBeginDateTime;
|
||
String base_sql = kqFormatSignData.signSignSql(rs);
|
||
|
||
int pre_has_cut_point = preKqOvertimeRulesDetailEntity != null ? preKqOvertimeRulesDetailEntity.getHas_cut_point() : 0;
|
||
|
||
if(pre_Worktime4Today.length() > 0){
|
||
if(pre_has_cut_point == 1){
|
||
String cut_point = Util.null2String(preKqOvertimeRulesDetailEntity.getCut_point());
|
||
if(cut_point.length() > 0){
|
||
if(cut_point.compareTo(pre_Worktime4Today) > 0){
|
||
pre_Worktime4Today = cut_point;
|
||
}else{
|
||
if(pre_Worktime4Today.length() == 5){
|
||
pre_Worktime4Today += ":00";
|
||
}
|
||
ore_signBeginDateTime = kqDate+" "+pre_Worktime4Today;
|
||
}
|
||
/**
|
||
打卡数据:2022/04/29 09:00:00----2022/04/29 23:59:59---2022/04/30 00:00:00----2022/04/30 02:00:00
|
||
加班流程:2022-04-29 20:00---2022-04-30 03:00
|
||
加班规则:2022-04-29周五工作日自定义跨天归属设置为00:00,取交集,然后30号的00:00-02:00两个小时加班无法生成
|
||
问题原因:当29的下班卡结束打卡时间在自定义跨天00:00之后,那么读卡范围是:29号结束打卡时间(pre_Worktime4Today)开始的
|
||
*/
|
||
pre_Worktime4Today = cut_point+":01";
|
||
}
|
||
}
|
||
if(pre_Worktime4Today.length() == 5){
|
||
pre_Worktime4Today += ":00";
|
||
}
|
||
signBeginDateTime = kqDate+" "+pre_Worktime4Today;
|
||
}else{
|
||
if(pre_has_cut_point == 1){
|
||
String cut_point = Util.null2String(preKqOvertimeRulesDetailEntity.getCut_point());
|
||
if(cut_point.length() > 0){
|
||
String cut_point_time = kqDate+" "+cut_point+":00";
|
||
signBeginDateTime = cut_point_time;
|
||
}
|
||
}
|
||
}
|
||
if(next_Worktime4Today.length() > 0){
|
||
if(next_Worktime4Today.length() == 5){
|
||
next_Worktime4Today += ":00";
|
||
}
|
||
signEndDateTime = kqDate+" "+next_Worktime4Today;
|
||
}else{
|
||
if(curKqOvertimeRulesDetailEntity != null){
|
||
int cur_has_cut_point = curKqOvertimeRulesDetailEntity.getHas_cut_point();
|
||
if(cur_has_cut_point == 1){
|
||
String cut_point = Util.null2String(curKqOvertimeRulesDetailEntity.getCut_point());
|
||
if(cut_point.length() > 0){
|
||
String cut_point_time = nextDate+" "+cut_point+":00";
|
||
signEndDateTime = cut_point_time;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
String sql = "select * from ("+base_sql+") a "+" order by signdate asc,signtime asc ";
|
||
rs.executeQuery(sql,resourceid,signBeginDateTime,signEndDateTime);
|
||
String nonwork_card_sql = "sql:"+sql+"|resourceid|"+resourceid+"|signBeginDateTime|"+signBeginDateTime+"|signEndDateTime|"+signEndDateTime;
|
||
eventMap.put("非工作日打卡sql|nonwork_card_sql", nonwork_card_sql);
|
||
eventMap.put("非工作日打卡sql结果|nonwork_card_sql_getCounts", rs.getCounts());
|
||
int idx = 0;
|
||
while (rs.next()){
|
||
String signId = Util.null2String(rs.getString("id"));
|
||
String signdate = Util.null2String(rs.getString("signdate"));
|
||
String signtime = Util.null2String(rs.getString("signtime"));
|
||
|
||
checkInfo = new HashMap<>();
|
||
checkInfo.put("signId", signId);//签到签退标识
|
||
checkInfo.put("signDate", signdate);//签到签退日期
|
||
checkInfo.put("signTime", signtime);//签到签退时间
|
||
idx++;
|
||
if(idx==1){//第一条算签到
|
||
checkInfo.put("signType", "1");
|
||
lsCheckInfo.add(checkInfo);
|
||
}else if(idx==rs.getCounts()){//最后一条算签退
|
||
checkInfo.put("signType", "2");
|
||
lsCheckInfo.add(checkInfo);
|
||
}
|
||
}
|
||
if(lsCheckInfo != null && !lsCheckInfo.isEmpty()){
|
||
if(lsCheckInfo.size() == 2){
|
||
Map<String, Object> begin_signMap = (Map<String, Object>) lsCheckInfo.get(0);
|
||
Map<String, Object> end_signMap = (Map<String, Object>) lsCheckInfo.get(lsCheckInfo.size()-1);
|
||
signMap.put("signindate", begin_signMap.get("signDate"));
|
||
signMap.put("signintime", begin_signMap.get("signTime"));
|
||
signMap.put("signoutdate", end_signMap.get("signDate"));
|
||
signMap.put("signouttime", end_signMap.get("signTime"));
|
||
}else if(lsCheckInfo.size() == 1){
|
||
Map<String, Object> begin_signMap = (Map<String, Object>) lsCheckInfo.get(0);
|
||
signMap.put("signindate", begin_signMap.get("signDate"));
|
||
signMap.put("signintime", begin_signMap.get("signTime"));
|
||
}
|
||
}else{
|
||
if(pre_has_cut_point == 1){
|
||
sql = "select * from ("+base_sql+") a "+" order by signdate asc,signtime asc ";
|
||
rs.executeQuery(sql,resourceid,ore_signBeginDateTime,signEndDateTime);
|
||
nonwork_card_sql = "sql:"+sql+"|resourceid|"+resourceid+"|ore_signBeginDateTime|"+ore_signBeginDateTime+"|signEndDateTime|"+signEndDateTime;
|
||
eventMap.put("昨日开启了打卡归属,非工作日打卡sql|nonwork_card_sql", nonwork_card_sql);
|
||
eventMap.put("昨日开启了打卡归属,非工作日打卡sql结果|nonwork_card_sql_getCounts", rs.getCounts());
|
||
idx = 0;
|
||
while (rs.next()){
|
||
String signId = Util.null2String(rs.getString("id"));
|
||
String signdate = Util.null2String(rs.getString("signdate"));
|
||
String signtime = Util.null2String(rs.getString("signtime"));
|
||
|
||
checkInfo = new HashMap<>();
|
||
checkInfo.put("signId", signId);//签到签退标识
|
||
checkInfo.put("signDate", signdate);//签到签退日期
|
||
checkInfo.put("signTime", signtime);//签到签退时间
|
||
idx++;
|
||
if(idx==1){//第一条算签到
|
||
checkInfo.put("signType", "1");
|
||
lsCheckInfo.add(checkInfo);
|
||
}else if(idx==rs.getCounts()){//最后一条算签退
|
||
checkInfo.put("signType", "2");
|
||
lsCheckInfo.add(checkInfo);
|
||
}
|
||
}
|
||
if(lsCheckInfo != null && !lsCheckInfo.isEmpty()){
|
||
//这种情况下,就只是把签到卡传回去作为前一天的签退了
|
||
Map<String, Object> begin_signMap = (Map<String, Object>) lsCheckInfo.get(0);
|
||
signMap.put("signindate", begin_signMap.get("signDate"));
|
||
signMap.put("signintime", begin_signMap.get("signTime"));
|
||
}
|
||
}
|
||
}
|
||
return signMap;
|
||
}
|
||
|
||
/**
|
||
* 获取班次信息 获取顺序 工作日调整、排班、固定班和周期班
|
||
* @param userId
|
||
* @param workdate
|
||
* @param containYesterday
|
||
* @return
|
||
*/
|
||
public Map<String,Object> getSerialInfo(String userId, String workdate, boolean containYesterday) {
|
||
Map<String, Object> serialInfo = new HashMap<>();
|
||
String preworkdate = "";
|
||
boolean isFormat = false;
|
||
try {
|
||
KQGroupMemberComInfo groupMemberComInfo = new KQGroupMemberComInfo();
|
||
groupMemberComInfo.setIsFormat(isFormat);
|
||
KQFixedSchedulceComInfo kqFixedSchedulceComInfo = new KQFixedSchedulceComInfo();
|
||
kqFixedSchedulceComInfo.setFormat(isFormat);
|
||
KQShiftScheduleComInfo kqShiftScheduleComInfo = new KQShiftScheduleComInfo();
|
||
kqShiftScheduleComInfo.setFormat(isFormat);
|
||
KQGroupEntity kqGroupEntity = groupMemberComInfo.getUserKQGroupInfo(userId,workdate);
|
||
ResourceComInfo resourceComInfo = new ResourceComInfo();
|
||
|
||
preworkdate = DateUtil.addDate(workdate,-1);
|
||
if(containYesterday){
|
||
Map<String, Object> pre_serialInfo = getSerialInfo(userId, preworkdate, false);
|
||
if(pre_serialInfo != null && !pre_serialInfo.isEmpty()){
|
||
if(pre_serialInfo.containsKey(preworkdate)){
|
||
serialInfo.put(preworkdate,pre_serialInfo.get(preworkdate));//获取前一天的班次
|
||
}
|
||
}
|
||
}
|
||
|
||
if(kqGroupEntity==null){//不在考勤组内
|
||
return serialInfo;
|
||
}
|
||
|
||
|
||
//无需考勤人员需要计算考勤时间,但不计算异常状态
|
||
|
||
if (("," + kqGroupEntity.getExcludeid() + ",").indexOf("," + userId + ",")>-1) {//排除人员无需计算考勤时间
|
||
serialInfo.put("isExclude","1");
|
||
}
|
||
|
||
String begindate = Util.null2String(resourceComInfo.getCreatedate(userId)).trim();
|
||
String companyStartDate = Util.null2String(resourceComInfo.getCompanyStartDate(userId)).trim();
|
||
if(companyStartDate.length()!=10){
|
||
companyStartDate = "";
|
||
}
|
||
if(companyStartDate.length()>0 && companyStartDate.indexOf("-")>0){
|
||
begindate=companyStartDate;
|
||
}
|
||
if(begindate.length()>0 && DateUtil.compDate(begindate,workdate)<0 ){//人员入职日期前无需计算考勤,如果没有入职日期,已创建日期为准
|
||
return serialInfo;
|
||
}
|
||
|
||
String endDate = Util.null2String(resourceComInfo.getEndDate(userId));
|
||
|
||
String status = Util.null2String(resourceComInfo.getStatus(userId));
|
||
if(status.equals("0")||status.equals("1")||status.equals("2")||status.equals("3")){
|
||
//在职
|
||
}else{
|
||
//其他状态
|
||
if(endDate.length()>0 && DateUtil.compDate(endDate,workdate)>0){//人员合同结束日期无需计算考勤
|
||
return serialInfo;
|
||
}
|
||
}
|
||
|
||
String groupid = kqGroupEntity.getId();
|
||
String groupname = kqGroupEntity.getGroupname();
|
||
String kqtype = kqGroupEntity.getKqtype();
|
||
int dayOfweek = DateUtil.getWeek(workdate)-1;
|
||
int preDayOfweek = DateUtil.getWeek(preworkdate)-1;
|
||
boolean preDayIsHoliday = KQHolidaySetBiz.isHoliday(userId,preworkdate);
|
||
boolean isHoliday = KQHolidaySetBiz.isHoliday(userId,workdate);
|
||
String serialid = "";
|
||
|
||
if(!kqtype.equals("2")){//处理调配工作日(除排班外)
|
||
if(KQHolidaySetBiz.getChangeType(groupid,preworkdate)==2){
|
||
preDayOfweek = KQHolidaySetBiz.getRelatedDay(userId,preworkdate);
|
||
}
|
||
|
||
if(KQHolidaySetBiz.getChangeType(groupid,workdate)==2){
|
||
dayOfweek = KQHolidaySetBiz.getRelatedDay(userId,workdate);
|
||
}
|
||
}
|
||
serialInfo.put("groupId",groupid);
|
||
serialInfo.put("groupName",groupname);
|
||
serialInfo.put("kqType",kqtype);
|
||
serialInfo.put("isHoliday",isHoliday);
|
||
if (kqtype.equals("1")) {//固定班
|
||
if(!serialInfo.containsKey(workdate)){
|
||
serialid = Util.null2String(kqFixedSchedulceComInfo.getSerialid(groupid,dayOfweek));
|
||
if( !isHoliday&&serialid.length()>0 && Util.getIntValue(serialid) > 0){
|
||
serialInfo.put(workdate, serialid);//获取当天的班次
|
||
}
|
||
}
|
||
} else if (kqtype.equals("2")) {//排班
|
||
//先取排班设置里的班次
|
||
serialid = Util.null2String(kqShiftScheduleComInfo.getSerialId(userId,workdate));
|
||
if(serialid.length()>0 && !isHoliday && Util.getIntValue(serialid) > 0){
|
||
serialInfo.put(workdate,Util.null2String(kqShiftScheduleComInfo.getSerialId(userId,workdate)));//获取当天的班次
|
||
}
|
||
} else if (kqtype.equals("3")) {//自由班
|
||
List weekDay = Util.splitString2List(kqGroupEntity.getWeekday(), ",");
|
||
String signStart = Util.null2String(kqGroupEntity.getSignstart());//签到开始时间
|
||
int workMins = Util.getIntValue(Util.getIntValues(""+Util.getDoubleValue(Util.null2String(kqGroupEntity.getWorkhour()))*60));//工作时长
|
||
if(signStart.length()>0 && workMins>0) {
|
||
String calmethod = Util.null2s(kqGroupEntity.getCalmethod(),"1");
|
||
Map<String, Object> map = null;
|
||
if (weekDay.contains(""+preDayOfweek) && !preDayIsHoliday) {//前一天
|
||
map = new HashMap<>();
|
||
map.put("signStart", signStart);
|
||
map.put("workMins", workMins);
|
||
map.put("calmethod", calmethod);
|
||
serialInfo.put(preworkdate, map);
|
||
}
|
||
if (weekDay.contains(""+dayOfweek) && !isHoliday) {//当前天
|
||
map = new HashMap<>();
|
||
map.put("signStart", signStart);
|
||
map.put("workMins", workMins);
|
||
map.put("calmethod", calmethod);
|
||
serialInfo.put(workdate, map);
|
||
}
|
||
}
|
||
}
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}
|
||
return serialInfo;
|
||
}
|
||
|
||
public Map<String,Object> getWorkTimeMap(String workdate,Map<String,Object> serialidInfo){
|
||
|
||
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||
Map<String,Object> dateWorkTimeMap = new HashMap<>();
|
||
LocalDate preLocalDate = LocalDate.parse(workdate);
|
||
String preSplitDate = "";
|
||
preLocalDate = preLocalDate.minusDays(1);
|
||
preSplitDate = preLocalDate.format(dateFormatter);
|
||
if(serialidInfo != null && !serialidInfo.isEmpty()){
|
||
String preSerialid = Util.null2String(serialidInfo.get(preSplitDate));
|
||
String serialid = Util.null2String(serialidInfo.get(workdate));
|
||
getShiftInfoBeanMap(dateWorkTimeMap,preSerialid, serialid);
|
||
}
|
||
|
||
return dateWorkTimeMap;
|
||
}
|
||
|
||
private void getShiftInfoBeanMap(Map<String,Object> dateWorkTimeMap,String preSerialid, String serialid) {
|
||
ShiftInfoCominfoBean cur_shiftInfoCominfoBean = getShiftInfoCominfoBean(serialid);
|
||
|
||
if(cur_shiftInfoCominfoBean != null){
|
||
dateWorkTimeMap.put("restTime",cur_shiftInfoCominfoBean.getRestAcrossLongTime());
|
||
dateWorkTimeMap.put("workTime",cur_shiftInfoCominfoBean.getWorkAcrossLongTime());
|
||
dateWorkTimeMap.put("workMins",cur_shiftInfoCominfoBean.getWorkmins());
|
||
dateWorkTimeMap.put("isAcross",cur_shiftInfoCominfoBean.getIsAcross());
|
||
dateWorkTimeMap.put("signTime", cur_shiftInfoCominfoBean.getSignWorkTime());
|
||
}
|
||
}
|
||
|
||
|
||
public ShiftInfoCominfoBean getShiftInfoCominfoBean(String serialid){
|
||
//改用redis和staticobj的方式
|
||
KQShiftManagementRedis kqShiftManagementRedis = new KQShiftManagementRedis();
|
||
return kqShiftManagementRedis.getShiftInfoBeanMapBySql(serialid);
|
||
}
|
||
|
||
public boolean checkIsBeforeOvertime(String resourceId,String kqDate,int computingmode,
|
||
String fromdate,String fromtime,String todate,String totime,
|
||
String fromdatedb,String fromtimedb,String todatedb,String totimedb,String ori_belongdate){
|
||
boolean bool = false;
|
||
|
||
String workbegintime = getWorkBegintime(resourceId,ori_belongdate);
|
||
|
||
// 无需审批,根据打卡时间计算加班时长 . 取 fromdate、fromtime
|
||
if (computingmode == 3) {
|
||
//开始日期不等于并且大于归属日期。需要将归属日期更新为 开始日期
|
||
if (!ori_belongdate.equals(kqDate) && compareDate(ori_belongdate, kqDate)) {
|
||
if (workbegintime.equals(totime)) {
|
||
bool = true;
|
||
}
|
||
}
|
||
}
|
||
if(computingmode == 4){
|
||
//开始日期不等于并且大于归属日期。需要将归属日期更新为 开始日期
|
||
if(!todatedb.equals(kqDate) && compareDate(todatedb, kqDate)) {
|
||
if(workbegintime.equals(totimedb)){
|
||
bool = true;
|
||
}
|
||
}
|
||
}
|
||
return bool;
|
||
}
|
||
|
||
public boolean checkIsAfterOvertime(String resourceId,String belongdate,int computingmode,
|
||
String fromdate,String fromtime,String todate,String totime,
|
||
String fromdatedb,String fromtimedb,String todatedb,String totimedb,String ori_belongdate) {
|
||
boolean bool = false;
|
||
|
||
String workendtime = getWorkEndtime(resourceId,ori_belongdate);
|
||
|
||
if(computingmode == 3){
|
||
// 加班开始日期不等于归属日期 并且大于 归属日期, 加班开始时间 = 归属日期所在班次的开始时间
|
||
if(!fromdate.equals(belongdate) && compareDate(fromdate,belongdate)){
|
||
if(fromtime.equals(workendtime)){
|
||
bool = true;
|
||
}
|
||
}
|
||
}
|
||
if(computingmode == 4){
|
||
// 加班开始日期不等于归属日期 并且大于 归属日期, 加班开始时间 = 归属日期所在班次的开始时间
|
||
if(!fromdatedb.equals(ori_belongdate) && compareDate(fromdatedb,ori_belongdate)){
|
||
if(fromtimedb.equals(workendtime)){
|
||
bool = true;
|
||
}
|
||
}
|
||
}
|
||
return bool;
|
||
}
|
||
|
||
|
||
/**
|
||
* 获取 班次开始时间
|
||
* @param userid
|
||
* @param date
|
||
* @return
|
||
*/
|
||
public String getWorkBegintime(String userid,String date){
|
||
String result = "";
|
||
RecordSet rs = new RecordSet();
|
||
rs.executeQuery("select workbegintime from kq_format_detail where resourceid = ? and kqdate = ?",userid,date);
|
||
while(rs.next()){
|
||
result = Util.null2String(rs.getString("workbegintime"));
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 班次结束时间
|
||
* @param userid
|
||
* @param date
|
||
* @return
|
||
*/
|
||
public String getWorkEndtime(String userid,String date){
|
||
String result = "";
|
||
RecordSet rs = new RecordSet();
|
||
rs.executeQuery("select workendtime from kq_format_detail where resourceid = ? and kqdate = ?",userid,date);
|
||
while(rs.next()){
|
||
result = Util.null2String(rs.getString("workendtime"));
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 比较时间的大小
|
||
* @param a
|
||
* @param b
|
||
* @return
|
||
*/
|
||
public static boolean compareDate(String a, String b){
|
||
boolean flag = false;
|
||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||
try {
|
||
long t1 = sdf.parse(a).getTime();
|
||
long t2 = sdf.parse(b).getTime();
|
||
if (t1 >= t2) {
|
||
flag = true;
|
||
} else {
|
||
flag = false;
|
||
}
|
||
}catch (Exception e){
|
||
e.printStackTrace();
|
||
}
|
||
return flag;
|
||
}
|
||
|
||
%>
|
||
|
||
<HEAD>
|
||
</HEAD>
|
||
<BODY>
|
||
|
||
<h1>Congratulation Mode 666666 !</h1>
|
||
|
||
<h2> 班次的信息 <%=serialInfoMap%></h2>
|
||
|
||
<h1> 加班规则 <%=commode%></h1>
|
||
|
||
<h1> 拆分后的日期 <%=dates%></h1>
|
||
|
||
<h1> 加班信息 <%=lsCheckInfoMaps%> </h1>
|
||
|
||
</BODY> |