init: init proj
This commit is contained in:
1
module_gnc/.gitignore
vendored
Normal file
1
module_gnc/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
||||
82
module_gnc/build.gradle
Normal file
82
module_gnc/build.gradle
Normal file
@@ -0,0 +1,82 @@
|
||||
if (isBuildModule.toBoolean()) {
|
||||
apply plugin: 'com.android.application'
|
||||
} else {
|
||||
apply plugin: 'com.android.library'
|
||||
}
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
|
||||
kapt {
|
||||
arguments {
|
||||
arg("AROUTER_MODULE_NAME", project.getName())
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk 31
|
||||
|
||||
sourceSets {
|
||||
main{
|
||||
// 应用
|
||||
if(isBuildModule.toBoolean()){
|
||||
manifest.srcFile 'src/main/debug/AndroidManifest.xml'
|
||||
}else{// 插件
|
||||
manifest.srcFile 'src/main/release/AndroidManifest.xml'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
if (isBuildModule.toBoolean()) {
|
||||
applicationId "com.lukouguoji.gnc"
|
||||
}
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 30
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = '1.8'
|
||||
}
|
||||
buildToolsVersion '30.0.3'
|
||||
// 或者
|
||||
/* dataBinding {
|
||||
enabled = true
|
||||
}*/
|
||||
|
||||
buildFeatures {
|
||||
dataBinding = true
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
api project(':module_base')
|
||||
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
implementation 'androidx.core:core-ktx:1.2.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
implementation 'com.google.android.material:material:1.2.1'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
testImplementation 'junit:junit:4.+'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||
|
||||
kapt 'com.alibaba:arouter-compiler:1.5.2'
|
||||
|
||||
implementation project(':Printer')
|
||||
}
|
||||
21
module_gnc/proguard-rules.pro
vendored
Normal file
21
module_gnc/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.lukouguoji.gnc
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class ExampleInstrumentedTest {
|
||||
@Test
|
||||
fun useAppContext() {
|
||||
// Context of the app under test.
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
assertEquals("com.lukouguoji.gnc", appContext.packageName)
|
||||
}
|
||||
}
|
||||
25
module_gnc/src/main/debug/AndroidManifest.xml
Normal file
25
module_gnc/src/main/debug/AndroidManifest.xml
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.lukouguoji.gnc">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.Aerologic">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:screenOrientation="userLandscape"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
11
module_gnc/src/main/java/com/lukouguoji/gnc/MainActivity.kt
Normal file
11
module_gnc/src/main/java/com/lukouguoji/gnc/MainActivity.kt
Normal file
@@ -0,0 +1,11 @@
|
||||
package com.lukouguoji.gnc
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
package com.lukouguoji.gnc.activity
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.widget.EditText
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.alibaba.fastjson.JSONArray
|
||||
import com.alibaba.fastjson.JSONObject
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.adapt.GncChuKuListAdapter
|
||||
import com.lukouguoji.module_base.BaseActivity
|
||||
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
import com.lukouguoji.gnc.model.GncFuBangList
|
||||
import com.lukouguoji.gnc.viewModel.GoutFuBangListViewModel
|
||||
import com.lukouguoji.gnc.adapt.GncFuBangListAdapter
|
||||
import com.lukouguoji.gnc.adapt.GncLoadListAdapter
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.ninetripods.sydialoglib.IDialog
|
||||
import com.scwang.smart.refresh.footer.ClassicsFooter
|
||||
import com.scwang.smart.refresh.header.ClassicsHeader
|
||||
import com.scwang.smart.refresh.layout.api.RefreshLayout
|
||||
import java.util.*
|
||||
//出库装机操作页面
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_GNC_LOAD_LIST_ACTIVITY)
|
||||
class GncLoadListActivity : BaseActivity() {
|
||||
public lateinit var viewModel: GoutFuBangListViewModel
|
||||
|
||||
private lateinit var adapter: GncLoadListAdapter
|
||||
private val collectList = ArrayList<GncFuBangList>()
|
||||
|
||||
private var currentPage = 1
|
||||
private var pageSize = 10
|
||||
private var totalPage = 0
|
||||
private var text = ""
|
||||
private lateinit var refreshLayout: RefreshLayout
|
||||
private lateinit var search: TextView
|
||||
private lateinit var searchContent: EditText
|
||||
private lateinit var scanCodeImg: ImageView
|
||||
|
||||
//是否刷新
|
||||
private var refresh = false
|
||||
|
||||
|
||||
private fun initView() {
|
||||
viewModel = ViewModelProvider(this).get(GoutFuBangListViewModel::class.java)
|
||||
|
||||
search = findViewById(R.id.search)
|
||||
searchContent = findViewById(R.id.search_content)
|
||||
scanCodeImg = findViewById(R.id.scanCodeImg)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_fu_bang_list)
|
||||
setBackArrow("装机确认")
|
||||
initView()
|
||||
|
||||
val layoutManager = LinearLayoutManager(this)
|
||||
adapter = GncLoadListAdapter(this, collectList)
|
||||
var recyclerView: RecyclerView = findViewById(R.id.guo_nei_collect_list)
|
||||
recyclerView.layoutManager = layoutManager
|
||||
recyclerView.adapter = adapter
|
||||
viewModel.chukuParamLive.observe(this){
|
||||
loadingCancel();
|
||||
}
|
||||
viewModel.loadParamLive.observe(this){
|
||||
loadingCancel();
|
||||
}
|
||||
viewModel.searchParamLive.observe(this) {
|
||||
loadingCancel()
|
||||
//1.获取数据
|
||||
var listArr: JSONArray = it["list"] as JSONArray
|
||||
totalPage = it["pages"] as Int
|
||||
// var listArr :JSONArray =it["list"] as JSONArray
|
||||
if (listArr.size > 0) {
|
||||
//2.循环遍历塞入collectList
|
||||
listArr.forEach {
|
||||
val itemObj = it as JSONObject
|
||||
val useId = itemObj.getIntValue("useId")
|
||||
val carId = itemObj.getString("carId") ?: ""
|
||||
val fno = itemObj.getString("fno") ?: ""
|
||||
val dest = itemObj.getString("fdest") ?: ""
|
||||
val totalWeight = itemObj.getDoubleValue("totalWeight")
|
||||
val volume = itemObj.getDoubleValue("volume")
|
||||
val pc = itemObj.getIntValue("pc")
|
||||
val reviewer = itemObj.getString("reviewer") ?: ""
|
||||
val opDate = itemObj.getString("opDate") ?: ""
|
||||
val outer = itemObj.getString("outer") ?: ""
|
||||
val loader = itemObj.getString("loader") ?: ""
|
||||
collectList.add(GncFuBangList(useId, carId,fno,dest, totalWeight, volume, pc, opDate,reviewer,outer,loader))
|
||||
}
|
||||
//3.调adpter展示
|
||||
if (currentPage == 1) {
|
||||
adapter.notifyDataSetChanged()
|
||||
} else {
|
||||
adapter.notifyItemRangeInserted((currentPage - 1) * 10, collectList.size)
|
||||
}
|
||||
refreshLayout.finishRefresh()
|
||||
refreshLayout.finishLoadMore()
|
||||
|
||||
}
|
||||
}
|
||||
//初始化查询
|
||||
viewModel.search(pageSize, currentPage, text,"3")
|
||||
loading()
|
||||
|
||||
/////////////////////////////// 加载刷新的布局
|
||||
refreshLayout = findViewById<View>(R.id.refreshLayout) as RefreshLayout
|
||||
refreshLayout.setRefreshHeader(ClassicsHeader(this))
|
||||
refreshLayout.setRefreshFooter(ClassicsFooter(this))
|
||||
/////////////////////////////// 下拉刷新
|
||||
refreshLayout.setOnRefreshListener {
|
||||
refresh = true
|
||||
currentPage = 1
|
||||
//recyclerView 清除所有数据数据
|
||||
adapter.notifyItemRangeRemoved(0, collectList.size)
|
||||
collectList.clear()
|
||||
//初始化查询
|
||||
viewModel.search(pageSize, currentPage, text,"3")
|
||||
adapter.notifyItemRangeInserted(0, collectList.size)
|
||||
}
|
||||
/////////////////////////////// 上拉加载
|
||||
refreshLayout.setOnLoadMoreListener {
|
||||
refresh = false
|
||||
if (currentPage < totalPage) {
|
||||
currentPage++
|
||||
//初始化查询
|
||||
viewModel.search(pageSize, currentPage, text,"3")
|
||||
} else {
|
||||
refreshLayout.finishLoadMoreWithNoMoreData()
|
||||
}
|
||||
}
|
||||
|
||||
search.setOnClickListener {
|
||||
currentPage = 1
|
||||
//recyclerView 清除所有数据数据
|
||||
adapter.notifyItemRangeRemoved(0, collectList.size)
|
||||
collectList.clear()
|
||||
//初始化查询
|
||||
viewModel.search(pageSize, currentPage, searchContent.text.toString(),"3")
|
||||
}
|
||||
|
||||
|
||||
//点击扫码
|
||||
scanCodeImg.setOnClickListener {
|
||||
scanCode(Constant.RequestCode.gnc_fubang_search)
|
||||
}
|
||||
}
|
||||
|
||||
public fun loadCar(useId:Int,carId:String)
|
||||
{
|
||||
Common.secondConfirmDialog(this,"板车:"+carId+"确定完成装机吗?")
|
||||
{ dialog-> dialog.dismiss()
|
||||
viewModel.load(useId,carId)
|
||||
Common.showToastLong(this, carId+"装机成功!")
|
||||
currentPage = 1
|
||||
//recyclerView 清除所有数据数据
|
||||
adapter.notifyItemRangeRemoved(0, collectList.size)
|
||||
collectList.clear()
|
||||
//初始化查询
|
||||
viewModel.search(pageSize, currentPage, searchContent.text.toString(),"3")
|
||||
}
|
||||
}
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
|
||||
// 扫描二维码/条码回传
|
||||
if (requestCode == Constant.RequestCode.gnc_fubang_search && resultCode == RESULT_OK) {
|
||||
if (data != null) {
|
||||
val content = data.getStringExtra(com.yzq.zxinglibrary.common.Constant.CODED_CONTENT)
|
||||
searchContent.setText("$content")
|
||||
|
||||
//调用接口查询进入详情页
|
||||
if (content != null && content != "") {
|
||||
Log.i("刷新:${content}",content.toString())
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GOUT_FU_BANG_ACTIVITY).withString("carNoParam", content)
|
||||
.navigation(this, Constant.RequestCode.gnc_shouyun_list_refresh)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (requestCode == Constant.RequestCode.gnc_shouyun_list_refresh && resultCode == RESULT_OK) {
|
||||
collectList.clear()
|
||||
currentPage = 1
|
||||
refreshLayout.setNoMoreData(false)
|
||||
viewModel.search(10, currentPage, "","3")
|
||||
loading()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
package com.lukouguoji.gnc.activity
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.core.widget.NestedScrollView
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.alibaba.android.arouter.facade.annotation.Autowired
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.alibaba.fastjson.JSONObject
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.adapt.GncQueryInfoListAdapter
|
||||
import com.lukouguoji.gnc.adapt.GncQueryInfoWhListAdapter
|
||||
import com.lukouguoji.gnc.model.GncQueryInfo
|
||||
import com.lukouguoji.gnc.model.GncQueryInfoWh
|
||||
import com.lukouguoji.gnc.viewModel.GncQueryInfoViewModel
|
||||
import com.lukouguoji.module_base.BaseActivity
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_GNC_QUERY_INFO)
|
||||
class GncQueryInfoActivity : BaseActivity(), View.OnClickListener {
|
||||
|
||||
private lateinit var viewModel: GncQueryInfoViewModel
|
||||
|
||||
private lateinit var scrollView: NestedScrollView
|
||||
private lateinit var gncQueryInfoList: RecyclerView
|
||||
private lateinit var adapter: GncQueryInfoListAdapter
|
||||
private val gncQueryInfoAdapterList = arrayListOf<GncQueryInfo>()
|
||||
|
||||
private lateinit var submit: TextView
|
||||
|
||||
|
||||
private lateinit var refWareHouseInfo: LinearLayout
|
||||
private lateinit var wareHouseInfoLayout: LinearLayout
|
||||
private lateinit var gncQueryWareHouseInfoList: RecyclerView
|
||||
private lateinit var wareHouseInfoAdapter: GncQueryInfoWhListAdapter
|
||||
private val gncQueryWareHouseInfoAdapterList = arrayListOf<GncQueryInfoWh>()
|
||||
|
||||
@JvmField
|
||||
@Autowired
|
||||
var id: Int = -9999
|
||||
|
||||
@JvmField
|
||||
@Autowired
|
||||
var wbNoParam: String? = null
|
||||
|
||||
private fun initView() {
|
||||
viewModel = ViewModelProvider(this).get(GncQueryInfoViewModel::class.java)
|
||||
|
||||
scrollView = findViewById(R.id.scrollView)
|
||||
refWareHouseInfo = findViewById(R.id.refWareHouseInfo)
|
||||
wareHouseInfoLayout = findViewById(R.id.wareHouseInfoLayout)
|
||||
submit = findViewById(R.id.submit)
|
||||
|
||||
val layoutManager = GridLayoutManager(this, 2)
|
||||
adapter = GncQueryInfoListAdapter(this, gncQueryInfoAdapterList)
|
||||
gncQueryInfoList = findViewById(R.id.gncQueryInfoList)
|
||||
gncQueryInfoList.adapter = adapter
|
||||
gncQueryInfoList.layoutManager = layoutManager
|
||||
|
||||
val wareHouseLayoutManager = LinearLayoutManager(this)
|
||||
wareHouseInfoAdapter = GncQueryInfoWhListAdapter(this, gncQueryWareHouseInfoAdapterList)
|
||||
gncQueryWareHouseInfoList = findViewById(R.id.gncQueryWareHouseInfoList)
|
||||
gncQueryWareHouseInfoList.adapter = wareHouseInfoAdapter
|
||||
gncQueryWareHouseInfoList.layoutManager = wareHouseLayoutManager
|
||||
|
||||
refWareHouseInfo.setOnClickListener(this)
|
||||
submit.setOnClickListener(this)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_gnc_query_info)
|
||||
setBackArrow("国内出港查询详情")
|
||||
initView()
|
||||
|
||||
// initData()
|
||||
|
||||
viewModel.queryWaybillById(id, wbNoParam)
|
||||
viewModel.waybillLiveData.observe(this) {
|
||||
val status = it.getString("status")
|
||||
if (Constant.Result.succ == status) {
|
||||
viewModel.wayBillInfo = it.getJSONObject("data")
|
||||
//主运单详情
|
||||
val maWbObj = viewModel.wayBillInfo.getJSONObject("maWb")
|
||||
adapter.append(GncQueryInfo(1, "运单号", maWbObj.getString("wbNo") ?: ""))
|
||||
viewModel.wbNo = maWbObj.getString("wbNo")
|
||||
adapter.append(GncQueryInfo(1, "件数", maWbObj.getIntValue("pc").toString()))
|
||||
adapter.append(
|
||||
GncQueryInfo(
|
||||
1,
|
||||
"重量",
|
||||
"${maWbObj.getDoubleValue("weight")} KG"
|
||||
)
|
||||
)
|
||||
adapter.append(GncQueryInfo(1, "承运人", maWbObj.getString("by1") ?: ""))
|
||||
adapter.append(GncQueryInfo(1, "目的港", maWbObj.getString("dest") ?: ""))
|
||||
adapter.append(GncQueryInfo(1, "品名", maWbObj.getString("goods") ?: ""))
|
||||
adapter.append(GncQueryInfo(1, "特码", maWbObj.getString("spCode") ?: ""))
|
||||
adapter.append(GncQueryInfo(1, "代理", maWbObj.getString("agentCode") ?: ""))
|
||||
adapter.append(GncQueryInfo(1, "运单类型", maWbObj.getString("awbType") ?: ""))
|
||||
adapter.append(GncQueryInfo(1, "业务类型", maWbObj.getString("businessType") ?: ""))
|
||||
adapter.append(GncQueryInfo(1, "包装类型", maWbObj.getString("packageType") ?: ""))
|
||||
/*adapter.append(GncQueryInfo(1, "卸货港", maWbObj.getString("dest1") ?: ""))
|
||||
adapter.append(GncQueryInfo(1, "危险品描述", maWbObj.getString("dgrDetail") ?: ""))
|
||||
adapter.append(GncQueryInfo(1, "危险品库位", maWbObj.getString("dgrLocation") ?: ""))
|
||||
adapter.append(GncQueryInfo(1, "航班", maWbObj.getString("flight") ?: ""))
|
||||
adapter.append(GncQueryInfo(1, "入库时间", maWbObj.getString("opDate") ?: ""))
|
||||
adapter.append(GncQueryInfo(1, "出库时间", maWbObj.getString("mclose") ?: ""))
|
||||
adapter.append(GncQueryInfo(1, "收运人", maWbObj.getString("opId") ?: ""))*/
|
||||
|
||||
//关联仓库详情
|
||||
val whListArr = viewModel.wayBillInfo.getJSONArray("whList")
|
||||
whListArr.forEach { waybill ->
|
||||
val waybillObj = waybill as JSONObject
|
||||
wareHouseInfoAdapter.append(
|
||||
GncQueryInfoWh(
|
||||
1,
|
||||
waybillObj.getString("wbNo") ?: "",
|
||||
waybillObj.getString("location") ?: "",
|
||||
waybillObj.getIntValue("pc"),
|
||||
waybillObj.getDoubleValue("weight"),
|
||||
waybillObj.getString("flight") ?: "",
|
||||
waybillObj.getString("opDate") ?: "",
|
||||
waybillObj.getString("fclose") ?: "",
|
||||
waybillObj.getString("opId") ?: ""
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
} else {
|
||||
//无数据
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun initData() {
|
||||
gncQueryInfoAdapterList.add(GncQueryInfo(1, "入库时间", "2021-04-05 15:22:33"))
|
||||
gncQueryInfoAdapterList.add(GncQueryInfo(1, "运单号", "A014d384"))
|
||||
gncQueryInfoAdapterList.add(GncQueryInfo(1, "代理人", "张三"))
|
||||
gncQueryInfoAdapterList.add(GncQueryInfo(1, "特码", "A06"))
|
||||
gncQueryInfoAdapterList.add(GncQueryInfo(1, "件数", "39件"))
|
||||
gncQueryInfoAdapterList.add(GncQueryInfo(1, "重量", "30kg"))
|
||||
gncQueryInfoAdapterList.add(GncQueryInfo(1, "品名", "TF"))
|
||||
gncQueryInfoAdapterList.add(GncQueryInfo(1, "目的港", "白云国际机场"))
|
||||
gncQueryInfoAdapterList.add(GncQueryInfo(1, "航班号", "U23"))
|
||||
gncQueryInfoAdapterList.add(GncQueryInfo(1, "运单类型", "配载单"))
|
||||
gncQueryInfoAdapterList.add(GncQueryInfo(1, "承运人", "SF"))
|
||||
gncQueryInfoAdapterList.add(GncQueryInfo(1, "包装", "木箱"))
|
||||
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
v?.let {
|
||||
when (it.id) {
|
||||
R.id.refWareHouseInfo -> {
|
||||
//开关关联列表
|
||||
if (wareHouseInfoLayout.visibility == View.GONE) {
|
||||
wareHouseInfoLayout.visibility = View.VISIBLE
|
||||
} else {
|
||||
wareHouseInfoLayout.visibility = View.GONE
|
||||
}
|
||||
scrollView.post { scrollView.scrollTo(0, scrollView.bottom) }
|
||||
}
|
||||
R.id.submit -> {
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_CARGO_TRACKING)
|
||||
.withString("countryTypeParam", Constant.CargoTracking.gnStatus)
|
||||
.withString("ieFlagParam", Constant.CargoTracking.exportStatus)
|
||||
.withString("wbNoParam", viewModel.wbNo)
|
||||
.navigation()
|
||||
}
|
||||
else -> {
|
||||
Toast.makeText(this, "未找到对应操作", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,533 @@
|
||||
package com.lukouguoji.gnc.activity
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.alibaba.fastjson.JSONArray
|
||||
import com.alibaba.fastjson.JSONObject
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.adapt.GncQueryListAdapter
|
||||
import com.lukouguoji.gnc.model.GncQueryList
|
||||
import com.lukouguoji.gnc.viewModel.GncQueryListViewModel
|
||||
import com.lukouguoji.module_base.ActivityCollector
|
||||
import com.lukouguoji.module_base.BaseActivity
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.scwang.smart.refresh.footer.ClassicsFooter
|
||||
import com.scwang.smart.refresh.header.ClassicsHeader
|
||||
import com.scwang.smart.refresh.layout.api.RefreshLayout
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
//@Route(path = ARouterConstants.ACTIVITY_URL_GNC_QUERY_LIST)
|
||||
class GncQueryListActivity : BaseActivity(), View.OnClickListener {
|
||||
private lateinit var viewModel: GncQueryListViewModel
|
||||
|
||||
private lateinit var adapter: GncQueryListAdapter
|
||||
private val collectList = ArrayList<GncQueryList>()
|
||||
|
||||
private var currentPage = 1
|
||||
private var pageSize = 10
|
||||
private var totalPage = 0
|
||||
private lateinit var refreshLayout: RefreshLayout
|
||||
|
||||
//标题
|
||||
private lateinit var toolBack: LinearLayout
|
||||
private lateinit var titleName: TextView
|
||||
|
||||
//搜索条件
|
||||
private lateinit var searchListFragment: LinearLayout
|
||||
private lateinit var filtrateLayout: LinearLayout
|
||||
private lateinit var wbNo: EditText
|
||||
private lateinit var fno: EditText
|
||||
private lateinit var beginDate: TextView
|
||||
private lateinit var beginDateIcon: ImageView
|
||||
private lateinit var endDate: TextView
|
||||
private lateinit var endDateIcon: ImageView
|
||||
private lateinit var mudiGang: EditText
|
||||
private lateinit var searchLayout: LinearLayout
|
||||
|
||||
//筛选页
|
||||
private lateinit var filtrateFragment: LinearLayout
|
||||
|
||||
/* private lateinit var startDateParam: TextView
|
||||
private lateinit var endDateParam: TextView
|
||||
private lateinit var hangCheng: EditText
|
||||
private lateinit var carrier: EditText
|
||||
private lateinit var kuWei: EditText*/
|
||||
private lateinit var spCode: TextView
|
||||
private var spCodeValue = ""
|
||||
private lateinit var agentCode: TextView
|
||||
private var agentCodeValue = ""
|
||||
private lateinit var goods: EditText
|
||||
private lateinit var awbType: TextView
|
||||
private var awbTypeValue = ""
|
||||
private lateinit var businessType: TextView
|
||||
private var businessTypeValue = ""
|
||||
|
||||
/*private lateinit var isCangDan: TextView
|
||||
private var isCangDanStatus = ""
|
||||
private val isCangDanArr = JSONArray()*/
|
||||
private lateinit var submit: TextView
|
||||
private lateinit var reset: TextView
|
||||
|
||||
// 、、特码、代理人、品名、运单类型、业务类型查询
|
||||
|
||||
|
||||
private val ymdSdf = SimpleDateFormat("yyyy-MM-dd")//年月日
|
||||
private val ymdHmsSdf = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")//年月日 时分秒
|
||||
private val calendar = Calendar.getInstance()
|
||||
|
||||
private fun initView() {
|
||||
viewModel = ViewModelProvider(this).get(GncQueryListViewModel::class.java)
|
||||
val layoutManager = LinearLayoutManager(this)
|
||||
adapter = GncQueryListAdapter(this, collectList)
|
||||
var recyclerView: RecyclerView = findViewById(R.id.recyclerList)
|
||||
recyclerView.layoutManager = layoutManager
|
||||
recyclerView.adapter = adapter
|
||||
|
||||
//标题
|
||||
toolBack = findViewById(R.id.tool_back)
|
||||
titleName = findViewById(R.id.title_name)
|
||||
//搜索列表页
|
||||
searchListFragment = findViewById(R.id.searchListFragment)
|
||||
wbNo = findViewById(R.id.wbNo)
|
||||
fno = findViewById(R.id.fno)
|
||||
beginDate = findViewById(R.id.beginDate)
|
||||
beginDateIcon = findViewById(R.id.beginDateIcon)
|
||||
endDate = findViewById(R.id.endDate)
|
||||
endDateIcon = findViewById(R.id.endDateIcon)
|
||||
mudiGang = findViewById(R.id.mudiGang)
|
||||
searchLayout = findViewById(R.id.searchLayout)
|
||||
filtrateLayout = findViewById(R.id.filtrateLayout)
|
||||
//筛选页
|
||||
filtrateFragment = findViewById(R.id.filtrateFragment)
|
||||
/*startDateParam = findViewById(R.id.startDateParam)
|
||||
endDateParam = findViewById(R.id.endDateParam)
|
||||
isCangDan = findViewById(R.id.isCangDan)
|
||||
hangCheng = findViewById(R.id.hangCheng)
|
||||
carrier = findViewById(R.id.carrier)
|
||||
kuWei = findViewById(R.id.kuWei)*/
|
||||
goods = findViewById(R.id.goods)
|
||||
spCode = findViewById(R.id.spCode)
|
||||
agentCode = findViewById(R.id.agentCode)
|
||||
businessType = findViewById(R.id.businessType)
|
||||
awbType = findViewById(R.id.awbType)
|
||||
submit = findViewById(R.id.submit)
|
||||
reset = findViewById(R.id.reset)
|
||||
|
||||
toolBack.setOnClickListener(this)
|
||||
searchLayout.setOnClickListener(this)
|
||||
beginDate.setOnClickListener(this)
|
||||
beginDateIcon.setOnClickListener(this)
|
||||
endDate.setOnClickListener(this)
|
||||
endDateIcon.setOnClickListener(this)
|
||||
/*startDateParam.setOnClickListener(this)
|
||||
endDateParam.setOnClickListener(this)*/
|
||||
spCode.setOnClickListener(this)
|
||||
agentCode.setOnClickListener(this)
|
||||
businessType.setOnClickListener(this)
|
||||
awbType.setOnClickListener(this)
|
||||
// isCangDan.setOnClickListener(this)
|
||||
filtrateLayout.setOnClickListener(this)
|
||||
submit.setOnClickListener(this)
|
||||
reset.setOnClickListener(this)
|
||||
|
||||
wbNo.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
if (s != null && s.toString().length > 11) {
|
||||
Common.alertDialog(ActivityCollector.getLastActivity()!!, "运单号不能超过11位!") { dialog ->
|
||||
wbNo.setText(s.toString().substring(0, 11))
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
fno.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun afterTextChanged(editable: Editable?) {
|
||||
val originText = editable.toString()
|
||||
if (originText != null && originText != "") {
|
||||
val regularExpression = "(^([A-Z0-9]+)$)"
|
||||
val matches = originText.matches(regularExpression.toRegex())
|
||||
if (!matches) {
|
||||
val regularExpression2 = "([^A-Za-z0-9]+)"
|
||||
val replaceStr = originText.replace(regularExpression2.toRegex(), "")
|
||||
val replaceStrToUpper = replaceStr.uppercase(Locale.ROOT)//小写转大写
|
||||
fno.setText(replaceStrToUpper)
|
||||
fno.setSelection(replaceStrToUpper.length)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
mudiGang.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun afterTextChanged(editable: Editable?) {
|
||||
val originText = editable.toString()
|
||||
if (originText != null && originText != "") {
|
||||
val regularExpression = "(^([A-Z]+)$)"
|
||||
val matches = originText.matches(regularExpression.toRegex())
|
||||
if (!matches) {
|
||||
val regularExpression2 = "([^A-Za-z]+)"
|
||||
val replaceStr = originText.replace(regularExpression2.toRegex(), "")
|
||||
val replaceStrToUpper = replaceStr.uppercase(Locale.ROOT)//小写转大写
|
||||
mudiGang.setText(replaceStrToUpper)
|
||||
mudiGang.setSelection(replaceStrToUpper.length)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
//是否上舱单
|
||||
/*val noneCangDan = JSONObject()
|
||||
noneCangDan["name"] = "请选择"
|
||||
noneCangDan["code"] = ""
|
||||
val yesCangDan = JSONObject()
|
||||
yesCangDan["name"] = "是"
|
||||
yesCangDan["code"] = "1"
|
||||
val noCangDan = JSONObject()
|
||||
noCangDan["name"] = "否"
|
||||
noCangDan["code"] = "0"
|
||||
isCangDanArr.add(noneCangDan)
|
||||
isCangDanArr.add(yesCangDan)
|
||||
isCangDanArr.add(noCangDan)*/
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_gnc_query_list2)
|
||||
initView()
|
||||
|
||||
//初始化查询
|
||||
searchFun()
|
||||
loading()
|
||||
viewModel.searchParamLive.observe(this) {
|
||||
loadingCancel()
|
||||
//1.获取数据
|
||||
var listArr: JSONArray = it["list"] as JSONArray
|
||||
totalPage = it["pages"] as Int
|
||||
// var listArr :JSONArray =it["list"] as JSONArray
|
||||
if (listArr.size > 0) {
|
||||
//2.循环遍历塞入collectList
|
||||
listArr.forEach {
|
||||
val itemObj = it as JSONObject
|
||||
val id = itemObj.getIntValue("mawbId")
|
||||
val wbNo = itemObj.getString("wbNo") ?: ""
|
||||
val agentCode = itemObj.getString("agentCode") ?: ""
|
||||
val spCode = itemObj.getString("spCode") ?: ""
|
||||
val goods = itemObj.getString("goods") ?: ""
|
||||
val flight = itemObj.getString("flight") ?: ""
|
||||
val dest = itemObj.getString("dest") ?: ""
|
||||
val opDate = itemObj.getString("opDate") ?: ""
|
||||
val fclose = itemObj.getString("fclose") ?: ""
|
||||
val pc = itemObj.getString("pc") ?: ""
|
||||
val weight = itemObj.getString("weight") ?: ""
|
||||
|
||||
collectList.add(GncQueryList(id, wbNo, agentCode, spCode, goods, flight, dest, opDate, fclose, pc, weight))
|
||||
}
|
||||
//3.调adpter展示
|
||||
if (currentPage == 1) {
|
||||
adapter.notifyDataSetChanged()
|
||||
} else {
|
||||
adapter.notifyItemRangeInserted((currentPage - 1) * 10, collectList.size)
|
||||
}
|
||||
refreshLayout.finishRefresh()
|
||||
refreshLayout.finishLoadMore()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/////////////// 下拉框 start
|
||||
viewModel.agentCode(System.currentTimeMillis().toString())
|
||||
viewModel.agentCodeObserver.observe(this) { vd ->
|
||||
val noneObj = JSONObject()
|
||||
noneObj["name"] = "请选择代理人"
|
||||
noneObj["code"] = ""
|
||||
viewModel.agentCodeList.add(noneObj)
|
||||
viewModel.agentCodeList.addAll(vd.getJSONArray("data"))
|
||||
}
|
||||
|
||||
viewModel.business(Constant.businessType.CO)
|
||||
viewModel.businessObserver.observe(this) { vd ->
|
||||
val noneObj = JSONObject()
|
||||
noneObj["name"] = "请选择业务类型"
|
||||
noneObj["code"] = ""
|
||||
viewModel.businessList.add(noneObj)
|
||||
viewModel.businessList.addAll(vd.getJSONArray("data"))
|
||||
}
|
||||
|
||||
viewModel.specialCode(System.currentTimeMillis().toString())
|
||||
viewModel.specialCodeObserver.observe(this) { vd ->
|
||||
val noneObj = JSONObject()
|
||||
noneObj["name"] = "请选择特码"
|
||||
noneObj["code"] = ""
|
||||
viewModel.specialCodeList.add(noneObj)
|
||||
viewModel.specialCodeList.addAll(vd.getJSONArray("data"))
|
||||
}
|
||||
|
||||
viewModel.awb(Constant.businessType.CO)
|
||||
viewModel.awbObserver.observe(this) { vd ->
|
||||
val noneObj = JSONObject()
|
||||
noneObj["name"] = "请选择运单类型"
|
||||
noneObj["code"] = ""
|
||||
viewModel.awbList.add(noneObj)
|
||||
viewModel.awbList.addAll(vd.getJSONArray("data"))
|
||||
}
|
||||
/////////////// 下拉框 end
|
||||
|
||||
/////////////////////////////// 加载刷新的布局
|
||||
refreshLayout = findViewById<View>(R.id.refreshLayout) as RefreshLayout
|
||||
refreshLayout.setRefreshHeader(ClassicsHeader(this))
|
||||
refreshLayout.setRefreshFooter(ClassicsFooter(this))
|
||||
/////////////////////////////// 下拉刷新
|
||||
refreshLayout.setOnRefreshListener {
|
||||
resetSearch()
|
||||
}
|
||||
/////////////////////////////// 上拉加载
|
||||
refreshLayout.setOnLoadMoreListener {
|
||||
if (currentPage < totalPage) {
|
||||
currentPage++
|
||||
//初始化查询
|
||||
searchFun()
|
||||
} else {
|
||||
refreshLayout.finishLoadMoreWithNoMoreData()
|
||||
}
|
||||
}
|
||||
|
||||
//点击扫码
|
||||
/*scanCodeImg.setOnClickListener {
|
||||
scanCode(Constant.RequestCode.gnc_query_list)
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
* onActivityResult 回调
|
||||
*/
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
|
||||
// 扫描二维码/条码回传
|
||||
/*if (requestCode == Constant.RequestCode.gnc_query_list && resultCode == RESULT_OK) {
|
||||
if (data != null) {
|
||||
val content = data.getStringExtra(com.yzq.zxinglibrary.common.Constant.CODED_CONTENT)
|
||||
searchContent.setText("$content")
|
||||
|
||||
//调用接口查询进入详情页
|
||||
if (content != null && content != "") {
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GNC_QUERY_INFO).withString("wbNoParam", content)
|
||||
.navigation(this)
|
||||
}
|
||||
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
v?.let {
|
||||
when (it.id) {
|
||||
R.id.tool_back -> {
|
||||
if (searchListFragment.visibility == View.GONE && filtrateFragment.visibility == View.VISIBLE) {
|
||||
searchListFragment.visibility = View.VISIBLE
|
||||
filtrateFragment.visibility = View.GONE
|
||||
titleName.text = "国内出港查询"
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
R.id.searchLayout -> {
|
||||
resetSearch()
|
||||
}
|
||||
R.id.filtrateLayout -> {
|
||||
if (searchListFragment.visibility == View.VISIBLE && filtrateFragment.visibility == View.GONE) {
|
||||
searchListFragment.visibility = View.GONE
|
||||
filtrateFragment.visibility = View.VISIBLE
|
||||
titleName.text = "搜索"
|
||||
} else {
|
||||
searchListFragment.visibility = View.VISIBLE
|
||||
filtrateFragment.visibility = View.GONE
|
||||
titleName.text = "国内出港查询"
|
||||
}
|
||||
// Common.showToast(this,"筛选")
|
||||
}
|
||||
R.id.beginDate -> {
|
||||
Common.onYearMonthDay(this, beginDate.text.toString()) { year, month, day ->
|
||||
calendar.set(year, month - 1, day)
|
||||
beginDate.text = ymdSdf.format(calendar.time)
|
||||
}
|
||||
}
|
||||
R.id.beginDateIcon -> {
|
||||
beginDate.text = ""
|
||||
}
|
||||
R.id.endDate -> {
|
||||
Common.onYearMonthDay(this, endDate.text.toString()) { year, month, day ->
|
||||
calendar.set(year, month - 1, day)
|
||||
endDate.text = ymdSdf.format(calendar.time)
|
||||
}
|
||||
}
|
||||
R.id.endDateIcon -> {
|
||||
endDate.text = ""
|
||||
}
|
||||
R.id.agentCode -> {
|
||||
Common.singleSelect(this, "代理", viewModel.agentCodeList, agentCodeValue) { _, item ->
|
||||
val jsonObject = item as JSONObject
|
||||
val name = jsonObject.getString("name")
|
||||
val code = jsonObject.getString("code")
|
||||
agentCode.text = name
|
||||
agentCodeValue = code
|
||||
}
|
||||
}
|
||||
R.id.businessType -> {
|
||||
Common.singleSelect(this, "业务类型", viewModel.businessList, businessTypeValue) { _, item ->
|
||||
val jsonObject = item as JSONObject
|
||||
val name = jsonObject.getString("name")
|
||||
val code = jsonObject.getString("code")
|
||||
businessType.text = name
|
||||
businessTypeValue = code
|
||||
}
|
||||
}
|
||||
R.id.spCode -> {
|
||||
Common.singleSelect(this, "特码", viewModel.specialCodeList, spCodeValue) { _, item ->
|
||||
val jsonObject = item as JSONObject
|
||||
val name = jsonObject.getString("name")
|
||||
val code = jsonObject.getString("code")
|
||||
spCode.text = name
|
||||
spCodeValue = code
|
||||
}
|
||||
}
|
||||
R.id.awbType -> {
|
||||
Common.singleSelect(this, "运单类型", viewModel.awbList, awbTypeValue) { _, item ->
|
||||
val jsonObject = item as JSONObject
|
||||
val name = jsonObject.getString("name")
|
||||
val code = jsonObject.getString("code")
|
||||
awbType.text = name
|
||||
awbTypeValue = code
|
||||
}
|
||||
}
|
||||
/*R.id.isCangDan -> {
|
||||
Common.singleSelect(this, "是否上舱单", isCangDanArr, isCangDanStatus) { _, item ->
|
||||
val jsonObject = item as JSONObject
|
||||
val name = jsonObject.getString("name")
|
||||
val code = jsonObject.getString("code")
|
||||
isCangDan.text = name
|
||||
isCangDanStatus = code
|
||||
}
|
||||
// Common.showToast(this,"筛选")
|
||||
}*/
|
||||
R.id.submit -> {
|
||||
//筛选页隐藏
|
||||
searchListFragment.visibility = View.VISIBLE
|
||||
filtrateFragment.visibility = View.GONE
|
||||
titleName.text = "国内出港查询"
|
||||
//搜索
|
||||
resetSearch()
|
||||
}
|
||||
R.id.reset -> {
|
||||
resetFun()
|
||||
}
|
||||
else -> {
|
||||
Toast.makeText(this, "未找到对应操作", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索
|
||||
*/
|
||||
private fun searchFun() {
|
||||
viewModel.search(
|
||||
pageSize,
|
||||
currentPage,
|
||||
"", // carrier.text.toString(),
|
||||
agentCodeValue,
|
||||
awbTypeValue,
|
||||
beginDate.text.toString(),
|
||||
endDate.text.toString(),
|
||||
"",//fdate.text.toString(),
|
||||
fno.text.toString(),
|
||||
mudiGang.text.toString(),
|
||||
"",// kuWei.text.toString(),
|
||||
"",// hangCheng.text.toString(),
|
||||
businessTypeValue,
|
||||
"",// isCangDanStatus,
|
||||
wbNo.text.toString(),
|
||||
spCodeValue,
|
||||
goods.text.toString()
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置数据,搜索
|
||||
*/
|
||||
private fun resetSearch() {
|
||||
//recyclerView 清除所有数据数据
|
||||
refreshLayout.setNoMoreData(false)
|
||||
adapter.notifyItemRangeRemoved(0, collectList.size)
|
||||
collectList.clear()
|
||||
currentPage = 1
|
||||
searchFun()
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置筛选条件
|
||||
*/
|
||||
private fun resetFun() {
|
||||
currentPage = 1
|
||||
|
||||
wbNo.setText("")
|
||||
mudiGang.setText("")
|
||||
/* carrier.setText("")
|
||||
startDateParam.text = ""
|
||||
endDateParam.text = ""
|
||||
kuWei.setText("")
|
||||
hangCheng.setText("")*/
|
||||
beginDate.text = ""
|
||||
endDate.text = ""
|
||||
fno.setText("")
|
||||
|
||||
spCode.text = ""
|
||||
spCodeValue = ""
|
||||
agentCode.text = ""
|
||||
agentCodeValue = ""
|
||||
goods.setText("")
|
||||
businessType.text = ""
|
||||
businessTypeValue = ""
|
||||
awbType.text = ""
|
||||
awbTypeValue = ""
|
||||
|
||||
/*isCangDan.text = ""
|
||||
isCangDanStatus = ""*/
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,436 @@
|
||||
package com.lukouguoji.gnc.activity
|
||||
|
||||
import android.os.Bundle
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.view.View
|
||||
import android.widget.EditText
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.alibaba.fastjson.JSONArray
|
||||
import com.alibaba.fastjson.JSONObject
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.adapt.GncWareHouseListAdapter
|
||||
import com.lukouguoji.gnc.model.GncWareHouseList
|
||||
import com.lukouguoji.gnc.viewModel.GoutWareHouseListViewModel
|
||||
import com.lukouguoji.module_base.ActivityCollector
|
||||
import com.lukouguoji.module_base.BaseActivity
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.scwang.smart.refresh.footer.ClassicsFooter
|
||||
import com.scwang.smart.refresh.header.ClassicsHeader
|
||||
import com.scwang.smart.refresh.layout.api.RefreshLayout
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
|
||||
//@Route(path = ARouterConstants.ACTIVITY_URL_GNC_WAREHOUSE)
|
||||
class GncWareHouseActivity : BaseActivity(), View.OnClickListener {
|
||||
private lateinit var viewModel: GoutWareHouseListViewModel
|
||||
|
||||
private lateinit var adapter: GncWareHouseListAdapter
|
||||
private val collectList = ArrayList<GncWareHouseList>()
|
||||
|
||||
private lateinit var refreshLayout: RefreshLayout
|
||||
private var currentPage = 1
|
||||
private var pageSize = 10
|
||||
private var totalPage = 0
|
||||
|
||||
//是否刷新
|
||||
private var refresh = false
|
||||
|
||||
//标题
|
||||
private lateinit var toolBack: LinearLayout
|
||||
private lateinit var titleName: TextView
|
||||
|
||||
//搜索条件
|
||||
private lateinit var searchListFragment: LinearLayout
|
||||
private lateinit var wayNo: EditText
|
||||
private lateinit var carrier: EditText
|
||||
private lateinit var kuWei: EditText
|
||||
private lateinit var mudiGang: EditText
|
||||
private lateinit var searchLayout: LinearLayout
|
||||
private lateinit var filtrateLayout: LinearLayout
|
||||
private lateinit var summaryText: TextView
|
||||
|
||||
//筛选页
|
||||
private lateinit var filtrateFragment: LinearLayout
|
||||
private lateinit var isGroup: TextView
|
||||
private var isGroupStatus = ""
|
||||
private val isGroupArr = JSONArray()
|
||||
private lateinit var isCangDan: TextView
|
||||
private var isCangDanStatus = ""
|
||||
private val isCangDanArr = JSONArray()
|
||||
|
||||
private lateinit var submit: TextView
|
||||
private lateinit var reset: TextView
|
||||
|
||||
private val ymdSdf = SimpleDateFormat("yyyy-MM-dd")//年月日
|
||||
private val ymdHmsSdf = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")//年月日 时分秒
|
||||
private val calendar = Calendar.getInstance()
|
||||
|
||||
private fun initView() {
|
||||
viewModel = ViewModelProvider(this).get(GoutWareHouseListViewModel::class.java)
|
||||
|
||||
val layoutManager = LinearLayoutManager(this)
|
||||
adapter = GncWareHouseListAdapter(this, collectList)
|
||||
var recyclerView: RecyclerView = findViewById(R.id.guo_nei_collect_list)
|
||||
recyclerView.layoutManager = layoutManager
|
||||
recyclerView.adapter = adapter
|
||||
|
||||
refreshLayout = findViewById(R.id.refreshLayout)
|
||||
|
||||
//标题
|
||||
toolBack = findViewById(R.id.tool_back)
|
||||
titleName = findViewById(R.id.title_name)
|
||||
|
||||
//搜索列表页
|
||||
searchListFragment = findViewById(R.id.searchListFragment)
|
||||
mudiGang = findViewById(R.id.mudiGang)
|
||||
searchLayout = findViewById(R.id.searchLayout)
|
||||
filtrateLayout = findViewById(R.id.filtrateLayout)
|
||||
summaryText = findViewById(R.id.summaryText)
|
||||
//筛选页
|
||||
filtrateFragment = findViewById(R.id.filtrateFragment)
|
||||
isGroup = findViewById(R.id.isGroup)
|
||||
isCangDan = findViewById(R.id.isCangDan)
|
||||
// hangCheng = findViewById(R.id.hangCheng)
|
||||
carrier = findViewById(R.id.carrier)
|
||||
kuWei = findViewById(R.id.kuWei)
|
||||
wayNo = findViewById(R.id.waybillNo)
|
||||
submit = findViewById(R.id.submit)
|
||||
reset = findViewById(R.id.reset)
|
||||
|
||||
toolBack.setOnClickListener(this)
|
||||
searchLayout.setOnClickListener(this)
|
||||
filtrateLayout.setOnClickListener(this)
|
||||
submit.setOnClickListener(this)
|
||||
reset.setOnClickListener(this)
|
||||
isGroup.setOnClickListener(this)
|
||||
isCangDan.setOnClickListener(this)
|
||||
|
||||
wayNo.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
if (s != null && s.toString().length > 11) {
|
||||
Common.alertDialog(ActivityCollector.getLastActivity()!!, "运单号不能超过11位!") { dialog ->
|
||||
wayNo.setText(s.toString().substring(0, 11))
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
carrier.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun afterTextChanged(editable: Editable?) {
|
||||
val originText = editable.toString()
|
||||
if (originText != null && originText != "") {
|
||||
val regularExpression = "(^([A-Z]+)$)"
|
||||
val matches = originText.matches(regularExpression.toRegex())
|
||||
if(!matches){
|
||||
val regularExpression2 = "([^A-Za-z]+)"
|
||||
val replaceStr = originText.replace(regularExpression2.toRegex(),"")
|
||||
val replaceStrToUpper = replaceStr.uppercase(Locale.ROOT)//小写转大写
|
||||
carrier.setText(replaceStrToUpper)
|
||||
carrier.setSelection(replaceStrToUpper.length)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
mudiGang.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun afterTextChanged(editable: Editable?) {
|
||||
val originText = editable.toString()
|
||||
if (originText != null && originText != "") {
|
||||
val regularExpression = "(^([A-Z]+)$)"
|
||||
val matches = originText.matches(regularExpression.toRegex())
|
||||
if(!matches){
|
||||
val regularExpression2 = "([^A-Za-z]+)"
|
||||
val replaceStr = originText.replace(regularExpression2.toRegex(),"")
|
||||
val replaceStrToUpper = replaceStr.uppercase(Locale.ROOT)//小写转大写
|
||||
mudiGang.setText(replaceStrToUpper)
|
||||
mudiGang.setSelection(replaceStrToUpper.length)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
//赋值
|
||||
//是否上舱单
|
||||
val noneGroup = JSONObject()
|
||||
noneGroup["name"] = "请选择分组类型"
|
||||
noneGroup["code"] = ""
|
||||
val yesGroup = JSONObject()
|
||||
yesGroup["name"] = "航程"
|
||||
yesGroup["code"] = "dest"
|
||||
val noGroup = JSONObject()
|
||||
noGroup["name"] = "库位"
|
||||
noGroup["code"] = "location"
|
||||
val dateGroup = JSONObject()
|
||||
dateGroup["name"] = "入库时间"
|
||||
dateGroup["code"] = "date"
|
||||
isGroupArr.add(noneGroup)
|
||||
isGroupArr.add(yesGroup)
|
||||
isGroupArr.add(noGroup)
|
||||
isGroupArr.add(dateGroup)
|
||||
//是否上舱单
|
||||
val noneCangDan = JSONObject()
|
||||
noneCangDan["name"] = "请选择"
|
||||
noneCangDan["code"] = ""
|
||||
val yesCangDan = JSONObject()
|
||||
yesCangDan["name"] = "是"
|
||||
yesCangDan["code"] = "1"
|
||||
val noCangDan = JSONObject()
|
||||
noCangDan["name"] = "否"
|
||||
noCangDan["code"] = "0"
|
||||
isCangDanArr.add(noneCangDan)
|
||||
isCangDanArr.add(yesCangDan)
|
||||
isCangDanArr.add(noCangDan)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_gnc_ware_house)
|
||||
initView()
|
||||
|
||||
//查询返回结果
|
||||
viewModel.searchParamLive.observe(this) {
|
||||
loadingCancel()
|
||||
//1.获取数据
|
||||
var listArr: JSONArray = it["list"] as JSONArray
|
||||
totalPage = it["pages"] as Int
|
||||
// var listArr :JSONArray =it["list"] as JSONArray
|
||||
if (listArr.size > 0) {
|
||||
//2.循环遍历塞入collectList
|
||||
listArr.forEach {
|
||||
val itemObj = it as JSONObject
|
||||
val whId = itemObj.getIntValue("whId")
|
||||
val no = itemObj.getString("wbNo") ?: ""
|
||||
val weight = itemObj.getDouble("weight")
|
||||
val pc = itemObj.getIntValue("pc")
|
||||
val fno = itemObj.getString("fno") ?: ""
|
||||
val opDate = itemObj.getString("opDate") ?: ""
|
||||
val locStatus = itemObj.getString("locStatus") ?: ""
|
||||
val dest = itemObj.getString("dest") ?: ""
|
||||
val location = itemObj.getString("location") ?: ""
|
||||
val days = itemObj.getIntValue("days")
|
||||
val gdate = itemObj.getString("gdate") ?: ""
|
||||
|
||||
var groupTitle = ""
|
||||
var groupName = ""
|
||||
var daysString: String? = null
|
||||
when (isGroupStatus) {
|
||||
"dest" -> {
|
||||
groupTitle = "目的港:"
|
||||
groupName = dest
|
||||
}
|
||||
"location" -> {
|
||||
groupTitle = "库位:"
|
||||
groupName = location
|
||||
}
|
||||
"date" -> {
|
||||
groupTitle = "入库时间:"
|
||||
groupName = "$gdate,入库天数:"
|
||||
daysString = days.toString()
|
||||
}
|
||||
else -> {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
collectList.add(GncWareHouseList(whId, no, location, pc, weight, fno, opDate, locStatus, groupTitle, groupName, daysString))
|
||||
}
|
||||
//3.调adpter展示
|
||||
if (currentPage == 1) {
|
||||
adapter.notifyDataSetChanged()
|
||||
} else {
|
||||
adapter.notifyItemRangeInserted((currentPage - 1) * 10, collectList.size)
|
||||
}
|
||||
refreshLayout.finishRefresh()
|
||||
refreshLayout.finishLoadMore()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//汇总返回结果
|
||||
viewModel.summaryObserver.observe(this) {
|
||||
loadingCancel()
|
||||
val status = it.getString("status")
|
||||
if (Constant.Result.succ == status) {
|
||||
var jsonObject = it.getJSONObject("data")
|
||||
val totalTemp = jsonObject.getIntValue("total")
|
||||
val totalPcTemp = jsonObject.getIntValue("pc")
|
||||
val totalWeightTemp = jsonObject.getDoubleValue("weight")
|
||||
summaryText.text = "总票数:$totalTemp,总件数:$totalPcTemp,总重量:$totalWeightTemp"
|
||||
} else {
|
||||
//无数据
|
||||
}
|
||||
}
|
||||
|
||||
//初始化查询
|
||||
searchFun()
|
||||
loading()
|
||||
|
||||
/////////////////////////////// 加载刷新的布局
|
||||
refreshLayout.setRefreshHeader(ClassicsHeader(this))
|
||||
refreshLayout.setRefreshFooter(ClassicsFooter(this))
|
||||
/////////////////////////////// 下拉刷新
|
||||
refreshLayout.setOnRefreshListener {
|
||||
refresh = true
|
||||
resetSearch()
|
||||
}
|
||||
/////////////////////////////// 上拉加载
|
||||
refreshLayout.setOnLoadMoreListener {
|
||||
refresh = false
|
||||
if (currentPage < totalPage) {
|
||||
currentPage++
|
||||
//初始化查询
|
||||
searchFun()
|
||||
} else {
|
||||
refreshLayout.finishLoadMoreWithNoMoreData()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
v?.let {
|
||||
when (it.id) {
|
||||
R.id.tool_back -> {
|
||||
if (searchListFragment.visibility == View.GONE && filtrateFragment.visibility == View.VISIBLE) {
|
||||
searchListFragment.visibility = View.VISIBLE
|
||||
filtrateFragment.visibility = View.GONE
|
||||
titleName.text = "国内出港仓库管理"
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
R.id.searchLayout -> {
|
||||
resetSearch()
|
||||
}
|
||||
R.id.filtrateLayout -> {
|
||||
if (searchListFragment.visibility == View.VISIBLE && filtrateFragment.visibility == View.GONE) {
|
||||
searchListFragment.visibility = View.GONE
|
||||
filtrateFragment.visibility = View.VISIBLE
|
||||
titleName.text = "搜索"
|
||||
} else {
|
||||
searchListFragment.visibility = View.VISIBLE
|
||||
filtrateFragment.visibility = View.GONE
|
||||
titleName.text = "国内出港仓库管理"
|
||||
}
|
||||
// Common.showToast(this,"筛选")
|
||||
}
|
||||
R.id.isGroup -> {
|
||||
Common.singleSelect(this, "分组类型", isGroupArr, isGroupStatus) { position, item ->
|
||||
val jsonObject = item as JSONObject
|
||||
val name = jsonObject.getString("name")
|
||||
val code = jsonObject.getString("code")
|
||||
isGroup.text = name
|
||||
isGroupStatus = code
|
||||
}
|
||||
// Common.showToast(this,"筛选")
|
||||
}
|
||||
R.id.isCangDan -> {
|
||||
Common.singleSelect(this, "是否上舱单", isCangDanArr, isCangDanStatus) { position, item ->
|
||||
val jsonObject = item as JSONObject
|
||||
val name = jsonObject.getString("name")
|
||||
val code = jsonObject.getString("code")
|
||||
isCangDan.text = name
|
||||
isCangDanStatus = code
|
||||
}
|
||||
// Common.showToast(this,"筛选")
|
||||
}
|
||||
R.id.submit -> {
|
||||
//筛选页隐藏
|
||||
searchListFragment.visibility = View.VISIBLE
|
||||
filtrateFragment.visibility = View.GONE
|
||||
titleName.text = "国内出港仓库管理"
|
||||
//搜索
|
||||
resetSearch()
|
||||
}
|
||||
R.id.reset -> {
|
||||
resetFun()
|
||||
}
|
||||
else -> {
|
||||
Toast.makeText(this, "未找到对应操作", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 搜索
|
||||
*/
|
||||
private fun searchFun() {
|
||||
viewModel.search(
|
||||
pageSize,
|
||||
currentPage,
|
||||
carrier.text.toString(),
|
||||
"",//startDate.text.toString(),
|
||||
"",//endDate.text.toString(),
|
||||
"",//flightDate.text.toString(),
|
||||
"",//flightNo.text.toString(),
|
||||
mudiGang.text.toString(),
|
||||
kuWei.text.toString(),
|
||||
"",
|
||||
isCangDanStatus,
|
||||
wayNo.text.toString(),
|
||||
isGroupStatus
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置数据,搜索
|
||||
*/
|
||||
private fun resetSearch() {
|
||||
//recyclerView 清除所有数据数据
|
||||
refreshLayout.setNoMoreData(false)
|
||||
adapter.notifyItemRangeRemoved(0, collectList.size)
|
||||
collectList.clear()
|
||||
currentPage = 1
|
||||
searchFun()
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置筛选条件
|
||||
*/
|
||||
private fun resetFun() {
|
||||
currentPage = 1
|
||||
carrier.setText("")
|
||||
mudiGang.setText("")
|
||||
kuWei.setText("")
|
||||
isCangDan.text = ""
|
||||
isCangDanStatus = ""
|
||||
wayNo.setText("")
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package com.lukouguoji.gnc.activity
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.core.widget.NestedScrollView
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.alibaba.android.arouter.facade.annotation.Autowired
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.adapt.GncWareHouseInfoListAdapter
|
||||
import com.lukouguoji.gnc.model.GncWareHouseInfo
|
||||
import com.lukouguoji.gnc.viewModel.GncWareHouseInfoViewModel
|
||||
import com.lukouguoji.module_base.BaseActivity
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_GNC_WARE_HOUSE_INFO)
|
||||
class GncWareHouseInfoActivity : BaseActivity(), View.OnClickListener {
|
||||
private lateinit var viewModel: GncWareHouseInfoViewModel
|
||||
|
||||
private lateinit var scrollView: NestedScrollView
|
||||
private lateinit var gncQueryInfoList: RecyclerView
|
||||
private lateinit var adapter: GncWareHouseInfoListAdapter
|
||||
private val queryInfoAdapterList = arrayListOf<GncWareHouseInfo>()
|
||||
|
||||
@JvmField
|
||||
@Autowired
|
||||
var id: Int = -9999
|
||||
|
||||
private fun initView() {
|
||||
viewModel = ViewModelProvider(this).get(GncWareHouseInfoViewModel::class.java)
|
||||
|
||||
scrollView = findViewById(R.id.scrollView)
|
||||
|
||||
val layoutManager = GridLayoutManager(this, 2)
|
||||
adapter = GncWareHouseInfoListAdapter(this, queryInfoAdapterList)
|
||||
gncQueryInfoList = findViewById(R.id.gncQueryInfoList)
|
||||
gncQueryInfoList.adapter = adapter
|
||||
gncQueryInfoList.layoutManager = layoutManager
|
||||
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_gnc_ware_house_info)
|
||||
setBackArrow("仓库管理详情")
|
||||
initView()
|
||||
|
||||
viewModel.queryInfoByIdWareHouse(id)
|
||||
viewModel.queryInfoByIdWareHouseObserver.observe(this) {
|
||||
val status = it.getString("status")
|
||||
if (Constant.Result.succ == status) {
|
||||
viewModel.wayBillInfo = it.getJSONObject("data")
|
||||
//运单号、
|
||||
adapter.append(GncWareHouseInfo(1, "运单号", viewModel.wayBillInfo.getString("wbNo") ?: ""))
|
||||
// 件数、
|
||||
adapter.append(GncWareHouseInfo(1, "件数", viewModel.wayBillInfo.getString("pc") ?: ""))
|
||||
// 重量、
|
||||
adapter.append(GncWareHouseInfo(1, "重量", "${viewModel.wayBillInfo.getDoubleValue("weight")} KG"))
|
||||
// 品名、
|
||||
adapter.append(GncWareHouseInfo(1, "品名", viewModel.wayBillInfo.getString("goods") ?: ""))
|
||||
// 特码、
|
||||
adapter.append(GncWareHouseInfo(1, "特码", viewModel.wayBillInfo.getString("spCode") ?: ""))
|
||||
// 代理人、
|
||||
adapter.append(GncWareHouseInfo(1, "代理人", viewModel.wayBillInfo.getString("agentCode") ?: ""))
|
||||
// 承运人、
|
||||
adapter.append(GncWareHouseInfo(1, "承运人", viewModel.wayBillInfo.getString("by1") ?: ""))
|
||||
//始发港、
|
||||
adapter.append(GncWareHouseInfo(1, "目的港", viewModel.wayBillInfo.getString("dest") ?: ""))
|
||||
// 航班、
|
||||
adapter.append(GncWareHouseInfo(1, "航班", viewModel.wayBillInfo.getString("flight") ?: ""))
|
||||
// 库位
|
||||
adapter.append(GncWareHouseInfo(1, "库位", viewModel.wayBillInfo.getString("location") ?: ""))
|
||||
// 运单类型、
|
||||
adapter.append(GncWareHouseInfo(1, "运单类型", viewModel.wayBillInfo.getString("awbType") ?: ""))
|
||||
// 业务类型、
|
||||
adapter.append(GncWareHouseInfo(1, "业务类型", viewModel.wayBillInfo.getString("businessType") ?: ""))
|
||||
// 包装类型
|
||||
adapter.append(GncWareHouseInfo(1, "包装类型", viewModel.wayBillInfo.getString("packageType") ?: ""))
|
||||
// 状态、
|
||||
// adapter.append(GncWareHouseInfo(1, "状态", viewModel.wayBillInfo.getString("ref") ?: ""))
|
||||
// 入库时间
|
||||
adapter.append(GncWareHouseInfo(1, "入库时间", viewModel.wayBillInfo.getString("opDate") ?: ""))
|
||||
|
||||
} else {
|
||||
//无数据
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
v?.let {
|
||||
when (it.id) {
|
||||
else -> {
|
||||
Toast.makeText(this, "未找到对应操作", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
package com.lukouguoji.gnc.activity
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.widget.EditText
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.alibaba.fastjson.JSONArray
|
||||
import com.alibaba.fastjson.JSONObject
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.adapt.GncChuKuListAdapter
|
||||
import com.lukouguoji.module_base.BaseActivity
|
||||
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
import com.lukouguoji.gnc.model.GncFuBangList
|
||||
import com.lukouguoji.gnc.viewModel.GoutFuBangListViewModel
|
||||
import com.lukouguoji.gnc.adapt.GncFuBangListAdapter
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.ninetripods.sydialoglib.IDialog
|
||||
import com.scwang.smart.refresh.footer.ClassicsFooter
|
||||
import com.scwang.smart.refresh.header.ClassicsHeader
|
||||
import com.scwang.smart.refresh.layout.api.RefreshLayout
|
||||
import java.util.*
|
||||
//出库装机操作页面
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_GOUT_CHU_KU_LIST_ACTIVITY)
|
||||
class GoutChuKuListActivity : BaseActivity() {
|
||||
public lateinit var viewModel: GoutFuBangListViewModel
|
||||
|
||||
private lateinit var adapter: GncChuKuListAdapter
|
||||
private val collectList = ArrayList<GncFuBangList>()
|
||||
|
||||
private var currentPage = 1
|
||||
private var pageSize = 10
|
||||
private var totalPage = 0
|
||||
private var text = ""
|
||||
private lateinit var refreshLayout: RefreshLayout
|
||||
private lateinit var search: TextView
|
||||
private lateinit var searchContent: EditText
|
||||
private lateinit var scanCodeImg: ImageView
|
||||
|
||||
//是否刷新
|
||||
private var refresh = false
|
||||
|
||||
|
||||
private fun initView() {
|
||||
viewModel = ViewModelProvider(this).get(GoutFuBangListViewModel::class.java)
|
||||
|
||||
search = findViewById(R.id.search)
|
||||
searchContent = findViewById(R.id.search_content)
|
||||
scanCodeImg = findViewById(R.id.scanCodeImg)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_fu_bang_list)
|
||||
setBackArrow("出库确认")
|
||||
initView()
|
||||
|
||||
val layoutManager = LinearLayoutManager(this)
|
||||
adapter = GncChuKuListAdapter(this, collectList)
|
||||
var recyclerView: RecyclerView = findViewById(R.id.guo_nei_collect_list)
|
||||
recyclerView.layoutManager = layoutManager
|
||||
recyclerView.adapter = adapter
|
||||
viewModel.chukuParamLive.observe(this){
|
||||
loadingCancel();
|
||||
}
|
||||
viewModel.loadParamLive.observe(this){
|
||||
loadingCancel();
|
||||
}
|
||||
viewModel.searchParamLive.observe(this) {
|
||||
loadingCancel()
|
||||
//1.获取数据
|
||||
var listArr: JSONArray = it["list"] as JSONArray
|
||||
totalPage = it["pages"] as Int
|
||||
// var listArr :JSONArray =it["list"] as JSONArray
|
||||
if (listArr.size > 0) {
|
||||
//2.循环遍历塞入collectList
|
||||
listArr.forEach {
|
||||
val itemObj = it as JSONObject
|
||||
val useId = itemObj.getIntValue("useId")
|
||||
val carId = itemObj.getString("carId") ?: ""
|
||||
val fno = itemObj.getString("fno") ?: ""
|
||||
val dest = itemObj.getString("fdest") ?: ""
|
||||
val totalWeight = itemObj.getDoubleValue("totalWeight")
|
||||
val volume = itemObj.getDoubleValue("volume")
|
||||
val pc = itemObj.getIntValue("pc")
|
||||
val reviewer = itemObj.getString("reviewer") ?: ""
|
||||
val opDate = itemObj.getString("opDate") ?: ""
|
||||
val outer = itemObj.getString("outer") ?: ""
|
||||
val loader = itemObj.getString("loader") ?: ""
|
||||
collectList.add(GncFuBangList(useId, carId,fno,dest, totalWeight, volume, pc, opDate,reviewer,outer,loader))
|
||||
}
|
||||
//3.调adpter展示
|
||||
if (currentPage == 1) {
|
||||
adapter.notifyDataSetChanged()
|
||||
} else {
|
||||
adapter.notifyItemRangeInserted((currentPage - 1) * 10, collectList.size)
|
||||
}
|
||||
refreshLayout.finishRefresh()
|
||||
refreshLayout.finishLoadMore()
|
||||
|
||||
}
|
||||
}
|
||||
//初始化查询
|
||||
viewModel.search(pageSize, currentPage, text,"2")
|
||||
loading()
|
||||
|
||||
/////////////////////////////// 加载刷新的布局
|
||||
refreshLayout = findViewById<View>(R.id.refreshLayout) as RefreshLayout
|
||||
refreshLayout.setRefreshHeader(ClassicsHeader(this))
|
||||
refreshLayout.setRefreshFooter(ClassicsFooter(this))
|
||||
/////////////////////////////// 下拉刷新
|
||||
refreshLayout.setOnRefreshListener {
|
||||
refresh = true
|
||||
currentPage = 1
|
||||
//recyclerView 清除所有数据数据
|
||||
adapter.notifyItemRangeRemoved(0, collectList.size)
|
||||
collectList.clear()
|
||||
//初始化查询
|
||||
viewModel.search(pageSize, currentPage, text,"2")
|
||||
adapter.notifyItemRangeInserted(0, collectList.size)
|
||||
}
|
||||
/////////////////////////////// 上拉加载
|
||||
refreshLayout.setOnLoadMoreListener {
|
||||
refresh = false
|
||||
if (currentPage < totalPage) {
|
||||
currentPage++
|
||||
//初始化查询
|
||||
viewModel.search(pageSize, currentPage, text,"2")
|
||||
} else {
|
||||
refreshLayout.finishLoadMoreWithNoMoreData()
|
||||
}
|
||||
}
|
||||
|
||||
search.setOnClickListener {
|
||||
currentPage = 1
|
||||
//recyclerView 清除所有数据数据
|
||||
adapter.notifyItemRangeRemoved(0, collectList.size)
|
||||
collectList.clear()
|
||||
//初始化查询
|
||||
viewModel.search(pageSize, currentPage, searchContent.text.toString(),"2")
|
||||
}
|
||||
|
||||
|
||||
//点击扫码
|
||||
scanCodeImg.setOnClickListener {
|
||||
scanCode(Constant.RequestCode.gnc_fubang_search)
|
||||
}
|
||||
}
|
||||
public fun ChuKu(useId:Int,carId:String)
|
||||
{
|
||||
Common.secondConfirmDialog(this,"板车:"+carId+"确定完成出库吗?")
|
||||
{dialog-> dialog.dismiss()
|
||||
viewModel.chuku(useId,carId)
|
||||
Common.showToastLong(this, carId+"出库成功!")
|
||||
currentPage = 1
|
||||
//recyclerView 清除所有数据数据
|
||||
adapter.notifyItemRangeRemoved(0, collectList.size)
|
||||
collectList.clear()
|
||||
//初始化查询
|
||||
viewModel.search(pageSize, currentPage, searchContent.text.toString(),"2")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
|
||||
// 扫描二维码/条码回传
|
||||
if (requestCode == Constant.RequestCode.gnc_fubang_search && resultCode == RESULT_OK) {
|
||||
if (data != null) {
|
||||
val content = data.getStringExtra(com.yzq.zxinglibrary.common.Constant.CODED_CONTENT)
|
||||
searchContent.setText("$content")
|
||||
|
||||
//调用接口查询进入详情页
|
||||
if (content != null && content != "") {
|
||||
Log.i("刷新:${content}",content.toString())
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GOUT_FU_BANG_ACTIVITY).withString("carNoParam", content)
|
||||
.navigation(this, Constant.RequestCode.gnc_shouyun_list_refresh)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (requestCode == Constant.RequestCode.gnc_shouyun_list_refresh && resultCode == RESULT_OK) {
|
||||
collectList.clear()
|
||||
currentPage = 1
|
||||
refreshLayout.setNoMoreData(false)
|
||||
viewModel.search(10, currentPage, "","2")
|
||||
loading()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,364 @@
|
||||
package com.lukouguoji.gnc.activity
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.alibaba.fastjson.JSONArray
|
||||
import com.alibaba.fastjson.JSONObject
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.adapt.GoutCollectionAdapter
|
||||
import com.lukouguoji.gnc.model.GuoNeiOutCollect
|
||||
import com.lukouguoji.gnc.page.shouyun.list.GncShouYunListActivity
|
||||
import com.lukouguoji.gnc.viewModel.GoutCollectionViewModel
|
||||
import com.lukouguoji.module_base.BaseActivity
|
||||
import com.lukouguoji.module_base.MyApplication
|
||||
import com.lukouguoji.module_base.adapter.bindAdapter
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.scwang.smart.refresh.footer.ClassicsFooter
|
||||
import com.scwang.smart.refresh.header.ClassicsHeader
|
||||
import com.scwang.smart.refresh.layout.api.RefreshLayout
|
||||
import com.yzq.zxinglibrary.common.Constant
|
||||
import dev.utils.app.info.KeyValue
|
||||
import dev.utils.common.StringUtils
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_GOUT_COLLECTION_ACTIVITY)
|
||||
class GoutCollectionActivity : BaseActivity(), View.OnClickListener {
|
||||
|
||||
private lateinit var adapter: GoutCollectionAdapter
|
||||
private val collectList = ArrayList<GuoNeiOutCollect>()
|
||||
|
||||
private var currentPage = 1
|
||||
private var pageSize = 10
|
||||
private var totalPage = 0
|
||||
private var text = ""
|
||||
private lateinit var refreshLayout: RefreshLayout
|
||||
|
||||
//标题
|
||||
private lateinit var toolBack: LinearLayout
|
||||
private lateinit var titleName: TextView
|
||||
|
||||
private lateinit var searchListFragment: LinearLayout
|
||||
private lateinit var filtrateFragment: LinearLayout
|
||||
private lateinit var filtrateLayout: LinearLayout
|
||||
private lateinit var dest: EditText
|
||||
|
||||
private lateinit var agentCode: Spinner
|
||||
private var agentCodeValue = ""
|
||||
private lateinit var spCode: Spinner
|
||||
private var spCodeValue = ""
|
||||
|
||||
private lateinit var search: LinearLayout
|
||||
private lateinit var add: LinearLayout
|
||||
private lateinit var searchContent: EditText
|
||||
private lateinit var scanCodeImg: ImageView
|
||||
private lateinit var fdate: TextView
|
||||
|
||||
private val ymdSdf = SimpleDateFormat("yyyy-MM-dd")//年月日
|
||||
private val ymdHmsSdf = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")//年月日 时分秒
|
||||
private val calendar = Calendar.getInstance()
|
||||
|
||||
//是否刷新
|
||||
private var refresh = false
|
||||
private lateinit var viewModel: GoutCollectionViewModel
|
||||
|
||||
val topTitleName = "国内出港待收运"
|
||||
|
||||
private fun initView() {
|
||||
|
||||
//标题
|
||||
toolBack = findViewById(R.id.tool_back)
|
||||
titleName = findViewById(R.id.title_name)
|
||||
titleName.text = topTitleName
|
||||
|
||||
agentCode = findViewById(R.id.agentCode)
|
||||
spCode = findViewById(R.id.spCode)
|
||||
|
||||
search = findViewById(R.id.search)
|
||||
searchListFragment = findViewById(R.id.searchListFragment)
|
||||
filtrateFragment = findViewById(R.id.filtrateFragment)
|
||||
filtrateLayout = findViewById(R.id.filtrateLayout)
|
||||
add = findViewById(R.id.add)
|
||||
dest = findViewById(R.id.dest)
|
||||
searchContent = findViewById(R.id.search_content)
|
||||
scanCodeImg = findViewById(R.id.scanCodeImg)
|
||||
fdate = findViewById(R.id.fdate)
|
||||
|
||||
|
||||
toolBack.setOnClickListener(this)
|
||||
search.setOnClickListener(this)
|
||||
add.setOnClickListener(this)
|
||||
fdate.setOnClickListener(this)
|
||||
filtrateLayout.setOnClickListener(this)
|
||||
findViewById<View>(R.id.shouyun).setOnClickListener(this)
|
||||
|
||||
|
||||
|
||||
viewModel.agentCode(System.currentTimeMillis().toString())
|
||||
viewModel.agentCodeObserver.observe(this) { vd ->
|
||||
viewModel.agentCodeList.clear()
|
||||
viewModel.agentCodeList.addAll(vd.getJSONArray("data"))
|
||||
initSpinner(agentCode, viewModel.agentCodeList, null, "请选择代理人")
|
||||
}
|
||||
|
||||
viewModel.specialCode(System.currentTimeMillis().toString())
|
||||
viewModel.specialCodeObserver.observe(this) { vd ->
|
||||
viewModel.specialCodeList.clear()
|
||||
viewModel.specialCodeList.addAll(vd.getJSONArray("data"))
|
||||
initSpinner(spCode, viewModel.specialCodeList, null, "请选择特码")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_check_in_list)
|
||||
viewModel = ViewModelProvider(this).get(GoutCollectionViewModel::class.java)
|
||||
initView()
|
||||
|
||||
|
||||
val layoutManager = LinearLayoutManager(this)
|
||||
adapter = GoutCollectionAdapter(this, collectList)
|
||||
var recyclerView: RecyclerView = findViewById(R.id.guo_nei_collect_list)
|
||||
recyclerView.layoutManager = layoutManager
|
||||
recyclerView.adapter = adapter
|
||||
|
||||
viewModel.searchParamLive.observe(this) {
|
||||
loadingCancel()
|
||||
//1.获取数据
|
||||
var listArr: JSONArray = it["list"] as JSONArray
|
||||
totalPage = it["pages"] as Int
|
||||
// var listArr :JSONArray =it["list"] as JSONArray
|
||||
if (listArr.size > 0) {
|
||||
//2.循环遍历塞入collectList
|
||||
listArr.forEach {
|
||||
val itemObj = it as JSONObject
|
||||
val mawbId = itemObj.getIntValue("mawbId")
|
||||
val wbNo = itemObj.getString("wbNo") ?: ""
|
||||
val agentCode = itemObj.getString("agentCode") ?: ""
|
||||
val dest = itemObj.getString("dest") ?: ""
|
||||
val spCode = itemObj.getString("pc") ?: ""
|
||||
val goods = itemObj.getString("goods") ?: ""
|
||||
//todo 增加预计起飞并且升序显示
|
||||
val planDate = itemObj.getString("estimatedTakeOff") ?: ""
|
||||
val flight = itemObj.getString("flight") ?: ""
|
||||
val range = itemObj.getString("range") ?: ""
|
||||
|
||||
collectList.add(
|
||||
GuoNeiOutCollect(
|
||||
mawbId,
|
||||
wbNo,
|
||||
dest,
|
||||
agentCode,
|
||||
spCode,
|
||||
goods,
|
||||
planDate,
|
||||
range,
|
||||
flight
|
||||
)
|
||||
)
|
||||
}
|
||||
//3.调adpter展示
|
||||
if (currentPage == 1) {
|
||||
adapter.notifyDataSetChanged()
|
||||
} else {
|
||||
adapter.notifyItemRangeInserted((currentPage - 1) * 10, collectList.size)
|
||||
}
|
||||
refreshLayout.finishRefresh()
|
||||
refreshLayout.finishLoadMore()
|
||||
|
||||
}
|
||||
}
|
||||
//初始化查询
|
||||
viewModel.search(pageSize, currentPage, text)
|
||||
loading()
|
||||
|
||||
/////////////////////////////// 加载刷新的布局
|
||||
refreshLayout = findViewById<View>(R.id.refreshLayout) as RefreshLayout
|
||||
refreshLayout.setRefreshHeader(ClassicsHeader(this))
|
||||
refreshLayout.setRefreshFooter(ClassicsFooter(this))
|
||||
/////////////////////////////// 下拉刷新
|
||||
refreshLayout.setOnRefreshListener {
|
||||
refresh = true
|
||||
currentPage = 1
|
||||
//recyclerView 清除所有数据数据
|
||||
adapter.notifyItemRangeRemoved(0, collectList.size)
|
||||
collectList.clear()
|
||||
//初始化查询
|
||||
viewModel.search(pageSize, currentPage, text)
|
||||
adapter.notifyItemRangeInserted(0, collectList.size)
|
||||
}
|
||||
/////////////////////////////// 上拉加载
|
||||
refreshLayout.setOnLoadMoreListener {
|
||||
refresh = false
|
||||
if (currentPage < totalPage) {
|
||||
currentPage++
|
||||
//初始化查询
|
||||
viewModel.search(pageSize, currentPage, text)
|
||||
} else {
|
||||
refreshLayout.finishLoadMoreWithNoMoreData()
|
||||
}
|
||||
}
|
||||
|
||||
search.setOnClickListener {
|
||||
currentPage = 1
|
||||
//recyclerView 清除所有数据数据
|
||||
adapter.notifyItemRangeRemoved(0, collectList.size)
|
||||
collectList.clear()
|
||||
//初始化查询
|
||||
viewModel.search(pageSize, currentPage, searchContent.text.toString())
|
||||
}
|
||||
|
||||
|
||||
//点击扫码
|
||||
scanCodeImg.setOnClickListener {
|
||||
scanCode(com.lukouguoji.module_base.common.Constant.RequestCode.gnc_shouyun_search)
|
||||
}
|
||||
searchContent.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
|
||||
if (s.toString() != "" && s.toString().length == 12) {
|
||||
ARouter.getInstance()
|
||||
.build(ARouterConstants.ACTIVITY_URL_GOUT_START_COT_ACTIVITY)
|
||||
.withString("wbNoParam", s.toString())
|
||||
.navigation(MyApplication.context)
|
||||
}
|
||||
}
|
||||
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
|
||||
// 扫描二维码/条码回传
|
||||
if (requestCode == com.lukouguoji.module_base.common.Constant.RequestCode.gnc_shouyun_search && resultCode == RESULT_OK) {
|
||||
if (data != null) {
|
||||
val content = data.getStringExtra(Constant.CODED_CONTENT)
|
||||
searchContent.setText("$content")
|
||||
|
||||
//调用接口查询进入详情页
|
||||
if (content != null && content != "") {
|
||||
ARouter.getInstance()
|
||||
.build(ARouterConstants.ACTIVITY_URL_GOUT_START_COT_ACTIVITY)
|
||||
.withString("wbNoParam", content)
|
||||
.navigation(this)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (requestCode == com.lukouguoji.module_base.common.Constant.RequestCode.gnc_shouyun_refresh && resultCode == RESULT_OK) {
|
||||
collectList.clear()
|
||||
currentPage = 1
|
||||
refreshLayout.setNoMoreData(false)
|
||||
viewModel.search(10, 1, "")
|
||||
loading()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
v?.let {
|
||||
when (it.id) {
|
||||
R.id.tool_back -> {
|
||||
if (searchListFragment.visibility == View.GONE && filtrateFragment.visibility == View.VISIBLE) {
|
||||
searchListFragment.visibility = View.VISIBLE
|
||||
filtrateFragment.visibility = View.GONE
|
||||
titleName.text = topTitleName
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
R.id.search -> {
|
||||
|
||||
}
|
||||
R.id.filtrateLayout -> {
|
||||
if (searchListFragment.visibility == View.VISIBLE && filtrateFragment.visibility == View.GONE) {
|
||||
searchListFragment.visibility = View.GONE
|
||||
filtrateFragment.visibility = View.VISIBLE
|
||||
titleName.text = "搜索"
|
||||
} else {
|
||||
searchListFragment.visibility = View.VISIBLE
|
||||
filtrateFragment.visibility = View.GONE
|
||||
titleName.text = topTitleName
|
||||
}
|
||||
// Common.showToast(this,"筛选")
|
||||
}
|
||||
R.id.add -> {
|
||||
ARouter.getInstance()
|
||||
.build(ARouterConstants.ACTIVITY_URL_GOUT_START_COT_ACTIVITY)
|
||||
.withString("wbNoParam", "")
|
||||
.navigation(MyApplication.context)
|
||||
}
|
||||
|
||||
R.id.shouyun -> {
|
||||
GncShouYunListActivity.start(this)
|
||||
}
|
||||
|
||||
R.id.fdate -> {
|
||||
Common.onYearMonthDay(this, fdate.text.toString()) { year, month, day ->
|
||||
calendar.set(year, month - 1, day)
|
||||
fdate.text = ymdSdf.format(calendar.time)
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
Toast.makeText(this, "未找到对应操作", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun initSpinner(sp: Spinner, dataListArr: JSONArray, selPosition: Int?, hint: String?) {
|
||||
val jsonObjectList: List<JSONObject> = (0 until dataListArr.size).map { dataListArr.getJSONObject(it) }
|
||||
val dataList: List<KeyValue> = jsonObjectList.map { KeyValue(it.getString("name"),it.getString("code")) }
|
||||
|
||||
bindAdapter(sp, dataList, hint, null)
|
||||
selPosition?.let { sp.setSelection(it) }
|
||||
//给下拉框设置选择监听器,一旦用户选中某一项,就触发监听器的onItemSelected方法
|
||||
sp.onItemSelectedListener = MySelectedListener(sp.id, hint)
|
||||
}
|
||||
|
||||
/**
|
||||
* 下拉框监听
|
||||
*/
|
||||
inner class MySelectedListener(private val spinnerView: Int, val hint: String?) : AdapterView.OnItemSelectedListener {
|
||||
override fun onItemSelected(adapterView: AdapterView<*>?, view: View, i: Int, l: Long) {
|
||||
when (spinnerView) {
|
||||
R.id.agentCode -> {
|
||||
agentCodeValue = if (StringUtils.isNotEmpty(hint) && i == viewModel.agentCodeList.size) {
|
||||
""
|
||||
} else {
|
||||
viewModel.agentCodeList.getJSONObject(i).getString("code")
|
||||
}
|
||||
}
|
||||
R.id.spCode -> {
|
||||
spCodeValue = if (StringUtils.isNotEmpty(hint) && i == viewModel.specialCodeList.size) {
|
||||
""
|
||||
} else {
|
||||
viewModel.specialCodeList.getJSONObject(i).getString("code")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onNothingSelected(adapterView: AdapterView<*>?) {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,519 @@
|
||||
package com.lukouguoji.gnc.activity
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.alibaba.android.arouter.facade.annotation.Autowired
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.alibaba.fastjson.JSONArray
|
||||
import com.alibaba.fastjson.JSONObject
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.bluetooth.bean.LabelBean
|
||||
import com.lukouguoji.gnc.viewModel.GoutFuBangViewModel
|
||||
import com.lukouguoji.module_base.BaseActivity
|
||||
import com.lukouguoji.module_base.adapter.bindAdapter
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.lukouguoji.module_base.util.NumberUtil
|
||||
import dev.utils.app.JSONObjectUtils.getJSONObject
|
||||
import dev.utils.app.info.KeyValue
|
||||
import dev.utils.common.StringUtils
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_GOUT_FU_BANG_ACTIVITY)
|
||||
class GoutFuBangActivity : BaseActivity(), View.OnClickListener {
|
||||
private lateinit var checkintongdao:Spinner
|
||||
private lateinit var viewModel: GoutFuBangViewModel
|
||||
|
||||
private lateinit var carNo: EditText
|
||||
private lateinit var carNoScan: ImageView
|
||||
private lateinit var dibangWeight: TextView
|
||||
private lateinit var dibangWeightScan: ImageView
|
||||
|
||||
//第一列
|
||||
private lateinit var cankaozhi: EditText
|
||||
private lateinit var volume: EditText
|
||||
private lateinit var pingbanWeight: EditText
|
||||
private lateinit var level: EditText
|
||||
private lateinit var uld: EditText
|
||||
|
||||
private lateinit var boardType: Spinner
|
||||
|
||||
//第二列
|
||||
private lateinit var currentWeight: EditText
|
||||
private lateinit var hangban: EditText
|
||||
private lateinit var cangwei: EditText
|
||||
private lateinit var uldWeight: EditText
|
||||
|
||||
//第三列
|
||||
private lateinit var offset: EditText
|
||||
private lateinit var mudiGang: EditText
|
||||
private lateinit var number: EditText
|
||||
private lateinit var youjian: EditText
|
||||
private lateinit var fdate: EditText
|
||||
|
||||
private lateinit var cargoType: Spinner
|
||||
|
||||
|
||||
private lateinit var remark: EditText
|
||||
private lateinit var submit: TextView
|
||||
private lateinit var labelPrint: CheckBox
|
||||
@JvmField
|
||||
@Autowired
|
||||
var carNoParam: String? = null
|
||||
|
||||
@JvmField
|
||||
@Autowired
|
||||
var userIdParam: String? = null
|
||||
|
||||
private fun initView() {
|
||||
checkintongdao=findViewById(R.id.checkin_tong_dao)
|
||||
carNo = findViewById(R.id.carNo)
|
||||
carNoScan = findViewById(R.id.carNoScan)
|
||||
dibangWeight = findViewById(R.id.dibangWeight)
|
||||
dibangWeightScan = findViewById(R.id.dibang_weight_scan)
|
||||
cankaozhi = findViewById(R.id.cankaozhi)
|
||||
volume = findViewById(R.id.volume)
|
||||
pingbanWeight = findViewById(R.id.pingbanWeight)
|
||||
level = findViewById(R.id.level)
|
||||
uld = findViewById(R.id.uld)
|
||||
currentWeight = findViewById(R.id.currentWeight)
|
||||
hangban = findViewById(R.id.hangban)
|
||||
cangwei = findViewById(R.id.cangwei)
|
||||
cargoType = findViewById(R.id.cargoType)
|
||||
boardType = findViewById(R.id.boardType)
|
||||
uldWeight = findViewById(R.id.uldWeight)
|
||||
offset = findViewById(R.id.offset)
|
||||
mudiGang = findViewById(R.id.mudiGang)
|
||||
number = findViewById(R.id.number)
|
||||
youjian = findViewById(R.id.youjian)
|
||||
fdate = findViewById(R.id.fdate)
|
||||
remark = findViewById(R.id.remark)
|
||||
submit = findViewById(R.id.submit)
|
||||
labelPrint=findViewById(R.id.label_print)
|
||||
carNoScan.setOnClickListener(this)
|
||||
dibangWeightScan.setOnClickListener(this)
|
||||
submit.setOnClickListener(this)
|
||||
labelPrint.setOnClickListener(this)
|
||||
///////////// 监听edittext变化
|
||||
/*
|
||||
dibangWeight.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
currentWeight.setText(s.toString())
|
||||
if (s != null && s.toString().trim() != "") {
|
||||
//当前净重 地磅称重 – 平板自重 或者 当前净重 = 地磅称重 – ULD自重 (平板车和ULD只会存在一种)
|
||||
var realWeight = s.toString().toDouble()
|
||||
if (pingbanWeight.text != null && pingbanWeight.text.toString() != "") {
|
||||
realWeight -= pingbanWeight.text.toString().toDouble()
|
||||
}
|
||||
if (uldWeight.text != null && uldWeight.text.toString() != "") {
|
||||
realWeight -= uldWeight.text.toString().toDouble()
|
||||
}
|
||||
currentWeight.setText(realWeight.toString())
|
||||
if(Math.abs(cankaozhi.text.toString().toDouble() - realWeight)<=6)
|
||||
{
|
||||
offset.setText(0.toString())
|
||||
return
|
||||
}
|
||||
//偏差 (参考净值-当前净重) / 当前净重 * 100
|
||||
var offsetValue = 0.0
|
||||
if (cankaozhi.text != null && cankaozhi.text.toString() != "" && realWeight != 0.0) {
|
||||
offsetValue = Arith.mul(Arith.div((cankaozhi.text.toString().toDouble() - realWeight), realWeight, 3), 100.0)
|
||||
}
|
||||
offset.setText(offsetValue.toString())
|
||||
}
|
||||
}
|
||||
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
|
||||
}
|
||||
})
|
||||
*/
|
||||
|
||||
carNo.setOnFocusChangeListener { _, hasFocus ->
|
||||
if (hasFocus) {
|
||||
// 此处为得到焦点时的处理内容
|
||||
} else {
|
||||
if (carNo.text != null && carNo.text.toString() != "") {
|
||||
viewModel.queryWaybillById(carNo.text.toString(), null)
|
||||
}
|
||||
}
|
||||
}
|
||||
//设置点击事件
|
||||
checkintongdao.onItemSelectedListener= object : AdapterView.OnItemSelectedListener {
|
||||
override fun onItemSelected(
|
||||
parent: AdapterView<*>?,
|
||||
view: View?,
|
||||
position: Int,
|
||||
id: Long
|
||||
) {
|
||||
if(position>=0){
|
||||
if (parent != null) {
|
||||
// Toast(this,"选中游戏:${parent.getItemAtPosition(position).toString()}")
|
||||
viewModel.setWeightName(parent.getItemAtPosition(position).toString()) // weightName tongdaoName=
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onNothingSelected(parent: AdapterView<*>?) {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_fu_bang)
|
||||
setBackArrow("国内出港开始复磅")
|
||||
initView()
|
||||
viewModel = ViewModelProvider(this).get(GoutFuBangViewModel::class.java)
|
||||
|
||||
|
||||
viewModel.queryWaybillById(carNoParam, userIdParam)
|
||||
viewModel.carDataObserver.observe(this) {
|
||||
val status = it.getString("status")
|
||||
if (Constant.Result.succ == status) {
|
||||
val jsonObject = it.getJSONObject("data")
|
||||
viewModel.fuBangInfoFormNetWork = jsonObject
|
||||
|
||||
/*
|
||||
tw:2022年5月5日22:25:55 不需要对checkFlag判断,10天后可删除
|
||||
val checkFlag = jsonObject.getString("checkFlag")//Default ‘0’记录确认状态(0:未复磅;1:复磅确认;2:二次复磅;3:配载确认
|
||||
if (checkFlag == "1") {
|
||||
Common.showToast(this, "该平板车已复磅,不可再复磅!")
|
||||
return@observe
|
||||
}*/
|
||||
|
||||
viewModel.fuBangInfo.userId = jsonObject.getIntValue("userId")
|
||||
viewModel.fuBangInfo.carId = jsonObject.getString("carId") ?: ""
|
||||
viewModel.fuBangInfo.maxWeight = jsonObject.getDoubleValue("maxWeight")
|
||||
viewModel.fuBangInfo.netWeight = jsonObject.getDoubleValue("netWeight")
|
||||
viewModel.fuBangInfo.carWeight = jsonObject.getDoubleValue("carWeight")
|
||||
viewModel.fuBangInfo.volume = jsonObject.getDoubleValue("volume")
|
||||
viewModel.fuBangInfo.mailWeight = jsonObject.getDoubleValue("mailWeight")
|
||||
viewModel.fuBangInfo.pc = jsonObject.getIntValue("pc")
|
||||
viewModel.fuBangInfo.flight = jsonObject.getString("flight") ?: ""
|
||||
viewModel.fuBangInfo.flight = jsonObject.getString("flight") ?: ""
|
||||
viewModel.fuBangInfo.priority = jsonObject.getIntValue("priority")
|
||||
viewModel.fuBangInfo.fdest = jsonObject.getString("fdest") ?: ""
|
||||
viewModel.fuBangInfo.fdate = jsonObject.getString("fdate") ?: ""
|
||||
viewModel.fuBangInfo.location = jsonObject.getString("location") ?: ""
|
||||
viewModel.fuBangInfo.cargoType = jsonObject.getString("cargoType") ?: ""
|
||||
viewModel.fuBangInfo.uld = jsonObject.getString("uld") ?: ""
|
||||
viewModel.fuBangInfo.uldWeight = jsonObject.getDoubleValue("uldWeight")
|
||||
viewModel.fuBangInfo.boardType = jsonObject.getString("boardType") ?: ""
|
||||
viewModel.fuBangInfo.remark = jsonObject.getString("remark") ?: ""
|
||||
|
||||
carNo.setText(viewModel.fuBangInfo.carId)
|
||||
uld.setText(viewModel.fuBangInfo.uld)
|
||||
uldWeight.setText(viewModel.fuBangInfo.uldWeight.toString())
|
||||
cankaozhi.setText(viewModel.fuBangInfo.netWeight.toString())
|
||||
// currentWeight.setText("")
|
||||
var offsetValue = 0.0
|
||||
if (viewModel.fuBangInfo.maxWeight != null && viewModel.fuBangInfo.netWeight != null) {
|
||||
offsetValue = viewModel.fuBangInfo.maxWeight!! - viewModel.fuBangInfo.netWeight!!
|
||||
}
|
||||
offset.setText(offsetValue.toString())
|
||||
volume.setText(viewModel.fuBangInfo.volume.toString())
|
||||
pingbanWeight.setText(viewModel.fuBangInfo.carWeight.toString())
|
||||
level.setText(viewModel.fuBangInfo.priority.toString())
|
||||
hangban.setText(viewModel.fuBangInfo.flight)
|
||||
cangwei.setText(viewModel.fuBangInfo.location)
|
||||
mudiGang.setText(viewModel.fuBangInfo.fdest)
|
||||
number.setText(viewModel.fuBangInfo.pc.toString())
|
||||
youjian.setText(viewModel.fuBangInfo.mailWeight.toString())
|
||||
fdate.setText(viewModel.fuBangInfo.fdate)
|
||||
|
||||
remark.setText(viewModel.fuBangInfo.remark)
|
||||
|
||||
//货物类型 下拉框赋值
|
||||
viewModel.cargoSelect(System.currentTimeMillis().toString())
|
||||
viewModel.cargoObserver.observe(this) { vd ->
|
||||
viewModel.cargoList = vd.getJSONArray("data")
|
||||
var position = 0
|
||||
for ((index, obj) in viewModel.cargoList.withIndex()) {
|
||||
val tempObj = obj as JSONObject
|
||||
val name = tempObj.getString("name")
|
||||
val code = tempObj.getString("code")
|
||||
if (viewModel.fuBangInfo.cargoType == code) {
|
||||
position = index
|
||||
}
|
||||
}
|
||||
initSpinner(cargoType, viewModel.cargoList, position,null)
|
||||
}
|
||||
|
||||
//板型类型 下拉框赋值
|
||||
viewModel.boardSelect(System.currentTimeMillis().toString())
|
||||
viewModel.boardObserver.observe(this) { vd ->
|
||||
viewModel.boardList = vd.getJSONArray("data")
|
||||
var position = 0
|
||||
for ((index, obj) in viewModel.boardList.withIndex()) {
|
||||
val tempObj = obj as JSONObject
|
||||
val name = tempObj.getString("name")
|
||||
val code = tempObj.getString("code")
|
||||
if (viewModel.fuBangInfo.boardType == code) {
|
||||
position = index
|
||||
}
|
||||
}
|
||||
initSpinner(boardType, viewModel.boardList, position,null)
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
//无数据
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.weightDataObserver.observe(this){ vd->
|
||||
dibangWeight.setText(vd)
|
||||
}
|
||||
//监听完成复磅
|
||||
viewModel.completedObserver.observe(this) {
|
||||
loadingCancel()
|
||||
val status = it.getString("status")
|
||||
val data = it.getString("data")
|
||||
if (Constant.Result.succ == status) {
|
||||
if (data == "1") {
|
||||
|
||||
print()
|
||||
carNo.setText("")
|
||||
Common.alertDialog(this, "完成复磅!") { dialog ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
} else if (data == "2") {
|
||||
Common.alertDialog(this, "板车不存在!") { dialog ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
||||
} else if (data == "3") {
|
||||
Common.alertDialog(this, "航班不存在!") { dialog ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
||||
} else if (data == "4") {
|
||||
Common.alertDialog(this, "航班已关闭!") { dialog ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
||||
} else if (data == "4") {
|
||||
Common.alertDialog(this, "航班已截载!") { dialog ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
||||
} else {
|
||||
Common.alertDialog(this, "复磅失败!") { dialog ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Common.showToastLong(this, "收运失败! ")
|
||||
Common.alertDialog(this, "复磅失败!") { dialog ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
viewModel.weightThread.start()
|
||||
}
|
||||
fun print(){
|
||||
var date=Date()
|
||||
var format=SimpleDateFormat("yyyy年MM月dd日")
|
||||
var numberUtil= NumberUtil()
|
||||
var label= LabelBean (
|
||||
titleName = "扬州泰州机场",
|
||||
dest = mudiGang.text.toString(),
|
||||
carId = carNo.text.toString(),
|
||||
fno = hangban.text.toString(),
|
||||
pc = number.text.toString(),
|
||||
weight = cankaozhi.text.toString(),
|
||||
volume = volume.text.toString(),
|
||||
location = cangwei.text.toString(),
|
||||
opdate = fdate .text.toString()
|
||||
)
|
||||
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_Printer_ACTIVITY).withObject("label",label)
|
||||
.navigation(this)
|
||||
}
|
||||
override fun onDestroy() {
|
||||
viewModel. weightThread.interrupt();
|
||||
super.onDestroy()
|
||||
}
|
||||
override fun onClick(v: View?) {
|
||||
v?.let {
|
||||
when (it.id) {
|
||||
R.id.carNoScan -> {
|
||||
scanCode(Constant.RequestCode.gnc_fubang_car_no)
|
||||
}
|
||||
R.id.dibang_weight_scan -> {
|
||||
dibangWeight.setText("")
|
||||
}
|
||||
R.id.submit -> {
|
||||
if (getAllEditData()) {
|
||||
Common.secondConfirmDialog(this, "确认复磅") { dialog ->
|
||||
viewModel.completed(viewModel.fuBangInfo)
|
||||
dialog.dismiss()
|
||||
loading()
|
||||
}
|
||||
}
|
||||
}
|
||||
R.id.label_print -> {
|
||||
//todo 打印挂签
|
||||
// print()
|
||||
}
|
||||
else -> {
|
||||
Toast.makeText(this, "未找到对应操作", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 扫码返回的结果
|
||||
*/
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
// 扫描二维码/条码回传
|
||||
if (resultCode == RESULT_OK && data != null) {
|
||||
val content = data.getStringExtra(com.yzq.zxinglibrary.common.Constant.CODED_CONTENT)
|
||||
if (content == null) {
|
||||
Common.showToast(this, "条码错误!")
|
||||
return
|
||||
}
|
||||
when (requestCode) {
|
||||
Constant.RequestCode.gnc_fubang_car_no -> {
|
||||
carNo.setText("$content")
|
||||
viewModel.queryWaybillById(content, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步viewModel的实体类数据
|
||||
*/
|
||||
private fun getAllEditData(): Boolean {
|
||||
viewModel.fuBangInfo.carId = carNo.text.toString()
|
||||
viewModel.fuBangInfo.netWeight = currentWeight.text.toString().toDouble()
|
||||
viewModel.fuBangInfo.carWeight = pingbanWeight.text.toString().toDouble()
|
||||
viewModel.fuBangInfo.volume = volume.text.toString().toDouble()
|
||||
viewModel.fuBangInfo.pc = number.text.toString().toInt()
|
||||
viewModel.fuBangInfo.flight = hangban.text.toString()
|
||||
viewModel.fuBangInfo.priority = if (StringUtils.isNotEmpty(level.text.toString())) level.text.toString().toInt() else -9999
|
||||
viewModel.fuBangInfo.fdest = mudiGang.text.toString()
|
||||
viewModel.fuBangInfo.location = cangwei.text.toString()
|
||||
viewModel.fuBangInfo.mailWeight = youjian.text.toString().toDouble()
|
||||
viewModel.fuBangInfo.uld = uld.text.toString()
|
||||
viewModel.fuBangInfo.uldWeight = uldWeight.text.toString().toDouble()
|
||||
viewModel.fuBangInfo.fdate = fdate.text.toString()
|
||||
viewModel.fuBangInfo.remark = remark.text.toString()
|
||||
|
||||
if (offset.text == null || offset.text.toString() == "" || offset.text.toString().toDouble() < -3 || offset.text.toString().toDouble() > 3) {
|
||||
Common.showToast(this, "偏差超出3%,不允许复磅!")
|
||||
return false
|
||||
}
|
||||
if (viewModel.fuBangInfo.carId == "") {
|
||||
Common.showToast(this, "请填写平板车编号!")
|
||||
return false
|
||||
}
|
||||
if (viewModel.fuBangInfo.netWeight == 0.0) {
|
||||
Common.showToast(this, "请填写净重!")
|
||||
return false
|
||||
}
|
||||
if (viewModel.fuBangInfo.carWeight == 0.0) {
|
||||
Common.showToast(this, "请填写平板车重量!")
|
||||
return false
|
||||
}
|
||||
if (viewModel.fuBangInfo.volume == 0.0) {
|
||||
Common.showToast(this, "请填写体积!")
|
||||
return false
|
||||
}
|
||||
if (viewModel.fuBangInfo.pc < 1) {
|
||||
Common.showToast(this, "请填写件数!")
|
||||
return false
|
||||
}
|
||||
if (viewModel.fuBangInfo.flight == "") {
|
||||
Common.showToast(this, "航班不能为空!")
|
||||
return false
|
||||
}
|
||||
if (viewModel.fuBangInfo.priority < 0) {
|
||||
Common.showToast(this, "请填写优先级!")
|
||||
return false
|
||||
}
|
||||
if (viewModel.fuBangInfo.fdest == "") {
|
||||
Common.showToast(this, "请填写目的港!")
|
||||
return false
|
||||
}
|
||||
// if (viewModel.fuBangInfo.location == "") {
|
||||
// Common.showToast(this, "请填写舱位!")
|
||||
// return false
|
||||
// }
|
||||
/*if (viewModel.fuBangInfo.mailWeight == 0.0) {
|
||||
Common.showToast(this, "邮件不能为空!")
|
||||
return false
|
||||
}
|
||||
if (viewModel.fuBangInfo.uld == "") {
|
||||
Common.showToast(this, "请填写ULD编号!")
|
||||
return false
|
||||
}
|
||||
if (viewModel.fuBangInfo.uldWeight == 0.0) {
|
||||
Common.showToast(this, "请填写ULD自重!")
|
||||
return false
|
||||
}
|
||||
if (viewModel.fuBangInfo.boardType == "") {
|
||||
Common.showToast(this, "请填写板型!")
|
||||
return false
|
||||
}
|
||||
if (viewModel.fuBangInfo.remark == "") {
|
||||
Common.showToast(this, "备注不能为空!")
|
||||
return false
|
||||
}*/
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
private fun initSpinner(sp: Spinner, dataListArr: JSONArray, selPosition: Int?, hint: String?) {
|
||||
val jsonObjectList: List<JSONObject> = (0 until dataListArr.size).map { dataListArr.getJSONObject(it) }
|
||||
val dataList: List<KeyValue> = jsonObjectList.map { KeyValue(it.getString("name"),it.getString("code")) }
|
||||
|
||||
bindAdapter(sp, dataList, hint, null)
|
||||
selPosition?.let { sp.setSelection(it) }
|
||||
//给下拉框设置选择监听器,一旦用户选中某一项,就触发监听器的onItemSelected方法
|
||||
sp.onItemSelectedListener = MySelectedListener(sp.id, hint)
|
||||
}
|
||||
|
||||
/**
|
||||
* 下拉框监听
|
||||
*/
|
||||
inner class MySelectedListener(private val spinnerView: Int, val hint: String? ) : AdapterView.OnItemSelectedListener {
|
||||
override fun onItemSelected(adapterView: AdapterView<*>?, view: View, i: Int, l: Long) {
|
||||
when (spinnerView) {
|
||||
R.id.cargoType -> {
|
||||
viewModel.fuBangInfo.cargoType = if (StringUtils.isNotEmpty(hint) && i == viewModel.cargoList.size) {
|
||||
""
|
||||
} else {
|
||||
viewModel.cargoList.getJSONObject(i).getString("code")
|
||||
}
|
||||
}
|
||||
R.id.boardType -> {
|
||||
viewModel.fuBangInfo.boardType = if (StringUtils.isNotEmpty(hint) && i == viewModel.boardList.size) {
|
||||
""
|
||||
} else {
|
||||
viewModel.boardList.getJSONObject(i).getString("code")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onNothingSelected(adapterView: AdapterView<*>?) {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
package com.lukouguoji.gnc.activity
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.alibaba.fastjson.JSONArray
|
||||
import com.alibaba.fastjson.JSONObject
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.module_base.BaseActivity
|
||||
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
import com.lukouguoji.gnc.model.GncFuBangList
|
||||
import com.lukouguoji.gnc.viewModel.GoutFuBangListViewModel
|
||||
import com.lukouguoji.gnc.adapt.GncFuBangListAdapter
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.scwang.smart.refresh.footer.ClassicsFooter
|
||||
import com.scwang.smart.refresh.header.ClassicsHeader
|
||||
import com.scwang.smart.refresh.layout.api.RefreshLayout
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_GOUT_FU_BANG_LIST_ACTIVITY)
|
||||
class GoutFuBangCotActivity : BaseActivity(), View.OnClickListener {
|
||||
private lateinit var viewModel: GoutFuBangListViewModel
|
||||
|
||||
private lateinit var adapter: GncFuBangListAdapter
|
||||
private val collectList = ArrayList<GncFuBangList>()
|
||||
|
||||
private var currentPage = 1
|
||||
private var pageSize = 10
|
||||
private var totalPage = 0
|
||||
private var text = ""
|
||||
private lateinit var refreshLayout: RefreshLayout
|
||||
private lateinit var search: LinearLayout
|
||||
private lateinit var add: LinearLayout
|
||||
private lateinit var searchContent: EditText
|
||||
private lateinit var scanCodeImg: ImageView
|
||||
private lateinit var fdate: TextView
|
||||
|
||||
private val ymdSdf = SimpleDateFormat("yyyy-MM-dd")//年月日
|
||||
private val ymdHmsSdf = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")//年月日 时分秒
|
||||
private val calendar = Calendar.getInstance()
|
||||
|
||||
//是否刷新
|
||||
private var refresh = false
|
||||
|
||||
|
||||
private fun initView() {
|
||||
viewModel = ViewModelProvider(this).get(GoutFuBangListViewModel::class.java)
|
||||
|
||||
search = findViewById(R.id.search)
|
||||
add = findViewById(R.id.add)
|
||||
searchContent = findViewById(R.id.search_content)
|
||||
scanCodeImg = findViewById(R.id.scanCodeImg)
|
||||
fdate = findViewById(R.id.fdate)
|
||||
|
||||
search.setOnClickListener(this)
|
||||
add.setOnClickListener(this)
|
||||
fdate.setOnClickListener(this)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_fu_bang_list)
|
||||
setBackArrow("国内出港复磅")
|
||||
initView()
|
||||
|
||||
val layoutManager = LinearLayoutManager(this)
|
||||
adapter = GncFuBangListAdapter(this, collectList)
|
||||
var recyclerView: RecyclerView = findViewById(R.id.guo_nei_collect_list)
|
||||
recyclerView.layoutManager = layoutManager
|
||||
recyclerView.adapter = adapter
|
||||
|
||||
viewModel.searchParamLive.observe(this) {
|
||||
loadingCancel()
|
||||
//1.获取数据
|
||||
var listArr: JSONArray = it["list"] as JSONArray
|
||||
totalPage = it["pages"] as Int
|
||||
// var listArr :JSONArray =it["list"] as JSONArray
|
||||
if (listArr.size > 0) {
|
||||
//2.循环遍历塞入collectList
|
||||
listArr.forEach {
|
||||
val itemObj = it as JSONObject
|
||||
val useId = itemObj.getIntValue("useId")
|
||||
val carId = itemObj.getString("carId") ?: ""
|
||||
val fno = itemObj.getString("fno") ?: ""
|
||||
val dest = itemObj.getString("fdest") ?: ""
|
||||
val totalWeight = itemObj.getDoubleValue("totalWeight")
|
||||
val volume = itemObj.getDoubleValue("volume")
|
||||
val pc = itemObj.getIntValue("pc")
|
||||
val reviewer = itemObj.getString("reviewer") ?: ""
|
||||
val opDate = itemObj.getString("opDate") ?: ""
|
||||
val outer = itemObj.getString("outer") ?: ""
|
||||
val loader = itemObj.getString("loader") ?: ""
|
||||
collectList.add(GncFuBangList(useId, carId,fno,dest, totalWeight, volume, pc, opDate,reviewer,outer,loader))
|
||||
}
|
||||
//3.调adpter展示
|
||||
if (currentPage == 1) {
|
||||
adapter.notifyDataSetChanged()
|
||||
} else {
|
||||
adapter.notifyItemRangeInserted((currentPage - 1) * 10, collectList.size)
|
||||
}
|
||||
refreshLayout.finishRefresh()
|
||||
refreshLayout.finishLoadMore()
|
||||
|
||||
}
|
||||
}
|
||||
//初始化查询
|
||||
viewModel.search(pageSize, currentPage, text,"1")
|
||||
loading()
|
||||
|
||||
/////////////////////////////// 加载刷新的布局
|
||||
refreshLayout = findViewById<View>(R.id.refreshLayout) as RefreshLayout
|
||||
refreshLayout.setRefreshHeader(ClassicsHeader(this))
|
||||
refreshLayout.setRefreshFooter(ClassicsFooter(this))
|
||||
/////////////////////////////// 下拉刷新
|
||||
refreshLayout.setOnRefreshListener {
|
||||
refresh = true
|
||||
currentPage = 1
|
||||
//recyclerView 清除所有数据数据
|
||||
adapter.notifyItemRangeRemoved(0, collectList.size)
|
||||
collectList.clear()
|
||||
//初始化查询
|
||||
viewModel.search(pageSize, currentPage, text,"1")
|
||||
adapter.notifyItemRangeInserted(0, collectList.size)
|
||||
}
|
||||
/////////////////////////////// 上拉加载
|
||||
refreshLayout.setOnLoadMoreListener {
|
||||
refresh = false
|
||||
if (currentPage < totalPage) {
|
||||
currentPage++
|
||||
//初始化查询
|
||||
viewModel.search(pageSize, currentPage, text,"1")
|
||||
} else {
|
||||
refreshLayout.finishLoadMoreWithNoMoreData()
|
||||
}
|
||||
}
|
||||
|
||||
search.setOnClickListener {
|
||||
currentPage = 1
|
||||
//recyclerView 清除所有数据数据
|
||||
adapter.notifyItemRangeRemoved(0, collectList.size)
|
||||
collectList.clear()
|
||||
//初始化查询
|
||||
viewModel.search(pageSize, currentPage, searchContent.text.toString(),"1")
|
||||
}
|
||||
|
||||
|
||||
//点击扫码
|
||||
scanCodeImg.setOnClickListener {
|
||||
scanCode(Constant.RequestCode.gnc_fubang_search)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
|
||||
// 扫描二维码/条码回传
|
||||
if (requestCode == Constant.RequestCode.gnc_fubang_search && resultCode == RESULT_OK) {
|
||||
if (data != null) {
|
||||
val content = data.getStringExtra(com.yzq.zxinglibrary.common.Constant.CODED_CONTENT)
|
||||
searchContent.setText("$content")
|
||||
|
||||
//调用接口查询进入详情页
|
||||
if (content != null && content != "") {
|
||||
Log.i("刷新:${content}",content.toString())
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GOUT_FU_BANG_ACTIVITY).withString("carNoParam", content)
|
||||
.navigation(this, Constant.RequestCode.gnc_shouyun_list_refresh)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (requestCode == Constant.RequestCode.gnc_shouyun_list_refresh && resultCode == RESULT_OK) {
|
||||
collectList.clear()
|
||||
currentPage = 1
|
||||
refreshLayout.setNoMoreData(false)
|
||||
viewModel.search(10, currentPage, "","1")
|
||||
loading()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
v?.let {
|
||||
when (it.id) {
|
||||
R.id.search -> {
|
||||
|
||||
}
|
||||
R.id.add -> {
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GOUT_FU_BANG_ACTIVITY).navigation(this, Constant.RequestCode.gnc_shouyun_list_refresh)
|
||||
}
|
||||
R.id.fdate -> {
|
||||
Common.onYearMonthDay(this, fdate.text.toString()) { year, month, day ->
|
||||
calendar.set(year, month - 1, day)
|
||||
fdate.text = ymdSdf.format(calendar.time)
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
Toast.makeText(this, "未找到对应操作", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,911 @@
|
||||
package com.lukouguoji.gnc.activity
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.*
|
||||
import android.widget.AdapterView.OnItemSelectedListener
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.alibaba.android.arouter.facade.annotation.Autowired
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.alibaba.fastjson.JSONArray
|
||||
import com.alibaba.fastjson.JSONObject
|
||||
import com.github.gzuliyujiang.wheelpicker.DatePicker
|
||||
import com.github.gzuliyujiang.wheelpicker.annotation.DateMode
|
||||
import com.github.gzuliyujiang.wheelpicker.entity.DateEntity
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.viewModel.GoutStartViewModel
|
||||
import com.lukouguoji.module_base.BaseActivity
|
||||
import com.lukouguoji.module_base.MyApplication
|
||||
import com.lukouguoji.module_base.adapter.bindAdapter
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
import com.lukouguoji.module_base.util.Arith
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import dev.utils.app.info.KeyValue
|
||||
import dev.utils.common.StringUtils
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import kotlin.math.abs
|
||||
|
||||
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_GOUT_START_COT_ACTIVITY)
|
||||
class GoutStartCotActivity : BaseActivity(), View.OnClickListener ,OnItemSelectedListener{
|
||||
private lateinit var checkintongdao:Spinner
|
||||
private lateinit var check: TextView
|
||||
private lateinit var fenDou: TextView
|
||||
private lateinit var finishCollect: TextView
|
||||
// private lateinit var reset: TextView
|
||||
private lateinit var labelPrint: CheckBox
|
||||
private lateinit var viewModel: GoutStartViewModel
|
||||
|
||||
private lateinit var wbNo: EditText
|
||||
private lateinit var wbNoScan: ImageView
|
||||
private lateinit var uldScan: ImageView
|
||||
private lateinit var uld: EditText
|
||||
// private lateinit var uldScan: ImageView
|
||||
private lateinit var uldWeight: EditText
|
||||
private lateinit var carrier: EditText
|
||||
private lateinit var fno: EditText
|
||||
private lateinit var fdate: Button
|
||||
private lateinit var flight1: EditText
|
||||
private lateinit var flight2: EditText
|
||||
private lateinit var flight3: EditText
|
||||
private lateinit var dgrDetail: Spinner
|
||||
private lateinit var dgr: Spinner
|
||||
// private lateinit var dgrDetailNotNull: TextView
|
||||
private lateinit var agentCode: Spinner
|
||||
private lateinit var spCode: Spinner
|
||||
private lateinit var goods: EditText
|
||||
private lateinit var pc: EditText
|
||||
private lateinit var weight: EditText
|
||||
private lateinit var volume: EditText
|
||||
private lateinit var remark: EditText
|
||||
private lateinit var dibangWeight: TextView
|
||||
private lateinit var dibangWeightScan: ImageView
|
||||
private lateinit var volumeInfo: EditText
|
||||
// private lateinit var uldStr: EditText
|
||||
private lateinit var uldSelfWeight: EditText
|
||||
// private lateinit var tongdaoName:String
|
||||
// private lateinit var weightThread:Thread
|
||||
/*
|
||||
tw:2022年4月27日15:23:52 下拉框改用 singleSelect 所以注释掉 6个月后可删除
|
||||
private val agentCodeList = arrayListOf<String>()
|
||||
private val businessList = arrayListOf<String>()
|
||||
private val specialCodeList = JSONArray()
|
||||
private val dgrDetailList = JSONArray()*/
|
||||
|
||||
// var simpleDateYMDFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
|
||||
var simpleDateFormat = SimpleDateFormat("yyyy-MM-dd")
|
||||
|
||||
@JvmField
|
||||
@Autowired
|
||||
var wbId: Int = -9999
|
||||
|
||||
@JvmField
|
||||
@Autowired
|
||||
var wbNoParam: String? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_check_in)
|
||||
setBackArrow("国内出港开始收运")
|
||||
viewModel = ViewModelProvider(this).get(GoutStartViewModel::class.java)
|
||||
initView()
|
||||
val dgrObj = JSONObject()
|
||||
dgrObj["name"] = "请选择"
|
||||
dgrObj["code"] = ""
|
||||
viewModel.dgrDetailList.add(dgrObj)
|
||||
|
||||
viewModel.queryWaybillById(wbId, wbNoParam)
|
||||
viewModel.waybillLiveData.observe(this) {
|
||||
val status = it.getString("status")
|
||||
if (Constant.Result.succ == status) {
|
||||
var jsonObject = it.getJSONObject("data")
|
||||
viewModel.waybillFormNetWork = jsonObject
|
||||
|
||||
val checkIn = jsonObject.getString("checkIn")
|
||||
if (checkIn == "1") {
|
||||
Common.showToast(this, "该订单收运已完成,不可再收运!")
|
||||
return@observe
|
||||
}
|
||||
viewModel.guoneiOutWaybill.activeId = jsonObject.getIntValue("activeId")
|
||||
viewModel.guoneiOutWaybill.awbType = jsonObject.getString("awbType")
|
||||
viewModel.guoneiOutWaybill.mawbId = jsonObject.getIntValue("mawbId")
|
||||
viewModel.guoneiOutWaybill.wbNo = jsonObject.getString("wbNo") ?: ""
|
||||
viewModel.guoneiOutWaybill.uld = jsonObject.getString("uld") ?: ""
|
||||
viewModel.guoneiOutWaybill.carrier = jsonObject.getString("carrier") ?: ""
|
||||
viewModel.guoneiOutWaybill.fno = jsonObject.getString("fno") ?: ""
|
||||
viewModel.guoneiOutWaybill.fdate = jsonObject.getString("fdate") ?: ""
|
||||
viewModel.guoneiOutWaybill.range = jsonObject.getString("range") ?: ""
|
||||
viewModel.guoneiOutWaybill.dgrDetail = jsonObject.getString("dgrDetail") ?: ""
|
||||
viewModel.guoneiOutWaybill.dgr = jsonObject.getString("dgr") ?: ""
|
||||
viewModel.guoneiOutWaybill.agentCode = jsonObject.getString("agentCode") ?: ""
|
||||
viewModel.guoneiOutWaybill.spCode = jsonObject.getString("spCode") ?: ""
|
||||
viewModel.guoneiOutWaybill.goods = jsonObject.getString("goods") ?: ""
|
||||
viewModel.guoneiOutWaybill.pc = jsonObject.getIntValue("pc")
|
||||
viewModel.guoneiOutWaybill.weight = jsonObject.getDouble("weight")
|
||||
viewModel.guoneiOutWaybill.volume = jsonObject.getDouble("volume")
|
||||
viewModel.guoneiOutWaybill.remark = jsonObject.getString("remark") ?: ""
|
||||
|
||||
wbNo.setText(viewModel.guoneiOutWaybill.wbNo)
|
||||
uld.setText(viewModel.guoneiOutWaybill.uld)
|
||||
carrier.setText(viewModel.guoneiOutWaybill.carrier)
|
||||
fno.setText(viewModel.guoneiOutWaybill.fno)
|
||||
if (viewModel.guoneiOutWaybill.fdate != "") {
|
||||
var parse = simpleDateFormat.parse(viewModel.guoneiOutWaybill.fdate)
|
||||
fdate.text = simpleDateFormat.format(parse)
|
||||
}
|
||||
if (viewModel.guoneiOutWaybill.range != "") {
|
||||
var split = viewModel.guoneiOutWaybill.range.split("-")
|
||||
for ((i, item) in split.withIndex()) {
|
||||
if (i == 0) {
|
||||
flight1.setText(item)
|
||||
} else if (i == 1) {
|
||||
flight2.setText(item)
|
||||
} else {
|
||||
flight3.setText(item)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// dgrDetail.setText(viewModel.guoneiOutWaybill.dgrDetail)
|
||||
// agentCode.setText(viewModel.guoneiOutWaybill.agentCode)
|
||||
// spCode.setsetText(viewModel.guoneiOutWaybill.spCode)
|
||||
goods.setText(viewModel.guoneiOutWaybill.goods)
|
||||
pc.setText(viewModel.guoneiOutWaybill.pc.toString())
|
||||
// dibangWeight.setText(viewModel.guoneiOutWaybill.weight.toString())
|
||||
volume.setText(viewModel.guoneiOutWaybill.volume.toString())
|
||||
remark.setText(viewModel.guoneiOutWaybill.remark)
|
||||
|
||||
viewModel.weightDataObserver.observe(this){ vd->
|
||||
if(!dibangWeight.text.toString().equals(vd))
|
||||
{
|
||||
dibangWeight.setText(vd)
|
||||
}
|
||||
}
|
||||
//下拉框赋值
|
||||
viewModel.agentCode(System.currentTimeMillis().toString())
|
||||
viewModel.agentCodeObserver.observe(this) { vd ->
|
||||
viewModel.agentCodeList = vd.getJSONArray("data")
|
||||
var postion = 0
|
||||
for ((index, obj) in viewModel.agentCodeList.withIndex()) {
|
||||
val tempObj = obj as JSONObject
|
||||
var name = tempObj.getString("name")
|
||||
var code = tempObj.getString("code")
|
||||
// agentCodeList.add(code)
|
||||
if (viewModel.guoneiOutWaybill.agentCode == code) {
|
||||
postion = index
|
||||
}
|
||||
}
|
||||
initSpinner(agentCode, viewModel.agentCodeList, postion,null)
|
||||
}
|
||||
|
||||
viewModel.specialCode(System.currentTimeMillis().toString())
|
||||
viewModel.specialCodeObserver.observe(this) { vd ->
|
||||
viewModel.specialCodeList = vd.getJSONArray("data")
|
||||
var postion = 0
|
||||
// val specialCodeStrList = arrayListOf<String>()
|
||||
for ((index, obj) in viewModel.specialCodeList.withIndex()) {
|
||||
val tempObj = obj as JSONObject
|
||||
var code = tempObj.getString("code")
|
||||
var name = tempObj.getString("name")
|
||||
// specialCodeList.add(tempObj)
|
||||
// specialCodeStrList.add(name)
|
||||
if (viewModel.guoneiOutWaybill.spCode == code) {
|
||||
postion = index
|
||||
}
|
||||
}
|
||||
/*if (viewModel.guoneiOutWaybill.spCode == Constant.Other.DGR) {
|
||||
dgrDetailNotNull.visibility = View.VISIBLE
|
||||
} else {
|
||||
dgrDetailNotNull.visibility = View.GONE
|
||||
}*/
|
||||
|
||||
initSpinner(spCode, viewModel.specialCodeList, postion,null)
|
||||
|
||||
}
|
||||
|
||||
viewModel.danger(System.currentTimeMillis().toString())
|
||||
viewModel.dangerObserver.observe(this) { vd ->
|
||||
viewModel.dgrList.addAll(vd.getJSONArray("data"))
|
||||
var postion = 0
|
||||
for ((index, obj) in viewModel.dgrList.withIndex()) {
|
||||
val tempObj = obj as JSONObject
|
||||
var code = tempObj.getString("code")
|
||||
var name = tempObj.getString("name")
|
||||
if (viewModel.guoneiOutWaybill.dgr == code) {
|
||||
postion = index
|
||||
}
|
||||
}
|
||||
initSpinner(dgr, viewModel.dgrList, postion,null)
|
||||
}
|
||||
|
||||
viewModel.danger(System.currentTimeMillis().toString())
|
||||
viewModel.dangerObserver.observe(this) { vd ->
|
||||
viewModel.dgrDetailList.addAll(vd.getJSONArray("data"))
|
||||
var postion = 0
|
||||
// val dgrDetailStrList = arrayListOf<String>()
|
||||
for ((index, obj) in viewModel.dgrDetailList.withIndex()) {
|
||||
val tempObj = obj as JSONObject
|
||||
var code = tempObj.getString("code")
|
||||
var name = tempObj.getString("name")
|
||||
// dgrDetailList.add(tempObj)
|
||||
// dgrDetailStrList.add(name)
|
||||
if (viewModel.guoneiOutWaybill.dgrDetail == code) {
|
||||
postion = index
|
||||
}
|
||||
}
|
||||
initSpinner(dgrDetail, viewModel.dgrDetailList, postion,null)
|
||||
}
|
||||
|
||||
} else {
|
||||
//无数据
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//监听板车是否异常
|
||||
viewModel.queryActiveCarObserver.observe(this) {
|
||||
val status = it.getString("status")
|
||||
if (Constant.Result.succ == status) {
|
||||
// Common.showToastLong(this, "平板车可正常使用 ")
|
||||
} else {
|
||||
uld.setText("")
|
||||
Common.showToastLong(this, "平板车未维护,请重新选择! ")
|
||||
}
|
||||
}
|
||||
|
||||
//托盘编号,查询集装器自重
|
||||
viewModel.queryFlatcarGjcReceiveObserver.observe(this) {
|
||||
loadingCancel()
|
||||
val status = it.getString("status")
|
||||
val data = it.getJSONObject("data")
|
||||
Log.i("queryFlatcarGjcReceiveObserver",it.toString())
|
||||
if (Constant.Result.succ == status && data != null) {
|
||||
val dataObj = it.getJSONObject("data")
|
||||
val dataStatus = dataObj.getString("status")
|
||||
// if (dataStatus == "0")
|
||||
|
||||
val carWeight = dataObj.getString("carWeight") ?: ""
|
||||
uldWeight.setText(carWeight)
|
||||
//板车上已装货物的重量
|
||||
viewModel.netWeight=dataObj.getFloat("signWeight")?:0f
|
||||
viewModel.carFno=dataObj.getString("remark")?:""
|
||||
viewModel.carpc=dataObj.getIntValue("maxWeight")?:0
|
||||
viewModel.carVolume=dataObj.getString("status").toString().toFloat()?:0f
|
||||
|
||||
if (uld.text.toString() != "") {
|
||||
check.isEnabled = true
|
||||
check.background = ContextCompat.getDrawable(this, R.drawable.submit_shape)
|
||||
/* val carWeightDb = carWeight.toDouble()
|
||||
val weightDb = weight.text.toString().toDouble()
|
||||
if (mt3percent(carWeightDb - weightDb, carWeightDb)) {
|
||||
check.isEnabled = true
|
||||
check.background = ContextCompat.getDrawable(this, R.drawable.submit_shape)
|
||||
} else {
|
||||
check.isEnabled = false
|
||||
check.background = ContextCompat.getDrawable(this, R.drawable.input_edit_text_disable)
|
||||
}*/
|
||||
}
|
||||
else{
|
||||
check.isEnabled = false
|
||||
check.background = ContextCompat.getDrawable(this, R.drawable.input_edit_text_disable)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//托盘编号,校验平板车重量
|
||||
viewModel.updateFlatcarGncStartReceiveObserver.observe(this) {
|
||||
loadingCancel()
|
||||
val status = it.getString("status")
|
||||
val data = it.getString("data")
|
||||
if (Constant.Result.succ == status && Constant.Result.succ == data) {
|
||||
uldWeight.setText(dibangWeight.text.toString())
|
||||
} else {
|
||||
Common.alertDialog(this, "校验失败!") { dialog ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//监听分斗
|
||||
viewModel.dividedObserver.observe(this) {
|
||||
loadingCancel()
|
||||
val status = it.getString("status")
|
||||
val data = it.getString("data")
|
||||
val msg = it.getString("msg")
|
||||
if (Constant.Result.succ == status && Constant.Result.succ == data) {
|
||||
// fendouSuccDataDeal()
|
||||
Common.showToastLong(this, "分斗成功! ")
|
||||
fill0AndQueryActiveCar(uld.text.toString())
|
||||
} else {
|
||||
if (msg != null && msg != "") {
|
||||
Common.alertDialog(this, msg) { dialog ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
} else {
|
||||
Common.alertDialog(this, "分斗失败!") { dialog ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//监听完成收运
|
||||
viewModel.completedObserver.observe(this) {
|
||||
loadingCancel()
|
||||
val status = it.getString("status")
|
||||
val data = it.getString("data")
|
||||
val msg = it.getString("msg")
|
||||
if (Constant.Result.succ == status && Constant.Result.succ == data) {
|
||||
wbNo.setText("")
|
||||
Common.alertDialog(this, "完成收运!") { dialog ->
|
||||
// reset()
|
||||
fill0AndQueryActiveCar(uld.text.toString())
|
||||
dialog.dismiss()
|
||||
}
|
||||
} else {
|
||||
if (msg != null && msg != "") {
|
||||
Common.alertDialog(this, msg) { dialog ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
} else {
|
||||
Common.alertDialog(this, "收运失败!") { dialog ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//设置点击事件
|
||||
checkintongdao.onItemSelectedListener= object : AdapterView.OnItemSelectedListener {
|
||||
override fun onItemSelected(
|
||||
parent: AdapterView<*>?,
|
||||
view: View?,
|
||||
position: Int,
|
||||
id: Long
|
||||
) {
|
||||
if(position>=0){
|
||||
if (parent != null) {
|
||||
// Toast(this,"选中游戏:${parent.getItemAtPosition(position).toString()}")
|
||||
viewModel.setWeightName(parent.getItemAtPosition(position).toString()) // weightName tongdaoName=
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onNothingSelected(parent: AdapterView<*>?) {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
}
|
||||
viewModel.weightThread.start()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
viewModel. weightThread.interrupt();
|
||||
super.onDestroy()
|
||||
}
|
||||
/////////onCreate 结束
|
||||
|
||||
private fun initView() {
|
||||
checkintongdao=findViewById(R.id.checkin_tong_dao)
|
||||
check = findViewById(R.id.check)
|
||||
fenDou = findViewById(R.id.fen_dou)
|
||||
finishCollect = findViewById(R.id.finish_collect)
|
||||
// reset=findViewById(R.id.reset_collect)
|
||||
labelPrint=findViewById(R.id.label_print)
|
||||
wbNo = findViewById(R.id.wbNo)
|
||||
wbNoScan = findViewById(R.id.wbNo_scan)
|
||||
uldScan = findViewById(R.id.uldScan)
|
||||
uld = findViewById(R.id.uld)
|
||||
// uldScan = findViewById(R.id.uldScan)
|
||||
uldWeight = findViewById(R.id.uldWeight)
|
||||
carrier = findViewById(R.id.carrier)
|
||||
fno = findViewById(R.id.fno)
|
||||
fdate = findViewById(R.id.fdate)
|
||||
flight1 = findViewById(R.id.flight1)
|
||||
flight2 = findViewById(R.id.flight2)
|
||||
flight3 = findViewById(R.id.flight3)
|
||||
dgrDetail = findViewById(R.id.dgrDetail)
|
||||
dgr = findViewById(R.id.dgr)
|
||||
// dgrDetailNotNull = findViewById(R.id.dgrDetailNotNull)
|
||||
agentCode = findViewById(R.id.agentCode)
|
||||
spCode = findViewById(R.id.spCode)
|
||||
goods = findViewById(R.id.goods)
|
||||
pc = findViewById(R.id.pc)
|
||||
weight = findViewById(R.id.weight)
|
||||
volume = findViewById(R.id.volume)
|
||||
remark = findViewById(R.id.remark)
|
||||
dibangWeight = findViewById(R.id.dibang_weight)
|
||||
// dibangWeightScan = findViewById(R.id.dibang_weight_scan)
|
||||
volumeInfo = findViewById(R.id.volume_info)
|
||||
// uldStr = findViewById(R.id.uldStr)
|
||||
uldSelfWeight = findViewById(R.id.uldSelfWeight)
|
||||
|
||||
|
||||
//////////////// 绑定点击事件
|
||||
check.setOnClickListener(this)
|
||||
fenDou.setOnClickListener(this)
|
||||
finishCollect.setOnClickListener(this)
|
||||
// reset.setOnClickListener(this)
|
||||
labelPrint.setOnClickListener(this)
|
||||
wbNoScan.setOnClickListener(this)
|
||||
uldScan.setOnClickListener(this)
|
||||
// uldScan.setOnClickListener(this)
|
||||
// dibangWeightScan.setOnClickListener(this)
|
||||
|
||||
// wbNo.setOnClickListener(this)
|
||||
// uld.setOnClickListener(this)
|
||||
// carrier.setOnClickListener(this)
|
||||
// fno.setOnClickListener(this)
|
||||
fdate.setOnClickListener(this)
|
||||
// flight.setOnClickListener(this)
|
||||
// dgrDetail.setOnClickListener(this)
|
||||
// agentCode.setOnClickListener(this)
|
||||
// spCode.setOnClickListener(this)
|
||||
// goods.setOnClickListener(this)
|
||||
// pc.setOnClickListener(this)
|
||||
// weight.setOnClickListener(this)
|
||||
// volume.setOnClickListener(this)
|
||||
// remark.setOnClickListener(this)
|
||||
// dibangWeight.setOnClickListener(this)
|
||||
// volumeInfo.setOnClickListener(this)
|
||||
|
||||
|
||||
///////////// 监听edittext变化
|
||||
dibangWeight.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
|
||||
if (s.toString() != "") {
|
||||
/*var volumeDouble = Arith.div(weight.text.toString().toDouble(), 220.0, 1)
|
||||
if (volumeDouble < 0.1) {
|
||||
volume.setText("0.1")
|
||||
} else {
|
||||
volume.setText(volumeDouble.toString())
|
||||
}*/
|
||||
|
||||
val carWeightDb = uldWeight.text.toString().toDouble()
|
||||
val diBangWeightDb = s.toString().toDouble()
|
||||
var checkInWeight=diBangWeightDb-viewModel.netWeight-carWeightDb
|
||||
weight.setText( checkInWeight.toString())
|
||||
if (uld.text.toString() != "") {
|
||||
check.isEnabled = true
|
||||
check.background = ContextCompat.getDrawable(MyApplication.context, R.drawable.submit_shape)
|
||||
} else {
|
||||
check.isEnabled = false
|
||||
check.background = ContextCompat.getDrawable(MyApplication.context, R.drawable.input_edit_text_disable)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
//点击确认
|
||||
uld.setOnEditorActionListener { v, actionId, event ->
|
||||
if (actionId == EditorInfo.IME_ACTION_DONE) {
|
||||
// uld.setText(fill0AndQueryActiveCar(uld.text.toString()))
|
||||
}
|
||||
false
|
||||
}
|
||||
//失去焦点
|
||||
uld.onFocusChangeListener = View.OnFocusChangeListener { v, hasFocus ->
|
||||
if (hasFocus) {
|
||||
|
||||
} else {
|
||||
//失去焦点
|
||||
uld.setText(fill0AndQueryActiveCar(uld.text.toString()))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
v?.let {
|
||||
when (it.id) {
|
||||
R.id.check -> {
|
||||
Common.secondConfirmDialog(this, "是否校验平板车重量?") { dialog ->
|
||||
viewModel.updateFlatcarGncStartReceive(uld.text.toString(), dibangWeight.text.toString().toDouble())
|
||||
dialog.dismiss()
|
||||
loading()
|
||||
}
|
||||
}
|
||||
R.id.fen_dou -> {
|
||||
if (getAllEditData()) {
|
||||
Common.secondConfirmDialog(this, "确认分斗") { dialog ->
|
||||
viewModel.divided(viewModel.guoneiOutWaybill)
|
||||
dialog.dismiss()
|
||||
loading()
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
}
|
||||
}
|
||||
R.id.finish_collect -> {
|
||||
if (getAllEditData()) {
|
||||
Common.secondConfirmDialog(this, "确认收运") { dialog ->
|
||||
viewModel.completed(viewModel.guoneiOutWaybill)
|
||||
dialog.dismiss()
|
||||
loading()
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
}
|
||||
}
|
||||
R.id.label_print -> {
|
||||
/*var date=Date()
|
||||
var format=SimpleDateFormat("yyyy年MM月dd日")
|
||||
var numberUtil=NumberUtil()
|
||||
var label= LabelBean (
|
||||
titleName = "扬州泰州机场",
|
||||
dest = flight2.text.toString(),
|
||||
carId = uld.text.toString(),
|
||||
fno = fno.text.toString(),
|
||||
pc = viewModel.carpc.toString(),
|
||||
weight =viewModel.netWeight.toString(),
|
||||
volume = viewModel.carVolume.toString(),
|
||||
location = "",
|
||||
opdate = fdate.text.toString()
|
||||
)
|
||||
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_Printer_ACTIVITY).withObject("label",label)
|
||||
.navigation(this)*/
|
||||
}
|
||||
/*R.id.reset_collect -> {
|
||||
reset()
|
||||
}*/
|
||||
R.id.wbNo_scan -> {
|
||||
scanCode(Constant.RequestCode.gnc_shouyun_waybill)
|
||||
}
|
||||
R.id.uldScan -> {
|
||||
scanCode(Constant.RequestCode.gnc_shouyun_uld)
|
||||
}
|
||||
R.id.dibang_weight_scan -> {
|
||||
dibangWeight.setText("")
|
||||
}
|
||||
R.id.fdate -> {
|
||||
onYearMonthDayTime()
|
||||
}
|
||||
/*R.id.agentCode -> {
|
||||
Common.singleSelect(this, "代理", viewModel.agentCodeList, viewModel.guoneiOutWaybill.agentCode) { position, item ->
|
||||
val jsonObject = item as JSONObject
|
||||
val name = jsonObject.getString("name")
|
||||
val code = jsonObject.getString("code")
|
||||
agentCode.text = name
|
||||
viewModel.guoneiOutWaybill.agentCode = code
|
||||
}
|
||||
}*/
|
||||
/*R.id.spCode -> {
|
||||
Common.singleSelect(this, "特码", viewModel.specialCodeList, viewModel.guoneiOutWaybill.spCode) { position, item ->
|
||||
val jsonObject = item as JSONObject
|
||||
val name = jsonObject.getString("name")
|
||||
val code = jsonObject.getString("code")
|
||||
spCode.text = name
|
||||
viewModel.guoneiOutWaybill.spCode = code
|
||||
*//*if (code == Constant.Other.DGR) {
|
||||
dgrDetailNotNull.visibility = View.VISIBLE
|
||||
} else {
|
||||
dgrDetailNotNull.visibility = View.GONE
|
||||
}*//*
|
||||
}
|
||||
}*/
|
||||
/*R.id.dgrDetail -> {
|
||||
Common.singleSelect(this, "危险品库", viewModel.dgrDetailList, viewModel.guoneiOutWaybill.dgrDetail) { position, item ->
|
||||
val jsonObject = item as JSONObject
|
||||
val name = jsonObject.getString("name")
|
||||
val code = jsonObject.getString("code")
|
||||
dgrDetail.text = name
|
||||
viewModel.guoneiOutWaybill.dgrDetail = code
|
||||
}
|
||||
}*/
|
||||
else -> {
|
||||
Toast.makeText(this, "未找到对应操作", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 扫码返回的结果
|
||||
*/
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
// 扫描二维码/条码回传
|
||||
if (resultCode == RESULT_OK && data != null) {
|
||||
val content = data.getStringExtra(com.yzq.zxinglibrary.common.Constant.CODED_CONTENT)
|
||||
if (content == null) {
|
||||
Common.showToast(this, "条码错误!")
|
||||
return
|
||||
}
|
||||
when (requestCode) {
|
||||
Constant.RequestCode.gnc_shouyun_waybill -> {
|
||||
wbNo.setText("$content")
|
||||
viewModel.queryWaybillById(-9999, content)
|
||||
}
|
||||
Constant.RequestCode.gnc_shouyun_uld -> {
|
||||
uld.setText(fill0AndQueryActiveCar(content))
|
||||
}
|
||||
Constant.RequestCode.gnc_shouyun_dibang_weight -> {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间 年月日
|
||||
*/
|
||||
private fun onYearMonthDayTime() {
|
||||
val picker = DatePicker(this)
|
||||
val wheelLayout = picker.wheelLayout
|
||||
//监听
|
||||
picker.setOnDatePickedListener { year, month, day ->
|
||||
fdate.text = "$year-$month-$day"
|
||||
}
|
||||
//支持年月日、时分秒
|
||||
wheelLayout.setDateMode(DateMode.YEAR_MONTH_DAY)
|
||||
//选择范围
|
||||
val selDate = DateEntity.target(1999, 1, 1)
|
||||
wheelLayout.setRange(selDate, DateEntity.yearOnFuture(50))
|
||||
//年月日时分秒
|
||||
wheelLayout.setDateLabel("年", "月", "日")
|
||||
//内间距,向右远离60
|
||||
wheelLayout.setPadding(0, 0, 60, 0)
|
||||
//设置打开组件的时间
|
||||
if (fdate.text.toString() != "") {
|
||||
var fdate = simpleDateFormat.parse(fdate.text.toString())
|
||||
var calendar = Calendar.getInstance()
|
||||
calendar.time = fdate
|
||||
val datimeEntity = DateEntity.target(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1, calendar.get(Calendar.DAY_OF_MONTH))
|
||||
wheelLayout.setDefaultValue(datimeEntity)
|
||||
} else {
|
||||
wheelLayout.setDefaultValue(DateEntity.today())
|
||||
}
|
||||
|
||||
//展示
|
||||
picker.show()
|
||||
}
|
||||
|
||||
|
||||
private fun initSpinner(sp: Spinner, dataListArr: JSONArray, selPosition: Int?, hint: String?) {
|
||||
val jsonObjectList: List<JSONObject> = (0 until dataListArr.size).map { dataListArr.getJSONObject(it) }
|
||||
val dataList: List<KeyValue> = jsonObjectList.map { KeyValue(it.getString("name"),it.getString("code")) }
|
||||
|
||||
bindAdapter(sp, dataList, hint, null)
|
||||
selPosition?.let { sp.setSelection(it) }
|
||||
//给下拉框设置选择监听器,一旦用户选中某一项,就触发监听器的onItemSelected方法
|
||||
sp.onItemSelectedListener = MySelectedListener(sp.id, hint)
|
||||
}
|
||||
|
||||
/**
|
||||
* 下拉框监听
|
||||
*/
|
||||
inner class MySelectedListener(private val spinnerView: Int, val hint: String?) : OnItemSelectedListener {
|
||||
override fun onItemSelected(adapterView: AdapterView<*>?, view: View, i: Int, l: Long) {
|
||||
when (spinnerView) {
|
||||
R.id.agentCode -> {
|
||||
viewModel.guoneiOutWaybill.agentCode = if (StringUtils.isNotEmpty(hint) && i == viewModel.agentCodeList.size) {
|
||||
""
|
||||
} else {
|
||||
viewModel.agentCodeList.getJSONObject(i).getString("code")
|
||||
}
|
||||
}
|
||||
R.id.spCode -> {
|
||||
viewModel.guoneiOutWaybill.spCode = if (StringUtils.isNotEmpty(hint) && i == viewModel.specialCodeList.size) {
|
||||
""
|
||||
} else {
|
||||
viewModel.specialCodeList.getJSONObject(i).getString("code")
|
||||
}
|
||||
}
|
||||
R.id.dgrDetail -> {
|
||||
viewModel.guoneiOutWaybill.dgrDetail = if (StringUtils.isNotEmpty(hint) && i == viewModel.dgrDetailList.size) {
|
||||
""
|
||||
} else {
|
||||
viewModel.dgrDetailList.getJSONObject(i).getString("code")
|
||||
}
|
||||
}
|
||||
R.id.dgr -> {
|
||||
viewModel.guoneiOutWaybill.dgr = if (StringUtils.isNotEmpty(hint) && i == viewModel.dgrList.size) {
|
||||
""
|
||||
} else {
|
||||
viewModel.dgrList.getJSONObject(i).getString("code")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onNothingSelected(adapterView: AdapterView<*>?) {}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分斗后数据处理
|
||||
*/
|
||||
private fun fendouSuccDataDeal() {
|
||||
uld.setText("")
|
||||
dibangWeight.setText("")
|
||||
pc.setText("")
|
||||
volume.setText("")
|
||||
volumeInfo.setText("")
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步viewModel的实体类数据
|
||||
*/
|
||||
private fun getAllEditData(): Boolean {
|
||||
if (wbNo.text.toString() == "") {
|
||||
Common.showToast(this, "请填写运单号!")
|
||||
return false
|
||||
}
|
||||
if (uld.text.toString() == "") {
|
||||
Common.showToast(this, "请填写板车号!")
|
||||
return false
|
||||
}
|
||||
if (carrier.text.toString() == "") {
|
||||
Common.showToast(this, "承运人不能为空!")
|
||||
return false
|
||||
}
|
||||
if (viewModel.guoneiOutWaybill.agentCode == "") {
|
||||
Common.showToast(this, "代理人不能为空!")
|
||||
return false
|
||||
}
|
||||
if (pc.text.toString() == "") {
|
||||
Common.showToast(this, "请填写件数!")
|
||||
return false
|
||||
}
|
||||
if (flight1.text.toString() == "" || (flight2.text.toString() == "" && flight3.text.toString() == "")) {
|
||||
Common.showToast(this, "航程不能为空!")
|
||||
return false
|
||||
}
|
||||
if (viewModel.guoneiOutWaybill.spCode == "") {
|
||||
Common.showToast(this, "特码不能为空!")
|
||||
return false
|
||||
}
|
||||
if (weight.text.toString() == "") {
|
||||
Common.showToast(this, "请填写重量!")
|
||||
return false
|
||||
}
|
||||
if (volume.text.toString() == "") {
|
||||
Common.showToast(this, "请填写体积!")
|
||||
return false
|
||||
}
|
||||
/*if (viewModel.guoneiOutWaybill.volDetail == "") {
|
||||
Common.showToast(this, "请填写体积明细!")
|
||||
return false
|
||||
}*/
|
||||
if (fdate.text.toString() == "") {
|
||||
Common.showToast(this, "航班日期不能为空!")
|
||||
return false
|
||||
}
|
||||
if (goods.text.toString() == "") {
|
||||
Common.showToast(this, "品名不能为空!")
|
||||
return false
|
||||
}
|
||||
if (fno.text.toString() == "") {
|
||||
Common.showToast(this, "计划航班不能为空!")
|
||||
return false
|
||||
}
|
||||
/*if (viewModel.guoneiOutWaybill.spCode == Constant.Other.DGR && viewModel.guoneiOutWaybill.dgrDetail == "") {
|
||||
Common.showToast(this, "危险品不能为空!")
|
||||
return false
|
||||
}*/
|
||||
|
||||
viewModel.guoneiOutWaybill.wbNo = wbNo.text.toString()
|
||||
viewModel.guoneiOutWaybill.uld = uld.text.toString()
|
||||
|
||||
viewModel.guoneiOutWaybill.carrier = carrier.text.toString()
|
||||
viewModel.guoneiOutWaybill.pc = pc.text.toString().toInt()
|
||||
|
||||
viewModel.guoneiOutWaybill.fno = fno.text.toString()
|
||||
viewModel.guoneiOutWaybill.weight = weight.text.toString().toDouble()
|
||||
|
||||
viewModel.guoneiOutWaybill.fdate = fdate.text.toString()
|
||||
viewModel.guoneiOutWaybill.goods = goods.text.toString()
|
||||
viewModel.guoneiOutWaybill.volume = volume.text.toString().toDouble()
|
||||
|
||||
viewModel.guoneiOutWaybill.range = "${flight1.text}-${flight2.text}-${flight3.text}"
|
||||
|
||||
viewModel.guoneiOutWaybill.volDetail = volumeInfo.text.toString()
|
||||
viewModel.guoneiOutWaybill.remark = remark.text.toString()
|
||||
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun setBackArrow(title: String) {
|
||||
setResult(RESULT_OK)
|
||||
super.setBackArrow(title)
|
||||
}
|
||||
|
||||
/**
|
||||
* 不足3位补0 并且判断车是否可用
|
||||
*/
|
||||
private fun fill0AndQueryActiveCar(content: String): String {
|
||||
//不足3位补0
|
||||
var add0Str = ""
|
||||
if (content.length < 3) {
|
||||
val add0length = 3 - content.length
|
||||
for (index in 1..add0length) {
|
||||
add0Str += "0"
|
||||
}
|
||||
}
|
||||
add0Str += content
|
||||
viewModel.queryActiveCar(add0Str)
|
||||
viewModel.queryFlatcarGjcReceive(add0Str)
|
||||
return add0Str
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置数据
|
||||
*/
|
||||
private fun reset() {
|
||||
wbNo.setText("")
|
||||
uld.setText("")
|
||||
dibangWeight.setText("")
|
||||
|
||||
carrier.setText("")
|
||||
agentCode.setSelection(0)
|
||||
viewModel.guoneiOutWaybill.agentCode = ""
|
||||
pc.setText("")
|
||||
|
||||
fno.setText("")
|
||||
spCode.setSelection(0)
|
||||
viewModel.guoneiOutWaybill.spCode = ""
|
||||
|
||||
fdate.text = ""
|
||||
goods.setText("")
|
||||
volume.setText("")
|
||||
|
||||
flight1.setText("")
|
||||
flight2.setText("")
|
||||
flight3.setText("")
|
||||
volumeInfo.setText("")
|
||||
|
||||
dgrDetail.setSelection(0)
|
||||
dgr.setSelection(0)
|
||||
viewModel.guoneiOutWaybill.dgrDetail = ""
|
||||
viewModel.guoneiOutWaybill.dgr = ""
|
||||
remark.setText("")
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否超过百分之三
|
||||
*/
|
||||
private fun mt3percent(num1: Double, num2: Double): Boolean {
|
||||
if (num2 == 0.0) {
|
||||
return false
|
||||
}
|
||||
val tempNum = abs(num1)
|
||||
val div = Arith.div(tempNum, num2, 3) * 100
|
||||
return div > 3
|
||||
}
|
||||
|
||||
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
||||
|
||||
}
|
||||
|
||||
override fun onNothingSelected(parent: AdapterView<*>?) {
|
||||
//TODO("Not yet implemented")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,209 @@
|
||||
package com.lukouguoji.gnc.activity
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.alibaba.fastjson.JSONArray
|
||||
import com.alibaba.fastjson.JSONObject
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.adapt.GncTransferListAdapter
|
||||
import com.lukouguoji.gnc.model.GncTransferList
|
||||
import com.lukouguoji.gnc.viewModel.GoutTransferViewModel
|
||||
import com.lukouguoji.module_base.BaseActivity
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.scwang.smart.refresh.footer.ClassicsFooter
|
||||
import com.scwang.smart.refresh.header.ClassicsHeader
|
||||
import com.scwang.smart.refresh.layout.api.RefreshLayout
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_GOUT_TRANSFER_ACTIVITY)
|
||||
class GoutTransferActivity : BaseActivity(), View.OnClickListener {
|
||||
private lateinit var viewModel: GoutTransferViewModel
|
||||
|
||||
private lateinit var adapter: GncTransferListAdapter
|
||||
private val collectList = ArrayList<GncTransferList>()
|
||||
|
||||
private var currentPage = 1
|
||||
private var pageSize = 10
|
||||
private var totalPage = 0
|
||||
private lateinit var refreshLayout: RefreshLayout
|
||||
|
||||
private lateinit var fdate: TextView
|
||||
private lateinit var fdateIcon: ImageView
|
||||
private lateinit var fno: EditText
|
||||
private lateinit var location: EditText
|
||||
private lateinit var locationScan: ImageView
|
||||
private lateinit var search: LinearLayout
|
||||
|
||||
|
||||
private val ymdSdf = SimpleDateFormat("yyyy-MM-dd")//年月日
|
||||
private val calendar = Calendar.getInstance()
|
||||
|
||||
private fun initView() {
|
||||
viewModel = ViewModelProvider(this).get(GoutTransferViewModel::class.java)
|
||||
//加载列表
|
||||
val layoutManager = LinearLayoutManager(this)
|
||||
adapter = GncTransferListAdapter(this, collectList)
|
||||
val recyclerView: RecyclerView = findViewById(R.id.recyclerList)
|
||||
recyclerView.layoutManager = layoutManager
|
||||
recyclerView.adapter = adapter
|
||||
|
||||
locationScan = findViewById(R.id.locationScan)
|
||||
location = findViewById(R.id.location)
|
||||
fdate = findViewById(R.id.fdateParam)
|
||||
fdateIcon = findViewById(R.id.fdateIcon)
|
||||
fno = findViewById(R.id.fno)
|
||||
search = findViewById(R.id.search)
|
||||
|
||||
|
||||
fdate.setOnClickListener(this)
|
||||
fdateIcon.setOnClickListener(this)
|
||||
locationScan.setOnClickListener(this)
|
||||
search.setOnClickListener(this)
|
||||
|
||||
fdate.text = ymdSdf.format(Date())
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_gout_transfer)
|
||||
setBackArrow("国内出港转运列表")
|
||||
viewModel = ViewModelProvider(this).get(GoutTransferViewModel::class.java)
|
||||
initView()
|
||||
|
||||
//初始化查询
|
||||
searchFun()
|
||||
loading()
|
||||
viewModel.searchParamLive.observe(this) {
|
||||
loadingCancel()
|
||||
//1.获取数据
|
||||
var listArr: JSONArray = it["list"] as JSONArray
|
||||
totalPage = it["pages"] as Int
|
||||
// var listArr :JSONArray =it["list"] as JSONArray
|
||||
if (listArr.size > 0) {
|
||||
//2.循环遍历塞入collectList
|
||||
listArr.forEach {
|
||||
val itemObj = it as JSONObject
|
||||
val id = itemObj.getIntValue("useId")
|
||||
val carId = itemObj.getString("carId") ?: ""
|
||||
val transId = itemObj.getString("transId") ?: ""// 确认人(如果此值不空,只能查看,也就是转运确定按钮隐藏)
|
||||
val transDate = itemObj.getString("transDate") ?: ""//确认时间
|
||||
|
||||
collectList.add(GncTransferList(id, carId, transId, transDate))
|
||||
}
|
||||
//3.调adpter展示
|
||||
if (currentPage == 1) {
|
||||
adapter.notifyDataSetChanged()
|
||||
} else {
|
||||
adapter.notifyItemRangeInserted((currentPage - 1) * 10, collectList.size)
|
||||
}
|
||||
refreshLayout.finishRefresh()
|
||||
refreshLayout.finishLoadMore()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////// 加载刷新的布局
|
||||
refreshLayout = findViewById<View>(R.id.refreshLayout) as RefreshLayout
|
||||
refreshLayout.setRefreshHeader(ClassicsHeader(this))
|
||||
refreshLayout.setRefreshFooter(ClassicsFooter(this))
|
||||
/////////////////////////////// 下拉刷新
|
||||
refreshLayout.setOnRefreshListener {
|
||||
resetSearch()
|
||||
}
|
||||
/////////////////////////////// 上拉加载
|
||||
refreshLayout.setOnLoadMoreListener {
|
||||
if (currentPage < totalPage) {
|
||||
currentPage++
|
||||
//初始化查询
|
||||
searchFun()
|
||||
} else {
|
||||
refreshLayout.finishLoadMoreWithNoMoreData()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
v?.let {
|
||||
when (it.id) {
|
||||
R.id.search -> {
|
||||
loading()
|
||||
resetSearch()
|
||||
}
|
||||
R.id.fdateParam -> {
|
||||
Common.onYearMonthDay(this, fdate.text.toString()) { year, month, day ->
|
||||
calendar.set(year, month - 1, day)
|
||||
fdate.text = ymdSdf.format(calendar.time)
|
||||
}
|
||||
}
|
||||
R.id.fdateIcon -> {
|
||||
fdate.text = ""
|
||||
}
|
||||
R.id.locationScan -> {
|
||||
scanCode(Constant.RequestCode.gnc_transfer_car_no)
|
||||
}
|
||||
else -> {
|
||||
Toast.makeText(this, "未找到对应操作", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 扫码返回的结果
|
||||
*/
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
// 扫描二维码/条码回传
|
||||
if (resultCode == RESULT_OK && data != null) {
|
||||
val content = data.getStringExtra(com.yzq.zxinglibrary.common.Constant.CODED_CONTENT)
|
||||
if (content == null || content == "") {
|
||||
Common.showToast(this, "条码错误!")
|
||||
return
|
||||
}
|
||||
when (requestCode) {
|
||||
Constant.RequestCode.gnc_transfer_car_no -> {
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GOUT_TRANSFER_INFO_ACTIVITY)
|
||||
.withString("carId", content)
|
||||
.navigation()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索
|
||||
*/
|
||||
private fun searchFun() {
|
||||
viewModel.search(
|
||||
pageSize,
|
||||
currentPage,
|
||||
fdate.text.toString(),
|
||||
fno.text.toString(),
|
||||
location.text.toString()
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置数据,搜索
|
||||
*/
|
||||
private fun resetSearch() {
|
||||
//recyclerView 清除所有数据数据
|
||||
refreshLayout.setNoMoreData(false)
|
||||
adapter.notifyItemRangeRemoved(0, collectList.size)
|
||||
collectList.clear()
|
||||
currentPage = 1
|
||||
searchFun()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,300 @@
|
||||
package com.lukouguoji.gnc.activity
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.alibaba.android.arouter.facade.annotation.Autowired
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.alibaba.fastjson.JSONObject
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.adapt.GncTransferRefListAdapter
|
||||
import com.lukouguoji.gnc.model.GncTransferRef
|
||||
import com.lukouguoji.gnc.viewModel.GoutTransferInfoViewModel
|
||||
import com.lukouguoji.module_base.BaseActivity
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_GOUT_TRANSFER_INFO_ACTIVITY)
|
||||
class GoutTransferInfoActivity : BaseActivity(), View.OnClickListener {
|
||||
private lateinit var viewModel: GoutTransferInfoViewModel
|
||||
|
||||
private lateinit var carNo: TextView
|
||||
private lateinit var scrollView: ScrollView
|
||||
private lateinit var bottomLayout: LinearLayout
|
||||
|
||||
//第一列
|
||||
private lateinit var guobangWeight: EditText
|
||||
private lateinit var volume: EditText
|
||||
private lateinit var level: EditText
|
||||
private lateinit var fdate: Button
|
||||
private lateinit var fubangStatus: EditText
|
||||
|
||||
//第二列
|
||||
private lateinit var currentWeight: EditText
|
||||
private lateinit var pc: EditText
|
||||
private lateinit var carrier: EditText
|
||||
private lateinit var mudiGang: EditText
|
||||
|
||||
//第三列
|
||||
private lateinit var cargoWeight: EditText
|
||||
private lateinit var cargoType: TextView
|
||||
private lateinit var hangban: EditText
|
||||
private lateinit var cangwei: EditText
|
||||
|
||||
//备注
|
||||
private lateinit var remark: EditText
|
||||
|
||||
//关联运单号
|
||||
private lateinit var refWaybill: LinearLayout
|
||||
private lateinit var adapter: GncTransferRefListAdapter
|
||||
private lateinit var recyclerView: RecyclerView
|
||||
private lateinit var recyclerViewLayout: LinearLayout
|
||||
|
||||
//确认
|
||||
private lateinit var submit: TextView
|
||||
|
||||
@JvmField
|
||||
@Autowired
|
||||
var id: Int = -9999
|
||||
|
||||
@JvmField
|
||||
@Autowired
|
||||
var carId: String? = null
|
||||
|
||||
private fun initView() {
|
||||
scrollView = findViewById(R.id.scrollView)
|
||||
bottomLayout = findViewById(R.id.bottomLayout)
|
||||
carNo = findViewById(R.id.carNo)
|
||||
guobangWeight = findViewById(R.id.guobangWeight)
|
||||
volume = findViewById(R.id.volume)
|
||||
level = findViewById(R.id.level)
|
||||
fdate = findViewById(R.id.fdate)
|
||||
fubangStatus = findViewById(R.id.fubangStatus)
|
||||
currentWeight = findViewById(R.id.currentWeight)
|
||||
pc = findViewById(R.id.pc)
|
||||
carrier = findViewById(R.id.carrier)
|
||||
mudiGang = findViewById(R.id.mudiGang)
|
||||
cargoWeight = findViewById(R.id.cargoWeight)
|
||||
cargoType = findViewById(R.id.cargoType)
|
||||
hangban = findViewById(R.id.hangban)
|
||||
cangwei = findViewById(R.id.cangwei)
|
||||
remark = findViewById(R.id.remark)
|
||||
refWaybill = findViewById(R.id.refWaybill)
|
||||
submit = findViewById(R.id.submit)
|
||||
//加载列表
|
||||
recyclerViewLayout = findViewById(R.id.gnc_transfer_list_layout)
|
||||
val layoutManager = LinearLayoutManager(this)
|
||||
adapter = GncTransferRefListAdapter(this, viewModel.gncTransferRefList)
|
||||
recyclerView = findViewById(R.id.gnc_transfer_waybill_list)
|
||||
recyclerView.layoutManager = layoutManager
|
||||
recyclerView.adapter = adapter
|
||||
|
||||
refWaybill.setOnClickListener(this)
|
||||
|
||||
submit.setOnClickListener(this)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_gout_transfer_info)
|
||||
setBackArrow("国内出港转运确认")
|
||||
viewModel = ViewModelProvider(this).get(GoutTransferInfoViewModel::class.java)
|
||||
initView()
|
||||
|
||||
viewModel.queryFlatByNo(id, carId)
|
||||
viewModel.queryFlatByNoObserver.observe(this) {
|
||||
loadingCancel()
|
||||
val status = it.getString("status")
|
||||
val data = it.getJSONObject("data")
|
||||
if (Constant.Result.succ == status && data != null) {
|
||||
viewModel.wbListArrFromNet = data.getJSONArray("wbList")
|
||||
viewModel.flatcarObjFromNet = data.getJSONObject("flatcar")
|
||||
|
||||
//确认人
|
||||
val transId = viewModel.flatcarObjFromNet.getString("transId")
|
||||
//确认人(如果此值不空,只能查看,也就是转运确定按钮隐藏)
|
||||
if (transId != null && transId != "") {
|
||||
bottomLayout.visibility = View.GONE
|
||||
} else {
|
||||
bottomLayout.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
//板车号
|
||||
carNo.text = viewModel.flatcarObjFromNet.getString("carId") ?: ""
|
||||
//过磅重量
|
||||
guobangWeight.setText(viewModel.flatcarObjFromNet.getDoubleValue("totalWeight").toString())
|
||||
//净重
|
||||
currentWeight.setText(viewModel.flatcarObjFromNet.getDoubleValue("netWeight").toString())
|
||||
|
||||
// 货重
|
||||
cargoWeight.setText(viewModel.flatcarObjFromNet.getDoubleValue("cargoWeight").toString())
|
||||
// 体积
|
||||
volume.setText(viewModel.flatcarObjFromNet.getDoubleValue("volume").toString())
|
||||
// 件数
|
||||
pc.setText(viewModel.flatcarObjFromNet.getIntValue("pc").toString())
|
||||
// 货物类型
|
||||
cargoType.text = viewModel.flatcarObjFromNet.getString("cargoType").toString()
|
||||
// 优先级
|
||||
level.setText(viewModel.flatcarObjFromNet.getString("priority") ?: "")
|
||||
// 承运人
|
||||
carrier.setText(viewModel.flatcarObjFromNet.getString("carrier") ?: "")
|
||||
// 航班号
|
||||
hangban.setText(viewModel.flatcarObjFromNet.getString("fno") ?: "")
|
||||
// 航班日期
|
||||
fdate.text = viewModel.flatcarObjFromNet.getString("fdate") ?: ""
|
||||
// 目的港
|
||||
mudiGang.setText(viewModel.flatcarObjFromNet.getString("fdest") ?: "")
|
||||
// 舱位
|
||||
cangwei.setText(viewModel.flatcarObjFromNet.getString("location") ?: "")
|
||||
// 复磅状态
|
||||
fubangStatus.setText(viewModel.flatcarObjFromNet.getString("checkFlag") ?: "")
|
||||
// 备注
|
||||
remark.setText(viewModel.flatcarObjFromNet.getString("remark") ?: "")
|
||||
|
||||
//加载关联运单列表
|
||||
viewModel.gncTransferRefList.clear()
|
||||
viewModel.wbListArrFromNet.forEach { waybill ->
|
||||
var waybillObj = waybill as JSONObject
|
||||
val gncTransferRef = GncTransferRef(
|
||||
waybillObj.getIntValue("whId"), waybillObj.getString("wbNo") ?: "",
|
||||
waybillObj.getString("agentCode") ?: "", waybillObj.getString("spCode") ?: "",
|
||||
waybillObj.getString("goods") ?: "", waybillObj.getString("flight") ?: "", waybillObj.getString("range") ?: ""
|
||||
)
|
||||
viewModel.gncTransferRefList.add(gncTransferRef)
|
||||
}
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.completedTransferObserver.observe(this) {
|
||||
loadingCancel()
|
||||
val status = it.getString("status")
|
||||
val data = it.getString("data")
|
||||
val msg = it.getString("msg")
|
||||
if (Constant.Result.succ == status && Constant.Result.succ == data) {
|
||||
Common.alertDialog(this, "转运成功!") { dialog ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
} else {
|
||||
if (msg != null && msg != "") {
|
||||
Common.alertDialog(this, msg) { dialog ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
} else {
|
||||
Common.alertDialog(this, "转运失败!") { dialog ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
v?.let {
|
||||
when (it.id) {
|
||||
R.id.refWaybill -> {
|
||||
//开关关联列表
|
||||
if (recyclerViewLayout.visibility == View.GONE) {
|
||||
recyclerViewLayout.visibility = View.VISIBLE
|
||||
} else {
|
||||
recyclerViewLayout.visibility = View.GONE
|
||||
}
|
||||
scrollView.post(Runnable { scrollView.scrollTo(0, scrollView.bottom) })
|
||||
// Common.showToast(this, "关联运单号")
|
||||
}
|
||||
R.id.submit -> {
|
||||
if(getAllEditData()){
|
||||
loading()
|
||||
viewModel.completedTransfer(viewModel.flatcarObjFromNet)
|
||||
}else{
|
||||
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
Toast.makeText(this, "未找到对应操作", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步viewModel的实体类数据
|
||||
*/
|
||||
private fun getAllEditData(): Boolean {
|
||||
/*if (carNo.text.toString() == "") {
|
||||
Common.showToast(this, getAllEditDataAlterStr("平板车编号"))
|
||||
return false
|
||||
}
|
||||
if (guobangWeight.text.toString().toDouble() <= 0.0) {
|
||||
Common.showToast(this, getAllEditDataAlterStr("过磅重量"))
|
||||
return false
|
||||
}
|
||||
if (currentWeight.text.toString().toDouble() <= 0.0) {
|
||||
Common.showToast(this, getAllEditDataAlterStr("净重"))
|
||||
return false
|
||||
}
|
||||
if (cargoWeight.text.toString().toDouble() <= 0.0) {
|
||||
Common.showToast(this, getAllEditDataAlterStr("货重"))
|
||||
return false
|
||||
}
|
||||
if (volume.text.toString().toDouble() <= 0.0) {
|
||||
Common.showToast(this, getAllEditDataAlterStr("体积"))
|
||||
return false
|
||||
}
|
||||
if (pc.text.toString().toInt() < 1) {
|
||||
Common.showToast(this, getAllEditDataAlterStr("件数"))
|
||||
return false
|
||||
}
|
||||
if (cargoType.text.toString() == "") {
|
||||
Common.showToast(this, getAllEditDataAlterStr("货物类型"))
|
||||
return false
|
||||
}*/
|
||||
/* if (level.text.toString() == "") {
|
||||
Common.showToast(this, "请填写优先级!")
|
||||
return false
|
||||
}*/
|
||||
/*if (carrier.text.toString() == "") {
|
||||
Common.showToast(this, getAllEditDataAlterStr("承运人"))
|
||||
return false
|
||||
}
|
||||
if (hangban.text.toString() == "") {
|
||||
Common.showToast(this, getAllEditDataAlterStr("航班号"))
|
||||
return false
|
||||
}
|
||||
if (fdate.text.toString() == "") {
|
||||
Common.showToast(this, getAllEditDataAlterStr("航班日期"))
|
||||
return false
|
||||
}
|
||||
if (mudiGang.text.toString() == "") {
|
||||
Common.showToast(this, getAllEditDataAlterStr("目的港"))
|
||||
return false
|
||||
}*/
|
||||
// if (cangwei.text.toString() == "") {
|
||||
// Common.showToast(this, getAllEditDataAlterStr("舱位"))
|
||||
// return false
|
||||
// }
|
||||
if (fubangStatus.text.toString() == "未复磅") {
|
||||
Common.showToast(this, "未复磅,不可转运!")
|
||||
return false
|
||||
}
|
||||
/* viewModel.flatcarObjFromNet["carId"] = carNo.text.toString()//板车号
|
||||
viewModel.flatcarObjFromNet["totalWeight"] = guobangWeight.text.toString().toDouble()//过磅重量
|
||||
viewModel.flatcarObjFromNet["netWeight"] = currentWeight.text.toString().toDouble()//净重
|
||||
viewModel.flatcarObjFromNet["cargoWeight"] = cargoWeight.text.toString().toDouble()//货重
|
||||
viewModel.flatcarObjFromNet["volume"] = volume.text.toString().toDouble()//体积
|
||||
viewModel.flatcarObjFromNet["pc"] = pc.text.toString().toInt()//件数
|
||||
viewModel.flatcarObjFromNet["cargoType"] = cargoType.text.toString()//货物类型*/
|
||||
|
||||
viewModel.flatcarObjFromNet["remark"] = remark.text.toString()//货物类型
|
||||
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
private fun getAllEditDataAlterStr(title: String) = "${title}为空,不可转运!"
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.lukouguoji.gnc.adapt
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Button
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.alibaba.fastjson.JSONObject
|
||||
import com.github.gzuliyujiang.dialog.DialogLog.print
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.activity.GoutChuKuListActivity
|
||||
import com.lukouguoji.gnc.model.GncFuBangList
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.http.user.UserNetwork
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
|
||||
/**
|
||||
* 出库,装机列表
|
||||
*/
|
||||
class GncChuKuListAdapter(val activity: Activity, private val collectList: List<GncFuBangList>) :
|
||||
RecyclerView.Adapter<GncChuKuListAdapter.ViewHolder>() {
|
||||
|
||||
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
val no: TextView = view.findViewById(R.id.no)
|
||||
val fno: TextView = view.findViewById(R.id.fno)
|
||||
val dest: TextView = view.findViewById(R.id.dest)
|
||||
val guobangWeight: TextView = view.findViewById(R.id.guobangWeight)
|
||||
val outer: TextView = view.findViewById(R.id.outer)
|
||||
val loader: TextView = view.findViewById(R.id.loader)
|
||||
val pc: TextView = view.findViewById(R.id.pc)
|
||||
var chuku: Button =view.findViewById(R.id.button_chuke)
|
||||
// var load: Button =view.findViewById(R.id.button_load)
|
||||
}
|
||||
|
||||
@SuppressLint("SuspiciousIndentation")
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.gnc_chu_ku_list_item, parent, false)
|
||||
val viewHolder = ViewHolder(view)
|
||||
viewHolder.chuku.setOnClickListener({
|
||||
val adapterPosition = viewHolder.adapterPosition
|
||||
val gncFuBang = collectList[adapterPosition]
|
||||
if(adapterPosition>=0){
|
||||
var a: GoutChuKuListActivity= activity as GoutChuKuListActivity
|
||||
a.ChuKu(gncFuBang.useId,gncFuBang.carId)
|
||||
}
|
||||
})
|
||||
/* viewHolder.load.setOnClickListener({
|
||||
val adapterPosition = viewHolder.adapterPosition
|
||||
val gncFuBang = collectList[adapterPosition]
|
||||
if(adapterPosition>=0){
|
||||
var a: GoutChuKuListActivity= activity as GoutChuKuListActivity
|
||||
a.viewModel.load(gncFuBang.useId,gncFuBang.carId)
|
||||
return@setOnClickListener
|
||||
}
|
||||
})*/
|
||||
viewHolder.itemView.setOnClickListener {
|
||||
val adapterPosition = viewHolder.adapterPosition
|
||||
// Log.i("刷新:${viewHolder.adapterPosition} ","刷新")
|
||||
if (adapterPosition < 0 || collectList.isEmpty()) {
|
||||
return@setOnClickListener
|
||||
}
|
||||
val gncFuBang = collectList[adapterPosition]
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
return viewHolder
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val collect = collectList[position]
|
||||
holder.no.text = collect.carId
|
||||
holder.fno.text = collect.fno
|
||||
holder.dest.text = collect.fdest
|
||||
holder.guobangWeight.text = "${collect.weight} KG"
|
||||
holder.outer.text = collect.outer
|
||||
holder.loader.text=collect.loader
|
||||
holder.pc.text = collect.pc.toString()
|
||||
}
|
||||
|
||||
override fun getItemCount() = collectList.size
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.lukouguoji.gnc.adapt
|
||||
|
||||
import android.app.Activity
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.github.gzuliyujiang.dialog.DialogLog.print
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.model.GncFuBangList
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
|
||||
/**
|
||||
* 复磅列表
|
||||
*/
|
||||
class GncFuBangListAdapter(val activity: Activity, private val collectList: List<GncFuBangList>) :
|
||||
RecyclerView.Adapter<GncFuBangListAdapter.ViewHolder>() {
|
||||
|
||||
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
val no: TextView = view.findViewById(R.id.no)
|
||||
val dest: TextView = view.findViewById(R.id.dest)
|
||||
val guobangWeight: TextView = view.findViewById(R.id.guobangWeight)
|
||||
val weight: TextView = view.findViewById(R.id.weight)
|
||||
val pc: TextView = view.findViewById(R.id.pc)
|
||||
val guobangDate: TextView = view.findViewById(R.id.guobangDate)
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.gnc_fu_bang_list_item, parent, false)
|
||||
val viewHolder = ViewHolder(view)
|
||||
|
||||
viewHolder.itemView.setOnClickListener {
|
||||
val adapterPosition = viewHolder.adapterPosition
|
||||
Log.i("刷新:${viewHolder.adapterPosition} ","刷新")
|
||||
if (adapterPosition < 0 || collectList.isEmpty()) {
|
||||
return@setOnClickListener
|
||||
}
|
||||
val gncFuBang = collectList[adapterPosition]
|
||||
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GOUT_FU_BANG_ACTIVITY).withString("userIdParam", gncFuBang.useId.toString())
|
||||
.navigation(activity, Constant.RequestCode.gnc_shouyun_list_refresh)
|
||||
|
||||
}
|
||||
|
||||
return viewHolder
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val collect = collectList[position]
|
||||
holder.no.text = collect.carId
|
||||
holder.dest.text = collect.fdest
|
||||
holder.guobangWeight.text = "${collect.weight} KG"
|
||||
holder.weight.text = collect.weight.toString()
|
||||
holder.pc.text = collect.pc.toString()
|
||||
holder.guobangDate.text = collect.date
|
||||
}
|
||||
|
||||
override fun getItemCount() = collectList.size
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.lukouguoji.gnc.adapt
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Button
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.alibaba.fastjson.JSONObject
|
||||
import com.github.gzuliyujiang.dialog.DialogLog.print
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.activity.GncLoadListActivity
|
||||
import com.lukouguoji.gnc.activity.GoutChuKuListActivity
|
||||
import com.lukouguoji.gnc.model.GncFuBangList
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.http.user.UserNetwork
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.ninetripods.sydialoglib.IDialog
|
||||
|
||||
/**
|
||||
* 出库,装机列表
|
||||
*/
|
||||
class GncLoadListAdapter(val activity: Activity, private val collectList: List<GncFuBangList>) :
|
||||
RecyclerView.Adapter<GncLoadListAdapter.ViewHolder>() {
|
||||
|
||||
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
val no: TextView = view.findViewById(R.id.no)
|
||||
val fno: TextView = view.findViewById(R.id.fno)
|
||||
val dest: TextView = view.findViewById(R.id.dest)
|
||||
val guobangWeight: TextView = view.findViewById(R.id.guobangWeight)
|
||||
val outer: TextView = view.findViewById(R.id.outer)
|
||||
val loader: TextView = view.findViewById(R.id.loader)
|
||||
val pc: TextView = view.findViewById(R.id.pc)
|
||||
// var chuku: Button =view.findViewById(R.id.button_chuke)
|
||||
var load: Button =view.findViewById(R.id.button_load)
|
||||
}
|
||||
|
||||
@SuppressLint("SuspiciousIndentation")
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.gnc_load_list_item, parent, false)
|
||||
val viewHolder = ViewHolder(view)
|
||||
viewHolder.load.setOnClickListener({
|
||||
val adapterPosition = viewHolder.adapterPosition
|
||||
val gncFuBang = collectList[adapterPosition]
|
||||
if(adapterPosition>=0){
|
||||
var a: GncLoadListActivity = activity as GncLoadListActivity
|
||||
a.loadCar(gncFuBang.useId,gncFuBang.carId)
|
||||
}
|
||||
})
|
||||
viewHolder.itemView.setOnClickListener {
|
||||
val adapterPosition = viewHolder.adapterPosition
|
||||
// Log.i("刷新:${viewHolder.adapterPosition} ","刷新")
|
||||
if (adapterPosition < 0 || collectList.isEmpty()) {
|
||||
return@setOnClickListener
|
||||
}
|
||||
val gncFuBang = collectList[adapterPosition]
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
return viewHolder
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val collect = collectList[position]
|
||||
holder.no.text = collect.carId
|
||||
holder.fno.text = collect.fno
|
||||
holder.dest.text = collect.fdest
|
||||
holder.guobangWeight.text = "${collect.weight} KG"
|
||||
holder.outer.text = collect.outer
|
||||
holder.loader.text=collect.loader
|
||||
holder.pc.text = collect.pc.toString()
|
||||
}
|
||||
|
||||
override fun getItemCount() = collectList.size
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.lukouguoji.gnc.adapt
|
||||
|
||||
import android.app.Activity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.EditText
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.model.GncQueryInfo
|
||||
|
||||
/**
|
||||
* 出港查询详情
|
||||
*/
|
||||
class GncQueryInfoListAdapter(val activity: Activity, val collectList: MutableList<GncQueryInfo>) :
|
||||
RecyclerView.Adapter<GncQueryInfoListAdapter.ViewHolder>() {
|
||||
|
||||
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
val title: TextView = view.findViewById(R.id.title)
|
||||
val content: EditText = view.findViewById(R.id.content)
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.gnc_query_info_item, parent, false)
|
||||
val viewHolder = ViewHolder(view)
|
||||
|
||||
/* viewHolder.itemView.setOnClickListener {
|
||||
|
||||
var adapterPosition = viewHolder.adapterPosition
|
||||
var gncFuBang = collectList[adapterPosition]
|
||||
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GOUT_FU_BANG_ACTIVITY).withString("userIdParam", gncFuBang.useId.toString())
|
||||
.navigation(activity, Constant.RequestCode.gnc_shouyun_list_refresh)
|
||||
|
||||
}
|
||||
*/
|
||||
return viewHolder
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val collect = collectList[position]
|
||||
holder.title.text = collect.title
|
||||
holder.content.setText(collect.content)
|
||||
}
|
||||
|
||||
override fun getItemCount() = collectList.size
|
||||
|
||||
fun append(gncQueryInfo: GncQueryInfo) {
|
||||
collectList.add(gncQueryInfo)
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.lukouguoji.gnc.adapt
|
||||
|
||||
import android.app.Activity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.model.GncQueryInfoWh
|
||||
|
||||
class GncQueryInfoWhListAdapter(val activity: Activity, val collectList: MutableList<GncQueryInfoWh>) :
|
||||
RecyclerView.Adapter<GncQueryInfoWhListAdapter.ViewHolder>() {
|
||||
|
||||
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
val location: TextView = view.findViewById(R.id.location)
|
||||
val pc: TextView = view.findViewById(R.id.pc)
|
||||
val weight: TextView = view.findViewById(R.id.weight)
|
||||
val flight: TextView = view.findViewById(R.id.flight)
|
||||
val opDate: TextView = view.findViewById(R.id.opDate)
|
||||
val fclose: TextView = view.findViewById(R.id.fclose)
|
||||
val opId: TextView = view.findViewById(R.id.opId)
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.gnc_query_info_wh_list_item, parent, false)
|
||||
val viewHolder = ViewHolder(view)
|
||||
|
||||
/* viewHolder.itemView.setOnClickListener {
|
||||
|
||||
var adapterPosition = viewHolder.adapterPosition
|
||||
var gncFuBang = collectList[adapterPosition]
|
||||
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GOUT_FU_BANG_ACTIVITY).withString("userIdParam", gncFuBang.useId.toString())
|
||||
.navigation(activity, Constant.RequestCode.gnc_shouyun_list_refresh)
|
||||
|
||||
}
|
||||
*/
|
||||
return viewHolder
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val collect = collectList[position]
|
||||
holder.location.text = collect.location
|
||||
holder.pc.text = collect.pc.toString()
|
||||
holder.weight.text = "${collect.weight} KG"
|
||||
holder.flight.text = collect.flight
|
||||
holder.opDate.text = collect.opDate
|
||||
holder.fclose.text = collect.fclose
|
||||
holder.opId.text = collect.opId
|
||||
}
|
||||
|
||||
override fun getItemCount() = collectList.size
|
||||
|
||||
fun append(gncQueryInfoWh: GncQueryInfoWh) {
|
||||
collectList.add(gncQueryInfoWh)
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.lukouguoji.gnc.adapt
|
||||
|
||||
import android.app.Activity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.model.GncQueryList
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
|
||||
/**
|
||||
* 国内出港查询列表
|
||||
*/
|
||||
class GncQueryListAdapter(val activity: Activity, private val collectList: List<GncQueryList>) :
|
||||
RecyclerView.Adapter<GncQueryListAdapter.ViewHolder>() {
|
||||
|
||||
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
val no: TextView = view.findViewById(R.id.no)
|
||||
val agentCode: TextView = view.findViewById(R.id.agentCode)
|
||||
val goods: TextView = view.findViewById(R.id.goods)
|
||||
val flight: TextView = view.findViewById(R.id.flight)
|
||||
val dest: TextView = view.findViewById(R.id.dest)
|
||||
|
||||
val opDate: TextView = view.findViewById(R.id.opDate)
|
||||
val fclose: TextView = view.findViewById(R.id.fclose)
|
||||
val pc: TextView = view.findViewById(R.id.pc)
|
||||
val weight: TextView = view.findViewById(R.id.weight)
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.gnc_query_list_item, parent, false)
|
||||
val viewHolder = ViewHolder(view)
|
||||
|
||||
viewHolder.itemView.setOnClickListener {
|
||||
|
||||
var adapterPosition = viewHolder.adapterPosition
|
||||
if (adapterPosition < 0 || collectList.isEmpty()) {
|
||||
return@setOnClickListener
|
||||
}
|
||||
var gncQueryList = collectList[adapterPosition]
|
||||
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GNC_QUERY_INFO).withInt("id", gncQueryList.mawbId)
|
||||
.navigation()
|
||||
|
||||
}
|
||||
|
||||
return viewHolder
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val collect = collectList[position]
|
||||
holder.no.text = collect.wbNo
|
||||
holder.agentCode.text = collect.agentCode
|
||||
holder.goods.text = collect.goods
|
||||
holder.flight.text = collect.flight
|
||||
holder.dest.text = collect.dest
|
||||
|
||||
holder.opDate.text = collect.opDate
|
||||
holder.fclose.text = collect.fclose
|
||||
holder.pc.text = collect.pc
|
||||
holder.weight.text = collect.weight
|
||||
|
||||
}
|
||||
|
||||
override fun getItemCount() = collectList.size
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.lukouguoji.gnc.adapt
|
||||
|
||||
import android.app.Activity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.model.GncTransferList
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
|
||||
/**
|
||||
* 国内出港转运列表
|
||||
*/
|
||||
class GncTransferListAdapter(val activity: Activity, private val collectList: List<GncTransferList>) :
|
||||
RecyclerView.Adapter<GncTransferListAdapter.ViewHolder>() {
|
||||
|
||||
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
val carId: TextView = view.findViewById(R.id.carId)
|
||||
val transId: TextView = view.findViewById(R.id.transId)
|
||||
val transDate: TextView = view.findViewById(R.id.transDate)
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.gnc_transfer_list_item, parent, false)
|
||||
val viewHolder = ViewHolder(view)
|
||||
|
||||
viewHolder.itemView.setOnClickListener {
|
||||
val adapterPosition = viewHolder.adapterPosition
|
||||
if (adapterPosition < 0 || collectList.isEmpty()) {
|
||||
return@setOnClickListener
|
||||
}
|
||||
val gncTransferList = collectList[adapterPosition]
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GOUT_TRANSFER_INFO_ACTIVITY).withInt("id", gncTransferList.mawbId)
|
||||
.navigation()
|
||||
|
||||
}
|
||||
|
||||
return viewHolder
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val collect = collectList[position]
|
||||
holder.carId.text = collect.carId
|
||||
holder.transId.text = collect.transId
|
||||
holder.transDate.text = collect.transDate
|
||||
}
|
||||
|
||||
override fun getItemCount() = collectList.size
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.lukouguoji.gnc.adapt
|
||||
|
||||
import android.app.Activity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.lukouguoji.gnc.R
|
||||
|
||||
import com.lukouguoji.gnc.model.GncTransferRef
|
||||
|
||||
/**
|
||||
* 复磅列表
|
||||
*/
|
||||
class GncTransferRefListAdapter(val activity: Activity, private val collectList: List<GncTransferRef>) :
|
||||
RecyclerView.Adapter<GncTransferRefListAdapter.ViewHolder>() {
|
||||
|
||||
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
val no: TextView = view.findViewById(R.id.no)
|
||||
val agentCode: TextView = view.findViewById(R.id.agentCode)
|
||||
val spCode: TextView = view.findViewById(R.id.spCode)
|
||||
val goods: TextView = view.findViewById(R.id.goods)
|
||||
val flight: TextView = view.findViewById(R.id.flight)
|
||||
val range: TextView = view.findViewById(R.id.range)
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.gnc_transfer_ref_list_item, parent, false)
|
||||
val viewHolder = ViewHolder(view)
|
||||
|
||||
/*viewHolder.itemView.setOnClickListener {
|
||||
|
||||
var adapterPosition = viewHolder.adapterPosition
|
||||
var guoNeiOutCollect = collectList[adapterPosition]
|
||||
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GOUT_START_COT_ACTIVITY).withInt("wbId", guoNeiOutCollect.mawbId)
|
||||
.navigation(activity, Constant.RequestCode.gnc_shouyun_refresh)
|
||||
|
||||
}*/
|
||||
|
||||
return viewHolder
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val collect = collectList[position]
|
||||
holder.no.text = collect.wbNo
|
||||
holder.agentCode.text = collect.agentCode
|
||||
holder.spCode.text = collect.spCode
|
||||
holder.goods.text = collect.goods
|
||||
holder.flight.text = collect.flight
|
||||
holder.range.text = collect.range
|
||||
|
||||
}
|
||||
|
||||
override fun getItemCount() = collectList.size
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.lukouguoji.gnc.adapt
|
||||
|
||||
import android.app.Activity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.EditText
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.model.GncWareHouseInfo
|
||||
|
||||
/**
|
||||
* 查询详情
|
||||
*/
|
||||
class GncWareHouseInfoListAdapter(val activity: Activity, val collectList: MutableList<GncWareHouseInfo>) :
|
||||
RecyclerView.Adapter<GncWareHouseInfoListAdapter.ViewHolder>() {
|
||||
|
||||
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
val title: TextView = view.findViewById(R.id.title)
|
||||
val content: EditText = view.findViewById(R.id.content)
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.gnc_ware_house_info_item, parent, false)
|
||||
val viewHolder = ViewHolder(view)
|
||||
|
||||
/* viewHolder.itemView.setOnClickListener {
|
||||
|
||||
var adapterPosition = viewHolder.adapterPosition
|
||||
var gncFuBang = collectList[adapterPosition]
|
||||
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GOUT_FU_BANG_ACTIVITY).withString("userIdParam", gncFuBang.useId.toString())
|
||||
.navigation(activity, Constant.RequestCode.gnc_shouyun_list_refresh)
|
||||
|
||||
}
|
||||
*/
|
||||
return viewHolder
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val collect = collectList[position]
|
||||
holder.title.text = collect.title
|
||||
holder.content.setText(collect.content)
|
||||
}
|
||||
|
||||
override fun getItemCount() = collectList.size
|
||||
|
||||
fun append(gncWareHouseInfo: GncWareHouseInfo) {
|
||||
collectList.add(gncWareHouseInfo)
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.lukouguoji.gnc.adapt
|
||||
|
||||
import android.app.Activity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.model.GncWareHouseList
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
|
||||
/**
|
||||
* 仓库管理列表
|
||||
*/
|
||||
class GncWareHouseListAdapter(val activity: Activity, private val collectList: List<GncWareHouseList>) :
|
||||
RecyclerView.Adapter<GncWareHouseListAdapter.ViewHolder>() {
|
||||
|
||||
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
val groupNameLayout: LinearLayout = view.findViewById(R.id.groupNameLayout)
|
||||
val groupTitle: TextView = view.findViewById(R.id.groupTitle)
|
||||
val groupContent: TextView = view.findViewById(R.id.groupContent)
|
||||
val days: TextView = view.findViewById(R.id.days)
|
||||
|
||||
val no: TextView = view.findViewById(R.id.no)
|
||||
val location: TextView = view.findViewById(R.id.location)
|
||||
val weight: TextView = view.findViewById(R.id.weight)
|
||||
val fno: TextView = view.findViewById(R.id.fno)
|
||||
val pc: TextView = view.findViewById(R.id.pc)
|
||||
val date: TextView = view.findViewById(R.id.date)
|
||||
val isCangDan: TextView = view.findViewById(R.id.isCangDan)
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.gnc_ware_house_list_item, parent, false)
|
||||
val viewHolder = ViewHolder(view)
|
||||
|
||||
viewHolder.itemView.setOnClickListener {
|
||||
|
||||
var adapterPosition = viewHolder.adapterPosition
|
||||
if (adapterPosition < 0 || collectList.isEmpty()) {
|
||||
return@setOnClickListener
|
||||
}
|
||||
var gncFuBang = collectList[adapterPosition]
|
||||
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GNC_WARE_HOUSE_INFO).withInt("id", gncFuBang.id)
|
||||
.navigation()
|
||||
|
||||
}
|
||||
return viewHolder
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val collect = collectList[position]
|
||||
val groupTitle = collect.groupTitle
|
||||
val groupName = collect.groupName
|
||||
val days = collect.days
|
||||
//第一条
|
||||
if (position == 0 && groupName != "") {
|
||||
holder.groupNameLayout.visibility = View.VISIBLE
|
||||
holder.groupTitle.text = groupTitle
|
||||
holder.groupContent.text = groupName
|
||||
//出库时间分组时,days数据不为null,展示
|
||||
if (days != null) {
|
||||
holder.days.text = days
|
||||
holder.days.visibility = View.VISIBLE
|
||||
} else {
|
||||
holder.days.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
//不是第一条
|
||||
else if (groupName != "") {
|
||||
//当前分组名和上一次分组名不一样,展示新的分组
|
||||
val preCollect = collectList[position - 1]
|
||||
val preGroupName = preCollect.groupName
|
||||
if (groupName != preGroupName) {
|
||||
holder.groupNameLayout.visibility = View.VISIBLE
|
||||
holder.groupTitle.text = groupTitle
|
||||
holder.groupContent.text = groupName
|
||||
//出库时间分组时,days数据不为null,展示
|
||||
if (days != null) {
|
||||
holder.days.text = days
|
||||
holder.days.visibility = View.VISIBLE
|
||||
} else {
|
||||
holder.days.visibility = View.GONE
|
||||
}
|
||||
} else {
|
||||
holder.groupNameLayout.visibility = View.GONE
|
||||
}
|
||||
} else {
|
||||
holder.groupNameLayout.visibility = View.GONE
|
||||
}
|
||||
|
||||
holder.no.text = collect.waybillNo
|
||||
holder.location.text = collect.location
|
||||
holder.pc.text = collect.pc.toString()
|
||||
holder.weight.text = "${collect.weight} KG"
|
||||
holder.fno.text = collect.fno
|
||||
holder.date.text = collect.date
|
||||
holder.isCangDan.text = if (collect.isCangDan == "1") "是" else "否"
|
||||
}
|
||||
|
||||
override fun getItemCount() = collectList.size
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.lukouguoji.gnc.adapt
|
||||
|
||||
import android.app.Activity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.lukouguoji.gnc.R
|
||||
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
import com.lukouguoji.gnc.model.GuoNeiOutCollect
|
||||
import com.lukouguoji.gnc.page.shouyun.list.GncShouYunListActivity
|
||||
|
||||
class GoutCollectionAdapter(val activity: Activity, private val collectList: List<GuoNeiOutCollect>) :
|
||||
RecyclerView.Adapter<GoutCollectionAdapter.ViewHolder>() {
|
||||
|
||||
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
val no: TextView = view.findViewById(R.id.no)
|
||||
val agentCode: TextView = view.findViewById(R.id.agentCode)
|
||||
val planDate: TextView = view.findViewById(R.id.planDate)
|
||||
val planFight: TextView = view.findViewById(R.id.planFight)
|
||||
val range: TextView = view.findViewById(R.id.range)
|
||||
val spCode: TextView = view.findViewById(R.id.spCode)
|
||||
val goods: TextView = view.findViewById(R.id.goods)
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.check_in_item, parent, false)
|
||||
val viewHolder = ViewHolder(view)
|
||||
|
||||
viewHolder.itemView.setOnClickListener {
|
||||
|
||||
var adapterPosition = viewHolder.adapterPosition
|
||||
if (adapterPosition < 0 || collectList.isEmpty()) {
|
||||
return@setOnClickListener
|
||||
}
|
||||
var guoNeiOutCollect = collectList[adapterPosition]
|
||||
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GOUT_START_COT_ACTIVITY).withInt("wbId", guoNeiOutCollect.mawbId)
|
||||
.navigation(activity, Constant.RequestCode.gnc_shouyun_refresh)
|
||||
|
||||
}
|
||||
|
||||
return viewHolder
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val collect = collectList[position]
|
||||
holder.no.text = collect.wbNo
|
||||
holder.agentCode.text = collect.agentCode
|
||||
holder.planDate.text = collect.planDate
|
||||
holder.spCode.text = collect.spCode
|
||||
holder.goods.text = collect.goods
|
||||
holder.planFight.text = collect.flight
|
||||
holder.range.text = collect.range
|
||||
|
||||
}
|
||||
|
||||
override fun getItemCount() = collectList.size
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.lukouguoji.gnc.bluetooth.adapter
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.bluetooth.bean.SimpleBlueDevice
|
||||
import com.lukouguoji.gnc.bluetooth.printerface.AdapterClickListener
|
||||
|
||||
/**
|
||||
*author : huitao
|
||||
*e-mail : pig.huitao@gmail.com
|
||||
*date : 2021/5/17 19:43
|
||||
*desc :
|
||||
*version :
|
||||
*/
|
||||
class BlueAdapter(list: List<SimpleBlueDevice>, context: Context) :
|
||||
RecyclerView.Adapter<BlueAdapter.MyHolder>() {
|
||||
private var mList = list
|
||||
private var mCtx = context
|
||||
private var mOnClickListener: AdapterClickListener? = null
|
||||
fun setOnClickListener(clickListener: AdapterClickListener) {
|
||||
this.mOnClickListener = clickListener
|
||||
}
|
||||
|
||||
inner class MyHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||
// val mBinding = DataBindingUtil.bind<AdapterBondListBinding>(view)
|
||||
val tvBlueName: TextView = view.findViewById(R.id.tv_blue_name)
|
||||
val tvBlueStatus: TextView = view.findViewById(R.id.tv_blue_status)
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyHolder {
|
||||
val view = LayoutInflater.from(mCtx).inflate(R.layout.adapter_bond_list, parent, false)
|
||||
return MyHolder(view)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: MyHolder, position: Int) {
|
||||
holder.tvBlueName.text = mList[position].name
|
||||
holder.tvBlueStatus.text = when (mList[position].isConnected) {
|
||||
true -> "已连接"
|
||||
else -> "连接"
|
||||
}
|
||||
holder.tvBlueStatus.setOnClickListener {
|
||||
mOnClickListener?.onClickViewListener(it, holder.adapterPosition)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return mList.size
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.lukouguoji.gnc.bluetooth.bean
|
||||
|
||||
/**
|
||||
*author : huitao
|
||||
*e-mail : pig.huitao@gmail.com
|
||||
*date : 2021/5/17 21:24
|
||||
*desc :
|
||||
*version :
|
||||
*/
|
||||
class LabelBean(){
|
||||
var titleName: String=""
|
||||
var dest: String=""
|
||||
var fno: String=""
|
||||
var pc: String=""
|
||||
var weight: String=""
|
||||
var volume: String?=""
|
||||
var location: String?=""
|
||||
var opdate: String?=""
|
||||
var carId:String?=""
|
||||
constructor( titleName: String,dest: String,carId: String,fno: String,pc: String,weight: String,volume: String?,location: String?,opdate: String?):this()
|
||||
{
|
||||
this.titleName=titleName
|
||||
this.dest=dest
|
||||
this.fno=fno
|
||||
this.carId=carId
|
||||
this.pc=pc
|
||||
this.weight=weight
|
||||
this.volume=volume
|
||||
this.location=location
|
||||
this.opdate=opdate
|
||||
var index=weight.indexOf(".")
|
||||
if(index>0) {
|
||||
this.weight=weight.subSequence(0,index).toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
fun getOrderData(): LabelBean {
|
||||
return LabelBean(
|
||||
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.lukouguoji.gnc.bluetooth.bean
|
||||
|
||||
/**
|
||||
*author : huitao
|
||||
*e-mail : pig.huitao@gmail.com
|
||||
*date : 2021/5/17 20:01
|
||||
*desc :
|
||||
*version :
|
||||
*/
|
||||
data class SimpleBlueDevice(var name: String, var isConnected: Boolean)
|
||||
@@ -0,0 +1,101 @@
|
||||
package com.lukouguoji.gnc.bluetooth.bean;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TSPL {
|
||||
String TAG="TSPL";
|
||||
int maxWidthInMM=800;
|
||||
int maxHeightInMM=600;
|
||||
///写入指令
|
||||
public byte[] tspl_writeCmd(String cmd, boolean end) {
|
||||
if (TextUtils.isEmpty(cmd)) {
|
||||
return null;
|
||||
}
|
||||
cmd = end ? (cmd + "\r\n") : cmd;
|
||||
Log.d(TAG, "tspl_writeCmd: " + cmd);
|
||||
byte[] data;
|
||||
try {
|
||||
data = cmd.getBytes();
|
||||
} catch (Exception var4) {
|
||||
Log.e(TAG, "String getBytes('GBK') failed");
|
||||
return null;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
///设置纸张和gap
|
||||
public ArrayList<byte[]> tspl_pageSetup(int widthInMM, int heightInMM, int gapInMM) {
|
||||
ArrayList<byte[]> list=new ArrayList<>();
|
||||
if (widthInMM <= 0 || heightInMM <= 0) {
|
||||
return list;
|
||||
}
|
||||
if (widthInMM > maxWidthInMM) widthInMM = maxWidthInMM;
|
||||
if (heightInMM > maxHeightInMM) heightInMM = maxHeightInMM;
|
||||
String cmd = String.format("SIZE %d mm, %d mm", widthInMM, heightInMM);
|
||||
list.add( tspl_writeCmd(cmd, true));
|
||||
list.add( tspl_writeCmd(String.format("GAP %d mm,0", gapInMM), true));
|
||||
return list;
|
||||
}
|
||||
|
||||
///绘制图片
|
||||
///1. 算法中对图片以2kb大小进行了切割,防止打印机内存不足,可以自行修改此值
|
||||
///2. 算法中用经验公式对图片进行了二值化处理,每8个点为1mm
|
||||
public ArrayList<byte[]> tspl_drawGraphic(int start_x, int start_y, Bitmap bmp) {
|
||||
ArrayList<byte[]> list=new ArrayList<>();
|
||||
int bmp_size_x = bmp.getWidth();
|
||||
int bmp_size_y = bmp.getHeight();
|
||||
int byteWidth = (bmp_size_x - 1) / 8 + 1; //8个点一个byte,所以要先计算byteWidth
|
||||
int byteHeight = bmp_size_y;
|
||||
if (byteWidth <= 0) return null;
|
||||
if (byteHeight <= 0) return null;
|
||||
int unitHeight = 2048 / byteWidth;//分包规则,算法可无需过多理解,一个包就unitHeight*byteWidth个点
|
||||
int unitCount = (byteHeight - 1) / unitHeight + 1;
|
||||
int startY, endY;//每个包y方向起始的位置
|
||||
byte[] dataByte;
|
||||
int color, A, R, G, B;
|
||||
for (int n = 0; n < unitCount; n++) {
|
||||
Log.d(TAG, "drawGraphic unit=" + (n + 1) + "/" + unitCount);
|
||||
startY = n * unitHeight;
|
||||
if ((startY + unitHeight) > bmp_size_y) {
|
||||
endY = bmp_size_y;
|
||||
} else {
|
||||
endY = startY + unitHeight;
|
||||
}
|
||||
int byteLen = (endY - startY) * byteWidth;//每个包数据的字节个数
|
||||
dataByte = new byte[byteLen];
|
||||
for (int y = startY; y < endY; y++) {
|
||||
for (int x = 0; x < bmp_size_x; x++) {
|
||||
color = bmp.getPixel(x, y);
|
||||
A = color >> 24 & 0xFF;
|
||||
R = color >> 16 & 0xFF;
|
||||
G = color >> 8 & 0xFF;
|
||||
B = color & 0xFF;
|
||||
//经验公式二值化,透明视为白色
|
||||
if (A == 0 || R * 0.3 + G * 0.59 + B * 0.11 > 127) {
|
||||
dataByte[(y - startY) * byteWidth + x / 8] |= (0x80 >> (x % 8));
|
||||
}
|
||||
}
|
||||
}
|
||||
int curUnitHeight = n == unitCount - 1 ? (byteHeight - (n * unitHeight)) : unitHeight;
|
||||
String cmdHeader = "BITMAP " + start_x + "," + (start_y + startY) + "," + byteWidth + "," + curUnitHeight + "," + 0 + ",";
|
||||
list.add(tspl_writeCmd(cmdHeader, false) );
|
||||
list.add(dataByte);
|
||||
list.add(new byte[]{0x0D, 0x0A});
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/// 打印
|
||||
public byte[] tspl_print(int count, boolean isReverse) {
|
||||
if (count < 0) count = 1;
|
||||
if (count > 65535) count = 65535;
|
||||
String cmd = String.format("PRINT %d,1", count);
|
||||
return tspl_writeCmd(cmd, true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
package com.lukouguoji.gnc.bluetooth.printer
|
||||
|
||||
import android.os.Bundle
|
||||
import android.os.Looper
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.alibaba.android.arouter.facade.annotation.Autowired
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.huitao.printer.Printer
|
||||
import com.huitao.printer.printerface.DeviceFoundCallback
|
||||
import com.huitao.printer.printerface.ProcessData
|
||||
import com.huitao.printer.printerface.TaskCallback
|
||||
import com.huitao.printer.utils.strToBytes
|
||||
import com.lukouguoji.gnc.bluetooth.adapter.BlueAdapter
|
||||
import com.lukouguoji.gnc.bluetooth.bean.SimpleBlueDevice
|
||||
import com.lukouguoji.gnc.bluetooth.printerface.AdapterClickListener
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.bluetooth.bean.LabelBean
|
||||
import com.lukouguoji.gnc.bluetooth.printer.SpaceItemDecoration
|
||||
import com.lukouguoji.module_base.BaseActivity
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
*author : huitao
|
||||
*e-mail : pig.huitao@gmail.com
|
||||
*date : 2021/5/17 19:00
|
||||
*desc :
|
||||
*version :
|
||||
*/
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_Printer_ACTIVITY)
|
||||
class PrinterActivity : BaseActivity(), AdapterClickListener {
|
||||
private lateinit var mList: ArrayList<SimpleBlueDevice>
|
||||
private lateinit var mAdapter: BlueAdapter
|
||||
// private lateinit var mBinding: ActivityPrinterBinding
|
||||
private var mIsConnect = false
|
||||
@Autowired
|
||||
lateinit var label : LabelBean
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView( R.layout.activity_printer)
|
||||
setBackArrow("出港复磅")
|
||||
|
||||
/* if (savedInstanceState != null) {
|
||||
label= LabelBean(
|
||||
titleName = savedInstanceState.getString("titleName","扬州泰州机场"),
|
||||
fno=savedInstanceState.getString("fno",""),
|
||||
dest = savedInstanceState.getString("dest",""),
|
||||
pc=savedInstanceState.getString("pc",""),
|
||||
weight = savedInstanceState.getString("weight",""),
|
||||
volume = savedInstanceState.getString("volume",""),
|
||||
opdate = savedInstanceState.getString("opdate",""),
|
||||
location = savedInstanceState.getString("location","")
|
||||
)
|
||||
// label= savedInstanceState.get("label") as LabelBean
|
||||
};*/
|
||||
initViews()
|
||||
}
|
||||
|
||||
private fun initViews() {
|
||||
mList = java.util.ArrayList()
|
||||
mAdapter = BlueAdapter(mList, this).apply {
|
||||
setOnClickListener(this@PrinterActivity)
|
||||
}
|
||||
val layoutManager = LinearLayoutManager(this)
|
||||
var recyclerView: RecyclerView = findViewById(R.id.rv)
|
||||
recyclerView.layoutManager = layoutManager
|
||||
recyclerView.adapter = mAdapter
|
||||
recyclerView.apply{
|
||||
addItemDecoration(SpaceItemDecoration(0, 12, true))
|
||||
adapter = mAdapter
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun obtainBondDevices(view: View) {
|
||||
if (view.id == R.id.tv_bond_device) {
|
||||
//获取周围蓝牙设备,已绑定的蓝牙设备会直接通过集合返回,扫描发现的设备通过DeviceFoundCallback回调回来
|
||||
val list = Printer.getInstance().getBondDevicesList(object : DeviceFoundCallback {
|
||||
override fun deviceFoundCallback(device: String) {
|
||||
//处理扫描发现的周围蓝牙设备
|
||||
}
|
||||
})
|
||||
if (mList.isNotEmpty()) mList.clear()
|
||||
list?.forEach {
|
||||
mList.add(SimpleBlueDevice(name = it, isConnected = false))
|
||||
}
|
||||
mAdapter.notifyDataSetChanged()
|
||||
} else {
|
||||
//如果设备已连接,则执行写入数据
|
||||
if (mIsConnect) {
|
||||
writeData(label)
|
||||
} else {
|
||||
Toast.makeText(this, getString(R.string.please_connect_first), Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private fun writeData(label: LabelBean?) {
|
||||
var _this=this
|
||||
Printer.getInstance().writeData(object : TaskCallback {
|
||||
override fun onSucceed() {
|
||||
//打印成功
|
||||
Looper.prepare()
|
||||
Toast.makeText(_this, "打印成功", Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
Looper.loop()
|
||||
}
|
||||
|
||||
override fun onFailed(error: String) {
|
||||
//打印失败
|
||||
Looper.prepare()
|
||||
Toast.makeText(_this, error, Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
Looper.loop()
|
||||
}
|
||||
}, object : ProcessData {
|
||||
//组装数据
|
||||
override fun processDataBeforeSend(): MutableList<ByteArray>? {
|
||||
val list = ArrayList<ByteArray>()
|
||||
list.add(strToBytes("SET HEAD ON \r\n")!!)
|
||||
list.add(strToBytes("SET PRINTKEY OFF \r\n")!!)
|
||||
list.add(strToBytes("SET KEY1 ON \r\n")!!)
|
||||
list.add(strToBytes("SHIFT 0 \r\n")!!)
|
||||
list.add(strToBytes("CLS \r\n")!!)
|
||||
list.add(strToBytes("SET TEAR 1 \r\n")!!)
|
||||
list.add(strToBytes("SET CUTTER 0 \r\n")!!)
|
||||
list.add(strToBytes("SIZE 76 mm,48 mm \r\n")!!)
|
||||
list.add(strToBytes("GAP 2 mm,0 mm \r\n")!!)
|
||||
list.add(strToBytes("TEXT 190,20,\"TSS16.BF2\",0,2,2,\"${label?.titleName}\" \r\n")!!)
|
||||
list.add(strToBytes("TEXT 20,100,\"TSS16.BF2\",0,2,2,\"航班: ${label?.fno} \" \r\n")!!)
|
||||
list.add(strToBytes("TEXT 280,100,\"TSS16.BF2\",0,2,2,\"目的地: ${label?.dest}\" \r\n")!!)
|
||||
list.add(strToBytes("TEXT 20,180,\"TSS16.BF2\",0,2,2,\"板车号: ${label?.carId} \" \r\n")!!)
|
||||
list.add(strToBytes("TEXT 280,180,\"TSS16.BF2\",0,2,2,\"重量: ${label?.weight}\" \r\n")!!)
|
||||
list.add(strToBytes("TEXT 20,260,\"TSS16.BF2\",0,2,2,\"体积: ${label?.volume}\" \r\n")!!)
|
||||
list.add(strToBytes("TEXT 280,260,\"TSS16.BF2\",0,2,2,\"舱位: ${label?.location}\" \r\n")!!)
|
||||
list.add(strToBytes("TEXT 20,330,\"TSS16.BF2\",0,2,2,\"件数: ${label?.pc}\" \r\n")!!)
|
||||
list.add(strToBytes("TEXT 250,330,\"TSS24.BF2\",0,2,2,\"${label?.opdate} \" \r\n")!!)
|
||||
list.add(strToBytes("DIRECTION 0,0 \r\n")!!)
|
||||
list.add(strToBytes("DENSITY 1 \r\n")!!)
|
||||
list.add(strToBytes("PRINT 1 \r\n")!!)
|
||||
return list
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun onClickViewListener(view: View, obj: Any) {
|
||||
//获取当前设备的连接状态,如果已连接,则断开,未连接则连接
|
||||
when (mList[obj as Int].isConnected) {
|
||||
true -> {
|
||||
Printer.getInstance().disconnected(object : TaskCallback {
|
||||
override fun onSucceed() {
|
||||
Toast.makeText(
|
||||
this@PrinterActivity,
|
||||
getString(R.string.disconnect_success),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
mList[obj].isConnected = false
|
||||
mAdapter.notifyItemChanged(obj)
|
||||
mIsConnect = false
|
||||
}
|
||||
|
||||
override fun onFailed(error: String) {
|
||||
Toast.makeText(
|
||||
this@PrinterActivity,
|
||||
getString(R.string.disconnect_failure),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
else -> {
|
||||
Printer.getInstance().connectDeviceByMac(mList[obj].name.split("\n").last().trim(),
|
||||
object : TaskCallback {
|
||||
override fun onSucceed() {
|
||||
Toast.makeText(
|
||||
this@PrinterActivity,
|
||||
getString(R.string.connect_success),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
mIsConnect = true
|
||||
mList[obj].isConnected = true
|
||||
mAdapter.notifyItemChanged(obj)
|
||||
}
|
||||
|
||||
override fun onFailed(error: String) {
|
||||
Toast.makeText(
|
||||
this@PrinterActivity,
|
||||
getString(R.string.connect_failure),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.lukouguoji.gnc.bluetooth.printer
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Rect
|
||||
import android.view.View
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
||||
class SpaceItemDecoration//leftRight为横向间的距离 topBottom为纵向间距离
|
||||
(private val leftRight: Int, private val topBottom: Int,private val firstNeedTop:Boolean = true) : RecyclerView.ItemDecoration() {
|
||||
|
||||
override fun onDraw(c: Canvas, parent: RecyclerView, state: RecyclerView.State) {
|
||||
super.onDraw(c, parent, state)
|
||||
}
|
||||
|
||||
@SuppressLint("WrongConstant")
|
||||
override fun getItemOffsets(
|
||||
outRect: Rect,
|
||||
view: View,
|
||||
parent: RecyclerView,
|
||||
state: RecyclerView.State
|
||||
) {
|
||||
val layoutManager = parent.layoutManager as LinearLayoutManager?
|
||||
//竖直方向的
|
||||
if (layoutManager!!.orientation == LinearLayoutManager.VERTICAL) {
|
||||
//最后一项需要 bottom
|
||||
if (parent.getChildAdapterPosition(view) == layoutManager.itemCount - 1) {
|
||||
outRect.bottom = topBottom
|
||||
}
|
||||
if(!firstNeedTop&&parent.getChildAdapterPosition(view)==0){
|
||||
outRect.top = 0
|
||||
}else{
|
||||
outRect.top = topBottom
|
||||
}
|
||||
outRect.left = leftRight
|
||||
outRect.right = leftRight
|
||||
} else {
|
||||
//最后一项需要right
|
||||
if (parent.getChildAdapterPosition(view) != layoutManager.itemCount - 1) {
|
||||
outRect.right = leftRight
|
||||
}
|
||||
outRect.top = topBottom
|
||||
outRect.left = 0
|
||||
outRect.bottom = topBottom
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.lukouguoji.gnc.bluetooth.printerface
|
||||
|
||||
import android.view.View
|
||||
|
||||
/**
|
||||
*author : huitao
|
||||
*e-mail : pig.huitao@gmail.com
|
||||
*date : 2021/5/17 20:39
|
||||
*desc :
|
||||
*version :
|
||||
*/
|
||||
interface AdapterClickListener {
|
||||
fun onClickViewListener(view: View, obj: Any)
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.lukouguoji.gnc.bluetooth.service
|
||||
|
||||
import android.app.*
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.IBinder
|
||||
import androidx.core.app.NotificationCompat
|
||||
import com.lukouguoji.module_base.R
|
||||
|
||||
/**
|
||||
*author : huitao
|
||||
*e-mail : pig.huitao@gmail.com
|
||||
*date : 2021/5/17 18:39
|
||||
*desc :
|
||||
*version :
|
||||
*/
|
||||
class AncillaryService:Service() {
|
||||
override fun onBind(intent: Intent?): IBinder? {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun onCreate() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
startForeground(this)
|
||||
}
|
||||
stopSelf()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
stopForeground(true)
|
||||
}
|
||||
|
||||
companion object{
|
||||
fun startForeground(ctx: Service) {
|
||||
try {
|
||||
val CHANNEL_ONE_ID = "CHANNEL_ONE_ID"
|
||||
val CHANNEL_ONE_NAME = "CHANNEL_ONE_ID"
|
||||
val SERVICE_ID = 802
|
||||
val notificationChannel: NotificationChannel
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
notificationChannel = NotificationChannel(
|
||||
CHANNEL_ONE_ID, CHANNEL_ONE_NAME, NotificationManager.IMPORTANCE_HIGH
|
||||
)
|
||||
notificationChannel.enableLights(true)
|
||||
notificationChannel.lightColor = R.color.app_them
|
||||
notificationChannel.setShowBadge(true)
|
||||
notificationChannel.lockscreenVisibility = Notification.VISIBILITY_PUBLIC
|
||||
val nm = ctx.getSystemService(NOTIFICATION_SERVICE) as NotificationManager
|
||||
nm.createNotificationChannel(notificationChannel)
|
||||
}
|
||||
val intent = Intent()
|
||||
val className = Class.forName("com.huitao.printerdemo.printer.PrinterActivity")
|
||||
intent.setClassName(ctx, className.name)
|
||||
val pendingIntent = PendingIntent.getActivity(ctx, 0, intent, 0)
|
||||
val builder = NotificationCompat.Builder(ctx, CHANNEL_ONE_ID)
|
||||
builder.setContentTitle(ctx.getString(R.string.pending_title))
|
||||
.setContentText(ctx.getString(R.string.pending_content))
|
||||
.setWhen(System.currentTimeMillis())
|
||||
.setPriority(Notification.PRIORITY_MIN)
|
||||
.setSmallIcon(R.mipmap.ic_launcher)
|
||||
.setContentIntent(pendingIntent)
|
||||
.setAutoCancel(true)
|
||||
val notification = builder.build()
|
||||
ctx.startForeground(SERVICE_ID, notification)
|
||||
} catch (e: ClassNotFoundException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.lukouguoji.gnc.bluetooth.service
|
||||
|
||||
import android.app.Service
|
||||
import android.content.*
|
||||
import android.os.Binder
|
||||
import android.os.Build
|
||||
import android.os.IBinder
|
||||
import com.huitao.printer.printerface.DeviceFoundCallback
|
||||
import com.huitao.printer.printerface.IMyBinder
|
||||
import com.huitao.printer.printerface.TaskCallback
|
||||
import com.huitao.printer.service.PrinterService
|
||||
import com.huitao.printer.utils.PrinterDev
|
||||
import com.lukouguoji.gnc.bluetooth.bean.LabelBean
|
||||
|
||||
/**
|
||||
*author : huitao
|
||||
*e-mail : pig.huitao@gmail.com
|
||||
*date : 2021/5/17 18:07
|
||||
*desc :
|
||||
*version :
|
||||
*/
|
||||
class MyService : Service() {
|
||||
private var mIMyBinder: IMyBinder? = null
|
||||
private val mServiceConnect = object : ServiceConnection {
|
||||
override fun onServiceConnected(name: ComponentName?, service: IBinder?) {
|
||||
mIMyBinder = service as IMyBinder
|
||||
val mac = ""
|
||||
connectByMac(mac, object : TaskCallback {
|
||||
override fun onSucceed() {
|
||||
|
||||
}
|
||||
|
||||
override fun onFailed(error: String) {
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun onServiceDisconnected(name: ComponentName?) {
|
||||
}
|
||||
}
|
||||
|
||||
fun getBondDeviceList(): MutableList<String>? {
|
||||
return mIMyBinder?.onDiscovery(
|
||||
this,
|
||||
PrinterDev.PortType.Bluetooth,
|
||||
object : DeviceFoundCallback {
|
||||
override fun deviceFoundCallback(device: String) {
|
||||
//这里接收扫描的周围蓝牙设备
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
fun writeData(bean: LabelBean, task: TaskCallback) {
|
||||
// printOrderDetail(mMyBinder = mIMyBinder!!, order = bean, taskCallback = task)
|
||||
}
|
||||
|
||||
fun connectByMac(mac: String, task: TaskCallback) {
|
||||
if (mac.isNotEmpty()) {
|
||||
mIMyBinder?.connectBtPort(mac, task)
|
||||
}
|
||||
}
|
||||
|
||||
fun disconnect(task: TaskCallback) {
|
||||
mIMyBinder?.disconnectCurrentPort(task)
|
||||
}
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
val intent = Intent(this, AncillaryService::class.java)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
AncillaryService.startForeground(this)
|
||||
startForegroundService(intent)
|
||||
} else {
|
||||
startService(intent)
|
||||
}
|
||||
|
||||
val service = Intent(this, PrinterService::class.java)
|
||||
bindService(service, mServiceConnect, BIND_AUTO_CREATE)
|
||||
}
|
||||
|
||||
override fun onBind(p0: Intent?): IBinder {
|
||||
return MyBinder()
|
||||
}
|
||||
|
||||
|
||||
inner class MyBinder : Binder() {
|
||||
fun getService(): MyService {
|
||||
return this@MyService
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.lukouguoji.gnc.model
|
||||
|
||||
class GncFuBang {
|
||||
var userId: Int = 0
|
||||
var carId: String = ""
|
||||
var maxWeight: Double? = 0.0 //最大载重
|
||||
var netWeight: Double? = 0.0 //净重(装机重量)
|
||||
var carWeight: Double? = 0.0 //平板车自重量
|
||||
var volume: Double = 0.0 //体积
|
||||
var pc: Int = 0 //件数
|
||||
var flight: String = "" //航班
|
||||
var priority: Int = -9999 //装载优先级
|
||||
var fdest: String = "" //航班目的港
|
||||
var location: String = "" //舱位
|
||||
var cargoType: String = "" //货物类型
|
||||
var mailWeight: Double? = 0.0 //其中邮件
|
||||
var uld: String? = "" //uld
|
||||
var uldWeight: Double? = 0.0 //uldWeight
|
||||
var boardType: String = "" //板型
|
||||
var fdate:String?=""
|
||||
var remark: String? = "" //备注
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.lukouguoji.gnc.model
|
||||
|
||||
class GncFuBangList(val useId: Int, val carId: String, val fno: String,val fdest: String,val weight: Double, val volume: Double, val pc: Int, val date: String, val reviewer: String, val outer: String, val loader: String)
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.lukouguoji.gnc.model
|
||||
|
||||
class GncQueryInfo(
|
||||
val id: Int,
|
||||
val title: String,
|
||||
val content: String
|
||||
)
|
||||
|
||||
/**
|
||||
* 关联运单
|
||||
*/
|
||||
class GncQueryInfoWh(
|
||||
val id: Int,
|
||||
val wbNo: String,
|
||||
val location: String,//库位
|
||||
val pc: Int,//件数
|
||||
val weight: Double,//重量
|
||||
val flight: String,//航班
|
||||
val opDate: String,//入库时间
|
||||
val fclose: String,//出库时间
|
||||
val opId: String //收运人
|
||||
)
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.lukouguoji.gnc.model
|
||||
|
||||
class GncQueryList(
|
||||
val mawbId: Int,
|
||||
val wbNo: String,
|
||||
val agentCode: String,
|
||||
val spCode: String,
|
||||
val goods: String,
|
||||
val flight: String,
|
||||
val dest: String,
|
||||
val opDate: String,
|
||||
val fclose: String,
|
||||
val pc: String,
|
||||
val weight: String,
|
||||
)
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.lukouguoji.gnc.model
|
||||
|
||||
class GncTransferList(
|
||||
val mawbId: Int,
|
||||
val carId: String,
|
||||
val transId: String,// 确认人(如果此值不空,只能查看,也就是转运确定按钮隐藏)
|
||||
val transDate: String//确认时间
|
||||
)
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.lukouguoji.gnc.model
|
||||
|
||||
class GncTransferRef(
|
||||
val mawbId: Int,
|
||||
val wbNo: String,
|
||||
val agentCode: String,
|
||||
val spCode: String,
|
||||
val goods: String,
|
||||
val flight: String,
|
||||
val range: String
|
||||
)
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.lukouguoji.gnc.model
|
||||
|
||||
class GncWareHouseInfo(
|
||||
val id: Int,
|
||||
val title: String,
|
||||
val content: String
|
||||
)
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.lukouguoji.gnc.model
|
||||
|
||||
class GncWareHouseList(
|
||||
val id: Int,
|
||||
val waybillNo: String,
|
||||
val location: String,
|
||||
val pc: Int,
|
||||
val weight: Double,
|
||||
val fno: String,
|
||||
val date: String,
|
||||
val isCangDan: String,
|
||||
val groupTitle: String,
|
||||
val groupName: String,
|
||||
val days: String?,
|
||||
)
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.lukouguoji.gnc.model
|
||||
|
||||
class GuoNeiOutCollect(val mawbId: Int, val wbNo: String,val dest:String, val agentCode: String, val spCode: String, val goods: String
|
||||
, val planDate: String,val range:String,val flight:String )
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.lukouguoji.gnc.model
|
||||
|
||||
class GuoneiOutWaybill {
|
||||
var mawbId: Int = 0
|
||||
var wbNo: String = ""
|
||||
var uld: String? = ""//板车号
|
||||
var carrier: String = ""//承运人
|
||||
var fno: String = ""//计划航班
|
||||
var fdate: String = ""//航班日期
|
||||
var range: String = ""//航程
|
||||
var dgrDetail: String? = ""//危险品库描述
|
||||
var dgr: String? = ""//危险品库
|
||||
var agentCode: String = ""//代理
|
||||
var spCode: String? = "" //特码
|
||||
var goods: String = "" //品名
|
||||
var businessType: String = "" //业务类型
|
||||
var pc: Int = 0 //件数
|
||||
var weight: Double = 0.0 //重量
|
||||
var volume: Double = 0.0 //体积
|
||||
var remark: String? = "" //备注
|
||||
|
||||
var activeId: Int = -9999 //运单活跃状态(0:当前有效运单;>0:运单复用次数;)
|
||||
var awbType: String? = "" //运单类型
|
||||
var volDetail: String? = "" //体积描述
|
||||
|
||||
//todo 增加uld自重、uld
|
||||
var uldStr: String = ""
|
||||
var uldSelfWeight: String = ""
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.lukouguoji.gnc.page.assemble.add
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.databinding.ActivityGncAssembleAddBinding
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.base.CommonAdapter
|
||||
import com.lukouguoji.module_base.bean.GncAssembleListBean
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.ktx.addOnItemClickListener
|
||||
import com.lukouguoji.module_base.ktx.getLifecycleOwner
|
||||
import com.lukouguoji.module_base.ktx.toJson
|
||||
|
||||
class GncAssembleAddActivity :
|
||||
BaseBindingActivity<ActivityGncAssembleAddBinding, GncAssembleAddViewModel>() {
|
||||
|
||||
override fun layoutId() = R.layout.activity_gnc_assemble_add
|
||||
|
||||
override fun viewModelClass(): Class<GncAssembleAddViewModel> {
|
||||
return GncAssembleAddViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国内出港开始组装")
|
||||
binding.viewModel = viewModel
|
||||
viewModel.pageModel.bindSmartRefreshLayout(
|
||||
binding.srl,
|
||||
binding.rv,
|
||||
viewModel,
|
||||
getLifecycleOwner()
|
||||
)
|
||||
viewModel.initOnCreated(intent)
|
||||
|
||||
binding.rv.adapter = CommonAdapter(
|
||||
requireContext(),
|
||||
R.layout.item_gnc_assemble_add,
|
||||
GncAssembleAddViewHolder::class.java
|
||||
)
|
||||
|
||||
binding.rv.addOnItemClickListener(viewModel)
|
||||
|
||||
viewModel.waybill.observe(this){
|
||||
if (it.length == 11) {
|
||||
viewModel.onWaybillChange(true)
|
||||
}
|
||||
if (it.length >= 4 && it.length < 9) {
|
||||
viewModel.getWaybillList(it)
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.refresh()
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context, bean: GncAssembleListBean? = null) {
|
||||
val starter = Intent(context, GncAssembleAddActivity::class.java)
|
||||
if (bean != null) {
|
||||
starter.putExtra(Constant.Key.DATA, bean.toJson(false))
|
||||
}
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.lukouguoji.gnc.page.assemble.add
|
||||
|
||||
import android.util.AndroidException
|
||||
import android.view.View
|
||||
import com.lukouguoji.gnc.databinding.ItemGncAssembleAddBinding
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.GjcWaybillBean
|
||||
import com.lukouguoji.module_base.bean.WaybillBean
|
||||
|
||||
class GncAssembleAddViewHolder(view: View) :
|
||||
BaseViewHolder<WaybillBean, ItemGncAssembleAddBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
val bean = getItemBean(item)!!
|
||||
binding.bean = bean
|
||||
|
||||
binding.ivIcon.setOnClickListener {
|
||||
bean.checked.set(!bean.checked.get())
|
||||
}
|
||||
|
||||
notifyItemClick(position, binding.tvBatch)
|
||||
notifyItemClick(position, binding.tvDelete)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,440 @@
|
||||
package com.lukouguoji.gnc.page.assemble.add
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.alibaba.fastjson.JSONArray
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.page.assemble.unload.GncAssembleUnloadListActivity
|
||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
||||
import com.lukouguoji.module_base.bean.FlatcarBean
|
||||
import com.lukouguoji.module_base.bean.GncAssembleListBean
|
||||
import com.lukouguoji.module_base.bean.WaybillBean
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.common.ConstantEvent
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.impl.FlowBus
|
||||
import com.lukouguoji.module_base.ktx.commonAdapter
|
||||
import com.lukouguoji.module_base.ktx.launchCollect
|
||||
import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
||||
import com.lukouguoji.module_base.ktx.loge
|
||||
import com.lukouguoji.module_base.ktx.noNull
|
||||
import com.lukouguoji.module_base.ktx.showConfirmDialog
|
||||
import com.lukouguoji.module_base.ktx.showToast
|
||||
import com.lukouguoji.module_base.ktx.toJson
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.lukouguoji.module_base.model.ScanModel
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import dev.DevUtils
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
|
||||
class GncAssembleAddViewModel : BasePageViewModel() {
|
||||
|
||||
private var id = ""
|
||||
|
||||
// 平板车
|
||||
val car = MutableLiveData<String>()
|
||||
|
||||
// 运单号
|
||||
val waybill = MutableLiveData<String>()
|
||||
|
||||
// 运单号列表
|
||||
val wbNoList = MutableLiveData<List<String>>()
|
||||
|
||||
// 平板车信息
|
||||
val flatcarBean = MutableLiveData(FlatcarBean())
|
||||
|
||||
// 数量
|
||||
val count = MutableLiveData(0)
|
||||
|
||||
// 总件数
|
||||
val totalCount = MutableLiveData(0)
|
||||
|
||||
// 总重量
|
||||
val totalWeight = MutableLiveData(0.0)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
fun initOnCreated(intent: Intent) {
|
||||
intent.getStringExtra(Constant.Key.DATA)?.let {
|
||||
val bean = NetApply.gson.fromJson(it, GncAssembleListBean::class.java)
|
||||
id = bean.useId
|
||||
bean.warehouseList?.forEach { b ->
|
||||
insertWaybill(b)
|
||||
}
|
||||
car.value = bean.carId
|
||||
onCarChange()
|
||||
}
|
||||
|
||||
FlowBus.with<List<WaybillBean>>(ConstantEvent.WAYBILL_CHECKED)
|
||||
.onEach {
|
||||
it.forEach { bean ->
|
||||
insertWaybill(bean)
|
||||
}
|
||||
}
|
||||
.launchIn(viewModelScope)
|
||||
}
|
||||
|
||||
override fun getData() {}
|
||||
|
||||
fun onFilterClick() {
|
||||
GncAssembleUnloadListActivity.start(getTopActivity())
|
||||
}
|
||||
|
||||
/**
|
||||
* 平板车 改变
|
||||
*/
|
||||
fun onCarChange(focused: Boolean = false) {
|
||||
if (focused) {
|
||||
return
|
||||
}
|
||||
val carid = car.value ?: return
|
||||
if (carid.isEmpty()) return
|
||||
|
||||
if (carid.startsWith("x") || carid.startsWith("X")) {
|
||||
flatcarBean.value = FlatcarBean().apply {
|
||||
carId = carid
|
||||
carWeight = "0"
|
||||
signWeight = "0"
|
||||
maxWeight = "0"
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getFlatcarInfo(carid)
|
||||
}) {
|
||||
onSuccess = {
|
||||
flatcarBean.value = it.data ?: FlatcarBean()
|
||||
if (id.isEmpty()) {
|
||||
// 根据carId查询flatcaruse表中数据
|
||||
launchCollect({
|
||||
NetApply.api.getGncAssembleList(
|
||||
mapOf(
|
||||
"pageNum" to 1,
|
||||
"pageSize" to 1,
|
||||
"carId" to car.value,
|
||||
"activited" to 0
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = { iit ->
|
||||
val bean = iit.list?.get(0)
|
||||
if (bean != null) {
|
||||
id = bean.useId
|
||||
bean.warehouseList?.forEach { b ->
|
||||
insertWaybill(b)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onCarScanClick() {
|
||||
ScanModel.startScan(
|
||||
getTopActivity(),
|
||||
Constant.RequestCode.CAR
|
||||
)
|
||||
}
|
||||
|
||||
fun onWaybillScanClick() {
|
||||
ScanModel.startScan(
|
||||
getTopActivity(),
|
||||
Constant.RequestCode.WAYBILL
|
||||
)
|
||||
}
|
||||
|
||||
override fun onItemClick(position: Int, type: Int) {
|
||||
val adapter = pageModel.rv!!.commonAdapter()!!
|
||||
val bean = adapter.getItem(position) as WaybillBean
|
||||
when (type) {
|
||||
R.id.tv_batch -> {
|
||||
if (car.value.isNullOrEmpty()){
|
||||
showToast("请先选择平板车!")
|
||||
return
|
||||
}
|
||||
GncAssembleBatchDialogModel(bean) {
|
||||
adapter.removeItem(adapter.items.indexOf(bean))
|
||||
getListForWaybillAndInsertForBatch(bean.whId)
|
||||
}.show()
|
||||
}
|
||||
|
||||
R.id.tv_delete -> {
|
||||
getTopActivity().showConfirmDialog("是否删除该条数据?") {
|
||||
adapter.removeItem(position)
|
||||
}
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 运单号 改变
|
||||
*/
|
||||
fun onWaybillChange(focused: Boolean = false) {
|
||||
if (focused) {
|
||||
return
|
||||
}
|
||||
val code = waybill.value.noNull()
|
||||
if(code.isNullOrEmpty()){
|
||||
return
|
||||
}
|
||||
getListForWaybillByCode(code)
|
||||
}
|
||||
|
||||
/**
|
||||
* 分批后将修改后的仓库记录加入到列表中
|
||||
*/
|
||||
private fun getListForWaybillAndInsertForBatch(code: String) {
|
||||
// if (code.length != 11) return
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getWaybillList(
|
||||
"/DomExpLoading/queryWarehouseList",
|
||||
mapOf("whId" to code).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
it.list?.forEach { bean ->
|
||||
loge("bean:{}")
|
||||
insertWaybill(bean)
|
||||
// if (bean.location.isNotBlank() && bean.location == flatcarBean.value?.carId){
|
||||
// insertWaybill(bean)
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun getListForWaybillAndInsert(code: String) {
|
||||
// if (code.length != 11) return
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getWaybillList(
|
||||
"/DomExpLoading/queryWarehouse",
|
||||
mapOf("whId" to code).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
it.list?.forEach { bean ->
|
||||
insertWaybill(bean)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getListForWaybillByCode(code: String) {
|
||||
// if (code.length != 11) return
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getWaybillList(
|
||||
"/DomExpLoading/queryWarehouse",
|
||||
mapOf("wbNo" to code).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
it.list?.forEach { bean ->
|
||||
insertWaybill(bean)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
fun getWaybillList(code: String) {
|
||||
if (code.length < 4 || code.length > 8) return
|
||||
launchCollect({
|
||||
NetApply.api.getWbNoList(
|
||||
"/DomExpLoading/queryWarehouseWbList",
|
||||
mapOf("wbNo" to code).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
val results = it.data!!
|
||||
when {
|
||||
results.size == 1 -> {
|
||||
waybill.value = results[0]
|
||||
wbNoList.value = emptyList()
|
||||
}
|
||||
results.size > 1 -> {
|
||||
wbNoList.value = results
|
||||
showWbNoListSelect()
|
||||
}
|
||||
else -> {
|
||||
wbNoList.value = emptyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
onFailed = { i: Int, s: String ->
|
||||
wbNoList.value = emptyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun insertWaybill(bean: WaybillBean) {
|
||||
loge("插入数据 ${bean.whId}")
|
||||
pageModel.rv?.post {
|
||||
pageModel.rv?.commonAdapter()?.let {
|
||||
loge("")
|
||||
val list = it.items as List<WaybillBean>
|
||||
if (list.find { b -> b.whId == bean.whId } == null) {
|
||||
bean.checked.set(false)
|
||||
it.addItem(bean)
|
||||
}
|
||||
}
|
||||
|
||||
computeCountData()
|
||||
}
|
||||
}
|
||||
|
||||
private fun computeCountData() {
|
||||
var c = 0
|
||||
var num = 0
|
||||
var w = 0.0
|
||||
pageModel.rv?.commonAdapter()?.items?.forEach {
|
||||
val bean = it as WaybillBean
|
||||
c += 1
|
||||
num += (bean.pc.toIntOrNull() ?: 0)
|
||||
w += (bean.weight.toDoubleOrNull() ?: 0.0)
|
||||
}
|
||||
count.value = c
|
||||
totalCount.value = num
|
||||
totalWeight.value = w
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并点击
|
||||
*/
|
||||
fun onMergeClick() {
|
||||
val list = getCheckedList()
|
||||
|
||||
if (list.size < 2) {
|
||||
showToast("请选择两个以上数据")
|
||||
return
|
||||
}
|
||||
if (list.groupBy { it.wbNo }.size > 1) {
|
||||
showToast("合并数据运单号必须一致")
|
||||
return
|
||||
}
|
||||
if (list.groupBy { it.dest }.size > 1) {
|
||||
showToast("合并数据目的港必须一致")
|
||||
return
|
||||
}
|
||||
|
||||
launchLoadingCollect({
|
||||
NetApply.api.anyPost(
|
||||
"DomExpLoading/mergeWarehouseList",
|
||||
list.map { it.whId }.toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
showToast(it.msg.noNull("合并成功"))
|
||||
val code = list.first().whId
|
||||
// 删除合并的数据
|
||||
list.forEach { bean ->
|
||||
val adapter = pageModel.rv!!.commonAdapter()!!
|
||||
adapter.removeItem(adapter.items.indexOf(bean))
|
||||
}
|
||||
// 查询运单下所有数据并插入
|
||||
getListForWaybillAndInsert(code)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 装货 点击
|
||||
*/
|
||||
fun onLoadingClick() {
|
||||
val adapter = pageModel.rv!!.commonAdapter()!!
|
||||
val list = adapter.items as List<WaybillBean>
|
||||
val distinctByWbNo = list.distinctBy { it.wbNo }
|
||||
if (list.size != distinctByWbNo.size) {
|
||||
showToast("请将相同运单号的货物合并后再进行装货!")
|
||||
return
|
||||
}
|
||||
if (list.isEmpty()) {
|
||||
showToast("请添加需要装货的数据!")
|
||||
return
|
||||
}
|
||||
launchLoadingCollect({
|
||||
if (id.isEmpty()) {
|
||||
NetApply.api.anyPost(
|
||||
"DomExpLoading/insertLoading", mapOf(
|
||||
"carId" to flatcarBean.value?.carId,
|
||||
"warehouseList" to list.map { b ->
|
||||
mapOf("whId" to b.whId)
|
||||
}
|
||||
).toRequestBody()
|
||||
)
|
||||
} else {
|
||||
NetApply.api.anyPost(
|
||||
"DomExpLoading/updateLoading", mapOf(
|
||||
"useId" to id,
|
||||
"carId" to flatcarBean.value?.carId,
|
||||
"warehouseList" to list.map { b ->
|
||||
mapOf("whId" to b.whId)
|
||||
}
|
||||
).toRequestBody()
|
||||
)
|
||||
}
|
||||
}) {
|
||||
onSuccess = {
|
||||
showToast(it.msg.noNull("装货成功"))
|
||||
adapter.refresh(emptyList())
|
||||
flatcarBean.value = FlatcarBean()
|
||||
car.value = ""
|
||||
computeCountData()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getCheckedList(): List<WaybillBean> {
|
||||
return (pageModel.rv?.commonAdapter()?.items?.filter { (it as WaybillBean).checked.get() }
|
||||
?: emptyList()) as List<WaybillBean>
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
when (requestCode) {
|
||||
Constant.RequestCode.CAR -> {
|
||||
val id = data.getStringExtra(Constant.Result.CODED_CONTENT).noNull()
|
||||
car.value = id
|
||||
onCarChange()
|
||||
}
|
||||
|
||||
Constant.RequestCode.WAYBILL -> {
|
||||
val id = data.getStringExtra(Constant.Result.CODED_CONTENT).noNull()
|
||||
waybill.value = id
|
||||
onWaybillChange()
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showWbNoListSelect() {
|
||||
Common.singleSelect(
|
||||
DevUtils.getTopActivity(),
|
||||
"选择运单号",
|
||||
JSONArray.parseArray(wbNoList.value!!.map {
|
||||
mapOf(
|
||||
"name" to it,
|
||||
"code" to it,
|
||||
)
|
||||
}.toList().toJson(false)),
|
||||
null
|
||||
) { position, _ ->
|
||||
waybill.value = wbNoList.value!![position]
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package com.lukouguoji.gnc.page.assemble.add
|
||||
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.databinding.DialogGncAssembleBatchBinding
|
||||
import com.lukouguoji.module_base.base.BaseDialogModel
|
||||
import com.lukouguoji.module_base.bean.GjjHandoverRecordBean
|
||||
import com.lukouguoji.module_base.bean.WaybillBean
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.interfaces.ILoading
|
||||
import com.lukouguoji.module_base.ktx.getLifecycleOwner
|
||||
import com.lukouguoji.module_base.ktx.launchCollect
|
||||
import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
||||
import com.lukouguoji.module_base.ktx.noNull
|
||||
import com.lukouguoji.module_base.ktx.showToast
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.lukouguoji.module_base.ktx.tryCatch
|
||||
import com.lukouguoji.module_base.util.Arith
|
||||
import com.lxj.xpopup.XPopup
|
||||
import dev.DevUtils
|
||||
import dev.utils.app.ScreenUtils
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
class GncAssembleBatchDialogModel(
|
||||
val bean: WaybillBean,
|
||||
val callBack: () -> Unit
|
||||
) : BaseDialogModel<DialogGncAssembleBatchBinding>(DIALOG_TYPE_CENTER) {
|
||||
|
||||
// 剩余件数
|
||||
val remainingCount = MutableLiveData(bean.pc.noNull())
|
||||
|
||||
// 剩余重量
|
||||
val remainingWeight = MutableLiveData(bean.weight.noNull())
|
||||
|
||||
// 件数
|
||||
val count = MutableLiveData("")
|
||||
|
||||
// 重量
|
||||
val weight = MutableLiveData("")
|
||||
|
||||
override fun onBuild(builder: XPopup.Builder) {
|
||||
builder.maxWidth((ScreenUtils.getScreenWidth() * 0.5).roundToInt())
|
||||
}
|
||||
|
||||
override fun layoutId() = R.layout.dialog_gnc_assemble_batch
|
||||
|
||||
override fun onDialogCreated(context: Context) {
|
||||
binding.model = this
|
||||
|
||||
// 件数改变监听
|
||||
count.observe(context.getLifecycleOwner()) {
|
||||
tryCatch({ _ ->
|
||||
val old = bean.pc.noNull().toInt()
|
||||
val new = it.toInt()
|
||||
if (old < new) {
|
||||
count.value = bean.pc.noNull()
|
||||
remainingCount.postValue("0")
|
||||
} else {
|
||||
val c = (old - new).toString()
|
||||
remainingCount.postValue(c)
|
||||
}
|
||||
}) {
|
||||
remainingCount.postValue(bean.pc.noNull())
|
||||
}
|
||||
}
|
||||
|
||||
// 重量改变监听
|
||||
weight.observe(context.getLifecycleOwner()) {
|
||||
tryCatch({ _ ->
|
||||
val old = bean.weight.noNull().toDouble()
|
||||
val new = it.toDouble()
|
||||
if (old < new) {
|
||||
weight.value = bean.weight.noNull()
|
||||
remainingWeight.postValue("0")
|
||||
} else {
|
||||
val w =
|
||||
Arith.round((old - new), 2).toString()
|
||||
remainingWeight.postValue(w)
|
||||
}
|
||||
}) {
|
||||
remainingWeight.postValue(bean.weight.noNull())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
fun save(view: View) {
|
||||
launchCollect({
|
||||
NetApply.api.anyPost(
|
||||
"DomExpLoading/gncWarehouseBatch", mapOf(
|
||||
"pc" to count.value,
|
||||
"weight" to weight.value,
|
||||
"whid" to bean.whId,
|
||||
"location" to bean.location,
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
showToast(it.msg.noNull("分批成功"))
|
||||
dismiss()
|
||||
callBack()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.lukouguoji.gnc.page.assemble.list
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.databinding.ActivityGncAssembleListBinding
|
||||
import com.lukouguoji.module_base.adapter.setCommonAdapter
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.base.CommonAdapter
|
||||
import com.lukouguoji.module_base.ktx.addOnItemClickListener
|
||||
import com.lukouguoji.module_base.ktx.getLifecycleOwner
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_GNC_ASSEMBLE_LIST)
|
||||
class GncAssembleListActivity :
|
||||
BaseBindingActivity<ActivityGncAssembleListBinding, GncAssembleListViewModel>() {
|
||||
|
||||
override fun layoutId() = R.layout.activity_gnc_assemble_list
|
||||
|
||||
override fun viewModelClass(): Class<GncAssembleListViewModel> {
|
||||
return GncAssembleListViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国内出港组装")
|
||||
binding.viewModel = viewModel
|
||||
viewModel.pageModel.bindSmartRefreshLayout(
|
||||
binding.srl,
|
||||
binding.rv,
|
||||
viewModel,
|
||||
getLifecycleOwner()
|
||||
)
|
||||
|
||||
binding.rv.addOnItemClickListener(viewModel)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
viewModel.refresh()
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
val starter = Intent(context, GncAssembleListActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.lukouguoji.gnc.page.assemble.list
|
||||
|
||||
import android.view.View
|
||||
import com.lukouguoji.gnc.databinding.ItemGncAssembleItemMoreBinding
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.GncWarehouse
|
||||
import com.lukouguoji.module_base.bean.WaybillBean
|
||||
|
||||
class GncAssembleListMoreViewHolder(view: View) :
|
||||
BaseViewHolder<WaybillBean, ItemGncAssembleItemMoreBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
binding.bean = getItemBean(item)
|
||||
|
||||
binding.tvIndex.text = (position + 1).toString()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.lukouguoji.gnc.page.assemble.list
|
||||
|
||||
import android.view.View
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.databinding.ItemGncAssembleListBinding
|
||||
import com.lukouguoji.module_base.adapter.setCommonAdapter
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.GncAssembleListBean
|
||||
import com.lukouguoji.module_base.ktx.refresh
|
||||
|
||||
class GncAssembleListViewHolder(view: View) :
|
||||
BaseViewHolder<GncAssembleListBean, ItemGncAssembleListBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
val bean = getItemBean(item)!!
|
||||
binding.bean = bean
|
||||
|
||||
notifyItemClick(position, binding.tvDelete)
|
||||
notifyItemClick(position, binding.tvModify)
|
||||
|
||||
binding.ivIcon.setOnClickListener {
|
||||
bean.checked.set(!bean.checked.get())
|
||||
}
|
||||
binding.ivShow.setOnClickListener {
|
||||
bean.showMore.set(!bean.showMore.get())
|
||||
}
|
||||
|
||||
setCommonAdapter(
|
||||
binding.rv,
|
||||
GncAssembleListMoreViewHolder::class.java,
|
||||
R.layout.item_gnc_assemble_item_more
|
||||
)
|
||||
binding.rv.refresh(bean.warehouseList)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
package com.lukouguoji.gnc.page.assemble.list
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.view.View
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.page.assemble.add.GncAssembleAddActivity
|
||||
import com.lukouguoji.gnc.page.assemble.unload.GncAssembleUnloadListActivity
|
||||
import com.lukouguoji.gnc.page.fubang.list.GncFuBangListViewHolder
|
||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
||||
import com.lukouguoji.module_base.base.BaseViewModel
|
||||
import com.lukouguoji.module_base.bean.GjcBoxAssembleBean
|
||||
import com.lukouguoji.module_base.bean.GncAssembleListBean
|
||||
import com.lukouguoji.module_base.bean.GoodsTransportBean
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.ktx.commonAdapter
|
||||
import com.lukouguoji.module_base.ktx.formatDate
|
||||
import com.lukouguoji.module_base.ktx.getActivity
|
||||
import com.lukouguoji.module_base.ktx.launchCollect
|
||||
import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
||||
import com.lukouguoji.module_base.ktx.loge
|
||||
import com.lukouguoji.module_base.ktx.noNull
|
||||
import com.lukouguoji.module_base.ktx.showConfirmDialog
|
||||
import com.lukouguoji.module_base.ktx.showToast
|
||||
import com.lukouguoji.module_base.ktx.toJson
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.lukouguoji.module_base.model.ConfirmDialogModel
|
||||
import com.lukouguoji.module_base.model.ScanModel
|
||||
import com.lukouguoji.module_base.request.GncAssembleListRequest
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.lukouguoji.module_base.util.DictUtils
|
||||
import dev.DevUtils
|
||||
import dev.utils.app.info.KeyValue
|
||||
import dev.utils.common.DateUtils
|
||||
import java.util.Calendar
|
||||
|
||||
class GncAssembleListViewModel : BasePageViewModel() {
|
||||
|
||||
// 航班日期
|
||||
val date = MutableLiveData(DateUtils.getCurrentTime().formatDate())
|
||||
|
||||
// 航班号
|
||||
val flightNo = MutableLiveData("")
|
||||
|
||||
// 平板车
|
||||
val car = MutableLiveData("")
|
||||
|
||||
// 复磅状态
|
||||
val status = MutableLiveData("")
|
||||
|
||||
// 截载状态
|
||||
val cutStatus = MutableLiveData("")
|
||||
|
||||
// 复磅状态列表
|
||||
val statusList = DictUtils.reWeightStatusList
|
||||
|
||||
// 截载状态列表
|
||||
val cutStatusList = listOf(
|
||||
KeyValue("全部", ""),
|
||||
KeyValue("未截载", "0"),
|
||||
KeyValue("已截载", "1"),
|
||||
)
|
||||
|
||||
val count = MutableLiveData(0)
|
||||
|
||||
val itemLayoutId = R.layout.item_gnc_assemble_list
|
||||
val itemViewHolder = GncAssembleListViewHolder::class.java
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
override fun getData() {
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getGncAssembleList(
|
||||
mapOf(
|
||||
"pageNum" to pageModel.page,
|
||||
"pageSize" to pageModel.limit,
|
||||
"fdate" to date.value,
|
||||
"fno" to flightNo.value,
|
||||
"carId" to car.value,
|
||||
"copStatus" to status.value,
|
||||
"activited" to cutStatus.value,
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
pageModel.handleListBean(it)
|
||||
count.value = it.total
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 平板车 扫描
|
||||
*/
|
||||
fun carScan(view: View) {
|
||||
ScanModel.startScan(view.context.getActivity(), Constant.RequestCode.CAR)
|
||||
}
|
||||
|
||||
fun onAddClick() {
|
||||
GncAssembleAddActivity.start(getTopActivity())
|
||||
}
|
||||
|
||||
fun onDeleteClick() {
|
||||
val list =
|
||||
(pageModel.rv?.commonAdapter()?.items?.filter { (it as GncAssembleListBean).checked.get() }
|
||||
?: emptyList()) as List<GncAssembleListBean>
|
||||
if (list.isEmpty()) {
|
||||
showToast("请选择需要删除的数据")
|
||||
return
|
||||
}
|
||||
getTopActivity().showConfirmDialog("是否确认删除选中数据?") {
|
||||
delete(list.map { it.useId })
|
||||
}
|
||||
}
|
||||
|
||||
private fun delete(list: List<String>) {
|
||||
launchLoadingCollect({
|
||||
NetApply.api.anyPost("DomExpLoading/delete", list.toRequestBody())
|
||||
}) {
|
||||
onSuccess = {
|
||||
showToast(it.msg.noNull("删除成功"))
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onAllSelectClick() {
|
||||
val allChecked =
|
||||
pageModel.rv?.commonAdapter()?.items
|
||||
?.find { item -> !(item as GncAssembleListBean).checked.get() } == null
|
||||
pageModel.rv?.commonAdapter()?.items?.forEach {
|
||||
(it as GncAssembleListBean).checked.set(!allChecked)
|
||||
}
|
||||
}
|
||||
|
||||
fun onUnloadClick() {
|
||||
GncAssembleUnloadListActivity.start(getTopActivity(), false)
|
||||
}
|
||||
|
||||
/**
|
||||
* item 点击
|
||||
*/
|
||||
override fun onItemClick(position: Int, type: Int) {
|
||||
val adapter = pageModel.rv!!.commonAdapter()!!
|
||||
val bean = adapter.getItem(position) as GncAssembleListBean
|
||||
when (type) {
|
||||
R.id.tv_delete -> {
|
||||
ConfirmDialogModel("是否删除该条记录?") {
|
||||
delete(listOf(bean.useId))
|
||||
}.show()
|
||||
}
|
||||
|
||||
R.id.tv_modify -> {
|
||||
GncAssembleAddActivity.start(getTopActivity(), bean)
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
when (requestCode) {
|
||||
Constant.RequestCode.CAR -> {
|
||||
car.value =
|
||||
data.getStringExtra(Constant.Result.CODED_CONTENT).noNull()
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.lukouguoji.gnc.page.assemble.unload
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.databinding.ActivityGncAssembleUnloadListBinding
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.ktx.getLifecycleOwner
|
||||
import com.lukouguoji.module_base.ktx.refresh
|
||||
|
||||
class GncAssembleUnloadListActivity :
|
||||
BaseBindingActivity<ActivityGncAssembleUnloadListBinding, GncAssembleUnloadListViewModel>() {
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.activity_gnc_assemble_unload_list
|
||||
}
|
||||
|
||||
override fun viewModelClass(): Class<GncAssembleUnloadListViewModel> {
|
||||
return GncAssembleUnloadListViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国内出港待装货物")
|
||||
binding.viewModel = viewModel
|
||||
|
||||
viewModel.pageModel.bindSmartRefreshLayout(
|
||||
binding.srl,
|
||||
binding.rv,
|
||||
viewModel,
|
||||
getLifecycleOwner()
|
||||
)
|
||||
|
||||
viewModel.initOnCreated(intent)
|
||||
}
|
||||
|
||||
companion object{
|
||||
@JvmStatic
|
||||
fun start(context: Context, modify: Boolean = true) {
|
||||
val starter = Intent(context, GncAssembleUnloadListActivity::class.java).putExtra(
|
||||
Constant.Key.MODIFY, modify)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,284 @@
|
||||
package com.lukouguoji.gnc.page.assemble.unload
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.view.View
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.alibaba.fastjson.JSONArray
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.page.assemble.add.GncAssembleAddViewHolder
|
||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
||||
import com.lukouguoji.module_base.bean.GjcWaybillBean
|
||||
import com.lukouguoji.module_base.bean.WaybillBean
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.common.ConstantEvent
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.impl.FlowBus
|
||||
import com.lukouguoji.module_base.ktx.commonAdapter
|
||||
import com.lukouguoji.module_base.ktx.formatDate
|
||||
import com.lukouguoji.module_base.ktx.getActivity
|
||||
import com.lukouguoji.module_base.ktx.launchCollect
|
||||
import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
||||
import com.lukouguoji.module_base.ktx.noNull
|
||||
import com.lukouguoji.module_base.ktx.refresh
|
||||
import com.lukouguoji.module_base.ktx.showToast
|
||||
import com.lukouguoji.module_base.ktx.toJson
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.lukouguoji.module_base.model.PadFilterDialogModel
|
||||
import com.lukouguoji.module_base.model.PadFilterModel
|
||||
import com.lukouguoji.module_base.model.ScanModel
|
||||
import com.lukouguoji.module_base.ui.weight.search.layout.SearchLayoutType
|
||||
import com.lukouguoji.module_base.util.CheckUtil
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.lukouguoji.module_base.util.DictUtils
|
||||
import dev.DevUtils
|
||||
import dev.utils.app.info.KeyValue
|
||||
import dev.utils.common.DateUtils
|
||||
import java.util.Collections.emptyList
|
||||
|
||||
class GncAssembleUnloadListViewModel : BasePageViewModel() {
|
||||
|
||||
val date = MutableLiveData("")
|
||||
val fno = MutableLiveData("")
|
||||
|
||||
// 承运人
|
||||
val carrier = MutableLiveData("")
|
||||
|
||||
// 目的港
|
||||
val dest = MutableLiveData("")
|
||||
|
||||
// 代理
|
||||
val agent = MutableLiveData("")
|
||||
|
||||
// 特码
|
||||
val specialCode = MutableLiveData("")
|
||||
|
||||
// 运单号
|
||||
val waybill = MutableLiveData("")
|
||||
|
||||
// 运单号列表
|
||||
val wbNoList = MutableLiveData<List<String>>()
|
||||
|
||||
val agentList = MutableLiveData<List<KeyValue>>(emptyList()).apply {
|
||||
DictUtils.getGncAgentList(addAll = false) {
|
||||
value = it
|
||||
}
|
||||
}
|
||||
val specialCodeList = MutableLiveData<List<KeyValue>>(emptyList()).apply {
|
||||
DictUtils.getSpecialCodeList(addAll = false) {
|
||||
val list = arrayListOf<KeyValue>()
|
||||
it.find { b -> b.key.contains("普通货物") }?.let { b ->
|
||||
list.add(b)
|
||||
}
|
||||
list.addAll(it.filter { b -> !b.key.contains("普通货物") })
|
||||
value = it
|
||||
}
|
||||
}
|
||||
|
||||
// 选中条数
|
||||
val count = MutableLiveData(0)
|
||||
// 是否只可查看---从国内出港组装页面进入即为false
|
||||
val modify = MutableLiveData(true)
|
||||
|
||||
val itemLayoutId = R.layout.item_gnc_assemble_add_no_right
|
||||
val itemViewHolder = GncAssembleUnloadViewHolder::class.java
|
||||
|
||||
private val filterModel by lazy {
|
||||
PadFilterDialogModel(
|
||||
DevUtils.getTopActivity(), listOf(
|
||||
PadFilterModel(
|
||||
agent,
|
||||
title = "代理",
|
||||
hint = "请选择代理",
|
||||
type = SearchLayoutType.SPINNER,
|
||||
list = agentList
|
||||
),
|
||||
PadFilterModel(
|
||||
specialCode,
|
||||
title = "特码",
|
||||
hint = "请选择特码",
|
||||
type = SearchLayoutType.SPINNER,
|
||||
list = specialCodeList
|
||||
),
|
||||
)
|
||||
) {
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
fun getWayBillList() {
|
||||
val body = mapOf(
|
||||
"pageNum" to pageModel.page,
|
||||
"pageSize" to pageModel.limit,
|
||||
"dest" to dest.value,
|
||||
"agentCode" to agent.value,
|
||||
"spCode" to specialCode.value,
|
||||
"wbNo" to waybill.value,
|
||||
"fdate" to date.value,
|
||||
"fno" to fno.value,
|
||||
"by1" to carrier.value,
|
||||
).toRequestBody()
|
||||
launchCollect({
|
||||
NetApply.api.getWbNoList(
|
||||
"/DomExpLoading/queryWarehouseWbList",
|
||||
body
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
val results = it.data!!
|
||||
when {
|
||||
results.size == 1 -> {
|
||||
waybill.value = results[0]
|
||||
wbNoList.value = kotlin.collections.emptyList()
|
||||
}
|
||||
results.size > 1 -> {
|
||||
wbNoList.value = results
|
||||
showWbNoListSelect()
|
||||
}
|
||||
else -> {
|
||||
wbNoList.value = kotlin.collections.emptyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
onFailed = { i: Int, s: String ->
|
||||
wbNoList.value = kotlin.collections.emptyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun initOnCreated(intent: Intent) {
|
||||
modify.value = intent.getBooleanExtra(Constant.Key.MODIFY, true)
|
||||
getData()
|
||||
}
|
||||
|
||||
override fun getData() {
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getWaybillList(
|
||||
"/DomExpLoading/queryWarehouse", mapOf(
|
||||
"pageNum" to pageModel.page,
|
||||
"pageSize" to pageModel.limit,
|
||||
"dest" to dest.value,
|
||||
"agentCode" to agent.value,
|
||||
"spCode" to specialCode.value,
|
||||
"wbNo" to waybill.value,
|
||||
"fdate" to date.value,
|
||||
"fno" to fno.value,
|
||||
"by1" to carrier.value,
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
if (modify.value == false) {
|
||||
it.list?.forEach { iit -> iit.needCheck = false }
|
||||
}
|
||||
pageModel.handleListBean(it)
|
||||
count.value = it.total
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索点击
|
||||
*/
|
||||
fun searchClick(view: View) {
|
||||
refresh()
|
||||
}
|
||||
|
||||
fun filterClick() {
|
||||
filterModel.show()
|
||||
}
|
||||
|
||||
/**
|
||||
* 运单号 扫描
|
||||
*/
|
||||
fun waybillNoScanClick(view: View) {
|
||||
ScanModel.startScan(view.context.getActivity(), Constant.RequestCode.WAYBILL)
|
||||
}
|
||||
|
||||
/**
|
||||
* 全选 点击
|
||||
*/
|
||||
fun checkAllClick(view: View) {
|
||||
CheckUtil.handleAllCheck(
|
||||
pageModel.rv?.commonAdapter()?.items as? List<GjcWaybillBean> ?: emptyList()
|
||||
)
|
||||
}
|
||||
|
||||
fun onMergeClick() {
|
||||
val list = getCheckedList()
|
||||
if (list.size < 2) {
|
||||
showToast("请选择两个以上数据")
|
||||
return
|
||||
}
|
||||
if (list.groupBy { it.wbNo }.size > 1) {
|
||||
showToast("合并数据运单号必须一致")
|
||||
return
|
||||
}
|
||||
if (list.groupBy { it.dest }.size > 1) {
|
||||
showToast("合并数据目的港必须一致")
|
||||
return
|
||||
}
|
||||
launchLoadingCollect({
|
||||
NetApply.api.anyPost(
|
||||
"DomExpLoading/mergeWarehouseList",
|
||||
list.map { it.whId }.toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
showToast(it.msg.noNull("合并成功"))
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onConfirmClick() {
|
||||
val list = getCheckedList()
|
||||
if (list.isEmpty()) {
|
||||
showToast("请选择数据")
|
||||
return
|
||||
}
|
||||
FlowBus.with<List<WaybillBean>>(ConstantEvent.WAYBILL_CHECKED)
|
||||
.tryEmit(list)
|
||||
getTopActivity().finish()
|
||||
}
|
||||
|
||||
private fun getCheckedList(): List<WaybillBean> {
|
||||
return (pageModel.rv?.commonAdapter()?.items?.filter { (it as WaybillBean).checked.get() }
|
||||
?: emptyList()) as List<WaybillBean>
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
when (requestCode) {
|
||||
Constant.RequestCode.WAYBILL -> {
|
||||
val id = data.getStringExtra(Constant.Result.CODED_CONTENT).noNull()
|
||||
waybill.value = id
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showWbNoListSelect() {
|
||||
Common.singleSelect(
|
||||
DevUtils.getTopActivity(),
|
||||
"选择运单号",
|
||||
JSONArray.parseArray(wbNoList.value!!.map {
|
||||
mapOf(
|
||||
"name" to it,
|
||||
"code" to it,
|
||||
)
|
||||
}.toList().toJson(false)),
|
||||
null
|
||||
) { position, _ ->
|
||||
waybill.value = wbNoList.value!![position]
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.lukouguoji.gnc.page.assemble.unload
|
||||
|
||||
import android.util.AndroidException
|
||||
import android.view.View
|
||||
import com.lukouguoji.gnc.databinding.ItemGncAssembleAddBinding
|
||||
import com.lukouguoji.gnc.databinding.ItemGncAssembleAddNoRightBinding
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.GjcWaybillBean
|
||||
import com.lukouguoji.module_base.bean.WaybillBean
|
||||
|
||||
class GncAssembleUnloadViewHolder(view: View) :
|
||||
BaseViewHolder<WaybillBean, ItemGncAssembleAddNoRightBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
val bean = getItemBean(item)!!
|
||||
binding.bean = bean
|
||||
|
||||
//
|
||||
if (bean.needCheck) {
|
||||
binding.ivIcon.setOnClickListener {
|
||||
bean.checked.set(!bean.checked.get())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.lukouguoji.gnc.page.deposit.list
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.databinding.DialogGncDepositBinding
|
||||
import com.lukouguoji.gnc.databinding.DialogGncDistributionDriverBinding
|
||||
import com.lukouguoji.module_base.base.BaseDialogModel
|
||||
import com.lukouguoji.module_base.ktx.verifyNullOrEmpty
|
||||
import dev.utils.app.info.KeyValue
|
||||
|
||||
class GncDepositDialogModel(
|
||||
val carList: String,
|
||||
val areaList: List<KeyValue>,
|
||||
val callBack: (GncDepositDialogModel) -> Unit
|
||||
) : BaseDialogModel<DialogGncDepositBinding>(DIALOG_TYPE_CENTER) {
|
||||
|
||||
// 区域
|
||||
val area = MutableLiveData("")
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.dialog_gnc_deposit
|
||||
}
|
||||
|
||||
override fun onDialogCreated(context: Context) {
|
||||
binding.model = this
|
||||
}
|
||||
|
||||
fun onConfirmClick() {
|
||||
if (area.value.verifyNullOrEmpty("请选择区域")) {
|
||||
return
|
||||
}
|
||||
dismiss()
|
||||
callBack(this)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.lukouguoji.gnc.page.deposit.list
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.databinding.ActivityGncDepositListBinding
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.ktx.getLifecycleOwner
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_GNC_DEPOSIT)
|
||||
class GncDepositListActivity :
|
||||
BaseBindingActivity<ActivityGncDepositListBinding, GncDepositListViewModel>() {
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.activity_gnc_deposit_list
|
||||
}
|
||||
|
||||
override fun viewModelClass(): Class<GncDepositListViewModel> {
|
||||
return GncDepositListViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国内出港存放")
|
||||
binding.viewModel = viewModel
|
||||
viewModel.pageModel.bindSmartRefreshLayout(
|
||||
binding.srl,
|
||||
binding.rv,
|
||||
viewModel,
|
||||
getLifecycleOwner()
|
||||
)
|
||||
viewModel.refresh()
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
val starter = Intent(context, GncDepositListActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.lukouguoji.gnc.page.deposit.list
|
||||
|
||||
import android.view.View
|
||||
import com.lukouguoji.gnc.databinding.ItemGncDepositListBinding
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.GncCunFangBean
|
||||
import com.lukouguoji.module_base.bean.SimpleCheckBean
|
||||
|
||||
class GncDepositListViewHolder(view: View) :
|
||||
BaseViewHolder<GncCunFangBean, ItemGncDepositListBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
val bean = getItemBean(item)!!
|
||||
binding.bean = bean
|
||||
|
||||
binding.ivIcon.setOnClickListener {
|
||||
bean.checked.set(!bean.checked.get())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
package com.lukouguoji.gnc.page.deposit.list
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.view.View
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
||||
import com.lukouguoji.module_base.bean.GncCunFangBean
|
||||
import com.lukouguoji.module_base.bean.SimpleCheckBean
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.interfaces.ICheck
|
||||
import com.lukouguoji.module_base.ktx.commonAdapter
|
||||
import com.lukouguoji.module_base.ktx.formatDate
|
||||
import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
||||
import com.lukouguoji.module_base.ktx.noNull
|
||||
import com.lukouguoji.module_base.ktx.showToast
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.lukouguoji.module_base.model.ScanModel
|
||||
import com.lukouguoji.module_base.util.CheckUtil
|
||||
import com.lukouguoji.module_base.util.DictUtils
|
||||
import dev.utils.app.info.KeyValue
|
||||
import dev.utils.common.DateUtils
|
||||
|
||||
class GncDepositListViewModel : BasePageViewModel() {
|
||||
|
||||
// 航班日期
|
||||
val date = MutableLiveData(DateUtils.getCurrentTime().formatDate())
|
||||
|
||||
// 航班号
|
||||
val flightNo = MutableLiveData("")
|
||||
|
||||
// 存放区域
|
||||
val depositArea = MutableLiveData("")
|
||||
|
||||
// 复磅状态
|
||||
val reweighStatus = MutableLiveData("")
|
||||
|
||||
// 平板车
|
||||
val car = MutableLiveData("")
|
||||
|
||||
// 存放区域列表
|
||||
val depositAreaList = MutableLiveData<List<KeyValue>>().apply {
|
||||
DictUtils.getAreaList {
|
||||
value = listOf(KeyValue("全部", "")) + it
|
||||
}
|
||||
}
|
||||
|
||||
// 复磅状态列表
|
||||
val reweighStatusList = MutableLiveData<List<KeyValue>>(
|
||||
DictUtils.reWeightStatusList
|
||||
)
|
||||
|
||||
val itemLayoutId = R.layout.item_gnc_deposit_list
|
||||
val itemViewHolder = GncDepositListViewHolder::class.java
|
||||
|
||||
val count = MutableLiveData("0")
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
override fun getData() {
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getGncCunFangList(
|
||||
mapOf(
|
||||
"pageNum" to pageModel.page,
|
||||
"pageSize" to pageModel.limit,
|
||||
"fdate" to date.value,
|
||||
"fno" to flightNo.value,
|
||||
"storageArea" to depositArea.value,
|
||||
"copStatus" to reweighStatus.value,
|
||||
"carId" to car.value,
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
pageModel.handleListBean(it)
|
||||
count.value = it.total.toString()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onCarScanClick() {
|
||||
ScanModel.startScan(getTopActivity(), Constant.RequestCode.CAR)
|
||||
}
|
||||
|
||||
fun checkAllClick(view: View) {
|
||||
CheckUtil.handleAllCheck(pageModel.rv?.commonAdapter()?.items as List<ICheck>)
|
||||
}
|
||||
|
||||
fun onConfirmClick() {
|
||||
val list = pageModel.rv!!.commonAdapter()!!.items as List<GncCunFangBean>
|
||||
val filter = list.filter { it.checked.get() }
|
||||
if (filter.isEmpty()) {
|
||||
showToast("请选择数据")
|
||||
return
|
||||
}
|
||||
|
||||
GncDepositDialogModel(
|
||||
filter.joinToString("、") { it.carId },
|
||||
depositAreaList.value!!
|
||||
) {
|
||||
launchLoadingCollect({
|
||||
NetApply.api.anyPost(
|
||||
"DomExpLoading/allocationArea", mapOf(
|
||||
"area" to it.area.value,
|
||||
"useIdList" to filter.map { b -> b.useId },
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
showToast(it.msg.noNull("分配区域成功"))
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
}.show(getTopActivity())
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
when (requestCode) {
|
||||
Constant.RequestCode.CAR -> {
|
||||
car.value = data.getStringExtra(Constant.Result.CODED_CONTENT).noNull()
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.lukouguoji.gnc.page.distribution.handover
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.databinding.ActivityDistributionHandoverBinding
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.ktx.addOnItemClickListener
|
||||
import com.lukouguoji.module_base.ktx.getLifecycleOwner
|
||||
import com.lukouguoji.module_base.ktx.loge
|
||||
|
||||
class GncDistributionHandoverActivity :
|
||||
BaseBindingActivity<ActivityDistributionHandoverBinding, GncDistributionHandoverViewModel>() {
|
||||
|
||||
override fun layoutId() = R.layout.activity_distribution_handover
|
||||
|
||||
override fun viewModelClass(): Class<GncDistributionHandoverViewModel> {
|
||||
return GncDistributionHandoverViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国内出港单证交接")
|
||||
binding.viewModel = viewModel
|
||||
viewModel.initOnCreated()
|
||||
|
||||
viewModel.pageModel.bindSmartRefreshLayout(
|
||||
binding.srl,
|
||||
binding.rv,
|
||||
viewModel,
|
||||
getLifecycleOwner()
|
||||
)
|
||||
|
||||
binding.rv.addOnItemClickListener(viewModel)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
viewModel.refresh()
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
val starter = Intent(context, GncDistributionHandoverActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.lukouguoji.gnc.page.distribution.handover
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.databinding.DialogGncDistributionHandoverModifyBinding
|
||||
import com.lukouguoji.module_base.base.BaseDialogModel
|
||||
import com.lukouguoji.module_base.bean.FlightBean
|
||||
import com.lukouguoji.module_base.ktx.showToast
|
||||
import com.lukouguoji.module_base.ktx.verifyNullOrEmpty
|
||||
import com.lukouguoji.module_base.util.DictUtils
|
||||
import dev.utils.app.info.KeyValue
|
||||
|
||||
class GncDistributionHandoverModifyDialogModel(
|
||||
val driverList: List<KeyValue>,
|
||||
val bean: FlightBean? = null,
|
||||
private val callBack: (GncDistributionHandoverModifyDialogModel) -> Unit
|
||||
) : BaseDialogModel<DialogGncDistributionHandoverModifyBinding>(DIALOG_TYPE_CENTER) {
|
||||
|
||||
// 司机
|
||||
val driver = MutableLiveData("")
|
||||
|
||||
// 业务袋
|
||||
val check1 = MutableLiveData(true)
|
||||
|
||||
// 特货通知单
|
||||
val check2 = MutableLiveData(false)
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.dialog_gnc_distribution_handover_modify
|
||||
}
|
||||
|
||||
override fun onDialogCreated(context: Context) {
|
||||
binding.model = this
|
||||
bean?.let {
|
||||
when (bean.fileType) {
|
||||
"1" -> {
|
||||
check1.value = true
|
||||
}
|
||||
|
||||
"2" -> {
|
||||
check2.value = true
|
||||
}
|
||||
|
||||
"3" -> {
|
||||
check1.value = true
|
||||
check2.value = true
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
driver.value = bean.driver
|
||||
}
|
||||
}
|
||||
|
||||
fun onConfirmClick() {
|
||||
if ( driver.value.isNullOrEmpty()){
|
||||
showToast("请选择司机")
|
||||
return
|
||||
}
|
||||
if ((getFileType().verifyNullOrEmpty("请选择单证类型"))
|
||||
) {
|
||||
return
|
||||
}
|
||||
dismiss()
|
||||
callBack(this)
|
||||
}
|
||||
|
||||
fun getFileType(): String {
|
||||
return when {
|
||||
check1.value == true && check2.value == true -> "3"
|
||||
check1.value == true -> "1"
|
||||
check2.value == true -> "2"
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.lukouguoji.gnc.page.distribution.handover
|
||||
|
||||
import android.view.View
|
||||
import com.lukouguoji.gnc.databinding.ItemGncDistributionHandoverBinding
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.FlightBean
|
||||
|
||||
class GncDistributionHandoverViewHolder(view: View) :
|
||||
BaseViewHolder<FlightBean, ItemGncDistributionHandoverBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
val bean = getItemBean(item)!!
|
||||
binding.bean = bean
|
||||
|
||||
notifyItemClick(position, binding.tvModify)
|
||||
binding.ivIcon.setOnClickListener {
|
||||
bean.checked.set(!bean.checked.get())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
package com.lukouguoji.gnc.page.distribution.handover
|
||||
|
||||
import android.view.View
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
||||
import com.lukouguoji.module_base.bean.FlightBean
|
||||
import com.lukouguoji.module_base.bean.GncDistributionBean
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.ktx.commonAdapter
|
||||
import com.lukouguoji.module_base.ktx.formatDate
|
||||
import com.lukouguoji.module_base.ktx.getActivity
|
||||
import com.lukouguoji.module_base.ktx.launchCollect
|
||||
import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
||||
import com.lukouguoji.module_base.ktx.noNull
|
||||
import com.lukouguoji.module_base.ktx.showToast
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.lukouguoji.module_base.util.DictUtils
|
||||
import dev.utils.DevFinal
|
||||
import dev.utils.app.info.KeyValue
|
||||
import dev.utils.common.DateUtils
|
||||
import java.util.Calendar
|
||||
|
||||
class GncDistributionHandoverViewModel : BasePageViewModel() {
|
||||
|
||||
// 航班日期
|
||||
val date = MutableLiveData(DateUtils.getCurrentTime().formatDate())
|
||||
|
||||
// 航班号
|
||||
val flightNo = MutableLiveData("")
|
||||
|
||||
// 单证类型
|
||||
val docType = MutableLiveData("")
|
||||
|
||||
// 交接状态
|
||||
val handoverStatus = MutableLiveData("")
|
||||
|
||||
// 司机
|
||||
val driver = MutableLiveData("")
|
||||
|
||||
// 数量
|
||||
val count = MutableLiveData("0")
|
||||
|
||||
// 单证类型列表
|
||||
val docTypeList = DictUtils.docTypeList
|
||||
|
||||
// 交接状态列表
|
||||
val handoverStatusList = DictUtils.handoverStatusList
|
||||
|
||||
// 司机列表
|
||||
val driverList = MutableLiveData<List<KeyValue>>().apply {
|
||||
DictUtils.getDriverList {
|
||||
value = listOf(KeyValue("全部", "")) + it
|
||||
}
|
||||
}
|
||||
|
||||
val itemLayoutId = R.layout.item_gnc_distribution_handover
|
||||
val itemViewHolder = GncDistributionHandoverViewHolder::class.java
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
fun initOnCreated() {
|
||||
date.value = DateUtils.getCurrentTime().formatDate()
|
||||
}
|
||||
|
||||
override fun getData() {
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getGncDistributionHandoverList(
|
||||
mapOf(
|
||||
"page" to pageModel.page,
|
||||
"limit" to pageModel.limit,
|
||||
"fdate" to date.value,
|
||||
"fno" to flightNo.value,
|
||||
"fileType" to docType.value,
|
||||
"handoverStatus" to handoverStatus.value,
|
||||
"driver" to driver.value,
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
pageModel.handleListBean(it)
|
||||
count.value = it.total.toString()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onItemClick(position: Int, type: Int) {
|
||||
val adapter = pageModel.rv!!.commonAdapter()!!
|
||||
val bean = adapter.getItem(position) as FlightBean
|
||||
when (type) {
|
||||
R.id.tv_modify -> {
|
||||
if (bean.id.isEmpty()) {
|
||||
showToast("该数据没有单证交接记录,无法修改")
|
||||
return
|
||||
}
|
||||
if (bean.actualTakeOff.isNotEmpty()) {
|
||||
showToast("该航班已起飞,无法修改")
|
||||
return
|
||||
}
|
||||
GncDistributionHandoverModifyDialogModel(driverList = driverList.value!!.filter { it.key != "全部" },bean) { model ->
|
||||
launchLoadingCollect({
|
||||
NetApply.api.anyPost(
|
||||
"flt/updateHandover",
|
||||
mapOf(
|
||||
"fileType" to model.getFileType(),
|
||||
"driver" to model.driver.value,
|
||||
"id" to bean.id,
|
||||
"fid" to bean.fid
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
showToast(it.msg.noNull("修改成功"))
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
}.show()
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始交接 点击
|
||||
*/
|
||||
fun onConfirmClick() {
|
||||
val adapter = pageModel.rv!!.commonAdapter()!!
|
||||
val list = (adapter.items as List<FlightBean>).filter { it.checked.get() }
|
||||
if (list.isEmpty()) {
|
||||
showToast("请选择数据")
|
||||
return
|
||||
}
|
||||
if (list.any { it.id.isNotEmpty() }) {
|
||||
showToast("已存在单证交接记录!")
|
||||
return
|
||||
}
|
||||
if (list.any { it.actualTakeOff.isNotEmpty() }) {
|
||||
showToast("航班已起飞,无法修改")
|
||||
return
|
||||
}
|
||||
GncDistributionHandoverModifyDialogModel(driverList = driverList.value!!.filter { it.key != "全部" }) { model ->
|
||||
launchLoadingCollect({
|
||||
NetApply.api.anyPost(
|
||||
"flt/insertHandoverBatch",
|
||||
mapOf(
|
||||
"fileType" to model.getFileType(),
|
||||
"driver" to model.driver.value,
|
||||
"fidList" to list.map { it.fid },
|
||||
"ieFlag" to "E"
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
showToast(it.msg.noNull("单证交接成功"))
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
}.show()
|
||||
}
|
||||
|
||||
/**
|
||||
* 屏蔽无货邮航班 点击
|
||||
*/
|
||||
fun onHideFlightClick() {
|
||||
val adapter = pageModel.rv!!.commonAdapter()!!
|
||||
val list = (adapter.items as List<FlightBean>).filter { it.checked.get() }
|
||||
if (list.isEmpty()) {
|
||||
showToast("请选择数据")
|
||||
return
|
||||
}
|
||||
launchLoadingCollect({
|
||||
NetApply.api.anyPost(
|
||||
"flt/updateFlightCMFlag",
|
||||
mapOf(
|
||||
"fidList" to list.map { it.fid },
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
showToast("无货邮航班设置成功!")
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.lukouguoji.gnc.page.distribution.home
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.databinding.ActivityDistributionHomeBinding
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.ktx.addOnItemClickListener
|
||||
import com.lukouguoji.module_base.ktx.getLifecycleOwner
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_GNC_DISTRIBUTION)
|
||||
class GncDistributionHomeActivity :
|
||||
BaseBindingActivity<ActivityDistributionHomeBinding, GncDistributionHomeViewModel>() {
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.activity_distribution_home
|
||||
}
|
||||
|
||||
override fun viewModelClass(): Class<GncDistributionHomeViewModel> {
|
||||
return GncDistributionHomeViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国内出港货物分配")
|
||||
binding.viewModel = viewModel
|
||||
viewModel.pageModel.bindSmartRefreshLayout(
|
||||
binding.srl,
|
||||
binding.rv,
|
||||
viewModel,
|
||||
getLifecycleOwner()
|
||||
)
|
||||
|
||||
binding.rv.addOnItemClickListener(viewModel)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
viewModel.refresh()
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
val starter = Intent(context, GncDistributionHomeActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.lukouguoji.gnc.page.distribution.home
|
||||
|
||||
import android.view.View
|
||||
import com.lukouguoji.gnc.databinding.ItemGncDistributionBinding
|
||||
import com.lukouguoji.module_base.adapter.setShape
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.GncDistributionBean
|
||||
|
||||
class GncDistributionHomeViewHolder(view: View) :
|
||||
BaseViewHolder<GncDistributionBean, ItemGncDistributionBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
val bean = getItemBean(item)!!
|
||||
binding.bean = bean
|
||||
|
||||
binding.ivIcon.setOnClickListener {
|
||||
bean.checked.set(!bean.checked.get())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,323 @@
|
||||
package com.lukouguoji.gnc.page.distribution.home
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.view.View
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.page.distribution.handover.GncDistributionHandoverActivity
|
||||
import com.lukouguoji.gnc.page.distribution.home.dialog.GncDistributionBackDialogModel
|
||||
import com.lukouguoji.gnc.page.distribution.home.dialog.GncDistributionDriverDialogModel
|
||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
||||
import com.lukouguoji.module_base.bean.GncDistributionBean
|
||||
import com.lukouguoji.module_base.bean.GoodsTransportBean
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.ktx.commonAdapter
|
||||
import com.lukouguoji.module_base.ktx.formatDate
|
||||
import com.lukouguoji.module_base.ktx.getActivity
|
||||
import com.lukouguoji.module_base.ktx.launchCollect
|
||||
import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
||||
import com.lukouguoji.module_base.ktx.logi
|
||||
import com.lukouguoji.module_base.ktx.noNull
|
||||
import com.lukouguoji.module_base.ktx.showConfirmDialog
|
||||
import com.lukouguoji.module_base.ktx.showToast
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.lukouguoji.module_base.model.GoodsTransportModifyDialogModel
|
||||
import com.lukouguoji.module_base.model.PadFilterDialogModel
|
||||
import com.lukouguoji.module_base.model.PadFilterModel
|
||||
import com.lukouguoji.module_base.model.ScanModel
|
||||
import com.lukouguoji.module_base.ui.weight.search.layout.SearchLayoutType
|
||||
import com.lukouguoji.module_base.util.CheckUtil
|
||||
import com.lukouguoji.module_base.util.DictUtils
|
||||
import dev.utils.app.info.KeyValue
|
||||
import dev.utils.common.DateUtils
|
||||
|
||||
class GncDistributionHomeViewModel : BasePageViewModel() {
|
||||
|
||||
// 日期
|
||||
val date = MutableLiveData(DateUtils.getCurrentTime().formatDate())
|
||||
|
||||
// 查询--开始日期
|
||||
val startDate = MutableLiveData(DateUtils.getCurrentTime().formatDate())
|
||||
// 查询--结束日期
|
||||
val endDate = MutableLiveData("")
|
||||
|
||||
// 航班号
|
||||
val flightNo = MutableLiveData("")
|
||||
|
||||
// 分配状态
|
||||
val distributionStatus = MutableLiveData("")
|
||||
|
||||
// 复磅状态
|
||||
val status = MutableLiveData("")
|
||||
|
||||
// 板车号
|
||||
val car = MutableLiveData("")
|
||||
|
||||
val driver = MutableLiveData("")
|
||||
|
||||
val fDest = MutableLiveData("")
|
||||
|
||||
// 复磅状态列表
|
||||
val statusList = DictUtils.reWeightStatusList
|
||||
|
||||
// 分配状态列表
|
||||
val distributionStatusList = DictUtils.distributionStatusList
|
||||
|
||||
val driverList = MutableLiveData<List<KeyValue>>().apply {
|
||||
DictUtils.getDriverList {
|
||||
value = listOf(KeyValue("全部", "")) + it
|
||||
}
|
||||
}
|
||||
private var fDestList = MutableLiveData<List<KeyValue>>()
|
||||
|
||||
val itemLayoutId = R.layout.item_gnc_distribution
|
||||
val itemViewHolder = GncDistributionHomeViewHolder::class.java
|
||||
|
||||
private val filterDialogModel by lazy {
|
||||
PadFilterDialogModel(
|
||||
getTopActivity(), listOf(
|
||||
PadFilterModel(
|
||||
data = driver,
|
||||
title = "分配司机",
|
||||
hint = "请选择司机",
|
||||
SearchLayoutType.SPINNER,
|
||||
driverList
|
||||
),
|
||||
PadFilterModel(
|
||||
data = status,
|
||||
title = "复磅状态",
|
||||
hint = "请选择复磅状态",
|
||||
SearchLayoutType.SPINNER,
|
||||
MutableLiveData(statusList)
|
||||
),
|
||||
PadFilterModel(
|
||||
data = fDest,
|
||||
title = "目的站",
|
||||
hint = "请选择目的站",
|
||||
SearchLayoutType.SPINNER,
|
||||
fDestList
|
||||
)
|
||||
)
|
||||
) {
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
|
||||
val count = MutableLiveData("0")
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
override fun getData() {
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getGncDistributionList(
|
||||
mapOf(
|
||||
"pageNum" to pageModel.page,
|
||||
"pageSize" to pageModel.limit,
|
||||
"startTime" to startDate.value,
|
||||
"endTime" to endDate.value,
|
||||
"fno" to flightNo.value,
|
||||
"allocationStatus" to distributionStatus.value,
|
||||
"copStatus" to status.value,
|
||||
"checkFlag" to status.value,
|
||||
"carId" to car.value,
|
||||
"allocationDriver" to driver.value,
|
||||
"fdest" to fDest.value
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
pageModel.handleListBean(it)
|
||||
count.value = it.total.toString()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 平板车 扫描
|
||||
*/
|
||||
fun carScan(view: View) {
|
||||
ScanModel.startScan(view.context.getActivity(), Constant.RequestCode.CAR)
|
||||
}
|
||||
|
||||
fun onAllSelectClick() {
|
||||
CheckUtil.handleAllCheck(pageModel.rv!!.commonAdapter()!!.items as List<GncDistributionBean>)
|
||||
}
|
||||
|
||||
fun onFilterClick() {
|
||||
filterDialogModel.show()
|
||||
}
|
||||
|
||||
/**
|
||||
* 平板车 改变
|
||||
*/
|
||||
fun onFnoChange() {
|
||||
if ((flightNo.value?.length ?: 0) <= 2) {
|
||||
fDestList.value = emptyList()
|
||||
fDest.value = ""
|
||||
return
|
||||
}
|
||||
launchCollect({
|
||||
NetApply.api.listFlightDest(
|
||||
mapOf(
|
||||
"beginDate" to startDate.value,
|
||||
"endDate" to endDate.value,
|
||||
"fno" to flightNo.value,
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = { it ->
|
||||
val results = it.data!!
|
||||
fDest.value = ""
|
||||
when {
|
||||
results.size == 1 -> {
|
||||
fDestList.value = listOf(KeyValue(results[0], results[0]))
|
||||
}
|
||||
results.size > 1 -> {
|
||||
fDestList.value = results.map { iit -> KeyValue(iit, iit) } + listOf(KeyValue("全部", ""))
|
||||
}
|
||||
else -> {
|
||||
fDestList.value = emptyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// fDestList.value = listOf(KeyValue("全部", ""), KeyValue("11", "11"))
|
||||
}
|
||||
|
||||
fun onBackClick() {
|
||||
val list = pageModel.rv!!.commonAdapter()!!.items.filter {
|
||||
(it as GncDistributionBean).checked.get()
|
||||
} as List<GncDistributionBean>
|
||||
if (list.isEmpty()) {
|
||||
showToast("请选择需要回退的数据")
|
||||
return
|
||||
}
|
||||
GncDistributionBackDialogModel(
|
||||
list.joinToString("、") { it.carId },
|
||||
) { model ->
|
||||
launchLoadingCollect({
|
||||
NetApply.api.anyPost(
|
||||
"DomExpLoading/backTrans", mapOf(
|
||||
"fdate" to model.date.value,
|
||||
"fno" to model.fno.value,
|
||||
"backDirection" to model.stash.value,
|
||||
"useIdList" to list.map { b -> b.useId },
|
||||
"driver" to model.driver.value,
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
showToast(it.msg.noNull("回退成功"))
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
}.show()
|
||||
}
|
||||
|
||||
/**
|
||||
* 单证交接 点击
|
||||
*/
|
||||
fun onHandoverClick() {
|
||||
GncDistributionHandoverActivity.start(getTopActivity())
|
||||
}
|
||||
|
||||
/**
|
||||
* 分配 点击
|
||||
*/
|
||||
fun onDistributionClick() {
|
||||
val list = pageModel.rv!!.commonAdapter()!!.items.filter {
|
||||
(it as GncDistributionBean).checked.get()
|
||||
} as List<GncDistributionBean>
|
||||
if (list.isEmpty()) {
|
||||
showToast("请选择需要分配的数据")
|
||||
return
|
||||
}
|
||||
GncDistributionDriverDialogModel(
|
||||
list.joinToString("、") { it.carId },
|
||||
driverList.value?.filter { it.value != "" } ?: emptyList()
|
||||
) {
|
||||
launchLoadingCollect({
|
||||
NetApply.api.anyPost(
|
||||
"DomExpLoading/allocationDriver", mapOf(
|
||||
"driver" to it.driver.value,
|
||||
"useIdList" to list.map { b -> b.useId },
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
showToast(it.msg.noNull("分配成功"))
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
}.show(getTopActivity())
|
||||
}
|
||||
|
||||
|
||||
fun onAddCargo() {
|
||||
val adapter = pageModel.rv!!.commonAdapter()!!
|
||||
val list = (adapter.items as List<GncDistributionBean>).filter { it.checked.get() }
|
||||
if (list.isEmpty()) {
|
||||
showToast("请选中需要补充机位的信息!")
|
||||
return
|
||||
}
|
||||
getTopActivity().showConfirmDialog("是否确认加货?") {
|
||||
launchLoadingCollect({
|
||||
NetApply.api.anyPost(
|
||||
url = "DomExpLoading/addCargo",
|
||||
mapOf(
|
||||
"useIdList" to list.map { it.useId },
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
showToast(it.msg.noNull("设置待加货成功"))
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onSupplementClick() {
|
||||
val adapter = pageModel.rv!!.commonAdapter()!!
|
||||
val list = (adapter.items as List<GncDistributionBean>).filter { it.checked.get() }
|
||||
if (list.isEmpty()) {
|
||||
showToast("请选中需要补充机位的信息!")
|
||||
return
|
||||
}
|
||||
GoodsTransportModifyDialogModel(
|
||||
list.joinToString("、") { it.carId }
|
||||
) {
|
||||
launchLoadingCollect({
|
||||
NetApply.api.anyPost(
|
||||
url = "DomExpLoading/updateAllocationStandId",
|
||||
mapOf(
|
||||
"standId" to it.data.value,
|
||||
"useIdList" to list.map { it.useId },
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
showToast(it.msg.noNull("补充机位成功"))
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
}.show()
|
||||
}
|
||||
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
when (requestCode) {
|
||||
Constant.RequestCode.CAR -> {
|
||||
car.value = data.getStringExtra(Constant.Result.CODED_CONTENT)
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.lukouguoji.gnc.page.distribution.home.dialog
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.databinding.DialogGncDistributionBackBinding
|
||||
import com.lukouguoji.gnc.databinding.DialogGncDistributionDriverBinding
|
||||
import com.lukouguoji.module_base.base.BaseDialogModel
|
||||
import com.lukouguoji.module_base.ktx.formatDate
|
||||
import com.lukouguoji.module_base.ktx.showToast
|
||||
import com.lukouguoji.module_base.ktx.verifyNullOrEmpty
|
||||
import com.lukouguoji.module_base.util.DictUtils
|
||||
import dev.utils.app.info.KeyValue
|
||||
import dev.utils.common.DateUtils
|
||||
|
||||
class GncDistributionBackDialogModel(
|
||||
val carList: String,
|
||||
private val callBack: (GncDistributionBackDialogModel) -> Unit
|
||||
) : BaseDialogModel<DialogGncDistributionBackBinding>(DIALOG_TYPE_CENTER) {
|
||||
|
||||
val date = MutableLiveData("")
|
||||
val fno = MutableLiveData("")
|
||||
val stash = MutableLiveData("")
|
||||
val stashList = MutableLiveData<List<KeyValue>>(
|
||||
listOf(
|
||||
KeyValue("", ""),
|
||||
KeyValue("进港库区", "1"),
|
||||
KeyValue("出港库区", "2"),
|
||||
KeyValue("出港机坪", "0"),
|
||||
)
|
||||
)
|
||||
val driver = MutableLiveData("")
|
||||
val driverList = MutableLiveData<List<KeyValue>>().apply {
|
||||
DictUtils.getDriverList {
|
||||
value = it
|
||||
}
|
||||
}
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.dialog_gnc_distribution_back
|
||||
}
|
||||
|
||||
override fun onDialogCreated(context: Context) {
|
||||
binding.model = this
|
||||
}
|
||||
|
||||
fun onConfirmClick() {
|
||||
if ((date.value.isNullOrEmpty() || fno.value.isNullOrEmpty()) && stash.value.isNullOrEmpty()) {
|
||||
showToast("航班信息或库位必须填写其中一项,否则无法退回!")
|
||||
return
|
||||
}
|
||||
if (stash.value == "1" && (date.value!!.isNotEmpty() || fno.value!!.isNotEmpty())) {
|
||||
showToast("若需退回进港库位,请清空航班日期和航班号!")
|
||||
return
|
||||
}
|
||||
if (stash.value == "2" && (date.value!!.isNotEmpty() || fno.value!!.isNotEmpty())) {
|
||||
showToast("若需退回出港库位,请清空航班日期和航班号!")
|
||||
return
|
||||
}
|
||||
|
||||
dismiss()
|
||||
callBack(this)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.lukouguoji.gnc.page.distribution.home.dialog
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.databinding.DialogGncDistributionDriverBinding
|
||||
import com.lukouguoji.module_base.base.BaseDialogModel
|
||||
import com.lukouguoji.module_base.ktx.verifyNullOrEmpty
|
||||
import dev.utils.app.info.KeyValue
|
||||
|
||||
class GncDistributionDriverDialogModel(
|
||||
val carList: String,
|
||||
val driverList: List<KeyValue>,
|
||||
private val callBack: (GncDistributionDriverDialogModel) -> Unit
|
||||
) : BaseDialogModel<DialogGncDistributionDriverBinding>(DIALOG_TYPE_CENTER) {
|
||||
|
||||
// 司机
|
||||
val driver = MutableLiveData("")
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.dialog_gnc_distribution_driver
|
||||
}
|
||||
|
||||
override fun onDialogCreated(context: Context) {
|
||||
binding.model = this
|
||||
}
|
||||
|
||||
fun onConfirmClick() {
|
||||
if (driver.value.verifyNullOrEmpty("请选择司机")) {
|
||||
return
|
||||
}
|
||||
dismiss()
|
||||
callBack(this)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.lukouguoji.gnc.page.distribution.home.dialog
|
||||
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.databinding.DialogDistributionFilterBinding
|
||||
import com.lukouguoji.module_base.base.BaseDialogModel
|
||||
import dev.utils.app.info.KeyValue
|
||||
|
||||
class GncDistributionFilterDialogModel(
|
||||
private val callBack: () -> Unit
|
||||
) : BaseDialogModel<DialogDistributionFilterBinding>(DIALOG_TYPE_FULL) {
|
||||
|
||||
// 司机
|
||||
val driver = MutableLiveData("")
|
||||
|
||||
// 司机列表
|
||||
val driverList = MutableLiveData<List<KeyValue>>(listOf(KeyValue("司机", "0")))
|
||||
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.dialog_distribution_filter
|
||||
}
|
||||
|
||||
override fun onDialogCreated(context: Context) {
|
||||
binding.model = this
|
||||
|
||||
binding.root.findViewById<View>(R.id.tool_back).setOnClickListener { dismiss() }
|
||||
binding.root.findViewById<TextView>(R.id.title_name).text = "搜索"
|
||||
}
|
||||
|
||||
fun onResetClick() {
|
||||
binding.psl.reset()
|
||||
}
|
||||
|
||||
fun onConfirmClick() {
|
||||
dismiss()
|
||||
callBack()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.lukouguoji.gnc.page.fubang.details
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.databinding.ActivityGncFuBangDetailsBinding
|
||||
import com.lukouguoji.gnc.databinding.ActivityGncShouYunDetailsBinding
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
|
||||
class GncFuBangDetailsActivity :
|
||||
BaseBindingActivity<ActivityGncFuBangDetailsBinding, GncFuBangDetailsViewModel>() {
|
||||
|
||||
override fun layoutId() = R.layout.activity_gnc_fu_bang_details
|
||||
|
||||
override fun viewModelClass() = GncFuBangDetailsViewModel::class.java
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国内出港开始复磅")
|
||||
viewModel.initOnCreated(requireActivity(),intent)
|
||||
binding.viewModel = viewModel
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context, car: String) {
|
||||
val starter = Intent(context, GncFuBangDetailsActivity::class.java)
|
||||
.putExtra(Constant.Key.FLATCAR, car)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
package com.lukouguoji.gnc.page.fubang.details
|
||||
|
||||
import android.app.Activity
|
||||
import android.bluetooth.BluetoothAdapter
|
||||
import android.content.Intent
|
||||
import android.util.Log
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.observe
|
||||
import com.lukouguoji.module_base.base.BaseViewModel
|
||||
import com.lukouguoji.module_base.bean.GncFuBangBean
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.common.DetailsPageType
|
||||
import com.lukouguoji.module_base.db.perference.SharedPreferenceUtil
|
||||
import com.lukouguoji.module_base.http.net.DiBangWeightModel
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.ktx.launchCollect
|
||||
import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
||||
import com.lukouguoji.module_base.ktx.noNull
|
||||
import com.lukouguoji.module_base.ktx.showToast
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.lukouguoji.module_base.ktx.verifyNullOrEmpty
|
||||
import com.lukouguoji.module_base.model.BluetoothDialogModel
|
||||
import com.lukouguoji.module_base.model.ScanModel
|
||||
import com.lukouguoji.module_base.util.DictUtils
|
||||
import com.lukouguoji.module_base.util.PrinterUtils
|
||||
import dev.utils.app.info.KeyValue
|
||||
import kotlin.math.abs
|
||||
|
||||
class GncFuBangDetailsViewModel : BaseViewModel() {
|
||||
|
||||
val pageType = MutableLiveData(DetailsPageType.Add)
|
||||
|
||||
val channel = MutableLiveData("")
|
||||
|
||||
val dataBean = MutableLiveData(GncFuBangBean())
|
||||
|
||||
val showWeightEdit = MutableLiveData(true)
|
||||
|
||||
val channelList = MutableLiveData<List<KeyValue>>().apply {
|
||||
DictUtils.getChannelList {
|
||||
value = it
|
||||
}
|
||||
}
|
||||
val goodsTypeList = MutableLiveData<List<KeyValue>>(
|
||||
listOf(
|
||||
KeyValue("货物", "C"),
|
||||
KeyValue("邮件", "M"),
|
||||
KeyValue("空板箱", "X"),
|
||||
)
|
||||
)
|
||||
|
||||
val print = MutableLiveData(false)
|
||||
|
||||
val diBangModel = DiBangWeightModel()
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
fun initOnCreated(activity: Activity, intent: Intent) {
|
||||
val car = intent.getStringExtra(Constant.Key.FLATCAR) ?: ""
|
||||
pageType.value = if (car.isEmpty()) DetailsPageType.Add else DetailsPageType.Modify
|
||||
dataBean.value?.carId = car
|
||||
|
||||
diBangModel.weight.observe(activity as LifecycleOwner) {
|
||||
dataBean.value?.weighbridgeWeight = it
|
||||
}
|
||||
|
||||
channel.observe(activity as LifecycleOwner) {
|
||||
diBangModel.key = it
|
||||
}
|
||||
|
||||
getDetails()
|
||||
}
|
||||
|
||||
fun getDetails() {
|
||||
if (dataBean.value?.carId.isNullOrEmpty()) return
|
||||
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getGncFuBangDetailsByCar(dataBean.value!!.carId)
|
||||
}) {
|
||||
onSuccess = {
|
||||
it.data?.let { bean ->
|
||||
dataBean.value = bean
|
||||
if (diBangModel.weight.value !== "") {
|
||||
dataBean.value?.weighbridgeWeight = diBangModel.weight.value.toString()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun carScanClick() {
|
||||
ScanModel.startScan(getTopActivity(), Constant.RequestCode.CAR)
|
||||
}
|
||||
|
||||
fun uldScanClick() {
|
||||
ScanModel.startScan(getTopActivity(), Constant.RequestCode.ULD)
|
||||
}
|
||||
|
||||
fun onWeightLongClick(): Boolean {
|
||||
showWeightEdit.value = true
|
||||
return true
|
||||
}
|
||||
|
||||
fun getUldInfo() {
|
||||
if (dataBean.value!!.uld.isEmpty()) {
|
||||
return
|
||||
}
|
||||
launchCollect({
|
||||
NetApply.api.getUldDetails(dataBean.value!!.uld)
|
||||
}) {
|
||||
onSuccess = {
|
||||
it.data?.let { data ->
|
||||
dataBean.value?.uldWeight = data.uldWeight
|
||||
}
|
||||
}
|
||||
onFailed = { _, message ->
|
||||
showToast(message)
|
||||
dataBean.value?.uldWeight = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认点击
|
||||
*/
|
||||
fun confirmClick() {
|
||||
if (!verifyData()) {
|
||||
return
|
||||
}
|
||||
if (print.value!! && !BluetoothAdapter.getDefaultAdapter().isEnabled) {
|
||||
showToast("请打开设备蓝牙")
|
||||
return
|
||||
}
|
||||
val bean = dataBean.value!!
|
||||
launchLoadingCollect({
|
||||
NetApply.api.anyPost("DomExpWeighting/completed", bean.toRequestBody(true))
|
||||
}) {
|
||||
onSuccess = {
|
||||
showToast(it.msg.noNull("复磅成功"))
|
||||
|
||||
if (print.value == true) {
|
||||
BluetoothDialogModel()
|
||||
.showCallBack {
|
||||
bean.username = SharedPreferenceUtil.getString(Constant.Share.userName)
|
||||
PrinterUtils.printFuBang(bean)
|
||||
}
|
||||
}
|
||||
dataBean.value = GncFuBangBean()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun verifyData(): Boolean {
|
||||
val bean = dataBean.value!!
|
||||
if (bean.carId.isEmpty()) {
|
||||
showToast("请输入正确的平板车号")
|
||||
return false
|
||||
}
|
||||
if ((bean.carWeight.verifyNullOrEmpty("平板车信息未维护,设备不可用!")
|
||||
|| bean.pc.verifyNullOrEmpty("请输入件数")
|
||||
|| bean.volume.verifyNullOrEmpty("请输入体积"))
|
||||
) {
|
||||
return false
|
||||
}
|
||||
|
||||
val netWeight = bean.netWeight.toFloatOrNull() ?: 0f
|
||||
val currentWeight = bean.currentWeight.toFloatOrNull() ?: 0f
|
||||
if (abs((netWeight - currentWeight)) / abs(netWeight) > 0.03f) {
|
||||
showToast("平板车(${dataBean.value?.carId.noNull()})复磅重量(${currentWeight})较入库重量(${netWeight})偏差超过3%,不允许复磅")
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
when (requestCode) {
|
||||
Constant.RequestCode.CAR -> {
|
||||
dataBean.value!!.carId =
|
||||
data.getStringExtra(Constant.Result.CODED_CONTENT) ?: ""
|
||||
getDetails()
|
||||
}
|
||||
|
||||
Constant.RequestCode.ULD -> {
|
||||
dataBean.value!!.uld = data.getStringExtra(Constant.Result.CODED_CONTENT) ?: ""
|
||||
getUldInfo()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
diBangModel.cancelLooperGet()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.lukouguoji.gnc.page.fubang.list
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.databinding.ActivityDistributionHandoverBinding
|
||||
import com.lukouguoji.gnc.databinding.ActivityGncFubangListBinding
|
||||
import com.lukouguoji.gnc.databinding.ActivityShouyunListBinding
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.ktx.addOnItemClickListener
|
||||
import com.lukouguoji.module_base.ktx.getLifecycleOwner
|
||||
|
||||
class GncFuBangListActivity :
|
||||
BaseBindingActivity<ActivityGncFubangListBinding, GncFuBangListViewModel>() {
|
||||
|
||||
override fun layoutId() = R.layout.activity_gnc_fubang_list
|
||||
|
||||
override fun viewModelClass(): Class<GncFuBangListViewModel> {
|
||||
return GncFuBangListViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国内出港复磅")
|
||||
binding.viewModel = viewModel
|
||||
|
||||
viewModel.pageModel.bindSmartRefreshLayout(
|
||||
binding.srl,
|
||||
binding.rv,
|
||||
viewModel,
|
||||
getLifecycleOwner()
|
||||
)
|
||||
|
||||
binding.rv.addOnItemClickListener(viewModel)
|
||||
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
viewModel.refresh()
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
val starter = Intent(context, GncFuBangListActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.lukouguoji.gnc.page.fubang.list
|
||||
|
||||
import android.view.View
|
||||
import com.lukouguoji.gnc.databinding.ItemGncDistributionHandoverBinding
|
||||
import com.lukouguoji.gnc.databinding.ItemGncFuBangBinding
|
||||
import com.lukouguoji.gnc.databinding.ItemGncShouyunBinding
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.GncFuBangBean
|
||||
import com.lukouguoji.module_base.bean.GncShouYunBean
|
||||
|
||||
class GncFuBangListViewHolder(view: View) :
|
||||
BaseViewHolder<GncFuBangBean, ItemGncFuBangBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
val bean = getItemBean(item)!!
|
||||
binding.bean = bean
|
||||
|
||||
notifyItemClick(position, binding.ll)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package com.lukouguoji.gnc.page.fubang.list
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.page.fubang.details.GncFuBangDetailsActivity
|
||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
||||
import com.lukouguoji.module_base.bean.GncFuBangBean
|
||||
import com.lukouguoji.module_base.bean.GncShouYunBean
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.ktx.commonAdapter
|
||||
import com.lukouguoji.module_base.ktx.formatDate
|
||||
import com.lukouguoji.module_base.ktx.launchCollect
|
||||
import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
||||
import com.lukouguoji.module_base.ktx.showToast
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.lukouguoji.module_base.model.ScanModel
|
||||
import com.lukouguoji.module_base.util.DictUtils
|
||||
import com.lukouguoji.module_base.util.PrinterUtils
|
||||
import dev.utils.app.info.KeyValue
|
||||
import dev.utils.common.DateUtils
|
||||
import okhttp3.RequestBody
|
||||
|
||||
class GncFuBangListViewModel : BasePageViewModel() {
|
||||
|
||||
// 日期
|
||||
val date = MutableLiveData(DateUtils.getCurrentTime().formatDate())
|
||||
|
||||
val fno = MutableLiveData("")
|
||||
|
||||
// 目的港
|
||||
val dest = MutableLiveData("")
|
||||
val car = MutableLiveData("")
|
||||
val status = MutableLiveData("")
|
||||
val reWeightStatusList = MutableLiveData<List<KeyValue>>(DictUtils.reWeightStatusList)
|
||||
|
||||
//查询条件增加“全部“、”上舱单“、”未上舱单“查询功能,查询条件默认”全部“
|
||||
val mftFlag = MutableLiveData("")
|
||||
val copStatus = MutableLiveData("")
|
||||
val mftFlagList = MutableLiveData<List<KeyValue>>(DictUtils.mftFlagList)
|
||||
|
||||
|
||||
|
||||
// 数量
|
||||
val count = MutableLiveData("0")
|
||||
val totalPc = MutableLiveData("0")
|
||||
val totalWeight = MutableLiveData("0")
|
||||
val totalCCargoWeight = MutableLiveData("0")
|
||||
|
||||
val itemLayoutId = R.layout.item_gnc_fu_bang
|
||||
val itemViewHolder = GncFuBangListViewHolder::class.java
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
override fun getData() {
|
||||
val requestBody = mapOf(
|
||||
"pageNum" to pageModel.page,
|
||||
"pageSize" to pageModel.limit,
|
||||
"fdate" to date.value,
|
||||
"fno" to fno.value,
|
||||
"fdest" to dest.value,
|
||||
"checkFlag" to status.value,
|
||||
"mftFlag" to mftFlag.value,
|
||||
"copStatus" to copStatus.value,
|
||||
"carId" to car.value,
|
||||
).toRequestBody()
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getGncFuBangList(
|
||||
requestBody
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
pageModel.handleListBean(it)
|
||||
count.value = it.total.toString()
|
||||
totalPc.value = it.totalPc.toString()
|
||||
totalWeight.value = it.totalWeight.toString()
|
||||
totalCCargoWeight.value = it.totalCCargoWeight.toString()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onScanClick() {
|
||||
ScanModel.startScan(getTopActivity(), Constant.RequestCode.CAR)
|
||||
}
|
||||
|
||||
fun onAddClick() {
|
||||
GncFuBangDetailsActivity.start(getTopActivity(), "")
|
||||
}
|
||||
|
||||
override fun onItemClick(position: Int, type: Int) {
|
||||
val bean = pageModel.rv!!.commonAdapter()!!.getItem(position) as GncFuBangBean
|
||||
GncFuBangDetailsActivity.start(getTopActivity(), bean.carId)
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
when (requestCode) {
|
||||
Constant.RequestCode.CAR -> {
|
||||
car.value = data.getStringExtra(Constant.Result.CODED_CONTENT)
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.lukouguoji.gnc.page.query.details
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.databinding.ActivityGncQueryDetailsBinding
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.ktx.refresh
|
||||
|
||||
class GncQueryDetailsActivity :
|
||||
BaseBindingActivity<ActivityGncQueryDetailsBinding, GncQueryDetailsViewModel>() {
|
||||
|
||||
override fun layoutId() = R.layout.activity_gnc_query_details
|
||||
|
||||
override fun viewModelClass() = GncQueryDetailsViewModel::class.java
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国内出港运单详情")
|
||||
|
||||
viewModel.initOnCreated(intent)
|
||||
|
||||
binding.viewModel = viewModel
|
||||
|
||||
viewModel.list.observe(this) {
|
||||
binding.rv.refresh(it)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context, id: String) {
|
||||
val starter = Intent(context, GncQueryDetailsActivity::class.java)
|
||||
.putExtra(Constant.Key.ID, id)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.lukouguoji.gnc.page.query.details
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.view.View
|
||||
import com.lukouguoji.gnc.databinding.ItemGncQueryDetailsBinding
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.GncQueryDetailsBean
|
||||
|
||||
class GncQueryDetailsViewHolder(view: View) :
|
||||
BaseViewHolder<GncQueryDetailsBean.WhBean, ItemGncQueryDetailsBinding>(view) {
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
binding.bean = getItemBean(item)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.lukouguoji.gnc.page.query.details
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.module_base.base.BaseViewModel
|
||||
import com.lukouguoji.module_base.bean.GncQueryBean
|
||||
import com.lukouguoji.module_base.bean.GncQueryDetailsBean
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
|
||||
class GncQueryDetailsViewModel : BaseViewModel() {
|
||||
|
||||
var id = ""
|
||||
|
||||
val dataBean = MutableLiveData<GncQueryBean>()
|
||||
|
||||
val list = MutableLiveData<List<GncQueryDetailsBean.WhBean>>()
|
||||
|
||||
val viewHolder = GncQueryDetailsViewHolder::class.java
|
||||
val itemLayoutId = R.layout.item_gnc_query_details
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
fun initOnCreated(intent: Intent) {
|
||||
id = intent.getStringExtra(Constant.Key.ID) ?: ""
|
||||
|
||||
getData()
|
||||
}
|
||||
|
||||
private fun getData() {
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getGncQueryDetails(id)
|
||||
}) {
|
||||
onSuccess = {
|
||||
dataBean.value = it.data?.maWb ?: GncQueryBean()
|
||||
list.value = it.data?.whList ?: emptyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onFlowChartClick() {
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_CARGO_TRACKING)
|
||||
.withString("countryTypeParam", Constant.CargoTracking.gnStatus)
|
||||
.withString("ieFlagParam", Constant.CargoTracking.exportStatus)
|
||||
.withString("wbNoParam", dataBean.value!!.wbNo)
|
||||
.navigation()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.lukouguoji.gnc.page.query.list
|
||||
|
||||
import android.os.Bundle
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.databinding.ActivityGncQueryListBinding
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.ktx.addOnItemClickListener
|
||||
import com.lukouguoji.module_base.ktx.getLifecycleOwner
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_GNC_QUERY_LIST)
|
||||
class GncQueryListActivity :
|
||||
BaseBindingActivity<ActivityGncQueryListBinding, GncQueryListViewModel>() {
|
||||
override fun layoutId() = R.layout.activity_gnc_query_list
|
||||
|
||||
override fun viewModelClass() = GncQueryListViewModel::class.java
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国内出港查询")
|
||||
binding.viewModel = viewModel
|
||||
|
||||
viewModel.pageModel
|
||||
.bindSmartRefreshLayout(binding.srl, binding.rv, viewModel, getLifecycleOwner())
|
||||
binding.rv.addOnItemClickListener(viewModel)
|
||||
|
||||
viewModel.refresh()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.lukouguoji.gnc.page.query.list
|
||||
|
||||
import android.view.View
|
||||
import com.lukouguoji.gnc.databinding.ItemGncQueryListBinding
|
||||
import com.lukouguoji.gnc.databinding.ItemGncStashListBinding
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.GncQueryBean
|
||||
|
||||
class GncQueryListViewHolder(view: View) :
|
||||
BaseViewHolder<GncQueryBean, ItemGncQueryListBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
binding.bean = getItemBean(item)
|
||||
|
||||
notifyItemClick(position, binding.ll)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,298 @@
|
||||
package com.lukouguoji.gnc.page.query.list
|
||||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.alibaba.fastjson.JSONArray
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.page.query.details.GncQueryDetailsActivity
|
||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
||||
import com.lukouguoji.module_base.bean.GncQueryBean
|
||||
import com.lukouguoji.module_base.bean.SimpleCheckBean
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.ktx.commonAdapter
|
||||
import com.lukouguoji.module_base.ktx.formatDate
|
||||
import com.lukouguoji.module_base.ktx.launchCollect
|
||||
import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
||||
import com.lukouguoji.module_base.ktx.toJson
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.lukouguoji.module_base.model.PadFilterDialogModel
|
||||
import com.lukouguoji.module_base.model.PadFilterModel
|
||||
import com.lukouguoji.module_base.model.ScanModel
|
||||
import com.lukouguoji.module_base.ui.weight.search.layout.SearchLayoutType
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.lukouguoji.module_base.util.DictUtils
|
||||
import dev.DevUtils
|
||||
import dev.utils.app.info.KeyValue
|
||||
import dev.utils.common.DateUtils
|
||||
import okhttp3.RequestBody
|
||||
|
||||
class GncQueryListViewModel : BasePageViewModel() {
|
||||
|
||||
// 日期
|
||||
val date = MutableLiveData(DateUtils.getCurrentTime().formatDate())
|
||||
val dateEnd = MutableLiveData("")
|
||||
|
||||
// 运单号
|
||||
val waybill = MutableLiveData("")
|
||||
|
||||
// 运单号列表
|
||||
val wbNoList = MutableLiveData<List<String>>()
|
||||
|
||||
// 日期类型
|
||||
val dateType = MutableLiveData("0")
|
||||
val dateTypeList = MutableLiveData(
|
||||
listOf(
|
||||
KeyValue("入库", "0"),
|
||||
KeyValue("离港", "1"),
|
||||
)
|
||||
)
|
||||
|
||||
// 特码
|
||||
val spCode = MutableLiveData("")
|
||||
val spCodeList = MutableLiveData<List<KeyValue>>().apply {
|
||||
DictUtils.getSpecialCodeList(parentcode = "ALL") {
|
||||
value = it
|
||||
}
|
||||
}
|
||||
|
||||
// 代理
|
||||
val agent = MutableLiveData("")
|
||||
val agentList = MutableLiveData(listOf(KeyValue("占位", "1"))).apply {
|
||||
DictUtils.getGncAgentList {
|
||||
value = it
|
||||
}
|
||||
}
|
||||
|
||||
// 航班号
|
||||
val fNo = MutableLiveData("")
|
||||
|
||||
// 目的港
|
||||
val dest = MutableLiveData("")
|
||||
|
||||
// 运单类型
|
||||
val waybillType = MutableLiveData("")
|
||||
val waybillTypeList = MutableLiveData(listOf(KeyValue("占位", "1"))).apply {
|
||||
DictUtils.getWaybillTypeList2(ieFlag = "E", type = "Co") {
|
||||
value = it
|
||||
}
|
||||
}
|
||||
|
||||
// 业务类型
|
||||
val businessType = MutableLiveData("")
|
||||
val businessTypeList = MutableLiveData(listOf(KeyValue("占位", "1"))).apply {
|
||||
DictUtils.getBusinessTypeList(type = "CO") {
|
||||
value = it
|
||||
}
|
||||
}
|
||||
|
||||
// 危险品描述
|
||||
val wxDesc = MutableLiveData("")
|
||||
val wxDescList = MutableLiveData(listOf(KeyValue("占位", "1"))).apply {
|
||||
DictUtils.getWxDescList {
|
||||
value = listOf(KeyValue("全部", "")) + it
|
||||
}
|
||||
}
|
||||
|
||||
// 危险品库
|
||||
val wxKuType = MutableLiveData("")
|
||||
val wxKuTypeList = MutableLiveData(listOf(KeyValue("占位", "1"))).apply {
|
||||
DictUtils.getWxKuList {
|
||||
value = listOf(KeyValue("全部", "")) + it
|
||||
}
|
||||
}
|
||||
|
||||
// 品名
|
||||
val goodsName = MutableLiveData("")
|
||||
|
||||
val count = MutableLiveData(0)
|
||||
val number = MutableLiveData("0")
|
||||
val weight = MutableLiveData("0")
|
||||
|
||||
private val filterDialogModel: PadFilterDialogModel by lazy {
|
||||
PadFilterDialogModel(
|
||||
DevUtils.getTopActivity(), listOf(
|
||||
PadFilterModel(
|
||||
data = agent,
|
||||
title = "代理",
|
||||
hint = "请选择代理",
|
||||
type = SearchLayoutType.SPINNER,
|
||||
list = agentList
|
||||
),
|
||||
PadFilterModel(
|
||||
data = fNo,
|
||||
title = "航班号",
|
||||
hint = "请输入航班号",
|
||||
forcedCap = true
|
||||
),
|
||||
PadFilterModel(
|
||||
data = dest,
|
||||
title = "目的港",
|
||||
hint = "请输入目的港",
|
||||
forcedCap = true
|
||||
),
|
||||
PadFilterModel(
|
||||
data = waybillType,
|
||||
title = "运单类型",
|
||||
hint = "请选择运单类型",
|
||||
type = SearchLayoutType.SPINNER,
|
||||
list = waybillTypeList
|
||||
),
|
||||
PadFilterModel(
|
||||
data = businessType,
|
||||
title = "业务类型",
|
||||
hint = "请选择业务类型",
|
||||
type = SearchLayoutType.SPINNER,
|
||||
list = businessTypeList
|
||||
),
|
||||
PadFilterModel(
|
||||
data = wxDesc,
|
||||
title = "危险品描述",
|
||||
hint = "请选择危险品描述",
|
||||
type = SearchLayoutType.SPINNER,
|
||||
list = wxDescList
|
||||
),
|
||||
PadFilterModel(
|
||||
data = wxKuType,
|
||||
title = "危险品库",
|
||||
hint = "请选择危险品库",
|
||||
type = SearchLayoutType.SPINNER,
|
||||
list = wxKuTypeList
|
||||
),
|
||||
PadFilterModel(data = goodsName, title = "品名", hint = "请输入品名"),
|
||||
)
|
||||
) {
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
|
||||
val itemLayoutId = R.layout.item_gnc_query_list
|
||||
val itemViewHolder = GncQueryListViewHolder::class.java
|
||||
|
||||
val countDesc = MutableLiveData("合计:0条,总件数:0,总重量:0KG")
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
fun getWayBillList() {
|
||||
val body = mapOf(
|
||||
"page" to pageModel.page,
|
||||
"limit" to pageModel.limit,
|
||||
"beginDate" to date.value,
|
||||
"endDate" to dateEnd.value,
|
||||
// 日期类型
|
||||
"dateType" to dateType.value,
|
||||
"spCode" to spCode.value,
|
||||
"wbNo" to waybill.value,
|
||||
"agentCode" to agent.value,
|
||||
"fno" to fNo.value,
|
||||
"dest" to dest.value,
|
||||
"awbType" to waybillType.value,
|
||||
"businessType" to businessType.value,
|
||||
"dgrDetail" to wxDesc.value,
|
||||
"dgrLocation" to wxKuType.value,
|
||||
"goods" to goodsName.value,
|
||||
).toRequestBody()
|
||||
launchCollect({
|
||||
NetApply.api.getWbNoList(
|
||||
"/DomExpSearch/searchWbList",
|
||||
body
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
val results = it.data!!
|
||||
when {
|
||||
results.size == 1 -> {
|
||||
waybill.value = results[0]
|
||||
wbNoList.value = emptyList()
|
||||
}
|
||||
results.size > 1 -> {
|
||||
wbNoList.value = results
|
||||
showWbNoListSelect()
|
||||
}
|
||||
else -> {
|
||||
wbNoList.value = emptyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
onFailed = { i: Int, s: String ->
|
||||
wbNoList.value = emptyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getData() {
|
||||
val body = mapOf(
|
||||
"page" to pageModel.page,
|
||||
"limit" to pageModel.limit,
|
||||
"beginDate" to date.value,
|
||||
"endDate" to dateEnd.value,
|
||||
// 日期类型
|
||||
"dateType" to dateType.value,
|
||||
"spCode" to spCode.value,
|
||||
"wbNo" to waybill.value,
|
||||
"agentCode" to agent.value,
|
||||
"fno" to fNo.value,
|
||||
"dest" to dest.value,
|
||||
"awbType" to waybillType.value,
|
||||
"businessType" to businessType.value,
|
||||
"dgrDetail" to wxDesc.value,
|
||||
"dgrLocation" to wxKuType.value,
|
||||
"goods" to goodsName.value,
|
||||
).toRequestBody()
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getGncQueryList(
|
||||
body
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
it.data?.let { data ->
|
||||
pageModel.handleListBean(data)
|
||||
count.value = data.total
|
||||
getCountData(body)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getCountData(body: RequestBody) {
|
||||
launchCollect({
|
||||
NetApply.api.simplePost("DomExpSearch/searchTotal", body)
|
||||
}) {
|
||||
onSuccess = {
|
||||
number.value = it.data?.totalPc ?: "0"
|
||||
weight.value = it.data?.totalWeight ?: "0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onScanClick() {
|
||||
ScanModel.startScan(getTopActivity(), Constant.RequestCode.WAYBILL)
|
||||
}
|
||||
|
||||
fun onFilterClick() {
|
||||
filterDialogModel.show()
|
||||
}
|
||||
|
||||
override fun onItemClick(position: Int, type: Int) {
|
||||
val bean = pageModel.rv!!.commonAdapter()!!.getItem(position) as GncQueryBean
|
||||
GncQueryDetailsActivity.start(getTopActivity(), bean.mawbId)
|
||||
}
|
||||
|
||||
private fun showWbNoListSelect() {
|
||||
Common.singleSelect(
|
||||
DevUtils.getTopActivity(),
|
||||
"选择运单号",
|
||||
JSONArray.parseArray(wbNoList.value!!.map {
|
||||
mapOf(
|
||||
"name" to it,
|
||||
"code" to it,
|
||||
)
|
||||
}.toList().toJson(false)),
|
||||
null
|
||||
) { position, _ ->
|
||||
waybill.value = wbNoList.value!![position]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.lukouguoji.gnc.page.shouyun.details
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.databinding.ActivityGncShouYunDetailsBinding
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
|
||||
class GncShouYunDetailsActivity :
|
||||
BaseBindingActivity<ActivityGncShouYunDetailsBinding, GncShouYunDetailsViewModel>() {
|
||||
|
||||
override fun layoutId() = R.layout.activity_gnc_shou_yun_details
|
||||
|
||||
override fun viewModelClass() = GncShouYunDetailsViewModel::class.java
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("开始收运")
|
||||
viewModel.initOnCreated(intent)
|
||||
binding.viewModel = viewModel
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context, waybill: String) {
|
||||
val starter = Intent(context, GncShouYunDetailsActivity::class.java)
|
||||
.putExtra(Constant.Key.WAYBILL, waybill)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,408 @@
|
||||
package com.lukouguoji.gnc.page.shouyun.details
|
||||
|
||||
import android.app.Activity
|
||||
import android.bluetooth.BluetoothAdapter
|
||||
import android.content.Intent
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.observe
|
||||
import com.lukouguoji.gnc.page.shouyun.details.dialog.GncShouYunSyncDialogModel
|
||||
import com.lukouguoji.module_base.base.BaseViewModel
|
||||
import com.lukouguoji.module_base.bean.GncShouYunBean
|
||||
import com.lukouguoji.module_base.bean.ShouYunSyncBean
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.common.DetailsPageType
|
||||
import com.lukouguoji.module_base.db.perference.SharedPreferenceUtil
|
||||
import com.lukouguoji.module_base.http.net.DiBangWeightModel
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.ktx.launchCollect
|
||||
import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
||||
import com.lukouguoji.module_base.ktx.limit
|
||||
import com.lukouguoji.module_base.ktx.noNull
|
||||
import com.lukouguoji.module_base.ktx.showConfirmDialog
|
||||
import com.lukouguoji.module_base.ktx.showToast
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.lukouguoji.module_base.ktx.verifyNullOrEmpty
|
||||
import com.lukouguoji.module_base.model.BluetoothDialogModel
|
||||
import com.lukouguoji.module_base.model.ScanModel
|
||||
import com.lukouguoji.module_base.util.DictUtils
|
||||
import com.lukouguoji.module_base.util.PrinterUtils
|
||||
import dev.utils.app.info.KeyValue
|
||||
import okhttp3.RequestBody
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
class GncShouYunDetailsViewModel : BaseViewModel() {
|
||||
|
||||
val pageType = MutableLiveData(DetailsPageType.Add)
|
||||
|
||||
val channel = MutableLiveData("")
|
||||
|
||||
val dataBean = MutableLiveData(GncShouYunBean())
|
||||
|
||||
val showWeightEdit = MutableLiveData(false)
|
||||
|
||||
val channelList = MutableLiveData<List<KeyValue>>().apply {
|
||||
DictUtils.getChannelList {
|
||||
value = it
|
||||
}
|
||||
}
|
||||
val agentList = MutableLiveData<List<KeyValue>>().apply {
|
||||
DictUtils.getGncAgentList(addAll = false) {
|
||||
value = listOf(KeyValue("", "")) + it
|
||||
}
|
||||
}
|
||||
val spCodeList = MutableLiveData<List<KeyValue>>().apply {
|
||||
DictUtils.getSpecialCodeList(addAll = false, parentcode = "ALL") {
|
||||
value = listOf(KeyValue("", "")) + it
|
||||
}
|
||||
}
|
||||
val wxKuList = MutableLiveData<List<KeyValue>>().apply {
|
||||
DictUtils.getWxKuList {
|
||||
value = listOf(KeyValue("", "")) + it
|
||||
}
|
||||
}
|
||||
val wxDescList = MutableLiveData<List<KeyValue>>().apply {
|
||||
DictUtils.getWxDescListValue {
|
||||
value = listOf(KeyValue("", "")) + it
|
||||
}
|
||||
}
|
||||
|
||||
val packageTypeList = MutableLiveData<List<KeyValue>>().apply {
|
||||
DictUtils.getShouYunPackageTypeList {
|
||||
value = listOf(KeyValue("", "")) + it
|
||||
}
|
||||
}
|
||||
|
||||
val print = MutableLiveData(true)
|
||||
|
||||
|
||||
val diBangModel = DiBangWeightModel()
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
fun initOnCreated(intent: Intent) {
|
||||
dataBean.value!!.wbNo = intent.getStringExtra(Constant.Key.WAYBILL) ?: ""
|
||||
pageType.value =
|
||||
if (dataBean.value!!.wbNo.isEmpty()) DetailsPageType.Add else DetailsPageType.Modify
|
||||
|
||||
getDetails()
|
||||
|
||||
// 监听重量改变
|
||||
diBangModel.weight.observe(getTopActivity() as LifecycleOwner) {
|
||||
if (it.isNotEmpty()) {
|
||||
dataBean.value?.weight = it
|
||||
}
|
||||
}
|
||||
|
||||
channel.observe(getTopActivity() as LifecycleOwner) {
|
||||
diBangModel.key = it
|
||||
}
|
||||
}
|
||||
|
||||
fun getDetails() {
|
||||
val waybill = dataBean.value!!.wbNo
|
||||
if (dataBean.value!!.wbNo.isEmpty() || dataBean.value!!.wbNo.length != 11) return
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getGncShouYunDetails(waybill)
|
||||
}) {
|
||||
onSuccess = {
|
||||
it.data?.let { bean ->
|
||||
bean.weight = ""
|
||||
bean.pc = ""
|
||||
bean.volume = ""
|
||||
dataBean.value = bean
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun waybillScanClick() {
|
||||
ScanModel.startScan(getTopActivity(), Constant.RequestCode.WAYBILL)
|
||||
}
|
||||
|
||||
fun carScanClick() {
|
||||
ScanModel.startScan(getTopActivity(), Constant.RequestCode.CAR)
|
||||
}
|
||||
|
||||
fun uldScanClick() {
|
||||
ScanModel.startScan(getTopActivity(), Constant.RequestCode.ULD)
|
||||
}
|
||||
|
||||
fun onWeightLongClick(): Boolean {
|
||||
showWeightEdit.value = true
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取平板车信息
|
||||
*/
|
||||
fun getCarInfo() {
|
||||
if (dataBean.value!!.carNo.isEmpty()) {
|
||||
return
|
||||
}
|
||||
launchCollect({
|
||||
NetApply.api.getCarDetails(dataBean.value!!.carNo)
|
||||
}) {
|
||||
onSuccess = {
|
||||
dataBean.value?.carWeight = it.data?.carWeight ?: ""
|
||||
}
|
||||
|
||||
onFailed = { _, message ->
|
||||
showToast(message)
|
||||
dataBean.value?.carWeight = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getUldInfo() {
|
||||
if (dataBean.value!!.uld.isEmpty()) {
|
||||
return
|
||||
}
|
||||
launchCollect({
|
||||
NetApply.api.getUldDetails(dataBean.value!!.uld)
|
||||
}) {
|
||||
onSuccess = {
|
||||
it.data?.let { data ->
|
||||
dataBean.value?.uldWeight = data.uldWeight
|
||||
}
|
||||
}
|
||||
onFailed = { _, message ->
|
||||
showToast(message)
|
||||
dataBean.value?.uldWeight = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印挂签点击
|
||||
*/
|
||||
fun printClick() {
|
||||
if (!BluetoothAdapter.getDefaultAdapter().isEnabled) {
|
||||
showToast("请打开设备蓝牙")
|
||||
return
|
||||
}
|
||||
printShouYun(dataBean.value!!, false)
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验点击
|
||||
*/
|
||||
fun verifyClick() {
|
||||
if (dataBean.value!!.carWeight.isEmpty()) {
|
||||
showToast("平板车信息未维护,设备不可用!")
|
||||
return
|
||||
}
|
||||
val wFloat = dataBean.value?.weight.orEmpty().toFloatOrNull() ?: 0f
|
||||
val carFloat = dataBean.value?.carWeight.orEmpty().toFloatOrNull() ?: 0f
|
||||
if (abs(wFloat - carFloat) > (carFloat * 0.03)) {
|
||||
getTopActivity().showConfirmDialog("误差超过3%,是否覆盖?") {
|
||||
launchLoadingCollect({
|
||||
NetApply.api.simplePost(
|
||||
"/eqm/flatcar/updateFlatcar", mapOf(
|
||||
"carId" to dataBean.value!!.carNo,
|
||||
"carWeight" to wFloat.roundToInt(),
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
getCarInfo()
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
showToast("数据在误差范围内")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分斗点击
|
||||
*/
|
||||
fun apartClick() {
|
||||
if (!verifyData()) {
|
||||
return
|
||||
}
|
||||
launchLoadingCollect({
|
||||
NetApply.api.anyPost("DomExpCheckIn/divided", dataBean.value!!.toRequestBody(true))
|
||||
}) {
|
||||
onSuccess = {
|
||||
showToast(it.msg.noNull("分斗成功"))
|
||||
dataBean.value?.carNo = ""
|
||||
dataBean.value?.pc = ""
|
||||
dataBean.value?.weight = ""
|
||||
dataBean.value?.volume = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认点击
|
||||
*/
|
||||
fun confirmClick() {
|
||||
if (!verifyData()) {
|
||||
return
|
||||
}
|
||||
showSyncDialog(dataBean.value!!.wbNo)
|
||||
}
|
||||
|
||||
|
||||
private fun showSyncDialog(waybill: String) {
|
||||
val data = dataBean.value!!
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getShouYunSyncList(
|
||||
mapOf(
|
||||
"wbNo" to waybill
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
//相同板车号收运需要叠加
|
||||
var isAdd = true
|
||||
var dbPc = 0
|
||||
var dbWeight = 0.0
|
||||
var dbVolume = 0.0
|
||||
if (!data.carNo.isNullOrEmpty()){
|
||||
it.data?.forEach { t ->
|
||||
if (t.location.equals(data.carNo)){
|
||||
println("匹配到对应平板车,件数重量累加")
|
||||
isAdd = false
|
||||
dbPc = t.pc.toInt()
|
||||
dbWeight = t.weight.toDouble()
|
||||
dbVolume = t.volume.toDouble()
|
||||
t.pc = ((t.pc.toInt()).plus(data.pc.toInt())).toString()
|
||||
t.weight = ((t.weight.toDouble()).plus(data.weight.toDouble())).toString()
|
||||
t.volume = (t.volume.toDouble().plus(data.volume.toDouble())).toString()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
var list = (it.data ?: emptyList())
|
||||
if (isAdd){
|
||||
list = (it.data ?: emptyList()) + listOf(
|
||||
ShouYunSyncBean().apply {
|
||||
location = data.carNo
|
||||
pc = data.pc
|
||||
weight = data.weight
|
||||
volume = data.volume
|
||||
}
|
||||
)
|
||||
}
|
||||
GncShouYunSyncDialogModel(waybill, list) { model ->
|
||||
if (isAdd){
|
||||
val last = list.last()
|
||||
data.pc = last.pc
|
||||
data.weight = last.weight
|
||||
data.volume = last.volume
|
||||
list = list.subList(0, list.size - 1)
|
||||
}else{
|
||||
list.forEach {t ->
|
||||
if (t.location.equals(data.carNo)) {
|
||||
val pc = (t.pc.toInt()).minus(dbPc)
|
||||
val weight = (t.weight.toDouble()).minus(dbWeight)
|
||||
if (pc <= 0){
|
||||
showToast("本次收运件数少于等于0!")
|
||||
return@GncShouYunSyncDialogModel
|
||||
}
|
||||
if (weight <= 0){
|
||||
showToast("本次收运重量少于等于0!")
|
||||
return@GncShouYunSyncDialogModel
|
||||
}
|
||||
data.pc = pc.toString()
|
||||
data.weight = weight.toString()
|
||||
data.volume = (weight / 220f).limit(2)
|
||||
t.pc =dbPc.toString()
|
||||
t.weight=dbWeight.toString()
|
||||
t.volume = dbVolume.toString()
|
||||
}
|
||||
}
|
||||
}
|
||||
launchLoadingCollect({
|
||||
NetApply.api.anyPost(
|
||||
"DomExpCheckIn/updateWarehouseList",
|
||||
mapOf(
|
||||
"list" to list,
|
||||
"wb" to data
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = { b ->
|
||||
showToast(b.msg.noNull("同步成功"))
|
||||
println("------------onSuccess")
|
||||
dataBean.value = GncShouYunBean()
|
||||
}
|
||||
|
||||
}
|
||||
}.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 打印挂签
|
||||
*/
|
||||
private fun printShouYun(bean: GncShouYunBean, showSync: Boolean) {
|
||||
bean.location = bean.carNo
|
||||
bean.username = SharedPreferenceUtil.getString(Constant.Share.userName)
|
||||
BluetoothDialogModel()
|
||||
.showCallBack {
|
||||
PrinterUtils.printShouYun(bean)
|
||||
if (showSync) {
|
||||
showSyncDialog(bean.wbNo)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun verifyData(): Boolean {
|
||||
val bean = dataBean.value!!
|
||||
if (bean.wbNo.length != 11 || bean.mawbId.isEmpty()) {
|
||||
showToast("请输入正确的运单号")
|
||||
return false
|
||||
}
|
||||
if (bean.pc.verifyNullOrEmpty("请输入件数")
|
||||
|| bean.agentCode.verifyNullOrEmpty("请选择代理人")
|
||||
|| bean.spCode.verifyNullOrEmpty("请选择特码")
|
||||
|| bean.weight.verifyNullOrEmpty("请输入重量")
|
||||
|| bean.volume.verifyNullOrEmpty("请输入体积")
|
||||
) {
|
||||
return false
|
||||
}
|
||||
//●如果特码=DGR,则危险品库不能为空!
|
||||
if (bean.spCode.equals("DGR")){
|
||||
if (bean.dgrLocation.verifyNullOrEmpty("特码为DGR,危险品库不能为空!")){
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
when (requestCode) {
|
||||
Constant.RequestCode.WAYBILL -> {
|
||||
dataBean.value!!.wbNo = data.getStringExtra(Constant.Result.CODED_CONTENT) ?: ""
|
||||
getDetails()
|
||||
}
|
||||
|
||||
Constant.RequestCode.CAR -> {
|
||||
dataBean.value!!.carNo =
|
||||
data.getStringExtra(Constant.Result.CODED_CONTENT) ?: ""
|
||||
getCarInfo()
|
||||
}
|
||||
|
||||
Constant.RequestCode.ULD -> {
|
||||
dataBean.value!!.uld = data.getStringExtra(Constant.Result.CODED_CONTENT) ?: ""
|
||||
getUldInfo()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
diBangModel.cancelLooperGet()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
package com.lukouguoji.gnc.page.shouyun.details.dialog
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.databinding.DialogGncShouYunSyncBinding
|
||||
import com.lukouguoji.module_base.base.BaseDialogModel
|
||||
import com.lukouguoji.module_base.bean.GncQueryDetailsBean
|
||||
import com.lukouguoji.module_base.bean.ShouYunSyncBean
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.interfaces.ILoading
|
||||
import com.lukouguoji.module_base.ktx.launchCollect
|
||||
import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
||||
import com.lukouguoji.module_base.ktx.limit
|
||||
import com.lukouguoji.module_base.ktx.noNull
|
||||
import com.lukouguoji.module_base.ktx.refresh
|
||||
import com.lukouguoji.module_base.ktx.showToast
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.lxj.xpopup.XPopup
|
||||
import dev.DevUtils
|
||||
|
||||
class GncShouYunSyncDialogModel(
|
||||
val waybill:String,
|
||||
val list: List<ShouYunSyncBean>,
|
||||
val callBack: (GncShouYunSyncDialogModel) -> Unit
|
||||
) : BaseDialogModel<DialogGncShouYunSyncBinding>(DIALOG_TYPE_CENTER) {
|
||||
|
||||
override fun onBuild(builder: XPopup.Builder) {
|
||||
builder.dismissOnBackPressed(false)
|
||||
.dismissOnTouchOutside(false)
|
||||
.autoDismiss(false)
|
||||
}
|
||||
val viewHolder = GncShouYunSyncViewHolder::class.java
|
||||
val itemLayoutId = R.layout.item_gnc_shou_yun_sync
|
||||
val number = MutableLiveData("0")
|
||||
val weight = MutableLiveData("0")
|
||||
val newList = MutableLiveData<List<ShouYunSyncBean>>()
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.dialog_gnc_shou_yun_sync
|
||||
}
|
||||
|
||||
override fun onDialogCreated(context: Context) {
|
||||
binding.model = this
|
||||
var totalPc = 0;
|
||||
var totalWeight = 0.0 ;
|
||||
for (obj in list){
|
||||
obj.pcLiveData.value = obj.pc
|
||||
obj.weightLiveData.value = obj.weight
|
||||
totalPc += obj.pc.toInt()
|
||||
totalWeight += obj.weight.toDouble()
|
||||
}
|
||||
number.value = totalPc.toString()
|
||||
weight.value = totalWeight.toString()
|
||||
// 监听每个 item 的 pc 变化
|
||||
list.forEach { item ->
|
||||
item.pcLiveData.observeForever { newValue ->
|
||||
changePcTotal()
|
||||
}
|
||||
item.weightLiveData.observeForever { newValue ->
|
||||
item.weight = newValue.toString()
|
||||
item.volume = ((newValue.toFloatOrNull() ?: 0f) / 220f).limit(2)
|
||||
changeWeightTotal()
|
||||
}
|
||||
}
|
||||
binding.rv.refresh(list)
|
||||
|
||||
}
|
||||
|
||||
fun confirmClick() {
|
||||
for (obj in list){
|
||||
obj.pc = obj.pcLiveData.value.toString()
|
||||
obj.weight = obj.weightLiveData.value.toString()
|
||||
}
|
||||
|
||||
callBack.invoke(this)
|
||||
dismiss()
|
||||
}
|
||||
|
||||
fun changePcTotal(){
|
||||
println("changePcTotal...")
|
||||
var totalPc = 0;
|
||||
for (obj in list){
|
||||
if (obj.pcLiveData.value != ""){
|
||||
totalPc += obj.pcLiveData.value!!.toInt()
|
||||
}
|
||||
}
|
||||
number.value = totalPc.toString()
|
||||
}
|
||||
|
||||
|
||||
fun changeWeightTotal(){
|
||||
println("changeWeightTotal...")
|
||||
var totalWeight = 0.0 ;
|
||||
for (obj in list){
|
||||
if (obj.weight != ""){
|
||||
totalWeight += obj.weight.toDouble()
|
||||
}
|
||||
}
|
||||
weight.value = totalWeight.toString()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.lukouguoji.gnc.page.shouyun.details.dialog
|
||||
|
||||
import android.view.View
|
||||
import com.lukouguoji.gnc.databinding.DialogGncShouYunSyncBinding
|
||||
import com.lukouguoji.gnc.databinding.ItemGncShouYunSyncBinding
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.ShouYunSyncBean
|
||||
|
||||
class GncShouYunSyncViewHolder(view: View) :
|
||||
BaseViewHolder<ShouYunSyncBean, ItemGncShouYunSyncBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
val itemBean = getItemBean(item)!!
|
||||
binding.bean = itemBean
|
||||
// binding.ivIcon.setOnClickListener {
|
||||
// itemBean.checked.set(!itemBean.checked.get())
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.lukouguoji.gnc.page.shouyun.list
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.databinding.ActivityDistributionHandoverBinding
|
||||
import com.lukouguoji.gnc.databinding.ActivityShouyunListBinding
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.ktx.addOnItemClickListener
|
||||
import com.lukouguoji.module_base.ktx.getLifecycleOwner
|
||||
|
||||
class GncShouYunListActivity :
|
||||
BaseBindingActivity<ActivityShouyunListBinding, GncShouYunListViewModel>() {
|
||||
|
||||
override fun layoutId() = R.layout.activity_shouyun_list
|
||||
|
||||
override fun viewModelClass(): Class<GncShouYunListViewModel> {
|
||||
return GncShouYunListViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国内出港收运记录")
|
||||
binding.viewModel = viewModel
|
||||
|
||||
viewModel.pageModel.bindSmartRefreshLayout(
|
||||
binding.srl,
|
||||
binding.rv,
|
||||
viewModel,
|
||||
getLifecycleOwner()
|
||||
)
|
||||
|
||||
binding.rv.addOnItemClickListener(viewModel)
|
||||
|
||||
viewModel.refresh()
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
val starter = Intent(context, GncShouYunListActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.lukouguoji.gnc.page.shouyun.list
|
||||
|
||||
import android.view.View
|
||||
import com.lukouguoji.gnc.databinding.ItemGncDistributionHandoverBinding
|
||||
import com.lukouguoji.gnc.databinding.ItemGncShouyunBinding
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.GncShouYunBean
|
||||
|
||||
class GncShouYunListViewHolder(view: View) :
|
||||
BaseViewHolder<GncShouYunBean, ItemGncShouyunBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
val bean = getItemBean(item)!!
|
||||
binding.bean = bean
|
||||
|
||||
notifyItemClick(position, binding.shouyunItem)
|
||||
|
||||
binding.ivIcon.setOnClickListener {
|
||||
bean.checked.set(!bean.checked.get())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,281 @@
|
||||
package com.lukouguoji.gnc.page.shouyun.list
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.alibaba.fastjson.JSONArray
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.page.query.details.GncQueryDetailsActivity
|
||||
import com.lukouguoji.gnc.page.shouyun.details.dialog.GncShouYunSyncDialogModel
|
||||
import com.lukouguoji.gnc.page.stash.details.GncStashDetailsActivity
|
||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
||||
import com.lukouguoji.module_base.bean.GncShouYunBean
|
||||
import com.lukouguoji.module_base.bean.GncStashBean
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.ktx.commonAdapter
|
||||
import com.lukouguoji.module_base.ktx.formatDate
|
||||
import com.lukouguoji.module_base.ktx.launchCollect
|
||||
import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
||||
import com.lukouguoji.module_base.ktx.showToast
|
||||
import com.lukouguoji.module_base.ktx.toJson
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.lukouguoji.module_base.model.BluetoothDialogModel
|
||||
import com.lukouguoji.module_base.model.PadFilterDialogModel
|
||||
import com.lukouguoji.module_base.model.PadFilterModel
|
||||
import com.lukouguoji.module_base.model.ScanModel
|
||||
import com.lukouguoji.module_base.ui.weight.search.layout.SearchLayoutType
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.lukouguoji.module_base.util.DictUtils
|
||||
import com.lukouguoji.module_base.util.PrinterUtils
|
||||
import dev.DevUtils
|
||||
import dev.utils.app.info.KeyValue
|
||||
import dev.utils.common.DateUtils
|
||||
import okhttp3.RequestBody
|
||||
import java.util.Collections.emptyList
|
||||
|
||||
class GncShouYunListViewModel : BasePageViewModel() {
|
||||
|
||||
// 日期
|
||||
val date = MutableLiveData(DateUtils.getCurrentTime().formatDate())
|
||||
val fdate = MutableLiveData("")
|
||||
val fno = MutableLiveData("")
|
||||
|
||||
// 目的港
|
||||
val dest = MutableLiveData("")
|
||||
val waybill = MutableLiveData("")
|
||||
|
||||
// 代理
|
||||
val agentList = MutableLiveData<List<KeyValue>>().apply {
|
||||
DictUtils.getGncAgentList() {
|
||||
value = it
|
||||
}
|
||||
}
|
||||
var agent = MutableLiveData("")
|
||||
|
||||
// 特码
|
||||
val spCodeList = MutableLiveData<List<KeyValue>>().apply {
|
||||
DictUtils.getSpecialCodeList(parentcode = "ALL") {
|
||||
value = it
|
||||
}
|
||||
}
|
||||
var spCode = MutableLiveData("")
|
||||
|
||||
val wbNoList = MutableLiveData<List<String>>()
|
||||
|
||||
// 数量
|
||||
val count = MutableLiveData("0")
|
||||
val number = MutableLiveData("0")
|
||||
val weight = MutableLiveData("0")
|
||||
|
||||
val itemLayoutId = R.layout.item_gnc_shouyun
|
||||
val itemViewHolder = GncShouYunListViewHolder::class.java
|
||||
|
||||
private val filterModel by lazy {
|
||||
PadFilterDialogModel(
|
||||
getTopActivity(), listOf(
|
||||
PadFilterModel(spCode, "特码", "请选择特码", SearchLayoutType.SPINNER, spCodeList),
|
||||
PadFilterModel(
|
||||
dest,
|
||||
"目的港",
|
||||
"请输入目的港",
|
||||
SearchLayoutType.INPUT,
|
||||
forcedCap = true
|
||||
),
|
||||
)
|
||||
) {
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
fun getWayBillList() {
|
||||
val requestBody = mapOf(
|
||||
"page" to pageModel.page,
|
||||
"limit" to pageModel.limit,
|
||||
"opDate" to date.value,
|
||||
"agentCode" to agent.value,
|
||||
"spCode" to spCode.value,
|
||||
"wbNo" to waybill.value,
|
||||
"dest" to dest.value,
|
||||
"fdate" to fdate.value,
|
||||
"fno" to fno.value,
|
||||
).toRequestBody()
|
||||
launchCollect({
|
||||
NetApply.api.getGncShouYunWbNoList(requestBody)
|
||||
}) {
|
||||
onSuccess = {
|
||||
val results = it.data!!
|
||||
when {
|
||||
results.size == 1 -> {
|
||||
waybill.value = results[0]
|
||||
wbNoList.value = emptyList()
|
||||
}
|
||||
results.size > 1 -> {
|
||||
wbNoList.value = results
|
||||
showWbNoListSelect()
|
||||
}
|
||||
else -> {
|
||||
wbNoList.value = emptyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
onFailed = { _: Int, _: String ->
|
||||
wbNoList.value = emptyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showWbNoListSelect() {
|
||||
Common.singleSelect(
|
||||
DevUtils.getTopActivity(),
|
||||
"选择运单号",
|
||||
JSONArray.parseArray(wbNoList.value!!.map {
|
||||
mapOf(
|
||||
"name" to it,
|
||||
"code" to it,
|
||||
)
|
||||
}.toList().toJson(false)),
|
||||
null
|
||||
) { position, _ ->
|
||||
waybill.value = wbNoList.value!![position]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun getData() {
|
||||
val requestBody = mapOf(
|
||||
"page" to pageModel.page,
|
||||
"limit" to pageModel.limit,
|
||||
"opDate" to date.value,
|
||||
"agentCode" to agent.value,
|
||||
"spCode" to spCode.value,
|
||||
"wbNo" to waybill.value,
|
||||
"dest" to dest.value,
|
||||
"fdate" to fdate.value,
|
||||
"fno" to fno.value,
|
||||
).toRequestBody()
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getGncShouYunList(
|
||||
requestBody
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
pageModel.handleListBean(it)
|
||||
count.value = it.total.toString()
|
||||
getCountData(requestBody)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getCountData(requestBody: RequestBody) {
|
||||
launchCollect({
|
||||
NetApply.api.simplePost("DomExpCheckIn/total", requestBody)
|
||||
}) {
|
||||
onSuccess = {
|
||||
number.value = it.data?.pc ?: "0"
|
||||
weight.value = it.data?.weight ?: "0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onScanClick() {
|
||||
ScanModel.startScan(getTopActivity(), Constant.RequestCode.WAYBILL)
|
||||
}
|
||||
|
||||
fun filterClick(){
|
||||
filterModel.show()
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击
|
||||
*/
|
||||
fun onConfirmClick() {
|
||||
val list = (pageModel.rv?.commonAdapter()?.items?.filter {
|
||||
(it as GncShouYunBean).checked.get()
|
||||
} ?: emptyList()) as List<GncShouYunBean>
|
||||
if (list.isEmpty()) {
|
||||
showToast("请选择需要打印的数据")
|
||||
return
|
||||
}
|
||||
BluetoothDialogModel()
|
||||
.showCallBack {
|
||||
list.forEach {
|
||||
PrinterUtils.printShouYun(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onItemClick(position: Int, type: Int) {
|
||||
println("GNCShouYunListViewModel国内出港收运记录 onItemClick...")
|
||||
val bean = pageModel.rv!!.commonAdapter()!!.getItem(position) as GncShouYunBean
|
||||
GncStashDetailsActivity.start(getTopActivity(), bean.whId)
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
when (requestCode) {
|
||||
Constant.RequestCode.WAYBILL -> {
|
||||
waybill.value = data.getStringExtra(Constant.Result.CODED_CONTENT)
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示重新同步
|
||||
*/
|
||||
fun showSyncDialog() {
|
||||
|
||||
val list =
|
||||
(pageModel.rv!!.commonAdapter()!!.items as List<GncShouYunBean>).filter { it.checked.get() }
|
||||
if (list.isEmpty()) {
|
||||
showToast("请选择需要重新同步的数据")
|
||||
return
|
||||
}
|
||||
val no = list.get(0).wbNo
|
||||
|
||||
for (obj in list){
|
||||
if (no != obj.wbNo){
|
||||
showToast("只能选择相同运单号的数据进行同步")
|
||||
return
|
||||
}
|
||||
}
|
||||
var loactionList = list.map { it.location }
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getShouYunSyncList(
|
||||
mapOf(
|
||||
"wbNo" to no
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
val ShouYunSyncBeanlist = (it.data ?: emptyList())
|
||||
|
||||
val list1 = ShouYunSyncBeanlist.filter { loactionList.contains(it.location) }
|
||||
GncShouYunSyncDialogModel(no, list1) { model ->
|
||||
println(model.list)
|
||||
launchLoadingCollect({
|
||||
NetApply.api.anyPost(
|
||||
"DomExpCheckIn/reUpdateAgt",
|
||||
mapOf(
|
||||
"list" to model.list
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = { b ->
|
||||
showToast("重新同步成功")
|
||||
}
|
||||
}
|
||||
}.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.lukouguoji.gnc.page.shouyun.unlist
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.text.TextWatcher
|
||||
import android.widget.EditText
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.databinding.ActivityShouyunListBinding
|
||||
import com.lukouguoji.gnc.databinding.ActivityShouyunUnListBinding
|
||||
import com.lukouguoji.gnc.page.shouyun.list.GncShouYunListActivity
|
||||
import com.lukouguoji.gnc.page.shouyun.list.GncShouYunListViewModel
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.ktx.addOnItemClickListener
|
||||
import com.lukouguoji.module_base.ktx.getLifecycleOwner
|
||||
|
||||
class GncShouYunUnListActivity :
|
||||
BaseBindingActivity<ActivityShouyunUnListBinding, GncShouYunUnListViewModel>() {
|
||||
|
||||
override fun layoutId() = R.layout.activity_shouyun_un_list
|
||||
|
||||
override fun viewModelClass(): Class<GncShouYunUnListViewModel> {
|
||||
return GncShouYunUnListViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国内出港待收运")
|
||||
binding.viewModel = viewModel
|
||||
|
||||
viewModel.pageModel.bindSmartRefreshLayout(
|
||||
binding.srl,
|
||||
binding.rv,
|
||||
viewModel,
|
||||
getLifecycleOwner()
|
||||
)
|
||||
|
||||
binding.rv.addOnItemClickListener(viewModel)
|
||||
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
viewModel.refresh()
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
val starter = Intent(context, GncShouYunUnListActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.lukouguoji.gnc.page.shouyun.unlist
|
||||
|
||||
import android.view.View
|
||||
import com.lukouguoji.gnc.databinding.ItemGncDistributionHandoverBinding
|
||||
import com.lukouguoji.gnc.databinding.ItemGncShouyunBinding
|
||||
import com.lukouguoji.gnc.databinding.ItemGncShouyunUnBinding
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.GncShouYunBean
|
||||
|
||||
class GncShouYunUnListViewHolder(view: View) :
|
||||
BaseViewHolder<GncShouYunBean, ItemGncShouyunUnBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
val itemBean = getItemBean(item)!!
|
||||
binding.bean = itemBean
|
||||
|
||||
notifyItemClick(position, binding.ll)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
package com.lukouguoji.gnc.page.shouyun.unlist
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.alibaba.fastjson.JSONArray
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.page.shouyun.details.GncShouYunDetailsActivity
|
||||
import com.lukouguoji.gnc.page.shouyun.list.GncShouYunListActivity
|
||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
||||
import com.lukouguoji.module_base.bean.GncShouYunBean
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.ktx.commonAdapter
|
||||
import com.lukouguoji.module_base.ktx.formatDate
|
||||
import com.lukouguoji.module_base.ktx.launchCollect
|
||||
import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
||||
import com.lukouguoji.module_base.ktx.loge
|
||||
import com.lukouguoji.module_base.ktx.toJson
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.lukouguoji.module_base.model.PadFilterDialogModel
|
||||
import com.lukouguoji.module_base.model.PadFilterModel
|
||||
import com.lukouguoji.module_base.model.ScanModel
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.lukouguoji.module_base.util.DictUtils
|
||||
import dev.DevUtils
|
||||
import dev.utils.app.info.KeyValue
|
||||
import dev.utils.common.DateUtils
|
||||
|
||||
class GncShouYunUnListViewModel : BasePageViewModel() {
|
||||
|
||||
// 日期
|
||||
val date = MutableLiveData(DateUtils.getCurrentTime().formatDate())
|
||||
|
||||
// 航班号
|
||||
val fno = MutableLiveData("")
|
||||
|
||||
// 运单号
|
||||
val waybill = MutableLiveData("")
|
||||
val dest = MutableLiveData("")
|
||||
|
||||
// 代理
|
||||
val agentList = MutableLiveData<List<KeyValue>>().apply {
|
||||
DictUtils.getGncAgentList() {
|
||||
value = it
|
||||
}
|
||||
}
|
||||
var agent = MutableLiveData("")
|
||||
|
||||
// 特码
|
||||
val spCodeList = MutableLiveData<List<KeyValue>>().apply {
|
||||
DictUtils.getSpecialCodeList(parentcode = "ALL") {
|
||||
value = it
|
||||
}
|
||||
}
|
||||
var spCode = MutableLiveData("")
|
||||
|
||||
val wbNoList = MutableLiveData<List<String>>()
|
||||
|
||||
|
||||
val itemLayoutId = R.layout.item_gnc_shouyun_un
|
||||
val itemViewHolder = GncShouYunUnListViewHolder::class.java
|
||||
|
||||
// 数量
|
||||
val count = MutableLiveData("0")
|
||||
|
||||
private val filterDialog by lazy {
|
||||
PadFilterDialogModel(
|
||||
getTopActivity(), listOf(
|
||||
PadFilterModel(dest, title = "目的港", hint = "请输入目的港", forcedCap = true)
|
||||
)
|
||||
) {
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
|
||||
fun getWayBillList() {
|
||||
val requestBody = mapOf(
|
||||
"pageNum" to pageModel.page,
|
||||
"pageSize" to pageModel.limit,
|
||||
"fdate" to date.value,
|
||||
"fno" to fno.value,
|
||||
"agentCode" to agent.value,
|
||||
"spCode" to spCode.value,
|
||||
"dest" to dest.value,
|
||||
"wbNo" to waybill.value
|
||||
).toRequestBody()
|
||||
launchCollect({
|
||||
NetApply.api.getGncShouYunUnWbNoList(
|
||||
requestBody
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
val results = it.data!!
|
||||
when {
|
||||
results.size == 1 -> {
|
||||
waybill.value = results[0]
|
||||
wbNoList.value = emptyList()
|
||||
}
|
||||
results.size > 1 -> {
|
||||
wbNoList.value = results
|
||||
showWbNoListSelect()
|
||||
}
|
||||
else -> {
|
||||
wbNoList.value = emptyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
onFailed = { i: Int, s: String ->
|
||||
wbNoList.value = emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun showWbNoListSelect() {
|
||||
Common.singleSelect(
|
||||
DevUtils.getTopActivity(),
|
||||
"选择运单号",
|
||||
JSONArray.parseArray(wbNoList.value!!.map {
|
||||
mapOf(
|
||||
"name" to it,
|
||||
"code" to it,
|
||||
)
|
||||
}.toList().toJson(false)),
|
||||
null
|
||||
) { position, _ ->
|
||||
waybill.value = wbNoList.value!![position]
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
override fun getData() {
|
||||
val requestBody = mapOf(
|
||||
"pageNum" to pageModel.page,
|
||||
"pageSize" to pageModel.limit,
|
||||
"fdate" to date.value,
|
||||
"fno" to fno.value,
|
||||
"agentCode" to agent.value,
|
||||
"spCode" to spCode.value,
|
||||
"wbNo" to waybill.value,
|
||||
"dest" to dest.value,
|
||||
).toRequestBody()
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getGncShouYunUnList(
|
||||
requestBody
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
pageModel.handleListBean(it)
|
||||
count.value = it.total.toString()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onScanClick() {
|
||||
ScanModel.startScan(getTopActivity(), Constant.RequestCode.WAYBILL)
|
||||
}
|
||||
|
||||
fun onFilterClick() {
|
||||
filterDialog.show()
|
||||
}
|
||||
|
||||
fun onAddClick() {
|
||||
GncShouYunDetailsActivity.start(getTopActivity(), "")
|
||||
}
|
||||
|
||||
override fun onItemClick(position: Int, type: Int) {
|
||||
val adapter = pageModel.rv!!.commonAdapter()!!
|
||||
val bean = adapter.getItem(position) as GncShouYunBean
|
||||
when (type) {
|
||||
R.id.ll -> {
|
||||
GncShouYunDetailsActivity.start(getTopActivity(), bean.wbNo)
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击
|
||||
*/
|
||||
fun onShouYunClick() {
|
||||
GncShouYunListActivity.start(getTopActivity())
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (resultCode == AppCompatActivity.RESULT_OK && data != null) {
|
||||
when (requestCode) {
|
||||
Constant.RequestCode.WAYBILL -> {
|
||||
waybill.value = data.getStringExtra(Constant.Result.CODED_CONTENT)
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.lukouguoji.gnc.page.stash.details
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.databinding.ActivityGncStashDetailsBinding
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
|
||||
class GncStashDetailsActivity :
|
||||
BaseBindingActivity<ActivityGncStashDetailsBinding, GncStashDetailsViewModel>() {
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.activity_gnc_stash_details
|
||||
}
|
||||
|
||||
override fun viewModelClass(): Class<GncStashDetailsViewModel> {
|
||||
return GncStashDetailsViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国内出港运单详情")
|
||||
viewModel.initOnCreated(intent)
|
||||
binding.viewModel = viewModel
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context, whId: String) {
|
||||
val starter = Intent(context, GncStashDetailsActivity::class.java)
|
||||
.putExtra(Constant.Key.ID, whId)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.lukouguoji.gnc.page.stash.details
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.module_base.base.BaseViewModel
|
||||
import com.lukouguoji.module_base.bean.GncStashBean
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
||||
import com.lukouguoji.module_base.util.DictUtils
|
||||
import dev.utils.app.info.KeyValue
|
||||
|
||||
class GncStashDetailsViewModel : BaseViewModel() {
|
||||
|
||||
var id = ""
|
||||
|
||||
// 详情信息
|
||||
val dataBean = MutableLiveData<GncStashBean>()
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
fun initOnCreated(intent: Intent) {
|
||||
id = intent.getStringExtra(Constant.Key.ID) ?: ""
|
||||
|
||||
getData()
|
||||
}
|
||||
|
||||
private fun getData() {
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getGncStashDetails(id)
|
||||
}) {
|
||||
onSuccess = {
|
||||
dataBean.value = it.data ?: GncStashBean()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.lukouguoji.gnc.page.stash.list
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.databinding.ActivityGncStashListBinding
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.ktx.addOnItemClickListener
|
||||
import com.lukouguoji.module_base.ktx.getLifecycleOwner
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_GNC_WAREHOUSE)
|
||||
class GncStashListActivity :
|
||||
BaseBindingActivity<ActivityGncStashListBinding, GncStashListViewModel>() {
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.activity_gnc_stash_list
|
||||
}
|
||||
|
||||
override fun viewModelClass(): Class<GncStashListViewModel> {
|
||||
return GncStashListViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国内出港仓库")
|
||||
binding.viewModel = viewModel
|
||||
|
||||
viewModel.pageModel
|
||||
.bindSmartRefreshLayout(binding.srl, binding.rv, viewModel, getLifecycleOwner())
|
||||
binding.rv.addOnItemClickListener(viewModel)
|
||||
|
||||
viewModel.refresh()
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
val starter = Intent(context, GncStashListActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.lukouguoji.gnc.page.stash.list
|
||||
|
||||
import android.view.View
|
||||
import com.lukouguoji.gnc.databinding.ItemGncStashListBinding
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.GncStashBean
|
||||
|
||||
class GncStashListViewHolder(view: View) :
|
||||
BaseViewHolder<GncStashBean, ItemGncStashListBinding>(view) {
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
binding.bean = getItemBean(item)
|
||||
|
||||
notifyItemClick(position, binding.ll)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
package com.lukouguoji.gnc.page.stash.list
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.alibaba.fastjson.JSONArray
|
||||
import com.lukouguoji.gnc.R
|
||||
import com.lukouguoji.gnc.page.stash.details.GncStashDetailsActivity
|
||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
||||
import com.lukouguoji.module_base.bean.GncStashBean
|
||||
import com.lukouguoji.module_base.bean.SimpleCheckBean
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.ktx.commonAdapter
|
||||
import com.lukouguoji.module_base.ktx.formatDate
|
||||
import com.lukouguoji.module_base.ktx.launchCollect
|
||||
import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
||||
import com.lukouguoji.module_base.ktx.loge
|
||||
import com.lukouguoji.module_base.ktx.noNull
|
||||
import com.lukouguoji.module_base.ktx.toJson
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.lukouguoji.module_base.model.PadFilterDialogModel
|
||||
import com.lukouguoji.module_base.model.PadFilterModel
|
||||
import com.lukouguoji.module_base.model.ScanModel
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import dev.DevUtils
|
||||
import dev.utils.app.info.KeyValue
|
||||
import dev.utils.common.DateUtils
|
||||
import okhttp3.RequestBody
|
||||
|
||||
class GncStashListViewModel : BasePageViewModel() {
|
||||
|
||||
// 日期
|
||||
val date = MutableLiveData(DateUtils.getCurrentTime().formatDate())
|
||||
val dateEnd = MutableLiveData("")
|
||||
|
||||
val fNo = MutableLiveData("")
|
||||
val dest = MutableLiveData("")
|
||||
|
||||
// 运单号
|
||||
val waybill = MutableLiveData("")
|
||||
|
||||
// 运单号列表
|
||||
val wbNoList = MutableLiveData<List<String>>()
|
||||
|
||||
// 排列方式
|
||||
val sortType = MutableLiveData("0")
|
||||
val sortTypeList = MutableLiveData(
|
||||
listOf(
|
||||
KeyValue("入库时间", "0"),
|
||||
KeyValue("航程", "1"),
|
||||
KeyValue("库位", "2"),
|
||||
)
|
||||
)
|
||||
|
||||
// 上舱状态
|
||||
val status = MutableLiveData("")
|
||||
val statusList = MutableLiveData(
|
||||
listOf(
|
||||
KeyValue("全部", ""),
|
||||
KeyValue("未上舱", "0"),
|
||||
KeyValue("已上舱", "1"),
|
||||
)
|
||||
)
|
||||
|
||||
val itemLayoutId = R.layout.item_gnc_stash_list
|
||||
val itemViewHolder = GncStashListViewHolder::class.java
|
||||
|
||||
private val filterDialogModel: PadFilterDialogModel by lazy {
|
||||
PadFilterDialogModel(
|
||||
DevUtils.getTopActivity(), listOf(
|
||||
PadFilterModel(
|
||||
data = fNo,
|
||||
title = "航班号",
|
||||
hint = "请输入航班号",
|
||||
forcedCap = true
|
||||
),
|
||||
PadFilterModel(
|
||||
data = dest,
|
||||
title = "目的港",
|
||||
hint = "请输入目的港",
|
||||
forcedCap = true
|
||||
),
|
||||
)
|
||||
) {
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
|
||||
val countDesc = MutableLiveData("合计:0条,总件数:0,总重量:0KG")
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
fun onScanClick() {
|
||||
ScanModel.startScan(getTopActivity(), Constant.RequestCode.WAYBILL)
|
||||
}
|
||||
|
||||
fun onFilterClick() {
|
||||
filterDialogModel.show()
|
||||
}
|
||||
|
||||
fun getWayBillList() {
|
||||
val requestBody = mapOf(
|
||||
"page" to pageModel.page,
|
||||
"limit" to pageModel.limit,
|
||||
"beginDate" to date.value,
|
||||
"endDate" to dateEnd.value,
|
||||
"locStatus" to status.value,
|
||||
"wbNo" to waybill.value,
|
||||
"fno" to fNo.value,
|
||||
"dest" to dest.value,
|
||||
).toRequestBody()
|
||||
launchCollect({
|
||||
NetApply.api.getWbNoList(
|
||||
"/DomExpWareHouse/searchWbList",
|
||||
requestBody
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
val results = it.data!!
|
||||
when {
|
||||
results.size == 1 -> {
|
||||
waybill.value = results[0]
|
||||
wbNoList.value = emptyList()
|
||||
}
|
||||
results.size > 1 -> {
|
||||
wbNoList.value = results
|
||||
showWbNoListSelect()
|
||||
}
|
||||
else -> {
|
||||
wbNoList.value = emptyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
onFailed = { i: Int, s: String ->
|
||||
wbNoList.value = emptyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getData() {
|
||||
val requestBody = mapOf(
|
||||
"page" to pageModel.page,
|
||||
"limit" to pageModel.limit,
|
||||
"beginDate" to date.value,
|
||||
"endDate" to dateEnd.value,
|
||||
"orderBy" to sortType.value,
|
||||
"locStatus" to status.value,
|
||||
"wbNo" to waybill.value,
|
||||
"fno" to fNo.value,
|
||||
"dest" to dest.value,
|
||||
).toRequestBody()
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getGncStashList(requestBody)
|
||||
}) {
|
||||
onSuccess = {
|
||||
pageModel.handleListBean(it)
|
||||
getCountData(requestBody)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getCountData(requestBody: RequestBody) {
|
||||
launchCollect({
|
||||
NetApply.api.simplePost("DomExpWareHouse/total", requestBody)
|
||||
}) {
|
||||
onSuccess = {
|
||||
countDesc.value =
|
||||
"合计:${it.data?.total}条,总件数:${it.data?.pc},总重量:${it.data?.weight}KG"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onItemClick(position: Int, type: Int) {
|
||||
println("onItemClick...")
|
||||
val bean = pageModel.rv!!.commonAdapter()!!.getItem(position) as GncStashBean
|
||||
GncStashDetailsActivity.start(getTopActivity(), bean.whId)
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||
when (requestCode) {
|
||||
Constant.RequestCode.WAYBILL -> {
|
||||
val id = data.getStringExtra(Constant.Result.CODED_CONTENT).noNull()
|
||||
waybill.value = id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private fun showWbNoListSelect() {
|
||||
Common.singleSelect(
|
||||
DevUtils.getTopActivity(),
|
||||
"选择运单号",
|
||||
JSONArray.parseArray(wbNoList.value!!.map {
|
||||
mapOf(
|
||||
"name" to it,
|
||||
"code" to it,
|
||||
)
|
||||
}.toList().toJson(false)),
|
||||
null
|
||||
) { position, _ ->
|
||||
waybill.value = wbNoList.value!![position]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.lukouguoji.gnc.viewModel
|
||||
|
||||
import android.util.Log
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.Transformations
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.liveData
|
||||
import com.alibaba.fastjson.JSONObject
|
||||
import com.lukouguoji.module_base.http.user.UserNetwork
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
||||
class GncQueryInfoViewModel : ViewModel() {
|
||||
|
||||
private val logName = "GncQueryInfoViewModel"
|
||||
|
||||
var wayBillInfo = JSONObject()
|
||||
var wbNo: String? = null
|
||||
|
||||
/**
|
||||
* 出港查询详情
|
||||
*/
|
||||
inner class WaybillParam(val wbId: Int, val wbNo: String?)
|
||||
|
||||
private val wbIdData = MutableLiveData<WaybillParam>()
|
||||
val waybillLiveData = Transformations.switchMap(wbIdData) { param ->
|
||||
liveData(Dispatchers.IO) {
|
||||
try {
|
||||
var response = JSONObject()
|
||||
if (param.wbId != -9999) {
|
||||
response = UserNetwork.searchByIdGncQuery(param.wbId)
|
||||
} else if (param.wbNo != null) {
|
||||
response = UserNetwork.searchByWbNoGncQuery(param.wbNo)
|
||||
} else {
|
||||
}
|
||||
emit(response)
|
||||
} catch (e: Exception) {
|
||||
Log.e(logName, e.stackTraceToString())
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fun queryWaybillById(wbId: Int, wbNo: String?) {
|
||||
wbIdData.value = WaybillParam(wbId, wbNo)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user