// // Source code recreated from a .class file by IntelliJ IDEA // (powered by FernFlower decompiler) // package com.hxzkoa.controller; import com.hxzkoa.json.R; import com.hxzkoa.json.tb_person; import com.hxzkoa.json.tb_tag; import com.hxzkoa.services.BasicInfoService; import com.hxzkoa.services.HelmetService; import com.hxzkoa.services.LabelService; import com.hxzkoa.services.SysSettingService; import com.hxzkoa.tools.SocketUtil; import com.hxzkoa.util.Config; import java.io.File; import java.io.IOException; import java.util.List; 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; @Controller public class HelmetController { @Autowired HelmetService helmetService; @Autowired SysSettingService sysSettingService; @Autowired LabelService labelservice; @Autowired BasicInfoService basicInfoService; public HelmetController() { } @ResponseBody @RequestMapping( value = {"warning.do"}, method = {RequestMethod.POST, RequestMethod.GET} ) public R warning(HttpServletRequest request) { String tagid = request.getParameter("tagid"); switch (request.getParameter("type")) { case "offhat": this.helmetService.offhat(tagid, "1"); break; case "smash": this.helmetService.smash(tagid, "1"); break; case "stopmoving": this.helmetService.stopmoving(tagid, "1"); break; case "high": this.helmetService.high(tagid, "1"); break; case "nearele": this.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); this.helmetService.video(tagid, tagid + "." + file.getContentType().split("/")[1]); return R.ok(); } catch (IOException var6) { throw new RuntimeException(var6); } } 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); this.helmetService.audio(tagid, tagid + "." + file.getContentType().split("/")[1]); return R.ok(); } catch (IOException var6) { throw new RuntimeException(var6); } } else { return R.error("文件不能为空"); } } @ResponseBody @RequestMapping( value = {"image.do"}, method = {RequestMethod.POST} ) public R image(MultipartFile file, HttpServletRequest request) { String tagid = request.getParameter("tagid"); File filen = new File(request.getServletContext().getRealPath("/") + "hxzk\\image\\image\\" + tagid + "." + file.getContentType().split("/")[1]); if (!file.isEmpty()) { try { file.transferTo(filen); this.helmetService.image(tagid, tagid + "." + file.getContentType().split("/")[1]); return R.ok(); } catch (IOException var6) { throw new RuntimeException(var6); } } 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"); this.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(); } @ResponseBody @RequestMapping( value = {"addtagid.do"}, method = {RequestMethod.POST, RequestMethod.GET} ) public R addtagid(HttpServletRequest request) { String tagid = request.getParameter("tagid"); List tag = this.labelservice.searchLabelManagement(tagid); if (tag.size() == 0) { tb_tag taga = new tb_tag(); taga.setTag_id(tagid); taga.setState(request.getParameter("name")); taga.setGaodu("150"); taga.setSudu("1000"); taga.setPinglv("1"); taga.setVersion(Config.getVersion()); this.labelservice.labelManagement_add(taga); tb_person person = new tb_person(); person.setP_tagid(taga.getTag_id()); person.setP_name(taga.getState()); person.setP_power("100"); person.setP_sex("男"); person.setP_minzu("汉"); person.setP_phone("131******88"); person.setP_department("系统默认"); person.setP_x("0"); person.setP_y("0"); person.setP_floor("0"); person.setP_sos("0"); person.setP_online("0"); person.setP_kaoqing("0"); person.setP_fence("0"); person.setP_image("image/targeticon/default.png"); this.basicInfoService.personManagement_add(person); } return R.ok(); } @ResponseBody @RequestMapping( value = {"playstop.do"}, method = {RequestMethod.POST, RequestMethod.GET} ) public R playstop(HttpServletRequest request) { String tagid = request.getParameter("tagid"); String type = request.getParameter("type"); String filename = this.helmetService.removefile(tagid, type); File file; if (type.equals("baoliu30")) { file = new File(request.getServletContext().getRealPath("/") + "hxzk\\image\\video\\" + filename); file.delete(); } else { file = new File(request.getServletContext().getRealPath("/") + "hxzk\\image\\audio\\" + filename); file.delete(); } this.helmetService.guanbi(tagid, type); return R.ok(); } }