| | |
| | | // |
| | | // Source code recreated from a .class file by IntelliJ IDEA |
| | | // (powered by FernFlower decompiler) |
| | | // |
| | | |
| | | package com.hxzkoa.controller; |
| | | |
| | | import com.hxzkoa.json.tb_login; |
| | | import com.hxzkoa.json.tb_user; |
| | | import com.hxzkoa.services.LoginService; |
| | | import com.hxzkoa.udp.Baowen_Receive; |
| | | import com.hxzkoa.udp.Dell_tag_reg_ms; |
| | | import com.hxzkoa.udp.Gas_Receive; |
| | | import com.hxzkoa.udp.Gps_Receive; |
| | | import com.hxzkoa.udp.Transfer_Receive; |
| | | import com.hxzkoa.udp.Yuanshi_Receive; |
| | | import com.hxzkoa.udp.Zhuce_Receive; |
| | | import com.hxzkoa.util.Config; |
| | | import com.hxzkoa.util.ModifyConfig; |
| | | import com.hxzkoa.util.PageUtil; |
| | | import java.io.File; |
| | | import java.io.FileWriter; |
| | | import java.io.IOException; |
| | | import java.lang.Thread.State; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import javax.servlet.ServletContext; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpSession; |
| | | |
| | | //import org.apache.tomcat.jni.Thread; |
| | | import net.sf.json.JSONObject; |
| | | 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 com.hxzkoa.json.tb_system; |
| | | import com.hxzkoa.json.tb_user; |
| | | import com.hxzkoa.services.LoginService; |
| | | import com.hxzkoa.services.SysSettingService; |
| | | import com.hxzkoa.udp.Baowen_Receive; |
| | | import com.hxzkoa.udp.Dell_tag_reg_ms; |
| | | import com.hxzkoa.udp.Gas_Receive; |
| | | import com.hxzkoa.udp.Gps_Receive; |
| | | import com.hxzkoa.udp.Transfer_Receive; |
| | | /*import com.hxzkoa.udp.Udp_Receive;*/ |
| | | import com.hxzkoa.udp.Yuanshi_Receive; |
| | | import com.hxzkoa.udp.Yuanshibaowen; |
| | | import com.hxzkoa.udp.Zhuce_Receive; |
| | | import com.hxzkoa.util.Config; |
| | | import com.hxzkoa.util.HttpUtil; |
| | | import com.hxzkoa.util.ModifyConfig; |
| | | |
| | | import net.sf.json.JSONObject; |
| | | |
| | | @Controller |
| | | public class LoginController { |
| | | @Autowired |
| | | private LoginService loginService; |
| | | |
| | | /* Udp_Receive receive1; */ |
| | | Gps_Receive receive2; |
| | | Transfer_Receive receive3; |
| | | Yuanshi_Receive receive4; |
| | |
| | | Zhuce_Receive receive6; |
| | | Baowen_Receive receive7; |
| | | Dell_tag_reg_ms thread1; |
| | | /** |
| | | * 登录控制 |
| | | * |
| | | * @param username |
| | | * @param password |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @RequestMapping(value = "/login.do", method = { RequestMethod.POST, RequestMethod.GET }) |
| | | |
| | | public LoginController() { |
| | | } |
| | | |
| | | @RequestMapping( |
| | | value = {"/login.do"}, |
| | | method = {RequestMethod.POST, RequestMethod.GET} |
| | | ) |
| | | @ResponseBody |
| | | public String login(HttpServletRequest request) { |
| | | String username = request.getParameter("username"); |
| | | String password = request.getParameter("password"); |
| | | tb_user user = loginService.login(username); |
| | | tb_user user = this.loginService.login(username); |
| | | String result = "0"; |
| | | String db_password = user.getPassword(); |
| | | if (password.equals(db_password)) { |
| | |
| | | application.setAttribute("deleteq", user.getDeleteq()); |
| | | application.setAttribute("alertq", user.getAlertq()); |
| | | application.setAttribute("deleteall", user.getDeleteall()); |
| | | application.setAttribute("fenceq", user.getFenceq()); |
| | | session.setAttribute("username", user.getUsername()); |
| | | session.setAttribute("password", user.getPassword()); |
| | | session.setAttribute("superuser", user.getSuperuser()); |
| | | session.setAttribute("deleteq", user.getDeleteq()); |
| | | session.setAttribute("alertq", user.getAlertq()); |
| | | session.setAttribute("deleteall", user.getDeleteall()); |
| | | session.setAttribute("fenceq", user.getFenceq()); |
| | | result = "1"; |
| | | String username2 = (String) application.getAttribute("username"); |
| | | System.out.print(username2); |
| | | |
| | | // tb_system system = new tb_system(); |
| | | // system.setUdpPort("8234"); |
| | | // System.out.print(system); |
| | | // JSONObject jsonObject = JSONObject.fromObject(system); |
| | | // String postUrl = Config.getPostUrl(); |
| | | // String url_setting_bw = postUrl + "getSysSetting.do"; |
| | | // System.out.print(url_setting_bw); |
| | | // JSONObject re_tb_setting = HttpUtil.doPost(url_setting_bw, jsonObject.toString(), "UTF-8"); |
| | | // tb_system re_setting = (tb_system) JSONObject.toBean(JSONObject.fromObject(re_tb_setting.get("result").toString()), |
| | | // tb_system.class); |
| | | // System.out.print(re_setting); |
| | | // String port = re_setting.getUdpPort(); |
| | | // 开启报文接收 |
| | | // try { |
| | | // receive1 = new Udp_Receive(port); |
| | | // receive2 = new Gps_Receive(); |
| | | // receive3 = new Transfer_Receive(); |
| | | // receive4 = new Yuanshi_Receive(); |
| | | // receive5 = new Gas_Receive(); |
| | | // receive6 = new Zhuce_Receive(); |
| | | // receive7 = new Baowen_Receive(); |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // if (Config.getUdpRunning().equals("1")) { |
| | | // try { |
| | | // receive1.startThread(); |
| | | // receive2.startThread(); |
| | | // receive3.startThread(); |
| | | // receive4.startThread(); |
| | | // receive5.startThread(); |
| | | // receive6.startThread(); |
| | | // receive7.startThread(); |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // } |
| | | // |
| | | String var9 = (String)application.getAttribute("username"); |
| | | } |
| | | |
| | | |
| | | //初始化配置文件 |
| | | /* |
| | | * Udp_Receive.allMessage = new ArrayList<String>(); Udp_Receive.zhuceMessage = |
| | | * new ArrayList<String>(); Udp_Receive.debugMessage = new ArrayList<String>(); |
| | | * Udp_Receive.mysqlMessage = new ArrayList<String>(); Udp_Receive.hexMessage = |
| | | * new ArrayList<String>(); Udp_Receive.gasMessage = new ArrayList<String>(); |
| | | * Udp_Receive.tcpMessage = new ArrayList<String>(); Udp_Receive.yuanshiMessage |
| | | * = new ArrayList<String>(); Udp_Receive.udpMessage = new ArrayList<String>(); |
| | | */ |
| | | |
| | | File fileBaowen = new File(Config.getBaowenConfig()); |
| | | if (!fileBaowen.exists()){ |
| | | if (!fileBaowen.exists()) { |
| | | try { |
| | | fileBaowen.createNewFile(); |
| | | } catch (IOException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } catch (IOException var19) { |
| | | var19.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | File fileAnchor = new File(Config.getAnchorConfig()); |
| | | if (!fileAnchor.exists()){ |
| | | if (!fileAnchor.exists()) { |
| | | try { |
| | | fileAnchor.createNewFile(); |
| | | } catch (IOException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } catch (IOException var18) { |
| | | var18.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | File fileMap = new File(Config.getMapConfig()); |
| | | if (!fileMap.exists()){ |
| | | if (!fileMap.exists()) { |
| | | try { |
| | | fileMap.createNewFile(); |
| | | } catch (IOException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } catch (IOException var17) { |
| | | var17.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | File filePage = new File(Config.getPageConfig()); |
| | | if (!filePage.exists()){ |
| | | if (!filePage.exists()) { |
| | | try { |
| | | filePage.createNewFile(); |
| | | } catch (IOException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } catch (IOException var16) { |
| | | var16.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | String perPage = Config.getPageConfig(); |
| | | |
| | | String perPage = Config.getPageConfig(); |
| | | ModifyConfig.writeData(perPage, "perPage", "10"); |
| | | String BaowenPath = Config.getBaowenConfig(); |
| | | ModifyConfig.writeData(BaowenPath, "baowenSwitch", "0"); |
| | |
| | | return result; |
| | | } |
| | | |
| | | @RequestMapping(value = "/logout.do", method = { RequestMethod.POST, RequestMethod.GET }) |
| | | @RequestMapping( |
| | | value = {"/logout.do"}, |
| | | method = {RequestMethod.POST, RequestMethod.GET} |
| | | ) |
| | | public String logout(HttpServletRequest request) throws Exception { |
| | | HttpSession session = request.getSession(); |
| | | ServletContext application = session.getServletContext(); |
| | |
| | | application.removeAttribute("deleteq"); |
| | | application.removeAttribute("alertq"); |
| | | application.removeAttribute("deleteall"); |
| | | application.removeAttribute("fenceq"); |
| | | session.removeAttribute("username"); |
| | | session.removeAttribute("password"); |
| | | session.removeAttribute("superuser"); |
| | | session.removeAttribute("deleteq"); |
| | | session.removeAttribute("alertq"); |
| | | session.removeAttribute("deleteall"); |
| | | |
| | | // 停止报文接收 |
| | | session.removeAttribute("fenceq"); |
| | | if (Config.getUdpRunning().equals("1")) { |
| | | try { |
| | | // thread1.stopThread(); |
| | | // receive7.stopThread(); |
| | | // receive6.stopThread(); |
| | | // receive5.stopThread(); |
| | | // receive4.stopThread(); |
| | | receive3.stopThread(); |
| | | // receive2.stopThread(); |
| | | /* receive1.stopThread(); */ |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | this.receive3.stopThread(); |
| | | } catch (Exception var5) { |
| | | var5.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | return "redirect:/hxzk/login.jsp"; |
| | | } |
| | | |
| | | @RequestMapping( |
| | | value = {"/loginfa.do"}, |
| | | method = {RequestMethod.POST, RequestMethod.GET} |
| | | ) |
| | | public String loginfa(HttpServletRequest request) throws Exception { |
| | | String toPage = "forward:/hxzk/sysSetting/loginfa.jsp"; |
| | | List<tb_login> logins = this.loginService.getloginManagement(1); |
| | | int curPage = 1; |
| | | int count = this.loginService.getloginManagementCount(); |
| | | int minPage = PageUtil.getMinPage(count); |
| | | request.setAttribute("dataList", logins); |
| | | request.setAttribute("pageList", PageUtil.getPage(minPage)); |
| | | request.setAttribute("curPage", Integer.valueOf(curPage)); |
| | | return toPage; |
| | | } |
| | | |
| | | @ResponseBody |
| | | @RequestMapping( |
| | | value = {"findloginid.do"}, |
| | | method = {RequestMethod.POST, RequestMethod.GET} |
| | | ) |
| | | public JSONObject findloginid(HttpServletRequest request) throws Exception { |
| | | JSONObject json = new JSONObject(); |
| | | String username = request.getParameter("input"); |
| | | List<tb_login> logins = this.loginService.getloginid(username); |
| | | json.put("dataList", logins); |
| | | return json; |
| | | } |
| | | |
| | | @ResponseBody |
| | | @RequestMapping( |
| | | value = {"/loginManagement_page.do"}, |
| | | method = {RequestMethod.POST, RequestMethod.GET} |
| | | ) |
| | | public String loginManagement_page(HttpServletRequest request) { |
| | | String pageStr = request.getParameter("page"); |
| | | String curPageStr = request.getParameter("curPage"); |
| | | int count = this.loginService.getloginManagementCount(); |
| | | int minPage = PageUtil.getMinPage(count); |
| | | int curPage = Integer.parseInt(curPageStr); |
| | | int page = 1; |
| | | if ("pre".equals(pageStr)) { |
| | | if (curPage > 1) { |
| | | page = curPage - 1; |
| | | } |
| | | } else if ("next".equals(pageStr)) { |
| | | if (curPage < minPage) { |
| | | page = curPage + 1; |
| | | } |
| | | } else { |
| | | page = Integer.parseInt(pageStr); |
| | | } |
| | | |
| | | List<tb_login> loginManagementList = this.loginService.getloginManagement(page); |
| | | List<Integer> pageList = PageUtil.getPage(PageUtil.getLocPage(page, curPage), page, minPage); |
| | | JSONObject json = new JSONObject(); |
| | | json.put("dataList", loginManagementList); |
| | | json.put("pageList", pageList); |
| | | json.put("curPage", page); |
| | | return json.toString(); |
| | | } |
| | | } |