南昌市物联网技防平台-后台
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.jfpt.attendance.controller;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.*;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import lombok.AllArgsConstructor;
 
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
 
import org.springblade.core.excel.util.ExcelUtil;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.constant.BladeConstant;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringPool;
import org.springblade.jfpt.attendance.excel.AttendanceExcel;
import org.springblade.jfpt.attendance.util.PointMapUtil;
import org.springblade.jfpt.attendance.wrapper.AttendanceWrapper;
import org.springblade.jfpt.enclosure.entity.Enclosure;
import org.springblade.jfpt.enclosure.service.IEnclosureService;
import org.springblade.system.entity.DictBiz;
import org.springblade.system.feign.IDictBizClient;
import org.springblade.system.user.entity.User;
import org.springblade.system.user.vo.UserVO;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.jfpt.attendance.entity.Attendance;
import org.springblade.jfpt.attendance.vo.AttendanceVO;
import org.springblade.jfpt.attendance.service.IAttendanceService;
import org.springblade.core.boot.ctrl.BladeController;
import springfox.documentation.annotations.ApiIgnore;
 
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.logging.SimpleFormatter;
 
/**
 * 控制器
 *
 * @author BladeX
 * @since 2021-03-03
 */
@RestController
@AllArgsConstructor
@RequestMapping("/attendance")
@Api(value = "", tags = "接口")
public class AttendanceController extends BladeController {
 
    private final IAttendanceService attendanceService;
 
    private final IEnclosureService iEnclosureService;
 
    private final IDictBizClient iDictBizService;
 
    /**
     * 详情
     */
    @GetMapping("/detail")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "详情", notes = "传入attendance")
    public R<Attendance> detail(Attendance attendance) {
        Attendance detail = attendanceService.getOne(Condition.getQueryWrapper(attendance));
        return R.data(detail);
    }
 
    /**
     * 分页
     */
    @GetMapping("/list")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "分页", notes = "传入attendance")
    public R<IPage<AttendanceVO>> list(Attendance attendance, Query query) {
        IPage<Attendance> pages = attendanceService.page(Condition.getPage(query), Condition.getQueryWrapper(attendance));
        return R.data(AttendanceWrapper.build().pageVO(pages));
    }
 
    /**
     * 自定义分页
     */
    @GetMapping("/page")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "分页", notes = "传入attendance")
    public R<IPage<AttendanceVO>> page(AttendanceVO attendance, Query query, Long department) {
        IPage<Attendance> pages = attendanceService.selectAttendancePage(Condition.getPage(query), department, attendance);
        return R.data(AttendanceWrapper.build().pageVO(pages));
    }
 
 
    /**
     * 新增
     */
    @PostMapping("/save")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "新增", notes = "传入attendance")
    public R save(@Valid @RequestBody Attendance attendance) {
        return R.status(attendanceService.save(attendance));
    }
 
    /**
     * 新增
     */
    @PostMapping("/AppSave")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "新增", notes = "传入attendance")
    public R AppSave(@Valid Attendance attendance) {
        System.out.println("attendance = " + attendance);
        Enclosure enclosure = new Enclosure();
        enclosure.setAnumber(attendance.getNumber());
        //查询当前处警人员的电子围栏信息
        Boolean onArea = iEnclosureService.isOnArea(attendance.getJd(),attendance.getWd(),enclosure);
        //判断是否在所在区域打卡,返回数据
        if (onArea){
            //查询当前考勤人员的部门信息
            //获取打卡时间标准
            R<List<DictBiz>> attendanceType = iDictBizService.getList("attendanceStandard");
            List<DictBiz> dictBizList = attendanceType.getData();
            //定义打卡时间标准,上午,下午
            StringBuilder forenoon = new StringBuilder();
            StringBuilder afternoon = new StringBuilder();
            String format = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
            for (DictBiz dictBiz:dictBizList) {
                if (dictBiz.getDictValue().contains("上午")){
                    forenoon=forenoon.append(dictBiz.getDictKey());
                }
                if (dictBiz.getDictValue().contains("下午")){
                    afternoon=afternoon.append(dictBiz.getDictKey());
                }
            }
            //上午打卡时间标准
            String forenoonWorkTime = format+" "+forenoon.toString().split("-")[0]+":00";
            String forenoonOfDutyTime = format+" "+forenoon.toString().split("-")[1]+":00";
            //下午打卡时间标准
            String afternoonWorkTime = format+" "+afternoon.toString().split("-")[0]+":00";
            String afternoonOfDutyTime = format+" "+afternoon.toString().split("-")[1]+":00";
            //查询当前人员当天打卡信息
            List<Attendance> attendanceList = attendanceService.selAttendanceListNow(attendance.getNumber());
            //判断打卡时间
            try {
                long time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(attendance.getClocktime()).getTime();
                //当天第一次打卡
                if(attendanceList.size()==0){
                    //当天还没有打卡,即为当天第一个打卡
 
                    //判断打卡时间是上午还是下午
                    if (time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()+30*60*1000)>0){
                        //下午
                        //正常上班
                        if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()<=0){
                            //正常上班
                            attendance.setClocktype("0");
                            attendance.setAttendancetype("0");
                        }
                        //迟到
                        if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()>0
                        && time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()<0
                        ){
                            //迟到上班
                            attendance.setClocktype("0");
                            attendance.setAttendancetype("1");
                        }
 
                        //正常下班
                        if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()>0
                            &&
                            time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000)<=0
                        ){
                            //正常下班
                            attendance.setClocktype("1");
                            attendance.setAttendancetype("0");
                        }
 
                        //加班
                        if (time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000)>0){
                            //下午下班
                            attendance.setClocktype("1");
                            attendance.setAttendancetype("0");
                        }
                        return R.status(attendanceService.save(attendance));
                    }else {
                        //上午
                        //正常上班
                        if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonWorkTime).getTime()<=0){
                            //正常上午上班
                            attendance.setClocktype("0");
                            attendance.setAttendancetype("0");
                        }
                        //迟到
                        if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonWorkTime).getTime()>0
                            &&
                            time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()<=0
                        ){
                            //迟到上班
                            attendance.setClocktype("0");
                            attendance.setAttendancetype("1");
                        }
 
 
                        //正常下班
                        if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()>0
                            &&
                            time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()+30*60*1000)<=0
                        ){
                            //正常下班
                            attendance.setClocktype("1");
                            attendance.setAttendancetype("0");
                        }
                        return R.status(attendanceService.save(attendance));
                    }
                    //打卡时间和上午上班时间
                }
                //已经打过一次卡,当天第二次打卡
                if(attendanceList.size()==1){
                    //判断第一次打卡的时间范围,上午还是下午
                    long time1 = 0;
                    try {
                        time1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(attendanceList.get(0).getClocktime()).getTime();
                    } catch (ParseException e) {
                        e.printStackTrace();
                    }
                    //上午下班时间的半个小时后
                    if (time1-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()+30*60*1000)>0) {
                        //下午
                        //更新上班信息
                        if (time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime() <= 0) {
                            //更新上班时间
                            //正常上班
                            attendance.setAttendancetype("0");
                            attendance.setId(attendanceList.get(0).getId());
                            //更新考勤消息
                            return R.status(attendanceService.updateById(attendance));
                        }
 
                        //早退
                        if (time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime() > 0
                            && time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime() < 0
                        ) {
                            //早退
                            attendance.setAttendancetype("2");
                            attendance.setClocktype("1");
                            //新增考勤消息
                            return R.status(attendanceService.save(attendance));
                        }
 
                        //正常下班
                        if (time - (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000) <= 0
                            && time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime() >= 0
                        ) {
                            //新增下班
                            attendance.setAttendancetype("0");
                            attendance.setClocktype("1");
                            //新增考勤消息
                            return R.status(attendanceService.save(attendance));
                        }
 
                        //其他时间修改
                        if (time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000>0){
                            //加班
//                            attendance.setAttendancetype("加班");
                            attendance.setId(attendanceList.get(0).getId());
                            //更新考勤消息
                            return R.status(attendanceService.updateById(attendance));
                        }
 
 
                    }else {
                        //上午
                        //更新
                        if (time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonWorkTime).getTime() <= 0) {
                            //更新上班时间
                            //正常上班
                            attendance.setAttendancetype("0");
                            attendance.setId(attendanceList.get(0).getId());
                            //更新考勤消息
                            return R.status(attendanceService.updateById(attendance));
                        }
                        //上午早退
                        if (time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonWorkTime).getTime() > 0
                            && time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime() < 0
                        ) {
                            //早退
                            attendance.setAttendancetype("2");
                            attendance.setClocktype("1");
                            //新增考勤消息
                            return R.status(attendanceService.save(attendance));
                        }
                        //下午早退
                        if (time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime() > 0
                            && time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime() < 0
                        ) {
                            //早退
                            attendance.setAttendancetype("2");
                            attendance.setClocktype("1");
                            //新增考勤消息
                            return R.status(attendanceService.save(attendance));
                        }
 
                        //上午正常下班
                        if (time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()>=0
                            && time - (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()+30*60*1000)<=0
                        ){
                            //下班
                            attendance.setAttendancetype("0");
                            attendance.setClocktype("1");
                            //新增考勤信息
                            return R.status(attendanceService.save(attendance));
                        }
                        //下午正常下班
                        if (time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()>=0
                            && time - (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000)<=0
                        ){
                            //下班
                            attendance.setAttendancetype("0");
                            attendance.setClocktype("1");
                            //新增考勤信息
                            return R.status(attendanceService.save(attendance));
                        }
 
                        //正常上班
                        if (time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()<=0
                        && time - (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()+30*60*1000)>0
                        ){
                            //上班
                            attendance.setAttendancetype("0");
                            attendance.setClocktype("0");
                            //新增考勤信息
                            return R.status(attendanceService.save(attendance));
                        }
                    }
                }
                //第三次打卡
                if (attendanceList.size()==2){
                    //第三次记录打卡如果时间范围在上午的在早退时间及下班后的半小时范围内,则更新上一次打卡记录
                    if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonWorkTime).getTime()>0
                        && time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()+30*60*1000)<0
                        ){
                        Attendance attendance1 = attendanceList.get(1);
                        attendance1.setClocktime(attendance.getClocktime());
                        //更新打卡信息
                        return R.status(attendanceService.updateById(attendance1));
                    }
                    //第三次打卡记录时间返回在上午下班半小时后到下午上班
                    if(time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()<=0
                        && time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()+30*60*1000)>=0){
                        //新增正常打卡信息
                        attendance.setClocktype("0");
                        attendance.setAttendancetype("0");
                        return R.status(attendanceService.save(attendance));
                    }
                    //第三次打卡记录时间返回在下午上班到下午下班之前
                    if(time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()>0
                        && time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()<0){
                        //判断第二次是否已经打卡上班
                        if (attendanceList.get(1).getClocktype().equals("0")){
                            //修改打卡信息
                            attendance.setClocktype("1");
                            attendance.setAttendancetype("2");
                            return R.status(attendanceService.save(attendance));
                        }else {
                            //新增上班迟到打卡信息
                            attendance.setClocktype("0");
                            attendance.setAttendancetype("1");
                            return R.status(attendanceService.save(attendance));
                        }
                    }
                    //下午正常下班时间节点
                    if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()>0
                        && time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000)<=0){
                        //新增下班正常打卡信息
                        attendance.setClocktype("1");
                        attendance.setAttendancetype("0");
                        return R.status(attendanceService.save(attendance));
                    }
                    //其他时间修改
                    if (time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000)>0){
                        //修改打卡信息
                        attendance.setClocktype("1");
                        attendance.setAttendancetype("2");
                        return R.status(attendanceService.save(attendance));
                    }
                }
                //第四次打卡
                if (attendanceList.size()==3){
                    //第四次打卡记录时间返回在上午下班半小时后到下午上班
                    if(time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()<=0
                        && time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()+30*60*1000)>=0){
                        Attendance attendance2 = attendanceList.get(2);
                        attendance2.setClocktime(attendance.getClocktime());
                        //更新正常打卡信息
                        return R.status(attendanceService.updateById(attendance2));
                    }
                    //第四次打卡记录时间返回在下午上班到下午下班之前
                    if(time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()>0
                        && time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()<0){
                        //判断第二次是否是早退或者迟到
                        //迟到
                        if (attendanceList.get(2).getAttendancetype().equals("1")){
                            //新增下班早退打卡信息
                            attendance.setClocktype("1");
                            attendance.setAttendancetype("2");
                            return R.status(attendanceService.save(attendance));
                        }else {
                            //早退
                            //更新上班早退打卡信息,只更新打卡时间,不更新考勤状态
                            Attendance attendance2 = attendanceList.get(2);
                            attendance2.setClocktime(attendance.getClocktime());
                            return R.status(attendanceService.updateById(attendance2));
                        }
                    }
                    //下午正常下班时间节点
                    if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()>0
                        && time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000)<=0){
                        //如果上一次为早退,则只更新信息
                        if (attendanceList.get(2).getAttendancetype().equals("2")) {
                            //修改打卡信息
                            Attendance attendance2 = attendanceList.get(2);
                            attendance2.setClocktime(attendance.getClocktime());
                            return R.status(attendanceService.updateById(attendance2));
                        }else {
                            //新增正常下班打卡信息
                            attendance.setClocktype("1");
                            attendance.setAttendancetype("0");
                            return R.status(attendanceService.save(attendance));
                        }
                    }
                    //其他时间
                    if (time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000)>0){
                        //修改打卡信息
                        Attendance attendance2 = attendanceList.get(2);
                        attendance2.setClocktime(attendance.getClocktime());
                        return R.status(attendanceService.updateById(attendance2));
                    }
                }
                //第五次打卡
                if (attendanceList.size()==4){
                    //只有在下午下班后可以有新增加班考勤数据,其他情况则是更新第四次的记录
                    //第五次打卡记录时间返回在下午上班到下午下班后的30分钟之前
//                    if(time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()>0
//                        && time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()<0){
//                            //早退
//                            //更新上班早退打卡信息,只更新打卡时间,不更新考勤状态
//                            Attendance attendance3 = attendanceList.get(3);
//                            attendance3.setClocktime(attendance.getClocktime());
//                            return R.status(attendanceService.updateById(attendance3));
//                    }
                    Attendance attendance3 = attendanceList.get(3);
                    attendance3.setClocktime(attendance.getClocktime());
                    return R.status(attendanceService.updateById(attendance3));
                    //下午正常下班30分钟后时间节点
//                    if (time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000)>0){
//                        //如果上一次为早退,则只更新信息
//                        //新增正常下班打卡信息
//                        attendance.setClocktype("1");
//                        attendance.setAttendancetype("0");
//                        return R.status(attendanceService.save(attendance));
//                    }
                }
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }
        return R.status(false);
    }
 
    /**
     * 修改
     */
    @PostMapping("/update")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "修改", notes = "传入attendance")
    public R update(@Valid @RequestBody Attendance attendance) {
        return R.status(attendanceService.updateById(attendance));
    }
 
    /**
     * 新增或修改
     */
    @PostMapping("/submit")
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "新增或修改", notes = "传入attendance")
    public R submit(@Valid @RequestBody Attendance attendance) {
        return R.status(attendanceService.saveOrUpdate(attendance));
    }
 
 
    /**
     * 删除
     */
    @PostMapping("/remove")
    @ApiOperationSupport(order = 8)
    @ApiOperation(value = "删除", notes = "传入ids")
    public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
        return R.status(attendanceService.removeByIds(Func.toLongList(ids)));
    }
 
    /**
     * 导出用户
     */
    @GetMapping("/export-Attendance")
    public void exportAttendane(String name, String beginTime, String endTime, String attendancetype, HttpServletResponse response) {
        String beginTimes = null;
        String endTimes = null;
        String attendancetypes = null;
        if (beginTime.equals("undefined        ") && endTime.equals("undefined")) {
            beginTimes=null;
            endTimes=null;
            attendancetypes=attendancetype;
        }
        else if (attendancetype.equals("undefined")){
            attendancetypes=null;
        }
        else {
            beginTimes=beginTime;
            endTimes=endTime;
            attendancetypes=attendancetype;
        }
 
        List<AttendanceExcel> list = attendanceService.exportAttendane(name, beginTimes, endTimes, attendancetypes);
        ExcelUtil.export(response, "考勤数据" + DateUtil.time(), "考勤数据表", list, AttendanceExcel.class);
 
 
}
 
}