コード例 #1
0
  public SysApplication findById(long id) {
    String cacheKey = "sys_app_" + id;

    if (SystemConfig.getBoolean("use_query_cache") && CacheFactory.getString(cacheKey) != null) {
      String text = CacheFactory.getString(cacheKey);
      com.alibaba.fastjson.JSONObject json = JSON.parseObject(text);
      SysApplication app = SysApplicationJsonFactory.jsonToObject(json);
      if (app != null && app.getNodeId() > 0) {
        SysTree node = sysTreeService.findById(app.getNodeId());
        app.setNode(node);
      }
      return app;
    }

    SysApplication app = sysApplicationMapper.getSysApplicationById(id);
    if (app != null && app.getNodeId() > 0) {
      SysTree node = sysTreeService.findById(app.getNodeId());
      app.setNode(node);
    }

    if (app != null && SystemConfig.getBoolean("use_query_cache")) {
      com.alibaba.fastjson.JSONObject json = app.toJsonObject();
      CacheFactory.put(cacheKey, json.toJSONString());
    }

    return app;
  }
コード例 #2
0
  // 编辑器上传图片
  @RequestMapping("/upload")
  @ResponseBody
  public JSONObject upload(
      @RequestParam("imgFile") MultipartFile file, HttpServletRequest request, ModelMap m)
      throws IOException {

    // String filetype =
    // StringUtils.substringAfterLast(file.getOriginalFilename(), ".");
    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
    String ymd = sdf.format(new Date());

    String realRootPath =
        getServletContext().getResource("/").toString() + "upload/choicenesscontent/" + ymd + "/";
    YztUtil.writeFile(file.getInputStream(), realRootPath, file.getOriginalFilename());

    /**/
    String path = request.getContextPath();
    String basePath =
        request.getScheme()
            + "://"
            + request.getServerName()
            + ":"
            + request.getServerPort()
            + path
            + "/";
    // System.out.println("getContextPath==="+
    // basePath+"upload/user/headimg/"+user.getId()+"."+filetype);
    String picurl = basePath + "upload/choicenesscontent/" + ymd + "/" + file.getOriginalFilename();
    // user.setPicurl(picurl);

    JSONObject json = new JSONObject();
    json.put("error", 0);
    json.put("url", picurl);
    return json;
  }
コード例 #3
0
ファイル: JMServer.java プロジェクト: is00hcw/Mycat-Web
 @RequestMapping("/dumpThead")
 @ResponseBody
 public void doDumpThread(HttpServletRequest request, HttpServletResponse response) {
   try {
     String app = request.getParameter("app");
     String threadId = request.getParameter("threadId");
     ThreadMXBean tBean = JMConnManager.getThreadMBean(app);
     JSONObject data = new JSONObject();
     if (threadId != null) {
       Long id = Long.valueOf(threadId);
       ThreadInfo threadInfo = tBean.getThreadInfo(id, Integer.MAX_VALUE);
       data.put("info", threadInfo.toString());
     } else {
       ThreadInfo[] dumpAllThreads = tBean.dumpAllThreads(false, false);
       StringBuffer info = new StringBuffer();
       for (ThreadInfo threadInfo : dumpAllThreads) {
         info.append("\n").append(threadInfo);
       }
       data.put("info", info);
     }
     writeFile(request, response, data);
   } catch (IOException e) {
     throw new RuntimeException(e);
   }
 }
