Commit 08119240 by lal Committed by chenzg

提交

parent 40633759
......@@ -151,7 +151,7 @@ public class ClockInController {
String staputime = new SimpleDateFormat("HH:mm").format(punchstart);//应打卡开始时间
String entputime = new SimpleDateFormat("HH:mm").format(punchend);//应打卡结束时间
String DKputime = new SimpleDateFormat("HH:mm").format(time_);//打卡时间
boolean effectiveDate = ClockInTool.hourMinuteBetween(DKputime, staputime, entputime);
boolean effectiveDate = ClockInTool.hourMinuteBetween(DKputime, staputime, entputime,"HH:mm");
if (!effectiveDate) {
System.out.println("当前打卡时间不在范围内");
// 手动抛出异常
......
......@@ -269,13 +269,20 @@ public class ClockInTool {
* @return true在时间段内,false不在时间段内
* @throws Exception
*/
public static boolean hourMinuteBetween(String nowDate, String startDate, String endDate) throws Exception {
public static boolean hourMinuteBetween(String nowDate, String startDate, String endDate,String date_format){
SimpleDateFormat format = new SimpleDateFormat("HH:mm");
SimpleDateFormat format = new SimpleDateFormat(date_format);
Date now = format.parse(nowDate);
Date start = format.parse(startDate);
Date end = format.parse(endDate);
Date now = null;
Date start = null;
Date end = null;
try {
now = format.parse(nowDate);
start = format.parse(startDate);
end = format.parse(endDate);
} catch (ParseException e) {
e.printStackTrace();
}
long nowTime = now.getTime();
long startTime = start.getTime();
......@@ -334,6 +341,8 @@ public class ClockInTool {
df2 = new SimpleDateFormat("yyyy-MM-dd' 'HH:mm:ss");
} else if (num == 2) {
df2 = new SimpleDateFormat("HH:mm");
}else if (num == 3) {
df2 = new SimpleDateFormat("yyyy-MM-dd' 'HH:mm");
}
return df2.format(date1);
......
......@@ -103,23 +103,26 @@ public class AttendanceTaskTiming implements SchedulingConfigurer {
* @throws ParseException
*/
// @Scheduled(cron = "0/5 * * * * ?") // 测试:5秒执行一次
@SuppressWarnings("unused")
public String AttendanceTask() throws ParseException {
boolean implement = false;
KqglTaskTiming sock = KqglTaskTiming.builder().build().selectOne(new QueryWrapper<KqglTaskTiming>().lambda().eq(KqglTaskTiming::getTask, "AttendanceTask"));
if(sock == null) {
KqglTaskTiming.builder().task("AttendanceTask").executionStatus(1).lastExecutionTime(new Date().getTime()).build().insert();
implement = true;
}else {
if(sock.getExecutionStatus() == 0) {
KqglTaskTiming.builder().task("AttendanceTask").id(sock.getId()).executionStatus(1).lastExecutionTime(new Date().getTime()).build().updateById();
implement = true;
}
}
// int sockid = 0;
// KqglTaskTiming sock = KqglTaskTiming.builder().build().selectOne(new QueryWrapper<KqglTaskTiming>().lambda().eq(KqglTaskTiming::getTask, "AttendanceTask"));
// if(sock == null) {
// KqglTaskTiming sock1 = KqglTaskTiming.builder().task("AttendanceTask").executionStatus(1).lastExecutionTime(new Date().getTime()).build();
// sock1.insert();
// sockid = sock1.getId();
// implement = true;
// }else {
// sockid = sock.getId();
// if(sock.getExecutionStatus() == 0) {
// KqglTaskTiming.builder().task("AttendanceTask").id(sock.getId()).executionStatus(1).lastExecutionTime(new Date().getTime()).build().updateById();
// implement = true;
// }
// }
//逻辑
if(false) {
if(implement) {
System.err.println("当前时间:" + dateFormat.format(new Date()));
System.err.println("时间:" + dateFormat.format(new Date()));
Calendar c = Calendar.getInstance();
c.add(Calendar.MONTH, 0);
......@@ -141,11 +144,11 @@ public class AttendanceTaskTiming implements SchedulingConfigurer {
KqglAssoMonthPunchSummary.builder().build().delete(new QueryWrapper<KqglAssoMonthPunchSummary>().lambda().eq(KqglAssoMonthPunchSummary::getBelongYear, year).eq(KqglAssoMonthPunchSummary::getBelongMonth, month));
for(int t = 0;t<orgcodelist.size();t++){
int org_code = orgcodelist.get(t).getId();//企业组织代码
// for(int t = 0;t<orgcodelist.size();t++){
int org_code = 117;//orgcodelist.get(t).getId();//企业组织代码
List<AdditionalDto> userlist = kqglassoleavebalancemapper.selectAdditionalList(org_code);
for(AdditionalDto user : userlist) {
double traveltotal,egresstotal,overtimetotal;
double traveltotal = 0,egresstotal = 0,overtimetotal = 0;
//出差总时长
KqglAssoRelationSummary travel = kqglassorelationsummarymapper.SecondaryValue(user.getEmpnum(), 3, ttstr);
if(travel !=null) { traveltotal = travel.getDuration(); }
......@@ -184,8 +187,9 @@ public class AttendanceTaskTiming implements SchedulingConfigurer {
}
}
//具体打卡时间入汇总表(打卡成功才会录入汇总表)
KqglAssoMonthPunchSummary isyessum = KqglAssoMonthPunchSummary.builder().build().selectOne(new QueryWrapper<KqglAssoMonthPunchSummary>().lambda()
.eq(KqglAssoMonthPunchSummary::getNum, user.getEmpnum()).eq(KqglAssoMonthPunchSummary::getOrgCode, org_code));
// KqglAssoMonthPunchSummary isyessum = KqglAssoMonthPunchSummary.builder().build().selectOne(new QueryWrapper<KqglAssoMonthPunchSummary>().lambda()
// .eq(KqglAssoMonthPunchSummary::getNum, user.getEmpnum()).eq(KqglAssoMonthPunchSummary::getOrgCode, org_code));
String[] ycqts = new String[31];//应上班的具体天数(yyyy-MM-dd)
String[] xxts = new String[31];//休息的具体天数(yyyy-MM-dd)
List<String> rowData = new ArrayList<String>();
......@@ -205,26 +209,16 @@ public class AttendanceTaskTiming implements SchedulingConfigurer {
double resttransferovertime = 0;//休息日(转加班费)
double holidaytransferovertime = 0;//节假日(转加班费)
int attgroid = 0;
if(attgro != null){//该员工是否加入到考勤组 排班方式 1:固定排班;2:自由排班;3:自由工时 计算出应出勤,实际出勤,休息天数
attgroid = attgro.getId();
// KqglAssoBcsz shif = KqglAssoBcsz.builder().build();
// //休息天数,应出勤天数,实际出勤
// double daysOff = 0,daysOnDuty = 0;//,actualAttDays = 0;
// int zjgzts = 0;//目前为止应该出勤的天数
if(attgro.getPbfs() == 1){ //固定排班
int several = Integer.valueOf(ClockInTool.dateToWeek(str));//
KqglAssoTeshu tesu = KqglAssoTeshu.builder().build().selectOne(new QueryWrapper<KqglAssoTeshu>().lambda().eq(KqglAssoTeshu::getKqzid, attgro.getId()).eq(KqglAssoTeshu::getTsrq, str));
if(tesu == null) {
//获取该员工最新班次
KqglAssoZhoupaiban gudingpb = KqglAssoZhoupaiban.builder().build().selectOne(new QueryWrapper<KqglAssoZhoupaiban>().lambda().eq(KqglAssoZhoupaiban::getKqzid, attgro.getId())
.eq(KqglAssoZhoupaiban::getType, several));
shif = shif.selectOne(new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getId, gudingpb.getBcid()));
}else {
shif = shif.selectOne(new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getId, tesu.getBcid()));
}
//获取该员工最新班次
KqglAssoZhoupaiban gudingpb = KqglAssoZhoupaiban.builder().build().selectOne(new QueryWrapper<KqglAssoZhoupaiban>().lambda().eq(KqglAssoZhoupaiban::getKqzid, attgro.getId())
.eq(KqglAssoZhoupaiban::getType, several));
shif = shif.selectOne(new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getId, gudingpb.getBcid()));
List<KqglAssoTeshu> bxdklist = kqglassoteshumapper.ShouldSpecialDatessetByKqzid(attgro.getId(), ttstr,1);//当前月 必须打卡日期
int bxdk = bxdklist.size();
String[] bxdkss = new String[bxdk];////特殊-必须打卡天数(工作日)
......@@ -240,6 +234,8 @@ public class AttendanceTaskTiming implements SchedulingConfigurer {
appmaps[d1] = spe.getTsrq();
d1++;
}
List<AttendanceWeeklySch> atwek = attendanceweeklyschmapper.selectAttendanceMadeByUserid(user.getEmpnum());
String[] week= new String[atwek.size()];
String[] needfig = new String[atwek.size()];//应打卡周期时间
......@@ -294,8 +290,6 @@ public class AttendanceTaskTiming implements SchedulingConfigurer {
}
}
}else if(attgro.getPbfs() == 2){ //自由排班
KqglAssoPbmx pbmxx = KqglAssoPbmx.builder().build().selectOne(new QueryWrapper<KqglAssoPbmx>().lambda().eq(KqglAssoPbmx::getUserid, user.getEmpnum()).eq(KqglAssoPbmx::getData, str).eq(KqglAssoPbmx::getKqzid, attgro.getId()));
shif = shif.selectOne(new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getId, pbmxx.getBcid()));
List<Schedule> ycqs = schedulemapper.getAttendanceShouldList(user.getEmpnum(),startDate,endDate);
int xiuxi = 0,shangban = 0,z=0;
String[] ziyoupb = new String[ycqs.size()];
......@@ -438,6 +432,11 @@ public class AttendanceTaskTiming implements SchedulingConfigurer {
bk++;
}
}
//排查请假是否在最后一次打卡范围内
List<KqglAssoRelationSummary> leainv = kqglassorelationsummarymapper.LeaveInvestigation(user.getEmpnum(), 2, ttstr);
int answer = shif.getSxbcs();//1=2次 2=4次 3=6次
String beginTime = sdf1.format(new Date());
// List<String> rowData = new ArrayList<String>();
//遍历目前为止所有日期 结合该用户发起的审批进行结合
......@@ -467,6 +466,7 @@ public class AttendanceTaskTiming implements SchedulingConfigurer {
}
}
rowData.add(lea.getStartTime() +"到"+ lea.getEndTime()+"请"+leavetype+lea.getDuration()+company);
}else if(Arrays.binarySearch(ClockInTool.replaceNull(travels), num) >= 0) {//出差
KqglAssoRelationSummary lea = KqglAssoRelationSummary.builder().build().selectOne(new QueryWrapper<KqglAssoRelationSummary>().lambda().eq(KqglAssoRelationSummary::getUserId, user.getEmpnum()).eq(KqglAssoRelationSummary::getAppTime, num).eq(KqglAssoRelationSummary::getApprovalType, 3));
rowData.add(lea.getStartTime() +"到"+ lea.getEndTime()+"出差"+lea.getDuration()+"天");
......@@ -537,9 +537,45 @@ public class AttendanceTaskTiming implements SchedulingConfigurer {
}
}
//未打最后一次卡的时候 判断最后一次打卡时间是否在请假范围内 相对应减少缺卡次数
/****************************************/
if(attgro.getPbfs() == 1){
int several = Integer.valueOf(ClockInTool.dateToWeek(num));//
KqglAssoTeshu tesu = KqglAssoTeshu.builder().build().selectOne(new QueryWrapper<KqglAssoTeshu>().lambda().eq(KqglAssoTeshu::getKqzid, attgro.getId()).eq(KqglAssoTeshu::getTsrq, num));
if(tesu == null) {
//获取该员工最新班次
KqglAssoZhoupaiban gudingpb = KqglAssoZhoupaiban.builder().build().selectOne(new QueryWrapper<KqglAssoZhoupaiban>().lambda().eq(KqglAssoZhoupaiban::getKqzid, attgro.getId())
.eq(KqglAssoZhoupaiban::getType, several));
shif = shif.selectOne(new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getId, gudingpb.getBcid()));
}else {
shif = shif.selectOne(new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getId, tesu.getBcid()));
}
//获取该员工最新班次
KqglAssoZhoupaiban gudingpb = KqglAssoZhoupaiban.builder().build().selectOne(new QueryWrapper<KqglAssoZhoupaiban>().lambda().eq(KqglAssoZhoupaiban::getKqzid, attgro.getId())
.eq(KqglAssoZhoupaiban::getType, several));
shif = shif.selectOne(new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getId, gudingpb.getBcid()));
}else if(attgro.getPbfs() == 2){
KqglAssoPbmx pbmxx = KqglAssoPbmx.builder().build().selectOne(new QueryWrapper<KqglAssoPbmx>().lambda().eq(KqglAssoPbmx::getUserid, user.getEmpnum()).eq(KqglAssoPbmx::getData, num).eq(KqglAssoPbmx::getKqzid, attgro.getId()));
shif = shif.selectOne(new QueryWrapper<KqglAssoBcsz>().lambda().eq(KqglAssoBcsz::getId, pbmxx.getBcid()));
}
//未打最后一次卡的时候 判断最后一次打卡时间是否在请假范围内 相对应减少下班缺卡次数
//最后一次应打卡时间
String latimeclock = "";
if(answer == 1) {
latimeclock = ClockInTool.dealDateFormat(shif.getXbdk1(),3);
}else if(answer == 2) {
latimeclock = ClockInTool.dealDateFormat(shif.getXbdk2(),3);
}else {
latimeclock = ClockInTool.dealDateFormat(shif.getXbdk3(),3);
}
for(KqglAssoRelationSummary learel:leainv) {
boolean adopt = ClockInTool.hourMinuteBetween(latimeclock, learel.getStartTime().substring(0, 16), learel.getEndTime().substring(0, 16),"yyyy-MM-dd HH:mm");
if(adopt) {
xbqkcs = xbqkcs-1;
}
}
}
}else {
for (String num2 : range) {
......@@ -549,8 +585,10 @@ public class AttendanceTaskTiming implements SchedulingConfigurer {
rowData.add("未排班");
}
}
System.out.println("该员工未加入考勤组");
System.err.print("该员工未加入考勤组");
}
String[] range1=ClockInTool.listToString(rowData).split(";");
String[] noticesArray=range1[0].split(",");
noticesArray = ClockInTool.arrycopy(noticesArray);
......@@ -560,9 +598,16 @@ public class AttendanceTaskTiming implements SchedulingConfigurer {
noticesArray = ClockInTool.arrycopy(noticesArray);
}
}
int answer = shif.getSxbcs();//1=2次 2=4次 3=6次
KqglAssoMonthPunchSummary summary = KqglAssoMonthPunchSummary.builder().name(user.getEmpname()).num(user.getEmpnum()).dept(user.getDepartment())
.post(user.getPosition()).attGroup(attgro.getId()).build();
String department = "",position="";
if(user.getDepartment() != null) {
department = user.getDepartment();
}
if(user.getPosition() != null) {
position = user.getPosition();
}
KqglAssoMonthPunchSummary summary = KqglAssoMonthPunchSummary.builder().name(user.getEmpname()).num(user.getEmpnum()).dept(department)
.post(position).attGroup(attgroid).build();
summary.setDaysOnDuty(daysOnDuty);//应出勤天数
summary.setActualAttDays(Double.valueOf(dkjl));//实际出勤天数
......@@ -629,8 +674,10 @@ public class AttendanceTaskTiming implements SchedulingConfigurer {
summary.setDay31(noticesArray[30]);
summary.insert();
}
}
KqglTaskTiming.builder().task("AttendanceTask").id(sock.getId()).executionStatus(0).lastExecutionTime(new Date().getTime()).build().updateById();
// }
// KqglTaskTiming.builder().task("AttendanceTask").id(sockid).executionStatus(0).lastExecutionTime(new Date().getTime()).build().updateById();
return new Exception().getStackTrace()[0].getMethodName();
}else {
return null;
......
......@@ -19,4 +19,6 @@ public interface KqglAssoRelationSummaryMapper extends BaseMapper<KqglAssoRelati
KqglAssoRelationSummary SecondaryValue(int userid, int approvaltype, String time);
List<KqglAssoRelationSummary> SpecificLeave(int userid,int approvaltype,String apptime);
List<KqglAssoRelationSummary> LeaveInvestigation(int userid,int approvaltype,String apptime);
}
......@@ -102,8 +102,8 @@
<select id="selectAdditionalList" resultMap="AdditionalMap">
SELECT emp.emp_num as empnum,
emp.`name` as empname,
IFNULL(c.name,'') as department,
gw.`name` as position
IFNULL(c.name,null) as department,
IFNULL(gw.`name`,null) as position
from yggl_main_emp emp
LEFT JOIN zzgl_bmgw_m as gw on gw.id = emp.bmgw_id
LEFT JOIN zzgl_bmgw_m as c ON c.id = gw.up_id
......
......@@ -65,6 +65,17 @@
and SUBSTR(res.app_time,1,7) = #{apptime}
</select>
<select id="LeaveInvestigation" resultMap="BaseResultMap">
select res.start_time,
res.end_time
from kqgl_asso_relation_summary res
where res.user_id = #{userid}
and res.approval_type = #{approvaltype}
and SUBSTR(res.app_time,1,7) = #{apptime}
GROUP BY res.start_time,res.end_time;
</select>
<!--
<insert id="insert" useGeneratedKeys="true" keyColumn="id" parameterType="cn.timer.api.bean.kqmk.KqglAssoRelationSummary">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment