zhitong.yu
2024-10-11 4f58a93c95ff123d51adcb8fa2e521333e8ab022
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
package com.hxzk.controller;
 
import com.github.pagehelper.PageInfo;
import com.hxzk.pojo.*;
import com.hxzk.service.FenceService;
import com.hxzk.service.ShiShiKaoQinService;
import com.hxzk.util.result;
import com.hxzk.util.resultutil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.text.SimpleDateFormat;
import java.util.*;
 
@RestController
@RequestMapping("/")
public class ShiShiKaoQinController {
    @Autowired
    ShiShiKaoQinService shiShiKaoQinService;
 
    @Autowired
    FenceService fenceService;
    @GetMapping("findshishikaoqin")
    result<List<TbRealkaoqing>> findshishigaojing(Integer page, Integer limit){
        PageInfo<TbRealkaoqing> cz= shiShiKaoQinService.findAll(page, limit);
        return resultutil.returnSuccess(cz.getTotal(), cz.getList());
    }
 
    @PostMapping("findShiShiKaoQinSearch")
    result<List<TbRealkaoqing>> findanchorSearch(Integer page, Integer limit, TbRealkaoqing realkaoqing){
        PageInfo<TbRealkaoqing> cz= shiShiKaoQinService.findSearch(page, limit,realkaoqing);
        return resultutil.returnSuccess(cz.getTotal(), cz.getList());
    }
    //获取在考勤区域中的人员信息
    @GetMapping("findKaoQinQuYu")
    public List<TbRealkaoqing> findKaoQinQuYu(){
        List<TbRealkaoqing> kaoqin =shiShiKaoQinService.findKaoQinQuYu();
        List<TbFence> fences = fenceService.findAllFence();
        List<TbRealkaoqing> filteredKaoqin = new ArrayList<>();
        // 遍历 fences 列表
        for (TbFence fence : fences) {
            String fenceName = fence.getName();
            // 检查在 kaoqin 列表中是否存在相同 name 的 TbRealkaoqing 对象
            if (kaoqin.size() == 0){
                TbRealkaoqing kaoqing1 = new TbRealkaoqing();
                kaoqing1.setTagid("0");
                kaoqing1.setArea(fenceName);
                kaoqing1.setName(gettime());
                filteredKaoqin.add(kaoqing1);
            }else{
                for (TbRealkaoqing kaoqing : kaoqin) {
                    if (kaoqing.getArea().equals(fenceName)) {
                        filteredKaoqin.add(kaoqing);
                    }else{
                        TbRealkaoqing kaoqing1 = new TbRealkaoqing();
                        kaoqing1.setTagid("0");
                        kaoqing1.setArea(fenceName);
                        kaoqing1.setName(gettime());
                        filteredKaoqin.add(kaoqing1);
                    }
                }
            }
 
        }
 
 
        return filteredKaoqin;
    }
 
 
    public String gettime(){
        Date now = new Date();
        // 创建日期格式化对象,设置格式为 "yyyy-MM-dd HH:mm"
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        // 格式化日期对象,输出字符串结果
        String formattedDate = sdf.format(now);
        return formattedDate;
    }
}