コード例 #4
0
 /**
  * 统计注册人数
  *
  * @creationDate. 2015-12-25 下午4:22:25
  * @throws ParseException
  */
 public void statistics() throws ParseException {
   List<YwUser> data = getData();
   SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-dd");
   JSONObject jsonData = new JSONObject();
   List<String> listXdata = new ArrayList<String>();
   List<Integer> incomeDataList = new ArrayList<Integer>();
   List<Highcharts> dataList = new ArrayList<Highcharts>();
   Highcharts incomeChart = new Highcharts();
   if (CollectionUtils.isNotEmpty(data)) {
     for (YwUser obj : data) {
       listXdata.add(sdf.format(obj.getCreateTime()).toString()); // 日期
       incomeDataList.add(obj.getRegiestCount()); // 当前日期注册数
       regCounts += obj.getRegiestCount(); // 总注册数
     }
   }
   incomeChart.setName("注册用户数");
   incomeChart.setData(incomeDataList);
   dataList.add(incomeChart);
   jsonData.put("regCounts", regCounts);
   jsonData.put("listYdata", dataList);
   jsonData.put("listXdata", listXdata);
   try {
     super.writeNoLog(jsonData);
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
コード例 #5
0
ファイル: User.java プロジェクト: Delicate90/mj_logistics
 public static JSONObject headerEdit(String username, File header) {
   JSONObject items = new JSONObject();
   boolean rs = false;
   if (!username.equals("")) {
     Record user =
         Db.findFirst("SELECT * FROM b_user WHERE username = ? AND status = 1", username);
     if (user != null) {
       System.out.println(header.getName());
       String fileName =
           "head_"
               + username
               + String.valueOf(System.currentTimeMillis())
               + "."
               + header.getName().split("\\.")[1];
       String QNToken = qiNiuKit.getUpToken();
       boolean qnRs = new qiNiuKit().uploadFile(header, fileName, QNToken);
       if (qnRs) {
         user.set("head", qiNiuKit.headSave(fileName));
         rs = Db.update("b_user", user);
         if (rs) {
           user =
               Db.findFirst(
                   "SELECT bu.*,fur.content AS roleValue,fus.content AS sexValue FROM b_user AS bu LEFT JOIN f_user_role AS fur ON bu.role = fur.id LEFT JOIN f_user_sex AS fus ON bu.sex = fus.id WHERE bu.username = ? AND bu.status = 1",
                   username);
           items.put("user", user.toJson());
         }
       }
     }
   }
   items.put("rs", rs);
   return items;
 }
コード例 #6
0
 private void initWeixinUser() {
   try {
     JSONObject jsonObject = WeixinUtil.getDepartUsersDetail("1", 1, WeixinDepartStatus.获取全部成员);
     if (null != jsonObject) {
       JSONArray jsonUserList = jsonObject.getJSONArray("userlist");
       String errmsg = jsonObject.getString("errmsg");
       String errcode = jsonObject.getString("errcode");
       if ("0".equals(errcode)) {
         if (null != jsonUserList) {
           List<WeixinUser> weixinUserList = new ArrayList<WeixinUser>(jsonUserList.size());
           for (int i = 0, size = jsonUserList.size(); i < size; i++) {
             weixinUserList.add(
                 JSON.toJavaObject(jsonUserList.getJSONObject(i), WeixinUser.class));
           }
           SystemCacheUtil.getInstance().getDefaultCache().add("AllUser", weixinUserList);
           LOGGER.info("初始化所有用户信息成功!" + JSON.toJSONString(weixinUserList));
         }
       } else {
         LOGGER.error("初始化所有用户信息失败,原因:" + errmsg);
       }
     }
   } catch (Exception e) {
     e.printStackTrace();
     LOGGER.error("初始化所有用户信息失败!", e);
   }
 }
コード例 #7
0
 /**
  * 订单管理页面载入
  *
  * @param page 页码,默认为1
  * @param order_status 订单状态,为空时查找所有状态(0未分配状态,10表示未配送,20表示配送中,30表示配送完成,40表示结算完成,50表示返回入库,60表示已返回入库)
  * @param key 按关键字查找,为空时不按关键字查找(order_id-订单号、staff_id-配送人员编号)
  * @param value 查找关键字、key不为空时起作用
  */
 @RequestMapping(value = "/getAllOrder", method = RequestMethod.GET)
 @ResponseBody
 public JSONObject getAllOrder(
     HttpSession httpSession,
     @RequestParam(required = false, value = "page") Long page,
     @RequestParam(required = false, value = "order_status") Integer order_status,
     @RequestParam(required = false, value = "key") String key,
     @RequestParam(required = false, value = "value") String value) {
   staff staff = (staff) httpSession.getAttribute("staff"); // 获取员工
   if (staff == null) {
     return CommonUtil.constructResponse(0, "员工不存在", null);
   }
   JSONObject jo = new JSONObject();
   List<Order> orders = new ArrayList<Order>();
   if (page == null || page <= 0) {
     page = Long.valueOf(1);
   }
   long total =
       orderService.getCountOrderManage(
           staff.getStaff_id(), staff.getStaff_rank(), order_status, key, value);
   if (total > 0) {
     orders =
         orderService.getOrderManage(
             staff.getStaff_id(), staff.getStaff_rank(), order_status, page, 10, key, value);
   }
   jo.put("total", total);
   jo.put("nowPage", page);
   jo.put("orders", orders);
   return CommonUtil.constructResponse(1, "success", jo);
 }
コード例 #8
0
 /**
  *
  *
  * <pre>解析封装职位分类列表  </pre>
  *
  * @param array JsonArray
  * @return
  * @throws JSONException
  */
 private static List<PositionClassify> parsePositionClassList(JSONArray array, String pcode)
     throws JSONException {
   List<PositionClassify> positionClasss = null;
   if (!StringUtils.isEmpty(array)) {
     int nn = array.size();
     PositionClassify positionClassify = null;
     positionClasss = new ArrayList<PositionClassify>(nn);
     for (int i = 0; i < nn; i++) {
       JSONObject jObject = array.getJSONObject(i);
       positionClassify = new PositionClassify();
       String code = jObject.getString("code");
       positionClassify.setCode(code);
       positionClassify.setPcode(pcode);
       positionClassify.setValue(jObject.getString("value"));
       boolean has = jObject.getIntValue("hassub") == 1;
       positionClassify.setHasSub(has);
       if (has) {
         JSONArray subArray = jObject.getJSONArray("sublist");
         if (!StringUtils.isEmpty(subArray)) {
           positionClassify.setSubList(parsePositionClassList(subArray, code));
         }
       }
       positionClasss.add(positionClassify);
       mapPositionClassifies.put(code, positionClassify);
     }
   }
   return positionClasss;
 }
コード例 #9
0
  public static boolean bind(WechatPost wechatPost) {
    try {
      String phoneNo = wechatPost.getUserPhone();
      String strPostUrl = PropertyUtil.getProperty("config.ini", "PROXY_PHONE_URL");
      String strRequest =
          "{\"groupGuid\":\"\",\"newMobile\":\"" + phoneNo + "\",\"workGroupName\":\"\"}";
      LOGGER.debug("strRequest=> {}", strRequest);
      String strResponse = REST_HttpUtil.PostMsg(strPostUrl, strRequest);
      LOGGER.debug("strResponse=> {}", strResponse);

      JSONObject jsonObj = JSON.parseObject(strResponse);
      // {"result_code":"0","result_data":[],"result_desc":"21BD13F5028E65C6E050A8C0E701DEBD,4008106290-9250,14112153"}

      String resultCode = jsonObj.getString("result_code");
      if ("0".equals(resultCode)) {
        String resultDesc = jsonObj.getString("result_desc");
        String[] result = resultDesc.split(",");
        String groupGuid = result[0];
        String phoneProxyNo = result[1];
        phoneProxyNo = phoneProxyNo.replaceAll("-", ",");
        wechatPost.setGroupGuid(groupGuid);
        wechatPost.setPhoneProxyNo(phoneProxyNo);
        return true;
      }

    } catch (Exception e) {
      LOGGER.error("error", e);
    }
    return false;
  }
コード例 #10
0
  @RequestMapping(value = "/doLogin", produces = "application/json; charset=UTF-8")
  @ResponseBody
  public String doLogin(HttpServletRequest request, LoginUserInfo loginInfo) {
    JSONObject result = new JSONObject();
    try {
      if (validateUserInfo(loginInfo, result)) {
        return result.toJSONString();
      }

      LoginUserInfo dbLoginInfo = iUserMaintainDao.queryUserInfoByName(loginInfo.getUserName());

      if (dbLoginInfo == null || !loginInfo.getPassword().equals(dbLoginInfo.getPassword())) {
        result.put("code", "400");
        result.put("message", "Username or password is not correct");
        return result.toJSONString();
      }

      logger.info("The userId[{}] has been login", dbLoginInfo.getUid());
      result.put("code", "200");
      result.put("message", "Login success");
      //
      request.getSession().setAttribute(Constants.SESSION_LOGIN_INFO_KEY, dbLoginInfo);
    } catch (Exception e) {
      logger.error(
          "Failed to login the user[{}] and password[{}]",
          loginInfo.getUserName(),
          loginInfo.getPassword(),
          e);
      result.put("code", "500");
      result.put("message", "fatal error. please try it again.");
    }
    return result.toJSONString();
  }
コード例 #11
0
  @RequestMapping(value = "/doRegister", produces = "application/json; charset=UTF-8")
  @ResponseBody
  public String doRegister(SignInUserInfo signInUserInfo) {
    JSONObject result = new JSONObject();
    try {

      if (validateUserInfo(signInUserInfo, result)) {
        return result.toJSONString();
      }
      signInUserInfo.setRoleType(Constants.USR.ROLE_TYPE_USER);
      signInUserInfo.setSts(Constants.USR.STR_VAL_A);
      iUserMaintainDao.addUser(signInUserInfo);
      if (StringUtil.isBlank(signInUserInfo.getUid())) {
        result.put("code", "500");
        result.put("message", "Failed to register user" + signInUserInfo.getUserName());
        return result.toJSONString();
      }

      result.put("code", "200");
      result.put("message", "register success");
    } catch (Exception e) {
      logger.error(
          "Failed to register the user[{}]",
          signInUserInfo.getUserName(),
          signInUserInfo.getPassword(),
          e);
      result.put("code", "500");
      result.put("message", "fatal error. please try it again.");
    }
    return result.toJSONString();
  }
コード例 #12
0
  @Override
  public Boolean hangupEc2(Integer jobId) {

    StringBuffer sb = new StringBuffer();
    sb.append("accessId=" + ConstantsForAccount.CALLENGINE_ACCESS_ID);
    sb.append("&accessKey=" + ConstantsForAccount.CALLENGINE_ACCESS_KEY);
    sb.append("&username="******"");

    if (res == null || res.equals("")) {
      return false;
    }

    JSONObject resJson = JSONObject.parseObject(res);
    String code = resJson.getString("code");
    if (code != null && code.equals("0")) {
      return true;
    }
    return false;
  }
コード例 #13
0
  @Override
  public Boolean dialEc2(Integer jobId, String destMobile) {

    StringBuffer sb = new StringBuffer();
    sb.append("accessId=" + ConstantsForAccount.CALLENGINE_ACCESS_ID);
    sb.append("&accessKey=" + ConstantsForAccount.CALLENGINE_ACCESS_KEY);
    sb.append("&username="******"&destNum=" + destMobile);

    System.out.println(sb.toString());

    System.out.println(new Date());

    String res =
        HttpRequestUtils.sendUTF8Post(
            ConstantsForAccount.CALLENGINE_URL,
            ConstantsForAccount.CALLENGINE_DIAL_METHOD,
            sb.toString(),
            "");
    System.out.println(res);

    if (res == null || res.equals("")) {
      return false;
    }

    JSONObject resJson = JSONObject.parseObject(res);
    String code = resJson.getString("code");
    if (code != null && code.equals("0")) {
      return true;
    } else {
      return false;
    }
  }
コード例 #14
0
 /**
  * 报销申请
  *
  * @return
  */
 @RequestMapping(
     value = "expenseApply",
     method = {RequestMethod.GET, RequestMethod.POST})
 public @ResponseBody Object addExpense(HttpServletRequest request) {
   ResponseResult responseResult = new ResponseResult();
   // 获取请假申请信息
   String jsonExpenseApplyInfo = HttpRequestUtil.getInst().getString("expenseApplyInfo");
   if (StringUtils.isEmpty(jsonExpenseApplyInfo)) {
     throw new VyiyunException("报销申请信息为空!");
   }
   try {
     JSONObject jsonExpenseApplyInfoObj =
         JSON.parseObject(URLDecoder.decode(jsonExpenseApplyInfo, "UTF-8"));
     String id = jsonExpenseApplyInfoObj.getString("id");
     // 存在id说明是重新发起
     if (StringUtils.isNotEmpty(id)) {
       jsonExpenseApplyInfoObj.put("isAgain", true);
     } else if (StringUtils.isEmpty(id)) {
       id = CommonUtil.GeneGUID();
       jsonExpenseApplyInfoObj.put("id", id);
     }
     responseResult.setValue(id);
     expenseService.doApply(jsonExpenseApplyInfoObj);
   } catch (Exception e) {
     e.printStackTrace();
     responseResult.setErrorMsg("请联系系统管理员");
     responseResult.setStatus(-1);
   }
   // 返回数据
   return responseResult;
 }
コード例 #15
0
  public void test_1() throws Exception {
    JSONObject res = new JSONObject();
    res.put("a", 1);
    res.put("b", 2);
    res.put("c", 3);

    String[] tests = {
      "{ 'a':1, 'b':2, 'c':3 }",
      "{ 'a':1,,'b':2, 'c':3 }",
      "{,'a':1, 'b':2, 'c':3 }",
      "{'a':1, 'b':2, 'c':3,,}",
      "{,,'a':1,,,,'b':2,'c':3,,,,,}",
    };

    for (String t : tests) {
      DefaultJSONParser ext = new DefaultJSONParser(t);
      ext.config(Feature.AllowArbitraryCommas, true);

      JSONObject extRes = ext.parseObject();
      Assert.assertEquals(res, extRes);

      DefaultJSONParser basic = new DefaultJSONParser(t);
      basic.config(Feature.AllowArbitraryCommas, true);
      JSONObject basicRes = basic.parseObject();
      Assert.assertEquals(res, basicRes);
    }
  }
コード例 #16
0
 /**
  * 签到处理
  *
  * @return
  * @throws UnsupportedEncodingException
  */
 @RequestMapping(
     value = "doSign",
     method = {RequestMethod.GET, RequestMethod.POST})
 public @ResponseBody Object doSign() {
   ResponseResult responseResult = new ResponseResult();
   try {
     // 获取请假申请信息
     JSONObject jsonSignInfoObj =
         JSON.parseObject(
             URLDecoder.decode(HttpRequestUtil.getInstance().getString("signInfo"), "UTF-8"));
     Map<String, Object> resultData = new HashMap<String, Object>();
     responseResult.setValue(resultData);
     if (null != jsonSignInfoObj) {
       String sSignTime = DateUtil.dateToString(new Date(), "yyyy-MM-dd HH:mm");
       Date signTime = DateUtil.stringToDate(sSignTime + ":00");
       String id = CommonUtil.GeneGUID();
       jsonSignInfoObj.put("signTime", signTime);
       jsonSignInfoObj.put("id", id);
       resultData.put("id", id);
       resultData.put("signTime", DateUtil.dateToString(signTime, "HH:mm"));
     }
     signService.doSign(jsonSignInfoObj);
   } catch (Exception e) {
     e.printStackTrace();
     responseResult.setStatus(-1);
   }
   return responseResult;
 }
コード例 #17
0
  @POST
  @Path("offlineWithDecrypt")
  @Override
  public Map<String, Object> offlineWithDecrypt(Map<String, Object> parameters) {
    String code = ""; // 状态码
    String message = ""; // 返回消息
    if (parameters != null) {
      try {
        String resultJson = rbisService.offlineWithDecrypt(parameters);
        // 转换为json数据
        JSONObject jsonObject = JSONObject.parseObject(resultJson);
        JSONObject content = (JSONObject) jsonObject.get("content");

        int state = content.getIntValue("code");
        if (state == 100) {
          code = "00";
          message = "用户下线成功!";
        } else {
          code = "11";
          message = "用户下线失败!";
        }
      } catch (Exception e) {

        message = "系统错误,用户下线失败!";
      }
    }

    return CommonUtil.returnObjectMap(code, message, "", null);
  }
コード例 #18
0
 private String getReplyResult(String js) {
   if (null == js) {
     return "发送失败";
   }
   js = js.replaceAll("window.script_muti_get_var_store=", "");
   if (js.indexOf("/*error fill content") > 0)
     js = js.substring(0, js.indexOf("/*error fill content"));
   js = js.replaceAll("\"content\":\\+(\\d+),", "\"content\":\"+$1\",");
   js = js.replaceAll("\"subject\":\\+(\\d+),", "\"subject\":\"+$1\",");
   js = js.replaceAll("/\\*\\$js\\$\\*/", "");
   JSONObject o = null;
   try {
     o = (JSONObject) JSON.parseObject(js).get("data");
   } catch (Exception e) {
     Log.e("TAG", "can not parse :\n" + js);
   }
   if (o == null) {
     try {
       o = (JSONObject) JSON.parseObject(js).get("error");
     } catch (Exception e) {
       Log.e("TAG", "can not parse :\n" + js);
     }
     if (o == null) {
       return "发送失败";
     }
     return o.getString("0");
   }
   return o.getString("0");
 }
コード例 #19
0
ファイル: Pay.java プロジェクト: Junred/wechat-company
 /**
  * 发货通知
  *
  * @param access_token
  * @param openid
  * @param transid
  * @param out_trade_no
  * @return
  * @throws IOException
  * @throws NoSuchProviderException
  * @throws NoSuchAlgorithmException
  * @throws KeyManagementException
  * @throws InterruptedException
  * @throws ExecutionException
  */
 public static boolean delivernotify(
     String access_token, String openid, String transid, String out_trade_no)
     throws IOException, ExecutionException, InterruptedException {
   Map<String, String> paras = new HashMap<String, String>();
   paras.put("appid", ConfKit.get("AppId"));
   paras.put("openid", openid);
   paras.put("transid", transid);
   paras.put("out_trade_no", out_trade_no);
   paras.put("deliver_timestamp", (System.currentTimeMillis() / 1000) + "");
   paras.put("deliver_status", "1");
   paras.put("deliver_msg", "ok");
   // 签名
   String app_signature = deliverSign(paras);
   paras.put("app_signature", app_signature);
   paras.put("sign_method", "sha1");
   String json =
       HttpKit.post(DELIVERNOTIFY_URL.concat(access_token), JSONObject.toJSONString(paras));
   if (StringUtils.isNotBlank(json)) {
     JSONObject object = JSONObject.parseObject(json);
     if (object.containsKey("errcode")) {
       int errcode = object.getIntValue("errcode");
       return errcode == 0;
     }
   }
   return false;
 }
コード例 #20
0
ファイル: Token.java プロジェクト: BarrieShieh/wechat4j
 /**
  * 解析token数据
  *
  * @param data
  * @return
  */
 private boolean parseData(String data) {
   JSONObject jsonObject = JSONObject.parseObject(data);
   String tokenName = tokenName();
   String expiresInName = expiresInName();
   try {
     String token = jsonObject.get(tokenName).toString();
     if (StringUtils.isBlank(token)) {
       logger.error("token获取失败,获取结果" + data);
       return false;
     }
     this.token = token;
     this.tokenTime = (new Date()).getTime();
     String expiresIn = jsonObject.get(expiresInName).toString();
     if (StringUtils.isBlank(expiresIn)) {
       logger.error("token获取失败,获取结果" + expiresIn);
       return false;
     } else {
       this.expires = Long.valueOf(expiresIn);
     }
   } catch (Exception e) {
     logger.error(
         "token 结果解析失败,token参数名称: "
             + tokenName
             + "有效期参数名称:"
             + expiresInName
             + "token请求结果:"
             + data);
     e.printStackTrace();
     return false;
   }
   return true;
 }
コード例 #21
0
 /**
  * @Title: commentDisplay @Description: 评论显示
  *
  * @author <a href="*****@*****.**">蔡志杰</a>
  * @date 2015-8-25 下午4:35:12
  * @version 1.0.0
  * @param @param data
  * @param @param request
  * @param @return
  * @return Object 返回类型
  * @throws
  */
 @RequestMapping("/commentDisplay")
 public Object commentDisplay(String data, HttpServletRequest request) {
   log.info("---------CommentsManagerController.commentDisplay-----------");
   log.info("----------------------data:" + data + "-------------------------");
   HeadObject headObject = null;
   ResultObject resultObject = null;
   try {
     JSONObject obj = JSON.parseObject(data);
     if (null == obj.getString("commentId")) {
       return processExpction("commentId不能为空!");
     } else if (null == obj.getString("display")) {
       return processExpction("display不能为空!");
     }
     String[] ids = {obj.getString("commentId")};
     headObject = CommonHeadUtil.geneHeadObject("orderCommentService.updateOrderCommentDisply");
     Map<String, Object> map = new HashMap<String, Object>();
     map.put("commentIds", ids);
     map.put("display", obj.getString("display"));
     resultObject =
         (ResultObject) orderService.doServiceByServer(new RequestObject(headObject, map));
   } catch (Exception e) {
     e.printStackTrace();
     log.error(e.toString());
     return CommonUtil.processExpction(headObject);
   }
   return resultObject;
 }
コード例 #22
0
  @ResponseBody
  @RequestMapping("doneDBRepay")
  public JSONObject doneDBRepayManage(
      RepayPlanQueryOrder queryOrder, PageParam pageParam, Model model) throws Exception {
    JSONObject jsonObject = new JSONObject();
    queryOrder.setPageSize(pageParam.getPageSize());
    queryOrder.setPageNumber(pageParam.getPageNo());
    List<String> status = new ArrayList<String>(1);
    status.add(RepayPlanStatusEnum.REPAY_SUCCESS.getCode());
    queryOrder.setGuaranteeId(getGuaranteeUserId());
    queryOrder.setStatusList(status);
    QueryBaseBatchResult<RepayPlanInfo> queryBaseBatchResult =
        repayPlanService.queryRepayPlanInfoGuarantee(queryOrder);
    Map<String, String> map = new HashMap<String, String>();
    List<RepayPlanInfo> recordList = queryBaseBatchResult.getPageList();
    if (ListUtil.isNotEmpty(recordList)) {
      for (RepayPlanInfo item : recordList) {
        Date date = new Date();
        if (date.after(item.getRepayDate())) {
          item.setCanPay("Y");
          getTradeLoanDemandId(map, item.getTradeId());
        }
      }
    }

    jsonObject.put("map", map);
    jsonObject.put("page", PageUtil.getCovertPage(queryBaseBatchResult));
    jsonObject.put("queryConditions", queryOrder);
    return jsonObject;
  }
コード例 #23
0
ファイル: JSONParserUtil.java プロジェクト: wqycsu/ganhuo
 private static String extractResult(String jsonStr) {
   JSONObject jsonObject = JSON.parseObject(jsonStr);
   if (jsonObject != null && jsonObject.containsKey(RESULTS)) {
     return jsonObject.get(RESULTS).toString();
   }
   return null;
 }
コード例 #24
0
ファイル: WXDomStatement.java プロジェクト: Rowandjj/weex
  /**
   * Update styles according to the given style. Then creating a command object for updating
   * corresponding view and put the command object in the queue.
   *
   * @param ref Reference of the dom.
   * @param style the new style. This style is only a part of the full style, and will be merged
   *     into styles
   * @see #updateAttrs(String, JSONObject)
   */
  void updateStyle(String ref, JSONObject style) {
    if (mDestroy || style == null) {
      return;
    }
    WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId);
    WXDomObject domObject = mRegistry.get(ref);
    if (domObject == null) {
      if (instance != null) {
        instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_UPDATESTYLE);
      }
      return;
    }

    Map<String, Object> animationMap = WXDataStructureUtil.newHashMapWithExpectedSize(2);
    animationMap.put(WXDomObject.TRANSFORM, style.remove(WXDomObject.TRANSFORM));
    animationMap.put(WXDomObject.TRANSFORM_ORIGIN, style.remove(WXDomObject.TRANSFORM_ORIGIN));
    animations.add(new Pair<>(ref, animationMap));

    if (!style.isEmpty()) {
      domObject.updateStyle(style);
      transformStyle(domObject, false);
      updateStyle(domObject, style);
    }
    mDirty = true;

    if (instance != null) {
      instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
    }
  }
