dev_zm
李栋 1 year ago
parent 1dab0ec245
commit 144e9a7f51

@ -0,0 +1,18 @@
#逃묏되션깊직넋-EHR 깊데id
billid=-379
#逃묏되션깊직넋-EHR 직넋id
workflowid=501
#짇拈 겯늴 id
sixnight_serialid=3
#12鬼珂묏鱗齡拈겯 겯늴 id
twelvehours_night_serialid=11
#껸엥<EABBB8>헝-EHR 직넋깊츰
fillcard_table=formtable_main_394
#속겯憩瑯 친욥id
overtime_formmmodeid=60

@ -0,0 +1,40 @@
#宁波精华考勤需求
#管理人员指定人员考勤组id
glrygroupid=6
#管理人员考勤组id
glgroupid=3
#事假病假产假id
sjbjcjid=6,7,8
#婚假丧假id
hjsjid=10,11
#预入职流程id
yrzWfid=518
#固定流程创建人id
lccjr=43
#目录id
secid=187
#管理人员12小时班制白班id
searIdBb=3
#管理人员12小时班制白班最大加班时长
bbMaxMins=150
#管理人员12小时班制夜班id
searIdYb=2
#管理人员12小时班制夜班最大加班时长
ybMaxMins=240
#加班申请流程表名
lctableName=formtable_main_374
#两小时起步加班休班次id
twoStartSerId=12

File diff suppressed because it is too large Load Diff

@ -0,0 +1,485 @@
package com.engine.kq.biz;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean;
import com.engine.kq.cmd.attendanceButton.ButtonStatusEnum;
import com.engine.kq.entity.KQShiftRuleEntity;
import com.engine.kq.entity.TimeScopeEntity;
import com.engine.kq.entity.TimeSignScopeEntity;
import com.engine.kq.entity.WorkTimeEntity;
import com.engine.kq.log.KQLog;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.apache.commons.lang3.StringUtils;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import java.util.*;
/**
*
*/
public class KQFormatShiftRule extends BaseBean {
private KQLog kqLog = new KQLog();
public KQShiftRuleEntity doShiftRule(WorkTimeEntity workTime, KQShiftRuleEntity kqShiftRuleEntity) {
Map<String, Object> shiftRuleInfo = workTime.getShiftRuleInfo();
//人性化处理
if (shiftRuleInfo != null && shiftRuleInfo.size() > 0) {
Map<String, Object> ruleDetail = (Map<String, Object>) shiftRuleInfo.get("ruleDetail");
//允许迟到分钟数
boolean usepermitlateminutes = Util.null2String(shiftRuleInfo.get("permitlatestatus")).equals("1");
int permitlateminutes = Util.getIntValue(Util.null2String(shiftRuleInfo.get("permitlateminutes")), 0);
boolean enableexcludelate = Util.null2String(shiftRuleInfo.get("enableexcludelate")).equals("1");
//允许早退分钟数
boolean usepermitleaveearlyminutes = Util.null2String(shiftRuleInfo.get("permitleaveearlystatus")).equals("1");
int permitleaveearlyminutes = Util.getIntValue(Util.null2String(shiftRuleInfo.get("permitleaveearlyminutes")), 0);
boolean enableexcludeleaveearly = Util.null2String(shiftRuleInfo.get("enableexcludeleaveearly")).equals("1");
//严重迟到分钟数
boolean useseriouslateminutes = Util.null2String(shiftRuleInfo.get("seriouslatestatus")).equals("1");
int seriouslateminutes = Util.getIntValue(Util.null2String(shiftRuleInfo.get("seriouslateminutes")), 0);
//严重早退分钟数
boolean useseriousleaveearlyminutes = Util.null2String(shiftRuleInfo.get("seriousleaveearlystatus")).equals("1");
int seriousleaveearlyminutes = Util.getIntValue(Util.null2String(shiftRuleInfo.get("seriousleaveearlyminutes")), 0);
//迟到多少钟数算旷工
boolean uselateabsentminutes = Util.null2String(shiftRuleInfo.get("lateabsentstatus")).equals("1");
int lateabsentminutes = Util.getIntValue(Util.null2String(shiftRuleInfo.get("lateabsentminutes")), 0);
//早退多少钟数算旷工
boolean useleaveearlyabsentminutes = Util.null2String(shiftRuleInfo.get("leaveearlyabsentstatus")).equals("1");
int leaveearlyabsentminutes = Util.getIntValue(Util.null2String(shiftRuleInfo.get("leaveearlyabsentminutes")), 0);
//允许下班不打卡
boolean isoffdutyfreecheck = Util.null2String(shiftRuleInfo.get("isoffdutyfreecheck")).equals("1");
String userId = kqShiftRuleEntity.getUserId();
String kqDate = kqShiftRuleEntity.getKqDate();
int beLateMins = kqShiftRuleEntity.getBelatemins();
int graveBeLateMins = 0;
int leaveEarlyMins = kqShiftRuleEntity.getLeaveearlymins();
int graveLeaveEarlyMins = 0;
int absenteeismMins = kqShiftRuleEntity.getAbsenteeismmins();
int forgotcheckMins = kqShiftRuleEntity.getForgotcheckmins();
int forgotBeginWorkCheckMins = kqShiftRuleEntity.getForgotBeginWorkCheckMins();
int earlyInMins = kqShiftRuleEntity.getEarlyInMins();
int lateOutMins = kqShiftRuleEntity.getLateOutMins();
List<Object> earlyinearlyout = null;//早到早走规则
List<Object> lateinlateout = null;//晚到晚走规则
List<Object> lateoutlatein = null;//晚走晚到规则
//这里个性化没法处理流程数据,逻辑改为在前面直接虚拟改掉了上下班时间
if (ruleDetail != null && ruleDetail.size() > 0 && false) {//处理人性化设置其他规则
earlyinearlyout = (List<Object>) ruleDetail.get("earlyinearlyout");
lateinlateout = (List<Object>) ruleDetail.get("lateinlateout");
lateoutlatein = (List<Object>) ruleDetail.get("lateoutlatein");
if (earlyinearlyout != null && earlyinearlyout.size() > 0 && leaveEarlyMins > 0) {
for (int i = 0; earlyInMins > 0 && i < earlyinearlyout.size(); i++) {
Map<String, Object> rule = (Map<String, Object>) earlyinearlyout.get(i);
if (Util.null2String(rule.get("enable")).equals("1")) {
int advancetime = new Double((Util.getDoubleValue(Util.null2String(rule.get("advancetime"))))).intValue();//早到时间
int postponetime = new Double((Util.getDoubleValue(Util.null2String(rule.get("postponetime"))))).intValue();//允许早走时间
if (Util.null2String(rule.get("enablesame")).equals("1")) {
if(earlyInMins>postponetime){
leaveEarlyMins -= postponetime;
if (leaveEarlyMins < 0) leaveEarlyMins = 0;
}else{
leaveEarlyMins -= earlyInMins;
if (leaveEarlyMins < 0) leaveEarlyMins = 0;
}
break;
}else{
if (earlyInMins >= advancetime) {
leaveEarlyMins -= postponetime;
if (leaveEarlyMins < 0) leaveEarlyMins = 0;
break;
}
}
}
}
}
if (lateinlateout != null && lateinlateout.size() > 0 && beLateMins > 0) {
for (int i = 0; lateOutMins > 0 && i < lateinlateout.size(); i++) {
Map<String, Object> rule = (Map<String, Object>) lateinlateout.get(i);
if (Util.null2String(rule.get("enable")).equals("1")) {
int advancetime = new Double((Util.getDoubleValue(Util.null2String(rule.get("advancetime"))))).intValue();//晚到时间
int postponetime = new Double((Util.getDoubleValue(Util.null2String(rule.get("postponetime"))))).intValue();//需要晚走时间
if (Util.null2String(rule.get("enablesame")).equals("1")) {
if(lateOutMins>postponetime){
beLateMins -= postponetime;
if (beLateMins < 0) beLateMins = 0;
}else{
beLateMins -= lateOutMins;
if (beLateMins < 0) beLateMins = 0;
}
break;
}else{
if (lateOutMins >= postponetime) {
beLateMins -= advancetime;
if (beLateMins < 0) beLateMins = 0;
break;
}
}
}
}
}
if (lateoutlatein != null && lateoutlatein.size() > 0 && beLateMins > 0) {
int preDayLateOutMins = getPreDayLateOutMins(userId, kqDate);
for (int i = 0; preDayLateOutMins > 0 && i < lateoutlatein.size(); i++) {
Map<String, Object> rule = (Map<String, Object>) lateoutlatein.get(i);
if (Util.null2String(rule.get("enable")).equals("1")) {
int advancetime = new Double((Util.getDoubleValue(Util.null2String(rule.get("advancetime"))))).intValue();//晚走时间
int postponetime = new Double((Util.getDoubleValue(Util.null2String(rule.get("postponetime"))))).intValue();//允许晚到时间
if (Util.null2String(rule.get("enablesame")).equals("1")) {
if(preDayLateOutMins>postponetime){
beLateMins -= postponetime;
if (beLateMins < 0) beLateMins = 0;
}else{
beLateMins -= preDayLateOutMins;
if (beLateMins < 0) beLateMins = 0;
}
break;
}else{
if (preDayLateOutMins >= advancetime) {
beLateMins -= postponetime;
if (beLateMins < 0) beLateMins = 0;
break;
}
}
}
}
}
}
if (beLateMins > 0) {//迟到人性化设置
if (usepermitlateminutes) {//允许迟到分钟数
if(permitlateminutes >= beLateMins) {
beLateMins = 0;
}else if(enableexcludelate){
beLateMins = beLateMins - permitlateminutes;
}
}
if (uselateabsentminutes && beLateMins >= lateabsentminutes) {//旷工
absenteeismMins += beLateMins;
beLateMins = 0;
//leaveEarlyMins = 0;
forgotcheckMins=0 ;
} else if (useseriouslateminutes && beLateMins >= seriouslateminutes) {//严重迟到
graveBeLateMins += beLateMins;
//TODO 这有个问题,严重迟到了,还要不要算迟到?这两个是同时存在的吗?
beLateMins = 0;
}
}
if (leaveEarlyMins > 0) {//早退人性化设置
if (usepermitleaveearlyminutes) {//允许早退分钟数
if(permitleaveearlyminutes >= leaveEarlyMins){
leaveEarlyMins = 0;
}else if (enableexcludeleaveearly) {
leaveEarlyMins = leaveEarlyMins - permitleaveearlyminutes;
}
}
if (useleaveearlyabsentminutes && leaveEarlyMins >= leaveearlyabsentminutes) {//旷工
absenteeismMins += leaveEarlyMins;
//beLateMins = 0;
leaveEarlyMins = 0;
forgotcheckMins=0 ;
forgotBeginWorkCheckMins = 0;
} else if (useseriousleaveearlyminutes && leaveEarlyMins >= seriousleaveearlyminutes) {//严重早退
graveLeaveEarlyMins += leaveEarlyMins;
//TODO 这有个问题,严重早退了,还要不要算早退?这两个是同时存在的吗?
leaveEarlyMins = 0;
}
}
//允许下班不打卡
if (isoffdutyfreecheck) {
forgotcheckMins = 0;
}
kqShiftRuleEntity.setBelatemins(beLateMins);
kqShiftRuleEntity.setGravebelatemins(graveBeLateMins);
kqShiftRuleEntity.setLeaveearlymins(leaveEarlyMins);
kqShiftRuleEntity.setGraveleaveearlymins(graveLeaveEarlyMins);
kqShiftRuleEntity.setAbsenteeismmins(absenteeismMins);
kqShiftRuleEntity.setForgotcheckmins(forgotcheckMins);
kqShiftRuleEntity.setForgotBeginWorkCheckMins(forgotBeginWorkCheckMins);
}
return kqShiftRuleEntity;
}
public int getEarlyInMins(String userId, String kqDate){
int earlyInMins = 0;
boolean oneSign = false;
String preDate = DateUtil.addDate(kqDate, -1);//上一天日期
String nextDate = DateUtil.addDate(kqDate, 1);//下一天日期
KQWorkTime kqWorkTime = new KQWorkTime();
WorkTimeEntity workTime = kqWorkTime.getWorkTime(userId, kqDate);
List<TimeScopeEntity> lsSignTime = new ArrayList<>();
List<TimeScopeEntity> lsWorkTime = new ArrayList<>();
if (workTime != null) {
lsSignTime = workTime.getSignTime();//允许打卡时间
lsWorkTime = workTime.getWorkTime();//工作时间
oneSign = lsWorkTime != null && lsWorkTime.size() == 1;
}
if (oneSign) {
KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo();
TimeScopeEntity signTimeScope = lsSignTime.get(0);
TimeScopeEntity workTimeScope = lsWorkTime.get(0);
int workBeginIdx = kqTimesArrayComInfo.getArrayindexByTimes(workTimeScope.getBeginTime());
List<Object> lsCheckInfo = new KQFormatSignData().getSignInfo(userId,signTimeScope,workTimeScope,kqDate,preDate,nextDate,kqTimesArrayComInfo);
for (int j = 0; lsCheckInfo != null && j < lsCheckInfo.size(); j++) {
Map<String, Object> checkInfo = (Map<String, Object>) lsCheckInfo.get(j);
String signDate = Util.null2String(checkInfo.get("signDate"));
String signTime = Util.null2String(checkInfo.get("signTime"));
String deduct_signintime = Util.null2String(checkInfo.get("deduct_signintime"));
if (checkInfo.get("signType").equals("1")) {//签到
//有签到但是没有signTime是因为开启了流程抵扣打卡
if(null == signTime || signTime.length()<5){
continue;
}else{
writeLog("signDate:"+signDate+",signTime="+signTime+",checkInfo="+checkInfo.toString());
}
String signMinTime = signTime.substring(0,5)+":00";
boolean signInWorkBeginTime = false;
if(signTime.compareTo(signMinTime) > 0){
//如果签到时间是带秒的且是迟到,那么签到时间多一秒和多一分钟是一样的
signInWorkBeginTime = true;
}
String signInTime = signTime;
int signInTimeIndx = kqTimesArrayComInfo.getArrayindexByTimes(signInTime);
String flow_signInTime = "";
if(deduct_signintime.length() > 0){
if(signTime.length() > 0){
if(deduct_signintime.compareTo(signTime) < 0){
flow_signInTime = deduct_signintime;
}
}else{
flow_signInTime = deduct_signintime;
}
}
if(flow_signInTime.length() > 0){
signInTimeIndx = kqTimesArrayComInfo.getArrayindexByTimes(flow_signInTime);
}
if(kqDate.compareTo(signDate) < 0)signInTimeIndx+=1440;
if(signInWorkBeginTime){
signInTimeIndx = signInTimeIndx + 1;
}
if(workBeginIdx>signInTimeIndx) {
earlyInMins = workBeginIdx-signInTimeIndx;
}
}
}
}
return earlyInMins;
}
public int getLateOutMins(String userId, String kqDate){
int lateOutMins = 0;
boolean oneSign = false;
String preDate = DateUtil.addDate(kqDate, -1);//上一天日期
String nextDate = DateUtil.addDate(kqDate, 1);//下一天日期
KQWorkTime kqWorkTime = new KQWorkTime();
WorkTimeEntity workTime = kqWorkTime.getWorkTime(userId, kqDate);
List<TimeScopeEntity> lsSignTime = new ArrayList<>();
List<TimeScopeEntity> lsWorkTime = new ArrayList<>();
if (workTime != null) {
lsSignTime = workTime.getSignTime();//允许打卡时间
lsWorkTime = workTime.getWorkTime();//工作时间
oneSign = lsWorkTime != null && lsWorkTime.size() == 1;
}
if (oneSign) {
KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo();
TimeScopeEntity signTimeScope = lsSignTime.get(0);
TimeScopeEntity workTimeScope = lsWorkTime.get(0);
int workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(workTimeScope.getEndTime());
List<Object> lsCheckInfo = new KQFormatSignData().getSignInfo(userId,signTimeScope,workTimeScope,kqDate,preDate,nextDate,kqTimesArrayComInfo);
for (int j = 0; lsCheckInfo != null && j < lsCheckInfo.size(); j++) {
Map<String, Object> checkInfo = (Map<String, Object>) lsCheckInfo.get(j);
String signDate = Util.null2String(checkInfo.get("signDate"));
String signTime = Util.null2String(checkInfo.get("signTime"));
String deduct_signofftime = Util.null2String(checkInfo.get("deduct_signofftime"));
if (checkInfo.get("signType").equals("2")) {//签退
String signOutTime = signTime;
int signInTimeOutdx = kqTimesArrayComInfo.getArrayindexByTimes(signOutTime);
String flow_signOutTime = signOutTime;
if(deduct_signofftime.length() > 0){
if(signTime.length() > 0){
if(deduct_signofftime.compareTo(signTime) > 0){
flow_signOutTime = deduct_signofftime;
}
}else{
flow_signOutTime = deduct_signofftime;
}
}
if(flow_signOutTime.length() > 0){
signInTimeOutdx = kqTimesArrayComInfo.getArrayindexByTimes(flow_signOutTime);
}
if(kqDate.compareTo(signDate) < 0)signInTimeOutdx+=1440;
if(signInTimeOutdx>workEndIdx) {
lateOutMins = signInTimeOutdx-workEndIdx;
}
}
}
}
return lateOutMins;
}
public int getPreDayLateOutMins(String userId, String kqDate) {
return getPreDayLateOutMins(userId, kqDate, Lists.newArrayList());
}
/**
*
*/
public int getPreDayLateOutMins(String userId, String kqDate,List<String> logList) {
int preDayLateOutMins = 0;
boolean oneSign = false;
KQWorkTime kqWorkTime = new KQWorkTime();
//前一天是非工作日,往前取到工作日
String tmpKQPreDate = DateUtil.addDate(kqDate, -1);
for(int i=0;i<31;i++){
WorkTimeEntity workTime = kqWorkTime.getWorkTime(userId, tmpKQPreDate);
if(workTime.getWorkMins()>0){
kqDate = DateUtil.addDate(tmpKQPreDate, 1);
break;
}
tmpKQPreDate = DateUtil.addDate(tmpKQPreDate, -1);
}
String kqPreDate = DateUtil.addDate(kqDate, -1);;
String kqPrePreDate = DateUtil.addDate(kqDate, -2);
WorkTimeEntity workTime = kqWorkTime.getWorkTime(userId, kqPreDate);
List<TimeScopeEntity> lsSignTime = new ArrayList<>();
List<TimeScopeEntity> lsWorkTime = new ArrayList<>();
if (workTime != null) {
lsSignTime = workTime.getSignTime();//允许打卡时间
lsWorkTime = workTime.getWorkTime();//工作时间
oneSign = lsWorkTime != null && lsWorkTime.size() == 1;
}
if (oneSign) {
KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo();
TimeScopeEntity signTimeScope = lsSignTime.get(0);
TimeScopeEntity workTimeScope = lsWorkTime.get(0);
String signBeginDateTime = signTimeScope.getBeginTimeAcross() ? kqPrePreDate : kqPreDate;
signBeginDateTime += " " + kqTimesArrayComInfo.turn48to24Time(signTimeScope.getBeginTime()) + ":00";
String signEndDateTime = signTimeScope.getEndTimeAcross() ? kqDate : kqPreDate;
signEndDateTime += " " + kqTimesArrayComInfo.turn48to24Time(signTimeScope.getEndTime()) + ":00";
String workBeginDateTime = workTimeScope.getBeginTimeAcross() ? kqPrePreDate : kqPreDate;
workBeginDateTime += " " + kqTimesArrayComInfo.turn48to24Time(workTimeScope.getBeginTime()) + ":00";
String workEndDateTime = workTimeScope.getEndTimeAcross() ? kqDate : kqPreDate;
workEndDateTime += " " + kqTimesArrayComInfo.turn48to24Time(workTimeScope.getEndTime()) + ":00";
Map<String, String> shifRuleMap = Maps.newHashMap();
String shif_workEndTime = "";
getPre_ShiftRuleInfo(kqPreDate,workTime,lsSignTime,lsWorkTime,userId,shifRuleMap,logList);
if(!shifRuleMap.isEmpty()){
if(shifRuleMap.containsKey("shift_endworktime")){
String shift_endworktime = Util.null2String(shifRuleMap.get("shift_endworktime"));
if(shift_endworktime.length() > 0){
shif_workEndTime = Util.null2String(shift_endworktime);
}
}
}
List<Object> lsCheckInfo = new KQFormatSignData().getSignInfo(userId,signTimeScope,workTimeScope,kqPreDate,kqPrePreDate,kqDate,kqTimesArrayComInfo);
Map<String, Object> checkInfo = null;
if (lsCheckInfo.size() == 2) {
for(int i = 0 ;i < lsCheckInfo.size() ;i++){
checkInfo = (Map<String, Object>) lsCheckInfo.get(i);
String signType = Util.null2String(checkInfo.get("signType"));
if("2".equalsIgnoreCase(signType)){
break;
}
}
String signDate = Util.null2String(checkInfo.get("signDate"));
String signTime = Util.null2String(checkInfo.get("signTime"));
String workEndTime = Util.null2String(workTimeScope.getEndTime());
int workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(workEndTime);
if(shif_workEndTime.length() > 0){
workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(shif_workEndTime);
}
if (!kqPreDate.equals(signDate)) { //跨天
signTime = kqTimesArrayComInfo.turn24to48Time(signTime);
}
int signOutTimeIdx = kqTimesArrayComInfo.getArrayindexByTimes(signTime);
if (signOutTimeIdx > workEndIdx) {
preDayLateOutMins = signOutTimeIdx - workEndIdx;
logList.add("签退时间是:"+(signDate+" "+kqTimesArrayComInfo.turn48to24Time(signTime))+",晚走了"+preDayLateOutMins+"分钟");
}
}else if(!lsCheckInfo.isEmpty()){
for(int i = 0 ;i < lsCheckInfo.size() ;i++){
Map<String, Object> checkInfoMap = (Map<String, Object>) lsCheckInfo.get(i);
String signType = Util.null2String(checkInfoMap.get("signType"));
if("2".equalsIgnoreCase(signType)){
String signDate = Util.null2String(checkInfoMap.get("signDate"));
String signTime = Util.null2String(checkInfoMap.get("signTime"));
String workEndTime = Util.null2String(workTimeScope.getEndTime());
int workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(workEndTime);
if(shif_workEndTime.length() > 0){
workEndIdx = kqTimesArrayComInfo.getArrayindexByTimes(shif_workEndTime);
}
if (!kqPreDate.equals(signDate)) { //跨天
signTime = kqTimesArrayComInfo.turn24to48Time(signTime);
}
int signOutTimeIdx = kqTimesArrayComInfo.getArrayindexByTimes(signTime);
if (signOutTimeIdx > workEndIdx) {
preDayLateOutMins = signOutTimeIdx - workEndIdx;
logList.add(",签退时间是:"+(signDate+" "+signTime)+",晚走了"+preDayLateOutMins+"分钟");
}
}
}
}
}
return preDayLateOutMins;
}
/**
*
* @param kqPreDate
* @param workTime
* @param lsSignTime
* @param lsWorkTime
* @param userId
* @param logList
*/
public void getPre_ShiftRuleInfo(String kqPreDate, WorkTimeEntity workTime,
List<TimeScopeEntity> lsSignTime, List<TimeScopeEntity> lsWorkTime, String userId,
Map<String, String> shifRuleMap,List<String> logList) {
ShiftInfoBean shiftInfoBean = new ShiftInfoBean();
shiftInfoBean.setSplitDate(kqPreDate);
shiftInfoBean.setShiftRuleMap(workTime.getShiftRuleInfo());
shiftInfoBean.setSignTime(lsSignTime);
shiftInfoBean.setWorkTime(lsWorkTime);
KQShiftRuleInfoBiz.getShiftRuleInfo(shiftInfoBean, userId, shifRuleMap,false,logList);
}
/**
*
* @param i
* @param serialId
*/
public Map<String, String> getModel_ShiftRule(int i,String serialId) {
RecordSet rs = new RecordSet();
HashMap<String,String> sectionMap = new HashMap<>();
String getStartWorkSections = "select * from kq_ShiftOnOffWorkSections where SERIALID=? and record=? ";
rs.executeQuery(getStartWorkSections,serialId,i);
while (rs.next()) {
String onoffworktype = Util.null2String(rs.getString("onoffworktype"));
String clockinnot = Util.null2s(Util.null2String(rs.getString("clockinnot")), "0");
sectionMap.put(onoffworktype, clockinnot);
}
return sectionMap;
}
}

@ -0,0 +1,649 @@
package com.engine.kq.biz;
import com.alibaba.fastjson.JSON;
import com.engine.kq.cmd.attendanceButton.ButtonStatusEnum;
import com.engine.kq.entity.TimeScopeEntity;
import com.engine.kq.entity.TimeSignScopeEntity;
import com.engine.kq.log.KQLog;
import com.engine.kq.util.UtilKQ;
import com.engine.kq.wfset.util.KQSignUtil;
import com.google.common.collect.Lists;
import java.io.PrintWriter;
import java.io.StringWriter;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import java.util.*;
/**
*
*/
public class KQFormatSignData extends BaseBean {
private KQLog kqLog = new KQLog();
public List<Object> getSignInfo(String userId, TimeScopeEntity signTimeScope,
TimeScopeEntity workTimeScope, String kqDate, String preDate,
String nextDate, KQTimesArrayComInfo kqTimesArrayComInfo) {
return getSignInfo(userId, signTimeScope, workTimeScope, kqDate, preDate, nextDate, kqTimesArrayComInfo,
Lists.newArrayList(), "");
}
public List<Object> getSignInfo(String userId, TimeScopeEntity signTimeScope,
TimeScopeEntity workTimeScope, String kqDate, String preDate,
String nextDate, KQTimesArrayComInfo kqTimesArrayComInfo,ArrayList<String> hostIps,String uuid) {
return getSignInfo(userId, signTimeScope, workTimeScope, kqDate, preDate, nextDate, kqTimesArrayComInfo, hostIps, uuid, 0, 0);
}
/***
*
* @param userId
* @param signTimeScope
* @param workTimeScope
* @param kqDate
* @param preDate
* @param nextDate
* @param kqTimesArrayComInfo
* @return
*/
public List<Object> getSignInfo(String userId, TimeScopeEntity signTimeScope,
TimeScopeEntity workTimeScope, String kqDate, String preDate,
String nextDate, KQTimesArrayComInfo kqTimesArrayComInfo,ArrayList<String> hostIps,String uuid, int shiftCount, int shiftI) {
kqLog.info("in getSignInfo ::userId" + userId + "kqDate==" + kqDate+":hostIps:"+hostIps+":uuid::"+uuid+" in ");
List<Object> lsCheckInfo = new ArrayList<>();
String count4NoonStartDateTime = "";
String count4NoonEndDateTime = "";
try{
Map<String, Object> checkInfo = null;
String base_sql = "";
RecordSet rs = new RecordSet();
String dbtype = rs.getDBType();
//获取工作上下班时间
String workBeginDateTime = workTimeScope.getBeginTimeAcross() ? nextDate : kqDate;
workBeginDateTime+=" "+kqTimesArrayComInfo.turn48to24Time(workTimeScope.getBeginTime())+":00";
kqLog.info("in getSignInfo ::userId" + userId + "kqDate==" + kqDate+":hostIps:"+hostIps+":uuid::"+uuid+"::workBeginDateTime::"+workBeginDateTime);
//获取工作上下班时间
String workEndDateTime = workTimeScope.getEndTimeAcross() ? nextDate : kqDate;
workEndDateTime+=" "+kqTimesArrayComInfo.turn48to24Time(workTimeScope.getEndTime())+":00";
kqLog.info("in getSignInfo ::userId" + userId + "kqDate==" + kqDate+":hostIps:"+hostIps+":uuid::"+uuid+"::workEndDateTime::"+workEndDateTime);
Map<String,String> flow_deduct_card_map = getflowDeductCardSql(userId,kqDate,workTimeScope.getBeginTime(),workTimeScope.getEndTime());
kqLog.info("in getSignInfo ::userId" + userId + "kqDate==" + kqDate+":hostIps:"+hostIps+":uuid::"+uuid+"::flow_deduct_card_map::"+flow_deduct_card_map);
List<Map<String,String>> sqlConditions = getCanSignInfo(signTimeScope,kqDate,preDate,nextDate,kqTimesArrayComInfo,workTimeScope, shiftCount, shiftI);
base_sql = signSignSql(rs);
new KQLog().info("sqlConditions:(userId:"+userId+":base_sql"+base_sql+":::userId" + userId + "kqDate==" + kqDate+":hostIps:"+hostIps+":uuid::"+uuid+"::flow_deduct_card_map::"+flow_deduct_card_map);
if(sqlConditions != null && !sqlConditions.isEmpty()){
if(shiftCount == 2) {
String fieldName = "";
if(shiftI == 0) {
fieldName = "signEndDateTime";
} else if(shiftI == 1) {
fieldName = "signBeginDateTime";
}
Map<String, String> sqlMap = sqlConditions.get(0);
count4NoonStartDateTime = Util.null2String(sqlMap.get(fieldName));
if (count4NoonStartDateTime.length() == 19) {
count4NoonStartDateTime = count4NoonStartDateTime.substring(0, 17) + "00";
}
sqlMap = sqlConditions.get(0);
count4NoonEndDateTime = Util.null2String(sqlMap.get(fieldName));
if (sqlConditions.size() >= 2) {
sqlMap = sqlConditions.get(1);
count4NoonEndDateTime = Util.null2String(sqlMap.get(fieldName));
}
}
for(Map<String,String> sqlMap : sqlConditions){
String sql = "";
String orderSql = "";
int idx = 0;
String signBeginDateTime = Util.null2String(sqlMap.get("signBeginDateTime"));
String signEndDateTime = Util.null2String(sqlMap.get("signEndDateTime"));
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);
new KQLog().info("getSignInfo:(userId:"+userId+":signBeginDateTime:"+
signBeginDateTime+":signEndDateTime:"+signEndDateTime+"):sql"+sql+":counts:"+rs.getCounts()+":::userId" + userId + "kqDate==" + kqDate+":hostIps:"+hostIps+":uuid::"+uuid+"::flow_deduct_card_map::"+flow_deduct_card_map);
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);//签到签退时间
String signDateTime = signdate + " " + signtime;
idx++;
if(type.length() > 0){
if("signin".equalsIgnoreCase(type)){
checkInfo.put("signType", "1");
if(workBeginDateTime.length()>0) {
checkInfo.put("signStatus", UtilKQ.getSignStatus("1", signDateTime, workBeginDateTime));
}
if(!Util.null2String(checkInfo.get("signStatus")).equalsIgnoreCase(ButtonStatusEnum.NORMAL.getStatusCode())){
if(flow_deduct_card_map.containsKey("signin")){
String deduct_signintime = Util.null2String(flow_deduct_card_map.get("signin"));
if(deduct_signintime.length() > 0){
signDateTime = signdate + " " + deduct_signintime;
checkInfo.put("deduct_signintime", deduct_signintime);//流程抵扣作为打卡时间
checkInfo.put("signStatus", UtilKQ.getSignStatus("1", signDateTime, workBeginDateTime));
}
}
}
lsCheckInfo.add(checkInfo);
}else {
checkInfo.put("signType", "2");
if(workEndDateTime.length()>0) {
checkInfo.put("signStatus", UtilKQ.getSignStatus("2", signDateTime, workEndDateTime));
}
if(!Util.null2String(checkInfo.get("signStatus")).equalsIgnoreCase(ButtonStatusEnum.NORMAL.getStatusCode())){
if(flow_deduct_card_map.containsKey("signoff")){
String deduct_signofftime = Util.null2String(flow_deduct_card_map.get("signoff"));
if(deduct_signofftime.length() > 0){
signDateTime = signdate + " " + deduct_signofftime;
checkInfo.put("deduct_signofftime", deduct_signofftime);//流程抵扣作为打卡时间
checkInfo.put("signStatus", UtilKQ.getSignStatus("2", signDateTime, workEndDateTime));
}
}
}
lsCheckInfo.add(checkInfo);
}
}else{
if(idx==1){//第一条算签到
checkInfo.put("signType", "1");
if(workBeginDateTime.length()>0) {
checkInfo.put("signStatus", UtilKQ.getSignStatus("1", signDateTime, workBeginDateTime));
}
if(!Util.null2String(checkInfo.get("signStatus")).equalsIgnoreCase(ButtonStatusEnum.NORMAL.getStatusCode())){
if(flow_deduct_card_map.containsKey("signin")){
String deduct_signintime = Util.null2String(flow_deduct_card_map.get("signin"));
if(deduct_signintime.length() > 0){
signDateTime = signdate + " " + deduct_signintime;
checkInfo.put("deduct_signintime", deduct_signintime);//流程抵扣作为打卡时间
checkInfo.put("signStatus", UtilKQ.getSignStatus("1", signDateTime, workBeginDateTime));
}
}
}
lsCheckInfo.add(checkInfo);
}else if(idx==rs.getCounts()){//最后一条算签退
checkInfo.put("signType", "2");
if(workEndDateTime.length()>0) {
checkInfo.put("signStatus", UtilKQ.getSignStatus("2", signDateTime, workEndDateTime));
}
if(!Util.null2String(checkInfo.get("signStatus")).equalsIgnoreCase(ButtonStatusEnum.NORMAL.getStatusCode())){
if(flow_deduct_card_map.containsKey("signoff")){
String deduct_signofftime = Util.null2String(flow_deduct_card_map.get("signoff"));
if(deduct_signofftime.length() > 0){
signDateTime = signdate + " " + deduct_signofftime;
checkInfo.put("deduct_signofftime", deduct_signofftime);//流程抵扣作为打卡时间
checkInfo.put("signStatus", UtilKQ.getSignStatus("2", signDateTime, workEndDateTime));
}
}
}
lsCheckInfo.add(checkInfo);
}
}
}
}
}
//如果签到,签退不成对,流程抵扣异常存在,那么需要判断下是不是可以补足
if(lsCheckInfo.size() < 2 && !flow_deduct_card_map.isEmpty()){
if(lsCheckInfo.isEmpty()){
if(flow_deduct_card_map.containsKey("signin")){
String deduct_signintime = Util.null2String(flow_deduct_card_map.get("signin"));
if(deduct_signintime.length() > 0){
checkInfo = new HashMap<>();
String[] workBeginDateTimes = workBeginDateTime.split(" ");
String tmp_workBeginDate = workBeginDateTimes[0];
String tmp_workBeginTime = workBeginDateTimes[1];
checkInfo.put("signType", "1");
checkInfo.put("signDate", tmp_workBeginDate);//签到签退日期
checkInfo.put("signTime", "");//签到签退时间
checkInfo.put("deduct_signintime", tmp_workBeginTime);//流程抵扣作为打卡时间
checkInfo.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode());
lsCheckInfo.add(checkInfo);
}
}
if(flow_deduct_card_map.containsKey("signoff")){
String deduct_signofftime = Util.null2String(flow_deduct_card_map.get("signoff"));
if(deduct_signofftime.length() > 0){
checkInfo = new HashMap<>();
String[] workEndDateTimes = workEndDateTime.split(" ");
String tmp_workEndDate = workEndDateTimes[0];
String tmp_workEndTime = workEndDateTimes[1];
checkInfo.put("signType", "2");
checkInfo.put("signDate", tmp_workEndDate);//签到签退日期
checkInfo.put("signTime", "");//签到签退时间
checkInfo.put("deduct_signofftime", tmp_workEndTime);//流程抵扣作为打卡时间
checkInfo.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode());
lsCheckInfo.add(checkInfo);
}
}
}else{
Map<String, Object> checkCardMap = (Map<String, Object>) lsCheckInfo.get(0);
if(!checkCardMap.isEmpty()){
String signType = Util.null2String(checkCardMap.get("signType"));
if("1".equalsIgnoreCase(signType)){
//如果签到数据有了,检测下是不是有签退的流程抵扣打卡
if(flow_deduct_card_map.containsKey("signoff")){
String deduct_signofftime = Util.null2String(flow_deduct_card_map.get("signoff"));
if(deduct_signofftime.length() > 0){
checkInfo = new HashMap<>();
String[] workEndDateTimes = workEndDateTime.split(" ");
String tmp_workEndDate = workEndDateTimes[0];
String tmp_workEndTime = workEndDateTimes[1];
checkInfo.put("signType", "2");
checkInfo.put("signDate", tmp_workEndDate);//签到签退日期
checkInfo.put("signTime", "");//签到签退时间
checkInfo.put("deduct_signofftime", tmp_workEndTime);//流程抵扣作为打卡时间
checkInfo.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode());
lsCheckInfo.add(checkInfo);
}
}
}else{
if(flow_deduct_card_map.containsKey("signin")){
String deduct_signintime = Util.null2String(flow_deduct_card_map.get("signin"));
if(deduct_signintime.length() > 0){
checkInfo = new HashMap<>();
String[] workBeginDateTimes = workBeginDateTime.split(" ");
String tmp_workBeginDate = workBeginDateTimes[0];
String tmp_workBeginTime = workBeginDateTimes[1];
checkInfo.put("signType", "1");
checkInfo.put("signDate", tmp_workBeginDate);//签到签退日期
checkInfo.put("signTime", "");//签到签退时间
checkInfo.put("deduct_signintime", tmp_workBeginTime);//流程抵扣作为打卡时间
checkInfo.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode());
lsCheckInfo.add(checkInfo);
}
}
}
}
}
}
// 上午的签退取中间时段的第一次打卡
if(shiftCount == 2 && shiftI == 0) {
String noonSignTimeSql = KQSignUtil.buildSignSql(count4NoonStartDateTime,count4NoonEndDateTime);
String baseSql = "select * from hrmschedulesign where 1=1 and isInCom='1' and userid="+userId+" ";
String sql = baseSql;
sql += " and "+noonSignTimeSql + " order by signdate, signtime";
rs.executeQuery(sql);
if(rs.next()) {
String signId = Util.null2String(rs.getString("id"));
String signDate = Util.null2String(rs.getString("signdate"));
String signTime = Util.null2String(rs.getString("signtime"));
String signDateTime = signDate+" "+signTime;
for (int j = 0; lsCheckInfo != null && j < lsCheckInfo.size(); j++) {
Map<String, Object> checkInfoInner = (Map<String, Object>) lsCheckInfo.get(j);
if (checkInfoInner.get("signType").equals("2")) {//签退
String signDateInner = Util.null2String(checkInfoInner.get("signDate"));
String signTimeInner = Util.null2String(checkInfoInner.get("signTime"));
String deduct_signofftime = Util.null2String(checkInfoInner.get("deduct_signofftime"));
if(!"".equals(signTimeInner)) {
String signDateTimeInner = signDateInner+" "+signTimeInner;
if(signDateTime.compareTo(signDateTimeInner) < 0) {
checkInfoInner.put("signId", signId);//签到签退标识
checkInfoInner.put("signType", "2");
checkInfoInner.put("signDate", signDateInner);//签到签退日期
checkInfoInner.put("signTime", signTime);//签到签退时间
checkInfoInner.put("deduct_signofftime", deduct_signofftime);//流程抵扣作为打卡时间
checkInfoInner.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode());
}
}
}
}
}
} else if(shiftCount == 2 && shiftI == 1) { // 下午的签到取中间时段的第二次打卡
String noonSignTimeSql = KQSignUtil.buildSignSql(count4NoonStartDateTime,count4NoonEndDateTime);
String baseSql = "select * from hrmschedulesign where 1=1 and isInCom='1' and userid="+userId+" ";
String sql = baseSql;
sql += " and "+noonSignTimeSql + " order by signdate, signtime";
rs.executeQuery(sql);
int count=0;
int counts=rs.getCounts();
if(counts==1){
lsCheckInfo.clear();
}
while (rs.next()) {
if(count == 0) {
count++;
continue;
}
String signId = Util.null2String(rs.getString("id"));
String signTime = Util.null2String(rs.getString("signtime"));
for (int j = 0; lsCheckInfo != null && j < lsCheckInfo.size(); j++) {
Map<String, Object> checkInfoInner = (Map<String, Object>) lsCheckInfo.get(j);
if (checkInfoInner.get("signType").equals("1")) {//签退
String signDateInner = Util.null2String(checkInfoInner.get("signDate"));
String signTimeInner = Util.null2String(checkInfoInner.get("signTime"));
String deduct_signofftime = Util.null2String(checkInfoInner.get("deduct_signofftime"));
checkInfoInner.put("signId", signId);//签到签退标识
checkInfoInner.put("signType", "1");
checkInfoInner.put("signDate", signDateInner);//签到签退日期
checkInfoInner.put("signTime", signTime);//签到签退时间
checkInfoInner.put("deduct_signofftime", deduct_signofftime);//流程抵扣作为打卡时间
checkInfoInner.put("signStatus", ButtonStatusEnum.NORMAL.getStatusCode());
}
}
break;
}
}
}catch (Exception e){
kqLog.info("报表错:getSignInfo:");
StringWriter errorsWriter = new StringWriter();
e.printStackTrace(new PrintWriter(errorsWriter));
kqLog.info(errorsWriter.toString());
}
//writeLog(sql,userId +"=="+ signBeginDateTime+"=="+signEndDateTime);
return lsCheckInfo;
}
/**
*
* @param userId
* @param kqDate
* @param workBeginDateTime
* @param workEndDateTime
*/
public Map<String,String> getflowDeductCardSql(String userId, String kqDate, String workBeginDateTime, String workEndDateTime) {
Map<String,String> flow_deduct_card_map = new HashMap<>();
RecordSet rs = new RecordSet();
String flow_deduct_card_sql = "select * from kq_flow_deduct_card where 1=1 and (isclear is null or isclear<>1) ";
if(userId.length() > 0){
flow_deduct_card_sql += " and resourceid="+userId;
}
if(kqDate.length() > 0){
flow_deduct_card_sql += " and belongDate='"+kqDate+"'";
}
if(workBeginDateTime.length() > 0){
flow_deduct_card_sql += " and workBeginTime='"+workBeginDateTime+"'";
}
if(workEndDateTime.length() > 0){
flow_deduct_card_sql += " and workEndTime='"+workEndDateTime+"'";
}
rs.executeQuery(flow_deduct_card_sql);
while (rs.next()){
String signtype = rs.getString("signtype");
if("1".equalsIgnoreCase(signtype)){
flow_deduct_card_map.put("signin",workBeginDateTime);
}
if("2".equalsIgnoreCase(signtype)){
flow_deduct_card_map.put("signoff",workEndDateTime);
}
}
return flow_deduct_card_map;
}
/**
* sql
* @param signTimeScope
* @param kqDate
* @param preDate
* @param nextDate
* @param kqTimesArrayComInfo
* @return
*/
public List<Map<String,String>> getCanSignInfo(TimeScopeEntity signTimeScope, String kqDate, String preDate, String nextDate, KQTimesArrayComInfo kqTimesArrayComInfo) {
return getCanSignInfo(signTimeScope,kqDate,preDate,nextDate,kqTimesArrayComInfo,null);
}
public List<Map<String,String>> getCanSignInfo(TimeScopeEntity signTimeScope, String kqDate, String preDate, String nextDate, KQTimesArrayComInfo kqTimesArrayComInfo,TimeScopeEntity workTimeScope) {
return getCanSignInfo(signTimeScope, kqDate, preDate, nextDate, kqTimesArrayComInfo,workTimeScope, 0, 0);
}
public List<Map<String,String>> getCanSignInfo(TimeScopeEntity signTimeScope, String kqDate, String preDate, String nextDate, KQTimesArrayComInfo kqTimesArrayComInfo,TimeScopeEntity workTimeScope, int shiftCount, int shiftI) {
List<Map<String,String>> sqlConditions = new ArrayList<>();
Map<String,String> conditionMap = new HashMap<>();
TimeSignScopeEntity timeSignScopeEntity = signTimeScope.getTimeSignScopeEntity();
String signBeginDateTime = "";
String signEndDateTime = "";
signBeginDateTime = signTimeScope.getBeginTimeAcross() ? nextDate : kqDate;
if(signTimeScope.isBeginTimePreAcross()){
signBeginDateTime = preDate;
}
signBeginDateTime+=" "+kqTimesArrayComInfo.turn48to24Time(signTimeScope.getBeginTime())+":00";
signEndDateTime = signTimeScope.getEndTimeAcross() ? nextDate : kqDate;
// if (workTimeScope != null && workTimeScope.getEndTimeAcross() && signTimeScope.getEndTimeAcross() ) {
// if(workTimeScope.getEndTime().compareTo(signTimeScope.getEndTime())>=0){
// signEndDateTime = DateUtil.addDate(kqDate, 2);//下下一天日期;
// }
// }
signEndDateTime+=" "+kqTimesArrayComInfo.turn48to24Time(signTimeScope.getEndTime())+":59";
if(timeSignScopeEntity == null){
//没有设置 签到最晚时间和签退最早时间
conditionMap = new HashMap<>();
conditionMap.put("signBeginDateTime", signBeginDateTime);
conditionMap.put("signEndDateTime", signEndDateTime);
sqlConditions.add(conditionMap);
}else{
String beginTimeEnd = timeSignScopeEntity.getBeginTimeEnd();
boolean beginTimeEndAcross = timeSignScopeEntity.isBeginTimeEndAcross();
String endTimeStart = timeSignScopeEntity.getEndTimeStart();
boolean endTimeStartAcross = timeSignScopeEntity.isEndTimeStartAcross();
if(beginTimeEnd.length() > 0){
//如果设置了 上班结束时间
if(endTimeStart.length() > 0){
//设置了下班开始时间
String signBeginDateEndTime = "";
String signEndDateStartTime = "";
signBeginDateEndTime = beginTimeEndAcross ? nextDate : kqDate;
signBeginDateEndTime+=" "+kqTimesArrayComInfo.turn48to24Time(beginTimeEnd)+":59";
conditionMap = new HashMap<>();
conditionMap.put("signBeginDateTime", signBeginDateTime);
conditionMap.put("signEndDateTime", signBeginDateEndTime);
conditionMap.put("type", "signin");
sqlConditions.add(conditionMap);
signEndDateStartTime = endTimeStartAcross ? nextDate : kqDate;
signEndDateStartTime+=" "+kqTimesArrayComInfo.turn48to24Time(endTimeStart)+":00";
conditionMap = new HashMap<>();
conditionMap.put("signBeginDateTime", signEndDateStartTime);
conditionMap.put("signEndDateTime", signEndDateTime);
conditionMap.put("type", "signoff");
sqlConditions.add(conditionMap);
}else{
//没有设置下班开始时间
String signBeginDateEndTime = "";
String signEndDateStartTime = "";
signBeginDateEndTime = beginTimeEndAcross ? nextDate : kqDate;
signBeginDateEndTime+=" "+kqTimesArrayComInfo.turn48to24Time(beginTimeEnd)+":59";
conditionMap = new HashMap<>();
conditionMap.put("signBeginDateTime", signBeginDateTime);
conditionMap.put("signEndDateTime", signBeginDateEndTime);
conditionMap.put("type", "signin");
sqlConditions.add(conditionMap);
//如果设置了上班结束时间,相当于下班开始时间也被限定了
String endTimeByBeginTime = kqTimesArrayComInfo.getTimesByArrayindex(kqTimesArrayComInfo.getArrayindexByTimes(beginTimeEnd)+1);
signEndDateStartTime = beginTimeEndAcross ? nextDate : kqDate;
signEndDateStartTime+=" "+kqTimesArrayComInfo.turn48to24Time(endTimeByBeginTime)+":00";
conditionMap = new HashMap<>();
conditionMap.put("signBeginDateTime", signEndDateStartTime);
conditionMap.put("signEndDateTime", signEndDateTime);
conditionMap.put("type", "signoff");
sqlConditions.add(conditionMap);
}
}else if(endTimeStart.length() > 0){
//如果没有设置上班结束时间,设置了下班开始时间
String signBeginDateEndTime = "";
String signEndDateStartTime = "";
//如果设置了下班开始时间,相当于上班结束时间也被限定了
String BeginTimeByendTime = kqTimesArrayComInfo.getTimesByArrayindex(kqTimesArrayComInfo.getArrayindexByTimes(endTimeStart)-1);
signBeginDateEndTime = endTimeStartAcross ? nextDate : kqDate;
signBeginDateEndTime+=" "+kqTimesArrayComInfo.turn48to24Time(BeginTimeByendTime)+":59";
conditionMap = new HashMap<>();
conditionMap.put("signBeginDateTime", signBeginDateTime);
conditionMap.put("signEndDateTime", signBeginDateEndTime);
conditionMap.put("type", "signin");
sqlConditions.add(conditionMap);
signEndDateStartTime = endTimeStartAcross ? nextDate : kqDate;
signEndDateStartTime+=" "+kqTimesArrayComInfo.turn48to24Time(endTimeStart)+":00";
conditionMap = new HashMap<>();
conditionMap.put("signBeginDateTime", signEndDateStartTime);
conditionMap.put("signEndDateTime", signEndDateTime);
conditionMap.put("type", "signoff");
sqlConditions.add(conditionMap);
}
}
return sqlConditions;
}
public String signSignSql(RecordSet rs){
String sql = "";
if(rs.getDBType().equals("oracle")){
sql = " select id,signdate,signtime from hrmschedulesign where isincom=1 and userid = ? and signdate||' '||signtime >= ? and signdate||' '||signtime <= ? " +
" ";
}else if("sqlserver".equals(rs.getDBType())){
sql = " select id,signdate,signtime from hrmschedulesign where isincom=1 and userid = ? and signdate + ' ' + signtime >= ? and signdate + ' ' + signtime <= ? " +
" ";
}else{
sql = " select id,signdate,signtime from hrmschedulesign where isincom=1 and userid = ? and concat(signdate,' ',signtime) >= ? and concat(signdate,' ',signtime) <= ? " +
" ";
}
return sql;
}
public List<Object> getSignInfoForAll(String userId, String signBeginDateTime, String signEndDateTime, String workBeginDateTime, String workEndDateTime) {
List<Object> lsCheckInfo = new ArrayList<>();
Map<String, Object> checkInfo = null;
String sql = "";
RecordSet rs = new RecordSet();
int idx = 0;
if(rs.getDBType().equals("oracle")){
sql = " select id,signdate,signtime from hrmschedulesign where isincom=1 and userid = ? and signdate||' '||signtime >= ? and signdate||' '||signtime <= ? " +
" order by signdate asc, signtime asc ";
}else if("sqlserver".equals(rs.getDBType())){
sql = " select id,signdate,signtime from hrmschedulesign where isincom=1 and userid = ? and signdate + ' ' + signtime >= ? and signdate + ' ' + signtime <= ? " +
" order by signdate asc, signtime asc ";
}else{
sql = " select id,signdate,signtime from hrmschedulesign where isincom=1 and userid = ? and concat(signdate,' ',signtime) >= ? and concat(signdate,' ',signtime) <= ? " +
" order by signdate asc, signtime asc ";
}
rs.executeQuery(sql, userId, signBeginDateTime, signEndDateTime);
//writeLog(sql,userId +"=="+ signBeginDateTime+"=="+signEndDateTime);
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);//签到签退时间
String signDateTime = signdate + " " + signtime;
idx++;
if(idx%2==1){
checkInfo.put("signType", "1");
}else{
checkInfo.put("signType", "2");
}
lsCheckInfo.add(checkInfo);
}
return lsCheckInfo;
}
public List<Object> getNonWorkSignInfo(String userId, String preDate, String kqDate,
List<TimeScopeEntity> pre_lsSignTime,
List<TimeScopeEntity> next_lsSignTime) {
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 sql = "select * from hrmschedulesign where userid="+userId+" and signdate = '"+kqDate+"' ";
if(pre_Worktime4Today.length() > 0){
if(pre_Worktime4Today.length() == 5){
pre_Worktime4Today += ":59";
}
sql += " and signtime > '"+pre_Worktime4Today+"'";
}
if(next_Worktime4Today.length() > 0){
if(next_Worktime4Today.length() == 5){
next_Worktime4Today += ":00";
}
sql += " and signtime < '"+next_Worktime4Today+"'";
}
sql += " order by signdate asc,signtime asc ";
rs.executeQuery(sql);
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);
}
}
return lsCheckInfo;
}
}

@ -0,0 +1,452 @@
package com.engine.kq.biz;
import com.engine.integration.util.MyX509TrustManager;
import com.engine.kq.log.KQLog;
import net.sf.json.JSONObject;
import org.apache.commons.lang3.StringUtils;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.file.Prop;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.systeminfo.SystemEnv;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.*;
/**
*
*/
public class KQHolidaySetBiz {
private static KQLog logger = new KQLog();
private static BaseBean bb = new BaseBean();
/**
* ID
*
* @param resourceId ID
* @param year
* @param month
* @return
*/
public static List getGroupHolidaySetList(String groupId, String year, String month) {
List<Map<String, Object>> valueList = new ArrayList<Map<String, Object>>();
Map<String, Object> valueMap = new HashMap<String, Object>();
/*指定年月*/
String startDate = year;
String endDate = month;
if (month.length() == 0) {
startDate = year + "-01" + "-01";
endDate = year + "-12" + "-31";
} else if (month.length() == 1) {
startDate = year + "-0" + month + "-01";
endDate = year + "-0" + month + "-31";
} else if (month.length() == 2) {
startDate = year + "-" + month + "-01";
endDate = year + "-" + month + "-31";
}
RecordSet recordSet = new RecordSet();
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo();
KQHolidaySetComInfo holidaySetComInfo = new KQHolidaySetComInfo();
boolean isEnd = false;
for (String date = startDate; !isEnd; ) {
if (date.compareTo(endDate) >= 0) {
isEnd = true;
}
String changeType = holidaySetComInfo.getChangeType(groupId, date);
String holidayDesc = holidaySetComInfo.getHolidayDesc(groupId, date);
if (!changeType.equals("")) {
valueMap = new HashMap<String, Object>();
valueMap.put("date", date);
valueMap.put("name", holidayDesc);
valueMap.put("type", changeType);
valueList.add(valueMap);
}
date = DateUtil.getDate(date, 1);
}
return valueList;
}
/**
* ID
*
* @param resourceId ID
* @param year
* @param month
* @return
*/
public static List getKQHolidaySetList(String resourceId, String year, String month) {
Map<String, Object> valueMap = new HashMap<String, Object>();
List<Map<String, Object>> valueList = new ArrayList<Map<String, Object>>();
/*指定年月*/
String startDate = year;
String endDate = month;
if (month.length() == 0) {
startDate = year + "-01" + "-01";
endDate = year + "-12" + "-31";
} else if (month.length() == 1) {
startDate = year + "-0" + month + "-01";
endDate = year + "-0" + month + "-31";
} else if (month.length() == 2) {
startDate = year + "-" + month + "-01";
endDate = year + "-" + month + "-31";
}
valueList = getHolidaySetListByScope(resourceId, startDate, endDate);
return valueList;
}
/**
*
*
* @param resourceId ID
* @param startDate
* @param endDate
* @return
*/
public static List getHolidaySetListByScope(String resourceId, String startDate, String endDate) {
Map<String, Object> valueMap = new HashMap<String, Object>();
List<Map<String, Object>> valueList = new ArrayList<Map<String, Object>>();
RecordSet recordSet = new RecordSet();
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo();
KQHolidaySetComInfo holidaySetComInfo = new KQHolidaySetComInfo();
boolean isEnd = false;
for (String date = startDate; !isEnd; ) {
if (date.compareTo(endDate) >= 0) {
isEnd = true;
}
/*获取考勤组的ID因为考勤组有有效期所以需要传入日期*/
String groupId = kqGroupMemberComInfo.getKQGroupId(resourceId, date);
String changeType = holidaySetComInfo.getChangeType(groupId, date);
String holidayDesc = holidaySetComInfo.getHolidayDesc(groupId, date);
if (!changeType.equals("")) {
valueMap = new HashMap<String, Object>();
valueMap.put("date", date);
valueMap.put("name", holidayDesc);
valueMap.put("type", changeType);
valueList.add(valueMap);
}
date = DateUtil.getDate(date, 1);
}
return valueList;
}
/**
* +
*
* @param resourceId ID
* @param date
* @return true-false
*/
public static boolean isHoliday(String resourceId, String date) {
return isHoliday(resourceId, date, false);
}
/**
* ++
*
* @param resourceId ID
* @param date
* @param containWeekend truefalse
* @return true-false
*/
public static boolean isHoliday(String resourceId, String date, boolean containWeekend) {
boolean flag = false;
bb.writeLog("isHoliday-" + resourceId + "-" + date);
//当天有排班的不算节假日
KQShiftScheduleComInfo scheduleComInfo = new KQShiftScheduleComInfo();
String serialId = scheduleComInfo.getSerialId(resourceId, date);
if (StringUtils.isNotEmpty(serialId)) {
return false;
}
/*获取考勤组的ID因为考勤组有有效期所以需要传入日期*/
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo();
String groupId = kqGroupMemberComInfo.getKQGroupId(resourceId, date);
int changeType = getChangeType(groupId, date);
/*如果需要包含周末,判断传入的日期是不是周末*/
if (containWeekend && changeType != 2 && (DateUtil.getWeek(date) == 6 || DateUtil.getWeek(date) == 7)) {
flag = true;
}
if (changeType == 1 || changeType == 3) {
flag = true;
}
return flag;
}
/**
* ()
*
* @param groupId ID
* @param date
* @return 1-2-3--1-
*/
public static int getChangeType(String groupId, String date) {
int changeType = -1;//默认没有设置过节假日(节假日设置的类型1-公众假日、2-调配工作日、3-调配休息日)
KQHolidaySetComInfo kqHolidaySetComInfo = new KQHolidaySetComInfo();
changeType = Util.getIntValue(kqHolidaySetComInfo.getChangeType(groupId, date), -1);
return changeType;
}
/**
* ()
*
* @param resourceId ID
* @param date
* @return
*/
public static int getRelatedDay(String resourceId, String date) {
int relatedDay = -1;
/*获取考勤组的ID因为考勤组有有效期所以需要传入日期*/
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo();
String groupId = kqGroupMemberComInfo.getKQGroupId(resourceId, date);
/*排班制不支持调配节假日数据*/
KQGroupComInfo kqGroupComInfo = new KQGroupComInfo();
String KQType = kqGroupComInfo.getKqtype(groupId);//考勤类型1-固定班制、2-排班制、3-自由班制
if (KQType.equals("2")) {
return relatedDay;
}
/*只有当调配工作日时才有对应工作日*/
KQHolidaySetComInfo kqHolidaySetComInfo = new KQHolidaySetComInfo();
int changeType = Util.getIntValue(kqHolidaySetComInfo.getChangeType(groupId, date), -1);
if (changeType == 2) {
relatedDay = Util.getIntValue(kqHolidaySetComInfo.getRelatedDay(groupId, date), 0);
}
return relatedDay;
}
/**
* ()
*
* @param groupIds ID(ID,)
* @param year
* @return
*/
public static Map<String, Object> initHolidaySet(String groupIds, String year, User user) {
Map<String, Object> resultMap = new HashMap<String, Object>();
List<String> errInfoList = new ArrayList<String>();//错误信息集合
/**
* API(JSON)(APIAPI)
* status1-0-
* sketch''
* holidayList[{holidayDate:'',changeType:'',holidayDesc:''},,{holidayDate:'',changeType:'',holidayDesc:''}]
*/
String url = Prop.getInstance().getPropValue("kq_settings", "KQHolidaySetUrl");
Map<String, Object> tempMap = httpRequest(url +"?year="+year+"&key="+Util.getEncrypt(Util.getRandom()), user);
if ("0".equals((String) tempMap.get("status"))) {
resultMap.put("status", "0");
resultMap.put("sketch", (String) tempMap.get("sketch"));
return resultMap;
}
List<String> holidayDateList = new ArrayList<String>();
try {
List<String> groupIdList = Util.TokenizerString(groupIds, ",");//考勤组ID集合
for (int i = 0; i < groupIdList.size(); i++) {
String groupId = groupIdList.get(i);
/**
*
*/
List<String> dateList = new ArrayList<String>();
KQHolidaySetComInfo kqHolidaySetComInfo = new KQHolidaySetComInfo();
kqHolidaySetComInfo.setTofirstRow();
while (kqHolidaySetComInfo.next()) {
if (kqHolidaySetComInfo.getGroupId().equals(groupId)) {
dateList.add(kqHolidaySetComInfo.getHolidayDate());
}
}
/**
* ~
*/
int relatedDay = 0;
for (int x = 0; x < 7; x++) {
KQFixedSchedulceComInfo kqFixedSchedulceComInfo = new KQFixedSchedulceComInfo();
String serialId = Util.null2String(kqFixedSchedulceComInfo.getSerialid(groupId, x));
if (!serialId.equals("")) {
relatedDay = x;
break;
}
}
/**
* ()
*/
boolean flag = true;
RecordSet recordSet = new RecordSet();
KQGroupComInfo kqGroupComInfo = new KQGroupComInfo();
List<Map<String, Object>> holidayList = (List<Map<String, Object>>) tempMap.get("holidayList");
Map<String, Object> holidayMap = new HashMap<String, Object>();
for (int j = 0; j < holidayList.size(); j++) {
holidayMap = holidayList.get(j);
String holidayDate = year + "-" + (String) holidayMap.get("holidayDate");
if (!holidayDateList.contains(holidayDate)) {
holidayDateList.add(holidayDate);
}
int changeType = (int) holidayMap.get("changeType");
if (kqGroupComInfo.getKqtype(groupId).equals("2")&&changeType == 2 ) {
//排班制的考勤组不能初始化调配工作日
continue;
}
String holidayDesc = (String) holidayMap.get("holidayDesc");
if (dateList.contains(holidayDate)) {
String deleteSql = "delete from kq_HolidaySet where groupId=? and holidayDate=?";
recordSet.executeUpdate(deleteSql, groupId, holidayDate);
}
String sql = "insert into kq_HolidaySet(groupId,holidayDate,changeType,holidayDesc,relatedDay) values(?,?,?,?,?)";
flag = recordSet.executeUpdate(sql, groupId, holidayDate, changeType, holidayDesc, relatedDay);
if (!flag) {
errInfoList.add(SystemEnv.getHtmlLabelName(5056701, user.getLanguage()).replace("$groupName$", kqGroupComInfo.getGroupname(groupId)).replace("$holidayDate$", holidayDate));
}
}
}
/**
*
*/
if (errInfoList.size() > 0) {
resultMap.put("status", "0");
resultMap.put("sketch", SystemEnv.getHtmlLabelName(125960, user.getLanguage()));
resultMap.put("description", errInfoList);
} else {
resultMap.put("status", "1");
resultMap.put("sketch", SystemEnv.getHtmlLabelName(20196, user.getLanguage()));
}
} catch (Exception e) {
resultMap.put("status", "0");
resultMap.put("sketch", SystemEnv.getHtmlLabelName(382661, user.getLanguage()));
resultMap.put("desscription", errInfoList);
} finally {
/*刷新缓存*/
KQHolidaySetComInfo kqHolidaySetComInfo = new KQHolidaySetComInfo();
kqHolidaySetComInfo.removeCache();
/*刷新考勤报表*/
logger.info("初始化节假日数据格式化考勤报表。groupIdList=" + com.alibaba.fastjson.JSONObject.toJSONString(groupIds) +
"。holidayDateList=" + com.alibaba.fastjson.JSONObject.toJSONString(holidayDateList));
List<String> groupIdList = Util.TokenizerString(groupIds, ",");//考勤组ID集合
new KQHolidaySetThread(groupIdList,holidayDateList).start();
}
return resultMap;
}
/**
* API
*
* @param requestUrl
* @return
*/
private static Map<String, Object> httpRequest(String requestUrl, User user) {
Map<String, Object> resultMap = new HashMap<String, Object>();
//buffer用于接受返回的字符
StringBuffer buffer = new StringBuffer();
try {
TrustManager[] tm = {new MyX509TrustManager()};
SSLContext sslContext = SSLContext.getInstance("SSL", "SunJSSE");
sslContext.init(null, tm, new java.security.SecureRandom());
SSLSocketFactory ssf = sslContext.getSocketFactory();
URL url= new URL(null, requestUrl, new sun.net.www.protocol.https.Handler());
HttpsURLConnection httpUrlConn = (HttpsURLConnection) url.openConnection();
httpUrlConn.setSSLSocketFactory(ssf);
httpUrlConn.setDoOutput(true);
httpUrlConn.setDoInput(true);
httpUrlConn.setUseCaches(false);
httpUrlConn.setRequestMethod("GET");
httpUrlConn.connect();
//获得输入
InputStream inputStream = httpUrlConn.getInputStream();
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "utf-8");
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
//将bufferReader的值给放到buffer里
String str = null;
while ((str = bufferedReader.readLine()) != null) {
buffer.append(str);
}
//关闭bufferReader和输入流
bufferedReader.close();
inputStreamReader.close();
inputStream.close();
inputStream = null;
//断开连接
httpUrlConn.disconnect();
/**
* JSON
*/
String jsonStr = buffer.toString();
JSONObject jsonObject = JSONObject.fromObject(jsonStr).getJSONObject("data");
int code = jsonObject.optInt("code");//0服务正常。-1服务出错
if (code != 0) {
//初始化节假日失败,获取网络服务出错
resultMap.put("status", "0");
resultMap.put("sketch", SystemEnv.getHtmlLabelName(520011, user.getLanguage()));
return resultMap;
}
JSONObject holiday = jsonObject.getJSONObject("holiday");
if (holiday.size() == 0) {
//初始化节假日失败,暂未获取到所选年份的节假日数据
resultMap.put("status", "0");
resultMap.put("sketch", SystemEnv.getHtmlLabelName(505673, user.getLanguage()));
return resultMap;
}
Map<String, Object> holidayMap = new HashMap<String, Object>();
List<Map<String, Object>> holidayList = new ArrayList<Map<String, Object>>();
Iterator iterator = holiday.keys();
while (iterator.hasNext()) {
holidayMap = new HashMap<String, Object>();
String holidayDate = (String) iterator.next();
holidayMap.put("holidayDate", holidayDate);//日期
JSONObject detailInfo = holiday.getJSONObject(holidayDate);
int wage = detailInfo.optInt("wage");
if (wage == 1) {
holidayMap.put("changeType", 2);//调配工作日
} else if (wage == 2) {
holidayMap.put("changeType", 3);//调配休息日
} else if (wage == 3) {
holidayMap.put("changeType", 1);//公众假日
}
String holidayDesc = detailInfo.getString("name");
holidayMap.put("holidayDesc", holidayDesc);//说明
holidayList.add(holidayMap);
}
resultMap.put("status", "1");
resultMap.put("sketch", SystemEnv.getHtmlLabelName(505674, user.getLanguage()));
resultMap.put("holidayList", holidayList);
} catch (Exception e) {
e.printStackTrace();
resultMap.put("status", "0");
resultMap.put("sketch", SystemEnv.getHtmlLabelName(520011, user.getLanguage()));
return resultMap;
}
return resultMap;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,759 @@
package com.engine.kq.biz;
import com.alibaba.fastjson.JSON;
import com.engine.kq.biz.chain.cominfo.HalfShiftComIndex;
import com.engine.kq.biz.chain.cominfo.RestShiftComIndex;
import com.engine.kq.biz.chain.cominfo.ShiftComIndex;
import com.engine.kq.biz.chain.cominfo.ShiftInfoCominfoBean;
import com.engine.kq.biz.chain.cominfo.WorkShiftComIndex;
import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean;
import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit;
import com.engine.kq.entity.TimeScopeEntity;
import com.engine.kq.log.KQLog;
import java.io.PrintWriter;
import java.io.Serializable;
import java.io.StringWriter;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import org.apache.commons.lang.math.NumberUtils;
import weaver.cache.CacheBase;
import weaver.cache.CacheColumn;
import weaver.cache.CacheColumnType;
import weaver.cache.CacheItem;
import weaver.cache.CacheMap;
import weaver.cache.PKColumn;
import weaver.conn.RecordSet;
import weaver.general.Util;
/**
*
*/
public class KQShiftManagementComInfo extends CacheBase implements Serializable {
/*
* : initCache
*/
protected static String TABLE_NAME = "";
/*
* : initCache
* sqlwherewhere
*/
protected static String TABLE_WHERE = null;
/*
* : initCache sqlorder
* byorder by
*
*/
protected static String TABLE_ORDER = null;
@PKColumn(type = CacheColumnType.NUMBER)
protected static String PK_NAME = "id";
@CacheColumn
protected static int shiftbean;
@CacheColumn
protected static int color;
@CacheColumn
protected static int isoffdutyfreecheck;
@CacheColumn
protected static int shiftonoffworkcount;
@CacheColumn
protected static int serial;
@CacheColumn
protected static int isresttimeopen;
@CacheColumn
protected static int worktime;
@CacheColumn
protected static int punchsetting;
@CacheColumn
protected static int cardRemind;
@CacheColumn
protected static int cardRemOfSignIn;
@CacheColumn
protected static int minsBeforeSignIn;
@CacheColumn
protected static int cardRemOfSignOut;
@CacheColumn
protected static int minsAfterSignOut;
@CacheColumn
protected static int remindMode;
@CacheColumn
protected static int remindOnPC;
@CacheColumn
protected static int rest_shift;
private KQLog kqLog = new KQLog();
@Override
public CacheItem initCache(String key) {
if (key == null || "".equals(key.trim())) {
return null;
}
CacheMap localData = createCacheMap();
String sql = "";
kqLog = new KQLog();
ConcurrentHashMap<String, Object> resourceKQGroups = new ConcurrentHashMap<>();
//考勤组优先级
try {
ConcurrentHashMap<String,Object> shiftInfoBeanMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String,Object> idMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String,Object> colorsMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String,Object> isoffdutyfreechecksMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String,Object> shiftonoffworkcountsMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String,Object> serialsMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String,Object> isresttimeopensMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String,Object> worktimesMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String,Object> punchsettingsMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String,Object> cardRemindMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String,Object> cardRemOfSignInMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String,Object> minsBeforeSignInMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String,Object> cardRemOfSignOutMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String,Object> minsAfterSignOutMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String,Object> remindModeMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String,Object> remindOnPCMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String,Object> restShiftMap = new ConcurrentHashMap<>();
RecordSet rs = new RecordSet();
String getShiftInfo = "select * from kq_ShiftManagement where 1=1 and id="+key+" order by id ";
rs.execute(getShiftInfo);
while(rs.next()){
String serialid = rs.getString("id");
String isresttimeopen = rs.getString("isresttimeopen");
String color = rs.getString("color");
String shiftonoffworkcount = rs.getString("shiftonoffworkcount");
String worktime = rs.getString("worktime");
String serial = rs.getString("serial");
String punchsetting = "1";
String isoffdutyfreecheck = rs.getString("isoffdutyfreecheck");
String cardRemind = rs.getString("cardRemind");
String cardRemOfSignIn = rs.getString("cardRemOfSignIn");
String minsBeforeSignIn = rs.getString("minsBeforeSignIn");
String cardRemOfSignOut = rs.getString("cardRemOfSignOut");
String minsAfterSignOut = rs.getString("minsAfterSignOut");
String remindMode = rs.getString("remindMode");
String remindOnPC = rs.getString("remindOnPC");
String halfcalrule = rs.getString("halfcalrule");
halfcalrule = Util.null2String(halfcalrule).length() == 0 ? "0" : halfcalrule;
String halfcalpoint = rs.getString("halfcalpoint");
String halfcalpoint2cross = rs.getString("halfcalpoint2cross");
String restShift = rs.getString("rest_shift");
getShiftInfoBean(serialid,isresttimeopen,worktime,punchsetting,shiftInfoBeanMap,halfcalrule,halfcalpoint,halfcalpoint2cross,restShift);
idMap.put(serialid, serialid);
colorsMap.put(serialid, color);
isoffdutyfreechecksMap.put(serialid, isoffdutyfreecheck);
shiftonoffworkcountsMap.put(serialid, shiftonoffworkcount);
serialsMap.put(serialid, serial);
isresttimeopensMap.put(serialid, isresttimeopen);
worktimesMap.put(serialid, worktime);
punchsettingsMap.put(serialid, punchsetting);
cardRemindMap.put(serialid,cardRemind);
cardRemOfSignInMap.put(serialid,cardRemOfSignIn);
minsBeforeSignInMap.put(serialid,minsBeforeSignIn);
cardRemOfSignOutMap.put(serialid,cardRemOfSignOut);
minsAfterSignOutMap.put(serialid,minsAfterSignOut);
remindModeMap.put(serialid,remindMode);
remindOnPCMap.put(serialid,remindOnPC);
restShiftMap.put(serialid,restShift);
}
if(shiftInfoBeanMap.size()>0){
CacheItem cacheItem = createCacheItem();
Iterator<Entry<String, Object>> iterator = shiftInfoBeanMap.entrySet().iterator();
while (iterator.hasNext()) {
Entry<String, Object> entry = iterator.next();
String id = entry.getKey();
Object value = entry.getValue();
cacheItem.set(PK_INDEX, id);
cacheItem.set(shiftbean, value);
cacheItem.set(isoffdutyfreecheck, isoffdutyfreechecksMap.get(id));
cacheItem.set(shiftonoffworkcount, shiftonoffworkcountsMap.get(id));
cacheItem.set(serial, serialsMap.get(id));
cacheItem.set(isresttimeopen, isresttimeopensMap.get(id));
cacheItem.set(worktime, worktimesMap.get(id));
cacheItem.set(punchsetting, punchsettingsMap.get(id));
cacheItem.set(cardRemind,cardRemindMap.get(id));
cacheItem.set(cardRemOfSignIn,cardRemOfSignInMap.get(id));
cacheItem.set(minsBeforeSignIn,minsBeforeSignInMap.get(id));
cacheItem.set(cardRemOfSignOut,cardRemOfSignOutMap.get(id));
cacheItem.set(minsAfterSignOut,minsAfterSignOutMap.get(id));
cacheItem.set(remindMode,remindModeMap.get(id));
cacheItem.set(remindOnPC,remindOnPCMap.get(id));
cacheItem.set(rest_shift,restShiftMap.get(id));
modifyCacheItem(id, cacheItem);
}
return cacheItem;
}
} catch (Exception e) {
kqLog.info(e);
}
return null;
}
@Override
public CacheMap initCache() {
CacheMap localData = createCacheMap();
String sql = "";
kqLog = new KQLog();
ConcurrentHashMap<String, Object> resourceKQGroups = new ConcurrentHashMap<>();
//考勤组优先级
try {
ConcurrentHashMap<String,Object> shiftInfoBeanMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String,Object> idMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String,Object> colorsMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String,Object> isoffdutyfreechecksMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String,Object> shiftonoffworkcountsMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String,Object> serialsMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String,Object> isresttimeopensMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String,Object> worktimesMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String,Object> punchsettingsMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String,Object> cardRemindMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String,Object> cardRemOfSignInMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String,Object> minsBeforeSignInMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String,Object> cardRemOfSignOutMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String,Object> minsAfterSignOutMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String,Object> remindModeMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String,Object> remindOnPCMap = new ConcurrentHashMap<>();
ConcurrentHashMap<String,Object> restShiftMap = new ConcurrentHashMap<>();
RecordSet rs = new RecordSet();
String getShiftInfo = "select * from kq_ShiftManagement where 1=1 order by id ";
rs.execute(getShiftInfo);
while(rs.next()){
String serialid = rs.getString("id");
String isresttimeopen = rs.getString("isresttimeopen");
String color = rs.getString("color");
String shiftonoffworkcount = rs.getString("shiftonoffworkcount");
String worktime = rs.getString("worktime");
String serial = rs.getString("serial");
String punchsetting = "1";
String isoffdutyfreecheck = rs.getString("isoffdutyfreecheck");
String cardRemind = rs.getString("cardRemind");
String cardRemOfSignIn = rs.getString("cardRemOfSignIn");
String minsBeforeSignIn = rs.getString("minsBeforeSignIn");
String cardRemOfSignOut = rs.getString("cardRemOfSignOut");
String minsAfterSignOut = rs.getString("minsAfterSignOut");
String remindMode = rs.getString("remindMode");
String remindOnPC = rs.getString("remindOnPC");
String halfcalrule = rs.getString("halfcalrule");
halfcalrule = Util.null2String(halfcalrule).length() == 0 ? "0" : halfcalrule;
String halfcalpoint = rs.getString("halfcalpoint");
String halfcalpoint2cross = rs.getString("halfcalpoint2cross");
String restShift = rs.getString("rest_shift");
getShiftInfoBean(serialid,isresttimeopen,worktime,punchsetting,shiftInfoBeanMap,halfcalrule,halfcalpoint,halfcalpoint2cross,restShift);
idMap.put(serialid, serialid);
colorsMap.put(serialid, color);
isoffdutyfreechecksMap.put(serialid, isoffdutyfreecheck);
shiftonoffworkcountsMap.put(serialid, shiftonoffworkcount);
serialsMap.put(serialid, serial);
isresttimeopensMap.put(serialid, isresttimeopen);
worktimesMap.put(serialid, worktime);
punchsettingsMap.put(serialid, punchsetting);
cardRemindMap.put(serialid,cardRemind);
cardRemOfSignInMap.put(serialid,cardRemOfSignIn);
minsBeforeSignInMap.put(serialid,minsBeforeSignIn);
cardRemOfSignOutMap.put(serialid,cardRemOfSignOut);
minsAfterSignOutMap.put(serialid,minsAfterSignOut);
remindModeMap.put(serialid,remindMode);
remindOnPCMap.put(serialid,remindOnPC);
restShiftMap.put(serialid,restShift);
}
if(shiftInfoBeanMap.size()>0){
Iterator<Entry<String, Object>> iterator = shiftInfoBeanMap.entrySet().iterator();
while (iterator.hasNext()) {
Entry<String, Object> entry = iterator.next();
String id = entry.getKey();
Object value = entry.getValue();
CacheItem cacheItem = createCacheItem();
cacheItem.set(PK_INDEX, id);
cacheItem.set(shiftbean, value);
cacheItem.set(isoffdutyfreecheck, isoffdutyfreechecksMap.get(id));
cacheItem.set(shiftonoffworkcount, shiftonoffworkcountsMap.get(id));
cacheItem.set(serial, serialsMap.get(id));
cacheItem.set(isresttimeopen, isresttimeopensMap.get(id));
cacheItem.set(worktime, worktimesMap.get(id));
cacheItem.set(punchsetting, punchsettingsMap.get(id));
cacheItem.set(cardRemind,cardRemindMap.get(id));
cacheItem.set(cardRemOfSignIn,cardRemOfSignInMap.get(id));
cacheItem.set(minsBeforeSignIn,minsBeforeSignInMap.get(id));
cacheItem.set(cardRemOfSignOut,cardRemOfSignOutMap.get(id));
cacheItem.set(minsAfterSignOut,minsAfterSignOutMap.get(id));
cacheItem.set(remindMode,remindModeMap.get(id));
cacheItem.set(remindOnPC,remindOnPCMap.get(id));
cacheItem.set(rest_shift,restShiftMap.get(id));
modifyCacheItem(id, cacheItem);
localData.put(id, cacheItem);
}
}
} catch (Exception e) {
StringWriter errorsWriter = new StringWriter();
e.printStackTrace(new PrintWriter(errorsWriter));
kqLog.info(errorsWriter.toString());
}
return localData;
}
public String getId(){
return (String)getRowValue(PK_INDEX);
}
public String getColor() { return (String)getRowValue(color); }
public String getColor(String key)
{
return (String)getValue(color,key);
}
public String getIsoffdutyfreecheck() { return (String)getRowValue(isoffdutyfreecheck); }
public String getIsoffdutyfreecheck(String key)
{
return (String)getValue(isoffdutyfreecheck,key);
}
public String getShiftonoffworkcounts() { return (String)getRowValue(shiftonoffworkcount); }
public String getShiftonoffworkcounts(String key)
{
return (String)getValue(shiftonoffworkcount,key);
}
public String getSerial() { return (String)getRowValue(serial); }
public String getSerial(String key)
{
return (String)getValue(serial,key);
}
public String getIsresttimeopen() { return (String)getRowValue(isresttimeopen); }
public String getIsresttimeopen(String key)
{
return (String)getValue(isresttimeopen,key);
}
public String getWorktime() { return (String)getRowValue(worktime); }
public String getWorktime(String key)
{
return (String)getValue(worktime,key);
}
public String getPunchsetting() {
return (String) getRowValue(punchsetting);
}
public String getPunchsetting(String key) {
return (String) getValue(punchsetting, key);
}
public String getCardRemind() {
return (String) getRowValue(cardRemind);
}
public String getCardRemind(String key) {
return (String) getValue(cardRemind,key);
}
public String getCardRemOfSignIn() {
return (String) getRowValue(cardRemOfSignIn);
}
public String getCardRemOfSignIn(String key) {
return (String) getValue(cardRemOfSignIn, key);
}
public String getMinsBeforeSignIn() {
return (String) getRowValue(minsBeforeSignIn);
}
public String getMinsBeforeSignIn(String key) {
return (String) getValue(minsBeforeSignIn, key);
}
public String getCardRemOfSignOut() {
return (String) getRowValue(cardRemOfSignOut);
}
public String getCardRemOfSignOut(String key) {
return (String) getValue(cardRemOfSignOut, key);
}
public String getMinsAfterSignOut() {
return (String) getRowValue(minsAfterSignOut);
}
public String getMinsAfterSignOut(String key) {
return (String) getValue(minsAfterSignOut, key);
}
public String getRemindMode() {
return (String) getRowValue(remindMode);
}
public String getRemindMode(String key) {
return (String) getValue(remindMode, key);
}
public String getRemindOnPC() {
return (String) getRowValue(remindOnPC);
}
public String getRemindOnPC(String key) {
return (String) getValue(remindOnPC, key);
}
public String getRestShift() {
return (String) getRowValue(rest_shift);
}
public String getRestShift(String key) {
return (String) getValue(rest_shift, key);
}
private void getShiftInfoBean(String serialid, String isresttimeopen, String worktime,
String punchsettings,
ConcurrentHashMap<String, Object> serialMap,
String halfcalrule,String halfcalpoint,String halfcalpoint2cross, String restShift) throws Exception {
Map<String,Object> workTimeMap = new HashMap<>();
int workmins = 0;
List<Object> workTimes = Collections.synchronizedList(new ArrayList<>());
List<Object> restTimes = Collections.synchronizedList(new ArrayList<>());
KQShiftOnOffWorkSectionComInfo kqShiftOnOffWorkSectionComInfo = new KQShiftOnOffWorkSectionComInfo();
KQShiftRestTimeSectionComInfo kqShiftRestTimeSectionComInfo = new KQShiftRestTimeSectionComInfo();
workTimes = kqShiftOnOffWorkSectionComInfo.getWorkSectionTimes(serialid);
if(workTimes != null && !workTimes.isEmpty()){
if("1".equalsIgnoreCase(isresttimeopen)) {
//如果开启了才去判断
restTimes = kqShiftRestTimeSectionComInfo.getRestSectionTimes(serialid);
}
if(NumberUtils.isNumber(worktime)){
if(worktime.indexOf('.') == -1){
workmins = Util.getIntValue(worktime,0);
}else {
worktime = worktime.substring(0,worktime.indexOf('.'));
workmins = Util.getIntValue(worktime,0);
}
}else{
workmins = 0;
kqLog.info("班次有问题serialid:"+serialid+"工作时长为:"+worktime);
}
workTimeMap.put("workTime", workTimes);
workTimeMap.put("restTime", restTimes);
workTimeMap.put("serialid", serialid);
//工作时长分钟数
workTimeMap.put("workmins", workmins+"");
workTimeMap.put("punchsettings", punchsettings);
workTimeMap.put("isresttimeopen", isresttimeopen);
workTimeMap.put("halfcalrule", halfcalrule);
workTimeMap.put("halfcalpoint", halfcalpoint);
workTimeMap.put("halfcalpoint2cross", halfcalpoint2cross);
workTimeMap.put("restShift", restShift.equals("1") ? "1" : "0");
ShiftInfoCominfoBean shiftInfoCominfoBean = setShiftInfoBean(workTimeMap);
serialMap.put(serialid, shiftInfoCominfoBean);
}
}
private ShiftInfoCominfoBean setShiftInfoBean(Map<String,Object> workTimeMap) throws Exception {
ShiftComIndex workComIndex = new WorkShiftComIndex(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005306,weaver.general.ThreadVarLanguage.getLang())+"",workTimeMap);
ShiftComIndex restComIndex = new RestShiftComIndex(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005307,weaver.general.ThreadVarLanguage.getLang())+"",workTimeMap);
ShiftComIndex halfComIndex = new HalfShiftComIndex(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005308,weaver.general.ThreadVarLanguage.getLang())+"",workTimeMap);
//创建执行链
//前一天的都执行完了,去获取当天工作时段,再执行半天的规则
workComIndex.setDuration(restComIndex);
//执行完了半天的规则,再最后判断休息的时段
restComIndex.setDuration(halfComIndex);
ShiftInfoCominfoBean shiftInfoCominfoBean = new ShiftInfoCominfoBean();
workComIndex.handleDuration(shiftInfoCominfoBean);
return shiftInfoCominfoBean;
}
/**
*
* @param workdate
* @param serialidInfo
* @param containYesterday
* @return
*/
public Map<String,Object> getWorkButton(String workdate,Map<String,Object> serialidInfo, boolean containYesterday){
Map<String,Object> shiftMap = new HashMap<>();
//考勤按钮还是走缓存
KQShiftManagementRedis kqShiftManagementRedis = new KQShiftManagementRedis();
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
if(serialidInfo != null && !serialidInfo.isEmpty()){
LocalDate preLocalDate = LocalDate.parse(workdate);
String preSplitDate = "";
preLocalDate = preLocalDate.minusDays(1);
preSplitDate = preLocalDate.format(dateFormatter);
String serialid = Util.null2String(serialidInfo.get(workdate));
String preSerialid = Util.null2String(serialidInfo.get(preSplitDate));
if(containYesterday){
if(Util.getIntValue(preSerialid) > 0){
ShiftInfoCominfoBean pre_shiftInfoCominfoBean = kqShiftManagementRedis.getShiftInfoBean(preSerialid);
List<Object> timelineList = pre_shiftInfoCominfoBean.getTimelineList();
if(timelineList!=null && !timelineList.isEmpty()){
shiftMap.put("pre_timelineList", timelineList);
}
shiftMap.put("pre_isAcross", pre_shiftInfoCominfoBean.getIsAcross());
shiftMap.put("pre_allWorkTime", pre_shiftInfoCominfoBean.getAllWorkTime());
shiftMap.put("pre_allAcrossWorkTime", pre_shiftInfoCominfoBean.getAllAcrossWorkTime());
shiftMap.put("pre_signTime", pre_shiftInfoCominfoBean.getSignWorkTime());
shiftMap.put("pre_restTime", pre_shiftInfoCominfoBean.getRestAcrossLongTime());
}
}
if(Util.getIntValue(serialid) > 0){
ShiftInfoCominfoBean cur_shiftInfoCominfoBean = kqShiftManagementRedis.getShiftInfoBean(serialid);
Map<String,Object> shiftRuleMap = ShiftManagementToolKit.getShiftRuleInfo(serialid,false);
List<Object> timelineList = cur_shiftInfoCominfoBean.getTimelineList();
if(timelineList!=null && !timelineList.isEmpty()){
shiftMap.put("timelineList", timelineList);
}
shiftMap.put("isAcross", cur_shiftInfoCominfoBean.getIsAcross());
shiftMap.put("allWorkTime", cur_shiftInfoCominfoBean.getAllWorkTime());
shiftMap.put("allAcrossWorkTime", cur_shiftInfoCominfoBean.getAllAcrossWorkTime());
shiftMap.put("signTime", cur_shiftInfoCominfoBean.getSignWorkTime());
shiftMap.put("restTime", cur_shiftInfoCominfoBean.getRestAcrossLongTime());
if(shiftRuleMap != null && !shiftRuleMap.isEmpty()){
shiftMap.put("shiftRuleMap", shiftRuleMap);
}
}
}
return shiftMap;
}
/**
*
* @param workdate
* @param serialidInfo
* @param containYesterday
* @return
* shiftInfoBean ,0-24
* shiftLongInfoBean 0-48
*/
public Map<String,Object> getWorkDuration(String workdate,Map<String,Object> serialidInfo,boolean containYesterday){
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));
ShiftInfoBean shiftInfoBean = new ShiftInfoBean();
shiftInfoBean.setPreSplitDate(preSplitDate);
shiftInfoBean.setSplitDate(workdate);
shiftInfoBean.setD_Mins(0.0);
shiftInfoBean.setPreSerialid(preSerialid);
shiftInfoBean.setSerialid(serialid);
if(containYesterday){
if(Util.getIntValue(serialid) > 0 || Util.getIntValue(preSerialid) > 0){
fillShiftInfoBean(shiftInfoBean, preSerialid, serialid);
dateWorkTimeMap.put("shiftInfoBean", shiftInfoBean);
}
}else{
if(Util.getIntValue(serialid) > 0){
fillShiftInfoBean(shiftInfoBean, preSerialid, serialid);
dateWorkTimeMap.put("shiftInfoBean", shiftInfoBean);
}
}
}
return dateWorkTimeMap;
}
/**
* id+
* @param workdate
* @param serialidInfo
* @return
*/
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;
}
/**
*
* @param dateWorkTimeMap
* @param preSerialid
* @param serialid
*/
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());
}
}
/**
*
* @param shiftInfoBean
* @param preSerialid
* @param serialid
*/
private void fillShiftInfoBean(ShiftInfoBean shiftInfoBean,String preSerialid,String serialid){
ShiftInfoCominfoBean pre_shiftInfoCominfoBean = getShiftInfoCominfoBean(preSerialid);
ShiftInfoCominfoBean cur_shiftInfoCominfoBean = getShiftInfoCominfoBean(serialid);
Map<String,Object> pre_shiftRuleMap = ShiftManagementToolKit.getShiftRuleInfo(preSerialid,false);
Map<String,Object> shiftRuleMap = ShiftManagementToolKit.getShiftRuleInfo(serialid,false);
//把前一个班次的填充好
if(pre_shiftInfoCominfoBean != null){
shiftInfoBean.setPreWorkIndex(pre_shiftInfoCominfoBean.getPreWorkTimeIndex());
shiftInfoBean.setPreWorkAcrossIndex(pre_shiftInfoCominfoBean.getWorkAcrossTimeIndex());
shiftInfoBean.setPreWorkMinsAcrossIndex(pre_shiftInfoCominfoBean.getWorkPunchMins());
shiftInfoBean.setPreRestIndex(pre_shiftInfoCominfoBean.getPreRestTimeIndex());
shiftInfoBean.setPreHalfWorkIndex(pre_shiftInfoCominfoBean.getHalfWorkIndex());
shiftInfoBean.setPreWorkmins(pre_shiftInfoCominfoBean.getWorkmins());
shiftInfoBean.setPreAllWorkTime(pre_shiftInfoCominfoBean.getAllWorkTime());
shiftInfoBean.setPreAllAcrossWorkTime(pre_shiftInfoCominfoBean.getAllAcrossWorkTime());
shiftInfoBean.setPreAllRestTime(pre_shiftInfoCominfoBean.getAllRestTime());
shiftInfoBean.setPreAllAcrossRestTime(pre_shiftInfoCominfoBean.getAllAcrossRestTime());
shiftInfoBean.setPreSerialid(preSerialid);
shiftInfoBean.setIsPreAcross(pre_shiftInfoCominfoBean.getIsAcross());
shiftInfoBean.setShiftRuleMap(pre_shiftRuleMap);
}
//把当前班次的填充好
if(cur_shiftInfoCominfoBean != null){
shiftInfoBean.setWorkIndex(cur_shiftInfoCominfoBean.getWorkTimeIndex());
shiftInfoBean.setWorkAcrossIndex(cur_shiftInfoCominfoBean.getWorkAcrossTimeIndex());
shiftInfoBean.setWorkMinsAcrossIndex(cur_shiftInfoCominfoBean.getWorkPunchMins());
shiftInfoBean.setRestIndex(cur_shiftInfoCominfoBean.getRestTimeIndex());
shiftInfoBean.setHalfWorkIndex(cur_shiftInfoCominfoBean.getHalfWorkIndex());
shiftInfoBean.setWorkmins(cur_shiftInfoCominfoBean.getWorkmins());
shiftInfoBean.setAllWorkTime(cur_shiftInfoCominfoBean.getAllWorkTime());
shiftInfoBean.setAllAcrossWorkTime(cur_shiftInfoCominfoBean.getAllAcrossWorkTime());
shiftInfoBean.setAllRestTime(cur_shiftInfoCominfoBean.getAllRestTime());
shiftInfoBean.setAllAcrossRestTime(cur_shiftInfoCominfoBean.getAllAcrossRestTime());
shiftInfoBean.setAllLongWorkTime(cur_shiftInfoCominfoBean.getAllLongWorkTime());
shiftInfoBean.setRestLongTimeIndex(cur_shiftInfoCominfoBean.getRestLongTimeIndex());
shiftInfoBean.setWorkLongTimeIndex(cur_shiftInfoCominfoBean.getWorkLongTimeIndex());
shiftInfoBean.setIsAcross(cur_shiftInfoCominfoBean.getIsAcross());
shiftInfoBean.setSerialid(serialid);
shiftInfoBean.setShiftRuleMap(shiftRuleMap);
if(cur_shiftInfoCominfoBean.getWorkAcrossLongTime() != null){
List<Object> workTime1 = cur_shiftInfoCominfoBean.getWorkAcrossLongTime().stream().collect(Collectors.toList());
List<TimeScopeEntity> lsWorkTime = new KQWorkTime().formatTimeScope(workTime1, false);
shiftInfoBean.setWorkTime(lsWorkTime);
}
if(cur_shiftInfoCominfoBean.getSignWorkTime() != null){
List<Object> signTime1 = cur_shiftInfoCominfoBean.getSignWorkTime().stream().collect(Collectors.toList());
List<TimeScopeEntity> lsSignTime = new KQWorkTime().formatTimeScope(signTime1, true);
shiftInfoBean.setSignTime(lsSignTime);
}
shiftInfoBean.setHalfcalrule(cur_shiftInfoCominfoBean.getHalfcalrule());
shiftInfoBean.setHalfcalpoint(cur_shiftInfoCominfoBean.getHalfcalpoint());
shiftInfoBean.setHalfcalpoint2cross(cur_shiftInfoCominfoBean.getHalfcalpoint2cross());
shiftInfoBean.setWorkAcrossTime(cur_shiftInfoCominfoBean.getWorkAcrossTime());
shiftInfoBean.setEachWorkMins(cur_shiftInfoCominfoBean.getEachWorkMins());
}
}
public void removeShiftManagementCache(){
KQShiftRestTimeSectionComInfo kqShiftRestTimeSectionComInfo = new KQShiftRestTimeSectionComInfo();
KQShiftOnOffWorkSectionComInfo kqShiftOnOffWorkSectionComInfo = new KQShiftOnOffWorkSectionComInfo();
kqShiftRestTimeSectionComInfo.removeShiftRestTimeSectionCache();
kqShiftOnOffWorkSectionComInfo.removeShiftWorkSectionCache();
super.removeCache();
//改用redis和staticobj的方式
KQShiftManagementRedis kqShiftManagementRedis = new KQShiftManagementRedis();
kqShiftManagementRedis.resetShiftValWithRedis();
}
/**
* shiftInfoCominfoBean
* @param serialid
* @return
*/
public ShiftInfoCominfoBean getShiftInfoCominfoBean(String serialid){
// Object object = getObjValue(shiftbean, serialid);
// if(object != null){
// return (ShiftInfoCominfoBean) object;
// }else{
// return null;
// }
//改用redis和staticobj的方式
KQShiftManagementRedis kqShiftManagementRedis = new KQShiftManagementRedis();
return kqShiftManagementRedis.getShiftInfoBeanMapBySql(serialid);
}
/**
* shiftInfoCominfoBean
* @param workdate
* @param serialidInfo
* @return
*/
public ShiftInfoCominfoBean getShiftInfoCominfoBean(String workdate,Map<String,Object> serialidInfo){
ShiftInfoCominfoBean shiftInfoCominfoBean = null;
if(serialidInfo != null && !serialidInfo.isEmpty()){
String serialid = Util.null2String(serialidInfo.get(workdate));
if(Util.getIntValue(serialid) > 0){
shiftInfoCominfoBean = getShiftInfoCominfoBean(serialid);
}
}
return shiftInfoCominfoBean;
}
}

@ -0,0 +1,413 @@
package com.engine.kq.biz;
import com.alibaba.fastjson.JSON;
import com.engine.kq.biz.chain.cominfo.ShiftInfoCominfoBean;
import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit;
import com.engine.kq.entity.KQGroupEntity;
import com.engine.kq.entity.TimeScopeEntity;
import com.engine.kq.entity.TimeSignScopeEntity;
import com.engine.kq.entity.WorkTimeEntity;
import com.engine.kq.log.KQLog;
import weaver.common.DateUtil;
import weaver.common.StringUtil;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.resource.ResourceComInfo;
import java.util.*;
public class KQWorkTime extends BaseBean {
private KQLog kqLog = new KQLog();
private boolean isFormat = false;
public WorkTimeEntity getWorkTime(String userId) {
return getWorkTime(userId, null);
}
/**
*
* @param userId
* @param workdate
* @return
*/
public boolean isWorkDay(String userId, String workdate) {
boolean isWorkDay = false;
if(!KQHolidaySetBiz.isHoliday(userId,workdate)) {//不是节假日,且有班次
Map<String, Object> serialInfo = getSerialInfo( userId, workdate, false);
if(!serialInfo.isEmpty()){
if(Util.null2String(serialInfo.get("kqType")).equals("3")){
Map<String, Object> result = (Map<String, Object>) serialInfo.get(workdate);
if(result!=null && result.size()>0 && Util.null2String(result.get("signStart")).length()>0 && Util.null2String(result.get("workMins")).length()>0){
isWorkDay = true;
}
}else{
int serialid = Util.getIntValue(Util.null2String(serialInfo.get(workdate)), 0);
KQShiftManagementComInfo kQShiftManagementComInfo = new KQShiftManagementComInfo();
int restShift = StringUtil.parseToInt(kQShiftManagementComInfo.getRestShift(String.valueOf(serialid)), 0);
isWorkDay = restShift == 1 ? false : serialid > 0;
}
}
}
return isWorkDay;
}
public Map<String, Object> getWorkButton(String userId, String workdate, boolean containYesterday) {
Map<String, Object> result = new HashMap<>();
try {
KQShiftManagementComInfo kQShiftManagementComInfo = new KQShiftManagementComInfo();
Map<String,Object> serialInfo = getSerialInfo(userId, workdate, containYesterday);
kqLog.info("考勤组获取成员所在的班次 getWorkButton:serialInfo:"+ serialInfo);
String kqType = Util.null2String(serialInfo.get("kqType"));
if(serialInfo!=null&&serialInfo.size()>0){
if("3".equalsIgnoreCase(kqType)){
//自由班制的单独处理
result = (Map<String, Object>) serialInfo.get(workdate);
if(result != null && !result.isEmpty()){
result.put("isfree", "1");
}else{
result = new HashMap<>();
}
}else{
result = kQShiftManagementComInfo.getWorkButton(workdate,serialInfo,containYesterday);
kqLog.info("考勤组获取成员所在的班次 getWorkButton:result:"+ JSON.toJSONString(result));
}
}
} catch (Exception e) {
writeLog(e);
}
return result;
}
/**
*
*
* @param userId
* @param workdate
* @param containYesterday
* @param isLog
* @return
*/
public Map<String, Object> getWorkDuration(String userId, String workdate,boolean containYesterday,boolean isLog) {
Map<String, Object> result = new HashMap<>();
try {
Map<String,Object> workTimeMap = null;
KQShiftManagementComInfo kQShiftManagementComInfo = new KQShiftManagementComInfo();
Map<String,Object> serialInfo = getSerialInfo(userId, workdate, true);
writeLog("getWorkDuration-serialInfo-" + userId + "-" + workdate + serialInfo);
if(isLog){
kqLog.info("考勤组获取成员所在的班次 getWorkDuration:"+serialInfo);
}
if(serialInfo!=null&&serialInfo.size()>0){
String kqType = Util.null2String(serialInfo.get("kqType"));
if("3".equalsIgnoreCase(kqType)){
//自由班制的单独处理
result = (Map<String, Object>) serialInfo.get(workdate);
if(result != null && !result.isEmpty()){
result.put("isfree", "1");
}else{
result = new HashMap<>();
}
}else{
workTimeMap = kQShiftManagementComInfo.getWorkDuration(workdate,serialInfo,containYesterday);
if(workTimeMap!=null){
if(isLog) {
kqLog.info(
"考勤组获取成员所在的班次 getWorkDuration:workTimeMap:" + JSON.toJSONString(workTimeMap));
}
result.put("shiftInfoBean",workTimeMap.get("shiftInfoBean"));
}
}
}
} catch (Exception e) {
writeLog(e);
}
return result;
}
/**
*
* @param userId
* @param workdate
* @param containYesterday
* @return
*/
public Map<String, Object> getWorkDuration(String userId, String workdate,boolean containYesterday) {
return getWorkDuration(userId,workdate,containYesterday,true);
}
/**
*
* @param userId
* @param workdate
* @return
*/
public ShiftInfoCominfoBean getShiftInfoCominfoBean(String userId, String workdate) {
ShiftInfoCominfoBean shiftInfoCominfoBean = null;
try {
Map<String,Object> workTimeMap = null;
KQShiftManagementComInfo kQShiftManagementComInfo = new KQShiftManagementComInfo();
Map<String,Object> serialInfo = getSerialInfo(userId, workdate, false);
if(serialInfo!=null&&serialInfo.size()>0){
shiftInfoCominfoBean = kQShiftManagementComInfo.getShiftInfoCominfoBean(workdate,serialInfo);
}
} catch (Exception e) {
writeLog(e);
}
return shiftInfoCominfoBean;
}
/**
*
* @param userId
* @param workdate
* @return
*/
public WorkTimeEntity getWorkTime(String userId, String workdate) {
WorkTimeEntity workTimeEntity = new WorkTimeEntity();
try {
KQShiftManagementComInfo kQShiftManagementComInfo = new KQShiftManagementComInfo();
ShiftManagementToolKit shiftManagementToolKit = new ShiftManagementToolKit();
Map<String,Object> serialInfo = getSerialInfo(userId, workdate, false);
workTimeEntity.setIsExclude(Util.null2String(serialInfo.get("isExclude")).equals("1"));
workTimeEntity.setGroupId(Util.null2String(serialInfo.get("groupId")));
if(serialInfo!=null&&serialInfo.size()>0) {
String kqType = Util.null2String(serialInfo.get("kqType"));
if(kqType.equals("3")){
Map<String,Object> map = (Map<String,Object>)serialInfo.get(workdate);
workTimeEntity.setGroupId(Util.null2String(serialInfo.get("groupId")));
workTimeEntity.setGroupName(Util.null2String(serialInfo.get("groupName")));
workTimeEntity.setKQType(Util.null2String(kqType));
workTimeEntity.setIsExclude(Util.null2String(serialInfo.get("isExclude")).equals("1"));
if(map!=null) {
workTimeEntity.setSignStart(Util.null2String(map.get("signStart")));
workTimeEntity.setWorkMins(Util.getIntValue(Util.null2String(map.get("workMins"))));
workTimeEntity.setCalmethod(Util.null2String(map.get("calmethod")));
}
workTimeEntity.setRestShift(0);
}else{
int serialid = Util.getIntValue(Util.null2String(serialInfo.get(workdate)), 0);
int restShift = StringUtil.parseToInt(kQShiftManagementComInfo.getRestShift(String.valueOf(serialid)), 0);
if(kqType.equals("1") && KQHolidaySetBiz.isHoliday(userId,workdate)) restShift = 1;
workTimeEntity.setRestShift(restShift);
if (serialid > 0){
Map<String,Object> dateWorkTimeMap = kQShiftManagementComInfo.getWorkTimeMap(workdate, serialInfo);
workTimeEntity.setGroupId(Util.null2String(serialInfo.get("groupId")));
workTimeEntity.setGroupName(Util.null2String(serialInfo.get("groupName")));
workTimeEntity.setKQType(kqType);
workTimeEntity.setSerialId(""+serialid);
workTimeEntity.setRestTime(formatTimeScope((List<Object>)dateWorkTimeMap.get("restTime"),false));
workTimeEntity.setShiftRuleInfo(ShiftManagementToolKit.getShiftRuleInfo(""+serialid,true));
workTimeEntity.setSignTime(formatTimeScope((List<Object>)dateWorkTimeMap.get("signTime"),false));
workTimeEntity.setWorkTime(formatTimeScope((List<Object>)dateWorkTimeMap.get("workTime"),true));
if(restShift != 1) {
workTimeEntity.setWorkMins(Util.getIntValue(Util.null2String(dateWorkTimeMap.get("workMins"))));
}
workTimeEntity.setIsAcross(Util.null2String(dateWorkTimeMap.get("isAcross")));
}
}
}
} catch (Exception e) {
writeLog(e);
}
return workTimeEntity;
}
public List<TimeScopeEntity> formatTimeScope(List<Object> timeScope, boolean needWorkMins){
List<TimeScopeEntity> timeScopes = new ArrayList<>();
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);
}
timeScopes.add(timeScopeEntity);
}
return timeScopes;
}
/**
*
* @param userId
* @param workdate
* @return
*/
public String getSerialIds(String userId, String workdate) {
Map<String, Object> serialInfo = getSerialInfo( userId, workdate, false);
return serialInfo!=null?Util.null2String(serialInfo.get(workdate)):"";
}
/**
*
* @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 = "";
try {
KQGroupMemberComInfo groupMemberComInfo = new KQGroupMemberComInfo();
groupMemberComInfo.setIsFormat(this.isFormat);
KQFixedSchedulceComInfo kqFixedSchedulceComInfo = new KQFixedSchedulceComInfo();
kqFixedSchedulceComInfo.setFormat(this.isFormat);
KQShiftScheduleComInfo kqShiftScheduleComInfo = new KQShiftScheduleComInfo();
kqShiftScheduleComInfo.setFormat(this.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) {//排除人员无需计算考勤时间
// 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 ){//人员入职日期前无需计算考勤,如果没有入职日期,已创建日期为准
// kqLog.writeLog("getSerialInfo 入职日期不满足条件:userId:"+userId+":workdate:"+workdate+":companyStartDate:"+companyStartDate+":begindate:"+begindate+":DateUtil.compDate(begindate,workdate):"+DateUtil.compDate(begindate,workdate));
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){//人员合同结束日期无需计算考勤
// kqLog.writeLog("getSerialInfo 人员合同结束日期不满足条件:userId:"+userId+":workdate:"+workdate+":endDate:"+endDate+":status:"+status+":DateUtil.compDate(endDate,workdate):"+DateUtil.compDate(endDate,workdate));
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(containYesterday && !serialInfo.containsKey(preworkdate)) {
// serialid = Util.null2String(kqFixedSchedulceComInfo.getSerialid(groupid,preDayOfweek));
// if(!preDayIsHoliday&&serialid.length()>0 && Util.getIntValue(serialid) > 0){
// serialInfo.put(preworkdate,serialid);//获取前一天的班次
// }
// }
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,preworkdate));
// if(containYesterday && serialid.length()>0 && !preDayIsHoliday && Util.getIntValue(serialid) > 0){
// serialInfo.put(preworkdate,Util.null2String(kqShiftScheduleComInfo.getSerialId(userId,preworkdate)));//获取前一天的班次
// }
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(),"2");
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) {
writeLog(e);
}
return serialInfo;
}
public void setIsFormat(boolean isFormat){
this.isFormat = isFormat;
}
}

@ -0,0 +1,78 @@
package com.engine.kq.cmd.attendanceEvent;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.kq.biz.KQGroupMemberComInfo;
import com.engine.kq.biz.KQLeaveRulesBiz;
import com.engine.kq.enums.DurationTypeEnum;
import com.engine.kq.util.KQDurationCalculatorUtil;
import java.util.HashMap;
import java.util.Map;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.hrm.resource.ResourceComInfo;
import weaver.systeminfo.SystemEnv;
/**
*
*/
public class GetLeaveWorkDurationCmd extends AbstractCommonCommand<Map<String, Object>> {
public GetLeaveWorkDurationCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> retmap = new HashMap<String, Object>();
RecordSet rs = new RecordSet();
String sql = "";
try{
String newLeaveType = Util.null2String(params.get("newLeaveType"));
String resourceId = Util.null2String(params.get("resourceId"));
String fromDate = Util.null2String(params.get("fromDate"));
String toDate = Util.null2String(params.get("toDate"));
String fromTime = Util.null2String(params.get("fromTime"));
String toTime = Util.null2String(params.get("toTime"));
String timestamp = Util.null2String(params.get("timestamp"));
ResourceComInfo rci = new ResourceComInfo();
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo();
String groupid = kqGroupMemberComInfo.getKQGroupId(resourceId,fromDate);
if(resourceId.length() > 0 && groupid.length() == 0){
retmap.put("status", "-1");
retmap.put("message", rci.getLastname(resourceId)+","+fromDate+""+ SystemEnv.getHtmlLabelName(10005329,weaver.general.ThreadVarLanguage.getLang())+"");
return retmap;
}
String durationrule = Util.null2String(KQLeaveRulesBiz.getMinimumUnit(newLeaveType));
String computingMode = Util.null2String(KQLeaveRulesBiz.getComputingMode(newLeaveType));
KQDurationCalculatorUtil kqDurationCalculatorUtil =new KQDurationCalculatorUtil.DurationParamBuilder(resourceId).
fromDateParam(fromDate).toDateParam(toDate).fromTimeParam(fromTime).toTimeParam(toTime).
newLeaveTypeParam(newLeaveType).durationRuleParam(durationrule).
computingModeParam(computingMode).durationTypeEnumParam(DurationTypeEnum.LEAVE).build();
Map<String,Object> durationMap = kqDurationCalculatorUtil.getWorkDuration();
retmap.put("duration", Util.null2String(durationMap.get("duration")));
retmap.put("min_duration", Util.null2String(durationMap.get("min_duration")));
retmap.put("timestamp", timestamp);
retmap.put("status", "1");
}catch (Exception e) {
retmap.put("status", "-1");
retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage()));
writeLog(e);
}
return retmap;
}
@Override
public BizLogContext getLogContext() {
return null;
}
}

@ -0,0 +1,196 @@
package com.engine.kq.cmd.attendanceEvent;
import com.alibaba.fastjson.JSONObject;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.kq.biz.KQGroupMemberComInfo;
import com.engine.kq.biz.KQOvertimeRulesBiz;
import com.engine.kq.biz.KQWorkTime;
import com.engine.kq.entity.WorkTimeEntity;
import com.engine.kq.enums.DurationTypeEnum;
import com.engine.kq.util.KQDurationCalculatorUtil;
import com.engine.kq.util.TimeRangeCalculator;
import org.apache.commons.lang3.StringUtils;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.hrm.resource.ResourceComInfo;
import weaver.systeminfo.SystemEnv;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
/**
*
*/
public class GetOverTimeWorkDurationCmd extends AbstractCommonCommand<Map<String, Object>> {
public GetOverTimeWorkDurationCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> retmap = new HashMap<String, Object>();
RecordSet rs = new RecordSet();
String sql = "";
try {
BaseBean bb = new BaseBean();
String resourceId = Util.null2String(params.get("resourceId"));
String fromDate = Util.null2String(params.get("fromDate"));
String toDate = Util.null2String(params.get("toDate"));
String fromTime = Util.null2String(params.get("fromTime"));
String toTime = Util.null2String(params.get("toTime"));
String overtime_type = Util.null2String(params.get("overtime_type"));
String timestamp = Util.null2String(params.get("timestamp"));
bb.writeLog("计算时长");
int minimumUnit = KQOvertimeRulesBiz.getMinimumUnit();
//
KQWorkTime kqWorkTime = new KQWorkTime();
WorkTimeEntity kqWorkTimeEntity = kqWorkTime.getWorkTime(resourceId, fromDate);
if (kqWorkTimeEntity != null) {
String kqType = Util.null2String(kqWorkTimeEntity.getKQType());
if ("3".equalsIgnoreCase(kqType)) {
writeLog("自由班制不计算加班");
retmap.put("status", "1");
retmap.put("message", "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005330, weaver.general.ThreadVarLanguage.getLang()) + "");
return retmap;
}
}
//休班次的加班时长
String restSerialValue = "";
restSerialValue = isRestSerialCalculate(resourceId, kqWorkTime);
if (StringUtils.isNotEmpty(restSerialValue)) {
retmap.put("duration", restSerialValue);
retmap.put("timestamp", timestamp);
retmap.put("status", "1");
return retmap;
}
ResourceComInfo rci = new ResourceComInfo();
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo();
String groupid = kqGroupMemberComInfo.getKQGroupId(resourceId, fromDate);
bb.writeLog("计算时长groupid" + groupid);
if (resourceId.length() > 0 && groupid.length() == 0) {
retmap.put("status", "-1");
retmap.put("message", rci.getLastname(resourceId) + "," + fromDate + "" + weaver.systeminfo.SystemEnv.getHtmlLabelName(10005329, weaver.general.ThreadVarLanguage.getLang()) + "");
return retmap;
}
bb.writeLog("计算时长fromDate" + fromDate + "toDate:" + toDate + "fromTime:" + fromTime + "toTime:" + toTime);
//加班默认是工作日加班
KQDurationCalculatorUtil kqDurationCalculatorUtil = new KQDurationCalculatorUtil.DurationParamBuilder(resourceId).
fromDateParam(fromDate).toDateParam(toDate).fromTimeParam(fromTime).toTimeParam(toTime).computingModeParam("1").
durationRuleParam(minimumUnit + "").durationTypeEnumParam(DurationTypeEnum.OVERTIME).
overtime_typeParam(overtime_type).build();
Map<String, Object> durationMap = kqDurationCalculatorUtil.getWorkDuration();
//管理人员12小时班制考勤组id
String glrygroupid = bb.getPropValue("nbkq_main", "glrygroupid");
bb.writeLog("获取当前人员groupId:" + groupid + "glrygroupid:" + glrygroupid);
String value = "";
if (groupid.equals(glrygroupid)) {
bb.writeLog("是12小时班制的人");
Double newValue = divide(String.valueOf(TimeUtil.timeInterval(fromDate + " " + fromTime + ":00", toDate + " " + toTime + ":00")), "3600");
if (newValue > 0) {
value = String.valueOf(newValue);
} else {
value = "0.0";
}
} else {
value = Util.null2String(durationMap.get("duration"));
}
bb.writeLog("计算时长timestamp" + timestamp);
bb.writeLog("计算时长durationMap" + JSONObject.toJSONString(durationMap));
retmap.put("duration", value);
retmap.put("timestamp", timestamp);
retmap.put("status", "1");
} catch (Exception e) {
retmap.put("status", "-1");
retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage()));
writeLog(e);
}
return retmap;
}
private String isRestSerialCalculate(String resourceId, KQWorkTime kqWorkTime) {
try {
String fromDate = Util.null2String(params.get("fromDate"));
String toDate = Util.null2String(params.get("toDate"));
String fromTime = Util.null2String(params.get("fromTime"));
String toTime = Util.null2String(params.get("toTime"));
BigDecimal workTimeTotal = new BigDecimal(TimeUtil.timeInterval(fromDate + " " + fromTime + ":00", toDate + " " + toTime + ":00"));
BigDecimal restTimeCount = new BigDecimal(0);
//加班是否跨天
boolean isAcross = false;
if (toDate.compareTo(fromDate) > 0) {
isAcross = true;
}
Map<String, Object> serialInfo = kqWorkTime.getSerialInfo(resourceId, fromDate, false);
String serialId = (String) serialInfo.get(fromDate);
RecordSet rs = new RecordSet();
RecordSet rs2 = new RecordSet();
String querySql = "select rest_shift from kq_ShiftManagement where id=?";
rs.executeQuery(querySql, serialId);
if (rs.next()) {
if (rs.getInt("rest_shift") == 1) {
String restStartSql = "select * from kq_ShiftRestTimeSections where serialid=? and resttype='start'";
rs.executeQuery(restStartSql, serialId);
while (rs.next()) {
//休息开始时间
String startTime = rs.getString("time");
String record1 = rs.getString("record1");
//休息结束时间
String restEndSql = "select * from kq_ShiftRestTimeSections where record1=? and resttype='end'";
rs2.executeQuery(restEndSql, record1);
rs2.next();
String endTime = rs2.getString("time");
if (isAcross) {
double restTime1 = TimeRangeCalculator.getRestTime(fromTime, "23:59", startTime, endTime);
double restTime2 = TimeRangeCalculator.getRestTime("00:00", toTime, startTime, endTime);
restTimeCount = restTimeCount.add(BigDecimal.valueOf(restTime1));
restTimeCount = restTimeCount.add(BigDecimal.valueOf(restTime2));
} else {
double restTime = TimeRangeCalculator.getRestTime(fromTime, toTime, startTime, endTime);
restTimeCount = restTimeCount.add(BigDecimal.valueOf(restTime));
}
}
}
}
Double workTotal = divide(workTimeTotal.subtract(restTimeCount).toString(), "3600");
return workTotal.toString();
} catch (Exception e) {
return null;
}
}
@Override
public BizLogContext getLogContext() {
return null;
}
/**
*
*
* @param v1
* @param v2
* @return
*/
public static Double divide(String v1, String v2) {
BigDecimal b1 = new BigDecimal(v1);
BigDecimal b2 = new BigDecimal(v2);
return b1.divide(b2, 2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
}

@ -0,0 +1,764 @@
package com.engine.kq.cmd.report;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.kq.biz.*;
import com.engine.kq.util.ExcelUtil;
import com.engine.kq.util.KQDurationCalculatorUtil;
import com.engine.kq.util.UtilKQ;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.hrm.company.DepartmentComInfo;
import weaver.hrm.company.SubCompanyComInfo;
import weaver.hrm.job.JobTitlesComInfo;
import weaver.hrm.resource.ResourceComInfo;
import weaver.systeminfo.SystemEnv;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public class ExportExcelCmd extends AbstractCommonCommand<Map<String, Object>> {
private HttpServletRequest request;
private HttpServletResponse response;
private List<String> lsFieldDataKey;
public ExportExcelCmd(Map<String, Object> params, HttpServletRequest request, HttpServletResponse response, User user) {
this.user = user;
this.params = params;
this.request = request;
this.response = response;
this.lsFieldDataKey = new ArrayList<>();
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> retmap = new HashMap<String, Object>();
RecordSet rs = new RecordSet();
String sql = "";
try {
SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo();
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
ResourceComInfo resourceComInfo = new ResourceComInfo();
JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo();
KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz();
KQReportBiz kqReportBiz = new KQReportBiz();
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
String attendanceSerial = Util.null2String(jsonObj.get("attendanceSerial"));
String fromDate = Util.null2String(jsonObj.get("fromDate"));
String toDate = Util.null2String(jsonObj.get("toDate"));
String typeselect = Util.null2String(jsonObj.get("typeselect"));
if (typeselect.length() == 0) typeselect = "3";
if (!typeselect.equals("") && !typeselect.equals("0") && !typeselect.equals("6")) {
if (typeselect.equals("1")) {
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
} else {
fromDate = TimeUtil.getDateByOption(typeselect, "0");
toDate = TimeUtil.getDateByOption(typeselect, "1");
}
}
//人员状态
String status = Util.null2String(jsonObj.get("status"));
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
String departmentId = Util.null2String(jsonObj.get("departmentId"));
String resourceId = Util.null2String(jsonObj.get("resourceId"));
String allLevel = Util.null2String(jsonObj.get("allLevel"));
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));
String viewScope = Util.null2String(jsonObj.get("viewScope"));
List<String> showColumns = Util.splitString2List(Util.null2String(jsonObj.get("showColumns")), ",");
showColumns.add("lastname");
showColumns.removeIf(showColumn -> showColumn.trim().equals(""));
List<String> tmpShowColumns = new ArrayList<>();
for (String showColumn : showColumns) {
tmpShowColumns.add(showColumn);
String cascadekey = "";
if (showColumn.equals("beLate")) {
cascadekey = "beLateMins";
} else if (showColumn.equals("leaveEearly")) {
cascadekey = "leaveEarlyMins";
} else if (showColumn.equals("graveBeLate")) {
cascadekey = "graveBeLateMins";
} else if (showColumn.equals("graveLeaveEarly")) {
cascadekey = "graveLeaveEarlyMins";
} else if (showColumn.equals("absenteeism")) {
cascadekey = "absenteeismMins";
} else if (showColumn.equals("overtime")) {
tmpShowColumns.add("overtime_4leave");
tmpShowColumns.add("overtime_nonleave");
tmpShowColumns.add("workingDayOvertime_nonleave");
tmpShowColumns.add("workingDayOvertime_4leave");
tmpShowColumns.add("restDayOvertime_nonleave");
tmpShowColumns.add("restDayOvertime_4leave");
tmpShowColumns.add("holidayOvertime_4leave");
tmpShowColumns.add("holidayOvertime_nonleave");
}
if (cascadekey.length() > 0) {
tmpShowColumns.add(cascadekey);
}
}
showColumns = tmpShowColumns;
String rightSql = new KQReportBiz().getReportRight("1", "" + user.getUID(), "a");
LinkedHashMap<String, Object> workbook = new LinkedHashMap<>();
List<Object> lsSheet = new ArrayList<>();
Map<String, Object> sheet = null;
List<Object> titleList = new ArrayList<>();
Map<String, Object> title = null;
List<List<Object>> dataList = new ArrayList<>();
List<Object> data = null;
List<Map<String, Object>> constraintList = null;
sheet = new HashMap<>();
sheet.put("sheetName", SystemEnv.getHtmlLabelName(390351, user.getLanguage()));
sheet.put("sheetTitle", SystemEnv.getHtmlLabelName(390351, user.getLanguage()));
boolean isEnd = false;
Calendar cal = DateUtil.getCalendar();
List<Map<String, Object>> leaveRules = kqLeaveRulesBiz.getAllLeaveRules();
Map<String, Object> mapChildColumnInfo = null;
List<Object> childColumns = null;
KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo();
while (kqReportFieldComInfo.next()) {
if (Util.null2String(kqReportFieldComInfo.getParentid()).length() > 0) continue;
if (kqReportFieldComInfo.getFieldname().equals("kqCalendar")) continue;
if (KQReportFieldComInfo.cascadekey2fieldname.keySet().contains(kqReportFieldComInfo.getFieldname()))
continue;
if (!kqReportFieldComInfo.getReportType().equals("all") && !kqReportFieldComInfo.getReportType().equals("month"))
continue;
if (!showColumns.contains(kqReportFieldComInfo.getFieldname()) && !showColumns.contains(kqReportFieldComInfo.getParentid()))
continue;
if ("leave".equalsIgnoreCase(kqReportFieldComInfo.getFieldname()) && leaveRules.size() == 0) {
continue;
}
title = new HashMap<>();
String unitType = KQReportBiz.getUnitType(kqReportFieldComInfo, user);
if (unitType.length() > 0) {
title.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage()) + "(" + unitType + ")");
} else {
title.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage()));
}
title.put("width", 30 * 256);
this.lsFieldDataKey.add(kqReportFieldComInfo.getFieldname());
mapChildColumnInfo = this.getChildColumnsInfo(kqReportFieldComInfo.getFieldname(), user);
childColumns = (List<Object>) mapChildColumnInfo.get("childColumns");
if (childColumns.size() > 0) {//跨列width取子列的width
title.put("children", childColumns);
title.put("colSpan", childColumns.size());
} else {
title.put("rowSpan", 3);
}
titleList.add(title);
titleList.addAll(this.getCascadeKeyColumnsInfo(kqReportFieldComInfo.getCascadekey(), user));
}
String today = DateUtil.getCurrentDate();
// if (DateUtil.compDate(today, toDate) > 0) {//结束如期不大于今天
// toDate = today;
// }
if (showColumns.contains("kqCalendar")) {
childColumns = new ArrayList<>();
for (String date = fromDate; !isEnd; ) {
if (date.equals(toDate)) isEnd = true;
title = new HashMap<>();
title.put("title", UtilKQ.getWeekDayShort(DateUtil.getWeek(date) - 1, user.getLanguage()) + "\r\n" + DateUtil.geDayOfMonth(date));
title.put("width", 30 * 256);
childColumns.add(title);
cal.setTime(DateUtil.parseToDate(date));
date = DateUtil.getDate(cal.getTime(), 1);
}
title = new HashMap();
title.put("title", SystemEnv.getHtmlLabelName(386476, user.getLanguage()));
if (childColumns.size() > 0) {//跨列width取子列的width
title.put("children", childColumns);
title.put("colSpan", childColumns.size());
}
titleList.add(title);
}
sheet.put("titleList", titleList);
String forgotBeginWorkCheck_field = " sum(b.forgotBeginWorkCheck) ";
if (rs.getDBType().equalsIgnoreCase("oracle")) {
forgotBeginWorkCheck_field = " sum(nvl(b.forgotBeginWorkCheck,0)) ";
} else if ((rs.getDBType()).equalsIgnoreCase("mysql")) {
forgotBeginWorkCheck_field = " sum(ifnull(b.forgotBeginWorkCheck,0)) ";
} else {
forgotBeginWorkCheck_field = " sum(isnull(b.forgotBeginWorkCheck,0)) ";
}
Map<String, Object> definedFieldInfo = new KQFormatBiz().getDefinedField();
String definedFieldSum = Util.null2String(definedFieldInfo.get("definedFieldSum"));
//支援班次统计
String supportSerId = new BaseBean().getPropValue("nbkq_main", "supportSerId");
String backFields = " (select sum(zma.workdays) from kq_format_total zma where zma.resourceid = a.id and zma.kqdate >='" + fromDate + "' and zma.kqdate <='" + toDate + "' and (DATEPART(dw, zma.kqdate) = 7 or DATEPART(dw, zma.kqdate) = 1) AND zma.kqdate NOT IN (select holidayDate from KQ_HolidaySet where changeType = 3 AND zma.groupid = groupId)) as saturdayworkdays," +
" (select count(0) from kq_shiftschedule where resourceid = a.id and kqdate >='" + fromDate + "' and kqdate <='" + toDate + "' and serialid=" + supportSerId + " )as supportTotal," +
" (select sum(zma.attendancedays) from kq_format_total zma where zma.resourceid = a.id and zma.kqdate >='" + fromDate + "' and zma.kqdate <='" + toDate + "' and (DATEPART(dw, zma.kqdate) = 7 or DATEPART(dw, zma.kqdate) = 1) AND zma.kqdate NOT IN (select holidayDate from KQ_HolidaySet where changeType = 3 AND zma.groupid = groupId)) as saturdayattendancedays," +
" (select sum(zma.workdays) from kq_format_total zma where zma.resourceid = a.id and zma.kqdate >='" + fromDate + "' and zma.kqdate <='" + toDate + "' and ((DATEPART(dw, zma.kqdate) != 7 and DATEPART(dw, zma.kqdate) != 1) or ((DATEPART(dw, zma.kqdate) = 7 or DATEPART(dw, zma.kqdate) = 1) and zma.kqdate IN (select holidayDate from KQ_HolidaySet where changeType = 3 and zma.groupid = groupId)))) as weekdayworkdays," +
" (select sum(zma.attendancedays) from kq_format_total zma where zma.resourceid = a.id and zma.kqdate >='" + fromDate + "' and zma.kqdate <='" + toDate + "' and ((DATEPART(dw, zma.kqdate) != 7 and DATEPART(dw, zma.kqdate) != 1) or ((DATEPART(dw, zma.kqdate) = 7 or DATEPART(dw, zma.kqdate) = 1) and zma.kqdate IN (select holidayDate from KQ_HolidaySet where changeType = 3 and zma.groupid = groupId)))) as weekdayattendancedays," +
" a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1 as subcompanyid,a.departmentid,a.jobtitle," +
" sum(b.workdays) as workdays,sum(b.workMins) as workMins,sum(b.attendancedays) as attendancedays," +
" sum(b.attendanceMins) as attendanceMins,sum(b.beLate) as beLate,sum(b.beLateMins) as beLateMins, " +
" sum(b.graveBeLate) as graveBeLate, sum(b.graveBeLateMins) as graveBeLateMins,sum(b.leaveEearly) as leaveEearly," +
" sum(b.leaveEarlyMins) as leaveEarlyMins, sum(b.graveLeaveEarly) as graveLeaveEarly, " +
" sum(b.graveLeaveEarlyMins) as graveLeaveEarlyMins,sum(b.absenteeism) as absenteeism, " +
" sum(b.signdays) as signdays,sum(b.signmins) as signmins, " +
" sum(b.absenteeismMins) as absenteeismMins, sum(b.forgotCheck)+" + forgotBeginWorkCheck_field + " as forgotCheck " + (definedFieldSum.length() > 0 ? "," + definedFieldSum + "" : "");
if (rs.getDBType().equals("oracle")) {
backFields = "/*+ index(kq_format_total IDX_KQ_FORMAT_TOTAL_KQDATE) */ " + backFields;
}
String sqlFrom = " from hrmresource a, kq_format_total b,kq_ShiftManagement c " +
"where a.id= b.resourceid and c.id=b.serialid and (c.rest_shift is null or c.rest_shift=0) " +
"and b.kqdate >='" + fromDate + "' and b.kqdate <='" + toDate + "'";
String sqlWhere = rightSql;
String groupBy = " group by a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1,a.departmentid,a.jobtitle ";
if (subCompanyId.length() > 0) {
sqlWhere += " and a.subcompanyid1 in(" + subCompanyId + ") ";
}
if (departmentId.length() > 0) {
sqlWhere += " and a.departmentid in(" + departmentId + ") ";
}
if (resourceId.length() > 0) {
sqlWhere += " and a.id in(" + resourceId + ") ";
}
if (viewScope.equals("4")) {//我的下属
if (allLevel.equals("1")) {//所有下属
sqlWhere += " and a.managerstr like '%," + user.getUID() + ",%'";
} else {
sqlWhere += " and a.managerid=" + user.getUID();//直接下属
}
}
if (!"1".equals(isNoAccount)) {
sqlWhere += " and a.loginid is not null " + (rs.getDBType().equals("oracle") ? "" : " and a.loginid<>'' ");
}
if (status.length() > 0) {
if (!status.equals("8") && !status.equals("9")) {
sqlWhere += " and a.status = " + status + "";
} else if (status.equals("8")) {
sqlWhere += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) ";
}
}
String orderBy = " order by a.dsporder asc, a.lastname asc ";
String descOrderBy = " order by a.dsporder desc, a.lastname desc ";
sql = "select " + backFields + sqlFrom + sqlWhere + groupBy + orderBy;
//System.out.println("start" + DateUtil.getFullDate());
Map<String, Object> flowData = new KQReportBiz().getFlowData(params, user);
Map<String, Object> saturdayFlowLeaveData = kqReportBiz.getSaturdayFlowLeaveData(params, user);
//System.out.println("end" + DateUtil.getFullDate());
// #1475814-概述:满足考勤报分部部门显示及导出时显示全路径
String fullPathMainKey = "show_full_path";
KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo();
String isShowFullPath = Util.null2String(kqSettingsComInfo.getMain_val(fullPathMainKey), "0");
rs.execute(sql);
rs.writeLog("========== ExportExcelCmd sql ========== " + sql);
while (rs.next()) {
data = new ArrayList<>();
String id = rs.getString("id");
for (int fieldDataKeyIdx = 0; fieldDataKeyIdx < lsFieldDataKey.size(); fieldDataKeyIdx++) {
String fieldName = lsFieldDataKey.get(fieldDataKeyIdx);
String fieldid = KQReportFieldComInfo.field2Id.get(fieldName);
String fieldValue = "";
//补卡次数int
if (fieldName.equals("fillCard")) {
fieldValue = KQDurationCalculatorUtil.getDurationRound(String.valueOf(kqReportBiz.getFillCardCount(fromDate, toDate, id)));
} else if (fieldName.equals("subcompany")) {
String tmpSubcompanyId = Util.null2String(rs.getString("subcompanyid"));
if (tmpSubcompanyId.length() == 0) {
tmpSubcompanyId = Util.null2String(resourceComInfo.getSubCompanyID(id));
}
fieldValue = "1".equals(isShowFullPath) ?
SubCompanyComInfo.getSubcompanyRealPath(tmpSubcompanyId, "/", "0") :
subCompanyComInfo.getSubCompanyname(tmpSubcompanyId);
// fieldValue = subCompanyComInfo.getSubCompanyname(tmpSubcompanyId);
} else if (fieldName.equals("department")) {
String tmpDepartmentId = Util.null2String(rs.getString("departmentid"));
if (tmpDepartmentId.length() == 0) {
tmpDepartmentId = Util.null2String(resourceComInfo.getDepartmentID(id));
}
fieldValue = "1".equals(isShowFullPath) ?
departmentComInfo.getDepartmentRealPath(tmpDepartmentId, "/", "0") :
departmentComInfo.getDepartmentname(tmpDepartmentId);
// fieldValue = departmentComInfo.getDepartmentname(tmpDepartmentId);
} else if (fieldName.equals("jobtitle")) {
String tmpJobtitleId = Util.null2String(rs.getString("jobtitle"));
if (tmpJobtitleId.length() == 0) {
tmpJobtitleId = Util.null2String(resourceComInfo.getJobTitle(id));
}
fieldValue = jobTitlesComInfo.getJobTitlesname(tmpJobtitleId);
} else if (fieldName.equals("attendanceSerial")) {
List<String> serialIds = null;
if (Util.null2String(jsonObj.get("attendanceSerial")).length() > 0) {
serialIds = Util.splitString2List(Util.null2String(jsonObj.get("attendanceSerial")), ",");
for (int i = 0; serialIds != null && i < serialIds.size(); i++) {
data.add(kqReportBiz.getSerialCount(id, fromDate, toDate, serialIds.get(i)));
}
} else {
data.add("");
}
continue;
} else if (fieldName.equals("leave")) {//请假
List<Map<String, Object>> allLeaveRules = kqLeaveRulesBiz.getAllLeaveRules();
Map<String, Object> leaveRule = null;
for (int i = 0; allLeaveRules != null && i < allLeaveRules.size(); i++) {
leaveRule = allLeaveRules.get(i);
String flowType = Util.null2String("leaveType_" + leaveRule.get("id"));
String leaveData = Util.null2String(flowData.get(id + "|" + flowType));
String flowLeaveBackType = Util.null2String("leavebackType_" + leaveRule.get("id"));
String leavebackData = Util.null2s(Util.null2String(flowData.get(id + "|" + flowLeaveBackType)), "0.0");
String b_flowLeaveData = "";
String flowLeaveData = "";
try {
//以防止出现精度问题
if (leaveData.length() == 0) {
leaveData = "0.0";
}
if (leavebackData.length() == 0) {
leavebackData = "0.0";
}
BigDecimal b_leaveData = new BigDecimal(leaveData);
BigDecimal b_leavebackData = new BigDecimal(leavebackData);
b_flowLeaveData = b_leaveData.subtract(b_leavebackData).toString();
if (Util.getDoubleValue(b_flowLeaveData, -1) < 0) {
b_flowLeaveData = "0.0";
}
} catch (Exception e) {
writeLog("GetKQReportCmd:leaveData" + leaveData + ":leavebackData:" + leavebackData + ":" + e);
}
if (b_flowLeaveData.length() > 0) {
flowLeaveData = KQDurationCalculatorUtil.getDurationRound(b_flowLeaveData);
} else {
flowLeaveData = KQDurationCalculatorUtil.getDurationRound(Util.null2String(Util.getDoubleValue(leaveData, 0.0) - Util.getDoubleValue(leavebackData, 0.0)));
}
data.add(flowLeaveData);
}
continue;
} else if (fieldName.equals("overtime")) {
//加班数据 — 取加班台账的数据
//加班不关联调休工作日加班
double workingDayOvertime_nonleave = kqReportBiz.getOverTimeCount(fromDate, toDate, id, "0", "1");
//加班不关联调休休息日加班
double restDayOvertime_nonleave = kqReportBiz.getOverTimeCount(fromDate, toDate, id, "1", "1");
//加班不关联调休节假日加班
double holidayOvertime_nonleave = kqReportBiz.getOverTimeCount(fromDate, toDate, id, "2", "1");
//加班关联调休工作日加班
double workingDayOvertime_4leave = kqReportBiz.getOverTimeCount(fromDate, toDate, id, "0", "0");
//加班关联调休休息日加班
double restDayOvertime_4leave = kqReportBiz.getOverTimeCount(fromDate, toDate, id, "1", "0");
//加班关联调休节假日加班
double holidayOvertime_4leave = kqReportBiz.getOverTimeCount(fromDate, toDate, id, "2", "0");
data.add(workingDayOvertime_nonleave);
data.add(restDayOvertime_nonleave);
data.add(holidayOvertime_nonleave);
data.add(workingDayOvertime_4leave);
data.add(restDayOvertime_4leave);
data.add(holidayOvertime_4leave);
String overtimeTotal = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_4leave + restDayOvertime_4leave + holidayOvertime_4leave +
workingDayOvertime_nonleave + restDayOvertime_nonleave + holidayOvertime_nonleave));
data.add(overtimeTotal);
// fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|workingDayOvertime_nonleave")));
// data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("workingDayOvertime_nonleave"))));
//
// fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|restDayOvertime_nonleave")));
// data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("restDayOvertime_nonleave"))));
//
// fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|holidayOvertime_nonleave")));
// data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("holidayOvertime_nonleave"))));
//
// fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|workingDayOvertime_4leave")));
// data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("workingDayOvertime_4leave"))));
//
// fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|restDayOvertime_4leave")));
// data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("restDayOvertime_4leave"))));
//
// fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|holidayOvertime_4leave")));
// data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("holidayOvertime_4leave"))));
//
// double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|workingDayOvertime_4leave")));
// workingDayOvertime_4leave = workingDayOvertime_4leave<0?0:workingDayOvertime_4leave;
// double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|restDayOvertime_4leave")));
// restDayOvertime_4leave = restDayOvertime_4leave<0?0:restDayOvertime_4leave;
// double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|holidayOvertime_4leave")));
// holidayOvertime_4leave = holidayOvertime_4leave<0?0:holidayOvertime_4leave;
//
// double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|workingDayOvertime_nonleave")));
// workingDayOvertime_nonleave = workingDayOvertime_nonleave<0?0:workingDayOvertime_nonleave;
// double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|restDayOvertime_nonleave")));
// restDayOvertime_nonleave = restDayOvertime_nonleave<0?0:restDayOvertime_nonleave;
// double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id+"|holidayOvertime_nonleave")));
// holidayOvertime_nonleave = holidayOvertime_nonleave<0?0:holidayOvertime_nonleave;
// fieldValue = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_4leave+restDayOvertime_4leave+holidayOvertime_4leave+
// workingDayOvertime_nonleave+restDayOvertime_nonleave+holidayOvertime_nonleave));
// data.add(getFieldValueByUnitType(fieldValue,kqReportFieldComInfo.getUnittype(KQReportFieldComInfo.field2Id.get("overtimeTotal"))));
continue;
} else if (fieldName.equals("nightSubsidy")) {
//夜班补贴次数
double nightSubsidy = kqReportBiz.getNightSubsidyTotal(fromDate, toDate, id);
data.add(nightSubsidy);
continue;
} else if (fieldName.equals("businessLeave") || fieldName.equals("officialBusiness")) {
String businessLeaveData = Util.null2s(Util.null2String(flowData.get(id + "|" + fieldName)), "0.0");
String backType = fieldName + "_back";
String businessLeavebackData = Util.null2s(Util.null2String(flowData.get(id + "|" + backType)), "0.0");
String businessLeave = "";
try {
//以防止出现精度问题
if (businessLeaveData.length() == 0) {
businessLeaveData = "0.0";
}
if (businessLeavebackData.length() == 0) {
businessLeavebackData = "0.0";
}
BigDecimal b_businessLeaveData = new BigDecimal(businessLeaveData);
BigDecimal b_businessLeavebackData = new BigDecimal(businessLeavebackData);
businessLeave = b_businessLeaveData.subtract(b_businessLeavebackData).toString();
if (Util.getDoubleValue(businessLeave, -1) < 0) {
businessLeave = "0.0";
}
} catch (Exception e) {
}
fieldValue = KQDurationCalculatorUtil.getDurationRound(businessLeave);
} else if (Util.null2String(kqReportFieldComInfo.getCascadekey(fieldid)).length() > 0) {
fieldValue = Util.formatMultiLang(Util.null2String(rs.getString(fieldName)), "" + user.getLanguage());
data.add(fieldValue);
List<String> lsCascadekey = Util.splitString2List(kqReportFieldComInfo.getCascadekey(fieldid), ",");
for (int i = 0; i < lsCascadekey.size(); i++) {
if (Util.null2String(rs.getString(lsCascadekey.get(i))).length() > 0) {
fieldid = KQReportFieldComInfo.field2Id.get(lsCascadekey.get(i));
//迟到早退使用分钟
if (lsCascadekey.get(i).contains("LateMins") || lsCascadekey.get(i).contains("EarlyMins")) {
fieldValue = rs.getString(lsCascadekey.get(i));
} else {
fieldValue = getFieldValueByUnitType(rs.getString(lsCascadekey.get(i)), kqReportFieldComInfo.getUnittype(fieldid));
}
} else {
fieldValue = "0";
}
data.add(fieldValue);
}
continue;
} else if (fieldName.equals("saturdaysbcjsc")) {
BaseBean baseBean = new BaseBean();
String sjbjcjidStr = baseBean.getPropValue("nbkq_main", "sjbjcjid");
String[] sjbjcjidArr = sjbjcjidStr.split(",");
List<Integer> sjbjcjidList = new ArrayList<>();
for (String idT : sjbjcjidArr) {
sjbjcjidList.add(Integer.valueOf(idT));
}
String sjbjcjRes = "0.0";
List<Map<String, Object>> allLeaveRules = kqLeaveRulesBiz.getAllLeaveRules();
Map<String, Object> leaveRule = null;
for (int i = 0; allLeaveRules != null && i < allLeaveRules.size(); i++) {
if (((!CollectionUtils.isEmpty(sjbjcjidList)) && sjbjcjidList.contains(i))) {
leaveRule = (Map<String, Object>) allLeaveRules.get(i);
String flowType = Util.null2String("leaveType_" + leaveRule.get("id"));
String leaveData = Util.null2String(saturdayFlowLeaveData.get(id + "|" + flowType));
String flowLeaveBackType = Util.null2String("leavebackType_" + leaveRule.get("id"));
String leavebackData = Util.null2s(Util.null2String(saturdayFlowLeaveData.get(id + "|" + flowLeaveBackType)), "0.0");
String b_flowLeaveData = "";
String flowLeaveData = "";
try {
//以防止出现精度问题
if (leaveData.length() == 0) {
leaveData = "0.0";
}
if (leavebackData.length() == 0) {
leavebackData = "0.0";
}
BigDecimal b_leaveData = new BigDecimal(leaveData);
BigDecimal b_leavebackData = new BigDecimal(leavebackData);
b_flowLeaveData = b_leaveData.subtract(b_leavebackData).toString();
if (Util.getDoubleValue(b_flowLeaveData, -1) < 0) {
b_flowLeaveData = "0.0";
}
} catch (Exception e) {
writeLog("GetKQReportCmd:leaveData" + leaveData + ":leavebackData:" + leavebackData + ":" + e);
}
//考虑下冻结的数据
if (b_flowLeaveData.length() > 0) {
flowLeaveData = KQDurationCalculatorUtil.getDurationRound(b_flowLeaveData);
} else {
flowLeaveData = KQDurationCalculatorUtil.getDurationRound(Util.null2String(Util.getDoubleValue(leaveData, 0.0) - Util.getDoubleValue(leavebackData, 0.0)));
}
if (StringUtils.isEmpty(flowLeaveData)) {
flowLeaveData = "0.0";
}
if ((!CollectionUtils.isEmpty(sjbjcjidList)) && sjbjcjidList.contains(i)) {
sjbjcjRes = new BigDecimal(sjbjcjRes).add(new BigDecimal(flowLeaveData)).toString();
}
}
}
fieldValue = sjbjcjRes;
} else if (fieldName.equals("saturdayshjsc")) {
BaseBean baseBean = new BaseBean();
String hjsjidStr = baseBean.getPropValue("nbkq_main", "hjsjid");
String[] hjsjidArr = hjsjidStr.split(",");
List<Integer> hjsjidList = new ArrayList<>();
for (String idT : hjsjidArr) {
hjsjidList.add(Integer.valueOf(idT));
}
String hjsjRes = "0.0";
List<Map<String, Object>> allLeaveRules = kqLeaveRulesBiz.getAllLeaveRules();
Map<String, Object> leaveRule = null;
for (int i = 0; allLeaveRules != null && i < allLeaveRules.size(); i++) {
if (((!CollectionUtils.isEmpty(hjsjidList)) && hjsjidList.contains(i))) {
leaveRule = (Map<String, Object>) allLeaveRules.get(i);
String flowType = Util.null2String("leaveType_" + leaveRule.get("id"));
String leaveData = Util.null2String(saturdayFlowLeaveData.get(id + "|" + flowType));
String flowLeaveBackType = Util.null2String("leavebackType_" + leaveRule.get("id"));
String leavebackData = Util.null2s(Util.null2String(saturdayFlowLeaveData.get(id + "|" + flowLeaveBackType)), "0.0");
String b_flowLeaveData = "";
String flowLeaveData = "";
try {
//以防止出现精度问题
if (leaveData.length() == 0) {
leaveData = "0.0";
}
if (leavebackData.length() == 0) {
leavebackData = "0.0";
}
BigDecimal b_leaveData = new BigDecimal(leaveData);
BigDecimal b_leavebackData = new BigDecimal(leavebackData);
b_flowLeaveData = b_leaveData.subtract(b_leavebackData).toString();
if (Util.getDoubleValue(b_flowLeaveData, -1) < 0) {
b_flowLeaveData = "0.0";
}
} catch (Exception e) {
writeLog("GetKQReportCmd:leaveData" + leaveData + ":leavebackData:" + leavebackData + ":" + e);
}
//考虑下冻结的数据
if (b_flowLeaveData.length() > 0) {
flowLeaveData = KQDurationCalculatorUtil.getDurationRound(b_flowLeaveData);
} else {
flowLeaveData = KQDurationCalculatorUtil.getDurationRound(Util.null2String(Util.getDoubleValue(leaveData, 0.0) - Util.getDoubleValue(leavebackData, 0.0)));
}
if (StringUtils.isEmpty(flowLeaveData)) {
flowLeaveData = "0.0";
}
if ((!CollectionUtils.isEmpty(hjsjidList)) && hjsjidList.contains(i)) {
hjsjRes = new BigDecimal(hjsjRes).add(new BigDecimal(flowLeaveData)).toString();
}
}
}
fieldValue = hjsjRes;
} else {
fieldValue = Util.formatMultiLang(Util.null2String(rs.getString(fieldName)), "" + user.getLanguage());
fieldValue = getFieldValueByUnitType(fieldValue, kqReportFieldComInfo.getUnittype(fieldid));
}
fieldValue = Util.formatMultiLang(fieldValue, "" + user.getLanguage());
data.add(fieldValue);
}
if (showColumns.contains("kqCalendar")) {
Map<String, Object> detialDatas = kqReportBiz.getDetialDatas(id, fromDate, toDate, user);
isEnd = false;
for (String date = fromDate; !isEnd; ) {
if (date.equals(toDate)) isEnd = true;
if (DateUtil.compDate(today, date) > 0) {
data.add("");
} else {
if (detialDatas.get(id + "|" + date) != null) {
data.add(((Map<String, Object>) detialDatas.get(id + "|" + date)).get("text"));
} else {
data.add(SystemEnv.getHtmlLabelName(26593, user.getLanguage()));
}
}
cal.setTime(DateUtil.parseToDate(date));
date = DateUtil.getDate(cal.getTime(), 1);
}
}
dataList.add(data);
}
sheet.put("dataList", dataList);
sheet.put("constraintList", constraintList);
sheet.put("createFile", "1");
lsSheet.add(sheet);
workbook.put("sheet", lsSheet);
String fileName = SystemEnv.getHtmlLabelName(390351, user.getLanguage()) + " " + fromDate + " " + toDate;
workbook.put("fileName", fileName);
ExcelUtil ExcelUtil = new ExcelUtil();
Map<String, Object> exportMap = ExcelUtil.export(workbook, request, response);
retmap.putAll(exportMap);
retmap.put("status", "1");
} catch (Exception e) {
retmap.put("status", "-1");
retmap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage()));
writeLog(e);
}
return retmap;
}
private Map<String, Object> getChildColumnsInfo(String parentid, User user) {
Map<String, Object> returnMap = new HashMap<>();
List<Object> titleList = new ArrayList<>();
Map<String, Object> title = null;
if (parentid.equals("attendanceSerial")) {//考勤班次
KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo();
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
List<String> serialIds = null;
if (Util.null2String(jsonObj.get("attendanceSerial")).length() > 0) {
serialIds = Util.splitString2List(Util.null2String(jsonObj.get("attendanceSerial")), ",");
}
for (int i = 0; serialIds != null && i < serialIds.size(); i++) {
title = new HashMap<>();
title.put("title", Util.formatMultiLang(kqShiftManagementComInfo.getSerial(serialIds.get(i)), "" + user.getLanguage()));
title.put("width", 30 * 256);
titleList.add(title);
}
} else if (parentid.equals("leave")) {
KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz();
List<Map<String, Object>> leaveRules = kqLeaveRulesBiz.getAllLeaveRules();
for (int i = 0; leaveRules != null && i < leaveRules.size(); i++) {
Map<String, Object> leaveRule = leaveRules.get(i);
String name = Util.formatMultiLang(Util.null2String(leaveRule.get("name")), "" + user.getLanguage());
String unitType = Util.null2String(leaveRule.get("unitType"));
String unitName = (KQUnitBiz.isLeaveHour(unitType)) ? SystemEnv.getHtmlLabelName(391, user.getLanguage()) : SystemEnv.getHtmlLabelName(1925, user.getLanguage());
title = new HashMap<>();
title.put("title", name + "(" + unitName + ")");
title.put("width", 30 * 256);
titleList.add(title);
}
} else if (parentid.equals("overtime")) {
String[] overtimeChild = {"overtime_nonleave", "overtime_4leave", "overtimeTotal"};
for (int i = 0; i < overtimeChild.length; i++) {
String id = overtimeChild[i];
title = new HashMap();
String fieldlabel = "";
if ("overtime_nonleave".equalsIgnoreCase(id)) {
fieldlabel = "125805";
title.put("title", SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage()));
title.put("rowSpan", "2");
} else if ("overtime_4leave".equalsIgnoreCase(id)) {
fieldlabel = "125804";
title.put("title", SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage()));
title.put("rowSpan", "2");
} else {
fieldlabel = "523";
title.put("showDetial", "1");
String unitType = (KQOvertimeRulesBiz.getMinimumUnit() == 3 || KQOvertimeRulesBiz.getMinimumUnit() == 5 || KQOvertimeRulesBiz.getMinimumUnit() == 6) ? "2" : "1";
String unitTypeName = "";
if (Util.null2String(unitType).length() > 0) {
if (unitType.equals("1")) {
unitTypeName = SystemEnv.getHtmlLabelName(1925, user.getLanguage());
} else if (unitType.equals("2")) {
unitTypeName = SystemEnv.getHtmlLabelName(391, user.getLanguage());
} else if (unitType.equals("3")) {
unitTypeName = SystemEnv.getHtmlLabelName(18083, user.getLanguage());
}
}
title.put("title", SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage()) + "(" + unitTypeName + ")");
}
Map<String, Object> mapChildColumnInfo = getChildColumnsInfo(id, user);
int childWidth = 65;
List<Object> childColumns = (List<Object>) mapChildColumnInfo.get("childColumns");
if (childColumns.size() > 0) {//跨列width取子列的width
title.put("children", childColumns);
childWidth = Util.getIntValue(Util.null2String(mapChildColumnInfo.get("sumChildColumnWidth")), 65);
}
title.put("width", childWidth + "");
titleList.add(title);
}
} else {
KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo();
while (kqReportFieldComInfo.next()) {
if (kqReportFieldComInfo.getParentid().equals(parentid)) {
if (!kqReportFieldComInfo.getReportType().equals("month")) continue;
title = new HashMap<>();
title.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage()) + "(" + KQReportBiz.getUnitType(kqReportFieldComInfo, user) + ")");
title.put("width", 30 * 256);
titleList.add(title);
}
}
}
returnMap.put("childColumns", titleList);
return returnMap;
}
private List<Object> getCascadeKeyColumnsInfo(String cascadeKey, User user) {
List<Object> titleList = new ArrayList<>();
Map<String, Object> title = null;
if (Util.null2String(cascadeKey).length() == 0) {
return titleList;
}
List<String> lsCascadeKey = Util.splitString2List(cascadeKey, ",");
KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo();
for (int i = 0; i < lsCascadeKey.size(); i++) {
kqReportFieldComInfo.setTofirstRow();
while (kqReportFieldComInfo.next()) {
if (!kqReportFieldComInfo.getReportType().equals("month")) continue;
if (kqReportFieldComInfo.getFieldname().equals(lsCascadeKey.get(i))) {
title = new HashMap<>();
//二开 迟到使用分钟
if (kqReportFieldComInfo.getFieldname().contains("LateMins") || kqReportFieldComInfo.getFieldname().contains("EarlyMins")) {
title.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage()) + "(分钟)");
} else {
title.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage()) + "(" + KQReportBiz.getUnitType(kqReportFieldComInfo, user) + ")");
}
title.put("width", 30 * 256);
titleList.add(title);
}
}
}
return titleList;
}
private String getFieldValueByUnitType(String fieldValue, String unittype) {
if (Util.null2String(unittype).length() > 0) {
if (fieldValue.length() == 0) {
fieldValue = "0";
} else {
if (unittype.equals("2")) {
fieldValue = KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(fieldValue) / 60.0)));
}
}
}
return fieldValue;
}
@Override
public BizLogContext getLogContext() {
return null;
}
}

@ -0,0 +1,745 @@
package com.engine.kq.cmd.report;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.kq.biz.*;
import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit;
import com.engine.kq.entity.WorkTimeEntity;
import com.engine.kq.log.KQLog;
import com.engine.kq.util.KQDurationCalculatorUtil;
import com.engine.kq.util.PageUidFactory;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.hrm.company.DepartmentComInfo;
import weaver.hrm.company.SubCompanyComInfo;
import weaver.hrm.job.JobTitlesComInfo;
import weaver.hrm.resource.ResourceComInfo;
import weaver.systeminfo.SystemEnv;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class GetKQDailyReportCmd extends AbstractCommonCommand<Map<String, Object>> {
private KQLog kqLog = new KQLog();
public GetKQDailyReportCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> retmap = new HashMap<String, Object>();
RecordSet rs = new RecordSet();
String sql = "";
try {
String pageUid = PageUidFactory.getHrmPageUid("KQDailyReport");
SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo();
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
ResourceComInfo resourceComInfo = new ResourceComInfo();
JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo();
KQWorkTime kqWorkTime = new KQWorkTime();
ShiftManagementToolKit shiftManagementToolKit = new ShiftManagementToolKit();
KQReportBiz kqReportBiz = new KQReportBiz();
KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz();
String rightSql = new KQReportBiz().getReportRight("2", "" + user.getUID(), "a");
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
String fromDate = Util.null2String(jsonObj.get("fromDate"));
String toDate = Util.null2String(jsonObj.get("toDate"));
String typeselect = Util.null2String(jsonObj.get("typeselect"));
if (typeselect.length() == 0) typeselect = "3";
if (!typeselect.equals("") && !typeselect.equals("0") && !typeselect.equals("6")) {
if (typeselect.equals("1")) {
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
} else {
fromDate = TimeUtil.getDateByOption(typeselect, "0");
toDate = TimeUtil.getDateByOption(typeselect, "1");
}
}
//人员状态
String status = Util.null2String(jsonObj.get("status"));
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
String departmentId = Util.null2String(jsonObj.get("departmentId"));
String resourceId = Util.null2String(jsonObj.get("resourceId"));
String allLevel = Util.null2String(jsonObj.get("allLevel"));
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));
String viewScope = Util.null2String(jsonObj.get("viewScope"));
if (typeselect.length() == 0) typeselect = "3";
int pageIndex = Util.getIntValue(Util.null2String(jsonObj.get("pageIndex")), 1);
int pageSize = KQReportBiz.getPageSize(Util.null2String(jsonObj.get("pageSize")), pageUid, user.getUID());
int count = 0;
int pageCount = 0;
int isHavePre = 0;
int isHaveNext = 0;
List<Map<String, Object>> leaveRules = kqLeaveRulesBiz.getAllLeaveRules();
List<Object> columns = new ArrayList();
Map<String, Object> column = null;
List<Object> datas = new ArrayList();
Map<String, Object> data = null;
Map<String, Object> mapChildColumnInfo = null;
List<Object> childColumns = null;
KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo();
while (kqReportFieldComInfo.next()) {
if (Util.null2String(kqReportFieldComInfo.getParentid()).length() > 0) continue;
boolean isDaily = kqReportFieldComInfo.getReportType().equals("daily");
if (!kqReportFieldComInfo.getReportType().equals("all") && !isDaily) continue;
if ("leave".equalsIgnoreCase(kqReportFieldComInfo.getFieldname()) && leaveRules.size() == 0) {
continue;
}
column = new HashMap();
column.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage()));
column.put("unit", KQReportBiz.getUnitType(kqReportFieldComInfo, user));
column.put("dataIndex", kqReportFieldComInfo.getFieldname());
column.put("key", kqReportFieldComInfo.getFieldname());
mapChildColumnInfo = this.getChildColumnsInfo(kqReportFieldComInfo.getFieldname(), user);
childColumns = (List<Object>) mapChildColumnInfo.get("childColumns");
if (childColumns.size() > 0) {//跨列width取子列的width
column.put("rowSpan", 1);
column.put("width", mapChildColumnInfo.get("sumChildColumnWidth"));
column.put("children", childColumns);
} else {
column.put("rowSpan", 3);
column.put("width", Util.getIntValue(kqReportFieldComInfo.getWidth()));
}
if (kqReportFieldComInfo.getReportType1().equals("daily")) {
column.put("isdaily", "1");
}
column.put("showDetial", kqReportFieldComInfo.getShowDetial());
//2024-01-31 二开 迟到时长使用分钟
String title = (String) column.get("title");
if (title.contains("迟到时长") || title.contains("早退时长")) {
column.put("title", title + "(分钟)");
column.put("unit", "");
}
if ("姓名".equals(column.get("title"))) {
column.put("fixed", "left");
}
columns.add(column);
}
// String today = DateUtil.getCurrentDate();
// if(DateUtil.compDate(today, toDate)>0){//结束如期不大于今天
// toDate = today;
// if(DateUtil.compDate(today, fromDate)>0){
// fromDate = today;
// }
// }
String forgotBeginWorkCheck_field = " b.forgotbeginworkcheck ";
if (rs.getDBType().equalsIgnoreCase("oracle") && !Util.null2String(rs.getOrgindbtype()).equals("dm") && !Util.null2String(rs.getOrgindbtype()).equals("st") && !Util.null2String(rs.getOrgindbtype()).equals("jc")) {
forgotBeginWorkCheck_field = " nvl(b.forgotBeginWorkCheck,0) ";
} else if ((rs.getDBType()).equalsIgnoreCase("mysql")) {
forgotBeginWorkCheck_field = " ifnull(b.forgotBeginWorkCheck,0) ";
} else {
forgotBeginWorkCheck_field = " isnull(b.forgotBeginWorkCheck,0) ";
}
String backFields = " (select workdays from kq_format_total where resourceid = a.id and kqdate = b.kqdate and (DATEPART(dw, kqdate) = 7 or DATEPART(dw, kqdate) = 1)) as saturdayworkdays," +
" (select attendancedays from kq_format_total where resourceid = a.id and kqdate = b.kqdate and (DATEPART(dw, kqdate) = 7 or DATEPART(dw, kqdate) = 1)) as saturdayattendancedays," +
" (select workdays from kq_format_total where resourceid = a.id and kqdate = b.kqdate and DATEPART(dw, kqdate) != 7 and DATEPART(dw, kqdate) != 1) as weekdayworkdays," +
" (select attendancedays from kq_format_total where resourceid = a.id and kqdate = b.kqdate and DATEPART(dw, kqdate) != 7 and DATEPART(dw, kqdate) != 1) as weekdayattendancedays," +
" a.id,a.lastname,a.subcompanyid1 as subcompanyid,a.departmentid, a.workcode,b.jobtitle,a.dsporder," +
" b.kqdate, b.workdays,b.workMins,b.serialid, b.attendancedays,b.attendanceMins," +
" b.beLate,b.beLateMins,b.graveBeLate,b.graveBeLateMins,b.leaveEearly,b.leaveEarlyMins," +
" b.signdays,b.signmins, " +
" b.graveLeaveEarly,b.graveLeaveEarlyMins,b.absenteeism ,b.absenteeismMins ,(b.forgotCheck+" + forgotBeginWorkCheck_field + ") forgotCheck ";
String sqlFrom = " from hrmresource a, kq_format_total b where a.id= b.resourceid and b.kqdate >='" + fromDate + "' and b.kqdate <='" + toDate + "'";
String sqlWhere = rightSql;
if (subCompanyId.length() > 0) {
sqlWhere += " and a.subcompanyid1 in(" + subCompanyId + ") ";
}
if (departmentId.length() > 0) {
sqlWhere += " and a.departmentid in(" + departmentId + ") ";
}
if (resourceId.length() > 0) {
sqlWhere += " and a.id in(" + resourceId + ") ";
}
if (viewScope.equals("4")) {//我的下属
if (allLevel.equals("1")) {//所有下属
sqlWhere += " and a.managerstr like '%," + user.getUID() + ",%'";
} else {
sqlWhere += " and a.managerid=" + user.getUID();//直接下属
}
}
if (!"1".equals(isNoAccount)) {
sqlWhere += " and a.loginid is not null " + (rs.getDBType().equals("oracle") ? "" : " and a.loginid<>'' ");
}
if (status.length() > 0) {
if (!status.equals("8") && !status.equals("9")) {
sqlWhere += " and a.status = " + status + "";
} else if (status.equals("8")) {
sqlWhere += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) ";
}
}
sql = " select count(*) as c from ( select 1 as c " + sqlFrom + sqlWhere + ") t";
rs.execute(sql);
if (rs.next()) {
count = rs.getInt("c");
}
if (count <= 0) {
pageCount = 0;
}
pageCount = count / pageSize + ((count % pageSize > 0) ? 1 : 0);
isHaveNext = (pageIndex + 1 <= pageCount) ? 1 : 0;
isHavePre = (pageIndex - 1 >= 1) ? 1 : 0;
String orderBy = " order by a.dsporder asc, a.lastname asc, b.kqdate asc ";
String descOrderBy = " order by a.dsporder desc, a.lastname desc, b.kqdate desc ";
sql = backFields + sqlFrom + sqlWhere + orderBy;
if (pageIndex > 0 && pageSize > 0) {
if (rs.getDBType().equals("oracle")) {
sql = " select " + sql;
sql = "select * from ( select row_.*, rownum rownum_ from ( " + sql + " ) row_ where rownum <= "
+ (pageIndex * pageSize) + ") where rownum_ > " + ((pageIndex - 1) * pageSize);
} else if (rs.getDBType().equals("mysql")) {
sql = " select " + sql;
sql = "select t1.* from (" + sql + ") t1 limit " + ((pageIndex - 1) * pageSize) + "," + pageSize;
} else if (rs.getDBType().equals("postgresql")) {
sql = " select " + sql;
sql = "select t1.* from (" + sql + ") t1 limit " + pageSize + " offset " + ((pageIndex - 1) * pageSize);
} else {
orderBy = " order by dsporder asc, lastname asc, kqdate asc ";
descOrderBy = " order by dsporder desc, lastname desc, kqdate desc ";
if (pageIndex > 1) {
int topSize = pageSize;
if (pageSize * pageIndex > count) {
topSize = count - (pageSize * (pageIndex - 1));
}
sql = " select top " + topSize + " * from ( select top " + topSize + " * from ( select top "
+ (pageIndex * pageSize) + sql + " ) tbltemp1 " + descOrderBy + ") tbltemp2 " + orderBy;
} else {
sql = " select top " + pageSize + sql;
}
}
} else {
sql = " select " + sql;
}
Map<String, Object> flowData = kqReportBiz.getDailyFlowData(params, user);
Map<String, Object> dailySaturdayFlowLeaveData = kqReportBiz.getDailySaturdayFlowLeaveData(params, user);
// #1475814-概述:满足考勤报分部部门显示及导出时显示全路径
String fullPathMainKey = "show_full_path";
KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo();
String isShowFullPath = Util.null2String(kqSettingsComInfo.getMain_val(fullPathMainKey), "0");
new BaseBean().writeLog("kkkkkk:" + sql);
rs.execute(sql);
while (rs.next()) {
String id = rs.getString("id");
String kqdate = rs.getString("kqdate");
WorkTimeEntity workTime = kqWorkTime.getWorkTime(id, kqdate);
data = new HashMap<>();
kqReportFieldComInfo.setTofirstRow();
while (kqReportFieldComInfo.next()) {
if (!Util.null2String(kqReportFieldComInfo.getIsdataColumn()).equals("1")) continue;
if (!kqReportFieldComInfo.getReportType().equals("all") && !kqReportFieldComInfo.getReportType().equals("daily"))
continue;
String fieldName = kqReportFieldComInfo.getFieldname();
String fieldValue = "";
if (fieldName.equals("subcompany")) {
String fieldValueID = rs.getString("subcompanyid");
fieldValue = "1".equals(isShowFullPath) ?
SubCompanyComInfo.getSubcompanyRealPath(fieldValueID, "/", "0") :
subCompanyComInfo.getSubCompanyname(fieldValueID);
//fieldValue = subCompanyComInfo.getSubCompanyname(fieldValueID);
if (fieldValue.length() == 0) {
fieldValueID = resourceComInfo.getSubCompanyID(id);
fieldValue = "1".equals(isShowFullPath) ?
SubCompanyComInfo.getSubcompanyRealPath(fieldValueID, "/", "0") :
subCompanyComInfo.getSubCompanyname(fieldValueID);
// fieldValue = subCompanyComInfo.getSubCompanyname(fieldValueID);
}
data.put(fieldName + "Id", fieldValueID);
data.put(fieldName, fieldValue);
} else if (fieldName.equals("department")) {
String fieldValueID = rs.getString("departmentid");
fieldValue = "1".equals(isShowFullPath) ?
departmentComInfo.getDepartmentRealPath(fieldValueID, "/", "0") :
departmentComInfo.getDepartmentname(fieldValueID);
//fieldValue = departmentComInfo.getDepartmentname(fieldValueID);
if (fieldValue.length() == 0) {
fieldValueID = resourceComInfo.getDepartmentID(id);
fieldValue = "1".equals(isShowFullPath) ?
departmentComInfo.getDepartmentRealPath(fieldValueID, "/", "0") :
departmentComInfo.getDepartmentname(fieldValueID);
// fieldValue = departmentComInfo.getDepartmentname(fieldValueID);
}
data.put(fieldName + "Id", fieldValueID);
data.put(fieldName, fieldValue);
} else if (fieldName.equals("jobtitle")) {
String fieldValueID = rs.getString("jobtitle");
fieldValue = jobTitlesComInfo.getJobTitlesname(rs.getString("jobtitle"));
if (fieldValue.length() == 0) {
fieldValueID = resourceComInfo.getJobTitle(id);
fieldValue = jobTitlesComInfo.getJobTitlesname(fieldValueID);
}
data.put(fieldName + "Id", fieldValueID);
data.put(fieldName, fieldValue);
} else if (kqReportFieldComInfo.getParentid().equals("overtime") || kqReportFieldComInfo.getParentid().equals("overtime_nonleave")
|| kqReportFieldComInfo.getParentid().equals("overtime_4leave") || fieldName.equals("businessLeave") || fieldName.equals("officialBusiness")) {
if (fieldName.equals("overtimeTotal")) {
double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|workingDayOvertime_4leave")));
workingDayOvertime_4leave = workingDayOvertime_4leave < 0 ? 0 : workingDayOvertime_4leave;
double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|restDayOvertime_4leave")));
restDayOvertime_4leave = restDayOvertime_4leave < 0 ? 0 : restDayOvertime_4leave;
double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|holidayOvertime_4leave")));
holidayOvertime_4leave = holidayOvertime_4leave < 0 ? 0 : holidayOvertime_4leave;
double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|workingDayOvertime_nonleave")));
workingDayOvertime_nonleave = workingDayOvertime_nonleave < 0 ? 0 : workingDayOvertime_nonleave;
double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|restDayOvertime_nonleave")));
restDayOvertime_nonleave = restDayOvertime_nonleave < 0 ? 0 : restDayOvertime_nonleave;
double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|" + kqdate + "|holidayOvertime_nonleave")));
holidayOvertime_nonleave = holidayOvertime_nonleave < 0 ? 0 : holidayOvertime_nonleave;
fieldValue = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_4leave + restDayOvertime_4leave + holidayOvertime_4leave +
workingDayOvertime_nonleave + restDayOvertime_nonleave + holidayOvertime_nonleave));
} else {
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|" + kqdate + "|" + fieldName)));
}
data.put(fieldName, fieldValue);
} else if (fieldName.equals("serialid")) {
fieldValue = Util.null2String(rs.getString(fieldName));
if (fieldValue.length() > 0) {//弹性工作制没有班次
data.put("serialid", shiftManagementToolKit.getShiftOnOffWorkSections(fieldValue, user.getLanguage()));
}
} else {
fieldValue = Util.null2String(rs.getString(fieldName));
//2024-01-31 二开 迟到使用分钟
writeLog("testreport-" + fieldName + fieldValue);
if (kqReportFieldComInfo.getUnittype().equals("2") && fieldValue.length() > 0
&& !fieldName.contains("LateMins") && !fieldName.contains("EarlyMins")) {
fieldValue = KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(fieldValue) / 60.0)));
}
data.put(fieldName, fieldValue);
}
}
data.putAll(this.getSignDetailInfo(id, kqdate));
//请假
List<Map<String, Object>> allLeaveRules = KQLeaveRulesBiz.getAllLeaveRules();
Map<String, Object> leaveRule = null;
for (int i = 0; allLeaveRules != null && i < allLeaveRules.size(); i++) {
leaveRule = (Map<String, Object>) allLeaveRules.get(i);
String flowType = Util.null2String("leaveType_" + leaveRule.get("id"));
String leaveData = Util.null2String(flowData.get(id + "|" + kqdate + "|" + flowType));
String flowLeaveBackType = Util.null2String("leavebackType_" + leaveRule.get("id"));
String leavebackData = Util.null2s(Util.null2String(flowData.get(id + "|" + kqdate + "|" + flowLeaveBackType)), "0.0");
String b_flowLeaveData = "";
String flowLeaveData = "";
try {
//以防止出现精度问题
if (leaveData.length() == 0) {
leaveData = "0.0";
}
if (leavebackData.length() == 0) {
leavebackData = "0.0";
}
BigDecimal b_leaveData = new BigDecimal(leaveData);
BigDecimal b_leavebackData = new BigDecimal(leavebackData);
b_flowLeaveData = b_leaveData.subtract(b_leavebackData).toString();
if (Util.getDoubleValue(b_flowLeaveData, -1) < 0) {
b_flowLeaveData = "0.0";
}
} catch (Exception e) {
kqLog.info("GetKQReportCmd:leaveData" + leaveData + ":leavebackData:" + leavebackData + ":" + e);
}
//考虑下冻结的数据
if (b_flowLeaveData.length() > 0) {
flowLeaveData = KQDurationCalculatorUtil.getDurationRound(b_flowLeaveData);
} else {
flowLeaveData = KQDurationCalculatorUtil.getDurationRound(Util.null2String(Util.getDoubleValue(leaveData, 0.0) - Util.getDoubleValue(leavebackData, 0.0)));
}
data.put(flowType, flowLeaveData);
}
BaseBean baseBean = new BaseBean();
String sjbjcjidStr = baseBean.getPropValue("nbkq_main", "sjbjcjid");
String[] sjbjcjidArr = sjbjcjidStr.split(",");
List<Integer> sjbjcjidList = new ArrayList<>();
for (String idT : sjbjcjidArr) {
sjbjcjidList.add(Integer.valueOf(idT));
}
String hjsjidStr = baseBean.getPropValue("nbkq_main", "hjsjid");
String[] hjsjidArr = hjsjidStr.split(",");
List<Integer> hjsjidList = new ArrayList<>();
for (String idT : hjsjidArr) {
hjsjidList.add(Integer.valueOf(idT));
}
String sjbjcjRes = "0.0";
String hjsjRes = "0.0";
for (int i = 0; allLeaveRules != null && i < allLeaveRules.size(); i++) {
if (((!CollectionUtils.isEmpty(sjbjcjidList)) && sjbjcjidList.contains(i)) ||
((!CollectionUtils.isEmpty(hjsjidList)) && hjsjidList.contains(i))) {
leaveRule = (Map<String, Object>) allLeaveRules.get(i);
String flowType = Util.null2String("leaveType_" + leaveRule.get("id"));
String leaveData = Util.null2String(dailySaturdayFlowLeaveData.get(id + "|" + flowType));
String flowLeaveBackType = Util.null2String("leavebackType_" + leaveRule.get("id"));
String leavebackData = Util.null2s(Util.null2String(dailySaturdayFlowLeaveData.get(id + "|" + flowLeaveBackType)), "0.0");
String b_flowLeaveData = "";
String flowLeaveData = "";
try {
//以防止出现精度问题
if (leaveData.length() == 0) {
leaveData = "0.0";
}
if (leavebackData.length() == 0) {
leavebackData = "0.0";
}
BigDecimal b_leaveData = new BigDecimal(leaveData);
BigDecimal b_leavebackData = new BigDecimal(leavebackData);
b_flowLeaveData = b_leaveData.subtract(b_leavebackData).toString();
if (Util.getDoubleValue(b_flowLeaveData, -1) < 0) {
b_flowLeaveData = "0.0";
}
} catch (Exception e) {
writeLog("GetKQReportCmd:leaveData" + leaveData + ":leavebackData:" + leavebackData + ":" + e);
}
//考虑下冻结的数据
if (b_flowLeaveData.length() > 0) {
flowLeaveData = KQDurationCalculatorUtil.getDurationRound(b_flowLeaveData);
} else {
flowLeaveData = KQDurationCalculatorUtil.getDurationRound(Util.null2String(Util.getDoubleValue(leaveData, 0.0) - Util.getDoubleValue(leavebackData, 0.0)));
}
if (StringUtils.isEmpty(flowLeaveData)) {
flowLeaveData = "0.0";
}
if ((!CollectionUtils.isEmpty(sjbjcjidList)) && sjbjcjidList.contains(i)) {
sjbjcjRes = new BigDecimal(sjbjcjRes).add(new BigDecimal(flowLeaveData)).toString();
}
if ((!CollectionUtils.isEmpty(hjsjidList)) && hjsjidList.contains(i)) {
hjsjRes = new BigDecimal(hjsjRes).add(new BigDecimal(flowLeaveData)).toString();
}
}
}
data.put("saturdaysbcjsc", sjbjcjRes); // 周六事假病假产假时长
data.put("saturdayshjsc", hjsjRes); // 周六丧假婚假时长
//加班数据 — 取加班台账的数据
//加班不关联调休工作日加班
double workingDayOvertime_nonleave = kqReportBiz.getOverTimeDailyCount(kqdate, id, "0", "1");
//加班不关联调休休息日加班
double restDayOvertime_nonleave = kqReportBiz.getOverTimeDailyCount(kqdate, id, "1", "1");
//加班不关联调休节假日加班
double holidayOvertime_nonleave = kqReportBiz.getOverTimeDailyCount(kqdate, id, "2", "1");
//加班关联调休工作日加班
double workingDayOvertime_4leave = kqReportBiz.getOverTimeDailyCount(kqdate, id, "0", "0");
//加班关联调休休息日加班
double restDayOvertime_4leave = kqReportBiz.getOverTimeDailyCount(kqdate, id, "1", "0");
//加班关联调休节假日加班
double holidayOvertime_4leave = kqReportBiz.getOverTimeDailyCount(kqdate, id, "2", "0");
rs.writeLog("================ GetKQDailyReportCmd workingDayOvertime_nonleave ============" + workingDayOvertime_nonleave);
rs.writeLog("================ GetKQDailyReportCmd restDayOvertime_nonleave ============" + restDayOvertime_nonleave);
rs.writeLog("================ GetKQDailyReportCmd holidayOvertime_nonleave ============" + holidayOvertime_nonleave);
rs.writeLog("================ GetKQDailyReportCmd workingDayOvertime_4leave ============" + workingDayOvertime_4leave);
rs.writeLog("================ GetKQDailyReportCmd restDayOvertime_4leave ============" + restDayOvertime_4leave);
rs.writeLog("================ GetKQDailyReportCmd holidayOvertime_4leave ============" + holidayOvertime_4leave);
data.put("workingDayOvertime_nonleave", workingDayOvertime_nonleave);
data.put("restDayOvertime_nonleave", restDayOvertime_nonleave);
data.put("holidayOvertime_nonleave", holidayOvertime_nonleave);
data.put("workingDayOvertime_4leave", workingDayOvertime_4leave);
data.put("restDayOvertime_4leave", restDayOvertime_4leave);
data.put("holidayOvertime_4leave", holidayOvertime_4leave);
String totalValue = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_4leave + workingDayOvertime_nonleave));
data.put("workdayovertotal", totalValue);
totalValue = KQDurationCalculatorUtil.getDurationRound(String.valueOf(restDayOvertime_4leave + restDayOvertime_nonleave));
data.put("restdayovertotal", totalValue);
totalValue = KQDurationCalculatorUtil.getDurationRound(String.valueOf(holidayOvertime_4leave + holidayOvertime_nonleave));
data.put("holidayovertotal", totalValue);
String overtimeTotal = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_4leave + restDayOvertime_4leave + holidayOvertime_4leave +
workingDayOvertime_nonleave + restDayOvertime_nonleave + holidayOvertime_nonleave));
data.put("overtimeTotal", overtimeTotal);
//夜班补贴次数
String nightSubsidy = KQDurationCalculatorUtil.getDurationRound(String.valueOf(kqReportBiz.getNightSubsidyDaily(kqdate, id)));
data.put("nightSubsidy", nightSubsidy);
//补卡次数
String fillCard = KQDurationCalculatorUtil.getDurationRound(String.valueOf(kqReportBiz.getFillCardCountDaily(kqdate, id)));
data.put("fillCard", fillCard);
data.put("resourceId", id);
data.put("kqdate", kqdate);
datas.add(data);
}
List<Object> lsHolidays = KQHolidaySetBiz.getHolidaySetListByScope("" + user.getUID(), fromDate, toDate);
retmap.put("holidays", lsHolidays);
retmap.put("columns", columns);
retmap.put("datas", datas);
retmap.put("pagesize", pageSize);
retmap.put("pageindex", pageIndex);
retmap.put("count", count);
retmap.put("pagecount", pageCount);
retmap.put("ishavepre", isHavePre);
retmap.put("ishavenext", isHaveNext);
} catch (Exception e) {
writeLog(e);
}
return retmap;
}
private String getUnitType(String unitType, User user) {
String unitTypeName = "";
if (Util.null2String(unitType).length() > 0) {
if (unitType.equals("1")) {
unitTypeName = SystemEnv.getHtmlLabelName(1925, user.getLanguage());
} else if (unitType.equals("2")) {
unitTypeName = SystemEnv.getHtmlLabelName(391, user.getLanguage());
} else if (unitType.equals("3")) {
unitTypeName = SystemEnv.getHtmlLabelName(18083, user.getLanguage());
}
}
return unitTypeName;
}
private Map<String, Object> getChildColumnsInfo(String parentid, User user) {
Map<String, Object> returnMap = new HashMap<>();
List<Object> lsChildColumns = new ArrayList<>();
Map column = null;
int sumChildColumnWidth = 0;
if (parentid.equals("leave")) {
KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz();
List<Map<String, Object>> leaveRules = kqLeaveRulesBiz.getAllLeaveRules();
for (int i = 0; leaveRules != null && i < leaveRules.size(); i++) {
Map<String, Object> leaveRule = leaveRules.get(i);
String id = "leaveType_" + Util.null2String(leaveRule.get("id"));
String name = Util.null2String(leaveRule.get("name"));
String unitType = Util.null2String(leaveRule.get("unitType"));
column = new HashMap();
column.put("title", name);
column.put("unit", KQUnitBiz.isLeaveHour(unitType) ? SystemEnv.getHtmlLabelName(391, user.getLanguage()) : SystemEnv.getHtmlLabelName(1925, user.getLanguage()));
column.put("width", 65);
column.put("dataIndex", id);
column.put("key", id);
column.put("rowSpan", 2);
column.put("colSpan", 1);
column.put("showDetial", "1");
sumChildColumnWidth += 65;
lsChildColumns.add(column);
}
} else if (parentid.equals("overtime")) {
String[] overtimeChild = {"overtime_nonleave", "overtime_4leave", "overtimeTotal", "workdayovertotal", "restdayovertotal", "holidayovertotal"};
for (int i = 0; i < overtimeChild.length; i++) {
String id = overtimeChild[i];
column = new HashMap();
String fieldlabel = "";
column.put("unit", "");
if ("overtime_nonleave".equalsIgnoreCase(id)) {
fieldlabel = "125805";
} else if ("overtime_4leave".equalsIgnoreCase(id)) {
fieldlabel = "125804";
} else if ("workdayovertotal".equalsIgnoreCase(id)) {
fieldlabel = "1";
} else if ("restdayovertotal".equalsIgnoreCase(id)) {
fieldlabel = "2";
} else if ("holidayovertotal".equalsIgnoreCase(id)) {
fieldlabel = "3";
}else {
fieldlabel = "523";
column.put("showDetial", "1");
String unitType = (KQOvertimeRulesBiz.getMinimumUnit() == 3 || KQOvertimeRulesBiz.getMinimumUnit() == 5 || KQOvertimeRulesBiz.getMinimumUnit() == 6) ? "2" : "1";
String unitTypeName = "";
if (Util.null2String(unitType).length() > 0) {
if (unitType.equals("1")) {
unitTypeName = SystemEnv.getHtmlLabelName(1925, user.getLanguage());
} else if (unitType.equals("2")) {
unitTypeName = SystemEnv.getHtmlLabelName(391, user.getLanguage());
} else if (unitType.equals("3")) {
unitTypeName = SystemEnv.getHtmlLabelName(18083, user.getLanguage());
}
}
column.put("unit", unitTypeName);
}
column.put("title", SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage()));
column.put("dataIndex", id);
column.put("key", id);
column.put("rowSpan", 1);
Map<String, Object> mapChildColumnInfo = getChildColumnsInfo(id, user);
int childWidth = 65;
List<Object> childColumns = (List<Object>) mapChildColumnInfo.get("childColumns");
if (childColumns.size() > 0) {//跨列width取子列的width
column.put("children", childColumns);
childWidth = Util.getIntValue(Util.null2String(mapChildColumnInfo.get("sumChildColumnWidth")), 65);
}
column.put("width", childWidth + "");
sumChildColumnWidth += childWidth;
lsChildColumns.add(column);
}
} else {
KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo();
while (kqReportFieldComInfo.next()) {
if (kqReportFieldComInfo.getParentid().equals(parentid)) {
if (!kqReportFieldComInfo.getReportType().equals("daily")) continue;
column = new HashMap();
column.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage()));
column.put("unit", KQReportBiz.getUnitType(kqReportFieldComInfo, user));
column.put("width", Util.getIntValue(kqReportFieldComInfo.getWidth()));
column.put("dataIndex", kqReportFieldComInfo.getFieldname());
column.put("key", kqReportFieldComInfo.getFieldname());
column.put("rowSpan", 2);
column.put("colSpan", 1);
column.put("isdaily", kqReportFieldComInfo.getReportType1().equals("daily") ? "1" : "0");
sumChildColumnWidth += Util.getIntValue(kqReportFieldComInfo.getWidth());
lsChildColumns.add(column);
}
}
}
returnMap.put("childColumns", lsChildColumns);
returnMap.put("sumChildColumnWidth", sumChildColumnWidth);
return returnMap;
}
public Map<String, Object> getSignDetailInfo(String resourceId, String kqDate) {
Map<String, Object> data = new HashMap<>();
Map<String, Object> signStatusInfo = null;
RecordSet rs = new RecordSet();
String sql = "";
KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo();
try {
sql = " select kqdate,resourceid,serialid,serialnumber,workbegindate,workbegintime, " +
" workenddate,workendtime,workmins,signindate,signintime,signoutdate,signouttime, \n" +
" attendanceMins,belatemins,graveBeLateMins,leaveearlymins,graveLeaveEarlyMins,absenteeismmins,forgotcheckMins,forgotBeginWorkCheckMins," +
" leaveMins,leaveInfo,evectionMins,outMins,signinid,signoutid \n" +
" from kq_format_detail b \n" +
" where resourceid = " + resourceId + " and kqdate ='" + kqDate + "' \n" +
" order by serialnumber \n";
rs.execute(sql);
while (rs.next()) {
String resourceid = Util.null2String(rs.getString("resourceid"));
String kqdate = Util.null2String(rs.getString("kqdate"));
String serialid = Util.null2String(rs.getString("serialid"));
int serialnumber = rs.getInt("serialnumber") + 1;
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();
int workMins = rs.getInt("workMins");
String signintime = Util.null2String(rs.getString("signintime")).trim();
String signouttime = Util.null2String(rs.getString("signouttime")).trim();
int attendanceMins = rs.getInt("attendanceMins");
String beLateMins = Util.null2String(rs.getString("beLateMins")).trim();
String graveBeLateMins = Util.null2String(rs.getString("graveBeLateMins")).trim();
String leaveEarlyMins = Util.null2String(rs.getString("leaveEarlyMins")).trim();
String graveLeaveEarlyMins = Util.null2String(rs.getString("graveLeaveEarlyMins")).trim();
String absenteeismMins = Util.null2String(rs.getString("absenteeismMins")).trim();
String forgotCheckMins = Util.null2String(rs.getString("forgotcheckMins")).trim();
String forgotBeginWorkCheckMins = Util.null2String(rs.getString("forgotBeginWorkCheckMins")).trim();
String signinid = Util.null2String(rs.getString("signinid")).trim();
String signoutid = Util.null2String(rs.getString("signoutid")).trim();
int leaveMins = rs.getInt("leaveMins");
String leaveInfo = Util.null2String(rs.getString("leaveInfo"));
int evectionMins = rs.getInt("evectionMins");
int outMins = rs.getInt("outMins");
if (serialid.length() > 0) {
if (workbegintime.length() > 0) {
signStatusInfo = new HashMap();
signStatusInfo.put("workdate", workbegindate);
signStatusInfo.put("worktime", workbegintime);
signStatusInfo.put("beLateMins", beLateMins);
signStatusInfo.put("forgotBeginWorkCheckMins", forgotBeginWorkCheckMins);
signStatusInfo.put("graveBeLateMins", graveBeLateMins);
signStatusInfo.put("absenteeismMins", absenteeismMins);
signStatusInfo.put("leaveMins", leaveMins);
signStatusInfo.put("leaveInfo", leaveInfo);
signStatusInfo.put("evectionMins", evectionMins);
signStatusInfo.put("outMins", outMins);
data.put("signintime" + serialnumber, signintime.length() == 0 ? SystemEnv.getHtmlLabelName(25994, user.getLanguage()) : signintime);
data.put("signinstatus" + serialnumber, KQReportBiz.getSignStatus(signStatusInfo, user, "on"));
}
if (workendtime.length() > 0) {
signStatusInfo = new HashMap();
signStatusInfo.put("workdate", workenddate);
signStatusInfo.put("worktime", kqTimesArrayComInfo.turn48to24Time(workendtime));
signStatusInfo.put("leaveEarlyMins", leaveEarlyMins);
signStatusInfo.put("graveLeaveEarlyMins", graveLeaveEarlyMins);
signStatusInfo.put("forgotCheckMins", forgotCheckMins);
signStatusInfo.put("forgotBeginWorkCheckMins", forgotBeginWorkCheckMins);
signStatusInfo.put("absenteeismMins", absenteeismMins);
signStatusInfo.put("leaveMins", leaveMins);
signStatusInfo.put("leaveInfo", leaveInfo);
signStatusInfo.put("evectionMins", evectionMins);
signStatusInfo.put("outMins", outMins);
data.put("signouttime" + serialnumber, signouttime.length() == 0 ? SystemEnv.getHtmlLabelName(25994, user.getLanguage()) : signouttime);
data.put("signoutstatus" + serialnumber, KQReportBiz.getSignStatus(signStatusInfo, user, "off"));
}
} else {
if (workMins > 0) {
//弹性工时打卡时间取自签到签退数据
}
signStatusInfo = new HashMap();
signStatusInfo.put("leaveMins", leaveMins);
signStatusInfo.put("leaveInfo", leaveInfo);
signStatusInfo.put("evectionMins", evectionMins);
signStatusInfo.put("outMins", outMins);
if (signinid.length() > 0) {
data.put("signintime" + serialnumber, signintime.length() == 0 ? SystemEnv.getHtmlLabelName(25994, user.getLanguage()) : signintime);
data.put("signinstatus" + serialnumber, KQReportBiz.getSignStatus(signStatusInfo, user, "on"));
if (signoutid.length() > 0) {
data.put("signouttime" + serialnumber, signouttime.length() == 0 ? SystemEnv.getHtmlLabelName(25994, user.getLanguage()) : signouttime);
data.put("signoutstatus" + serialnumber, KQReportBiz.getSignStatus(signStatusInfo, user, "off"));
}
} else {
data.put("signinstatus" + serialnumber, KQReportBiz.getSignStatus(signStatusInfo, user, "on"));
}
}
}
} catch (Exception e) {
writeLog(e);
}
return data;
}
@Override
public BizLogContext getLogContext() {
return null;
}
}

@ -0,0 +1,790 @@
package com.engine.kq.cmd.report;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.kq.biz.*;
import com.engine.kq.util.KQDurationCalculatorUtil;
import com.engine.kq.util.PageUidFactory;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.hrm.company.DepartmentComInfo;
import weaver.hrm.company.SubCompanyComInfo;
import weaver.hrm.job.JobTitlesComInfo;
import weaver.hrm.resource.ResourceComInfo;
import weaver.systeminfo.SystemEnv;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class GetKQReportCmd extends AbstractCommonCommand<Map<String, Object>> {
public GetKQReportCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> retmap = new HashMap<String, Object>();
RecordSet rs = new RecordSet();
String sql = "";
try {
String pageUid = PageUidFactory.getHrmPageUid("KQReport");
SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo();
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
ResourceComInfo resourceComInfo = new ResourceComInfo();
JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo();
KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz();
KQReportBiz kqReportBiz = new KQReportBiz();
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
String attendanceSerial = Util.null2String(jsonObj.get("attendanceSerial"));
String fromDate = Util.null2String(jsonObj.get("fromDate"));
String toDate = Util.null2String(jsonObj.get("toDate"));
String typeselect = Util.null2String(jsonObj.get("typeselect"));
if (typeselect.length() == 0) typeselect = "3";
if (!typeselect.equals("") && !typeselect.equals("0") && !typeselect.equals("6")) {
if (typeselect.equals("1")) {
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
} else {
fromDate = TimeUtil.getDateByOption(typeselect, "0");
toDate = TimeUtil.getDateByOption(typeselect, "1");
}
}
//人员状态
String status = Util.null2String(jsonObj.get("status"));
String subCompanyId = Util.null2String(jsonObj.get("subCompanyId"));
String departmentId = Util.null2String(jsonObj.get("departmentId"));
String resourceId = Util.null2String(jsonObj.get("resourceId"));
String allLevel = Util.null2String(jsonObj.get("allLevel"));
String isNoAccount = Util.null2String(jsonObj.get("isNoAccount"));
String viewScope = Util.null2String(jsonObj.get("viewScope"));
String isFromMyAttendance = Util.null2String(jsonObj.get("isFromMyAttendance"));//是否是来自我的考勤的请求,如果是,不加载考勤报表权限共享的限制,不然我的考勤会提示无权限
int pageIndex = Util.getIntValue(Util.null2String(jsonObj.get("pageIndex")), 1);
int pageSize = KQReportBiz.getPageSize(Util.null2String(jsonObj.get("pageSize")), pageUid, user.getUID());
int count = 0;
int pageCount = 0;
int isHavePre = 0;
int isHaveNext = 0;
String rightSql = kqReportBiz.getReportRight("1", "" + user.getUID(), "a");
if (isFromMyAttendance.equals("1")) {
rightSql = "";
}
List<Map<String, Object>> leaveRules = kqLeaveRulesBiz.getAllLeaveRules();
List<Object> columns = new ArrayList();
Map<String, Object> column = null;
List<Object> datas = new ArrayList();
Map<String, Object> data = null;
Map<String, Object> mapChildColumnInfo = null;
List<Object> childColumns = null;
KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo();
while (kqReportFieldComInfo.next()) {
if (Util.null2String(kqReportFieldComInfo.getParentid()).length() > 0) continue;
if (kqReportFieldComInfo.getFieldname().equals("kqCalendar")) continue;
if (KQReportFieldComInfo.cascadekey2fieldname.keySet().contains(kqReportFieldComInfo.getFieldname()))
continue;
if (!kqReportFieldComInfo.getReportType().equals("all") && !kqReportFieldComInfo.getReportType().equals("month"))
continue;
if ("leave".equalsIgnoreCase(kqReportFieldComInfo.getFieldname()) && leaveRules.size() == 0) continue;
column = new HashMap();
column.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage()));
column.put("unit", KQReportBiz.getUnitType(kqReportFieldComInfo, user));
column.put("dataIndex", kqReportFieldComInfo.getFieldname());
column.put("type", kqReportFieldComInfo.getFieldname());
column.put("key", kqReportFieldComInfo.getFieldname());
column.put("isSystem", kqReportFieldComInfo.getIsSystem());
mapChildColumnInfo = this.getChildColumnsInfo(kqReportFieldComInfo.getFieldname(), user);
childColumns = (List<Object>) mapChildColumnInfo.get("childColumns");
if (childColumns.size() > 0) {//跨列width取子列的width
column.put("rowSpan", 1);
column.put("width", mapChildColumnInfo.get("sumChildColumnWidth"));
column.put("children", childColumns);
} else {
column.put("rowSpan", 3);
column.put("width", Util.getIntValue(kqReportFieldComInfo.getWidth()));
}
column.put("showDetial", kqReportFieldComInfo.getShowDetial());
if ("姓名".equals(column.get("title"))) {
column.put("fixed", "left");
}
columns.add(column);
//2024-01-31 二开 迟到时长使用分钟
List<Object> columnsInfo = this.getCascadeKeyColumnsInfo(kqReportFieldComInfo.getCascadekey(), user);
columnsInfo.stream().forEach(item -> {
Map<String, Object> map = (Map<String, Object>) item;
String title = (String) map.get("title");
if (title.contains("迟到时长") || title.contains("早退时长")) {
map.put("title", title + "(分钟)");
map.put("unit", "");
}
});
columns.addAll(columnsInfo);
}
boolean isEnd = false;
Calendar cal = DateUtil.getCalendar();
String today = DateUtil.getCurrentDate();
// if(DateUtil.compDate(today, toDate)>0){//结束日期不大于今天
// toDate = today;
// if(DateUtil.compDate(today, fromDate)>0){//结束日期不大于今天
// fromDate = today;
// }
// }
childColumns = new ArrayList<>();
for (String date = fromDate; !isEnd; ) {
if (date.equals(toDate)) isEnd = true;
column = new HashMap();
column.put("title", DateUtil.geDayOfMonth(date));
column.put("dataIndex", date);
column.put("key", date);
column.put("type", date);
column.put("rowSpan", 1);
column.put("width", 65);
column.put("isCalendar", 1);
childColumns.add(column);
cal.setTime(DateUtil.parseToDate(date));
date = DateUtil.getDate(cal.getTime(), 1);
}
column = new HashMap();
column.put("title", SystemEnv.getHtmlLabelName(386476, user.getLanguage()));
column.put("dataIndex", "kqCalendar");
column.put("key", "kqCalendar");
if (childColumns.size() > 0) {//跨列width取子列的width
column.put("rowSpan", 1);
column.put("width", childColumns.size() * 65);
column.put("children", childColumns);
}
columns.add(column);
String forgotBeginWorkCheck_field = " sum(b.forgotBeginWorkCheck) ";
if (rs.getDBType().equalsIgnoreCase("oracle")) {
forgotBeginWorkCheck_field = " sum(nvl(b.forgotBeginWorkCheck,0)) ";
} else if ((rs.getDBType()).equalsIgnoreCase("mysql")) {
forgotBeginWorkCheck_field = " sum(ifnull(b.forgotBeginWorkCheck,0)) ";
} else {
forgotBeginWorkCheck_field = " sum(isnull(b.forgotBeginWorkCheck,0)) ";
}
Map<String, Object> definedFieldInfo = new KQFormatBiz().getDefinedField();
String definedFieldSum = Util.null2String(definedFieldInfo.get("definedFieldSum"));
//支援班次统计
String supportSerId = new BaseBean().getPropValue("nbkq_main", "supportSerId");
String backFields = " (select sum(workdays) from kq_format_total where resourceid = a.id and kqdate >='" + fromDate + "' and kqdate <='" + toDate + "' and (DATEPART(dw, kqdate) = 7 or DATEPART(dw, kqdate) = 1)) as saturdayworkdays," +
" (select count(0) from kq_shiftschedule where resourceid = a.id and kqdate >='" + fromDate + "' and kqdate <='" + toDate + "' and serialid=" + supportSerId + " )as supportTotal," +
" (select sum(attendancedays) from kq_format_total where resourceid = a.id and kqdate >='" + fromDate + "' and kqdate <='" + toDate + "' and (DATEPART(dw, kqdate) = 7 or DATEPART(dw, kqdate) = 1)) as saturdayattendancedays," +
" (select sum(workdays) from kq_format_total where resourceid = a.id and kqdate >='" + fromDate + "' and kqdate <='" + toDate + "' and DATEPART(dw, kqdate) != 7 and DATEPART(dw, kqdate) != 1) as weekdayworkdays," +
" (select sum(attendancedays) from kq_format_total where resourceid = a.id and kqdate >='" + fromDate + "' and kqdate <='" + toDate + "' and DATEPART(dw, kqdate) != 7 and DATEPART(dw, kqdate) != 1) as weekdayattendancedays," +
"a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1 as subcompanyid,a.departmentid,a.jobtitle," +
" sum(b.workdays) as workdays,sum(b.workMins) as workMins,sum(b.attendancedays) as attendancedays," +
" sum(b.attendanceMins) as attendanceMins,sum(b.beLate) as beLate,sum(b.beLateMins) as beLateMins, " +
" sum(b.graveBeLate) as graveBeLate, sum(b.graveBeLateMins) as graveBeLateMins,sum(b.leaveEearly) as leaveEearly," +
" sum(b.leaveEarlyMins) as leaveEarlyMins, sum(b.graveLeaveEarly) as graveLeaveEarly, " +
" sum(b.graveLeaveEarlyMins) as graveLeaveEarlyMins,sum(b.absenteeism) as absenteeism, " +
" sum(b.signdays) as signdays,sum(b.signmins) as signmins, " +
" sum(b.absenteeismMins) as absenteeismMins, sum(b.forgotCheck)+" + forgotBeginWorkCheck_field + " as forgotCheck " + (definedFieldSum.length() > 0 ? "," + definedFieldSum + "" : "");
if (rs.getDBType().equals("oracle")) {
backFields = "/*+ index(kq_format_total IDX_KQ_FORMAT_TOTAL_KQDATE) */ " + backFields;
}
String sqlFrom = " from hrmresource a, kq_format_total b ,kq_ShiftManagement c " +
"where a.id= b.resourceid and c.id=b.serialid and (c.rest_shift is null or c.rest_shift=0) " +
"and b.kqdate >='" + fromDate + "' and b.kqdate <='" + toDate + "'";
String sqlWhere = rightSql;
String groupBy = " group by a.id,a.lastname,a.workcode,a.dsporder,b.resourceid,a.subcompanyid1,a.departmentid,a.jobtitle ";
if (subCompanyId.length() > 0) {
sqlWhere += " and a.subcompanyid1 in(" + subCompanyId + ") ";
}
if (departmentId.length() > 0) {
sqlWhere += " and a.departmentid in(" + departmentId + ") ";
}
if (resourceId.length() > 0) {
sqlWhere += " and a.id in(" + resourceId + ") ";
}
if (viewScope.equals("4")) {//我的下属
if (allLevel.equals("1")) {//所有下属
sqlWhere += " and a.managerstr like '%," + user.getUID() + ",%'";
} else {
sqlWhere += " and a.managerid=" + user.getUID();//直接下属
}
}
if (!"1".equals(isNoAccount)) {
sqlWhere += " and a.loginid is not null " + (rs.getDBType().equals("oracle") ? "" : " and a.loginid<>'' ");
}
if (status.length() > 0) {
if (!status.equals("8") && !status.equals("9")) {
sqlWhere += " and a.status = " + status + "";
} else if (status.equals("8")) {
sqlWhere += " and (a.status = 0 or a.status = 1 or a.status = 2 or a.status = 3) ";
}
}
sql = " select count(*) as c from ( select 1 as c " + sqlFrom + sqlWhere + groupBy + ") t";
rs.execute(sql);
if (rs.next()) {
count = rs.getInt("c");
}
if (count <= 0) {
pageCount = 0;
}
pageCount = count / pageSize + ((count % pageSize > 0) ? 1 : 0);
isHaveNext = (pageIndex + 1 <= pageCount) ? 1 : 0;
isHavePre = (pageIndex - 1 >= 1) ? 1 : 0;
String orderBy = " order by t.dsporder asc, t.lastname asc ";
String descOrderBy = " order by t.dsporder desc, t.lastname desc ";
//默认排序设置 start有性能问题先取消后面再看看有没有好的方式
// String orderBySql = "select * from kq_report_order where userId=? and sort=1 order by orders";
// rs.executeQuery(orderBySql, user.getUID());
// if (rs.getCounts() <= 0) {
// orderBySql = "select * from kq_report_order where userId=0 and sort=1 order by orders";
// rs.executeQuery(orderBySql);
// }
// while (rs.next()) {
// String dataIndex = rs.getString("dataIndex");
// String ascOrDesc = rs.getString("ascOrDesc");
// String ascOrDesc1 = (ascOrDesc.equals("")||ascOrDesc.equals("asc"))?"desc":"asc";
// if (dataIndex.equals("organization")) {
// orderBy += ",showOrderOfDeptTree " + ascOrDesc + ",dept_id " + ascOrDesc;
// descOrderBy += ",showOrderOfDeptTree " + ascOrDesc1 + ",dept_id " + ascOrDesc1;
// }
// if (dataIndex.equalsIgnoreCase("dspOrder") || dataIndex.equalsIgnoreCase("lastName")) {
// orderBy += "," + dataIndex + " " + ascOrDesc + ",id " + ascOrDesc;
// descOrderBy += "," + dataIndex + " " + ascOrDesc1 + ",id " + ascOrDesc1;
// } else if (dataIndex.equalsIgnoreCase("deptShowOrder") || dataIndex.equalsIgnoreCase("deptName")) {
// orderBy += "," + dataIndex + " " + ascOrDesc + ",dept_id " + ascOrDesc;
// descOrderBy += "," + dataIndex + " " + ascOrDesc1 + ",dept_id " + ascOrDesc1;
// } else if (dataIndex.equalsIgnoreCase("subcomShowOrder") || dataIndex.equalsIgnoreCase("subcomName")) {
// orderBy += "," + dataIndex + " " + ascOrDesc + ",subcom_id " + ascOrDesc;
// descOrderBy += "," + dataIndex + " " + ascOrDesc1 + ",subcom_id " + ascOrDesc1;
// }
// }
// orderBy = orderBy.startsWith(",") ? orderBy.substring(1) : orderBy;
// descOrderBy = descOrderBy.startsWith(",") ? descOrderBy.substring(1) : descOrderBy;
// orderBy = orderBy.equals("") ? " t.dspOrder,t.id " : orderBy;
// descOrderBy = descOrderBy.equals("") ? " t.dspOrder,t.id " : descOrderBy;
// orderBy = "order by "+orderBy;
sql = backFields + sqlFrom + sqlWhere + groupBy;
if (pageIndex > 0 && pageSize > 0) {
if (rs.getDBType().equals("oracle")) {
sql = " select * from (select " + sql + ") t " + orderBy;
sql = "select * from ( select row_.*, rownum rownum_ from ( " + sql + " ) row_ where rownum <= "
+ (pageIndex * pageSize) + ") where rownum_ > " + ((pageIndex - 1) * pageSize);
} else if (rs.getDBType().equals("mysql")) {
sql = " select * from (select " + sql + ") t " + orderBy;
sql = "select t1.* from (" + sql + ") t1 limit " + ((pageIndex - 1) * pageSize) + "," + pageSize;
} else if (rs.getDBType().equals("postgresql")) {
sql = " select * from (select " + sql + ") t " + orderBy;
sql = "select t1.* from (" + sql + ") t1 limit " + pageSize + " offset " + ((pageIndex - 1) * pageSize);
} else {
orderBy = " order by dsporder asc, lastname asc ";
descOrderBy = " order by dsporder desc, lastname desc ";
if (pageIndex > 1) {
int topSize = pageSize;
if (pageSize * pageIndex > count) {
topSize = count - (pageSize * (pageIndex - 1));
}
sql = " select top " + topSize + " * from ( select top " + topSize + " * from ( select top "
+ (pageIndex * pageSize) + sql + orderBy + " ) tbltemp1 " + descOrderBy + ") tbltemp2 " + orderBy;
} else {
sql = " select top " + pageSize + sql + orderBy;
}
}
} else {
sql = " select " + sql;
}
// #1475814-概述:满足考勤报分部部门显示及导出时显示全路径
String fullPathMainKey = "show_full_path";
KQSettingsComInfo kqSettingsComInfo = new KQSettingsComInfo();
String isShowFullPath = Util.null2String(kqSettingsComInfo.getMain_val(fullPathMainKey), "0");
Map<String, Object> flowData = kqReportBiz.getFlowData(params, user);
Map<String, Object> saturdayFlowLeaveData = kqReportBiz.getSaturdayFlowLeaveData(params, user);
rs.execute(sql);
rs.writeLog("========== GetKQReportCmd sql ========== " + sql);
while (rs.next()) {
data = new HashMap<>();
kqReportFieldComInfo.setTofirstRow();
String id = rs.getString("id");
data.put("resourceId", id);
while (kqReportFieldComInfo.next()) {
if (!Util.null2String(kqReportFieldComInfo.getIsdataColumn()).equals("1")) continue;
if (!kqReportFieldComInfo.getReportType().equals("all") && !kqReportFieldComInfo.getReportType().equals("month"))
continue;
if ("leave".equalsIgnoreCase(kqReportFieldComInfo.getFieldname()) && leaveRules.size() == 0) {
continue;
}
String fieldName = kqReportFieldComInfo.getFieldname();
String fieldValue = "";
if (fieldName.equals("subcompany")) {
String tmpSubcompanyId = Util.null2String(rs.getString("subcompanyid"));
if (tmpSubcompanyId.length() == 0) {
tmpSubcompanyId = Util.null2String(resourceComInfo.getSubCompanyID(id));
}
data.put("subcompanyId", tmpSubcompanyId);
fieldValue = "1".equals(isShowFullPath) ?
SubCompanyComInfo.getSubcompanyRealPath(tmpSubcompanyId, "/", "0") :
subCompanyComInfo.getSubCompanyname(tmpSubcompanyId);
// fieldValue = subCompanyComInfo.getSubCompanyname(tmpSubcompanyId);
} else if (fieldName.equals("department")) {
String tmpDepartmentId = Util.null2String(rs.getString("departmentid"));
if (tmpDepartmentId.length() == 0) {
tmpDepartmentId = Util.null2String(resourceComInfo.getDepartmentID(id));
}
data.put("departmentId", tmpDepartmentId);
fieldValue = "1".equals(isShowFullPath) ?
departmentComInfo.getDepartmentRealPath(tmpDepartmentId, "/", "0") :
departmentComInfo.getDepartmentname(tmpDepartmentId);
// fieldValue = departmentComInfo.getDepartmentname(tmpDepartmentId);
} else if (fieldName.equals("jobtitle")) {
String tmpJobtitleId = Util.null2String(rs.getString("jobtitle"));
if (tmpJobtitleId.length() == 0) {
tmpJobtitleId = Util.null2String(resourceComInfo.getJobTitle(id));
}
data.put("jobtitleId", tmpJobtitleId);
fieldValue = jobTitlesComInfo.getJobTitlesname(tmpJobtitleId);
} else if (fieldName.equals("attendanceSerial")) {
List<String> serialIds = null;
if (attendanceSerial.length() > 0) {
serialIds = Util.splitString2List(attendanceSerial, ",");
}
for (int i = 0; serialIds != null && i < serialIds.size(); i++) {
data.put(serialIds.get(i), kqReportBiz.getSerialCount(id, fromDate, toDate, serialIds.get(i)));
}
} else if (kqReportFieldComInfo.getParentid().equals("overtime") || kqReportFieldComInfo.getParentid().equals("overtime_nonleave")
|| kqReportFieldComInfo.getParentid().equals("overtime_4leave") || fieldName.equals("businessLeave") || fieldName.equals("officialBusiness")) {
if (fieldName.equals("overtimeTotal")) {
double workingDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|workingDayOvertime_4leave")));
workingDayOvertime_4leave = workingDayOvertime_4leave < 0 ? 0 : workingDayOvertime_4leave;
double restDayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|restDayOvertime_4leave")));
restDayOvertime_4leave = restDayOvertime_4leave < 0 ? 0 : restDayOvertime_4leave;
double holidayOvertime_4leave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|holidayOvertime_4leave")));
holidayOvertime_4leave = holidayOvertime_4leave < 0 ? 0 : holidayOvertime_4leave;
double workingDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|workingDayOvertime_nonleave")));
workingDayOvertime_nonleave = workingDayOvertime_nonleave < 0 ? 0 : workingDayOvertime_nonleave;
double restDayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|restDayOvertime_nonleave")));
restDayOvertime_nonleave = restDayOvertime_nonleave < 0 ? 0 : restDayOvertime_nonleave;
double holidayOvertime_nonleave = Util.getDoubleValue(Util.null2String(flowData.get(id + "|holidayOvertime_nonleave")));
holidayOvertime_nonleave = holidayOvertime_nonleave < 0 ? 0 : holidayOvertime_nonleave;
fieldValue = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_4leave + restDayOvertime_4leave + holidayOvertime_4leave +
workingDayOvertime_nonleave + restDayOvertime_nonleave + holidayOvertime_nonleave));
} else if (fieldName.equals("businessLeave") || fieldName.equals("officialBusiness")) {
String businessLeaveData = Util.null2s(Util.null2String(flowData.get(id + "|" + fieldName)), "0.0");
String backType = fieldName + "_back";
String businessLeavebackData = Util.null2s(Util.null2String(flowData.get(id + "|" + backType)), "0.0");
String businessLeave = "";
try {
//以防止出现精度问题
if (businessLeaveData.length() == 0) {
businessLeaveData = "0.0";
}
if (businessLeavebackData.length() == 0) {
businessLeavebackData = "0.0";
}
BigDecimal b_businessLeaveData = new BigDecimal(businessLeaveData);
BigDecimal b_businessLeavebackData = new BigDecimal(businessLeavebackData);
businessLeave = b_businessLeaveData.subtract(b_businessLeavebackData).toString();
if (Util.getDoubleValue(businessLeave, -1) < 0) {
businessLeave = "0.0";
}
} catch (Exception e) {
}
fieldValue = KQDurationCalculatorUtil.getDurationRound(businessLeave);
} else {
fieldValue = KQDurationCalculatorUtil.getDurationRound(Util.null2String(flowData.get(id + "|" + fieldName)));
}
} else {
fieldValue = Util.null2String(rs.getString(fieldName));
if (Util.null2String(kqReportFieldComInfo.getUnittype()).length() > 0) {
if (fieldValue.length() == 0) {
fieldValue = "0";
} else {
//2024-01-31 二开 迟到使用分钟
writeLog("testreport-" + fieldName + fieldValue);
if (kqReportFieldComInfo.getUnittype().equals("2")
&& !fieldName.contains("LateMins") && !fieldName.contains("EarlyMins")) {
fieldValue = KQDurationCalculatorUtil.getDurationRound(("" + (Util.getDoubleValue(fieldValue) / 60.0)));
}
}
}
}
data.put(fieldName, fieldValue);
}
rs.writeLog("================ GetKQReportCmd 111 data ============" + data);
//请假
List<Map<String, Object>> allLeaveRules = kqLeaveRulesBiz.getAllLeaveRules();
Map<String, Object> leaveRule = null;
for (int i = 0; allLeaveRules != null && i < allLeaveRules.size(); i++) {
leaveRule = (Map<String, Object>) allLeaveRules.get(i);
String flowType = Util.null2String("leaveType_" + leaveRule.get("id"));
String leaveData = Util.null2String(flowData.get(id + "|" + flowType));
String flowLeaveBackType = Util.null2String("leavebackType_" + leaveRule.get("id"));
String leavebackData = Util.null2s(Util.null2String(flowData.get(id + "|" + flowLeaveBackType)), "0.0");
String b_flowLeaveData = "";
String flowLeaveData = "";
try {
//以防止出现精度问题
if (leaveData.length() == 0) {
leaveData = "0.0";
}
if (leavebackData.length() == 0) {
leavebackData = "0.0";
}
BigDecimal b_leaveData = new BigDecimal(leaveData);
BigDecimal b_leavebackData = new BigDecimal(leavebackData);
b_flowLeaveData = b_leaveData.subtract(b_leavebackData).toString();
if (Util.getDoubleValue(b_flowLeaveData, -1) < 0) {
b_flowLeaveData = "0.0";
}
} catch (Exception e) {
writeLog("GetKQReportCmd:leaveData" + leaveData + ":leavebackData:" + leavebackData + ":" + e);
}
//考虑下冻结的数据
if (b_flowLeaveData.length() > 0) {
flowLeaveData = KQDurationCalculatorUtil.getDurationRound(b_flowLeaveData);
} else {
flowLeaveData = KQDurationCalculatorUtil.getDurationRound(Util.null2String(Util.getDoubleValue(leaveData, 0.0) - Util.getDoubleValue(leavebackData, 0.0)));
}
data.put(flowType, flowLeaveData);
}
BaseBean baseBean = new BaseBean();
String sjbjcjidStr = baseBean.getPropValue("nbkq_main", "sjbjcjid");
String[] sjbjcjidArr = sjbjcjidStr.split(",");
List<Integer> sjbjcjidList = new ArrayList<>();
for (String idT : sjbjcjidArr) {
sjbjcjidList.add(Integer.valueOf(idT));
}
String hjsjidStr = baseBean.getPropValue("nbkq_main", "hjsjid");
String[] hjsjidArr = hjsjidStr.split(",");
List<Integer> hjsjidList = new ArrayList<>();
for (String idT : hjsjidArr) {
hjsjidList.add(Integer.valueOf(idT));
}
String sjbjcjRes = "0.0";
String hjsjRes = "0.0";
for (int i = 0; allLeaveRules != null && i < allLeaveRules.size(); i++) {
if (((!CollectionUtils.isEmpty(sjbjcjidList)) && sjbjcjidList.contains(i)) ||
((!CollectionUtils.isEmpty(hjsjidList)) && hjsjidList.contains(i))) {
leaveRule = (Map<String, Object>) allLeaveRules.get(i);
String flowType = Util.null2String("leaveType_" + leaveRule.get("id"));
String leaveData = Util.null2String(saturdayFlowLeaveData.get(id + "|" + flowType));
String flowLeaveBackType = Util.null2String("leavebackType_" + leaveRule.get("id"));
String leavebackData = Util.null2s(Util.null2String(saturdayFlowLeaveData.get(id + "|" + flowLeaveBackType)), "0.0");
String b_flowLeaveData = "";
String flowLeaveData = "";
try {
//以防止出现精度问题
if (leaveData.length() == 0) {
leaveData = "0.0";
}
if (leavebackData.length() == 0) {
leavebackData = "0.0";
}
BigDecimal b_leaveData = new BigDecimal(leaveData);
BigDecimal b_leavebackData = new BigDecimal(leavebackData);
b_flowLeaveData = b_leaveData.subtract(b_leavebackData).toString();
if (Util.getDoubleValue(b_flowLeaveData, -1) < 0) {
b_flowLeaveData = "0.0";
}
} catch (Exception e) {
writeLog("GetKQReportCmd:leaveData" + leaveData + ":leavebackData:" + leavebackData + ":" + e);
}
//考虑下冻结的数据
if (b_flowLeaveData.length() > 0) {
flowLeaveData = KQDurationCalculatorUtil.getDurationRound(b_flowLeaveData);
} else {
flowLeaveData = KQDurationCalculatorUtil.getDurationRound(Util.null2String(Util.getDoubleValue(leaveData, 0.0) - Util.getDoubleValue(leavebackData, 0.0)));
}
if (StringUtils.isEmpty(flowLeaveData)) {
flowLeaveData = "0.0";
}
if ((!CollectionUtils.isEmpty(sjbjcjidList)) && sjbjcjidList.contains(i)) {
sjbjcjRes = new BigDecimal(sjbjcjRes).add(new BigDecimal(flowLeaveData)).toString();
}
if ((!CollectionUtils.isEmpty(hjsjidList)) && hjsjidList.contains(i)) {
hjsjRes = new BigDecimal(hjsjRes).add(new BigDecimal(flowLeaveData)).toString();
}
}
}
data.put("saturdaysbcjsc", sjbjcjRes); // 周六事假病假产假时长
data.put("saturdayshjsc", hjsjRes); // 周六丧假婚假时长
//加班数据 — 取加班台账的数据
//加班不关联调休工作日加班
double workingDayOvertime_nonleave = kqReportBiz.getOverTimeCount(fromDate, toDate, id, "0", "1");
//加班不关联调休休息日加班
double restDayOvertime_nonleave = kqReportBiz.getOverTimeCount(fromDate, toDate, id, "1", "1");
//加班不关联调休节假日加班
double holidayOvertime_nonleave = kqReportBiz.getOverTimeCount(fromDate, toDate, id, "2", "1");
//加班关联调休工作日加班
double workingDayOvertime_4leave = kqReportBiz.getOverTimeCount(fromDate, toDate, id, "0", "0");
//加班关联调休休息日加班
double restDayOvertime_4leave = kqReportBiz.getOverTimeCount(fromDate, toDate, id, "1", "0");
//加班关联调休节假日加班
double holidayOvertime_4leave = kqReportBiz.getOverTimeCount(fromDate, toDate, id, "2", "0");
rs.writeLog("================ GetKQReportCmd workingDayOvertime_nonleave ============" + workingDayOvertime_nonleave);
rs.writeLog("================ GetKQReportCmd restDayOvertime_nonleave ============" + restDayOvertime_nonleave);
rs.writeLog("================ GetKQReportCmd holidayOvertime_nonleave ============" + holidayOvertime_nonleave);
rs.writeLog("================ GetKQReportCmd workingDayOvertime_4leave ============" + workingDayOvertime_4leave);
rs.writeLog("================ GetKQReportCmd restDayOvertime_4leave ============" + restDayOvertime_4leave);
rs.writeLog("================ GetKQReportCmd holidayOvertime_4leave ============" + holidayOvertime_4leave);
data.put("workingDayOvertime_nonleave", workingDayOvertime_nonleave);
data.put("restDayOvertime_nonleave", restDayOvertime_nonleave);
data.put("holidayOvertime_nonleave", holidayOvertime_nonleave);
data.put("workingDayOvertime_4leave", workingDayOvertime_4leave);
data.put("restDayOvertime_4leave", restDayOvertime_4leave);
data.put("holidayOvertime_4leave", holidayOvertime_4leave);
String totalValue = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_4leave + workingDayOvertime_nonleave));
data.put("workdayovertotal", totalValue);
totalValue = KQDurationCalculatorUtil.getDurationRound(String.valueOf(restDayOvertime_4leave + restDayOvertime_nonleave));
data.put("restdayovertotal", totalValue);
totalValue = KQDurationCalculatorUtil.getDurationRound(String.valueOf(holidayOvertime_4leave + holidayOvertime_nonleave));
data.put("holidayovertotal", totalValue);
data.put("supportTotal", rs.getString("supportTotal"));
String overtimeTotal = KQDurationCalculatorUtil.getDurationRound(String.valueOf(workingDayOvertime_4leave + restDayOvertime_4leave + holidayOvertime_4leave +
workingDayOvertime_nonleave + restDayOvertime_nonleave + holidayOvertime_nonleave));
data.put("overtimeTotal", overtimeTotal);
//夜班补贴次数
String nightSubsidy = KQDurationCalculatorUtil.getDurationRound(String.valueOf(kqReportBiz.getNightSubsidyTotal(fromDate, toDate, id)));
data.put("nightSubsidy", nightSubsidy);
//补卡次数int
String fillCard = KQDurationCalculatorUtil.getDurationRound(String.valueOf(kqReportBiz.getFillCardCount(fromDate, toDate, id)));
data.put("fillCard", fillCard);
rs.writeLog("================ GetKQReportCmd 222 data ============" + data);
Map<String, Object> detialDatas = kqReportBiz.getDetialDatas(id, fromDate, toDate, user);
// new KQLog().info("id:"+id+":detialDatas:"+detialDatas);
isEnd = false;
for (String date = fromDate; !isEnd; ) {
if (date.equals(toDate)) isEnd = true;
if (DateUtil.compDate(today, date) > 0) {
data.put(date, "");
} else {
// new KQLog().info("id:date:"+(id+"|"+date)+":detialDatas.get:"+detialDatas.get(id+"|"+date));
data.put(date, detialDatas.get(id + "|" + date) == null ? SystemEnv.getHtmlLabelName(26593, user.getLanguage()) : detialDatas.get(id + "|" + date));
}
cal.setTime(DateUtil.parseToDate(date));
date = DateUtil.getDate(cal.getTime(), 1);
}
datas.add(data);
}
List<Object> lsHolidays = KQHolidaySetBiz.getHolidaySetListByScope("" + user.getUID(), fromDate, toDate);
retmap.put("holidays", lsHolidays);
retmap.put("columns", columns);
retmap.put("datas", datas);
retmap.put("pagesize", pageSize);
retmap.put("pageindex", pageIndex);
retmap.put("count", count);
retmap.put("pagecount", pageCount);
retmap.put("ishavepre", isHavePre);
retmap.put("ishavenext", isHaveNext);
} catch (Exception e) {
writeLog(e);
}
return retmap;
}
private Map<String, Object> getChildColumnsInfo(String parentid, User user) {
Map<String, Object> returnMap = new HashMap<>();
List<Object> lsChildColumns = new ArrayList<>();
Map column = null;
int sumChildColumnWidth = 0;
if (parentid.equals("attendanceSerial")) {//考勤班次
KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo();
JSONObject jsonObj = JSON.parseObject(Util.null2String(params.get("data")));
List<String> serialIds = null;
if (Util.null2String(jsonObj.get("attendanceSerial")).length() > 0) {
serialIds = Util.splitString2List(Util.null2String(jsonObj.get("attendanceSerial")), ",");
}
for (int i = 0; serialIds != null && i < serialIds.size(); i++) {
column = new HashMap();
column.put("title", kqShiftManagementComInfo.getSerial(serialIds.get(i)));
column.put("unit", "");
column.put("width", 65);
column.put("dataIndex", serialIds.get(i));
column.put("key", serialIds.get(i));
column.put("rowSpan", 2);
column.put("colSpan", 1);
sumChildColumnWidth += 65;
lsChildColumns.add(column);
}
} else if (parentid.equals("leave")) {
KQLeaveRulesBiz kqLeaveRulesBiz = new KQLeaveRulesBiz();
List<Map<String, Object>> leaveRules = kqLeaveRulesBiz.getAllLeaveRules();
for (int i = 0; leaveRules != null && i < leaveRules.size(); i++) {
Map<String, Object> leaveRule = leaveRules.get(i);
String id = "leaveType_" + Util.null2String(leaveRule.get("id"));
String name = Util.null2String(leaveRule.get("name"));
String unitType = Util.null2String(leaveRule.get("unitType"));
column = new HashMap();
column.put("title", name);
column.put("unit", KQUnitBiz.isLeaveHour(unitType) ? SystemEnv.getHtmlLabelName(391, user.getLanguage()) : SystemEnv.getHtmlLabelName(1925, user.getLanguage()));
column.put("width", 65);
column.put("dataIndex", id);
column.put("key", id);
column.put("rowSpan", 2);
column.put("colSpan", 1);
column.put("showDetial", "1");
sumChildColumnWidth += 65;
lsChildColumns.add(column);
}
} else if (parentid.equals("overtime")) {
String[] overtimeChild = {"overtime_nonleave", "overtime_4leave", "overtimeTotal", "workdayovertotal", "restdayovertotal", "holidayovertotal"};
for (int i = 0; i < overtimeChild.length; i++) {
String id = overtimeChild[i];
column = new HashMap();
String fieldlabel = "";
column.put("unit", "");
if ("overtime_nonleave".equalsIgnoreCase(id)) {
fieldlabel = "125805";
} else if ("overtime_4leave".equalsIgnoreCase(id)) {
fieldlabel = "125804";
} else if ("workdayovertotal".equalsIgnoreCase(id)) {
fieldlabel = "1";
} else if ("restdayovertotal".equalsIgnoreCase(id)) {
fieldlabel = "2";
} else if ("holidayovertotal".equalsIgnoreCase(id)) {
fieldlabel = "3";
} else {
fieldlabel = "523";
column.put("showDetial", "1");
String unitType = (KQOvertimeRulesBiz.getMinimumUnit() == 3 || KQOvertimeRulesBiz.getMinimumUnit() == 5 || KQOvertimeRulesBiz.getMinimumUnit() == 6) ? "2" : "1";
String unitTypeName = "";
if (Util.null2String(unitType).length() > 0) {
if (unitType.equals("1")) {
unitTypeName = SystemEnv.getHtmlLabelName(1925, user.getLanguage());
} else if (unitType.equals("2")) {
unitTypeName = SystemEnv.getHtmlLabelName(391, user.getLanguage());
} else if (unitType.equals("3")) {
unitTypeName = SystemEnv.getHtmlLabelName(18083, user.getLanguage());
}
}
column.put("unit", unitTypeName);
}
column.put("title", SystemEnv.getHtmlLabelNames(fieldlabel, user.getLanguage()));
column.put("dataIndex", id);
column.put("key", id);
column.put("rowSpan", 1);
Map<String, Object> mapChildColumnInfo = getChildColumnsInfo(id, user);
int childWidth = 65;
List<Object> childColumns = (List<Object>) mapChildColumnInfo.get("childColumns");
if (childColumns.size() > 0) {//跨列width取子列的width
column.put("children", childColumns);
childWidth = Util.getIntValue(Util.null2String(mapChildColumnInfo.get("sumChildColumnWidth")), 65);
}
column.put("width", childWidth + "");
sumChildColumnWidth += childWidth;
lsChildColumns.add(column);
}
} else {
KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo();
while (kqReportFieldComInfo.next()) {
if (kqReportFieldComInfo.getParentid().equals(parentid)) {
if (!kqReportFieldComInfo.getReportType().equals("month")) continue;
column = new HashMap();
column.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage()));
column.put("unit", KQReportBiz.getUnitType(kqReportFieldComInfo, user));
column.put("width", Util.getIntValue(kqReportFieldComInfo.getWidth()));
column.put("dataIndex", kqReportFieldComInfo.getFieldname());
column.put("key", kqReportFieldComInfo.getFieldname());
column.put("rowSpan", 1);
column.put("colSpan", 1);
column.put("showDetial", kqReportFieldComInfo.getShowDetial());
sumChildColumnWidth += Util.getIntValue(kqReportFieldComInfo.getWidth());
lsChildColumns.add(column);
}
}
}
returnMap.put("childColumns", lsChildColumns);
returnMap.put("sumChildColumnWidth", sumChildColumnWidth);
return returnMap;
}
private List<Object> getCascadeKeyColumnsInfo(String cascadeKey, User user) {
List<Object> lsChildColumns = new ArrayList<>();
if (Util.null2String(cascadeKey).length() == 0) {
return lsChildColumns;
}
Map<String, Object> column = null;
List<String> lsCascadeKey = Util.splitString2List(cascadeKey, ",");
KQReportFieldComInfo kqReportFieldComInfo = new KQReportFieldComInfo();
for (int i = 0; i < lsCascadeKey.size(); i++) {
kqReportFieldComInfo.setTofirstRow();
while (kqReportFieldComInfo.next()) {
if (!kqReportFieldComInfo.getReportType().equals("month")) continue;
if (kqReportFieldComInfo.getFieldname().equals(lsCascadeKey.get(i))) {
column = new HashMap();
column.put("title", SystemEnv.getHtmlLabelNames(kqReportFieldComInfo.getFieldlabel(), user.getLanguage()));
column.put("unit", KQReportBiz.getUnitType(kqReportFieldComInfo, user));
column.put("width", Util.getIntValue(kqReportFieldComInfo.getWidth()));
column.put("dataIndex", kqReportFieldComInfo.getFieldname());
column.put("key", kqReportFieldComInfo.getFieldname());
column.put("rowSpan", 1);
column.put("colSpan", 1);
column.put("showDetial", kqReportFieldComInfo.getShowDetial());
column.put("isSystem", kqReportFieldComInfo.getIsSystem());
lsChildColumns.add(column);
}
}
}
return lsChildColumns;
}
@Override
public BizLogContext getLogContext() {
return null;
}
}

@ -0,0 +1,167 @@
package com.engine.kq.cmd.reportdetial;
import com.cloudstore.dev.api.util.Util_TableMap;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.hrm.util.HrmUtil;
import com.engine.kq.biz.KQReportBiz;
import com.engine.kq.enums.FlowReportTypeEnum;
import com.engine.kq.enums.ReportColumnEnum;
import com.engine.kq.util.PageUidFactory;
import weaver.conn.RecordSet;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import weaver.systeminfo.SystemEnv;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/***
*
*/
public class GetBeLateInfoCmd extends AbstractCommonCommand<Map<String, Object>> {
public GetBeLateInfoCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> retmap = new HashMap<String, Object>();
RecordSet rs = new RecordSet();
String sql = "";
try{
String dialogTitle = SystemEnv.getHtmlLabelName(20088, user.getLanguage());
String tabKey = Util.null2String(params.get("tabKey"));
String resourceId = Util.null2String(params.get("resourceId"));
String keyWord = Util.null2String(params.get("keyWord"));
String fromDate = Util.null2String(params.get("fromDate"));
String toDate = Util.null2String(params.get("toDate"));
String typeselect =Util.null2String(params.get("typeselect"));
if(typeselect.length()==0)typeselect = "3";
if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){
if(typeselect.equals("1")){
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
}else{
fromDate = TimeUtil.getDateByOption(typeselect,"0");
toDate = TimeUtil.getDateByOption(typeselect,"1");
}
}
String viewScope = Util.null2String(params.get("viewScope"));
String subCompanyId = Util.null2String(params.get("subCompanyId"));
String departmentId = Util.null2String(params.get("departmentId"));
String allLevel = Util.null2String(params.get("allLevel"));
String isNoAccount = Util.null2String(params.get("isNoAccount"));
String formula = Util.null2String(params.get("formula"));
String backFields = " a.id, b.resourceid,a.departmentid, a.lastname, a.workcode, a.status, a.dsporder, kqdate, serialid, serialid as serialid1," +
" workbegintime,workendtime, signintime,signouttime, beLateMins, graveBeLateMins ";
String sqlFrom = "from hrmresource a, kq_format_detail b ";
String sqlWhere = " where a.id = b.resourceid";
String orderby = " kqdate asc, workbegintime asc, a.id asc " ;
String tableString = "";
String rightSql = new KQReportBiz().getReportRight("1",""+user.getUID(),"a");
if(rightSql.length()>0){
sqlWhere += rightSql;
}
if (keyWord.length() > 0){
sqlWhere += " and lastname = "+keyWord;
}
if (fromDate.length() > 0){
sqlWhere += " and kqdate >= '"+fromDate+"'";
}
if (toDate.length() > 0){
sqlWhere += " and kqdate <= '"+toDate+"'";
}
if(subCompanyId.length()>0){
sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") ";
}
if(departmentId.length()>0){
sqlWhere +=" and a.departmentid in("+departmentId+") ";
}
if (resourceId.length() > 0){
sqlWhere += " and b.resourceid in ( "+resourceId+")";
}
if(viewScope.equals("4")){//我的下属
if(allLevel.equals("1")){//所有下属
sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'";
}else{
sqlWhere+=" and a.managerid="+user.getUID();//直接下属
}
}
if (!"1".equals(isNoAccount)) {
sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' ");
}
if(tabKey.equals("2")){
sqlWhere += " and graveBeLateMins>0 ";
}else{
sqlWhere += " and beLateMins>0 ";
}
if(formula.length()>0){
formula = formula.replace("${beLateMins}>","").replace("${beLateMins}<=","").replace("?1:0","").replace(" && ","-");
String[] tmpValue = Util.splitString(formula,"-");
sqlWhere += " and beLateMins>"+tmpValue[0]+" and beLateMins<= "+tmpValue[1];
}
// #1475814-概述:满足考勤报分部部门显示及导出时显示全路径需求
String transMethodString = HrmUtil.getKqDepartmentTransMethod();
String pageUid = PageUidFactory.getHrmPageUid("KQReportDetialList");
tableString=""+
"<table pageUid=\""+pageUid+"\" pagesize=\"10\" tabletype=\"none\">"+
"<sql backfields=\""+backFields+"\" sqlform=\""+Util.toHtmlForSplitPage(sqlFrom)+"\" sqlprimarykey=\"b.id\" sqlorderby=\""+orderby+"\" sqlsortway=\"asc\" sqldistinct=\"true\" sqlwhere=\""+Util.toHtmlForSplitPage(sqlWhere)+"\"/>"+
"<head>"+
" <col width=\"10%\" text=\""+SystemEnv.getHtmlLabelName(413,user.getLanguage())+"\" column=\"lastname\" orderkey=\"lastname\"/>"+
" <col width=\"10%\" text=\""+SystemEnv.getHtmlLabelName(714,user.getLanguage())+"\" column=\"workcode\" orderkey=\"workcode\"/>"+
" <col width=\"15%\" text=\""+SystemEnv.getHtmlLabelName(124,user.getLanguage())+"\" column=\"departmentid\" orderkey=\"departmentid\" transmethod=\""+transMethodString+"\"/>"+
" <col width=\"10%\" text=\""+SystemEnv.getHtmlLabelName(602,user.getLanguage())+"\" column=\"status\" orderkey=\"status\" transmethod=\"weaver.hrm.resource.ResourceComInfo.getStatusName\" otherpara=\""+user.getLanguage()+"\"/>"+
" <col width=\"15%\" text=\""+SystemEnv.getHtmlLabelName(97,user.getLanguage())+"\" column=\"kqdate\" orderkey=\"kqdate\"/>"+
" <col width=\"20%\" text=\""+SystemEnv.getHtmlLabelName(390054,user.getLanguage())+"\" column=\"serialid\" orderkey=\"serialid\" transmethod=\"com.engine.kq.util.TransMethod.getSerailName\" otherpara=\"column:workbegintime+column:workendtime\"/>"+
" <col width=\"10%\" text=\""+SystemEnv.getHtmlLabelName(18949,user.getLanguage())+"\" column=\"serialid1\" orderkey=\"serialid1\" transmethod=\"com.engine.kq.util.TransMethod.getReportDetialSignTime\" otherpara=\"column:signintime++column:kqdate+column:resourceid+"+user.getLanguage()+"\"/>";
if(tabKey.equals("2")){
tableString += " <col width=\"10%\" text=\""+SystemEnv.getHtmlLabelName(391413,user.getLanguage())+"\" column=\"graveBeLateMins\" orderkey=\"graveBeLateMins\"/>";
}else{
tableString += " <col width=\"10%\" text=\""+SystemEnv.getHtmlLabelName(391413,user.getLanguage())+"\" column=\"beLateMins\" orderkey=\"beLateMins\"/>";
}
tableString += "</head>"+
"</table>";
//主要用于 显示定制列以及 表格 每页展示记录数选择
String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom());
Util_TableMap.setVal(sessionkey, tableString);
retmap.put("dialogTitle",dialogTitle);
retmap.put("sessionkey", sessionkey);
retmap.put("status", "1");
}catch (Exception e) {
retmap.put("status", "-1");
retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage()));
writeLog(e);
}
return retmap;
}
@Override
public BizLogContext getLogContext() {
return null;
}
}

@ -0,0 +1,167 @@
package com.engine.kq.cmd.reportdetial;
import com.cloudstore.dev.api.util.Util_TableMap;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.hrm.util.HrmUtil;
import com.engine.kq.biz.KQReportBiz;
import com.engine.kq.enums.FlowReportTypeEnum;
import com.engine.kq.enums.ReportColumnEnum;
import com.engine.kq.util.PageUidFactory;
import weaver.conn.RecordSet;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import weaver.systeminfo.SystemEnv;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/***
* 退
*/
public class GetLeaveEearlyInfoCmd extends AbstractCommonCommand<Map<String, Object>> {
public GetLeaveEearlyInfoCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> retmap = new HashMap<String, Object>();
RecordSet rs = new RecordSet();
String sql = "";
try{
String dialogTitle = SystemEnv.getHtmlLabelName(20089, user.getLanguage());
String tabKey = Util.null2String(params.get("tabKey"));
String resourceId = Util.null2String(params.get("resourceId"));
String keyWord = Util.null2String(params.get("keyWord"));
String fromDate = Util.null2String(params.get("fromDate"));
String toDate = Util.null2String(params.get("toDate"));
String typeselect =Util.null2String(params.get("typeselect"));
if(typeselect.length()==0)typeselect = "3";
if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){
if(typeselect.equals("1")){
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
}else{
fromDate = TimeUtil.getDateByOption(typeselect,"0");
toDate = TimeUtil.getDateByOption(typeselect,"1");
}
}
String viewScope = Util.null2String(params.get("viewScope"));
String subCompanyId = Util.null2String(params.get("subCompanyId"));
String departmentId = Util.null2String(params.get("departmentId"));
String allLevel = Util.null2String(params.get("allLevel"));
String isNoAccount = Util.null2String(params.get("isNoAccount"));
String formula = Util.null2String(params.get("formula"));
String backFields = " a.id, b.resourceid,a.departmentid, a.lastname, a.workcode, a.status, a.dsporder, kqdate, serialid, serialid as serialid1," +
" workbegintime,workendtime, signintime,signouttime, leaveEarlyMins, graveLeaveEarlyMins ";
String sqlFrom = "from hrmresource a, kq_format_detail b ";
String sqlWhere = " where a.id = b.resourceid";
String orderby = " kqdate asc, workbegintime asc " ;
String tableString = "";
String rightSql = new KQReportBiz().getReportRight("1",""+user.getUID(),"a");
if(rightSql.length()>0){
sqlWhere += rightSql;
}
if (keyWord.length() > 0){
sqlWhere += " and lastname = "+keyWord;
}
if (fromDate.length() > 0){
sqlWhere += " and kqdate >= '"+fromDate+"'";
}
if (toDate.length() > 0){
sqlWhere += " and kqdate <= '"+toDate+"'";
}
if(subCompanyId.length()>0){
sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") ";
}
if(departmentId.length()>0){
sqlWhere +=" and a.departmentid in("+departmentId+") ";
}
if (resourceId.length() > 0){
sqlWhere += " and b.resourceid in ( "+resourceId+")";
}
if(viewScope.equals("4")){//我的下属
if(allLevel.equals("1")){//所有下属
sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'";
}else{
sqlWhere+=" and a.managerid="+user.getUID();//直接下属
}
}
if (!"1".equals(isNoAccount)) {
sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' ");
}
if(tabKey.equals("2")){
sqlWhere += " and graveLeaveEarlyMins>0 ";
}else{
sqlWhere += " and leaveEarlyMins>0 ";
}
if(formula.length()>0){
formula = formula.replace("${leaveEarlyMins}>","").replace("${leaveEarlyMins}<=","").replace("?1:0","").replace(" && ","-");
String[] tmpValue = Util.splitString(formula,"-");
sqlWhere += " and leaveEarlyMins>"+tmpValue[0]+" and leaveEarlyMins<= "+tmpValue[1];
}
// #1475814-概述:满足考勤报分部部门显示及导出时显示全路径需求
String transMethodString = HrmUtil.getKqDepartmentTransMethod();
String pageUid = PageUidFactory.getHrmPageUid("KQReportDetialList");
tableString=""+
"<table pageUid=\""+pageUid+"\" pagesize=\"10\" tabletype=\"none\">"+
"<sql backfields=\""+backFields+"\" sqlform=\""+Util.toHtmlForSplitPage(sqlFrom)+"\" sqlprimarykey=\"b.id\" sqlorderby=\""+orderby+"\" sqlsortway=\"asc\" sqldistinct=\"true\" sqlwhere=\""+Util.toHtmlForSplitPage(sqlWhere)+"\"/>"+
"<head>"+
" <col width=\"10%\" text=\""+SystemEnv.getHtmlLabelName(413,user.getLanguage())+"\" column=\"lastname\" orderkey=\"lastname\"/>"+
" <col width=\"10%\" text=\""+SystemEnv.getHtmlLabelName(714,user.getLanguage())+"\" column=\"workcode\" orderkey=\"workcode\"/>"+
" <col width=\"15%\" text=\""+SystemEnv.getHtmlLabelName(124,user.getLanguage())+"\" column=\"departmentid\" orderkey=\"departmentid\" transmethod=\""+transMethodString+"\"/>"+
" <col width=\"10%\" text=\""+SystemEnv.getHtmlLabelName(602,user.getLanguage())+"\" column=\"status\" orderkey=\"status\" transmethod=\"weaver.hrm.resource.ResourceComInfo.getStatusName\" otherpara=\""+user.getLanguage()+"\"/>"+
" <col width=\"15%\" text=\""+SystemEnv.getHtmlLabelName(97,user.getLanguage())+"\" column=\"kqdate\" orderkey=\"kqdate\"/>"+
" <col width=\"20%\" text=\""+SystemEnv.getHtmlLabelName(390054,user.getLanguage())+"\" column=\"serialid\" orderkey=\"serialid\" transmethod=\"com.engine.kq.util.TransMethod.getSerailName\" otherpara=\"column:workbegintime+column:workendtime\"/>"+
" <col width=\"10%\" text=\""+SystemEnv.getHtmlLabelName(18949,user.getLanguage())+"\" column=\"serialid1\" orderkey=\"serialid1\" transmethod=\"com.engine.kq.util.TransMethod.getReportDetialSignTime\" otherpara=\"+column:signouttime+column:kqdate+column:resourceid+"+user.getLanguage()+"\"/>";
if(tabKey.equals("2")){
tableString += " <col width=\"10%\" text=\""+SystemEnv.getHtmlLabelName(391414,user.getLanguage())+"\" column=\"graveLeaveEarlyMins\" orderkey=\"graveLeaveEarlyMins\" />";
}else{
tableString += " <col width=\"10%\" text=\""+SystemEnv.getHtmlLabelName(391414,user.getLanguage())+"\" column=\"leaveEarlyMins\" orderkey=\"leaveEarlyMins\" />";
}
tableString += "</head>"+
"</table>";
//主要用于 显示定制列以及 表格 每页展示记录数选择
String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom());
Util_TableMap.setVal(sessionkey, tableString);
retmap.put("dialogTitle",dialogTitle);
retmap.put("sessionkey", sessionkey);
retmap.put("status", "1");
}catch (Exception e) {
retmap.put("status", "-1");
retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage()));
writeLog(e);
}
return retmap;
}
@Override
public BizLogContext getLogContext() {
return null;
}
}

@ -0,0 +1,146 @@
package com.engine.kq.cmd.reportdetial;
import com.cloudstore.dev.api.util.Util_TableMap;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.hrm.util.HrmUtil;
import com.engine.kq.biz.KQReportBiz;
import com.engine.kq.enums.FlowReportTypeEnum;
import com.engine.kq.enums.ReportColumnEnum;
import com.engine.kq.util.PageUidFactory;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import weaver.systeminfo.SystemEnv;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/***
*
*/
public class GetWorkDayInfoCmd extends AbstractCommonCommand<Map<String, Object>> {
public GetWorkDayInfoCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> retmap = new HashMap<String, Object>();
RecordSet rs = new RecordSet();
String sql = "";
try{
String dialogTitle = SystemEnv.getHtmlLabelName(390956,user.getLanguage());
String resourceId = Util.null2String(params.get("resourceId"));
String keyWord = Util.null2String(params.get("keyWord"));
String fromDate = Util.null2String(params.get("fromDate"));
String toDate = Util.null2String(params.get("toDate"));
String typeselect =Util.null2String(params.get("typeselect"));
if(typeselect.length()==0)typeselect = "3";
if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){
if(typeselect.equals("1")){
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
}else{
fromDate = TimeUtil.getDateByOption(typeselect,"0");
toDate = TimeUtil.getDateByOption(typeselect,"1");
}
}
String viewScope = Util.null2String(params.get("viewScope"));
String subCompanyId = Util.null2String(params.get("subCompanyId"));
String departmentId = Util.null2String(params.get("departmentId"));
String allLevel = Util.null2String(params.get("allLevel"));
String isNoAccount = Util.null2String(params.get("isNoAccount"));
String backFields = " a.id, b.resourceid,a.departmentid, a.lastname, a.workcode, a.status, a.dsporder, kqdate, " +
" serialid, workmins, workbegintime,workendtime ";
String sqlFrom = "from hrmresource a, kq_format_detail b,kq_ShiftManagement c ";
String sqlWhere = " where a.id = b.resourceid and workmins>0 and b.serialid=c.id and (c.rest_shift is null or c.rest_shift=0) ";
String orderby = " kqdate asc, workbegintime asc " ;
String tableString = "";
String rightSql = new KQReportBiz().getReportRight("1",""+user.getUID(),"a");
if(rightSql.length()>0){
sqlWhere += rightSql;
}
if (keyWord.length() > 0){
sqlWhere += " and lastname = "+keyWord;
}
if (fromDate.length() > 0){
sqlWhere += " and kqdate >= '"+fromDate+"'";
}
if (toDate.length() > 0){
sqlWhere += " and kqdate <= '"+toDate+"'";
}
if(subCompanyId.length()>0){
sqlWhere +=" and a.subcompanyid1 in("+subCompanyId+") ";
}
if(departmentId.length()>0){
sqlWhere +=" and a.departmentid in("+departmentId+") ";
}
if (resourceId.length() > 0){
sqlWhere += " and b.resourceid in ( "+resourceId+")";
}
if(viewScope.equals("4")){//我的下属
if(allLevel.equals("1")){//所有下属
sqlWhere+=" and a.managerstr like '%,"+user.getUID()+",%'";
}else{
sqlWhere+=" and a.managerid="+user.getUID();//直接下属
}
}
if (!"1".equals(isNoAccount)) {
sqlWhere += " and a.loginid is not null "+(rs.getDBType().equals("oracle")?"":" and a.loginid<>'' ");
}
// #1475814-概述:满足考勤报分部部门显示及导出时显示全路径需求
String transMethodString = HrmUtil.getKqDepartmentTransMethod();
String pageUid = PageUidFactory.getHrmPageUid("KQReportDetialList");
tableString=""+
"<table pageUid=\""+pageUid+"\" pagesize=\"10\" tabletype=\"none\">"+
"<sql backfields=\""+backFields+"\" sqlform=\""+Util.toHtmlForSplitPage(sqlFrom)+"\" sqlprimarykey=\"b.id\" sqlorderby=\""+orderby+"\" sqlsortway=\"asc\" sqldistinct=\"true\" sqlwhere=\""+Util.toHtmlForSplitPage(sqlWhere)+"\"/>"+
"<head>"+
" <col width=\"15%\" text=\""+SystemEnv.getHtmlLabelName(413,user.getLanguage())+"\" column=\"lastname\" orderkey=\"lastname\"/>"+
" <col width=\"15%\" text=\""+SystemEnv.getHtmlLabelName(714,user.getLanguage())+"\" column=\"workcode\" orderkey=\"workcode\"/>"+
" <col width=\"20%\" text=\""+SystemEnv.getHtmlLabelName(124,user.getLanguage())+"\" column=\"departmentid\" orderkey=\"departmentid\" transmethod=\""+transMethodString+"\"/>"+
" <col width=\"15%\" text=\""+SystemEnv.getHtmlLabelName(602,user.getLanguage())+"\" column=\"status\" orderkey=\"status\" transmethod=\"weaver.hrm.resource.ResourceComInfo.getStatusName\" otherpara=\""+user.getLanguage()+"\"/>"+
" <col width=\"15%\" text=\""+SystemEnv.getHtmlLabelName(97,user.getLanguage())+"\" column=\"kqdate\" orderkey=\"kqdate\"/>"+
" <col width=\"25%\" text=\""+SystemEnv.getHtmlLabelName(390054,user.getLanguage())+"\" column=\"serialid\" orderkey=\"serialid\" transmethod=\"com.engine.kq.util.TransMethod.getSerailName\" otherpara=\"column:workbegintime+column:workendtime\"/>"+
" <col width=\"15%\" text=\""+SystemEnv.getHtmlLabelName(132055,user.getLanguage())+"\" column=\"workmins\" orderkey=\"workmins\" transmethod=\"com.engine.kq.util.TransMethod.getReportDetialMinToHour\"/>"+
"</head>"+
"</table>";
//主要用于 显示定制列以及 表格 每页展示记录数选择
String sessionkey = pageUid + "_" + Util.getEncrypt(Util.getRandom());
Util_TableMap.setVal(sessionkey, tableString);
retmap.put("dialogTitle",dialogTitle);
retmap.put("sessionkey", sessionkey);
retmap.put("status", "1");
}catch (Exception e) {
retmap.put("status", "-1");
retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage()));
writeLog(e);
}
return retmap;
}
@Override
public BizLogContext getLogContext() {
return null;
}
}

@ -0,0 +1,136 @@
package com.engine.kq.entity;
import java.util.List;
import java.util.Map;
/***
*
*/
public class WorkTimeEntity {
private String groupId;//所属考勤组
private String groupName;//所属考勤组
private String kqType;//考勤类型
private String serialId;//班次
private Map<String,Object> shiftRuleInfo;//班次人性化规则
private List<TimeScopeEntity> signTime;//允许打卡时间
private List<TimeScopeEntity> workTime;//工作时间
private List<TimeScopeEntity> restTime;//休息时间
private int workMins;//工作时长
private String isAcross;//是否跨天
private String signstart;//自由工时开始打卡时间
private boolean isExclude;//无需考勤人员
private String calmethod;//自由班制计算方式
private int restShift;
public String getGroupId() {
return groupId;
}
public void setGroupId(String groupId) {
this.groupId = groupId;
}
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
public String getKQType() {
return kqType;
}
public void setKQType(String kqType) {
this.kqType = kqType;
}
public String getSerialId() {
return serialId;
}
public void setSerialId(String serialId) {
this.serialId = serialId;
}
public Map<String, Object> getShiftRuleInfo() {
return shiftRuleInfo;
}
public void setShiftRuleInfo(Map<String, Object> shiftRuleInfo) {
this.shiftRuleInfo = shiftRuleInfo;
}
public List<TimeScopeEntity> getWorkTime() {
return workTime;
}
public void setWorkTime(List<TimeScopeEntity> workTime) {
this.workTime = workTime;
}
public List<TimeScopeEntity> getRestTime() {
return restTime;
}
public void setRestTime(List<TimeScopeEntity> restTime) {
this.restTime = restTime;
}
public int getWorkMins() {
return workMins;
}
public void setWorkMins(int workMins) {
this.workMins = workMins;
}
public String getIsAcross() {
return isAcross;
}
public void setIsAcross(String isAcross) {
this.isAcross = isAcross;
}
public String getSignStart() {
return signstart;
}
public void setSignStart(String signstart) {
this.signstart = signstart;
}
public List<TimeScopeEntity> getSignTime() {
return signTime;
}
public void setSignTime(List<TimeScopeEntity> signTime) {
this.signTime = signTime;
}
public boolean getIsExclude() {
return isExclude;
}
public void setIsExclude(boolean isExclude) {
this.isExclude = isExclude;
}
public String getCalmethod() {
return calmethod;
}
public void setCalmethod(String calmethod) {
this.calmethod = calmethod;
}
public int getRestShift() {
return restShift;
}
public void setRestShift(int restShift) {
this.restShift = restShift;
}
}

@ -0,0 +1,54 @@
package com.engine.kq.service.impl;
import com.engine.core.impl.Service;
import com.engine.kq.cmd.reportdetial.*;
import com.engine.kq.service.KQReportDetailService;
import weaver.hrm.User;
import java.util.Map;
public class KQReportDetailServiceImpl extends Service implements KQReportDetailService {
@Override
public Map<String, Object> getTabs(Map<String, Object> params, User user) {
return commandExecutor.execute(new GetTabsCmd(params, user));
}
@Override
public Map<String, Object> getWorkDayInfo(Map<String, Object> params, User user) {
return commandExecutor.execute(new GetWorkDayInfoCmd(params, user));
}
@Override
public Map<String, Object> getSignInfo(Map<String, Object> params, User user) {
return commandExecutor.execute(new GetSignInfoCmd(params, user));
}
@Override
public Map<String, Object> getBeLateInfo(Map<String, Object> params, User user) {
return commandExecutor.execute(new GetBeLateInfoCmd(params, user));
}
@Override
public Map<String, Object> getLeaveEearlyInfo(Map<String, Object> params, User user) {
return commandExecutor.execute(new GetLeaveEearlyInfoCmd(params, user));
}
@Override
public Map<String, Object> getAbsenteeismInfo(Map<String, Object> params, User user) {
return commandExecutor.execute(new GetAbsenteeismInfoCmd(params, user));
}
@Override
public Map<String, Object> getForgotCheckInfo(Map<String, Object> params, User user) {
return commandExecutor.execute(new GetForgotCheckInfoCmd(params, user));
}
@Override
public Map<String, Object> getLeaveInfo(Map<String, Object> params, User user) {
return commandExecutor.execute(new GetLeaveInfoCmd(params, user));
}
@Override
public Map<String, Object> getDailyDetialInfo(Map<String, Object> params, User user) {
return commandExecutor.execute(new GetDailyDetialInfoCmd(params, user));
}
}

@ -0,0 +1,652 @@
package com.engine.kq.util;
import com.engine.kq.biz.KQLeaveRulesBiz;
import com.engine.kq.biz.KQLeaveRulesComInfo;
import com.engine.kq.biz.KQShiftManagementComInfo;
import com.engine.kq.biz.KQWorkTime;
import com.engine.kq.biz.chain.cominfo.ShiftInfoCominfoBean;
import com.engine.kq.biz.chain.duration.NonDayUnitSplitChain;
import com.engine.kq.biz.chain.duration.NonHalfUnitSplitChain;
import com.engine.kq.biz.chain.duration.NonHourUnitSplitChain;
import com.engine.kq.biz.chain.duration.NonWholeUnitSplitChain;
import com.engine.kq.biz.chain.duration.NonWorkDurationChain;
import com.engine.kq.biz.chain.duration.WorkDayUnitSplitChain;
import com.engine.kq.biz.chain.duration.WorkDurationChain;
import com.engine.kq.biz.chain.duration.WorkHalfUnitSplitChain;
import com.engine.kq.biz.chain.duration.WorkHourUnitSplitChain;
import com.engine.kq.biz.chain.duration.WorkWholeUnitSplitChain;
import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean;
import com.engine.kq.enums.DurationTypeEnum;
import com.engine.kq.log.KQLog;
import com.engine.kq.wfset.bean.SplitBean;
import com.engine.kq.wfset.util.KQFlowUtil;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import weaver.common.StringUtil;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.hrm.report.schedulediff.HrmScheduleDiffUtil;
public class KQDurationCalculatorUtil extends BaseBean {
private KQLog kqLog = new KQLog();
private final String resourceid;
private String fromDate;
private String toDate;
private String fromTime;
private String toTime;
private String newLeaveType;
/**
*
* 1-
* 2-
* 3-
* 4-
*/
private String durationrule;
/**
* 1-
* 2-
*/
private String computingMode;
/**
*
*/
private String overtime_type;
private DurationTypeEnum durationTypeEnum;
//外部类的构造函数
private KQDurationCalculatorUtil(DurationParamBuilder build) {
this.resourceid = build.resourceid;
this.fromDate = build.fromDate;
this.toDate = build.toDate;
this.fromTime = build.fromTime;
this.toTime = build.toTime;
this.newLeaveType = build.newLeaveType;
this.durationrule = build.durationrule;
this.computingMode = build.computingMode;
this.durationTypeEnum = build.durationTypeEnum;
this.overtime_type = build.overtime_type;
}
/**
*
*
* @param resourceid
* @param date
* @param containYesterday
* @return
*/
public static ShiftInfoBean getWorkTime(String resourceid, String date, boolean containYesterday) {
User user = User.getUser(Util.getIntValue(resourceid), 0);
if (user == null) {
return null;
}
return getWorkTime(user, date, containYesterday);
}
public static ShiftInfoBean getWorkTimeNew(String resourceid, String date, boolean containYesterday) {
User user = User.getUser(Util.getIntValue(resourceid), 0);
if (user == null) {
return null;
}
return getWorkTime(user, date, containYesterday, true, false);
}
/**
*
*
* @param resourceid
* @param date
* @param containYesterday
* @param isLog
* @return
*/
public static ShiftInfoBean getWorkTime(String resourceid, String date, boolean containYesterday, boolean isLog) {
User user = User.getUser(Util.getIntValue(resourceid), 0);
if (user == null) {
return null;
}
return getWorkTime(user, date, containYesterday, isLog);
}
public static ShiftInfoCominfoBean getShiftInfoCominfoBean(String resourceid, String date) {
KQWorkTime kqWorkTime = new KQWorkTime();
Map<String, Object> kqWorkTimeMap = new HashMap<>();
ShiftInfoCominfoBean shiftInfoCominfoBean = kqWorkTime.getShiftInfoCominfoBean(resourceid, date);
return shiftInfoCominfoBean;
}
/**
* user
*
* @param user
* @param date
* @param containYesterday
* @param isLog
* @return
*/
public static ShiftInfoBean getWorkTime(User user, String date, boolean containYesterday, boolean isLog) {
return getWorkTime(user, date, containYesterday, isLog, true);
}
public static ShiftInfoBean getWorkTime(User user, String date, boolean containYesterday, boolean isLog, boolean isUsedRestShift) {
KQWorkTime kqWorkTime = new KQWorkTime();
Map<String, Object> kqWorkTimeMap = new HashMap<>();
kqWorkTimeMap = kqWorkTime.getWorkDuration("" + user.getUID(), date, containYesterday, isLog);
boolean isfree = "1".equalsIgnoreCase(Util.null2String(kqWorkTimeMap.get("isfree")));
if (isfree) {
ShiftInfoBean shiftInfoBean = new ShiftInfoBean();
shiftInfoBean.setIsfree(true);
String signStart = Util.null2String(kqWorkTimeMap.get("signStart"));
String workMins = Util.null2String(kqWorkTimeMap.get("workMins"));
shiftInfoBean.setFreeSignStart(signStart);
shiftInfoBean.setFreeWorkMins(workMins);
shiftInfoBean.setSplitDate(date);
if (signStart.length() > 0 && workMins.length() > 0) {
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm");
LocalTime signLocalTime = LocalTime.parse(signStart, dateTimeFormatter);
shiftInfoBean.setFreeSignEnd(signLocalTime.plusMinutes(Util.getIntValue(workMins)).format(dateTimeFormatter));
shiftInfoBean.setFreeSignMiddle(signLocalTime.plusMinutes(Util.getIntValue(workMins) / 2).format(dateTimeFormatter));
}
return shiftInfoBean;
} else {
if (kqWorkTimeMap.get("shiftInfoBean") != null) {
ShiftInfoBean shiftInfoBean = (ShiftInfoBean) kqWorkTimeMap.get("shiftInfoBean");
if (isUsedRestShift) {
int serialid = Util.getIntValue(Util.null2String(shiftInfoBean.getSerialid()), 0);
KQShiftManagementComInfo kQShiftManagementComInfo = new KQShiftManagementComInfo();
int restShift = StringUtil.parseToInt(kQShiftManagementComInfo.getRestShift(String.valueOf(serialid)), 0);
if (restShift == 1) {
return null;
}
}
return shiftInfoBean;
} else {
return null;
}
}
}
/**
* user
*
* @param user
* @param date
* @param containYesterday
* @return
*/
public static ShiftInfoBean getWorkTime(User user, String date, boolean containYesterday) {
return getWorkTime(user, date, containYesterday, true);
}
public static Map<String, Object> getWorkButton(String resourceid, String date, boolean containYesterday) {
User user = User.getUser(Util.getIntValue(resourceid), 0);
return getWorkButton(user, date, containYesterday);
}
public static Map<String, Object> getWorkButton(User user, String date, boolean containYesterday) {
KQWorkTime kqWorkTime = new KQWorkTime();
Map<String, Object> kqWorkTimeMap = new HashMap<>();
kqWorkTimeMap = kqWorkTime.getWorkButton("" + user.getUID(), date, containYesterday);
return kqWorkTimeMap;
}
/**
*
*
* @return
*/
public Map<String, Object> getNonWorkDuration() {
Map<String, Object> durationMap = new HashMap<>();
try {
double D_Duration = 0.0;
double Min_Duration = 0.0;
//公众假日加班时长
double D_Pub_Duration = 0.0;
double D_Pub_Mins = 0.0;
//工作日加班时长
double D_Work_Duration = 0.0;
double D_Work_Mins = 0.0;
//休息日加班时长
double D_Rest_Duration = 0.0;
double D_Rest_Mins = 0.0;
SplitBean splitBean = new SplitBean();
splitBean.setFromDate(fromDate);
splitBean.setFromTime(fromTime);
splitBean.setToDate(toDate);
splitBean.setToTime(toTime);
splitBean.setResourceId(resourceid);
splitBean.setFromdatedb(fromDate);
splitBean.setTodatedb(toDate);
splitBean.setFromtimedb(fromTime);
splitBean.setTotimedb(toTime);
splitBean.setDurationrule(durationrule);
splitBean.setComputingMode(computingMode);
splitBean.setDurationTypeEnum(DurationTypeEnum.OVERTIME);
splitBean.setOvertime_type(overtime_type);
List<SplitBean> splitBeans = new ArrayList<>();
NonWorkDurationChain hourUnitSplitChain = new NonHourUnitSplitChain(splitBeans);
NonWorkDurationChain dayUnitSplitChain = new NonDayUnitSplitChain(splitBeans);
NonWorkDurationChain halfUnitSplitChain = new NonHalfUnitSplitChain(splitBeans);
NonWorkDurationChain wholeUnitSplitChain = new NonWholeUnitSplitChain(splitBeans);
//设置执行链
hourUnitSplitChain.setDurationChain(dayUnitSplitChain);
dayUnitSplitChain.setDurationChain(halfUnitSplitChain);
halfUnitSplitChain.setDurationChain(wholeUnitSplitChain);
//把初始数据设置进去
hourUnitSplitChain.handleDuration(splitBean);
//每一天的流程时长都在这里了,搞吧
for (SplitBean sb : splitBeans) {
// * 1-公众假日、2-工作日、3-休息日
int changeType = sb.getChangeType();
double durations = Util.getDoubleValue(sb.getDuration(), 0.0);
double durationMins = sb.getD_Mins();
if (1 == changeType) {
D_Pub_Duration += durations;
D_Pub_Mins += durationMins;
}
if (2 == changeType) {
D_Work_Duration += durations;
D_Work_Mins += durationMins;
}
if (3 == changeType) {
D_Rest_Duration += durations;
D_Rest_Mins += durationMins;
}
}
Min_Duration = D_Pub_Mins + D_Work_Mins + D_Rest_Mins;
if ("3".equalsIgnoreCase(durationrule) || "5".equalsIgnoreCase(durationrule) || "6".equalsIgnoreCase(durationrule)) {
double d_hour = Min_Duration / 60.0;
durationMap.put("duration", KQDurationCalculatorUtil.getDurationRound("" + d_hour));
} else {
double oneDayHour = KQFlowUtil.getOneDayHour(DurationTypeEnum.OVERTIME, "");
double d_day = Min_Duration / (oneDayHour * 60);
durationMap.put("duration", KQDurationCalculatorUtil.getDurationRound("" + d_day));
}
durationMap.put("min_duration", KQDurationCalculatorUtil.getDurationRound("" + Min_Duration));
} catch (Exception e) {
e.printStackTrace();
}
return durationMap;
}
/**
*
*
* @return
*/
public Map<String, Object> getWorkDuration() {
writeLog("KQDurationCalculatorUtil-getWorkDuration");
Map<String, Object> durationMap = new HashMap<>();
try {
if (!isValidate(fromDate, toDate, fromTime, toTime)) {
durationMap.put("duration", "0.0");
return durationMap;
}
if (durationTypeEnum != DurationTypeEnum.COMMON_CAL) {
kqLog.info("getWorkDuration:" + durationTypeEnum.getDurationType() + ":fromDate:" + fromDate + ":toDate:" + toDate + ":fromTime:" + fromTime + ":toTime:" + toTime + ":durationrule:" + durationrule + ":computingMode:" + computingMode);
}
//如果是加班
if (durationTypeEnum == DurationTypeEnum.OVERTIME) {
return getNonWorkDuration();
}
//时长
double D_Duration = 0.0;
//分钟数
double Min_Duration = 0.0;
SplitBean splitBean = new SplitBean();
splitBean.setFromDate(fromDate);
splitBean.setFromTime(fromTime);
splitBean.setToDate(toDate);
splitBean.setToTime(toTime);
splitBean.setResourceId(resourceid);
splitBean.setFromdatedb(fromDate);
splitBean.setTodatedb(toDate);
splitBean.setFromtimedb(fromTime);
splitBean.setTotimedb(toTime);
splitBean.setDurationrule(durationrule);
splitBean.setDurationTypeEnum(durationTypeEnum);
splitBean.setComputingMode(computingMode);
splitBean.setNewLeaveType(newLeaveType);
writeLog("getWorkDuration-" + splitBean);
if ("2".equalsIgnoreCase(computingMode)) {
double oneDayHour = KQFlowUtil.getOneDayHour(durationTypeEnum, newLeaveType);
splitBean.setOneDayHour(oneDayHour);
if (durationTypeEnum == DurationTypeEnum.LEAVE) {
//只有自然日 请假才有这个排除节假日、休息日的功能
splitBean.setFilterholidays(KQLeaveRulesBiz.getFilterHolidays(splitBean.getNewLeaveType()));
}
}
if (durationTypeEnum == DurationTypeEnum.LEAVE || durationTypeEnum == DurationTypeEnum.LEAVEBACK) {
if (newLeaveType.length() > 0) {
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
String conversion = kqLeaveRulesComInfo.getConversion(newLeaveType);
splitBean.setConversion(conversion);
}
}
List<SplitBean> splitBeans = new ArrayList<>();
WorkDurationChain hourUnitSplitChain = new WorkHourUnitSplitChain(splitBeans);
WorkDurationChain dayUnitSplitChain = new WorkDayUnitSplitChain(splitBeans);
WorkDurationChain halfUnitSplitChain = new WorkHalfUnitSplitChain(splitBeans);
WorkDurationChain wholeUnitSplitChain = new WorkWholeUnitSplitChain(splitBeans);
//设置执行链
hourUnitSplitChain.setDurationChain(dayUnitSplitChain);
dayUnitSplitChain.setDurationChain(halfUnitSplitChain);
halfUnitSplitChain.setDurationChain(wholeUnitSplitChain);
//把初始数据设置进去
hourUnitSplitChain.handleDuration(splitBean);
//每一天的流程时长都在这里了,搞吧
for (SplitBean sb : splitBeans) {
double durations = Util.getDoubleValue(sb.getDuration(), 0.0);
double min_durations = sb.getD_Mins();
D_Duration += durations;
Min_Duration += min_durations;
}
durationMap.put("duration", KQDurationCalculatorUtil.getDurationRound("" + D_Duration));
durationMap.put("min_duration", KQDurationCalculatorUtil.getDurationRound("" + Min_Duration));
} catch (Exception e) {
e.printStackTrace();
}
return durationMap;
}
/**
*
*
* @return false
*/
private boolean isValidate(String fromDate, String toDate, String fromTime, String toTime) {
if (fromDate.length() == 0 || toDate.length() == 0) {
return false;
}
if (fromTime.length() == 0 || toTime.length() == 0) {
return false;
}
DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String fromDateTime = fromDate + " " + fromTime + ":00";
String toDateTime = toDate + " " + toTime + ":00";
LocalDateTime localFromDateTime = LocalDateTime.parse(fromDateTime, fullFormatter);
LocalDateTime localToDateTime = LocalDateTime.parse(toDateTime, fullFormatter);
if (localFromDateTime.isAfter(localToDateTime) || localFromDateTime.isEqual(localToDateTime)) {
return false;
}
return true;
}
/**
*
*
* @param fromDate
* @param fromTime
* @param toDate
* @param toTime
* @param resourceid
* @return
*/
public Map<String, Object> getTotalWorkingDurations(String fromDate, String fromTime, String toDate, String toTime, String resourceid) {
KQDurationCalculatorUtil kqDurationCalculatorUtil = new DurationParamBuilder(resourceid).
fromDateParam(fromDate).toDateParam(toDate).fromTimeParam(fromTime).toTimeParam(toTime).durationRuleParam("1")
.computingModeParam("1").durationTypeEnumParam(DurationTypeEnum.COMMON_CAL).build();
Map<String, Object> durationMap = kqDurationCalculatorUtil.getWorkDuration();
return durationMap;
}
/**
*
*
* @param fromDate
* @param fromTime
* @param toDate
* @param toTime
* @param resourceid
* @return
*/
public String getTotalWorkingDays(String fromDate, String fromTime, String toDate, String toTime, String resourceid) {
Map<String, Object> durationMap = getTotalWorkingDurations(fromDate, fromTime, toDate, toTime, resourceid);
String duration4day = Util.null2s(Util.null2String(durationMap.get("duration")), "0");
return KQDurationCalculatorUtil.getDurationRound(duration4day);
}
/**
*
*
* @param fromDate
* @param fromTime
* @param toDate
* @param toTime
* @param resourceid
* @return
*/
public String getTotalWorkingHours(String fromDate, String fromTime, String toDate, String toTime, String resourceid) {
Map<String, Object> durationMap = getTotalWorkingDurations(fromDate, fromTime, toDate, toTime, resourceid);
String duration4min = Util.null2s(Util.null2String(durationMap.get("min_duration")), "0");
double duration4hour = Util.getDoubleValue(duration4min) / 60.0;
return KQDurationCalculatorUtil.getDurationRound(duration4hour + "");
}
/**
*
*
* @param fromDate
* @param fromTime
* @param toDate
* @param toTime
* @param resourceid
* @return
*/
public String getTotalWorkingMins(String fromDate, String fromTime, String toDate, String toTime, String resourceid) {
Map<String, Object> durationMap = getTotalWorkingDurations(fromDate, fromTime, toDate, toTime, resourceid);
String duration4min = Util.null2s(Util.null2String(durationMap.get("min_duration")), "0");
return KQDurationCalculatorUtil.getDurationRound(duration4min + "");
}
/**
*
*
* @param fromDate
* @param fromTime
* @param toDate
* @param toTime
* @param resourceid
* @return
*/
public String getTotalNonWorkingDays(String fromDate, String fromTime, String toDate, String toTime, String resourceid) {
KQDurationCalculatorUtil kqDurationCalculatorUtil = new DurationParamBuilder(resourceid).
fromDateParam(fromDate).toDateParam(toDate).fromTimeParam(fromTime).toTimeParam(toTime).computingModeParam("1").
durationRuleParam("1").durationTypeEnumParam(DurationTypeEnum.OVERTIME).build();
Map<String, Object> durationMap = kqDurationCalculatorUtil.getNonWorkDuration();
String duration = Util.null2String(durationMap.get("duration"));
return KQDurationCalculatorUtil.getDurationRound(duration);
}
/**
*
*
* @param fromDate
* @param fromTime
* @param toDate
* @param toTime
* @param resourceid
* @return
*/
public String getTotalNonWorkingHours(String fromDate, String fromTime, String toDate, String toTime, String resourceid) {
KQDurationCalculatorUtil kqDurationCalculatorUtil = new DurationParamBuilder(resourceid).
fromDateParam(fromDate).toDateParam(toDate).fromTimeParam(fromTime).toTimeParam(toTime).computingModeParam("1").
durationRuleParam("3").durationTypeEnumParam(DurationTypeEnum.OVERTIME).build();
Map<String, Object> durationMap = kqDurationCalculatorUtil.getNonWorkDuration();
String duration = Util.null2String(durationMap.get("duration"));
return KQDurationCalculatorUtil.getDurationRound(duration);
}
/**
* 2
*
* @param duration
* @return
*/
public static String getDurationRound(String duration) {
if (HrmScheduleDiffUtil.isFromFlow()) {
return Util.round(duration, 5);
}
return Util.round(duration, 2);
}
/**
* 5
*
* @param duration
* @return
*/
public static String getDurationRound5(String duration) {
return Util.round(duration, 5);
}
/**
* Builder
*/
public static class DurationParamBuilder {
//必选变量 人员看怎么都是需要的
private final String resourceid;
//可选变量
private String fromDate = "";
private String toDate = "";
private String fromTime = "";
private String toTime = "";
/**
*
*/
private String newLeaveType = "";
/**
*
* 1-
* 2-
* 3-
* 4-
*/
private String durationrule = "";
/**
*
* 1-
* 2-
*/
private String computingMode = "";
/**
*
*/
private String overtime_type = "";
/**
*
*/
private DurationTypeEnum durationTypeEnum;
public DurationParamBuilder(String resourceid) {
this.resourceid = resourceid;
//初始化的时候需要把其他参数先清空下
this.fromDate = "";
this.toDate = "";
this.fromTime = "";
this.toTime = "";
this.newLeaveType = "";
this.durationrule = "";
this.computingMode = "";
this.overtime_type = "";
}
//成员方法返回其自身,所以可以链式调用
public DurationParamBuilder fromDateParam(final String fromDate) {
this.fromDate = fromDate;
return this;
}
public DurationParamBuilder toDateParam(final String toDate) {
this.toDate = toDate;
return this;
}
public DurationParamBuilder fromTimeParam(final String fromTime) {
this.fromTime = fromTime;
return this;
}
public DurationParamBuilder toTimeParam(final String toTime) {
this.toTime = toTime;
return this;
}
public DurationParamBuilder newLeaveTypeParam(final String newLeaveType) {
this.newLeaveType = newLeaveType;
return this;
}
public DurationParamBuilder durationRuleParam(final String durationrule) {
this.durationrule = durationrule;
return this;
}
public DurationParamBuilder computingModeParam(final String computingMode) {
this.computingMode = computingMode;
return this;
}
public DurationParamBuilder overtime_typeParam(final String overtime_type) {
this.overtime_type = overtime_type;
return this;
}
public DurationParamBuilder durationTypeEnumParam(final DurationTypeEnum durationTypeEnum) {
this.durationTypeEnum = durationTypeEnum;
return this;
}
//Builder的build方法返回外部类的实例
public KQDurationCalculatorUtil build() {
return new KQDurationCalculatorUtil(this);
}
}
}

@ -0,0 +1,21 @@
package com.engine.kq.util;
import java.time.Duration;
import java.time.LocalTime;
public class TimeRangeCalculator {
public static double getRestTime(String startTime, String endTime, String restStartTime, String restEndTime) {
LocalTime workStart = LocalTime.parse(startTime);
LocalTime workEnd = LocalTime.parse(endTime);
LocalTime restStart = LocalTime.parse(restStartTime);
LocalTime restEnd = LocalTime.parse(restEndTime);
Duration restDuration = Duration.ZERO;
if (!restStart.isAfter(workEnd) && !restEnd.isBefore(workStart)) {
LocalTime effectiveRestStart = restStart.isBefore(workStart) ? workStart : restStart;
LocalTime effectiveRestEnd = restEnd.isAfter(workEnd) ? workEnd : restEnd;
restDuration = Duration.between(effectiveRestStart, effectiveRestEnd);
}
return restDuration.getSeconds();
}
}

@ -0,0 +1,929 @@
package com.engine.kq.util;
import com.api.browser.bean.SearchConditionOption;
import com.engine.kq.biz.*;
import com.engine.kq.cmd.shiftmanagement.toolkit.ShiftManagementToolKit;
import com.engine.kq.enums.KQSettingsEnum;
import com.engine.kq.enums.KqSplitFlowTypeEnum;
import com.engine.kq.wfset.util.SplitSelectSet;
import java.text.DecimalFormat;
import java.util.*;
import weaver.systeminfo.systemright.CheckSubCompanyRight;
import weaver.common.DateUtil;
import weaver.common.StringUtil;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.systeminfo.SystemEnv;
import weaver.workflow.workflow.WorkflowComInfo;
import weaver.workflow.workflow.WorkflowRequestComInfo;
public class TransMethod extends BaseBean {
private static DecimalFormat df = new DecimalFormat("0.00");
public ArrayList<String> getOperateByGroup(String id, String otherPara) {
ArrayList<String> resultList = new ArrayList<String>();
String[] splitStr = Util.splitString(otherPara, "+");
String kqType = Util.null2String(splitStr[0]);
String subcompanyid = Util.null2String(splitStr[1]);
String userid = Util.null2String(splitStr[2]);
int resourceid = Util.getIntValue(userid);
CheckSubCompanyRight checkSubCompanyRight = new CheckSubCompanyRight();
int operatelevel = checkSubCompanyRight.ChkComRightByUserRightCompanyId(resourceid, "HrmKQGroup:Add", Util.getIntValue(subcompanyid, -1));
if (operatelevel > 0) {
resultList.add("true");
resultList.add("true");
resultList.add("true");
resultList.add(String.valueOf(kqType.equals("2")));
}else{
resultList.add("false");
resultList.add("false");
resultList.add("false");
resultList.add("false");
}
if (operatelevel > 1) {
resultList.add(this.getKQGroupCheckbox(id));
}else{
resultList.add("false");
}
resultList.add("true");
return resultList;
}
public ArrayList<String> getOperate(String id, String kqType){
ArrayList<String> resultList = new ArrayList<String>();
resultList.add("true");
resultList.add("true");
resultList.add("true");
resultList.add(String.valueOf(kqType.equals("2")));
resultList.add(this.getKQGroupCheckbox(id));
resultList.add("true");
return resultList;
}
public ArrayList<String> getGroupMembersOperate(String id, String groupId){
ArrayList<String> resultList = new ArrayList<String>();
String result = getKQGroupMembersCheckbox(id+"+"+groupId);
resultList.add(result);
return resultList;
}
public String getKQGroupName(String groupname, String otherPara){
String kqGroupName = groupname;
String[] splitStr = Util.splitString(otherPara, "+");
String groupid = Util.null2String(splitStr[0]);
String resourceid = Util.null2String(splitStr[1]);
String kqdate = Util.null2String(splitStr[2]);
String strLanguage = Util.null2String(splitStr[3]);
if(resourceid.length()>0){
int language = Util.getIntValue(strLanguage,7);
if(kqdate.length()==0) {
kqdate = DateUtil.getCurrentDate();
}
String currentGroupId = Util.null2String(new KQGroupMemberComInfo().getKQGroupId(resourceid,kqdate));
if(groupid.equals(currentGroupId)) {
kqGroupName += "(<span style=\"color:#F00\">"+ SystemEnv.getHtmlLabelName(509551, language)+"</span>)";
}
}
return kqGroupName;
}
public int getGroupUserCount(String groupid){
int count = 0;
RecordSet rs = new RecordSet();
String sql = "";
sql = " SELECT count(distinct id) FROM ( "+
" SELECT a.id,a.status FROM HrmResource a, kq_groupmember b "+
" WHERE (a.id=b.typevalue and b.type =1 and (isdelete is null or isdelete <> '1') and groupid = "+groupid+" ) "+
" UNION ALL "+
" SELECT a.id,a.status FROM HrmResource a, kq_groupmember b "+
" WHERE (a.subcompanyid1 = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=2 and (isdelete is null or isdelete <> '1') and groupid = "+groupid+" ) "+
" UNION ALL "+
" SELECT a.id,a.status FROM HrmResource a, kq_groupmember b "+
" WHERE (a.departmentid = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=3 and (isdelete is null or isdelete <> '1') and groupid = "+groupid+" ) "+
" UNION ALL "+
" SELECT a.id,a.status FROM HrmResource a, kq_groupmember b "+
" WHERE (a.jobtitle = b.typevalue AND b.type=5 and (isdelete is null or isdelete <> '1') and groupid = "+groupid+" AND (b.jobtitlelevel=1 OR (b.jobtitlelevel=2 AND a.subcompanyid1 IN(b.jobtitlelevelvalue)) OR (b.jobtitlelevel=3 AND a.departmentid IN(b.jobtitlelevelvalue))))" +
" UNION ALL "+
" select a.id,a.status from hrmresource a where seclevel>=(select min(seclevel) from kq_groupmember where type=6 and (isdelete is null or isdelete <> '1') and groupid = "+groupid+" ) and seclevel<= (select max(seclevelto) from kq_groupmember where type=6 and (isdelete is null or isdelete <> '1') and groupid = "+groupid+" )" +
"UNION all " +
" select id,status from hrmresource h " +
" where JOBTITLE in (select id from hrmjobtitles h " +
" where JOBACTIVITYID in (select id from hrmjobactivities h2 " +
" where jobgroupid in (select typevalue from kq_groupmember b " +
" where b.type =10 and (isdelete is null or isdelete <> '1') and b.groupid = "+groupid+"))))t " +
" where t.status in(0,1,2,3) ";
rs.executeQuery(sql) ;
if(rs.next()){
count=rs.getInt(1);
}
return count;
}
public String getKQTypeName(String kqtype, String strLanguage){
int language = Util.getIntValue(strLanguage,7);
String kQTypeName = "";
if(kqtype.equals("1")){
kQTypeName = SystemEnv.getHtmlLabelName(389127,language);
}else if(kqtype.equals("2")){
kQTypeName = SystemEnv.getHtmlLabelName(389128,language);
}else if(kqtype.equals("3")){
kQTypeName = SystemEnv.getHtmlLabelName(520551,language);
}
return kQTypeName;
}
public String getKQGroupDetial(String id,String otherPara){
String kQGroupDetial = "";
String[] splitStr = Util.splitString(otherPara, "+");
String kqtype = Util.null2String(splitStr[0]);
int language = Util.getIntValue(splitStr[1],7);
KQGroupComInfo kqGroupComInfo = new KQGroupComInfo();
ShiftManagementToolKit shiftManagementToolKit = new ShiftManagementToolKit();
if(kqtype.equals("1")){
String sql = "";
RecordSet rs = new RecordSet();
LinkedHashMap<String, String> map = new LinkedHashMap<>();
sql = "select * from kq_fixedschedulce where groupid = ? order by weekday ";
rs.executeQuery(sql,id);
while(rs.next()){
int weekday = rs.getInt("weekday");
String serialid = Util.null2String(rs.getString("serialid"));
if(serialid.length()==0)serialid="0";
if(map.get(serialid)==null){
map.put(serialid,UtilKQ.getWeekDay(weekday,language) );
}else{
String value = map.get(serialid);
value=value+"、"+UtilKQ.getWeekDay(weekday,language);
map.put(serialid,value);
}
}
Iterator<Map.Entry<String,String>> iter = map.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry<String, String> entry = iter.next();
String serialid = entry.getKey();
String weeks = entry.getValue();
if(kQGroupDetial.length()>0)kQGroupDetial+="<br>";
if(serialid.equals("0")){
kQGroupDetial += weeks + SystemEnv.getHtmlLabelName(26593,language);
}else{
kQGroupDetial += weeks + shiftManagementToolKit.getShiftOnOffWorkSections(serialid,language);
}
}
}else if(kqtype.equals("2")){
List<String> serialids = Util.splitString2List(kqGroupComInfo.getSerialids(id),",") ;
List<String> lsSerialids = new ArrayList<>();
for (String serialid : serialids) {
if(Util.null2String(serialid).length()==0 || lsSerialids.contains(serialid)
||Util.null2String(shiftManagementToolKit.getShiftOnOffWorkSections(serialid,language)).length()==0)continue;
lsSerialids.add(serialid);
if(kQGroupDetial.length()>0)kQGroupDetial+="<br>";
kQGroupDetial += shiftManagementToolKit.getShiftOnOffWorkSections(serialid,language);
}
}else if(kqtype.equals("3")){
kQGroupDetial = SystemEnv.getHtmlLabelName(389120,language);
}
return kQGroupDetial;
}
public String getSignTime(String signDate, String signTime){
return signDate+" "+signTime;
}
public String getFlowDurationByUnit(String duration, String otherPara){
String[] splitStr = Util.splitString(otherPara, "+");
String kqType = "";
String durationrule = "";
String lan = "";
String newLeaveType = "";
String requestid = "";
String typeselect = "";
String fromDate = "";
String toDate = "";
String backduraion = "";
if(splitStr.length == 6){
kqType = splitStr[0];
durationrule = splitStr[1];
lan = splitStr[2];
newLeaveType = splitStr[3];
requestid = splitStr[4];
backduraion = splitStr[5];
}else if(splitStr.length == 5){
kqType = splitStr[0];
durationrule = splitStr[1];
lan = splitStr[2];
requestid = splitStr[3];
backduraion = splitStr[4];
}else if(splitStr.length == 8){
kqType = splitStr[0];
durationrule = splitStr[1];
lan = splitStr[2];
newLeaveType = splitStr[3];
requestid = splitStr[4];
typeselect = splitStr[5];
fromDate = splitStr[6];
toDate = splitStr[7];
}else if(splitStr.length == 3){
kqType = splitStr[0];
durationrule = splitStr[1];
lan = splitStr[2];
}
if(Util.getIntValue(kqType) == 0 && newLeaveType.length() == 0){
return duration;
}
return getUnitByKQType(kqType,newLeaveType,durationrule,Util.getDoubleValue(duration),requestid,lan,backduraion);
}
/**
* +id
* @param kqType
* @param newLeaveType
* @param durationrule
* @param duration
* @param requestid
* @param lan
* @param backduraion
* @return
*/
private String getUnitByKQType(String kqType, String newLeaveType, String durationrule,
double duration, String requestid, String lan, String backduraion) {
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
// String unit = "";
double kq_duration = duration;
double proportion = 0.0;
Map<String,String> backDuraion = new HashMap<>();
double backDuration = Util.getDoubleValue(Util.null2s(backduraion,"0.0"),0.0);
String minimumUnit = "";
switch (kqType){
case "0":
proportion = Util.getDoubleValue(kqLeaveRulesComInfo.getProportion(newLeaveType));
minimumUnit = ""+KQLeaveRulesBiz.getMinimumUnit(newLeaveType);
// if(requestid.length() > 0){
// backDuraion = getLeaveBackDuraion(requestid,typeselect,fromDate,toDate);
// }
// unit = getMinimumUnitName(""+minimumUnit, lan);
break;
case "1":
minimumUnit = KQTravelRulesBiz.getMinimumUnit();//单位类型
proportion = Util.getDoubleValue(KQTravelRulesBiz.getHoursToDay());//换算关系
// unit = getMinimumUnitName(minimumUnit,lan);
break;
case "2":
minimumUnit = KQExitRulesBiz.getMinimumUnit();//单位类型
proportion = Util.getDoubleValue(KQExitRulesBiz.getHoursToDay());//换算关系
// unit = getMinimumUnitName(minimumUnit,lan);
break;
case "3":
minimumUnit = ""+KQOvertimeRulesBiz.getMinimumUnit();//当前加班单位
proportion = KQOvertimeRulesBiz.getHoursToDay();//当前天跟小时计算关系
// unit = getMinimumUnitName(minimumUnit,lan);
break;
case "4":
break;
case "5":
break;
case "6":
break;
case "7":
break;
default:
break;
}
if(KQUnitBiz.isLeaveHour(minimumUnit)){//按小时
if(!KQUnitBiz.isLeaveHour(durationrule)){
if(proportion>0) {
kq_duration = duration*proportion;
backDuration = backDuration*proportion;
}
}
}else{//按天
if(KQUnitBiz.isLeaveHour(durationrule)){
if(proportion>0) {
kq_duration = duration/proportion;
backDuration = backDuration/proportion;
}
}
}
// if(unit.length() > 0){
// return kq_duration+"("+unit+")";
// }else{
// }
if(backDuration > 0){
return KQDurationCalculatorUtil.getDurationRound(""+kq_duration)+"("+SystemEnv.getHtmlLabelName(24473,
Util.getIntValue(lan))+":"+KQDurationCalculatorUtil.getDurationRound(""+backDuration)+")";
}else{
return KQDurationCalculatorUtil.getDurationRound(""+kq_duration);
}
}
/**
* id
* @param requestid
* @param typeselect
* @param fromDate
* @param toDate
* @return
*/
public Map<String,String> getLeaveBackDuraion(String requestid, String typeselect,
String fromDate, String toDate) {
if(typeselect.length()==0){
typeselect = "3";
}
if(!typeselect.equals("") && !typeselect.equals("0")&& !typeselect.equals("6")){
if(typeselect.equals("1")){
fromDate = TimeUtil.getCurrentDateString();
toDate = TimeUtil.getCurrentDateString();
}else{
fromDate = TimeUtil.getDateByOption(typeselect,"0");
toDate = TimeUtil.getDateByOption(typeselect,"1");
}
}
Map<String,String> backDuraion = new HashMap<>();
RecordSet rs = new RecordSet();
String getLeaveBackDuraion = "select sum(cast(duration as decimal(18,4))) as duration1,durationrule from kq_flow_split_leaveback where leavebackrequestid = ? ";
if (fromDate.length() > 0 && toDate.length() > 0){
getLeaveBackDuraion += " and ( fromDate between '"+fromDate+"' and '"+toDate+"' or toDate between '"+fromDate+"' and '"+toDate+"' "
+ " or '"+fromDate+"' between fromDate and toDate or '"+toDate+"' between fromDate and toDate) ";
}
getLeaveBackDuraion += " group by durationrule ";
rs.executeQuery(getLeaveBackDuraion, requestid);
if (rs.next()){
String duration1 = rs.getString("duration1");
String durationrule = rs.getString("durationrule");
backDuraion.put("durationrule", durationrule);
backDuraion.put("duration", duration1);
}
return backDuraion;
}
private String getMinimumUnitName(String minimumUnit,int lan){
String minimumUnitName = "";
switch (minimumUnit) {
case "1":
minimumUnitName = SystemEnv.getHtmlLabelName(1925, lan);
break;
case "2":
minimumUnitName = SystemEnv.getHtmlLabelName(1925, lan);
break;
case "3":
minimumUnitName = SystemEnv.getHtmlLabelName(391, lan);
break;
case "4":
minimumUnitName = SystemEnv.getHtmlLabelName(1925, lan);
break;
default:
break;
}
return minimumUnitName;
}
public String getSerailName(String serialid,String otherPara) {
String serailName = "";
if(Util.null2String(serialid).trim().length()==0) return serailName;
String workSections = "";
KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo();
KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo();
String[] params = Util.splitString(otherPara, "+");
String workbegintime = Util.null2String(params[0]).trim();
String workendtime = Util.null2String(params[1]).trim();
serailName = kqShiftManagementComInfo.getSerial(serialid);
if(workbegintime.length()>0&&workendtime.length()>0){
//只有下班时间可能跨天
workendtime = kqTimesArrayComInfo.turn48to24Time(workendtime);
workSections += workbegintime+"-"+workendtime;
}
if(workSections.length()>0) {
serailName += "(" + workSections + ")";
}
return serailName;
}
/**
*
* @param serialid
* @param otherPara
* @return
*/
public String getReportDetialSignInTime(String serialid,String otherPara) {
String signTime = "";
String[] params = Util.splitString(otherPara, "+");
String begintime = Util.null2String(params[0]).trim();
String kqdate = Util.null2String(params[1]).trim();
String resourceid = Util.null2String(params[2]).trim();
int language = Util.getIntValue(params[3],7);
if(begintime.length()>0){
signTime += begintime;
}
if(Util.null2String(serialid).length()>0){
if(signTime.length()==0){
signTime = SystemEnv.getHtmlLabelName(25994,language);
}
}else{
//弹性工时打卡时间取自签到签退数据
}
return signTime;
}
/**
*
* @param serialid
* @param otherPara
* @return
*/
public String getReportDetialSignOutTime(String serialid,String otherPara) {
String signTime = "";
String[] params = Util.splitString(otherPara, "+");
String endtime = Util.null2String(params[0]).trim();
String kqdate = Util.null2String(params[1]).trim();
String resourceid = Util.null2String(params[2]).trim();
int language = Util.getIntValue(params[3],7);
if(endtime.length()>0){
signTime += endtime;
}
if(Util.null2String(serialid).length()>0){
if(signTime.length()==0){
signTime = SystemEnv.getHtmlLabelName(25994,language);
}
}else{
//弹性工时打卡时间取自签到签退数据
}
return signTime;
}
public String getReportDetialSignTime(String serialid,String otherPara) {
String signTime = "";
String[] params = Util.splitString(otherPara, "+");
String begintime = Util.null2String(params[0]).trim();
String endtime = Util.null2String(params[1]).trim();
String kqdate = Util.null2String(params[2]).trim();
String resourceid = Util.null2String(params[3]).trim();
int language = Util.getIntValue(params[4],7);
if(begintime.length()>0&&endtime.length()>0){
signTime += begintime+"-"+endtime;
}else if(begintime.length()>0){
signTime += begintime;
}else if(endtime.length()>0){
signTime += endtime;
}
if(Util.null2String(serialid).length()>0){
if(signTime.length()==0){
signTime = SystemEnv.getHtmlLabelName(25994,language);
}
}else{
//弹性工时打卡时间取自签到签退数据
}
return signTime;
}
public String getReportDetialMinToHour(String value) {
value = value.trim();
if(value.length()>0){
value = df.format(Util.getDoubleValue(value)/60);
}
return value;
}
public String getLeavetype(String newleavetype) {
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
if(newleavetype.length() == 0){
return "";
}
boolean show_leave_type_unit = KQSettingsBiz.showLeaveTypeSet(KQSettingsEnum.LEAVETYPE_UNIT.getMain_key());
String name = kqLeaveRulesComInfo.getLeaveName(newleavetype);
if(show_leave_type_unit){
name += kqLeaveRulesComInfo.getUnitName(newleavetype, 7);
}
return name;
}
public String getLeavetype(String newleavetype, String otherPara) {
String[] splitStr = Util.splitString(otherPara, "+");
String languageId = (splitStr==null || splitStr.length<1) ? "7":splitStr[0];
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
if(newleavetype.length() == 0){
return "";
}
boolean show_leave_type_unit = KQSettingsBiz.showLeaveTypeSet(KQSettingsEnum.LEAVETYPE_UNIT.getMain_key());
String name = kqLeaveRulesComInfo.getLeaveName(newleavetype);
if(show_leave_type_unit){
name += kqLeaveRulesComInfo.getUnitName(newleavetype, Util.getIntValue(languageId));
}
return name;
}
public String getKQGroupCheckboxByGroup(String otherPara){
String returnVal = "true";
RecordSet rs = new RecordSet();
String[] splitStr = Util.splitString(otherPara, "+");
String id = Util.null2String(splitStr[0]);
String subcompanyid = Util.null2String(splitStr[1]);
String userid = Util.null2String(splitStr[2]);
int resourceid = Util.getIntValue(userid);
CheckSubCompanyRight checkSubCompanyRight = new CheckSubCompanyRight();
int operatelevel = checkSubCompanyRight.ChkComRightByUserRightCompanyId(resourceid, "HrmKQGroup:Add", Util.getIntValue(subcompanyid, -1));
if (operatelevel <= 1) {
returnVal = "false";
}
String sql = "";
//有考勤组成员
if(returnVal.equals("true")) {
sql = " SELECT count(1) FROM kq_groupmember WHERE (isdelete is null or isdelete <> '1') AND groupid=" + id;
rs.executeQuery(sql);
if (rs.next()) {
if (rs.getInt(1) > 0) {
returnVal = "false";
}
}
}
//有考勤排班
if(returnVal.equals("true")){
sql = " SELECT count(1) FROM kq_shiftschedule where (isdelete is null or isdelete <> '1') AND groupid="+id;
rs.executeQuery(sql);
if(rs.next()){
if(rs.getInt(1)>0){
returnVal = "false";
}
}
}
return returnVal;
}
public String getKQGroupCheckbox(String id){
String returnVal = "true";
String sql = "";
RecordSet rs = new RecordSet();
//有考勤组成员
sql = " SELECT count(1) FROM kq_groupmember WHERE (isdelete is null or isdelete <> '1') AND groupid="+id;
rs.executeQuery(sql);
if(rs.next()){
if(rs.getInt(1)>0){
returnVal = "false";
}
}
//有考勤排班
if(returnVal.equals("true")){
sql = " SELECT count(1) FROM kq_shiftschedule where (isdelete is null or isdelete <> '1') AND groupid="+id;
rs.executeQuery(sql);
if(rs.next()){
if(rs.getInt(1)>0){
returnVal = "false";
}
}
}
return returnVal;
}
public String getKQGroupMembersCheckbox(String params){
String returnVal = "true";
String[] arrParams = Util.splitString(params,"+");
String id = arrParams[0];
String groupId = arrParams[1];
String sql = "";
RecordSet rs = new RecordSet();
sql = " SELECT count(1) FROM (\n" +
" SELECT DISTINCT t.id, t.resourceid, t.groupid, t.status, t.dsporder,t.lastname,t.subcompanyid1, t.departmentid, t.loginid FROM ( \n" +
" SELECT b.id,a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" +
" WHERE a.id=b.typevalue and b.type =1 and (b.isdelete is null or b.isdelete <> '1') \n" +
" UNION ALL \n" +
" SELECT b.id,a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" +
" WHERE a.subcompanyid1 = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=2 and (b.isdelete is null or b.isdelete <> '1') \n" +
" UNION ALL \n" +
" SELECT b.id,a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" +
" WHERE a.departmentid = b.typevalue AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto AND b.type=3 and (b.isdelete is null or b.isdelete <> '1') \n" +
" UNION ALL \n" +
" SELECT b.id,a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" +
" WHERE (a.jobtitle = b.typevalue AND b.type=5 and (b.isdelete is null or b.isdelete <> '1') AND (b.jobtitlelevel=1 OR (b.jobtitlelevel=2 AND a.subcompanyid1 IN(b.jobtitlelevelvalue)) OR (b.jobtitlelevel=3 AND a.departmentid IN(b.jobtitlelevelvalue))))) t \n" +
" UNION ALL \n" +
" SELECT b.id,a.id AS resourceid, b.groupid, a.status,a.dsporder,a.lastname,a.subcompanyid1, a.departmentid, a.loginid FROM HrmResource a, kq_groupmember b \n" +
" WHERE b.type=6 AND a.seclevel>=b.seclevel AND a.seclevel<=b.seclevelto and (b.isdelete is null or b.isdelete <> '1')) t, kq_shiftschedule a\n" +
" where t.resourceid=a.resourceid AND t.groupid=a.groupid AND (a.isdelete is null or a.isdelete <> '1') AND t.id="+id + " and t.groupId="+groupId;
rs.executeQuery(sql);
if(rs.next()){
if(rs.getInt(1)>0){
returnVal = "false";
}
}
return returnVal;
}
public String getFlowTimeByUnit(String time, String otherPara){
String compareTime = time;
String timename = time;
String[] splitStr = Util.splitString(otherPara, "+");
String kqtype = "";
String timetype = "";//0表示开始时间1表示结束时间
String lan = "";
String newLeaveType = "";
String durationrule = "";
String timeselection = "1";
String selectiontype = "";
String changeType = "";
KQTimeSelectionComInfo kqTimeSelectionComInfo = new KQTimeSelectionComInfo();
KQLeaveRulesComInfo kqLeaveRulesComInfo = new KQLeaveRulesComInfo();
Map<String,String> half_map = new HashMap<>();
if(splitStr.length == 5){
//归档
kqtype = splitStr[0];
timetype = splitStr[1];
lan = splitStr[2];
newLeaveType = splitStr[3];
durationrule = splitStr[4];
}else if(splitStr.length == 4){
kqtype = splitStr[0];
timetype = splitStr[1];
lan = splitStr[2];
newLeaveType = splitStr[3];
}
switch (kqtype){
case "0":
durationrule = (durationrule.length() > 0 ? durationrule : ""+KQLeaveRulesBiz.getMinimumUnit(newLeaveType));
timeselection = kqLeaveRulesComInfo.getTimeSelection(newLeaveType);
selectiontype = ""+KqSplitFlowTypeEnum.LEAVE.getFlowtype();
changeType = kqLeaveRulesComInfo.getMinimumUnit(newLeaveType);
break;
case "1":
durationrule = (durationrule.length() > 0 ? durationrule : ""+KQTravelRulesBiz.getMinimumUnit());
timeselection = KQTravelRulesBiz.getTimeselection();
selectiontype = ""+KqSplitFlowTypeEnum.EVECTION.getFlowtype();
changeType = durationrule;
newLeaveType = "0";
break;
case "2":
durationrule = (durationrule.length() > 0 ? durationrule : ""+KQExitRulesBiz.getMinimumUnit());
timeselection = KQExitRulesBiz.getTimeselection();
selectiontype = ""+KqSplitFlowTypeEnum.OUT.getFlowtype();
changeType = durationrule;
newLeaveType = "0";
break;
case "3":
durationrule = (durationrule.length() > 0 ? durationrule : ""+KQOvertimeRulesBiz.getMinimumUnit());
timeselection = KQOvertimeRulesBiz.getTimeselection();
selectiontype = ""+KqSplitFlowTypeEnum.OVERTIME.getFlowtype();
changeType = durationrule;
newLeaveType = "0";
if(compareTime.length() > 5){
compareTime = compareTime.substring(0,5);
}
break;
case "4":
break;
case "5":
break;
case "6":
break;
case "7":
break;
default:
break;
}
if("2".equalsIgnoreCase(durationrule) || "4".equalsIgnoreCase(durationrule)){
if("2".equalsIgnoreCase(durationrule)){
half_map = kqTimeSelectionComInfo.getTimeselections(selectiontype,newLeaveType,changeType);
if("1".equalsIgnoreCase(timeselection)){
//下拉框显示
String cus_am = "";
String cus_pm = "";
if(half_map != null && !half_map.isEmpty()){
cus_am = Util.null2String(half_map.get("half_on"));
cus_pm = Util.null2String(half_map.get("half_off"));
}
if("0".equalsIgnoreCase(timetype)){
if(compareTime.equalsIgnoreCase(SplitSelectSet.forenoon_start)){
timename = SystemEnv.getHtmlLabelName(16689,Util.getIntValue(lan));
if(cus_am.length() > 0){
timename = cus_am;
}
}else if(compareTime.equalsIgnoreCase(SplitSelectSet.forenoon_end)){
timename = SystemEnv.getHtmlLabelName(16690,Util.getIntValue(lan));
if(cus_pm.length() > 0){
timename = cus_pm;
}
}
}else if("1".equalsIgnoreCase(timetype)){
if(compareTime.equalsIgnoreCase(SplitSelectSet.afternoon_start)){
timename = SystemEnv.getHtmlLabelName(16689,Util.getIntValue(lan));
if(cus_am.length() > 0){
timename = cus_am;
}
}else if(compareTime.equalsIgnoreCase(SplitSelectSet.afternoon_end)){
timename = SystemEnv.getHtmlLabelName(16690,Util.getIntValue(lan));
if(cus_pm.length() > 0){
timename = cus_pm;
}
}
}
}else{
}
}
if("4".equalsIgnoreCase(durationrule)){
if("0".equalsIgnoreCase(timetype)){
if(compareTime.equalsIgnoreCase(SplitSelectSet.forenoon_start)){
timename = SystemEnv.getHtmlLabelName(390728,Util.getIntValue(lan));
}
}else if("1".equalsIgnoreCase(timetype)){
if(compareTime.equalsIgnoreCase(SplitSelectSet.afternoon_end)){
timename = SystemEnv.getHtmlLabelName(390728,Util.getIntValue(lan));
}
}
}
}
return timename;
}
/**
*
* @param duration
* @return
*/
public String getDuration_minByUnit(String duration){
int uintType = KQOvertimeRulesBiz.getMinimumUnit();//当前加班单位
double hoursToDay = KQOvertimeRulesBiz.getHoursToDay();//当前天跟小时计算关系
String valueField = "";
if(uintType==3 || uintType== 5 || uintType== 6){//按小时计算
valueField = KQDurationCalculatorUtil.getDurationRound(""+(Util.getDoubleValue(duration)/(60)));
}else{//按天计算
valueField = KQDurationCalculatorUtil.getDurationRound(""+(Util.getDoubleValue(duration)/(60*hoursToDay)));
}
return valueField;
}
/**
*
* @param paidLeaveEnable
* @param otherPram
* @return
*/
public String getPaidLeaveEnable(String paidLeaveEnable,String otherPram){
int lan = Util.getIntValue(otherPram,7);
if("1".equalsIgnoreCase(paidLeaveEnable)){
return SystemEnv.getHtmlLabelName(163, lan);
}else{
return SystemEnv.getHtmlLabelName(161, lan);
}
}
/**
*
* @param computingMode
* @param otherPram
* @return
*/
public String getComputingMode(String computingMode,String otherPram){
// String mode = "";
// if("1".equalsIgnoreCase(computingMode)){
// mode = "以加班流程为准";
// }else if("2".equalsIgnoreCase(computingMode)){
// mode = "以打卡为准,但不能超过加班流程时长";
// }else if("3".equalsIgnoreCase(computingMode)){
// mode = "根据打卡时间计算加班时长";
// }
int lan = Util.getIntValue(otherPram,7);
if("1".equalsIgnoreCase(computingMode)){
return SystemEnv.getHtmlLabelName(30045, lan);
}else{
return SystemEnv.getHtmlLabelName(500502, lan);
}
}
public String getSchedulecode(String params){
String schedulecode = "";
String sql = "";
RecordSet rs = new RecordSet();
try{
boolean isOneDevice = true;
sql = " select count(1) from kq_schedule_device ";
rs.executeQuery(sql);
if(rs.next()){
if(rs.getInt(1)>1){
isOneDevice = false;
}
}
if(isOneDevice){
sql = " SELECT schedulecode FROM kq_schedule_code where resourceid="+params;
rs.executeQuery(sql);
while (rs.next()){
if(schedulecode.length()>0)schedulecode+=",";
schedulecode += Util.null2String(rs.getString("schedulecode"));
}
}else{
sql = " SELECT count(1) as cnt FROM kq_schedule_code where resourceid="+params;
rs.executeQuery(sql);
if(rs.next()){
schedulecode = ""+rs.getInt("cnt");
}
}
}catch (Exception e){
writeLog(e);
}
return schedulecode;
}
public String getScheduleDeviceCheckbox(String id){
String returnVal = "true";
String sql = "";
RecordSet rs = new RecordSet();
try{
sql = " select count(1) from kq_schedule_code where deviceid = ? ";
rs.executeQuery(sql,id);
if(rs.next()){
if(rs.getInt(1)>0){
returnVal = "false";
}
}
}catch (Exception e){
writeLog(e);
}
return returnVal;
}
public ArrayList<String> getScheduleDeviceOperate(String id){
ArrayList<String> resultList = new ArrayList<String>();
resultList.add("true");
resultList.add(this.getScheduleDeviceCheckbox(id));
resultList.add("true");
return resultList;
}
public String getWorkflowname(String field001){
WorkflowComInfo workflowComInfo = new WorkflowComInfo();
return workflowComInfo.getWorkflowname(field001);
}
public String getFlowTypeName(String field006, String strLanguage){
if("0".equalsIgnoreCase(field006)){
return SystemEnv.getHtmlLabelName(83393, Util.getIntValue(Util.getIntValue(strLanguage)));
}else if("1".equalsIgnoreCase(field006)){
return SystemEnv.getHtmlLabelName(83394, Util.getIntValue(Util.getIntValue(strLanguage)));
}else if("2".equalsIgnoreCase(field006)){
return SystemEnv.getHtmlLabelName(83395, Util.getIntValue(Util.getIntValue(strLanguage)));
}else if("3".equalsIgnoreCase(field006)){
return SystemEnv.getHtmlLabelName(83396, Util.getIntValue(Util.getIntValue(strLanguage)));
}else if("5".equalsIgnoreCase(field006)){
return SystemEnv.getHtmlLabelName(390737, Util.getIntValue(Util.getIntValue(strLanguage)));
}else if("6".equalsIgnoreCase(field006)){
return SystemEnv.getHtmlLabelName(389117, Util.getIntValue(Util.getIntValue(strLanguage)));
}else if("7".equalsIgnoreCase(field006)){
return SystemEnv.getHtmlLabelName(390274, Util.getIntValue(Util.getIntValue(strLanguage)));
}else if("8".equalsIgnoreCase(field006)){
return SystemEnv.getHtmlLabelName(513400, Util.getIntValue(Util.getIntValue(strLanguage)));
}else {
return "";
}
}
public String getRequestLink(String fromDate,String req_requestid){
WorkflowRequestComInfo workflowRequestComInfo = new WorkflowRequestComInfo();
if(req_requestid.length() > 0 && Util.getIntValue(req_requestid) > 0){
return "<a href='"+weaver.general.GCONST.getContextPath()+"/spa/workflow/index_form.jsp#/main/workflow/req?ismonitor=1&requestid=" + req_requestid + "'target='_blank'>" + fromDate + "</a>";
}else{
return fromDate;
}
}
public String getOvertimeCard(String fromdate,String otherPara){
String[] splitStr = Util.splitString(otherPara, "+");
if(splitStr.length == 3){
String fromtime = splitStr[0];
String todate = splitStr[1];
String totime = splitStr[2];
//多时区会把这个文字给转换改成/
String tmpfromdate = fromdate.replaceAll("-", "/");
String tmptodate = todate.replaceAll("-", "/");
String datetime = tmpfromdate+" "+fromtime+"-"+tmptodate+" "+totime;
return datetime;
}
return "";
}
}

@ -0,0 +1,144 @@
package com.engine.kq.web;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.kq.biz.KQReportFieldComInfo;
import com.engine.kq.enums.KqSplitFlowTypeEnum;
import com.engine.kq.service.KQReportDetailService;
import com.engine.kq.service.impl.KQReportDetailServiceImpl;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import weaver.systeminfo.SystemEnv;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.HashMap;
import java.util.Map;
/**
*
*/
public class KQReportDetailAction extends BaseBean {
private KQReportDetailService getService(User user) {
return (KQReportDetailService) ServiceUtil.getService(KQReportDetailServiceImpl.class, user);
}
/**
* Tabs
* @param request
* @param response
* @return
*/
@POST
@Path("/getTabs")
@Produces(MediaType.TEXT_PLAIN)
public String getTabs(@Context HttpServletRequest request, @Context HttpServletResponse response) {
Map<String, Object> apidatas = new HashMap<String, Object>();
try {
User user = HrmUserVarify.getUser(request, response);
apidatas = getService(user).getTabs(ParamUtil.request2Map(request), user);
} catch (Exception e) {
apidatas.put("status", "-1");
writeLog(e);
}
return JSONObject.toJSONString(apidatas);
}
/**
*
* @param request
* @param response
* @return
*/
@POST
@Path("/getKQReportDetail")
@Produces(MediaType.TEXT_PLAIN)
public String getKQReportDetail(@Context HttpServletRequest request, @Context HttpServletResponse response) {
Map<String, Object> apidatas = new HashMap<String, Object>();
Map<String,Object> params =ParamUtil.request2Map(request) ;
params.put("isNoAccount","1") ;
RecordSet rs = new RecordSet();
String sql = "";
try {
User user = HrmUserVarify.getUser(request, response);
String type = Util.null2String(request.getParameter("type"));
String reportType = Util.null2String(request.getParameter("reportType"));
if(KQReportFieldComInfo.cascadekey2fieldname.keySet().contains(type)){
type=KQReportFieldComInfo.cascadekey2fieldname.get(type);
}
if(reportType.equals("month")) {
sql = "select formula from kq_report_field where fieldname = ? ";
rs.executeQuery(sql, type);
if(rs.next()){
String formula = Util.null2String(rs.getString("formula"));
if(formula.indexOf("beLateMins")>-1){
type = "beLate";
params.put("type",type);
}else if(formula.indexOf("leaveEarlyMins")>-1){
type = "leaveEearly";
params.put("type",type);
}
params.put("formula",formula);
}
}
if(type.equals("workdays")||type.equals("workmins")){
apidatas = getService(user).getWorkDayInfo(params, user);
}else if(type.equals("attendancedays")||type.equals("attendanceMins")||
type.equals("signdays")||type.equals("signmins")){
apidatas = getService(user).getSignInfo(params, user);
}else if(type.equals("beLate")||type.equals("beLateMins")||
type.equals("graveBeLate")||type.equals("graveBeLateMins")){
apidatas = getService(user).getBeLateInfo(params, user);
}else if(type.equals("leaveEearly")||type.equals("leaveEarlyMins")||
type.equals("graveLeaveEarly")||type.equals("graveLeaveEarlyMins")){
apidatas = getService(user).getLeaveEearlyInfo(params, user);
}else if(type.equals("absenteeism")||type.equals("absenteeismMins")){
apidatas = getService(user).getAbsenteeismInfo(params, user);
}else if(type.equals("forgotCheck")){
apidatas = getService(user).getForgotCheckInfo(params, user);
}else if(type.equals("leave")||type.startsWith("leaveType_")||type.equals("overtimeTotal")||
type.equals("businessLeave")||type.equals("officialBusiness")||
type.equals("leaveDeduction")){
apidatas = getService(user).getLeaveInfo(params, user);
}
} catch (Exception e) {
apidatas.put("status", "-1");
writeLog(e);
}
return JSONObject.toJSONString(apidatas);
}
/**
*
* @param request
* @param response
* @return
*/
@POST
@Path("/getDailyDetialInfo")
@Produces(MediaType.TEXT_PLAIN)
public String getDailyDetialInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) {
Map<String, Object> apidatas = new HashMap<String, Object>();
try {
User user = HrmUserVarify.getUser(request, response);
apidatas = getService(user).getDailyDetialInfo(ParamUtil.request2Map(request), user);
} catch (Exception e) {
apidatas.put("status", "-1");
writeLog(e);
}
return JSONObject.toJSONString(apidatas);
}
}

@ -0,0 +1,72 @@
package com.engine.kq.wfset.action;
import com.engine.kq.biz.KQFlowActiontBiz;
import com.engine.kq.log.KQLog;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;
import weaver.workflow.workflow.WorkflowComInfo;
/**
* action
*/
public class KqSplitAction extends BaseBean implements Action {
private KQLog kqLog = new KQLog();
@Override
public String execute(RequestInfo request) {
this.writeLog("KqSplitAction", "do action on request:" + request.getRequestid());
String requestid = request.getRequestid();
kqLog.info("do KqSplitAction on requestid:"+requestid);
int requestidInt = Util.getIntValue(requestid, 0);
String workflowid = request.getWorkflowid();
String formid = new WorkflowComInfo().getFormId(workflowid);
try {
KQFlowActiontBiz kqFlowActiontBiz = new KQFlowActiontBiz();
RecordSet rs = new RecordSet();
String proc_set_sql = "select * from kq_att_proc_set where field001 = ? and field002 = ? ";
rs.executeQuery(proc_set_sql, workflowid,formid);
if(rs.next()){
String proc_set_id = rs.getString("id");
//得到这个考勤流程设置是否使用明细
String usedetails = rs.getString("usedetail");
int kqtype = Util.getIntValue(rs.getString("field006"));
kqLog.info("do action on kqtype:" + kqtype+":requestidInt:"+requestidInt);
Map<String, String> map = new HashMap<String, String>();
if(requestidInt > 0){
map.put("requestId", "and t.requestId = " + requestidInt);
}
Map<String,String> result = kqFlowActiontBiz.handleKQFlowAction(proc_set_id, usedetails, requestidInt, kqtype, Util.getIntValue(workflowid), false,false,map);
if(!result.isEmpty()){
String error = Util.null2String(result.get("message"));
request.getRequestManager().setMessageid("666" + request.getRequestid() + "999");
request.getRequestManager().setMessagecontent(error);
return Action.FAILURE_AND_CONTINUE;
}
}
} catch (Exception e) {
kqLog.info("流程数据报错:KqSplitAction:");
StringWriter errorsWriter = new StringWriter();
e.printStackTrace(new PrintWriter(errorsWriter));
kqLog.info(errorsWriter.toString());
request.getRequestManager().setMessageid("11111" + request.getRequestid() + "22222");
request.getRequestManager().setMessagecontent("【考勤报表统计action】报错请联系管理员");
return Action.FAILURE_AND_CONTINUE;
}
return Action.SUCCESS;
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,707 @@
package weaver.interfaces.bnkq.action;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.engine.kq.biz.*;
import com.engine.kq.entity.KQOvertimeRulesDetailEntity;
import com.engine.kq.entity.WorkTimeEntity;
import com.engine.kq.timer.KQOvertimeCardBean;
import com.engine.kq.util.TimeRangeCalculator;
import com.engine.kq.wfset.bean.OvertimeBalanceTimeBean;
import com.engine.kq.wfset.bean.SplitBean;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import weaver.conn.RecordSet;
import weaver.formmode.setup.ModeRightInfo;
import weaver.general.BaseBean;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.hrm.resource.ResourceComInfo;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.Property;
import weaver.soa.workflow.request.RequestInfo;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
/**
*
*/
public class GdJbUpdateAction implements Action {
static String dateFormat = "yyyy-MM-dd";
static SimpleDateFormat format = new SimpleDateFormat(dateFormat);
public GdJbUpdateAction() {
}
@Override
public String execute(RequestInfo info) {
new BaseBean();
BaseBean bb = new BaseBean();
bb.writeLog("固定加班时长写入加班台账");
RecordSet rs = new RecordSet();
int userid = info.getRequestManager().getUser().getUID();
String wfid = info.getWorkflowid();
String reqid = info.getRequestid();
String tablaName = info.getRequestManager().getBillTableName();
try {
//获取主表数据
Map mainInfo = getMainInfo(info);
//加班人
String jbr = Util.null2String(mainInfo.get("jbr"));
//开始日期
String ksrq = Util.null2String(mainInfo.get("ksrq"));
//结束日期
String jsrq = Util.null2String(mainInfo.get("jsrq"));
//加班方式
String jblx = Util.null2String(mainInfo.get("jbxz"));
//报销方式
String bcfs = Util.null2String(mainInfo.get("bcfs"));
//申请事由
String sqsy = Util.null2String(mainInfo.get("sqsy"));
//开始时间
String kssj = Util.null2String(mainInfo.get("kssj"));
//结束时间
String jssj = Util.null2String(mainInfo.get("jssj"));
/*获取考勤组的ID因为考勤组有有效期所以需要传入日期*/
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo();
String groupId = kqGroupMemberComInfo.getKQGroupId(jbr, ksrq);
//管理人员12小时班制考勤组id
String glrygroupid = bb.getPropValue("nbkq_main", "glrygroupid");
bb.writeLog("获取当前人员groupId:" + groupId + "glrygroupid:" + glrygroupid);
if (groupId.equals(glrygroupid)) {
buildOvertime(jbr, ksrq, jsrq, "固定加班流程生成台账", jblx, bcfs, sqsy, ksrq, jsrq, kssj, jssj);
}
} catch (Exception e) {
e.printStackTrace();
bb.writeLog(e);
bb.writeLog("固定加班时长写入加班台账error" + e.getMessage());
info.getRequestManager().setMessageid("2000");
info.getRequestManager().setMessagecontent("固定加班时长写入加班台账error");
return Action.FAILURE_AND_CONTINUE;
}
return Action.SUCCESS;
}
/**
*
*
* @param resourceid
* @param fromDate
* @param toDate
* @param eventtype
*/
public void buildOvertime(String resourceid, String fromDate, String toDate, String eventtype, String jblx, String bxfs, String sqsy, String ksrq, String jsrq, String kssj, String jssj) {
BaseBean bb = new BaseBean();
RecordSet singleRs = new RecordSet();
try {
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo();
KQOverTimeRuleCalBiz kqOverTimeRuleCalBiz = new KQOverTimeRuleCalBiz();
Map<String, Integer> changeTypeMap = Maps.newHashMap();
Map<String, KQOvertimeRulesDetailEntity> overRulesDetailMap = Maps.newHashMap();
Map<String, List<String[]>> restTimeMap = Maps.newHashMap();
Map<String, Integer> computingModeMap = Maps.newHashMap();
//先获取一些前提数据,加班規則和假期規則
kqOverTimeRuleCalBiz.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);
String logKey = "|key|" + resourceid + "_" + fromDate + "_" + toDate;
bb.writeLog("buildOvertime|生成加班调休" + JSONObject.toJSONString(eventLogMap) + "logKey" + 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();
for (int i = 0; i <= betweenDays; i++) {
LocalDate curLocalDate = preFromDate.plusDays(i);
String splitDate = curLocalDate.format(dateFormatter);
// 需审批,以打卡为准,取流程和打卡的交集
doComputingMode4(resourceid, splitDate, dateFormatter, changeTypeMap, overRulesDetailMap, restTimeMap,
computingModeMap, kqTimesArrayComInfo, "", jblx, bxfs, sqsy, ksrq, jsrq, kssj, jssj, singleRs);
}
} catch (Exception e) {
bb.writeLog("加班生成数据报错:KQOverTimeRuleCalBiz:");
}
}
/**
*
*
* @param resourceid
* @param splitDate
* @param dateFormatter
* @param changeTypeMap
* @param overRulesDetailMap
* @param restTimeMap
* @param computingModeMap
* @param kqTimesArrayComInfo
* @param main_uuid
* @param singleRs
*/
private void 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, String jblx, String bxfs, String sqsy, String ksrq, String jsrq, String kssj, String jssj, RecordSet singleRs) throws Exception {
String key = resourceid + "_" + splitDate;
//加班日志记录类
KQWorkTime kqWorkTime = new KQWorkTime();
BaseBean bb = new BaseBean();
WorkTimeEntity workTimeEntity = kqWorkTime.getWorkTime(resourceid, splitDate);
Map<String, Object> workTimeEntityLogMap = Maps.newHashMap();
workTimeEntityLogMap.put("resourceid", resourceid);
workTimeEntityLogMap.put("splitDate", splitDate);
workTimeEntityLogMap.put("workTimeEntity", workTimeEntity);
Map<String, Object> overtimeLogMap = Maps.newLinkedHashMap();
Map<String, Object> eventMap = Maps.newLinkedHashMap();
Map<String, KQOvertimeCardBean> lsCheckInfoMaps = Maps.newLinkedHashMap();
KQOverTimeRuleCalBiz kqOverTimeRuleCalBiz = new KQOverTimeRuleCalBiz();
//获取加班打卡数据
kqOverTimeRuleCalBiz.getOverTimeCardDataMap(resourceid, splitDate, splitDate, dateFormatter, kqTimesArrayComInfo, overRulesDetailMap, changeTypeMap, lsCheckInfoMaps, eventMap);
bb.writeLog("获取打卡数据结束lsCheckInfoMaps:" + JSONObject.toJSONString(lsCheckInfoMaps));
if (lsCheckInfoMaps.isEmpty()) {
bb.writeLog("对应的加班流程数据key" + key);
return;
}
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 + "changeType_key" + changeType_key;
bb.writeLog("changetypeLogInfo:" + changetypeLogInfo);
KQOvertimeRulesDetailEntity kqOvertimeRulesDetailEntity = overRulesDetailMap.get(changeType_key);
if (kqOvertimeCardBean != null) {
int[] initArrays = kqTimesArrayComInfo.getInitArr();
List<Map<String, String>> hasOverTime4SignList = Lists.newArrayList();
getHasOverTimeData(resourceid, realSplitDate, hasOverTime4SignList);
bb.writeLog("kqOvertimeCardBean:" + JSONObject.toJSONString(kqOvertimeCardBean));
bb.writeLog("realSplitDate:" + realSplitDate);
bb.writeLog("hasOverTime4SignList:" + JSONObject.toJSONString(hasOverTime4SignList));
Map<String, String> signinoffMap = kqOverTimeRuleCalBiz.buildOvertimeCard(kqOvertimeCardBean, resourceid, realSplitDate, kqTimesArrayComInfo, restTimeMap, changeType_key, initArrays, hasOverTime4SignList,
overRulesDetailMap, true, overtimeLogMap);
bb.writeLog("signinoffMap:" + JSONObject.toJSONString(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);
Integer check = Integer.valueOf(signinTime.substring(0, 2));
if (check > 24) {
bb.writeLog("不插入台账");
} else {
if (signinTimeIndex < signoutTimeIndex) {
int across_mins = 0;
int kssjIndex = kqTimesArrayComInfo.getArrayindexByTimes(kssj + ":00");
int jssjIndex = kqTimesArrayComInfo.getArrayindexByTimes(jssj + ":00");
int checkIndex = kqTimesArrayComInfo.getArrayindexByTimes("20:00:00");
int check2Index = kqTimesArrayComInfo.getArrayindexByTimes("06:30:00");
String endTime = "";
if (signoutTimeIndex < jssjIndex) {
endTime = signoutTime;
} else {
endTime = jssj + ":00";
}
bb.writeLog("endTime" + endTime);
if (jssjIndex < checkIndex) {
//夜班
//白班
String kssjNew = "";
if (kssjIndex < check2Index) {
kssjNew = "06:30";
} else {
kssjNew = kssj;
}
across_mins = divide(String.valueOf(TimeUtil.timeInterval(ksrq + " " + kssjNew + ":00", jsrq + " " + endTime)), "60").intValue();
} else {
//白班
String kssjNew = "";
if (kssjIndex < checkIndex) {
kssjNew = "20:00";
} else {
kssjNew = kssj;
}
across_mins = divide(String.valueOf(TimeUtil.timeInterval(ksrq + " " + kssjNew + ":00", jsrq + " " + endTime)), "60").intValue();
}
bb.writeLog("最终生成的加班分钟数" + across_mins);
/*获取考勤组的ID因为考勤组有有效期所以需要传入日期*/
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo();
String groupId = kqGroupMemberComInfo.getKQGroupId(resourceid, realSplitDate);
bb.writeLog("获取当前人员groupId:" + groupId + "across_mins:" + across_mins);
//管理人员12小时班制考勤组id
String glrygroupid = bb.getPropValue("nbkq_main", "glrygroupid");
Integer bxszh = changeBxs(across_mins);
Integer yxszh = changeyxs(across_mins);
String searIdFrom = workTimeEntity.getSerialId();
bb.writeLog("半小时计提时长bxszh:" + bxszh + "yxszh:" + yxszh + "searIdFrom:" + searIdFrom);
bb.writeLog("jblx:" + jblx);
if (groupId.equals(glrygroupid)) {
bb.writeLog("是管理人员12小时");
//是管理人员12小时班
if ("0".equals(jblx)) {
//临时去一线
//判断是否小于0.5
if (across_mins < 30) {
bb.writeLog("小于半小时计0");
across_mins = 0;
} else {
bb.writeLog("半小时计提");
across_mins = bxszh;
}
} else {
//管理人员的12小时班制加班规则是加班最小单位是1小时以1小时为递增计算单位,例如1、2、3
//判断是否小于1
if (across_mins < 60) {
bb.writeLog("小于1小时计0");
across_mins = 0;
} else {
bb.writeLog("1小时计提");
across_mins = yxszh;
}
}
}
bb.writeLog("预计插入时长:" + across_mins);
signinTime = kqTimesArrayComInfo.turn48to24Time(signinTime);
signoutTime = kqTimesArrayComInfo.turn48to24Time(signoutTime);
if (changeType == 2) {
deleteJbtz(resourceid, "0", realSplitDate);
insertJbtz(resourceid, String.valueOf(across_mins), resourceid, jblx, bxfs,
signinDate + " " + signinTime, signoutDate + " " + signoutTime, "0",
String.valueOf(changeType), ksrq, jsrq, sqsy, kssj, jssj, realSplitDate, searIdFrom, singleRs);
}
} else {
bb.writeLog("打卡数据异常");
}
}
} else {
bb.writeLog("打卡数据KQOvertimeCardBean为null");
}
}
}
/**
*
*
* @param date1
* @param date2
* @return
*/
public static ArrayList days(String date1, String date2) {
ArrayList L = new ArrayList();
if (date1.equals(date2)) {
System.out.println("两个日期相等!");
return L;
}
String tmp;
if (date1.compareTo(date2) > 0) { // 确保 date1的日期不晚于date2
tmp = date1;
date1 = date2;
date2 = tmp;
}
tmp = format.format(str2Date(date1).getTime() + 3600 * 24 * 1000);
int num = 0;
while (tmp.compareTo(date2) < 0) {
L.add(tmp);
num++;
tmp = format.format(str2Date(tmp).getTime() + 3600 * 24 * 1000);
}
if (num == 0) {
System.out.println("两个日期相邻!");
}
return L;
}
private static Date str2Date(String str) {
if (str == null) {
return null;
}
try {
return format.parse(str);
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
/**
*
*
* @param requestInfo
* @return
*/
private static Map getMainInfo(RequestInfo requestInfo) {
Map map = new HashMap();
Property[] property = requestInfo.getMainTableInfo().getProperty();
for (int i = 0; i < property.length; i++) {
map.put(property[i].getName().toLowerCase(), Util.null2String(property[i].getValue()));
}
return map;
}
/**
*
*
* @param v1
* @param v2
* @return
*/
public static Double multiply(String v1, String v2) {
BigDecimal b1 = new BigDecimal(v1);
BigDecimal b2 = new BigDecimal(v2);
return b1.multiply(b2).doubleValue();
}
/**
*
*
* @param requestid
* @param userid
* @param fromDate
* @param MaxHours
*/
private static void insertLeave(String requestid, Integer userid, String fromDate, Double MaxHours, String durationrule, String newleavetype, String subcompany, String department, String toDate, String wfid, String tablename) {
BaseBean bb = new BaseBean();
//插入加班时间
RecordSet rsInsert = new RecordSet();
String sql = "insert into kq_flow_split_evection (requestid,resourceid,fromdate,fromtime,todate,totime,duration,durationrule,belongdate,newleavetype,subcompanyid,departmentid,workflowid,tablenamedb) "
+ " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?) ";
rsInsert.executeUpdate(sql, requestid, userid, fromDate, "08:00", toDate, "17:00", MaxHours, durationrule, fromDate, newleavetype, subcompany, department, wfid, tablename);
bb.writeLog("insertSql:" + sql);
}
/**
*
*
* @param value
* @return
*/
public static Integer changeBxs(Integer value) {
return (value / 30) * 30;
}
/**
* 1
*
* @param value
* @return
*/
public static Integer changeyxs(Integer value) {
return (value / 60) * 60;
}
/**
*
*
* @param jbr
* @param ly
* @param date
*/
public static void deleteJbtz(String jbr, String ly, String date) {
RecordSet rs = new RecordSet();
String sql = "delete from uf_jbtz where jbr='" + jbr + "' and ly =" + ly + " and gzrq = '" + date + "' ";
rs.executeUpdate(sql);
}
/**
*
*/
public static void insertJbtz(String jbr, String gjsc, String sqr, String jbxz, String bcfs, String zzdksj, String zwdkrq, String ly, String jblx, String ksrq, String jsrq, String sqsy, String kssj, String jssj, String szrq, String searIdFrom, RecordSet singleRs) {
RecordSet rs = new RecordSet();
String idNew = "1";
int modeid = getFormModeIdByCubeName("uf_jbtz");
SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat sdfTime = new SimpleDateFormat("HH:mm:ss");
String modedatacreatedate = sdfDate.format(new Date());
String modedatacreatetime = sdfTime.format(new Date());
try {
ResourceComInfo resourceComInfo = new ResourceComInfo();
String bm = resourceComInfo.getDepartmentID(jbr);
String szbm = resourceComInfo.getDepartmentID(sqr);
String sjh = resourceComInfo.getTelephone(jbr);
String gh = resourceComInfo.getWorkcode(jbr);
String zw = resourceComInfo.getJobActivityDesc(jbr);
Double sc = divide(gjsc, "60");
String jblxNew = "";
if ("1".equals(jblx)) {
jblxNew = "2";
} else if ("2".equals(jblx)) {
jblxNew = "0";
} else if ("3".equals(jblx)) {
jblxNew = "1";
}
int weekDay = TimeUtil.dateWeekday(ksrq);
if (weekDay == 0 || weekDay == 6) {
jblxNew = "1";
}
//如果是休班次,加班类型为休息日加班
if (isRestSerial(searIdFrom, rs)) {
jblxNew = "1";
sc = recalculateOverTime(sc, searIdFrom, ksrq, kssj, jsrq, jssj, rs, singleRs);
}
String sqlMode = "insert into uf_jbtz (jbr,gjsc,bcfs,jbxz,sqr,szbm,sjh,zzdksj,zwdkrq,ly,gh,bm,zw,jblx,ksrq,jsrq,sqsy,kssj,jssj,gzrq,FORMMODEID,MODEDATACREATER,MODEDATACREATERTYPE,MODEDATACREATEDATE,MODEDATACREATETIME) \n" +
"values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
rs.executeUpdate(sqlMode, jbr, sc, bcfs, jbxz, sqr, szbm, sjh, zzdksj, zwdkrq, ly, gh, bm, zw, jblxNew, ksrq, jsrq, sqsy, kssj, jssj, szrq, modeid, jbr, "0", modedatacreatedate, modedatacreatetime);
RecordSet findNew = new RecordSet();
String sqlFindnew = "select Id from uf_jbtz where jbr = '" + jbr + "' and zzdksj = '" + zzdksj + "' and zwdkrq = '" + zwdkrq + "' order by" +
" modedatacreatedate desc,modedatacreatetime desc";
findNew.execute(sqlFindnew);
if (findNew.next()) {
idNew = Util.null2String(findNew.getString("id"));
}
// 权限重构
int dataId = Integer.valueOf(idNew);
ModeRightInfo modeRightInfo = new ModeRightInfo();
modeRightInfo.editModeDataShare(Integer.valueOf(jbr), modeid, dataId);
} catch (Exception e) {
e.printStackTrace();
}
}
private static Double recalculateOverTime(Double sc, String serialId, String ksrq, String kssj, String jsrq, String jssj, RecordSet rs, RecordSet singleRs) {
BaseBean bb = new BaseBean();
try {
boolean isAcross = false;
BigDecimal workTimeTotal = new BigDecimal(TimeUtil.timeInterval(ksrq + " " + kssj + ":00", jsrq + " " + jssj + ":00"));
BigDecimal restTimeCount = new BigDecimal(0);
if (ksrq.compareTo(jsrq) > 0) {
isAcross = true;
}
String restStartSql = "select * from kq_ShiftRestTimeSections where serialid=? and resttype='start'";
rs.executeQuery(restStartSql, serialId);
while (rs.next()) {
//休息开始时间
String startTime = rs.getString("time");
String record1 = rs.getString("record1");
//休息结束时间
String restEndSql = "select * from kq_ShiftRestTimeSections where record1=? and resttype='end'";
singleRs.executeQuery(restEndSql, record1);
singleRs.next();
String endTime = singleRs.getString("time");
if (isAcross) {
double restTime1 = TimeRangeCalculator.getRestTime(kssj, "23:59", startTime, endTime);
double restTime2 = TimeRangeCalculator.getRestTime("00:00", jssj, startTime, endTime);
restTimeCount = restTimeCount.add(BigDecimal.valueOf(restTime1));
restTimeCount = restTimeCount.add(BigDecimal.valueOf(restTime2));
} else {
double restTime = TimeRangeCalculator.getRestTime(kssj, jssj, startTime, endTime);
restTimeCount = restTimeCount.add(BigDecimal.valueOf(restTime));
}
}
sc = divideRoundModeDown(workTimeTotal.subtract(restTimeCount).toString(), "3600");
//加班最小单位是2小时
//一小时和两小时起休班次id
String twoStartSerId = bb.getPropValue("nbkq_main", "twoStartSerId");
if (Arrays.asList(twoStartSerId.split(",")).contains(serialId) && sc < 2) {
sc = 0.0;
}
return sc;
} catch (Exception e) {
bb.writeLog("recalculateOverTime-e-" + e.getMessage());
return sc;
}
}
private static boolean isRestSerial(String serialId, RecordSet rs) {
try {
String querySql = "select rest_shift from kq_ShiftManagement where id=?";
rs.executeQuery(querySql, serialId);
if (rs.next()) {
return rs.getInt("rest_shift") == 1;
}
} catch (Exception e) {
return false;
}
return false;
}
/**
*
*
* @param v1
* @param v2
* @return
*/
public static Double divide(String v1, String v2) {
BigDecimal b1 = new BigDecimal(v1);
BigDecimal b2 = new BigDecimal(v2);
return b1.divide(b2, 2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
public static Double divideRoundModeDown(String v1, String v2) {
BigDecimal b1 = new BigDecimal(v1);
BigDecimal b2 = new BigDecimal(v2);
BigDecimal divide = b1.divide(b2, 2, BigDecimal.ROUND_HALF_UP);
return divide.setScale(0, RoundingMode.DOWN).doubleValue();
}
/**
*
*
* @return
*/
public static Double findSc(String jbr, String gsrq) {
RecordSet rs = new RecordSet();
String sql = "select gjsc from uf_jbtz where jbr = " + jbr + " and gzrq = '" + gsrq + "'";
rs.executeQuery(sql);
String gjsc = "";
if (rs.next()) {
gjsc = Util.null2String(rs.getString("gjsc"));
}
return multiply(gjsc, "60");
}
/**
* formModeId
*
* @param cubeName
* @return int formModeId
*/
private static int getFormModeIdByCubeName(String cubeName) {
RecordSet rs = new RecordSet();
rs.executeQuery("select t1.id from modeinfo t1\n" +
" left join workflow_bill t2\n" +
" on t1.formid=t2.id\n" +
" where t2.tablename='" + cubeName + "'");
rs.next();
return rs.getInt("id");
}
/**
*
*
* @param resourceid
* @param fromDate
* @param toDate
* @param splitBeanMaps
* @param dateFormatter
*/
private void 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);
}
}
}
/**
*
*
* @param resourceid
* @param belongdate
* @param hasOverTimeList
*/
private 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);
}
}
}

@ -0,0 +1,189 @@
package weaver.interfaces.bnkq.action;
import com.engine.kq.biz.KQWorkTime;
import com.engine.kq.entity.WorkTimeEntity;
import com.engine.workflow.service.HtmlToPdfService;
import org.apache.commons.lang3.StringUtils;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.PinyinUtil;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.Property;
import weaver.soa.workflow.request.RequestInfo;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* Action
*/
public class UpdateCcTimeAction implements Action {
static String dateFormat = "yyyy-MM-dd";
static SimpleDateFormat format = new SimpleDateFormat(dateFormat);
public UpdateCcTimeAction() {
}
@Override
public String execute(RequestInfo info) {
new BaseBean();
BaseBean bb = new BaseBean();
bb.writeLog("更新人员出差时长");
RecordSet rs = new RecordSet();
int userid = info.getRequestManager().getUser().getUID();
String wfid = info.getWorkflowid();
String reqid = info.getRequestid();
String tablaName = info.getRequestManager().getBillTableName();
try {
//获取主表数据
Map mainInfo = getMainInfo(info);
//申请人
String sqr = Util.null2String(mainInfo.get("ccr"));
//实际出差开始时间
String sjksrq = Util.null2String(mainInfo.get("sjccksrq"));
//实际出差结束时间
String sjccjsrq = Util.null2String(mainInfo.get("sjccjsrq"));
//部门
String szbm = Util.null2String(mainInfo.get("szbm"));
//分部
String szgs = Util.null2String(mainInfo.get("szgs"));
//相差天数
Integer cz = TimeUtil.dateInterval(sjksrq, sjccjsrq) + 1;
//插入出差表
Double czours = multiply(String.valueOf(cz), "8");
Set<String> all = new HashSet<>();
all.add(sjksrq);
List<String> back = days(sjksrq, sjccjsrq);
all.addAll(back);
all.add(sjccjsrq);
KQWorkTime kqWorkTime = new KQWorkTime();
kqWorkTime.setIsFormat(true);
for (String date : all) {
bb.writeLog("date:" + date);
WorkTimeEntity tmpworkTime = kqWorkTime.getWorkTime(sqr, date);
if (tmpworkTime.getWorkMins() > 0) {
bb.writeLog("当天排班了:" + tmpworkTime.getWorkMins());
insertLeave(reqid, Integer.valueOf(sqr), date, 8.00, "3", "1", szgs, szbm, date, wfid, tablaName);
insertDetail(sqr, date, rs);
}
}
} catch (Exception e) {
e.printStackTrace();
bb.writeLog(e);
bb.writeLog("更新人员出差时长error" + e.getMessage());
info.getRequestManager().setMessageid("2000");
info.getRequestManager().setMessagecontent("更新人员出差时长error");
return Action.FAILURE_AND_CONTINUE;
}
return Action.SUCCESS;
}
private void insertDetail(String resourceId, String date, RecordSet rs) {
String sql = "update kq_format_detail set evectionMins=480,absenteeismMins=0 where resourceid=? and kqdate='" + date + "'";
rs.executeUpdate(sql, resourceId);
}
/**
*
*
* @param date1
* @param date2
* @return
*/
public static ArrayList days(String date1, String date2) {
ArrayList L = new ArrayList();
if (date1.equals(date2)) {
System.out.println("两个日期相等!");
return L;
}
String tmp;
if (date1.compareTo(date2) > 0) { // 确保 date1的日期不晚于date2
tmp = date1;
date1 = date2;
date2 = tmp;
}
tmp = format.format(str2Date(date1).getTime() + 3600 * 24 * 1000);
int num = 0;
while (tmp.compareTo(date2) < 0) {
L.add(tmp);
num++;
tmp = format.format(str2Date(tmp).getTime() + 3600 * 24 * 1000);
}
if (num == 0)
System.out.println("两个日期相邻!");
return L;
}
private static Date str2Date(String str) {
if (str == null)
return null;
try {
return format.parse(str);
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
/**
*
*
* @param requestInfo
* @return
*/
private static Map getMainInfo(RequestInfo requestInfo) {
Map map = new HashMap();
Property[] property = requestInfo.getMainTableInfo().getProperty();
for (int i = 0; i < property.length; i++) {
map.put(property[i].getName().toLowerCase(), Util.null2String(property[i].getValue()));
}
return map;
}
/**
*
*
* @param v1
* @param v2
* @return
*/
public static Double multiply(String v1, String v2) {
BigDecimal b1 = new BigDecimal(v1);
BigDecimal b2 = new BigDecimal(v2);
return b1.multiply(b2).doubleValue();
}
/**
*
*
* @param requestid
* @param userid
* @param fromDate
* @param MaxHours
*/
private static void insertLeave(String requestid, Integer userid, String fromDate, Double MaxHours, String durationrule, String newleavetype, String subcompany, String department, String toDate, String wfid, String tablename) {
BaseBean bb = new BaseBean();
//插入加班时间
RecordSet rsInsert = new RecordSet();
String sql = "insert into kq_flow_split_evection (requestid,resourceid,fromdate,fromtime,todate,totime,duration,durationrule,belongdate,newleavetype,subcompanyid,departmentid,workflowid,tablenamedb) "
+ " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?) ";
rsInsert.executeUpdate(sql, requestid, userid, fromDate, "08:00", toDate, "17:00", MaxHours, durationrule, fromDate, newleavetype, subcompany, department, wfid, tablename);
bb.writeLog("insertSql:" + sql);
}
}
Loading…
Cancel
Save