InspectionRecordController.java 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. package cn.com.usky.iot.controller;
  2. import javax.annotation.PostConstruct;
  3. import javax.annotation.Resource;
  4. import javax.servlet.http.HttpServletRequest;
  5. import javax.servlet.http.HttpServletResponse;
  6. import cn.com.usky.iot.auth.TokenAuthBO;
  7. import cn.com.usky.iot.auth.TokenAuthService;
  8. import cn.com.usky.iot.controller.login.Constants;
  9. import cn.com.usky.iot.entity.YtiotTAdmin;
  10. import cn.com.usky.utils.HttpServletRequestUtils;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.stereotype.Controller;
  13. import org.springframework.web.bind.annotation.RequestMapping;
  14. import org.springframework.web.bind.annotation.RequestMethod;
  15. import org.springframework.web.bind.annotation.RequestParam;
  16. import org.springframework.web.multipart.MultipartFile;
  17. import org.springframework.web.servlet.ModelAndView;
  18. import cn.com.usky.iot.inspectionrecord.service.YtiotTInspectionRecordService;
  19. @Controller
  20. @RequestMapping("/iot/inspectionrecord")
  21. public class InspectionRecordController {
  22. @Resource
  23. private YtiotTInspectionRecordService ytiotTInspectionRecordService;
  24. private static InspectionRecordController inspectionrecordController;
  25. @PostConstruct
  26. public void init() {
  27. inspectionrecordController = this;
  28. inspectionrecordController.ytiotTInspectionRecordService = this.ytiotTInspectionRecordService;
  29. }
  30. @Autowired
  31. private TokenAuthService tokenAuthService;
  32. @RequestMapping(value = "/getList", method = {RequestMethod.GET, RequestMethod.POST})
  33. public ModelAndView getList(@RequestParam(value = "queryJson", required = false) String queryJson,
  34. @RequestParam(value = "page", required = false) String page,
  35. @RequestParam(value = "start", required = false) String start,
  36. @RequestParam(value = "limit", required = false) String limit,
  37. @RequestParam(value = "sort", required = false) String sort,
  38. HttpServletRequest request) {
  39. // TODO Auto-generated constructor stub
  40. ModelAndView mav = new ModelAndView();
  41. TokenAuthBO tokenAuthBO = HttpServletRequestUtils.tokenAuthForYT(request, tokenAuthService);
  42. boolean isAuth = tokenAuthBO.isAuthState();
  43. if (!isAuth) {
  44. com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
  45. json.put("check", false);
  46. json.put("errMsg", "权限错误,请重新登录");
  47. mav.addObject("ret_str", json.toJSONString());
  48. }
  49. mav.setViewName("return");
  50. //通过获取用户信息
  51. YtiotTAdmin o = (YtiotTAdmin) tokenAuthBO.getData().get(Constants.USER_INFO);
  52. com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(queryJson);
  53. jsonObject.put("V_LOGINNAME", o.getVLoginname());
  54. jsonObject.put("V_PASSWORD", o.getVPassword());
  55. try {
  56. String ret = inspectionrecordController.ytiotTInspectionRecordService.getInspectionRecordList(jsonObject.toString(), page, start, limit, sort);
  57. // System.out.println(ret);
  58. mav.addObject("ret_str", ret);
  59. } catch (Exception e) {
  60. // TODO Auto-generated catch block
  61. e.printStackTrace();
  62. }
  63. return mav;
  64. }
  65. @RequestMapping(value = "/getList1", method = {RequestMethod.GET, RequestMethod.POST})
  66. public ModelAndView getList1(@RequestParam(value = "queryJson", required = false) String queryJson,
  67. @RequestParam(value = "page", required = false) String page,
  68. @RequestParam(value = "start", required = false) String start,
  69. @RequestParam(value = "limit", required = false) String limit,
  70. @RequestParam(value = "sort", required = false) String sort,
  71. HttpServletRequest request) {
  72. // TODO Auto-generated constructor stub
  73. ModelAndView mav = new ModelAndView();
  74. TokenAuthBO tokenAuthBO = HttpServletRequestUtils.tokenAuthForYT(request, tokenAuthService);
  75. boolean isAuth = tokenAuthBO.isAuthState();
  76. if (!isAuth) {
  77. com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
  78. json.put("check", false);
  79. json.put("errMsg", "权限错误,请重新登录");
  80. mav.addObject("ret_str", json.toJSONString());
  81. }
  82. mav.setViewName("return");
  83. //通过获取用户信息
  84. YtiotTAdmin o = (YtiotTAdmin) tokenAuthBO.getData().get(Constants.USER_INFO);
  85. com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(queryJson);
  86. jsonObject.put("V_LOGINNAME", o.getVLoginname());
  87. jsonObject.put("V_PASSWORD", o.getVPassword());
  88. try {
  89. String ret = inspectionrecordController.ytiotTInspectionRecordService.getInspectionRecordList1(jsonObject.toString(), page, start, limit, sort);
  90. // System.out.println(ret);
  91. mav.addObject("ret_str", ret);
  92. } catch (Exception e) {
  93. // TODO Auto-generated catch block
  94. e.printStackTrace();
  95. }
  96. return mav;
  97. }
  98. }