Пример #1
0
  private Set<String> getImgs() {
    Set<String> imgSet = new HashSet<String>();
    List<App> apps = appDao.findAutoUpdatedList();

    for (App app : apps) {

      String url1080 = app.getUrl1080();

      if (url1080 != null && !url1080.equals("")) {
        imgSet.add(app.getUrl1080());
      }
    }

    return imgSet;
  }
Пример #2
0
  private synchronized void refreshAppList(boolean auto) {
    try {
      updating = true;

      Set<String> imgSet = getImgs();

      List<Machine> machines = MachineUtils.getMachineList();

      appDao.deleteAutoUpdatedRecords();
      HashSet<String> set = new HashSet<String>();

      for (Machine machine : machines) {
        String data = thirdAppService.getAppData(machine.getCode(), "3.0");
        AppVO appVO = jsonMapper.fromJson(data, AppVO.class);

        if (appVO.getState().equals("0000")) {
          for (AppInfo appInfo : appVO.getZone()) {
            App app = new App();
            app.setActionUrl(jsonMapper.toJson(appInfo.getData()));
            app.setUrl1080(upload(appInfo.getIcon()));
            app.setClientType(machine.getCode());
            app.setTitle(jsonMapper.toJson(new String[] {appInfo.getName()}));
            app.setUpdateRefer("app:1");

            if (auto) {
              User user = new User();
              user.setId(1L);
              app.setUser(user);
            } else {
              app.setUser(UserUtils.getUser());
            }
            appDao.save(app);
            set.add(app.getUpdateRefer());
          }
        }
      }
      for (String ur : set) {
        templateService.evictTplByUpdateRefer(ur);
      }

    } catch (Exception e) {
      throw new RuntimeException(e);
    } finally {
      updating = false;
    }
  }