コード例 #25
0
ファイル: Sign.java プロジェクト: darlingtld/crab
  public static void main(String[] args) {
    RestTemplate restTemplate = new RestTemplate();
    String getAccessTokenUrl =
        String.format(
            "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s",
            PropertyHolder.APPID, PropertyHolder.APPSECRET);
    String retData =
        restTemplate.getForObject(getAccessTokenUrl, String.class, new HashMap<String, Object>());
    System.out.println("[Acess Token returned data] " + retData);

    JSONObject jsonObject = JSON.parseObject(retData);
    String accessToken = jsonObject.getString("access_token");
    String jsapiTicketUrl =
        String.format(
            "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=%s&type=jsapi",
            accessToken);
    retData =
        restTemplate.getForObject(jsapiTicketUrl, String.class, new HashMap<String, Object>());
    System.out.println("[jsapiTicketUrl returned data] " + retData);

    jsonObject = JSON.parseObject(retData);
    String jsapi_ticket = jsonObject.getString("ticket");

    String url = "http://cai.songdatech.com/crab/?buy_type=card";
    Map<String, String> ret = sign(jsapi_ticket, url);
    for (Map.Entry entry : ret.entrySet()) {
      System.out.println(entry.getKey() + ", " + entry.getValue());
    }
  }
コード例 #26
0
  public JSONObject getSomething(String something) throws Exception {

    //        Connection con = datasource.getConnection();
    //
    //        Statement stmt = con.createStatement();
    //
    //        String sql = "select * from somewhere";
    //
    //        ResultSet res = stmt.executeQuery(sql);
    //
    //        JSONArray records = new JSONArray();
    //
    //        while (res.next()) {
    //
    //            JSONObject record = new JSONObject();
    //            records.add(record);
    //            record.put("value", res.getString("value"));
    //        }
    //
    //        res.close();
    //        stmt.close();
    //        con.close();
    //
    JSONObject results = new JSONObject();
    //
    //        results.put("records", records);
    results.put("something", something);
    return results;
  }
