package cn.com.usky.iot.controller; import javax.annotation.PostConstruct; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; 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 com.alibaba.fastjson.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.RequestParam; import org.springframework.web.servlet.ModelAndView; import cn.com.usky.iot.patrolplan.service.YtiotTPatrolPlanService; @Controller @RequestMapping("/iot/checkrecord") public class CheckRecordController { @Resource private YtiotTPatrolPlanService ytiotTPatrolPlanService; private static CheckRecordController checkrecordController; @PostConstruct public void init() { checkrecordController = this; checkrecordController.ytiotTPatrolPlanService = this.ytiotTPatrolPlanService; } @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) { JSONObject json = new 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); JSONObject jsonObject = JSONObject.parseObject(queryJson); jsonObject.put("V_LOGINNAME", o.getVLoginname()); jsonObject.put("V_PASSWORD", o.getVPassword()); try { String ret = checkrecordController.ytiotTPatrolPlanService.getCheckRecordList(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; } }