diff --git a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/bean/NewLjBean.kt b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/bean/NewLjBean.kt index 92d400d..125c7a4 100644 --- a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/bean/NewLjBean.kt +++ b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/bean/NewLjBean.kt @@ -22,27 +22,34 @@ data class PickupBean( data class GDLocation( var baiduLongitude: Double = 0.0, var baiduLatitude: Double = 0.0, - var location: String, - var time: String, - var altitude: Double = 0.0, - var speed: Float = 0f, - var direction: Float = 0f, - var interval: Int = 0 + var location: String = "", + var time: String = "" ) -data class UpimgBean(var shipmentCode: String="", var enterpriseCode: String="", var image: GDImage? = null) +data class UpimgBean( + var shipmentCode: String = "", + var enterpriseCode: String = "", + var image: GDImage? = null +) data class GDImage( - var fileName: String, var fileData: String, var fileExt: String, var imageTakenDate: String + var fileName: String = "", + var fileData: String = "", + var fileExt: String = "", + var imageTakenDate: String = "", + var baiduLongitude: Double = 0.0, + var baiduLatitude: Double = 0.0, + var location: String = "", + var time: String = "" ) data class InvoiceBean( - var driverIdentification: String="", - var driverInvoiceCode: String="", - var enterpriseCode: String="" + var driverIdentification: String = "", + var driverInvoiceCode: String = "", + var enterpriseCode: String = "" ) -data class ShipmentStatusBean(var shipmentCode: String="", var enterpriseCode: String="") +data class ShipmentStatusBean(var shipmentCode: String = "", var enterpriseCode: String = "") data class InvoicesBean( diff --git a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/waybill/activity/WaybillUpPicActivity.kt b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/waybill/activity/WaybillUpPicActivity.kt index 7cee06a..b2a2ce6 100644 --- a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/waybill/activity/WaybillUpPicActivity.kt +++ b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/waybill/activity/WaybillUpPicActivity.kt @@ -3,14 +3,17 @@ package com.arpa.hndahesudintocctmsdriver.ui.waybill.activity import android.os.Bundle import android.util.Log import android.view.View -import android.widget.Toast import androidx.recyclerview.widget.GridLayoutManager import com.amap.api.maps.model.LatLng import com.arpa.hndahesudintocctmsdriver.base.AppConfig +import com.arpa.hndahesudintocctmsdriver.bean.GDImage +import com.arpa.hndahesudintocctmsdriver.bean.GDLocation import com.arpa.hndahesudintocctmsdriver.bean.LUInputBean import com.arpa.hndahesudintocctmsdriver.bean.OrderDetailBean import com.arpa.hndahesudintocctmsdriver.bean.UpPicBean import com.arpa.hndahesudintocctmsdriver.bean.WaybillPhoto +import com.arpa.hndahesudintocctmsdriver.callback.OnGDDownloadResultListener +import com.arpa.hndahesudintocctmsdriver.callback.OnGDResultListener import com.arpa.hndahesudintocctmsdriver.databinding.ActivityWaybillUppicBinding import com.arpa.hndahesudintocctmsdriver.net.BaseObserver import com.arpa.hndahesudintocctmsdriver.net.DataManager @@ -18,6 +21,7 @@ import com.arpa.hndahesudintocctmsdriver.net.RxHttpCallBack import com.arpa.hndahesudintocctmsdriver.oss.OssServiceUtil import com.arpa.hndahesudintocctmsdriver.third.JTTProcess import com.arpa.hndahesudintocctmsdriver.utils.GDLocationUtils +import com.arpa.hndahesudintocctmsdriver.utils.NewLJUtils import com.arpa.hndahesudintocctmsdriver.utils.OcrUtils import com.arpa.hndahesudintocctmsdriver.utils.OrderUtils import com.arpa.mylibrary.adapter.GridImageAdapter @@ -120,14 +124,15 @@ class WaybillUpPicActivity : BaseActivity() { ) var myAdapter = GridImageAdapter(mContext, mData) - myAdapter.selectMax = if (type==2) 6 else 1 + myAdapter.selectMax = if (type == 2) 6 else 1 myAdapter.setOnItemClickListener(object : OnItemClickListener { override fun onItemClick(v: View?, position: Int) { PopsUtils.getInstance() - .showSelPic(mContext, if (type==2) 6 else 1, true, myAdapter) { it -> - OssServiceUtil.getInstance().asyncPutImages(it.map { it.availablePath },this@WaybillUpPicActivity + .showSelPic(mContext, if (type == 2) 6 else 1, true, myAdapter) { it -> + OssServiceUtil.getInstance().asyncPutImages( + it.map { it.availablePath }, this@WaybillUpPicActivity ) { success, failure -> - upBean.waybillPhotoList.removeAll { it.type=="3" } + upBean.waybillPhotoList.removeAll { it.type == "3" } success.forEachIndexed { index, s -> picBean = WaybillPhoto() picBean.run { @@ -152,10 +157,11 @@ class WaybillUpPicActivity : BaseActivity() { override fun openPicture() { PopsUtils.getInstance() - .showSelPic(mContext, if (type==2) 6 else 1, true, myAdapter) { it -> - OssServiceUtil.getInstance().asyncPutImages(it.map { it.availablePath },this@WaybillUpPicActivity + .showSelPic(mContext, if (type == 2) 6 else 1, true, myAdapter) { it -> + OssServiceUtil.getInstance().asyncPutImages( + it.map { it.availablePath }, this@WaybillUpPicActivity ) { success, failure -> - upBean.waybillPhotoList.removeAll { it.type=="3" } + upBean.waybillPhotoList.removeAll { it.type == "3" } success.forEachIndexed { index, s -> picBean = WaybillPhoto() picBean.run { @@ -258,7 +264,7 @@ class WaybillUpPicActivity : BaseActivity() { return } - var dis = + val dis = TimeUtil.compareNowDate(TimeUtil.string2Millis(orderBean.waybillInfo.loadTime)) if (dis <= 5) { //大于五分钟可以接单 ToastUtils.showToast(this@WaybillUpPicActivity, "请到卸货地再进行卸货操作!") @@ -266,47 +272,85 @@ class WaybillUpPicActivity : BaseActivity() { } } -// val l = Location() -// l.baiduLongitude = bdLatLng.longitude -// l.baiduLatitude = bdLatLng.latitude -// l.location = binding.tvLoca.text.toString() -// l.time = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(Date()) - -// if (orderType == 1) {//装货 -// load(l) -// } else {//卸货 -// unLoad(l) -// } - - -// DataManager.getInstance().driverLoadOrUnload(upBean) -// .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()) -// .subscribe(BaseObserver(mContext, object : RxHttpCallBack() { -// override fun onSuccess(t: CommonResponseBean) { -// super.onSuccess(t) -// if (1 == orderType) { -// ActivityUtils.startActivity( -// mContext, -// WaybillSuccActivity::class.java, -// intent.extras -// ) -// //装货成功-开启轨迹上传 -// OrderUtils.getInstance().upLocation(mContext) -// } else { -// OrderUtils.getInstance().stopUpLocation(mContext) -// ActivityUtils.startActivity( -// mContext, -// WaybillSuccActivity::class.java, -// intent.extras -// ) -// } -// } -// })) - + val l = GDLocation().apply { + baiduLongitude = bdLatLng.longitude + baiduLatitude = bdLatLng.latitude + location = binding.tvLoca.text.toString() + time = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(Date()) + } + if (orderType == 1) {//装货 + load(l) + } else {//卸货 + unLoad(l) + } } -// private fun load(location: Location) { + private fun load(location: GDLocation) { + NewLJUtils.getInstance() + .getShipmentStatus(mContext, orderBean.orderNum, object : OnGDDownloadResultListener { + override fun onSuccess(var1: String) { + if (var1 == "30") { + Log.e("上报安联", "装货上传成功") +// //上传安联和交通厅,平台-装货 +// //交通厅 + if (orderBean.report === "1") { + JTTProcess.start(mContext, orderBean, "") + } + + upLoadImage() + + DataManager.getInstance().driverLoadOrUnload(upBean) + .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()) + .subscribe(BaseObserver(mContext, object : RxHttpCallBack() { + override fun onSuccess(t: CommonResponseBean) { + super.onSuccess(t) + //装货成功-开启轨迹上传 + OrderUtils.getInstance().upLocation(mContext) + } + })) + } else { + NewLJUtils.getInstance() + .pickUp(mContext, orderBean.orderNum, location, object : + OnGDResultListener { + override fun onSuccess() { + Log.e("上报安联", "装货上传成功") + + //上传安联和交通厅,平台-装货 + //交通厅 + if (orderBean.report === "1") { + JTTProcess.start(mContext, orderBean, "") + } + upLoadImage() + DataManager.getInstance().driverLoadOrUnload(upBean) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe( + BaseObserver( + mContext, + object : RxHttpCallBack() { + override fun onSuccess(t: CommonResponseBean) { + super.onSuccess(t) + //装货成功-开启轨迹上传 + OrderUtils.getInstance() + .upLocation(mContext) + } + }) + ) + } + + override fun onFailure(code: String, message: String) { + ToastUtils.showToast(mContext, """${code},${message}""") + } + }) + } + } + + override fun onFailure(code: String, message: String) { + ToastUtils.showToast(mContext, """${code},${message}""") + } + }) + // MDPLocationCollectionManager.pickup( // mContext, // orderBean.orderNum, @@ -340,10 +384,43 @@ class WaybillUpPicActivity : BaseActivity() { // ToastUtils.showToast(mContext, """${p1},${p0}""") // } // }) -// } -// -// private fun unLoad(location: Location) { -// showLoading() + } + + private fun unLoad(location: GDLocation) { + showLoading() + NewLJUtils.getInstance() + .unload(mContext, orderBean.orderNum, location, object : OnGDResultListener { + override fun onSuccess() { + Log.e("上报安联", "卸货上传成功") + // 交通厅 + if (orderBean.report === "1") { + JTTProcess.stop(mContext, orderBean, "") + } + //卸货状态-平台 +// hyr.dischargeCargo(lub) + //卸货照片-安联 + upUnloadImage() + + //卸货回单 + upTrafficSign(location) + upTrafficReceipt(location) + receiptImage() + + //todo 平台更换运单状态 暂时注释 + DataManager.getInstance().driverLoadOrUnload(upBean) + .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()) + .subscribe(BaseObserver(mContext, object : RxHttpCallBack() { + override fun onSuccess(t: CommonResponseBean) { + super.onSuccess(t) + + } + })) + } + + override fun onFailure(code: String, message: String) { + Log.e("上报安联失败(卸货):", code + message) + } + }) // MDPLocationCollectionManager.unload(mContext, orderBean.orderNum, location, // object : OnResultListener { // override fun onSuccess() { @@ -379,24 +456,44 @@ class WaybillUpPicActivity : BaseActivity() { //// MessageUtils().showCenMessage(con, s1) // } // }) -// } + } //上传安联装货 -// fun upLoadImage() { -// ///storage/emulated/0/Android/data/com.oneclouds.wangluohuoyun/files/Pictures/163124593063154.jpg -// -// var photoPaht = upBean.waybillPhotoList.find { it.type == "1" }?.localPhotoUrl -// val file = File(photoPaht) -// val image = Image() -// val base: String = BitmapUtil.imageToBase64(photoPaht) -// image.fileData = "data:image/" + FileUtil.lastName(file) + ";base64," + base -// image.fileExt = FileUtil.lastName(file) -// image.fileName = FileUtil.fileName(file) -// image.imageTakenDate = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(Date()) -// image.baiduLongitude = bdLatLng.longitude -// image.baiduLatitude = bdLatLng.latitude -// image.location = binding.tvLoca.text.toString() + fun upLoadImage() { + ///storage/emulated/0/Android/data/com.oneclouds.wangluohuoyun/files/Pictures/163124593063154.jpg + + var photoPaht = upBean.waybillPhotoList.find { it.type == "1" }?.localPhotoUrl + val base: String = BitmapUtil.imageToBase64(photoPaht) + val file = File(photoPaht) + val image = GDImage().apply { + fileData = "data:image/" + FileUtil.lastName(file) + ";base64," + base + fileExt = FileUtil.lastName(file) + fileName = FileUtil.fileName(file) + imageTakenDate = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(Date()) + time = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(Date()) + baiduLongitude = bdLatLng.longitude + baiduLatitude = bdLatLng.latitude + location = binding.tvLoca.text.toString() + } + + NewLJUtils.getInstance() + .uploadPickupImage(mContext, orderBean.orderNum, image, object : OnGDResultListener { + override fun onSuccess() { + Log.e("上报安联", "装货照片上传成功") + ToastUtils.showToast(mContext, "上传成功") + ActivityUtils.startActivity( + mContext, + WaybillSuccActivity::class.java, + intent.extras + ) + } + + override fun onFailure(code: String, message: String) { + Log.e("上报安联失败(装货照片):", code + message) + } + }) + // MDPLocationCollectionManager.uploadPickupImage( // mContext, // orderBean.orderNum, @@ -416,21 +513,35 @@ class WaybillUpPicActivity : BaseActivity() { // Log.e("上报安联失败(装货照片):", s + s1) // } // }) -// } + } //上传安联卸货 -// fun upUnloadImage() { -// var photoPaht = upBean.waybillPhotoList.find { it.type == "2" }?.localPhotoUrl -// val file = File(photoPaht) -// val image = Image() -// val base = BitmapUtil.imageToBase64(photoPaht) -// image.fileData = "data:image/" + FileUtil.lastName(file) + ";base64," + base -// image.fileExt = FileUtil.lastName(file) -// image.fileName = FileUtil.fileName(file) -// image.imageTakenDate = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(Date()) -// image.baiduLongitude = bdLatLng.longitude -// image.baiduLatitude = bdLatLng.latitude -// image.location = binding.tvLoca.text.toString() + fun upUnloadImage() { + var photoPaht = upBean.waybillPhotoList.find { it.type == "2" }?.localPhotoUrl + val file = File(photoPaht) + val base = BitmapUtil.imageToBase64(photoPaht) + val image = GDImage().apply { + fileData = "data:image/" + FileUtil.lastName(file) + ";base64," + base + fileExt = FileUtil.lastName(file) + fileName = FileUtil.fileName(file) + imageTakenDate = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(Date()) + baiduLongitude = bdLatLng.longitude + baiduLatitude = bdLatLng.latitude + location = binding.tvLoca.text.toString() + time = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(Date()) + } + + NewLJUtils.getInstance() + .uploadUnloadImage(mContext, orderBean.orderNum, image, object : OnGDResultListener { + override fun onSuccess() { + Log.e("上报安联", "卸货照片上传成功") + } + + override fun onFailure(code: String, message: String) { + Log.e("上报安联失败(卸货照片):", code + message) + } + }) + // MDPLocationCollectionManager.uploadUnloadImage( // mContext, // orderBean.orderNum, @@ -450,28 +561,22 @@ class WaybillUpPicActivity : BaseActivity() { //// startService(serviceIn); // } // }) -// } + } //上传安联-签收 -// fun upTrafficSign(location: Location) { -// //安联 -// val gs = mutableListOf() -// orderBean.goodsList.forEach { -// var g = Goods() -// g.goodsName = it.goodName -// g.unit = it.packName -// g.itemNo = it.orderGoodsId.toInt() -// //实收 -// g.quantity = 1 -// //应收 -// g.receivedQuantity = 1 -// //破损 -// g.damageQuantity = 1 -// //丢失 -// g.quantity = 1 -// gs.add(g) -// } + fun upTrafficSign(location: GDLocation) { + //安联 + NewLJUtils.getInstance() + .sign(mContext, orderBean.orderNum, location, object : OnGDResultListener { + override fun onSuccess() { + Log.e("上报安联", "签收成功") + } + + override fun onFailure(code: String, message: String) { + Log.e("上报安联失败(签收):", code + message) + } + }) // MDPLocationCollectionManager.sign( // mContext, // orderBean.orderNum, @@ -486,11 +591,21 @@ class WaybillUpPicActivity : BaseActivity() { // Log.e("上报安联失败(签收):", s + s1) // } // }) -// } + } //上传安联-回单 -// fun upTrafficReceipt(location: Location) { -// //安联 + fun upTrafficReceipt(location: GDLocation) { + //安联 + NewLJUtils.getInstance() + .pod(mContext, orderBean.orderNum, location, object : OnGDResultListener { + override fun onSuccess() { + Log.e("上报安联", "回单上传成功") + } + + override fun onFailure(code: String, message: String) { + Log.e("上报安联失败(回单):", code + message) + } + }) // MDPLocationCollectionManager.pod( // mContext, // orderBean.orderNum, @@ -504,24 +619,60 @@ class WaybillUpPicActivity : BaseActivity() { // Log.e("上报安联失败(回单):", s + s1) // } // }) -// } + } //卸货回单照片 -// fun receiptImage() { -// ///storage/emulated/0/Android/data/com.oneclouds.wangluohuoyun/files/Pictures/163124593063154.jpg -// var upCount = 0 -// upBean.waybillPhotoList.filter { it.type == "3" && it.receiptType == "5" }.forEach { it -> -// var photoPaht = it.localPhotoUrl -// val file: File = File(photoPaht) -// val image = Image() -// val base = BitmapUtil.imageToBase64(photoPaht) -// image.fileData = "data:image/" + FileUtil.lastName(file) + ";base64," + base -// image.fileExt = FileUtil.lastName(file) -// image.fileName = FileUtil.fileName(file) -// image.imageTakenDate = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(Date()) -// image.baiduLongitude = bdLatLng.longitude -// image.baiduLatitude = bdLatLng.latitude -// image.location = binding.tvLoca.text.toString() + fun receiptImage() { + ///storage/emulated/0/Android/data/com.oneclouds.wangluohuoyun/files/Pictures/163124593063154.jpg + var upCount = 0 + upBean.waybillPhotoList.filter { it.type == "3" && it.receiptType == "5" }.forEach { it -> + var photoPaht = it.localPhotoUrl + val file: File = File(photoPaht) + val base = BitmapUtil.imageToBase64(photoPaht) + val image = GDImage().apply { + fileData = "data:image/" + FileUtil.lastName(file) + ";base64," + base + fileExt = FileUtil.lastName(file) + fileName = FileUtil.fileName(file) + imageTakenDate = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(Date()) + time = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(Date()) + baiduLongitude = bdLatLng.longitude + baiduLatitude = bdLatLng.latitude + location = binding.tvLoca.text.toString() + } + + NewLJUtils.getInstance() + .uploadPODImage(mContext, orderBean.orderNum, image, object : OnGDResultListener { + override fun onSuccess() { + Log.e("上报安联", "回单照片上传成功") + upCount++ + dissLoading() + if (upCount == upBean.waybillPhotoList.filter { it.type == "3" && it.receiptType == "5" }.size) { + //跳转成功页面,停止上传轨迹 + OrderUtils.getInstance().stopUpLocation(mContext) + ActivityUtils.startActivity( + mContext, + WaybillSuccActivity::class.java, + intent.extras + ) + ToastUtils.showToast(mContext, "上传成功") + } + } + + override fun onFailure(code: String, message: String) { + upCount++ + if (upCount == upBean.waybillPhotoList.filter { it.type == "3" && it.receiptType == "5" }.size) { + //跳转成功页面,停止上传轨迹 + OrderUtils.getInstance().stopUpLocation(mContext) + ActivityUtils.startActivity( + mContext, + WaybillSuccActivity::class.java, + intent.extras + ) + ToastUtils.showToast(mContext, "上传成功") + } + Log.e("上报安联失败(回单照片):", code + message) + } + }) // MDPLocationCollectionManager.uploadPODImage( // mContext, // orderBean.orderNum, @@ -564,52 +715,8 @@ class WaybillUpPicActivity : BaseActivity() { ////// startService(serviceIn); // } // }) -// -// -// -// -// } -// -//// var photoPaht = -//// upBean.waybillPhotoList.find { it.type == "3" && it.receiptType == "5" }?.localPhotoUrl -//// val file: File = File(photoPaht) -//// val image = Image() -//// val base = BitmapUtil.imageToBase64(photoPaht) -//// image.fileData = "data:image/" + FileUtil.lastName(file) + ";base64," + base -//// image.fileExt = FileUtil.lastName(file) -//// image.fileName = FileUtil.fileName(file) -//// image.imageTakenDate = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(Date()) -//// image.baiduLongitude = bdLatLng.longitude -//// image.baiduLatitude = bdLatLng.latitude -//// image.location = binding.tvLoca.text.toString() -//// MDPLocationCollectionManager.uploadPODImage( -//// mContext, -//// orderBean.orderNum, -//// image, -//// object : OnResultListener { -//// override fun onSuccess() { -//// Log.e("上报安联", "回单照片上传成功") -//// dissLoading() -//// //跳转成功页面,停止上传轨迹 -//// OrderUtils.getInstance().stopUpLocation(mContext) -//// ActivityUtils.startActivity( -//// mContext, -//// WaybillSuccActivity::class.java, -//// intent.extras -//// ) -//// Toast.makeText(mContext, "上传成功", Toast.LENGTH_SHORT).show() -////// finish() -//// } -//// -//// override fun onFailure(s: String, s1: String) { -//// Log.e("上报安联失败(回单照片):", s + s1) -//// // SPUtil.insSP(con,"make","回单",sob.getData().getShippingNoteNumber()); -//////// SPUtil.insSP(con,"make","回单-"+sob.getData().getShippingNoteNumber(),gson.toJson(image)); -//////// Intent serviceIn=new Intent(con, MakeUpAlService.class); -//////// startService(serviceIn); -//// } -//// }) -// } + } + } private val mData: List = ArrayList()