| | |
| | | import com.dayu.pipirrapp.net.BaseResponse; |
| | | import com.dayu.pipirrapp.net.subscribers.SubscriberListener; |
| | | import com.dayu.pipirrapp.utils.DateUtils; |
| | | import com.dayu.pipirrapp.utils.MyLog; |
| | | import com.tencent.bugly.crashreport.CrashReport; |
| | | |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | | import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers; |
| | | import io.reactivex.rxjava3.functions.Action; |
| | | import io.reactivex.rxjava3.functions.Consumer; |
| | | import io.reactivex.rxjava3.schedulers.Schedulers; |
| | | |
| | | /** |
| | |
| | | * @param fragment |
| | | * @return |
| | | */ |
| | | public static String getInspectionId(MapFragment fragment) { |
| | | public static void getInspectionId(MapFragment fragment) { |
| | | DaoSingleton.getAsynchInstance(fragment.getContext()).inspectionDao().getMostRecentInspectionWithNoStopTime() |
| | | .subscribeOn(Schedulers.io()) |
| | | .observeOn(Schedulers.io()).subscribe(inspectionBean -> { |
| | | |
| | | }); |
| | | return ""; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 继续显示异常关闭之前的巡检坐标 |
| | | * |
| | | * @param fragment |
| | | */ |
| | | public static void aginShowLocation(MapFragment fragment) { |
| | | //查询当前未关闭的巡检记录 |
| | | DaoSingleton.getAsynchInstance(fragment.getContext()).inspectionDao().getMostRecentInspectionWithNoStopTime() |
| | |
| | | .subscribe(strings -> { |
| | | //循环查询所有id |
| | | for (String data : strings) { |
| | | DaoSingleton.getAsynchInstance(context).inspectionDao().findBymInspectId(data) |
| | | .subscribeOn(Schedulers.io()) |
| | | .observeOn(Schedulers.io()) |
| | | .subscribe(inspectionBeans -> { |
| | | DaoSingleton.getAsynchInstance(context).inspectionLocationDao().findByNoPostAndInspectId(data) |
| | | .subscribeOn(Schedulers.io()) |
| | | .observeOn(Schedulers.io()) |
| | | .subscribe(inspectionLocationBeans -> { |
| | | postInspectionData(context, inspectionBeans, inspectionLocationBeans); |
| | | }); |
| | | }); |
| | | if (!TextUtils.isEmpty(data)) { |
| | | DaoSingleton.getAsynchInstance(context).inspectionDao().findBymInspectId(data) |
| | | .subscribeOn(Schedulers.io()) |
| | | .observeOn(Schedulers.io()) |
| | | .subscribe(inspectionBeans -> { |
| | | DaoSingleton.getAsynchInstance(context).inspectionLocationDao().findByNoPostAndInspectId(data) |
| | | .subscribeOn(Schedulers.io()) |
| | | .observeOn(Schedulers.io()) |
| | | .subscribe(inspectionLocationBeans -> { |
| | | if (inspectionLocationBeans != null && inspectionLocationBeans.size() > 0) { |
| | | postInspectionData(context, inspectionBeans, inspectionLocationBeans); |
| | | } |
| | | }); |
| | | }); |
| | | } |
| | | } |
| | | |
| | | }); |
| | |
| | | * @param inspectionLocationBeans |
| | | */ |
| | | private static void postInspectionData(Context context, InspectionBean inspectionBean, List<InspectionLocationBean> inspectionLocationBeans) { |
| | | MyLog.d("postInspectionData>>>上传未上传成功的数据"); |
| | | InspectionRequest inspectionRequest = new InspectionRequest(); |
| | | inspectionRequest.setInspectId(inspectionBean.getInspectId()); |
| | | inspectionRequest.setInspectorId(inspectionBean.getInspectorId()); |
| | |
| | | public void onNext(BaseResponse<List<InsectionResult>> t) { |
| | | try { |
| | | if (t.isSuccess()) { |
| | | MyLog.d("postInspectionData>>>上传未上传成功的数据》》》》成功"); |
| | | if (t.getContent() != null) { |
| | | inspectionBean.setInspectId(String.valueOf(t.getContent().get(0).getInspectId())); |
| | | InspectionUtils.upataInspectionData(context, inspectionBean); |
| | | } |
| | | DaoSingleton.getAsynchInstance(context).inspectionLocationDao().updataByInspectIdSetIsPost(inspectionBean.getmInspectId()).subscribeOn(Schedulers.io()).observeOn(Schedulers.io()).subscribe(() -> { |
| | | // 插入成功的回调 |
| | | Log.d(TAG, "addInspectionLocationData数据插入成功"); |
| | | Log.d(TAG, "updataByInspectIdSetIsPost数据插入成功"); |
| | | }, throwable -> { |
| | | // 处理错误 |
| | | Log.e(TAG, "addInspectionLocationData数据插入失败", throwable); |
| | | Log.e(TAG, "updataByInspectIdSetIsPost数据插入失败", throwable); |
| | | }); |
| | | } else { |
| | | |
| | | MyLog.d("postInspectionData>>>上传未上传成功的数据》》》》失败"); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | inspectionLocationBean.setmInspectId(mInspectionBean.getmInspectId()); |
| | | inspectionLocationBean.setLocateTime(DateUtils.getNowDateStr()); |
| | | inspectionLocationBean.setPost(false); |
| | | |
| | | inspectionLocationBean.setLng(String.valueOf(latLonBean.getLongitude())); |
| | | inspectionLocationBean.setLat(String.valueOf(latLonBean.getLatitude())); |
| | | return inspectionLocationBean; |