コード例 #27
0
ファイル: DepgAction.java プロジェクト: kolenxiao/work
  /** 获取一周回看分类节目列表 */
  @SuppressWarnings({"unchecked", "rawtypes"})
  public void getBTVPrograms() {
    try {
      Assert.notNull(typeId, "分类id不能为空!");
      Map params = new HashMap();
      params.put("typeId", typeId);
      params.put("pageSize", String.valueOf(getPager().getMax()));
      params.put("curPage", String.valueOf(getPager().getPage()));

      String response = HttpUtils.sendPost(BTV_PROGRAMS_URL, params, "utf-8");
      JSONObject jo = JSON.parseObject(response);
      if (null != jo) {
        String ret = jo.getString("ret");
        if (StringUtils.equals("0", ret)) {
          String programList = jo.getString("result");
          List<Map> rows = null;
          if (StringUtils.isNotBlank(programList)) {
            rows = JSON.parseArray(programList, Map.class);
          }
          if (null == rows) {
            rows = new ArrayList<Map>();
          }
          resultMap.put("total", jo.get("totalCount"));
          resultMap.put("rows", rows);
          jsonMap();
        }
      }
    } catch (Exception e) {
      logger.error("调用接口getBTVPrograms失败", e);
      jsonRet("1", e.getMessage());
    }
  }
