#NBJH-1# SVN上的源码

main
shilei 2 years ago
parent 9b725d26a7
commit d3cce7870d

@ -0,0 +1,431 @@
package com.engine.kq.bean;
import com.engine.kq.biz.KQLeaveRulesComInfo;
import com.engine.kq.biz.KQLeaveRulesDetailComInfo;
import com.engine.kq.biz.KQUsageHistoryBiz;
import com.engine.kq.entity.KQUsageHistoryEntity;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.resource.ResourceComInfo;
import weaver.systeminfo.SystemEnv;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
/**
* --Excel
*/
public class KQBalanceOfLeave extends BaseBean {
/**
* ID
*/
private String resourceId;
/**
*
*/
private String workcode ;
/**
*
*/
private String lastName;
/**
* ID
*/
private String leaveRulesId;
/**
*
*/
private String belongYear;
/**
* ()
*/
private double baseAmount = 0.00;
/**
* ()使
*/
private double usedAmount = 0.00;
/**
* ()
*/
private double extraAmount = 0.00;
/**
* (使)
*/
private double baseAmount2 = 0.00;
/**
* (使)使
*/
private double usedAmount2 = 0.00;
/**
* (使)
*/
private double extraAmount2 = 0.00;
/**
*
*/
private int userlanguage = 7;
/**
* Excel
*/
private String operator;
/**
* --Excel
*
* @return
*/
public String valExcelData() {
String errorInfo = "";
if (!isExist(resourceId, lastName)) {
errorInfo = SystemEnv.getHtmlLabelName(389985, userlanguage);//ID和姓名不匹配
return errorInfo;
}
return errorInfo;
}
/**
*
*
* @return
*/
public String save() {
String resultStr = "false";
try {
/*获取当前日期,当前时间*/
Calendar today = Calendar.getInstance();
String currentDate = Util.add0(today.get(Calendar.YEAR), 4) + "-" +
Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-" +
Util.add0(today.get(Calendar.DAY_OF_MONTH), 2);
String currentTime = Util.add0(today.get(Calendar.HOUR_OF_DAY), 2) + ":" +
Util.add0(today.get(Calendar.MINUTE), 2) + ":" +
Util.add0(today.get(Calendar.SECOND), 2);
/********************************************************************************************************/
/*获取人员的相关信息*/
ResourceComInfo resourceComInfo = new ResourceComInfo();
/*分部ID*/
String subcompanyId = resourceComInfo.getSubCompanyID(this.resourceId);
/*入职日期*/
String companyStartDate = resourceComInfo.getCompanyStartDate(this.resourceId);
/********************************************************************************************************/
/*获取假期类型的相关设置*/
KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo();
/*请假最小单位*/
String minimumUnit = rulesComInfo.getMinimumUnit(this.leaveRulesId);
/********************************************************************************************************/
/*获取假期规则(一个假期类型下可能存在多个假期规则)的相关设置*/
KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo();
/*请假时长计算方式1-按工作日计算请假时长、2-按自然日计算请假时长*/
int distributionMode = Util.getIntValue(detailComInfo.getDistributionMode(this.leaveRulesId, subcompanyId), 1);
/*有效期规则0-永久有效、1-按自然年1月1日-12月31日、2-按入职日期起12个月、3-自定义次年失效日期*/
int validityRule = validityRule = Util.getIntValue(detailComInfo.getValidityRule(this.leaveRulesId, subcompanyId), 0);
;
/*失效日期--月当有效期规则选择4-自定义次年失效日期时有效)*/
String expirationMonth = detailComInfo.getExpirationMonth(this.leaveRulesId, subcompanyId);
/*失效日期--日当有效期规则选择4-自定义次年失效日期时有效)*/
String expirationDay = detailComInfo.getExpirationDay(this.leaveRulesId, subcompanyId);
/*允许延长有效期0-不允许、1-允许*/
int extensionEnable = Util.getIntValue(detailComInfo.getExtensionEnable(this.leaveRulesId, subcompanyId), 0);
/*允许超过有效期天数*/
int extendedDays = Util.getIntValue(detailComInfo.getExtendedDays(this.leaveRulesId, subcompanyId), 0);
/********************************************************************************************************/
/*员工假期余额变更记录*/
String insertOrUpdate = "";
KQUsageHistoryEntity usageHistoryEntity = new KQUsageHistoryEntity();//员工假期余额变更记录实体类
List<KQUsageHistoryEntity> usageHistoryEntityList = new ArrayList<KQUsageHistoryEntity>();//员工假期余额变更记录集合
/********************************************************************************************************/
double oldBaseAmount = 0.00;
double oldUsedAmount = 0.00;
double oldExtraAmount = 0.00;
double oldBaseAmount2 = 0.00;
double oldUsedAmount2 = 0.00;
double oldExtraAmount2 = 0.00;
double newBaseAmount = 0.00;
double newUsedAmount = 0.00;
double newExtraAmount = 0.00;
double newBaseAmount2 = 0.00;
double newUsedAmount2 = 0.00;
double newExtraAmount2 = 0.00;
int status = 0;
String expirationDate = "";
/*计算有效期 start*/
if (validityRule == 0) {
/*不限制有效期,默认永久有效*/
status = 0;
} else if (validityRule == 1) {
/*按自然年1月1日-12月31日*/
if (extensionEnable == 1) {
/*允许延长有效期*/
expirationDate = DateUtil.addDate(this.belongYear + "-12-31", extendedDays);
if (Util.dayDiff(expirationDate, currentDate) > 1) {
status = 1;
}
} else {
expirationDate = this.belongYear + "-12-31";
if (Util.dayDiff(expirationDate, currentDate) > 1) {
status = 1;
}
}
} else if (validityRule == 2) {
/*按入职日期起12个月*/
if (companyStartDate.equals("")) {
status = 1;
} else if (extensionEnable == 1) {
/*允许延长有效期*/
expirationDate = DateUtil.addDate((Util.getIntValue(this.belongYear) + 1) + companyStartDate.substring(4), extendedDays);
if (Util.dayDiff(expirationDate, currentDate) > 1) {
status = 1;
}
} else {
expirationDate = (Util.getIntValue(this.belongYear) + 1) + companyStartDate.substring(4);
if (Util.dayDiff(expirationDate, currentDate) > 1) {
status = 1;
}
}
} else if (validityRule == 3) {
/*自定义次年失效日期*/
if (extensionEnable == 1) {
/*允许延长有效期*/
expirationDate = DateUtil.addDate((Util.getIntValue(this.belongYear) + 1) + "-" + expirationMonth + "-" + expirationDay, extendedDays);
if (Util.dayDiff(expirationDate, currentDate) > 1) {
status = 1;
}
} else {
expirationDate = (Util.getIntValue(this.belongYear) + 1) + "-" + expirationMonth + "-" + expirationDay;
if (Util.dayDiff(expirationDate, currentDate) > 1) {
status = 1;
}
}
}
/*计算有效期 end*/
newBaseAmount = this.baseAmount;
newExtraAmount = this.extraAmount;
newUsedAmount = this.usedAmount;
if (distributionMode == 6) {
newBaseAmount2 = this.baseAmount2;
newExtraAmount2 = this.extraAmount2;
newUsedAmount2 = this.usedAmount2;
}
boolean flag = true;//记录SQL操作是否成功
String searchSql = "select * from kq_BalanceOfLeave where leaveRulesId=? and resourceId=? and belongYear=?";
String updateSql = "update kq_BalanceOfLeave set baseAmount=?,extraAmount=?,usedAmount=?,baseAmount2=?,extraAmount2=?,usedAmount2=?,status=?,expirationDate=? where leaveRulesId=? and resourceId=? and belongYear=?";
String insertSql = "insert into kq_BalanceOfLeave(baseAmount,extraAmount,usedAmount,baseAmount2,extraAmount2,usedAmount2,status,expirationDate,leaveRulesId,resourceId,belongYear) values(?,?,?,?,?,?,?,?,?,?,?) ";
RecordSet recordSet = new RecordSet();
recordSet.executeQuery(searchSql, this.leaveRulesId, this.resourceId, this.belongYear);
if (recordSet.next()) {
oldBaseAmount = Util.getDoubleValue(recordSet.getString("baseAmount"), 0.00);
oldExtraAmount = Util.getDoubleValue(recordSet.getString("extraAmount"), 0.00);
oldUsedAmount = Util.getDoubleValue(recordSet.getString("usedAmount"), 0.00);
if (distributionMode == 6) {
oldBaseAmount2 = Util.getDoubleValue(recordSet.getString("baseAmount2"), 0.00);
oldExtraAmount2 = Util.getDoubleValue(recordSet.getString("extraAmount2"), 0.00);
oldUsedAmount2 = Util.getDoubleValue(recordSet.getString("usedAmount2"), 0.00);
}
/*更新员工假期余额 start*/
flag = recordSet.executeUpdate(updateSql, String.format("%.2f", newBaseAmount), String.format("%.2f", newExtraAmount), String.format("%.2f", newUsedAmount), String.format("%.2f", newBaseAmount2), String.format("%.2f", newExtraAmount2), String.format("%.2f", newUsedAmount2), status, expirationDate, this.leaveRulesId, this.resourceId, this.belongYear);
resultStr = String.valueOf(flag);
if (!flag) {
resultStr = "false";
return resultStr;
}
/*更新员工假期余额 end*/
insertOrUpdate = "update";
} else {
/*新增员工假期余额 start*/
flag = recordSet.executeUpdate(insertSql, String.format("%.2f", newBaseAmount), String.format("%.2f", newExtraAmount), String.format("%.2f", newUsedAmount), String.format("%.2f", newBaseAmount2), String.format("%.2f", newExtraAmount2), String.format("%.2f", newUsedAmount2), status, expirationDate, this.leaveRulesId, this.resourceId, this.belongYear);
resultStr = String.valueOf(flag);
if (!flag) {
return resultStr;
}
/*新增员工假期余额 end*/
insertOrUpdate = "insert";
}
/*员工假期余额变更记录 start*/
usageHistoryEntity = new KQUsageHistoryEntity();
usageHistoryEntity.setLeaveRulesId(this.leaveRulesId);
usageHistoryEntity.setRelatedId(this.resourceId);
usageHistoryEntity.setWfRequestId("");
usageHistoryEntity.setOperator(this.operator);
usageHistoryEntity.setOperateDate(currentDate);
usageHistoryEntity.setOperateTime(currentTime);
usageHistoryEntity.setOperateType("7");
usageHistoryEntity.setBelongYear(this.belongYear);
usageHistoryEntity.setOldBaseAmount(String.format("%.2f", oldBaseAmount));
usageHistoryEntity.setNewBaseAmount(String.format("%.2f", newBaseAmount));
usageHistoryEntity.setOldExtraAmount(String.format("%.2f", oldExtraAmount));
usageHistoryEntity.setNewExtraAmount(String.format("%.2f", newExtraAmount));
usageHistoryEntity.setOldUsedAmount(String.format("%.2f", oldUsedAmount));
usageHistoryEntity.setNewUsedAmount(String.format("%.2f", newUsedAmount));
usageHistoryEntity.setOldBaseAmount2(String.format("%.2f", oldBaseAmount2));
usageHistoryEntity.setNewBaseAmount2(String.format("%.2f", newBaseAmount2));
usageHistoryEntity.setOldExtraAmount2(String.format("%.2f", oldExtraAmount2));
usageHistoryEntity.setNewExtraAmount2(String.format("%.2f", newExtraAmount2));
usageHistoryEntity.setOldUsedAmount2(String.format("%.2f", oldUsedAmount2));
usageHistoryEntity.setNewUsedAmount2(String.format("%.2f", newUsedAmount2));
usageHistoryEntity.setOldMinimumUnit(minimumUnit);
usageHistoryEntity.setNewMinimumUnit(minimumUnit);
usageHistoryEntity.setInsertOrUpdate(insertOrUpdate);
usageHistoryEntityList.add(usageHistoryEntity);
KQUsageHistoryBiz usageHistoryBiz = new KQUsageHistoryBiz();
flag = usageHistoryBiz.save(usageHistoryEntityList);
resultStr = String.valueOf(flag);
if (!flag) {
return resultStr;
}
/*员工假期余额变更记录 end*/
} catch (Exception e) {
writeLog(e);
}
return resultStr;
}
/**
* ID
*
* @param resourceId
* @param lastName
* @return
*/
private boolean isExist(String resourceId, String lastName) {
String sql = "select 1 from HrmResource where id=? ";
RecordSet recordSet = new RecordSet();
recordSet.executeQuery(sql, resourceId);
if (recordSet.next()) {
return true;
} else {
return false;
}
}
public String getResourceId() {
return resourceId;
}
public void setResourceId(String resourceId) {
this.resourceId = resourceId;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getLeaveRulesId() {
return leaveRulesId;
}
public void setLeaveRulesId(String leaveRulesId) {
this.leaveRulesId = leaveRulesId;
}
public String getBelongYear() {
return belongYear;
}
public void setBelongYear(String belongYear) {
this.belongYear = belongYear;
}
public double getBaseAmount() {
return baseAmount;
}
public void setBaseAmount(double baseAmount) {
this.baseAmount = baseAmount;
}
public double getUsedAmount() {
return usedAmount;
}
public void setUsedAmount(double usedAmount) {
this.usedAmount = usedAmount;
}
public double getExtraAmount() {
return extraAmount;
}
public void setExtraAmount(double extraAmount) {
this.extraAmount = extraAmount;
}
public double getBaseAmount2() {
return baseAmount2;
}
public void setBaseAmount2(double baseAmount2) {
this.baseAmount2 = baseAmount2;
}
public double getUsedAmount2() {
return usedAmount2;
}
public void setUsedAmount2(double usedAmount2) {
this.usedAmount2 = usedAmount2;
}
public double getExtraAmount2() {
return extraAmount2;
}
public void setExtraAmount2(double extraAmount2) {
this.extraAmount2 = extraAmount2;
}
public void setUserLanguage(String languageId) {
this.userlanguage = Util.getIntValue(languageId, 7);
}
public String getOperator() {
return operator;
}
public void setOperator(String operator) {
this.operator = operator;
}
public String getWorkcode() {
return workcode;
}
public void setWorkcode(String workcode) {
this.workcode = workcode;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,709 @@
package com.engine.kq.biz;
import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean;
import com.engine.kq.entity.KQOvertimeRulesDetailEntity;
import com.engine.kq.log.KQLog;
import com.engine.kq.util.KQDurationCalculatorUtil;
import com.engine.kq.wfset.bean.OvertimeBalanceTimeBean;
import com.engine.kq.wfset.bean.SplitBean;
import com.engine.kq.wfset.util.KQFlowUtil;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.springframework.beans.BeanUtils;
import weaver.general.Util;
/**
*
*
*/
public class KQOverTimeFlowBiz {
private KQLog kqLog = new KQLog();
/**
*
*
*
* A-B A24A
* A-A24A
* -A0A
*
*
*
* @param splitBean
* @param splitBeans
*/
public void getSplitDurationBean_new(SplitBean splitBean,List<SplitBean> splitBeans) {
try{
long a = System.currentTimeMillis();
double oneDayHour = KQFlowUtil.getOneDayHour(splitBean.getDurationTypeEnum(),"");
int workmins = (int)(oneDayHour * 60);
String resourceid = splitBean.getResourceId();
String fromDate = splitBean.getFromdatedb();
String toDate = splitBean.getTodatedb();
String overtime_type = splitBean.getOvertime_type();
LocalDate localFromDate = LocalDate.parse(fromDate);
LocalDate localToDate = LocalDate.parse(toDate);
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate preFromDate = localFromDate.minusDays(1);
KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo();
KQOvertimeRulesBiz kqOvertimeRulesBiz = new KQOvertimeRulesBiz();
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);
if(overRulesDetailMap.isEmpty()){
return;
}
String fromTime = splitBean.getFromtimedb();
String toTime = splitBean.getTotimedb();
long betweenDays = localToDate.toEpochDay() - preFromDate.toEpochDay();
//默认是从加班开始日期的前一天开始计算 需要特殊处理的就三个情况i=0的时候i=1的时候就是加班流程开始日期那一天i=最后一天就是加班流程结束日期那一天
for (int i = 0; i <= betweenDays; i++) {
SplitBean overSplitBean = new SplitBean();
//然后把bean重新赋值下根据拆分后的时间
BeanUtils.copyProperties(splitBean, overSplitBean);
//从加班流程开始的前一天开始算归属
LocalDate curLocalDate = preFromDate.plusDays(i);
String splitDate = curLocalDate.format(dateFormatter);
String preSplitDate = LocalDate.parse(splitDate).minusDays(1).format(dateFormatter);
LocalDate nextLocalDate = curLocalDate.plusDays(1);
String nextSplitDate = nextLocalDate.format(dateFormatter);
String change_key = splitDate+"_"+resourceid;
String pre_change_key = preSplitDate+"_"+resourceid;
String next_change_key = nextSplitDate+"_"+resourceid;
int changeType = Util.getIntValue(""+changeTypeMap.get(change_key),-1);
int preChangeType = Util.getIntValue(""+changeTypeMap.get(pre_change_key),-1);
int next_changeType = Util.getIntValue(""+changeTypeMap.get(next_change_key),-1);
boolean shouldAcross = false;
String changeType_key = splitDate+"_"+changeType;
String preChangeType_key = preSplitDate+"_"+preChangeType;
String nextChangeType_key = nextSplitDate+"_"+next_changeType;
if(!computingModeMap.containsKey(changeType_key)){
continue;
}
int computingMode = computingModeMap.get(changeType_key);
if(computingMode == 3){
//如果是纯打卡为主的不生成加班
continue;
}
int[] initArrays = kqTimesArrayComInfo.getInitArr();
//当前日期的加班分割点 分割点都是次日的
String overtime_cut_point = "";
int before_startTime = 0;
int startTime = 0;
int curMins = 0 ;
//排除休息类型
int restTimeType = -1;
String next_beginwork_time = "";
String cur_beginwork_time = "";
String serialid = "";
//需要知道明日的类型:如果今天是工作日的话,那么今天的加班临界点可能和明日的上班时间冲突,需要知道明日的上班时间进行比较,
// 如果今天是休息日,那么明天如果是工作日的话,默认规则下,明天的上班前都是属于今天的加班区间
if(next_changeType == 2){
ShiftInfoBean next_shiftInfoBean = KQDurationCalculatorUtil.getWorkTime(resourceid, nextSplitDate, false);
if(next_shiftInfoBean != null){
List<int[]> workLongTimeIndex = next_shiftInfoBean.getWorkLongTimeIndex();
List<int[]> real_workLongTimeIndex = Lists.newArrayList();
get_real_workLongTimeIndex(workLongTimeIndex,real_workLongTimeIndex,next_shiftInfoBean,kqTimesArrayComInfo,splitBean);
if(real_workLongTimeIndex != null && !real_workLongTimeIndex.isEmpty()){
next_beginwork_time = kqTimesArrayComInfo.getTimesByArrayindex(real_workLongTimeIndex.get(0)[0]);
}
}
}
if(changeType == 2){
ShiftInfoBean cur_shiftInfoBean = KQDurationCalculatorUtil.getWorkTime(resourceid, splitDate, false);
if(cur_shiftInfoBean != null){
List<int[]> workLongTimeIndex = cur_shiftInfoBean.getWorkLongTimeIndex();
List<int[]> real_workLongTimeIndex = Lists.newArrayList();
get_real_workLongTimeIndex(workLongTimeIndex,real_workLongTimeIndex,cur_shiftInfoBean,kqTimesArrayComInfo,splitBean);
if(real_workLongTimeIndex != null && !real_workLongTimeIndex.isEmpty()){
cur_beginwork_time = kqTimesArrayComInfo.getTimesByArrayindex(real_workLongTimeIndex.get(0)[0]);
}
}
}
boolean needSplitByTime = false;
// 按照加班时长转调休的 时长设置
List<String> timepointList = null;
List<OvertimeBalanceTimeBean> overtimeBalanceTimeBeans = Lists.newArrayList();
KQOvertimeRulesDetailEntity curKqOvertimeRulesDetailEntity = overRulesDetailMap.get(changeType_key);
if(curKqOvertimeRulesDetailEntity != null){
int has_cut_point = curKqOvertimeRulesDetailEntity.getHas_cut_point();
before_startTime = curKqOvertimeRulesDetailEntity.getBefore_startTime();
int overtimeEnable = curKqOvertimeRulesDetailEntity.getOvertimeEnable();
if(overtimeEnable != 1){
continue;
}
if(has_cut_point != 1){
before_startTime = -1;
}
startTime = curKqOvertimeRulesDetailEntity.getStartTime();
restTimeType = curKqOvertimeRulesDetailEntity.getRestTimeType();
int paidLeaveEnable = kqOverTimeRuleCalBiz.getPaidLeaveEnable(curKqOvertimeRulesDetailEntity,overtime_type);
needSplitByTime = kqOverTimeRuleCalBiz.getNeedSplitByTime(curKqOvertimeRulesDetailEntity,paidLeaveEnable);
if(needSplitByTime){
int ruleDetailid = curKqOvertimeRulesDetailEntity.getId();
Map<String,List<String>> balanceTimethDetailMap = kqOvertimeRulesBiz.getBalanceTimeDetailMap(ruleDetailid);
if(balanceTimethDetailMap != null && !balanceTimethDetailMap.isEmpty()){
timepointList = balanceTimethDetailMap.get("timepointList");
}
}
if(has_cut_point == 0){
if(changeType == 2){
overtime_cut_point = cur_beginwork_time;
}else {
if(next_beginwork_time.length() > 0){
overtime_cut_point = next_beginwork_time;
}
}
}else{
overtime_cut_point = curKqOvertimeRulesDetailEntity.getCut_point();
if(next_beginwork_time.length() > 0){
int next_beginwork_time_index = kqTimesArrayComInfo.getArrayindexByTimes(next_beginwork_time);
int overtime_cut_point_index = kqTimesArrayComInfo.getArrayindexByTimes(overtime_cut_point);
if(overtime_cut_point_index > next_beginwork_time_index){
overtime_cut_point = next_beginwork_time;
}
}
}
if(overtime_cut_point.length() == 0){
overtime_cut_point = "00:00";
}
}else{
continue;
}
int fromTime_index = 0;
int toTime_index = 0;
if(i == 0){
//i=0就是加班开始日期的前一天只有当加班临界点超过了加班流程开始时间的话i=0才会有可能计算出时长
if(overtime_cut_point.compareTo(fromTime) > 0){
fromTime_index = kqTimesArrayComInfo.getArrayindexByTimes(kqTimesArrayComInfo.turn24to48Time(fromTime));
toTime_index = kqTimesArrayComInfo.getArrayindexByTimes(kqTimesArrayComInfo.turn24to48Time(overtime_cut_point));
if(fromDate.equalsIgnoreCase(toDate)){
//如果开始日期和结束日期是同一天,还需要比较流程的结束时间和归属点的大小
int oriTotime_index = kqTimesArrayComInfo.getArrayindexByTimes(kqTimesArrayComInfo.turn24to48Time(toTime));
if(toTime_index > oriTotime_index){
toTime_index = oriTotime_index;
}
}
Arrays.fill(initArrays, fromTime_index, toTime_index, 0);
// 1-节假日、2-工作日、3-休息日
if(changeType == 1){
handle_changeType_1(initArrays,overRulesDetailMap,nextChangeType_key,next_changeType,next_beginwork_time);
}else if(changeType == 2){
boolean isok = handle_changeType_2(initArrays, resourceid, splitDate, before_startTime, startTime, fromTime_index,kqTimesArrayComInfo,splitBean,
toTime_index);
serialid = splitBean.getSerialid();
if(!isok){
continue;
}
}else if(changeType == 3){
handle_changeType_3(initArrays,overRulesDetailMap,nextChangeType_key,next_changeType,next_beginwork_time);
}
if(restTimeType == 1){
//如果排除设置的休息时间
handle_resttime(restTimeMap,changeType_key,kqTimesArrayComInfo,shouldAcross,initArrays);
}
curMins = kqTimesArrayComInfo.getCnt(initArrays, fromTime_index,toTime_index,0);
if(restTimeType == 2){
//如果排除休息时间是扣除时长
curMins = handle_restlength(curMins,restTimeMap,changeType_key);
}
}else{
continue;
}
}else{
//除了i=0的情况其他的每一天都是要获取一下昨日的临界点的
String pre_overtime_cut_point = get_pre_overtime_cut_point(overRulesDetailMap,preChangeType_key,resourceid,preSplitDate,splitDate,preChangeType,kqTimesArrayComInfo,splitBean,changeType);
if(changeType == 2){
//如果今天是工作日,昨日的打卡归属会受到今日的上班前开始加班分钟数的影响
int cur_beginwork_time_index = kqTimesArrayComInfo.getArrayindexByTimes(cur_beginwork_time);
if(before_startTime > -1){
int pre_overtime_cut_point_index = kqTimesArrayComInfo.getArrayindexByTimes(pre_overtime_cut_point);
int before_cur_beginwork_time_index = cur_beginwork_time_index - before_startTime;
}
}
//计算区间加班开始日期和加班结束日期这两天都是要特殊处理的
fromTime_index = kqTimesArrayComInfo.getArrayindexByTimes(pre_overtime_cut_point);
if(i == 1){
if(fromTime.compareTo(pre_overtime_cut_point) > 0){
fromTime_index = kqTimesArrayComInfo.getArrayindexByTimes(fromTime);
}
}
if(i == betweenDays){
toTime_index = kqTimesArrayComInfo.getArrayindexByTimes(toTime);
}else{
toTime_index = kqTimesArrayComInfo.turn24to48TimeIndex(kqTimesArrayComInfo.getArrayindexByTimes(overtime_cut_point));
if(next_beginwork_time.length() > 0){
int overtime_cut_point_index = kqTimesArrayComInfo.getArrayindexByTimes(overtime_cut_point);
int next_beginwork_time_index = kqTimesArrayComInfo.getArrayindexByTimes(next_beginwork_time);
//如果临界点都已经超过第二天上班的开始时间了,要相应的缩短成第二天上班时间
if(overtime_cut_point_index > next_beginwork_time_index){
toTime_index = kqTimesArrayComInfo.turn24to48TimeIndex(next_beginwork_time_index);
}
}
if(i == betweenDays-1){
int ori_totime_index = kqTimesArrayComInfo.turn48to24TimeIndex(toTime_index);
int last_toTime_index = kqTimesArrayComInfo.getArrayindexByTimes(toTime);
if(ori_totime_index > last_toTime_index){
toTime_index = kqTimesArrayComInfo.turn24to48TimeIndex(last_toTime_index);
}
}
}
System.out.println(i+":betweenDays:"+betweenDays+":fromTime_index:"+fromTime_index+":toTime_index:"+toTime_index+":changeType:"+changeType);
if(fromTime_index > toTime_index){
continue;
}
Arrays.fill(initArrays, fromTime_index, toTime_index, 0);
if(changeType == 1){
handle_changeType_1(initArrays, overRulesDetailMap, nextChangeType_key, next_changeType,
next_beginwork_time);
}else if(changeType == 2){
serialid = splitBean.getSerialid();
boolean isok = handle_changeType_2(initArrays, resourceid, splitDate, before_startTime, startTime, fromTime_index,
kqTimesArrayComInfo, splitBean, toTime_index);
if(!isok){
continue;
}
}else if(changeType == 3){
handle_changeType_3(initArrays, overRulesDetailMap, nextChangeType_key, next_changeType,
overtime_cut_point);
}
if(restTimeType == 1) {
//如果排除设置的休息时间
handle_resttime(restTimeMap, changeType_key, kqTimesArrayComInfo, shouldAcross,initArrays);
}
curMins = kqTimesArrayComInfo.getCnt(initArrays, fromTime_index,toTime_index,0);
if(restTimeType == 2){
//如果排除休息时间是扣除时长
curMins = handle_restlength(curMins,restTimeMap,changeType_key);
}
}
int minimumUnit = curKqOvertimeRulesDetailEntity.getMinimumLen();
if(curMins < minimumUnit){
continue;
}
if(needSplitByTime){
kqOverTimeRuleCalBiz.get_overtimeBalanceTimeBeans(timepointList,overtimeBalanceTimeBeans,kqTimesArrayComInfo,initArrays,toTime_index,fromTime_index,0);
if(overtimeBalanceTimeBeans != null && !overtimeBalanceTimeBeans.isEmpty()){
String bean_cross_fromtime = kqTimesArrayComInfo.getTimesByArrayindex(fromTime_index);
String bean_cross_totime = kqTimesArrayComInfo.getTimesByArrayindex(toTime_index);
for(int timeIndex = 0 ; timeIndex < overtimeBalanceTimeBeans.size() ;timeIndex++) {
OvertimeBalanceTimeBean overtimeBalanceTimeBean = overtimeBalanceTimeBeans.get(timeIndex);
String timePointStart = overtimeBalanceTimeBean.getTimepoint_start();
String timePointEnd = overtimeBalanceTimeBean.getTimepoint_end();
boolean isNeedTX = overtimeBalanceTimeBean.isNeedTX();
int timePointStart_index = kqTimesArrayComInfo.getArrayindexByTimes(timePointStart);
int timePointEnd_index = kqTimesArrayComInfo.getArrayindexByTimes(timePointEnd);
if(timePointStart_index > fromTime_index){
bean_cross_fromtime = kqTimesArrayComInfo.getTimesByArrayindex(timePointStart_index);
}else{
bean_cross_fromtime = kqTimesArrayComInfo.getTimesByArrayindex(fromTime_index);
}
if(timePointEnd_index < toTime_index){
bean_cross_totime = kqTimesArrayComInfo.getTimesByArrayindex(timePointEnd_index);
}else{
bean_cross_totime = kqTimesArrayComInfo.getTimesByArrayindex(toTime_index);
}
int timepoint_mins = overtimeBalanceTimeBean.getTimepoint_mins();
if(isNeedTX){
if(timepoint_mins > 0){
overSplitBean = new SplitBean();
//然后把bean重新赋值下根据拆分后的时间
BeanUtils.copyProperties(splitBean, overSplitBean);
overSplitBean.setChangeType(changeType);
overSplitBean.setPreChangeType(preChangeType);
overSplitBean.setOneDayHour(oneDayHour);
overSplitBean.setWorkmins(workmins);
overSplitBean.setComputingMode(computingMode+"");
overSplitBean.setChangeType(changeType);
overSplitBean.setFromDate(splitDate);
overSplitBean.setFromTime(bean_cross_fromtime);
overSplitBean.setToDate(splitDate);
overSplitBean.setToTime(bean_cross_totime);
overSplitBean.setBelongDate(splitDate);
overSplitBean.setD_Mins(timepoint_mins);
overSplitBean.setOvertimeBalanceTimeBeans(overtimeBalanceTimeBeans);
overSplitBean.setSerialid(serialid);
getDurationByRule(overSplitBean);
splitBeans.add(overSplitBean);
}
}
}
}
}else{
curMins = (int) kqOverTimeRuleCalBiz.getD_MinsByUnit(curMins);
overSplitBean.setChangeType(changeType);
overSplitBean.setPreChangeType(preChangeType);
overSplitBean.setOneDayHour(oneDayHour);
overSplitBean.setWorkmins(workmins);
overSplitBean.setComputingMode(computingMode+"");
overSplitBean.setChangeType(changeType);
overSplitBean.setFromDate(splitDate);
overSplitBean.setFromTime(kqTimesArrayComInfo.getTimesByArrayindex(fromTime_index));
overSplitBean.setToDate(splitDate);
overSplitBean.setToTime(kqTimesArrayComInfo.getTimesByArrayindex(toTime_index));
overSplitBean.setBelongDate(splitDate);
overSplitBean.setD_Mins(curMins);
overSplitBean.setOvertimeBalanceTimeBeans(overtimeBalanceTimeBeans);
overSplitBean.setSerialid(serialid);
getDurationByRule(overSplitBean);
splitBeans.add(overSplitBean);
}
}
long b = System.currentTimeMillis();
System.out.println("::"+(b-a));
}catch (Exception e){
StringWriter errorsWriter = new StringWriter();
e.printStackTrace(new PrintWriter(errorsWriter));
kqLog.info(errorsWriter.toString());
}
}
/**
*
* @param workLongTimeIndex
* @param real_workLongTimeIndex
* @param shiftInfoBean
* @param kqTimesArrayComInfo
* @param splitBean
*/
public void get_real_workLongTimeIndex(List<int[]> workLongTimeIndex,
List<int[]> real_workLongTimeIndex,
ShiftInfoBean shiftInfoBean, KQTimesArrayComInfo kqTimesArrayComInfo,
SplitBean splitBean) {
//list带数组这里要深拷贝
for(int[] tmp : workLongTimeIndex){
int[] real_tmp = new int[tmp.length];
System.arraycopy(tmp, 0, real_tmp, 0, tmp.length);
real_workLongTimeIndex.add(real_tmp);
}
if(real_workLongTimeIndex.size() == 1){
//个性化设置只支持一次打卡的
KQShiftRuleInfoBiz kqShiftRuleInfoBiz = new KQShiftRuleInfoBiz();
kqShiftRuleInfoBiz.rest_workLongTimeIndex(shiftInfoBean,splitBean,real_workLongTimeIndex,kqTimesArrayComInfo,null);
}
}
/**
*
* @param overRulesDetailMap
* @param preChangeType_key
* @param resourceid
* @param preSplitDate
* @param splitDate
* @param preChangeType
* @param kqTimesArrayComInfo
* @param splitBean
* @param changeType
* @return
*/
private String get_pre_overtime_cut_point(
Map<String, KQOvertimeRulesDetailEntity> overRulesDetailMap,
String preChangeType_key, String resourceid, String preSplitDate, String splitDate,
int preChangeType, KQTimesArrayComInfo kqTimesArrayComInfo,
SplitBean splitBean, int changeType) {
String pre_overtime_cut_point = "";
KQOvertimeRulesDetailEntity preKqOvertimeRulesDetailEntity = overRulesDetailMap.get(preChangeType_key);
if(preKqOvertimeRulesDetailEntity != null){
int has_cut_point = preKqOvertimeRulesDetailEntity.getHas_cut_point();
if(has_cut_point == 0){
if(preChangeType == 2){
ShiftInfoBean pre_shiftInfoBean = KQDurationCalculatorUtil.getWorkTime(resourceid, preSplitDate, false);
if(pre_shiftInfoBean != null){
List<int[]> workLongTimeIndex = pre_shiftInfoBean.getWorkLongTimeIndex();
List<int[]> real_workLongTimeIndex = Lists.newArrayList();
get_real_workLongTimeIndex(workLongTimeIndex,real_workLongTimeIndex,pre_shiftInfoBean,kqTimesArrayComInfo,splitBean);
if(real_workLongTimeIndex != null && !real_workLongTimeIndex.isEmpty()){
pre_overtime_cut_point = kqTimesArrayComInfo.getTimesByArrayindex(real_workLongTimeIndex.get(0)[0]);
}
}
}else {
String next_beginwork_time = "";
if(changeType == 2){
ShiftInfoBean next_shiftInfoBean = KQDurationCalculatorUtil.getWorkTime(resourceid, splitDate, false);
if(next_shiftInfoBean != null){
List<int[]> workLongTimeIndex = next_shiftInfoBean.getWorkLongTimeIndex();
List<int[]> real_workLongTimeIndex = Lists.newArrayList();
get_real_workLongTimeIndex(workLongTimeIndex,real_workLongTimeIndex,next_shiftInfoBean,kqTimesArrayComInfo,splitBean);
if(real_workLongTimeIndex != null && !real_workLongTimeIndex.isEmpty()){
next_beginwork_time = kqTimesArrayComInfo.getTimesByArrayindex(real_workLongTimeIndex.get(0)[0]);
}
}
}
if(next_beginwork_time.length() > 0){
pre_overtime_cut_point = next_beginwork_time;
}
}
}else{
pre_overtime_cut_point = preKqOvertimeRulesDetailEntity.getCut_point();
}
if(pre_overtime_cut_point.length() == 0){
pre_overtime_cut_point = "00:00";
}
}
return pre_overtime_cut_point;
}
/**
*
* @param initArrays
* @param overRulesDetailMap
* @param nextChangeType_key
* @param next_changeType
* @param next_beginwork_time
*/
public void handle_changeType_1(int[] initArrays,
Map<String, KQOvertimeRulesDetailEntity> overRulesDetailMap,
String nextChangeType_key, int next_changeType, String next_beginwork_time){
KQOvertimeRulesDetailEntity nextKqOvertimeRulesDetailEntity = overRulesDetailMap.get(nextChangeType_key);
// if(nextKqOvertimeRulesDetailEntity != null){
// if(next_changeType == 2){
// //如果明日是工作日 工作日如果设置了上班前分钟,会导致加班归属被设置的分钟数给切断,上班前某些部分属于今天不属于昨日
// int overtimeEnable = nextKqOvertimeRulesDetailEntity.getOvertimeEnable();
// if(overtimeEnable == 1){
// KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo();
// int before_startTime = nextKqOvertimeRulesDetailEntity.getBefore_startTime();
// int has_cut_point = nextKqOvertimeRulesDetailEntity.getHas_cut_point();
// if(has_cut_point != 1){
// before_startTime = -1;
// }
// int next_beginwork_time_index = kqTimesArrayComInfo.getArrayindexByTimes(next_beginwork_time);
// if(before_startTime > -1){
// int before_next_beginwork_time_index = next_beginwork_time_index - before_startTime;
// if(before_next_beginwork_time_index > 0 && before_next_beginwork_time_index < next_beginwork_time_index){
// before_next_beginwork_time_index = kqTimesArrayComInfo.turn24to48TimeIndex(before_next_beginwork_time_index);
// next_beginwork_time_index = kqTimesArrayComInfo.turn24to48TimeIndex(next_beginwork_time_index);
// Arrays.fill(initArrays, before_next_beginwork_time_index,next_beginwork_time_index,-1);
// }
// }
// }
// }
// }
}
/**
*
* @param restTimeMap
* @param changeType_key
* @param kqTimesArrayComInfo
* @param shouldAcross
* @param initArrays
*/
public void handle_resttime(Map<String, List<String[]>> restTimeMap, String changeType_key, KQTimesArrayComInfo kqTimesArrayComInfo, boolean shouldAcross, int[] initArrays) {
if(restTimeMap.containsKey(changeType_key)){
List<String[]> restTimeList = restTimeMap.get(changeType_key);
//再把休息时间填充上去
if(!restTimeList.isEmpty()){
for(int k =0 ; k < restTimeList.size() ; k++){
String[] restTimes = restTimeList.get(k);
if(restTimes.length == 2){
int restStart = kqTimesArrayComInfo.getArrayindexByTimes(restTimes[0]);
int restEnd = kqTimesArrayComInfo.getArrayindexByTimes(restTimes[1]);
if(shouldAcross && restEnd == 1439){
//针对跨天的休息时段单独处理排除掉23:59-00:00的时间
restEnd = 1440;
}
Arrays.fill(initArrays, restStart, restEnd, 1);
}
}
}
}
}
/**
*
* @param curMins
* @param restTimeMap
* @param changeType_key
* @return
*/
public int handle_restlength(int curMins, Map<String, List<String[]>> restTimeMap, String changeType_key) {
if(restTimeMap.containsKey(changeType_key)) {
List<String[]> restTimeList = restTimeMap.get(changeType_key);
//再把休息时间填充上去
if (!restTimeList.isEmpty()) {
for(int k = restTimeList.size()-1 ; k >= 0 ; k--) {
String[] restTimes = restTimeList.get(k);
if (restTimes.length == 2) {
//overlength 是满多少小时 cutlength是减去多少小时
double overlength = Util.getDoubleValue(restTimes[0],-1);
double cutlength = Util.getDoubleValue(restTimes[1],-1);
if(overlength > 0 && cutlength > 0){
double min_overlength = overlength * 60;
double min_cutlength = cutlength * 60;
if(curMins >= min_overlength){
curMins = (int) (curMins-min_cutlength);
break;
}
}
}
}
}
}
return curMins;
}
/**
*
* @param initArrays
* @param resourceid
* @param splitDate
* @param before_startTime
* @param startTime
* @param fromTime_index
* @param kqTimesArrayComInfo
* @param splitBean
* @param toTime_index
* @return
*/
public boolean handle_changeType_2(int[] initArrays, String resourceid, String splitDate,
int before_startTime, int startTime, int fromTime_index,
KQTimesArrayComInfo kqTimesArrayComInfo, SplitBean splitBean, int toTime_index){
boolean isok = true;
ShiftInfoBean cur_shiftInfoBean = KQDurationCalculatorUtil.getWorkTime(resourceid, splitDate, false);
if(cur_shiftInfoBean != null){
splitBean.setSerialid(cur_shiftInfoBean.getSerialid());
List<int[]> workLongTimeIndex = cur_shiftInfoBean.getWorkLongTimeIndex();
List<int[]> real_workLongTimeIndex = Lists.newArrayList();
get_real_workLongTimeIndex(workLongTimeIndex,real_workLongTimeIndex,cur_shiftInfoBean,kqTimesArrayComInfo,splitBean);
if(real_workLongTimeIndex != null && !real_workLongTimeIndex.isEmpty()){
int all_firstworktime = 0;
int all_lastworktime = 0;
boolean need_middle_time = false;
for(int k = 0 ; k < real_workLongTimeIndex.size() ; k++){
int workLongTimeStartIndex = real_workLongTimeIndex.get(k)[0];
int workLongTimeEndIndex = real_workLongTimeIndex.get(k)[1];
if(k == 0){
if(before_startTime > -1){
int before_workLongTimeStartIndex = workLongTimeStartIndex-before_startTime;
if(before_workLongTimeStartIndex > 0){
//从前一天的加班归属点到今天的上班前开始加班点,这段时间属于两不靠。需要排除
if(fromTime_index < before_workLongTimeStartIndex){
Arrays.fill(initArrays, fromTime_index,before_workLongTimeStartIndex,-1);
}
}
}
all_firstworktime = workLongTimeStartIndex;
}
if(k == real_workLongTimeIndex.size()-1){
if(startTime > -1){
int after_workLongTimeEndIndex = workLongTimeEndIndex+startTime;
if(workLongTimeEndIndex < after_workLongTimeEndIndex){
Arrays.fill(initArrays, workLongTimeEndIndex,after_workLongTimeEndIndex,-1);
}
}
all_lastworktime = workLongTimeEndIndex;
}
if(!need_middle_time){
//目前标准加班,一天多次打卡的话是不算中间时间的,只算上班前和下班后的加班
}else{
//这个里面是可以算一天多次打卡的话是中间时间的
Arrays.fill(initArrays, workLongTimeStartIndex,workLongTimeEndIndex,1);
}
}
if(!need_middle_time){
Arrays.fill(initArrays, all_firstworktime,all_lastworktime,1);
}
List<int[]> restLongTimeIndex = cur_shiftInfoBean.getRestLongTimeIndex();
if(restLongTimeIndex != null && !restLongTimeIndex.isEmpty()){
for (int k = 0; k < restLongTimeIndex.size(); k++) {
//休息时段填充2
Arrays.fill(initArrays, restLongTimeIndex.get(k)[0], restLongTimeIndex.get(k)[1], 2);
}
}
}else {
System.out.println("error");
isok = false;
}
}else {
System.out.println("error");
isok = false;
}
return isok;
}
/**
*
* @param restTimeMap
* @param initArrays
* @param overRulesDetailMap
* @param nextChangeType_key
* @param next_changeType
* @param next_beginwork_time
*/
public void handle_changeType_3(int[] initArrays,
Map<String, KQOvertimeRulesDetailEntity> overRulesDetailMap,
String nextChangeType_key, int next_changeType, String next_beginwork_time){
KQOvertimeRulesDetailEntity nextKqOvertimeRulesDetailEntity = overRulesDetailMap.get(nextChangeType_key);
// if(nextKqOvertimeRulesDetailEntity != null){
// if(next_changeType == 2){
// //如果明日是工作日 工作日如果设置了上班前分钟,会导致加班归属被设置的分钟数给切断,上班前某些部分属于今天不属于昨日
// int overtimeEnable = nextKqOvertimeRulesDetailEntity.getOvertimeEnable();
// if(overtimeEnable == 1){
// KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo();
// int before_startTime = nextKqOvertimeRulesDetailEntity.getBefore_startTime();
// int has_cut_point = nextKqOvertimeRulesDetailEntity.getHas_cut_point();
// if(has_cut_point != 1){
// before_startTime = -1;
// }
// int next_beginwork_time_index = kqTimesArrayComInfo.getArrayindexByTimes(next_beginwork_time);
// if(before_startTime > -1){
// int before_next_beginwork_time_index = next_beginwork_time_index - before_startTime;
// if(before_next_beginwork_time_index > 0 && before_next_beginwork_time_index < next_beginwork_time_index){
// before_next_beginwork_time_index = kqTimesArrayComInfo.turn24to48TimeIndex(before_next_beginwork_time_index);
// next_beginwork_time_index = kqTimesArrayComInfo.turn24to48TimeIndex(next_beginwork_time_index);
// Arrays.fill(initArrays, before_next_beginwork_time_index,next_beginwork_time_index,-1);
// }
// }
// }
// }
// }
}
public void getDurationByRule(SplitBean splitBean) {
double D_Mins = splitBean.getD_Mins();
int workmins = splitBean.getWorkmins();
String durationrule = splitBean.getDurationrule();
if("3".equalsIgnoreCase(durationrule) || "5".equalsIgnoreCase(durationrule)
|| "6".equalsIgnoreCase(durationrule)){
double d_hour = D_Mins/60.0;
splitBean.setDuration(KQDurationCalculatorUtil.getDurationRound5(""+d_hour));
}else if("1".equalsIgnoreCase(durationrule)){
double d_day = D_Mins/workmins;
splitBean.setDuration(KQDurationCalculatorUtil.getDurationRound5(""+d_day));
}
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,922 @@
package com.engine.kq.biz;
import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean;
import com.engine.kq.entity.KQOvertimeRulesDetailEntity;
import com.engine.kq.log.KQLog;
import com.engine.kq.util.KQDurationCalculatorUtil;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
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 weaver.wechat.util.DateUtil;
import java.math.BigDecimal;
import java.util.*;
/**
*
*/
public class KQOvertimeRulesBiz {
private static KQLog logger = new KQLog();//用于记录日志信息
private static KQOvertimeRulesDetailEntity kqOvertimeRulesDetail = new KQOvertimeRulesDetailEntity();//加班规则实体类
/**
* ID
*
* @param resourceId ID
* IDID
* @param date
* ()
* @return 1-2-3--1-
*/
public static int getChangeType(String resourceId, String date) {
int changeType = -1;
/*获取考勤组的ID因为考勤组有有效期所以需要传入日期*/
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo();
String groupId = kqGroupMemberComInfo.getKQGroupId(resourceId, date);
/*该人员不存在于任意一个考勤组中,请为其设置考勤组*/
if(groupId.equals("")){
logger.writeLog("该人员不存在于任意一个考勤组中请为其设置考勤组。resourceId=" + resourceId + ",date=" + date);
}
changeType = KQHolidaySetBiz.getChangeType(groupId, date);
if (changeType != 1 && changeType != 2 && changeType != 3) {
KQWorkTime kqWorkTime = new KQWorkTime();
changeType = kqWorkTime.isWorkDay(resourceId, date) ? 2 : 3;
}
return changeType;
}
/**
*
*
* @param resourceId
* IDIDID
* @param date
*
* @return 0-1-
*/
public static int getOvertimeEnable(String resourceId, String date) {
int overtimeEnable = 0;
kqOvertimeRulesDetail = getOvertimeRulesDetail(resourceId, date);
overtimeEnable = kqOvertimeRulesDetail.getOvertimeEnable();
return overtimeEnable;
}
/**
*
* 1-
* 2-
* 3-
*
* @param resourceId
* IDIDID
* @param date
*
* @return -1
*/
public static int getComputingMode(String resourceId, String date) {
int computingMode = -1;
kqOvertimeRulesDetail = getOvertimeRulesDetail(resourceId, date);
computingMode = kqOvertimeRulesDetail.getComputingMode();
return computingMode;
}
/**
*
*
* @param resourceId
* IDIDID
* @param date
*
* @return -1
*/
public static int getStartTime(String resourceId, String date) {
int startTime = -1;
kqOvertimeRulesDetail = getOvertimeRulesDetail(resourceId, date);
startTime = kqOvertimeRulesDetail.getStartTime();
return startTime;
}
/**
*
*
* @param resourceId
* IDIDID
* @param date
*
* @return -1
*/
public static int getMinimumLen(String resourceId, String date) {
int minimumUnit = -1;
kqOvertimeRulesDetail = getOvertimeRulesDetail(resourceId, date);
minimumUnit = kqOvertimeRulesDetail.getMinimumLen();
return minimumUnit;
}
/**
*
* 0-1-
*
* @param resourceId
* IDIDID
* @param date
*
* @return
*/
public static int getPaidLeaveEnable(String resourceId, String date) {
int paidLeaveEnable = 0;
kqOvertimeRulesDetail = getOvertimeRulesDetail(resourceId, date);
paidLeaveEnable = kqOvertimeRulesDetail.getPaidLeaveEnable();
return paidLeaveEnable;
}
/**
*
*
* @param resourceId
* IDIDID
* @param date
*
* @return -1
*/
public static double getLenOfOvertime(String resourceId, String date) {
double lenOfOvertime = -1;
kqOvertimeRulesDetail = getOvertimeRulesDetail(resourceId, date);
lenOfOvertime = kqOvertimeRulesDetail.getLenOfOvertime();
BigDecimal bigDecimal = new BigDecimal(lenOfOvertime);
lenOfOvertime = bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
return lenOfOvertime;
}
/**
*
*
* @param resourceId
* IDIDID
* @param date
*
* @return -1
*/
public static double getLenOfLeave(String resourceId, String date) {
double lenOfLeave = -1;
kqOvertimeRulesDetail = getOvertimeRulesDetail(resourceId, date);
lenOfLeave = kqOvertimeRulesDetail.getLenOfLeave();
BigDecimal bigDecimal = new BigDecimal(lenOfLeave);
lenOfLeave = bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
return lenOfLeave;
}
/**
*
*
* @param resourceId
* IDIDID
* @param date
*
* @return 0-1-
*/
public static int getHasRestTime(String resourceId, String date) {
int hasRestTime = 0;
kqOvertimeRulesDetail = getOvertimeRulesDetail(resourceId, date);
hasRestTime = kqOvertimeRulesDetail.getHasRestTime();
return hasRestTime;
}
/**
*
* startType0-1-
* startTime
* endType0-1-
* endTime
*
* @param resourceId
* IDIDID
* @param date
*
* @return
*/
public static List<String[]> getRestTimeList(String resourceId, String date) {
List<String[]> restTimeList = new ArrayList<String[]>();
/**
*
*/
String lastDay = DateUtil.addDay(date, -1, "yyyy-MM-dd");
kqOvertimeRulesDetail = getOvertimeRulesDetail(resourceId, lastDay);
int overtimeEnable = kqOvertimeRulesDetail.getOvertimeEnable();
int hasRestTime = kqOvertimeRulesDetail.getHasRestTime();
if (overtimeEnable == 1 && hasRestTime == 1) {
int dayType = kqOvertimeRulesDetail.getDayType();
int ruleId = kqOvertimeRulesDetail.getRuleId();
String sql = "select * from kq_OvertimeRestTime where ruleId=" + ruleId + " and dayType=" + dayType;
RecordSet recordSet = new RecordSet();
recordSet.executeQuery(sql);
while (recordSet.next()) {
String startType = recordSet.getString("startType");
String startTime = recordSet.getString("startTime");
String endType = recordSet.getString("endType");
String endTime = recordSet.getString("endTime");
if (startType.equals("0") && endType.equals("1")) {
String[] str = new String[]{"00:00", endTime};
restTimeList.add(str);
} else if (startType.equals("1") && endType.equals("1")) {
String[] str = new String[]{startTime, endTime};
restTimeList.add(str);
}
}
}
kqOvertimeRulesDetail = getOvertimeRulesDetail(resourceId, date);
overtimeEnable = kqOvertimeRulesDetail.getOvertimeEnable();
hasRestTime = kqOvertimeRulesDetail.getHasRestTime();
if (overtimeEnable == 1 && hasRestTime == 1) {
int dayType = kqOvertimeRulesDetail.getDayType();
int ruleId = kqOvertimeRulesDetail.getRuleId();
String sql = "select * from kq_OvertimeRestTime where ruleId=" + ruleId + " and dayType=" + dayType;
RecordSet recordSet = new RecordSet();
recordSet.executeQuery(sql);
while (recordSet.next()) {
String startType = recordSet.getString("startType");
String startTime = recordSet.getString("startTime");
String endType = recordSet.getString("endType");
String endTime = recordSet.getString("endTime");
if (startType.equals("0") && endType.equals("0")) {
String[] str = new String[]{startTime, endTime};
restTimeList.add(str);
} else if (startType.equals("0") && endType.equals("1")) {
String[] str = new String[]{startTime, "24:00"};
restTimeList.add(str);
}
}
}
return restTimeList;
}
/**
*
*
* @param resourceId
* IDIDID
* @param changeType 1-2-3-
* @return
*/
private static KQOvertimeRulesDetailEntity getOvertimeRulesDetail(String resourceId, String date) {
KQOvertimeRulesDetailEntity kqOvertimeRulesDetail = new KQOvertimeRulesDetailEntity();
try {
/*获取考勤组的ID因为考勤组有有效期所以需要传入日期*/
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo();
String groupIds = kqGroupMemberComInfo.getKQGroupId(resourceId, date);
if (groupIds.equals("")) {
/*该人员不存在于任意一个考勤组中,请为其设置考勤组*/
logger.writeLog("该人员不存在于任意一个考勤组中请为其设置考勤组。resourceId=" + resourceId + ",date=" + date);
}
int changeType = getChangeType(resourceId, date);
/*获取当前日期的日期类型错误*/
if (changeType != 1 && changeType != 2 && changeType != 3) {
logger.writeLog("获取当前日期的日期类型错误。resourceId=" + resourceId + ",date=" + date + ",changeType=" + changeType);
}
int overtimeRuleId = 0;//加班规则的ID
RecordSet recordSet = new RecordSet();
String sql = "select id from kq_OvertimeRules where (isDelete is null or isDelete !=1) ";
if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) {
sql += " and ','+groupIds+',' like '%," + groupIds + ",%'";
} else if (recordSet.getDBType().equalsIgnoreCase("mysql")) {
sql += " and concat(',',groupIds,',') like '%," + groupIds + ",%'";
} else {
sql += " and ','||groupIds||',' like '%," + groupIds + ",%'";
}
recordSet.executeQuery(sql);
if (recordSet.next()) {
overtimeRuleId = recordSet.getInt("id");
sql = "select * from kq_OvertimeRulesDetail where ruleId=" + overtimeRuleId + " and dayType=" + changeType;
recordSet.executeQuery(sql);
if (recordSet.next()) {
int ruleId = recordSet.getInt("ruleId");
int dayType = recordSet.getInt("dayType");
int overtimeEnable = recordSet.getInt("overtimeEnable");
int computingMode = recordSet.getInt("computingMode");
int startTime = recordSet.getInt("startTime");
int minimumLen = recordSet.getInt("minimumLen");
int paidLeaveEnable = recordSet.getInt("paidLeaveEnable");
double lenOfOvertime = Util.getDoubleValue(recordSet.getString("lenOfOvertime"), 1.00);
double lenOfLeave = Util.getDoubleValue(recordSet.getString("lenOfLeave"), 1.00);
int hasRestTime = Util.getIntValue(recordSet.getString("hasRestTime"));
kqOvertimeRulesDetail.setRuleId(ruleId);
kqOvertimeRulesDetail.setDayType(dayType);
kqOvertimeRulesDetail.setOvertimeEnable(overtimeEnable);
kqOvertimeRulesDetail.setComputingMode(computingMode);
kqOvertimeRulesDetail.setStartTime(startTime);
kqOvertimeRulesDetail.setMinimumLen(minimumLen);
kqOvertimeRulesDetail.setPaidLeaveEnable(paidLeaveEnable);
kqOvertimeRulesDetail.setLenOfOvertime(lenOfOvertime);
kqOvertimeRulesDetail.setLenOfLeave(lenOfLeave);
kqOvertimeRulesDetail.setHasRestTime(hasRestTime);
}
} else {
logger.writeLog("该人员所属的考勤组没有设置过任何加班规则请为其设置加班规则。resourceId=" + resourceId + ",date="+date+",changeType=" + changeType);
}
} catch (Exception e) {
logger.writeLog("根据人员ID获取加班规则的规则内容出错。resourceId=" + resourceId + ",date=" + date);
e.printStackTrace();
}
return kqOvertimeRulesDetail;
}
/**
*
*
* @param params
* @return
*/
public static int addOvertimeRules(Map<String, Object> params, User user) {
/*是否保存成功*/
boolean flag = false;
/*新插入的加班规则的ID*/
int ruleId = -1;
try {
boolean canAdd = HrmUserVarify.checkUserRight("KQOvertimeRulesAdd:Add", user);//是否具有新建权限
if (!canAdd) {
logger.info(user.getLastname() + "暂时没有权限!");
return -1;
}
/*加班规则名称*/
String name = Util.null2String(params.get("name"));
/*考勤组的ID*/
String groupIds = Util.null2String(params.get("groupIds"));
/*工作日是否允许加班0-不允许、1-允许*/
int overtimeEnable2 = Util.getIntValue((String) params.get("overtimeEnable2"), 1);
/*工作日的加班方式1-需审批以审批单为准、2-需审批以打卡为准但是不能超过审批时长、3-无需审批,根据打卡时间计算加班时长*/
int computingMode2 = Util.getIntValue((String) params.get("computingMode2"), 1);
/*工作日下班多少分钟后开始计算加班*/
int startTime2 = Util.getIntValue((String) params.get("startTime2"), 30);
/*工作日最小加班时长*/
int minimumLen2 = Util.getIntValue((String) params.get("minimumLen2"), 30);
/*工作日是否允许加班转调休*/
int paidLeaveEnable2 = Util.getIntValue((String) params.get("paidLeaveEnable2"), 0);
/*工作日加班转调休比例中的加班时长*/
int lenOfOvertime2 = Util.getIntValue((String) params.get("lenOfOvertime2"), 1);
/*工作日加班转调休比例中的调休时长*/
int lenOfLeave2 = Util.getIntValue((String) params.get("lenOfLeave2"), 1);
/*休息日是否允许加班0-不允许、1-允许*/
int overtimeEnable3 = Util.getIntValue((String) params.get("overtimeEnable3"), 1);
/*休息日的加班方式1-需审批以审批单为准、2-需审批以打卡为准但是不能超过审批时长、3-无需审批,根据打卡时间计算加班时长*/
int computingMode3 = Util.getIntValue((String) params.get("computingMode3"), 1);
/*休息日的最小加班时长*/
int minimumLen3 = Util.getIntValue((String) params.get("minimumLen3"), 30);
/*休息日是否允许加班转调休*/
int paidLeaveEnable3 = Util.getIntValue((String) params.get("paidLeaveEnable3"), 0);
/*休息日加班转调休比例中的加班时长*/
int lenOfOvertime3 = Util.getIntValue((String) params.get("lenOfOvertime3"), 1);
/*休息日加班转调休比例中的调休时长*/
int lenOfLeave3 = Util.getIntValue((String) params.get("lenOfLeave3"), 1);
/*休息日是否有休息时间*/
int hasRestTime3 = Util.getIntValue((String) params.get("hasRestTime3"), 0);
/*节假日是否允许加班0-不允许、1-允许*/
int overtimeEnable1 = Util.getIntValue((String) params.get("overtimeEnable1"), 1);
/*节假日的加班方式1-需审批以审批单为准、2-需审批以打卡为准但是不能超过审批时长、3-无需审批,根据打卡时间计算加班时长*/
int computingMode1 = Util.getIntValue((String) params.get("computingMode1"), 1);
/*节假日的最小加班时长*/
int minimumLen1 = Util.getIntValue((String) params.get("minimumLen1"), 30);
/*节假日是否允许加班转调休*/
int paidLeaveEnable1 = Util.getIntValue((String) params.get("paidLeaveEnable1"), 0);
/*节假日加班转调休比例中的加班时长*/
int lenOfOvertime1 = Util.getIntValue((String) params.get("lenOfOvertime1"), 1);
/*节假日加班转调休比例中的调休时长*/
int lenOfLeave1 = Util.getIntValue((String) params.get("lenOfLeave1"), 1);
/*节假日是否有休息时间*/
int hasRestTime1 = Util.getIntValue((String) params.get("hasRestTime1"), 0);
int paidLeaveEnableType2 = Util.getIntValue((String) params.get("paidLeaveEnableType2"), 2);
int paidLeaveEnableType3 = Util.getIntValue((String) params.get("paidLeaveEnableType3"), 2);
int paidLeaveEnableType1 = Util.getIntValue((String) params.get("paidLeaveEnableType1"), 2);
int paidLeaveEnableFlowType2 = Util.getIntValue((String) params.get("paidLeaveEnableFlowType2"), 1);
int paidLeaveEnableFlowType3 = Util.getIntValue((String) params.get("paidLeaveEnableFlowType3"), 1);
int paidLeaveEnableFlowType1 = Util.getIntValue((String) params.get("paidLeaveEnableFlowType1"), 1);
/*获取今天的日期*/
Calendar today = Calendar.getInstance();
String currentDate = Util.add0(today.get(Calendar.YEAR), 4) + "-"
+ Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-"
+ Util.add0(today.get(Calendar.DAY_OF_MONTH), 2);
String tomorrowDate = weaver.common.DateUtil.addDate(currentDate, 1);
/*校验休息日排除休息时间的设置是否正确*/
if (hasRestTime3 == 1) {
int restTimeLen3 = Util.getIntValue((String) params.get("restTimeLen3"), 0);
List<String> fromList = new ArrayList<String>();
List<String> toList = new ArrayList<String>();
for (int i = 0; i < restTimeLen3; i++) {
String startType = "0";
String startTime = Util.getIntValues((String) params.get("startTime3_" + i));
String endType = "0";
String endTime = Util.getIntValues((String) params.get("endTime3_" + i));
String fromDateTime = (startType.equals("0") ? currentDate : tomorrowDate) + " " + startTime + ":00";
String toDateTime = (endType.equals("0") ? currentDate : tomorrowDate) + " " + endTime + ":00";
if (fromDateTime.compareTo(toDateTime) > 0) {
logger.info("结束时间必须大于开始时间fromDateTime=" + fromDateTime + "toDateTime=" + toDateTime);
return -1;
}
fromList.add(fromDateTime);
toList.add(toDateTime);
}
/*利用冒泡法对日期时间进行排序*/
for (int i = 0; i < fromList.size(); i++) {
for (int j = 0; j < fromList.size() - i - 1; j++) {
if (fromList.get(j).compareTo(fromList.get(j + 1)) > 0) {
String str = fromList.get(j);
fromList.set(j, fromList.get(j + 1));
fromList.set(j + 1, str);
str = toList.get(j);
toList.set(j, toList.get(j + 1));
toList.set(j + 1, str);
}
}
}
/*根据排序后的数据判断是否时间段有重叠*/
for (int i = 0; i < fromList.size() - 1; i++) {
if (fromList.get(i + 1).compareTo(toList.get(i)) < 0) {
logger.info("休息时段不能交叉");
return -1;
}
}
}
/*校验休息日排除休息时间的设置是否正确*/
if (hasRestTime1 == 1) {
int restTimeLen1 = Util.getIntValue((String) params.get("restTimeLen1"), 0);
List<String> fromList = new ArrayList<String>();
List<String> toList = new ArrayList<String>();
for (int i = 0; i < restTimeLen1; i++) {
String startType = "0";
String startTime = Util.getIntValues((String) params.get("startTime1_" + i));
String endType = "0";
String endTime = Util.getIntValues((String) params.get("endTime1_" + i));
String fromDateTime = (startType.equals("0") ? currentDate : tomorrowDate) + " " + startTime + ":00";
String toDateTime = (endType.equals("0") ? currentDate : tomorrowDate) + " " + endTime + ":00";
if (fromDateTime.compareTo(toDateTime) > 0) {
logger.info("结束时间必须大于开始时间fromDateTime=" + fromDateTime + "toDateTime=" + toDateTime);
return -1;
}
fromList.add(fromDateTime);
toList.add(toDateTime);
}
/*利用冒泡法对日期时间进行排序*/
for (int i = 0; i < fromList.size(); i++) {
for (int j = 0; j < fromList.size() - i - 1; j++) {
if (fromList.get(j).compareTo(fromList.get(j + 1)) > 0) {
String str = fromList.get(j);
fromList.set(j, fromList.get(j + 1));
fromList.set(j + 1, str);
str = toList.get(j);
toList.set(j, toList.get(j + 1));
toList.set(j + 1, str);
}
}
}
/*根据排序后的数据判断是否时间段有重叠*/
for (int i = 0; i < fromList.size() - 1; i++) {
if (fromList.get(i + 1).compareTo(toList.get(i)) < 0) {
logger.info("休息时段不能交叉");
return -1;
}
}
}
String sql = "insert into kq_OvertimeRules(name,groupIds,isDelete) values(?,?,0)";
RecordSet recordSet = new RecordSet();
flag = recordSet.executeUpdate(sql, name, groupIds);
if (!flag) {
logger.info("加班规则保存失败");//保存失败
return -1;
}
sql = "select max(id) maxId from kq_OvertimeRules";
recordSet.executeQuery(sql);
if (recordSet.next()) {
ruleId = recordSet.getInt("maxId");
}
if (ruleId != 0) {
sql = "insert into kq_OvertimeRulesDetail(ruleId,dayType,overtimeEnable,computingMode,startTime,minimumLen,paidLeaveEnable,lenOfOvertime,lenOfLeave,hasRestTime,paidleaveenabletype,paidleaveenableflowtype) " +
"values(?,?,?,?,?,?,?,?,?,?,?,?)";
/**
*
*/
flag = recordSet.executeUpdate(sql, ruleId, 2, overtimeEnable2, computingMode2, startTime2, minimumLen2, paidLeaveEnable2, lenOfOvertime2, lenOfLeave2, 0,paidLeaveEnableType2,paidLeaveEnableFlowType2);
if (!flag) {
logger.info("工作日加班规则保存失败");//保存失败
return -1;
}
/**
*
*/
flag = recordSet.executeUpdate(sql, ruleId, 3, overtimeEnable3, computingMode3, 0, minimumLen3, paidLeaveEnable3, lenOfOvertime3, lenOfLeave3, hasRestTime3,paidLeaveEnableType3,paidLeaveEnableFlowType3);
if (!flag) {
logger.info("休息日加班规则保存失败");//保存失败
return -1;
}
if (hasRestTime3 == 1) {
int restTimeLen3 = Util.getIntValue((String) params.get("restTimeLen3"), 0);
for (int i = 0; i < restTimeLen3; i++) {
String startType = "0";
String startTime = Util.getIntValues((String) params.get("startTime3_" + i));
String endType = "0";
String endTime = Util.getIntValues((String) params.get("endTime3_" + i));
String restTimeSql = "insert into kq_OvertimeRestTime(ruleId,dayType,startType,startTime,endType,endTime) values(?,?,?,?,?,?)";
flag = recordSet.executeUpdate(restTimeSql, ruleId, 3, startType, startTime, endType, endTime);
if (!flag) {
logger.info("休息日加班规则休息时段保存失败");//保存失败
return -1;
}
}
}
/**
*
*/
flag = recordSet.executeUpdate(sql, ruleId, 1, overtimeEnable1, computingMode1, 0, minimumLen1, paidLeaveEnable1, lenOfOvertime1, lenOfLeave1, hasRestTime1,paidLeaveEnableType1,paidLeaveEnableFlowType1);
if (!flag) {
logger.info("节假日加班规则保存失败");
return -1;
}
if (hasRestTime1 == 1) {
int restTimeLen1 = Util.getIntValue((String) params.get("restTimeLen1"), 0);
for (int i = 0; i < restTimeLen1; i++) {
String startType = "0";
String startTime = Util.getIntValues((String) params.get("startTime1_" + i));
String endType = "0";
String endTime = Util.getIntValues((String) params.get("endTime1_" + i));
String restTimeSql = "insert into kq_OvertimeRestTime(ruleId,dayType,startType,startTime,endType,endTime) values(?,?,?,?,?,?)";
flag = recordSet.executeUpdate(restTimeSql, ruleId, 1, startType, startTime, endType, endTime);
if (!flag) {
logger.info("节假日加班规则休息时段保存失败");
return -1;
}
}
}
}
} catch (Exception e) {
ruleId = -1;
}
return ruleId;
}
/************************************************加班单位的相关接口************************************************/
/**
*
* 1-
* 2-
* 3-
* 4-
* 5-
* 6-
* @return -1
*/
public static int getMinimumUnit() {
int minimumUnit = -1;
String sql = "select * from kq_OvertimeUnit where (isDelete is null or isDelete !=1) and id=1";
RecordSet recordSet = new RecordSet();
recordSet.executeQuery(sql);
if (recordSet.next()) {
minimumUnit = recordSet.getInt("minimumUnit");
}
return minimumUnit;
}
/**
*
* 1-
* 2-
* 3-
* 4-
* 5-
* 6-
* @return -1
*/
public static Map<String,String> getMinimumUnitAndConversion() {
Map<String,String> map = Maps.newHashMap();
int minimumUnit = -1;
int overtimeConversion = -1;
String sql = "select * from kq_OvertimeUnit where (isDelete is null or isDelete !=1) and id=1";
RecordSet recordSet = new RecordSet();
recordSet.executeQuery(sql);
if (recordSet.next()) {
minimumUnit = recordSet.getInt("minimumUnit");
overtimeConversion = recordSet.getInt("overtimeConversion");
map.put("minimumUnit", ""+minimumUnit);
map.put("overtimeConversion", ""+overtimeConversion);
}
return map;
}
/**
*
*
* @return -1
*/
public static double getHoursToDay() {
double hoursToDay = -1.00;
String sql = "select * from kq_OvertimeUnit where (isDelete is null or isDelete !=1) and id=1";
RecordSet recordSet = new RecordSet();
recordSet.executeQuery(sql);
if (recordSet.next()) {
hoursToDay = recordSet.getDouble("hoursToDay");
}
BigDecimal bigDecimal = new BigDecimal(hoursToDay);
return bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
/**
*
* 1- 2-
* @return
*/
public static String getTimeselection() {
int timeselection = 1;
String sql = "select * from kq_OvertimeUnit where (isDelete is null or isDelete !=1) and id=1";
RecordSet recordSet = new RecordSet();
recordSet.executeQuery(sql);
if (recordSet.next()) {
timeselection = recordSet.getInt("timeselection");
}
if(timeselection == 1 || timeselection == 2){
return ""+timeselection;
}else{
return "1";
}
}
/**
*
* @param resourceId
* @param date
* @param changeTypeMap
* @return
*/
public static void getOverTimeData(String resourceId, String date,
Map<String,Integer> changeTypeMap,Map<String,KQOvertimeRulesDetailEntity> overRulesDetailMap,Map<String,List<String[]>> restTimeMap,Map<String,Integer> computingModeMap) {
int changeType = -1;
/*获取考勤组的ID因为考勤组有有效期所以需要传入日期*/
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo();
String groupId = Util.null2s(kqGroupMemberComInfo.getKQGroupId(resourceId, date),"");
/*该人员不存在于任意一个考勤组中,请为其设置考勤组*/
if(groupId.length() == 0){
logger.writeLog("该人员不存在于任意一个考勤组中请为其设置考勤组。resourceId=" + resourceId + ",date=" + date);
return ;
}
changeType = KQHolidaySetBiz.getChangeType(groupId, date);
if (changeType != 1 && changeType != 2 && changeType != 3) {
KQWorkTime kqWorkTime = new KQWorkTime();
changeType = kqWorkTime.isWorkDay(resourceId, date) ? 2 : 3;
}
String change_key = date+"_"+resourceId;
changeTypeMap.put(change_key, changeType);
List<String[]> restTimeList = new ArrayList<String[]>();
int overtimeRuleId = 0;//加班规则的ID
RecordSet recordSet = new RecordSet();
String sql = "select id from kq_OvertimeRules where (isDelete is null or isDelete !=1) ";
if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) {
sql += " and ','+groupIds+',' like '%," + groupId + ",%'";
} else if (recordSet.getDBType().equalsIgnoreCase("mysql")) {
sql += " and concat(',',groupIds,',') like '%," + groupId + ",%'";
} else {
sql += " and ','||groupIds||',' like '%," + groupId + ",%'";
}
recordSet.executeQuery(sql);
if (recordSet.next()) {
overtimeRuleId = recordSet.getInt("id");
sql = "select * from kq_OvertimeRulesDetail where ruleId=" + overtimeRuleId + " and dayType=" + changeType;
recordSet.executeQuery(sql);
if (recordSet.next()) {
int id = recordSet.getInt("id");
int ruleId = recordSet.getInt("ruleId");
int dayType = recordSet.getInt("dayType");
int overtimeEnable = recordSet.getInt("overtimeEnable");
int computingMode = recordSet.getInt("computingMode");
int startTime = recordSet.getInt("startTime");
int minimumLen = recordSet.getInt("minimumLen");
int paidLeaveEnable = recordSet.getInt("paidLeaveEnable");
double lenOfOvertime = Util.getDoubleValue(recordSet.getString("lenOfOvertime"), 1.00);
double lenOfLeave = Util.getDoubleValue(recordSet.getString("lenOfLeave"), 1.00);
int hasRestTime = Util.getIntValue(recordSet.getString("hasRestTime"));
int before_startTime = recordSet.getInt("before_startTime");
int paidLeaveEnableType = recordSet.getInt("paidLeaveEnableType");
int paidLeaveEnableDefaultType = recordSet.getInt("paidLeaveEnableDefaultType");
int paidLeaveEnableFlowType = recordSet.getInt("paidLeaveEnableFlowType");
int restTimeType = recordSet.getInt("restTimeType");
int has_cut_point = Util.getIntValue(Util.null2s(recordSet.getString("has_cut_point"),"0"),0);
if(paidLeaveEnableType <= 0){
paidLeaveEnableType = 1;
}
if(paidLeaveEnableDefaultType <= 0){
paidLeaveEnableDefaultType = 1;
}
if(paidLeaveEnableFlowType <= 0){
paidLeaveEnableFlowType = 1;
}
if(paidLeaveEnableType == 1 && paidLeaveEnable == 0){
//如果就没有开启关联调休,那么默认的加班转调休方式就是第一种
paidLeaveEnableDefaultType = 1;
}
if(restTimeType <= 0){
restTimeType = 1;
}
String cut_point = Util.null2s(recordSet.getString("cut_point"),"");
String key = date+"_"+changeType;
KQOvertimeRulesDetailEntity kqOvertimeRulesDetail = new KQOvertimeRulesDetailEntity();
kqOvertimeRulesDetail.setRuleId(ruleId);
kqOvertimeRulesDetail.setDayType(dayType);
kqOvertimeRulesDetail.setOvertimeEnable(overtimeEnable);
kqOvertimeRulesDetail.setComputingMode(computingMode);
kqOvertimeRulesDetail.setStartTime(startTime);
kqOvertimeRulesDetail.setMinimumLen(minimumLen);
kqOvertimeRulesDetail.setPaidLeaveEnable(paidLeaveEnable);
kqOvertimeRulesDetail.setLenOfOvertime(lenOfOvertime);
kqOvertimeRulesDetail.setLenOfLeave(lenOfLeave);
kqOvertimeRulesDetail.setHasRestTime(hasRestTime);
kqOvertimeRulesDetail.setBefore_startTime(before_startTime);
kqOvertimeRulesDetail.setCut_point(cut_point);
kqOvertimeRulesDetail.setHas_cut_point(has_cut_point);
kqOvertimeRulesDetail.setId(id);
kqOvertimeRulesDetail.setPaidLeaveEnableType(paidLeaveEnableType);
kqOvertimeRulesDetail.setPaidLeaveEnableDefaultType(paidLeaveEnableDefaultType);
kqOvertimeRulesDetail.setPaidLeaveEnableFlowType(paidLeaveEnableFlowType);
kqOvertimeRulesDetail.setRestTimeType(restTimeType);
overRulesDetailMap.put(key, kqOvertimeRulesDetail);
computingModeMap.put(key, computingMode);
/**
*
*/
String lastDay = DateUtil.addDay(date, -1, "yyyy-MM-dd");
KQOvertimeRulesDetailEntity pre_kqOvertimeRulesDetail = getOvertimeRulesDetail(resourceId, lastDay);
int pre_overtimeEnable = pre_kqOvertimeRulesDetail.getOvertimeEnable();
int pre_hasRestTime = pre_kqOvertimeRulesDetail.getHasRestTime();
if (pre_overtimeEnable == 1 && pre_hasRestTime == 1) {
int pre_dayType = pre_kqOvertimeRulesDetail.getDayType();
int pre_ruleId = pre_kqOvertimeRulesDetail.getRuleId();
sql = "select * from kq_OvertimeRestTime where ruleId=" + pre_ruleId + " and dayType=" + pre_dayType;
RecordSet recordSet1 = new RecordSet();
recordSet1.executeQuery(sql);
while (recordSet1.next()) {
String startType = recordSet1.getString("startType");
String startTime1 = recordSet1.getString("startTime");
String endType = recordSet1.getString("endType");
String endTime = recordSet1.getString("endTime");
if (startType.equals("0") && endType.equals("1")) {
String[] str = new String[]{"00:00", endTime};
restTimeList.add(str);
} else if (startType.equals("1") && endType.equals("1")) {
String[] str = new String[]{startTime1, endTime};
restTimeList.add(str);
}
}
}
overtimeEnable = kqOvertimeRulesDetail.getOvertimeEnable();
hasRestTime = kqOvertimeRulesDetail.getHasRestTime();
restTimeType = kqOvertimeRulesDetail.getRestTimeType();
if (overtimeEnable == 1 && hasRestTime == 1) {
if(restTimeType == 1){
sql = "select * from kq_OvertimeRestTime where ruleId=" + ruleId + " and dayType=" + dayType;
RecordSet recordSet1 = new RecordSet();
recordSet1.executeQuery(sql);
while (recordSet1.next()) {
String startType = recordSet1.getString("startType");
String startTime1 = recordSet1.getString("startTime");
String endType = recordSet1.getString("endType");
String endTime = recordSet1.getString("endTime");
if (startType.equals("0") && endType.equals("0")) {
String[] str = new String[]{startTime1, endTime};
restTimeList.add(str);
} else if (startType.equals("0") && endType.equals("1")) {
String[] str = new String[]{startTime1, "24:00"};
restTimeList.add(str);
}
}
}else{
sql = "select * from kq_OvertimeRestlength where ruleId=" + ruleId + " and dayType=" + dayType+" order by dsporder ";
RecordSet recordSet1 = new RecordSet();
recordSet1.executeQuery(sql);
while (recordSet1.next()) {
String overlength = Util.null2String(recordSet1.getString("overlength"));
String cutlength = Util.null2String(recordSet1.getString("cutlength"));
if(overlength.length() > 0 && cutlength.length() > 0){
String[] str = new String[]{overlength, cutlength};
restTimeList.add(str);
}
}
}
}
restTimeMap.put(key, restTimeList);
}
} else {
logger.writeLog("该人员所属的考勤组没有设置过任何加班规则请为其设置加班规则。resourceId=" + resourceId + ",date="+date+",changeType=" + changeType);
}
return ;
}
/**
*
*
*/
public Map<String,List<String>> getBalanceLengthDetailMap(int ruleDetailid){
Map<String,List<String>> balanceLengthDetailMap = Maps.newHashMap();
RecordSet recordSet = new RecordSet();
List<String> overtimelengthList = Lists.newArrayList();
List<String> balancelengthList = Lists.newArrayList();
String sql = "select * from kq_OvertimeBalanceLengthDetail where rulesdetailid= ? order by overtimelength desc ";
recordSet.executeQuery(sql, ruleDetailid);
while (recordSet.next()){
String overtimelength = recordSet.getString("overtimelength");
String balancelength = recordSet.getString("balancelength");
overtimelengthList.add(overtimelength);
balancelengthList.add(balancelength);
}
if(!overtimelengthList.isEmpty() && !balancelengthList.isEmpty()){
balanceLengthDetailMap.put("overtimelengthList", overtimelengthList);
balanceLengthDetailMap.put("balancelengthList", balancelengthList);
return balanceLengthDetailMap;
}
return balanceLengthDetailMap;
}
/**
*
*/
public Map<String,List<String>> getBalanceTimeDetailMap(int ruleDetailid){
Map<String,List<String>> balanceTimethDetailMap = Maps.newHashMap();
RecordSet recordSet = new RecordSet();
List<String> idList = Lists.newArrayList();
List<String> timepointList = Lists.newArrayList();
List<String> lenOfOvertimeList = Lists.newArrayList();
List<String> lenOfLeaveList = Lists.newArrayList();
String sql = "select * from kq_OvertimeBalanceTimeDetail where rulesdetailid= ? order by dsporder ";
recordSet.executeQuery(sql, ruleDetailid);
while (recordSet.next()){
String id = recordSet.getString("id");
String timepoint = recordSet.getString("timepoint");
String lenOfOvertime = recordSet.getString("lenOfOvertime");
String lenOfLeave = recordSet.getString("lenOfLeave");
idList.add(id);
timepointList.add(timepoint);
lenOfOvertimeList.add(lenOfOvertime);
lenOfLeaveList.add(lenOfLeave);
}
if(!timepointList.isEmpty() && !lenOfOvertimeList.isEmpty() && !lenOfLeaveList.isEmpty()){
balanceTimethDetailMap.put("idList", idList);
balanceTimethDetailMap.put("timepointList", timepointList);
balanceTimethDetailMap.put("lenOfOvertimeList", lenOfOvertimeList);
balanceTimethDetailMap.put("lenOfLeaveList", lenOfLeaveList);
return balanceTimethDetailMap;
}
return balanceTimethDetailMap;
}
}

@ -0,0 +1,435 @@
package com.engine.kq.biz;
import com.engine.kq.bean.KQHrmScheduleSign;
import com.engine.kq.log.KQLog;
import com.engine.kq.wfset.util.KQSignUtil;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import weaver.conn.RecordSet;
import weaver.general.Util;
/**
* 退
*/
public class KQScheduleSignBiz {
private KQLog kqLog = new KQLog();
private String resourceid;
private String userType;
private String signDate;
private String signTime;
private String worksection;
/**
*
*/
private String belongdate;
private String signtype;
private String signDateTimeSql;
/**
*
*/
private String signSectionTime;
/**
*
*/
private String signSectionEndTime;
/**
*
*/
private String signSectionBeginTime;
/**
*
*/
private String offSignSectionTime;
private KQScheduleSignBiz(KQScheduleSignParamBuilder build){
this.resourceid = build.resourceid;
this.userType = build.userType;
this.signDate = build.signDate;
this.signTime = build.signTime;
this.belongdate = build.belongdate;
this.signtype = build.signtype;
this.worksection = build.worksection;
this.signDateTimeSql = build.signDateTimeSql;
this.signSectionTime = build.signSectionTime;
this.signSectionEndTime = build.signSectionEndTime;
this.signSectionBeginTime = build.signSectionBeginTime;
this.offSignSectionTime = build.offSignSectionTime;
}
/**
* 退
* @return
*/
public List<KQHrmScheduleSign> getFreeScheduleSignInfo() {
RecordSet rs = new RecordSet();
String signSql = "select * from hrmschedulesign where 1=1 and isInCom='1' ";
String sqlWhere = sqlParamWhere();
if(sqlWhere.length() > 0){
signSql += sqlWhere;
}
signSql += " order by signdate,signtime";
List<KQHrmScheduleSign> kqHrmScheduleSigns = new ArrayList<>();
try{
rs.execute(signSql);
while (rs.next()){
KQHrmScheduleSign kqHrmScheduleSign = getSignBean(rs);
kqHrmScheduleSigns.add(kqHrmScheduleSign);
}
}catch (Exception e){
e.printStackTrace();
}
return kqHrmScheduleSigns;
}
/**
*
* 退
* @return
*/
public Map<String,KQHrmScheduleSign> getScheduleSignInfoWithCardRange(){
String signSql = "";
Map<String,KQHrmScheduleSign> signMap = new HashMap<>();
RecordSet rs = new RecordSet();
String dbtype = rs.getDBType();
String baseSql = "select * from hrmschedulesign where 1=1 and isInCom='1' ";
String sqlWhere = sqlParamWhere();
if(sqlWhere.length() > 0){
baseSql += sqlWhere;
}
if(signSectionEndTime.length() == 0 && signSectionBeginTime.length() == 0){
//如果没设置上班后,下班前打卡
String signTimeSql = KQSignUtil.buildSignSql(signSectionTime,offSignSectionTime);
if(signTimeSql.length() > 0){
baseSql += " and "+signTimeSql;
}
if(baseSql.length() > 0){
signSql = baseSql;
signSql += " order by signdate,signtime";
kqLog.info("signSql:"+signSql);
try{
rs.execute(signSql);
while (rs.next()){
getScheduleSignBean(rs,signMap);
}
}catch (Exception e){
e.printStackTrace();
}
}
}else {
String onSignTimeSql = KQSignUtil.buildSignSql(signSectionTime,signSectionEndTime);
String offSignTimeSql = KQSignUtil.buildSignSql(signSectionBeginTime,offSignSectionTime);
String onSql = "";
String orderSql = "";
if(onSignTimeSql.length() > 0){
orderSql = " order by signdate asc, signtime asc ";
onSql += "select 'on' as belongtype,t.* from ("+baseSql+" and "+onSignTimeSql+") t";
if("oracle".equalsIgnoreCase(dbtype)){
onSql = "select * from ("+onSql+" "+orderSql+" ) a where rownum=1";
}else if("mysql".equalsIgnoreCase(dbtype)){
onSql = "select * from (select * from ("+onSql+" "+orderSql+" ) a limit 0,1) a ";
}
else if("postgresql".equalsIgnoreCase(dbtype)){
onSql = "select * from (select * from ("+onSql+" "+orderSql+" ) a limit 1 offset 0) a ";
}
else if("sqlserver".equalsIgnoreCase(dbtype)){
onSql = "select top 1 * from ("+onSql+" ) a "+" "+orderSql ;
}
}
String offSql = "";
if(offSignTimeSql.length() > 0){
orderSql = " order by signdate desc, signtime desc ";
offSql += "select 'off' as belongtype,t.* from ("+baseSql+" and "+offSignTimeSql+") t";
if("oracle".equalsIgnoreCase(dbtype)){
offSql = "select * from ("+offSql+" "+orderSql+" ) a where rownum=1";
}else if("mysql".equalsIgnoreCase(dbtype)){
offSql = "select * from (select * from ("+offSql+" "+orderSql+" ) a limit 0,1) a ";
}
else if("postgresql".equalsIgnoreCase(dbtype)){
offSql = "select * from (select * from ("+offSql+" "+orderSql+" ) a limit 1 offset 0) a ";
}
else if("sqlserver".equalsIgnoreCase(dbtype)){
offSql = "select top 1 * from ("+offSql+" ) a "+" "+orderSql ;
}
}
if(onSql.length() > 0 && offSql.length() > 0){
signSql = "select * from ("+onSql+" UNION ALL "+offSql+") s ";
kqLog.info("signSql:"+signSql);
try{
Map<String,KQHrmScheduleSign> checkMap = new HashMap<>();
rs.execute(signSql);
while (rs.next()){
getScheduleSignCardRangeBean(rs,signMap,checkMap);
}
}catch (Exception e){
e.printStackTrace();
}
}
}
return signMap;
}
/**
* 退
* @param rs
* @param signMap
* @param checkMap
*/
public void getScheduleSignCardRangeBean(RecordSet rs, Map<String, KQHrmScheduleSign> signMap,
Map<String, KQHrmScheduleSign> checkMap){
String belongtype =Util.null2String(rs.getString("belongtype"));
KQHrmScheduleSign kqHrmScheduleSign = getSignBean(rs);
if("on".equalsIgnoreCase(belongtype)){
if(!checkMap.containsKey("on")){
signMap.put("signin",kqHrmScheduleSign);
}
}else{
signMap.put("signout",kqHrmScheduleSign);
}
}
/**
* 退
* @param rs
* @param signMap
*/
public void getScheduleSignBean(RecordSet rs,Map<String,KQHrmScheduleSign> signMap){
KQHrmScheduleSign kqHrmScheduleSign = getSignBean(rs);
if(signMap.isEmpty()){
signMap.put("signin",kqHrmScheduleSign);
}else {
signMap.put("signout",kqHrmScheduleSign);
}
}
public KQHrmScheduleSign getSignBean(RecordSet rs){
KQHrmScheduleSign kqHrmScheduleSign = new KQHrmScheduleSign();
String id=Util.null2String(rs.getString("id"));
String userid=Util.null2String(rs.getString("userid"));
String usertype =Util.null2String(rs.getString("usertype"));
String signtype=Util.null2String(rs.getString("signtype"));
String signdate=Util.null2String(rs.getString("signdate"));
String signtime=Util.null2String(rs.getString("signtime"));
String clientaddress=Util.null2String(rs.getString("clientaddress"));
String signfrom=Util.null2String(rs.getString("signfrom"));
String longitude=Util.null2String(rs.getString("longitude"));
String latitude=Util.null2String(rs.getString("latitude"));
String addr=Util.null2String(rs.getString("addr"));
String isincom=Util.null2String(rs.getString("isincom"));
String isimport=Util.null2String(rs.getString("isimport"));
String importsql=Util.null2String(rs.getString("importsql"));
String belongdate=Util.null2String(rs.getString("belongdate"));
String serialid=Util.null2String(rs.getString("serialid"));
String worksections=Util.null2String(rs.getString("worksection"));
String signstatus=Util.null2String(rs.getString("signstatus"));
kqHrmScheduleSign.setId(id);
kqHrmScheduleSign.setUserid(userid);
kqHrmScheduleSign.setUsertype(usertype);
kqHrmScheduleSign.setSigntype(signtype);
kqHrmScheduleSign.setSigndate(signdate);
kqHrmScheduleSign.setSigntime(signtime);
kqHrmScheduleSign.setClientaddress(clientaddress);
kqHrmScheduleSign.setSignfrom(signfrom);
kqHrmScheduleSign.setLongitude(longitude);
kqHrmScheduleSign.setLatitude(latitude);
kqHrmScheduleSign.setAddr(addr);
kqHrmScheduleSign.setIsincom(isincom);
kqHrmScheduleSign.setIsimport(isimport);
kqHrmScheduleSign.setImportsql(importsql);
kqHrmScheduleSign.setBelongdate(belongdate);
kqHrmScheduleSign.setSerialid(serialid);
kqHrmScheduleSign.setWorksections(worksections);
kqHrmScheduleSign.setSignstatus(signstatus);
return kqHrmScheduleSign;
}
/**
*
* @return
*/
public Map<String,KQHrmScheduleSign> getScheduleSignInfo(){
RecordSet rs = new RecordSet();
String signSql = "select * from hrmschedulesign where 1=1 and isInCom='1' ";
String sqlWhere = sqlParamWhere();
if(sqlWhere.length() > 0){
signSql += sqlWhere;
}
signSql += " order by signdate,signtime";
Map<String,KQHrmScheduleSign> signMap = new HashMap<>();
try{
kqLog.info("signSql:"+signSql);
rs.execute(signSql);
while (rs.next()){
getScheduleSignBean(rs,signMap);
}
}catch (Exception e){
e.printStackTrace();
}
return signMap;
}
/**
*
* @return
*/
private String sqlParamWhere() {
String sqlWhere = "";
if(resourceid.length() > 0){
sqlWhere += " and userid in ( "+resourceid+" )";
}
if(signDate.length() > 0){
sqlWhere += " and signDate = '"+signDate+"' ";
}
if(signTime.length() > 0){
sqlWhere += " and signTime = '"+signTime+"' ";
}
if(signDateTimeSql.length() > 0){
sqlWhere += " and "+signDateTimeSql;
}
if(belongdate.length() > 0){
sqlWhere += " and belongdate = '"+belongdate+"' ";
}
if(signtype.length() > 0){
sqlWhere += " and signtype = '"+signtype+"' ";
}
//不需要userType没啥用
// if(userType.length() > 0){
// sqlWhere += " and userType = '"+userType+"' ";
// }
if(worksection.length() > 0){
sqlWhere += " and worksection = '"+worksection+"' ";
}
return sqlWhere;
}
public static class KQScheduleSignParamBuilder{
private String resourceid;
private String userType;
private String signDate;
private String signTime;
private String belongdate;
private String signtype;
private String worksection;
/**
* sql
*/
private String signDateTimeSql;
/**
*
*/
private String signSectionTime;
/**
*
*/
private String signSectionEndTime;
/**
*
*/
private String signSectionBeginTime;
/**
*
*/
private String offSignSectionTime;
public KQScheduleSignParamBuilder() {
this.resourceid = resourceid;
//初始化的时候需要把其他参数先清空下
this.userType = "";
this.signDate = "";
this.signTime = "";
this.belongdate = "";
this.signtype = "";
this.worksection = "";
this.signDateTimeSql = "";
this.signSectionTime = "";
this.signSectionEndTime = "";
this.signSectionBeginTime = "";
this.offSignSectionTime = "";
}
//成员方法返回其自身,所以可以链式调用
public KQScheduleSignBiz.KQScheduleSignParamBuilder resourceidParam(final String resourceid) {
this.resourceid = resourceid;
return this;
}
public KQScheduleSignBiz.KQScheduleSignParamBuilder userTypeParam(final String userType) {
this.userType = userType;
return this;
}
public KQScheduleSignBiz.KQScheduleSignParamBuilder signDateParam(final String signDate) {
this.signDate = signDate;
return this;
}
public KQScheduleSignBiz.KQScheduleSignParamBuilder signTimeParam(final String signTime) {
this.signTime = signTime;
return this;
}
public KQScheduleSignBiz.KQScheduleSignParamBuilder belongDateParam(final String belongdate) {
this.belongdate = belongdate;
return this;
}
public KQScheduleSignBiz.KQScheduleSignParamBuilder signtypeParam(final String signtype) {
this.signtype = signtype;
return this;
}
public KQScheduleSignBiz.KQScheduleSignParamBuilder worksectionParam(final String worksection) {
this.worksection = worksection;
return this;
}
public KQScheduleSignBiz.KQScheduleSignParamBuilder signDateTimeSqlParam(final String signDateTimeSql) {
this.signDateTimeSql = signDateTimeSql;
return this;
}
public KQScheduleSignBiz.KQScheduleSignParamBuilder signSectionTimeParam(final String signSectionTime) {
this.signSectionTime = signSectionTime;
return this;
}
public KQScheduleSignBiz.KQScheduleSignParamBuilder signSectionEndTimeParam(final String signSectionEndTime) {
this.signSectionEndTime = signSectionEndTime;
return this;
}
public KQScheduleSignBiz.KQScheduleSignParamBuilder signSectionBeginTimeParam(final String signSectionBeginTime) {
this.signSectionBeginTime = signSectionBeginTime;
return this;
}
public KQScheduleSignBiz.KQScheduleSignParamBuilder offSignSectionTimeParam(final String offSignSectionTime) {
this.offSignSectionTime = offSignSectionTime;
return this;
}
//Builder的build方法返回外部类的实例
public KQScheduleSignBiz build() {
return new KQScheduleSignBiz(this);
}
}
}

@ -0,0 +1,242 @@
package com.engine.kq.biz;
import com.alibaba.fastjson.JSON;
import com.engine.kq.log.KQLog;
import weaver.cache.*;
import weaver.conn.RecordSet;
import weaver.general.Util;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
*/
public class KQShiftRestTimeSectionComInfo 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 serial;
private KQLog kqLog = new KQLog();
@Override
protected boolean autoInitIfNotFound() {
return false;
}
@Override
public CacheMap initCache() {
CacheMap localData = createCacheMap();
RecordSet rs = new RecordSet();
kqLog = new KQLog();
List<Object> restSectionList = new ArrayList<>();
List<Object> sectionList = new ArrayList<>();
Map<String,Object> sectionMap = new HashMap<>();
Map<String,Object> serialMaps = new HashMap<>();//分组用的map
try {
String getRestSections = "select * from kq_ShiftRestTimeSections where 1=1 ";
rs.executeQuery(getRestSections);
while(rs.next()){
String id = Util.null2String(rs.getString("id"));
sectionMap = new HashMap<>();
String serialid = Util.null2String(rs.getString("serialid"));
String resttype = Util.null2String(rs.getString("resttype"));
String across = Util.null2String(rs.getString("across"));
String times = Util.null2String(rs.getString("time"));
sectionMap.put("across", across);
sectionMap.put("times", times);
if(serialMaps.get(serialid) != null){
List<Object> tmpList = (List<Object>)serialMaps.get(serialid);
if("start".equalsIgnoreCase(resttype)){
tmpList.set(0, sectionMap);
}else if("end".equalsIgnoreCase(resttype)){
tmpList.set(1, sectionMap);
}
}else{
restSectionList = new ArrayList<>();
sectionList = new ArrayList<>();
sectionList.add("");
sectionList.add("");
if("start".equalsIgnoreCase(resttype)){
sectionList.set(0, sectionMap);
}else if("end".equalsIgnoreCase(resttype)){
sectionList.set(1, sectionMap);
}
restSectionList.addAll(sectionList);
serialMaps.put(serialid, restSectionList);
}
}
for(Map.Entry<String,Object> me : serialMaps.entrySet()){
String id = me.getKey();
List<Object> valList = (List<Object>)me.getValue();
CacheItem cacheItem = createCacheItem();
cacheItem.set(PK_INDEX, id);
cacheItem.set(serial, valList);
modifyCacheItem(id, cacheItem);
localData.put(id, cacheItem);
}
}catch (Exception e){
writeLog(e);
}
return localData;
}
/**
* id
* @param serialid
* @return
*/
public List<String[]> getRestSectionTimesList(String serialid){
String startSql = "select * from kq_ShiftRestTimeSections where (isdelete is null or isdelete <> '1') and resttype='start' and serialid = ? ";
String endSql = "select * from kq_ShiftRestTimeSections where (isdelete is null or isdelete <> '1') and resttype='end' and serialid = ? ";
List<String[]> restList = new ArrayList<>();
RecordSet rstemp=new RecordSet();
rstemp.executeQuery(startSql, serialid);
while(rstemp.next()){
String times = rstemp.getString("time");
String[] timeArr = new String[2];
timeArr[0] = times;
restList.add(timeArr);
}
int i = 0;
rstemp=new RecordSet();
rstemp.executeQuery(endSql, serialid);
while(rstemp.next()){
String times = rstemp.getString("time");
String[] timeArr = restList.get(i);
timeArr[1] = times;
i++;
}
return restList;
}
/**
*
* @param serialid
* @return
*/
public List<Object> getRestSectionTimes(String serialid){
//return (List<Object>) getObjValue(serial, serialid);
RecordSet rs = new RecordSet();
kqLog = new KQLog();
List<Object> valList = new ArrayList<>();
List<Object> restSectionList = new ArrayList<>();
List<Object> sectionList = new ArrayList<>();
Map<String,Object> sectionMap = new HashMap<>();
Map<String,Object> serialMaps = new HashMap<>();//分组用的map
Map<String,Object> groupSectionMaps = new HashMap<>();//分组用的map
try {
String getRestSections = "select * from kq_ShiftRestTimeSections where serialid=? order by orderId ";
rs.executeQuery(getRestSections,serialid);
while(rs.next()){
String id = Util.null2String(rs.getString("id"));
sectionMap = new HashMap<>();
String resttype = Util.null2String(rs.getString("resttype"));
String across = Util.null2String(rs.getString("across"));
String times = Util.null2String(rs.getString("time"));
String record = Util.null2String(rs.getString("record1"));
sectionMap.put("across", across);
sectionMap.put("times", times);
if(serialMaps.get(serialid) != null){
Map<String,Object> tmpgroupSectionMaps = (Map<String,Object>)serialMaps.get(serialid);
if(tmpgroupSectionMaps.get(record) != null){
List<Object> tmpWorkSection = (List<Object>) tmpgroupSectionMaps.get(record);
List<Object> tmpSection = ((List<Object>)tmpWorkSection.get(tmpWorkSection.size()-1));
if("start".equalsIgnoreCase(resttype)){
tmpSection.set(0, sectionMap);
}else if("end".equalsIgnoreCase(resttype)){
tmpSection.set(1, sectionMap);
}
}else{
restSectionList = new ArrayList<>();
sectionList = new ArrayList<>();
sectionList.add("");
sectionList.add("");
if("start".equalsIgnoreCase(resttype)){
sectionList.set(0, sectionMap);
}else if("end".equalsIgnoreCase(resttype)){
sectionList.set(1, sectionMap);
}
restSectionList.add(sectionList);
tmpgroupSectionMaps.put(record, restSectionList);
}
}else{
groupSectionMaps = new HashMap<>();
restSectionList = new ArrayList<>();
serialMaps.put(serialid, groupSectionMaps);
if(groupSectionMaps.get(record) != null){
List<Object> tmpWorkSection = (List<Object>) groupSectionMaps.get(record);
List<Object> tmpSection = ((List<Object>)tmpWorkSection.get(tmpWorkSection.size()-1));
if("start".equalsIgnoreCase(resttype)){
tmpSection.set(0, sectionMap);
}else if("end".equalsIgnoreCase(resttype)){
tmpSection.set(1, sectionMap);
}
}else{
sectionList = new ArrayList<>();
sectionList.add("");
sectionList.add("");
if("start".equalsIgnoreCase(resttype)){
sectionList.set(0, sectionMap);
}else if("end".equalsIgnoreCase(resttype)){
sectionList.set(1, sectionMap);
}
restSectionList.add(sectionList);
groupSectionMaps.put(record, restSectionList);
}
}
}
for(Map.Entry<String,Object> me : serialMaps.entrySet()){
valList = new ArrayList<>();
Map<String,Object> val = (Map<String,Object>)me.getValue();
for(Map.Entry<String,Object> mee : val.entrySet()){
valList.addAll((List<Object>)mee.getValue());
}
}
}catch (Exception e){
writeLog(e);
}
return valList;
}
/**
*
*/
public void removeShiftRestTimeSectionCache() {
removeCache();
}
}

@ -0,0 +1,820 @@
package com.engine.kq.biz;
import com.alibaba.fastjson.JSON;
import com.engine.kq.bean.KQHrmScheduleSign;
import com.engine.kq.biz.chain.cominfo.HalfShiftComIndex;
import com.engine.kq.biz.chain.cominfo.ShiftInfoCominfoBean;
import com.engine.kq.biz.chain.duration.WorkHalfUnitSplitChain;
import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean;
import com.engine.kq.entity.TimeScopeEntity;
import com.engine.kq.entity.WorkTimeEntity;
import com.engine.kq.log.KQLog;
import com.engine.kq.wfset.bean.SplitBean;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import weaver.common.DateUtil;
import weaver.general.BaseBean;
import weaver.general.Util;
/**
*
*/
public class KQShiftRuleInfoBiz {
public static void getShiftRuleInfo(ShiftInfoBean shiftInfoBean, String resourceId,Map<String,String> shifRuleMap,List<String> logList) {
getShiftRuleInfo(shiftInfoBean, resourceId, shifRuleMap, true,logList);
}
public static void getShiftRuleInfo(ShiftInfoBean shiftInfoBean, String resourceId,Map<String,String> shifRuleMap) {
getShiftRuleInfo(shiftInfoBean, resourceId, shifRuleMap, true);
}
public static void getShiftRuleInfo(ShiftInfoBean shiftInfoBean, String resourceId,Map<String,String> shifRuleMap,boolean need_lateoutlatein) {
getShiftRuleInfo(shiftInfoBean, resourceId, shifRuleMap, need_lateoutlatein,
Lists.newArrayList());
}
/**
* do4ShiftRule
* @param shiftInfoBean
* @param resourceId
* @param need_lateoutlatein
*/
public static void getShiftRuleInfo(ShiftInfoBean shiftInfoBean, String resourceId,Map<String,String> shifRuleMap,boolean need_lateoutlatein,List<String> logList) {
DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
DateTimeFormatter minFormatter = DateTimeFormatter.ofPattern("HH:mm");
KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo();
List<Object> earlyinearlyout = null;//早到早走规则
List<Object> lateinlateout = null;//晚到晚走规则
List<Object> lateoutlatein = null;//晚走晚到规则
if(shiftInfoBean == null){
return ;
}
String splitDate = shiftInfoBean.getSplitDate();
String preDate = DateUtil.addDate(splitDate, -1);//上一天日期
String nextDate = DateUtil.addDate(splitDate, 1);//下一天日期
KQWorkTime kqWorkTime = new KQWorkTime();
kqWorkTime.setIsFormat(true);
WorkTimeEntity workTime = kqWorkTime.getWorkTime(resourceId, preDate);
Map<String, Object> preshiftRuleMap = workTime.getShiftRuleInfo();
if (preshiftRuleMap != null && !preshiftRuleMap.isEmpty() && preshiftRuleMap.containsKey("ruleDetail")) {
Map<String, Object> preruleDetail = (Map<String, Object>) preshiftRuleMap.get("ruleDetail");
if(preruleDetail != null && !preruleDetail.isEmpty()){
lateoutlatein = (List<Object>) preruleDetail.get("lateoutlatein");//晚走晚到应该取前一天的个性化班次的设置,而不是当天
}
}
Map<String, Object> shiftRuleMap = shiftInfoBean.getShiftRuleMap();
if (shiftRuleMap != null && !shiftRuleMap.isEmpty() && shiftRuleMap.containsKey("ruleDetail")) {//处理人性化设置其他规则
//允许迟到分钟数
boolean usepermitlateminutes = Util.null2String(shiftRuleMap.get("permitlatestatus")).equals("1");
//和蔡志军讨论,优先满足弹性,即如果晚到了,开启了弹性,那么就先按照弹性来处理,不满足弹性的部分再按照允许迟到来处理
usepermitlateminutes = false;
int permitlateminutes = Util.getIntValue(Util.null2String(shiftRuleMap.get("permitlateminutes")), 0);
// //允许早退分钟数
// boolean usepermitleaveearlyminutes = Util.null2String(shiftRuleMap.get("permitleaveearlystatus")).equals("1");
// int permitleaveearlyminutes = Util.getIntValue(Util.null2String(shiftRuleMap.get("permitleaveearlyminutes")), 0);
Map<String, Object> ruleDetail = (Map<String, Object>) shiftRuleMap.get("ruleDetail");
if(ruleDetail != null && !ruleDetail.isEmpty()){
earlyinearlyout = (List<Object>) ruleDetail.get("earlyinearlyout");
lateinlateout = (List<Object>) ruleDetail.get("lateinlateout");
//上面已经搞了下面注释掉
// lateoutlatein = (List<Object>) ruleDetail.get("lateoutlatein");
// KQWorkTime kqWorkTime = new KQWorkTime();
//如果设置了个性化规则,需要先获取下打卡数据
List<TimeScopeEntity> lsSignTime = new ArrayList<>();
List<TimeScopeEntity> lsWorkTime = new ArrayList<>();
List<TimeScopeEntity> lsRestTime = new ArrayList<>();
lsSignTime = shiftInfoBean.getSignTime();//允许打卡时间
lsWorkTime = shiftInfoBean.getWorkTime();//工作时间
//只有一次签到签退才有个性化的这些设置
if(lsWorkTime != null && lsWorkTime.size() > 0){
//早到早走后,引起下班时间变化后的时间
LocalDateTime early_localEndDateTime = null;
//早到早走后,引起上班时间变化后的时间
LocalDateTime early_localBeginDateTime = null;
//晚到晚走后,引起下班时间变化后的时间
LocalDateTime late_localEndDateTime = null;
//晚到晚走后,引起上班时间变化后的时间
LocalDateTime late_localBeginDateTime = null;
//晚走晚到后,引起上班时间变化后的时间
LocalDateTime latein_localBeginDateTime = null;
TimeScopeEntity signTimeScope = lsSignTime.get(0);
TimeScopeEntity workTimeScope = lsWorkTime.get(0);
String signInDate = "";
String signInTime = "";
String signOutDate = "";
String signOutTime = "";
String workbeigintime = workTimeScope.getBeginTime();
boolean beginTimeAcross = workTimeScope.getBeginTimeAcross();
String workbegindate = splitDate;
if(beginTimeAcross){
workbegindate = nextDate;
workbeigintime = kqTimesArrayComInfo.turn48to24Time(workbeigintime);
}
String workbegindatetime = workbegindate+" "+workbeigintime+":00";
LocalDateTime localBeginDateTime = LocalDateTime.parse(workbegindatetime,fullFormatter);
String workendtime = workTimeScope.getEndTime();
boolean endTimeAcross = workTimeScope.getEndTimeAcross();
String workenddate = splitDate;
if(endTimeAcross){
workenddate = nextDate;
workendtime = kqTimesArrayComInfo.turn48to24Time(workendtime);
}
String workenddatetime = workenddate+" "+workendtime+":00";
LocalDateTime localEndDateTime = LocalDateTime.parse(workenddatetime,fullFormatter);
List<Object> lsCheckInfo = new KQFormatSignData().getSignInfo(resourceId,signTimeScope,workTimeScope,splitDate,preDate,nextDate,kqTimesArrayComInfo);
if(lsCheckInfo.isEmpty()){
//如果当天没有打卡数据,判断下是否存在昨天有打卡数据,晚走晚到的情况
if (lateoutlatein != null && lateoutlatein.size() > 0) {
}else{
return ;
}
}
if(lsCheckInfo.size() > 1){
for(int i = 0 ; i < lsCheckInfo.size() ; i++){
Map<String, Object> checkInfo = (Map<String, Object>) lsCheckInfo.get(i);
if (checkInfo.get("signType").equals("1")) {
//签到
signInDate = Util.null2String(checkInfo.get("signDate"));
signInTime = Util.null2String(checkInfo.get("signTime"));
}
if (checkInfo.get("signType").equals("2")) {
//签退
signOutDate = Util.null2String(checkInfo.get("signDate"));
signOutTime = Util.null2String(checkInfo.get("signTime"));
}
}
}else if(lsCheckInfo.size() == 1){
Map<String, Object> checkInfo = (Map<String, Object>) lsCheckInfo.get(0);
if (checkInfo.get("signType").equals("1")) {
//签到
signInDate = Util.null2String(checkInfo.get("signDate"));
signInTime = Util.null2String(checkInfo.get("signTime"));
}
if (checkInfo.get("signType").equals("2")) {
//签退
signOutDate = Util.null2String(checkInfo.get("signDate"));
signOutTime = Util.null2String(checkInfo.get("signTime"));
}
}
if (need_lateoutlatein && lateoutlatein != null && lateoutlatein.size() > 0) {
String log_str = "";
KQFormatShiftRule kqFormatShiftRule = new KQFormatShiftRule();
int preDayLateOutMins = kqFormatShiftRule.getPreDayLateOutMins(resourceId, splitDate,logList);
if(!logList.isEmpty()){
for(int i = 0 ; i < logList.size() ; i++){
if(i == 0){
log_str += ""+logList.get(i);
}else{
log_str += ","+logList.get(i);
}
}
logList.clear();
}
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();//允许晚到时间
boolean enablesame = Util.null2String(rule.get("enablesame")).equals("1");
if(log_str.length() > 0){
log_str += ","+(" "+"开启了晚走晚到,"+(enablesame?"相对时间,前一天晚走,第二天可以晚到,弹性限额"+postponetime+"分钟":"绝对时间"+",前一天晚走"+advancetime+"分钟,第二天上班可以晚到"+postponetime+"分钟"));
}else{
log_str += ""+(" "+"开启了晚走晚到,"+(enablesame?"相对时间,前一天晚走,第二天可以晚到,弹性限额"+postponetime+"分钟":"绝对时间"+",前一天晚走"+advancetime+"分钟,第二天上班可以晚到"+postponetime+"分钟"));
}
if (enablesame) {
if(preDayLateOutMins >= advancetime){
//如果昨日的晚走时长已经完全大于了设置的晚走时长,那么就可以晚到整个postponetime
latein_localBeginDateTime = localBeginDateTime.plusMinutes(postponetime);
}else{
latein_localBeginDateTime = localBeginDateTime.plusMinutes(preDayLateOutMins);
}
break;
}else{
if (preDayLateOutMins >= advancetime) {
//如果昨日的晚走时长已经完全大于了设置的晚走时长,那么就可以晚到整个postponetime
latein_localBeginDateTime = localBeginDateTime.plusMinutes(postponetime);
break;
}else{
logList.clear();
}
}
}else{
logList.clear();
}
}
if(latein_localBeginDateTime != null){
shifRuleMap.put("shift_type", "lateoutlatein");
String beginDate = latein_localBeginDateTime.format(dateFormatter);
String beginmin = latein_localBeginDateTime.format(minFormatter);
// 前一天的晚到影响了今天的早到或者晚到
workbegindatetime = latein_localBeginDateTime.format(fullFormatter);
localBeginDateTime = LocalDateTime.parse(workbegindatetime,fullFormatter);
log_str += ","+("满足了晚走晚到,所以今天的上班时间变化了,变成了:"+workbegindatetime+"-"+workenddatetime);
shifRuleMap.put("shift_begindate", beginDate);
if(beginDate.compareTo(splitDate) > 0){
shifRuleMap.put("shift_beginworktime", kqTimesArrayComInfo.turn24to48Time(beginmin));
}else{
shifRuleMap.put("shift_beginworktime", beginmin);
}
}else{
log_str = "";
}
if(log_str.length() > 0){
logList.add(log_str);
}else{
logList.clear();
}
}
String log_str = "";
long signIn_before_mins = 0;
long signIn_after_mins = 0;
long signOut_before_mins = 0;
long signOut_after_mins = 0;
if(signInDate.length() > 0 && signInTime.length() > 0){
//判断下签到和上班时间,是否存在早到或者晚到的情况的情况
String fromDateTime = signInDate+" "+signInTime;
String toDateTime = workbegindatetime;
long signIn_mins = Duration.between(LocalDateTime.parse(fromDateTime, fullFormatter), LocalDateTime.parse(toDateTime, fullFormatter)).toMinutes();
if(latein_localBeginDateTime != null){
signIn_mins = Duration.between(LocalDateTime.parse(fromDateTime, fullFormatter), latein_localBeginDateTime).toMinutes();
}
boolean need_plus_one_min = false;
new BaseBean().writeLog("fromDateTime="+fromDateTime+">>>toDateTime="+toDateTime);
if(signInTime.length() > 6){
String signMinTime = signInTime.substring(0,5)+":00";
if(signInTime.compareTo(signMinTime) > 0){
//如果签到时间是带秒的且是迟到,那么签到时间多一秒和多一分钟是一样的
need_plus_one_min = true;
String tmpfromDateTime = signInDate+" "+signMinTime;
if(need_plus_one_min){
signIn_mins = Duration.between(LocalDateTime.parse(tmpfromDateTime, fullFormatter).plusMinutes(1), LocalDateTime.parse(toDateTime, fullFormatter)).toMinutes();
if(latein_localBeginDateTime != null){
signIn_mins = Duration.between(LocalDateTime.parse(tmpfromDateTime, fullFormatter).plusMinutes(1), latein_localBeginDateTime).toMinutes();
}
}
}
}
if(signIn_mins > 0){
log_str = (splitDate+" 上班时间是:"+toDateTime+",签到时间是:"+fromDateTime+",早到"+signIn_mins+"分钟");
//确实是早到了
signIn_before_mins = signIn_mins;
}else if(signIn_mins < 0){
//这属于是晚到了
signIn_after_mins = Math.abs(signIn_mins);
log_str = (splitDate+" "+"上班时间是:"+toDateTime+",签到时间是:"+fromDateTime+",晚到"+signIn_after_mins+"分钟");
if (usepermitlateminutes) {//允许迟到分钟数
signIn_after_mins = signIn_after_mins - permitlateminutes;
}
}
}
if(signOutDate.length() > 0 && signOutTime.length() > 0){
//判断下签退和下班时间,是否存在晚走的情况
String fromDateTime = workenddatetime;
String toDateTime = signOutDate+" "+signOutTime;
long signOut_mins = Duration.between(LocalDateTime.parse(fromDateTime, fullFormatter), LocalDateTime.parse(toDateTime, fullFormatter)).toMinutes();
if(signOut_mins > 0){
//这属于是晚走了
signOut_after_mins = signOut_mins;
}else if(signOut_mins < 0){
//这属于是早退了
signOut_before_mins = Math.abs(signOut_mins);
}
}
if (earlyinearlyout != null && earlyinearlyout.size() > 0 && signIn_before_mins > 0) {
//必须有早到时间才能继续下面的判断
for (int i = 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();//允许早走时间
boolean enablesame = Util.null2String(rule.get("enablesame")).equals("1");
if(log_str.length() > 0){
log_str += ","+(" "+"开启了早到早走,"+(enablesame?"相对时间,早到可以早走,弹性限额"+postponetime+"分钟":"绝对时间"+",上班早到"+advancetime+"分钟,下班可以早走"+postponetime+"分钟"));
}else{
log_str += ""+(" "+"开启了早到早走,"+(enablesame?"相对时间,早到可以早走,弹性限额"+postponetime+"分钟":"绝对时间"+",上班早到"+advancetime+"分钟,下班可以早走"+postponetime+"分钟"));
}
if (enablesame) {
//使用相对时间
if(signIn_before_mins >= advancetime){
//如果打卡的早到时长已经完全大于了设置的早到时长,那么就可以早走整个postponetime
early_localEndDateTime = localEndDateTime.minusMinutes(postponetime);
early_localBeginDateTime = localBeginDateTime.minusMinutes(advancetime);
}else{
early_localEndDateTime = localEndDateTime.minusMinutes(signIn_before_mins);
early_localBeginDateTime = localBeginDateTime.minusMinutes(signIn_before_mins);
}
break;
}else{
if(signIn_before_mins >= advancetime){
//如果打卡的早到时长已经完全大于了设置的早到时长,那么就可以早走整个postponetime
early_localEndDateTime = localEndDateTime.minusMinutes(postponetime);
early_localBeginDateTime = localBeginDateTime.minusMinutes(advancetime);
break;
}
}
}
}
String new_beginDateTime = "";
String new_endDateTime = "";
if(early_localBeginDateTime != null){
shifRuleMap.put("shift_type", "earlyinearlyout");
String beginDate = early_localBeginDateTime.format(dateFormatter);
String beginmin = early_localBeginDateTime.format(minFormatter);
shifRuleMap.put("shift_begindate", beginDate);
if(beginDate.compareTo(splitDate) > 0){
shifRuleMap.put("shift_beginworktime", kqTimesArrayComInfo.turn24to48Time(beginmin));
}else{
shifRuleMap.put("shift_beginworktime", beginmin);
}
new_beginDateTime = beginDate+" "+beginmin;
}
if(early_localEndDateTime != null){
shifRuleMap.put("shift_type", "earlyinearlyout");
String endDate = early_localEndDateTime.format(dateFormatter);
String endmin = early_localEndDateTime.format(minFormatter);
shifRuleMap.put("shift_enddate", endDate);
if(endDate.compareTo(splitDate) > 0){
shifRuleMap.put("shift_endworktime", kqTimesArrayComInfo.turn24to48Time(endmin));
}else{
shifRuleMap.put("shift_endworktime", endmin);
}
new_endDateTime = endDate+" "+endmin;
}
if(new_beginDateTime.length() > 0 && new_endDateTime.length() > 0){
log_str += ","+"满足了早到,所以"+splitDate+"的上班时间和下班时间变化了,上班时间变成了:"+new_beginDateTime+",下班时间变成了:"+new_endDateTime;
}else{
log_str += ",不满足规则,所以"+splitDate+"的上班时间和下班时间未发生变化,上班时间还是:"+workbegindatetime+",下班时间还是:"+workenddatetime;
}
if(log_str.length() > 0){
logList.add(log_str);
}
}
boolean isLateinlateout = false;
if (lateinlateout != null && lateinlateout.size() > 0) {
if(signIn_after_mins > 0){
isLateinlateout = true;
//必须有晚到时间才能继续下面的判断
for (int i = 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();//需要晚走时间
boolean enablesame = Util.null2String(rule.get("enablesame")).equals("1");
if(log_str.length() > 0){
log_str += ","+(" "+"开启了晚到晚走,"+(enablesame?"相对时间,晚到可以晚走,弹性限额"+postponetime+"分钟":"绝对时间"+",上班晚到"+advancetime+"分钟,下班需要晚走"+postponetime+"分钟"));
}else{
log_str += ""+(" "+"开启了晚到晚走,"+(enablesame?"相对时间,晚到可以晚走,弹性限额"+postponetime+"分钟":"绝对时间"+",上班晚到"+advancetime+"分钟,下班需要晚走"+postponetime+"分钟"));
}
if (enablesame) {
//使用相对时间
if(signIn_after_mins <= advancetime){
//如果打卡的晚到时长必须要小于等于设置的晚到时长,才算满足,晚到多久就可以晚走多久
late_localEndDateTime = localEndDateTime.plusMinutes(signIn_after_mins);
late_localBeginDateTime = localBeginDateTime.plusMinutes(signIn_after_mins);
break;
}else{
if(KQSettingsBiz.is_lateinlateout_outrule()){
late_localEndDateTime = localEndDateTime.plusMinutes(advancetime);
late_localBeginDateTime = localBeginDateTime.plusMinutes(advancetime);
break;
}
}
}else{
if (signIn_after_mins <= advancetime) {
//如果打卡的晚到时长已经完全小于了设置的晚到时长,那么需要晚走整个postponetime
late_localEndDateTime = localEndDateTime.plusMinutes(postponetime);
late_localBeginDateTime = localBeginDateTime.plusMinutes(advancetime);
break;
}else{
if(KQSettingsBiz.is_lateinlateout_outrule()){
late_localEndDateTime = localEndDateTime.plusMinutes(postponetime);
late_localBeginDateTime = localBeginDateTime.plusMinutes(advancetime);
break;
}
}
}
}
}
}
if(isLateinlateout){
String new_beginDateTime = "";
String new_endDateTime = "";
if(late_localBeginDateTime != null){
shifRuleMap.put("shift_type", "lateinlateout");
String beginDate = late_localBeginDateTime.format(dateFormatter);
String beginmin = late_localBeginDateTime.format(minFormatter);
shifRuleMap.put("shift_begindate", beginDate);
if(beginDate.compareTo(splitDate) > 0){
shifRuleMap.put("shift_beginworktime", kqTimesArrayComInfo.turn24to48Time(beginmin));
}else{
shifRuleMap.put("shift_beginworktime", beginmin);
}
new_beginDateTime = beginDate+" "+beginmin;
}
if(late_localEndDateTime != null){
shifRuleMap.put("shift_type", "lateinlateout");
String endDate = late_localEndDateTime.format(dateFormatter);
String endmin = late_localEndDateTime.format(minFormatter);
shifRuleMap.put("shift_enddate", endDate);
if(endDate.compareTo(splitDate) > 0){
shifRuleMap.put("shift_endworktime", kqTimesArrayComInfo.turn24to48Time(endmin));
}else{
shifRuleMap.put("shift_endworktime", endmin);
}
new_endDateTime = endDate+" "+endmin;
}
if(new_beginDateTime.length() > 0 && new_endDateTime.length() > 0){
log_str += ",满足了晚到,所以"+splitDate+"的上班时间和下班时间变化了,上班时间变成了:"+new_beginDateTime+",下班时间变成了:"+new_endDateTime;
}else{
log_str += ",不满足规则,所以"+splitDate+"的上班时间和下班时间未发生变化,上班时间还是:"+workbegindatetime+",下班时间还是:"+workenddatetime;
}
if(log_str.length() > 0){
logList.add(log_str);
}
}
}
}
}
}
}
public void rest_workLongTimeIndex(ShiftInfoBean shiftInfoBean,
SplitBean splitBean, List<int[]> real_workLongTimeIndex,
KQTimesArrayComInfo kqTimesArrayComInfo,
List<String> real_allLongWorkTime){
boolean is_flow_humanized = KQSettingsBiz.is_flow_humanized();
if(!is_flow_humanized){
return ;
}
//个性化设置只支持一次打卡的
Map<String,String> shifRuleMap = Maps.newHashMap();
KQShiftRuleInfoBiz.getShiftRuleInfo(shiftInfoBean,splitBean.getResourceId(),shifRuleMap);
if(!shifRuleMap.isEmpty()){
if(shifRuleMap.containsKey("shift_beginworktime")){
String shift_beginworktime = Util.null2String(shifRuleMap.get("shift_beginworktime"));
if(shift_beginworktime.length() > 0){
int[] workLongTimeIndex_arr = real_workLongTimeIndex.get(0);
workLongTimeIndex_arr[0] = kqTimesArrayComInfo.getArrayindexByTimes(shift_beginworktime);
if(real_allLongWorkTime != null){
real_allLongWorkTime.set(0,shift_beginworktime);
}
}
}
if(shifRuleMap.containsKey("shift_endworktime")){
String shift_endworktime = Util.null2String(shifRuleMap.get("shift_endworktime"));
if(shift_endworktime.length() > 0){
int[] workLongTimeIndex_arr = real_workLongTimeIndex.get(0);
workLongTimeIndex_arr[1] = kqTimesArrayComInfo.getArrayindexByTimes(shift_endworktime);
if(real_allLongWorkTime != null){
real_allLongWorkTime.set(1,shift_endworktime);
}
}
}
reset_halfIndex(shiftInfoBean,real_allLongWorkTime,kqTimesArrayComInfo);
}
}
public void reset_halfIndex(ShiftInfoBean shiftInfoBean, List<String> real_allLongWorkTime, KQTimesArrayComInfo kqTimesArrayComInfo) {
try{
List<String[]> real_workAcrossTime = shiftInfoBean.getWorkAcrossTime();
List<int[]> shift_halfWorkIndex = shiftInfoBean.getHalfWorkIndex();
List<int[]> real_shift_halfWorkIndex = Lists.newArrayList();
List<Integer> eachWorkMins = Lists.newArrayList();
List<Integer> tmp_eachWorkMins = Lists.newArrayList();
List<int[]> workLongTimeIndex = shiftInfoBean.getWorkLongTimeIndex();
List<int[]> restLongTimeIndex = shiftInfoBean.getRestLongTimeIndex();
String allLongWorkBeginTime = real_allLongWorkTime.get(0);
String allLongWorkEndTime = real_allLongWorkTime.get(1);
String[] real_workAcrossTimes = new String[2];
real_workAcrossTimes[0] = allLongWorkBeginTime;
real_workAcrossTimes[1] = allLongWorkEndTime;
if(!workLongTimeIndex.isEmpty()){
real_workAcrossTime.set(0,real_workAcrossTimes);
}
int[] real_workLongTimeIndex = new int[2];
real_workLongTimeIndex[0] = kqTimesArrayComInfo.getArrayindexByTimes(allLongWorkBeginTime);
real_workLongTimeIndex[1] = kqTimesArrayComInfo.getArrayindexByTimes(allLongWorkEndTime);
if(!workLongTimeIndex.isEmpty()){
workLongTimeIndex.set(0, real_workLongTimeIndex);
}
int allLongWorkBeginTime_Index = kqTimesArrayComInfo.getArrayindexByTimes(allLongWorkBeginTime);
int allLongWorkEndTime_Index = kqTimesArrayComInfo.getArrayindexByTimes(allLongWorkEndTime);
tmp_eachWorkMins.add(allLongWorkBeginTime_Index);
int real_workmins = allLongWorkEndTime_Index-allLongWorkBeginTime_Index;
for(int k = 0 ; k < restLongTimeIndex.size() ; k++){
int[] rests = restLongTimeIndex.get(k);
if(rests != null && rests.length == 2){
real_workmins = real_workmins - (rests[1]-rests[0]);
tmp_eachWorkMins.add(rests[0]);
tmp_eachWorkMins.add(rests[1]);
}
}
tmp_eachWorkMins.add(allLongWorkEndTime_Index);
for(int j = 0 ; j < tmp_eachWorkMins.size() ; ){
int end_index = tmp_eachWorkMins.get(j+1);
int begin_index = tmp_eachWorkMins.get(j);
int tmp = end_index-begin_index;
if(tmp > 0){
eachWorkMins.add(end_index-begin_index);
}
j = j + 2;
}
Map<String,Object> workTimeMap = Maps.newHashMap();
workTimeMap.put("halfcalrule", shiftInfoBean.getHalfcalrule());
workTimeMap.put("halfcalpoint", shiftInfoBean.getHalfcalpoint());
workTimeMap.put("halfcalpoint2cross", shiftInfoBean.getHalfcalpoint2cross());
workTimeMap.put("workmins", real_workmins);
HalfShiftComIndex halfShiftComIndex = new HalfShiftComIndex(""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005308,weaver.general.ThreadVarLanguage.getLang())+"",workTimeMap);
ShiftInfoCominfoBean shiftInfoCominfoBean = new ShiftInfoCominfoBean();
shiftInfoCominfoBean.setAllLongWorkTime(real_allLongWorkTime);
shiftInfoCominfoBean.setRestLongTimeIndex(shiftInfoBean.getRestLongTimeIndex());
shiftInfoCominfoBean.setWorkAcrossTime(real_workAcrossTime);
shiftInfoCominfoBean.setEachWorkMins(eachWorkMins);
shiftInfoCominfoBean.setHalfWorkIndex(real_shift_halfWorkIndex);
shiftInfoCominfoBean.setWorkLongTimeIndex(workLongTimeIndex);
halfShiftComIndex.handleHalfTime(shiftInfoCominfoBean);
if(!real_shift_halfWorkIndex.isEmpty()){
shiftInfoBean.setHalfWorkIndex(real_shift_halfWorkIndex);
}
}catch (Exception e){
}
}
/**
*
* @param ruleDetail
* @param signInTimeBean
* @param signOutTimeBean
* @param allWorkTime
* @param splitDate
* @param nextday
* @param resourceid
*/
public static Map<String, String> do4ShiftRule(Map<String, Object> ruleDetail,
KQHrmScheduleSign signInTimeBean, KQHrmScheduleSign signOutTimeBean,
List<String> allWorkTime, String splitDate, String nextday, String resourceid) {
Map<String,String> shifRuleMap = Maps.newHashMap();
boolean is_flow_humanized = KQSettingsBiz.is_flow_humanized();
if(!is_flow_humanized){
return shifRuleMap;
}
DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
DateTimeFormatter minFormatter = DateTimeFormatter.ofPattern("HH:mm");
KQTimesArrayComInfo kqTimesArrayComInfo = new KQTimesArrayComInfo();
List<Object> earlyinearlyout = null;//早到早走规则
List<Object> lateinlateout = null;//晚到晚走规则
List<Object> lateoutlatein = null;//晚走晚到规则
String begintime = allWorkTime.get(0);
String endtime = allWorkTime.get(allWorkTime.size()-1);
boolean isEndAcross = false;
if(begintime.compareTo(endtime) > 0){
//结束时间跨天了
isEndAcross = true;
}
//早到早走后,引起下班时间变化后的时间
LocalDateTime early_localEndDateTime = null;
//早到早走后,引起上班时间变化后的时间
LocalDateTime early_localBeginDateTime = null;
//晚到晚走后,引起下班时间变化后的时间
LocalDateTime late_localEndDateTime = null;
//晚到晚走后,引起上班时间变化后的时间
LocalDateTime late_localBeginDateTime = null;
//晚走晚到后,引起上班时间变化后的时间
LocalDateTime latein_localBeginDateTime = null;
earlyinearlyout = (List<Object>) ruleDetail.get("earlyinearlyout");
lateinlateout = (List<Object>) ruleDetail.get("lateinlateout");
lateoutlatein = (List<Object>) ruleDetail.get("lateoutlatein");
String workbegindatetime = splitDate+" "+begintime+":00";
LocalDateTime localBeginDateTime = LocalDateTime.parse(workbegindatetime,fullFormatter);
String workenddatetime = (isEndAcross ? nextday : splitDate)+" "+endtime+":00";
LocalDateTime localEndDateTime = LocalDateTime.parse(workenddatetime,fullFormatter);
long signIn_before_mins = 0;
long signIn_after_mins = 0;
long signOut_before_mins = 0;
long signOut_after_mins = 0;
if(signInTimeBean != null){
String signInDate = signInTimeBean.getSigndate();
String signInTime = signInTimeBean.getSigntime();
//判断下签到和上班时间,是否存在早到或者晚到的情况的情况
String fromDateTime = signInDate+" "+signInTime;
String toDateTime = workbegindatetime;
long signIn_mins = Duration.between(LocalDateTime.parse(fromDateTime, fullFormatter), LocalDateTime.parse(toDateTime, fullFormatter)).toMinutes();
if(signIn_mins > 0){
//确实是早到了
signIn_before_mins = signIn_mins;
}else if(signIn_mins < 0){
//这属于是晚到了
signIn_after_mins = Math.abs(signIn_mins);
}
}
if(signOutTimeBean != null){
String signOutDate = signOutTimeBean.getSigndate();
String signOutTime = signOutTimeBean.getSigntime();
//判断下签退和下班时间,是否存在晚走的情况
String fromDateTime = workenddatetime;
String toDateTime = signOutDate+" "+signOutTime;
long signOut_mins = Duration.between(LocalDateTime.parse(fromDateTime, fullFormatter), LocalDateTime.parse(toDateTime, fullFormatter)).toMinutes();
if(signOut_mins > 0){
//这属于是晚走了
signOut_after_mins = signOut_mins;
}else if(signOut_mins < 0){
//这属于是早退了
signOut_before_mins = Math.abs(signOut_mins);
}
}
if (earlyinearlyout != null && earlyinearlyout.size() > 0 && signIn_before_mins > 0) {
//必须有早到时间才能继续下面的判断
for (int i = 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(signIn_before_mins >= advancetime){
//如果打卡的早到时长已经完全大于了设置的早到时长,那么就可以早走整个postponetime
early_localEndDateTime = localEndDateTime.minusMinutes(postponetime);
early_localBeginDateTime = localBeginDateTime.minusMinutes(advancetime);
}else{
early_localEndDateTime = localEndDateTime.minusMinutes(signIn_before_mins);
early_localBeginDateTime = localBeginDateTime.minusMinutes(signIn_before_mins);
}
break;
}else{
if(signIn_before_mins >= advancetime){
//如果打卡的早到时长已经完全大于了设置的早到时长,那么就可以早走整个postponetime
early_localEndDateTime = localEndDateTime.minusMinutes(postponetime);
early_localBeginDateTime = localBeginDateTime.minusMinutes(advancetime);
break;
}
}
}
}
}
if (lateinlateout != null && lateinlateout.size() > 0 && signIn_after_mins > 0) {
//必须有晚到时间才能继续下面的判断
for (int i = 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(signIn_after_mins <= advancetime){
//如果打卡的晚到时长必须要小于等于设置的晚到时长,才算满足,晚到多久就可以晚走多久
late_localEndDateTime = localEndDateTime.plusMinutes(signIn_after_mins);
late_localBeginDateTime = localBeginDateTime.plusMinutes(signIn_after_mins);
}
break;
}else{
if (signIn_after_mins <= advancetime) {
//如果打卡的晚到时长已经完全小于了设置的晚到时长,那么需要晚走整个postponetime
late_localEndDateTime = localEndDateTime.plusMinutes(postponetime);
late_localBeginDateTime = localBeginDateTime.plusMinutes(advancetime);
break;
}
}
}
}
}
if (lateoutlatein != null && lateoutlatein.size() > 0) {
LocalDateTime tmp_localBeginDateTime = localBeginDateTime;
if(early_localBeginDateTime != null){
tmp_localBeginDateTime = early_localBeginDateTime;
}
if(late_localBeginDateTime != null){
tmp_localBeginDateTime = late_localBeginDateTime;
}
KQFormatShiftRule kqFormatShiftRule = new KQFormatShiftRule();
int preDayLateOutMins = kqFormatShiftRule.getPreDayLateOutMins(resourceid, splitDate);
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 >= advancetime){
//如果昨日的晚走时长已经完全大于了设置的晚走时长,那么就可以晚到整个postponetime
latein_localBeginDateTime = tmp_localBeginDateTime.plusMinutes(postponetime);
}else{
latein_localBeginDateTime = tmp_localBeginDateTime.plusMinutes(preDayLateOutMins);
}
break;
}else{
if (preDayLateOutMins >= advancetime) {
//如果昨日的晚走时长已经完全大于了设置的晚走时长,那么就可以晚到整个postponetime
latein_localBeginDateTime = tmp_localBeginDateTime.plusMinutes(postponetime);
break;
}
}
}
}
}
if(early_localEndDateTime != null){
shifRuleMap.put("shift_type", "earlyinearlyout");
String endDate = early_localEndDateTime.format(dateFormatter);
String endmin = early_localEndDateTime.format(minFormatter);
if(endDate.compareTo(splitDate) > 0){
shifRuleMap.put("shift_endworktime", kqTimesArrayComInfo.turn24to48Time(endmin));
}else{
shifRuleMap.put("shift_endworktime", endmin);
}
}
if(late_localEndDateTime != null){
shifRuleMap.put("shift_type", "lateinlateout");
String endDate = late_localEndDateTime.format(dateFormatter);
String endmin = late_localEndDateTime.format(minFormatter);
if(endDate.compareTo(splitDate) > 0){
shifRuleMap.put("shift_endworktime", kqTimesArrayComInfo.turn24to48Time(endmin));
}else{
shifRuleMap.put("shift_endworktime", endmin);
}
}
if(early_localBeginDateTime != null){
shifRuleMap.put("shift_type", "earlyinearlyout");
String beginDate = early_localBeginDateTime.format(dateFormatter);
String beginmin = early_localBeginDateTime.format(minFormatter);
if(beginDate.compareTo(splitDate) > 0){
shifRuleMap.put("shift_beginworktime", kqTimesArrayComInfo.turn24to48Time(beginmin));
}else{
shifRuleMap.put("shift_beginworktime", beginmin);
}
}
if(late_localBeginDateTime != null){
shifRuleMap.put("shift_type", "lateinlateout");
String beginDate = late_localBeginDateTime.format(dateFormatter);
String beginmin = late_localBeginDateTime.format(minFormatter);
if(beginDate.compareTo(splitDate) > 0){
shifRuleMap.put("shift_beginworktime", kqTimesArrayComInfo.turn24to48Time(beginmin));
}else{
shifRuleMap.put("shift_beginworktime", beginmin);
}
}
if(latein_localBeginDateTime != null){
shifRuleMap.put("shift_type", "lateoutlatein");
String beginDate = latein_localBeginDateTime.format(dateFormatter);
String beginmin = latein_localBeginDateTime.format(minFormatter);
if(beginDate.compareTo(splitDate) > 0){
shifRuleMap.put("shift_beginworktime", kqTimesArrayComInfo.turn24to48Time(beginmin));
}else{
shifRuleMap.put("shift_beginworktime", beginmin);
}
}
return shifRuleMap;
}
}

@ -0,0 +1,402 @@
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.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{
isWorkDay = Util.getIntValue(Util.null2String(serialInfo.get(workdate)))>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);
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")));
}
}else{
int serialid = Util.getIntValue(Util.null2String(serialInfo.get(workdate)), 0);
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.setShiftRuleInfo(ShiftManagementToolKit.getShiftRuleInfo(""+serialid,true));
workTimeEntity.setSignTime(formatTimeScope((List<Object>)dateWorkTimeMap.get("signTime"),false));
workTimeEntity.setWorkTime(formatTimeScope((List<Object>)dateWorkTimeMap.get("workTime"),true));
workTimeEntity.setRestTime(formatTimeScope((List<Object>)dateWorkTimeMap.get("restTime"),false));
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,508 @@
package com.engine.kq.biz.chain.cominfo;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
*/
public class ShiftInfoCominfoBean implements Serializable {
private static final long serialVersionUID = -1735765502081116461L;
/**
*
*/
private List<String[]> preWorkTime;
/**
* 0-24
*/
private List<String[]> workTime;
/**
* 0-24
*/
private List<String[]> workAcrossTime;
/**
*
*/
private List<int[]> preWorkTimeIndex;
/**
* 0-24
*/
private List<int[]> workTimeIndex;
/**
* 0-48
*/
private List<int[]> workLongTimeIndex;
/**
* 0-48
*/
private List<int[]> restLongTimeIndex;
/**
* 48
*/
private List<String> allLongWorkTime;
/**
* 0-24
*/
private List<int[]> workAcrossTimeIndex;
/**
* 48
*/
private List<Map<String,String>> workAcrossLongTime;
/**
* 退
*/
private List<String[][]> workPunchMins;
/**
*
*/
private List<String[]> preRestTime;
/**
* 0-24
*/
private List<String[]> restTime;
/**
* r0-24
*/
private List<String[]> restAcrossTime;
/**
*
*/
private List<int[]> preRestTimeIndex;
/**
* 0-24
*/
private List<int[]> restTimeIndex;
/**
* r0-24
*/
private List<int[]> restAcrossTimeIndex;
/**
* 48
*/
private List<Map<String,String>> restAcrossLongTime;
/**
*
*
*/
private List<String> halfWorkTime;
/**
*
*
*/
private List<int[]> halfWorkIndex;
/**
*
*/
private List<String> allWorkTime;
/**
*
*/
private List<String> allAcrossWorkTime;
/**
*
*/
private List<String> allRestTime;
/**
*
*/
private List<String> allAcrossRestTime;
/**
*
*/
private List<Integer> eachWorkMins;
/**
*
*/
private int workmins;
/**
*
*/
private String serialid;
/**
*
*/
private String isAcross;
/**
*
*/
private String halfcalrule;
/**
*
*/
private String halfcalpoint;
private String halfcalpoint2cross;
private List<Object> timelineList;
/**
* 退
*/
private List<Map<String,String>> signWorkTime;
/**
* allWorkTime
*/
private List<String> allWorkTimeisAcross;
private String uuid = "";
public ShiftInfoCominfoBean() {
this.preWorkTime = new ArrayList<>();
this.workTime = new ArrayList<>();
this.workAcrossTime = new ArrayList<>();
this.preWorkTimeIndex = new ArrayList<>();
this.workTimeIndex = new ArrayList<>();
this.workAcrossTimeIndex = new ArrayList<>();
this.workAcrossLongTime = new ArrayList<>();
this.workPunchMins = new ArrayList<>();
this.preRestTime = new ArrayList<>();
this.restTime = new ArrayList<>();
this.restAcrossTime = new ArrayList<>();
this.preRestTimeIndex = new ArrayList<>();
this.restTimeIndex = new ArrayList<>();
this.restAcrossTimeIndex = new ArrayList<>();
this.restAcrossLongTime = new ArrayList<>();
this.halfWorkTime = new ArrayList<>();
this.allWorkTime = new ArrayList<>();
this.allAcrossWorkTime = new ArrayList<>();
this.allRestTime = new ArrayList<>();
this.allAcrossRestTime = new ArrayList<>();
this.eachWorkMins = new ArrayList<>();
this.workmins = 0;
this.serialid = "";
this.isAcross = "0";
this.halfcalrule = "0";
this.halfWorkIndex = new ArrayList<>();
this.timelineList = new ArrayList<>();
this.workLongTimeIndex = new ArrayList<>();
this.restLongTimeIndex = new ArrayList<>();
this.allLongWorkTime = new ArrayList<>();
this.signWorkTime = new ArrayList<>();
this.allWorkTimeisAcross = new ArrayList<>();
this.uuid = UUID.randomUUID().toString();
this.halfcalpoint = "0";
this.halfcalpoint2cross = "0";
}
public List<String[]> getPreWorkTime() {
return preWorkTime;
}
public void setPreWorkTime(List<String[]> preWorkTime) {
this.preWorkTime = preWorkTime;
}
public List<String[]> getWorkTime() {
return workTime;
}
public void setWorkTime(List<String[]> workTime) {
this.workTime = workTime;
}
public List<String[]> getWorkAcrossTime() {
return workAcrossTime;
}
public void setWorkAcrossTime(List<String[]> workAcrossTime) {
this.workAcrossTime = workAcrossTime;
}
public List<Map<String, String>> getWorkAcrossLongTime() {
return workAcrossLongTime;
}
public void setWorkAcrossLongTime(
List<Map<String, String>> workAcrossLongTime) {
this.workAcrossLongTime = workAcrossLongTime;
}
public List<String[][]> getWorkPunchMins() {
return workPunchMins;
}
public void setWorkPunchMins(List<String[][]> workPunchMins) {
this.workPunchMins = workPunchMins;
}
public List<String> getHalfWorkTime() {
return halfWorkTime;
}
public void setHalfWorkTime(List<String> halfWorkTime) {
this.halfWorkTime = halfWorkTime;
}
public int getWorkmins() {
return workmins;
}
public void setWorkmins(int workmins) {
this.workmins = workmins;
}
public String getSerialid() {
return serialid;
}
public void setSerialid(String serialid) {
this.serialid = serialid;
}
public List<String> getAllWorkTime() {
return allWorkTime;
}
public void setAllWorkTime(List<String> allWorkTime) {
this.allWorkTime = allWorkTime;
}
public List<String> getAllAcrossWorkTime() {
return allAcrossWorkTime;
}
public void setAllAcrossWorkTime(List<String> allAcrossWorkTime) {
this.allAcrossWorkTime = allAcrossWorkTime;
}
public List<String[]> getRestTime() {
return restTime;
}
public void setRestTime(List<String[]> restTime) {
this.restTime = restTime;
}
public String getIsAcross() {
return isAcross;
}
public void setIsAcross(String isAcross) {
this.isAcross = isAcross;
}
public List<String[]> getPreRestTime() {
return preRestTime;
}
public void setPreRestTime(List<String[]> preRestTime) {
this.preRestTime = preRestTime;
}
public List<String[]> getRestAcrossTime() {
return restAcrossTime;
}
public void setRestAcrossTime(List<String[]> restAcrossTime) {
this.restAcrossTime = restAcrossTime;
}
public List<Map<String, String>> getRestAcrossLongTime() {
return restAcrossLongTime;
}
public void setRestAcrossLongTime(
List<Map<String, String>> restAcrossLongTime) {
this.restAcrossLongTime = restAcrossLongTime;
}
public List<String> getAllRestTime() {
return allRestTime;
}
public void setAllRestTime(List<String> allRestTime) {
this.allRestTime = allRestTime;
}
public List<String> getAllAcrossRestTime() {
return allAcrossRestTime;
}
public void setAllAcrossRestTime(List<String> allAcrossRestTime) {
this.allAcrossRestTime = allAcrossRestTime;
}
public List<Integer> getEachWorkMins() {
return eachWorkMins;
}
public void setEachWorkMins(List<Integer> eachWorkMins) {
this.eachWorkMins = eachWorkMins;
}
public List<int[]> getPreWorkTimeIndex() {
return preWorkTimeIndex;
}
public void setPreWorkTimeIndex(List<int[]> preWorkTimeIndex) {
this.preWorkTimeIndex = preWorkTimeIndex;
}
public List<int[]> getWorkTimeIndex() {
return workTimeIndex;
}
public void setWorkTimeIndex(List<int[]> workTimeIndex) {
this.workTimeIndex = workTimeIndex;
}
public List<int[]> getWorkAcrossTimeIndex() {
return workAcrossTimeIndex;
}
public void setWorkAcrossTimeIndex(List<int[]> workAcrossTimeIndex) {
this.workAcrossTimeIndex = workAcrossTimeIndex;
}
public List<int[]> getPreRestTimeIndex() {
return preRestTimeIndex;
}
public void setPreRestTimeIndex(List<int[]> preRestTimeIndex) {
this.preRestTimeIndex = preRestTimeIndex;
}
public List<int[]> getRestTimeIndex() {
return restTimeIndex;
}
public void setRestTimeIndex(List<int[]> restTimeIndex) {
this.restTimeIndex = restTimeIndex;
}
public List<int[]> getRestAcrossTimeIndex() {
return restAcrossTimeIndex;
}
public void setRestAcrossTimeIndex(List<int[]> restAcrossTimeIndex) {
this.restAcrossTimeIndex = restAcrossTimeIndex;
}
public List<int[]> getHalfWorkIndex() {
return halfWorkIndex;
}
public void setHalfWorkIndex(List<int[]> halfWorkIndex) {
this.halfWorkIndex = halfWorkIndex;
}
public List<Object> getTimelineList() {
return timelineList;
}
public void setTimelineList(List<Object> timelineList) {
this.timelineList = timelineList;
}
public List<int[]> getWorkLongTimeIndex() {
return workLongTimeIndex;
}
public void setWorkLongTimeIndex(List<int[]> workLongTimeIndex) {
this.workLongTimeIndex = workLongTimeIndex;
}
public List<int[]> getRestLongTimeIndex() {
return restLongTimeIndex;
}
public void setRestLongTimeIndex(List<int[]> restLongTimeIndex) {
this.restLongTimeIndex = restLongTimeIndex;
}
public List<String> getAllLongWorkTime() {
return allLongWorkTime;
}
public void setAllLongWorkTime(List<String> allLongWorkTime) {
this.allLongWorkTime = allLongWorkTime;
}
public List<Map<String, String>> getSignWorkTime() {
return signWorkTime;
}
public void setSignWorkTime(
List<Map<String, String>> signWorkTime) {
this.signWorkTime = signWorkTime;
}
public List<String> getAllWorkTimeisAcross() {
return allWorkTimeisAcross;
}
public void setAllWorkTimeisAcross(List<String> allWorkTimeisAcross) {
this.allWorkTimeisAcross = allWorkTimeisAcross;
}
public String getHalfcalrule() {
return halfcalrule;
}
public void setHalfcalrule(String halfcalrule) {
this.halfcalrule = halfcalrule;
}
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public String getHalfcalpoint() {
return halfcalpoint;
}
public void setHalfcalpoint(String halfcalpoint) {
this.halfcalpoint = halfcalpoint;
}
public String getHalfcalpoint2cross() {
return halfcalpoint2cross;
}
public void setHalfcalpoint2cross(String halfcalpoint2cross) {
this.halfcalpoint2cross = halfcalpoint2cross;
}
}

@ -0,0 +1,35 @@
package com.engine.kq.biz.chain.cominfo;
import com.engine.kq.biz.KQTimesArrayComInfo;
import java.util.List;
import java.util.Map;
import weaver.general.Util;
/**
*
*/
public class WorkShiftComIndex extends ShiftComIndex {
public WorkShiftComIndex(String name,Map<String,Object> workTimeMap){
super(name,workTimeMap);
}
@Override
public void handleDuration(ShiftInfoCominfoBean shiftInfoCominfoBean) throws Exception {
handleWorkTime(shiftInfoCominfoBean);
this.success.handleDuration(shiftInfoCominfoBean);
}
private void handleWorkTime(ShiftInfoCominfoBean shiftInfoCominfoBean) throws Exception {
List<Object> workTimes = (List<Object>)workTimeMap.get("workTime");
int workmins = Util.getIntValue(Util.null2String(workTimeMap.get("workmins")));
shiftInfoCominfoBean.setWorkmins(workmins);
String serialid = Util.null2String(workTimeMap.get("serialid"));
shiftInfoCominfoBean.setSerialid(serialid);
setWorkDuration(workTimes, shiftInfoCominfoBean);
}
}

@ -0,0 +1,225 @@
package com.engine.kq.cmd.attendanceButton;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.kq.biz.KQCardLogBiz;
import com.engine.kq.biz.KQGroupComInfo;
import com.engine.kq.biz.KQGroupMemberComInfo;
import com.engine.kq.biz.KQSettingsBiz;
import com.engine.kq.biz.KQWorkTime;
import com.engine.kq.entity.KQGroupEntity;
import com.engine.kq.entity.WorkTimeEntity;
import com.engine.kq.log.KQLog;
import com.google.common.collect.Maps;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;
import com.engine.portal.biz.constants.ModuleConstants;
import com.engine.portal.biz.nonstandardfunction.SysModuleInfoBiz;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.hrm.resource.ResourceComInfo;
import weaver.systeminfo.SystemEnv;
/**
*
*/
public class GetButtonBaseInfoCmd extends AbstractCommonCommand<Map<String, Object>> {
public KQLog kqLog = new KQLog();
private DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
private DateTimeFormatter datetimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
private DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm");
private DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
private DateTimeFormatter fullTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
private Map<String,Object> logMap = Maps.newHashMap();
private Map<String,Object> workTimeEntityLogMap = Maps.newHashMap();
public GetButtonBaseInfoCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
kqLog.info(user.getLastname()+":GetButtonBaseInfoCmd:params:"+params);
logMap.put("lastname", user.getLastname());
logMap.put("params", params);
Map<String, Object> retmap = new HashMap<String, Object>();
RecordSet rs = new RecordSet();
String sql = "";
try{
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo();
KQGroupComInfo kqGroupComInfo = new KQGroupComInfo();
ResourceComInfo resourceComInfo = new ResourceComInfo();
String ismobile = Util.null2String(params.get("ismobile"));
String lastname = user.getLastname();
String messagerurl = resourceComInfo.getMessagerUrls(""+user.getUID());
String shortname = "";
boolean USERICONLASTNAME = Util.null2String(new BaseBean().getPropValue("Others" , "USERICONLASTNAME")).equals("1");
if(USERICONLASTNAME&&(messagerurl.indexOf("icon_w_wev8.jpg")>-1||messagerurl.indexOf("icon_m_wev8.jpg")>-1||messagerurl.indexOf("dummyContact.png")>-1)){
shortname = User.getLastname(Util.null2String(Util.formatMultiLang(lastname, ""+user.getLanguage())));
}
String curDate = DateUtil.getCurrentDate();
LocalDateTime now = LocalDateTime.now();
String now_date = now.format(dateFormatter);
String now_time = now.format(fullTimeFormatter);
GetButtonsCmd getButtonsCmd = new GetButtonsCmd(params, user);
LocalDateTime now_zone = getButtonsCmd.getZoneOfClientDateTime(now_date,now_time,logMap);
if(now_zone != null){
curDate = now_zone.format(dateFormatter);
}
KQWorkTime kqWorkTime = new KQWorkTime();
WorkTimeEntity workTimeEntity = kqWorkTime.getWorkTime(user.getUID()+"", curDate);
String userinfo = "#userid#"+user.getUID()+"#getUserSubCompany1#"+user.getUserSubCompany1()+"#getUserSubCompany1#"+user.getUserDepartment()
+"#getJobtitle#"+user.getJobtitle();
workTimeEntityLogMap.put("resourceid", userinfo);
workTimeEntityLogMap.put("splitDate", curDate);
workTimeEntityLogMap.put("workTimeEntity", workTimeEntity);
String groupid = workTimeEntity.getGroupId();
logMap.put("groupid", groupid);
String groupname = "";
String locationshowaddress = Util.null2String(kqGroupComInfo.getLocationshowaddress(groupid));//是否记录统一地址
String locationfacecheck = Util.null2String(kqGroupComInfo.getLocationfacecheck(groupid));//办公地点启用人脸识别拍照打卡
String locationfacechecktype = Util.null2String(kqGroupComInfo.getLocationfacechecktype(groupid));//办公地点启用人脸识别拍照打卡方式
String wififacecheck = Util.null2String(kqGroupComInfo.getWififacecheck(groupid));//wifi启用人脸识别拍照打卡
String wififacechecktype = Util.null2String(kqGroupComInfo.getWififacechecktype(groupid));//wifi启用人脸识别拍照打卡方式
logMap.put("locationshowaddress", locationshowaddress);
logMap.put("locationfacecheck", locationfacecheck);
logMap.put("locationfacechecktype", locationfacechecktype);
logMap.put("wififacecheck", wififacecheck);
logMap.put("wififacechecktype", wififacechecktype);
boolean isAdmin = user.isAdmin();
logMap.put("isAdmin", isAdmin);
if(isAdmin){
retmap.put("showbutton", "0");
retmap.put("status", "1");
retmap.put("userid", user.getUID());
KQCardLogBiz.logCardInfo(user.getUID()+"", logMap, workTimeEntityLogMap, "buttonBaseInfo");
return retmap;
}
// * 1、PC和移动端均可打卡
// * 2、仅PC可打卡
// * 3、仅移动端可打卡
// * 4、无需打卡
String groupSignType = getSignType();
logMap.put("groupSignType", groupSignType);
//无需打卡
if("4".equalsIgnoreCase(groupSignType)){
retmap.put("showbutton", "0");
retmap.put("status", "1");
retmap.put("userid", user.getUID());
KQCardLogBiz.logCardInfo(user.getUID()+"", logMap, workTimeEntityLogMap, "buttonBaseInfo");
return retmap;
}
if("2".equalsIgnoreCase(groupSignType)){
if("1".equalsIgnoreCase(ismobile)){
retmap.put("showbutton", "0");
retmap.put("status", "1");
retmap.put("userid", user.getUID());
KQCardLogBiz.logCardInfo(user.getUID()+"", logMap, workTimeEntityLogMap, "buttonBaseInfo");
return retmap;
}
}
if("3".equalsIgnoreCase(groupSignType)){
if(!"1".equalsIgnoreCase(ismobile)){
retmap.put("showbutton", "0");
retmap.put("status", "1");
retmap.put("userid", user.getUID());
KQCardLogBiz.logCardInfo(user.getUID()+"", logMap, workTimeEntityLogMap, "buttonBaseInfo");
return retmap;
}
}
if(groupid.length() > 0){
groupname = SystemEnv.getHtmlLabelName(10000801,weaver.general.Util.getIntValue(user.getLanguage()))+kqGroupComInfo.getGroupname(groupid);
}else{
groupname = SystemEnv.getHtmlLabelName(10000799,weaver.general.Util.getIntValue(user.getLanguage()));
retmap.put("showbutton", "0");
}
retmap.put("hasCrmModule", SysModuleInfoBiz.checkModuleStatus(ModuleConstants.Crm));
retmap.put("userid", user.getUID());
retmap.put("lastname", lastname);
retmap.put("shortname", shortname);
retmap.put("messagerurl", messagerurl);
retmap.put("groupname", groupname);
retmap.put("locationshowaddress", locationshowaddress);
retmap.put("locationfacecheck", locationfacecheck);
retmap.put("locationfacechecktype", locationfacechecktype);
retmap.put("wififacecheck", wififacecheck);
retmap.put("wififacechecktype", wififacechecktype);
retmap.put("date", curDate);
retmap.put("timemillis", System.currentTimeMillis());
retmap.put("wificheck",Util.null2String(kqGroupComInfo.getWificheck(groupid)).equals("1"));
retmap.put("locationcheck",Util.null2String(kqGroupComInfo.getLocationcheck(groupid)).equals("1"));
retmap.put("locationcheckscope",Util.null2String(kqGroupComInfo.getLocationcheckscope(groupid)));
String user_last_map = get_user_last_map(user.getUID()+"");
logMap.put("user_last_map", user_last_map);
if(user_last_map.length() > 0){
retmap.put("user_last_map", user_last_map);
}
retmap.put("isFirstLocation", KQSettingsBiz.isFirstLocation()?"1":"0");
retmap.put("status", "1");
}catch (Exception e) {
retmap.put("status", "-1");
retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage()));
writeLog(e);
}
kqLog.info(user.getLastname()+":GetButtonBaseInfoCmd:retmap:"+retmap);
logMap.put("result", retmap);
KQCardLogBiz.logCardInfo(user.getUID()+"", logMap, workTimeEntityLogMap, "buttonBaseInfo");
return retmap;
}
/**
*
* @param userid
*/
public static String get_user_last_map(String userid) {
RecordSet rs = new RecordSet();
String sql = "select * from user_last_map where userid = ? ";
rs.executeQuery(sql, userid);
if(rs.next()){
return rs.getString("last_map");
}
return "";
}
/**
*
* 1PC
* 2PC
* 3
*/
private String getSignType() {
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo();
KQGroupEntity kqGroupEntity = kqGroupMemberComInfo.getUserKQGroupInfo(user.getUID()+"");
if(kqGroupEntity == null){
return "";
}
return kqGroupEntity.getSignintype();
}
@Override
public BizLogContext getLogContext() {
return null;
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,608 @@
package com.engine.kq.cmd.attendanceButton;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.cloudstore.dev.api.util.EMManager;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.kq.biz.KQCardLogBiz;
import com.engine.kq.biz.KQFormatBiz;
import com.engine.kq.biz.KQGroupBiz;
import com.engine.kq.biz.KQGroupMemberComInfo;
import com.engine.kq.biz.KQLoactionComInfo;
import com.engine.kq.biz.KQShiftRuleInfoBiz;
import com.engine.kq.biz.KQTimesArrayComInfo;
import com.engine.kq.biz.KQWorkTime;
import com.engine.kq.biz.chain.shiftinfo.ShiftInfoBean;
import com.engine.kq.entity.KQGroupEntity;
import com.engine.kq.entity.WorkTimeEntity;
import com.engine.kq.log.KQLog;
import com.engine.kq.timer.KQQueue;
import com.engine.kq.timer.KQTaskBean;
import com.engine.kq.util.KQDurationCalculatorUtil;
import com.engine.kq.wfset.util.SplitActionUtil;
import com.google.common.collect.Maps;
import java.time.Duration;
import java.time.LocalDate;
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 java.util.Map.Entry;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.dateformat.DateTransformer;
import weaver.dateformat.TimeZoneVar;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.systeminfo.SystemEnv;
/**
* 退
*/
public class PunchButtonCmd extends AbstractCommonCommand<Map<String, Object>> {
public KQLog kqLog = new KQLog();
private HttpServletRequest request;
private Map<String,Object> logMap = Maps.newHashMap();
private Map<String,Object> workTimeEntityLogMap = Maps.newHashMap();
public PunchButtonCmd(HttpServletRequest request,Map<String, Object> params, User user) {
this.request = request;
this.user = user;
this.params = params;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> retmap = new HashMap<String, Object>();
try{
insertSign(retmap);
}catch (Exception e) {
retmap.put("status", "-1");
retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage()));
writeLog(e);
}
kqLog.info(user.getLastname()+":PunchButtonCmd:retmap:"+retmap);
KQCardLogBiz.logCardInfo(user.getUID()+"", logMap, workTimeEntityLogMap, "punchButton");
return retmap;
}
/**
* ip
* @param ismobile
*/
private boolean checkIsInIp(String ismobile) {
// if("1".equalsIgnoreCase(ismobile)){
// return true;
// }
KQGroupBiz kqGroupBiz = new KQGroupBiz();
String clientAddress = Util.getIpAddr(request);
kqLog.info("PunchButtonCmd:clientAddress:"+clientAddress);
return kqGroupBiz.getIsInScopeV4V6(user.getUID()+"", clientAddress,ismobile);
}
public void insertSign(Map<String, Object> retmap) throws Exception{
logMap.put("lastname", user.getLastname());
logMap.put("params", params);
kqLog.info(user.getLastname()+":PunchButtonCmd:params:"+params);
RecordSet rs = new RecordSet();
String deviceInfo = Util.null2String(params.get("deviceInfo"));
JSONObject jsonObject = null;
if(deviceInfo.length() > 0){
jsonObject = JSON.parseObject(deviceInfo);
JSONObject jsonObject1 = new JSONObject();
Set<Entry<String, Object>> jsonSet = jsonObject.entrySet();
for(Entry<String, Object> js : jsonSet){
String key = js.getKey();
String value = Util.null2String(js.getValue());
jsonObject1.put(key, value);
}
if(!jsonObject1.isEmpty()){
deviceInfo = jsonObject1.toJSONString();
}
}
//应上班 工作时间点
String time = Util.null2String(params.get("time"));
//应上班 工作时间 带日期
String datetime = Util.null2String(params.get("datetime"));
//允许打卡时段 带日期
String signSectionTime = Util.null2String(params.get("signSectionTime"));
//上传照片
String attachment = Util.null2String(params.get("fileids"));
//打卡所属worksection的对应的点
String type = Util.null2String(params.get("type"));
//所属打卡日期
String belongdate = Util.null2String(params.get("belongdate"));
belongdate = belongdate.length() == 0 ? DateUtil.getCurrentDate() : belongdate;
String islastsign = Util.null2String(params.get("islastsign"));
String isfirstsign = Util.null2String(params.get("isfirstsign"));
String workmins = Util.null2String(params.get("workmins"));
//针对非工作时段 签退的时候记录的签到数据 用于计算加班
String signInTime4Out = Util.null2String(params.get("signInTime4Out"));
//允许打卡的范围
String signsection = Util.null2String(params.get("signSection"));
//手机打卡部分
String longitude = Util.null2String(params.get("longitude"));
String latitude = Util.null2String(params.get("latitude"));
double d_longitude = Util.getDoubleValue(longitude);
double d_latitude = Util.getDoubleValue(latitude);
if(d_latitude <= 0){
latitude = "";
}
if(d_longitude <= 0){
longitude = "";
}
//wifi用的
String mac = Util.null2String(params.get("mac"));
String sid = Util.null2String(params.get("sid"));
String addr = Util.null2String(params.get("position"));
String ismobile = Util.null2String(params.get("ismobile"));
//区分是来自于钉钉还是EM7
String browser = Util.null2String(params.get("browser"));
//自由班制处理
String isfree = Util.null2String(Util.null2String(params.get("isfree")),"0");
//上班打卡 允许最晚打卡时间
String signSectionEndTime = Util.null2String(params.get("signSectionEndTime"));
//下班打卡 允许最早打卡时间
String signSectionBeginTime = Util.null2String(params.get("signSectionBeginTime"));
String locationshowaddress = Util.null2String(params.get("locationshowaddress"));
if(locationshowaddress.equals("1")){//记录统一地址
String locationid = Util.null2String(params.get("locationid"));//办公地点id
if(locationid.length()>0){//如果开启统一显示,就用配置的地址
KQLoactionComInfo kqLoactionComInfo = new KQLoactionComInfo();
addr = kqLoactionComInfo.getLocationname(locationid);
}
}
DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
LocalTime localTime = LocalTime.now();
String signTime =localTime.format(dateTimeFormatter);
String signDate = LocalDate.now().format(dateFormatter);
String timeZone = Util.null2String(TimeZoneVar.getTimeZone(),"");
//处理多时区
String timeZoneConversion = Util.null2String(new weaver.general.BaseBean().getPropValue("weaver_timezone_conversion","timeZoneConversion")).trim();
logMap.put("timeZoneConversion", timeZoneConversion);
if("1".equals(timeZoneConversion)) {
DateTransformer dateTransformer=new DateTransformer();
String[] zone_localTime = dateTransformer.getLocaleDateAndTime(signDate,signTime);
kqLog.info(user.getLastname()+":TimeZoneVar.getTimeZone():"+TimeZoneVar.getTimeZone()+":zone_localTime:"+JSON.toJSONString(zone_localTime));
if(zone_localTime != null && zone_localTime.length == 2){
signDate = zone_localTime[0];
signTime = zone_localTime[1];
}
}
int userId = user.getUID();
String userType = user.getLogintype();
String signType = "on".equalsIgnoreCase(type) ? "1" : "2";
String clientAddress = Util.getIpAddr(request);
boolean isInIp = checkIsInIp(ismobile);
logMap.put("clientAddress", clientAddress);
if(!isInIp){
retmap.put("message", SystemEnv.getHtmlLabelName(20157,user.getLanguage()));
retmap.put("isInIp", "0");
}
String isInCom = isInIp ? "1" : "0";
//是否是考勤例外人员
boolean isExclude = false;
KQGroupMemberComInfo kqGroupMemberComInfo = new KQGroupMemberComInfo();
KQWorkTime kqWorkTime = new KQWorkTime();
WorkTimeEntity workTimeEntity = kqWorkTime.getWorkTime(user.getUID()+"", signDate);
String userinfo = "#userid#"+user.getUID()+"#getUserSubCompany1#"+user.getUserSubCompany1()+"#getUserSubCompany1#"+user.getUserDepartment()
+"#getJobtitle#"+user.getJobtitle();
workTimeEntityLogMap.put("resourceid", userinfo);
workTimeEntityLogMap.put("splitDate", signDate);
workTimeEntityLogMap.put("workTimeEntity", workTimeEntity);
String groupid = workTimeEntity.getGroupId();
logMap.put("groupid", groupid);
KQGroupEntity kqGroupEntity = kqGroupMemberComInfo.getUserKQGroupInfo(user.getUID()+"");
String kqGroupEntityInfo = kqGroupEntity != null ? JSON.toJSONString(kqGroupEntity): "";
logMap.put("kqGroupEntityInfo", kqGroupEntityInfo);
if (kqGroupEntity != null && ("," + kqGroupEntity.getExcludeid() + ",").indexOf("," + user.getUID() + ",")>-1) {//排除人员无需计算考勤时间
isExclude = true;
}
String[] signsections = signsection.split("#");
if(!"1".equalsIgnoreCase(isfree)){
if(signsections != null && signsections.length == 2){
//判断是未签到直接签退
String signedMsg = signedMsg(userId+"", signType, user,signsections,signSectionBeginTime,signSectionEndTime);
if(signedMsg.length() > 0){
retmap.put("status", "1");
retmap.put("message", signedMsg);
isInCom = "0";
}
}
}
String datetime_timezone = signDate+" "+signTime;
LocalDateTime nowDateTime = LocalDateTime.parse(datetime_timezone,fullFormatter);
kqLog.info("timeZone:"+timeZone+":signDate:"+signDate+":signTime:"+signTime+":nowDateTime:"+nowDateTime);
if("1".equalsIgnoreCase(signType) && signSectionTime.length() > 0 ){
LocalDateTime startWorkDateTime = LocalDateTime.parse(signSectionTime,fullFormatter);
if(nowDateTime.isBefore(startWorkDateTime)){
Duration duration = Duration.between(nowDateTime, startWorkDateTime);
retmap.put("status", "1");
retmap.put("message", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005326,weaver.general.ThreadVarLanguage.getLang())+""+duration.toMinutes()+""+weaver.systeminfo.SystemEnv.getHtmlLabelName(15049,weaver.general.ThreadVarLanguage.getLang())+"");
isInCom = "0";
}
}else if("2".equalsIgnoreCase(signType) && signSectionTime.length() > 0 ){
LocalDateTime endWorkDateTime = LocalDateTime.parse(signSectionTime,fullFormatter);
if(nowDateTime.isAfter(endWorkDateTime)){
Duration duration = Duration.between(endWorkDateTime, nowDateTime);
retmap.put("status", "1");
retmap.put("message", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10005327,weaver.general.ThreadVarLanguage.getLang())+""+duration.toMinutes()+""+weaver.systeminfo.SystemEnv.getHtmlLabelName(15049,weaver.general.ThreadVarLanguage.getLang())+"");
isInCom = "0";
}
}
//记录下是来自于E9的pc端签到
String signfrom = "e9pc";
if("1".equalsIgnoreCase(ismobile)){
signfrom = "e9mobile";
boolean needLocationRange = false;
boolean needWifiRange = false;
boolean isLocationRange = false;
boolean isWifiRange = false;
KQGroupBiz kqGroupBiz = new KQGroupBiz();
Map<String,Object> locationMap = kqGroupBiz.checkLocationScope(userId+"",longitude,latitude);
logMap.put("locationMap", locationMap);
String locationNeedCheck = Util.null2String(locationMap.get("needCheck"));
boolean locationInScope = Boolean.parseBoolean(Util.null2String(locationMap.get("inScope")));
if("1".equalsIgnoreCase(locationNeedCheck)){
needLocationRange = true;
if(locationInScope){
isLocationRange = true;
}
}
String wifiNeedCheck = "";
Map<String,Object> wifiMap = kqGroupBiz.checkWifiScope(userId+"", sid, mac);
logMap.put("wifiMap", wifiMap);
wifiNeedCheck = Util.null2String(wifiMap.get("needCheck"));
boolean wifiInScope = Boolean.parseBoolean(Util.null2String(wifiMap.get("inScope")));
if("1".equalsIgnoreCase(wifiNeedCheck)){
needWifiRange = true;
if(wifiInScope){
isWifiRange = true;
}
}
if(needLocationRange){
if(isLocationRange){
}else{
if(needWifiRange){
if(isWifiRange){
}else{
//地理位置开启而且不在范围内且开启wifi验证,不在范围内
retmap.put("message", SystemEnv.getHtmlLabelName(507524, user.getLanguage()));
isInCom = "0";
}
}else {
//地理位置开启而且不在范围内且未开启wifi验证
retmap.put("message", SystemEnv.getHtmlLabelName(500510, user.getLanguage()));
isInCom = "0";
}
}
}else{
if(needWifiRange) {
if (isWifiRange) {
} else {
//地理位置未开启且开启wifi验证,不在范围内
retmap.put("message", SystemEnv.getHtmlLabelName(507524, user.getLanguage()));
isInCom = "0";
}
}
}
if("DingTalk".equalsIgnoreCase(browser)){
signfrom = "DingTalk";
}else if("Wechat".equalsIgnoreCase(browser)){
signfrom = "Wechat";
String weChat_deviceid = Util.null2String(request.getSession().getAttribute(EMManager.DeviceId));
logMap.put("weChat_deviceid", weChat_deviceid);
kqLog.info("EMManager.DeviceId:"+EMManager.DeviceId+":weChat_deviceid:"+weChat_deviceid);
if(weChat_deviceid.length() > 0){
//微信打卡的设备号需要单独处理
if(jsonObject != null){
jsonObject.put("deviceId", weChat_deviceid);
}else{
jsonObject = new JSONObject();
jsonObject.put("deviceId", weChat_deviceid);
}
if(!jsonObject.isEmpty()){
deviceInfo = jsonObject.toJSONString();
}
}
}
}
String signStatus = "";
if(!"1".equalsIgnoreCase(isfree) && datetime.length() > 0){
signStatus = getSignStatus(signType,datetime,user.getUID()+"",belongdate,nowDateTime);
logMap.put("signStatus", signStatus);
}
if(isExclude){
signStatus = ButtonStatusEnum.NORMAL.getStatusCode();
}
String punchSql = "insert into HrmScheduleSign(userId,userType,signType,signDate,signTime,clientAddress,isInCom,timeZone,belongdate,signfrom,longitude,latitude,addr,deviceInfo) "+
" values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
boolean isOk = rs.executeUpdate(punchSql,userId,userType,signType,signDate,signTime,clientAddress,isInCom,
timeZone,belongdate,signfrom,longitude,latitude,addr,deviceInfo);
if(!isOk){
retmap.put("status", "1");
retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage()));
return ;
}
logMap.put("punchSql", punchSql);
logMap.put("punchSql_isOk", isOk);
kqLog.info(user.getLastname()+":PunchButtonCmd:punchSql:"+punchSql+":isOk:"+isOk);
//打卡提醒处理
String remindSql = "insert into hrmschedulesign_remind(userId,signType,signDate,signTime,belongdate) values(?,?,?,?,?)";
isOk = rs.executeUpdate(remindSql, userId,signType,signDate,signTime,belongdate);
kqLog.info(user.getLastname()+":PunchButtonCmd:remindSql:"+remindSql+":isOk:"+isOk);
//同步更新考勤数据到考勤报表
new KQFormatBiz().formatDate(""+userId,(belongdate.length() == 0 ? DateUtil.getCurrentDate() : belongdate));
//点击签退的时候,可能存在加班数据生成的情况
if("2".equalsIgnoreCase(signType)){
if("1".equalsIgnoreCase(islastsign)){
List<KQTaskBean> tasks = new ArrayList<>();
List<KQTaskBean> after_tasks = new ArrayList<>();
SplitActionUtil.pushOverTimeTasks(belongdate, belongdate, ""+userId,tasks);
if(!tasks.isEmpty()){
for(KQTaskBean kqTaskBean : tasks){
after_tasks.add(kqTaskBean);
}
}
logMap.put("after_tasks", after_tasks);
if(!after_tasks.isEmpty()){
KQQueue.writeTasks(after_tasks);
}
}
}
if("1".equalsIgnoreCase(signType)){
if("1".equalsIgnoreCase(isfirstsign)){
List<KQTaskBean> tasks = new ArrayList<>();
List<KQTaskBean> before_tasks = new ArrayList<>();
SplitActionUtil.pushOverTimeTasks(belongdate, belongdate, ""+userId,tasks);
if(!tasks.isEmpty()){
for(KQTaskBean kqTaskBean : tasks){
kqTaskBean.setTasktype("punchcard");
before_tasks.add(kqTaskBean);
}
}
logMap.put("before_tasks", before_tasks);
if(!before_tasks.isEmpty()){
KQQueue.writeTasks(before_tasks);
}
}
}
String reSignStatus = reSignStatus(user.getUID()+"",signType,nowDateTime,belongdate);
if(Util.null2String(reSignStatus,"").length() > 0){
signStatus = reSignStatus;
}
retmap.put("status", "1");
retmap.put("signdate", signDate);
retmap.put("signtime", signTime);
retmap.put("kqstatus", signStatus);
if(!"1".equalsIgnoreCase(signStatus) && !"2".equalsIgnoreCase(signStatus)){
if("".equalsIgnoreCase(Util.null2String(retmap.get("message")))){
retmap.put("success", "1");
retmap.put("message", SystemEnv.getHtmlLabelName(512596,weaver.general.Util.getIntValue(user.getLanguage())));
}
}
logMap.put("retmap", retmap);
}
public String reSignStatus(String userid, String signType, LocalDateTime nowDateTime,
String workdate) {
String signStatus = "";
String shift_begindateworktime = "";
String shift_enddateworktime = "";
ShiftInfoBean shiftInfoBean = KQDurationCalculatorUtil.getWorkTime(userid, workdate,false);
if(shiftInfoBean == null){
return signStatus;
}
Map<String,String> shifRuleMap = Maps.newHashMap();
KQShiftRuleInfoBiz.getShiftRuleInfo(shiftInfoBean,userid,shifRuleMap);
KQTimesArrayComInfo arrayComInfo = new KQTimesArrayComInfo();
if(!shifRuleMap.isEmpty()) {
DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String datetime = "";
if (shifRuleMap.containsKey("shift_beginworktime")) {
String shift_beginworktime = Util.null2String(shifRuleMap.get("shift_beginworktime"));
if (shift_beginworktime.length() > 0) {
int shift_beginworktime_index = -1;
shift_beginworktime_index = arrayComInfo.getArrayindexByTimes(shift_beginworktime);
datetime = workdate+" "+shift_beginworktime+":00";
if(shift_beginworktime_index >= 1440){
//跨天了
datetime = DateUtil.addDate(workdate, 1)+" "+arrayComInfo.turn48to24Time(shift_beginworktime)+":00";
}
}
}
if (shifRuleMap.containsKey("shift_endworktime")) {
String shift_endworktime = Util.null2String(shifRuleMap.get("shift_endworktime"));
if (shift_endworktime.length() > 0) {
int shift_endworktime_index = -1;
shift_endworktime_index = arrayComInfo.getArrayindexByTimes(shift_endworktime);
datetime = workdate+" "+shift_endworktime+":00";
if(shift_endworktime_index >= 1440) {
//跨天了
datetime = DateUtil.addDate(workdate, 1)+" "+arrayComInfo.turn48to24Time(shift_endworktime)+":00";
}
}
}
if (datetime.length() > 0) {
if("1".equalsIgnoreCase(signType)) {
LocalDateTime startWorkDateTime = LocalDateTime.parse(datetime, fullFormatter);
//打卡时间比上班时间晚,迟到了
if (nowDateTime.isAfter(startWorkDateTime)) {
signStatus = ButtonStatusEnum.BELATE.getStatusCode();
} else {
signStatus = ButtonStatusEnum.NORMAL.getStatusCode();
}
} else if ("2".equalsIgnoreCase(signType)) {
LocalDateTime endWorkDateTime = LocalDateTime.parse(datetime, fullFormatter);
//签退的话
if (nowDateTime.isBefore(endWorkDateTime)) {
signStatus = ButtonStatusEnum.LEAVEERALY.getStatusCode();
} else {
signStatus = ButtonStatusEnum.NORMAL.getStatusCode();
}
} else {
writeLog(user.getLastname() + nowDateTime + ":竟然没有传:" + signType);
return "";
}
}
}
return signStatus;
}
/**
*
* @param resourceid
* @param pre_splitDate
* @param signtime
* @param pre_bengintime
* @param signdate
*/
public void doBeforeAcrossOvertime(String resourceid,String pre_splitDate,String signtime,String pre_bengintime,String signdate) {
KQTaskBean kqTaskBean = new KQTaskBean();
kqTaskBean.setResourceId(resourceid);
kqTaskBean.setTaskDate(pre_splitDate);
kqTaskBean.setLastWorkTime(signtime);
if(pre_bengintime.length() == 5){
kqTaskBean.setTaskSignTime(pre_bengintime+":00");
}else{
kqTaskBean.setTaskSignTime(pre_bengintime);
}
kqTaskBean.setSignDate(signdate);
kqTaskBean.setSignEndDate(signdate);
kqTaskBean.setTimesource("before");
KQQueue.writeTask(kqTaskBean);
}
/**
*
* @param userid
* @param signtype
* @param curUser
* @param signsections
* @param signSectionBeginTime
* @param signSectionEndTime
* @return
*/
public String signedMsg(String userid, String signtype, User curUser, String[] signsections,
String signSectionBeginTime, String signSectionEndTime) throws Exception{
String signedMsg = "";
RecordSet rs = new RecordSet();
boolean hasSigned = false;
String onSignSectionTime = signsections[0];
String offSignSectionTime = signsections[1];
if(onSignSectionTime.length() > 0 && offSignSectionTime.length() > 0){
String hasSign = "select 1 from hrmschedulesign where 1 = 1 and isInCom = '1' and userid = ? ";
StringBuffer sql = new StringBuffer();
if(rs.getDBType().equals("oracle")||rs.getDBType().equals("postgresql")){
sql.append(" AND signDate||' '||signTime>=? ");
sql.append(" AND signDate||' '||signTime<=? ");
}else if(rs.getDBType().equals("mysql")){
sql.append(" AND concat(signDate,' ',signTime)>=? ");
sql.append(" AND concat(signDate,' ',signTime)<=? ");
}else{
sql.append(" AND signDate+' '+signTime>=? ");
sql.append(" AND signDate+' '+signTime<=? ");
}
hasSign += sql.toString();
rs.executeQuery(hasSign, userid,onSignSectionTime,offSignSectionTime);
if(rs.next()){
hasSigned = true;
}
if("1".equalsIgnoreCase(signtype)){
if(signSectionBeginTime.length() > 0 || signSectionEndTime.length() > 0){
}else{
if(hasSigned){
signedMsg = SystemEnv.getHtmlLabelName(129706, curUser.getLanguage());
}
}
}else if("2".equalsIgnoreCase(signtype)){
if(signSectionBeginTime.length() > 0 || signSectionEndTime.length() > 0){
}else{
if(!hasSigned){
signedMsg = SystemEnv.getHtmlLabelName(501301, curUser.getLanguage());
}
}
}
}
return signedMsg;
}
/**
* 退
* 退
* @return
*/
public String getSignStatus(String signType, String datetime, String userid, String workdate,
LocalDateTime nowDateTime) {
DateTimeFormatter fullFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String signStatus = "";
//签到的话
if("1".equalsIgnoreCase(signType)){
LocalDateTime startWorkDateTime = LocalDateTime.parse(datetime,fullFormatter);
//打卡时间比上班时间晚,迟到了
if(nowDateTime.isAfter(startWorkDateTime)){
signStatus = ButtonStatusEnum.BELATE.getStatusCode();
}else{
signStatus = ButtonStatusEnum.NORMAL.getStatusCode();
}
}else if("2".equalsIgnoreCase(signType)){
LocalDateTime endWorkDateTime = LocalDateTime.parse(datetime,fullFormatter);
//签退的话
if(nowDateTime.isBefore(endWorkDateTime)){
signStatus = ButtonStatusEnum.LEAVEERALY.getStatusCode();
}else{
signStatus = ButtonStatusEnum.NORMAL.getStatusCode();
}
}else{
writeLog(user.getLastname()+nowDateTime+":竟然没有传:"+signType);
return "";
}
return signStatus;
}
@Override
public BizLogContext getLogContext() {
return null;
}
}

@ -0,0 +1,342 @@
package com.engine.kq.cmd.leaverules;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.biz.SimpleBizLogger;
import com.engine.common.constant.BizLogSmallType4Hrm;
import com.engine.common.constant.BizLogType;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.kq.biz.KQBalanceOfLeaveBiz;
import com.engine.kq.biz.KQLeaveRulesComInfo;
import com.engine.kq.biz.KQLeaveRulesDetailComInfo;
import com.engine.kq.util.KQTransMethod;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import weaver.hrm.company.SubCompanyComInfo;
import weaver.systeminfo.SystemEnv;
import java.util.*;
/**
* --
*/
public class AddLeaveRulesCmd extends AbstractCommonCommand<Map<String, Object>> {
private SimpleBizLogger logger;
public AddLeaveRulesCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
this.logger = new SimpleBizLogger();
String ruleId = Util.null2String(params.get("typeId"));
String ruleName = Util.null2String(params.get("ruleName"));
BizLogContext bizLogContext = new BizLogContext();
bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型
bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_LEAVERULES);//所属大类型
bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_LEAVERULES);//当前小类型
bizLogContext.setParams(params);//当前request请求参数
logger.setUser(user);//当前操作人
String mainSql = "select * from kq_LeaveRulesDetail where ruleId=" + ruleId + " and ruleName like '%" + ruleName + "%'";
logger.setMainSql(mainSql, "id");//主表sql
logger.setMainPrimarykey("id");//主日志表唯一key
logger.setMainTargetNameColumn("rulename");
SimpleBizLogger.SubLogInfo subLogInfo1 = logger.getNewSubLogInfo();
String subSql1 = "select * from kq_EntryToLeave where leaveRulesId in (select id from kq_LeaveRulesDetail where ruleId=" + ruleId + " and ruleName like '%" + ruleName + "%')";
subLogInfo1.setSubSql(subSql1, "id");
logger.addSubLogInfo(subLogInfo1);
SimpleBizLogger.SubLogInfo subLogInfo2 = logger.getNewSubLogInfo();
String subSql2 = "select * from kq_WorkingAgeToLeave where leaveRulesId in (select id from kq_LeaveRulesDetail where ruleId=" + ruleId + " and ruleName like '%" + ruleName + "%')";
subLogInfo2.setSubSql(subSql2, "id");
logger.addSubLogInfo(subLogInfo2);
SimpleBizLogger.SubLogInfo subLogInfo3 = logger.getNewSubLogInfo();
String subSql3 = "select * from kq_MixModeToLegalLeave where leaveRulesId in (select id from kq_LeaveRulesDetail where ruleId=" + ruleId + " and ruleName like '%" + ruleName + "%')";
subLogInfo3.setSubSql(subSql3, "id");
logger.addSubLogInfo(subLogInfo3);
SimpleBizLogger.SubLogInfo subLogInfo4 = logger.getNewSubLogInfo();
String subSql4 = "select * from kq_MixModeToWelfareLeave where leaveRulesId in (select id from kq_LeaveRulesDetail where ruleId=" + ruleId + " and ruleName like '%" + ruleName + "%')";
subLogInfo4.setSubSql(subSql4, "id");
logger.addSubLogInfo(subLogInfo4);
logger.before(bizLogContext);
}
@Override
public BizLogContext getLogContext() {
return null;
}
@Override
public List<BizLogContext> getLogContexts() {
return logger.getBizLogContexts();
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> resultMap = new HashMap<String, Object>();
try {
boolean canAdd = HrmUserVarify.checkUserRight("KQLeaveRulesAdd:Add", user);//是否具有新建权限
if (!canAdd) {
resultMap.put("status", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage()));//没有权限
return resultMap;
}
/*假期规则对应的假期类型的ID*/
String ruleId = Util.null2String(params.get("typeId"));
/*假期规则名称*/
String ruleName = Util.null2String(params.get("ruleName"));
/*应用范围0-总部、1-分部*/
int scopeType = Util.getIntValue((String) params.get("scopeType"));
/*应用范围为分部时选择的分部ID*/
String scopeValue = Util.null2String(params.get("scopeValue"));
/*余额发放方式1-手动发放、2-按司龄自动发放、3-按工龄自动发放、4-每年自动发放固定天数、5-加班时长自动计入余额、6-按司龄+工龄自动发放*/
int distributionMode = Util.getIntValue((String) params.get("distributionMode"), 1);
/*每人发放小时(天)数(当余额发放方式为每年自动发放固定天数时有效)*/
double annualAmount = Util.getDoubleValue((String) params.get("annualAmount"), 0);
//法定年假规则0-工龄、1-司龄、2-工龄+司龄 (当余额发放方式为按工龄+司龄自动发放时有效)
String legalKey = Util.null2s((String) params.get("legalKey"), "0");
//福利年假规则0-工龄、1-工龄、2-工龄+司龄 (当余额发放方式为按工龄+司龄自动发放时有效)
String welfareKey = Util.null2s((String) params.get("welfareKey"), "1");
/*扣减优先级1-法定年假、2-福利年假*/
int priority = Util.getIntValue((String) params.get("priority"), 1);
/*有效期规则0-不限制、1-按自然月(1月1日-12月31日)、2-按入职日期起12个月、3-自定义次年失效日期、4-自定义有效天数*/
int validityRule = Util.getIntValue((String) params.get("validityRule"), 1);
/*有效期天数:(当有效期天数选择按天数失效的时候有效)*/
int effectiveDays = Util.getIntValue((String) params.get("effectiveDays"), 30);
//有效月数(当有效期规则选择自定义有效月数时)
int effectiveMonths = Util.getIntValue((String) params.get("effectiveMonths"), 1);
/*失效日期--月当有效期规则选择3-自定义次年失效日期时有效)*/
String expirationMonth = Util.null2String(params.get("expirationMonth"));
/*失效日期--日当有效期规则选择3-自定义次年失效日期时有效)*/
String expirationDay = Util.null2String(params.get("expirationDay"));
/*允许延长有效期0-不允许、1-允许*/
int extensionEnable = Util.getIntValue((String) params.get("extensionEnable"), 0);
/*允许超过有效期天数*/
int extendedDays = Util.getIntValue((String) params.get("extendedDays"), 0);
/*释放规则0-不限制、1-按天释放、2-按月释放*/
int releaseRule = Util.getIntValue((String) params.get("releaseRule"), 0);
/*假期基数计算方式0-精确计算、1-按最少的假期余额计算、2-按最多的假期余额计算*/
int calcMethod = Util.getIntValue((String) params.get("calcMethod"), 0);
/*是否折算0-不折算、1-四舍五入、2-向上取整、3-向下取整、4-向上取0.5的倍数、5-向下取0.5的倍数*/
int convertMode = Util.getIntValue("" + params.get("convertMode"), 1);
/*次账号是否发放假期余额0-不发放、1-发放*/
int excludeSubAccount = Util.getIntValue("" + params.get("excludeSubAccount"), 1);
/*转正之前是否发放假期余额0-不发放、1-发放*/
int beforeFormal = Util.getIntValue("" + params.get("excludeSubAccount"), 1);
if (scopeType != 0 && scopeValue.equals("")) {
resultMap.put("status", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(388858, user.getLanguage()));//参数有误
return resultMap;
}
/*两个不同的假期类型下不能同时存在 加班时长自动计入余额 的余额发放方式*/
if (distributionMode == 5) {
releaseRule = 0;
String sql = "select * from kq_LeaveRules where (isDelete is null or isDelete<>1) and id<>? and id in (select ruleId from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and distributionMode=5)";
RecordSet recordSet = new RecordSet();
recordSet.executeQuery(sql, ruleId);
if (recordSet.next()) {
resultMap.put("status", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(505664, user.getLanguage()));//两个不同的假期类型下不能同时存在 加班时长自动计入余额 的余额发放方式
return resultMap;
}
} else if (distributionMode == 6) {
/*同一假期类型下 按司龄+工龄自动发放 不能与其他余额发放方式共存*/
String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=? and distributionMode<>6";
RecordSet recordSet = new RecordSet();
recordSet.executeQuery(sql, ruleId);
if (recordSet.next()) {
resultMap.put("status", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(505665, user.getLanguage()));//同一假期类型下 按司龄+工龄自动发放 不能与其他余额发放方式共存
return resultMap;
}
} else {
/*同一个假期类型下其他余额发放方式不能与 按司龄+工龄自动发放 共存*/
String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=? and distributionMode=6";
RecordSet recordSet = new RecordSet();
recordSet.executeQuery(sql, ruleId);
if (recordSet.next()) {
resultMap.put("status", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(505666, user.getLanguage()));//同一个假期类型下其他余额发放方式不能与 按司龄+工龄自动发放 共存
return resultMap;
}
//同一个假期类型下其他余额发放方式不能与 加班时长自动计入余额 共存
sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=? and distributionMode=5";
recordSet.executeQuery(sql, ruleId);
if (recordSet.next()) {
resultMap.put("status", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(510357, user.getLanguage()));//同一个假期类型下其他余额发放方式不能与 加班时长自动计入余额 共存
return resultMap;
}
}
String searchSql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=?";
RecordSet recordSet = new RecordSet();
recordSet.executeQuery(searchSql, ruleId);
while (recordSet.next()) {
int scopeTypeTemp = Util.getIntValue(recordSet.getString("scopeType"), 0);
String scopeValueTemp = recordSet.getString("scopeValue");
if (scopeType == 0 && scopeTypeTemp == 0) {
resultMap.put("status", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(505667, user.getLanguage()));//该假期类型下已经新建过总部的假期规则,请勿重复新建
return resultMap;
}
if (scopeType == 1 && scopeTypeTemp == 1) {
List<String> scopeValueTempList = Util.TokenizerString(scopeValueTemp, ",");
List<String> scopeValueList = Util.TokenizerString(scopeValue, ",");
for (String temp : scopeValueList)
if (scopeValueTempList.contains(temp)) {
SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo();
String subcomName = subCompanyComInfo.getSubCompanyname(temp);
resultMap.put("status", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(505668, user.getLanguage()).replace("$", subcomName));//该假期类型下已经新建过分部的假期规则,请勿重复新建
return resultMap;
}
}
}
boolean flag = false;//数据是否插入成功
String sql = "insert into kq_LeaveRulesDetail(ruleId,ruleName,scopeType,scopeValue," +
"distributionMode,annualAmount,legalKey,welfareKey,priority,validityRule,effectiveDays,effectiveMonths,expirationMonth,expirationDay,extensionEnable,extendedDays,releaseRule,calcMethod,convertMode,excludeSubAccount,beforeFormal,isDelete) values(?,?,?,?, ?,?,?,?, ?,?,?,?, ?,?,?,?, ?,?,?,?, ?,0)";
flag = recordSet.executeUpdate(sql, ruleId, ruleName, scopeType, scopeValue,
distributionMode, annualAmount, legalKey, welfareKey, priority, validityRule, effectiveDays, effectiveMonths, expirationMonth, expirationDay, extensionEnable, extendedDays, releaseRule, calcMethod, convertMode, excludeSubAccount, beforeFormal);
if (!flag) {
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
/*获取刚才插入的假期规则详情的ID*/
int ruleDetailId = 0;
sql = "select max(id) maxId from kq_LeaveRulesDetail";
recordSet.executeQuery(sql);
if (recordSet.next()) {
ruleDetailId = Util.getIntValue(recordSet.getString("maxId"), 0);
}
if ((distributionMode == 2 || distributionMode == 7) && ruleDetailId != 0) {
int lowerLimit = 0;//司龄下限
int upperLimit = 0;//司龄上限
String data = Util.null2String(params.get("detailRule"));
JSONArray jsonArray = JSONArray.parseArray(data);
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
int timePoint = jsonObject.getIntValue("timePoint");
double amount = jsonObject.getDoubleValue("amount");
lowerLimit = i == 0 ? 0 : timePoint;
upperLimit = i == jsonArray.size() - 1 ? 9999 : jsonArray.getJSONObject(i + 1).getIntValue("timePoint");
sql = "insert into kq_EntryToLeave(leaveRulesId,lowerLimit,upperLimit,amount) values(?,?,?,?)";
flag = recordSet.executeUpdate(sql, ruleDetailId, lowerLimit, upperLimit, amount);
if (!flag) {
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
}
}
if (distributionMode == 3 && ruleDetailId != 0) {
int lowerLimit = 0;//工龄下限
int upperLimit = 0;//工龄上限
String data = Util.null2String(params.get("detailRule"));
JSONArray jsonArray = JSONArray.parseArray(data);
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
int timePoint = jsonObject.getIntValue("timePoint");
double amount = jsonObject.getDoubleValue("amount");
lowerLimit = i == 0 ? 0 : timePoint;
upperLimit = i == jsonArray.size() - 1 ? 9999 : jsonArray.getJSONObject(i + 1).getIntValue("timePoint");
sql = "insert into kq_WorkingAgeToLeave(leaveRulesId,lowerLimit,upperLimit,amount) values(?,?,?,?)";
flag = recordSet.executeUpdate(sql, ruleDetailId, lowerLimit, upperLimit, amount);
if (!flag) {
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
}
}
if (distributionMode == 6 && ruleDetailId != 0) {
String mixModeData = Util.null2String(params.get("legalRule"));
JSONArray jsonArray = JSONArray.parseArray(mixModeData);
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
int workYear = jsonObject.getIntValue("workYear");
int entryTime = jsonObject.getIntValue("entryTime");
double legalAmount = jsonObject.getDoubleValue("legalAmount");
sql = "insert into kq_MixModeToLegalLeave(leaveRulesId,limit1,limit2,amount) values(?,?,?,?)";
flag = recordSet.executeUpdate(sql, ruleDetailId, workYear, entryTime, legalAmount);
if (!flag) {
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
}
mixModeData = Util.null2String(params.get("welfareRule"));
jsonArray = JSONArray.parseArray(mixModeData);
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
int workYear = jsonObject.getIntValue("workYear");
int entryTime = jsonObject.getIntValue("entryTime");
double welfareAmount = jsonObject.getDoubleValue("welfareAmount");
sql = "insert into kq_MixModeToWelfareLeave(leaveRulesId,limit1,limit2,amount) values(?,?,?,?)";
flag = recordSet.executeUpdate(sql, ruleDetailId, workYear, entryTime, welfareAmount);
if (!flag) {
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
}
}
if (flag) {
resultMap.put("sign", "1");
resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功
}
} catch (Exception e) {
writeLog(e);
} finally {
KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo();
detailComInfo.removeCache();
}
return resultMap;
}
}

@ -0,0 +1,364 @@
package com.engine.kq.cmd.leaverules;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.biz.SimpleBizLogger;
import com.engine.common.constant.BizLogSmallType4Hrm;
import com.engine.common.constant.BizLogType;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.kq.biz.KQBalanceOfLeaveBiz;
import com.engine.kq.biz.KQLeaveRulesComInfo;
import com.engine.kq.biz.KQLeaveRulesDetailComInfo;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import weaver.hrm.company.SubCompanyComInfo;
import weaver.systeminfo.SystemEnv;
import java.util.*;
/**
* --
*/
public class EditLeaveRulesCmd extends AbstractCommonCommand<Map<String, Object>> {
private SimpleBizLogger logger;
public EditLeaveRulesCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
this.logger = new SimpleBizLogger();
int ruleDetailId = Util.getIntValue((String) params.get("ruleId"));
BizLogContext bizLogContext = new BizLogContext();
bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型
bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_LEAVERULES);//所属大类型
bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_LEAVERULES);//当前小类型
bizLogContext.setParams(params);//当前request请求参数
logger.setUser(user);//当前操作人
String mainSql = "select * from kq_LeaveRulesDetail where id=" + ruleDetailId;
logger.setMainSql(mainSql, "id");//主表sql
logger.setMainPrimarykey("id");//主日志表唯一key
logger.setMainTargetNameColumn("rulename");
SimpleBizLogger.SubLogInfo subLogInfo1 = logger.getNewSubLogInfo();
String subSql1 = "select * from kq_EntryToLeave where leaveRulesId=" + ruleDetailId;
subLogInfo1.setSubSql(subSql1, "id");
logger.addSubLogInfo(subLogInfo1);
SimpleBizLogger.SubLogInfo subLogInfo2 = logger.getNewSubLogInfo();
String subSql2 = "select * from kq_WorkingAgeToLeave where leaveRulesId=" + ruleDetailId;
subLogInfo2.setSubSql(subSql2, "id");
logger.addSubLogInfo(subLogInfo2);
SimpleBizLogger.SubLogInfo subLogInfo3 = logger.getNewSubLogInfo();
String subSql3 = "select * from kq_MixModeToLegalLeave where leaveRulesId=" + ruleDetailId;
subLogInfo3.setSubSql(subSql3, "id");
logger.addSubLogInfo(subLogInfo3);
SimpleBizLogger.SubLogInfo subLogInfo4 = logger.getNewSubLogInfo();
String subSql4 = "select * from kq_MixModeToLegalLeave where leaveRulesId=" + ruleDetailId;
subLogInfo4.setSubSql(subSql4, "id");
logger.addSubLogInfo(subLogInfo4);
logger.before(bizLogContext);
}
@Override
public BizLogContext getLogContext() {
return null;
}
@Override
public List<BizLogContext> getLogContexts() {
return logger.getBizLogContexts();
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> resultMap = new HashMap<String, Object>();
try {
boolean canEdit = HrmUserVarify.checkUserRight("KQLeaveRulesEdit:Edit", user);//是否具有新建权限
if (!canEdit) {
resultMap.put("status", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage()));
return resultMap;
}
/*假期类型的ID*/
int ruleId = Util.getIntValue((String) params.get("typeId"));
/*假期规则详情的ID*/
int ruleDetailId = Util.getIntValue((String) params.get("ruleId"));
/*假期规则名称*/
String ruleName = Util.null2String(params.get("ruleName"));
/*应用范围0-总部、1-分部*/
int scopeType = Util.getIntValue((String) params.get("scopeType"));
/*应用范围为分部时选择的分部ID*/
String scopeValue = Util.null2String(params.get("scopeValue"));
/*余额发放方式1-手动发放、2-按司龄自动发放、3-按工龄自动发放、4-每年自动发放固定天数、 5-加班时长自动计入余额*/
int distributionMode = Util.getIntValue((String) params.get("distributionMode"), 1);
/*每人发放小时(天)数(当余额发放方式为每年自动发放固定天数时有效)*/
double annualAmount = Util.getDoubleValue((String) params.get("annualAmount"), 0);
/*扣减优先级1-法定年假、2-福利年假*/
int priority = Util.getIntValue((String) params.get("priority"), 1);
//法定年假规则0-工龄、1-司龄、2-工龄+司龄 (当余额发放方式为按工龄+司龄自动发放时有效)
String legalKey = Util.null2s((String) params.get("legalKey"), "0");
//福利年假规则0-工龄、1-工龄、2-工龄+司龄 (当余额发放方式为按工龄+司龄自动发放时有效)
String welfareKey = Util.null2s((String) params.get("welfareKey"), "1");
/*有效期规则0-不限制、1-按自然月(1月1日-12月31日)、2-按入职日期起12个月、3-自定义次年失效日期、4-自定义有效天数*/
int validityRule = Util.getIntValue((String) params.get("validityRule"), 1);
/*有效期天数:(当有效期天数选择按天数失效的时候有效)*/
int effectiveDays = Util.getIntValue((String) params.get("effectiveDays"), 30);
//有效月数(当有效期规则选择自定义有效月数时)
int effectiveMonths = Util.getIntValue((String) params.get("effectiveMonths"), 1);
/*失效日期--月当有效期规则选择3-自定义次年失效日期时有效)*/
String expirationMonth = Util.null2String(params.get("expirationMonth"));
/*失效日期--日当有效期规则选择3-自定义次年失效日期时有效)*/
String expirationDay = Util.null2String(params.get("expirationDay"));
/*允许延长有效期0-不允许、1-允许*/
int extensionEnable = Util.getIntValue((String) params.get("extensionEnable"), 0);
/*允许超过有效期天数*/
int extendedDays = Util.getIntValue((String) params.get("extendedDays"), 0);
/*释放规则0-不限制、1-按天释放、2-按月释放*/
int releaseRule = Util.getIntValue((String) params.get("releaseRule"), 0);
/*假期基数计算方式0-精确计算、1-按最少的假期余额计算、2-按最多的假期余额计算*/
int calcMethod = Util.getIntValue((String) params.get("calcMethod"), 0);
/*是否折算0-不折算、1-四舍五入、2-向上取整、3-向下取整、4-向上取0.5的倍数、5-向下取0.5的倍数*/
int convertMode = Util.getIntValue("" + params.get("convertMode"), 1);
/*次账号是否发放假期余额0-不发放、1-发放*/
int excludeSubAccount = Util.getIntValue("" + params.get("excludeSubAccount"), 1);
/*转正之前是否发放假期余额0-不发放、1-发放*/
int beforeFormal = Util.getIntValue("" + params.get("beforeFormal"), 1);
if (scopeType == 1 && scopeValue.equals("")) {
resultMap.put("status", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(388858, user.getLanguage()));//参数有误
return resultMap;
}
if (distributionMode == 5) {
releaseRule = 0;
/*两个不同的假期类型下不能同时存在 加班时长自动计入余额 的余额发放方式*/
String sql = "select * from kq_LeaveRules where (isDelete is null or isDelete<>1) and id<>? and id in (select ruleId from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and distributionMode=5)";
RecordSet recordSet = new RecordSet();
recordSet.executeQuery(sql, ruleId);
if (recordSet.next()) {
resultMap.put("status", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(505664, user.getLanguage()));//两个不同的假期类型下不能同时存在 加班时长自动计入余额 的余额发放方式
return resultMap;
}
} else if (distributionMode == 6) {
/*同一假期类型下 按司龄+工龄自动发放 不能与其他余额发放方式共存*/
String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=? and distributionMode<>6";
RecordSet recordSet = new RecordSet();
recordSet.executeQuery(sql, ruleId);
if (recordSet.next()) {
resultMap.put("status", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(505665, user.getLanguage()));//同一假期类型下 按司龄+工龄自动发放 不能与其他余额发放方式共存
return resultMap;
}
} else {
/*同一个假期类型下其他余额发放方式不能与 按司龄+工龄自动发放 共存*/
String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=? and distributionMode=6";
RecordSet recordSet = new RecordSet();
recordSet.executeQuery(sql, ruleId);
if (recordSet.next()) {
resultMap.put("status", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(505666, user.getLanguage()));//同一个假期类型下其他余额发放方式不能与 按司龄+工龄自动发放 共存
return resultMap;
}
//同一个假期类型下其他余额发放方式不能与 加班时长自动计入余额 共存
sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=? and distributionMode=5";
recordSet.executeQuery(sql, ruleId);
if (recordSet.next()) {
resultMap.put("status", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(510357, user.getLanguage()));//同一个假期类型下其他余额发放方式不能与 加班时长自动计入余额 共存
return resultMap;
}
}
String searchSql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=? and id<>?";
RecordSet recordSet = new RecordSet();
recordSet.executeQuery(searchSql, ruleId, ruleDetailId);
while (recordSet.next()) {
int scopeTypeTemp = Util.getIntValue(recordSet.getString("scopeType"), 0);
String scopeValueTemp = recordSet.getString("scopeValue");
if (scopeType == 0 && scopeTypeTemp == 0) {
resultMap.put("status", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(505667, user.getLanguage()));//该假期类型下已经新建过总部的假期规则,请勿重复新建
return resultMap;
}
if (scopeType == 1 && scopeTypeTemp == 1) {
List<String> scopeValueTempList = Util.TokenizerString(scopeValueTemp, ",");
List<String> scopeValueList = Util.TokenizerString(scopeValue, ",");
for (String temp : scopeValueList)
if (scopeValueTempList.contains(temp)) {
SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo();
String subcomName = subCompanyComInfo.getSubCompanyname(temp);
resultMap.put("status", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(505668, user.getLanguage()).replace("$", subcomName));//该假期类型下已经新建过分部的假期规则,请勿重复新建
return resultMap;
}
}
}
boolean flag = false;//数据是否更新成功
String sql = "update kq_LeaveRulesDetail set ruleId=?,ruleName=?,scopeType=?,scopeValue=?," +
"distributionMode=?,annualAmount=?,legalKey=?,welfareKey=?,priority=?,validityRule=?,effectiveDays=?,effectiveMonths=?,expirationMonth=?,expirationDay=?,extensionEnable=?,extendedDays=?,releaseRule=?,calcMethod=?,convertMode=?,excludeSubAccount=?,beforeFormal=? where id=?";
flag = recordSet.executeUpdate(sql, ruleId, ruleName, scopeType, scopeValue,
distributionMode, annualAmount, legalKey, welfareKey, priority, validityRule, effectiveDays, effectiveMonths, expirationMonth, expirationDay, extensionEnable, extendedDays, releaseRule, calcMethod, convertMode, excludeSubAccount, beforeFormal, ruleDetailId);
if (!flag) {
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
if ((distributionMode == 2 || distributionMode == 7) && ruleDetailId != 0) {
sql = "delete from kq_EntryToLeave where leaveRulesId=?";
flag = recordSet.executeUpdate(sql, ruleDetailId);
if (!flag) {
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
int lowerLimit = 0;//司龄下限
int upperLimit = 0;//司龄上限
String data = Util.null2String(params.get("detailRule"));
JSONArray jsonArray = JSONArray.parseArray(data);
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
int timePoint = jsonObject.getIntValue("timePoint");
double amount = jsonObject.getDoubleValue("amount");
lowerLimit = i == 0 ? 0 : timePoint;
upperLimit = i == jsonArray.size() - 1 ? 9999 : jsonArray.getJSONObject(i + 1).getIntValue("timePoint");
sql = "insert into kq_EntryToLeave(leaveRulesId,lowerLimit,upperLimit,amount) values(?,?,?,?)";
flag = recordSet.executeUpdate(sql, ruleDetailId, lowerLimit, upperLimit, amount);
if (!flag) {
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
}
}
if (distributionMode == 3 && ruleDetailId != 0) {
sql = "delete from kq_WorkingAgeToLeave where leaveRulesId=?";
flag = recordSet.executeUpdate(sql, ruleDetailId);
if (!flag) {
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
int lowerLimit = 0;//工龄下限
int upperLimit = 0;//工龄上限
String data = Util.null2String(params.get("detailRule"));
JSONArray jsonArray = JSONArray.parseArray(data);
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
int timePoint = jsonObject.getIntValue("timePoint");
double amount = jsonObject.getDoubleValue("amount");
lowerLimit = i == 0 ? 0 : timePoint;
upperLimit = i == jsonArray.size() - 1 ? 9999 : jsonArray.getJSONObject(i + 1).getIntValue("timePoint");
sql = "insert into kq_WorkingAgeToLeave(leaveRulesId,lowerLimit,upperLimit,amount) values(?,?,?,?)";
flag = recordSet.executeUpdate(sql, ruleDetailId, lowerLimit, upperLimit, amount);
if (!flag) {
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
}
}
if (distributionMode == 6 && ruleDetailId != 0) {
sql = "delete from kq_MixModeToLegalLeave where leaveRulesId=?";
flag = recordSet.executeUpdate(sql, ruleDetailId);
if (!flag) {
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
sql = "delete from kq_MixModeToWelfareLeave where leaveRulesId=?";
flag = recordSet.executeUpdate(sql, ruleDetailId);
if (!flag) {
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
String mixModeData = Util.null2String(params.get("legalRule"));
JSONArray jsonArray = JSONArray.parseArray(mixModeData);
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
int workYear = jsonObject.getIntValue("workYear");
int entryTime = jsonObject.getIntValue("entryTime");
double legalAmount = jsonObject.getDoubleValue("legalAmount");
sql = "insert into kq_MixModeToLegalLeave(leaveRulesId,limit1,limit2,amount) values(?,?,?,?)";
flag = recordSet.executeUpdate(sql, ruleDetailId, workYear, entryTime, legalAmount);
if (!flag) {
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
}
mixModeData = Util.null2String(params.get("welfareRule"));
jsonArray = JSONArray.parseArray(mixModeData);
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
int workYear = jsonObject.getIntValue("workYear");
int entryTime = jsonObject.getIntValue("entryTime");
double welfareAmount = jsonObject.getDoubleValue("welfareAmount");
sql = "insert into kq_MixModeToWelfareLeave(leaveRulesId,limit1,limit2,amount) values(?,?,?,?)";
flag = recordSet.executeUpdate(sql, ruleDetailId, workYear, entryTime, welfareAmount);
if (!flag) {
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
}
}
if (flag) {
resultMap.put("sign", "1");
resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功
}
} catch (Exception e) {
writeLog(e);
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
} finally {
KQLeaveRulesDetailComInfo detailComInfo = new KQLeaveRulesDetailComInfo();
detailComInfo.removeCache();
}
return resultMap;
}
}

@ -0,0 +1,803 @@
package com.engine.kq.cmd.leaverules;
import com.api.browser.bean.SearchConditionItem;
import com.api.browser.bean.SearchConditionOption;
import com.api.hrm.bean.HrmFieldBean;
import com.api.hrm.util.HrmFieldSearchConditionComInfo;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.kq.biz.KQLeaveRulesComInfo;
import weaver.conn.RecordSet;
import weaver.filter.XssUtil;
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 GetLeaveRulesFormCmd extends AbstractCommonCommand<Map<String, Object>> {
public GetLeaveRulesFormCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
}
@Override
public BizLogContext getLogContext() {
return null;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> resultMap = new HashMap<String, Object>();
try {
boolean canEdit = HrmUserVarify.checkUserRight("KQLeaveRulesEdit:Edit", user);//是否具有编辑权限
if (!canEdit) {
resultMap.put("status", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage()));
return resultMap;
}
/**假期类型的相关信息:*/
KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo();
/*新建假期规则时选择完请假类型后会再次请求此表单接口*/
/*规则对应的假期类型的ID*/
String ruleId = Util.null2String(params.get("typeId"));
/*是否启用0-未启用、1-启用*/
int isEnable = 1;
/*最小请假单位1-按天请假、2-按半天请假、3-按小时请假、4-按整天请假*/
int minimumUnit = 1;
/******************************************************************************/
/**假期规则详情的相关信息:*/
/*是否是编辑*/
boolean isEdit = false;
/*假期规则详情的ID*/
String ruleDetailId = Util.null2String(params.get("ruleId"));
/*假期规则名称*/
String ruleName = "";
/*应用范围0-总部、1-分部*/
int scopeType = 0;
/*应用范围为分部时选择的分部ID*/
String scopeValue = "";
/*余额发放方式1-手动发放、2-按司龄自动发放、3-按工龄自动发放、4-每年自动发放固定天数、5-加班时长自动计入余额、6-按工龄+司龄自动发放*/
int distributionMode = 1;
//年假基数计算方式:
// 0(精确计算)-假期基数发放日期和假期基数变动日期均为每年的01月01号(但是假期基数是结合 司龄/工龄 变化前后的值按天数比例折算出来的)、
// 1(按最少的余额计算)-假期基数发放日期和假期基数变动日期均为每年的01月01号、
// 2(按最多的余额计算)-假期基数发放日期发放日期为每年的01月01号假期基数的变动日期为每年的 入职日期/参加工作日期
int calcMethod = 1;
//是否折算0-不折算、1-四舍五入、2-向上取整、3-向下取整、4-向上取0.5的倍数、向下取0.5的倍数
int convertMode = 1;
//折算后的小数点位数
int decimalDigit = 2;
/*每人发放小时(天)数(当余额发放方式为是每年发放固定天数时有效)*/
double annualAmount = 0;
//法定年假规则0-工龄、1-司龄、2-工龄+司龄 (当余额发放方式为按工龄+司龄自动发放时有效)
String legalKey = "0";
//福利年假规则0-工龄、1司龄、2-工龄+司龄 (当余额发放方式为按工龄+司龄自动发放时有效)
String welfareKey = "1";
/*扣减优先级1-法定年假、2-福利年假(当余额发放方式为按工龄+司龄自动发放时有效)*/
int priority = 1;
//有效期规则0-永久有效、1-按自然年1月1日-12月31日、2-按入职日期起12个月、3-自定义次年失效日期、4、按天数失效、5-按季度失效、6-按月数失效
int validityRule = 0;
/*失效日期--月(当有效期规则选择自定义次年失效日期时有效)*/
String expirationMonth = "1";
/*失效日期--日(当有效期规则选择自定义次年失效日期时有效)*/
String expirationDay = "1";
//有效天数(当有效期规则选择自定义有效天数时)
String effectiveDays = "30";
//有效月数(当有效期规则选择自定义有效月数时)
String effectiveMonths = "1";
/*允许延长有效期0-不允许、1-允许*/
int extensionEnable = 0;
/*允许超过有效期天数*/
int extendedDays = 90;
/*释放规则0-不限制、1-按天释放、2-按月释放*/
int releaseRule = 0;
//是否需要排除次账号0--不排除即次账号正常享受年假、1--排除,即次账号不能享受年假
int excludeSubAccount = 1;
//转正之前是否允许发放假期余额0-不允许、1-允许
int beforeFormal = 1;
/*入职时长--年假*/
Map<String, Object> entryMap = new HashMap<String, Object>();
List entryList = new ArrayList();
/*工龄--年假*/
Map<String, Object> workingAgeMap = new HashMap<String, Object>();
List workingAgeList = new ArrayList();
/*入职时长+工龄混合--年假*/
Map<String, Object> mixedModeMap = new HashMap<String, Object>();
List mixedModeList = new ArrayList();
if (!ruleDetailId.equals("")) {
String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete != 1) and id=" + ruleDetailId;
RecordSet recordSet = new RecordSet();
recordSet.executeQuery(sql);
if (recordSet.next()) {
isEdit = true;
ruleName = recordSet.getString("ruleName");
ruleId = recordSet.getString("ruleId");
scopeType = recordSet.getInt("scopeType");
scopeValue = recordSet.getString("scopeValue");
distributionMode = Util.getIntValue(recordSet.getString("distributionMode"), 1);
annualAmount = Util.getDoubleValue(recordSet.getString("annualAmount"), 0);
legalKey = "" + Util.getIntValue(recordSet.getString("legalKey"), 0);
welfareKey = "" + Util.getIntValue(recordSet.getString("welfareKey"), 1);
priority = Util.getIntValue(recordSet.getString("priority"), 1);
validityRule = Util.getIntValue(recordSet.getString("validityRule"), 0);
effectiveDays = Util.null2s(recordSet.getString("effectiveDays"), "30");
effectiveMonths = Util.null2s(recordSet.getString("effectiveMonths"),"1");
expirationMonth = Util.null2s(recordSet.getString("expirationMonth"), "1");
expirationDay = Util.null2s(recordSet.getString("expirationDay"), "1");
extensionEnable = Util.getIntValue(recordSet.getString("extensionEnable"), 0);
extendedDays = Util.getIntValue(recordSet.getString("extendedDays"), 90);
releaseRule = Util.getIntValue(recordSet.getString("releaseRule"), 0);
calcMethod = Util.getIntValue(recordSet.getString("calcMethod"), 1);
convertMode = Util.getIntValue(recordSet.getString("convertMode"), 1);
excludeSubAccount = Util.getIntValue(recordSet.getString("excludeSubAccount"), 1);
beforeFormal = Util.getIntValue(recordSet.getString("beforeFormal"), 1);
}
if (distributionMode == 2 || distributionMode == 7) {
sql = "select * from kq_EntryToLeave where leaveRulesId = ? order by lowerLimit,upperLimit";
recordSet.executeQuery(sql, ruleDetailId);
int lowerLimit = 0;//入职年限下限
int upperLimit = 0;//入职年限上限
double amount = 0;//假期天数
while (recordSet.next()) {
lowerLimit = recordSet.getInt("lowerLimit");
upperLimit = recordSet.getInt("upperLimit");
amount = Util.getDoubleValue(recordSet.getString("amount"), 0);
entryMap = new HashMap<String, Object>();
entryMap.put("timePoint", lowerLimit);
entryMap.put("amount", String.format("%.2f", amount));
entryList.add(entryMap);
}
resultMap.put("detailRule", entryList);
}
if (distributionMode == 3) {
sql = "select * from kq_WorkingAgeToLeave where leaveRulesId = ? order by lowerLimit,upperLimit";
recordSet.executeQuery(sql, ruleDetailId);
int lowerLimit = 0;//工龄下限
int upperLimit = 0;//工龄上限
double amount = 0;//假期天数
while (recordSet.next()) {
lowerLimit = recordSet.getInt("lowerLimit");
upperLimit = recordSet.getInt("upperLimit");
amount = Util.getDoubleValue(recordSet.getString("amount"), 0);
workingAgeMap = new HashMap<String, Object>();
workingAgeMap.put("timePoint", lowerLimit);
workingAgeMap.put("amount", String.format("%.2f", amount));
workingAgeList.add(workingAgeMap);
}
resultMap.put("detailRule", workingAgeList);
}
if (distributionMode == 6) {
sql = "select * from kq_MixModeToLegalLeave where leaveRulesId=? order by id ";
recordSet.executeQuery(sql, ruleDetailId);
double limit1 = 0;//工龄下限
double limit2 = 0;//司龄下限
double amount = 0;//法定年假天数or福利年假天数
while (recordSet.next()) {
limit1 = Util.getDoubleValue(recordSet.getString("limit1"), 0);
limit2 = Util.getDoubleValue(recordSet.getString("limit2"), 0);
amount = Util.getDoubleValue(recordSet.getString("amount"), 0);
mixedModeMap = new HashMap<String, Object>();
if (legalKey.equals("0") || legalKey.equals("2")) {
mixedModeMap.put("workYear", limit1);
}
if (legalKey.equals("1") || legalKey.equals("2")) {
mixedModeMap.put("entryTime", limit2);
}
mixedModeMap.put("legalAmount", String.format("%.2f", amount));
mixedModeList.add(mixedModeMap);
}
resultMap.put("legalRule", mixedModeList);
resultMap.put("legalKey", legalKey);
mixedModeList = new ArrayList();
sql = "select * from kq_MixModeToWelfareLeave where leaveRulesId=? order by id ";
recordSet.executeQuery(sql, ruleDetailId);
while (recordSet.next()) {
limit1 = Util.getDoubleValue(recordSet.getString("limit1"), 0);
limit2 = Util.getDoubleValue(recordSet.getString("limit2"), 0);
amount = Util.getDoubleValue(recordSet.getString("amount"), 0);
mixedModeMap = new HashMap<String, Object>();
if (welfareKey.equals("0") || welfareKey.equals("2")) {
mixedModeMap.put("workYear", limit1);
}
if (welfareKey.equals("1") || welfareKey.equals("2")) {
mixedModeMap.put("entryTime", limit2);
}
mixedModeMap.put("welfareAmount", String.format("%.2f", amount));
mixedModeList.add(mixedModeMap);
}
resultMap.put("welfareRule", mixedModeList);
resultMap.put("welfareKey", welfareKey);
}
}
if (isEdit) {
isEnable = Util.getIntValue(rulesComInfo.getIsEnable(ruleId), 1);
}
List<Map<String, Object>> groupList = new ArrayList<Map<String, Object>>();
Map<String, Object> groupItem = new HashMap<String, Object>();
List<Object> itemList = new ArrayList<Object>();
HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo();
SearchConditionItem searchConditionItem = null;
HrmFieldBean hrmFieldBean = null;
/****************************************************基本信息****************************************************/
groupItem.put("title", SystemEnv.getHtmlLabelName(1361, user.getLanguage()));
groupItem.put("defaultshow", true);
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname("typeId");//假期类型
hrmFieldBean.setFieldlabel("129811");
hrmFieldBean.setFieldhtmltype("5");
hrmFieldBean.setType("1");
hrmFieldBean.setFieldvalue(ruleId);
hrmFieldBean.setIsFormField(true);
hrmFieldBean.setViewAttr(isEnable == 0 || isEdit ? 1 : 3);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
List<SearchConditionOption> optionsList = new ArrayList<SearchConditionOption>();
if (!isEdit) {
rulesComInfo.setTofirstRow();
while (rulesComInfo.next()) {
if (!rulesComInfo.getIsEnable().equals("1") || !rulesComInfo.getBalanceEnable().equals("1")) {
continue;
}
optionsList.add(new SearchConditionOption(rulesComInfo.getId(), Util.formatMultiLang(rulesComInfo.getLeaveName(), "" + user.getLanguage()), ruleId.equals(rulesComInfo.getId())));
}
} else {
optionsList.add(new SearchConditionOption(ruleId, Util.formatMultiLang(rulesComInfo.getLeaveName(ruleId), "" + user.getLanguage()), true));
}
searchConditionItem.setOptions(optionsList);
searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(505298, user.getLanguage()));//只能选择启用状态下开启了假期余额的假期类型,并且编辑假期规则时不能变更假期类型
searchConditionItem.setRules("required|string");
if (hrmFieldBean.getViewAttr() == 1) {
Map<String, Object> OtherParamsMap = new HashMap<String, Object>();
OtherParamsMap.put("hasBorder", true);
searchConditionItem.setOtherParams(OtherParamsMap);
}
itemList.add(searchConditionItem);
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname("ruleName");//规则名称
hrmFieldBean.setFieldlabel("19829");
hrmFieldBean.setFieldhtmltype("1");
hrmFieldBean.setType("1");
hrmFieldBean.setFieldvalue(ruleName);
hrmFieldBean.setIsFormField(true);
hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
searchConditionItem.setRules("required|string");
if (hrmFieldBean.getViewAttr() == 1) {
Map<String, Object> OtherParamsMap = new HashMap<String, Object>();
OtherParamsMap.put("hasBorder", true);
searchConditionItem.setOtherParams(OtherParamsMap);
}
itemList.add(searchConditionItem);
/*应用范围是否能够选择总部,如果已经新建过总部的假期规则,则无法新建总部的假期规则*/
boolean canSelectCom = true;
/*已经新建过某分部的假期规则,则无法继续新建该分部的假期规则*/
String selectedSubcomIds = "";
/*新建假期规则的时候选择完假期类型后重亲请求了此接口*/
if (!ruleId.equals("") && !isEdit) {
String sql = "select * from kq_LeaveRulesDetail where (isDelete is null or isDelete<>1) and ruleId=?";
RecordSet recordSet = new RecordSet();
recordSet.executeQuery(sql, ruleId);
while (recordSet.next()) {
int scopeTypeTemp = Util.getIntValue(recordSet.getString("scopeType"), 0);
String scopeValueTemp = recordSet.getString("scopeValue");
if (scopeTypeTemp == 0) {
canSelectCom = false;
}
if (scopeTypeTemp == 1) {
selectedSubcomIds += "," + scopeValueTemp;
}
}
}
selectedSubcomIds = selectedSubcomIds.length() > 0 ? selectedSubcomIds.substring(1) : "";
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname("scopeType");//此规则适用范围
hrmFieldBean.setFieldlabel("19374");
hrmFieldBean.setFieldhtmltype("5");
hrmFieldBean.setType("1");
hrmFieldBean.setIsFormField(true);
hrmFieldBean.setViewAttr(isEnable == 0 || !canSelectCom ? 1 : 3);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
optionsList = new ArrayList<SearchConditionOption>();
optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(140, user.getLanguage()), scopeType == 0 || !canSelectCom));
optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(33553, user.getLanguage()), scopeType == 1));
searchConditionItem.setOptions(optionsList);
//对于一个请假类型各分部能够且仅能够设置一个属于本分部的假期规则如果未设置本分部的假期规则默认取总部的假期规则如果总部也未设置则假期基数视作0.00
searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(505299, user.getLanguage()));
searchConditionItem.setRules("required|string");
if (hrmFieldBean.getViewAttr() == 1) {
Map<String, Object> OtherParamsMap = new HashMap<String, Object>();
OtherParamsMap.put("hasBorder", true);
searchConditionItem.setOtherParams(OtherParamsMap);
}
itemList.add(searchConditionItem);
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname("scopeValue");//分部
hrmFieldBean.setFieldlabel("33553");
hrmFieldBean.setFieldhtmltype("3");
hrmFieldBean.setType("170");
hrmFieldBean.setFieldvalue(scopeValue);
hrmFieldBean.setIsFormField(true);
hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
searchConditionItem.getBrowserConditionParam().getDataParams().put("rightStr", "KQLeaveRulesAdd:Add");
if (selectedSubcomIds.length() > 0) {
XssUtil xssUtil = new XssUtil();
String sqlWhere = " id not in (" + selectedSubcomIds + ") ";
searchConditionItem.getBrowserConditionParam().getDataParams().put("sqlWhere", xssUtil.put(sqlWhere));
searchConditionItem.getBrowserConditionParam().getCompleteParams().put("sqlWhere", xssUtil.put(sqlWhere));
searchConditionItem.getBrowserConditionParam().getDestDataParams().put("sqlWhere", xssUtil.put(sqlWhere));
}
searchConditionItem.setRules("required|string");
if (hrmFieldBean.getViewAttr() == 1) {
Map<String, Object> OtherParamsMap = new HashMap<String, Object>();
OtherParamsMap.put("hasBorder", true);
searchConditionItem.setOtherParams(OtherParamsMap);
}
itemList.add(searchConditionItem);
groupItem.put("items", itemList);
groupList.add(groupItem);
/****************************************************发放规则****************************************************/
groupItem = new HashMap<String, Object>();
itemList = new ArrayList<Object>();
groupItem.put("title", SystemEnv.getHtmlLabelName(508539, user.getLanguage()));
groupItem.put("defaultshow", true);
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname("distributionMode");//余额发放方式
hrmFieldBean.setFieldlabel("388946");
hrmFieldBean.setFieldhtmltype("5");
hrmFieldBean.setType("1");
hrmFieldBean.setIsFormField(true);
hrmFieldBean.setViewAttr((isEnable == 0 || (isEdit && distributionMode == 6)) ? 1 : 3);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
optionsList = new ArrayList<SearchConditionOption>();
optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(388947, user.getLanguage()), distributionMode == 1));
optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(390374, user.getLanguage()), distributionMode == 2));
optionsList.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(388949, user.getLanguage()), distributionMode == 3));
optionsList.add(new SearchConditionOption("4", SystemEnv.getHtmlLabelName(390323, user.getLanguage()), distributionMode == 4));
optionsList.add(new SearchConditionOption("5", SystemEnv.getHtmlLabelName(388951, user.getLanguage()), distributionMode == 5));
SearchConditionOption searchConditionOption = new SearchConditionOption("6", SystemEnv.getHtmlLabelName(390822, user.getLanguage()), distributionMode == 6);
searchConditionOption.setDisabled((isEdit && distributionMode != 6) ? true : false);
optionsList.add(searchConditionOption);
optionsList.add(new SearchConditionOption("7", SystemEnv.getHtmlLabelName(514025, user.getLanguage()), distributionMode == 7));
optionsList.add(new SearchConditionOption("8", SystemEnv.getHtmlLabelName(536880, user.getLanguage()), distributionMode == 8));
searchConditionItem.setOptions(optionsList);
searchConditionItem.setHelpfulTip("★" + SystemEnv.getHtmlLabelName(10000815,user.getLanguage()) + "★" + SystemEnv.getHtmlLabelName(501107, user.getLanguage()));
if (hrmFieldBean.getViewAttr() == 1) {
Map<String, Object> OtherParamsMap = new HashMap<String, Object>();
OtherParamsMap.put("hasBorder", true);
searchConditionItem.setOtherParams(OtherParamsMap);
}
itemList.add(searchConditionItem);
List<String> distributionModeTips = new ArrayList<String>();
distributionModeTips.add(SystemEnv.getHtmlLabelName(389735, user.getLanguage()) + " <font color=\"#FF0000\"><b>" + SystemEnv.getHtmlLabelName(511045, user.getLanguage()) + "</b></font>");
distributionModeTips.add(SystemEnv.getHtmlLabelName(500952, user.getLanguage()) + " <font color=\"#FF0000\"><b>" + SystemEnv.getHtmlLabelName(511045, user.getLanguage()) + "</b></font>");
distributionModeTips.add(SystemEnv.getHtmlLabelName(500953, user.getLanguage()) + " <font color=\"#FF0000\"><b>" + SystemEnv.getHtmlLabelName(511046, user.getLanguage()) + "</b></font>");
distributionModeTips.add(SystemEnv.getHtmlLabelName(389736, user.getLanguage()) + " <font color=\"#FF0000\"><b>" + SystemEnv.getHtmlLabelName(511045, user.getLanguage()) + "</b></font>");
distributionModeTips.add(SystemEnv.getHtmlLabelName(389737, user.getLanguage()) + " <font color=\"#FF0000\"><b>" + SystemEnv.getHtmlLabelName(511045, user.getLanguage()) + "</b></font>");
distributionModeTips.add(SystemEnv.getHtmlLabelName(500954, user.getLanguage()) + " <font color=\"#FF0000\"><b>" + SystemEnv.getHtmlLabelName(511046, user.getLanguage()) + "</b></font>");
distributionModeTips.add(SystemEnv.getHtmlLabelName(514026, user.getLanguage()) + " <font color=\"#FF0000\"><b>" + SystemEnv.getHtmlLabelName(511045, user.getLanguage()) + "</b></font>");
distributionModeTips.add(SystemEnv.getHtmlLabelName(536881, user.getLanguage()));
resultMap.put("distributionMode", distributionModeTips);
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname("calcMethod");//假期基数计算方式
hrmFieldBean.setFieldlabel("501121");
hrmFieldBean.setFieldhtmltype("5");
hrmFieldBean.setType("1");
hrmFieldBean.setIsFormField(true);
hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
optionsList = new ArrayList<SearchConditionOption>();
optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(505302, user.getLanguage()), calcMethod == 0));
optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(505303, user.getLanguage()), calcMethod == 1));
optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(505304, user.getLanguage()), calcMethod == 2));
searchConditionItem.setOptions(optionsList);
if (hrmFieldBean.getViewAttr() == 1) {
Map<String, Object> OtherParamsMap = new HashMap<String, Object>();
OtherParamsMap.put("hasBorder", true);
searchConditionItem.setOtherParams(OtherParamsMap);
}
itemList.add(searchConditionItem);
List<String> calcMethodTips = new ArrayList<String>();
//以入职日期(或参加工作日期)为分隔点将一年划分为上半年和下半年,全年可用假期天数=上半年天数/全年总天数*上半年司龄(或工龄)对应的假期天数+下半年天数/全年总天数*下半年司龄(或工龄)对应的假期天数。每年1月1日自动发放假期天数。
calcMethodTips.add(SystemEnv.getHtmlLabelName(505305, user.getLanguage()));
//每年1月1日计算员工的司龄(或工龄)取对应的假期天数于1月1日自动发放。
calcMethodTips.add(SystemEnv.getHtmlLabelName(505306, user.getLanguage()));
//每年1月1日计算员工的司龄(或工龄)取对应的假期天数于1月1日自动发放。若一年中员工司龄(或工龄)增加后,对应的假期天数也随之增加,则自动补发增加的假期天数。
calcMethodTips.add(SystemEnv.getHtmlLabelName(505307, user.getLanguage()));
resultMap.put("calcMethod", calcMethodTips);
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname("priority");//扣减优先级
hrmFieldBean.setFieldlabel("2093");
hrmFieldBean.setFieldhtmltype("5");
hrmFieldBean.setType("1");
hrmFieldBean.setIsFormField(true);
hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
optionsList = new ArrayList<SearchConditionOption>();
optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(129819, user.getLanguage()), priority == 1));
optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(132046, user.getLanguage()), priority == 2));
searchConditionItem.setOptions(optionsList);
if (hrmFieldBean.getViewAttr() == 1) {
Map<String, Object> OtherParamsMap = new HashMap<String, Object>();
OtherParamsMap.put("hasBorder", true);
searchConditionItem.setOtherParams(OtherParamsMap);
}
itemList.add(searchConditionItem);
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname("annualAmount");//每人发放小时数
hrmFieldBean.setFieldlabel("503237");
hrmFieldBean.setFieldhtmltype("1");
hrmFieldBean.setType("2");
hrmFieldBean.setFieldvalue(annualAmount);
hrmFieldBean.setIsFormField(true);
hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
searchConditionItem.setRules("required|numeric");
searchConditionItem.setPrecision(2);
searchConditionItem.setMin("0");
if (hrmFieldBean.getViewAttr() == 1) {
Map<String, Object> OtherParamsMap = new HashMap<String, Object>();
OtherParamsMap.put("hasBorder", true);
searchConditionItem.setOtherParams(OtherParamsMap);
}
itemList.add(searchConditionItem);
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname("convertMode");//是否折算
hrmFieldBean.setFieldlabel("508419");
hrmFieldBean.setFieldhtmltype("5");
hrmFieldBean.setType("1");
hrmFieldBean.setIsFormField(true);
hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
optionsList = new ArrayList<SearchConditionOption>();
optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(508423, user.getLanguage()), convertMode == 0));
optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(389654, user.getLanguage()), convertMode == 1));
optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(508424, user.getLanguage()), convertMode == 2));
optionsList.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(508425, user.getLanguage()), convertMode == 3));
optionsList.add(new SearchConditionOption("4", SystemEnv.getHtmlLabelName(508426, user.getLanguage()), convertMode == 4));
optionsList.add(new SearchConditionOption("5", SystemEnv.getHtmlLabelName(508427, user.getLanguage()), convertMode == 5));
searchConditionItem.setOptions(optionsList);
//当假期基数计算方式选择【精确计算】时,不能选择【不折算】
searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(510491, user.getLanguage()));
if (hrmFieldBean.getViewAttr() == 1) {
Map<String, Object> OtherParamsMap = new HashMap<String, Object>();
OtherParamsMap.put("hasBorder", true);
searchConditionItem.setOtherParams(OtherParamsMap);
}
itemList.add(searchConditionItem);
List<String> convertModeTips = new ArrayList<String>();
//指不考虑是否是入职当年还是初始获得年即年初01月01日的时候计算工龄或者司龄得出对应的假期基数为0。但是当这一年的工龄或者司龄增加后对应的假期基数就不再是0了这样的年份称作初始获得年通过工龄或司龄计算出对应的假期基数不做任何扣减折算
convertModeTips.add(SystemEnv.getHtmlLabelName(510131, user.getLanguage()));
//通过工龄或司龄计算出对应的假期基数后(若是入职当年或初始获得年会进行扣减折算),折算后四舍五入保留两位小数
convertModeTips.add(SystemEnv.getHtmlLabelName(510132, user.getLanguage()));
//通过工龄或司龄计算出对应的假期基数后若是入职当年或初始获得年会进行扣减折算折算后的数值取整例如折算后的基数为3.21取整后为4.0
convertModeTips.add(SystemEnv.getHtmlLabelName(510133, user.getLanguage()));
//通过工龄或司龄计算出对应的假期基数后若是入职当年或初始获得年会进行扣减折算折算后的数值取整例如折算后的基数为3.21取整后为3.0
convertModeTips.add(SystemEnv.getHtmlLabelName(510134, user.getLanguage()));
//通过工龄或司龄计算出对应的假期基数后若是入职当年或初始获得年会进行扣减折算折算后的数值取0.5的倍数例如折算后的基数为3.21最终为3.5
convertModeTips.add(SystemEnv.getHtmlLabelName(510135, user.getLanguage()));
//通过工龄或司龄计算出对应的假期基数后若是入职当年或初始获得年会进行扣减折算折算后的数值取0.5的倍数例如折算后的基数为3.21最终后为3.0
convertModeTips.add(SystemEnv.getHtmlLabelName(510136, user.getLanguage()));
resultMap.put("convertModeTips", convertModeTips);
groupItem.put("items", itemList);
groupList.add(groupItem);
/****************************************************有效期****************************************************/
groupItem = new HashMap<String, Object>();
itemList = new ArrayList<Object>();
groupItem.put("title", SystemEnv.getHtmlLabelName(15030, user.getLanguage()));
groupItem.put("defaultshow", true);
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname("validityRule");//有效期规则
hrmFieldBean.setFieldlabel("388952");
hrmFieldBean.setFieldhtmltype("5");
hrmFieldBean.setType("1");
hrmFieldBean.setIsFormField(true);
hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
optionsList = new ArrayList<SearchConditionOption>();
optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(22135, user.getLanguage()), validityRule == 0));
optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(388953, user.getLanguage()), validityRule == 1));
optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(388954, user.getLanguage()), validityRule == 2));
optionsList.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(389739, user.getLanguage()), validityRule == 3));
optionsList.add(new SearchConditionOption("4", SystemEnv.getHtmlLabelName(508428, user.getLanguage()), validityRule == 4));
optionsList.add(new SearchConditionOption("5", SystemEnv.getHtmlLabelName(513525, user.getLanguage()), validityRule == 5));
optionsList.add(new SearchConditionOption("6", SystemEnv.getHtmlLabelName(515135, user.getLanguage()), validityRule == 6));
optionsList.add(new SearchConditionOption("7", SystemEnv.getHtmlLabelName(536941, user.getLanguage()), validityRule == 7));
searchConditionItem.setOptions(optionsList);
searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(515354, user.getLanguage()));
if (hrmFieldBean.getViewAttr() == 1) {
Map<String, Object> OtherParamsMap = new HashMap<String, Object>();
OtherParamsMap.put("hasBorder", true);
searchConditionItem.setOtherParams(OtherParamsMap);
}
itemList.add(searchConditionItem);
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname("effectiveDays");//有效月数
hrmFieldBean.setFieldlabel("132356");
hrmFieldBean.setFieldhtmltype("1");
hrmFieldBean.setType("2");
hrmFieldBean.setFieldvalue(effectiveDays);
hrmFieldBean.setIsFormField(true);
hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
searchConditionItem.setRules("required|integer");
searchConditionItem.setMin("1");
if (hrmFieldBean.getViewAttr() == 1) {
Map<String, Object> OtherParamsMap = new HashMap<String, Object>();
OtherParamsMap.put("hasBorder", true);
searchConditionItem.setOtherParams(OtherParamsMap);
}
itemList.add(searchConditionItem);
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname("effectiveMonths");//有效月数
hrmFieldBean.setFieldlabel("515174");
hrmFieldBean.setFieldhtmltype("1");
hrmFieldBean.setType("2");
hrmFieldBean.setFieldvalue(effectiveMonths);
hrmFieldBean.setIsFormField(true);
hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
searchConditionItem.setRules("required|integer");
searchConditionItem.setMin("1");
if (hrmFieldBean.getViewAttr() == 1) {
Map<String, Object> OtherParamsMap = new HashMap<String, Object>();
OtherParamsMap.put("hasBorder", true);
searchConditionItem.setOtherParams(OtherParamsMap);
}
itemList.add(searchConditionItem);
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname("expirationMonth");//失效日期--月
hrmFieldBean.setFieldlabel("390103");
hrmFieldBean.setFieldhtmltype("5");
hrmFieldBean.setType("1");
hrmFieldBean.setFieldvalue(expirationMonth);
hrmFieldBean.setIsFormField(true);
hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
optionsList = new ArrayList<SearchConditionOption>();
for (int i = 1; i <= 12; i++) {
if(user.getLanguage()==8){
optionsList.add(new SearchConditionOption("" + i, i+"", Util.getIntValue(expirationMonth, 1) == i));
}else {
optionsList.add(new SearchConditionOption("" + i, i + SystemEnv.getHtmlLabelName(383373, user.getLanguage()), Util.getIntValue(expirationMonth, 1) == i));
}
}
searchConditionItem.setOptions(optionsList);
searchConditionItem.setRules("required|string");
if (hrmFieldBean.getViewAttr() == 1) {
Map<String, Object> OtherParamsMap = new HashMap<String, Object>();
OtherParamsMap.put("hasBorder", true);
searchConditionItem.setOtherParams(OtherParamsMap);
}
itemList.add(searchConditionItem);
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname("expirationDay");//失效日期--日
hrmFieldBean.setFieldlabel("390103");
hrmFieldBean.setFieldhtmltype("5");
hrmFieldBean.setType("1");
hrmFieldBean.setFieldvalue(expirationDay);
hrmFieldBean.setIsFormField(true);
hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
optionsList = new ArrayList<SearchConditionOption>();
for (int i = 1; i <= 31; i++) {
if(user.getLanguage()==8){
optionsList.add(new SearchConditionOption("" + i, i+"", Util.getIntValue(expirationMonth, 1) == i));
}else {
optionsList.add(new SearchConditionOption("" + i, i + SystemEnv.getHtmlLabelName(390, user.getLanguage()), Util.getIntValue(expirationDay, 1) == i));
}
}
searchConditionItem.setOptions(optionsList);
searchConditionItem.setRules("required|string");
if (hrmFieldBean.getViewAttr() == 1) {
Map<String, Object> OtherParamsMap = new HashMap<String, Object>();
OtherParamsMap.put("hasBorder", true);
searchConditionItem.setOtherParams(OtherParamsMap);
}
itemList.add(searchConditionItem);
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname("extensionEnable");//允许延长有效期
hrmFieldBean.setFieldlabel("388955");
hrmFieldBean.setFieldhtmltype("4");
hrmFieldBean.setType("1");
hrmFieldBean.setFieldvalue(extensionEnable);
hrmFieldBean.setIsFormField(true);
hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 2);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
Map<String, Object> otherParamsMap = new HashMap<String, Object>();
otherParamsMap.put("display", "switch");
searchConditionItem.setOtherParams(otherParamsMap);
if (hrmFieldBean.getViewAttr() == 1) {
Map<String, Object> OtherParamsMap = new HashMap<String, Object>();
OtherParamsMap.put("hasBorder", true);
searchConditionItem.setOtherParams(OtherParamsMap);
}
itemList.add(searchConditionItem);
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname("extendedDays");//允许延长的天数
hrmFieldBean.setFieldlabel("389198");
hrmFieldBean.setFieldhtmltype("1");
hrmFieldBean.setType("2");
hrmFieldBean.setFieldvalue(extendedDays);
hrmFieldBean.setIsFormField(true);
hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
searchConditionItem.setRules("required|integer");
if (hrmFieldBean.getViewAttr() == 1) {
Map<String, Object> OtherParamsMap = new HashMap<String, Object>();
OtherParamsMap.put("hasBorder", true);
searchConditionItem.setOtherParams(OtherParamsMap);
}
itemList.add(searchConditionItem);
groupItem.put("items", itemList);
groupList.add(groupItem);
/****************************************************其他设置****************************************************/
groupItem = new HashMap<String, Object>();
itemList = new ArrayList<Object>();
groupItem.put("title", SystemEnv.getHtmlLabelName(20824, user.getLanguage()));
groupItem.put("defaultshow", true);
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname("releaseRule");//释放规则
hrmFieldBean.setFieldlabel("389093");
hrmFieldBean.setFieldhtmltype("5");
hrmFieldBean.setType("1");
hrmFieldBean.setIsFormField(true);
hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 3);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
optionsList = new ArrayList<SearchConditionOption>();
optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(32499, user.getLanguage()), releaseRule == 0));
optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(127263, user.getLanguage()), releaseRule == 1));
optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(127262, user.getLanguage()), releaseRule == 2));
searchConditionItem.setOptions(optionsList);
if (hrmFieldBean.getViewAttr() == 1) {
Map<String, Object> OtherParamsMap = new HashMap<String, Object>();
OtherParamsMap.put("hasBorder", true);
searchConditionItem.setOtherParams(OtherParamsMap);
}
searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(510129, user.getLanguage()));
itemList.add(searchConditionItem);
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname("excludeSubAccount");//次账号发放假期余额
hrmFieldBean.setFieldlabel("510174");
hrmFieldBean.setFieldhtmltype("4");
hrmFieldBean.setType("1");
hrmFieldBean.setFieldvalue(excludeSubAccount);
hrmFieldBean.setIsFormField(true);
hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 2);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
otherParamsMap = new HashMap<String, Object>();
otherParamsMap.put("display", "switch");
searchConditionItem.setOtherParams(otherParamsMap);
if (hrmFieldBean.getViewAttr() == 1) {
Map<String, Object> OtherParamsMap = new HashMap<String, Object>();
OtherParamsMap.put("hasBorder", true);
searchConditionItem.setOtherParams(OtherParamsMap);
}
itemList.add(searchConditionItem);
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname("beforeFormal");//转正之前发放假期余额
hrmFieldBean.setFieldlabel("510175");
hrmFieldBean.setFieldhtmltype("4");
hrmFieldBean.setType("1");
hrmFieldBean.setFieldvalue(beforeFormal);
hrmFieldBean.setIsFormField(true);
hrmFieldBean.setViewAttr(isEnable == 0 ? 1 : 2);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
otherParamsMap = new HashMap<String, Object>();
otherParamsMap.put("display", "switch");
searchConditionItem.setOtherParams(otherParamsMap);
if (hrmFieldBean.getViewAttr() == 1) {
Map<String, Object> OtherParamsMap = new HashMap<String, Object>();
OtherParamsMap.put("hasBorder", true);
searchConditionItem.setOtherParams(OtherParamsMap);
}
itemList.add(searchConditionItem);
groupItem.put("items", itemList);
groupList.add(groupItem);
resultMap.put("condition", groupList);
resultMap.put("isEnable", "" + isEnable);
if (isEdit) {
minimumUnit = Util.getIntValue(rulesComInfo.getMinimumUnit(ruleId), 1);
String unitName = "";//单位名称,天/小时
if (minimumUnit == 1 || minimumUnit == 2 || minimumUnit == 4) {
unitName = SystemEnv.getHtmlLabelName(1925, user.getLanguage());//天
} else {
unitName = SystemEnv.getHtmlLabelName(391, user.getLanguage());//小时
}
resultMap.put("unitName", unitName);
}
} catch (Exception e) {
e.printStackTrace();
}
return resultMap;
}
}

@ -0,0 +1,86 @@
package com.engine.kq.cmd.leaverules;
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 weaver.general.PageIdConst;
import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import weaver.hrm.moduledetach.ManageDetachComInfo;
import weaver.systeminfo.SystemEnv;
import weaver.systeminfo.systemright.CheckSubCompanyRight;
import java.util.HashMap;
import java.util.Map;
/**
* --
*/
public class GetSearchListCmd extends AbstractCommonCommand<Map<String, Object>> {
public GetSearchListCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
}
@Override
public BizLogContext getLogContext() {
return null;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> resultMap = new HashMap<String, Object>();
String ruleName = Util.null2String(params.get("ruleName"));//假期规则名称
String typeId = Util.null2String(params.get("typeId"));//假期类型的ID
boolean canEdit = HrmUserVarify.checkUserRight("KQLeaveRulesEdit:Edit", user);//是否具有编辑权限
boolean canDelete = HrmUserVarify.checkUserRight("KQLeaveRulesDelete:Delete", user);//是否具有删除权限
boolean canLog = HrmUserVarify.checkUserRight("KQLeaveRules:Log", user);//是否具有查看日志的权限
/*如果没有权限*/
if (!canEdit) {
resultMap.put("status", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage()));
return resultMap;
}
String backFields = " * ";
String sqlFrom = " from kq_LeaveRulesDetail ";
String sqlWhere = " where (isDelete is null or isDelete!=1) ";
String orderBy = " id ";
if (!ruleName.equals("")) {
sqlWhere += " and ruleName like '%" + ruleName + "%'";
}
if(!typeId.equals("")){
sqlWhere += " and ruleId="+typeId;
}
String pageUid = "b0c005a2-447f-0977-b692-6d8de7ead576";
String operateString = "";
operateString = "<operates width=\"20%\">";
operateString += "<popedom transmethod=\"weaver.hrm.common.SplitPageTagOperate.getBasicOperate\" otherpara=\"" + canEdit + ":" + canDelete + ":" + canLog + "\"></popedom> ";
operateString += " <operate href=\"javascript:openDialog();\" text=\"" + SystemEnv.getHtmlLabelName(93, user.getLanguage()) + "\" index=\"0\"/>";
operateString += " <operate href=\"javascript:doDel()\" text=\"" + SystemEnv.getHtmlLabelName(91, user.getLanguage()) + "\" index=\"1\"/>";
operateString += " <operate href=\"javascript:onLog()\" text=\"" + SystemEnv.getHtmlLabelName(83, user.getLanguage()) + "\" index=\"2\"/>";
operateString += "</operates>";
String tableString = "" +
"<table pageId=\"KQ:LeaveRulesDetailList\" pageUid=\"" + pageUid + "\" tabletype=\"checkbox\" pagesize=\"" + PageIdConst.getPageSize("Kq:LeaveRulesDetailList", user.getUID(), PageIdConst.HRM) + "\" >" +
"<sql backfields=\"" + backFields + "\" sqlform=\"" + sqlFrom + "\" sqlwhere=\"" + Util.toHtmlForSplitPage(sqlWhere) + "\" sqlorderby=\"" + orderBy + "\" sqlprimarykey=\"id\" sqlsortway=\"asc\" sqlisdistinct=\"false\"/>"
+ operateString +
" <head>" +
" <col width=\"20%\" text=\"" + SystemEnv.getHtmlLabelName(19829, user.getLanguage()) + "\" column=\"ruleName\" otherpara=\"" + user.getLanguage() + "\" transmethod=\"weaver.general.Util.formatMultiLang\" />" +
" <col width=\"20%\" text=\"" + SystemEnv.getHtmlLabelName(129811, user.getLanguage()) + "\" column=\"ruleId\" otherpara=\"" + user.getLanguage() + "\" transmethod=\"com.engine.kq.util.KQTransMethod.getLeaveTypesName\"/>" +
" <col width=\"20%\" text=\"" + SystemEnv.getHtmlLabelName(388946, user.getLanguage()) + "\" column=\"distributionMode\" otherpara=\"" + user.getLanguage() + "\" transmethod=\"com.engine.kq.util.KQTransMethod.getDistributionModName\"/>" +
" <col width=\"20%\" text=\"" + SystemEnv.getHtmlLabelName(388952, user.getLanguage()) + "\" column=\"validityRule\" otherpara=\"" + user.getLanguage() + "\" transmethod=\"com.engine.kq.util.KQTransMethod.getValidityRuleShow\"/>" +
" <col width=\"20%\" text=\"" + SystemEnv.getHtmlLabelName(389093, user.getLanguage()) + "\" column=\"releaseRule\" otherpara=\"" + user.getLanguage() + "\" transmethod=\"com.engine.kq.util.KQTransMethod.getReleaseRuleName\"/>" +
" <col width=\"10%\" text=\"" + SystemEnv.getHtmlLabelName(19374, user.getLanguage()) + "\" column=\"scopeType\" otherpara=\"" + user.getLanguage() + "\" transmethod=\"com.engine.kq.util.KQTransMethod.getScopeTypeName\"/>" +
" </head>" +
"</table>";
String sessionKey = pageUid + "_" + Util.getEncrypt(Util.getRandom());
Util_TableMap.setVal(sessionKey, tableString);
resultMap.put("sessionkey", sessionKey);
return resultMap;
}
}

@ -0,0 +1,991 @@
package com.engine.kq.cmd.myattendance;
import com.api.hrm.bean.KQReportType;
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.entity.WorkTimeEntity;
import com.engine.kq.enums.KqSplitFlowTypeEnum;
import com.engine.kq.wfset.util.KQSignUtil;
import com.engine.kq.wfset.util.SplitActionUtil;
import com.engine.kq.wfset.util.SplitSelectSet;
import org.apache.commons.lang3.StringUtils;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import weaver.hrm.resource.ResourceComInfo;
import weaver.systeminfo.SystemEnv;
import java.util.*;
/**
* ----
*/
public class GetHrmKQMonthReportInfoCmd extends AbstractCommonCommand<Map<String, Object>> {
public GetHrmKQMonthReportInfoCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
}
private static boolean isIndirectSuperId(String id,String checkSuperId,ResourceComInfo info){
int loopBreakTimes = 20 ;
for(String loopId = id;
isRightResourceId(loopId) && (loopBreakTimes--)>0 ;
loopId = info.getManagerID(loopId)){
if(isDirectSuperId(loopId,checkSuperId,info)) return true ;
}
return false ;
}
private static boolean isDirectSuperId(String id,String checkSuperId,ResourceComInfo info){
String superId = Util.null2String(info.getManagerID(id)) ;
return isRightResourceId(superId) && superId.equals(checkSuperId) ;
}
private static boolean isRightResourceId(String id){
return StringUtils.isNotBlank(id) && !"0".equals(id) ;
}
@Override
public BizLogContext getLogContext() {
return null;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> resultMap = new HashMap<String, Object>();
try {
String nowdate = DateUtil.getCurrentDate();
String type = Util.null2String(params.get("type"));//是查看一年的数据还是一月的数据1-年、2-月
String typevalue = Util.null2String(params.get("typevalue"));//指定的年份或者指定的月份
String fromDate = Util.null2String(params.get("fromDate"));//指定日期起点
String toDate = Util.null2String(params.get("toDate"));//指定日期终点
int subCompanyId = Util.getIntValue((String) params.get("subCompanyId"), 0);//指定查看的人员的所属分部
int departmentId = Util.getIntValue((String) params.get("departmentId"), 0);//指定查看的人员的所属部门
String resourceId = Util.null2String(params.get("resourceId"));//指定查看的人员ID
String status = Util.null2String(params.get("status"));//?
/**
*
*/
if (resourceId.length() == 0) {
resourceId = "" + user.getUID();
}
ResourceComInfo resourceComInfo = new ResourceComInfo();
if (subCompanyId == 0 || departmentId == 0) {
subCompanyId = Util.getIntValue(resourceComInfo.getSubCompanyID(resourceId), 0);
departmentId = Util.getIntValue(resourceComInfo.getDepartmentID(resourceId), 0);
}
String lastName = resourceComInfo.getResourcename(resourceId);
if (resourceId.equals("" + user.getUID())) {
resultMap.put("title", SystemEnv.getHtmlLabelName(513535, user.getLanguage()));
} else {
resultMap.put("title", SystemEnv.getHtmlLabelName(515563, user.getLanguage()).replace("{name}", lastName));
}
/**
*
*/
if (!resourceId.equals("" + user.getUID()) && !isIndirectSuperId(resourceId, user.getUID() + "", resourceComInfo) && !HrmUserVarify.checkUserRight("HrmResource:Absense", user, departmentId)) {
resultMap.put("status", "-1");
resultMap.put("hasRight", false);
return resultMap;
}
/**
*
*/
if (type.equals("1")) {//年
if (typevalue.length() == 0 || typevalue.length() != 4) {
typevalue = DateUtil.getYear();
}
fromDate = typevalue + "-01-01";
toDate = DateUtil.getLastDayOfYear(DateUtil.parseToDate(fromDate));
} else if (type.equals("2")) {//月
if (typevalue.length() == 0) {
typevalue = DateUtil.getYear() + "-" + DateUtil.getMonth();
}
fromDate = typevalue + "-01";
toDate = DateUtil.getLastDayOfMonthToString(DateUtil.parseToDate(fromDate));
}
/**获取今天的日期*/
Calendar today = Calendar.getInstance();
String currentdate = Util.add0(today.get(Calendar.YEAR), 4) + "-"
+ Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-"
+ Util.add0(today.get(Calendar.DAY_OF_MONTH), 2);
/**判断是否在考勤日历上显示签到签退数据*/
boolean showSign = true;
String settingSql = "select * from KQ_SETTINGS where main_key='showSignOnCalendar'";
RecordSet rs = new RecordSet();
rs.executeQuery(settingSql);
if (rs.next()) {
String main_val = rs.getString("main_val");
showSign = main_val.equals("1");
}
//签到签退明细
Map<String,Object> signInfoMap = getSignInfo();
List<Map<String, Object>> signInfoList = new ArrayList<Map<String, Object>>();
//休息明细(统计工作日)
List<String> isNotRestList = new ArrayList<String>();
//迟到明细
List<String> beLateList = new ArrayList<String>();
//早退明细
List<String> leaveEarlyList = new ArrayList<String>();
//旷工明细
List<String> absentList = new ArrayList<String>();
//漏签明细
List<String> noSignList = new ArrayList<String>();
//请假明细
Map<String, Object> leaveMap = getFlowData(KqSplitFlowTypeEnum.LEAVE.getFlowtype());
//出差明细
Map<String, Object> evectionMap = getFlowData(KqSplitFlowTypeEnum.EVECTION.getFlowtype());
//公出明细
Map<String, Object> outDaysMap = getFlowData(KqSplitFlowTypeEnum.OUT.getFlowtype());
//加班明细
Map<String, Object> overtimeMap = getFlowData(KqSplitFlowTypeEnum.OVERTIME.getFlowtype());
//调配工作日
List<String> workdayList = new ArrayList<String>();
//调配休息日、公众假日
List<String> holidayList = new ArrayList<String>();
//获取节假日
List<Map<String, Object>> tempList = KQHolidaySetBiz.getHolidaySetListByScope(resourceId, fromDate, toDate);
for (Map<String, Object> tempMap : tempList) {
String date = Util.null2String(tempMap.get("date"));
int changeType = Util.getIntValue((String) tempMap.get("type"), 1);
if (changeType == 1 || changeType == 3) {
holidayList.add(date);
} else if (changeType == 2) {
workdayList.add(date);
}
}
String sql = "select * from kq_format_detail where resourceId=" + resourceId + " and KQDate>='" + fromDate + "' and KQDate<='" + toDate + "' order by kqDate";
RecordSet recordSet = new RecordSet();
RecordSet detailRs = new RecordSet();
recordSet.executeQuery(sql);
KQWorkTime kqWorkTime = new KQWorkTime();
while (recordSet.next()) {
String kqDate = recordSet.getString("kqDate");
String serialId = recordSet.getString("serialId");
WorkTimeEntity workTime = kqWorkTime.getWorkTime(resourceId,kqDate);
if (!isNotRestList.contains(kqDate) && !serialId.equals("")) {
isNotRestList.add(kqDate);
}else if(Util.null2String(workTime.getKQType()).equals("3")){
if(workTime!=null&&Util.getIntValue(workTime.getWorkMins())>0) {
isNotRestList.add(kqDate);
// groupid = Util.null2String(workTime.getGroupId());
// signstart = Util.null2String(workTime.getSignStart());//签到开始时间
// workMins = Util.getIntValue(Util.null2String(workTime.getWorkMins()));//工作时长
}
}
int beLate = recordSet.getInt("beLateMins");//迟到
int graveBeLate = recordSet.getInt("graveBeLateMins");//严重迟到
int leaveEarly = recordSet.getInt("leaveEarlyMins");//早退
int graveLeaveEarly = recordSet.getInt("graveLeaveEarlyMins");//严重早退
int absenteeism = recordSet.getInt("absenteeismMins");//旷工
int forgotCheck = recordSet.getInt("forgotCheckMins");//下班打卡漏签
int forgotBeginWorkCheckMins = recordSet.getInt("forgotBeginWorkCheckMins");//上班打卡漏签
if (absenteeism > 0) {//旷工
absentList.add(kqDate);
} else {
if (beLate > 0 || graveBeLate > 0) { //迟到
beLateList.add(kqDate);
}
if (leaveEarly > 0 || graveLeaveEarly > 0) {//早退
leaveEarlyList.add(kqDate);
}
if (forgotCheck > 0 || forgotBeginWorkCheckMins > 0) {//漏签
noSignList.add(kqDate);
}
}
}
Map<String, Object> year = new HashMap<String, Object>();
Map<String, Object> month = new HashMap<String, Object>();
Map<String, Object> day = new HashMap<String, Object>();
List<Object> types = new ArrayList<Object>();
List<Map<String, Object>> lsWorkflow = new ArrayList<Map<String, Object>>();
Map<String, Object> workflow = new HashMap<String, Object>();
boolean isEnd = false;
for (String date = fromDate; !isEnd; ) {
String tmpMonth = "" + Util.getIntValue(date.split("-")[1]);
String tmpDay = "" + Util.getIntValue(date.split("-")[2]);
if (date.compareTo(toDate) >= 0) {
isEnd = true;
}
/*如果是按年份查看*/
if (type.equals("1")) {
if (!year.containsKey(tmpMonth)) {
month = new HashMap<String, Object>();
year.put(tmpMonth, month);
}
}
day = new HashMap<String, Object>();
month.put(tmpDay, day);
if (isNotRestList.contains(date)) {
day.put("isWorkDay", true);
} else {
day.put("isWorkDay", false);
}
if (type.equals("1")) {
day.put("tip", "");
}
if (holidayList.contains(date)) {
day.put("tip", SystemEnv.getHtmlLabelName(125806, user.getLanguage()));
day.put("isWorkDay", false);
} else if (workdayList.contains(date)) {
day.put("tip", SystemEnv.getHtmlLabelName(125807, user.getLanguage()));
day.put("isWorkDay", true);
}
day.put("date", date);
types = new ArrayList<Object>();
if (type.equals("2")) {
day.put("types", types);
}
lsWorkflow = new ArrayList<Map<String, Object>>();
/*只有月视图才显示流程数据、只有月视图才把签到签退信息显示在日历上*/
if (type.equals("2") && showSign) {
signInfoList = (List)signInfoMap.get(date);
if (signInfoList != null && signInfoList.size() > 0) {
day.put("signInfo", signInfoList);
}
}
/*只有月视图才显示流程数据*/
if (type.equals("2")) {
day.put("workflow", lsWorkflow);
}
boolean isNormal = true;
//迟到明细
if (beLateList.contains(date)) {
if (!types.contains(KQReportType.BELATE)) {
types.add(KQReportType.BELATE);
isNormal = false;
}
}
//旷工明细
if (absentList.contains(date)) {
if (!types.contains(KQReportType.ABSENT)) {
types.add(KQReportType.ABSENT);
isNormal = false;
}
}
//早退明细
if (leaveEarlyList.contains(date)) {
if (!types.contains(KQReportType.LEAVEEARLY)) {
types.add(KQReportType.LEAVEEARLY);
isNormal = false;
}
}
//漏签明细
if (noSignList.contains(date)) {
if (!types.contains(KQReportType.NOSIGN)) {
types.add(KQReportType.NOSIGN);
isNormal = false;
}
}
//请假明细
if (leaveMap.containsKey(resourceId + "|" + date)) {
if (!types.contains(KQReportType.LEAVE)) {
types.add(KQReportType.LEAVE);
isNormal = false;
}
tempList = (List<Map<String, Object>>) leaveMap.get(resourceId + "|" + date);
for (Map<String, Object> tempMap : tempList) {
lsWorkflow.add(tempMap);
}
}
//加班明细
if (!Util.null2String(overtimeMap.get(resourceId + "|" + date)).equals("")) {
if (!types.contains(KQReportType.OVERTIME)) {
types.add(KQReportType.OVERTIME);
}
tempList = (List<Map<String, Object>>) overtimeMap.get(resourceId + "|" + date);
for (Map<String, Object> tempMap : tempList) {
lsWorkflow.add(tempMap);
}
}
//外出明细
if (evectionMap.containsKey(resourceId + "|" + date)) {
if (!types.contains(KQReportType.EVECTION)) {
types.add(KQReportType.EVECTION);
isNormal = false;
}
tempList = (List<Map<String, Object>>) evectionMap.get(resourceId + "|" + date);
for (Map<String, Object> tempMap : tempList) {
lsWorkflow.add(tempMap);
}
}
//公出明细
if (outDaysMap.containsKey(resourceId + "|" + date)) {
if (!types.contains(KQReportType.OUTDAYS)) {
types.add(KQReportType.OUTDAYS);
isNormal = false;
}
tempList = (List<Map<String, Object>>) outDaysMap.get(resourceId + "|" + date);
for (Map<String, Object> tempMap : tempList) {
lsWorkflow.add(tempMap);
}
}
if (isNotRestList.contains(date) && DateUtil.isInDateRange(date, fromDate, nowdate)) {
if (isNormal) {
types.add(KQReportType.NORMAL);
}
}
if (type.equals("1")) {
day.put("type", types.size() > 0 ? types.get(0) : "NORMAL");
}
date = DateUtil.getDate(date, 1);
}
if (type.equals("1")) {
resultMap.put("result", year);
} else {
resultMap.put("result", month);
}
resultMap.put("status", "1");
} catch (Exception e) {
resultMap.put("api_status", false);
resultMap.put("api_errormsg", e.getMessage());
writeLog(e);
}
return resultMap;
}
/**
*
*
* @return
*/
public Map<String, Object> getFlowData(int flowType) {
Map<String, Object> resultMap = new HashMap<String, Object>();
try {
String nowdate = DateUtil.getCurrentDate();
String type = Util.null2String(params.get("type"));//是查看一年的数据还是一月的数据1-年、2-月
String typevalue = Util.null2String(params.get("typevalue"));//指定的年份或者指定的月份
String fromDate = Util.null2String(params.get("fromDate"));//指定日期起点
String toDate = Util.null2String(params.get("toDate"));//指定日期终点
int subCompanyId = Util.getIntValue((String) params.get("subCompanyId"), 0);//指定查看的人员的所属分部
int departmentId = Util.getIntValue((String) params.get("departmentId"), 0);//指定查看的人员的所属部门
String resourceId = Util.null2String(params.get("resourceId"));//指定查看的人员ID
String status = Util.null2String(params.get("status"));//?
/**
*
*/
if (resourceId.length() == 0) {
resourceId = "" + user.getUID();
}
/**
*
*/
if (type.equals("1")) {//年
if (typevalue.length() == 0 || typevalue.length() != 4) {
typevalue = DateUtil.getYear();
}
fromDate = typevalue + "-01-01";
toDate = DateUtil.getLastDayOfYear(DateUtil.parseToDate(fromDate));
} else if (type.equals("2")) {//月
if (typevalue.length() == 0) {
typevalue = DateUtil.getYear() + "-" + DateUtil.getMonth();
}
fromDate = typevalue + "-01";
toDate = DateUtil.getLastDayOfMonthToString(DateUtil.parseToDate(fromDate));
}
/**获取销假*/
List<String> leaveBackList = getLeaveDate();
KQExitRulesComInfo exitRulesComInfo = new KQExitRulesComInfo();
KQTravelRulesComInfo travelRulesComInfo = new KQTravelRulesComInfo();
KQLeaveRulesComInfo rulesComInfo = new KQLeaveRulesComInfo();
KQTimeSelectionComInfo kqTimeSelectionComInfo = new KQTimeSelectionComInfo();
KQWorkTime kqWorkTime = new KQWorkTime();
boolean showOnHoliday = true;//非工作日是否显示流程(出差、公出、请假)
String timeselection = "1";
String selectiontype = "";
String typeName = "";
KQReportType workflowType = null;
switch (flowType) {
case 3://加班
typeName = SystemEnv.getHtmlLabelName(6151, user.getLanguage());
workflowType = KQReportType.OVERTIME;
selectiontype = ""+KqSplitFlowTypeEnum.OVERTIME.getFlowtype();
timeselection = KQOvertimeRulesBiz.getTimeselection();
break;
case 2://公出
typeName = SystemEnv.getHtmlLabelName(24058, user.getLanguage());
workflowType = KQReportType.OUTDAYS;
showOnHoliday = exitRulesComInfo.getComputingMode("1").equals("2");
selectiontype = ""+KqSplitFlowTypeEnum.OUT.getFlowtype();
timeselection = KQExitRulesBiz.getTimeselection();
break;
case 1://出差
typeName = SystemEnv.getHtmlLabelName(20084, user.getLanguage());
workflowType = KQReportType.EVECTION;
showOnHoliday = travelRulesComInfo.getComputingMode("1").equals("2");
selectiontype = ""+KqSplitFlowTypeEnum.EVECTION.getFlowtype();
timeselection = KQTravelRulesBiz.getTimeselection();
break;
case 0://请假
typeName = SystemEnv.getHtmlLabelName(670, user.getLanguage());
workflowType = KQReportType.LEAVE;
selectiontype = ""+KqSplitFlowTypeEnum.LEAVE.getFlowtype();
break;
default:
break;
}
/**
*
*/
List<Map<String, Object>> workflowList = new ArrayList<Map<String, Object>>();
Map<String, Object> workflowMap = new HashMap<String, Object>();
Map<String, Object> paramsMap = new HashMap<String, Object>();
paramsMap.put("typeselect", "6");
paramsMap.put("tabKey", "1");
paramsMap.put("kqtype", "" + flowType);
paramsMap.put("resourceId", resourceId);
paramsMap.put("fromDate", fromDate);
paramsMap.put("toDate", toDate);
paramsMap.put("isMyKQ", "1");
paramsMap.put("isNoAccount","1");
KQAttFlowSetBiz kqAttFlowSetBiz = new KQAttFlowSetBiz();
Map<String, String> sqlMap = kqAttFlowSetBiz.getFLowSql(paramsMap, user);
String sqlFrom = sqlMap.get("from");
String sqlWhere = sqlMap.get("where");
String sql = "select * " + sqlFrom + sqlWhere;
RecordSet recordSet = new RecordSet();
recordSet.executeQuery(sql);
while (recordSet.next()) {
String requestId = recordSet.getString("requestId");
double duration = Util.getDoubleValue(recordSet.getString("duration"), 0.00);
double backDuration = 0.00;
int durationrule = recordSet.getInt("durationrule");
String fromDateTemp = recordSet.getString("fromDate");
String fromTimeTemp = recordSet.getString("fromTime");
String toDateTemp = recordSet.getString("toDate");
String toTimeTemp = recordSet.getString("toTime");
String leaveRulesId = "";
String filterholidays = "";
String count = String.format("%.2f", duration) + "(" + ((durationrule == 3||durationrule == 5||durationrule == 6) ? SystemEnv.getHtmlLabelName(391, user.getLanguage()) : SystemEnv.getHtmlLabelName(1925, user.getLanguage())) + ")";
if(flowType == 3){
count = String.format("%.2f", duration) + "(" + ((durationrule == 3||durationrule == 5||durationrule == 6) ? SystemEnv.getHtmlLabelName(391, user.getLanguage()) : SystemEnv.getHtmlLabelName(1925, user.getLanguage())) + ")";
}
if (flowType == 0) {
backDuration = Util.getDoubleValue(recordSet.getString("backDuraion"), 0.00);
if (backDuration > 0) {
count = String.format("%.2f", duration) + "(" + (SystemEnv.getHtmlLabelName(24473, user.getLanguage()) + ":" + String.format("%.2f", backDuration)) + ")" + ((durationrule == 3||durationrule == 5||durationrule == 6) ? SystemEnv.getHtmlLabelName(391, user.getLanguage()) : SystemEnv.getHtmlLabelName(1925, user.getLanguage()));
}
leaveRulesId = recordSet.getString("newleavetype");
String computingMode = rulesComInfo.getComputingMode(leaveRulesId);
if("2".equalsIgnoreCase(computingMode)){
//按照自然日计算
showOnHoliday = true;
filterholidays= rulesComInfo.getFilterHolidays(leaveRulesId);
} else {
showOnHoliday = false;
}
typeName = Util.formatMultiLang(rulesComInfo.getLeaveName(leaveRulesId), "" + user.getLanguage());
}
String start = fromDateTemp + " " + fromTimeTemp;
String end = toDateTemp + " " + toTimeTemp;
if (2 == durationrule || 4 == durationrule) {
if (2 == durationrule) {
if(leaveRulesId.length() > 0){
timeselection = rulesComInfo.getTimeSelection(leaveRulesId);
}
if("1".equalsIgnoreCase(timeselection)){
Map<String,String> half_map = kqTimeSelectionComInfo.getTimeselections(selectiontype,leaveRulesId,durationrule+"");
String cus_am = SystemEnv.getHtmlLabelName(16689, user.getLanguage());
String cus_pm = SystemEnv.getHtmlLabelName(16690, user.getLanguage());
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 (fromTimeTemp.equalsIgnoreCase(SplitSelectSet.forenoon_start)) {
start = fromDateTemp + " " + cus_am;
} else if (fromTimeTemp.equalsIgnoreCase(SplitSelectSet.forenoon_end)) {
start = fromDateTemp + " " + cus_pm;
}
if (toTimeTemp.equalsIgnoreCase(SplitSelectSet.afternoon_start)) {
end = toDateTemp + " " + cus_am;
} else if (toTimeTemp.equalsIgnoreCase(SplitSelectSet.afternoon_end)) {
end = toDateTemp + " " + cus_pm;
}
}
}
if (4 == durationrule) {
if (fromTimeTemp.equalsIgnoreCase(SplitSelectSet.forenoon_start)) {
start = fromDateTemp + " " + SystemEnv.getHtmlLabelName(390728, user.getLanguage());
}
if (toTimeTemp.equalsIgnoreCase(SplitSelectSet.afternoon_end)) {
end = toDateTemp + " " + SystemEnv.getHtmlLabelName(390728, user.getLanguage());
}
}
}
boolean isEnd = false;
for (String date = fromDateTemp; !isEnd; ) {
if (date.equals(toDateTemp)) {
isEnd = true;
}
boolean isWorkDay = kqWorkTime.isWorkDay(resourceId, date);
if(!isWorkDay && !showOnHoliday) {
date = DateUtil.getDate(date, 1);
continue;
}
if (!leaveBackList.contains(resourceId + "|" + date + "|" + requestId)) {
workflowList = (ArrayList<Map<String, Object>>) resultMap.get(resourceId + "|" + date);
if (null == workflowList) {
workflowList = new ArrayList<Map<String, Object>>();
}
workflowMap = new HashMap<String, Object>();
workflowMap.put("count", count);
workflowMap.put("start", start);
workflowMap.put("end", end);
workflowMap.put("type", typeName);
workflowMap.put("workflowtype", workflowType);
workflowMap.put("requestId", requestId);
workflowMap.put("title", "<a href=javaScript:openFullWindowHaveBarForWFList('/workflow/request/ViewRequestForwardSPA.jsp?requestid=" + requestId + "&ismonitor=1&isovertime=0'," + requestId + ");>" + typeName + "</a>");
workflowList.add(workflowMap);
if (!(!isWorkDay && !showOnHoliday)) {
SplitActionUtil splitActionUtil = new SplitActionUtil();
boolean is_filterholidays = splitActionUtil.check_filterholidays(filterholidays, resourceId, date, 1);
if(!is_filterholidays){
resultMap.put(resourceId + "|" + date, workflowList);
}
}
}
date = DateUtil.getDate(date, 1);
}
}
} catch (Exception e) {
writeLog(e);
}
return resultMap;
}
/**
*
*
* @return
*/
private List<String> getLeaveDate() {
List<String> resultList = new ArrayList<String>();
try {
String nowdate = DateUtil.getCurrentDate();
String type = Util.null2String(params.get("type"));//是查看一年的数据还是一月的数据1-年、2-月
String typevalue = Util.null2String(params.get("typevalue"));//指定的年份或者指定的月份
String fromDate = Util.null2String(params.get("fromDate"));//指定日期起点
String toDate = Util.null2String(params.get("toDate"));//指定日期终点
int subCompanyId = Util.getIntValue((String) params.get("subCompanyId"), 0);//指定查看的人员的所属分部
int departmentId = Util.getIntValue((String) params.get("departmentId"), 0);//指定查看的人员的所属部门
String resourceId = Util.null2String(params.get("resourceId"));//指定查看的人员ID
String status = Util.null2String(params.get("status"));//?
/**
*
*/
if (resourceId.length() == 0) {
resourceId = "" + user.getUID();
}
/**
*
*/
if (type.equals("1")) {//年
if (typevalue.length() == 0 || typevalue.length() != 4) {
typevalue = DateUtil.getYear();
}
fromDate = typevalue + "-01-01";
toDate = DateUtil.getLastDayOfYear(DateUtil.parseToDate(fromDate));
} else if (type.equals("2")) {//月
if (typevalue.length() == 0) {
typevalue = DateUtil.getYear() + "-" + DateUtil.getMonth();
}
fromDate = typevalue + "-01";
toDate = DateUtil.getLastDayOfMonthToString(DateUtil.parseToDate(fromDate));
}
String leaveBackTableName = KqSplitFlowTypeEnum.LEAVEBACK.getTablename();
String leaveTableName = KqSplitFlowTypeEnum.LEAVE.getTablename();
String sql = " select requestId,resourceId,belongDate,duration,durationRule," +
" (select sum(duration) from " + leaveBackTableName + " where " + leaveBackTableName + ".leavebackrequestid=" + leaveTableName + ".requestid " +
" and " + leaveBackTableName + ".newleavetype=" + leaveTableName + ".newleavetype " +
" and " + leaveBackTableName + ".belongdate=" + leaveTableName + ".belongDate ) as backDuration " +
" from " + leaveTableName + " where 1=1 ";
if (!resourceId.equals("")) {
sql += " and " + leaveTableName + ".resourceId=" + resourceId;
}
if (fromDate.length() > 0 && toDate.length() > 0) {
sql += " and " + leaveTableName + ".belongdate between'" + fromDate + "' and '" + toDate + "' ";
}
RecordSet recordSet = new RecordSet();
recordSet.executeQuery(sql);
while (recordSet.next()) {
String requestId = recordSet.getString("requestId");
String belongDate = recordSet.getString("belongDate");
double duration = Util.getDoubleValue(recordSet.getString("duration"), 0.00);
if (duration <= 0) {
continue;
}
double backDuration = Util.getDoubleValue(recordSet.getString("backDuration"), 0.00);
if (backDuration >= duration) {
resultList.add(resourceId + "|" + belongDate + "|" + requestId);
}
}
} catch (Exception e) {
writeLog(e);
}
return resultList;
}
/**
* 退
*
* @return
*/
private Map<String, Object> getSignInfo() {
Map<String, Object> resultMap = new HashMap<String, Object>();
try {
String type = Util.null2String(params.get("type"));//是查看一年的数据还是一月的数据1-年、2-月
String typevalue = Util.null2String(params.get("typevalue"));//指定的年份或者指定的月份
String fromDate = Util.null2String(params.get("fromDate"));//指定日期起点
String toDate = Util.null2String(params.get("toDate"));//指定日期终点
String resourceId = Util.null2String(params.get("resourceId"));//指定查看的人员ID
/**
*
*/
if (resourceId.length() == 0) {
resourceId = "" + user.getUID();
}
/**
*
*/
if (type.equals("1")) {//年
if (typevalue.length() == 0 || typevalue.length() != 4) {
typevalue = DateUtil.getYear();
}
fromDate = typevalue + "-01-01";
toDate = DateUtil.getLastDayOfYear(DateUtil.parseToDate(fromDate));
} else if (type.equals("2")) {//月
if (typevalue.length() == 0) {
typevalue = DateUtil.getYear() + "-" + DateUtil.getMonth();
}
fromDate = typevalue + "-01";
toDate = DateUtil.getLastDayOfMonthToString(DateUtil.parseToDate(fromDate));
}
/**
*
*/
RecordSet recordSet = new RecordSet();
boolean showCard = false;
String settingSql = "select * from KQ_SETTINGS where main_key='showSignFromCard'";
recordSet.executeQuery(settingSql);
if (recordSet.next()) {
String main_val = recordSet.getString("main_val");
showCard = main_val.equals("1");
}
SignInfo signInfo = null;
Map<String, SignInfo> signInfoMap = new LinkedHashMap<String, SignInfo>();
String sql = "SELECT a.kqdate,a.resourceId,a.serialNumber,a.serialId,'signIn' signType,a.signInDate signDate,a.signInTime signTime,b.clientAddress,b.addr FROM KQ_FORMAT_DETAIL a LEFT JOIN HrmScheduleSign b ON a.signInId=b.id WHERE 1=1 AND resourceId=" + resourceId + "\n ";
if (!showCard) {
sql += " AND (signFrom is null or signFrom not like 'card%') ";
}
if (!"".equals(fromDate)) {
sql += " AND kqDate>='" + fromDate + "' ";
}
if (!"".equals(toDate)) {
sql += " AND kqDate<='" + toDate + "' ";
}
sql += " UNION ALL\n " +
"SELECT a.kqdate,a.resourceId,a.serialNumber,a.serialId,'signOut' signType,a.signOutDate signDate,a.signOutTime signTime,b.clientAddress,b.addr FROM KQ_FORMAT_DETAIL a LEFT JOIN HrmScheduleSign b ON a.signOutId=b.id WHERE 1=1 AND resourceId=" + resourceId + "\n ";
if (!showCard) {
sql += " AND (signFrom is null or signFrom not like 'card%') ";
}
if (!"".equals(fromDate)) {
sql += " AND kqDate>='" + fromDate + "' ";
}
if (!"".equals(toDate)) {
sql += " AND kqDate<='" + toDate + "' ";
}
sql += "ORDER BY kqDate,resourceId,serialNumber,signType ";
recordSet.executeQuery(sql);
while (recordSet.next()) {
String kqDate = Util.null2String(recordSet.getString("kqDate"));
String signType = Util.null2String(recordSet.getString("signType"));
String signDate = Util.null2String(recordSet.getString("signDate"));
String signTime = Util.null2String(recordSet.getString("signTime"));
String serialId = Util.null2String(recordSet.getString("serialId"));
int serialNumber = Util.getIntValue(recordSet.getString("serialNumber"), 0);
signInfo = signInfoMap.get(kqDate);
if (signInfo == null) {
signInfo = new SignInfo();
}
signInfo.setSerialId("" + serialId);
if ("signIn".equals(signType)) {
if (serialNumber == 2) {
signInfo.setNeedSign3(true);
signInfo.setSignInTime3(signTime);
} else if (serialNumber == 1) {
signInfo.setNeedSign2(true);
signInfo.setSignInTime2(signTime);
} else {
signInfo.setNeedSign1(true);
signInfo.setSignInTime1(signTime);
}
} else {
if (serialNumber == 2) {
signInfo.setNeedSign3(true);
signInfo.setSignOutTime3(signTime);
} else if (serialNumber == 1) {
signInfo.setNeedSign2(true);
signInfo.setSignOutTime2(signTime);
} else {
signInfo.setNeedSign1(true);
signInfo.setSignOutTime1(signTime);
}
}
signInfoMap.put(kqDate,signInfo);
}
Map<String, Object> itemMap = null;
List<Map<String, Object>> itemList = null;
for (Map.Entry entry : signInfoMap.entrySet()) {
String kqDate = (String) entry.getKey();
signInfo = (SignInfo) entry.getValue();
String serialId = Util.null2String(signInfo.getSerialId());
boolean needSign1 = signInfo.isNeedSign1();
String signInTime1 = Util.null2String(signInfo.getSignInTime1());
String signOutTime1 = Util.null2String(signInfo.getSignOutTime1());
boolean needSign2 = signInfo.isNeedSign2();
String signInTime2 = Util.null2String(signInfo.getSignInTime2());
String signOutTime2 = Util.null2String(signInfo.getSignOutTime2());
boolean needSign3 = signInfo.isNeedSign3();
String signInTime3 = Util.null2String(signInfo.getSignInTime3());
String signOutTime3 = Util.null2String(signInfo.getSignOutTime3());
itemList = new ArrayList<Map<String, Object>>();
if (serialId.equals("") || serialId.equals("0")) {
if (signInTime1.equals("") && signOutTime1.equals("")) {
continue;
} else {
itemMap = new HashMap<String, Object>();
itemMap.put("title", SystemEnv.getHtmlLabelName(512504, user.getLanguage()));
if (signInTime1.equals("")) {
itemMap.put("signTime", SystemEnv.getHtmlLabelName(25994, user.getLanguage()));
} else {
itemMap.put("signTime", signInTime1);
}
itemList.add(itemMap);
itemMap = new HashMap<String, Object>();
itemMap.put("title", SystemEnv.getHtmlLabelName(512505, user.getLanguage()));
if (signOutTime1.equals("")) {
itemMap.put("signTime", SystemEnv.getHtmlLabelName(25994, user.getLanguage()));
} else {
itemMap.put("signTime", signOutTime1);
}
itemList.add(itemMap);
resultMap.put(kqDate,itemList);
}
} else {
itemMap = new HashMap<String, Object>();
itemMap.put("title", SystemEnv.getHtmlLabelName(512504, user.getLanguage()));
if (signInTime1.equals("")) {
itemMap.put("signTime", SystemEnv.getHtmlLabelName(25994, user.getLanguage()));
} else {
itemMap.put("signTime", signInTime1);
}
itemList.add(itemMap);
itemMap = new HashMap<String, Object>();
itemMap.put("title", SystemEnv.getHtmlLabelName(512505, user.getLanguage()));
if (signOutTime1.equals("")) {
itemMap.put("signTime", SystemEnv.getHtmlLabelName(25994, user.getLanguage()));
} else {
itemMap.put("signTime", signOutTime1);
}
itemList.add(itemMap);
if (needSign2) {
itemMap = new HashMap<String, Object>();
itemMap.put("title", SystemEnv.getHtmlLabelName(512504, user.getLanguage()));
if (signInTime2.equals("")) {
itemMap.put("signTime", SystemEnv.getHtmlLabelName(25994, user.getLanguage()));
} else {
itemMap.put("signTime", signInTime2);
}
itemList.add(itemMap);
itemMap = new HashMap<String, Object>();
itemMap.put("title", SystemEnv.getHtmlLabelName(512505, user.getLanguage()));
if (signOutTime2.equals("")) {
itemMap.put("signTime", SystemEnv.getHtmlLabelName(25994, user.getLanguage()));
} else {
itemMap.put("signTime", signOutTime2);
}
itemList.add(itemMap);
}
if (needSign3) {
itemMap = new HashMap<String, Object>();
itemMap.put("title", SystemEnv.getHtmlLabelName(512504, user.getLanguage()));
if (signInTime3.equals("")) {
itemMap.put("signTime", SystemEnv.getHtmlLabelName(25994, user.getLanguage()));
} else {
itemMap.put("signTime", signInTime3);
}
itemList.add(itemMap);
itemMap = new HashMap<String, Object>();
itemMap.put("title", SystemEnv.getHtmlLabelName(512505, user.getLanguage()));
if (signOutTime3.equals("")) {
itemMap.put("signTime", SystemEnv.getHtmlLabelName(25994, user.getLanguage()));
} else {
itemMap.put("signTime", signOutTime3);
}
itemList.add(itemMap);
}
resultMap.put(kqDate,itemList);
}
}
} catch (Exception e) {
writeLog(e);
}
return resultMap;
}
class SignInfo {
private String serialId;
private boolean needSign1 = false;
private String signInTime1;
private String signOutTime1;
private boolean needSign2 = false;
private String signInTime2;
private String signOutTime2;
private boolean needSign3 = false;
private String signInTime3;
private String signOutTime3;
public SignInfo() {
}
public String getSerialId() {
return serialId;
}
public void setSerialId(String serialId) {
this.serialId = serialId;
}
public boolean isNeedSign1() {
return needSign1;
}
public void setNeedSign1(boolean needSign1) {
this.needSign1 = needSign1;
}
public String getSignInTime1() {
return signInTime1;
}
public void setSignInTime1(String signInTime1) {
this.signInTime1 = signInTime1;
}
public String getSignOutTime1() {
return signOutTime1;
}
public void setSignOutTime1(String signOutTime1) {
this.signOutTime1 = signOutTime1;
}
public boolean isNeedSign2() {
return needSign2;
}
public void setNeedSign2(boolean needSign2) {
this.needSign2 = needSign2;
}
public String getSignInTime2() {
return signInTime2;
}
public void setSignInTime2(String signInTime2) {
this.signInTime2 = signInTime2;
}
public String getSignOutTime2() {
return signOutTime2;
}
public void setSignOutTime2(String signOutTime2) {
this.signOutTime2 = signOutTime2;
}
public boolean isNeedSign3() {
return needSign3;
}
public void setNeedSign3(boolean needSign3) {
this.needSign3 = needSign3;
}
public String getSignInTime3() {
return signInTime3;
}
public void setSignInTime3(String signInTime3) {
this.signInTime3 = signInTime3;
}
public String getSignOutTime3() {
return signOutTime3;
}
public void setSignOutTime3(String signOutTime3) {
this.signOutTime3 = signOutTime3;
}
}
}

@ -0,0 +1,424 @@
package com.engine.kq.cmd.overtimerules;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.biz.SimpleBizLogger;
import com.engine.common.constant.BizLogSmallType4Hrm;
import com.engine.common.constant.BizLogType;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.kq.biz.KQOvertimeRulesBiz;
import com.engine.kq.log.KQLog;
import com.google.common.collect.Lists;
import java.util.Arrays;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import weaver.systeminfo.SystemEnv;
/**
* --
*/
public class AddOvertimeRulesCmd extends AbstractCommonCommand<Map<String, Object>> {
private SimpleBizLogger logger;
public AddOvertimeRulesCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
this.logger = new SimpleBizLogger();
String name = Util.null2String(params.get("name"));
BizLogContext bizLogContext = new BizLogContext();
bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型
bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_OVERTIMERULES);//所属大类型
bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_OVERTIMERULES);//当前小类型
bizLogContext.setParams(params);//当前request请求参数
logger.setUser(user);//当前操作人
String mainSql = "select * from kq_overtimeRules where name like '%" + name + "%'";
logger.setMainSql(mainSql, "id");//主表sql
logger.setMainPrimarykey("id");//主日志表唯一key
logger.setMainTargetNameColumn("name");
SimpleBizLogger.SubLogInfo subLogInfo = logger.getNewSubLogInfo();
String subSql = "select * from kq_overtimeRulesDetail where ruleId in (select id from kq_overtimeRules where name like '%" + name + "%') order by id";
subLogInfo.setSubSql(subSql, "id");
logger.addSubLogInfo(subLogInfo);
logger.before(bizLogContext);
}
@Override
public BizLogContext getLogContext() {
return null;
}
@Override
public List<BizLogContext> getLogContexts() {
return logger.getBizLogContexts();
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> resultMap = new HashMap<String, Object>();
try {
boolean canAdd = HrmUserVarify.checkUserRight("KQOvertimeRulesAdd:Add", user);//是否具有新建权限
if (!canAdd) {
resultMap.put("status", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage()));
return resultMap;
}
/*加班规则名称*/
String name = Util.null2String(params.get("name"));
/*考勤组的ID*/
String groupIds = Util.null2String(params.get("groupIds"));
/*工作日是否允许加班0-不允许、1-允许*/
int overtimeEnable2 = Util.getIntValue((String) params.get("overtimeEnable2"), 1);
/*工作日的加班方式1-需审批以审批单为准、2-需审批以打卡为准但是不能超过审批时长、3-无需审批,根据打卡时间计算加班时长*/
int computingMode2 = Util.getIntValue((String) params.get("computingMode2"), 1);
/*工作日下班多少分钟后开始计算加班*/
int startTime2 = Util.getIntValue((String) params.get("startTime2"), 30);
/*工作日最小加班时长*/
int minimumLen2 = Util.getIntValue((String) params.get("minimumLen2"), 30);
/*工作日是否允许加班转调休*/
int paidLeaveEnable2 = Util.getIntValue((String) params.get("paidLeaveEnable2"), 0);
/*工作日加班转调休比例中的加班时长*/
double lenOfOvertime2 = Util.getDoubleValue((String) params.get("lenOfOvertime2"), 30.0);
/*工作日加班转调休比例中的调休时长*/
double lenOfLeave2 = Util.getDoubleValue((String) params.get("lenOfLeave2"), 30.0);
/*休息日是否允许加班0-不允许、1-允许*/
int overtimeEnable3 = Util.getIntValue((String) params.get("overtimeEnable3"), 1);
/*休息日的加班方式1-需审批以审批单为准、2-需审批以打卡为准但是不能超过审批时长、3-无需审批,根据打卡时间计算加班时长*/
int computingMode3 = Util.getIntValue((String) params.get("computingMode3"), 1);
/*休息日的最小加班时长*/
int minimumLen3 = Util.getIntValue((String) params.get("minimumLen3"), 30);
/*休息日是否允许加班转调休*/
int paidLeaveEnable3 = Util.getIntValue((String) params.get("paidLeaveEnable3"), 0);
/*休息日加班转调休比例中的加班时长*/
double lenOfOvertime3 = Util.getDoubleValue((String) params.get("lenOfOvertime3"), 30.0);
/*休息日加班转调休比例中的调休时长*/
double lenOfLeave3 = Util.getDoubleValue((String) params.get("lenOfLeave3"), 30.0);
/*休息日是否有休息时间*/
int hasRestTime3 = Util.getIntValue((String) params.get("hasRestTime3"), 0);
/*节假日是否允许加班0-不允许、1-允许*/
int overtimeEnable1 = Util.getIntValue((String) params.get("overtimeEnable1"), 1);
/*节假日的加班方式1-需审批以审批单为准、2-需审批以打卡为准但是不能超过审批时长、3-无需审批,根据打卡时间计算加班时长*/
int computingMode1 = Util.getIntValue((String) params.get("computingMode1"), 1);
/*节假日的最小加班时长*/
int minimumLen1 = Util.getIntValue((String) params.get("minimumLen1"), 30);
/*节假日是否允许加班转调休*/
int paidLeaveEnable1 = Util.getIntValue((String) params.get("paidLeaveEnable1"), 0);
/*节假日加班转调休比例中的加班时长*/
double lenOfOvertime1 = Util.getDoubleValue((String) params.get("lenOfOvertime1"), 30.0);
/*假节日加班转调休比例中的调休时长*/
double lenOfLeave1 = Util.getDoubleValue((String) params.get("lenOfLeave1"), 30.0);
/*节假日是否有休息时间*/
int hasRestTime1 = Util.getIntValue((String) params.get("hasRestTime1"), 0);
if(computingMode2 == 4 || computingMode1 == 4 || computingMode3 == 4 ){
//如果是流程和打卡取交集的话,加班单位不能是下拉框半天或者整天
int minimumUnit = KQOvertimeRulesBiz.getMinimumUnit();
if(minimumUnit == 2 || minimumUnit == 4){
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(529168, user.getLanguage()));
return resultMap;
}
}
KQLog kqLog = new KQLog();
kqLog.info("AddOvertimeRulesCmd:params:"+params);
/*获取今天的日期*/
Calendar today = Calendar.getInstance();
String currentDate = Util.add0(today.get(Calendar.YEAR), 4) + "-"
+ Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-"
+ Util.add0(today.get(Calendar.DAY_OF_MONTH), 2);
String tomorrowDate = DateUtil.addDate(currentDate, 1);
//顺序显示2是工作日3是休息日1是节假日
int[] changetype = {2,3,1};
boolean flag = false;//是否保存成功
String sql = "insert into kq_OvertimeRules(name,groupIds,isDelete) values(?,?,0)";
RecordSet recordSet = new RecordSet();
RecordSet recordSet1 = new RecordSet();
flag = recordSet.executeUpdate(sql, name, groupIds);
if (!flag) {
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
int ruleId = 0;//刚刚插入的数据的ID
sql = "select max(id) maxId from kq_OvertimeRules";
recordSet.executeQuery(sql);
if (recordSet.next()) {
ruleId = recordSet.getInt("maxId");
}
List<String> rulesdetailidList = Lists.newArrayList();
String[] fields = new String[]{"overtimeEnable","computingMode","startTime","minimumLen",
"paidLeaveEnable","lenOfOvertime","lenOfLeave","hasRestTime","before_startTime",
"has_cut_point","cut_point","paidLeaveEnableType","paidLeaveEnableDefaultType",
"paidLeaveEnableFlowType","restTimeType"};
String str_fields = Arrays.asList(fields).stream().collect(Collectors.joining(","));
String split_str = Arrays.asList(fields).stream().map(s -> {return "?";}).collect(Collectors.joining(","));
for(int i = 0 ; i < changetype.length ; i++) {
int changetype_index = changetype[i];
sql = "insert into kq_OvertimeRulesDetail(ruleId,dayType,"+str_fields+") " +
"values(?,?,"+split_str+")";
String value_str = "";
int size = 2+fields.length;
Object[] objects = new Object[size];
objects[0] = ruleId;
objects[1] = changetype_index;
for(int j = 0 ; j < fields.length ;j++){
String _key = fields[j]+changetype_index;
String _value = Util.null2String(params.get(_key));
if("before_startTime".equalsIgnoreCase(fields[j])){
_value = Util.null2s(Util.null2String(params.get(_key)),"0");
}
if("startTime".equalsIgnoreCase(fields[j])){
_value = Util.null2s(Util.null2String(params.get(_key)),"0");
}
value_str += ","+_value;
objects[2+j] = _value;
}
if(value_str.length() > 0){
flag = recordSet.executeUpdate(sql, objects);
if(flag){
int rulesdetailid = 0;//刚刚插入的明细数据的ID
sql = "select max(id) maxId from kq_OvertimeRulesDetail";
recordSet.executeQuery(sql);
if (recordSet.next()) {
rulesdetailid = recordSet.getInt("maxId");
}
rulesdetailidList.add(rulesdetailid+"");
String hasRestTime_key = "hasRestTime"+changetype_index;
String hasRestTime_value = Util.null2String(params.get(hasRestTime_key));
if("1".equalsIgnoreCase(hasRestTime_value)){
List<String> restIds = Lists.newArrayList();
String restTimeType_key = "restTimeType"+changetype_index;
String restTimeType_value = Util.null2String(params.get(restTimeType_key));
String restTimeRule_key = "restTimeRule"+changetype_index;
String restTimeRule_value = Util.null2String(params.get(restTimeRule_key));
if(restTimeRule_value.length() > 0){
JSONArray jsonArray = JSONArray.parseArray(restTimeRule_value);
if("1".equalsIgnoreCase(restTimeType_value)){
for(int k = 0 ; k < jsonArray.size() ; k++){
JSONObject jsonObject = (JSONObject) jsonArray.get(k);
String startType = "0";
String endType = "0";
String startTime = Util.null2String(jsonObject.get("startTime"));
String endTime = Util.null2String(jsonObject.get("endTime"));
String restTimeSql = "insert into kq_OvertimeRestTime(ruleId,dayType,startType,startTime,endType,endTime) values(?,?,?,?,?,?)";
flag = recordSet.executeUpdate(restTimeSql, ruleId, changetype_index, startType, startTime, endType, endTime);
if (flag) {
int restId = 0;
String restSql = "select max(id) maxId from kq_OvertimeRestTime";
recordSet1.executeQuery(restSql);
if (recordSet1.next()) {
restId = recordSet1.getInt("maxId");
restIds.add(""+restId);
}
resultMap.put("sign", "1");
resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功
} else {
if(!rulesdetailidList.isEmpty()){
delFail(rulesdetailidList,restIds,ruleId);
}
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
}
}else if("2".equalsIgnoreCase(restTimeType_value)){
for(int k = 0 ; k < jsonArray.size() ; k++){
JSONObject jsonObject = (JSONObject) jsonArray.get(k);
String overtime = Util.null2String(jsonObject.get("overtime"));
String exclude = Util.null2String(jsonObject.get("exclude"));
String restTimeSql = "insert into kq_OvertimeRestlength(ruleId,dayType,overlength,cutlength,dsporder) values(?,?,?,?,?)";
flag = recordSet.executeUpdate(restTimeSql, ruleId, changetype_index, overtime, exclude, k);
if (flag) {
int restId = 0;
String restSql = "select max(id) maxId from kq_OvertimeRestlength";
recordSet1.executeQuery(restSql);
if (recordSet1.next()) {
restId = recordSet1.getInt("maxId");
restIds.add(""+restId);
}
resultMap.put("sign", "1");
resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功
} else {
if(!rulesdetailidList.isEmpty()){
delFail(rulesdetailidList, restIds, ruleId);
}
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
}
}
}
}
String paidLeaveEnableType_key = "paidLeaveEnableType"+changetype_index;
String paidLeaveEnableType_value = Util.null2String(params.get(paidLeaveEnableType_key));
String paidLeaveEnableTypeRule_key = "paidLeaveEnableTypeRule"+changetype_index;
String paidLeaveEnableTypeRule_value = Util.null2String(params.get(paidLeaveEnableTypeRule_key));
if("1".equalsIgnoreCase(paidLeaveEnableType_value)){
String paidLeaveEnableDefaultType_key = "paidLeaveEnableDefaultType"+changetype_index;
String paidLeaveEnableDefaultType_value = Util.null2String(params.get(paidLeaveEnableDefaultType_key));
if("2".equalsIgnoreCase(paidLeaveEnableDefaultType_value)){
// 按加班时长范围设置转调休时长
JSONArray jsonArray = JSONArray.parseArray(paidLeaveEnableTypeRule_value);
for(int k = 0 ; k < jsonArray.size() ; k++){
JSONObject jsonObject = (JSONObject) jsonArray.get(k);
String work = Util.null2String(jsonObject.get("work"));
String rest = Util.null2String(jsonObject.get("rest"));
String detailsql = "insert into kq_OvertimeBalanceLengthDetail(rulesdetailid,overtimelength,balancelength,dsporder) values(?,?,?,?)";
flag = recordSet.executeUpdate(detailsql, rulesdetailid, work, rest, k);
if (flag) {
resultMap.put("sign", "1");
resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功
} else {
if(!rulesdetailidList.isEmpty()){
delFail(rulesdetailidList, null, ruleId);
}
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
}
}else if("3".equalsIgnoreCase(paidLeaveEnableDefaultType_value)){
// 按加班的时间段设置转调休时长
JSONArray jsonArray = JSONArray.parseArray(paidLeaveEnableTypeRule_value);
for(int k = 0 ; k < jsonArray.size() ; k++){
JSONObject jsonObject = (JSONObject) jsonArray.get(k);
String time = Util.null2String(jsonObject.get("time"));
String left = Util.null2String(jsonObject.get("left"));
String right = Util.null2String(jsonObject.get("right"));
String detailsql = "insert into kq_OvertimeBalanceTimeDetail(rulesdetailid,timepoint,lenOfOvertime,lenOfLeave,dsporder) values(?,?,?,?,?)";
flag = recordSet.executeUpdate(detailsql, rulesdetailid, time, left, right,k);
if (flag) {
resultMap.put("sign", "1");
resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功
} else {
if(!rulesdetailidList.isEmpty()){
delFail(rulesdetailidList, null, ruleId);
}
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
}
}
}else if("2".equalsIgnoreCase(paidLeaveEnableType_value)){
String paidLeaveEnableFlowType_key = "paidLeaveEnableFlowType"+changetype_index;
String paidLeaveEnableFlowType_value = Util.null2String(params.get(paidLeaveEnableFlowType_key));
if("2".equalsIgnoreCase(paidLeaveEnableFlowType_value)){
// 按加班时长范围设置转调休时长
JSONArray jsonArray = JSONArray.parseArray(paidLeaveEnableTypeRule_value);
for(int k = 0 ; k < jsonArray.size() ; k++){
JSONObject jsonObject = (JSONObject) jsonArray.get(k);
String work = Util.null2String(jsonObject.get("work"));
String rest = Util.null2String(jsonObject.get("rest"));
String detailsql = "insert into kq_OvertimeBalanceLengthDetail(rulesdetailid,overtimelength,balancelength,dsporder) values(?,?,?,?)";
flag = recordSet.executeUpdate(detailsql, rulesdetailid, work, rest, k);
if (flag) {
resultMap.put("sign", "1");
resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功
} else {
if(!rulesdetailidList.isEmpty()){
delFail(rulesdetailidList, null, ruleId);
}
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
}
}else if("3".equalsIgnoreCase(paidLeaveEnableFlowType_value)){
// 按加班的时间段设置转调休时长
JSONArray jsonArray = JSONArray.parseArray(paidLeaveEnableTypeRule_value);
for(int k = 0 ; k < jsonArray.size() ; k++){
JSONObject jsonObject = (JSONObject) jsonArray.get(k);
String time = Util.null2String(jsonObject.get("time"));
String left = Util.null2String(jsonObject.get("left"));
String right = Util.null2String(jsonObject.get("right"));
String detailsql = "insert into kq_OvertimeBalanceTimeDetail(rulesdetailid,timepoint,lenOfOvertime,lenOfLeave,dsporder) values(?,?,?,?,?)";
flag = recordSet.executeUpdate(detailsql, rulesdetailid, time, left, right,k);
if (flag) {
resultMap.put("sign", "1");
resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功
} else {
if(!rulesdetailidList.isEmpty()){
delFail(rulesdetailidList, null, ruleId);
}
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
}
}
}
}else{
if(!rulesdetailidList.isEmpty()){
delFail(rulesdetailidList, null, ruleId);
}
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
}
}
resultMap.put("sign", "1");
resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功
} catch (Exception e) {
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage()));
writeLog(e);
}
return resultMap;
}
/**
*
* @param rulesdetailidList
* @param restIds
* @param ruleId
*/
public void delFail(List<String> rulesdetailidList, List<String> restIds, int ruleId){
RecordSet rs = new RecordSet();
String delSql1 = "delete from kq_OvertimeRules where id = ? ";
rs.executeUpdate(delSql1, ruleId);
for(String rulesdetailid : rulesdetailidList){
String delSql = "delete from kq_overtimerulesdetail where id = ? ";
rs.executeUpdate(delSql,rulesdetailid);
}
if(restIds != null && !restIds.isEmpty()){
for(String restId : restIds){
String delSql = "delete from kq_overtimeresttime where id = ? ";
rs.executeUpdate(delSql,restId);
delSql = "delete from kq_overtimerestlength where id = ? ";
rs.executeUpdate(delSql,restId);
}
}
}
}

@ -0,0 +1,85 @@
package com.engine.kq.cmd.overtimerules;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.biz.SimpleBizLogger;
import com.engine.common.constant.BizLogSmallType4Hrm;
import com.engine.common.constant.BizLogType;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import weaver.systeminfo.SystemEnv;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* --
*/
public class DeleteOvertimeRulesCmd extends AbstractCommonCommand<Map<String, Object>> {
private SimpleBizLogger logger;
public DeleteOvertimeRulesCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
this.logger = new SimpleBizLogger();
String ruleIds = Util.null2String(params.get("ruleIds"));//需要删除的加班规则ID
BizLogContext bizLogContext = new BizLogContext();
bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型
bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_OVERTIMERULES);//所属大类型
bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_OVERTIMERULES);//当前小类型
bizLogContext.setParams(params);//当前request请求参数
logger.setUser(user);//当前操作人
String mainSql = "select * from kq_overtimeRules where (isDelete is null or isDelete<>1) and id in ("+ruleIds+")";
logger.setMainSql(mainSql, "id");//主表sql
logger.setMainPrimarykey("id");//主日志表唯一key
logger.setMainTargetNameColumn("name");
logger.before(bizLogContext);
}
@Override
public BizLogContext getLogContext() {
return null;
}
@Override
public List<BizLogContext> getLogContexts() {
return logger.getBizLogContexts();
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> resultMap = new HashMap<String, Object>();
String ruleIds = Util.null2String(params.get("ruleIds"));//需要删除的加班规则ID
if (ruleIds.equals("")) {
resultMap.put("status", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(388858, user.getLanguage()));
return resultMap;
}
boolean canDelete = HrmUserVarify.checkUserRight("KQOvertimeRulesDelete:Delete", user);//是否具有删除的权限;
if (!canDelete) {
resultMap.put("status", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage()));
return resultMap;
}
boolean flag = false;
String sql = "update kq_OvertimeRules set isDelete=1 where id in (" + ruleIds + ")";
RecordSet recordSet = new RecordSet();
flag = recordSet.executeUpdate(sql);
if (flag) {
resultMap.put("sign", "1");
resultMap.put("message", SystemEnv.getHtmlLabelName(20461, user.getLanguage()));//删除成功
} else {
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(20462, user.getLanguage()));//删除失败
}
return resultMap;
}
}

@ -0,0 +1,499 @@
package com.engine.kq.cmd.overtimerules;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.biz.SimpleBizLogger;
import com.engine.common.constant.BizLogSmallType4Hrm;
import com.engine.common.constant.BizLogType;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.kq.biz.KQOvertimeRulesBiz;
import com.engine.kq.log.KQLog;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import java.util.stream.Collectors;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import weaver.systeminfo.SystemEnv;
import java.util.*;
/**
* --
*/
public class EditOverTimeRulesCmd extends AbstractCommonCommand<Map<String, Object>> {
private SimpleBizLogger logger;
public EditOverTimeRulesCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
this.logger = new SimpleBizLogger();
int ruleId = Util.getIntValue((String) params.get("ruleId"), 0);
BizLogContext bizLogContext = new BizLogContext();
bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型
bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_OVERTIMERULES);//所属大类型
bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_OVERTIMERULES);//当前小类型
bizLogContext.setParams(params);//当前request请求参数
logger.setUser(user);//当前操作人
String mainSql = "select * from kq_overtimeRules where id="+ruleId;
logger.setMainSql(mainSql, "id");//主表sql
logger.setMainPrimarykey("id");//主日志表唯一key
logger.setMainTargetNameColumn("name");
SimpleBizLogger.SubLogInfo subLogInfo = logger.getNewSubLogInfo();
String subSql = "select * from kq_overtimeRulesDetail where ruleId="+ruleId +" order by id";
subLogInfo.setSubSql(subSql, "id");
logger.addSubLogInfo(subLogInfo);
logger.before(bizLogContext);
}
@Override
public BizLogContext getLogContext() {
return null;
}
@Override
public List<BizLogContext> getLogContexts() {
return logger.getBizLogContexts();
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> resultMap = new HashMap<String, Object>();
try {
/*加班规则的ID*/
int ruleId = Util.getIntValue((String) params.get("ruleId"), 0);
if (ruleId == 0) {
resultMap.put("status", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(388858, user.getLanguage()));
return resultMap;
}
boolean canEdit = HrmUserVarify.checkUserRight("KQOvertimeRulesEdit:Edit", user);//是否具有编辑的权限;
if (!canEdit) {
resultMap.put("status", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage()));
return resultMap;
}
/*加班规则名称*/
String name = Util.null2String(params.get("name"));
/*考勤组的ID*/
String groupIds = Util.null2String(params.get("groupIds"));
/*工作日是否允许加班0-不允许、1-允许*/
int overtimeEnable2 = Util.getIntValue((String) params.get("overtimeEnable2"), 1);
/*工作日的加班方式1-需审批以审批单为准、2-需审批以打卡为准但是不能超过审批时长、3-无需审批,根据打卡时间计算加班时长*/
int computingMode2 = Util.getIntValue((String) params.get("computingMode2"), 1);
/*工作日下班多少分钟后开始计算加班*/
int startTime2 = Util.getIntValue((String) params.get("startTime2"), 30);
/*工作日最小加班时长*/
int minimumLen2 = Util.getIntValue((String) params.get("minimumLen2"), 30);
/*工作日是否允许加班转调休*/
int paidLeaveEnable2 = Util.getIntValue((String) params.get("paidLeaveEnable2"), 0);
/*工作日加班转调休比例中的加班时长*/
double lenOfOvertime2 = Util.getDoubleValue((String) params.get("lenOfOvertime2"), 30.0);
/*工作日加班转调休比例中的调休时长*/
double lenOfLeave2 = Util.getDoubleValue((String) params.get("lenOfLeave2"), 30.0);
/*休息日是否允许加班0-不允许、1-允许*/
int overtimeEnable3 = Util.getIntValue((String) params.get("overtimeEnable3"), 1);
/*休息日的加班方式1-需审批以审批单为准、2-需审批以打卡为准但是不能超过审批时长、3-无需审批,根据打卡时间计算加班时长*/
int computingMode3 = Util.getIntValue((String) params.get("computingMode3"), 1);
/*休息日的最小加班时长*/
int minimumLen3 = Util.getIntValue((String) params.get("minimumLen3"), 30);
/*休息日是否允许加班转调休*/
int paidLeaveEnable3 = Util.getIntValue((String) params.get("paidLeaveEnable3"), 0);
/*休息日加班转调休比例中的加班时长*/
double lenOfOvertime3 = Util.getDoubleValue((String) params.get("lenOfOvertime3"), 30.0);
/*休息日加班转调休比例中的调休时长*/
double lenOfLeave3 = Util.getDoubleValue((String) params.get("lenOfLeave3"), 30.0);
/*休息日是否有休息时间*/
int hasRestTime3 = Util.getIntValue((String) params.get("hasRestTime3"), 0);
/*节假日是否允许加班0-不允许、1-允许*/
int overtimeEnable1 = Util.getIntValue((String) params.get("overtimeEnable1"), 1);
/*节假日的加班方式1-需审批以审批单为准、2-需审批以打卡为准但是不能超过审批时长、3-无需审批,根据打卡时间计算加班时长*/
int computingMode1 = Util.getIntValue((String) params.get("computingMode1"), 1);
/*节假日的最小加班时长*/
int minimumLen1 = Util.getIntValue((String) params.get("minimumLen1"), 30);
/*节假日是否允许加班转调休*/
int paidLeaveEnable1 = Util.getIntValue((String) params.get("paidLeaveEnable1"), 0);
/*节假日加班转调休比例中的加班时长*/
double lenOfOvertime1 = Util.getDoubleValue((String) params.get("lenOfOvertime1"), 30.0);
/*假节日加班转调休比例中的调休时长*/
double lenOfLeave1 = Util.getDoubleValue((String) params.get("lenOfLeave1"), 30.0);
/*节假日是否有休息时间*/
int hasRestTime1 = Util.getIntValue((String) params.get("hasRestTime1"), 0);
if(computingMode2 == 4 || computingMode1 == 4 || computingMode3 == 4 ){
//如果是流程和打卡取交集的话,加班单位不能是下拉框半天或者整天
int minimumUnit = KQOvertimeRulesBiz.getMinimumUnit();
if(minimumUnit == 2 || minimumUnit == 4){
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(529168, user.getLanguage()));
return resultMap;
}
}
KQLog kqLog = new KQLog();
kqLog.info("EditOverTimeRulesCmd:params:"+params);
/*获取今天的日期*/
Calendar today = Calendar.getInstance();
String currentDate = Util.add0(today.get(Calendar.YEAR), 4) + "-"
+ Util.add0(today.get(Calendar.MONTH) + 1, 2) + "-"
+ Util.add0(today.get(Calendar.DAY_OF_MONTH), 2);
String tomorrowDate = DateUtil.addDate(currentDate, 1);
//顺序显示2是工作日3是休息日1是节假日
int[] changetype = {2,3,1};
boolean flag = false;//是否保存成功
String sql = "update kq_OvertimeRules set name=?,groupIds=? where id=?";
RecordSet recordSet = new RecordSet();
RecordSet recordSet1 = new RecordSet();
RecordSet recordSet2 = new RecordSet();
flag = recordSet.executeUpdate(sql, name, groupIds, ruleId);
if (!flag) {
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
Map<String,String> detailMap = Maps.newHashMap();
String detailSql = "select * from kq_OvertimeRulesDetail where ruleId=?";
recordSet.executeQuery(detailSql,ruleId);
while (recordSet.next()){
String daytype = recordSet.getString("daytype");
String id = recordSet.getString("id");
detailMap.put(daytype, id);
}
String[] fields = new String[]{"overtimeEnable","computingMode","startTime","minimumLen",
"paidLeaveEnable","lenOfOvertime","lenOfLeave","hasRestTime","before_startTime",
"has_cut_point","cut_point","paidLeaveEnableType","paidLeaveEnableDefaultType",
"paidLeaveEnableFlowType","restTimeType"};
String str_fields = Arrays.asList(fields).stream().collect(Collectors.joining(","));
String split_str = Arrays.asList(fields).stream().map(s -> {return "?";}).collect(Collectors.joining(","));
for(int i = 0 ; i < changetype.length ; i++) {
int changetype_index = changetype[i];
String fieldName = "";
for(int j = 0 ; j < fields.length ;j++){
String _key = fields[j]+changetype_index;
String _value = Util.null2String(params.get(_key));
if("before_startTime".equalsIgnoreCase(fields[j])){
_value = Util.null2s(Util.null2String(params.get(_key)),"0");
}
if("startTime".equalsIgnoreCase(fields[j])){
_value = Util.null2s(Util.null2String(params.get(_key)),"0");
}
fieldName += ","+fields[j]+"='"+_value+"'";
}
if(fieldName.length() > 0){
fieldName = fieldName.substring(1);
fieldName += ",ruleId="+ruleId+",dayType="+changetype_index;
String detailid = Util.null2s(detailMap.get((changetype_index+"")),"-1");
String updateSql = "update kq_OvertimeRulesDetail set "+fieldName+" where id = ? ";
flag = recordSet.executeUpdate(updateSql,detailid);
if(flag){
List<String> restIds = Lists.newArrayList();
List<String> lengthDetailIds = Lists.newArrayList();
List<String> timeDetailIds = Lists.newArrayList();
int rulesdetailid = Util.getIntValue(detailid);
String hasRestTime_key = "hasRestTime"+changetype_index;
String hasRestTime_value = Util.null2String(params.get(hasRestTime_key));
if("1".equalsIgnoreCase(hasRestTime_value)){
String restTimeType_key = "restTimeType"+changetype_index;
String restTimeType_value = Util.null2String(params.get(restTimeType_key));
String restTimeRule_key = "restTimeRule"+changetype_index;
String restTimeRule_value = Util.null2String(params.get(restTimeRule_key));
if(restTimeRule_value.length() > 0){
JSONArray jsonArray = JSONArray.parseArray(restTimeRule_value);
if("1".equalsIgnoreCase(restTimeType_value)){
String deleteSql = "delete from kq_OvertimeRestTime where dayType=? and ruleId = ?";
flag = recordSet.executeUpdate(deleteSql, changetype_index,ruleId);
if (!flag) {
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
for(int k = 0 ; k < jsonArray.size() ; k++){
JSONObject jsonObject = (JSONObject) jsonArray.get(k);
String startType = "0";
String endType = "0";
String startTime = Util.null2String(jsonObject.get("startTime"));
String endTime = Util.null2String(jsonObject.get("endTime"));
String restTimeSql = "insert into kq_OvertimeRestTime(ruleId,dayType,startType,startTime,endType,endTime) values(?,?,?,?,?,?)";
flag = recordSet.executeUpdate(restTimeSql, ruleId, changetype_index, startType, startTime, endType, endTime);
if (flag) {
int restDetailId = 0;
String getIdSql = "select max(id) maxId from kq_OvertimeRestTime";
recordSet1.executeQuery(getIdSql);
if (recordSet1.next()) {
restDetailId = recordSet1.getInt("maxId");
restIds.add(""+restDetailId);
}
resultMap.put("sign", "1");
resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功
} else {
if(!restIds.isEmpty()){
if(restIds != null && !restIds.isEmpty()){
for(String detailId : restIds){
String delSql = "delete from kq_OvertimeRestTime where id = ? ";
recordSet2.executeUpdate(delSql,detailId);
}
}
}
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
}
}else if("2".equalsIgnoreCase(restTimeType_value)){
String deleteSql = "delete from kq_OvertimeRestlength where dayType=? and ruleId = ?";
flag = recordSet.executeUpdate(deleteSql, changetype_index,ruleId);
if (!flag) {
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
for(int k = 0 ; k < jsonArray.size() ; k++){
JSONObject jsonObject = (JSONObject) jsonArray.get(k);
String overtime = Util.null2String(jsonObject.get("overtime"));
String exclude = Util.null2String(jsonObject.get("exclude"));
String restTimeSql = "insert into kq_OvertimeRestlength(ruleId,dayType,overlength,cutlength,dsporder) values(?,?,?,?,?)";
flag = recordSet.executeUpdate(restTimeSql, ruleId, changetype_index, overtime, exclude, k);
if (flag) {
int restDetailId = 0;
String getIdSql = "select max(id) maxId from kq_OvertimeRestlength";
recordSet1.executeQuery(getIdSql);
if (recordSet1.next()) {
restDetailId = recordSet1.getInt("maxId");
restIds.add(""+restDetailId);
}
resultMap.put("sign", "1");
resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功
} else {
if(!restIds.isEmpty()){
if(restIds != null && !restIds.isEmpty()){
for(String detailId : restIds){
String delSql = "delete from kq_OvertimeRestlength where id = ? ";
recordSet2.executeUpdate(delSql,detailId);
}
}
}
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
}
}
}
}
String paidLeaveEnableType_key = "paidLeaveEnableType"+changetype_index;
String paidLeaveEnableType_value = Util.null2String(params.get(paidLeaveEnableType_key));
String paidLeaveEnableTypeRule_key = "paidLeaveEnableTypeRule"+changetype_index;
String paidLeaveEnableTypeRule_value = Util.null2String(params.get(paidLeaveEnableTypeRule_key));
if("1".equalsIgnoreCase(paidLeaveEnableType_value)){
String paidLeaveEnableDefaultType_key = "paidLeaveEnableDefaultType"+changetype_index;
String paidLeaveEnableDefaultType_value = Util.null2String(params.get(paidLeaveEnableDefaultType_key));
if("2".equalsIgnoreCase(paidLeaveEnableDefaultType_value)){
String deleteSql = "delete from kq_OvertimeBalanceLengthDetail where rulesdetailid = ?";
flag = recordSet.executeUpdate(deleteSql, detailid);
if (!flag) {
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
// 按加班时长范围设置转调休时长
JSONArray jsonArray = JSONArray.parseArray(paidLeaveEnableTypeRule_value);
for(int k = 0 ; k < jsonArray.size() ; k++){
JSONObject jsonObject = (JSONObject) jsonArray.get(k);
String work = Util.null2String(jsonObject.get("work"));
String rest = Util.null2String(jsonObject.get("rest"));
String detailsql = "insert into kq_OvertimeBalanceLengthDetail(rulesdetailid,overtimelength,balancelength,dsporder) values(?,?,?,?)";
flag = recordSet.executeUpdate(detailsql, rulesdetailid, work, rest, k);
if (flag) {
int lengthDetailId = 0;
String getIdSql = "select max(id) maxId from kq_OvertimeBalanceLengthDetail";
recordSet1.executeQuery(getIdSql);
if (recordSet1.next()) {
lengthDetailId = recordSet1.getInt("maxId");
lengthDetailIds.add(""+lengthDetailId);
}
resultMap.put("sign", "1");
resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功
} else {
if(!lengthDetailIds.isEmpty()){
if(lengthDetailIds != null && !lengthDetailIds.isEmpty()){
for(String detailId : lengthDetailIds){
String delSql = "delete from kq_OvertimeBalanceLengthDetail where id = ? ";
recordSet2.executeUpdate(delSql,detailId);
}
}
}
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
}
}else if("3".equalsIgnoreCase(paidLeaveEnableDefaultType_value)){
String deleteSql = "delete from kq_OvertimeBalanceTimeDetail where rulesdetailid = ?";
flag = recordSet.executeUpdate(deleteSql, detailid);
if (!flag) {
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
// 按加班的时间段设置转调休时长
JSONArray jsonArray = JSONArray.parseArray(paidLeaveEnableTypeRule_value);
for(int k = 0 ; k < jsonArray.size() ; k++){
JSONObject jsonObject = (JSONObject) jsonArray.get(k);
String time = Util.null2String(jsonObject.get("time"));
String left = Util.null2String(jsonObject.get("left"));
String right = Util.null2String(jsonObject.get("right"));
String detailsql = "insert into kq_OvertimeBalanceTimeDetail(rulesdetailid,timepoint,lenOfOvertime,lenOfLeave,dsporder) values(?,?,?,?,?)";
flag = recordSet.executeUpdate(detailsql, rulesdetailid, time, left, right,k);
if (flag) {
int timeDetailId = 0;
String getIdSql = "select max(id) maxId from kq_OvertimeBalanceTimeDetail";
recordSet1.executeQuery(getIdSql);
if (recordSet1.next()) {
timeDetailId = recordSet1.getInt("maxId");
timeDetailIds.add(""+timeDetailId);
}
resultMap.put("sign", "1");
resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功
} else {
if(!timeDetailIds.isEmpty()){
if(timeDetailIds != null && !timeDetailIds.isEmpty()){
for(String detailId : timeDetailIds){
String delSql = "delete from kq_OvertimeBalanceTimeDetail where id = ? ";
recordSet2.executeUpdate(delSql,detailId);
}
}
}
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
}
}
}else if("2".equalsIgnoreCase(paidLeaveEnableType_value)){
String paidLeaveEnableFlowType_key = "paidLeaveEnableFlowType"+changetype_index;
String paidLeaveEnableFlowType_value = Util.null2String(params.get(paidLeaveEnableFlowType_key));
if("2".equalsIgnoreCase(paidLeaveEnableFlowType_value)){
String deleteSql = "delete from kq_OvertimeBalanceLengthDetail where rulesdetailid = ?";
flag = recordSet.executeUpdate(deleteSql, detailid);
if (!flag) {
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
// 按加班时长范围设置转调休时长
JSONArray jsonArray = JSONArray.parseArray(paidLeaveEnableTypeRule_value);
for(int k = 0 ; k < jsonArray.size() ; k++){
JSONObject jsonObject = (JSONObject) jsonArray.get(k);
String work = Util.null2String(jsonObject.get("work"));
String rest = Util.null2String(jsonObject.get("rest"));
String detailsql = "insert into kq_OvertimeBalanceLengthDetail(rulesdetailid,overtimelength,balancelength,dsporder) values(?,?,?,?)";
flag = recordSet.executeUpdate(detailsql, rulesdetailid, work, rest, k);
if (flag) {
int lengthDetailId = 0;
String getIdSql = "select max(id) maxId from kq_OvertimeBalanceLengthDetail";
recordSet1.executeQuery(getIdSql);
if (recordSet1.next()) {
lengthDetailId = recordSet1.getInt("maxId");
lengthDetailIds.add(""+lengthDetailId);
}
resultMap.put("sign", "1");
resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功
} else {
if(!lengthDetailIds.isEmpty()){
if(lengthDetailIds != null && !lengthDetailIds.isEmpty()){
for(String detailId : lengthDetailIds){
String delSql = "delete from kq_OvertimeBalanceLengthDetail where id = ? ";
recordSet2.executeUpdate(delSql,detailId);
}
}
}
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
}
}else if("3".equalsIgnoreCase(paidLeaveEnableFlowType_value)){
String deleteSql = "delete from kq_OvertimeBalanceTimeDetail where rulesdetailid = ?";
flag = recordSet.executeUpdate(deleteSql, detailid);
if (!flag) {
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
// 按加班的时间段设置转调休时长
JSONArray jsonArray = JSONArray.parseArray(paidLeaveEnableTypeRule_value);
for(int k = 0 ; k < jsonArray.size() ; k++){
JSONObject jsonObject = (JSONObject) jsonArray.get(k);
String time = Util.null2String(jsonObject.get("time"));
String left = Util.null2String(jsonObject.get("left"));
String right = Util.null2String(jsonObject.get("right"));
String detailsql = "insert into kq_OvertimeBalanceTimeDetail(rulesdetailid,timepoint,lenOfOvertime,lenOfLeave,dsporder) values(?,?,?,?,?)";
flag = recordSet.executeUpdate(detailsql, rulesdetailid, time, left, right,k);
if (flag) {
int timeDetailId = 0;
String getIdSql = "select max(id) maxId from kq_OvertimeBalanceTimeDetail";
recordSet1.executeQuery(getIdSql);
if (recordSet1.next()) {
timeDetailId = recordSet1.getInt("maxId");
timeDetailIds.add(""+timeDetailId);
}
resultMap.put("sign", "1");
resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功
} else {
if(!timeDetailIds.isEmpty()){
if(timeDetailIds != null && !timeDetailIds.isEmpty()){
for(String detailId : timeDetailIds){
String delSql = "delete from kq_OvertimeBalanceTimeDetail where id = ? ";
recordSet2.executeUpdate(delSql,detailId);
}
}
}
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
}
}
}
}else{
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
return resultMap;
}
}
}
resultMap.put("sign", "1");
resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功
} catch (Exception e) {
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(382661, user.getLanguage()));
writeLog(e);
}
return resultMap;
}
}

@ -0,0 +1,697 @@
package com.engine.kq.cmd.overtimerules;
import com.api.browser.bean.SearchConditionItem;
import com.api.browser.bean.SearchConditionOption;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.api.hrm.bean.HrmFieldBean;
import com.api.hrm.util.HrmFieldSearchConditionComInfo;
import com.engine.kq.biz.KQGroupComInfo;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import weaver.conn.RecordSet;
import weaver.filter.XssUtil;
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 GetOvertimeRulesFormCmd extends AbstractCommonCommand<Map<String, Object>> {
public GetOvertimeRulesFormCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
}
@Override
public BizLogContext getLogContext() {
return null;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> resultMap = new HashMap<String, Object>();
String ruleId = Util.null2String(params.get("ruleId"));//加班规则的ID
boolean canAdd = HrmUserVarify.checkUserRight("KQOvertimeRulesAdd:Add", user);//是否具有新建权限
boolean canEdit = HrmUserVarify.checkUserRight("KQOvertimeRulesEdit:Edit", user);//是否具有编辑的权限
if (!canAdd && !canEdit) {
resultMap.put("status", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage()));
return resultMap;
}
boolean isEdit = false;
/*加班规则名称*/
String name = "";
/*考勤组的ID*/
String groupIds = "";
/**
*
*/
/*工作日是否允许加班0-不允许、1-允许*/
int overtimeEnable2 = 1;
/*工作日的加班方式1-需审批以加班流程为准、2-需审批以打卡为准但是不能超过加班流程时长、3-无需审批,根据打卡时间计算加班时长*/
int computingMode2 = 1;
/*工作日下班多少分钟后开始计算加班*/
int startTime2 = 30;
/*工作日上班前多少分钟后开始计算加班*/
int before_startTime2 = 0;
/*工作日最小加班时长*/
int minimumLen2 = 30;
/*工作日是否允许加班转调休*/
int paidLeaveEnable2 = 0;
/*工作日加班转调休比例中的加班时长*/
double lenOfOvertime2 = 1;
/*工作日加班转调休比例中的调休时长*/
double lenOfLeave2 = 1;
/*工作日加班补偿方式 1-默认加班补偿规则、2-根据员工在加班流程上选择的加班补偿类型进行补偿两种*/
int paidLeaveEnableType2 = 0;
/*工作日默认加班补偿方式 里转调休的方式: 1-按加班时长比例转调休时长、2-按加班时长范围设置转调休时长、3-按加班的时间段设置转调休时长*/
int paidLeaveEnableDefaultType2 = 1;
/*工作日 根据员工在加班流程上选择的加班补偿类型进行补偿 里转调休的方式: 1-按加班时长比例转调休时长、2-按加班时长范围设置转调休时长、3-按加班的时间段设置转调休时长*/
int paidLeaveEnableFlowType2 = 1;
// 按加班时长范围设置转调休时长: 加班时长 ≥* 分钟,转调休时长*分钟
List<Map<String,String>> balanceLengthDetailLists2 = Lists.newArrayList();
// 加班时间在19:00后比例转调休时长 按照1:1
List<Map<String,String>> balanceTimeDetailLists2 = Lists.newArrayList();
/*工作日是否有休息时间*/
int hasRestTime2 = 0;
/*排除休息时间两种方式 :1、设置休息时间 2、根据加班时长扣除 */
int restType2=1;
// 工作日 是否开启 自定义跨天加班归属分界点
int has_cut_point2 = 0;
// 开启 自定义跨天加班归属分界点
String cut_point2 = "00:00";
/*休息日是否允许加班0-不允许、1-允许*/
int overtimeEnable3 = 1;
/*休息日的加班方式1-需审批以加班流程为准、2-需审批以打卡为准但是不能超过加班流程时长、3-无需审批,根据打卡时间计算加班时长*/
int computingMode3 = 1;
/*休息日的最小加班时长*/
int minimumLen3 = 30;
/*休息日是否允许加班转调休*/
int paidLeaveEnable3 = 0;
/*休息日加班转调休比例中的加班时长*/
double lenOfOvertime3 = 1;
/*休息日加班转调休比例中的调休时长*/
double lenOfLeave3 = 1;
/*休息日是否有休息时间*/
int hasRestTime3 = 0;
/*休息日加班补偿方式 1-默认加班补偿规则、2-根据员工在加班流程上选择的加班补偿类型进行补偿两种*/
int paidLeaveEnableType3 = 0;
/*休息日默认加班补偿方式 里转调休的方式: 1-按加班时长比例转调休时长、2-按加班时长范围设置转调休时长、3-按加班的时间段设置转调休时长*/
int paidLeaveEnableDefaultType3 = 1;
/*休息日 根据员工在加班流程上选择的加班补偿类型进行补偿 里转调休的方式: 1-按加班时长比例转调休时长、2-按加班时长范围设置转调休时长、3-按加班的时间段设置转调休时长*/
int paidLeaveEnableFlowType3 = 1;
// 按加班时长范围设置转调休时长: 加班时长 ≥* 分钟,转调休时长*分钟
List<Map<String,String>> balanceLengthDetailLists3 = Lists.newArrayList();
// 加班时间在19:00后比例转调休时长 按照1:1
List<Map<String,String>> balanceTimeDetailLists3 = Lists.newArrayList();
/*排除休息时间两种方式 :1、设置休息时间 2、根据加班时长扣除 */
int restType3=1;
/*节假日是否允许加班0-不允许、1-允许*/
int overtimeEnable1 = 1;
/*节假日的加班方式1-需审批以加班流程为准、2-需审批以打卡为准但是不能超过加班流程时长、3-无需审批,根据打卡时间计算加班时长*/
int computingMode1 = 1;
/*节假日的最小加班时长*/
int minimumLen1 = 30;
/*节假日是否允许加班转调休*/
int paidLeaveEnable1 = 0;
/*节假日加班转调休比例中的加班时长*/
double lenOfOvertime1 = 1;
/*假节日加班转调休比例中的调休时长*/
double lenOfLeave1 = 1;
/*节假日是否有休息时间*/
int hasRestTime1 = 0;
/*节假日加班补偿方式 1-默认加班补偿规则、2-根据员工在加班流程上选择的加班补偿类型进行补偿两种*/
int paidLeaveEnableType1 = 0;
/*节假日默认加班补偿方式 里转调休的方式: 1-按加班时长比例转调休时长、2-按加班时长范围设置转调休时长、3-按加班的时间段设置转调休时长*/
int paidLeaveEnableDefaultType1 = 1;
/*节假日 根据员工在加班流程上选择的加班补偿类型进行补偿 里转调休的方式: 1-按加班时长比例转调休时长、2-按加班时长范围设置转调休时长、3-按加班的时间段设置转调休时长*/
int paidLeaveEnableFlowType1 = 1;
// 按加班时长范围设置转调休时长: 加班时长 ≥* 分钟,转调休时长*分钟
List<Map<String,String>> balanceLengthDetailLists1 = Lists.newArrayList();
// 加班时间在19:00后比例转调休时长 按照1:1
List<Map<String,String>> balanceTimeDetailLists1 = Lists.newArrayList();
/*排除节假时间两种方式 :1、设置休息时间 2、根据加班时长扣除 */
int restType1=1;
/**
*
*/
//顺序显示2是工作日3是休息日1是节假日
int[] changetype = {2,3,1};
Map<String,String> valueMap = Maps.newHashMap();
if (!ruleId.equals("")) {
String sql = "select t1.name,t1.groupids,t2.* from kq_OvertimeRules t1 left join kq_OvertimeRulesDetail t2 on t1.id=t2.ruleId where (t1.isDelete is null or t1.isDelete!=1) and t1.id=" + ruleId;
RecordSet recordSet = new RecordSet();
recordSet.executeQuery(sql);
int dayType = 0;//1-工作日、2-休息日、3-节假日
while (recordSet.next()) {
isEdit = true;
name = recordSet.getString("name");
groupIds = recordSet.getString("groupIds");
dayType = recordSet.getInt("dayType");
int detailid = recordSet.getInt("id");
int overtimeEnable = recordSet.getInt("overtimeEnable");
int computingMode = recordSet.getInt("computingMode");
int startTime = recordSet.getInt("startTime");
int before_startTime = recordSet.getInt("before_startTime");
int minimumLen = recordSet.getInt("minimumLen");
int paidLeaveEnable = recordSet.getInt("paidLeaveEnable");
double lenOfOvertime = recordSet.getDouble("lenOfOvertime");
double lenOfLeave = recordSet.getDouble("lenOfLeave");
int hasRestTime = recordSet.getInt("hasRestTime");
int has_cut_point = recordSet.getInt("has_cut_point");
String cut_point = recordSet.getString("cut_point");
if("-1".equalsIgnoreCase(cut_point)){
cut_point = "00:00";
}
if(has_cut_point < 0){
has_cut_point = 0;
}
if(has_cut_point == 0){
cut_point = "00:00";
}
if(before_startTime < 0){
before_startTime = 0;
}
int paidLeaveEnableType = recordSet.getInt("paidLeaveEnableType");
int paidLeaveEnableDefaultType = recordSet.getInt("paidLeaveEnableDefaultType");
int paidLeaveEnableFlowType = recordSet.getInt("paidLeaveEnableFlowType");
int restTimeType = recordSet.getInt("restTimeType");
if(paidLeaveEnableType <= 0){
paidLeaveEnableType = 1;
}
if(paidLeaveEnableDefaultType <= 0){
paidLeaveEnableDefaultType = 1;
}
if(paidLeaveEnableFlowType <= 0){
paidLeaveEnableFlowType = 1;
}
if(paidLeaveEnableDefaultType == 1 && paidLeaveEnable == 0){
//如果是第一种生成调休方式,且没有开启关联调休,那么默认的加班转调休方式就是第一种
paidLeaveEnableDefaultType = 1;
}
if(restTimeType <= 0){
restTimeType = 1;
}
valueMap.put("ID_"+dayType, detailid+"");
valueMap.put("overtimeEnable"+dayType, overtimeEnable+"");
valueMap.put("computingMode"+dayType, computingMode+"");
valueMap.put("startTime"+dayType, startTime+"");
valueMap.put("before_startTime"+dayType, before_startTime+"");
valueMap.put("minimumLen"+dayType, minimumLen+"");
valueMap.put("paidLeaveEnable"+dayType, paidLeaveEnable+"");
valueMap.put("lenOfOvertime"+dayType, lenOfOvertime+"");
valueMap.put("lenOfLeave"+dayType, lenOfLeave+"");
valueMap.put("hasRestTime"+dayType, hasRestTime+"");
valueMap.put("restTimeType"+dayType, restTimeType+"");
valueMap.put("has_cut_point"+dayType, has_cut_point+"");
valueMap.put("cut_point"+dayType, cut_point+"");
valueMap.put("paidLeaveEnableType"+dayType, paidLeaveEnableType+"");
valueMap.put("paidLeaveEnableDefaultType"+dayType, paidLeaveEnableDefaultType+"");
valueMap.put("paidLeaveEnableFlowType"+dayType, paidLeaveEnableFlowType+"");
}
for(int i = 0 ; i < changetype.length ; i++) {
int changetype_index = changetype[i];
String hasRestTime_index = "hasRestTime"+changetype_index;
String paidLeaveEnable_index = "paidLeaveEnable"+changetype_index;
String paidLeaveEnableType_index = "paidLeaveEnableType"+changetype_index;
String paidLeaveEnableDefaultType_index = "paidLeaveEnableDefaultType"+changetype_index;
String paidLeaveEnableFlowType_index = "paidLeaveEnableFlowType"+changetype_index;
if(valueMap.containsKey(hasRestTime_index)){
String hasRestTime = Util.null2String(valueMap.get(hasRestTime_index));
if("1".equalsIgnoreCase(hasRestTime)){
String restTimeType_index = "restTimeType"+changetype_index;
if(valueMap.containsKey(restTimeType_index)){
String restTimeType = Util.null2String(valueMap.get(restTimeType_index));
if("1".equalsIgnoreCase(restTimeType)){
// 排除休息时间
List restTimeList = new ArrayList();
sql = "select * from kq_OvertimeRestTime where ruleId=? and dayType=? order by dayType,id";
recordSet.executeQuery(sql, ruleId,changetype_index);
while (recordSet.next()) {
String startType = recordSet.getString("startType");
String startTime = recordSet.getString("startTime");
String endType = recordSet.getString("endType");
String endTime = recordSet.getString("endTime");
Map<String, Object> restTimeMap = new HashMap<String, Object>();
restTimeMap.put("startType", startType);
restTimeMap.put("startTime", startTime);
restTimeMap.put("endType", endType);
restTimeMap.put("endTime", endTime);
restTimeList.add(restTimeMap);
}
if(!restTimeList.isEmpty()){
resultMap.put("restTimeRule"+changetype_index, restTimeList);
}
}else if("2".equalsIgnoreCase(restTimeType)){
// 排除休息时长
List restTimeList = new ArrayList();
sql = "select * from kq_OvertimeRestlength where ruleId=? and dayType=? order by dayType,dsporder";
recordSet.executeQuery(sql, ruleId,changetype_index);
while (recordSet.next()) {
String overlength = recordSet.getString("overlength");
String cutlength = recordSet.getString("cutlength");
Map<String, Object> restTimeMap = new HashMap<String, Object>();
restTimeMap.put("overtime", overlength);
restTimeMap.put("exclude", cutlength);
restTimeList.add(restTimeMap);
}
if(!restTimeList.isEmpty()){
resultMap.put("restTimeRule"+changetype_index, restTimeList);
}
}
}
}
}
if(valueMap.containsKey(paidLeaveEnableType_index)){
String ID_index = "ID_"+changetype_index;
if(valueMap.containsKey(ID_index)){
String detailid = Util.null2String(valueMap.get(ID_index));
String paidLeaveEnableType = Util.null2String(valueMap.get(paidLeaveEnableType_index));
String paidLeaveEnableDefaultType = Util.null2String(valueMap.get(paidLeaveEnableDefaultType_index));
String paidLeaveEnableFlowType = Util.null2String(valueMap.get(paidLeaveEnableFlowType_index));
if("1".equalsIgnoreCase(paidLeaveEnableType)){
if(valueMap.containsKey(paidLeaveEnable_index)) {
String paidLeaveEnable = Util.null2String(valueMap.get(paidLeaveEnable_index));
if("1".equalsIgnoreCase(paidLeaveEnable)){
if("2".equalsIgnoreCase(paidLeaveEnableDefaultType)){
set_lengthDetailList(detailid,changetype_index,resultMap);
}else if("3".equalsIgnoreCase(paidLeaveEnableDefaultType)){
set_TimeDetailList(detailid,changetype_index,resultMap);
}
}
}
}else if("2".equalsIgnoreCase(paidLeaveEnableType)){
if("2".equalsIgnoreCase(paidLeaveEnableFlowType)){
set_lengthDetailList(detailid,changetype_index,resultMap);
}else if("3".equalsIgnoreCase(paidLeaveEnableFlowType)){
set_TimeDetailList(detailid,changetype_index,resultMap);
}
}
}
}
}
}
List<Map<String, Object>> groupList = new ArrayList<Map<String, Object>>();
Map<String, Object> groupItem = new HashMap<String, Object>();
List<Object> itemList = new ArrayList<Object>();
HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo();
SearchConditionItem searchConditionItem = null;
HrmFieldBean hrmFieldBean = null;
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname("name");//加班规则名称
hrmFieldBean.setFieldlabel("388831");
hrmFieldBean.setFieldhtmltype("1");
hrmFieldBean.setType("1");
hrmFieldBean.setViewAttr(3);
hrmFieldBean.setFieldvalue(name);
hrmFieldBean.setIsFormField(true);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
searchConditionItem.setRules("required|string");
itemList.add(searchConditionItem);
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname("groupIds");//应用范围--考勤组
hrmFieldBean.setFieldlabel("19374");
hrmFieldBean.setFieldhtmltype("3");
hrmFieldBean.setType("mkqgroup");
hrmFieldBean.setFieldvalue(groupIds);
hrmFieldBean.setIsFormField(true);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
KQGroupComInfo kqGroupComInfo = new KQGroupComInfo();
List<Map<String, Object>> replaceDatas = new ArrayList<Map<String, Object>>();
Map<String, Object> datas = new HashMap<String, Object>();
String[] groupIdArr = groupIds.split(",");
for (String groupId : groupIdArr) {
datas = new HashMap<String, Object>();
datas.put("id", groupId);
datas.put("name", kqGroupComInfo.getGroupname(groupId));
replaceDatas.add(datas);
}
searchConditionItem.getBrowserConditionParam().setReplaceDatas(replaceDatas);
/*一个考勤组只能关联一个加班规则,所以新建或者编辑的时候需要对考勤组浏览按钮内的数据进行过滤*/
Map<String,Object> dataMap = new HashMap<String,Object>();
Map<String,Object> completeMap = new HashMap<String,Object>();
String kqGroupIdStr = "";
String sql = "select * from kq_OvertimeRules where (isDelete is null or isDelete !=1) ";
if (isEdit) {
sql += " and id !=" + ruleId;
}
RecordSet recordSet = new RecordSet();
recordSet.executeQuery(sql);
while (recordSet.next()) {
String kqGroupIds = recordSet.getString("groupIds");
if (kqGroupIds.equals("")) {
continue;
}
kqGroupIdStr += "," + kqGroupIds;
}
XssUtil xssUtil = new XssUtil();
dataMap.put("sqlWhere", kqGroupIdStr.length() > 0 ? xssUtil.put(" kqType <>3 and id not in (" + kqGroupIdStr.substring(1) + ")") : xssUtil.put(" kqType <>3 "));
completeMap.put("sqlWhere", kqGroupIdStr.length() > 0 ? xssUtil.put(" kqType <>3 and id not in (" + kqGroupIdStr.substring(1) + ")") : xssUtil.put(" kqType <>3 "));
searchConditionItem.getBrowserConditionParam().setDataParams(dataMap);
searchConditionItem.getBrowserConditionParam().setCompleteParams(completeMap);
itemList.add(searchConditionItem);
groupItem.put("title", SystemEnv.getHtmlLabelName(1361, user.getLanguage()));
groupItem.put("defaultshow", true);
groupItem.put("items", itemList);
groupList.add(groupItem);
for(int i = 0 ; i < changetype.length ; i++){
int changetype_index = changetype[i];
groupItem = new HashMap<String, Object>();
itemList = new ArrayList<Object>();
String overtimeEnable_key = "overtimeEnable"+changetype_index;
String overtimeEnable_value = isEdit?Util.null2String(valueMap.get(overtimeEnable_key),"1"):"1";
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname(overtimeEnable_key);//是否允许加班
hrmFieldBean.setFieldlabel("388833");
hrmFieldBean.setFieldhtmltype("4");
hrmFieldBean.setType("1");
hrmFieldBean.setFieldvalue(overtimeEnable_value);
hrmFieldBean.setIsFormField(true);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
Map<String, Object> otherParamsMap = new HashMap<String, Object>();
otherParamsMap.put("display", "switch");
searchConditionItem.setOtherParams(otherParamsMap);
itemList.add(searchConditionItem);
String computingMode_key = "computingMode"+changetype_index;
String computingMode_value = isEdit?Util.null2String(valueMap.get(computingMode_key),"1"):"1";
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname(computingMode_key);//加班方式
hrmFieldBean.setFieldlabel("388834");
hrmFieldBean.setFieldhtmltype("5");
hrmFieldBean.setType("1");
hrmFieldBean.setIsFormField(true);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
List<SearchConditionOption> statusOptions = new ArrayList<SearchConditionOption>();
statusOptions.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(500382, user.getLanguage()),"1".equalsIgnoreCase(computingMode_value)));
statusOptions.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(500383, user.getLanguage()),"2".equalsIgnoreCase(computingMode_value)));
statusOptions.add(new SearchConditionOption("4", SystemEnv.getHtmlLabelName(524827, user.getLanguage()),"4".equalsIgnoreCase(computingMode_value)));
statusOptions.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(390837, user.getLanguage()),"3".equalsIgnoreCase(computingMode_value)));
searchConditionItem.setOptions(statusOptions);
searchConditionItem.setDetailtype(3);
itemList.add(searchConditionItem);
if(changetype_index == 2){
String startTime_key = "startTime"+changetype_index;
String startTime_value = isEdit?Util.null2String(valueMap.get(startTime_key),"30"):"30";
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname(startTime_key);//工作日下班多少分钟后开始计算加班
hrmFieldBean.setFieldlabel("388842");
hrmFieldBean.setFieldhtmltype("1");
hrmFieldBean.setType("2");
hrmFieldBean.setViewAttr(3);
hrmFieldBean.setFieldvalue(startTime_value);
hrmFieldBean.setIsFormField(true);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
searchConditionItem.setRules("required|integer");
searchConditionItem.setMin("0");
itemList.add(searchConditionItem);
String before_startTime_key = "before_startTime"+changetype_index;
String before_startTime_value = isEdit?Util.null2String(valueMap.get(before_startTime_key),"0"):"0";
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname(before_startTime_key);//工作日上班前多少分钟后开始计算加班
hrmFieldBean.setFieldlabel("388842");
hrmFieldBean.setFieldhtmltype("1");
hrmFieldBean.setType("2");
hrmFieldBean.setViewAttr(3);
hrmFieldBean.setFieldvalue(before_startTime_value);
hrmFieldBean.setIsFormField(true);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
searchConditionItem.setRules("required|integer");
searchConditionItem.setMin("0");
itemList.add(searchConditionItem);
}
String minimumLen_key = "minimumLen"+changetype_index;
String minimumLen_value = isEdit?Util.null2String(valueMap.get(minimumLen_key),"30"):"30";
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname(minimumLen_key);//最小加班时长
hrmFieldBean.setFieldlabel("388843");
hrmFieldBean.setFieldhtmltype("1");
hrmFieldBean.setType("2");
hrmFieldBean.setViewAttr(3);
hrmFieldBean.setFieldvalue(minimumLen_value);
hrmFieldBean.setIsFormField(true);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
searchConditionItem.setRules("required|integer");
searchConditionItem.setMin("1");
itemList.add(searchConditionItem);
String paidLeaveEnableType_key = "paidLeaveEnableType"+changetype_index;
String paidLeaveEnableType_value = isEdit?Util.null2String(valueMap.get(paidLeaveEnableType_key),"1"):"1";
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname(paidLeaveEnableType_key);//加班补偿方式
hrmFieldBean.setFieldlabel("388838");
hrmFieldBean.setFieldhtmltype("5");
hrmFieldBean.setType("1");
hrmFieldBean.setIsFormField(true);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
List<SearchConditionOption> paidLeaveEnableOptions = new ArrayList<SearchConditionOption>();
paidLeaveEnableOptions.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(524828, user.getLanguage()),"1".equalsIgnoreCase(paidLeaveEnableType_value)));
paidLeaveEnableOptions.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(524833, user.getLanguage()),"2".equalsIgnoreCase(paidLeaveEnableType_value)));
searchConditionItem.setOptions(paidLeaveEnableOptions);
searchConditionItem.setDetailtype(3);
itemList.add(searchConditionItem);
String paidLeaveEnableDefaultType_key = "paidLeaveEnableDefaultType"+changetype_index;
String paidLeaveEnableDefaultType_value = isEdit?Util.null2String(valueMap.get(paidLeaveEnableDefaultType_key),"1"):"1";
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname(paidLeaveEnableDefaultType_key);//默认加班补偿方式 里转调休的方式
hrmFieldBean.setFieldlabel("524828");
hrmFieldBean.setFieldhtmltype("5");
hrmFieldBean.setType("2");
hrmFieldBean.setIsFormField(true);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
List<SearchConditionOption> paidLeaveDefaultTypeOptions = new ArrayList<SearchConditionOption>();
paidLeaveDefaultTypeOptions.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(524830, user.getLanguage()),"1".equalsIgnoreCase(paidLeaveEnableDefaultType_value)));
paidLeaveDefaultTypeOptions.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(524831, user.getLanguage()),"2".equalsIgnoreCase(paidLeaveEnableDefaultType_value)));
// 这个方式只是临时屏蔽后面可能还是会启用不要占用这个key是3的
// paidLeaveDefaultTypeOptions.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(524832, user.getLanguage()),"3".equalsIgnoreCase(paidLeaveEnableDefaultType_value)));
searchConditionItem.setOptions(paidLeaveDefaultTypeOptions);
searchConditionItem.setDetailtype(1);
itemList.add(searchConditionItem);
String paidLeaveEnableFlowType_key = "paidLeaveEnableFlowType"+changetype_index;
String paidLeaveEnableFlowType_value = isEdit?Util.null2String(valueMap.get(paidLeaveEnableFlowType_key),"1"):"1";
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname(paidLeaveEnableFlowType_key);//根据员工在加班流程上选择的加班补偿类型进行补偿
hrmFieldBean.setFieldlabel("524833");
hrmFieldBean.setFieldhtmltype("5");
hrmFieldBean.setType("2");
hrmFieldBean.setIsFormField(true);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
List<SearchConditionOption> paidLeaveFlowTypeOptions = new ArrayList<SearchConditionOption>();
paidLeaveFlowTypeOptions.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(524830, user.getLanguage()),"1".equalsIgnoreCase(paidLeaveEnableFlowType_value)));
paidLeaveFlowTypeOptions.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(524831, user.getLanguage()),"2".equalsIgnoreCase(paidLeaveEnableFlowType_value)));
// 这个方式只是临时屏蔽后面可能还是会启用不要占用这个key是3的
// paidLeaveFlowTypeOptions.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(524832, user.getLanguage()),"3".equalsIgnoreCase(paidLeaveEnableFlowType_value)));
searchConditionItem.setOptions(paidLeaveFlowTypeOptions);
searchConditionItem.setDetailtype(1);
itemList.add(searchConditionItem);
String paidLeaveEnable_key = "paidLeaveEnable"+changetype_index;
String paidLeaveEnable_value = isEdit?Util.null2String(valueMap.get(paidLeaveEnable_key),"0"):"0";
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname(paidLeaveEnable_key);//是否允许加班转调休
hrmFieldBean.setFieldlabel("388838");
hrmFieldBean.setFieldhtmltype("4");
hrmFieldBean.setType("1");
hrmFieldBean.setFieldvalue(paidLeaveEnable_value);
hrmFieldBean.setIsFormField(true);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
itemList.add(searchConditionItem);
String lenOfOvertime_key = "lenOfOvertime"+changetype_index;
String lenOfOvertime_value = isEdit?Util.null2String(valueMap.get(lenOfOvertime_key),"1"):"1";
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname(lenOfOvertime_key);//加班转调休比例中的加班时长
hrmFieldBean.setFieldlabel("389222");
hrmFieldBean.setFieldhtmltype("1");
hrmFieldBean.setType("2");
hrmFieldBean.setViewAttr(3);
hrmFieldBean.setFieldvalue(lenOfOvertime_value);
hrmFieldBean.setIsFormField(true);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
searchConditionItem.setRules("required|numeric");
searchConditionItem.setStep("0.01");
searchConditionItem.setPrecision(2);
itemList.add(searchConditionItem);
String lenOfLeave_key = "lenOfLeave"+changetype_index;
String lenOfLeave_value = isEdit?Util.null2String(valueMap.get(lenOfLeave_key),"1"):"1";
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname(lenOfLeave_key);//加班转调休比例中的调休时长
hrmFieldBean.setFieldlabel("389223");
hrmFieldBean.setFieldhtmltype("1");
hrmFieldBean.setType("2");
hrmFieldBean.setViewAttr(3);
hrmFieldBean.setFieldvalue(lenOfLeave_value);
hrmFieldBean.setIsFormField(true);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
searchConditionItem.setRules("required|numeric");
searchConditionItem.setStep("0.01");
searchConditionItem.setPrecision(2);
itemList.add(searchConditionItem);
String hasRestTime_key = "hasRestTime"+changetype_index;
String hasRestTime_value = isEdit?Util.null2String(valueMap.get(hasRestTime_key),"0"):"0";
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname(hasRestTime_key);//排除休息时间
hrmFieldBean.setFieldlabel("388565");
hrmFieldBean.setFieldhtmltype("4");
hrmFieldBean.setType("1");
hrmFieldBean.setFieldvalue(hasRestTime_value);
hrmFieldBean.setIsFormField(true);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
otherParamsMap = new HashMap<String, Object>();
otherParamsMap.put("display", "switch");
searchConditionItem.setOtherParams(otherParamsMap);
itemList.add(searchConditionItem);
String restTimeType_key = "restTimeType"+changetype_index;
String restTimeType_value = isEdit?Util.null2String(valueMap.get(restTimeType_key),"1"):"1";
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname(restTimeType_key);//排除休息时间类型
hrmFieldBean.setFieldlabel("388565");
hrmFieldBean.setFieldhtmltype("5");
hrmFieldBean.setType("1");
hrmFieldBean.setIsFormField(true);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
List<SearchConditionOption> restTimeTypeOptions = new ArrayList<SearchConditionOption>();
restTimeTypeOptions.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(525905, user.getLanguage()),"1".equalsIgnoreCase(restTimeType_value)));
restTimeTypeOptions.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(524834, user.getLanguage()),"2".equalsIgnoreCase(restTimeType_value)));
searchConditionItem.setOptions(restTimeTypeOptions);
searchConditionItem.setDetailtype(3);
itemList.add(searchConditionItem);
String has_cut_point_key = "has_cut_point"+changetype_index;
String has_cut_point_value = isEdit?Util.null2String(valueMap.get(has_cut_point_key),"0"):"0";
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname(has_cut_point_key);// 是否开启 自定义跨天加班归属分界点
hrmFieldBean.setFieldlabel("524835");
hrmFieldBean.setFieldhtmltype("4");
hrmFieldBean.setType("2");
hrmFieldBean.setFieldvalue(has_cut_point_value);
hrmFieldBean.setIsFormField(true);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
itemList.add(searchConditionItem);
String cut_point_key = "cut_point"+changetype_index;
String cut_point_value = isEdit?Util.null2String(valueMap.get(cut_point_key),"00:00"):"00:00";
if("0".equalsIgnoreCase(has_cut_point_value)){
cut_point_value = "00:00";
}
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname(cut_point_key);// 自定义跨天加班归属分界点
hrmFieldBean.setFieldlabel("524835");
hrmFieldBean.setFieldhtmltype("3");
hrmFieldBean.setType("19");
hrmFieldBean.setFieldvalue(cut_point_value);
hrmFieldBean.setIsFormField(true);
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
itemList.add(searchConditionItem);
// 2是工作日3是休息日1是节假日
if(changetype_index == 2){
groupItem.put("title", SystemEnv.getHtmlLabelName(388841, user.getLanguage()));//工作日加班
}else if(changetype_index == 3){
groupItem.put("title", SystemEnv.getHtmlLabelName(389730, user.getLanguage()));//休息日加班
}else if(changetype_index == 1){
groupItem.put("title", SystemEnv.getHtmlLabelName(1959, user.getLanguage()));//节假日加班
}
groupItem.put("defaultshow", true);
groupItem.put("items", itemList);
groupList.add(groupItem);
}
resultMap.put("condition", groupList);
/**
*
*/
sql = "select * from kq_LeaveRules where (isDelete is null or isDelete <>1) and id in (select ruleId from kq_LeaveRulesDetail where (isDelete is null or isDelete <>1) and distributionMode=5)";
recordSet.executeQuery(sql);
boolean hasTXRules = recordSet.getCounts()>0;
resultMap.put("hasTXrules",hasTXRules);
return resultMap;
}
private void set_TimeDetailList(String detailid, int changetype_index, Map<String, Object> resultMap) {
RecordSet recordSet = new RecordSet();
List timeDetailList = new ArrayList();
String sql = "select * from kq_OvertimeBalanceTimeDetail where rulesdetailid=? order by timepoint";
recordSet.executeQuery(sql, detailid);
while (recordSet.next()) {
String timepoint = recordSet.getString("timepoint");
String lenOfOvertime = recordSet.getString("lenOfOvertime");
String lenOfLeave = recordSet.getString("lenOfLeave");
String dsporder = recordSet.getString("dsporder");
Map<String, Object> timeDetailMap = new HashMap<String, Object>();
timeDetailMap.put("time", timepoint);
timeDetailMap.put("left", lenOfOvertime);
timeDetailMap.put("right", lenOfLeave);
timeDetailMap.put("dsporder", dsporder);
timeDetailList.add(timeDetailMap);
}
if(!timeDetailList.isEmpty()){
resultMap.put("paidLeaveEnableTypeRule"+changetype_index, timeDetailList);
}
}
private void set_lengthDetailList(String detailid, int changetype_index,
Map<String, Object> resultMap){
RecordSet recordSet = new RecordSet();
List lengthDetailList = new ArrayList();
String sql = "select * from kq_OvertimeBalanceLengthDetail where rulesdetailid=? order by overtimelength";
recordSet.executeQuery(sql, detailid);
while (recordSet.next()) {
String overtimelength = recordSet.getString("overtimelength");
String balancelength = recordSet.getString("balancelength");
String dsporder = recordSet.getString("dsporder");
Map<String, Object> lengthDetailMap = new HashMap<String, Object>();
lengthDetailMap.put("work", overtimelength);
lengthDetailMap.put("rest", balancelength);
lengthDetailMap.put("dsporder", dsporder);
lengthDetailList.add(lengthDetailMap);
}
if(!lengthDetailList.isEmpty()){
resultMap.put("paidLeaveEnableTypeRule"+changetype_index, lengthDetailList);
}
}
}

@ -0,0 +1,67 @@
package com.engine.kq.cmd.overtimerules;
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 weaver.conn.RecordSet;
import weaver.general.PageIdConst;
import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import weaver.systeminfo.SystemEnv;
import java.util.HashMap;
import java.util.Map;
/**
* --
*/
public class GetSearchListCmd extends AbstractCommonCommand<Map<String, Object>> {
public GetSearchListCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
}
@Override
public BizLogContext getLogContext() {
return null;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> resultMap = new HashMap<String, Object>();
boolean canEdit = HrmUserVarify.checkUserRight("KQOvertimeRulesEdit:Edit", user);//是否具有编辑的权限;
boolean canDelete = HrmUserVarify.checkUserRight("KQOvertimeRulesDelete:Delete", user);//是否具有删除的权限;
boolean canLog = HrmUserVarify.checkUserRight("KQOvertimeRules:Log", user);//是否具有查看日志的权限;
String backFields = " id,name,groupIds ";
String sqlFrom = " from kq_OvertimeRules ";
String sqlWhere = " where 1=1 and (isDelete is null or isDelete!=1) ";
String orderBy = " id ";
String pageUid = "1b3ad739-67fa-8b1e-1c19-6d37c1a33469";
String operateString = "";
operateString = "<operates width=\"20%\">";
operateString += "<popedom transmethod=\"weaver.hrm.common.SplitPageTagOperate.getBasicOperate\" otherpara=\"" + canEdit + ":" + canDelete + ":" + canLog + "\"></popedom> ";
operateString += " <operate href=\"javascript:openDialog();\" text=\"" + SystemEnv.getHtmlLabelName(93, user.getLanguage()) + "\" index=\"0\"/>";
operateString += " <operate href=\"javascript:doDel()\" text=\"" + SystemEnv.getHtmlLabelName(91, user.getLanguage()) + "\" index=\"1\"/>";
operateString += " <operate href=\"javascript:onLog()\" text=\"" + SystemEnv.getHtmlLabelName(83, user.getLanguage()) + "\" index=\"2\"/>";
operateString += "</operates>";
String tableString = "" +
"<table pageId=\"Hrm:OvertimeRules\" pageUid=\"" + pageUid + "\" tabletype=\"checkbox\" pagesize=\"" + PageIdConst.getPageSize("Hrm:OvertimeRules", user.getUID(), PageIdConst.HRM) + "\" >" +
" <sql backfields=\"" + backFields + "\" sqlform=\"" + sqlFrom + "\" sqlwhere=\"" + Util.toHtmlForSplitPage(sqlWhere) + "\" sqlorderby=\"" + orderBy + "\" sqlprimarykey=\"id\" sqlsortway=\"asc\" sqlisdistinct=\"false\"/>"
+ operateString +
" <head>" +
" <col width=\"25%\" text=\"" + SystemEnv.getHtmlLabelName(388831, user.getLanguage()) + "\" column=\"name\" transmethod=\"weaver.general.Util.formatMultiLang\" otherpara=\"" + user.getLanguage() + "\" orderkey=\"name\"/>" +
" <col width=\"40%\" text=\"" + SystemEnv.getHtmlLabelName(388832, user.getLanguage()) + "\" column=\"id\" transmethod=\"com.engine.kq.util.KQTransMethod.getRuleContent\" otherpara=\"" + user.getLanguage() + "\"/>" +
" <col width=\"25%\" text=\"" + SystemEnv.getHtmlLabelName(19374, user.getLanguage()) + "\" column=\"groupIds\" transmethod=\"com.engine.kq.util.KQTransMethod.getGroupName\" otherpara=\"" + user.getLanguage() + "\" />" +
" </head>" +
"</table>";
String sessionKey = pageUid + "_" + Util.getEncrypt(Util.getRandom());
Util_TableMap.setVal(sessionKey, tableString);
resultMap.put("sessionkey", sessionKey);
return resultMap;
}
}

@ -0,0 +1,70 @@
package com.engine.kq.cmd.overtimerules;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import weaver.conn.RecordSet;
import weaver.general.Util;
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 IsRepeatSettingCmd extends AbstractCommonCommand<Map<String, Object>> {
public IsRepeatSettingCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
}
@Override
public BizLogContext getLogContext() {
return null;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> resultMap = new HashMap<String, Object>();
String ruleId = Util.null2String(params.get("ruleId"));//加班规则的ID
String groupIds = Util.null2String(params.get("groupIds"));//考勤组的ID
List<String> errMsgList = new ArrayList<String>();//考勤组重复设置了加班规则的错误信息提示集合
RecordSet recordSet = new RecordSet();
String[] groupIdArr = groupIds.split(",");
for (int i = 0; i < groupIdArr.length; i++) {
String groupId = groupIdArr[i];
String groupName = "";//考勤组的名称
String sql = "select * from kq_overtimeRules where (isDelete is null or isDelete!=1) ";
if (recordSet.getDBType().equalsIgnoreCase("sqlserver")) {
sql += " and ','+groupIds+',' like '%," + groupId + ",%'";
} else if (recordSet.getDBType().equalsIgnoreCase("mysql")) {
sql += " and contract(',',groupIds,',') like '%," + groupId + ",%'";
} else {
sql += " and ','||groupIds||',' like '%," + groupId + ",%'";
}
if (!ruleId.equals("")) {
sql += " and ruleId not in (" + ruleId + ")";
}
recordSet.executeQuery(sql);
if (recordSet.next()) {
errMsgList.add(groupName + SystemEnv.getHtmlLabelName(81869, user.getLanguage()));
}
}
if(errMsgList.size()==0){
resultMap.put("isRepeatSetting",false);
}else{
resultMap.put("isRepeatSetting",true);
resultMap.put("message",errMsgList);
}
return resultMap;
}
}

@ -0,0 +1,115 @@
package com.engine.kq.cmd.overtimerules;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.biz.SimpleBizLogger;
import com.engine.common.constant.BizLogSmallType4Hrm;
import com.engine.common.constant.BizLogType;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.kq.biz.KQAttFlowSetComInfo;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import weaver.systeminfo.SystemEnv;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* --
*/
public class SaveOvertimeUnitCmd extends AbstractCommonCommand<Map<String, Object>> {
private SimpleBizLogger logger;
public SaveOvertimeUnitCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
this.logger = new SimpleBizLogger();
BizLogContext bizLogContext = new BizLogContext();
bizLogContext.setLogType(BizLogType.HRM_ENGINE);//模块类型
bizLogContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_OVERTIMEUNIT);//所属大类型
bizLogContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_KQ_OVERTIMEUNIT);//当前小类型
bizLogContext.setParams(params);//当前request请求参数
logger.setUser(user);//当前操作人
String mainSql = "select * from kq_overtimeUnit";
logger.setMainSql(mainSql, "id");//主表sql
logger.setMainPrimarykey("id");//主日志表唯一key
logger.setMainTargetNameMethod("com.engine.kq.util.KQTransMethod.getTargetName4OvertimeUnit",""+user.getLanguage());
logger.before(bizLogContext);
}
@Override
public BizLogContext getLogContext() {
return null;
}
@Override
public List<BizLogContext> getLogContexts() {
return logger.getBizLogContexts();
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> resultMap = new HashMap<String, Object>();
/* 加班规则维护权限 */
boolean canAdd = HrmUserVarify.checkUserRight("KQOvertimeRulesAdd:Add", user);//是否具有新建权限
boolean canEdit = HrmUserVarify.checkUserRight("KQOvertimeRulesEdit:Edit", user);//是否具有编辑的权限;
if (!canAdd && !canEdit) {
resultMap.put("status", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage()));
return resultMap;
}
//是否设置了【流程和打卡取交集的加班方式】
boolean hasComputingmode4 = false;
RecordSet recordSet1 = new RecordSet();
String checkSql = "select * from kq_overtimerulesdetail where computingmode = 4 and ruleid not in(select id from kq_overtimerules where isdelete =1) ";
recordSet1.executeQuery(checkSql);
if(recordSet1.next()){
hasComputingmode4 = true;
}
int id = 1;////暂为备用字段加班单位ID固定为1
int minimumUnit = Util.getIntValue((String) params.get("minimumUnit"), 1);//最小加班单位1-按天加班、2-按半天加班、3-按小时加班、4-按整天加班
int overtimeConversion = Util.getIntValue((String) params.get("overtimeConversion"), 1);//加班时长折算方式1-四舍五入、2-向上取整、3-向下取整
double hoursToday = Util.getDoubleValue((String) params.get("hoursToday"), -1.00);//日折算时长
int timeselection = Util.getIntValue((String) params.get("timeselection"), 1);//半天单位 时间选择方式1-下拉框选择 、2-具体时间
if(hasComputingmode4){
if(minimumUnit == 2 || minimumUnit == 4){
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(529168, user.getLanguage()));
return resultMap;
}
}
if(minimumUnit != 2){
RecordSet rs = new RecordSet();
//如果出差单位不再是半天了,需要删除原半天设置
String del_2_sql = "delete from kq_timeselection where selectiontype=3 and minimumUnit=2";
boolean is_2_del = rs.executeUpdate(del_2_sql);
}
boolean flag = true;
String sql = "update kq_OvertimeUnit set minimumUnit=?,hoursToday=?,timeselection=?,overtimeConversion=? where id=?";
RecordSet recordSet = new RecordSet();
flag = recordSet.executeUpdate(sql, minimumUnit, hoursToday,timeselection,overtimeConversion, id);
if (flag) {
resultMap.put("sign", "1");
resultMap.put("message", SystemEnv.getHtmlLabelName(83551, user.getLanguage()));//保存成功
} else {
resultMap.put("sign", "-1");
resultMap.put("message", SystemEnv.getHtmlLabelName(84544, user.getLanguage()));//保存失败
}
KQAttFlowSetComInfo kqAttFlowSetComInfo = new KQAttFlowSetComInfo();
kqAttFlowSetComInfo.removeKQAttFlowSetComInfoCache();
return resultMap;
}
}

@ -0,0 +1,431 @@
package com.engine.kq.cmd.shiftmanagement;
import com.api.browser.bean.SearchConditionItem;
import com.api.browser.bean.SearchConditionOption;
import com.api.hrm.bean.HrmFieldBean;
import com.api.hrm.util.HrmFieldSearchConditionComInfo;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import weaver.hrm.company.SubCompanyComInfo;
import weaver.hrm.moduledetach.ManageDetachComInfo;
import weaver.systeminfo.SystemEnv;
import weaver.systeminfo.systemright.CheckSubCompanyRight;
/**
*
* @author pzy
*
*/
public class GetShiftManagementBaseFormCmd extends AbstractCommonCommand<Map<String, Object>>{
public GetShiftManagementBaseFormCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
}
@Override
public BizLogContext getLogContext() {
// TODO Auto-generated method stub
return null;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> retmap = new HashMap<String, Object>();
List<Map<String, Object>> grouplist = new ArrayList<Map<String, Object>>();
Map<String, Object> groupitem = null;
List<Object> itemlist = null;
RecordSet rs = new RecordSet();
RecordSet rs1 = new RecordSet();
String sql = "";
try {
if(!HrmUserVarify.checkUserRight("KQClass:Management",user)) {
retmap.put("status", "-1");
retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage()));
return retmap;
}
CheckSubCompanyRight newCheck=new CheckSubCompanyRight();
ManageDetachComInfo manageDetachComInfo = new ManageDetachComInfo();
boolean hrmdetachable = manageDetachComInfo.isUseHrmManageDetach();//是否开启了人力资源模块的管理分权
String hrmdftsubcomid = manageDetachComInfo.getHrmdftsubcomid();//分权默认分部
SubCompanyComInfo sc = new SubCompanyComInfo();
String _id = Util.null2String(params.get("id"));
String subcompanyid = Util.null2String(params.get("subcompanyid"));
boolean isEdit = false;
List<Object> workSectionList = new ArrayList<>();
Map<String,Object> groupSectionMaps = new HashMap<>();//分组用的map
Map<String,Object> sectionMaps = new HashMap<>();
Map<String,Object> sectionMap = new HashMap<>();
//现在休息时段还是只能设置一个的对于以后可能出现的多个休息时段预留这个map
List<Object> restSectionsList = new ArrayList<>();
Map<String,Object> restSectionsMap = new HashMap<>();
String[] fields = new String[]{"serial,125818,1,1","subcompanyid,141,3,169","shiftonoffworkcount,388563,5,3","punchsettings,388564,4,1",
"isresttimeopen,388565,4,2","restbeigin,388566,3,19","restend,388567,3,19","halfcalrule,513090,5,1","cardRemind,507833,4,2","cardRemOfSignIn,507835,5,1",
"minsBeforeSignIn,510106,1,2","cardRemOfSignOut,507837,5,1","minsAfterSignOut,510108,1,2","remindMode,501471,5,3","remindOnPC,513233,4,2",
"isoffdutyfreecheck,388568,4,2","halfcalpoint,513145,3,19","halfcalpoint2cross,513090,5,1"};
Map<String,String> shiftValMap = new HashMap<>();
if(_id.length() > 0){
String getShiftInfo = "select * from kq_ShiftManagement where (isdelete is null or isdelete <> '1') and id = ?";
rs.executeQuery(getShiftInfo, _id);
if(rs.next()){
for(int i = 0 ; i < fields.length ; i++){
String[] tmpField = Util.null2String(fields[i]).split(",");
String fieldname = tmpField[0];
String fieldvalue = rs.getString(fieldname);
if("shiftonoffworkcount".equalsIgnoreCase(fieldname) ||
"punchsettings".equalsIgnoreCase(fieldname) ||
"cardRemOfSignIn".equalsIgnoreCase(fieldname) ||
"cardRemOfSignOut".equalsIgnoreCase(fieldname) ||
"remindMode".equalsIgnoreCase(fieldname)){
fieldvalue = Util.null2s(fieldvalue, "1");
}else if("isresttimeopen".equalsIgnoreCase(fieldname) ||
"halfcalrule".equalsIgnoreCase(fieldname) ||
"cardRemind".equalsIgnoreCase(fieldname) ||
"minsAfterSignOut".equalsIgnoreCase(fieldname) ||
"remindOnPC".equalsIgnoreCase(fieldname) ||
"isoffdutyfreecheck".equalsIgnoreCase(fieldname) ||
"halfcalpoint".equalsIgnoreCase(fieldname) ||
"halfcalpoint2cross".equalsIgnoreCase(fieldname)){
fieldvalue = Util.null2s(fieldvalue, "0");
}else if("minsBeforeSignIn".equalsIgnoreCase(fieldname)){
fieldvalue = Util.null2s(fieldvalue, "10");
}else if("subcompanyid".equalsIgnoreCase(fieldname)){
subcompanyid = fieldvalue;
}
shiftValMap.put(fieldname, fieldvalue);
}
}
String getWorkSections = "select * from kq_ShiftOnOffWorkSections where (isdelete is null or isdelete <> '1') and serialid = ? order by record ";
rs.executeQuery(getWorkSections, _id);
while(rs.next()){
String record = rs.getString("record");
if(record.length() == 0) {
continue;
}
String onoffworktype = Util.null2String(rs.getString("onoffworktype"));
String across = Util.null2String(rs.getString("across"));
String times = Util.null2String(rs.getString("times"));
String mins = Util.null2String(rs.getString("mins"));
String mins_next = Util.null2String(rs.getString("mins_next"));
String clockinnot = Util.null2String(rs.getString("clockinnot"));
sectionMap = new HashMap<>();
sectionMaps = new HashMap<>();
sectionMap.put("across", across);
sectionMap.put("times", times);
sectionMap.put("mins", mins);
sectionMap.put("mins_next", mins_next);
sectionMap.put("clockinnot", clockinnot);
sectionMaps.put(onoffworktype, sectionMap);
if(groupSectionMaps.get(record) != null){
List<Object> tmpSections = (List<Object>) groupSectionMaps.get(record);
((Map<String,Object>)tmpSections.get(tmpSections.size()-1)).putAll(sectionMaps);
}else{
sectionMaps.put("record", record);
workSectionList.add(sectionMaps);
groupSectionMaps.put(record, workSectionList);
}
}
groupSectionMaps = new HashMap<>();
sectionMaps = new HashMap<>();
String getRestSections = "select * from kq_ShiftRestTimeSections where (isdelete is null or isdelete <> '1') and serialid = ? order by orderId ";
rs.executeQuery(getRestSections, _id);
while(rs.next()){
String resttype = Util.null2String(rs.getString("resttype"));
String across = Util.null2String(rs.getString("across"));
String times = Util.null2String(rs.getString("time"));
String record = Util.null2String(rs.getString("record1"));
String orderId = Util.null2String(rs.getString("orderId"));
restSectionsMap = new HashMap<>();
sectionMaps = new HashMap<>();
restSectionsMap.put("resttype", resttype);
restSectionsMap.put("time", times);
restSectionsMap.put("across", across);
restSectionsMap.put("record", record);
restSectionsMap.put("orderId", orderId);
sectionMaps.put(resttype, restSectionsMap);
if(groupSectionMaps.get(record) != null){
List<Object> tmpSections = (List<Object>) groupSectionMaps.get(record);
((Map<String,Object>)tmpSections.get(tmpSections.size()-1)).putAll(sectionMaps);
}else{
sectionMaps.put("record", record);
restSectionsList.add(sectionMaps);
groupSectionMaps.put(record, restSectionsList);
}
}
isEdit = true;
}
//班次名称 所属机构(开启分权有所属机构) 一天内上下班次数 打卡时段是否开启 排除休息时间是否开启 休息开始时间 休息结束时间 允许下班不打卡
HrmFieldBean hrmFieldBean = null;
HrmFieldSearchConditionComInfo hrmFieldSearchConditionComInfo = new HrmFieldSearchConditionComInfo();
SearchConditionItem searchConditionItem = null;
List<SearchConditionOption> options = new ArrayList<SearchConditionOption>();
groupitem = new HashMap<String, Object>();
itemlist = new ArrayList<Object>();
for (int j = 0; j < fields.length; j++) {
options = new ArrayList<SearchConditionOption>();
String[] tmpField = Util.null2String(fields[j]).split(",");
String fieldname = tmpField[0];
String beanVal = Util.null2String(shiftValMap.get(fieldname));
hrmFieldBean = new HrmFieldBean();
hrmFieldBean.setFieldname(fieldname);
hrmFieldBean.setFieldlabel(tmpField[1]);
hrmFieldBean.setFieldhtmltype(tmpField[2]);
hrmFieldBean.setType(tmpField[3]);
hrmFieldBean.setIsFormField(true);
if("serial".equalsIgnoreCase(tmpField[0]) || "restbeigin".equalsIgnoreCase(tmpField[0]) || "restend".equalsIgnoreCase(tmpField[0])){
hrmFieldBean.setViewAttr(3);
hrmFieldBean.setRules("required|string");
}
if("shiftonoffworkcount".equalsIgnoreCase(tmpField[0]) || "restbeigin".equalsIgnoreCase(tmpField[0]) || "restend".equalsIgnoreCase(tmpField[0])){
hrmFieldBean.setRules("required|string");
if(!isEdit){
if("restbeigin".equalsIgnoreCase(tmpField[0])){
hrmFieldBean.setFieldvalue("12:00");
}
if("restend".equalsIgnoreCase(tmpField[0])){
hrmFieldBean.setFieldvalue("13:00");
}
}
}
// if("color".equalsIgnoreCase(tmpField[0])){
// hrmFieldBean.setTip(SystemEnv.getHtmlLabelName(389509, user.getLanguage()));
// }
if(!isEdit){
if("isresttimeopen".equalsIgnoreCase(tmpField[0])){
hrmFieldBean.setFieldvalue("0");
}
if("isoffdutyfreecheck".equalsIgnoreCase(tmpField[0])){
hrmFieldBean.setFieldvalue("0");
}
if("punchsettings".equalsIgnoreCase(tmpField[0])){
hrmFieldBean.setFieldvalue("1");
}
// if("color".equalsIgnoreCase(tmpField[0])){
// hrmFieldBean.setFieldvalue("#000");
// }
if("cardRemOfSignIn".equals(hrmFieldBean.getFieldname())){
beanVal = "1";
}
if("minsBeforeSignIn".equals(hrmFieldBean.getFieldname())){
beanVal = "10";
}
if("cardRemOfSignOut".equals(hrmFieldBean.getFieldname())){
beanVal = "1";
}
if("minsAfterSignOut".equals(hrmFieldBean.getFieldname())){
beanVal = "0";
}
if("remindMode".equals(hrmFieldBean.getFieldname())){
beanVal = "1";
}
if("halfcalrule".equals(hrmFieldBean.getFieldname())){
hrmFieldBean.setFieldvalue("0");
}
if("halfcalpoint2cross".equals(hrmFieldBean.getFieldname())){
hrmFieldBean.setFieldvalue("0");
}
}
if("shiftonoffworkcount".equals(tmpField[0])){
SearchConditionOption SearchConditionOption_1 = new SearchConditionOption("1",SystemEnv.getHtmlLabelName(388569, user.getLanguage()));
SearchConditionOption SearchConditionOption_2 = new SearchConditionOption("2",SystemEnv.getHtmlLabelName(388570, user.getLanguage()));
SearchConditionOption SearchConditionOption_3 = new SearchConditionOption("3",SystemEnv.getHtmlLabelName(388571, user.getLanguage()));
if(isEdit){
if("1".equalsIgnoreCase(beanVal)){
SearchConditionOption_1.setSelected(true);
}else if("2".equalsIgnoreCase(beanVal)){
SearchConditionOption_2.setSelected(true);
}else if("3".equalsIgnoreCase(beanVal)){
SearchConditionOption_3.setSelected(true);
}
}else{
SearchConditionOption_1.setSelected(true);
}
options.add(SearchConditionOption_1);
options.add(SearchConditionOption_2);
options.add(SearchConditionOption_3);
hrmFieldBean.setSelectOption(options);
}
if(isEdit){
hrmFieldBean.setFieldvalue(beanVal);
}
if("subcompanyid".equals(tmpField[0])){
if(hrmdetachable){
hrmFieldBean.setViewAttr(3);
hrmFieldBean.setRules("required|string");
String defaultSubcompanyid = "";
int[] subcomids = newCheck.getSubComByUserRightId(user.getUID(),"KQClass:Management",0);
ManageDetachComInfo detachComInfo = new ManageDetachComInfo();
if(detachComInfo.isUseHrmManageDetach()){
defaultSubcompanyid = detachComInfo.getHrmdftsubcomid();
}else{
rs.executeProc("SystemSet_Select","");
if(rs.next()){
if(subcompanyid.length()==0||subcompanyid.equals("0")){
defaultSubcompanyid = Util.null2String(rs.getString("dftsubcomid"));
}
}
}
boolean hasRight = false;
for (int i = 0; subcomids!=null&& i < subcomids.length; i++) {
if((""+subcomids[i]).equals(defaultSubcompanyid)){
hasRight = true;
break;
}
}
if(!hasRight){
defaultSubcompanyid = "";
}
//表示左侧分部树选择了
if(Util.getIntValue(Util.null2String(subcompanyid)) > 0){
hrmFieldBean.setFieldvalue(subcompanyid);
}else{
hrmFieldBean.setFieldvalue(defaultSubcompanyid);
}
}else{
//不开启分权的话,不显示分部
continue;
}
}
if("punchsettings".equalsIgnoreCase(tmpField[0])){
hrmFieldBean.setFieldvalue("1");
}
searchConditionItem = hrmFieldSearchConditionComInfo.getSearchConditionItem(hrmFieldBean, user);
if("shiftonoffworkcount".equals(tmpField[0])){
// searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(388574, user.getLanguage()));
}
if("isoffdutyfreecheck".equals(tmpField[0])){
searchConditionItem.setHelpfulTip(SystemEnv.getHtmlLabelName(388573, user.getLanguage()));
}
if(hrmdetachable && "subcompanyid".equals(tmpField[0])){
searchConditionItem.getBrowserConditionParam().getDataParams().put("rightStr", "KQClass:Management");
searchConditionItem.getBrowserConditionParam().getCompleteParams().put("rightStr", "KQClass:Management");
}
if("cardRemOfSignIn".equals(hrmFieldBean.getFieldname())){
List<SearchConditionOption> optionsList = new ArrayList<SearchConditionOption>();
optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(19782, user.getLanguage()), "0".equals(beanVal)));
optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(510106, user.getLanguage()), "1".equals(beanVal)));
searchConditionItem.setOptions(optionsList);
searchConditionItem.setValue(beanVal);
}
if("minsBeforeSignIn".equals(hrmFieldBean.getFieldname())||"minsAfterSignOut".equals(hrmFieldBean.getFieldname())){
searchConditionItem.setValue(beanVal);
searchConditionItem.setMin("0");
searchConditionItem.setViewAttr(3);
searchConditionItem.setRules("required|integer");
}
if("cardRemOfSignOut".equals(hrmFieldBean.getFieldname())){
List<SearchConditionOption> optionsList = new ArrayList<SearchConditionOption>();
optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(19782, user.getLanguage()), "0".equals(beanVal)));
optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(510108, user.getLanguage()), "1".equals(beanVal)));
searchConditionItem.setOptions(optionsList);
searchConditionItem.setValue(beanVal);
}
if("remindMode".equals(hrmFieldBean.getFieldname())){
List<SearchConditionOption> optionsList = new ArrayList<SearchConditionOption>();
optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(383607, user.getLanguage()), "1".equals(beanVal)));
optionsList.add(new SearchConditionOption("2", SystemEnv.getHtmlLabelName(18845, user.getLanguage()), "2".equals(beanVal)));
optionsList.add(new SearchConditionOption("3", SystemEnv.getHtmlLabelName(17586, user.getLanguage()), "3".equals(beanVal)));
searchConditionItem.setOptions(optionsList);
searchConditionItem.setValue(beanVal);
}
if("halfcalrule".equals(hrmFieldBean.getFieldname())){
List<SearchConditionOption> optionsList = new ArrayList<SearchConditionOption>();
optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(513091, user.getLanguage()), "0".equals(beanVal)));
optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(513092, user.getLanguage()), "1".equals(beanVal)));
searchConditionItem.setOptions(optionsList);
}
if("halfcalpoint2cross".equals(hrmFieldBean.getFieldname())){
List<SearchConditionOption> optionsList = new ArrayList<SearchConditionOption>();
optionsList.add(new SearchConditionOption("0", SystemEnv.getHtmlLabelName(509159, user.getLanguage()), "0".equals(beanVal)));
optionsList.add(new SearchConditionOption("1", SystemEnv.getHtmlLabelName(388785, user.getLanguage()), "1".equals(beanVal)));
searchConditionItem.setOptions(optionsList);
}
searchConditionItem.setColSpan(1);
itemlist.add(searchConditionItem);
}
groupitem.put("items", itemlist);
grouplist.add(groupitem);
int operatelevel = -1;
if(hrmdetachable){
if(subcompanyid.length()>0 && !subcompanyid.equalsIgnoreCase("0")){
CheckSubCompanyRight checkSubCompanyRight = new CheckSubCompanyRight();
operatelevel=checkSubCompanyRight.ChkComRightByUserRightCompanyId(user.getUID(),"KQClass:Management",Util.getIntValue(subcompanyid,-1));
}
}else{
operatelevel = 2;
}
if(!isEdit){
operatelevel = 2;
}
if(user.getUID() == 1){
operatelevel = 2;
}
if(operatelevel > 0){
retmap.put("canAdd", true);
}else{
retmap.put("canAdd", false);
}
retmap.put("status", "1");
retmap.put("condition", grouplist);
retmap.put("workSections", workSectionList);
retmap.put("restTimeSections", restSectionsList);
if(shift_24()){
retmap.put("shift_24", "1");
}else{
retmap.put("shift_24", "0");
}
retmap.put("id", _id);
} catch (Exception e) {
retmap.put("status", "-1");
retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage()));
writeLog(e);
}
return retmap;
}
/**
* 24
* @return
*/
public boolean shift_24() {
boolean shift_24 = false;
RecordSet rs = new RecordSet();
String settingSql = "select * from KQ_SETTINGS where main_key='shift_24'";
rs.executeQuery(settingSql);
if(rs.next()){
String main_val = rs.getString("main_val");
if("1".equalsIgnoreCase(main_val)){
shift_24 = true;
}
}
return shift_24;
}
}

@ -0,0 +1,514 @@
package com.engine.kq.cmd.shiftmanagement;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.biz.SimpleBizLogger;
import com.engine.common.constant.BizLogSmallType4Hrm;
import com.engine.common.constant.BizLogType;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import com.engine.kq.biz.KQGroupBiz;
import com.engine.kq.biz.KQGroupComInfo;
import com.engine.kq.biz.KQConfigComInfo;
import com.engine.kq.biz.KQGroupBiz;
import com.engine.kq.biz.KQGroupComInfo;
import com.engine.kq.biz.KQShiftManagementComInfo;
import com.engine.kq.biz.KQShiftOnOffWorkSectionComInfo;
import com.engine.kq.biz.KQShiftRestTimeSectionComInfo;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;
import weaver.common.StringUtil;
import weaver.conn.RecordSet;
import weaver.conn.RecordSetTrans;
import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.Reminder.KQAutoCardTask;
import weaver.hrm.User;
import weaver.hrm.common.database.dialect.DbDialectFactory;
import weaver.hrm.common.database.dialect.IDbDialectSql;
import weaver.systeminfo.SystemEnv;
/**
*
* @author pzy
*
*/
public class SaveShiftManagementBaseFormCmd extends AbstractCommonCommand<Map<String, Object>>{
private SimpleBizLogger logger;
public SaveShiftManagementBaseFormCmd() {
}
public SaveShiftManagementBaseFormCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
this.logger = new SimpleBizLogger();
BizLogContext logContext = new BizLogContext();
logContext.setDateObject(new Date());
logContext.setLogType(BizLogType.HRM_ENGINE);
logContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_SHIFTMANAGER);
logContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_SHIFTMANAGER);
logContext.setParams(params);
logger.setUser(user);//当前操作人
if(params != null && params.containsKey("data")){
String datas = Util.null2String(params.get("data"));
JSONObject jsonObj = JSON.parseObject(datas);
String serialid = Util.null2String(jsonObj.get("id"));
if(serialid.length() > 0){
String mainSql = " select * from kq_ShiftManagement where id= "+serialid +" ";
logger.setMainSql(mainSql);//主表sql
logger.setMainPrimarykey("id");//主日志表唯一key
logger.setMainTargetNameColumn("serial");
SimpleBizLogger.SubLogInfo subLogInfo1 = logger.getNewSubLogInfo();
String subSql1 = "select * from kq_ShiftOnOffWorkSections where serialid="+serialid;
subLogInfo1.setSubTargetNameColumn("times");
subLogInfo1.setGroupId("0"); //所属分组, 按照groupid排序显示在详情中 不设置默认按照add的顺序。
subLogInfo1.setSubGroupNameLabel(27961); //在详情中显示的分组名称不设置默认显示明细x
subLogInfo1.setSubSql(subSql1);
logger.addSubLogInfo(subLogInfo1);
SimpleBizLogger.SubLogInfo subLogInfo = logger.getNewSubLogInfo();
String subSql = " select * from kq_ShiftRestTimeSections where serialid = "+serialid;
subLogInfo.setSubSql(subSql);
subLogInfo.setSubTargetNameColumn("time");
subLogInfo.setGroupId("1"); //所属分组, 按照groupid排序显示在详情中 不设置默认按照add的顺序。
subLogInfo.setSubGroupNameLabel(505603); //在详情中显示的分组名称不设置默认显示明细x
logger.addSubLogInfo(subLogInfo);
logger.before(logContext);
}
}
}
@Override
public BizLogContext getLogContext() {
// TODO Auto-generated method stub
return null;
}
@Override
public List<BizLogContext> getLogContexts() {
return logger.getBizLogContexts();
}
/**
*
* @param id
* @param para2
* @return
*/
public String getTargetName(String id,String para2){
try {
return para2;
} catch (Exception e) {
e.printStackTrace();
return "";
}
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String,Object> retmap = new HashMap<String,Object>();
String datas = Util.null2String(params.get("data"));
JSONObject jsonObj = JSON.parseObject(datas);
String serialid = Util.null2String(jsonObj.get("id"));
if(!HrmUserVarify.checkUserRight("KQClass:Management",user)) {
retmap.put("status", "-1");
retmap.put("message", SystemEnv.getHtmlLabelName(2012, user.getLanguage()));
return retmap;
}
try{
if(serialid.length() > 0){
edit(retmap,jsonObj);
}else{
add(retmap,jsonObj);
}
KQShiftManagementComInfo kqShiftManagementComInfo = new KQShiftManagementComInfo();
kqShiftManagementComInfo.removeShiftManagementCache();
if(retmap.containsKey("id")){
KQConfigComInfo kqConfigComInfo = new KQConfigComInfo();
String auto_card_cominfo = Util.null2String(kqConfigComInfo.getValue("auto_card_cominfo"),"0");
if("1".equalsIgnoreCase(auto_card_cominfo)){
String serial_id = Util.null2String(retmap.get("id"));
KQGroupBiz kqGroupBiz = new KQGroupBiz();
List<String> groupList = kqGroupBiz.getGroupIdByUesedSerialId(serial_id);
KQGroupComInfo kqGroupComInfo = new KQGroupComInfo();
if(!groupList.isEmpty()){
for(String groupId : groupList){
String auto_checkin = kqGroupComInfo.getAuto_checkin(groupId);
String auto_checkout = kqGroupComInfo.getAuto_checkout(groupId);
if("1".equalsIgnoreCase(auto_checkout) || "1".equalsIgnoreCase(auto_checkin)){
//当前班次存在自动打卡设置,修改班次后,不影响当天的自动打卡时间,变更后的班次自动打卡需要第二天才起作用
retmap.put("message", "当前班次存在自动打卡设置,修改班次后,不影响当天的自动打卡时间,变更后的班次自动打卡需要第二天才起作用");
break;
}
}
}
}
}
}catch (Exception e){
retmap.put("status", "-1");
retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage()));
writeLog(e);
}
return retmap;
}
/**
*
* @param retmap
* @param jsonObj
*/
public void edit(Map<String,Object> retmap,JSONObject jsonObj) throws Exception{
RecordSetTrans rst = new RecordSetTrans();
rst.setAutoCommit(true);
RecordSet rs = new RecordSet();
String serialid = Util.null2String(jsonObj.get("id"));
String serial = Util.null2String(jsonObj.get("serial"));//班次名称
String subcompanyid = Util.null2o(Util.null2String(jsonObj.get("subcompanyid")));
String shiftOnOffWorkCount = Util.null2o(Util.null2String(jsonObj.get("shiftonoffworkcount")));//一天内上下班次数
String punchSettings = "1";//打卡时段是否开启 1表示开启
String isOffDutyFreeCheck = Util.null2o(Util.null2String(jsonObj.get("isoffdutyfreecheck")));//允许下班不打卡 1表示开启
String isRestTimeOpen = Util.null2o(Util.null2String(jsonObj.get("isresttimeopen")));//排除休息时间是否开启 1表示开启
String worktime = Util.null2o(Util.null2String(jsonObj.get("worktime")));//工作时长
// String color = Util.null2o(Util.null2String(jsonObj.get("color")));//工作时长
String color = "#000";
String cardRemind = Util.null2s(jsonObj.getString("cardRemind"),"0");//是否开启打卡提醒0-不开启、1-开启。默认不开启
String cardRemOfSignIn = Util.null2s(jsonObj.getString("cardRemOfSignIn"),"1");//上班打卡提醒0-不提醒、1-自定义提前提醒分钟数。默认为1
String minsBeforeSignIn = Util.null2s(jsonObj.getString("minsBeforeSignIn"),"10");//自定义提前提醒分钟数。默认10分钟
String cardRemOfSignOut = Util.null2s(jsonObj.getString("cardRemOfSignOut"),"1");//下班打卡提醒0-不提醒、1-自定义延后提醒分钟数。默认为1
String minsAfterSignOut = Util.null2s(jsonObj.getString("minsAfterSignOut"),"0");//自定义延后提醒分钟数。默认0分钟
String remindMode = Util.null2s(jsonObj.getString("remindMode"),"1");//提醒方式1-消息中心提醒、2-邮件提醒、3-短信提醒。默认消息中心提醒
String remindOnPC = Util.null2s(jsonObj.getString("remindOnPC"),"0");//登陆PC端弹窗提醒0-不开启、1-开启
String halfcalrule = Util.null2s(jsonObj.getString("halfcalrule"),"0");//半天计算规则
String halfcalpoint = Util.null2s(jsonObj.getString("halfcalpoint"),"");//半天分界点
String halfcalpoint2cross = Util.null2s(jsonObj.getString("halfcalpoint2cross"),"0");//当日
if(duplicationCheck(serial,serialid)){
retmap.put("status", "-1");
retmap.put("message", SystemEnv.getHtmlLabelName(389019,user.getLanguage()));
return ;
}
String[] works = new String[]{"start","end"};
JSONArray workSections = (JSONArray)jsonObj.get("workSections");
checkRule(retmap,workSections,works);
if(!retmap.isEmpty()){
return ;
}
String mainSql = "update kq_ShiftManagement set serial=?,subcompanyid=?,shiftonoffworkcount=?,punchsettings=?,isoffdutyfreecheck=?,isresttimeopen=?,worktime=?,color=?," +
"cardRemind=? ,cardRemOfSignIn=? ,minsBeforeSignIn=? ,cardRemOfSignOut=? ,minsAfterSignOut=? ,remindMode=? ,remindOnPC=?,halfcalrule=?,halfcalpoint=?,halfcalpoint2cross=? where id = ? ";
boolean isUpdated = rst.executeUpdate(mainSql, serial,subcompanyid,shiftOnOffWorkCount,punchSettings,isOffDutyFreeCheck,isRestTimeOpen,worktime,color,
cardRemind ,cardRemOfSignIn ,minsBeforeSignIn ,cardRemOfSignOut ,minsAfterSignOut ,remindMode ,remindOnPC,halfcalrule,halfcalpoint,halfcalpoint2cross,serialid);
if(isUpdated){
//对于休息时间和工作时间,直接删除后重新创建
String delRestSql = "delete from kq_ShiftRestTimeSections where serialid = ? ";
rs = new RecordSet();
rst.executeUpdate(delRestSql, serialid);
String delWorkSql = "delete from kq_ShiftOnOffWorkSections where serialid = ? ";
rs = new RecordSet();
rst.executeUpdate(delWorkSql, serialid);
//休息时间 resttype:start开始时间,end结束时间
JSONArray restTimeSections = (JSONArray)jsonObj.get("restTimeSections");
//工作时间 across是否跨天1表示跨天;beginMin上班前分钟数开始签到endMin下班后分钟数停止签退;times具体上下班时间;onOffWorkType:start开始时间,end结束时间
String restSql = "insert into kq_ShiftRestTimeSections(serialid,resttype,time,across,record1,orderId) values(?,?,?,?,?,?)";
int restCount = restTimeSections.size();
rs = new RecordSet();
for(int i = 0 ; i < restCount ; i++){
JSONObject jsonRest = ((JSONObject)restTimeSections.get(i));
if(jsonRest.containsKey("start") && jsonRest.containsKey("end")){
String record=Util.null2String(jsonRest.get("record"));
String orderId=Util.null2String(jsonRest.get("orderId"));
JSONObject start_jsonRest = (JSONObject) jsonRest.get("start");
String time=Util.null2String(start_jsonRest.get("time"));
String resttype="start";
String across=Util.null2String(start_jsonRest.get("accross"));
rst.executeUpdate(restSql, serialid,resttype,time,across,record,orderId);
JSONObject end_jsonRest = (JSONObject) jsonRest.get("end");
time=Util.null2String(end_jsonRest.get("time"));
resttype="end";
across=Util.null2String(end_jsonRest.get("accross"));
rst.executeUpdate(restSql, serialid,resttype,time,across,record,orderId);
}
}
rs = new RecordSet();
String workSql = "insert into kq_ShiftOnOffWorkSections(serialid,across,mins,times,onoffworktype,record,mins_next,clockinnot) values(?,?,?,?,?,?,?,?)";
int workCount = workSections.size();
for(int i = 0 ; i < workCount ; i++){
JSONObject jsonWork = ((JSONObject)workSections.get(i));
String record = Util.null2String(jsonWork.get("record"));
for(int j = 0 ; j < works.length ; j++){
String onOffWorkType=works[j];
JSONObject inWork=(JSONObject)jsonWork.get(onOffWorkType);
String across=Util.null2String(inWork.get("across"));
String mins = Util.null2s(Util.null2String(inWork.get("mins")),"0");
String times=Util.null2String(inWork.get("times"));
String mins_next=Util.null2String(inWork.get("mins_next"));
String clockinnot=Util.null2s(Util.null2String(inWork.get("clockinnot")),"0");
rst.executeUpdate(workSql, serialid,across,mins,times,onOffWorkType,record,mins_next,clockinnot);
}
}
retmap.put("id", serialid);
retmap.put("status", "1");
retmap.put("message", SystemEnv.getHtmlLabelName(18758, user.getLanguage()));
}else{
retmap.put("status", "-1");
retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage()));
}
}
/**
*
* @param retmap
* @param jsonObj
*/
public void add(Map<String,Object> retmap,JSONObject jsonObj) throws Exception{
RecordSetTrans rst = new RecordSetTrans();
rst.setAutoCommit(true);
RecordSet rs = new RecordSet();
String subcompanyid = Util.null2o(Util.null2String(jsonObj.get("subcompanyid")));
String serial = Util.null2String(jsonObj.get("serial"));//班次名称
String shiftOnOffWorkCount = Util.null2o(Util.null2String(jsonObj.get("shiftonoffworkcount")));//一天内上下班次数
String punchSettings = "1";//打卡时段是否开启 1表示开启
String isOffDutyFreeCheck = Util.null2o(Util.null2String(jsonObj.get("isoffdutyfreecheck")));//允许下班不打卡 1表示开启
String isRestTimeOpen = Util.null2o(Util.null2String(jsonObj.get("isresttimeopen")));//排除休息时间是否开启 1表示开启
String worktime = Util.null2o(Util.null2String(jsonObj.get("worktime")));//工作时长
// String color = Util.null2o(Util.null2String(jsonObj.get("color")));//工作时长
String color = "#000";
String uuid = UUID.randomUUID().toString();//uuid供查询使用
String cardRemind = Util.null2s(jsonObj.getString("cardRemind"),"0");//是否开启打卡提醒0-不开启、1-开启。默认不开启
String cardRemOfSignIn = Util.null2s(jsonObj.getString("cardRemOfSignIn"),"1");//上班打卡提醒0-不提醒、1-自定义提前提醒分钟数。默认为1
String minsBeforeSignIn = Util.null2s(jsonObj.getString("minsBeforeSignIn"),"10");//自定义提前提醒分钟数。默认10分钟
String cardRemOfSignOut = Util.null2s(jsonObj.getString("cardRemOfSignOut"),"1");//下班打卡提醒0-不提醒、1-自定义延后提醒分钟数。默认为1
String minsAfterSignOut = Util.null2s(jsonObj.getString("minsAfterSignOut"),"0");//自定义延后提醒分钟数。默认0分钟
String remindMode = Util.null2s(jsonObj.getString("remindMode"),"1");//提醒方式1-消息中心提醒、2-邮件提醒、3-短信提醒。默认消息中心提醒
String remindOnPC = Util.null2s(jsonObj.getString("remindOnPC"),"0");//登陆PC端弹窗提醒0-不开启、1-开启
String halfcalrule = Util.null2s(jsonObj.getString("halfcalrule"),"0");//半天计算规则
String halfcalpoint = Util.null2s(jsonObj.getString("halfcalpoint"),"");//半天分界点
String halfcalpoint2cross = Util.null2s(jsonObj.getString("halfcalpoint2cross"),"0");//当日
if(duplicationCheck(serial,"")){
retmap.put("status", "-1");
retmap.put("message", SystemEnv.getHtmlLabelName(389019,user.getLanguage()));
return ;
}
//工作时间 across是否跨天1表示跨天;beginMin上班前分钟数开始签到endMin下班后分钟数停止签退;times具体上下班时间;onOffWorkType:start开始时间,end结束时间
JSONArray workSections = (JSONArray)jsonObj.get("workSections");
String[] works = new String[]{"start","end"};
checkRule(retmap,workSections,works);
if(!retmap.isEmpty()){
return ;
}
//color改为前台获取
// String color = getRandomColor();
boforeLog(uuid);
String mainSql = "insert into kq_ShiftManagement(serial,subcompanyid,shiftonoffworkcount,punchsettings,isoffdutyfreecheck,isresttimeopen,worktime,uuid,color," +
"cardRemind ,cardRemOfSignIn ,minsBeforeSignIn ,cardRemOfSignOut ,minsAfterSignOut ,remindMode ,remindOnPC,halfcalrule,halfcalpoint,halfcalpoint2cross)"
+ " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
boolean isUpdated = rst.executeUpdate(mainSql, serial,subcompanyid,shiftOnOffWorkCount,punchSettings,isOffDutyFreeCheck,isRestTimeOpen,worktime,uuid,color,
cardRemind ,cardRemOfSignIn ,minsBeforeSignIn ,cardRemOfSignOut ,minsAfterSignOut ,remindMode ,remindOnPC,halfcalrule,halfcalpoint,halfcalpoint2cross);
if(isUpdated){
int serialid = 0;
String idSql = "select id from kq_ShiftManagement where uuid=? and (isdelete is null or isdelete <> '1') ";
rs = new RecordSet();
rs.executeQuery(idSql,uuid);
if(rs.next()) {
serialid = rs.getInt("id");
}
if(serialid > 0){
//休息时间 resttype:start开始时间,end结束时间
JSONArray restTimeSections = (JSONArray)jsonObj.get("restTimeSections");
String restSql = "insert into kq_ShiftRestTimeSections(serialid,resttype,time,across,record1,orderId) values(?,?,?,?,?,?)";
int restCount = restTimeSections.size();
rs = new RecordSet();
for(int i = 0 ; i < restCount ; i++){
JSONObject jsonRest = ((JSONObject)restTimeSections.get(i));
if(jsonRest.containsKey("start") && jsonRest.containsKey("end")){
String record=Util.null2String(jsonRest.get("record"));
String orderId=Util.null2String(jsonRest.get("orderId"));
JSONObject start_jsonRest = (JSONObject) jsonRest.get("start");
String time=Util.null2String(start_jsonRest.get("time"));
String resttype="start";
String across=Util.null2String(start_jsonRest.get("accross"));
rst.executeUpdate(restSql, serialid,resttype,time,across,record,orderId);
JSONObject end_jsonRest = (JSONObject) jsonRest.get("end");
time=Util.null2String(end_jsonRest.get("time"));
resttype="end";
across=Util.null2String(end_jsonRest.get("accross"));
rst.executeUpdate(restSql, serialid,resttype,time,across,record,orderId);
}
}
rs = new RecordSet();
String workSql = "insert into kq_ShiftOnOffWorkSections(serialid,across,mins,times,onoffworktype,record,mins_next,clockinnot) values(?,?,?,?,?,?,?,?)";
int workCount = workSections.size();
for(int i = 0 ; i < workCount ; i++){
JSONObject jsonWork = ((JSONObject)workSections.get(i));
String record = Util.null2String(jsonWork.get("record"));
for(int j = 0 ; j < works.length ; j++){
String onOffWorkType=works[j];
JSONObject inWork=(JSONObject)jsonWork.get(onOffWorkType);
String across=Util.null2String(inWork.get("across"));
String mins = Util.null2s(Util.null2String(inWork.get("mins")),"1");
String times=Util.null2String(inWork.get("times"));
String mins_next=Util.null2String(inWork.get("mins_next"));
String clockinnot = Util.null2s(Util.null2String(inWork.get("clockinnot")),"0");
rst.executeUpdate(workSql, serialid,across,mins,times,onOffWorkType,record,mins_next,clockinnot);
}
}
retmap.put("status", "1");
retmap.put("id", serialid);
retmap.put("message", SystemEnv.getHtmlLabelName(18758, user.getLanguage()));
}else{
retmap.put("status", "-1");
retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage()));
}
}else{
retmap.put("status", "-1");
retmap.put("message", SystemEnv.getHtmlLabelName(382661,user.getLanguage()));
}
}
private void checkRule(Map<String, Object> retmap,
JSONArray workSections, String[] works) {
for(int i = 0 ; i < workSections.size() ; i++) {
JSONObject jsonWork = ((JSONObject) workSections.get(i));
for(int j = 0 ; j < works.length ; j++){
String onOffWorkType=works[j];
JSONObject inWork=(JSONObject)jsonWork.get(onOffWorkType);
String mins = Util.null2String(inWork.get("mins"));
if(mins.length() == 0 || Util.getIntValue(mins) == 0){
retmap.put("status", "-1");
retmap.put("message", ""+ SystemEnv.getHtmlLabelName(10005343,weaver.general.ThreadVarLanguage.getLang())+"");
break;
}
}
}
}
/**
*
* @param serial
* @param serialid
* @return
*/
private boolean duplicationCheck(String serial,String serialid){
boolean isDuplicated = false;
RecordSet rs = new RecordSet();
String checkSql = "select 1 from kq_ShiftManagement where serial=? and (isdelete is null or isdelete <> '1') ";
if(serialid.length() > 0){
checkSql += " and id != "+serialid;
}
rs.executeQuery(checkSql, Util.null2s(serial, "").trim());
if(rs.next()){
isDuplicated = true;
}
return isDuplicated;
}
/**
*
* @return
*/
private String getRandomColor(){
RecordSet rs = new RecordSet();
List<String> colorLists = new ArrayList<>();
String hasSameColor = "select color from kq_ShiftManagement group by color ";
rs.executeQuery(hasSameColor);
while (rs.next()){
colorLists.add(rs.getString("color"));
}
String color = "";
Random random = null;
int i = 0 ;
// while(true){
// random = new Random();
// //颜色就要深色的
// String[] colors = new String[]{"0","1","2","3","4","5","6"};
// int not_r = random.nextInt(16);
// int not_g = random.nextInt(16);
// int not_b = random.nextInt(16);
// int not_r1 = random.nextInt(16);
// int not_g1 = random.nextInt(16);
// int not_b1 = random.nextInt(16);
// color = "#"+colors[not_r]+colors[not_g]+colors[not_b]+colors[not_r1]+colors[not_g1]+colors[not_b1];
// //以防死锁
// if(i > 1000){
// break;
// }
// if(!colorLists.contains(color)){
// break;
// }
// i++;
// }
return color;
}
public void boforeLog(String uuid){
BizLogContext logContext = new BizLogContext();
logContext.setDateObject(new Date());
logContext.setLogType(BizLogType.HRM_ENGINE);
logContext.setBelongType(BizLogSmallType4Hrm.HRM_ENGINE_SHIFTMANAGER);
logContext.setLogSmallType(BizLogSmallType4Hrm.HRM_ENGINE_SHIFTMANAGER);
logContext.setParams(params);
String log_mainSql = " select * from kq_ShiftManagement where uuid in('"+uuid+"')";
logger.setMainSql(log_mainSql);//主表sql
logger.setMainPrimarykey("id");//主日志表唯一key
logger.setMainTargetNameColumn("serial");
SimpleBizLogger.SubLogInfo subLogInfo1 = logger.getNewSubLogInfo();
String subSql1 = "select * from kq_ShiftOnOffWorkSections where serialid in (select id from kq_ShiftManagement where uuid in('"+uuid+"'))" ;
subLogInfo1.setSubTargetNameColumn("times");
subLogInfo1.setGroupId("0"); //所属分组, 按照groupid排序显示在详情中 不设置默认按照add的顺序。
subLogInfo1.setSubGroupNameLabel(27961); //在详情中显示的分组名称不设置默认显示明细x
subLogInfo1.setSubSql(subSql1);
logger.addSubLogInfo(subLogInfo1);
SimpleBizLogger.SubLogInfo subLogInfo = logger.getNewSubLogInfo();
String subSql = " select * from kq_ShiftRestTimeSections where serialid in (select id from kq_ShiftManagement where uuid in('"+uuid+"'))" ;
subLogInfo.setSubSql(subSql);
subLogInfo.setSubTargetNameColumn("time");
subLogInfo.setGroupId("1"); //所属分组, 按照groupid排序显示在详情中 不设置默认按照add的顺序。
subLogInfo.setSubGroupNameLabel(505603); //在详情中显示的分组名称不设置默认显示明细x
logger.addSubLogInfo(subLogInfo);
logger.before(logContext);
}
}

@ -0,0 +1,127 @@
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;//自由班制计算方式
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;
}
}

@ -0,0 +1,66 @@
package com.engine.kq.enums;
/**
*
* 1-
* 2-
* 3-
*/
public enum OverTimeComputingModeEnum {
/**
*
*/
FLOW("1","需审批,以加班流程为准","500382"),
/**
*
*/
FLOW2CARD("2","需审批,以打卡为准,但不能超过加班流程时长","500383"),
/**
*
*/
FLOWINCARD("4","需审批,打卡和流程均统计,取两者的交集","524827"),
/**
*
*/
CARD("3","无需审批,根据打卡时间计算加班时长","390837");
private String computingMode;
private String title;
private String label;
/**
*
* @param computingMode
*/
OverTimeComputingModeEnum(String computingMode,String title,String label) {
this.computingMode = computingMode;
this.title = title;
this.label = label;
}
public String getComputingMode() {
return computingMode;
}
public void setComputingMode(String computingMode) {
this.computingMode = computingMode;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
}

@ -0,0 +1,608 @@
package com.engine.kq.util;
import com.engine.kq.biz.KQLeaveRulesBiz;
import com.engine.kq.biz.KQLeaveRulesComInfo;
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.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);
}
/**
*
* @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){
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");
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(){
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);
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 KQDurationCalculatorUtil.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 KQDurationCalculatorUtil.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 KQDurationCalculatorUtil.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);
}
}
}

File diff suppressed because it is too large Load Diff

@ -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;
}
}
Loading…
Cancel
Save