人脸临时修改

This commit is contained in:
czx 2021-01-12 16:32:55 +08:00
parent 172dd0dcd3
commit 6083931b6d
3 changed files with 174 additions and 44 deletions

View File

@ -0,0 +1,39 @@
package com.ruoyi.system.fantang.common;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import java.util.Date;
public enum DinnerType {
breakfast, lunch, dinner, notMatch;
/**
* 根据当前时间判断现在的就餐类型
* @return 返回就餐类型的枚举类
*/
public static DinnerType GetDinnerType() {
String today = DateUtil.today();
Date breakfastStart = DateUtil.parse(today + " 07:30");
Date breakfastEnd = DateUtil.parse(today + " 08:30");
Date lunchStart = DateUtil.parse(today + " 11:30");
Date lunchEnd = DateUtil.parse(today + " 12:30");
Date dinnerStart = DateUtil.parse(today + " 17:00");
Date dinnerEnd = DateUtil.parse(today + " 18:00");
DateTime now = new DateTime(DateTime.now());
if (now.isIn(breakfastStart, breakfastEnd) == true) {
return DinnerType.breakfast;
} else if (now.isIn(lunchStart, lunchEnd) == true) {
return DinnerType.lunch;
} else if (now.isIn(dinnerStart, dinnerEnd) == true){
return DinnerType.dinner;
}else {
return DinnerType.notMatch;
}
}
}

View File

@ -0,0 +1,70 @@
package com.ruoyi.system.fantang.common;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.ruoyi.system.fantang.service.IFtConfigDaoService;
import com.ruoyi.system.fantang.service.impl.FtConfigDaoServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.Map;
@Lazy
@Service
@Transactional
public class DinnerTypeUtils {
public enum DinnerType {
breakfast, lunch, dinner, notMatch;
}
private Date breakfastStart;
private Date breakfastEnd;
private Date lunchStart;
private Date lunchEnd;
private Date dinnerStart;
private Date dinnerEnd;
@Autowired
IFtConfigDaoService configDaoService;
@Autowired(required = true)
public DinnerTypeUtils() {
Map<String, String> setting = configDaoService.getDinnerTimeSetting();
String today = DateUtil.today();
this.breakfastStart = DateUtil.parse(today + setting.get("breakfastStart"));
this.breakfastEnd = DateUtil.parse(today + setting.get("breakfastEnd"));
this.lunchStart = DateUtil.parse(today + setting.get("lunchStart"));
this.lunchEnd = DateUtil.parse(today + setting.get("lunchEnd"));
this.dinnerStart = DateUtil.parse(today + setting.get("dinnerStart"));
this.dinnerEnd = DateUtil.parse(today + setting.get("dinnerEnd"));
}
/**
* 根据当前时间判断现在的就餐类型
*
* @return 返回就餐类型的枚举类
*/
public DinnerType GetDinnerType() {
DateTime now = new DateTime(DateTime.now());
if (now.isIn(this.breakfastStart, this.breakfastEnd)) {
return DinnerType.breakfast;
} else if (now.isIn(this.lunchStart, this.lunchEnd)) {
return DinnerType.lunch;
} else if (now.isIn(this.dinnerStart, this.dinnerEnd)) {
return DinnerType.dinner;
} else {
return DinnerType.notMatch;
}
}
}

View File

@ -6,10 +6,13 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.fantang.common.DinnerType;
import com.ruoyi.system.fantang.common.DinnerTypeUtils;
import com.ruoyi.system.fantang.domain.*; import com.ruoyi.system.fantang.domain.*;
import com.ruoyi.system.fantang.mapper.FtFaceEventDaoMapper; import com.ruoyi.system.fantang.mapper.FtFaceEventDaoMapper;
import com.ruoyi.system.fantang.service.*; import com.ruoyi.system.fantang.service.*;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -23,7 +26,7 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@Slf4j
@RequiredArgsConstructor(onConstructor_ = @Autowired) @RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController @RestController
@RequestMapping("/client_api/staff") @RequestMapping("/client_api/staff")
@ -558,55 +561,73 @@ public class ClientController extends BaseController {
* @return * @return
*/ */
@PostMapping("/heartbeat") @PostMapping("/heartbeat")
public String HeartbeatControl(HttpServletRequest request){ public String faceDeviceHeartbeatEvent(@RequestBody JSONObject request){
System.out.println("face device heartbeat....."); System.out.println("face device heartbeat.....");
StringBuffer data = new StringBuffer(); System.out.println(request);
String line = null; return "ok";
BufferedReader reader = null; // StringBuffer data = new StringBuffer();
try { // String line = null;
reader = request.getReader(); // BufferedReader reader = null;
while (null != (line = reader.readLine())) { // try {
data.append(line); // reader = request.getReader();
} // while (null != (line = reader.readLine())) {
JSONObject jsonObject = JSONObject.parseObject(data.toString()); // data.append(line);
System.out.println(jsonObject); // }
} catch (IOException e) { // JSONObject jsonObject = JSONObject.parseObject(data.toString());
} finally { // System.out.println(jsonObject);
} // } catch (IOException e) {
return data.toString(); // } finally {
// }
// return data.toString();
} }
@PostMapping("/Verify") @PostMapping("/verify")
public String VerifyControl(HttpServletRequest request){ public String faceDeviceVerifyEvent(@RequestBody JSONObject request){
System.out.println("verify.....");
StringBuffer data = new StringBuffer();
try { // 判断是否在用餐时间否则只写日志不处理事件
BufferedReader reader = request.getReader(); DinnerType dinnerType = DinnerType.GetDinnerType();
String line = null; System.out.println(request);
while (null != (line = reader.readLine())) if (dinnerType == DinnerType.notMatch) {
data.append(line); log.info("data : {} " , request);
JSONObject jsonObject = JSONObject.parseObject(data.toString()); return request.toJSONString();
System.out.println(jsonObject); }
HashMap<String, Object> map = new HashMap<>(); // 从数据中获取人脸id
map.put("flag", 0);
List<FtFaceEventDao> dao = faceEventService.selectByMap(map);
if (dao.size() == 0)
{
JSONObject infoObject = JSONObject.parseObject(jsonObject.getString("info"));
FtFaceEventDao eventDao = new FtFaceEventDao();
eventDao.setDeviceId(infoObject.getString("DeviceID")); // 跟进人脸id信息查找该id对应的员工id的当餐订单
eventDao.setPersonId(infoObject.getString("PersonID"));
// faceEventService.insert(eventDao); // 将该订餐设置为核销状态
}
else {
} // StringBuffer data = new StringBuffer();
} catch (IOException e) { //
} finally { // try {
} // // 从请求头中获取数据
// BufferedReader reader = request.getReader();
// String line = null;
// while (null != (line = reader.readLine()))
// data.append(line);
// JSONObject jsonObject = JSONObject.parseObject(data.toString());
// System.out.println(jsonObject);
//
// HashMap<String, Object> map = new HashMap<>();
// map.put("flag", 0);
// List<FtFaceEventDao> dao = faceEventService.selectByMap(map);
// if (dao.size() == 0)
// {
// JSONObject infoObject = JSONObject.parseObject(jsonObject.getString("info"));
// FtFaceEventDao eventDao = new FtFaceEventDao();
//
// eventDao.setDeviceId(infoObject.getString("DeviceID"));
// eventDao.setPersonId(infoObject.getString("PersonID"));
//// faceEventService.insert(eventDao);
// }
// else {
// }
// } catch (IOException e) {
// } finally {
// }
return "ok"; return "ok";
} }