public String update(String json) throws Exception {

    User user = ActionContext.getCurrentUserInThread();

    String resultVO = null;
    WxyWjGcVO vo = new WxyWjGcVO();

    try {
      JSONArray list = vo.doInitJson(json);
      vo.setValueFromJson((JSONObject) list.get(0));
      // 设置主键
      /*
       * vo.setId(new RandomGUID().toString()); // 主键
       */
      /* vo.setId("20FC7EF9-696D-6398-15C8-A77F2C4DFC02"); */
      JSONObject obj = (JSONObject) list.get(0);
      String ywid = obj.getString("ywid");
      if (ywid != null && !"".equals(ywid)) {
        FileUploadOldService.updateFjztOrYwidByYwid(
            ywid, vo.getWxy_wj_gc_uid(), Constants.FS_FILEUPLOAD_FJLB_WXY_WJGC);
      }
      // 修改
      wxyWjGcDao.update(vo);
      resultVO = vo.getRowJson();

    } catch (DaoException e) {
      logger.error("危险源网架构过程管理{}", e.getMessage());
      SystemException.handleMessageException("危险源网架构过程管理修改失败,请联系相关人员处理");
    } finally {
    }
    return resultVO;
  }
 public void setVip() {
   String context = new Run().ReadFile("C:\\Users\\hp\\IdeaProjects\\Pos\\user.json");
   JSONArray u1 = JSONArray.fromObject(context);
   JSONObject vip = (JSONObject) user.get(0);
   for (int i = 0; i < user.size(); i++) {
     JSONObject user = (JSONObject) u1.get(i);
     if (vip.getString("user").equals(user.getString("user"))) this.vip = user.getBoolean("isvip");
   }
 }
  public JSONObject removeNode(String id) {
    JSONObject result = new JSONObject();
    JSONObject targetElement = this.elementCache.get(id);
    JSONObject parent = this.parentCache.get(id);

    JSONArray children = parent.getJSONArray("children");
    if (children != null && !children.isEmpty()) {
      int targetIndex = -1;
      int targetCount = 0;
      for (int i = 0; i < children.size(); i++) {
        JSONObject child = (JSONObject) children.get(i);
        if (child.getString("id").equals(id)) {
          targetIndex = i;
        }
      }

      if (targetIndex >= 0) {
        children.remove(targetIndex);
        this.elementCache.remove(id);
        this.parentCache.remove(id);
      }

      result = result.element("id", id);
    } else {
      result = result.element("error", "could not find target element");
    }

    this.saveMappings();

    return result;
  }
    /**
     * Parses the raw response from Google
     *
     * @param rawResponse The raw, unparsed response from Google
     * @return Returns the parsed response.
     */
    void parseResponse(String rawResponse, GoogleResponse googleResponse) {
        try {
            JSONObject json = JSONObject.fromObject(rawResponse);
            int status = json.getInt("status");

            if (status == 0) {
                JSONArray hypotheses = json.getJSONArray("hypotheses");

                for (int index = 0; index < hypotheses.size(); index++) {
                    JSONObject hypothese = (JSONObject) hypotheses.get(index);

                    if (hypothese.containsKey(CONFIDENCE)) {
                        googleResponse.setResponse(hypothese.getString("utterance"));
                        googleResponse.setConfidence(hypothese.getDouble(CONFIDENCE) + "");
                    } else {
                        googleResponse.getOtherPossibleResponses().add(hypothese.getString("utterance"));
                    }
                }
            } else {
                Logger.getLogger(Recognizer.class.getName()).log(Level.WARNING, "status: {0}", status);
            }
        } catch (JSONException e) {
            Logger.getLogger(Recognizer.class.getName()).log(Level.WARNING, e.getLocalizedMessage(), e);
        }
    }
  private static JSONArray[] getJSONArrayCache(
      JSONConvert jsonConvert,
      HttpServletRequest req,
      FindListHandler handler,
      List jsonAwareList) {
    int start = ServletRequestUtils.getIntParameter(req, "start", 0);
    int limit = ServletRequestUtils.getIntParameter(req, "limit", NUM_PER_PAGE);

    String sessionName = getPrefixPrivate();
    JSONArray jsonArray = null;
    if (start > 0) {
      jsonArray = (JSONArray) req.getSession().getAttribute(sessionName);
    }
    if (jsonArray == null) {
      log.info("取数据库数据"); // ////////////////
      jsonArray = jsonConvert.modelCollect2JSONArray(handler.findList(), jsonAwareList);
      req.getSession().setAttribute(sessionName, jsonArray);
    } else {
      log.info("命中缓存"); // ////////////////
    }

    if (start < 0) {
      start = 0;
    }
    JSONArray pageJSONArray = new JSONArray();
    for (int i = start; i <= start + limit - 1 && i < jsonArray.size(); i++) {
      pageJSONArray.add(jsonArray.get(i));
    }
    return new JSONArray[] {jsonArray, pageJSONArray};
  }
 public DateTime getLatestTime(String walletName) {
   MultivaluedMapImpl queryParams = getWalletExplorerQueryParams(walletName, 0l);
   JSONObject latestQueryJsonObject =
       tryToGetQueryResponseOrThrowRuntimeException(queryParams, walletName);
   JSONArray subWalletTransactions = getSubWalletTransactionsFromResponse(latestQueryJsonObject);
   JSONObject firstSubWalletTransaction = (JSONObject) subWalletTransactions.get(0);
   DateTime latestTime = getTimeOfSubWalletTransaction(firstSubWalletTransaction);
   return latestTime;
 }
 /**
  * @param jsonArray
  * @param foundFields
  * @param pathStack
  */
 public void visit(
     JSONArray jsonArray, HashMap<String, CandidateField> foundFields, Stack<Object> pathStack) {
   for (int i = 0; i < jsonArray.size(); i++) {
     Object jsonArrayObj = jsonArray.get(i);
     pathStack.push(i);
     visitAny(jsonArrayObj, foundFields, pathStack);
     pathStack.pop();
   }
 }
  private void clearAllMappings(JSONObject object) {
    JSONArray mappings = object.getJSONArray("mappings");
    mappings.clear();

    if (object.has("attributes")) {
      JSONArray attributes = object.getJSONArray("attributes");
      for (int i = 0; i < attributes.size(); i++) {
        JSONObject a = (JSONObject) attributes.get(i);
        clearAllMappings(a);
      }
    }

    if (object.has("children")) {
      JSONArray children = object.getJSONArray("children");
      for (int i = 0; i < children.size(); i++) {
        JSONObject a = (JSONObject) children.get(i);
        clearAllMappings(a);
      }
    }
  }
 @Override
 public List<Object> getCities(Map<String, Object> params) {
   String d = ClutterConstant.getProperty("cities");
   List<Object> list = new ArrayList<Object>();
   JSONArray j = JSONArray.fromObject(d);
   for (int i = 0; i < j.size(); i++) {
     Object jo = j.get(i);
     list.add(jo);
   }
   return list;
 }
 public DateTime getEarliestTime(String walletName) {
   long latestFromCount = getTxsCount(walletName);
   MultivaluedMapImpl queryParams = getWalletExplorerQueryParams(walletName, latestFromCount);
   JSONObject latestQueryJsonObject =
       tryToGetQueryResponseOrThrowRuntimeException(queryParams, walletName);
   JSONArray subWalletTransactions = getSubWalletTransactionsFromResponse(latestQueryJsonObject);
   int lastValueIndex = subWalletTransactions.size() - 1;
   JSONObject firstSubWalletTransaction = (JSONObject) subWalletTransactions.get(lastValueIndex);
   DateTime earliestTime = getTimeOfSubWalletTransaction(firstSubWalletTransaction);
   return earliestTime;
 }
  public String insert(String json) throws Exception {

    User user = ActionContext.getCurrentUserInThread();

    String resultVO = null;
    BuSpywCspsxkzsqVO vo = new BuSpywCspsxkzsqVO();

    try {
      JSONArray list = vo.doInitJson(json);
      vo.setValueFromJson((JSONObject) list.get(0));
      // 设置主键
      // vo.setId(new RandomGUID().toString()); // 主键
      vo.setCspsxkzsq_uid(DBUtil.getSequenceValue("CSPSXKZSQ_UID"));

      vo.setCreated_uid(user.getUserSN());
      vo.setCreated_name(user.getName());

      vo.setEvent_uid(new RandomGUID().toString());

      // 插入
      buSpywCspsxkzsqDao.save(vo);
      resultVO = vo.getRowJson();

      LogManager.writeUserLog(
          vo.getEvent_uid(),
          ywlx,
          Globals.OPERATION_TYPE_INSERT,
          LogManager.RESULT_SUCCESS,
          user.getName() + "排水许可证申请新增成功",
          user,
          "",
          "");

      // String jsona="{querycondition: {conditions:
      // [{\"value\":\""+vo.getId()+"\",\"fieldname\":\"t.id\",\"operation\":\"=\",\"logic\":\"and\"} ]}}";
      // return queryCondition(jsona, user);

    } catch (DaoException e) {
      logger.error("排水许可证申请{}", e.getMessage());
      LogManager.writeUserLog(
          vo.getEvent_uid(),
          ywlx,
          Globals.OPERATION_TYPE_INSERT,
          LogManager.RESULT_FAILURE,
          user.getName() + "排水许可证申请新增失败",
          user,
          "",
          "");
      SystemException.handleMessageException("排水许可证申请新增失败,请联系相关人员处理");
    } finally {
    }
    return resultVO;
  }
