/** 显示在图订单的条数 */
  private void requestNum() {

    String aspectType = Constant.RECEIVER_ROLE_ID + "";
    String orgCode = common.getStringByKey(Constant.ORG_CODE);
    String enterpriseId = common.getStringByKey(Constant.ENTERPRISE_ID);
    String sessionUuid = common.getStringByKey(Constant.SESSION_UUID);

    //
    // /v1.1/appSenderAndReceiverOrderCount.json?sessionUuid=&aspectType=1&enterpriseId=53&orgCode=1
    String url =
        Constant.ENTRANCE_PREFIX_v1
            + "appSenderAndReceiverOrderCount.json?sessionUuid="
            + sessionUuid
            + "&aspectType="
            + aspectType
            + "&enterpriseId="
            + enterpriseId
            + "&orgCode="
            + orgCode;

    // 第一次进来显示loading
    showProgressDialog();
    OkHttpClientManager.getAsyn(
        url,
        new OkHttpClientManager.ResultCallback<String>() {
          @Override
          public void onError(Request request, Exception e) {
            dissmissProgressDialog();
            //                Toast.makeText(getActivity(), "获取信息异常", Toast.LENGTH_SHORT).show();
            Common.showToast(getActivity(), "获取信息异常");
          }

          @Override
          public void onResponse(String response) {
            JSONObject jsonObject;
            JSONArray jsonArray;
            try {
              jsonObject = new JSONObject(response);
              if (!jsonObject.getString("status").equals(Constant.LOGIN_SUCCESS_STATUS)) {
                Toast.makeText(getActivity(), "返回信息失败", Toast.LENGTH_SHORT).show();
                dissmissProgressDialog();
                return;
              }
              jsonArray = jsonObject.getJSONArray("rows");
              int onwayNum = jsonArray.getInt(0);

              Message msg = Message.obtain();
              msg.what = onwayNum;
              handler.sendMessage(msg);

            } catch (JSONException e) {
              e.printStackTrace();
            }
          }
        });
  }
  /**
   * 更新角色
   *
   * @param enterpriseId 企业ID
   */
  private void updateRole(String enterpriseId) {
    String sessionUuid = common.getStringByKey(Constant.SESSION_UUID);
    String accountUrl =
        Constant.ENTRANCE_PREFIX
            + "Compare.json?sessionUuid="
            + sessionUuid
            + "&enterpriseId="
            + enterpriseId;
    OkHttpClientManager.getAsyn(
        accountUrl,
        new AccountTypeResultCallback<String>() {
          @Override
          public void onError(Request request, Exception e) {
            common.showToast(context, "更新角色异常");
            transitionDialog.dismissDialog();
          }

          @Override
          public void onResponse(String response) {
            JSONObject jsonObject;
            JSONArray jsonArray;
            JSONObject item;
            try {
              jsonObject = new JSONObject(response);
              String status = jsonObject.getString("status");
              if (!status.equals(Constant.LOGIN_SUCCESS_STATUS)) {
                // 角色类型请求失败
                common.showToast(context, "更新角色失败");
                transitionDialog.dismissDialog();
                return;
              }
              jsonArray = jsonObject.getJSONArray("rows");
              item = jsonArray.getJSONObject(0);
              int roleID = item.getInt("role");
              Map<Object, Object> map = new HashMap<Object, Object>();
              map.put(getString(R.string.role_id), roleID);
              // 保存角色类型信息
              if (!common.isSave(map)) {
                common.showToast(context, "角色类型信息保存失败");
                return;
              }

              Message message = Message.obtain();
              message.what = HANDLER_UPDATE_ROLE_CODE;
              handler.sendMessage(message);
            } catch (JSONException e) {
              e.printStackTrace();
            }
          }
        });
  }
  /** 请求账户类型数据 */
  private void requestAccountTypeList() {
    String sessionUuid = common.getStringByKey(Constant.SESSION_UUID); // 获取当前sessionUUID
    String url =
        Constant.ENTRANCE_PREFIX_v1
            + "appGetRelatedEnterpriseList.json?sessionUuid="
            + sessionUuid; // 账户类型访问地址
    OkHttpClientManager.getAsyn(
        url,
        new AccountTypeResultCallback<String>() {

          @Override
          public void onError(Request request, Exception e) {
            common.showToast(context, "账户类型请求异常");
            transitionDialog.dismissDialog();
          }

          @Override
          public void onResponse(String response) {
            JSONObject jsonObject;
            JSONArray jsonArray;
            JSONObject item;
            try {
              jsonObject = new JSONObject(response);
              String status = jsonObject.getString("status");
              if (!status.equals(Constant.LOGIN_SUCCESS_STATUS)) {
                // 用户名和密码错误
                common.showToast(context, "账户类型请求失败");
                transitionDialog.dismissDialog();
                return;
              }
              jsonArray = jsonObject.getJSONArray("rows");
              if (jsonArray.length() == 0) {
                common.showToast(context, "暂无数据");
                return;
              }
              for (int i = 0; i < jsonArray.length(); i++) {
                item = jsonArray.getJSONObject(i);
                AccountTypeInfoBean accountTypeInfo = new AccountTypeInfoBean();
                accountTypeInfo.setEnterpriseId(item.getString("enterpriseId"));
                accountTypeInfo.setEnterpriseName(item.getString("enterpriseName"));
                accountTypeInfoBeanList.add(accountTypeInfo);
              }
              Message message = Message.obtain();
              message.what = HANDLER_ACCOUNT_TYPE_CODE;
              handler.sendMessage(message);
            } catch (JSONException e) {
              e.printStackTrace();
            }
          }
        });
  }