コード例 #28
0
ファイル: ResponseUtils.java プロジェクト: jior/glaf
  public static byte[] responseJsonResult(boolean success, Map<String, Object> dataMap) {
    if (success) {
      Map<String, Object> jsonMap = new java.util.HashMap<String, Object>();
      jsonMap.put("statusCode", 200);

      Set<Entry<String, Object>> entrySet = dataMap.entrySet();
      for (Entry<String, Object> entry : entrySet) {
        String key = entry.getKey();
        Object value = entry.getValue();
        jsonMap.put(key, value);
      }

      JSONObject object = new JSONObject(jsonMap);
      try {
        return object.toString().getBytes("UTF-8");
      } catch (UnsupportedEncodingException e) {
      }
    } else {
      Map<String, Object> jsonMap = new java.util.HashMap<String, Object>();
      jsonMap.put("statusCode", 500);

      Set<Entry<String, Object>> entrySet = dataMap.entrySet();
      for (Entry<String, Object> entry : entrySet) {
        String key = entry.getKey();
        Object value = entry.getValue();
        jsonMap.put(key, value);
      }
      JSONObject object = new JSONObject(jsonMap);
      try {
        return object.toString().getBytes("UTF-8");
      } catch (UnsupportedEncodingException e) {
      }
    }
    return null;
  }
