责任制下月默认排班设置

dev
Administrator 1 year ago
parent 3727c0a5db
commit 8a94de0d05

@ -31,6 +31,7 @@ import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.dateformat.DateTransformer;
import weaver.dateformat.TimeZoneVar;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.systeminfo.SystemEnv;
@ -365,19 +366,36 @@ public class PunchButtonCmd extends AbstractCommonCommand<Map<String, Object>> {
LIST.add(Util.null2String(rs.getString("kqzid")));
}
kqLog.info("PunchButtonCmd.LIST"+LIST);
if(LIST.contains(groupid)&&StringUtils.isBlank(workTimeEntity.getSerialId())) {
if(LIST.contains(groupid)) {
RecordSet rt = new RecordSet();
BaseBean bb = new BaseBean();
//休息日或节假日给休息班次
//int changeType = KQOvertimeRulesBiz.getChangeType(Util.null2String(userId), signDate);
boolean holiday = KQHolidaySetBiz.isHoliday(Util.null2String(userId), signDate,true);
String fixedSerialid = Util.null2String(bb.getPropValue("project_hostar", "fixedSerialid"));
String weekendDefaultSerialid = Util.null2String(bb.getPropValue("project_hostar", "weekendDefaultSerialid"));
String holidayDefaultSerialid = Util.null2String(bb.getPropValue("project_hostar", "holidayDefaultSerialid"));
String fixedUserId = "";
//查询指定和考勤组成员
String query_sql = "select distinct typevalue from kq_groupmember where groupid = ? ";
rs.executeQuery(query_sql, fixedSerialid);
if (rs.next()) {
fixedUserId = rs.getString("typevalue");
}
boolean holiday = KQHolidaySetBiz.isHoliday(fixedUserId, signDate, true);
kqLog.info("format.holiday:" + holiday);
String sql = "insert into kq_shiftschedule(kqdate,serialid,resourceid,groupid,isdelete)values(?,?,?,?,?)";
//String sql = "insert into kq_shiftschedule(kqdate,serialid,resourceid,groupid,isdelete)values(?,?,?,?,?)";
String sql = "update kq_shiftschedule set serialid = ? where resourceid = ? and kqdate= ? and groupid = ? and isdelete = 0 ";
//考勤当天是节假日或者休息日
if (holiday) {
//休息班
boolean b = rt.executeUpdate(sql, signDate, "-1", Util.null2String(userId), groupid, "0");
//节假日休息班
boolean b = rt.executeUpdate(sql, holidayDefaultSerialid, Util.null2String(userId), signDate, groupid);
kqLog.info("PunchButtonCmd.b1:" + b);
} else {
//周末休息班
// if (DateUtil.getWeek(signDate) == 6 || DateUtil.getWeek(signDate) == 7) {
// boolean b = rt.executeUpdate(sql, weekendDefaultSerialid, Util.null2String(userId), signDate, groupid);
// kqLog.info("PunchButtonCmd.b1:" + b);
// } else {
String dybc = "";
//正常打卡,排对应打卡地点对应班次
//2.查询指定打卡地点的经纬度及范围的list
@ -403,9 +421,10 @@ public class PunchButtonCmd extends AbstractCommonCommand<Map<String, Object>> {
kqLog.info("PunchButtonCmd.dybc:" + dybc);
//设置考勤班次为对应班次
if (StringUtils.isNotBlank(dybc)) {
boolean b = rt.executeUpdate(sql, signDate, dybc, Util.null2String(userId), groupid, "0");
boolean b = rt.executeUpdate(sql, dybc, Util.null2String(userId), signDate, groupid);
kqLog.info("PunchButtonCmd.b2:" + b);
}
// }
}
}

@ -361,23 +361,42 @@ public class PunchOutButtonCmd extends AbstractCommonCommand<Map<String, Object>
LIST.add(Util.null2String(rs.getString("kqzid")));
}
kqLog.info("PunchOutButtonCmd.LIST"+LIST);
if(LIST.contains(groupid)&&StringUtils.isBlank(workTimeEntity.getSerialId())) {
if(LIST.contains(groupid)) {
RecordSet rt = new RecordSet();
boolean b;
BaseBean bb= new BaseBean();
//休息日或节假日给休息班次
//int changeType = KQOvertimeRulesBiz.getChangeType(Util.null2String(userId), signDate);
boolean holiday = KQHolidaySetBiz.isHoliday(Util.null2String(userId), signDate,true);
String fixedSerialid = Util.null2String(bb.getPropValue("project_hostar", "fixedSerialid"));
String defaultSerialid = Util.null2String(bb.getPropValue("project_hostar", "defaultSerialid"));
String weekendDefaultSerialid = Util.null2String(bb.getPropValue("project_hostar", "weekendDefaultSerialid"));
String holidayDefaultSerialid = Util.null2String(bb.getPropValue("project_hostar", "holidayDefaultSerialid"));
String fixedUserId = "";
//查询指定和考勤组成员
String query_sql = "select distinct typevalue from kq_groupmember where groupid = ? ";
rs.executeQuery(query_sql,fixedSerialid);
if (rs.next()) {
fixedUserId = rs.getString("typevalue");
}
boolean holiday = KQHolidaySetBiz.isHoliday(fixedUserId, signDate,true);
kqLog.info("format.holiday:" + holiday);
String sql = "insert into kq_shiftschedule(kqdate,serialid,resourceid,groupid,isdelete)values(?,?,?,?,?)";
//String sql = "insert into kq_shiftschedule(kqdate,serialid,resourceid,groupid,isdelete)values(?,?,?,?,?)";
String sql = "update kq_shiftschedule set serialid = ? where resourceid = ? and kqdate= ? and groupid = ? and isdelete = 0 ";
//考勤当天是节假日或者休息日
if (holiday) {
//休息班
b = rt.executeUpdate(sql, signDate, "-1", Util.null2String(userId), groupid, "0");
//节假日休息班
b = rt.executeUpdate(sql, signDate, holidayDefaultSerialid, Util.null2String(userId),signDate,groupid);
kqLog.info("PunchOutButtonCmd.b1:" + b);
}else{
//周末休息班
// if(DateUtil.getWeek(signDate) == 6 || DateUtil.getWeek(signDate) == 7){
// b = rt.executeUpdate(sql,weekendDefaultSerialid, Util.null2String(userId), signDate,groupid);
// kqLog.info("PunchOutButtonCmd.b2:"+b);
// }else{
//设置考勤班次为对应班次
b = rt.executeUpdate(sql, signDate, "9", Util.null2String(userId), groupid, "0");
kqLog.info("PunchOutButtonCmd.b2:"+b);
b = rt.executeUpdate(sql,defaultSerialid, Util.null2String(userId), signDate,groupid);
kqLog.info("PunchOutButtonCmd.b3:"+b);
//}
}
}
//同步更新考勤数据到考勤报表

@ -0,0 +1,133 @@
package weaver.interfaces.hostar.job;
import com.engine.kq.biz.KQHolidaySetBiz;
import com.engine.kq.biz.KQWorkTime;
import com.engine.kq.entity.WorkTimeEntity;
import weaver.common.DateUtil;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.interfaces.schedule.BaseCronJob;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
public class AutoScheduNextMonthJob extends BaseCronJob {
private String fromDate;
private String toDate;
public String getFromDate() {
return fromDate;
}
public String getToDate() {
return toDate;
}
public void setFromDate(String fromDate) {
this.fromDate = fromDate;
}
public void setToDate(String toDate) {
this.toDate = toDate;
}
BaseBean bb= new BaseBean();
private final List<String> LIST = new ArrayList<>();
@Override
public void execute() {
bb.writeLog("AutoSchedulJob Start");
try {
//DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
//DateTimeFormatter formatter2 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
//bb.writeLog("fromDate: " + fromDate);
//bb.writeLog("toDate: " + toDate);
//当前日期
//toDate = DateUtils.format(new Date(), "yyyy-MM-dd");
RecordSet rs = new RecordSet();
boolean b = false;
String sql = "insert into kq_shiftschedule(kqdate,serialid,resourceid,groupid,isdelete)values(?,?,?,?,?)";
//责任制考勤组id收集
rs.executeQuery("select kqzid from uf_zrzkqz");
while (rs.next()) {
LIST.add(Util.null2String(rs.getString("kqzid")));
}
bb.writeLog("AutoScheduNextMonthJob.LIST" + LIST);
List<String> userList = new ArrayList<>();
//查询指定和考勤组成员
String query_sql = "select distinct typevalue from kq_groupmember where groupid in" + "('" + String.join("','", LIST) + "')";
rs.execute(query_sql);
while (rs.next()) {
userList.add(Util.null2String(rs.getString("typevalue")));
}
bb.writeLog("AutoScheduNextMonthJob.userList: " + userList);
//查询固班制人员节假日设置
String fixedSerialid = Util.null2String(bb.getPropValue("project_hostar", "fixedSerialid"));
String defaultSerialid = Util.null2String(bb.getPropValue("project_hostar", "defaultSerialid"));
String weekendDefaultSerialid = Util.null2String(bb.getPropValue("project_hostar", "weekendDefaultSerialid"));
String holidayDefaultSerialid = Util.null2String(bb.getPropValue("project_hostar", "holidayDefaultSerialid"));
bb.writeLog("AutoScheduNextMonthJob.fixedSerialid:{},defaultSerialid:{},weekendDefaultSerialid{},holidayDefaultSerialid:{} " + fixedSerialid+defaultSerialid+weekendDefaultSerialid+holidayDefaultSerialid);
String fixedUserId = "";
//查询指定和考勤组成员
String query = "select distinct typevalue from kq_groupmember where groupid = ? ";
rs.executeQuery(query,fixedSerialid);
if (rs.next()) {
fixedUserId = rs.getString("typevalue");
}
bb.writeLog("AutoScheduNextMonthJob.fixedUserId: " + fixedUserId);
//查询下个月的全部日期
List<String> nextMonthDates = getNextMonthDates();
//排默认班次
for (String userId : userList) {
for (String nextMonthDate : nextMonthDates) {
WorkTimeEntity workTimeEntity = new KQWorkTime().getWorkTime(userId, nextMonthDate);
boolean holiday = KQHolidaySetBiz.isHoliday(fixedUserId, nextMonthDate, true);
if (holiday) {
//节假日休息班
b = rs.executeUpdate(sql, nextMonthDate, holidayDefaultSerialid, userId, workTimeEntity.getGroupId(), "0");
} else {
// //周末休息班
// if(DateUtil.getWeek(nextMonthDate) == 6 || DateUtil.getWeek(nextMonthDate) == 7){
// b = rs.executeUpdate(sql, nextMonthDate, weekendDefaultSerialid, userId, workTimeEntity.getGroupId(), "0");
// }else{
b = rs.executeUpdate(sql, nextMonthDate, defaultSerialid, userId, workTimeEntity.getGroupId(), "0");
//}
}
}
}
bb.writeLog("AutoScheduNextMonthJob.b: " + b);
}catch (Exception e) {
bb.writeLog("AutoScheduNextMonthJob Exception: " + e);
}
}
/*
*/
public static List<String> getNextMonthDates() {
// 获取当前时间的Calendar实例
List<String> list = new ArrayList<>();
Calendar cal = Calendar.getInstance();
// 将Calendar实例中的月份加1得到下个月的Calendar实例
cal.add(Calendar.MONTH, 1);
// 获取下个月的天数
int daysInMonth = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
// 循环获取下个月中的每一天的日期
for (int i = 1; i <= daysInMonth; i++) {
// 将Calendar实例中的日期设置为循环变量i的值
cal.set(Calendar.DATE, i);
// 获取日期并格式化
Date date = cal.getTime();
String dateString = new SimpleDateFormat("yyyy-MM-dd").format(date);
list.add(dateString);
}
return list;
}
}
Loading…
Cancel
Save