164 lines
5.8 KiB
Plaintext
164 lines
5.8 KiB
Plaintext
|
|
package com.bonus.recognition;
|
||
|
|
|
||
|
|
import java.util.HashMap;
|
||
|
|
import java.util.List;
|
||
|
|
import java.util.Map;
|
||
|
|
|
||
|
|
import javax.servlet.http.HttpServletRequest;
|
||
|
|
import javax.servlet.http.HttpServletResponse;
|
||
|
|
import javax.servlet.http.HttpSession;
|
||
|
|
|
||
|
|
import org.apache.poi.ss.formula.functions.T;
|
||
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
|
import org.springframework.stereotype.Controller;
|
||
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
||
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||
|
|
import com.bonus.registration.beans.RegistrationBean;
|
||
|
|
import com.bonus.registration.service.RegistrationService;
|
||
|
|
import com.bonus.sys.AjaxRes;
|
||
|
|
import com.bonus.sys.BaseController;
|
||
|
|
import com.bonus.sys.GlobalConst;
|
||
|
|
import com.gexin.fastjson.JSONObject;
|
||
|
|
|
||
|
|
@Controller
|
||
|
|
@RequestMapping("/Subscribe/")
|
||
|
|
public class recognController extends BaseController<T> {
|
||
|
|
@Autowired
|
||
|
|
RegistrationService service;
|
||
|
|
@Autowired
|
||
|
|
RegistrationService regisservice;
|
||
|
|
|
||
|
|
@RequestMapping("Snap")
|
||
|
|
public void Snap(HttpServletRequest request, @RequestBody JSONObject obj, HttpSession session) {
|
||
|
|
|
||
|
|
RegistrationBean jsonToBean = jsonToBean(obj);
|
||
|
|
//数据库通过最新时间获取最近一条数据记录
|
||
|
|
List<RegistrationBean> bean=service.getnewinfoBytime();
|
||
|
|
jsonToBean.setName(bean.get(0).getName());
|
||
|
|
jsonToBean.setIdcard(bean.get(0).getIdcard());
|
||
|
|
|
||
|
|
// 查询是否报名内的人员
|
||
|
|
RegistrationBean b = regisservice.findByidcard(bean.get(0).getIdcard());
|
||
|
|
if (b != null) {
|
||
|
|
//service.updatebyidcard(jsonToBean);
|
||
|
|
jsonToBean.setIfexamPeople("3");
|
||
|
|
service.sitesave(jsonToBean);
|
||
|
|
} else {
|
||
|
|
jsonToBean.setIfexamPeople("3");
|
||
|
|
service.sitesave(jsonToBean);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
@RequestMapping("Card")
|
||
|
|
public void Card(HttpServletRequest request, @RequestBody JSONObject obj, HttpSession session) {
|
||
|
|
// 查询是否报名内的人员
|
||
|
|
RegistrationBean jsonToBean = cardjsonToBean(obj);
|
||
|
|
RegistrationBean b = regisservice.findByidcard(jsonToBean.getIdcard());
|
||
|
|
if (b != null) {
|
||
|
|
// 通过查询当前的日期判断是否有人已经分配座位号
|
||
|
|
Integer getlimit = service.findbynowDate(jsonToBean);
|
||
|
|
if (getlimit > 0) {
|
||
|
|
service.updatebyidcard(jsonToBean);
|
||
|
|
} else {
|
||
|
|
service.sitesave(jsonToBean);
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
jsonToBean.setIfexamPeople("2");
|
||
|
|
service.sitesave(jsonToBean);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
@RequestMapping("Verify")
|
||
|
|
public void questionFormPage(HttpServletRequest request, @RequestBody JSONObject obj) {
|
||
|
|
RegistrationBean jsonToBean = jsonToBean(obj);
|
||
|
|
//数据库通过最新时间获取最近一条数据记录
|
||
|
|
List<RegistrationBean> bean=service.getnewinfoBytime();
|
||
|
|
jsonToBean.setName(bean.get(0).getName());
|
||
|
|
jsonToBean.setIdcard(bean.get(0).getIdcard());
|
||
|
|
|
||
|
|
// 查询是否报名内的人员
|
||
|
|
RegistrationBean b = regisservice.findByidcard(bean.get(0).getIdcard());
|
||
|
|
if (b != null) {
|
||
|
|
service.updatebyidcard(jsonToBean);
|
||
|
|
} else {
|
||
|
|
jsonToBean.setIfexamPeople("1");
|
||
|
|
service.sitesave(jsonToBean);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/*
|
||
|
|
* @RequestMapping("Verify") public void questionFormPage(HttpServletRequest
|
||
|
|
* request, @RequestBody JSONObject obj) { RegistrationBean jsonToBean =
|
||
|
|
* jsonToBean(obj); // 查询是否报名内的人员 RegistrationBean b =
|
||
|
|
* regisservice.findByidcard(jsonToBean.getIdcard()); if (b != null) {
|
||
|
|
* service.updatebyidcard(jsonToBean); } else { jsonToBean.setIfexamPeople("1");
|
||
|
|
* service.sitesave(jsonToBean); } }
|
||
|
|
*/
|
||
|
|
@RequestMapping(value = "selectseatinfo")
|
||
|
|
@ResponseBody
|
||
|
|
public AjaxRes toStartStatus(RegistrationBean o, HttpServletResponse response) {
|
||
|
|
response.setHeader("Access-Control-Allow-Origin", "*");
|
||
|
|
/* 星号表示所有的域都可以接受, */
|
||
|
|
response.setHeader("Access-Control-Allow-Methods", "GET,POST");
|
||
|
|
AjaxRes ar = getAjaxRes();
|
||
|
|
try {
|
||
|
|
List<RegistrationBean> list = service.selectseatinfo(o);
|
||
|
|
Map<String, Object> p = new HashMap<String, Object>();
|
||
|
|
p.put("list", list);
|
||
|
|
ar.setSucceed(p);
|
||
|
|
} catch (Exception e) {
|
||
|
|
logger.error(e.toString(), e);
|
||
|
|
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
||
|
|
}
|
||
|
|
return ar;
|
||
|
|
}
|
||
|
|
|
||
|
|
@RequestMapping("heartbeat")
|
||
|
|
public void heartbeat(HttpServletRequest request) {
|
||
|
|
// System.out.println("心跳");
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
public static RegistrationBean cardjsonToBean(JSONObject data) {
|
||
|
|
System.out.println(data.toString());
|
||
|
|
RegistrationBean bean = new RegistrationBean();
|
||
|
|
System.out.println(JSONObject.toJSONString(data));
|
||
|
|
String SanpPic = data.getString("IDCard_photo");// 图片64位的
|
||
|
|
bean.setPicture(SanpPic);
|
||
|
|
System.out.println(SanpPic);
|
||
|
|
String operator = data.getString("operator");
|
||
|
|
JSONObject info = data.getJSONObject("info");// 人员信息对象
|
||
|
|
String PersonID = info.getString("PersonID");// 人员id
|
||
|
|
String Name = info.getString("IDCard_Name");// 人员姓名
|
||
|
|
bean.setName(Name);
|
||
|
|
String IdCard = info.getString("IDCard_Idno");// 人员身份证
|
||
|
|
bean.setIdcard(IdCard);
|
||
|
|
String Temperature = info.getString("Temperature");// 温度
|
||
|
|
bean.setTemperature(Temperature);
|
||
|
|
return bean;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
public static RegistrationBean jsonToBean(JSONObject data) {
|
||
|
|
System.out.println(data.toString());
|
||
|
|
RegistrationBean bean = new RegistrationBean();
|
||
|
|
System.out.println(JSONObject.toJSONString(data));
|
||
|
|
String SanpPic = data.getString("SanpPic");// 图片64位的
|
||
|
|
bean.setPicture(SanpPic);
|
||
|
|
System.out.println(SanpPic);
|
||
|
|
String operator = data.getString("operator");
|
||
|
|
JSONObject info = data.getJSONObject("info");// 人员信息对象
|
||
|
|
String PersonID = info.getString("PersonID");// 人员id
|
||
|
|
String Name = info.getString("Name");// 人员姓名
|
||
|
|
bean.setName(Name);
|
||
|
|
String IdCard = info.getString("IdCard");// 人员身份证
|
||
|
|
bean.setIdcard(IdCard);
|
||
|
|
String Temperature = info.getString("Temperature");// 温度
|
||
|
|
bean.setTemperature(Temperature);
|
||
|
|
return bean;
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|