Beispiel #12
0
 int add(String number, Double balance) {
   if (isExist(number)) return -1;
   Map<String, Object> map = new LinkedHashMap<>();
   map.put("carnumber", number);
   map.put("balance", balance);
   JSONArray json = JSONArray.fromObject(map);
   String jstr = json.get(0).toString();
   String url = Values.DOMAIN + "Balance/";
   String resultXML = HttpHelper.SendHttpRequest("post", url, jstr);
   System.out.println(resultXML);
   return 0;
 }
Beispiel #13
0
 public int pay(String number, Double fee) {
   Balance b = get(number);
   if (b == null) return -1;
   Map<String, Object> map = new LinkedHashMap<>();
   map.put("carnumber", number);
   map.put("balance", b.getBalance() - fee);
   JSONArray json = JSONArray.fromObject(map);
   String jstr = json.get(0).toString();
   String url = Values.DOMAIN + "Balance/" + b.getId();
   String resultXML = HttpHelper.SendHttpRequest("put", url, jstr);
   System.out.println(resultXML);
   return 0;
 }
  public String update(String json) throws Exception {

    User user = ActionContext.getCurrentUserInThread();

    String resultVO = null;
    BuSpywCspsxkzsqVO vo = new BuSpywCspsxkzsqVO();

    try {
      JSONArray list = vo.doInitJson(json);
      vo.setValueFromJson((JSONObject) list.get(0));
      // 设置主键
      /*
       * vo.setId(new RandomGUID().toString()); // 主键
       */
      /* vo.setId("20FC7EF9-696D-6398-15C8-A77F2C4DFC02"); */

      vo.setEvent_uid(new RandomGUID().toString());

      vo.setCreated_uid(user.getUserSN());
      vo.setCreated_name(user.getName());

      // 修改
      buSpywCspsxkzsqDao.update(vo);
      resultVO = vo.getRowJson();

      LogManager.writeUserLog(
          vo.getEvent_uid(),
          ywlx,
          Globals.OPERATION_TYPE_UPDATE,
          LogManager.RESULT_SUCCESS,
          user.getName() + "排水许可证申请修改成功",
          user,
          "",
          "");

    } catch (DaoException e) {
      logger.error("排水许可证申请{}", e.getMessage());
      LogManager.writeUserLog(
          vo.getEvent_uid(),
          ywlx,
          Globals.OPERATION_TYPE_UPDATE,
          LogManager.RESULT_FAILURE,
          user.getName() + "排水许可证申请修改失败",
          user,
          "",
          "");
      SystemException.handleMessageException("排水许可证申请修改失败,请联系相关人员处理");
    } finally {
    }
    return resultVO;
  }
  private void cacheElements(JSONObject object) {
    String id = this.generateUniqueId();
    object.put("id", id);
    this.elementCache.put(id, object);

    if (object.has("attributes")) {
      JSONArray attributes = object.getJSONArray("attributes");
      for (int i = 0; i < attributes.size(); i++) {
        JSONObject a = (JSONObject) attributes.get(i);
        this.cacheElements(a);
        this.parentCache.put(a.getString("id"), object);
      }
    }

    if (object.has("children")) {
      JSONArray children = object.getJSONArray("children");
      for (int i = 0; i < children.size(); i++) {
        JSONObject a = (JSONObject) children.get(i);
        this.cacheElements(a);
        this.parentCache.put(a.getString("id"), object);
      }
    }
  }
