CheckRecordController.java 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 cn.com.usky.iot.auth.TokenAuthBO;
  6. import cn.com.usky.iot.auth.TokenAuthService;
  7. import cn.com.usky.iot.controller.login.Constants;
  8. import cn.com.usky.iot.entity.YtiotTAdmin;
  9. import cn.com.usky.utils.HttpServletRequestUtils;
  10. import com.alibaba.fastjson.JSONObject;
  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.servlet.ModelAndView;
  17. import cn.com.usky.iot.patrolplan.service.YtiotTPatrolPlanService;
  18. @Controller
  19. @RequestMapping("/iot/checkrecord")
  20. public class CheckRecordController {
  21. @Resource
  22. private YtiotTPatrolPlanService ytiotTPatrolPlanService;
  23. private static CheckRecordController checkrecordController;
  24. @PostConstruct
  25. public void init() {
  26. checkrecordController = this;
  27. checkrecordController.ytiotTPatrolPlanService = this.ytiotTPatrolPlanService;
  28. }
  29. @Autowired
  30. private TokenAuthService tokenAuthService;
  31. @RequestMapping(value = "/getList", method = {RequestMethod.GET, RequestMethod.POST})
  32. public ModelAndView getList(@RequestParam(value = "queryJson", required = false) String queryJson,
  33. @RequestParam(value = "page", required = false) String page,
  34. @RequestParam(value = "start", required = false) String start,
  35. @RequestParam(value = "limit", required = false) String limit,
  36. @RequestParam(value = "sort", required = false) String sort,
  37. HttpServletRequest request) {
  38. // TODO Auto-generated constructor stub
  39. ModelAndView mav = new ModelAndView();
  40. TokenAuthBO tokenAuthBO = HttpServletRequestUtils.tokenAuthForYT(request, tokenAuthService);
  41. boolean isAuth = tokenAuthBO.isAuthState();
  42. if (!isAuth) {
  43. JSONObject json = new JSONObject();
  44. json.put("check", false);
  45. json.put("errMsg", "权限错误,请重新登录");
  46. mav.addObject("ret_str", json.toJSONString());
  47. }
  48. mav.setViewName("return");
  49. //通过获取用户信息
  50. YtiotTAdmin o = (YtiotTAdmin) tokenAuthBO.getData().get(Constants.USER_INFO);
  51. JSONObject jsonObject = JSONObject.parseObject(queryJson);
  52. jsonObject.put("V_LOGINNAME", o.getVLoginname());
  53. jsonObject.put("V_PASSWORD", o.getVPassword());
  54. try {
  55. String ret = checkrecordController.ytiotTPatrolPlanService.getCheckRecordList(jsonObject.toString(), page, start, limit, sort);
  56. // System.out.println(ret);
  57. mav.addObject("ret_str", ret);
  58. } catch (Exception e) {
  59. // TODO Auto-generated catch block
  60. e.printStackTrace();
  61. }
  62. return mav;
  63. }
  64. }