示例#4
0
  /**
   * 更新订单
   *
   * @param orderDetail
   */
  private void operationOrder(final OrderDetail orderDetail) {

    receiveOrder.setBackgroundResource(R.drawable.border_corner_order);
    receiveOrder.setEnabled(false);

    int controlId = orderDetail.getControlId();
    final int controlStatus = orderDetail.getOrderStatusLists().get(0);
    String sessionUUID = getSessionUUID();
    String url =
        Constant.ENTRANCE_PREFIX
            + "appAutoUpdateOrderStatus.json?sessionUuid="
            + sessionUUID
            + "&controlId="
            + controlId;
    OkHttpClientManager.getAsyn(
        url,
        new OkHttpClientManager.ResultCallback<String>() {
          @Override
          public void onError(Request request, Exception e) {
            receiveOrder.setBackgroundResource(R.drawable.border_corner_order);
            receiveOrder.setEnabled(true);
          }

          @Override
          public void onResponse(String response) {
            JSONObject jsonObject;
            JSONArray jsonArray;
            List<OrderPerTime> orderPerTimeList = orderDetail.getOrderPerTimeList();
            try {
              jsonObject = new JSONObject(response);
              if (!jsonObject.getString("status").equals(Constant.LOGIN_SUCCESS_STATUS)) {
                Toast.makeText(getApplicationContext(), "接单异常异常", Toast.LENGTH_SHORT).show();
                return;
              }

              //                    TimerService timerService= EdydApplication.timerService;
              //                    LocationSource.OnLocationChangedListener listener =
              // TimerService.mListener;
              //                    timerService.stopTimer();
              //                    timerService.startTimer();
              //                    timerService.reActivate(listener);

              // ServiceUtil.cancelAlarmManager(getApplicationContext());
              // ServiceUtil.invokeTimerPOIService(getApplicationContext(),
              // String.valueOf(orderDetail.getControlId()), String.valueOf(controlStatus));
              MLocation mLocation;
              switch (controlStatus) {
                case 17:
                  tControlStatus = 20;
                  break;
                case 20:
                  tControlStatus = 30;
                  break;
                case 30:
                  tControlStatus = 40;
                  break;
                case 40:
                  tControlStatus = 50;
                  break;
                case 50:
                  tControlStatus = 60;
                  break;
                case 60:
                  tControlStatus = 99;
                  break;
              }
              mLocation =
                  new MLocation(
                      getApplicationContext(),
                      common,
                      String.valueOf(orderDetail.getControlId()),
                      String.valueOf(tControlStatus));

              Message message = new Message();
              message.what = 0x13;
              handler.sendMessage(message);
            } catch (JSONException e) {
              e.printStackTrace();
            }
          }
        });
  }