Beispiel #16
0
  @ResponseBody
  @RequestMapping(value = "/commit", method = RequestMethod.POST)
  public ModelMap commit(HttpServletRequest req) {
    ModelMap resMap = new ModelMap();
    System.out.println("Order = " + req.getParameter("order"));
    JSONObject jsonObject = JSONObject.fromObject(req.getParameter("order"));

    double amount = jsonObject.getDouble("amount");
    String salemanid = jsonObject.getString("salemanid");

    SalemanInfo saleman = salemanService.getSalemanById(salemanid);
    if (saleman == null) {

      resMap.addAttribute("code", 1);
      resMap.addAttribute("desc", "编号为" + salemanid + "的业务员不存在");
      return resMap;
    }

    long guid = CustomGUIDUtil.getMyGUId();
    Date curTime = new Date();

    JSONArray jsonArray = jsonObject.getJSONArray("goodlist");
    int typeCount = jsonArray.size();

    Order order = new Order();
    order.setOrderid(guid);
    order.setOrdertime(curTime);
    order.setSalemanid(salemanid);
    order.setOrderstatus(0);
    order.setAmount(amount);
    order.setGoodtypecount(typeCount);
    order.setStat(1);
    order.setUpdatetime(curTime);

    orderService.create(order);

    for (int i = 0; i < typeCount; i++) {

      JSONObject itemObj = (JSONObject) jsonArray.get(i);
      OrderDetail orderDetail = new OrderDetail();
      orderDetail.setOrderid(guid);
      orderDetail.setGoodid(itemObj.getLong("goodid"));
      orderDetail.setCount(itemObj.getInt("count"));
      orderDetail.setPrice(itemObj.getDouble("price"));

      orderDetailService.create(orderDetail);
    }

    return null;
  }
  public void find(String binFile, List<SourceFileResult> results) {
    File bin = new File(binFile);
    String url = null;
    String fileDownloaded = null;

    try {
      if (canceled) return;
      InputStream is2 = null;
      String md5;
      try {
        md5 = new String(Hex.encodeHex(Files.getDigest(bin, MessageDigest.getInstance("MD5"))));
        String serviceUrl = SERVICE + "/rest/libraries?md5=" + md5;
        is2 = new URL(serviceUrl).openStream();
        String str = IOUtils.toString(is2);
        JSONArray json = JSONArray.fromObject(str);

        for (int i = 0; i < json.size(); i++) {
          if (canceled) return;
          JSONObject obj = (JSONObject) json.get(i);
          JSONObject source = obj.getJSONObject("source");
          if (source != null && !source.isNullObject()) {
            JSONArray ar = source.getJSONArray("urls");
            if (ar != null && !ar.isEmpty()) {
              String url1 = ar.getString(0);
              String tmpFile = new UrlDownloader().download(url1);
              if (tmpFile != null && isSourceCodeFor(tmpFile, bin.getAbsolutePath())) {
                fileDownloaded = tmpFile;
                url = url1;
                break;
              }
            }
          }
        }

        if (url != null && fileDownloaded != null) {
          String name = url.substring(url.lastIndexOf('/') + 1);

          SourceFileResult object = new SourceFileResult(binFile, fileDownloaded, name, 90);
          Logger.debug(this.toString() + " FOUND: " + object, null);
          results.add(object);
        }

      } finally {
        IOUtils.closeQuietly(is2);
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  public String insert(String json) throws Exception {

    User user = ActionContext.getCurrentUserInThread();

    String resultVO = null;
    WxyWjGcVO vo = new WxyWjGcVO();

    try {
      JSONArray list = vo.doInitJson(json);
      vo.setValueFromJson((JSONObject) list.get(0));
      // 设置主键
      // vo.setId(new RandomGUID().toString()); // 主键
      vo.setWxy_wj_gc_uid(DBUtil.getSequenceValue("WXY_WJ_GC_UID"));
      // 设置主键
      // vo.setId(new RandomGUID().toString()); // 主键
      JSONObject obj = (JSONObject) list.get(0);
      String ywid = obj.getString("ywid");
      if (ywid != null && !"".equals(ywid)) {
        FileUploadOldService.updateFjztOrYwidByYwid(
            ywid, vo.getWxy_wj_gc_uid(), Constants.FS_FILEUPLOAD_FJLB_WXY_WJGC);
      }

      // 插入
      wxyWjGcDao.save(vo);
      resultVO = vo.getRowJson();

      // String jsona="{querycondition: {conditions:
      // [{\"value\":\""+vo.getId()+"\",\"fieldname\":\"t.id\",\"operation\":\"=\",\"logic\":\"and\"} ]}}";
      // return queryCondition(jsona, user);

    } catch (DaoException e) {
      logger.error("危险源网架构过程管理{}", e.getMessage());
      SystemException.handleMessageException("危险源网架构过程管理新增失败,请联系相关人员处理");
    } finally {
    }
    return resultVO;
  }
Beispiel #19
0
 public static Map<String, Object> parseXml(String xml) {
   try {
     xml = xml.replaceAll(">\\s+<", "><");
     JSON json1 = (new XMLSerializer()).read(xml);
     Map<String, Object> map = null;
     if (json1.isArray()) {
       JSONArray jsonarray = (JSONArray) json1;
       map = (Map<String, Object>) jsonarray.get(0);
     } else {
       map = (Map<String, Object>) json1;
     }
     return map;
   } catch (Exception e) {
   }
   return null;
 }
Beispiel #20
0
  public static List<BattleQueue> parse(String response) {
    JSONObject json = JSONObject.fromObject(response);
    if (json == null || json.get("battle_queue") == null) return null;

    JSONArray arrays = json.getJSONArray("battle_queue");
    if (arrays != null) {
      List<BattleQueue> battleQueues = new Vector<BattleQueue>();
      for (int i = 0; i < arrays.size(); i++) {
        JSONObject array = (JSONObject) arrays.get(i);
        BattleQueue battleQueue = new BattleQueue();
        battleQueue.setToLevel(array.get("to_level") != null ? array.getLong("to_level") : null);
        battleQueue.setToX(array.get("to_x") != null ? array.getLong("to_x") : null);
        battleQueue.setActionOwnerTownId(
            array.get("action_owner_town_id") != null
                ? array.getLong("action_owner_town_id")
                : null);
        battleQueue.setTotalTime(
            array.get("total_time") != null ? array.getLong("total_time") : null);
        battleQueue.setArriveTime(
            array.get("arrive_time") != null
                ? DateTime.getTime(array.getLong("arrive_time"))
                : null);
        battleQueue.setToY(array.get("to_y") != null ? array.getLong("to_y") : null);
        battleQueue.setFromLevel(
            array.get("from_level") != null ? array.getLong("from_level") : null);
        battleQueue.setFromX(array.get("from_x") != null ? array.getLong("from_x") : null);
        battleQueue.setFromTownName(
            array.get("from_town_name") != null ? array.getString("from_town_name") : null);
        battleQueue.setFromY(array.get("from_y") != null ? array.getLong("from_y") : null);
        battleQueue.setMission(
            array.get("mission_type") != null ? array.getLong("mission_type") : null);
        battleQueue.setToTownId(
            array.get("to_town_id") != null ? array.getLong("to_town_id") : null);
        battleQueue.setBattleInfoLevel(
            array.get("battleInfoLevel") != null ? array.getLong("battleInfoLevel") : null);
        battleQueue.setToTownName(
            array.get("to_town_name") != null ? array.getString("to_town_name") : null);
        battleQueue.setId(array.get("queue_id") != null ? array.getLong("queue_id") : null);
        battleQueue.setFromTownId(
            array.get("from_town_id") != null ? array.getLong("from_town_id") : null);
        battleQueues.add(battleQueue);
      }

      return battleQueues;
    } else return null;
  }
  public String delete(String json) throws Exception {

    User user = ActionContext.getCurrentUserInThread();

    String resultVo = null;
    BuSpywCspsxkzsqVO vo = new BuSpywCspsxkzsqVO();
    try {
      JSONArray list = vo.doInitJson(json);
      JSONObject jsonObj = (JSONObject) list.get(0);

      vo.setValueFromJson(jsonObj);

      vo.setEvent_uid(new RandomGUID().toString());

      // 删除   根据据主键
      buSpywCspsxkzsqDao.delete(BuSpywCspsxkzsqVO.class, vo.getCspsxkzsq_uid());

      resultVo = vo.getRowJson();

      LogManager.writeUserLog(
          vo.getEvent_uid(),
          ywlx,
          Globals.OPERATION_TYPE_DELETE,
          LogManager.RESULT_SUCCESS,
          user.getName() + "排水许可证申请删除成功",
          user,
          "",
          "");

    } catch (DaoException e) {
      logger.error("排水许可证申请{}", e.getMessage());
      LogManager.writeUserLog(
          vo.getEvent_uid(),
          ywlx,
          Globals.OPERATION_TYPE_DELETE,
          LogManager.RESULT_FAILURE,
          user.getName() + "排水许可证申请删除失败",
          user,
          "",
          "");
      SystemException.handleMessageException("排水许可证申请删除失败,请联系相关人员处理");
    } finally {
    }
    return resultVo;
  }
  public void testReadArray() throws Exception {
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(new JsonLibModule());

    JSONArray array =
        mapper.readValue("[null, 13, false, 1.25, \"abc\", {\"a\":13}, [ ] ]", JSONArray.class);
    assertEquals(7, array.size());
    assertTrue(JSONUtils.isNull(array.get(0)));
    assertEquals(13, array.getInt(1));
    assertFalse(array.getBoolean(2));
    assertEquals(Double.valueOf(1.25), array.getDouble(3));
    assertEquals("abc", array.getString(4));
    JSONObject ob = array.getJSONObject(5);
    assertEquals(1, ob.size());
    assertEquals(13, ob.getInt("a"));
    JSONArray array2 = array.getJSONArray(6);
    assertEquals(0, array2.size());
  }
  public JSONObject duplicateNode(String id) {
    JSONObject targetElement = this.elementCache.get(id);
    JSONObject parent = this.parentCache.get(id);

    JSONObject duplicate = duplicateJSONObject(targetElement);

    JSONArray children = parent.getJSONArray("children");
    if (children != null) {
      int index = -1;
      for (int i = 0; i < children.size(); i++) {
        JSONObject child = (JSONObject) children.get(i);
        if (child.getString("id").equals(id)) {
          index = i;
          break;
        }
      }

      if (index >= 0) {
        children.add(index, duplicate);
        duplicate = children.getJSONObject(index);
      }
    } else {
      JSONArray array = new JSONArray();
      array.add(duplicate);
      parent.put("children", array);
      children = parent.getJSONArray("children");
      duplicate = children.getJSONObject(0);
    }

    this.cacheElements(duplicate);
    String duplicateId = duplicate.getString("id");
    this.parentCache.put(duplicateId, parent);

    this.saveMappings();

    return new JSONObject()
        .element("parent", parent.getString("id"))
        .element("original", id)
        .element("duplicate", duplicate);
  }
Beispiel #24
0
  private static String[] parseYouku(String url) {
    String[] result = new String[2];
    String id = "";
    if (url.indexOf("sid/") != -1) {
      id = url.substring(url.indexOf("sid/") + 4, url.indexOf("/v.swf"));
    } else {
      Pattern p = Pattern.compile("(?<=id_)(.*)(?=.html)");
      Matcher m = p.matcher(url);
      if (m.find()) {
        id = m.group();
      } else {
        return null;
      }
    }

    net.sf.json.JSONArray arr = new net.sf.json.JSONArray();
    try {
      URL myurl =
          new URL(
              "http://v.youku.com/player/getPlayList/VideoIDS/"
                  + id
                  + "/timezone/+08/version/5/source/out?password=&ran=2513&n=3");
      InputStreamReader isr = new InputStreamReader(myurl.openStream());
      BufferedReader br = new BufferedReader(isr);
      String urls = br.readLine();
      br.close();
      net.sf.json.JSONObject json = net.sf.json.JSONObject.fromObject(urls);
      arr = json.getJSONArray("data");
      if (arr.size() == 0) {
        return null;
      }
    } catch (Exception e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }

    result[0] = "http://player.youku.com/player.php/sid/" + id + "/v.swf";
    result[1] = net.sf.json.JSONObject.fromObject(arr.get(0)).get("logo").toString();
    return result;
  }
Beispiel #25
0
  public void Json2java(String str) {
    try {

      JSONObject jar = JSONObject.fromObject(str);
      JSONArray array = jar.getJSONArray("books");
      json_length = array.size();
      System.out.println(json_length);

      bklist = new ArrayList<DouBan_Book>();
      for (int i = 0; i < json_length; i++) {
        System.out.print(i + "¡¢");
        System.out.println(array.get(i));
        jsonobj = array.getJSONObject(i);
        DouBan_Book bk = new DouBan_Book();
        bk.setId(jsonobj.getString("id"));
        bk.setTitle(jsonobj.getString("title"));
        bk.setIsbn10(jsonobj.getString("isbn10"));
        // bk.setIsbn13(jsonobj.getString("isbn13"));
        bk.setImagePath(jsonobj.getString("image"));
        bk.setUrl(jsonobj.getString("url"));
        bk.setAuthor(jsonobj.getString("author"));
        bk.setBinding(jsonobj.getString("binding"));
        bk.setPages(jsonobj.getString("pages"));
        bk.setPrice(jsonobj.getString("price"));
        bk.setPubdate(jsonobj.getString("pubdate"));
        bk.setPublisher(jsonobj.getString("publisher"));
        bk.setSummary(jsonobj.getString("summary"));
        // bklist=new  ArrayList<DouBan_Book>();
        bklist.add(bk);
      }

    } catch (Exception r) {
      r.printStackTrace();
    }
    System.out.println(bklist.size());
  }
  public String delete(String json) throws Exception {

    User user = ActionContext.getCurrentUserInThread();

    String resultVo = null;
    WxyWjGcVO vo = new WxyWjGcVO();
    try {
      JSONArray list = vo.doInitJson(json);
      JSONObject jsonObj = (JSONObject) list.get(0);

      vo.setValueFromJson(jsonObj);

      // 删除   根据据主键
      wxyWjGcDao.delete(WxyWjGcVO.class, vo.getWxy_wj_gc_uid());

      resultVo = vo.getRowJson();

    } catch (DaoException e) {
      logger.error("危险源网架构过程管理{}", e.getMessage());
      SystemException.handleMessageException("危险源网架构过程管理删除失败,请联系相关人员处理");
    } finally {
    }
    return resultVo;
  }
Beispiel #27
0
  /**
   * 支付宝返回的数据顺序与格式确定,因此直接写成固定的
   *
   * @param jsonArray
   * @return
   */
  private AlipayBizPo getAlipayBizPoFromJsonArray(JSONArray jsonArray) {
    for (int i = 0; i < jsonArray.size(); i++) {
      if (Float.parseFloat(jsonArray.get(i).toString()) == 0) {
        return null;
      }
    }
    AlipayBizPo alipayBizDo = new AlipayBizPo();
    alipayBizDo.setCreateSuccess(Integer.parseInt(jsonArray.get(0).toString()));
    alipayBizDo.setCreateTotal(Integer.parseInt(jsonArray.get(1).toString()));
    alipayBizDo.setCreateTime(Float.parseFloat(jsonArray.get(2).toString()));

    alipayBizDo.setPaySuccess(Integer.parseInt(jsonArray.get(3).toString()));
    alipayBizDo.setPayTotal(Integer.parseInt(jsonArray.get(4).toString()));
    alipayBizDo.setPayTime(Float.parseFloat(jsonArray.get(5).toString()));

    alipayBizDo.setSendSuccess(Integer.parseInt(jsonArray.get(6).toString()));
    alipayBizDo.setSendTotal(Integer.parseInt(jsonArray.get(7).toString()));
    alipayBizDo.setSendTime(Float.parseFloat(jsonArray.get(8).toString()));

    alipayBizDo.setConfirmSuccess(Integer.parseInt(jsonArray.get(9).toString()));
    alipayBizDo.setConfirmTotal(Integer.parseInt(jsonArray.get(10).toString()));
    alipayBizDo.setConfirmTime(Float.parseFloat(jsonArray.get(11).toString()));
    return alipayBizDo;
  }
  @Override
  public <T> SocialUserWeibo convertThirdToWeiboEntity(SocialUserWeibo weibo, T thirdInfo) {
    JSONObject jsonInfo = (JSONObject) thirdInfo;
    if (weibo == null) {
      weibo = new SocialUserWeibo();
      weibo.setCreateAt(new Date());
    }

    String weiboId = jsonInfo.getString("id");
    System.out.println(" weibId " + weiboId);
    weibo.setWeiboId(weiboId); // 微博唯一id
    weibo.setCreateAt(new Date(jsonInfo.getLong("timestamp") * 1000));

    weibo.setSource(jsonInfo.getString("from")); // 来源
    weibo.setSourceUrl(jsonInfo.getString("fromurl"));
    weibo.setUserDomain(jsonInfo.getString("fromurl")); // 来源

    // 微博内容
    weibo.setText(jsonInfo.getString("origtext"));
    // System.out.println(jsonInfo.getString("text") + "&&*&&&&");
    // System.out.println(jsonInfo.getString("origtext"));
    weibo.setUserVerified(jsonInfo.getInt("isvip"));

    /*	System.out.println(jsonInfo.getInt("type")  + "--source---" + jsonInfo.getString("origtext"));
    if(jsonInfo.getString("source") != null){
    	System.out.println("&&&&  99999----" + jsonInfo.getString("source"));
    }*/
    // 转发数
    weibo.setRepostsCount(jsonInfo.getInt("count"));
    // 评论数
    weibo.setCommentsCount(jsonInfo.getInt("mcount"));
    // 微博类型 type : 微博类型,1-原创发表,2-转载,3-私信,4-回复,5-空回,6-提及,7-评论

    // weibo.setWeiboType(jsonInfo.getInt("type"));
    // 用户粉丝说
    // weibo.setWeiboUidFollower(weiboUidFollower);
    // 微博userid
    weibo.setWeiboUid(jsonInfo.getString("openid"));
    weibo.setUserName(jsonInfo.getString("name")); // 发表人账号
    weibo.setUserScreenName(jsonInfo.getString("nick"));
    weibo.setUserProfileImageUrl(jsonInfo.getString("head"));
    // 图片
    Object t = jsonInfo.get("image");
    if (!judgeNull(t)) {
      JSONArray arrays = jsonInfo.getJSONArray("image");
      for (int i = 0; i < arrays.size(); i++) { // 没一条的微博
        Object infoObj = arrays.get(i);
        // System.out.println(infoObj);
        String thumbnailPic = infoObj.toString() + "/120";
        weibo.setThumbnailPic(thumbnailPic);
        if (StringTool.judgeBlank(thumbnailPic)) { // 取图片的大小
          String sizeStr = ImageUtil.queryURLImageSize(thumbnailPic);
          weibo.setThumbnailPicSize(sizeStr);
        }

        String bmiddlePic = infoObj.toString() + "/2000";
        weibo.setBmiddlePic(bmiddlePic);
        if (StringTool.judgeBlank(bmiddlePic)) { // 取图片的大小
          String sizeStr = ImageUtil.queryURLImageSize(bmiddlePic);
          weibo.setBmiddlePicSize(sizeStr);
        }

        String originalPic = infoObj.toString() + "/460";
        weibo.setOriginalPic(originalPic);
        if (StringTool.judgeBlank(originalPic)) { // 取图片的大小
          String sizeStr = ImageUtil.queryURLImageSize(originalPic);
          weibo.setOriginalPicSize(sizeStr);
        }
      }
    }

    // JSONObject source = jsonInfo.getJSONObject("source");
    /*
     * if (source.toString().equals("null")) {
     * weibo.setWeiboType(DictDef.dictInt("at_me_status"));//@我的 } else { if
     * (jsonInfo.getString("text").indexOf("@") > -1) {
     * weibo.setWeiboType(DictDef.dictInt("at_me_comment")); } else {
     * weibo.setWeiboType(DictDef.dictInt("comment_to_me")); }
     * SocialUserWeibo subWeibo =
     * socialUserWeiboService.newSocialUserWeibo();
     * subWeibo.setUserName(source.getString("name"));
     * subWeibo.setWeiboId(source.getString("id"));
     * subWeibo.setText(source.getString("text"));
     * subWeibo.setRetweetedId(weibo.getId()); }
     */

    return weibo;
  }
 public void setIntegral() {
   String context = new Run().ReadFile("C:\\Users\\hp\\IdeaProjects\\Pos\\integral.json");
   JSONArray u = JSONArray.fromObject(context);
   JSONObject integral = (JSONObject) u.get(0);
   this.integral = integral.getInt("integral");
 }
  /** 材料核发调用获取MAP数据 */
  public String ywlzclhf(String json) throws Exception {
    User user = ActionContext.getCurrentUserInThread();

    String resultVO = null;
    BuSpLzhfVO vo = new BuSpLzhfVO();
    //        obj.YWLZ_UID = data.YWLZ_UID;
    //		obj.YWCL_UID = data.YWCL_UID;
    //		obj.PIJIAN_CODE = codeid;
    //		obj.PIJIAN_NAME = nameid;
    //		obj.LINGJIAN_REN =ljr;
    //		obj.LINGJIAN_PHONE=ljrdh;
    try {
      JSONArray list = vo.doInitJson(json);
      JSONObject object = (JSONObject) list.get(0);
      String YWLZ_UID = (String) object.get("YWLZ_UID");

      // 通过业务流转UID查询企业填报的数据,map类型
      String id = buSpywCspsxkzsqDao.getIdByYwlzuid(YWLZ_UID);
      BuSpywCspsxkzsqVO mapFtl = new BuSpywCspsxkzsqVO();
      if (StringUtil.isNotBlankStr(id)) {
        mapFtl = this.findById(id);
      }

      //
      //        	//复选框的判断
      //        	String Wszx_gyws=mapFtl.getWszx_gyws();
      //        	String Wsxz_shws=mapFtl.getWsxz_shws();
      //        	String Sfclml=mapFtl.getSfclml();
      //        	if(StringUtils.isBlank(Wszx_gyws)){
      //        		mapFtl.put("WSZX_GYWS", "");
      //        	}
      //        	if(StringUtils.isBlank(Wsxz_shws)){
      //        		mapFtl.put("WSXZ_SHWS", "");
      //        	}
      //        	if(StringUtils.isBlank(Sfclml)){
      //        		mapFtl.put("SFCLML", "");
      //        	}
      //

      // 组装业务流转核发数据
      Map mapVo = new HashMap();
      mapVo.put("YWLZ_UID", YWLZ_UID);
      mapVo.put("YWCL_UID", object.get("YWCL_UID"));
      mapVo.put("PIJIAN_CODE", object.get("PIJIAN_CODE"));
      mapVo.put("PIJIAN_NAME", object.get("PIJIAN_NAME"));
      mapVo.put("LINGJIAN_PHONE", object.get("LINGJIAN_PHONE"));
      mapVo.put("LINGJIAN_REN", object.get("LINGJIAN_REN"));
      mapVo.put("CLK_UID", object.getString("CLK_UID"));
      mapVo.put("FZ_DATE", object.getString("FZ_DATE"));
      mapVo.put("YXQ_DATE", object.getString("YXQ_DATE"));

      if (mapFtl != null) {
        buSpLzhfService.saveBuSpLzhfVO(mapFtl, mapVo);
      }

      resultVO = vo.getRowJson();
    } catch (DaoException e) {
      logger.error("审批业务材料核发{}", e);
      SystemException.handleMessageException("审批业务材料核发调用失败,请联系相关人员处理");
    } finally {
    }
    return resultVO;
  }