package com.hxzkoa.controller;
|
|
import java.io.File;
|
import java.io.IOException;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.multipart.MultipartFile;
|
|
import com.hxzkoa.json.R;
|
import com.hxzkoa.json.tb_system;
|
import com.hxzkoa.services.HelmetService;
|
import com.hxzkoa.services.SysSettingService;
|
import com.hxzkoa.tools.SocketUtil;
|
|
@Controller
|
public class HelmetController {
|
|
@Autowired
|
HelmetService helmetService;
|
@Autowired
|
SysSettingService sysSettingService;
|
|
@ResponseBody
|
@RequestMapping(value="warning.do",method={RequestMethod.POST,RequestMethod.GET})
|
public R warning(HttpServletRequest request) {
|
String tagid = request.getParameter("tagid");
|
String type = request.getParameter("type");
|
switch(type) {
|
case "offhat":
|
helmetService.offhat(tagid, "1");
|
break;
|
case "smash":
|
helmetService.smash(tagid, "1");
|
break;
|
case "stopmoving":
|
helmetService.stopmoving(tagid,"1");
|
break;
|
case "high":
|
helmetService.high(tagid,"1");
|
break;
|
case "nearele":
|
helmetService.nearele(tagid,"1");
|
}
|
return R.ok();
|
}
|
|
@ResponseBody
|
@RequestMapping(value="video.do",method={RequestMethod.POST})
|
public R video(MultipartFile file,HttpServletRequest request) {
|
String tagid = request.getParameter("tagid");
|
File filen = new File(request.getServletContext().getRealPath("/")+"hxzk\\image\\video\\"+tagid+"."+file.getContentType().split("/")[1]);
|
if (!file.isEmpty()) {
|
try {
|
file.transferTo(filen);
|
helmetService.video(tagid, tagid+"."+file.getContentType().split("/")[1]);
|
return R.ok();
|
} catch (IOException e) {
|
throw new RuntimeException(e);
|
}
|
} else {
|
return R.error("文件不能为空");
|
}
|
}
|
|
@ResponseBody
|
@RequestMapping(value="audio.do",method={RequestMethod.POST})
|
public R audio(MultipartFile file,HttpServletRequest request) {
|
String tagid = request.getParameter("tagid");
|
File filen = new File(request.getServletContext().getRealPath("/")+"hxzk\\image\\audio\\"+tagid+"."+file.getContentType().split("/")[1]);
|
if (!file.isEmpty()) {
|
try {
|
file.transferTo(filen);
|
helmetService.audio(tagid, tagid+"."+file.getContentType().split("/")[1]);
|
return R.ok();
|
} catch (IOException e) {
|
throw new RuntimeException(e);
|
}
|
} else {
|
return R.error("文件不能为空");
|
}
|
}
|
|
@ResponseBody
|
@RequestMapping(value="setgps.do",method={RequestMethod.POST})
|
public R setgps(HttpServletRequest request) {
|
String tagid = request.getParameter("tagid");
|
String lon = request.getParameter("lon");
|
String lat = request.getParameter("lat");
|
helmetService.setgps(tagid,lon,lat);
|
return R.ok();
|
}
|
|
@ResponseBody
|
@RequestMapping(value="sendmsg.do", method={RequestMethod.POST,RequestMethod.GET})
|
public R sendmsg(HttpServletRequest request) {
|
String tagid = request.getParameter("tagid");
|
String message = request.getParameter("message");
|
message = tagid+":"+message;
|
new SocketUtil().sendmsg(message);
|
return R.ok();
|
}
|
}
|