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;
|
}
|
}
|