示例#5
0
  /**
   * 根据ID请求订单详情数据
   *
   * @param primaryID
   */
  private void requestOrderDetailData(String primaryID) {
    Common common =
        new Common(getSharedPreferences(Constant.LOGIN_PREFERENCES_FILE, Context.MODE_PRIVATE));
    String sessionUuid = common.getStringByKey(Constant.SESSION_UUID);
    String url =
        Constant.ENTRANCE_PREFIX
            + "appQueryOrderDetail.json?sessionUuid="
            + sessionUuid
            + "&primaryId="
            + primaryID;
    OkHttpClientManager.getAsyn(
        url,
        new OrderDetailResultCallback<String>() {
          @Override
          public void onError(Request request, Exception e) {}

          @Override
          public void onResponse(String response) {
            JSONObject jsonObject;
            JSONObject rowJson;
            try {
              jsonObject = new JSONObject(response);
              if (!jsonObject.getString("status").equals(Constant.LOGIN_SUCCESS_STATUS)) {
                Toast.makeText(getApplicationContext(), "订单详情查询异常", Toast.LENGTH_SHORT).show();
                return;
              }
              // 实体数据设置
              OrderDetail orderDetail = new OrderDetail();
              rowJson = jsonObject.getJSONArray("rows").getJSONObject(0);

              // 订单日期
              JSONArray perTimeArray = rowJson.getJSONArray("operTime");
              List<OrderPerTime> orderPerTimeList = new ArrayList<OrderPerTime>(); // 时间集
              for (int i = 0; i < perTimeArray.length(); i++) {
                JSONObject perJSON = perTimeArray.getJSONObject(i);
                OrderPerTime orderPerTime = new OrderPerTime();
                orderPerTime.setDate(
                    formatDate(perJSON.getInt("month") + 1, perJSON.getInt("date")));
                orderPerTime.setHour(
                    formatTime(perJSON.getInt("hours"), perJSON.getInt("minutes")));
                orderPerTimeList.add(orderPerTime);
              }
              orderDetail.setOrderPerTimeList(orderPerTimeList);

              // 订单详情
              orderDetail.setControlId(rowJson.getInt("ID"));
              orderDetail.setControlNum(rowJson.getString("controlNum")); // 订单号
              // orderDetail.setControlStatus(rowJson.getJSONArray("controlStatus").getInt(0));
              // 订单状态
              JSONArray orderStatusArray = rowJson.getJSONArray("controlStatus");
              List<Integer> orderStatusLists = new ArrayList<Integer>(); // 订单状态
              for (int i = 0; i < orderStatusArray.length(); i++) {
                orderStatusLists.add(orderStatusArray.getInt(i));
              }
              tControlStatus = orderStatusLists.get(0);
              orderDetail.setOrderStatusLists(orderStatusLists);

              orderDetail.setStartPoint(rowJson.getString("senderAddr")); // 起始地点
              orderDetail.setEndPoint(rowJson.getString("receiverAddr")); // 终点地址
              orderDetail.setShipper(rowJson.getString("senderContactPerson")); // 发货人
              orderDetail.setPhoneNumber(rowJson.getString("senderContactTel")); // 发货联系人
              orderDetail.setConsignee(rowJson.getString("receiverContactPerson")); // 收货人
              orderDetail.setConsigneePhoneNumber(
                  rowJson.getString("receiverContactTel")); // 收货人联系电话

              // 货物
              // orderDetail.setGoodsName(rowJson.getJSONArray("goodsName").getString(0)); //获取名称
              JSONArray goodNameArray = rowJson.getJSONArray("goodsName");
              List<String> goodNameLists = new ArrayList<String>(); // 订单状态
              for (int i = 0; i < goodNameArray.length(); i++) {
                goodNameLists.add(goodNameArray.getString(i));
              }
              orderDetail.setGoodNameLists(goodNameLists);

              orderDetail.setGoodsTotalVolume(rowJson.getString("totalVolume")); // 货物总体积
              orderDetail.setGoodsTotalQuantity(rowJson.getString("totalNum")); // 货物总数量
              orderDetail.setGoodsTotalWeight(rowJson.getString("totalWeight"));

              Message message = new Message();
              message.what = 0x12;
              Bundle bundle = new Bundle();
              bundle.putSerializable("orderDetail", orderDetail);
              message.setData(bundle);
              handler.sendMessage(message);
            } catch (JSONException e) {
              e.printStackTrace();
            }
          }
        });
  }