コード例 #1
0
ファイル: DeviceService.java プロジェクト: Jeanwin/disrec
 /**
  * 第三方请求并处理返回轮询数据
  *
  * @param devicePoling 发送数据
  * @param url
  * @param pollingData 返回结果
  */
 private void sendToDeviceService(
     DevicePoling devicePoling,
     String url,
     List<List<Map<String, Object>>> pollingData,
     Map<String, Object> data,
     List<Map<String, String>> macList) {
   int set = Integer.parseInt(devicePoling.getPolingset());
   // 机位字典
   List<Map<String, Object>> dics = syscodeMapper.getCode("RoundRobin");
   int i = 0;
   for (Map<String, String> map : macList) {
     data.put("macInfo", map);
     String result = HttpSend.post(url, data);
     List<Map<String, Object>> resultList = JsonUtil.jsonToObject(result, List.class);
     if (resultList != null) {
       String className = map.get("className");
       transforData(resultList, className, dics);
       handleData(resultList, set, pollingData);
       if (pollingData.size() > 0 && pollingData.get(0).size() == set) {
         i++;
         break;
       }
     }
     i++;
   }
   for (int j = 0; j < i; j++) {
     macList.remove(0);
   }
   if (macList.size() > 0) {
     new pollingThread(set, url, dics, data, pollingData, macList).start();
   }
 }
コード例 #2
0
ファイル: DeviceService.java プロジェクト: Jeanwin/disrec
 @Override
 public void run() {
   long starttime = System.currentTimeMillis();
   for (Map<String, String> map : macList) {
     data.put("macInfo", map);
     String result = HttpSend.post(url, data);
     List<Map<String, Object>> resultList = JsonUtil.jsonToObject(result, List.class);
     if (resultList != null) {
       String className = map.get("className");
       transforData(resultList, className, dics);
       handleData(resultList, set, pollingData);
     }
   }
 }
コード例 #3
0
ファイル: DeviceService.java プロジェクト: Jeanwin/disrec
 /**
  * 返回轮询结果
  *
  * @param req
  * @param page页面
  * @return
  */
 public String polling(HttpServletRequest req, int page) {
   Map<String, Object> datas = new HashMap<String, Object>();
   // 机位
   List<String> seats = null;
   // 教室编号
   List<String> innerids = null;
   // 名字服务需要的数据
   Map<String, Object> data = new HashMap<String, Object>();
   String loginname = ShiroDbRealm.getCurrentLoginName();
   if (loginname == null) {
     return "unauthc";
   }
   DevicePoling devicePoling = devicePolingMapper.findDevicePolingSetByAreaid(loginname);
   seats = Arrays.asList(devicePoling.getDeviceinfo().split(","));
   innerids = Arrays.asList(devicePoling.getAreainfo().split(","));
   List<Map<String, String>> macList =
       deviceMapper.getMacByInnerId(innerids, AppConstants.TYPE_DEVICETYPE_RECORD);
   data.put("seats", seats); // car0,car1,car4
   // 轮询方式
   String roundType = devicePoling.getRoundType();
   String ipPort = serverService.getWebServer();
   String url = "http://" + ipPort + "/deviceService/polling/" + roundType;
   // 视频轮询
   List<List<Map<String, Object>>> pollingData =
       (List<List<Map<String, Object>>>) req.getSession().getAttribute(roundType);
   if (roundType.equals("flowType")) {
     if (page == 0 && (pollingData == null || pollingData.size() == 0)) {
       pollingData = new ArrayList<List<Map<String, Object>>>();
       req.getSession().setAttribute(roundType, pollingData);
       sendToDeviceService(devicePoling, url, pollingData, data, macList);
     }
     if (pollingData != null && pollingData.size() > page) {
       datas.put("data", pollingData.get(page));
     }
   } else {
     data.put("macList", macList);
     String result = HttpSend.post(url, data);
     List<Map<String, Object>> files = cutPic(result, macList, seats);
     String path = "http://" + req.getLocalAddr() + "/images";
     datas.put("url", path);
     datas.put("data", files);
   }
   datas.put("polingtime", devicePoling.getPolingtime());
   datas.put("polingset", devicePoling.getPolingset());
   return JsonUtil.toJson(datas);
 }