@Override
  public void DeleteOrderReceived(String msg) {
    // {delete:fieldName=PlotID,fieldValue=xxxxxxx}
    int pos = msg.indexOf(":");
    if (pos > msg.length() || pos < 0) return;
    String order = msg.substring(1, pos);
    msg = msg.substring(pos + 1);

    if (!order.equalsIgnoreCase("delete")) {
      return;
    }
    pos = msg.indexOf(",");
    if (pos > msg.length() || pos < 0) return;

    // fileName为fieldName=PlotID
    String fieldName = msg.substring(0, pos);
    msg = msg.substring(pos + 1);

    pos = fieldName.indexOf("=");
    if (pos > fieldName.length() || pos < 0) return;
    fieldName = fieldName.substring(pos + 1);
    if (!fieldName.equalsIgnoreCase("PlotID")) {
      return;
    }

    // fileValue为fieldValue=xxxxxxx}
    String fieldValue = msg.substring(0, msg.length() - 1);

    pos = fieldValue.indexOf("=");
    if (pos > fieldValue.length() || pos < 0) return;
    fieldValue = fieldValue.substring(pos + 1, msg.length() - 1);

    // 查处所有数据集对象,依次遍历找到PlotID值为fieldValue的对象,并删除????
    DatasetVector dv =
        (DatasetVector)
            (mapShow
                .getMap()
                .getWorkspace()
                .getDatasources()
                .get("multimedia")
                .getDatasets()
                .get("CAD"));
    Recordset recordset = dv.getRecordset(false, CursorType.DYNAMIC);
    recordset.moveFirst();
    while (!recordset.isEOF()) {
      String value = (String) recordset.getFieldValue(fieldName);
      if (value.equalsIgnoreCase(fieldValue)) {
        recordset.delete();
        recordset.update();
        break;
      }
      recordset.moveNext();
    }
    recordset.close();
    recordset.dispose();
  }
  public void sendPlot() {
    Layer layerCAD = mMapControl.getMap().getLayers().get(0);
    Recordset record =
        ((DatasetVector) layerCAD.getDataset()).getRecordset(false, CursorType.DYNAMIC);
    record.moveFirst();

    int failedCount = 0; // 记录发送失败的数据个数
    while (!record.isEOF()) {
      String msg = "{content_type=2}";

      String plotID = record.getFieldValue("PlotID").toString();
      if (m_ArraySendedIDs.contains(plotID)) {
        record.moveNext();
        continue;
      }
      msg += "{PlotID=";
      msg += plotID;
      msg += "}";
      // 对象类型
      GeometryType type = record.getGeometry().getType();
      msg += "{type=";
      msg += type.value(); // type.toString();
      msg += "}";

      String geoJson = record.getGeometry().toXML();
      msg += geoJson;

      boolean bOk = m_MessageQueue.sendMessageByType(msg, 2);
      if (bOk) {
        m_ArraySendedIDs.add(plotID);
        MyApplication.getInstance().showInfo("发送成功");
      } else {
        failedCount++;
      }

      record.moveNext();
    }

    record.dispose();
    if (failedCount != 0) {
      MyApplication.getInstance().showInfo("发送失败" + failedCount + "个对象,请继续发送!");
    }
  }
  @Override
  public void PlotObjectsReceived(String msg) {
    // {PlotID=xxxxxxxxxx}xml
    int pos = msg.indexOf("}");
    if (pos > msg.length() || pos < 0) return;
    String plotID = msg.substring(1, pos);
    msg = msg.substring(pos + 1);
    pos = plotID.indexOf("=");
    if (pos > msg.length() || pos < 0) return;
    plotID = plotID.substring(pos + 1);
    if (plotID.equalsIgnoreCase("0")) {
      return;
    }

    // 获取数据类型 {type=**}
    pos = msg.indexOf("}");
    if (pos > msg.length() || pos < 0) return;
    String type = msg.substring(1, pos);
    msg = msg.substring(pos + 1);

    pos = type.indexOf("=");
    if (pos > type.length() || pos < 0) return;
    type = type.substring(pos + 1);
    GeometryType geometryType =
        (GeometryType) Enum.parse(GeometryType.class, Integer.parseInt(type));

    Geometry geometry;
    if (geometryType == GeometryType.GEOGRAPHICOBJECT) {
      geometry = new GeoGraphicObject();
      geometry.fromXML(msg);
    } else if (geometryType == GeometryType.GEOREGION) {
      geometry = new GeoRegion();
      geometry.fromXML(msg);
    } else {
      geometry = new GeoLine();
      geometry.fromXML(msg);
    }

    Layer layerCAD = mMapControl.getMap().getLayers().get(0);
    Recordset record =
        ((DatasetVector) layerCAD.getDataset()).getRecordset(false, CursorType.DYNAMIC);
    record.moveFirst();

    String nodeName = "PlotID";
    try {
      boolean bHasGeometry = false;
      while (!record.isEOF()) {
        String old = record.getFieldValue(nodeName).toString();
        if (old.equalsIgnoreCase(plotID)) {
          record.edit();
          record.setGeometry(geometry);
          record.update();
          bHasGeometry = true;
          break;
        }
        record.moveNext();
      }
      if (!bHasGeometry) {
        record.edit();
        if (geometry.getType() == GeometryType.GEOLINE) {
          GeoStyle style = new GeoStyle();
          style.setLineColor(new com.supermap.data.Color(127, 127, 127));
          style.setFillForeColor(new com.supermap.data.Color(189, 235, 255));
          style.setLineWidth(1.0);
          geometry.setStyle(style);
        } else if (geometry.getType() == GeometryType.GEOREGION) {
          GeoStyle style = new GeoStyle();
          style.setLineColor(new com.supermap.data.Color(91, 89, 91));
          style.setFillForeColor(new com.supermap.data.Color(189, 235, 255));
          style.setLineWidth(1.0);
          geometry.setStyle(style);
        }

        record.addNew(geometry);
        record.setFieldValue(nodeName, plotID);
        record.update();

        m_ArraySendedIDs.add(plotID);
      }

    } catch (Exception ex) {
      ex.printStackTrace();
    }
    record.close();
    record.dispose();
    mMapControl.getMap().refresh();
  }
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.consult_message:
        {
          mMapControl.submit();
          mMapControl.setAction(Action.SELECT);
          mMapControl.getMap().refresh();

          if (m_popupMultiMedia != null && m_popupMultiMedia.isShowing()) {
            m_popupMultiMedia.dismiss();
          }
          if (m_PlotTypePopup != null && m_PlotTypePopup.isShowing()) {
            m_PlotTypePopup.dismiss();
          }
          m_nMessageCount = 0;
          btnNewMessage.setVisibility(4);
          showMessageList(v);
        }
        break;
      case R.id.message_switch:
        {
          if (m_popupMultiMedia != null && m_popupMultiMedia.isShowing()) {
            m_popupMultiMedia.dismiss();
          }
          if (m_PlotTypePopup != null && m_PlotTypePopup.isShowing()) {
            m_PlotTypePopup.dismiss();
          }
          mMessageQueueOn = !mMessageQueueOn;
          if (!mMessageQueueOn) {
            btnMessageSwitch.setBackgroundResource(R.drawable.btn_message_switch_noselect);
            m_MessageQueue.suspend();
          } else {
            btnMessageSwitch.setBackgroundResource(R.drawable.btn_message_switch_focused);
            m_MessageQueue.resume();

            // 先去下载一次多媒体数据
            if (m_popupMultiMedia == null) {
              // 多媒体列表初始化
              m_popupMultiMedia =
                  new MultiMediaPopup(btnMultiMedia.getRootView(), getApplicationContext(), this);
              // 设置多媒体工作空间
              m_popupMultiMedia.setWorkspace(mapShow.getWorkspace(), mapShow.getBounds());
            }
          }
        }
        break;
      case R.id.locate:
        {
          if (m_popupMultiMedia != null && m_popupMultiMedia.isShowing()) {
            m_popupMultiMedia.dismiss();
          }
          if (m_PlotTypePopup != null && m_PlotTypePopup.isShowing()) {
            m_PlotTypePopup.dismiss();
          }
          m_StartPoint = m_TencentLocation.getGPSPoint();
          if ((m_StartPoint.getX() == 0) || (m_StartPoint.getY() == 0)) {
            MyApplication.getInstance().showInfo("现在无法定位,请稍后再试!");
            break;
          }
          // 导航纠偏
          m_StartPoint = m_Navigation.encryptGPS(m_StartPoint.getX(), m_StartPoint.getY());

          Point2D pt = mapShow.getPoint(m_StartPoint);
          if (pt == null) {
            MyApplication.getInstance().showInfo("现在无法定位,请稍后再试!");
            break;
          }
          drawCircleOnDyn(pt, 0, m_TencentLocation.getAccuracy());
          mapShow.panTo(pt);
          m_MapView.refresh();
        }
        break;
      case R.id.multi_media:
        {
          mMapControl.submit();
          mMapControl.setAction(Action.SELECT);
          mMapControl.getMap().refresh();

          if (m_PlotTypePopup != null && m_PlotTypePopup.isShowing()) {
            m_PlotTypePopup.dismiss();
          }
          showMultiMediaPopup(v);
          break;
        }
      case R.id.plot:
        {
          if (m_popupMultiMedia != null && m_popupMultiMedia.isShowing()) {
            m_popupMultiMedia.dismiss();
          }

          mMapControl.submit();
          mMapControl.setAction(Action.SELECT);
          mMapControl.getMap().refresh();

          if (m_PlotTypePopup == null) {
            m_PlotTypePopup = new PlotTypePopup(mMapControl, btnPlot.getRootView(), this);
          }
          if (m_PlotTypePopup.isShowing()) {
            m_PlotTypePopup.dismiss();
            mMapControl.setAction(Action.SELECT);
          } else {
            m_PlotTypePopup.show(v);
          }

          break;
        }
      case R.id.text_message:
        {
          mMapControl.submit();
          mMapControl.setAction(Action.SELECT);
          mMapControl.getMap().refresh();

          if (m_popupMultiMedia != null && m_popupMultiMedia.isShowing()) {
            m_popupMultiMedia.dismiss();
          }
          if (m_PlotTypePopup != null && m_PlotTypePopup.isShowing()) {
            m_PlotTypePopup.dismiss();
          }
          if (!mMessageQueueOn) {
            MyApplication.getInstance().showInfo("请先打开消息开关!");
            break;
          }
          if (m_popupTextMessage == null) {
            m_popupTextMessage =
                new TextMessagePopup(btnTextMessage.getRootView(), getApplicationContext(), this);
          }

          if (m_popupTextMessage.isShowing()) {
            m_popupTextMessage.dismiss();
          } else {
            m_popupTextMessage.setFocusable(true);
            m_popupTextMessage.show();
          }
        }
        break;
      case R.id.send_message:
        {
          mMapControl.submit();
          mMapControl.setAction(Action.SELECT);
          mMapControl.getMap().refresh();

          if (m_popupMultiMedia != null && m_popupMultiMedia.isShowing()) {
            m_popupMultiMedia.dismiss();
          }
          if (m_PlotTypePopup != null && m_PlotTypePopup.isShowing()) {
            m_PlotTypePopup.dismiss();
          }
          if (!mMessageQueueOn) {
            MyApplication.getInstance().showInfo("请先打开消息开关!");
            break;
          }
          sendPlot();
        }
        break;
      case R.id.position_upload:
        {
          if (m_popupMultiMedia != null && m_popupMultiMedia.isShowing()) {
            m_popupMultiMedia.dismiss();
          }
          if (m_PlotTypePopup != null && m_PlotTypePopup.isShowing()) {
            m_PlotTypePopup.dismiss();
          }
          if (!mMessageQueueOn) {
            MyApplication.getInstance().showInfo("请先打开消息开关!");
            break;
          }
          m_StartPoint = m_TencentLocation.getGPSPoint();
          if ((m_StartPoint.getX() == 0) || (m_StartPoint.getY() == 0)) {
            MyApplication.getInstance().showInfo("现在无法定位,请稍后再试!");
            break;
          }
          // 导航纠偏
          m_StartPoint = m_Navigation.encryptGPS(m_StartPoint.getX(), m_StartPoint.getY());
          String json = m_StartPoint.toJson();
          String msg = "{content_type=0}" + json;
          boolean bOk = m_MessageQueue.sendMessageByType(msg, 0);
          if (bOk) {
            MyApplication.getInstance().showInfo("发送成功");
          } else {
            MyApplication.getInstance().showInfo("发送失败,请重新发送!");
          }
        }
        break;
      case R.id.delete:
        {
          if (m_layerSelected == null || m_IDSelected == -1) {
            break;
          }
          DatasetVector dataset = (DatasetVector) m_layerSelected.getDataset();
          if (dataset != null && dataset.getName().equalsIgnoreCase("CAD")) {
            QueryParameter parameter = new QueryParameter();
            parameter.setAttributeFilter("SmID=" + m_IDSelected);
            parameter.setCursorType(CursorType.DYNAMIC);
            Recordset recordset = dataset.query(parameter);
            recordset.moveFirst();
            if (!recordset.isEmpty()) {
              String strPlotID = (String) recordset.getFieldValue("PlotID");
              recordset.delete();
              recordset.update();
              String msg = "{content_type=5}";
              msg += "{delete:feildName=PlotID,feildValue=";
              msg += strPlotID;
              msg += "}";
              m_MessageQueue.sendMessageByRoutingKey(msg, "plot");
            }
            recordset.close();
            recordset.dispose();
          }
          mMapControl.getMap().refresh();
          mMapControl.setAction(Action.SELECT);
          m_IDSelected = -1;
          btnDelete.setVisibility(4);
          break;
        }
      case R.id.clear:
        {
          // 清空屏幕
          clearScreen();
          break;
        }
      default:
        {
          //			mMapControl.getMap().refresh();

        }
    }
  }