123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- package cn.com.usky.iot.controller;
- import javax.annotation.PostConstruct;
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import cn.com.usky.iot.auth.TokenAuthBO;
- import cn.com.usky.iot.auth.TokenAuthService;
- import cn.com.usky.iot.controller.login.Constants;
- import cn.com.usky.iot.entity.YtiotTAdmin;
- import cn.com.usky.utils.HttpServletRequestUtils;
- 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.RequestParam;
- import org.springframework.web.multipart.MultipartFile;
- import org.springframework.web.servlet.ModelAndView;
- import cn.com.usky.iot.inspectionrecord.service.YtiotTInspectionRecordService;
- @Controller
- @RequestMapping("/iot/inspectionrecord")
- public class InspectionRecordController {
- @Resource
- private YtiotTInspectionRecordService ytiotTInspectionRecordService;
- private static InspectionRecordController inspectionrecordController;
- @PostConstruct
- public void init() {
- inspectionrecordController = this;
- inspectionrecordController.ytiotTInspectionRecordService = this.ytiotTInspectionRecordService;
- }
- @Autowired
- private TokenAuthService tokenAuthService;
- @RequestMapping(value = "/getList", method = {RequestMethod.GET, RequestMethod.POST})
- public ModelAndView getList(@RequestParam(value = "queryJson", required = false) String queryJson,
- @RequestParam(value = "page", required = false) String page,
- @RequestParam(value = "start", required = false) String start,
- @RequestParam(value = "limit", required = false) String limit,
- @RequestParam(value = "sort", required = false) String sort,
- HttpServletRequest request) {
- // TODO Auto-generated constructor stub
- ModelAndView mav = new ModelAndView();
- TokenAuthBO tokenAuthBO = HttpServletRequestUtils.tokenAuthForYT(request, tokenAuthService);
- boolean isAuth = tokenAuthBO.isAuthState();
- if (!isAuth) {
- com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
- json.put("check", false);
- json.put("errMsg", "权限错误,请重新登录");
- mav.addObject("ret_str", json.toJSONString());
- }
- mav.setViewName("return");
- //通过获取用户信息
- YtiotTAdmin o = (YtiotTAdmin) tokenAuthBO.getData().get(Constants.USER_INFO);
- com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(queryJson);
- jsonObject.put("V_LOGINNAME", o.getVLoginname());
- jsonObject.put("V_PASSWORD", o.getVPassword());
- try {
- String ret = inspectionrecordController.ytiotTInspectionRecordService.getInspectionRecordList(jsonObject.toString(), page, start, limit, sort);
- // System.out.println(ret);
- mav.addObject("ret_str", ret);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return mav;
- }
- @RequestMapping(value = "/getList1", method = {RequestMethod.GET, RequestMethod.POST})
- public ModelAndView getList1(@RequestParam(value = "queryJson", required = false) String queryJson,
- @RequestParam(value = "page", required = false) String page,
- @RequestParam(value = "start", required = false) String start,
- @RequestParam(value = "limit", required = false) String limit,
- @RequestParam(value = "sort", required = false) String sort,
- HttpServletRequest request) {
- // TODO Auto-generated constructor stub
- ModelAndView mav = new ModelAndView();
- TokenAuthBO tokenAuthBO = HttpServletRequestUtils.tokenAuthForYT(request, tokenAuthService);
- boolean isAuth = tokenAuthBO.isAuthState();
- if (!isAuth) {
- com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
- json.put("check", false);
- json.put("errMsg", "权限错误,请重新登录");
- mav.addObject("ret_str", json.toJSONString());
- }
- mav.setViewName("return");
- //通过获取用户信息
- YtiotTAdmin o = (YtiotTAdmin) tokenAuthBO.getData().get(Constants.USER_INFO);
- com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(queryJson);
- jsonObject.put("V_LOGINNAME", o.getVLoginname());
- jsonObject.put("V_PASSWORD", o.getVPassword());
- try {
- String ret = inspectionrecordController.ytiotTInspectionRecordService.getInspectionRecordList1(jsonObject.toString(), page, start, limit, sort);
- // System.out.println(ret);
- mav.addObject("ret_str", ret);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return mav;
- }
- }
|