Browse Source

1.修改运输轨迹。

石慧云 4 năm trước cách đây
mục cha
commit
c499d78141

+ 1 - 0
app/src/main/java/com/quansu/heifengwuliu/activity/WaybillDetailsActivity.kt

@@ -162,6 +162,7 @@ class WaybillDetailsActivity : MBActivity<WaybillDetailsVModel, ActivityWaybilld
             list.add(item)
         }
 
+
         var isShow=false
         if(!TextUtils.isEmpty(list[0].latitude)&&!TextUtils.isEmpty(list[list.size-1].latitude)){
             isShow=true

+ 2 - 2
app/src/main/java/com/quansu/heifengwuliu/config/Config.kt

@@ -7,8 +7,8 @@ class Config : IConfig {
       // return "https://heifengwuliu.qs110.com/"
      // return "https://heifengwuliudev.qs110.com/"
 
-   //   return "https://xinyunbida.qs110.com/"
-       return "https://xinyunbidadev.qs110.com/"
+      return "https://xinyunbida.qs110.com/"
+     //  return "https://xinyunbidadev.qs110.com/"
 
     }
 

+ 10 - 11
app/src/main/java/com/quansu/heifengwuliu/vmodel/WaybillDetailsVModel.kt

@@ -261,14 +261,13 @@ open class WaybillDetailsVModel(application: Application) : BViewModel<BReposito
 
                 var list = ArrayList<PositionBean>()
 
-                var positionName =   info.value!!.info.send[0].province.name+info.value!!.info.send[0].city.name+info.value!!.info.send[0].area.name
+                var positionName =   info.value!!.info.send[0].province.name+info.value!!.info.send[0].city.name+info.value!!.info.send[0].area.name+info.value!!.info.send[0].address
 
-
-                var item = PositionBean(positionName, info.value!!.info.receive[info.value!!.info.receive.size - 1].lat, info.value!!.info.receive[info.value!!.info.receive.size - 1].lng)
+                var item = PositionBean(positionName, info.value!!.info.send[info.value!!.info.send.size - 1].lat, info.value!!.info.send[info.value!!.info.send.size - 1].lng)
 
                 list.add(item)
-                for(ss in info.value!!.info.send){
-                    var positionName = ss.province.name +ss.city.name + ss.city.name
+                for(ss in info.value!!.info.receive){
+                    var positionName = ss.province.name +ss.city.name + ss.city.name+ss.address
 
                     var item = PositionBean(positionName, ss.lat, ss.lng)
                     list.add(item)
@@ -301,9 +300,9 @@ open class WaybillDetailsVModel(application: Application) : BViewModel<BReposito
 
                 UiSwitch.bundleRes(repository().context as Activity, EvaluateActivity::class.java, Bundle().apply {
                     putString("order_id", order_id)
-                    putString("url", info.value!!.driver.avatar)
-                    putString("sn", info.value!!.order.order_sn)
-                    putString("time", info.value!!.order.create_time)
+                    putString("url", info.value?.driver?.avatar)
+                    putString("sn", info.value?.order?.order_sn)
+                    putString("time", info.value?.order?.create_time)
                 }, MIntentAction.REQUEST_CODE_COMMENT)
 
 
@@ -349,9 +348,9 @@ open class WaybillDetailsVModel(application: Application) : BViewModel<BReposito
 
                 UiSwitch.bundleRes(repository().context as Activity, EvaluateActivity::class.java, Bundle().apply {
                     putString("order_id", order_id)
-                    putString("url", info.value!!.company.avatar)
-                    putString("sn", info.value!!.order.order_sn)
-                    putString("time", info.value!!.order.create_time)
+                    putString("url", info.value?.company?.avatar)
+                    putString("sn", info.value?.order?.order_sn)
+                    putString("time", info.value?.order?.create_time)
                 }, MIntentAction.REQUEST_CODE_COMMENT)
 
 

+ 76 - 78
gaode/src/main/java/com/quansu/gaode/activity/PolylineActivity.java

@@ -13,6 +13,7 @@ import android.widget.Toast;
 
 import androidx.annotation.Nullable;
 import androidx.appcompat.app.AppCompatActivity;
+
 import com.amap.api.maps.AMap;
 import com.amap.api.maps.CameraUpdateFactory;
 import com.amap.api.maps.MapView;
@@ -55,7 +56,7 @@ import java.util.List;
  * Created by shihuiyun
  * on 2020/10/15
  */
-public class PolylineActivity extends AppCompatActivity  {
+public class PolylineActivity extends AppCompatActivity {
     private AMap aMap;
     private MapView mapView;
 
@@ -65,9 +66,6 @@ public class PolylineActivity extends AppCompatActivity  {
     private MapView mapThree;
 
 
-
-
-
     private ImageView imgBack;
     private TextView tvStart;
     private TextView tvEnd;
@@ -80,7 +78,6 @@ public class PolylineActivity extends AppCompatActivity  {
     private List<PositionBean> item;
 
 
-
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         StatusBarCompat.setStatusBarColor(this, Color.parseColor("#00ffffff"));
@@ -88,11 +85,11 @@ public class PolylineActivity extends AppCompatActivity  {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.map_layout);
 
-         item = new Gson().fromJson(getIntent().getStringExtra("item"), new TypeToken<List<PositionBean>>() {
+        item = new Gson().fromJson(getIntent().getStringExtra("item"), new TypeToken<List<PositionBean>>() {
         }.getType());
 
 
-        Log.e("-shy-", "item=: "+item.size() );
+        Log.e("-shy-", "item=: " + item.size());
 
 
         imgBack = findViewById(R.id.img_back);
@@ -104,7 +101,7 @@ public class PolylineActivity extends AppCompatActivity  {
         butTwo = findViewById(R.id.but_two);
         butThree = findViewById(R.id.but_three);
         tvStart.setText(item.get(0).position);
-        tvEnd.setText(item.get(item.size()-1).position);
+        tvEnd.setText(item.get(item.size() - 1).position);
 
 
         imgBack.setOnClickListener(v -> {
@@ -120,7 +117,7 @@ public class PolylineActivity extends AppCompatActivity  {
 
 
         butOne.setOnClickListener(view -> {
-            Toast.makeText(this,"切换路线一",Toast.LENGTH_SHORT).show();
+            Toast.makeText(this, "切换路线一", Toast.LENGTH_SHORT).show();
 
             mapView.setVisibility(View.VISIBLE);
             mapTwo.setVisibility(View.GONE);
@@ -129,13 +126,13 @@ public class PolylineActivity extends AppCompatActivity  {
         });
 
         butTwo.setOnClickListener(view -> {
-            Toast.makeText(this,"切换路线二",Toast.LENGTH_SHORT).show();
+            Toast.makeText(this, "切换路线二", Toast.LENGTH_SHORT).show();
             mapTwo.setVisibility(View.VISIBLE);
             mapThree.setVisibility(View.GONE);
             mapView.setVisibility(View.GONE);
         });
         butThree.setOnClickListener(view -> {
-            Toast.makeText(this,"切换路线三",Toast.LENGTH_SHORT).show();
+            Toast.makeText(this, "切换路线三", Toast.LENGTH_SHORT).show();
 
             mapTwo.setVisibility(View.GONE);
             mapThree.setVisibility(View.VISIBLE);
@@ -148,38 +145,36 @@ public class PolylineActivity extends AppCompatActivity  {
     }
 
 
-
-
     //获取路线 多条 三条或者一条
-    protected  List<NaviLatLng> navOne = new ArrayList<NaviLatLng>();
-    protected  List<NaviLatLng> navTwo = new ArrayList<NaviLatLng>();
-    protected  List<NaviLatLng> navThree = new ArrayList<NaviLatLng>();
+    protected List<NaviLatLng> navOne = new ArrayList<NaviLatLng>();
+    protected List<NaviLatLng> navTwo = new ArrayList<NaviLatLng>();
+    protected List<NaviLatLng> navThree = new ArrayList<NaviLatLng>();
 
-    public void  setShow(){
+    public void setShow() {
 
 
-        if(navOne.size()>0){
+        if (navOne.size() > 0) {
             llBottom.setVisibility(View.VISIBLE);
             butOne.setVisibility(View.VISIBLE);
-            list= getshowList(navOne);
+            list = getshowList(navOne);
             init();
 
         }
-        if(navTwo.size()>0){
+        if (navTwo.size() > 0) {
             butTwo.setVisibility(View.VISIBLE);
-            list= getshowList(navTwo);
+            list = getshowList(navTwo);
             initTwo();
         }
-        if(navThree.size()>0){
+        if (navThree.size() > 0) {
             butThree.setVisibility(View.VISIBLE);
-            list= getshowList(navThree);
+            list = getshowList(navThree);
             initThree();
         }
 
-        Log.e("-shy-", "navOne="+navOne.size());
-        Log.e("-shy-", "navTwo="+navTwo.size());
-        Log.e("-shy-", "navThree="+navThree.size());
-        if(navOne.size()==0&&navTwo.size()==0&&navThree.size()==0){
+        Log.e("-shy-", "navOne=" + navOne.size());
+        Log.e("-shy-", "navTwo=" + navTwo.size());
+        Log.e("-shy-", "navThree=" + navThree.size());
+        if (navOne.size() == 0 && navTwo.size() == 0 && navThree.size() == 0) {
             list = showListLat(item);
             init();
         }
@@ -187,24 +182,24 @@ public class PolylineActivity extends AppCompatActivity  {
     }
 
 
-    public void  getRoute(){
+    public void getRoute() {
 
         // 获取导航Manager
         AMapNavi mAMapNavi = AMapNavi.getInstance(this);
         // 起点信息
         List<NaviLatLng> startList = new ArrayList<NaviLatLng>();
-        startList.add(new NaviLatLng(Double.parseDouble(item.get(0).latitude),Double.parseDouble(item.get(0).longitude)));
+        startList.add(new NaviLatLng(Double.parseDouble(item.get(0).latitude), Double.parseDouble(item.get(0).longitude)));
         // 终点信息
         List<NaviLatLng> endList = new ArrayList<NaviLatLng>();
-        endList.add(new NaviLatLng(Double.parseDouble(item.get(item.size()-1).latitude),Double.parseDouble(item.get(item.size()-1).longitude)));
+        endList.add(new NaviLatLng(Double.parseDouble(item.get(item.size() - 1).latitude), Double.parseDouble(item.get(item.size() - 1).longitude)));
 
         //中间停靠点
         List<NaviLatLng> centerList = null;
-        if(item.size()>2) {
-            centerList=new ArrayList<NaviLatLng>();
-            int i=0;
+        if (item.size() > 2) {
+            centerList = new ArrayList<NaviLatLng>();
+            int i = 0;
             for (PositionBean ss : item) {
-                if(i>0||i<item.size()-1) {
+                if (i > 0 || i < item.size() - 1) {
                     if (!TextUtils.isEmpty(ss.latitude) && !TextUtils.isEmpty(ss.longitude)) {
                         centerList.add(new NaviLatLng(Double.parseDouble(ss.latitude), Double.parseDouble(ss.longitude)));
                     }
@@ -212,7 +207,7 @@ public class PolylineActivity extends AppCompatActivity  {
                 i++;
             }
         }
-       // 经纬度算路
+        // 经纬度算路
         mAMapNavi.calculateDriveRoute(startList, endList, centerList,
                 PathPlanningStrategy.DRIVING_MULTIPLE_ROUTES_DEFAULT);
 
@@ -221,27 +216,33 @@ public class PolylineActivity extends AppCompatActivity  {
             @Override
             public void onCalculateRouteSuccess(AMapCalcRouteResult aMapCalcRouteResult) {
 
-                // 获取路线数据对象
-                HashMap<Integer, AMapNaviPath> naviPaths =mAMapNavi.getNaviPaths();
-                // 绘制显示路径 遍历值
-                int i=0;
-                for (AMapNaviPath value : naviPaths.values()) {
-                    if(i==0){
-                        navOne.addAll(value.getCoordList());
+                try {
+
+                    // 获取路线数据对象
+                    HashMap<Integer, AMapNaviPath> naviPaths = mAMapNavi.getNaviPaths();
+                    // 绘制显示路径 遍历值
+                    int i = 0;
+                    for (AMapNaviPath value : naviPaths.values()) {
+                        if (i == 0) {
+                            navOne.addAll(value.getCoordList());
+                        }
+                        if (i == 1) {
+                            navTwo.addAll(value.getCoordList());
+
+                        }
+                        if (i == 2) {
+                            navThree.addAll(value.getCoordList());
+                        }
+                        i++;
                     }
-                    if(i==1){
-                        navTwo.addAll(value.getCoordList());
+                } catch (Exception e) {
 
-                    }
-                    if(i==2){
-                        navThree.addAll(value.getCoordList());
-                    }
-                    i++;
                 }
 
                 setShow();
 
             }
+
             @Override
             public void onInitNaviFailure() {
 
@@ -421,7 +422,6 @@ public class PolylineActivity extends AppCompatActivity  {
     }
 
 
-
     /**
      * 初始化AMap对象
      */
@@ -447,24 +447,24 @@ public class PolylineActivity extends AppCompatActivity  {
                 //线的宽度
                 .width(30).setDottedLine(true).geodesic(true)
                 //颜色
-                .color(Color.argb(255,255,20,147)));
+                .color(Color.argb(255, 255, 20, 147)));
 
 
-        if(TextUtils.isEmpty(item.get(0).latitude)||TextUtils.isEmpty(item.get(item.size()-1).latitude)){
+        if (TextUtils.isEmpty(item.get(0).latitude) || TextUtils.isEmpty(item.get(item.size() - 1).latitude)) {
             return;
         }
-        LatLonPoint latLonPoint = new LatLonPoint(Double.parseDouble(item.get(0).latitude),Double.parseDouble(item.get(0).longitude));
+        LatLonPoint latLonPoint = new LatLonPoint(Double.parseDouble(item.get(0).latitude), Double.parseDouble(item.get(0).longitude));
 
         //起点图标
-        View markerView = LayoutInflater.from(this).inflate(R.layout.gaode_start_marker,mapView,false);
+        View markerView = LayoutInflater.from(this).inflate(R.layout.gaode_start_marker, mapView, false);
         aMap.addMarker(new MarkerOptions()
                 .position(AMapUtil.convertToLatLng(latLonPoint))
                 .icon(BitmapDescriptorFactory.fromView(markerView)));
 
         //终点坐标
-        View markerEndView = LayoutInflater.from(this).inflate(R.layout.gaode_end_marker,mapView,false);
+        View markerEndView = LayoutInflater.from(this).inflate(R.layout.gaode_end_marker, mapView, false);
 
-        LatLonPoint latLonPointEnd = new LatLonPoint(Double.parseDouble(item.get(item.size()-1).latitude),Double.parseDouble(item.get(item.size()-1).longitude));
+        LatLonPoint latLonPointEnd = new LatLonPoint(Double.parseDouble(item.get(item.size() - 1).latitude), Double.parseDouble(item.get(item.size() - 1).longitude));
         aMap.addMarker(new MarkerOptions()
                 .position(AMapUtil.convertToLatLng(latLonPointEnd))
                 .icon(BitmapDescriptorFactory.fromView(markerEndView)));
@@ -492,24 +492,24 @@ public class PolylineActivity extends AppCompatActivity  {
                 //线的宽度
                 .width(30).setDottedLine(true).geodesic(true)
                 //颜色
-                .color(Color.argb(255,255,20,147)));
+                .color(Color.argb(255, 255, 20, 147)));
 
 
-        if(TextUtils.isEmpty(item.get(0).latitude)||TextUtils.isEmpty(item.get(item.size()-1).latitude)){
+        if (TextUtils.isEmpty(item.get(0).latitude) || TextUtils.isEmpty(item.get(item.size() - 1).latitude)) {
             return;
         }
-        LatLonPoint latLonPoint = new LatLonPoint(Double.parseDouble(item.get(0).latitude),Double.parseDouble(item.get(0).longitude));
+        LatLonPoint latLonPoint = new LatLonPoint(Double.parseDouble(item.get(0).latitude), Double.parseDouble(item.get(0).longitude));
 
         //起点图标
-        View markerView = LayoutInflater.from(this).inflate(R.layout.gaode_start_marker,mapView,false);
+        View markerView = LayoutInflater.from(this).inflate(R.layout.gaode_start_marker, mapView, false);
         aMapTwo.addMarker(new MarkerOptions()
                 .position(AMapUtil.convertToLatLng(latLonPoint))
                 .icon(BitmapDescriptorFactory.fromView(markerView)));
 
         //终点坐标
-        View markerEndView = LayoutInflater.from(this).inflate(R.layout.gaode_end_marker,mapView,false);
+        View markerEndView = LayoutInflater.from(this).inflate(R.layout.gaode_end_marker, mapView, false);
 
-        LatLonPoint latLonPointEnd = new LatLonPoint(Double.parseDouble(item.get(item.size()-1).latitude),Double.parseDouble(item.get(item.size()-1).longitude));
+        LatLonPoint latLonPointEnd = new LatLonPoint(Double.parseDouble(item.get(item.size() - 1).latitude), Double.parseDouble(item.get(item.size() - 1).longitude));
         aMapTwo.addMarker(new MarkerOptions()
                 .position(AMapUtil.convertToLatLng(latLonPointEnd))
                 .icon(BitmapDescriptorFactory.fromView(markerEndView)));
@@ -537,33 +537,30 @@ public class PolylineActivity extends AppCompatActivity  {
                 //线的宽度
                 .width(30).setDottedLine(true).geodesic(true)
                 //颜色
-                .color(Color.argb(255,255,20,147)));
+                .color(Color.argb(255, 255, 20, 147)));
 
 
-        if(TextUtils.isEmpty(item.get(0).latitude)||TextUtils.isEmpty(item.get(item.size()-1).latitude)){
+        if (TextUtils.isEmpty(item.get(0).latitude) || TextUtils.isEmpty(item.get(item.size() - 1).latitude)) {
             return;
         }
-        LatLonPoint latLonPoint = new LatLonPoint(Double.parseDouble(item.get(0).latitude),Double.parseDouble(item.get(0).longitude));
+        LatLonPoint latLonPoint = new LatLonPoint(Double.parseDouble(item.get(0).latitude), Double.parseDouble(item.get(0).longitude));
 
         //起点图标
-        View markerView = LayoutInflater.from(this).inflate(R.layout.gaode_start_marker,mapView,false);
+        View markerView = LayoutInflater.from(this).inflate(R.layout.gaode_start_marker, mapView, false);
         aMapThree.addMarker(new MarkerOptions()
                 .position(AMapUtil.convertToLatLng(latLonPoint))
                 .icon(BitmapDescriptorFactory.fromView(markerView)));
 
         //终点坐标
-        View markerEndView = LayoutInflater.from(this).inflate(R.layout.gaode_end_marker,mapView,false);
+        View markerEndView = LayoutInflater.from(this).inflate(R.layout.gaode_end_marker, mapView, false);
 
-        LatLonPoint latLonPointEnd = new LatLonPoint(Double.parseDouble(item.get(item.size()-1).latitude),Double.parseDouble(item.get(item.size()-1).longitude));
+        LatLonPoint latLonPointEnd = new LatLonPoint(Double.parseDouble(item.get(item.size() - 1).latitude), Double.parseDouble(item.get(item.size() - 1).longitude));
         aMapThree.addMarker(new MarkerOptions()
                 .position(AMapUtil.convertToLatLng(latLonPointEnd))
                 .icon(BitmapDescriptorFactory.fromView(markerEndView)));
     }
 
 
-
-
-
     /**
      * 方法必须重写
      */
@@ -581,6 +578,7 @@ public class PolylineActivity extends AppCompatActivity  {
         super.onPause();
         mapView.onPause();
     }
+
     /**
      * 方法必须重写
      */
@@ -598,17 +596,18 @@ public class PolylineActivity extends AppCompatActivity  {
         super.onDestroy();
         mapView.onDestroy();
     }
+
     /***
      *经纬度集合
      */
-    private List<LatLng> showListLat(List<PositionBean> item){
+    private List<LatLng> showListLat(List<PositionBean> item) {
 
 
         List<LatLng> points = new ArrayList<LatLng>();
 
-        for(PositionBean ss:item){
-            if(!TextUtils.isEmpty(ss.latitude)&&!TextUtils.isEmpty(ss.longitude)) {
-                Log.e("-shy-", "latitude=: "+ss.latitude+"//longitude="+ss.longitude );
+        for (PositionBean ss : item) {
+            if (!TextUtils.isEmpty(ss.latitude) && !TextUtils.isEmpty(ss.longitude)) {
+                Log.e("-shy-", "latitude=: " + ss.latitude + "//longitude=" + ss.longitude);
                 points.add(new LatLng(Double.parseDouble(ss.latitude), Double.parseDouble(ss.longitude)));
             }
         }
@@ -616,11 +615,11 @@ public class PolylineActivity extends AppCompatActivity  {
     }
 
 
-    public  List<LatLng>  getshowList( List<NaviLatLng> list){
+    public List<LatLng> getshowList(List<NaviLatLng> list) {
 
         List<LatLng> points = new ArrayList<LatLng>();
 
-        for(NaviLatLng ss:list){
+        for (NaviLatLng ss : list) {
             points.add(new LatLng(ss.getLatitude(), ss.getLongitude()));
         }
 
@@ -629,5 +628,4 @@ public class PolylineActivity extends AppCompatActivity  {
     }
 
 
-
 }