283 lines
8.6 KiB
Plaintext
283 lines
8.6 KiB
Plaintext
package com.bonus.seat.controller;
|
|
|
|
|
|
import com.bonus.mcu.beans.BallBean;
|
|
import com.bonus.mcu.beans.GlobalConst;
|
|
import com.bonus.mcu.service.McuService;
|
|
import com.bonus.registration.beans.RegistrationBean;
|
|
import com.bonus.registration.service.RegistrationService;
|
|
import com.bonus.score.beans.ScoreBean;
|
|
import com.bonus.seat.beans.SeatBean;
|
|
import com.bonus.seat.service.SeatService;
|
|
import com.bonus.sys.AjaxRes;
|
|
import com.bonus.sys.BaseController;
|
|
import com.bonus.sys.Page;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.ui.Model;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import java.io.File;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
import java.util.Date;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* @author lzh
|
|
*/
|
|
@Controller
|
|
@RequestMapping("/backstage/seat/")
|
|
public class SeatController extends BaseController<SeatBean> {
|
|
|
|
@Autowired
|
|
SeatService service;
|
|
|
|
@Autowired
|
|
RegistrationService registrationService;
|
|
|
|
@Autowired
|
|
private McuService mcuService;
|
|
|
|
@RequestMapping("openinserd")
|
|
public String openinserd(Model model) {
|
|
List<SeatBean> findRoomInfo = service.findRoomInfo();
|
|
model.addAttribute("findRoomInfo", findRoomInfo);
|
|
return "/site/siteForm";
|
|
}
|
|
|
|
@RequestMapping("list")
|
|
public String List(Model model) {
|
|
return "/site/siteList";
|
|
}
|
|
|
|
@RequestMapping("findByPage")
|
|
public String findByPage(@RequestBody Page<SeatBean> page, SeatBean o, Model model) {
|
|
try {
|
|
o = page.getObj();
|
|
page = service.findByPage(o, page);
|
|
if (page.getResults() != null && page.getResults().size() != 0) {
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy");// 设置日期格式
|
|
String date = df.format(new Date());
|
|
for (int i = 0; i < page.getResults().size(); i++) {
|
|
SeatBean bean = page.getResults().get(i);
|
|
page.getResults().set(i, bean);
|
|
}
|
|
}
|
|
model.addAttribute("page", page);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
return "/site/siteDetails";
|
|
}
|
|
|
|
|
|
// 选择座位
|
|
@RequestMapping("selectSeat")
|
|
public String selectSeat(String id, Model model) {
|
|
|
|
List<SeatBean> seat = service.findRoomInfo();
|
|
model.addAttribute("seat", seat);
|
|
return "/grade/selectSeatPage";
|
|
}
|
|
|
|
|
|
@RequestMapping("addRegistration")
|
|
@ResponseBody
|
|
public AjaxRes addQuestion(@RequestBody SeatBean o) {
|
|
AjaxRes ar = getAjaxRes();
|
|
try {
|
|
ar = service.addRegistration(o);
|
|
ar.setSucceedMsg("添加考试人员成功");
|
|
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
ar.setFailMsg("新增座位号人员失败,异常处理!");
|
|
}
|
|
return ar;
|
|
}
|
|
/**
|
|
* 删除
|
|
* @param o
|
|
* @return
|
|
*/
|
|
@RequestMapping("delete")
|
|
@ResponseBody
|
|
public AjaxRes deleteApply(SeatBean o) {
|
|
AjaxRes ar = getAjaxRes();
|
|
try {
|
|
ar = service.deleteApply(o);
|
|
} catch (Exception e) {
|
|
logger.error(e.toString(), e);
|
|
ar.setFailMsg("删除失败!");
|
|
}
|
|
return ar;
|
|
}
|
|
|
|
// 查看人员对应座位
|
|
@RequestMapping("checkSeat")
|
|
public String checkSeat(Model model, HttpServletRequest request) {
|
|
String examId = request.getParameter("id");
|
|
String examPersonNum = request.getParameter("examPersonNum");
|
|
SeatBean o = new SeatBean();
|
|
o.setExamId(examId);
|
|
List<SeatBean> lists = service.checkSeat(o);
|
|
String info = "";
|
|
for (SeatBean seat: lists){
|
|
info += seat.getSeatNum()+"-";
|
|
info += seat.getIdcard()+"-";
|
|
info += seat.getUser().getName()+"-";
|
|
if (seat.getNowIdcard()!=null && !seat.getNowIdcard().equals("")){
|
|
info += seat.getNowIdcard()+"-";
|
|
info += seat.getNowUserName()+"-";
|
|
}
|
|
info += seat.getExamId()+";";
|
|
}
|
|
model.addAttribute("lists",lists);
|
|
model.addAttribute("info",info);
|
|
return "/grade/checkSeatPage";
|
|
}
|
|
|
|
// 选择座位
|
|
@RequestMapping("findSeatPage")
|
|
public String findSeatPage(String id, Model model) {
|
|
|
|
List<SeatBean> seat = service.findRoomInfo();
|
|
model.addAttribute("seat", seat);
|
|
return "/grade/selectSeatPage";
|
|
}
|
|
|
|
@RequestMapping("saveSeatNum")
|
|
@ResponseBody
|
|
public AjaxRes saveSeatNum(SeatBean o) {
|
|
service.delete(o);
|
|
AjaxRes ar = getAjaxRes();
|
|
Integer res = 0;
|
|
String seatNums = o.getSeatNumArrs();
|
|
String[] seatArr = seatNums.split(";");
|
|
List<RegistrationBean> lists = registrationService.findExamingPerson(o);
|
|
Collections.shuffle(lists);
|
|
for (int i = 0;i<lists.size();i++) {
|
|
o.setSeatNum(seatArr[i]);
|
|
o.setIdcard(lists.get(i).getIdcard());
|
|
res = service.insertInfo(o);
|
|
if(res == 0) {
|
|
ar.setFailMsg("选择座位失败");
|
|
}else{
|
|
ar.setSucceedMsg("选择座位保存成功!!!");
|
|
}
|
|
}
|
|
return ar;
|
|
}
|
|
/**
|
|
*违规图片查询
|
|
* @param o
|
|
* @param model
|
|
* @return
|
|
*/
|
|
@RequestMapping("findpictureByid")
|
|
public String findpictureByid(SeatBean o, Model model) {
|
|
try {
|
|
o = service.findById(o);
|
|
model.addAttribute("registration", o);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
return "/site/pictureForm";
|
|
}
|
|
/**
|
|
* 座位号修改
|
|
* @param o
|
|
* @param model
|
|
* @return
|
|
*/
|
|
@RequestMapping("findRegistrationForm")
|
|
public String questionFormPage(SeatBean o, Model model) {
|
|
try {
|
|
o = service.findById(o);
|
|
model.addAttribute("registration", o);
|
|
List<SeatBean> findRoomInfo = service.findRoomInfo();
|
|
model.addAttribute("findRoomInfo", findRoomInfo);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
return "/site/siteForm";
|
|
}
|
|
@RequestMapping(value = "import", method = RequestMethod.POST)
|
|
@ResponseBody
|
|
public AjaxRes export(@RequestParam("file") MultipartFile file) {
|
|
AjaxRes ar = getAjaxRes();
|
|
ar=service.export(file);
|
|
return ar;
|
|
}
|
|
@RequestMapping(value = "findfilesave", method = RequestMethod.POST)
|
|
@ResponseBody
|
|
public AjaxRes saveProject(@RequestParam("articleImageFile") MultipartFile file,HttpServletRequest request) {
|
|
AjaxRes ar = getAjaxRes();
|
|
String path = request.getSession().getServletContext().getRealPath("upload");
|
|
String kc = request.getParameter("kc");
|
|
String zw = request.getParameter("zw");
|
|
String uuidpicture=get32UUID();
|
|
SeatBean bean=new SeatBean();
|
|
bean.setRoomName(kc);
|
|
bean.setSeatId(zw);
|
|
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/"+"upload/";
|
|
bean.setPicture(basePath+uuidpicture+".jpg");
|
|
File parent = new File(path);
|
|
if (!parent.exists()) {
|
|
parent.mkdirs();
|
|
}
|
|
//通过场次和座位号更新此条座位号的违章图片
|
|
try {
|
|
int n=service.updateBykc(bean);
|
|
if(n == 1) {
|
|
File dest = new File(parent, uuidpicture+".jpg");
|
|
file.transferTo(dest);
|
|
ar.setSucceedMsg("违规图片上传成功");
|
|
}else {
|
|
|
|
ar.setSucceedMsg("考场没有找到指定的人");
|
|
}
|
|
} catch (Exception e) {
|
|
ar.setFailMsg("违规图片上传失败");
|
|
e.printStackTrace();
|
|
}
|
|
|
|
return ar;
|
|
|
|
}
|
|
/**
|
|
* 通过摄像头获取摄像头对应的人员信息
|
|
*/
|
|
@RequestMapping(value = "getinfoBysxt", method = RequestMethod.POST)
|
|
@ResponseBody
|
|
public AjaxRes findByPageTwo(BallBean bean) {
|
|
|
|
AjaxRes ar = getAjaxRes();
|
|
try {
|
|
List<BallBean> getinfoBysxt = mcuService.getinfoBysxt(bean);
|
|
Map<String, Object> p = new HashMap<String, Object>();
|
|
p.put("list", getinfoBysxt);
|
|
ar.setSucceed(p);
|
|
} catch (Exception e) {
|
|
logger.error(e.toString(), e);
|
|
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
|
}
|
|
return ar;
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|