コード例 #29
0
ファイル: JMServer.java プロジェクト: is00hcw/Mycat-Web
  @RequestMapping("/loadRuntimeInfo")
  @ResponseBody
  public JSONObject doLoadRuntimeInfo(HttpServletRequest request) {
    try {
      String app = request.getParameter("app");
      RuntimeMXBean mBean = JMConnManager.getRuntimeMBean(app);
      ClassLoadingMXBean cBean = JMConnManager.getClassMbean(app);
      Map<String, String> props = mBean.getSystemProperties();
      DateFormat format = DateFormat.getInstance();
      List<String> input = mBean.getInputArguments();
      Date date = new Date(mBean.getStartTime());

      TreeMap<String, Object> data = new TreeMap<String, Object>();

      data.put("apppid", mBean.getName());
      data.put("startparam", input.toString());
      data.put("starttime", format.format(date));
      data.put("classLoadedNow", cBean.getLoadedClassCount());
      data.put("classUnloadedAll", cBean.getUnloadedClassCount());
      data.put("classLoadedAll", cBean.getTotalLoadedClassCount());
      data.putAll(props);

      JSONObject json = new JSONObject(true);
      json.putAll(data);
      return json;
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
コード例 #30
0
 private String getClientUpdateLogWhere(JSONObject jsonobject) {
   if (null != jsonobject) {
     StringBuilder sql = new StringBuilder();
     Integer equip_id = jsonobject.getInteger("equip_id");
     if (null != equip_id) {
       sql.append("equip_id =" + equip_id + " ");
     } else {
       sql.append("equip_id is null ");
     }
     Integer column_id = jsonobject.getInteger("column_id");
     sql.append("and ");
     if (null != column_id) {
       sql.append("column_id =" + column_id + " ");
     } else {
       sql.append("column_id is null ");
     }
     Integer version_id = jsonobject.getInteger("version_id");
     sql.append("and ");
     if (null != version_id) {
       sql.append("version_id =" + version_id + " ");
     } else {
       sql.append("version_id is null ");
     }
     Integer version_type = jsonobject.getInteger("version_type");
     sql.append("and ");
     if (null != version_type) {
       sql.append("version_type =" + version_type + " ");
     } else {
       sql.append("version_type is null ");
     }
     return sql.toString();
   }
   return "";
 }