예제 #1
0
 private List<CartListDTO> findProImage(List<CartListDTO> list) throws Exception {
   if (list != null && list.size() >= 1) {
     HeadObject headObject = null;
     ResultObject resultObject = null;
     List<Picture> pictureList = null;
     for (int i = 0; i < list.size(); i++) {
       // 查询图片
       headObject = CommonHeadUtil.geneHeadObject("pictureService.selectByProductId");
       resultObject =
           (ResultObject)
               itemService.doServiceByServer(
                   new RequestObject(headObject, list.get(i).getProductId()));
       //				pictureList = (List<Picture>) resultObject.getContent();
       if (resultObject.getContent() != null) {
         pictureList =
             com.alibaba.fastjson.JSONObject.parseArray(
                 resultObject.getContent().toString(), Picture.class);
         if (pictureList != null && pictureList.size() >= 1) {
           list.get(i).setGoodsImage(pictureList.get(0).getPicturePath());
         }
       }
     }
   }
   return list;
 }
예제 #2
0
 public static List<Banner> parseOthers(String paramString) {
   try {
     List localList = JSONObject.parseArray(paramString, Banner.class);
     return localList;
   } catch (Exception localException) {
     localException.printStackTrace();
   }
   return null;
 }
 @Override
 public ConsoleCommandBean handleCommand(
     ConsoleCommandBean bean, ConsoleCommandManager manager, Object... args) {
   ConsoleCommandBean re = new ConsoleCommandBean();
   try {
     List<String> ll = JSONObject.parseArray(JSONObject.toJSONString(bean.getOb()), String.class);
     manager.getSpiderManager().stop(ll.get(0));
     re.setCommand(ConsoleCommand.STOPSUCCESS);
   } catch (Exception e) {
     re.setCommand(ConsoleCommand.STOPFAILURE);
     re.setOb(e.getLocalizedMessage());
   }
   return re;
 }
  @Override
  public Object sevice(String param, String ip) { // service的具体业务在此处进行具体调用
    // TODO Auto-generated method stub
    logger.info("param:" + param);
    List<RouterSysLog> msgBodyList = JSONObject.parseArray(param, RouterSysLog.class);

    Reslut reslut = new Reslut();
    if (msgBodyList == null || msgBodyList.size() == 0) {
      reslut.setResultCode("FAIL-001");
      reslut.setResultMsg("参数解析错误");
    } else {
      try {
        boolean flag = routerMsgLogBusiService.saveRouteMsgLog(msgBodyList);
        if (flag) {
          reslut.setResultCode("success");
          reslut.setResultMsg("数据上报成功");
        } else {
          reslut.setResultCode("FAIL-002");
          reslut.setResultMsg("数据入库异常,请检查接口日志!");
        }
      } catch (Exception e) {
        logger.error(e.getMessage());
        String errorMsg = e.getMessage() == null ? "" : e.getMessage();
        String[] errorMsgArr = errorMsg.split("~");
        if (errorMsgArr == null || errorMsgArr.length == 1) { // 系统发生了未知异常
          reslut.setResultCode("FAIL-002");
          reslut.setResultMsg(e.getMessage());
        } else {
          reslut.setResultCode(errorMsgArr[0]);
          reslut.setResultMsg(errorMsgArr[1]);
        }
      }
    }
    String msg = JSON.toJSONString(reslut);
    return msg;
  }