init: init proj
This commit is contained in:
1
module_p/.gitignore
vendored
Normal file
1
module_p/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
||||
57
module_p/build.gradle
Normal file
57
module_p/build.gradle
Normal file
@@ -0,0 +1,57 @@
|
||||
plugins {
|
||||
id 'com.android.library'
|
||||
id 'org.jetbrains.kotlin.android'
|
||||
id 'kotlin-kapt'
|
||||
}
|
||||
|
||||
kapt {
|
||||
arguments {
|
||||
arg("AROUTER_MODULE_NAME", project.getName())
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'com.sixin.module_p'
|
||||
compileSdk 34
|
||||
|
||||
defaultConfig {
|
||||
minSdk 24
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles "consumer-rules.pro"
|
||||
}
|
||||
|
||||
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'
|
||||
}
|
||||
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'
|
||||
|
||||
}
|
||||
0
module_p/consumer-rules.pro
Normal file
0
module_p/consumer-rules.pro
Normal file
21
module_p/proguard-rules.pro
vendored
Normal file
21
module_p/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.sixin.module_p
|
||||
|
||||
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.sixin.module_p.test", appContext.packageName)
|
||||
}
|
||||
}
|
||||
125
module_p/src/main/AndroidManifest.xml
Normal file
125
module_p/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,125 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<application>
|
||||
<activity
|
||||
android:name=".ui.set.PdaSetActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".ui.lihuo.PdaLiHuoActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".ui.zuzhuang.PdaZuZhuangActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".ui.guobang.PdaGuoBangActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".ui.shouyun.PdaShouYunActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".ui.enter.PDAEnterActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".ui.enter.gn.document.PdaDocumentHandoverActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".ui.gnc.shouyun.un.list.GncUnShouYunActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".ui.gnc.shouyun.list.PdaGncShouYunActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.sixin.module_p.ui.gnc.shouyun.add.PdaShouYunAddActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.sixin.module_p.ui.gnc.fubang.add.PdaGncFuBangAddActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.sixin.module_p.ui.gnc.cunfang.list.PdaGncCunFangListActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.sixin.module_p.ui.gnc.cunfang.add.PdaGncCunFangAddActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.sixin.module_p.ui.gnj.xieji.list.PdaGnjXieJiListActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.sixin.module_p.ui.gnj.xieji.add.PdaGnjXieJiAddActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity android:name=".ui.gnj.xieji.details.PdaGnjXieJiDetailsActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.sixin.module_p.ui.gnj.accidentVisa.list.PdaAccidentVisaListActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.sixin.module_p.ui.gnj.accidentVisa.add.PdaAccidentVisaAddActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.sixin.module_p.ui.goods.transport.list.PdaGoodsTransportListActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.sixin.module_p.ui.goods.transport.add.PdaGoodsTransportAddActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.sixin.module_p.ui.goods.transportLog.list.PdaTransportLogActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.sixin.module_p.ui.user.about.PdaAboutUsActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name="com.sixin.module_p.ui.user.message.PdaMessageListActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity android:name="com.lukouguoji.gnc.page.stash.details.GncPdaStashDetailsActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.sixin.module_p.base
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import androidx.databinding.ViewDataBinding
|
||||
import androidx.lifecycle.ViewModel
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.helper.PDAHelper
|
||||
import me.jessyan.autosize.internal.CustomAdapt
|
||||
|
||||
abstract class BasePdaActivity<T : ViewDataBinding, VM : ViewModel> : BaseBindingActivity<T, VM>(),
|
||||
CustomAdapt {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
findViewById<TextView>(R.id.tool_tv_back)?.visibility = View.INVISIBLE
|
||||
}
|
||||
|
||||
override fun isBaseOnWidth() = true
|
||||
|
||||
override fun getSizeInDp(): Float = PDAHelper.PDA_WIDTH
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.sixin.module_p.helper
|
||||
|
||||
import dev.utils.common.NumberUtils
|
||||
|
||||
object PDAHelper {
|
||||
|
||||
const val PDA_WIDTH = 400f
|
||||
|
||||
/**
|
||||
* 根据扫描的数据,获取运单号/运单号+件号
|
||||
* 返回空字符串则获取失败
|
||||
*/
|
||||
fun getWaybillFormScan(data: String): String {
|
||||
if (NumberUtils.isNumber(data)) {
|
||||
if (data.length == 11 || data.length == 16) {
|
||||
return data
|
||||
}
|
||||
} else if (data.length > 16 && data.contains("/")) {
|
||||
val substring = data.substring(data.lastIndexOf("/"))
|
||||
if (substring.length == 11) {
|
||||
return substring
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.sixin.module_p.holder
|
||||
|
||||
import android.view.View
|
||||
import com.lukouguoji.module_base.adapter.visible
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.base.CommonAdapter
|
||||
import com.lukouguoji.module_base.bean.GjcWaybillBean
|
||||
import com.lukouguoji.module_base.bean.GjjHandoverRecordBean
|
||||
import com.lukouguoji.module_base.bean.GjjTallyAddBean
|
||||
import com.lukouguoji.module_base.ktx.refresh
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.databinding.ItemPdaLhBinding
|
||||
import com.sixin.module_p.databinding.ItemPdaLhSelectBinding
|
||||
import com.sixin.module_p.databinding.ItemPdaZuZhuangBinding
|
||||
import com.sixin.module_p.databinding.ItemPdaZzSelectBinding
|
||||
import com.sixin.module_p.ui.zuzhuang.holder.PdaJianViewHolder
|
||||
|
||||
class PdaLhSelectViewHolder(view: View) :
|
||||
BaseViewHolder<GjjHandoverRecordBean, ItemPdaLhSelectBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
binding.bean = getItemBean(item)
|
||||
notifyItemClick(position, binding.ll)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.sixin.module_p.holder
|
||||
|
||||
import android.view.View
|
||||
import com.lukouguoji.module_base.adapter.visible
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.base.CommonAdapter
|
||||
import com.lukouguoji.module_base.bean.GjcWaybillBean
|
||||
import com.lukouguoji.module_base.ktx.refresh
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.databinding.ItemPdaZuZhuangBinding
|
||||
import com.sixin.module_p.databinding.ItemPdaZzSelectBinding
|
||||
import com.sixin.module_p.ui.zuzhuang.holder.PdaJianViewHolder
|
||||
|
||||
class PdaZzSelectViewHolder(view: View) :
|
||||
BaseViewHolder<GjcWaybillBean, ItemPdaZzSelectBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
binding.bean = getItemBean(item)
|
||||
notifyItemClick(position, binding.ll)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.sixin.module_p.model
|
||||
|
||||
import android.content.Context
|
||||
import com.lukouguoji.module_base.base.BaseDialogModel
|
||||
import com.lukouguoji.module_base.bean.GjcWaybillBean
|
||||
import com.lukouguoji.module_base.bean.GjjHandoverRecordBean
|
||||
import com.lukouguoji.module_base.interfaces.IOnItemClickListener
|
||||
import com.lukouguoji.module_base.ktx.addOnItemClickListener
|
||||
import com.lukouguoji.module_base.ktx.refresh
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.databinding.DialogPdaLhSelectBinding
|
||||
import com.sixin.module_p.holder.PdaLhSelectViewHolder
|
||||
|
||||
class PdaLhSelectDialogModel(
|
||||
val list: List<GjjHandoverRecordBean>,
|
||||
private val callBack: (GjjHandoverRecordBean) -> Unit
|
||||
) : BaseDialogModel<DialogPdaLhSelectBinding>(DIALOG_TYPE_CENTER) {
|
||||
|
||||
val itemId = R.layout.item_pda_lh_select
|
||||
val itemHolder = PdaLhSelectViewHolder::class.java
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.dialog_pda_lh_select
|
||||
}
|
||||
|
||||
override fun onDialogCreated(context: Context) {
|
||||
binding.model = this
|
||||
binding.rv.refresh(list)
|
||||
|
||||
binding.rv.addOnItemClickListener(object : IOnItemClickListener {
|
||||
override fun onItemClick(position: Int, type: Int) {
|
||||
callBack.invoke(list[position])
|
||||
dismiss()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.sixin.module_p.model
|
||||
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import com.lukouguoji.module_base.base.BaseDialogModel
|
||||
import com.lukouguoji.module_base.bean.GjcWaybillBean
|
||||
import com.lukouguoji.module_base.interfaces.IOnItemClickListener
|
||||
import com.lukouguoji.module_base.ktx.addOnItemClickListener
|
||||
import com.lukouguoji.module_base.ktx.refresh
|
||||
import com.lukouguoji.module_base.ktx.showToast
|
||||
import com.lukouguoji.module_base.util.CheckUtil
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.databinding.DialogPdaZzSelectBinding
|
||||
import com.sixin.module_p.holder.PdaZzSelectViewHolder
|
||||
|
||||
class PdaZzSelectDialogModel(
|
||||
val list: List<GjcWaybillBean>,
|
||||
private val callBack: (GjcWaybillBean) -> Unit
|
||||
) : BaseDialogModel<DialogPdaZzSelectBinding>(DIALOG_TYPE_CENTER) {
|
||||
|
||||
val itemId = R.layout.item_pda_zz_select
|
||||
val itemHolder = PdaZzSelectViewHolder::class.java
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.dialog_pda_zz_select
|
||||
}
|
||||
|
||||
override fun onDialogCreated(context: Context) {
|
||||
binding.model = this
|
||||
binding.rv.refresh(list)
|
||||
|
||||
binding.rv.addOnItemClickListener(object : IOnItemClickListener {
|
||||
override fun onItemClick(position: Int, type: Int) {
|
||||
callBack.invoke(list[position])
|
||||
dismiss()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.sixin.module_p.service
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.lukouguoji.module_base.common.ConstantEvent
|
||||
import com.lukouguoji.module_base.impl.FlowBus
|
||||
import com.lukouguoji.module_base.ktx.loge
|
||||
import com.lukouguoji.module_base.ktx.noNull
|
||||
import com.lukouguoji.module_base.ktx.toJson
|
||||
|
||||
/**
|
||||
* 条码通知
|
||||
* 广播接收后模拟回车输出
|
||||
*
|
||||
* @author h6900
|
||||
*/
|
||||
class ScanCodeBroadcastReceiver : BroadcastReceiver() {
|
||||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
loge("监听到信息了")
|
||||
intent.extras?.let {
|
||||
val keySet = it.keySet()
|
||||
val map = hashMapOf<String, Any?>()
|
||||
for (key in keySet) {
|
||||
map[key] = it.get(key)
|
||||
}
|
||||
loge("获取扫描广播信息 :\n${map.toJson()}")
|
||||
}
|
||||
val code = intent.getStringExtra(EXTRA_BARCODE_STRING).noNull().trim()
|
||||
if (code.isEmpty()) {
|
||||
return
|
||||
}
|
||||
FlowBus.with<String>(ConstantEvent.SCAN_CODE_RESULT)
|
||||
.tryEmit(code)
|
||||
}
|
||||
|
||||
|
||||
|
||||
companion object {
|
||||
|
||||
// 扫描广播
|
||||
const val ACTION: String = "android.intent.ACTION_DECODE_DATA"
|
||||
|
||||
// 扫描结果 (barcode)
|
||||
const val EXTRA_BARCODE_STRING: String = "barcode_string"
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package com.sixin.module_p.ui.enter
|
||||
|
||||
import android.content.Context.RECEIVER_EXPORTED
|
||||
import android.content.IntentFilter
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.lukouguoji.module_base.base.CustomVP2Adapter
|
||||
import com.lukouguoji.module_base.bean.SocketEventBean
|
||||
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.impl.observe
|
||||
import com.lukouguoji.module_base.ktx.launchCollect
|
||||
import com.lukouguoji.module_base.ktx.noNull
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
import com.lukouguoji.module_base.util.WebSocketUtil
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.base.BasePdaActivity
|
||||
import com.sixin.module_p.databinding.ActivityPdaenterBinding
|
||||
import com.sixin.module_p.helper.PDAHelper
|
||||
import com.sixin.module_p.service.ScanCodeBroadcastReceiver
|
||||
import com.sixin.module_p.ui.user.message.PdaMessageListActivity
|
||||
import me.jessyan.autosize.internal.CustomAdapt
|
||||
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_PDA_ENTER)
|
||||
class PDAEnterActivity : BasePdaActivity<ActivityPdaenterBinding, PDAEnterViewModel>(),
|
||||
CustomAdapt {
|
||||
|
||||
private val receiver by lazy {
|
||||
ScanCodeBroadcastReceiver()
|
||||
}
|
||||
|
||||
override fun layoutId() = R.layout.activity_pdaenter
|
||||
|
||||
override fun viewModelClass(): Class<PDAEnterViewModel> {
|
||||
return PDAEnterViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
binding.viewModel = viewModel
|
||||
|
||||
binding.vp.adapter =
|
||||
CustomVP2Adapter(viewModel.fragmentList, supportFragmentManager, lifecycle)
|
||||
binding.vp.isUserInputEnabled = false
|
||||
binding.vp.offscreenPageLimit = 4
|
||||
|
||||
viewModel.index.observe(this) {
|
||||
binding.vp.setCurrentItem(it, false)
|
||||
}
|
||||
|
||||
FlowBus.with<Any>(ConstantEvent.LOGOUT)
|
||||
.observe(this) {
|
||||
finish()
|
||||
}
|
||||
FlowBus.with<SocketEventBean>(ConstantEvent.SOCKET_EVENT_CLICK)
|
||||
.observe(this) {
|
||||
PdaMessageListActivity.start(this)
|
||||
}
|
||||
FlowBus.with<SocketEventBean>(ConstantEvent.SOCKET_EVENT)
|
||||
.observe(this) {
|
||||
queryUnHandleMessageCount()
|
||||
}
|
||||
|
||||
// 注册广播
|
||||
val filter = IntentFilter()
|
||||
filter.addAction(ScanCodeBroadcastReceiver.ACTION)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
registerReceiver(receiver, filter, RECEIVER_EXPORTED)
|
||||
} else {
|
||||
registerReceiver(receiver, filter)
|
||||
}
|
||||
|
||||
// 连接socket
|
||||
WebSocketUtil.connect()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
queryUnHandleMessageCount()
|
||||
}
|
||||
|
||||
private fun queryUnHandleMessageCount() {
|
||||
launchCollect({
|
||||
NetApply.api.simplePost("msg/msgStateQuery")
|
||||
}) {
|
||||
onSuccess = {
|
||||
val unread = it.data?.unread.noNull("0")
|
||||
binding.tvMessage.text = unread
|
||||
binding.tvMessage.visibility = if (unread != "0") View.VISIBLE else View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
unregisterReceiver(receiver)
|
||||
}
|
||||
|
||||
|
||||
override fun isBaseOnWidth() = true
|
||||
|
||||
override fun getSizeInDp(): Float = PDAHelper.PDA_WIDTH
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.sixin.module_p.ui.enter
|
||||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.module_base.base.BaseViewModel
|
||||
import com.sixin.module_p.ui.enter.gj.GjFragment
|
||||
import com.sixin.module_p.ui.enter.gn.GnFragment
|
||||
import com.sixin.module_p.ui.enter.home.HomeFragment
|
||||
import com.sixin.module_p.ui.enter.mine.PdaMineFragment
|
||||
import com.sixin.module_p.ui.user.message.PdaMessageListActivity
|
||||
|
||||
class PDAEnterViewModel : BaseViewModel() {
|
||||
|
||||
val fragmentList by lazy {
|
||||
listOf(
|
||||
HomeFragment.newInstance(),
|
||||
GnFragment.newInstance(),
|
||||
GjFragment.newInstance(),
|
||||
PdaMineFragment.newInstance()
|
||||
)
|
||||
}
|
||||
|
||||
val index = MutableLiveData(0)
|
||||
|
||||
fun onIndexChanged(type: Int) {
|
||||
index.value = type
|
||||
}
|
||||
|
||||
/**
|
||||
* 消息 点击
|
||||
*/
|
||||
fun onMessageClick() {
|
||||
PdaMessageListActivity.start(getTopActivity())
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.sixin.module_p.ui.enter.gj
|
||||
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.lukouguoji.module_base.base.BaseBindingFragment
|
||||
import com.lukouguoji.module_base.base.CommonAdapter
|
||||
import com.lukouguoji.module_base.interfaces.IOnItemClickListener
|
||||
import com.lukouguoji.module_base.ktx.addOnItemClickListener
|
||||
import com.lukouguoji.module_base.ktx.loge
|
||||
import com.lukouguoji.module_base.ktx.refresh
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.databinding.FragmentGjBinding
|
||||
|
||||
class GjFragment : BaseBindingFragment<FragmentGjBinding, GjViewModel>() {
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.fragment_gj
|
||||
}
|
||||
|
||||
override fun viewModelClass(): Class<GjViewModel> {
|
||||
return GjViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnViewCreated() {
|
||||
binding.viewModel = viewModel
|
||||
|
||||
binding.rv.adapter =
|
||||
CommonAdapter(requireContext(), R.layout.item_pda_action, GjViewHolder::class.java)
|
||||
|
||||
binding.rv.addOnItemClickListener(object : IOnItemClickListener {
|
||||
override fun onItemClick(position: Int, type: Int) {
|
||||
viewModel.onItemClick(position)
|
||||
}
|
||||
})
|
||||
|
||||
binding.rv.refresh(viewModel.actionList)
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun newInstance(): Fragment {
|
||||
return GjFragment()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.sixin.module_p.ui.enter.gj
|
||||
|
||||
import android.view.View
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.ActionBean
|
||||
import com.sixin.module_p.databinding.ItemPdaActionBinding
|
||||
|
||||
class GjViewHolder(view: View) : BaseViewHolder<ActionBean, ItemPdaActionBinding>(view) {
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
binding.bean = getItemBean(item)
|
||||
notifyItemClick(position, binding.ll)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.sixin.module_p.ui.enter.gj
|
||||
|
||||
import com.lukouguoji.module_base.base.BaseViewModel
|
||||
import com.lukouguoji.module_base.bean.ActionBean
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.db.perference.SharedPreferenceUtil
|
||||
import com.lukouguoji.module_base.ktx.loge
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.ui.guobang.PdaGuoBangActivity
|
||||
import com.sixin.module_p.ui.lihuo.PdaLiHuoActivity
|
||||
import com.sixin.module_p.ui.shouyun.PdaShouYunActivity
|
||||
import com.sixin.module_p.ui.zuzhuang.PdaZuZhuangActivity
|
||||
import dev.DevUtils
|
||||
|
||||
class GjViewModel : BaseViewModel() {
|
||||
|
||||
val actionList = listOf(
|
||||
ActionBean("普货收运", R.drawable.gjc_shou_yun_icon, Constant.AuthName.GjcAppDomExpCheckin),
|
||||
ActionBean("板箱组装", R.drawable.img_bxzz, Constant.AuthName.GjcBanXListActivity),
|
||||
ActionBean("板箱过磅", R.drawable.gjc_fu_bang_icon, Constant.AuthName.GjcFuBangActivity),
|
||||
ActionBean("进港理货", R.drawable.img_jglh, Constant.AuthName.GjjTallyListActivity),
|
||||
).filter { SharedPreferenceUtil.getString(Constant.Share.authList).contains(it.key) }
|
||||
|
||||
fun onItemClick(position: Int) {
|
||||
when (val title = actionList[position].title) {
|
||||
"普货收运" -> {
|
||||
PdaShouYunActivity.start(DevUtils.getTopActivity())
|
||||
}
|
||||
|
||||
"板箱组装" -> {
|
||||
PdaZuZhuangActivity.start(DevUtils.getTopActivity())
|
||||
}
|
||||
|
||||
"板箱过磅" -> {
|
||||
PdaGuoBangActivity.start(DevUtils.getTopActivity())
|
||||
}
|
||||
|
||||
"进港理货" -> {
|
||||
PdaLiHuoActivity.start(DevUtils.getTopActivity())
|
||||
}
|
||||
|
||||
else -> {
|
||||
loge("点击事件 $title 未处理")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.sixin.module_p.ui.enter.gn
|
||||
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.lukouguoji.module_base.base.BaseBindingFragment
|
||||
import com.lukouguoji.module_base.base.CommonAdapter
|
||||
import com.lukouguoji.module_base.interfaces.IOnItemClickListener
|
||||
import com.lukouguoji.module_base.ktx.addOnItemClickListener
|
||||
import com.lukouguoji.module_base.ktx.loge
|
||||
import com.lukouguoji.module_base.ktx.refresh
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.databinding.FragmentGnBinding
|
||||
import com.sixin.module_p.ui.enter.gj.GjViewHolder
|
||||
|
||||
class GnFragment : BaseBindingFragment<FragmentGnBinding, GnViewModel>() {
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.fragment_gn
|
||||
}
|
||||
|
||||
override fun viewModelClass(): Class<GnViewModel> {
|
||||
return GnViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnViewCreated() {
|
||||
binding.viewModel = viewModel
|
||||
|
||||
binding.rv.adapter =
|
||||
CommonAdapter(requireContext(), R.layout.item_pda_action, GjViewHolder::class.java)
|
||||
|
||||
binding.rv.addOnItemClickListener(object : IOnItemClickListener {
|
||||
override fun onItemClick(position: Int, type: Int) {
|
||||
viewModel.onItemClick(position)
|
||||
}
|
||||
})
|
||||
|
||||
binding.rv.refresh(viewModel.actionList)
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun newInstance(): Fragment {
|
||||
return GnFragment()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package com.sixin.module_p.ui.enter.gn
|
||||
|
||||
import android.content.Intent
|
||||
import com.lukouguoji.module_base.base.BaseViewModel
|
||||
import com.lukouguoji.module_base.bean.ActionBean
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.db.perference.SharedPreferenceUtil
|
||||
import com.lukouguoji.module_base.ktx.logd
|
||||
import com.lukouguoji.module_base.ktx.loge
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.ui.enter.gn.document.PdaDocumentHandoverActivity
|
||||
import com.sixin.module_p.ui.gnc.cunfang.list.PdaGncCunFangListActivity
|
||||
import com.sixin.module_p.ui.gnc.fubang.add.PdaGncFuBangAddActivity
|
||||
import com.sixin.module_p.ui.gnc.shouyun.un.list.GncUnShouYunActivity
|
||||
import com.sixin.module_p.ui.gnj.accidentVisa.list.PdaAccidentVisaListActivity
|
||||
import com.sixin.module_p.ui.gnj.xieji.list.PdaGnjXieJiListActivity
|
||||
import com.sixin.module_p.ui.goods.transport.list.PdaGoodsTransportListActivity
|
||||
import com.sixin.module_p.ui.goods.transportLog.list.PdaTransportLogActivity
|
||||
import dev.DevUtils
|
||||
|
||||
class GnViewModel : BaseViewModel() {
|
||||
|
||||
val actionList = listOf(
|
||||
ActionBean(
|
||||
"出港收运",
|
||||
com.lukouguoji.module_base.R.drawable.img_gnc_shouyun,
|
||||
Constant.AuthName.AppDomExpCheckin
|
||||
),
|
||||
ActionBean("出港复磅", R.drawable.gnc_fubang, Constant.AuthName.AppDomExpWeighting),
|
||||
ActionBean(
|
||||
"出港存放",
|
||||
com.lukouguoji.module_base.R.drawable.img_gnc_cunfang,
|
||||
Constant.AuthName.AppDomExpDeposit
|
||||
),
|
||||
ActionBean(
|
||||
"进港卸机",
|
||||
com.lukouguoji.module_base.R.drawable.img_gnc_xieji,
|
||||
Constant.AuthName.MonitorInPack
|
||||
),
|
||||
ActionBean(
|
||||
"货物转运",
|
||||
com.lukouguoji.module_base.R.drawable.img_gnc_huowuzhuanyun,
|
||||
Constant.AuthName.ComprehensiveTransfer
|
||||
),
|
||||
ActionBean(
|
||||
"转运记录",
|
||||
com.lukouguoji.module_base.R.mipmap.transport_log,
|
||||
Constant.AuthName.TransportLog
|
||||
),
|
||||
ActionBean(
|
||||
"事故签证",
|
||||
R.mipmap.mit_accident_visa,
|
||||
Constant.AuthName.ComprehensiveAccidentVisa
|
||||
),
|
||||
ActionBean(
|
||||
"单证交接",
|
||||
R.mipmap.gnc_document_handover,
|
||||
Constant.AuthName.DocumentHandover
|
||||
),
|
||||
)
|
||||
.filter { SharedPreferenceUtil.getString(Constant.Share.authList).contains(it.key) }
|
||||
|
||||
|
||||
fun onItemClick(position: Int) {
|
||||
when (val title = actionList[position].title) {
|
||||
"出港收运" -> {
|
||||
GncUnShouYunActivity.start(DevUtils.getTopActivity())
|
||||
}
|
||||
|
||||
"出港复磅" -> {
|
||||
PdaGncFuBangAddActivity.start(DevUtils.getTopActivity())
|
||||
}
|
||||
|
||||
"出港存放" -> {
|
||||
PdaGncCunFangListActivity.start(DevUtils.getTopActivity())
|
||||
}
|
||||
|
||||
"进港卸机" -> {
|
||||
PdaGnjXieJiListActivity.start(DevUtils.getTopActivity())
|
||||
}
|
||||
|
||||
"货物转运" -> {
|
||||
PdaGoodsTransportListActivity.start(DevUtils.getTopActivity())
|
||||
}
|
||||
|
||||
"转运记录" -> {
|
||||
PdaTransportLogActivity.start(DevUtils.getTopActivity())
|
||||
}
|
||||
|
||||
"事故签证" -> {
|
||||
PdaAccidentVisaListActivity.start(DevUtils.getTopActivity())
|
||||
}
|
||||
"单证交接" -> {
|
||||
DevUtils.getTopActivity()?.let {
|
||||
it.startActivity(Intent(it,PdaDocumentHandoverActivity::class.java))
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
loge("点击事件 $title 未处理")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
package com.sixin.module_p.ui.enter.gn.document
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
||||
import com.lukouguoji.module_base.bean.DocumentHandoverBean
|
||||
import com.lukouguoji.module_base.bean.GncCunFangBean
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.common.ConstantEvent
|
||||
import com.lukouguoji.module_base.db.perference.SharedPreferenceUtil
|
||||
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.noNull
|
||||
import com.lukouguoji.module_base.ktx.showToast
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.lukouguoji.module_base.model.ScanModel
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.ui.gnc.cunfang.list.PdaGncCunFangAddDialogModel
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
|
||||
class PDADocumentViewModel: BasePageViewModel() {
|
||||
|
||||
val flightNumber = MutableLiveData("")
|
||||
|
||||
val index = MutableLiveData(0)
|
||||
|
||||
val count = MutableLiveData(0)
|
||||
|
||||
val unSaveSelectedCount = MutableLiveData(0)
|
||||
|
||||
val itemLayoutId = R.layout.item_pda_document_handover_list
|
||||
val itemViewHolder = PdaDocumentHandoverViewHolder::class.java
|
||||
|
||||
private val filterModel = PdaDocumentHandoverFilterDialogModel{
|
||||
refresh()
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
fun initOnCreated(intent: Intent) {
|
||||
FlowBus.with<String>(ConstantEvent.SCAN_CODE_RESULT)
|
||||
.onEach {
|
||||
flightNumber.value = it
|
||||
onFlightNumberChange()
|
||||
}.launchIn(viewModelScope)
|
||||
}
|
||||
|
||||
override fun getData() {
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getDocumentHandoverList(
|
||||
mapOf(
|
||||
"pageNum" to pageModel.page,
|
||||
"pageSize" to pageModel.limit,
|
||||
"fdate" to filterModel.date.value,
|
||||
"fno" to flightNumber.value,
|
||||
"fileType" to filterModel.docType.value,
|
||||
"ieFlag" to filterModel.ieFlag.value,
|
||||
"reviewStatus" to filterModel.reviewStatus.value
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
pageModel.handleListBean(it)
|
||||
count.value = it.total
|
||||
}
|
||||
onComplete = {
|
||||
pageModel.finishLoading()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 筛选点击
|
||||
*/
|
||||
fun onFilterClick() {
|
||||
filterModel.show()
|
||||
}
|
||||
|
||||
fun onFlightNumberChange(focused: Boolean = false) {
|
||||
if (focused) {
|
||||
return
|
||||
}
|
||||
refresh()
|
||||
}
|
||||
|
||||
private fun resetUnSaveSelectedCount(){
|
||||
unSaveSelectedCount.postValue(0)
|
||||
}
|
||||
private fun refreshPage(){
|
||||
resetUnSaveSelectedCount()
|
||||
refresh()
|
||||
}
|
||||
|
||||
fun onReviewClick() {
|
||||
val list = pageModel.rv!!.commonAdapter()!!.items as List<DocumentHandoverBean>
|
||||
val filter = list.filter { it.checked.get() }
|
||||
if (filter.isEmpty()) {
|
||||
showToast("请选择数据")
|
||||
return
|
||||
}
|
||||
val reviewed = filter.filter { it.reviewer != "" }
|
||||
if (reviewed.isNotEmpty()) {
|
||||
showToast("存在已复核数据")
|
||||
return
|
||||
}
|
||||
// 判断选择的项中是否存在不是当前登录用户为交接司机的
|
||||
val currentUserName = SharedPreferenceUtil.getString(Constant.Share.userName).noNull()
|
||||
val notCurrentDriver = filter.filter { iit -> iit.driver != "" && iit.driver != currentUserName }
|
||||
if (notCurrentDriver.isNotEmpty()) {
|
||||
showToast("不可复核分配司机不是自己的数据")
|
||||
return
|
||||
}
|
||||
launchLoadingCollect({
|
||||
NetApply.api.anyPost(
|
||||
"flt/reviewHandover", mapOf(
|
||||
"idList" to filter.map { b -> b.id },
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
showToast(it.msg.noNull("分配区域成功"))
|
||||
refreshPage()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun scanClick() {
|
||||
ScanModel.startScan(getTopActivity(), Constant.RequestCode.CAR)
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
if (data == null || resultCode != Activity.RESULT_OK) {
|
||||
return
|
||||
}
|
||||
when (requestCode) {
|
||||
Constant.RequestCode.CAR -> {
|
||||
flightNumber.value = data.getStringExtra(Constant.Result.CODED_CONTENT).noNull()
|
||||
onFlightNumberChange()
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onItemClick(position: Int, type: Int) {
|
||||
super.onItemClick(position, type)
|
||||
if(type == R.id.pda_handover_checkBox){
|
||||
val list = pageModel.rv!!.commonAdapter()!!.items as List<DocumentHandoverBean>
|
||||
val oldValue = unSaveSelectedCount.value
|
||||
if (oldValue != null) {
|
||||
if(list[position].checked.get()){
|
||||
if(oldValue<list.size){
|
||||
unSaveSelectedCount.postValue(oldValue+1)
|
||||
}
|
||||
}else{
|
||||
if(oldValue>0){
|
||||
unSaveSelectedCount.postValue(oldValue-1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.sixin.module_p.ui.enter.gn.document
|
||||
|
||||
import android.os.Bundle
|
||||
import com.lukouguoji.module_base.ktx.addOnItemClickListener
|
||||
import com.lukouguoji.module_base.ktx.getLifecycleOwner
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.base.BasePdaActivity
|
||||
import com.sixin.module_p.databinding.ActivityPdaDocumentHandoverBinding
|
||||
|
||||
class PdaDocumentHandoverActivity : BasePdaActivity<ActivityPdaDocumentHandoverBinding, PDADocumentViewModel>(){
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.activity_pda_document_handover
|
||||
}
|
||||
|
||||
override fun viewModelClass(): Class<PDADocumentViewModel> {
|
||||
return PDADocumentViewModel::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.addOnItemClickListener(viewModel)
|
||||
viewModel.getData()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.sixin.module_p.ui.enter.gn.document
|
||||
|
||||
import android.content.Context
|
||||
import android.widget.Spinner
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.module_base.base.BaseDialogModel
|
||||
import com.lukouguoji.module_base.ktx.formatDate
|
||||
import com.lukouguoji.module_base.ktx.noNull
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.lukouguoji.module_base.util.DictUtils
|
||||
import com.lxj.xpopup.XPopup
|
||||
import com.lxj.xpopup.enums.PopupPosition
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.databinding.DialogPdaDocumentHandoverFilterBinding
|
||||
import dev.DevUtils
|
||||
import dev.utils.app.info.KeyValue
|
||||
import dev.utils.common.DateUtils
|
||||
import java.util.Calendar
|
||||
|
||||
class PdaDocumentHandoverFilterDialogModel(
|
||||
private val callBack: () -> Unit
|
||||
) : BaseDialogModel<DialogPdaDocumentHandoverFilterBinding>(DIALOG_TYPE_DRAWER) {
|
||||
|
||||
val date = MutableLiveData(DateUtils.getCurrentTime().formatDate())
|
||||
|
||||
val flightNo = MutableLiveData("")
|
||||
|
||||
val docType = MutableLiveData("")
|
||||
|
||||
val docTypeList = MutableLiveData<List<KeyValue>>(listOf()).apply {
|
||||
DictUtils.getDocumentHandoverTypeList {
|
||||
value = listOf(KeyValue("全部", "")) + it
|
||||
docType.value = ""
|
||||
}
|
||||
}
|
||||
|
||||
val reviewStatus = MutableLiveData("")
|
||||
val reviewStatusList = MutableLiveData<List<KeyValue>>(listOf()).apply {
|
||||
value = listOf(KeyValue("全部", ""), KeyValue("未复核", "0"), KeyValue("已复核", "1"),)
|
||||
}
|
||||
|
||||
val ieFlag = MutableLiveData("")
|
||||
|
||||
val ieFlagList = MutableLiveData<List<KeyValue>>(listOf()).apply {
|
||||
value = listOf(KeyValue("国内出港", "E"), KeyValue("国内进港", "I"), KeyValue("全部", ""))
|
||||
ieFlag.value = "E"
|
||||
}
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.dialog_pda_document_handover_filter
|
||||
}
|
||||
|
||||
override fun onDialogCreated(context: Context) {
|
||||
binding.model = this
|
||||
}
|
||||
|
||||
override fun onBuild(builder: XPopup.Builder) {
|
||||
builder.popupPosition(PopupPosition.Right)
|
||||
}
|
||||
|
||||
fun onDateClick() {
|
||||
Common.onYearMonthDay(DevUtils.getTopActivity(), date.value) { year, month, day ->
|
||||
val calendar = Calendar.getInstance()
|
||||
calendar.set(year, month - 1, day)
|
||||
date.value = DateUtils.formatDate(calendar.time, "yyyy-MM-dd")
|
||||
}
|
||||
}
|
||||
|
||||
fun onDocTypeSelected(position: Int) {
|
||||
docType.value = docTypeList.value?.getOrNull(position)?.value.noNull()
|
||||
}
|
||||
|
||||
fun onIEFlagSelected(position: Int) {
|
||||
ieFlag.value = ieFlagList.value?.getOrNull(position)?.value.noNull()
|
||||
}
|
||||
|
||||
fun onReviewSelected(position: Int) {
|
||||
reviewStatus.value = reviewStatusList.value?.getOrNull(position)?.value.noNull()
|
||||
}
|
||||
|
||||
fun onResetClick() {
|
||||
date.value = DateUtils.getCurrentTime().formatDate()
|
||||
flightNo.value = ""
|
||||
callBack.invoke()
|
||||
binding.spinnerTypes.setSelection(0)
|
||||
binding.spinnerIeFlags.setSelection(0)
|
||||
dismiss()
|
||||
}
|
||||
|
||||
fun onConfirmClick() {
|
||||
callBack.invoke()
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.sixin.module_p.ui.enter.gn.document
|
||||
|
||||
import android.view.View
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.DocumentHandoverBean
|
||||
import com.lukouguoji.module_base.bean.TransportLogBean
|
||||
import com.sixin.module_p.databinding.ItemPdaDocumentHandoverListBinding
|
||||
import com.sixin.module_p.databinding.ItemPdaTransportLogListBinding
|
||||
|
||||
class PdaDocumentHandoverViewHolder(view: View) :
|
||||
BaseViewHolder<DocumentHandoverBean, ItemPdaDocumentHandoverListBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
binding.bean = getItemBean(item)
|
||||
notifyItemClick(position, binding.pdaHandoverCheckBox)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.sixin.module_p.ui.enter.home
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.alibaba.fastjson.JSONArray
|
||||
import com.lukouguoji.module_base.base.BaseDialogModel
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.ktx.formatDate
|
||||
import com.lukouguoji.module_base.ktx.launchCollect
|
||||
import com.lukouguoji.module_base.ktx.toInt
|
||||
import com.lukouguoji.module_base.ktx.toJson
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.lukouguoji.module_base.util.DictUtils
|
||||
import com.lxj.xpopup.XPopup
|
||||
import com.lxj.xpopup.enums.PopupPosition
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.databinding.DialogPdaCunfangFilterBinding
|
||||
import com.sixin.module_p.databinding.DialogPdaDaishouyunFilterBinding
|
||||
import com.sixin.module_p.databinding.FragmentPdaHomeConfigBinding
|
||||
import dev.DevUtils
|
||||
import dev.utils.app.info.KeyValue
|
||||
import dev.utils.common.DateUtils
|
||||
import java.util.Calendar
|
||||
|
||||
class HomeConfigDialogModel(
|
||||
private val callBack: () -> Unit
|
||||
) : BaseDialogModel<FragmentPdaHomeConfigBinding>(DIALOG_TYPE_DRAWER) {
|
||||
|
||||
|
||||
val filterContent = MutableLiveData("")
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.fragment_pda_home_config
|
||||
}
|
||||
|
||||
override fun onDialogCreated(context: Context) {
|
||||
binding.model = this
|
||||
launchCollect({
|
||||
NetApply.api.getFltFilter()
|
||||
}) {
|
||||
onSuccess = {
|
||||
filterContent.value = it.data?.filterContent
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onBuild(builder: XPopup.Builder) {
|
||||
builder.popupPosition(PopupPosition.Right)
|
||||
}
|
||||
|
||||
|
||||
fun onResetClick() {
|
||||
filterContent.value = ""
|
||||
/*callBack.invoke()
|
||||
dismiss()*/
|
||||
}
|
||||
|
||||
fun onConfirmClick() {
|
||||
launchCollect({
|
||||
NetApply.api.addOrModifyFltFilter(
|
||||
mapOf(
|
||||
"filterContent" to filterContent.value,
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
callBack.invoke()
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.sixin.module_p.ui.enter.home
|
||||
|
||||
import android.widget.LinearLayout
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.lukouguoji.module_base.base.BaseBindingFragment
|
||||
import com.lukouguoji.module_base.base.CommonAdapter
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.databinding.FragmentPdaHomeBinding
|
||||
|
||||
class HomeFragment : BaseBindingFragment<FragmentPdaHomeBinding, HomeViewModel>() {
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.fragment_pda_home
|
||||
}
|
||||
|
||||
override fun viewModelClass(): Class<HomeViewModel> {
|
||||
return HomeViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnViewCreated() {
|
||||
viewModel.onInit()
|
||||
binding.viewModel = viewModel
|
||||
|
||||
binding.rv.adapter =
|
||||
CommonAdapter(requireContext(), R.layout.item_pda_home, HomeViewHolder::class.java)
|
||||
viewModel.pageModel.bindSmartRefreshLayout(binding.srl, binding.rv, viewModel, this)
|
||||
|
||||
viewModel.refresh()
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun newInstance(): Fragment {
|
||||
return HomeFragment()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.sixin.module_p.ui.enter.home
|
||||
|
||||
import android.graphics.Color
|
||||
import android.view.View
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.FlightBean
|
||||
import com.sixin.module_p.databinding.ItemPdaHomeBinding
|
||||
|
||||
class HomeViewHolder(view: View) : BaseViewHolder<FlightBean, ItemPdaHomeBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
binding.bean = getItemBean(item)
|
||||
|
||||
if (position % 2 == 0) {
|
||||
binding.ll.setBackgroundColor(Color.parseColor("#8c8c8c"))
|
||||
} else {
|
||||
binding.ll.setBackgroundColor(Color.parseColor("#41cea5"))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package com.sixin.module_p.ui.enter.home
|
||||
|
||||
import android.app.DatePickerDialog
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.observe
|
||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.ktx.launchCollect
|
||||
import com.lukouguoji.module_base.ktx.toInt
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.sixin.module_p.ui.gnc.shouyun.dialog.PdaDaiShouYunFilterDialogModel
|
||||
import dev.DevUtils
|
||||
import dev.utils.common.DateUtils
|
||||
|
||||
class HomeViewModel : BasePageViewModel() {
|
||||
|
||||
|
||||
// 日期
|
||||
val date = MutableLiveData(DateUtils.formatDate(DateUtils.getCurrentTime(), "yyyy-MM-dd"))
|
||||
|
||||
// 类型
|
||||
val type = MutableLiveData(TYPE_LEAVE)
|
||||
|
||||
// 航班类型- 0:国内, 1:国际
|
||||
val countryType = MutableLiveData(false)
|
||||
|
||||
private val datePicker by lazy {
|
||||
DatePickerDialog(getTopActivity()).apply {
|
||||
setOnDateSetListener { _, year, month, dayOfMonth ->
|
||||
date.value = "${year}-${month + 1}-${dayOfMonth}"
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val configModel = HomeConfigDialogModel {
|
||||
getData()
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
fun onInit() {
|
||||
countryType.observe(DevUtils.getTopActivity() as LifecycleOwner) {
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
|
||||
override fun getData() {
|
||||
launchCollect({
|
||||
NetApply.api.getFlightList(
|
||||
mapOf(
|
||||
"page" to pageModel.page,
|
||||
"limit" to pageModel.limit,
|
||||
"fdate" to date.value,
|
||||
"status" to type.value,
|
||||
"countryType" to countryType.value.toInt(),
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
pageModel.handleListBean(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onConfigClick() {
|
||||
configModel.show()
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期点击
|
||||
*/
|
||||
fun onDateClick() {
|
||||
datePicker.show()
|
||||
}
|
||||
|
||||
/**
|
||||
* 类型 改变
|
||||
*/
|
||||
fun onTypeChange(type: Int) {
|
||||
this.type.value = type
|
||||
refresh()
|
||||
}
|
||||
|
||||
companion object {
|
||||
// 出发
|
||||
const val TYPE_LEAVE = 0
|
||||
|
||||
// 到达
|
||||
const val TYPE_ARRIVAL = 1
|
||||
|
||||
// 国内
|
||||
const val TYPE_GN = 0
|
||||
|
||||
// 国际
|
||||
const val TYPE_GJ = 1
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.sixin.module_p.ui.enter.mine
|
||||
|
||||
import com.lukouguoji.module_base.base.BaseBindingFragment
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.databinding.FragmentPdaMineBinding
|
||||
|
||||
class PdaMineFragment : BaseBindingFragment<FragmentPdaMineBinding, PdaMineViewModel>() {
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.fragment_pda_mine
|
||||
}
|
||||
|
||||
override fun viewModelClass(): Class<PdaMineViewModel> {
|
||||
return PdaMineViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnViewCreated() {
|
||||
binding.viewModel = viewModel
|
||||
|
||||
viewModel.onInit()
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
fun newInstance(): PdaMineFragment {
|
||||
return PdaMineFragment()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.sixin.module_p.ui.enter.mine
|
||||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.lukouguoji.module_base.base.BaseViewModel
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.common.ConstantEvent
|
||||
import com.lukouguoji.module_base.db.perference.SharedPreferenceUtil
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.impl.FlowBus
|
||||
import com.lukouguoji.module_base.ktx.launchCollect
|
||||
import com.lukouguoji.module_base.ktx.noNull
|
||||
import com.lukouguoji.module_base.ktx.showConfirmDialog
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
import com.lukouguoji.module_base.service.repository.LoginRepository
|
||||
import com.lukouguoji.module_base.util.WebSocketUtil
|
||||
import com.sixin.module_p.ui.set.PdaSetActivity
|
||||
import com.sixin.module_p.ui.user.about.PdaAboutUsActivity
|
||||
|
||||
class PdaMineViewModel : BaseViewModel() {
|
||||
|
||||
val userName = SharedPreferenceUtil.getString(Constant.Share.userName).noNull()
|
||||
val userRole = MutableLiveData("计重员")
|
||||
|
||||
fun onInit() {
|
||||
launchCollect({
|
||||
NetApply.api.getUserRole(
|
||||
SharedPreferenceUtil.getString(Constant.Share.account).noNull()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
if (it.verifySuccess()) {
|
||||
userRole.value = it.data?.roleName ?: ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onModifyPasswordClick() {
|
||||
PdaSetActivity.start(getTopActivity())
|
||||
}
|
||||
|
||||
fun onAboutUsClick() {
|
||||
PdaAboutUsActivity.start(getTopActivity())
|
||||
}
|
||||
|
||||
fun onLogoutClick() {
|
||||
getTopActivity().showConfirmDialog("确定要退出账号吗?") {
|
||||
LoginRepository.logout()
|
||||
WebSocketUtil.closeWebSocket()
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_LOGIN).navigation()
|
||||
FlowBus.with<Any>(ConstantEvent.LOGOUT)
|
||||
.tryEmit(true)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.sixin.module_p.ui.gnc.cunfang.add
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.base.BasePdaActivity
|
||||
import com.sixin.module_p.databinding.ActivityPdaGncCunFangAddBinding
|
||||
|
||||
class PdaGncCunFangAddActivity :
|
||||
BasePdaActivity<ActivityPdaGncCunFangAddBinding, PdaGncCunFangAddViewModel>() {
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.activity_pda_gnc_cun_fang_add
|
||||
}
|
||||
|
||||
override fun viewModelClass(): Class<PdaGncCunFangAddViewModel> {
|
||||
return PdaGncCunFangAddViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国内出港区域分配")
|
||||
binding.viewModel = viewModel
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
val starter = Intent(context, PdaGncCunFangAddActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.sixin.module_p.ui.gnc.cunfang.add
|
||||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.module_base.base.BaseViewModel
|
||||
import dev.utils.app.info.KeyValue
|
||||
|
||||
class PdaGncCunFangAddViewModel : BaseViewModel() {
|
||||
|
||||
val area = MutableLiveData("")
|
||||
|
||||
val areaList = MutableLiveData<List<KeyValue>>(listOf())
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
fun onAreaSelected(position: Int) {
|
||||
|
||||
}
|
||||
|
||||
fun onConfirmClick() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.sixin.module_p.ui.gnc.cunfang.dialog
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.module_base.base.BaseDialogModel
|
||||
import com.lukouguoji.module_base.ktx.formatDate
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.lukouguoji.module_base.util.DictUtils
|
||||
import com.lxj.xpopup.XPopup
|
||||
import com.lxj.xpopup.enums.PopupPosition
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.databinding.DialogPdaCunfangFilterBinding
|
||||
import dev.DevUtils
|
||||
import dev.utils.app.info.KeyValue
|
||||
import dev.utils.common.DateUtils
|
||||
import java.util.Calendar
|
||||
|
||||
class PdaCunFangFilterDialogModel(
|
||||
private val callBack: () -> Unit
|
||||
) : BaseDialogModel<DialogPdaCunfangFilterBinding>(DIALOG_TYPE_DRAWER) {
|
||||
|
||||
val date = MutableLiveData(DateUtils.getCurrentTime().formatDate())
|
||||
|
||||
val flightNo = MutableLiveData("")
|
||||
|
||||
// 存放区域
|
||||
val area = MutableLiveData("")
|
||||
|
||||
// 复磅状态
|
||||
val status = MutableLiveData("")
|
||||
|
||||
val areaList = MutableLiveData<List<KeyValue>>().apply {
|
||||
DictUtils.getAreaList {
|
||||
value = listOf(KeyValue("全部", "")) + it
|
||||
}
|
||||
}
|
||||
val statusList = MutableLiveData<List<KeyValue>>(
|
||||
DictUtils.reWeightStatusList
|
||||
)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.dialog_pda_cunfang_filter
|
||||
}
|
||||
|
||||
override fun onDialogCreated(context: Context) {
|
||||
binding.model = this
|
||||
}
|
||||
|
||||
fun onAreaSelected(position: Int) {
|
||||
area.value = areaList.value?.get(position)?.value
|
||||
}
|
||||
|
||||
fun onStatusSelected(position: Int) {
|
||||
status.value = statusList.value?.get(position)?.value
|
||||
}
|
||||
|
||||
override fun onBuild(builder: XPopup.Builder) {
|
||||
builder.popupPosition(PopupPosition.Right)
|
||||
}
|
||||
|
||||
fun onDateClick() {
|
||||
Common.onYearMonthDay(DevUtils.getTopActivity(), date.value) { year, month, day ->
|
||||
val calendar = Calendar.getInstance()
|
||||
calendar.set(year, month - 1, day)
|
||||
date.value = DateUtils.formatDate(calendar.time, "yyyy-MM-dd")
|
||||
}
|
||||
}
|
||||
|
||||
fun onResetClick() {
|
||||
date.value = DateUtils.getCurrentTime().formatDate()
|
||||
flightNo.value = ""
|
||||
if (binding.spinnerArea.adapter.count > 0) {
|
||||
binding.spinnerArea.setSelection(0)
|
||||
}
|
||||
if (binding.spinnerStatus.adapter.count > 0) {
|
||||
binding.spinnerStatus.setSelection(0)
|
||||
}
|
||||
|
||||
callBack.invoke()
|
||||
dismiss()
|
||||
}
|
||||
|
||||
fun onConfirmClick() {
|
||||
callBack.invoke()
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.sixin.module_p.ui.gnc.cunfang.list
|
||||
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.module_base.base.BaseDialogModel
|
||||
import com.lukouguoji.module_base.base.BaseViewModel
|
||||
import com.lukouguoji.module_base.ktx.verifyNullOrEmpty
|
||||
import com.lukouguoji.module_base.util.DictUtils
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.databinding.DialogPdaGncCunFangAddBinding
|
||||
import dev.utils.app.info.KeyValue
|
||||
|
||||
class PdaGncCunFangAddDialogModel(
|
||||
val carList: String,
|
||||
val callBack: (PdaGncCunFangAddDialogModel) -> Unit
|
||||
) :
|
||||
BaseDialogModel<DialogPdaGncCunFangAddBinding>(DIALOG_TYPE_FULL) {
|
||||
|
||||
val area = MutableLiveData("")
|
||||
|
||||
val areaList = MutableLiveData<List<KeyValue>>().apply {
|
||||
DictUtils.getAreaList {
|
||||
value = it
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
override fun layoutId() = R.layout.dialog_pda_gnc_cun_fang_add
|
||||
|
||||
override fun onDialogCreated(context: Context) {
|
||||
setBackArrow("分配存放区域")
|
||||
binding.model = this
|
||||
}
|
||||
|
||||
private fun setBackArrow(title: String) {
|
||||
val toolbar: Toolbar = binding.root.findViewById(com.lukouguoji.module_base.R.id.toolbar)
|
||||
val titleName: TextView = binding.root.findViewById(com.lukouguoji.module_base.R.id.title_name)
|
||||
titleName.text = title
|
||||
val toolBack: View = binding.root.findViewById(com.lukouguoji.module_base.R.id.tool_back)
|
||||
toolBack.setOnClickListener {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
fun onAreaSelected(position: Int) {
|
||||
area.value = areaList.value?.getOrNull(position)?.value ?: ""
|
||||
}
|
||||
|
||||
fun onConfirmClick() {
|
||||
if (area.value.verifyNullOrEmpty("请选择区域")) {
|
||||
return
|
||||
}
|
||||
callBack.invoke(this)
|
||||
dismiss()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.sixin.module_p.ui.gnc.cunfang.list
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.KeyEvent
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import com.lukouguoji.module_base.ktx.addOnItemClickListener
|
||||
import com.lukouguoji.module_base.ktx.getLifecycleOwner
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.base.BasePdaActivity
|
||||
import com.sixin.module_p.databinding.ActivityPdaGncCunFangListBinding
|
||||
|
||||
class PdaGncCunFangListActivity :
|
||||
BasePdaActivity<ActivityPdaGncCunFangListBinding, PdaGncCunFangListViewModel>() {
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.activity_pda_gnc_cun_fang_list
|
||||
}
|
||||
|
||||
override fun viewModelClass(): Class<PdaGncCunFangListViewModel> {
|
||||
return PdaGncCunFangListViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国内出港存放")
|
||||
binding.viewModel = viewModel
|
||||
binding.etCarNo.setOnFocusChangeListener { v, hasFocus ->
|
||||
if(!hasFocus){
|
||||
val carNo = binding.etCarNo.text.toString()
|
||||
Log.i("TEST","initOnCreate setOnFocusChangeListener $carNo")
|
||||
viewModel.findMatchInputCarNo(carNo)
|
||||
}
|
||||
}
|
||||
binding.etCarNo.imeOptions = EditorInfo.IME_ACTION_DONE
|
||||
binding.etCarNo.setOnKeyListener { v, keyCode, event ->
|
||||
if (event.action === KeyEvent.ACTION_DOWN && keyCode === KeyEvent.KEYCODE_ENTER) {
|
||||
viewModel.refresh()
|
||||
return@setOnKeyListener true
|
||||
}
|
||||
return@setOnKeyListener false
|
||||
}
|
||||
viewModel.pageModel.bindSmartRefreshLayout(
|
||||
binding.srl,
|
||||
binding.rv,
|
||||
viewModel,
|
||||
getLifecycleOwner()
|
||||
)
|
||||
viewModel.initOnCreated()
|
||||
binding.rv.addOnItemClickListener(viewModel)
|
||||
viewModel.getData()
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
val starter = Intent(context, PdaGncCunFangListActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.sixin.module_p.ui.gnc.cunfang.list
|
||||
|
||||
import android.view.View
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.GncCunFangBean
|
||||
import com.sixin.module_p.databinding.ItemPdaGncCunfangListBinding
|
||||
|
||||
class PdaGncCunFangListViewHolder(view: View) :
|
||||
BaseViewHolder<GncCunFangBean, ItemPdaGncCunfangListBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
binding.bean = getItemBean(item)
|
||||
notifyItemClick(position, binding.pdaGncCheckBox)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
package com.sixin.module_p.ui.gnc.cunfang.list
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.util.Log
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
||||
import com.lukouguoji.module_base.bean.GncCunFangBean
|
||||
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.interfaces.IOnItemClickListener
|
||||
import com.lukouguoji.module_base.ktx.commonAdapter
|
||||
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.sixin.module_p.R
|
||||
import com.sixin.module_p.ui.gnc.cunfang.dialog.PdaCunFangFilterDialogModel
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
|
||||
class PdaGncCunFangListViewModel : BasePageViewModel(), IOnItemClickListener {
|
||||
|
||||
val car = MutableLiveData("")
|
||||
|
||||
val index = MutableLiveData(0)
|
||||
|
||||
val count = MutableLiveData(0)
|
||||
|
||||
val unSaveSelectedCount = MutableLiveData(0)
|
||||
|
||||
val itemLayoutId = R.layout.item_pda_gnc_cunfang_list
|
||||
val itemViewHolder = PdaGncCunFangListViewHolder::class.java
|
||||
|
||||
private val filterModel = PdaCunFangFilterDialogModel {
|
||||
refreshPage()
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
fun initOnCreated() {
|
||||
FlowBus.with<String>(ConstantEvent.SCAN_CODE_RESULT)
|
||||
.onEach {
|
||||
car.value = it
|
||||
// refreshPage()
|
||||
findMatchInputCarNo(it)
|
||||
}.launchIn(viewModelScope)
|
||||
}
|
||||
|
||||
override fun getData() {
|
||||
resetUnSaveSelectedCount()
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getGncCunFangList(
|
||||
mapOf(
|
||||
"pageNum" to pageModel.page,
|
||||
"pageSize" to pageModel.limit,
|
||||
"fdate" to filterModel.date.value,
|
||||
"fno" to filterModel.flightNo.value,
|
||||
"storageArea" to filterModel.area.value,
|
||||
"copStatus" to filterModel.status.value,
|
||||
"checkFlag" to filterModel.status.value,
|
||||
"carId" to car.value,
|
||||
"isStorage" to index.value,
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
pageModel.handleListBean(it)
|
||||
count.value = it.total
|
||||
}
|
||||
onComplete = {
|
||||
pageModel.finishLoading()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* tab切换
|
||||
*/
|
||||
fun onTabChanged(index: Int) {
|
||||
this.index.value = index
|
||||
refreshPage()
|
||||
}
|
||||
|
||||
fun refreshPage(){
|
||||
resetUnSaveSelectedCount()
|
||||
refresh()
|
||||
}
|
||||
|
||||
/**
|
||||
* 筛选点击
|
||||
*/
|
||||
fun onFilterClick() {
|
||||
filterModel.show()
|
||||
}
|
||||
|
||||
fun onDistributionClick() {
|
||||
val list = pageModel.rv!!.commonAdapter()!!.items as List<GncCunFangBean>
|
||||
val filter = list.filter { it.checked.get() }
|
||||
if (filter.isEmpty()) {
|
||||
showToast("请选择数据")
|
||||
return
|
||||
}
|
||||
val carList = filter.joinToString("、") { it.carId }
|
||||
PdaGncCunFangAddDialogModel(
|
||||
carList,
|
||||
) {
|
||||
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("分配区域成功"))
|
||||
refreshPage()
|
||||
}
|
||||
}
|
||||
}.show(getTopActivity())
|
||||
}
|
||||
|
||||
fun findMatchInputCarNo(carNo: String){
|
||||
if(carNo.length>=3){
|
||||
val list = pageModel.rv?.commonAdapter()?.items as List<GncCunFangBean>
|
||||
Log.i("TEST","findMatchInputCarNo ${list.size}")
|
||||
for(i in list?.indices){
|
||||
list[i].carId.let {
|
||||
if(it.contains(carNo)){
|
||||
Log.i("TEST","findMatchInputCarNo $i")
|
||||
pageModel.rv?.smoothScrollToPosition(i)
|
||||
if(!list[i].checked.get()){
|
||||
list[i].checked.set(true)
|
||||
val oldValue = unSaveSelectedCount.value
|
||||
if (oldValue != null) {
|
||||
unSaveSelectedCount.postValue(oldValue+1)
|
||||
}
|
||||
pageModel.rv?.commonAdapter()?.notifyItemChanged(i)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun scanClick() {
|
||||
ScanModel.startScan(getTopActivity(), Constant.RequestCode.CAR)
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
if (data == null || resultCode != Activity.RESULT_OK) {
|
||||
return
|
||||
}
|
||||
when (requestCode) {
|
||||
Constant.RequestCode.CAR -> {
|
||||
car.value = data.getStringExtra(Constant.Result.CODED_CONTENT).noNull()
|
||||
refreshPage()
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
private fun resetUnSaveSelectedCount(){
|
||||
unSaveSelectedCount.postValue(0)
|
||||
}
|
||||
override fun onItemClick(position: Int, type: Int) {
|
||||
super.onItemClick(position, type)
|
||||
if(type == R.id.pda_gnc_checkBox){
|
||||
val list = pageModel.rv!!.commonAdapter()!!.items as List<GncCunFangBean>
|
||||
val oldValue = unSaveSelectedCount.value
|
||||
if (oldValue != null) {
|
||||
if(list[position].checked.get()){
|
||||
if(oldValue<list.size){
|
||||
unSaveSelectedCount.postValue(oldValue+1)
|
||||
}
|
||||
}else{
|
||||
if(oldValue>0){
|
||||
unSaveSelectedCount.postValue(oldValue-1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.sixin.module_p.ui.gnc.fubang.add
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.base.BasePdaActivity
|
||||
import com.sixin.module_p.databinding.ActivityPdaFuBangAddBinding
|
||||
|
||||
class PdaGncFuBangAddActivity :
|
||||
BasePdaActivity<ActivityPdaFuBangAddBinding, PdaGncFuBangAddViewModel>() {
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.activity_pda_fu_bang_add
|
||||
}
|
||||
|
||||
override fun viewModelClass(): Class<PdaGncFuBangAddViewModel> {
|
||||
return PdaGncFuBangAddViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国内出港开始复磅")
|
||||
viewModel.initOnCreated(requireActivity(),intent)
|
||||
binding.viewModel = viewModel
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
val starter = Intent(context, PdaGncFuBangAddActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
package com.sixin.module_p.ui.gnc.fubang.add
|
||||
|
||||
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 androidx.lifecycle.viewModelScope
|
||||
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.ConstantEvent
|
||||
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.impl.FlowBus
|
||||
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 kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlin.math.abs
|
||||
|
||||
class PdaGncFuBangAddViewModel : BaseViewModel() {
|
||||
|
||||
// 通道列表
|
||||
val passageList = MutableLiveData<List<KeyValue>>().apply {
|
||||
DictUtils.getChannelList {
|
||||
value = it
|
||||
}
|
||||
}
|
||||
|
||||
private val channel = MutableLiveData<String>()
|
||||
|
||||
// 货物类型
|
||||
val goodsTypeList = MutableLiveData<List<KeyValue>>(
|
||||
listOf(
|
||||
KeyValue("货物", "C"),
|
||||
KeyValue("邮件", "M"),
|
||||
KeyValue("空板箱", "X"),
|
||||
)
|
||||
)
|
||||
|
||||
private var goodsType = ""
|
||||
|
||||
// 打印挂签
|
||||
val print = MutableLiveData(false)
|
||||
|
||||
val showWeightEdit = MutableLiveData(true)
|
||||
|
||||
val dataBean = MutableLiveData(GncFuBangBean())
|
||||
|
||||
val diBangModel = DiBangWeightModel()
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
fun initOnCreated(activity: Activity,intent: Intent) {
|
||||
getDetails()
|
||||
|
||||
FlowBus.with<String>(ConstantEvent.SCAN_CODE_RESULT)
|
||||
.onEach {
|
||||
dataBean.value!!.carId = it
|
||||
getDetails()
|
||||
}.launchIn(viewModelScope)
|
||||
|
||||
diBangModel.weight.observe(activity as LifecycleOwner) {
|
||||
dataBean.value?.weighbridgeWeight = it
|
||||
}
|
||||
|
||||
channel.observe(activity as LifecycleOwner) {
|
||||
diBangModel.key = it
|
||||
}
|
||||
}
|
||||
|
||||
fun getDetails() {
|
||||
if (dataBean.value?.carId.isNullOrEmpty()) return
|
||||
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getGncFuBangDetailsByCar(dataBean.value!!.carId)
|
||||
}) {
|
||||
onSuccess = {
|
||||
it.data?.let { bean ->
|
||||
dataBean.value = bean
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onPassageSelected(position: Int) {
|
||||
channel.value = passageList.value!!.getOrNull(position)?.value ?: ""
|
||||
}
|
||||
|
||||
fun onGoodsTypeSelected(position: Int) {
|
||||
goodsType = goodsTypeList.value!!.getOrNull(position)?.value ?: ""
|
||||
}
|
||||
|
||||
fun onWeightLoginClick(): 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
|
||||
}
|
||||
|
||||
fun scanClick() {
|
||||
ScanModel.startScan(getTopActivity(), Constant.RequestCode.CAR)
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
if (data == null || resultCode != Activity.RESULT_OK) {
|
||||
return
|
||||
}
|
||||
when (requestCode) {
|
||||
Constant.RequestCode.CAR -> {
|
||||
dataBean.value!!.carId = data.getStringExtra(Constant.Result.CODED_CONTENT).noNull()
|
||||
getDetails()
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
diBangModel.cancelLooperGet()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.sixin.module_p.ui.gnc.shouyun.add
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.lukouguoji.module_base.adapter.bindAdapter
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.ktx.loge
|
||||
import com.lukouguoji.module_base.ktx.toJson
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.base.BasePdaActivity
|
||||
import com.sixin.module_p.databinding.ActivityPdaShouYunAddBinding
|
||||
import dev.utils.app.info.KeyValue
|
||||
|
||||
class PdaShouYunAddActivity :
|
||||
BasePdaActivity<ActivityPdaShouYunAddBinding, PdaShouYunAddViewModel>() {
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.activity_pda_shou_yun_add
|
||||
}
|
||||
|
||||
override fun viewModelClass(): Class<PdaShouYunAddViewModel> {
|
||||
return PdaShouYunAddViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国内出港开始收运")
|
||||
binding.viewModel = viewModel
|
||||
|
||||
viewModel.init(intent)
|
||||
|
||||
viewModel.dataBean.observe(this) {
|
||||
onInitDataChanged()
|
||||
}
|
||||
viewModel.agentList.observe(this) {
|
||||
bindAdapter(binding.spinnerAgent, it)
|
||||
binding.spinnerAgent.setSelection(getIndex(viewModel.dataBean.value!!.agentCode, it))
|
||||
}
|
||||
viewModel.spCodeList.observe(this) {
|
||||
bindAdapter(binding.spinnerSpCode, it)
|
||||
binding.spinnerSpCode.setSelection(getIndex(viewModel.dataBean.value!!.spCode, it))
|
||||
}
|
||||
viewModel.businessTypeList.observe(this) {
|
||||
bindAdapter(binding.spinnerBusinessType, it)
|
||||
binding.spinnerBusinessType
|
||||
.setSelection(getIndex(viewModel.dataBean.value!!.businessType, it))
|
||||
}
|
||||
viewModel.dangerousGoodsList.observe(this) {
|
||||
bindAdapter(binding.spinnerWxku, it)
|
||||
binding.spinnerWxku.setSelection(getIndex(viewModel.dataBean.value!!.dgrLocation, it))
|
||||
}
|
||||
viewModel.dangerousGoodsDescList.observe(this) {
|
||||
bindAdapter(binding.spinnerWxdesc, it)
|
||||
binding.spinnerWxdesc.setSelection(getIndex(viewModel.dataBean.value!!.dgrDetail, it))
|
||||
}
|
||||
viewModel.packageTypeList.observe(this) {
|
||||
bindAdapter(binding.spinnerPackageType, it)
|
||||
binding.spinnerPackageType.setSelection(getIndex(viewModel.dataBean.value!!.packageType, it))
|
||||
}
|
||||
}
|
||||
|
||||
private fun onInitDataChanged() {
|
||||
viewModel.dataBean.value?.let {
|
||||
binding.spinnerAgent.setSelection(getIndex(it.agentCode, viewModel.agentList.value!!))
|
||||
binding.spinnerSpCode.setSelection(getIndex(it.spCode, viewModel.spCodeList.value!!))
|
||||
binding.spinnerBusinessType.setSelection(
|
||||
getIndex(
|
||||
it.businessType,
|
||||
viewModel.businessTypeList.value!!
|
||||
)
|
||||
)
|
||||
binding.spinnerWxku.setSelection(
|
||||
getIndex(
|
||||
it.dgrLocation,
|
||||
viewModel.dangerousGoodsList.value!!
|
||||
)
|
||||
)
|
||||
binding.spinnerWxdesc.setSelection(
|
||||
getIndex(
|
||||
it.dgrDetail,
|
||||
viewModel.dangerousGoodsDescList.value!!
|
||||
)
|
||||
)
|
||||
binding.spinnerPackageType.setSelection(
|
||||
getIndex(
|
||||
it.packageType,
|
||||
viewModel.packageTypeList.value!!
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getIndex(data: String, list: List<KeyValue>): Int {
|
||||
val index = list.indexOfFirst { it.value == data }.coerceAtLeast(0)
|
||||
return index
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context, waybill: String = "") {
|
||||
val starter = Intent(context, PdaShouYunAddActivity::class.java)
|
||||
.putExtra(Constant.Key.WAYBILL, waybill)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,460 @@
|
||||
package com.sixin.module_p.ui.gnc.shouyun.add
|
||||
|
||||
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 androidx.lifecycle.viewModelScope
|
||||
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.ConstantEvent
|
||||
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.impl.FlowBus
|
||||
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.limit
|
||||
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.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 com.sixin.module_p.ui.gnc.shouyun.dialog.GncPdaShouYunSyncDialogModel
|
||||
import dev.DevUtils
|
||||
import dev.utils.app.info.KeyValue
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import okhttp3.RequestBody
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
class PdaShouYunAddViewModel : BaseViewModel() {
|
||||
|
||||
val pageType = MutableLiveData(DetailsPageType.Add)
|
||||
|
||||
// 通道
|
||||
val channel = MutableLiveData("")
|
||||
|
||||
// 重量
|
||||
val showWeightEdit = MutableLiveData(false)
|
||||
|
||||
// 通道列表
|
||||
val passageList = MutableLiveData(listOf(KeyValue("通道1", "001"))).apply {
|
||||
DictUtils.getChannelList {
|
||||
value = it
|
||||
}
|
||||
}
|
||||
|
||||
// 代理人列表
|
||||
val agentList = MutableLiveData(emptyList<KeyValue>()).apply {
|
||||
DictUtils.getGncAgentList(addAll = false) {
|
||||
value = listOf(KeyValue("", "")) + it
|
||||
}
|
||||
}
|
||||
|
||||
// 特码列表
|
||||
val spCodeList = MutableLiveData(emptyList<KeyValue>()).apply {
|
||||
DictUtils.getSpecialCodeList(addAll = false) {
|
||||
value = listOf(KeyValue("", "")) + it
|
||||
}
|
||||
}
|
||||
|
||||
// 业务类型列表
|
||||
val businessTypeList = MutableLiveData(emptyList<KeyValue>()).apply {
|
||||
DictUtils.getBusinessTypeList(type = "CO", addAll = false) {
|
||||
value = listOf(KeyValue("", "")) + it
|
||||
}
|
||||
}
|
||||
|
||||
// 危险品库列表
|
||||
val dangerousGoodsList = MutableLiveData(emptyList<KeyValue>()).apply {
|
||||
DictUtils.getWxKuList {
|
||||
value = listOf(KeyValue("", "")) + it
|
||||
}
|
||||
}
|
||||
|
||||
// 危险品描述
|
||||
val dangerousGoodsDescList = MutableLiveData(emptyList<KeyValue>()).apply {
|
||||
DictUtils.getWxDescListValue {
|
||||
value = listOf(KeyValue("", "")) + it
|
||||
}
|
||||
}
|
||||
|
||||
// 包装类型
|
||||
val packageTypeList = MutableLiveData(emptyList<KeyValue>()).apply {
|
||||
DictUtils.getShouYunPackageTypeList {
|
||||
value = listOf(KeyValue("", "")) + it
|
||||
}
|
||||
}
|
||||
|
||||
val dataBean = MutableLiveData(GncShouYunBean())
|
||||
|
||||
val print = MutableLiveData(true)
|
||||
|
||||
|
||||
val diBangModel = DiBangWeightModel()
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
fun init(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
|
||||
}
|
||||
|
||||
// 监听扫描信息
|
||||
FlowBus.with<String>(ConstantEvent.SCAN_CODE_RESULT)
|
||||
.onEach {
|
||||
if (it.length == 11) {
|
||||
dataBean.value!!.wbNo = it
|
||||
getDetails()
|
||||
} else {
|
||||
dataBean.value!!.carNo = it
|
||||
getCarInfo()
|
||||
}
|
||||
}
|
||||
.launchIn(viewModelScope)
|
||||
}
|
||||
|
||||
fun onPassageSelected(position: Int) {
|
||||
channel.value = passageList.value!!.getOrNull(position)?.value ?: ""
|
||||
}
|
||||
|
||||
fun onAgentSelected(position: Int) {
|
||||
dataBean.value!!.agentCode = agentList.value!!.getOrNull(position)?.value ?: ""
|
||||
}
|
||||
|
||||
fun onSpCodeSelected(position: Int) {
|
||||
dataBean.value!!.spCode = spCodeList.value!!.getOrNull(position)?.value ?: ""
|
||||
}
|
||||
|
||||
fun onBusinessTypeSelected(position: Int) {
|
||||
dataBean.value!!.businessType = businessTypeList.value!!.getOrNull(position)?.value ?: ""
|
||||
}
|
||||
|
||||
fun onDangerousGoodsSelected(position: Int) {
|
||||
dataBean.value!!.dgrLocation = dangerousGoodsList.value!!.getOrNull(position)?.value ?: ""
|
||||
}
|
||||
|
||||
fun onDangerousGoodsDescSelected(position: Int) {
|
||||
dataBean.value!!.dgrDetail = dangerousGoodsDescList.value!!.getOrNull(position)?.value ?: ""
|
||||
}
|
||||
|
||||
fun onPackageTypeSelected(position: Int) {
|
||||
dataBean.value!!.packageType = packageTypeList.value!!.getOrNull(position)?.value ?: ""
|
||||
}
|
||||
|
||||
fun onWeightLoginClick(): Boolean {
|
||||
showWeightEdit.value = true
|
||||
return true
|
||||
}
|
||||
|
||||
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 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 onVerifyClick() {
|
||||
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 onSplitClick() {
|
||||
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 onConfirmClick() {
|
||||
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
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
GncPdaShouYunSyncDialogModel(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@GncPdaShouYunSyncDialogModel
|
||||
return@GncPdaShouYunSyncDialogModel
|
||||
}
|
||||
if (weight <= 0){
|
||||
showToast("本次收运重量少于等于0!")
|
||||
return@GncPdaShouYunSyncDialogModel
|
||||
}
|
||||
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("同步成功"))
|
||||
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
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
fun carScanClick() {
|
||||
ScanModel.startScan(getTopActivity(), Constant.RequestCode.CAR)
|
||||
}
|
||||
|
||||
fun waybillScanClick() {
|
||||
ScanModel.startScan(getTopActivity(), Constant.RequestCode.WAYBILL)
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
if (data == null || resultCode != Activity.RESULT_OK) {
|
||||
return
|
||||
}
|
||||
when (requestCode) {
|
||||
Constant.RequestCode.CAR -> {
|
||||
dataBean.value!!.carNo = data.getStringExtra(Constant.Result.CODED_CONTENT).noNull()
|
||||
getCarInfo()
|
||||
}
|
||||
|
||||
Constant.RequestCode.WAYBILL -> {
|
||||
dataBean.value!!.wbNo = data.getStringExtra(Constant.Result.CODED_CONTENT).noNull()
|
||||
getDetails()
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
diBangModel.cancelLooperGet()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.lukouguoji.gnc.page.stash.details
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.sixin.module_p.R
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.sixin.module_p.base.BasePdaActivity
|
||||
import com.sixin.module_p.databinding.ActivityPdaGncStashDetailsBinding
|
||||
|
||||
class GncPdaStashDetailsActivity :
|
||||
BasePdaActivity<ActivityPdaGncStashDetailsBinding, GncPdaStashDetailsViewModel>() {
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.activity_pda_gnc_stash_details
|
||||
}
|
||||
|
||||
override fun viewModelClass(): Class<GncPdaStashDetailsViewModel> {
|
||||
return GncPdaStashDetailsViewModel::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, GncPdaStashDetailsActivity::class.java)
|
||||
.putExtra(Constant.Key.ID, whId)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
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
|
||||
|
||||
class GncPdaStashDetailsViewModel : 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,109 @@
|
||||
package com.sixin.module_p.ui.gnc.shouyun.dialog
|
||||
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.module_base.base.BaseDialogModel
|
||||
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 com.sixin.module_p.R
|
||||
import com.sixin.module_p.databinding.DialogPdaGncShouYunSyncBinding
|
||||
import dev.DevUtils
|
||||
|
||||
class GncPdaShouYunSyncDialogModel(
|
||||
val waybill: String,
|
||||
val list: List<ShouYunSyncBean>,
|
||||
val callBack: (GncPdaShouYunSyncDialogModel) -> Unit
|
||||
) : BaseDialogModel<DialogPdaGncShouYunSyncBinding>(DIALOG_TYPE_FULL) {
|
||||
|
||||
val viewHolder = GncPdaShouYunSyncViewHolder::class.java
|
||||
val itemLayoutId = R.layout.item_pda_gnc_shou_yun_sync
|
||||
val number = MutableLiveData("0")
|
||||
val weight = MutableLiveData("0")
|
||||
|
||||
override fun onBuild(builder: XPopup.Builder) {
|
||||
builder.autoDismiss(false)
|
||||
.dismissOnBackPressed(false)
|
||||
.dismissOnTouchOutside(false)
|
||||
.enableDrag(false)
|
||||
}
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.dialog_pda_gnc_shou_yun_sync
|
||||
}
|
||||
|
||||
override fun onDialogCreated(context: Context) {
|
||||
binding.model = this
|
||||
binding.root.findViewById<TextView>(R.id.title_name).text = "同步操作"
|
||||
binding.root.findViewById<View>(R.id.tool_back).setOnClickListener { dismiss() }
|
||||
binding.root.findViewById<View>(R.id.tool_tv_back).visibility = View.GONE
|
||||
|
||||
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() {
|
||||
println("confirmClick:"+list.get(0).pc)
|
||||
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,17 @@
|
||||
package com.sixin.module_p.ui.gnc.shouyun.dialog
|
||||
|
||||
import android.view.View
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.ShouYunSyncBean
|
||||
import com.sixin.module_p.databinding.DialogPdaGncShouYunSyncBinding
|
||||
import com.sixin.module_p.databinding.ItemPdaGncShouYunSyncBinding
|
||||
|
||||
class GncPdaShouYunSyncViewHolder(view: View) :
|
||||
BaseViewHolder<ShouYunSyncBean, ItemPdaGncShouYunSyncBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
val bean = getItemBean(item)!!
|
||||
binding.bean = bean
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.sixin.module_p.ui.gnc.shouyun.dialog
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.alibaba.fastjson.JSONArray
|
||||
import com.lukouguoji.module_base.base.BaseDialogModel
|
||||
import com.lukouguoji.module_base.ktx.formatDate
|
||||
import com.lukouguoji.module_base.ktx.toJson
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.lukouguoji.module_base.util.DictUtils
|
||||
import com.lxj.xpopup.XPopup
|
||||
import com.lxj.xpopup.enums.PopupPosition
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.databinding.DialogPdaCunfangFilterBinding
|
||||
import com.sixin.module_p.databinding.DialogPdaDaishouyunFilterBinding
|
||||
import dev.DevUtils
|
||||
import dev.utils.app.info.KeyValue
|
||||
import dev.utils.common.DateUtils
|
||||
import java.util.Calendar
|
||||
|
||||
class PdaDaiShouYunFilterDialogModel(
|
||||
private val callBack: () -> Unit
|
||||
) : BaseDialogModel<DialogPdaDaishouyunFilterBinding>(DIALOG_TYPE_DRAWER) {
|
||||
|
||||
val date = MutableLiveData(DateUtils.getCurrentTime().formatDate())
|
||||
|
||||
val flightNo = MutableLiveData("")
|
||||
|
||||
val dest = MutableLiveData("")
|
||||
|
||||
// 代理
|
||||
val agent = MutableLiveData("")
|
||||
|
||||
// 特码
|
||||
val spCode = MutableLiveData("")
|
||||
val spCodeDesc = MutableLiveData("全部")
|
||||
|
||||
val agentList = MutableLiveData<List<KeyValue>>(listOf()).apply {
|
||||
DictUtils.getAgentList {
|
||||
value = it
|
||||
}
|
||||
}
|
||||
val spCodeList = MutableLiveData<List<KeyValue>>(listOf()).apply {
|
||||
DictUtils.getSpecialCodeList {
|
||||
value = it
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.dialog_pda_daishouyun_filter
|
||||
}
|
||||
|
||||
override fun onDialogCreated(context: Context) {
|
||||
binding.model = this
|
||||
}
|
||||
|
||||
fun onAgentSelected(position: Int) {
|
||||
agent.value = agentList.value?.get(position)?.value
|
||||
}
|
||||
|
||||
fun onSpCodeSelected(position: Int) {
|
||||
spCode.value = spCodeList.value?.get(position)?.value
|
||||
}
|
||||
|
||||
fun spCodeClick() {
|
||||
Common.singleSelect(
|
||||
DevUtils.getTopActivity(),
|
||||
"选择特码",
|
||||
JSONArray.parseArray(spCodeList.value!!.map {
|
||||
mapOf(
|
||||
"name" to it.key,
|
||||
"code" to it.value,
|
||||
)
|
||||
}.toList().toJson(false)),
|
||||
null
|
||||
) { position, _ ->
|
||||
spCode.value = spCodeList.value?.get(position)?.value
|
||||
spCodeDesc.value = spCodeList.value?.get(position)?.key
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBuild(builder: XPopup.Builder) {
|
||||
builder.popupPosition(PopupPosition.Right)
|
||||
}
|
||||
|
||||
fun onDateClick() {
|
||||
Common.onYearMonthDay(DevUtils.getTopActivity(), date.value) { year, month, day ->
|
||||
val calendar = Calendar.getInstance()
|
||||
calendar.set(year, month - 1, day)
|
||||
date.value = DateUtils.formatDate(calendar.time, "yyyy-MM-dd")
|
||||
}
|
||||
}
|
||||
|
||||
fun onResetClick() {
|
||||
date.value = DateUtils.getCurrentTime().formatDate()
|
||||
flightNo.value = ""
|
||||
if (binding.spinnerArea.adapter.count > 0) {
|
||||
binding.spinnerArea.setSelection(0)
|
||||
}
|
||||
spCode.value = ""
|
||||
spCodeDesc.value = "全部"
|
||||
dest.value = ""
|
||||
|
||||
callBack.invoke()
|
||||
dismiss()
|
||||
}
|
||||
|
||||
fun onConfirmClick() {
|
||||
callBack.invoke()
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package com.sixin.module_p.ui.gnc.shouyun.dialog
|
||||
|
||||
import android.content.Context
|
||||
import android.text.Editable
|
||||
import android.widget.EditText
|
||||
import androidx.core.widget.addTextChangedListener
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.Observer
|
||||
import com.alibaba.fastjson.JSONArray
|
||||
import com.lukouguoji.module_base.base.BaseDialogModel
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.ktx.formatDate
|
||||
import com.lukouguoji.module_base.ktx.getActivity
|
||||
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.loge
|
||||
import com.lukouguoji.module_base.ktx.toJson
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.lukouguoji.module_base.util.DictUtils
|
||||
import com.lxj.xpopup.XPopup
|
||||
import com.lxj.xpopup.enums.PopupPosition
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.databinding.DialogPdaShouyunFilterBinding
|
||||
import dev.DevUtils
|
||||
import dev.utils.app.ViewUtils.findViewById
|
||||
import dev.utils.app.info.KeyValue
|
||||
import dev.utils.common.DateUtils
|
||||
import java.util.Calendar
|
||||
|
||||
class PdaShouYunFilterDialogModel(
|
||||
private val scanClick: () -> Unit,
|
||||
private val callBack: () -> Unit
|
||||
) : BaseDialogModel<DialogPdaShouyunFilterBinding>(DIALOG_TYPE_DRAWER) {
|
||||
|
||||
val date = MutableLiveData("")
|
||||
val dateRuKu = MutableLiveData(DateUtils.getCurrentTime().formatDate())
|
||||
|
||||
val flightNo = MutableLiveData("")
|
||||
|
||||
val waybill = MutableLiveData("")
|
||||
private val waybillLive: LiveData<String> = waybill
|
||||
|
||||
val wbNoList = MutableLiveData<List<String>>()
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.dialog_pda_shouyun_filter
|
||||
}
|
||||
|
||||
override fun onDialogCreated(context: Context) {
|
||||
binding.model = this
|
||||
|
||||
waybillLive.observe(context.getLifecycleOwner(), Observer { result ->
|
||||
if (result != null && result.length >=4 && result.length < 9) {
|
||||
getWbNoList(result)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
override fun onBuild(builder: XPopup.Builder) {
|
||||
builder.popupPosition(PopupPosition.Right)
|
||||
|
||||
}
|
||||
|
||||
fun onDateClick() {
|
||||
Common.onYearMonthDay(DevUtils.getTopActivity(), date.value) { year, month, day ->
|
||||
val calendar = Calendar.getInstance()
|
||||
calendar.set(year, month - 1, day)
|
||||
date.value = DateUtils.formatDate(calendar.time, "yyyy-MM-dd")
|
||||
}
|
||||
}
|
||||
|
||||
fun onDateRKClick() {
|
||||
Common.onYearMonthDay(DevUtils.getTopActivity(), dateRuKu.value) { year, month, day ->
|
||||
val calendar = Calendar.getInstance()
|
||||
calendar.set(year, month - 1, day)
|
||||
dateRuKu.value = DateUtils.formatDate(calendar.time, "yyyy-MM-dd")
|
||||
}
|
||||
}
|
||||
|
||||
fun onResetClick() {
|
||||
dateRuKu.value = DateUtils.getCurrentTime().formatDate()
|
||||
date.value = ""
|
||||
flightNo.value = ""
|
||||
waybill.value = ""
|
||||
callBack.invoke()
|
||||
dismiss()
|
||||
}
|
||||
|
||||
fun onConfirmClick() {
|
||||
callBack.invoke()
|
||||
dismiss()
|
||||
}
|
||||
|
||||
fun onWaybillScanClick() {
|
||||
scanClick.invoke()
|
||||
}
|
||||
private fun getWbNoList(input: String) {
|
||||
val requestBody = mapOf(
|
||||
"page" to 1,
|
||||
"limit" to 20,
|
||||
"fdate" to date.value,
|
||||
"opDate" to dateRuKu.value,
|
||||
"fno" to flightNo.value,
|
||||
"wbNo" to input,
|
||||
).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 = { 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]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.sixin.module_p.ui.gnc.shouyun.list
|
||||
|
||||
import android.view.View
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.GncShouYunBean
|
||||
import com.sixin.module_p.databinding.ItemShouYunListBinding
|
||||
|
||||
class GncShouYunViewHolder(view: View) :
|
||||
BaseViewHolder<GncShouYunBean, ItemShouYunListBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
binding.bean = getItemBean(item)
|
||||
notifyItemClick(position, binding.llContent)
|
||||
notifyItemClick(position, binding.shouyunItem)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
package com.sixin.module_p.ui.gnc.shouyun.list
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.lukouguoji.gnc.page.stash.details.GncPdaStashDetailsActivity
|
||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
||||
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.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.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.BluetoothDialogModel
|
||||
import com.lukouguoji.module_base.model.ScanModel
|
||||
import com.lukouguoji.module_base.util.PrinterUtils
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.ui.gnc.shouyun.dialog.GncPdaShouYunSyncDialogModel
|
||||
import com.sixin.module_p.ui.gnc.shouyun.dialog.PdaShouYunFilterDialogModel
|
||||
import com.sixin.module_p.ui.gnc.shouyun.un.list.GncUnShouYunViewHolder
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
|
||||
class GncShouYunViewModel : BasePageViewModel() {
|
||||
|
||||
// 平板车
|
||||
val keyWord = MutableLiveData("")
|
||||
|
||||
// 数量
|
||||
val count = MutableLiveData(0)
|
||||
|
||||
val itemLayoutId = R.layout.item_shou_yun_list
|
||||
val itemViewHolder = GncShouYunViewHolder::class.java
|
||||
|
||||
// 筛选
|
||||
private val filterModel = PdaShouYunFilterDialogModel({
|
||||
ScanModel.startScan(getTopActivity(), Constant.RequestCode.WAYBILL)
|
||||
}) {
|
||||
refresh()
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
init {
|
||||
FlowBus.with<String>(ConstantEvent.SCAN_CODE_RESULT)
|
||||
.onEach {
|
||||
if (it.length == 11) {
|
||||
filterModel.waybill.value = it
|
||||
refresh()
|
||||
} else {
|
||||
keyWord.value = it
|
||||
onCarChange(false)
|
||||
}
|
||||
}
|
||||
.launchIn(viewModelScope)
|
||||
}
|
||||
|
||||
override fun getData() {
|
||||
val requestBody = mapOf(
|
||||
"page" to pageModel.page,
|
||||
"limit" to pageModel.limit,
|
||||
"location" to keyWord.value,
|
||||
"fdate" to filterModel.date.value,
|
||||
"opDate" to filterModel.dateRuKu.value,
|
||||
"fno" to filterModel.flightNo.value,
|
||||
"wbNo" to filterModel.waybill.value,
|
||||
).toRequestBody()
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getGncShouYunList(requestBody)
|
||||
}) {
|
||||
onSuccess = {
|
||||
pageModel.handleListBean(it)
|
||||
count.value = it.total
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onCarChange(focused: Boolean = false) {
|
||||
if (focused) {
|
||||
return
|
||||
}
|
||||
refresh()
|
||||
}
|
||||
|
||||
override fun onItemClick(position: Int, type: Int) {
|
||||
println("国内出港收运记录 onItemClick...")
|
||||
when (type) {
|
||||
R.id.shouyunItem -> {
|
||||
// TODO: item点击
|
||||
println("国内出港收运记录 onItemClick...")
|
||||
val bean = pageModel.rv!!.commonAdapter()!!.getItem(position) as GncShouYunBean
|
||||
GncPdaStashDetailsActivity.start(getTopActivity(), bean.whId)
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
fun onFilterClick() {
|
||||
filterModel.show()
|
||||
}
|
||||
|
||||
fun scanClick() {
|
||||
ScanModel.startScan(getTopActivity(), Constant.RequestCode.CAR)
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
if (data == null || resultCode != Activity.RESULT_OK) {
|
||||
return
|
||||
}
|
||||
when (requestCode) {
|
||||
Constant.RequestCode.CAR -> {
|
||||
keyWord.value = data.getStringExtra(Constant.Result.CODED_CONTENT).noNull()
|
||||
refresh()
|
||||
}
|
||||
|
||||
Constant.RequestCode.WAYBILL -> {
|
||||
filterModel.waybill.value =
|
||||
data.getStringExtra(Constant.Result.CODED_CONTENT).noNull()
|
||||
refresh()
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun printClick() {
|
||||
val list =
|
||||
(pageModel.rv!!.commonAdapter()!!.items as List<GncShouYunBean>).filter { it.checked.get() }
|
||||
if (list.isEmpty()) {
|
||||
showToast("请选择需要打印的数据")
|
||||
return
|
||||
}
|
||||
BluetoothDialogModel()
|
||||
.showCallBack {
|
||||
list.forEach {
|
||||
PrinterUtils.printShouYun(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示重新同步
|
||||
*/
|
||||
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) }
|
||||
GncPdaShouYunSyncDialogModel(no, list1) { model ->
|
||||
println(model.list)
|
||||
launchLoadingCollect({
|
||||
NetApply.api.anyPost(
|
||||
"DomExpCheckIn/reUpdateAgt",
|
||||
mapOf(
|
||||
"list" to model.list
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = { b ->
|
||||
showToast(b.msg.noNull("重新同步成功"))
|
||||
}
|
||||
}
|
||||
}.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.sixin.module_p.ui.gnc.shouyun.list
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.lukouguoji.module_base.ktx.addOnItemClickListener
|
||||
import com.lukouguoji.module_base.ktx.getLifecycleOwner
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.base.BasePdaActivity
|
||||
import com.sixin.module_p.databinding.ActivityPdaGncShouyunListBinding
|
||||
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_GOUT_COLLECTION_RECORD_ACTIVITY)
|
||||
class PdaGncShouYunActivity :
|
||||
BasePdaActivity<ActivityPdaGncShouyunListBinding, GncShouYunViewModel>() {
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.activity_pda_gnc_shouyun_list
|
||||
}
|
||||
|
||||
override fun viewModelClass(): Class<GncShouYunViewModel> {
|
||||
return GncShouYunViewModel::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, PdaGncShouYunActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.sixin.module_p.ui.gnc.shouyun.un.list
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.widget.EditText
|
||||
import androidx.core.widget.addTextChangedListener
|
||||
import com.lukouguoji.module_base.ktx.addOnItemClickListener
|
||||
import com.lukouguoji.module_base.ktx.getLifecycleOwner
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.base.BasePdaActivity
|
||||
import com.sixin.module_p.databinding.ActivityGncUnShouYunBinding
|
||||
|
||||
class GncUnShouYunActivity :
|
||||
BasePdaActivity<ActivityGncUnShouYunBinding, GncUnShouYunViewModel>() {
|
||||
|
||||
private lateinit var editText: EditText
|
||||
private var mTextWatcher: TextWatcher? = null
|
||||
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.activity_gnc_un_shou_yun
|
||||
}
|
||||
|
||||
override fun viewModelClass(): Class<GncUnShouYunViewModel> {
|
||||
return GncUnShouYunViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国内出港待收运")
|
||||
binding.viewModel = viewModel
|
||||
|
||||
viewModel.pageModel.bindSmartRefreshLayout(
|
||||
binding.srl,
|
||||
binding.rv,
|
||||
viewModel,
|
||||
getLifecycleOwner()
|
||||
)
|
||||
|
||||
binding.rv.addOnItemClickListener(viewModel)
|
||||
|
||||
editText = findViewById(R.id.editText)
|
||||
|
||||
mTextWatcher = 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(s: Editable?) {
|
||||
val input = s?.toString()?.trim()
|
||||
if (input != null && input.length >= 4 && input.length < 8) {
|
||||
viewModel.getWayBillList(input)
|
||||
}
|
||||
}
|
||||
}
|
||||
editText.addTextChangedListener(mTextWatcher)
|
||||
|
||||
}
|
||||
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
viewModel.refresh()
|
||||
}
|
||||
override fun onStop(){
|
||||
super.onStop()
|
||||
// 安全移除(自动处理 null 检查)
|
||||
mTextWatcher?.let { editText.removeTextChangedListener(it) }
|
||||
mTextWatcher = null // 帮助 GC 回收
|
||||
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
val starter = Intent(context, GncUnShouYunActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.sixin.module_p.ui.gnc.shouyun.un.list
|
||||
|
||||
import android.view.View
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.GncShouYunBean
|
||||
import com.sixin.module_p.databinding.ItemUnShouYunListBinding
|
||||
|
||||
class GncUnShouYunViewHolder(view: View) :
|
||||
BaseViewHolder<GncShouYunBean, ItemUnShouYunListBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
binding.bean = getItemBean(item)
|
||||
notifyItemClick(position, binding.llContent)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
package com.sixin.module_p.ui.gnc.shouyun.un.list
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.util.Log
|
||||
import android.widget.ArrayAdapter
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.alibaba.fastjson.JSONArray
|
||||
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.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.toJson
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.lukouguoji.module_base.model.ScanModel
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.ui.gnc.shouyun.add.PdaShouYunAddActivity
|
||||
import com.sixin.module_p.ui.gnc.shouyun.dialog.PdaDaiShouYunFilterDialogModel
|
||||
import com.sixin.module_p.ui.gnc.shouyun.list.PdaGncShouYunActivity
|
||||
import dev.DevUtils
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
class GncUnShouYunViewModel : BasePageViewModel() {
|
||||
|
||||
// 运单号
|
||||
val waybill = MutableLiveData("")
|
||||
|
||||
// 数量
|
||||
val count = MutableLiveData(0)
|
||||
|
||||
val itemLayoutId = R.layout.item_un_shou_yun_list
|
||||
val itemViewHolder = GncUnShouYunViewHolder::class.java
|
||||
|
||||
val wbNoList = MutableLiveData<List<String>>()
|
||||
|
||||
private val filterModel = PdaDaiShouYunFilterDialogModel {
|
||||
getData()
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
init {
|
||||
FlowBus.with<String>(ConstantEvent.SCAN_CODE_RESULT)
|
||||
.onEach {
|
||||
waybill.value = it
|
||||
onWaybillChange(focused = false)
|
||||
}
|
||||
.launchIn(viewModelScope)
|
||||
}
|
||||
fun getWayBillList(input : String) {
|
||||
val requestBody = mapOf(
|
||||
"pageNum" to pageModel.page,
|
||||
"pageSize" to pageModel.limit,
|
||||
"fdate" to filterModel.date.value,
|
||||
"fno" to filterModel.flightNo.value,
|
||||
"agentCode" to filterModel.agent.value,
|
||||
"spCode" to filterModel.spCode.value,
|
||||
"dest" to filterModel.dest.value,
|
||||
"wbNo" to input
|
||||
).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()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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!!.get(position)
|
||||
onWaybillChange(false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getData() {
|
||||
val requestBody = mapOf(
|
||||
"pageNum" to pageModel.page,
|
||||
"pageSize" to pageModel.limit,
|
||||
"fdate" to filterModel.date.value,
|
||||
"fno" to filterModel.flightNo.value,
|
||||
"agentCode" to filterModel.agent.value,
|
||||
"spCode" to filterModel.spCode.value,
|
||||
"wbNo" to waybill.value,
|
||||
"dest" to filterModel.dest.value,
|
||||
).toRequestBody()
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getGncShouYunUnList(
|
||||
requestBody
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
pageModel.handleListBean(it)
|
||||
count.value = it.total
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onWaybillChange(focused: Boolean = false) {
|
||||
if (focused) {
|
||||
return
|
||||
}
|
||||
refresh()
|
||||
}
|
||||
|
||||
override fun onItemClick(position: Int, type: Int) {
|
||||
loge("点击事件: $position $type")
|
||||
val bean = pageModel.rv!!.commonAdapter()!!.getItem(position) as GncShouYunBean
|
||||
when (type) {
|
||||
R.id.ll_content -> {
|
||||
PdaShouYunAddActivity.start(DevUtils.getTopActivity(), bean.wbNo)
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
fun onFilterClick() {
|
||||
filterModel.show()
|
||||
}
|
||||
|
||||
fun onAddClick() {
|
||||
PdaShouYunAddActivity.start(DevUtils.getTopActivity())
|
||||
}
|
||||
|
||||
fun onMenuClick() {
|
||||
PdaGncShouYunActivity.start(DevUtils.getTopActivity())
|
||||
}
|
||||
|
||||
fun scanClick() {
|
||||
ScanModel.startScan(getTopActivity(), Constant.RequestCode.WAYBILL)
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
loge(
|
||||
"扫码返回信息 : $resultCode ; ${data != null} ; ${
|
||||
data?.getStringExtra(Constant.Result.CODED_CONTENT).noNull()
|
||||
}"
|
||||
)
|
||||
if (data == null || resultCode != Activity.RESULT_OK) {
|
||||
return
|
||||
}
|
||||
when (requestCode) {
|
||||
Constant.RequestCode.WAYBILL -> {
|
||||
waybill.value = data.getStringExtra(Constant.Result.CODED_CONTENT).noNull()
|
||||
onWaybillChange(focused = false)
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.sixin.module_p.ui.gnj.accidentVisa.add
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.view.ViewGroup
|
||||
import android.widget.EditText
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.common.DetailsPageType
|
||||
import com.lukouguoji.module_base.ktx.addOnItemClickListener
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.base.BasePdaActivity
|
||||
import com.sixin.module_p.databinding.ActivityAccidentVisaAddBinding
|
||||
|
||||
|
||||
class PdaAccidentVisaAddActivity :
|
||||
BasePdaActivity<ActivityAccidentVisaAddBinding, PdaAccidentVisaAddViewModel>() {
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.activity_accident_visa_add
|
||||
}
|
||||
|
||||
override fun viewModelClass(): Class<PdaAccidentVisaAddViewModel> {
|
||||
return PdaAccidentVisaAddViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
viewModel.rv = binding.rv
|
||||
viewModel.initOnCreate(intent)
|
||||
|
||||
setBackArrow("国内事故签证${viewModel.pageType.value!!.title}")
|
||||
|
||||
binding.viewModel = viewModel
|
||||
binding.rv.addOnItemClickListener(viewModel)
|
||||
|
||||
// 调用方法修改所有 EditText 的背景色
|
||||
if(viewModel.pageType.value == DetailsPageType.Add){
|
||||
println("--------------调用方法修改所有 EditText 的背景色")
|
||||
var large = findViewById<ViewGroup>(R.id.largeView)
|
||||
large.setBackgroundColor(Color.parseColor("#F2F0EA"))
|
||||
|
||||
var group = findViewById<ViewGroup>(R.id.addVisa)
|
||||
changeEditTextBackgroundColor(group, Color.parseColor("#F2F0EA")) // 设置为白色 灰色 #F2F0EA
|
||||
// group.setBackgroundColor(Color.parseColor("#FFFFFFFF"))
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
private fun changeEditTextBackgroundColor(group: ViewGroup, color: Int) {
|
||||
group.setBackgroundColor(color)
|
||||
for (i in 0 until group.childCount) {
|
||||
val view = group.getChildAt(i)
|
||||
if (view is EditText) {
|
||||
view.setBackgroundColor(Color.parseColor("#FFFFFFFF")) // 修改背景色
|
||||
} else if (view is ViewGroup) {
|
||||
changeEditTextBackgroundColor(view, color) // 递归处理子视图
|
||||
}
|
||||
}
|
||||
}
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context, id: String = "", editable: Boolean = id.isEmpty()) {
|
||||
val starter = Intent(context, PdaAccidentVisaAddActivity::class.java)
|
||||
.putExtra(Constant.Key.ID, id)
|
||||
.putExtra(Constant.Key.DATA, editable)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.sixin.module_p.ui.gnj.accidentVisa.add
|
||||
|
||||
import android.view.View
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.FlatcarBean
|
||||
import com.sixin.module_p.databinding.ItemPdaGnjXiejiAddBinding
|
||||
|
||||
class PdaAccidentVisaAddViewHolder(view: View) :
|
||||
BaseViewHolder<FlatcarBean, ItemPdaGnjXiejiAddBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
binding.bean = getItemBean(item)
|
||||
notifyItemClick(position, binding.tvDelete)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
package com.sixin.module_p.ui.gnj.accidentVisa.add
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.lukouguoji.module_base.base.BaseViewModel
|
||||
import com.lukouguoji.module_base.bean.AccidentVisaBean
|
||||
import com.lukouguoji.module_base.bean.FileBean
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.common.DetailsPageType
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.impl.PdaImageSelectViewHolder
|
||||
import com.lukouguoji.module_base.interfaces.IOnItemClickListener
|
||||
import com.lukouguoji.module_base.ktx.commonAdapter
|
||||
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.showToast
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.lukouguoji.module_base.ktx.verifyNullOrEmpty
|
||||
import com.lukouguoji.module_base.model.ScanModel
|
||||
import com.lukouguoji.module_base.util.MediaUtil
|
||||
import com.lukouguoji.module_base.util.UploadUtil
|
||||
import com.sixin.module_p.R
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.asFlow
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.filter
|
||||
import kotlinx.coroutines.flow.flowOn
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.onCompletion
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.flow.onStart
|
||||
|
||||
class PdaAccidentVisaAddViewModel : BaseViewModel(), IOnItemClickListener {
|
||||
|
||||
var id = ""
|
||||
|
||||
|
||||
val itemLayoutId = R.layout.pda_item_image_select
|
||||
val itemViewHolder = PdaImageSelectViewHolder::class.java
|
||||
var rv: RecyclerView? = null
|
||||
|
||||
val dataBean = MutableLiveData(AccidentVisaBean())
|
||||
|
||||
val pageType = MutableLiveData(DetailsPageType.Add)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
fun initOnCreate(intent: Intent) {
|
||||
id = intent.getStringExtra(Constant.Key.ID) ?: ""
|
||||
val modify = intent.getBooleanExtra(Constant.Key.DATA, false)
|
||||
pageType.value = if (id.isEmpty()) DetailsPageType.Add
|
||||
else if (modify) DetailsPageType.Modify else DetailsPageType.Details
|
||||
|
||||
if (id.isNotEmpty()) {
|
||||
getData()
|
||||
}
|
||||
|
||||
rv?.post {
|
||||
loge("获取页面类型 : ${pageType.value?.title}")
|
||||
if (pageType.value != DetailsPageType.Details) {
|
||||
rv?.commonAdapter()?.addItem(FileBean())
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun getData() {
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getGnAccidentVisaDetails(id)
|
||||
}) {
|
||||
onSuccess = {
|
||||
dataBean.value = it.data ?: AccidentVisaBean()
|
||||
|
||||
// 渲染图片
|
||||
val list = dataBean.value!!.pic.split(",")
|
||||
.filter { url -> url.isNotEmpty() }
|
||||
.map { url ->
|
||||
FileBean(MediaUtil.fillUrl(url), url)
|
||||
}
|
||||
val zipList = dataBean.value!!.originalPic.split(",")
|
||||
.filter { url -> url.isNotEmpty() }
|
||||
.map { url ->
|
||||
FileBean(MediaUtil.fillUrl(url))
|
||||
}
|
||||
for ((index, fileBean) in list.withIndex()) {
|
||||
val originalPic = zipList.get(index).path
|
||||
fileBean.originalPic= originalPic
|
||||
}
|
||||
|
||||
rv?.commonAdapter()
|
||||
?.loadMore(list)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun reSet(){
|
||||
dataBean.value = AccidentVisaBean()
|
||||
}
|
||||
|
||||
fun onSaveClick() {
|
||||
val bean = dataBean.value!!
|
||||
if (bean.fno.verifyNullOrEmpty("请输入航班号")) {
|
||||
return
|
||||
}
|
||||
|
||||
(rv?.commonAdapter()?.items ?: emptyList())
|
||||
.asFlow()
|
||||
.map {
|
||||
it as FileBean
|
||||
}
|
||||
.filter { it.path.isNotEmpty() && it.url.isEmpty() }
|
||||
.onEach {
|
||||
val data = UploadUtil.upload(it.path).data
|
||||
it.url = data?.newName ?: ""
|
||||
it.originalPic = data?.zipFileName ?: ""
|
||||
}
|
||||
.flowOn(Dispatchers.IO)
|
||||
.onStart { showLoading() }
|
||||
.catch {
|
||||
showToast(it.message.noNull("上传图片失败"))
|
||||
dismissLoading()
|
||||
}
|
||||
.onCompletion {
|
||||
launchLoadingCollect({
|
||||
val list =
|
||||
(rv?.commonAdapter()?.items as List<FileBean>).filter { it.path.isNotEmpty() }
|
||||
bean.picnumber = list.size.toString()
|
||||
bean.originalPic = list.joinToString(separator = ",") { MediaUtil.removeUrl(it.url) }
|
||||
bean.pic = list.joinToString(separator = ",") { MediaUtil.removeUrl(it.originalPic) }
|
||||
|
||||
NetApply.api.anyPost(
|
||||
url = if (pageType.value == DetailsPageType.Add) "GnAccidentVisa/saveVisa" else "GnAccidentVisa/updateVisa",
|
||||
body = bean.toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
showToast(it.msg.noNull("${pageType.value!!.title}成功"))
|
||||
getTopActivity().finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
.launchIn(viewModelScope)
|
||||
}
|
||||
|
||||
|
||||
|
||||
override fun onItemClick(position: Int, type: Int) {
|
||||
val adapter = rv!!.commonAdapter()!!
|
||||
val bean = adapter.getItem(position) as FileBean
|
||||
when (type) {
|
||||
R.id.rl -> {
|
||||
if (pageType.value != DetailsPageType.Details) {
|
||||
bean.canDelete.set(!bean.canDelete.get())
|
||||
}
|
||||
}
|
||||
|
||||
R.id.iv_delete -> {
|
||||
adapter.removeItem(position)
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
fun scanClick() {
|
||||
ScanModel.startScan(getTopActivity(), Constant.RequestCode.CAR)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.sixin.module_p.ui.gnj.accidentVisa.dialog
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.module_base.base.BaseDialogModel
|
||||
import com.lukouguoji.module_base.ktx.formatDate
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.lxj.xpopup.XPopup
|
||||
import com.lxj.xpopup.enums.PopupPosition
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.databinding.DialogAccidentVisaFilterBinding
|
||||
import com.sixin.module_p.databinding.DialogPdaGnjXiejiFilterBinding
|
||||
import dev.DevUtils
|
||||
import dev.utils.common.DateUtils
|
||||
import java.util.Calendar
|
||||
|
||||
class PdaAccidentVisaFilterDialogModel(
|
||||
private val callBack: () -> Unit
|
||||
) : BaseDialogModel<DialogAccidentVisaFilterBinding>(
|
||||
DIALOG_TYPE_DRAWER
|
||||
) {
|
||||
|
||||
val date = MutableLiveData(DateUtils.getCurrentTime().formatDate())
|
||||
val opDateStart = MutableLiveData(DateUtils.getCurrentTime().formatDate())
|
||||
val opDateEnd = MutableLiveData(DateUtils.getCurrentTime().formatDate())
|
||||
|
||||
val flightNo = MutableLiveData("")
|
||||
|
||||
// 发运站
|
||||
val dep = MutableLiveData("")
|
||||
|
||||
// 单号
|
||||
val order = MutableLiveData("")
|
||||
|
||||
// 填表人
|
||||
val name = MutableLiveData("")
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.dialog_accident_visa_filter
|
||||
}
|
||||
|
||||
override fun onDialogCreated(context: Context) {
|
||||
binding.model = this
|
||||
}
|
||||
|
||||
override fun onBuild(builder: XPopup.Builder) {
|
||||
builder.popupPosition(PopupPosition.Right)
|
||||
}
|
||||
|
||||
fun onDateClick() {
|
||||
Common.onYearMonthDay(DevUtils.getTopActivity(), date.value) { year, month, day ->
|
||||
val calendar = Calendar.getInstance()
|
||||
calendar.set(year, month - 1, day)
|
||||
date.value = DateUtils.formatDate(calendar.time, "yyyy-MM-dd")
|
||||
}
|
||||
}
|
||||
|
||||
fun onStartDateClick() {
|
||||
Common.onYearMonthDay(DevUtils.getTopActivity(), date.value) { year, month, day ->
|
||||
val calendar = Calendar.getInstance()
|
||||
calendar.set(year, month - 1, day)
|
||||
opDateStart.value = DateUtils.formatDate(calendar.time, "yyyy-MM-dd")
|
||||
}
|
||||
}
|
||||
|
||||
fun onEndDateClick() {
|
||||
Common.onYearMonthDay(DevUtils.getTopActivity(), date.value) { year, month, day ->
|
||||
val calendar = Calendar.getInstance()
|
||||
calendar.set(year, month - 1, day)
|
||||
opDateEnd.value = DateUtils.formatDate(calendar.time, "yyyy-MM-dd")
|
||||
}
|
||||
}
|
||||
|
||||
fun onResetClick() {
|
||||
date.value = DateUtils.getCurrentTime().formatDate()
|
||||
opDateStart.value = DateUtils.getCurrentTime().formatDate()
|
||||
opDateEnd.value = DateUtils.getCurrentTime().formatDate()
|
||||
flightNo.value = ""
|
||||
name.value = ""
|
||||
order.value = ""
|
||||
dep.value = ""
|
||||
callBack.invoke()
|
||||
dismiss()
|
||||
}
|
||||
|
||||
fun onConfirmClick() {
|
||||
callBack.invoke()
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.sixin.module_p.ui.gnj.accidentVisa.list
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.widget.EditText
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.lukouguoji.module_base.common.ConstantEvent
|
||||
import com.lukouguoji.module_base.impl.FlowBus
|
||||
import com.lukouguoji.module_base.ktx.addOnItemClickListener
|
||||
import com.lukouguoji.module_base.ktx.getLifecycleOwner
|
||||
import com.lukouguoji.module_base.ktx.setTextAllCaps
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.base.BasePdaActivity
|
||||
import com.sixin.module_p.databinding.ActivityPdaAccidentVisaListBinding
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
|
||||
class PdaAccidentVisaListActivity :
|
||||
BasePdaActivity<ActivityPdaAccidentVisaListBinding, PdaAccidentVisaListViewModel>() {
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.activity_pda_accident_visa_list
|
||||
}
|
||||
|
||||
override fun viewModelClass(): Class<PdaAccidentVisaListViewModel> {
|
||||
return PdaAccidentVisaListViewModel::class.java
|
||||
}
|
||||
|
||||
private lateinit var flightNo: EditText
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国内事故签证")
|
||||
binding.viewModel = viewModel
|
||||
|
||||
viewModel.pageModel.bindSmartRefreshLayout(
|
||||
binding.srl,
|
||||
binding.rv,
|
||||
viewModel,
|
||||
getLifecycleOwner()
|
||||
)
|
||||
binding.rv.addOnItemClickListener(viewModel)
|
||||
|
||||
flightNo = findViewById(R.id.flightNoEditText)
|
||||
setTextAllCaps(flightNo, true)
|
||||
|
||||
FlowBus.with<String>(ConstantEvent.SCAN_CODE_RESULT)
|
||||
.onEach {
|
||||
// 仅当前页面在活跃时监听
|
||||
if (lifecycle.currentState == Lifecycle.State.RESUMED) {
|
||||
viewModel.flightNo.value = it
|
||||
viewModel.onCarChange(false)
|
||||
}
|
||||
}.launchIn(lifecycleScope)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
viewModel.refresh()
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
val starter = Intent(context, PdaAccidentVisaListActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.sixin.module_p.ui.gnj.accidentVisa.list
|
||||
|
||||
import android.view.View
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.AccidentVisaBean
|
||||
import com.lukouguoji.module_base.bean.GnjUnloadListBean
|
||||
import com.sixin.module_p.databinding.ItemPdaAccidentVisaListBinding
|
||||
import com.sixin.module_p.databinding.ItemPdaGnjXiejiListBinding
|
||||
|
||||
class PdaAccidentVisaListViewHolder(view: View) :
|
||||
BaseViewHolder<AccidentVisaBean, ItemPdaAccidentVisaListBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
binding.bean = getItemBean(item)
|
||||
notifyItemClick(position, binding.tvDelete)
|
||||
notifyItemClick(position, binding.llContent)
|
||||
notifyItemClick(position, binding.tvModify)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package com.sixin.module_p.ui.gnj.accidentVisa.list
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
||||
import com.lukouguoji.module_base.bean.AccidentVisaBean
|
||||
import com.lukouguoji.module_base.bean.GnjUnloadListBean
|
||||
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.launchLoadingCollect
|
||||
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.ScanModel
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.ui.gnj.accidentVisa.add.PdaAccidentVisaAddActivity
|
||||
import com.sixin.module_p.ui.gnj.accidentVisa.dialog.PdaAccidentVisaFilterDialogModel
|
||||
import com.sixin.module_p.ui.gnj.xieji.add.PdaGnjXieJiAddActivity
|
||||
import dev.DevUtils
|
||||
import dev.utils.common.DateUtils
|
||||
|
||||
class PdaAccidentVisaListViewModel : BasePageViewModel() {
|
||||
|
||||
|
||||
|
||||
// 日期
|
||||
val date = MutableLiveData(DateUtils.getCurrentTime().formatDate())
|
||||
|
||||
// 航班号
|
||||
val flightNo = MutableLiveData("")
|
||||
|
||||
// 发运站
|
||||
val dep = MutableLiveData("")
|
||||
|
||||
// 单号
|
||||
val order = MutableLiveData("")
|
||||
|
||||
// 填表人
|
||||
val name = MutableLiveData("")
|
||||
|
||||
// 合计数量
|
||||
val count = MutableLiveData(0)
|
||||
|
||||
|
||||
|
||||
|
||||
val itemLayoutId = R.layout.item_pda_accident_visa_list
|
||||
val itemViewHolder = PdaAccidentVisaListViewHolder::class.java
|
||||
|
||||
private val dialogModel = PdaAccidentVisaFilterDialogModel {
|
||||
refresh()
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
override fun getData() {
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getGnAccidentVisaList(
|
||||
mapOf(
|
||||
"pageNum" to pageModel.page,
|
||||
"pageSize" to pageModel.limit,
|
||||
// "opDate" to dialogModel.date.value,
|
||||
"opDateStart" to dialogModel.opDateStart.value,
|
||||
"opDateEnd" to dialogModel.opDateEnd.value,
|
||||
"fno" to flightNo.value,
|
||||
"dep" to dialogModel.dep.value,
|
||||
"mawbno" to dialogModel.order.value,
|
||||
"opid" to dialogModel.name.value,
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
pageModel.handleListBean(it)
|
||||
count.value = it.total
|
||||
}
|
||||
}
|
||||
}
|
||||
fun onCarChange(focus: Boolean = false) {
|
||||
if (focus) {
|
||||
return
|
||||
}
|
||||
getData()
|
||||
}
|
||||
|
||||
fun onFilterClick() {
|
||||
dialogModel.show()
|
||||
}
|
||||
|
||||
fun onAddClick() {
|
||||
PdaAccidentVisaAddActivity.start(DevUtils.getTopActivity())
|
||||
}
|
||||
|
||||
override fun onItemClick(position: Int, type: Int) {
|
||||
val adapter = pageModel.rv!!.commonAdapter()!!
|
||||
val bean = adapter.getItem(position) as AccidentVisaBean
|
||||
when (type) {
|
||||
R.id.ll_content -> {
|
||||
PdaAccidentVisaAddActivity.start(DevUtils.getTopActivity(), bean.id, false)
|
||||
}
|
||||
R.id.tv_modify -> {
|
||||
PdaAccidentVisaAddActivity.start(DevUtils.getTopActivity(), bean.id, true)
|
||||
}
|
||||
|
||||
R.id.tv_delete -> {
|
||||
Common.secondConfirmDialog(
|
||||
DevUtils.getTopActivity(), "确定删除吗?"
|
||||
) {
|
||||
launchLoadingCollect({
|
||||
NetApply.api.anyPostForId("/GnAccidentVisa/deleteVisa", bean.id)
|
||||
}) {
|
||||
onSuccess = {
|
||||
showToast(it.msg.noNull("删除成功"))
|
||||
adapter.removeItem(position)
|
||||
count.value = count.value!!.minus(1)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
fun scanClick() {
|
||||
ScanModel.startScan(getTopActivity(), Constant.RequestCode.CAR)
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
if (data == null || resultCode != Activity.RESULT_OK) {
|
||||
return
|
||||
}
|
||||
when (requestCode) {
|
||||
Constant.RequestCode.CAR -> {
|
||||
// car.value = data.getStringExtra(Constant.Result.CODED_CONTENT).noNull()
|
||||
onCarChange()
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.sixin.module_p.ui.gnj.xieji.add
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.alibaba.fastjson.JSON
|
||||
import com.lukouguoji.module_base.bean.GnjUnloadListBean
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.ktx.addOnItemClickListener
|
||||
import com.lukouguoji.module_base.ktx.refresh
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.base.BasePdaActivity
|
||||
import com.sixin.module_p.databinding.ActivityGnjXiejiAddBinding
|
||||
|
||||
class PdaGnjXieJiAddActivity :
|
||||
BasePdaActivity<ActivityGnjXiejiAddBinding, PdaGnjXieJiAddViewModel>() {
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.activity_gnj_xieji_add
|
||||
}
|
||||
|
||||
override fun viewModelClass(): Class<PdaGnjXieJiAddViewModel> {
|
||||
return PdaGnjXieJiAddViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国内进港开始卸机")
|
||||
viewModel.rv = binding.rv
|
||||
binding.viewModel = viewModel
|
||||
binding.rv.addOnItemClickListener(viewModel)
|
||||
viewModel.onInit(intent)
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context, data: GnjUnloadListBean) {
|
||||
val starter = Intent(context, PdaGnjXieJiAddActivity::class.java)
|
||||
.putExtra(Constant.Key.DATA, JSON.toJSONString(data))
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.sixin.module_p.ui.gnj.xieji.add
|
||||
|
||||
import android.view.View
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.FlatcarBean
|
||||
import com.sixin.module_p.databinding.ItemPdaGnjXiejiAddBinding
|
||||
|
||||
class PdaGnjXieJiAddViewHolder(view: View) :
|
||||
BaseViewHolder<FlatcarBean, ItemPdaGnjXiejiAddBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
binding.bean = getItemBean(item)
|
||||
notifyItemClick(position, binding.tvDelete)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,396 @@
|
||||
package com.sixin.module_p.ui.gnj.xieji.add
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.AlertDialog
|
||||
import android.content.Intent
|
||||
import android.util.Log
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.lukouguoji.module_base.base.BaseViewModel
|
||||
import com.lukouguoji.module_base.bean.FlatcarBean
|
||||
import com.lukouguoji.module_base.bean.FlightBean
|
||||
import com.lukouguoji.module_base.bean.GnjUnloadListBean
|
||||
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.interfaces.IOnItemClickListener
|
||||
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.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.ScanModel
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.lukouguoji.module_base.util.DictUtils
|
||||
import com.sixin.module_p.R
|
||||
import dev.DevUtils
|
||||
import dev.utils.app.info.KeyValue
|
||||
import dev.utils.common.DateUtils
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import java.util.Calendar
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
class PdaGnjXieJiAddViewModel : BaseViewModel(), IOnItemClickListener {
|
||||
|
||||
val date = MutableLiveData(DateUtils.getCurrentTime().formatDate())
|
||||
val fno = MutableLiveData("")
|
||||
val car = MutableLiveData("")
|
||||
|
||||
val count = MutableLiveData(0)
|
||||
|
||||
val itemViewHolder = PdaGnjXieJiAddViewHolder::class.java
|
||||
val itemLayoutId = R.layout.item_pda_gnj_xieji_add
|
||||
|
||||
//货物类型:0“国际货”,1“活体鲜活”,2“贵重物品”,3“其他特货”
|
||||
var cargoType = MutableLiveData("")
|
||||
|
||||
var cargoTypeString = MutableLiveData("")
|
||||
|
||||
private lateinit var checkedItems : BooleanArray
|
||||
|
||||
var clearable = MutableLiveData(false)
|
||||
|
||||
private val cargoTypeList = MutableLiveData<List<KeyValue>>()
|
||||
|
||||
var rv: RecyclerView by Delegates.notNull()
|
||||
val flight = MutableLiveData(FlightBean())
|
||||
|
||||
// 业务袋
|
||||
val check = MutableLiveData(false)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
fun onInit(intent: Intent) {
|
||||
FlowBus.with<String>(ConstantEvent.SCAN_CODE_RESULT)
|
||||
.onEach {
|
||||
car.value = it
|
||||
onCarInputFinished()
|
||||
}
|
||||
.launchIn(viewModelScope)
|
||||
|
||||
DictUtils.getDicCargoTypeList {
|
||||
cargoTypeList.value = it
|
||||
checkedItems = BooleanArray(it.size)
|
||||
val dataBeanString = intent.getStringExtra(Constant.Key.DATA) ?: ""
|
||||
val unloadList = NetApply.gson.fromJson(dataBeanString, GnjUnloadListBean::class.java)
|
||||
if (unloadList.fid !== "") {
|
||||
date.value = unloadList.fdate
|
||||
fno.value = unloadList.fno
|
||||
queryFlight()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 板车号输入完成
|
||||
* 焦点失去
|
||||
*/
|
||||
fun onCarInputFinished() {
|
||||
if (car.value.isNullOrEmpty()) {
|
||||
return
|
||||
}
|
||||
if (rv.commonAdapter()?.items?.find { (it as FlatcarBean).carId == car.value } != null) {
|
||||
showToast("该平板车已添加")
|
||||
return
|
||||
}
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getFlatcarInfo(car.value.noNull())
|
||||
}) {
|
||||
onSuccess = {
|
||||
rv.commonAdapter()?.addItem(it.data)
|
||||
count.value = count.value?.plus(1)
|
||||
}
|
||||
onComplete = {
|
||||
car.value = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询航班信息
|
||||
*/
|
||||
fun queryFlight() {
|
||||
if (date.value.isNullOrEmpty() || fno.value.isNullOrEmpty()) {
|
||||
return
|
||||
}
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getGnFlightBean(
|
||||
mapOf(
|
||||
"fdate" to date.value,
|
||||
"fno" to fno.value,
|
||||
"fdest" to "HFE"
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
if (it.verifySuccess()) {
|
||||
val data = it.data!!
|
||||
if (data.countryType == "0" && data.fdest == "HFE") {
|
||||
flight.value = it.data
|
||||
|
||||
//查询对应航班的卸机信息
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getGnjUnloadCarList(
|
||||
mapOf(
|
||||
"fdate" to date.value,
|
||||
"fno" to fno.value,
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
// 获取单证交接--根据上面查出来的航班fid
|
||||
launchCollect({NetApply.api.getHandover(flight.value!!.fid)}){
|
||||
onSuccess = { iit ->
|
||||
check.value = iit.data != null
|
||||
}
|
||||
}
|
||||
// println(it.list)
|
||||
// 根据航班查询卸机后根据第一条的货物类型来塞值
|
||||
val first = it.list?.firstOrNull()
|
||||
if (first != null) {
|
||||
cargoType.value = first.cargoType
|
||||
cargoTypeString.value = first.cargoTypeName
|
||||
checkedItems = cargoTypeList.value?.size?.let {
|
||||
BooleanArray(it) { index ->
|
||||
first.cargoType.contains(cargoTypeList.value!![index].value)
|
||||
}
|
||||
}!!
|
||||
if (first.cargoType !== "") {
|
||||
clearable.value = true
|
||||
}
|
||||
if (first.cargoTypeName === "") {
|
||||
cargoTypeString.value = cargoTypeList.value?.filter { item -> first.cargoType.contains(item.value) }
|
||||
?.joinToString(",") { it1 -> it1.key }
|
||||
}
|
||||
}
|
||||
for (item in it.list!!){
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getFlatcarInfo(item.carId)
|
||||
}) {
|
||||
onSuccess = {
|
||||
var flatcarBean = it.data as FlatcarBean
|
||||
flatcarBean.addFalg = false
|
||||
flatcarBean.xieJiId = item.id
|
||||
rv.commonAdapter()?.addItem(flatcarBean)
|
||||
count.value = count.value?.plus(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
showToast("该航班不是国内进港航班")
|
||||
}
|
||||
} else {
|
||||
showToast(it.msg.noNull("获取数据失败"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onDateClick() {
|
||||
Common.onYearMonthDay(DevUtils.getTopActivity(), date.value) { year, month, day ->
|
||||
val calendar = Calendar.getInstance()
|
||||
calendar.set(year, month - 1, day)
|
||||
date.value = calendar.time.formatDate()
|
||||
queryFlight()
|
||||
}
|
||||
}
|
||||
|
||||
fun onCargoTypeClick() {
|
||||
showAlertDialog()
|
||||
}
|
||||
|
||||
private fun showAlertDialog() {
|
||||
val items = cargoTypeList.value
|
||||
val displayValues = items?.map { it.key }?.toTypedArray()
|
||||
val nowCheckedItems = checkedItems.clone()
|
||||
AlertDialog.Builder(getTopActivity())
|
||||
.setTitle("请选择")
|
||||
.setMultiChoiceItems(displayValues, nowCheckedItems) { _, which, isChecked ->
|
||||
// 当选项被点击时更新选中状态
|
||||
nowCheckedItems[which] = isChecked
|
||||
}
|
||||
.setPositiveButton("确定") { dialog, _ ->
|
||||
checkedItems = nowCheckedItems
|
||||
// 遍历选中的项目
|
||||
val selectedItems = items?.filterIndexed { index, _ -> checkedItems[index] } ?.joinToString(separator = ",") { it.value }
|
||||
val selectedItemsString = items?.filterIndexed { index, _ -> checkedItems[index] } ?.joinToString(separator = ",") { it.key }
|
||||
// 显示选择结果
|
||||
if (selectedItems != null) {
|
||||
if (selectedItems.isNotEmpty()) {
|
||||
cargoType.value = selectedItems
|
||||
cargoTypeString.value = selectedItemsString
|
||||
clearable.value = true
|
||||
}
|
||||
}
|
||||
dialog.dismiss()
|
||||
}
|
||||
.setNegativeButton("取消") { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
}
|
||||
.create()
|
||||
.show()
|
||||
}
|
||||
|
||||
fun clearChecked() {
|
||||
checkedItems = cargoTypeList.value?.size?.let { BooleanArray(it) }!!
|
||||
cargoTypeString.value = ""
|
||||
cargoType.value = ""
|
||||
clearable.value = false
|
||||
}
|
||||
|
||||
private fun verifyHandover () {
|
||||
// 业务袋(单证交接)--勾选上则新增,不够选择删除
|
||||
if (check.value == true) {
|
||||
launchCollect({
|
||||
NetApply.api.anyPost(
|
||||
"flt/insertHandover",
|
||||
mapOf(
|
||||
"fileType" to "1",
|
||||
"fid" to flight.value!!.fid,
|
||||
"ieFlag" to "I"
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {}
|
||||
onFailed = { _: Int, _: String -> }
|
||||
}
|
||||
} else {
|
||||
launchCollect({
|
||||
NetApply.api.anyPostForId( "/flt/deleteHandoverByFid", flight.value!!.fid)
|
||||
}) {
|
||||
onSuccess = {}
|
||||
onFailed = { _: Int, _: String -> }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onConfirmClick() {
|
||||
if (flight.value!!.fid.verifyNullOrEmpty("请录入航班信息")) {
|
||||
return
|
||||
}
|
||||
if (rv.commonAdapter()?.items?.isNullOrEmpty() == true) {
|
||||
showToast("请添加平板车数据")
|
||||
return
|
||||
}
|
||||
// 业务袋(单证交接)
|
||||
verifyHandover()
|
||||
// addFalg为true的才新增
|
||||
var filteredList = ArrayList<FlatcarBean>()
|
||||
var airCraftIdList = ArrayList<Long>()
|
||||
for (item in rv.commonAdapter()?.items!!){
|
||||
item as FlatcarBean
|
||||
println("进港卸机id:"+item.xieJiId)
|
||||
if (item.addFalg) {
|
||||
filteredList.add(item)
|
||||
}else{
|
||||
airCraftIdList.add(item.xieJiId.toLong())
|
||||
}
|
||||
}
|
||||
|
||||
//对货物类型判空,走修改接口
|
||||
if(! cargoType.value.isNullOrEmpty() ){
|
||||
launchLoadingCollect({
|
||||
NetApply.api.anyPost(
|
||||
"unloadingAirCraft/update", mapOf(
|
||||
"cargoType" to cargoType.value,
|
||||
"airCraftIdList" to airCraftIdList,
|
||||
).toRequestBody(true)
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
println("修改货物类型成功!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (filteredList.size == 0){
|
||||
DevUtils.getTopActivity().finish()
|
||||
// showToast("请添加平板车数据")
|
||||
return
|
||||
}
|
||||
|
||||
launchLoadingCollect({
|
||||
NetApply.api.anyPost(
|
||||
"unloadingAirCraft/completed", mapOf(
|
||||
"fdate" to flight.value!!.fdate,
|
||||
"fid" to flight.value!!.fid,
|
||||
"fno" to flight.value!!.fno,
|
||||
"cargoType" to cargoType.value,
|
||||
"flatcarList" to filteredList,
|
||||
).toRequestBody(true)
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
showToast(it.msg.noNull("确认装板成功"))
|
||||
DevUtils.getTopActivity().finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onItemClick(position: Int, type: Int) {
|
||||
val adapter = rv!!.commonAdapter()!!
|
||||
val bean = adapter.getItem(position) as FlatcarBean
|
||||
when (type) {
|
||||
R.id.tv_delete -> {
|
||||
getTopActivity().showConfirmDialog(
|
||||
"是否删除该条记录?"
|
||||
) {
|
||||
|
||||
|
||||
if (bean.xieJiId.isNotBlank()){
|
||||
launchLoadingCollect({
|
||||
NetApply.api.anyGetForId(
|
||||
"unloadingAirCraft/deleteById", bean.xieJiId
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
showToast(it.msg.noNull("删除成功"))
|
||||
rv.commonAdapter()?.removeItem(position)
|
||||
count.value = count.value?.minus(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
fun scanClick() {
|
||||
ScanModel.startScan(getTopActivity(), Constant.RequestCode.CAR)
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
loge(
|
||||
"扫码返回信息 : $resultCode ; ${data != null} ; ${
|
||||
data?.getStringExtra(Constant.Result.CODED_CONTENT).noNull()
|
||||
}"
|
||||
)
|
||||
if (data == null || resultCode != Activity.RESULT_OK) {
|
||||
return
|
||||
}
|
||||
when (requestCode) {
|
||||
Constant.RequestCode.CAR -> {
|
||||
car.value = data.getStringExtra(Constant.Result.CODED_CONTENT).noNull()
|
||||
onCarInputFinished()
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.sixin.module_p.ui.gnj.xieji.details
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.alibaba.fastjson.JSON
|
||||
import com.lukouguoji.module_base.bean.GnjUnloadListBean
|
||||
import com.sixin.module_p.R
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.ktx.getLifecycleOwner
|
||||
import com.sixin.module_p.base.BasePdaActivity
|
||||
import com.sixin.module_p.databinding.ActivityPdaXieJiDetailsBinding
|
||||
|
||||
class PdaGnjXieJiDetailsActivity :
|
||||
BasePdaActivity<ActivityPdaXieJiDetailsBinding, PdaGnjXieJiDetailsViewModel>() {
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.activity_pda_xie_ji_details
|
||||
}
|
||||
|
||||
override fun viewModelClass(): Class<PdaGnjXieJiDetailsViewModel> {
|
||||
return PdaGnjXieJiDetailsViewModel::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, data: GnjUnloadListBean) {
|
||||
val starter = Intent(context, PdaGnjXieJiDetailsActivity::class.java)
|
||||
.putExtra(Constant.Key.DATA, JSON.toJSONString(data))
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.sixin.module_p.ui.gnj.xieji.details
|
||||
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.module_base.base.BaseDialogModel
|
||||
import com.lukouguoji.module_base.ktx.noNull
|
||||
import com.lukouguoji.module_base.ktx.verifyNullOrEmpty
|
||||
import com.lukouguoji.module_base.util.DictUtils
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.databinding.DialogPdaGncCunFangAddBinding
|
||||
import com.sixin.module_p.databinding.DialogPdaGnjXiejiDetatisAllocationBinding
|
||||
import dev.utils.app.info.KeyValue
|
||||
|
||||
class PdaGnjXieJiDetailsAllocationDialogModel(
|
||||
val carList: String,
|
||||
val transDestNow: String,
|
||||
val callBack: (PdaGnjXieJiDetailsAllocationDialogModel) -> Unit
|
||||
) :
|
||||
BaseDialogModel<DialogPdaGnjXiejiDetatisAllocationBinding>(DIALOG_TYPE_FULL) {
|
||||
|
||||
val transDest = MutableLiveData("")
|
||||
|
||||
val transDestList = MutableLiveData<List<KeyValue>>().apply {
|
||||
DictUtils.getTransDestList {
|
||||
var filter = it.filter { b -> !b.value.equals("3") }
|
||||
println("filter:"+filter)
|
||||
value = filter
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
override fun layoutId() = R.layout.dialog_pda_gnj_xieji_detatis_allocation
|
||||
|
||||
override fun onDialogCreated(context: Context) {
|
||||
binding.model = this
|
||||
setBackArrow("转运目的地分配")
|
||||
}
|
||||
|
||||
private fun setBackArrow(title: String) {
|
||||
val toolbar: Toolbar = binding.root.findViewById(com.lukouguoji.module_base.R.id.toolbar)
|
||||
val titleName: TextView = binding.root.findViewById(com.lukouguoji.module_base.R.id.title_name)
|
||||
titleName.text = title
|
||||
val toolBack: View = binding.root.findViewById(com.lukouguoji.module_base.R.id.tool_back)
|
||||
toolBack.setOnClickListener {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
fun onAreaSelected(position: Int) {
|
||||
println("transDestNow:"+transDestNow)
|
||||
transDest.value = transDestList.value?.getOrNull(position)?.value.noNull()
|
||||
}
|
||||
|
||||
fun onConfirmClick() {
|
||||
if (transDest.value.verifyNullOrEmpty("请选择目的站")) {
|
||||
return
|
||||
}
|
||||
callBack.invoke(this)
|
||||
dismiss()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.sixin.module_p.ui.gnj.xieji.details
|
||||
|
||||
import android.view.View
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.FlatcarBean
|
||||
import com.lukouguoji.module_base.bean.GnjUnloadListBean
|
||||
import com.sixin.module_p.databinding.ItemPdaGnjXiejiAddBinding
|
||||
import com.sixin.module_p.databinding.ItemPdaGnjXiejiCarListBinding
|
||||
|
||||
class PdaGnjXieJiDetailsViewHolder(view: View) :
|
||||
BaseViewHolder<GnjUnloadListBean, ItemPdaGnjXiejiCarListBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
binding.bean = getItemBean(item)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
package com.sixin.module_p.ui.gnj.xieji.details
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
||||
import com.lukouguoji.module_base.bean.GnjUnloadListBean
|
||||
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.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.sixin.module_p.R
|
||||
import android.view.View
|
||||
import android.widget.CompoundButton
|
||||
import androidx.databinding.ObservableBoolean
|
||||
import com.lukouguoji.module_base.interfaces.ICheck
|
||||
import com.lukouguoji.module_base.util.CheckUtil
|
||||
|
||||
|
||||
class PdaGnjXieJiDetailsViewModel : BasePageViewModel() {
|
||||
// 详情信息
|
||||
val dataBean = MutableLiveData<GnjUnloadListBean>()
|
||||
|
||||
// 单证交警--类型
|
||||
val handover = MutableLiveData("")
|
||||
|
||||
val itemViewHolder = PdaGnjXieJiDetailsViewHolder::class.java
|
||||
val itemLayoutId = R.layout.item_pda_gnj_xieji_car_list
|
||||
|
||||
// 确认按钮是否可用
|
||||
val confirmEnable = MutableLiveData(true)
|
||||
val isAllSelected = MutableLiveData(false)
|
||||
// val carList = MutableList(List<GnjUnloadListBean>)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
fun initOnCreated(intent: Intent) {
|
||||
val dataBeanString = intent.getStringExtra(Constant.Key.DATA) ?: ""
|
||||
dataBean.value = NetApply.gson.fromJson(dataBeanString, GnjUnloadListBean::class.java)
|
||||
refresh()
|
||||
}
|
||||
|
||||
override fun getData() {
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getGnjUnloadCarList(
|
||||
mapOf(
|
||||
"fid" to dataBean.value?.fid,
|
||||
"fdate" to dataBean.value?.fdate
|
||||
).toRequestBody())
|
||||
}) {
|
||||
onSuccess = {
|
||||
launchCollect({NetApply.api.getHandover(dataBean.value!!.fid)}) {
|
||||
onSuccess = { itt ->
|
||||
if (itt.data == null) handover.value = "" else handover.value = "业务袋"
|
||||
}
|
||||
}
|
||||
setItems(it.list as List<GnjUnloadListBean>)
|
||||
pageModel.handleListBean(it)
|
||||
isAllSelected.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 添加数据到列表
|
||||
fun setItems(items: List<GnjUnloadListBean>) {
|
||||
items.forEach { bean ->
|
||||
// 设置监听器
|
||||
bean.onCheckedChangeListener = object : GnjUnloadListBean.OnCheckedChangeListener {
|
||||
override fun onCheckedChanged(bean: GnjUnloadListBean, isChecked: Boolean) {
|
||||
println("Hello, World!")
|
||||
updateSelectAllState()
|
||||
}
|
||||
}
|
||||
}
|
||||
updateSelectAllState()
|
||||
}
|
||||
|
||||
// 更新全选按钮状态
|
||||
private fun updateSelectAllState() {
|
||||
val adapter = pageModel.rv!!.commonAdapter()!!
|
||||
val filter: List<GnjUnloadListBean> =
|
||||
adapter.items.filter { (it as GnjUnloadListBean).checked.get() } as List<GnjUnloadListBean>
|
||||
if (filter.isEmpty()) {
|
||||
isAllSelected.value = false
|
||||
return
|
||||
}
|
||||
if (filter.size == adapter.items.size){
|
||||
isAllSelected.value = true
|
||||
}else{
|
||||
isAllSelected.value = false
|
||||
}
|
||||
}
|
||||
|
||||
fun onAllSelectClick() {
|
||||
val adapter = pageModel.rv!!.commonAdapter()!!
|
||||
if (isAllSelected.value == true){
|
||||
CheckUtil.checkAll(adapter.items as List<ICheck>)
|
||||
}else{
|
||||
CheckUtil.unCheckAll(adapter.items as List<ICheck>)
|
||||
}
|
||||
}
|
||||
|
||||
fun onDistributionClick() {
|
||||
val list = pageModel.rv!!.commonAdapter()!!.items as List<GnjUnloadListBean>
|
||||
val filter = list.filter { it.checked.get() }
|
||||
if (filter.isEmpty()) {
|
||||
showToast("请选择数据")
|
||||
return
|
||||
}
|
||||
val carList = filter.joinToString("、") { it.carId }
|
||||
val transDest = filter.get(0).transDest
|
||||
var isTrue = false
|
||||
for (t in filter) { // T 替换为实际类型(如 YourModel)
|
||||
if (!t.transDest.equals(transDest)) { // 假设 transDest 是基本类型或需用 != 比较
|
||||
isTrue = true
|
||||
break // 发现符合条件可立即终止循环(优化性能)
|
||||
}
|
||||
}
|
||||
if (isTrue){
|
||||
showToast("请选择同一转运目的地")
|
||||
return
|
||||
}
|
||||
PdaGnjXieJiDetailsAllocationDialogModel(
|
||||
carList,
|
||||
transDest
|
||||
) {
|
||||
launchLoadingCollect({
|
||||
NetApply.api.anyPost(
|
||||
"unloadingAirCraft/update", mapOf(
|
||||
"transDest" to it.transDest.value,
|
||||
"airCraftIdList" to filter.map { b -> b.id },
|
||||
).toRequestBody(true)
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
showToast(it.msg.noNull("分配转运目的地成功"))
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
}.show(getTopActivity())
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.sixin.module_p.ui.gnj.xieji.dialog
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.module_base.base.BaseDialogModel
|
||||
import com.lukouguoji.module_base.ktx.formatDate
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.lxj.xpopup.XPopup
|
||||
import com.lxj.xpopup.enums.PopupPosition
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.databinding.DialogPdaGnjXiejiFilterBinding
|
||||
import dev.DevUtils
|
||||
import dev.utils.common.DateUtils
|
||||
import java.util.Calendar
|
||||
|
||||
class PdaGnjXieJiFilterDialogModel(
|
||||
private val callBack: () -> Unit
|
||||
) : BaseDialogModel<DialogPdaGnjXiejiFilterBinding>(
|
||||
DIALOG_TYPE_DRAWER
|
||||
) {
|
||||
|
||||
val date = MutableLiveData(DateUtils.getCurrentTime().formatDate())
|
||||
|
||||
val flightNo = MutableLiveData("")
|
||||
|
||||
val onlyMe = MutableLiveData(true)
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.dialog_pda_gnj_xieji_filter
|
||||
}
|
||||
|
||||
override fun onDialogCreated(context: Context) {
|
||||
binding.model = this
|
||||
}
|
||||
|
||||
override fun onBuild(builder: XPopup.Builder) {
|
||||
builder.popupPosition(PopupPosition.Right)
|
||||
}
|
||||
|
||||
fun onDateClick() {
|
||||
Common.onYearMonthDay(DevUtils.getTopActivity(), date.value) { year, month, day ->
|
||||
val calendar = Calendar.getInstance()
|
||||
calendar.set(year, month - 1, day)
|
||||
date.value = DateUtils.formatDate(calendar.time, "yyyy-MM-dd")
|
||||
}
|
||||
}
|
||||
|
||||
fun onResetClick() {
|
||||
date.value = DateUtils.getCurrentTime().formatDate()
|
||||
flightNo.value = ""
|
||||
callBack.invoke()
|
||||
dismiss()
|
||||
}
|
||||
|
||||
fun onConfirmClick() {
|
||||
callBack.invoke()
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.sixin.module_p.ui.gnj.xieji.list
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.lukouguoji.module_base.common.ConstantEvent
|
||||
import com.lukouguoji.module_base.impl.FlowBus
|
||||
import com.lukouguoji.module_base.ktx.addOnItemClickListener
|
||||
import com.lukouguoji.module_base.ktx.getLifecycleOwner
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.base.BasePdaActivity
|
||||
import com.sixin.module_p.databinding.ActivityGnjXieJiListBinding
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
|
||||
class PdaGnjXieJiListActivity :
|
||||
BasePdaActivity<ActivityGnjXieJiListBinding, PdaGnjXieJiListViewModel>() {
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.activity_gnj_xie_ji_list
|
||||
}
|
||||
|
||||
override fun viewModelClass(): Class<PdaGnjXieJiListViewModel> {
|
||||
return PdaGnjXieJiListViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国内进港卸机")
|
||||
binding.viewModel = viewModel
|
||||
|
||||
viewModel.pageModel.bindSmartRefreshLayout(
|
||||
binding.srl,
|
||||
binding.rv,
|
||||
viewModel,
|
||||
getLifecycleOwner()
|
||||
)
|
||||
binding.rv.addOnItemClickListener(viewModel)
|
||||
|
||||
FlowBus.with<String>(ConstantEvent.SCAN_CODE_RESULT)
|
||||
.onEach {
|
||||
// 仅当前页面在活跃时监听
|
||||
if (lifecycle.currentState == Lifecycle.State.RESUMED) {
|
||||
viewModel.car.value = it
|
||||
viewModel.onCarChange(false)
|
||||
}
|
||||
}.launchIn(lifecycleScope)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
viewModel.refresh()
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
val starter = Intent(context, PdaGnjXieJiListActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.sixin.module_p.ui.gnj.xieji.list
|
||||
|
||||
import android.view.View
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.GnjUnloadListBean
|
||||
import com.sixin.module_p.databinding.ItemPdaGnjXiejiListBinding
|
||||
|
||||
class PdaGnjXieJiListViewHolder(view: View) :
|
||||
BaseViewHolder<GnjUnloadListBean, ItemPdaGnjXiejiListBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
binding.bean = getItemBean(item)
|
||||
notifyItemClick(position, binding.tvDelete)
|
||||
notifyItemClick(position, binding.tvModify)
|
||||
notifyItemClick(position, binding.llContent)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package com.sixin.module_p.ui.gnj.xieji.list
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.util.Log
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
||||
import com.lukouguoji.module_base.bean.GnjUnloadListBean
|
||||
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.launchLoadingCollect
|
||||
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.ScanModel
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.ui.gnj.xieji.add.PdaGnjXieJiAddActivity
|
||||
import com.sixin.module_p.ui.gnj.xieji.details.PdaGnjXieJiDetailsActivity
|
||||
import com.sixin.module_p.ui.gnj.xieji.dialog.PdaGnjXieJiFilterDialogModel
|
||||
import dev.DevUtils
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
|
||||
class PdaGnjXieJiListViewModel : BasePageViewModel() {
|
||||
|
||||
val car = MutableLiveData("")
|
||||
|
||||
val count = MutableLiveData(0)
|
||||
|
||||
val itemLayoutId = R.layout.item_pda_gnj_xieji_list
|
||||
val itemViewHolder = PdaGnjXieJiListViewHolder::class.java
|
||||
|
||||
private val dialogModel = PdaGnjXieJiFilterDialogModel {
|
||||
refresh()
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
override fun getData() {
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getGnjUnloadList(
|
||||
mapOf(
|
||||
"fdate" to dialogModel.date.value,
|
||||
"fno" to dialogModel.flightNo.value,
|
||||
"carId" to car.value,
|
||||
"onlyMe" to dialogModel.onlyMe.value
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
pageModel.handleListBean(it)
|
||||
count.value = it.total
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onCarChange(focus: Boolean = false) {
|
||||
if (focus) {
|
||||
return
|
||||
}
|
||||
getData()
|
||||
}
|
||||
|
||||
fun onFilterClick() {
|
||||
dialogModel.show()
|
||||
}
|
||||
|
||||
fun onAddClick() {
|
||||
PdaGnjXieJiAddActivity.start(DevUtils.getTopActivity(), GnjUnloadListBean())
|
||||
}
|
||||
|
||||
override fun onItemClick(position: Int, type: Int) {
|
||||
val adapter = pageModel.rv!!.commonAdapter()!!
|
||||
val bean = adapter.getItem(position) as GnjUnloadListBean
|
||||
when (type) {
|
||||
R.id.ll_content -> {
|
||||
PdaGnjXieJiDetailsActivity.start(DevUtils.getTopActivity(), bean)
|
||||
}
|
||||
R.id.tv_modify -> {
|
||||
PdaGnjXieJiAddActivity.start(DevUtils.getTopActivity(), bean)
|
||||
}
|
||||
R.id.tv_delete -> {
|
||||
getTopActivity().showConfirmDialog("是否删除该航班下所有平板车信息?") {
|
||||
launchLoadingCollect({
|
||||
NetApply.api.anyGetForId(
|
||||
"unloadingAirCraft/deleteByFid", bean.fid.noNull()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
showToast(it.msg.noNull("删除成功"))
|
||||
adapter.removeItem(position)
|
||||
count.value = count.value?.minus(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
fun scanClick() {
|
||||
ScanModel.startScan(getTopActivity(), Constant.RequestCode.CAR)
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
if (data == null || resultCode != Activity.RESULT_OK) {
|
||||
return
|
||||
}
|
||||
when (requestCode) {
|
||||
Constant.RequestCode.CAR -> {
|
||||
car.value = data.getStringExtra(Constant.Result.CODED_CONTENT).noNull()
|
||||
onCarChange()
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.sixin.module_p.ui.goods.transport.add
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.base.BasePdaActivity
|
||||
import com.sixin.module_p.databinding.ActivityPdaGoodsTransportAddBinding
|
||||
|
||||
class PdaGoodsTransportAddActivity :
|
||||
BasePdaActivity<ActivityPdaGoodsTransportAddBinding, PdaGoodsTransportAddViewModel>() {
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.activity_pda_goods_transport_add
|
||||
}
|
||||
|
||||
override fun viewModelClass(): Class<PdaGoodsTransportAddViewModel> {
|
||||
return PdaGoodsTransportAddViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("货物转运信息补充")
|
||||
binding.viewModel = viewModel
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
val starter = Intent(context, PdaGoodsTransportAddActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.sixin.module_p.ui.goods.transport.add
|
||||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.module_base.base.BaseViewModel
|
||||
import dev.utils.app.info.KeyValue
|
||||
|
||||
class PdaGoodsTransportAddViewModel : BaseViewModel() {
|
||||
|
||||
val machine = MutableLiveData("")
|
||||
|
||||
val machineList = MutableLiveData<List<KeyValue>>(listOf())
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
fun onConfirmClick() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.sixin.module_p.ui.goods.transport.dialog
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.module_base.base.BaseDialogModel
|
||||
import com.lukouguoji.module_base.ktx.formatDate
|
||||
import com.lukouguoji.module_base.ktx.noNull
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.lukouguoji.module_base.util.DictUtils
|
||||
import com.lxj.xpopup.XPopup
|
||||
import com.lxj.xpopup.enums.PopupPosition
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.databinding.DialogPdaGoodsTransportFilterBinding
|
||||
import dev.DevUtils
|
||||
import dev.utils.app.info.KeyValue
|
||||
import dev.utils.common.DateUtils
|
||||
import java.util.Calendar
|
||||
|
||||
class PdaGoodsTransportFilterDialogModel(
|
||||
private val callBack: () -> Unit
|
||||
) : BaseDialogModel<DialogPdaGoodsTransportFilterBinding>(DIALOG_TYPE_DRAWER) {
|
||||
|
||||
val date = MutableLiveData(DateUtils.getCurrentTime().formatDate())
|
||||
|
||||
val flightNo = MutableLiveData("")
|
||||
|
||||
val transportType = MutableLiveData("1")
|
||||
val transportStatus = MutableLiveData("")
|
||||
val driver = MutableLiveData("")
|
||||
|
||||
val transportTypeList = MutableLiveData<List<KeyValue>>(listOf()).apply {
|
||||
DictUtils.getTransTypeListByRole {
|
||||
value = it
|
||||
transportType.value = it.firstOrNull()?.value ?: ""
|
||||
callBack()
|
||||
}
|
||||
}
|
||||
val transportStatusList = MutableLiveData<List<KeyValue>>(listOf()).apply {
|
||||
DictUtils.getTransStatusList {
|
||||
value = listOf(KeyValue("全部", "")) + it
|
||||
}
|
||||
}
|
||||
val driverList = MutableLiveData<List<KeyValue>>(listOf()).apply {
|
||||
DictUtils.getDriverList {
|
||||
value = listOf(KeyValue("全部", "")) + it
|
||||
}
|
||||
}
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.dialog_pda_goods_transport_filter
|
||||
}
|
||||
|
||||
override fun onDialogCreated(context: Context) {
|
||||
binding.model = this
|
||||
}
|
||||
|
||||
override fun onBuild(builder: XPopup.Builder) {
|
||||
builder.popupPosition(PopupPosition.Right)
|
||||
}
|
||||
|
||||
fun onDateClick() {
|
||||
Common.onYearMonthDay(DevUtils.getTopActivity(), date.value) { year, month, day ->
|
||||
val calendar = Calendar.getInstance()
|
||||
calendar.set(year, month - 1, day)
|
||||
date.value = DateUtils.formatDate(calendar.time, "yyyy-MM-dd")
|
||||
}
|
||||
}
|
||||
|
||||
fun onTransportTypeSelected(position: Int) {
|
||||
transportType.value = transportTypeList.value?.getOrNull(position)?.value.noNull()
|
||||
}
|
||||
|
||||
fun onTransportStatusSelected(position: Int) {
|
||||
transportStatus.value = transportStatusList.value?.getOrNull(position)?.value.noNull()
|
||||
}
|
||||
|
||||
fun onDriverSelected(position: Int) {
|
||||
driver.value = driverList.value?.getOrNull(position)?.value.noNull()
|
||||
}
|
||||
|
||||
fun onResetClick() {
|
||||
date.value = DateUtils.getCurrentTime().formatDate()
|
||||
flightNo.value = ""
|
||||
callBack.invoke()
|
||||
binding.spinnerType.setSelection(0)
|
||||
binding.spinnerStatus.setSelection(0)
|
||||
// binding.spinnerDriver.setSelection(0)
|
||||
dismiss()
|
||||
}
|
||||
|
||||
fun onConfirmClick() {
|
||||
callBack.invoke()
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.sixin.module_p.ui.goods.transport.list
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.KeyEvent
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.Toast
|
||||
import com.lukouguoji.module_base.ktx.addOnItemClickListener
|
||||
import com.lukouguoji.module_base.ktx.getLifecycleOwner
|
||||
import com.lukouguoji.module_base.ktx.logw
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.base.BasePdaActivity
|
||||
import com.sixin.module_p.databinding.ActivityPdaGoodsTransportListBinding
|
||||
|
||||
|
||||
class PdaGoodsTransportListActivity :
|
||||
BasePdaActivity<ActivityPdaGoodsTransportListBinding, PdaGoodsTransportListViewModel>() {
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.activity_pda_goods_transport_list
|
||||
}
|
||||
|
||||
override fun viewModelClass(): Class<PdaGoodsTransportListViewModel> {
|
||||
return PdaGoodsTransportListViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("货物转运")
|
||||
binding.viewModel = viewModel
|
||||
binding.etCarNo.setOnFocusChangeListener { v, hasFocus ->
|
||||
if(!hasFocus){
|
||||
val carNo = binding.etCarNo.text.toString()
|
||||
Log.i("TEST","initOnCreate setOnFocusChangeListener $carNo")
|
||||
viewModel.findMatchInputCarNo(carNo)
|
||||
}
|
||||
}
|
||||
binding.etCarNo.imeOptions = EditorInfo.IME_ACTION_DONE
|
||||
binding.etCarNo.setOnKeyListener { v, keyCode, event ->
|
||||
if (event.action === KeyEvent.ACTION_DOWN && keyCode === KeyEvent.KEYCODE_ENTER) {
|
||||
viewModel.refresh()
|
||||
return@setOnKeyListener true
|
||||
}
|
||||
return@setOnKeyListener false
|
||||
}
|
||||
viewModel.pageModel.bindSmartRefreshLayout(
|
||||
binding.srl,
|
||||
binding.rv,
|
||||
viewModel,
|
||||
getLifecycleOwner()
|
||||
)
|
||||
binding.rv.addOnItemClickListener(viewModel)
|
||||
viewModel.initOnCreated()
|
||||
viewModel.refresh()
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
val starter = Intent(context, PdaGoodsTransportListActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.sixin.module_p.ui.goods.transport.list
|
||||
|
||||
import android.view.View
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.GoodsTransportBean
|
||||
import com.sixin.module_p.databinding.ItemPdaZhuanyunListBinding
|
||||
|
||||
class PdaGoodsTransportListViewHolder(view: View) :
|
||||
BaseViewHolder<GoodsTransportBean, ItemPdaZhuanyunListBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
binding.bean = getItemBean(item)
|
||||
|
||||
notifyItemClick(position, binding.ll)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,340 @@
|
||||
package com.sixin.module_p.ui.goods.transport.list
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.util.Log
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
||||
import com.lukouguoji.module_base.bean.GoodsTransportBean
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.common.ConstantEvent
|
||||
import com.lukouguoji.module_base.db.perference.SharedPreferenceUtil
|
||||
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.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.toRequestBody
|
||||
import com.lukouguoji.module_base.model.GoodsTransportModifyDialogModel
|
||||
import com.lukouguoji.module_base.model.GoodsTransportReturnDialogModel
|
||||
import com.lukouguoji.module_base.model.ScanModel
|
||||
import com.lukouguoji.module_base.util.HandlerUtils
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.ui.goods.transport.dialog.PdaGoodsTransportFilterDialogModel
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
|
||||
class PdaGoodsTransportListViewModel : BasePageViewModel() {
|
||||
// 平板车
|
||||
val keyWord = MutableLiveData("")
|
||||
|
||||
// 数量
|
||||
val count = MutableLiveData(0)
|
||||
|
||||
val index = MutableLiveData(0)
|
||||
|
||||
val itemLayoutId = R.layout.item_pda_zhuanyun_list
|
||||
val itemViewHolder = PdaGoodsTransportListViewHolder::class.java
|
||||
|
||||
// 筛选
|
||||
private val filterModel = PdaGoodsTransportFilterDialogModel {
|
||||
refresh()
|
||||
}
|
||||
|
||||
// 补位补充是否可用
|
||||
val supplementEnable = MutableLiveData(false)
|
||||
|
||||
// 确认按钮是否可用
|
||||
val confirmEnable = MutableLiveData(true)
|
||||
|
||||
// 退回按钮是否可用
|
||||
val returnEnable = MutableLiveData(false)
|
||||
|
||||
// 确认文字
|
||||
val confirmText = MutableLiveData("开始运输")
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* tab切换
|
||||
*/
|
||||
fun onTabChanged(index: Int) {
|
||||
this.index.value = index
|
||||
refresh()
|
||||
}
|
||||
|
||||
|
||||
|
||||
fun initOnCreated() {
|
||||
FlowBus.with<String>(ConstantEvent.SCAN_CODE_RESULT)
|
||||
.onEach {
|
||||
keyWord.value = it
|
||||
// onCarChange()
|
||||
findMatchInputCarNo(it)
|
||||
}.launchIn(viewModelScope)
|
||||
}
|
||||
|
||||
override fun getData() {
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getGoodsTransportList(
|
||||
mapOf(
|
||||
"pageNum" to pageModel.page,
|
||||
"pageSize" to pageModel.limit,
|
||||
"fdate" to filterModel.date.value,
|
||||
"fno" to filterModel.flightNo.value,
|
||||
"transStatus" to index.value,
|
||||
"transType" to filterModel.transportType.value,
|
||||
"driver" to filterModel.driver.value,
|
||||
"carId" to keyWord.value,
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
it.list?.forEach { iit -> iit.storageAreaVisible = index.value == 0}
|
||||
pageModel.handleListBean(it)
|
||||
count.value = it.total
|
||||
HandlerUtils.postRunnable({
|
||||
computeEnableState()
|
||||
}, 100)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun findMatchInputCarNo(carNo: String){
|
||||
Log.i("TEST","findMatchInputCarNo $carNo")
|
||||
if(carNo.length>=3){
|
||||
val list = pageModel.rv?.commonAdapter()?.items as List<GoodsTransportBean>
|
||||
Log.i("TEST","findMatchInputCarNo ${list.size}")
|
||||
for(i in list?.indices){
|
||||
list[i].carId.let {
|
||||
if(it.contains(carNo)){
|
||||
Log.i("TEST","findMatchInputCarNo $i")
|
||||
pageModel.rv?.smoothScrollToPosition(i)
|
||||
if(!list[i].checked.get()){
|
||||
list[i].checked.set(true)
|
||||
pageModel.rv?.commonAdapter()?.notifyItemChanged(i)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun onCarChange(focused: Boolean = false) {
|
||||
if (focused) {
|
||||
return
|
||||
}
|
||||
refresh()
|
||||
}
|
||||
|
||||
fun onFilterClick() {
|
||||
filterModel.show()
|
||||
}
|
||||
|
||||
fun returnClick() {
|
||||
val list = (getAdapter().items as List<GoodsTransportBean>).filter { it.checked.get() }
|
||||
if (list.isEmpty()) {
|
||||
showToast("请选择数据")
|
||||
return
|
||||
}
|
||||
val inOutStatus = list.first().status
|
||||
GoodsTransportReturnDialogModel(
|
||||
list.joinToString("、") { it.carId }
|
||||
) {
|
||||
launchLoadingCollect({
|
||||
NetApply.api.anyPost(
|
||||
url = if (inOutStatus == "0") "DomExpLoading/backTrans" else "unloadingAirCraft/backTrans",
|
||||
mapOf(
|
||||
"backDirection" to it.data.value,
|
||||
"transType" to list.first().transType,
|
||||
"useIdList" to list.map { it.useId }
|
||||
).toRequestBody())
|
||||
}) {
|
||||
onSuccess = {
|
||||
showToast(it.msg.noNull("退回成功"))
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
}.show()
|
||||
}
|
||||
|
||||
fun onAddCargo() {
|
||||
val adapter = pageModel.rv!!.commonAdapter()!!
|
||||
val list = (adapter.items as List<GoodsTransportBean>).filter { it.checked.get() }
|
||||
if (list.isEmpty()) {
|
||||
showToast("请选中需要加货的平板车信息!")
|
||||
return
|
||||
}
|
||||
getTopActivity().showConfirmDialog("是否完成加货?") {
|
||||
var canAddCargo = true
|
||||
for (obj in list) {
|
||||
if (obj.addCargoFlag != "1") {
|
||||
showToast("平板车不可加货!")
|
||||
canAddCargo = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if (canAddCargo) {
|
||||
launchLoadingCollect({
|
||||
NetApply.api.anyPost(
|
||||
url = "DomExpLoading/updateAddCargo",
|
||||
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<GoodsTransportBean>).filter { it.checked.get() }
|
||||
if (list.isEmpty()) {
|
||||
showToast("请选中需要补充机位的平板车信息!")
|
||||
return
|
||||
}
|
||||
val inOutStatus = list.first().status
|
||||
GoodsTransportModifyDialogModel(
|
||||
list.joinToString("、") { it.carId }
|
||||
) {
|
||||
launchLoadingCollect({
|
||||
NetApply.api.anyPost(
|
||||
url = "DomExpLoading/updateStandId",
|
||||
mapOf(
|
||||
"status" to inOutStatus,
|
||||
"standId" to it.data.value,
|
||||
"transType" to list.first().transType,
|
||||
"useIdList" to list.map { it.useId },
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
showToast(it.msg.noNull("补充机位成功"))
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
}.show()
|
||||
}
|
||||
|
||||
fun onConfirmClick() {
|
||||
val adapter = pageModel.rv!!.commonAdapter()!!
|
||||
val list = (adapter.items as List<GoodsTransportBean>).filter { it.checked.get() }
|
||||
if (list.isEmpty()) {
|
||||
showToast("请选中需要转运的平板车信息!")
|
||||
return
|
||||
}
|
||||
val inOutStatus = list.first().status
|
||||
getTopActivity().showConfirmDialog("是否确定${confirmText.value}?") {
|
||||
launchLoadingCollect({
|
||||
NetApply.api.anyPost(
|
||||
url = if (inOutStatus == "0") {
|
||||
if (confirmText.value == "开始运输") "DomExpLoading/startTrans" else "DomExpLoading/finishTrans"
|
||||
} else {
|
||||
if (confirmText.value == "开始运输") "unloadingAirCraft/startTrans" else "unloadingAirCraft/finishTrans"
|
||||
},
|
||||
mapOf(
|
||||
"transType" to list.first().transType,
|
||||
"useIdList" to list.map { it.useId }
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
showToast(it.msg.noNull("操作成功"))
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onItemClick(position: Int, type: Int) {
|
||||
val list = getAdapter().items as List<GoodsTransportBean>
|
||||
val bean = list[position]
|
||||
if (!bean.canReturn() && bean.endFlag == "1") {
|
||||
// 不能退回且已结束的数据不允许点击
|
||||
return
|
||||
}
|
||||
when (type) {
|
||||
R.id.ll -> {
|
||||
val checkedStatus = list.firstOrNull { it.checked.get() }?.transStatus ?: ""
|
||||
// 没有选中,或选中状态一致,则处理逻辑
|
||||
if (checkedStatus.isEmpty() || checkedStatus == bean.transStatus) {
|
||||
bean.checked.set(!bean.checked.get())
|
||||
}
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
computeEnableState()
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算可用信息
|
||||
*/
|
||||
private fun computeEnableState() {
|
||||
val list = getAdapter().items as List<GoodsTransportBean>
|
||||
// 补充机位是否可用
|
||||
// supplementEnable.value = list.firstOrNull()?.transType in listOf("2", "8", "9")
|
||||
|
||||
// 选中结束状态的数据,则不展示
|
||||
confirmEnable.value = list.firstOrNull { it.checked.get() }?.endFlag != "1"
|
||||
if (index.value == 2) {
|
||||
//完成运输页面不可以开始运输
|
||||
confirmEnable.value = false
|
||||
}
|
||||
// 确认是否可用
|
||||
confirmText.value = if (list.firstOrNull { it.checked.get() }?.transStatus == "1") {
|
||||
"完成运输"
|
||||
} else {
|
||||
"开始运输"
|
||||
}
|
||||
if (index.value == 1) {
|
||||
confirmText.value = "完成运输"
|
||||
}
|
||||
val userRole = SharedPreferenceUtil.getString(Constant.Share.roleId).noNull()
|
||||
supplementEnable.value = userRole == "7" && !confirmEnable.value!!
|
||||
loge("判断补充机位是否可用 : ${supplementEnable.value}")
|
||||
|
||||
// 退回是否可用
|
||||
returnEnable.value = list.firstOrNull { it.checked.get() }?.canReturn() == true
|
||||
}
|
||||
|
||||
private fun getAdapter() = pageModel.rv!!.commonAdapter()!!
|
||||
|
||||
fun scanClick() {
|
||||
ScanModel.startScan(getTopActivity(), Constant.RequestCode.CAR)
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
if (data == null || resultCode != Activity.RESULT_OK) {
|
||||
return
|
||||
}
|
||||
when (requestCode) {
|
||||
Constant.RequestCode.CAR -> {
|
||||
val carNo = data.getStringExtra(Constant.Result.CODED_CONTENT).noNull()
|
||||
keyWord.value = carNo
|
||||
// onCarChange()
|
||||
findMatchInputCarNo(carNo)
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.sixin.module_p.ui.goods.transportLog.dialog
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.module_base.base.BaseDialogModel
|
||||
import com.lukouguoji.module_base.ktx.formatDate
|
||||
import com.lukouguoji.module_base.ktx.noNull
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.lukouguoji.module_base.util.DictUtils
|
||||
import com.lxj.xpopup.XPopup
|
||||
import com.lxj.xpopup.enums.PopupPosition
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.databinding.DialogPdaTransportLogFilterBinding
|
||||
import dev.DevUtils
|
||||
import dev.utils.app.info.KeyValue
|
||||
import dev.utils.common.DateUtils
|
||||
import java.util.Calendar
|
||||
|
||||
class PdaTransportLogFilterDialogModel(
|
||||
private val callBack: () -> Unit
|
||||
) : BaseDialogModel<DialogPdaTransportLogFilterBinding>(DIALOG_TYPE_DRAWER) {
|
||||
|
||||
val date = MutableLiveData(DateUtils.getCurrentTime().formatDate())
|
||||
|
||||
val flightNo = MutableLiveData("")
|
||||
|
||||
val transportType = MutableLiveData("")
|
||||
val transportStatus = MutableLiveData("")
|
||||
val driver = MutableLiveData("")
|
||||
|
||||
val transportTypeList = MutableLiveData<List<KeyValue>>(listOf()).apply {
|
||||
DictUtils.getTransTypeListByRole {
|
||||
value = listOf(KeyValue("全部", "")) + it
|
||||
transportType.value = ""
|
||||
}
|
||||
}
|
||||
val transportStatusList = MutableLiveData<List<KeyValue>>(listOf()).apply {
|
||||
DictUtils.getTransStatusList {
|
||||
value = listOf(KeyValue("全部", "")) + it
|
||||
}
|
||||
}
|
||||
val driverList = MutableLiveData<List<KeyValue>>(listOf()).apply {
|
||||
DictUtils.getAllDriverList {
|
||||
value = listOf(KeyValue("全部", "")) + it
|
||||
}
|
||||
}
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.dialog_pda_transport_log_filter
|
||||
}
|
||||
|
||||
override fun onDialogCreated(context: Context) {
|
||||
binding.model = this
|
||||
}
|
||||
|
||||
override fun onBuild(builder: XPopup.Builder) {
|
||||
builder.popupPosition(PopupPosition.Right)
|
||||
}
|
||||
|
||||
fun onDateClick() {
|
||||
Common.onYearMonthDay(DevUtils.getTopActivity(), date.value) { year, month, day ->
|
||||
val calendar = Calendar.getInstance()
|
||||
calendar.set(year, month - 1, day)
|
||||
date.value = DateUtils.formatDate(calendar.time, "yyyy-MM-dd")
|
||||
}
|
||||
}
|
||||
|
||||
fun onTransportTypeSelected(position: Int) {
|
||||
transportType.value = transportTypeList.value?.getOrNull(position)?.value.noNull()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
fun onTransportStatusSelected(position: Int) {
|
||||
transportStatus.value = transportStatusList.value?.getOrNull(position)?.value.noNull()
|
||||
}
|
||||
|
||||
fun onDriverSelected(position: Int) {
|
||||
driver.value = driverList.value?.getOrNull(position)?.value.noNull()
|
||||
}
|
||||
|
||||
fun onResetClick() {
|
||||
date.value = DateUtils.getCurrentTime().formatDate()
|
||||
flightNo.value = ""
|
||||
callBack.invoke()
|
||||
binding.spinnerType.setSelection(0)
|
||||
binding.spinnerStatus.setSelection(0)
|
||||
binding.spinnerDriver.setSelection(0)
|
||||
dismiss()
|
||||
}
|
||||
|
||||
fun onConfirmClick() {
|
||||
callBack.invoke()
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.sixin.module_p.ui.goods.transportLog.list
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.lukouguoji.module_base.ktx.getLifecycleOwner
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.base.BasePdaActivity
|
||||
import com.sixin.module_p.databinding.ActivityPdaTransportLogListBinding
|
||||
|
||||
class PdaTransportLogActivity :
|
||||
BasePdaActivity<ActivityPdaTransportLogListBinding, PdaTransportLogViewModel>() {
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.activity_pda_transport_log_list
|
||||
}
|
||||
|
||||
override fun viewModelClass(): Class<PdaTransportLogViewModel> {
|
||||
return PdaTransportLogViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("转运记录")
|
||||
binding.viewModel = viewModel
|
||||
viewModel.pageModel.bindSmartRefreshLayout(
|
||||
binding.srl,
|
||||
binding.rv,
|
||||
viewModel,
|
||||
getLifecycleOwner()
|
||||
)
|
||||
viewModel.initOnCreated(intent)
|
||||
|
||||
viewModel.getData()
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
val starter = Intent(context, PdaTransportLogActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.sixin.module_p.ui.goods.transportLog.list
|
||||
|
||||
import android.view.View
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.TransportLogBean
|
||||
import com.sixin.module_p.databinding.ItemPdaTransportLogListBinding
|
||||
|
||||
class PdaTransportLogViewHolder(view: View) :
|
||||
BaseViewHolder<TransportLogBean, ItemPdaTransportLogListBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
binding.bean = getItemBean(item)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.sixin.module_p.ui.goods.transportLog.list
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.util.Log
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
||||
import com.lukouguoji.module_base.base.BaseViewModel
|
||||
import com.lukouguoji.module_base.bean.GncCunFangBean
|
||||
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.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.sixin.module_p.R
|
||||
import com.sixin.module_p.ui.gnc.cunfang.add.PdaGncCunFangAddActivity
|
||||
import com.sixin.module_p.ui.gnc.cunfang.dialog.PdaCunFangFilterDialogModel
|
||||
import com.sixin.module_p.ui.goods.transportLog.dialog.PdaTransportLogFilterDialogModel
|
||||
import dev.DevUtils
|
||||
import dev.utils.common.RandomUtils
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
|
||||
class PdaTransportLogViewModel : BasePageViewModel() {
|
||||
|
||||
val car = MutableLiveData("")
|
||||
|
||||
val index = MutableLiveData(0)
|
||||
|
||||
val count = MutableLiveData(0)
|
||||
|
||||
val itemLayoutId = R.layout.item_pda_transport_log_list
|
||||
val itemViewHolder = PdaTransportLogViewHolder::class.java
|
||||
|
||||
private val filterModel = PdaTransportLogFilterDialogModel{
|
||||
refresh()
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
fun initOnCreated(intent: Intent) {
|
||||
FlowBus.with<String>(ConstantEvent.SCAN_CODE_RESULT)
|
||||
.onEach {
|
||||
car.value = it
|
||||
onCarChange()
|
||||
}.launchIn(viewModelScope)
|
||||
}
|
||||
|
||||
override fun getData() {
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getTransportLogList(
|
||||
mapOf(
|
||||
"pageNum" to pageModel.page,
|
||||
"pageSize" to pageModel.limit,
|
||||
"fdate" to filterModel.date.value,
|
||||
"fno" to filterModel.flightNo.value,
|
||||
"opId" to filterModel.driver.value,
|
||||
"transType" to filterModel.transportType.value,
|
||||
"transStatus" to filterModel.transportStatus.value,
|
||||
"carId" to car.value,
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
pageModel.handleListBean(it)
|
||||
count.value = it.total
|
||||
}
|
||||
onComplete = {
|
||||
pageModel.finishLoading()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 筛选点击
|
||||
*/
|
||||
fun onFilterClick() {
|
||||
filterModel.show()
|
||||
}
|
||||
|
||||
fun onCarChange(focused: Boolean = false) {
|
||||
if (focused) {
|
||||
return
|
||||
}
|
||||
refresh()
|
||||
}
|
||||
|
||||
|
||||
fun scanClick() {
|
||||
ScanModel.startScan(getTopActivity(), Constant.RequestCode.CAR)
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
if (data == null || resultCode != Activity.RESULT_OK) {
|
||||
return
|
||||
}
|
||||
when (requestCode) {
|
||||
Constant.RequestCode.CAR -> {
|
||||
car.value = data.getStringExtra(Constant.Result.CODED_CONTENT).noNull()
|
||||
onCarChange()
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.sixin.module_p.ui.guobang
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.base.BasePdaActivity
|
||||
import com.sixin.module_p.databinding.ActivityPdaGuoBangBinding
|
||||
import com.sixin.module_p.helper.PDAHelper
|
||||
import me.jessyan.autosize.internal.CustomAdapt
|
||||
|
||||
class PdaGuoBangActivity : BasePdaActivity<ActivityPdaGuoBangBinding, PdaGuoBangViewModel>(),
|
||||
CustomAdapt {
|
||||
|
||||
override fun layoutId() = R.layout.activity_pda_guo_bang
|
||||
|
||||
override fun viewModelClass(): Class<PdaGuoBangViewModel> {
|
||||
return PdaGuoBangViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国际出港板箱过磅")
|
||||
viewModel.init(this)
|
||||
binding.viewModel = viewModel
|
||||
}
|
||||
|
||||
override fun isBaseOnWidth() = true
|
||||
|
||||
override fun getSizeInDp(): Float = PDAHelper.PDA_WIDTH
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
val starter = Intent(context, PdaGuoBangActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
package com.sixin.module_p.ui.guobang
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.module_base.base.BaseViewModel
|
||||
import com.lukouguoji.module_base.bean.GbCarOrUldBean
|
||||
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.impl.observe
|
||||
import com.lukouguoji.module_base.ktx.launchCollect
|
||||
import com.lukouguoji.module_base.ktx.limit
|
||||
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.DictUtils
|
||||
import dev.utils.app.info.KeyValue
|
||||
|
||||
class PdaGuoBangViewModel : BaseViewModel() {
|
||||
|
||||
val weight = MutableLiveData("0")
|
||||
|
||||
// 平板车或集装器
|
||||
val carUld = MutableLiveData("")
|
||||
val carUldBean = MutableLiveData(GbCarOrUldBean.Data())
|
||||
|
||||
// 通道列表
|
||||
val channelList = MutableLiveData(emptyList<KeyValue>())
|
||||
private var channel = KeyValue("", "")
|
||||
|
||||
// 版型
|
||||
val version = MutableLiveData("")
|
||||
|
||||
// 高度
|
||||
val height = MutableLiveData("")
|
||||
|
||||
// 收口
|
||||
val mouth = MutableLiveData("")
|
||||
|
||||
// 尺寸
|
||||
val size = MutableLiveData("")
|
||||
|
||||
// IMP代码
|
||||
val impCode = MutableLiveData("")
|
||||
|
||||
// 装机重量
|
||||
val zjWeight = MutableLiveData("")
|
||||
|
||||
// 货物重量
|
||||
val hwWeight = MutableLiveData("")
|
||||
|
||||
val cargoTypeList = mutableListOf<KeyValue>()
|
||||
|
||||
fun init(activity: AppCompatActivity) {
|
||||
// 获取通道列表
|
||||
DictUtils.getChannelList {
|
||||
channelList.postValue(listOf(KeyValue("请选择收运通道", "")) + it)
|
||||
}
|
||||
DictUtils.getCargoTypeList {
|
||||
cargoTypeList.clear()
|
||||
cargoTypeList.addAll(it)
|
||||
}
|
||||
|
||||
weight.observe(activity) {
|
||||
computeWeight()
|
||||
}
|
||||
|
||||
FlowBus.with<String>(ConstantEvent.SCAN_CODE_RESULT)
|
||||
.observe(activity) {
|
||||
carUld.value = it
|
||||
getCarOrUldData(it)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通道 选中
|
||||
*/
|
||||
fun channelSelected(position: Int) {
|
||||
channel = channelList.value!![position]
|
||||
}
|
||||
|
||||
/**
|
||||
* 运单号 改变
|
||||
*/
|
||||
fun onCarOrUldChange(focused: Boolean = false) {
|
||||
if (focused || carUld.value.isNullOrEmpty()) {
|
||||
return
|
||||
}
|
||||
getCarOrUldData(carUld.value!!)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取平板车/集装器数据
|
||||
*/
|
||||
private fun getCarOrUldData(data: String) {
|
||||
if (data.isEmpty()) {
|
||||
return
|
||||
}
|
||||
launchCollect({
|
||||
NetApply.api
|
||||
.getCarOrUldInfoForGb(data)
|
||||
}) {
|
||||
onSuccess = {
|
||||
if (it.verifySuccess()) {
|
||||
val bean = carUldBean.value!!.createForMerge(it.data!!.data!!)
|
||||
|
||||
if (!bean.getGjcLoadingBean().cargotype.isNullOrEmpty()) {
|
||||
bean.getGjcLoadingBean().cargoName = cargoTypeList.firstOrNull { item ->
|
||||
item.value == bean.getGjcLoadingBean().cargotype
|
||||
}?.key
|
||||
}
|
||||
|
||||
carUldBean.value = bean
|
||||
computeWeight()
|
||||
} else {
|
||||
showToast(it.msg.noNull("获取数据失败"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空 点击
|
||||
*/
|
||||
fun clearClick() {
|
||||
carUld.value = ""
|
||||
}
|
||||
|
||||
private fun computeWeight() {
|
||||
val total = weight.value?.toFloatOrNull() ?: 0f
|
||||
val data = carUldBean.value!!
|
||||
val carWeight = data.carweight?.toFloatOrNull() ?: 0f
|
||||
val uldWeight = data.uldWeight?.toFloatOrNull() ?: 0f
|
||||
zjWeight.value = (total - carWeight).limit()
|
||||
hwWeight.value = (total - carWeight - uldWeight).limit()
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认点击
|
||||
*/
|
||||
fun confirmClick() {
|
||||
val data = carUldBean.value!!
|
||||
if (data.carid.isNullOrEmpty() && data.uld.isNullOrEmpty()) {
|
||||
showToast("请扫描平板车或集装器")
|
||||
return
|
||||
}
|
||||
showLoading()
|
||||
launchCollect({
|
||||
NetApply.api.gjcBoxWeighingSubmit(
|
||||
mapOf(
|
||||
"carid" to data.carid,
|
||||
"carweight" to data.carweight,
|
||||
"locId" to data.getGjcLoadingBean().locId,
|
||||
"totalWeight" to data.totalWeight,
|
||||
"gjcLoading" to listOf(
|
||||
mapOf(
|
||||
"cargoweight" to hwWeight.value,
|
||||
"locId" to data.getGjcLoadingBean().locId,
|
||||
"netweight" to zjWeight.value,
|
||||
"remark" to "",
|
||||
"uldweight" to data.uldWeight,
|
||||
)
|
||||
),
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
if (it.verifySuccess()) {
|
||||
showToast("提交成功")
|
||||
resetData()
|
||||
} else {
|
||||
showToast(it.msg.noNull("提交失败"))
|
||||
}
|
||||
}
|
||||
|
||||
onComplete = {
|
||||
dismissLoading()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun resetData() {
|
||||
weight.value = "0"
|
||||
carUld.value = ""
|
||||
carUldBean.value = GbCarOrUldBean.Data()
|
||||
channel = KeyValue("", "")
|
||||
version.value = ""
|
||||
height.value = ""
|
||||
mouth.value = ""
|
||||
size.value = ""
|
||||
impCode.value = ""
|
||||
computeWeight()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.sixin.module_p.ui.lihuo
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.base.CommonAdapter
|
||||
import com.lukouguoji.module_base.interfaces.IOnItemClickListener
|
||||
import com.lukouguoji.module_base.ktx.addOnItemClickListener
|
||||
import com.lukouguoji.module_base.ktx.commonAdapter
|
||||
import com.lukouguoji.module_base.ktx.refresh
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.base.BasePdaActivity
|
||||
import com.sixin.module_p.databinding.ActivityPdaLiHuoBinding
|
||||
import com.sixin.module_p.databinding.ActivityPdaZuZhuangBinding
|
||||
import com.sixin.module_p.helper.PDAHelper
|
||||
import com.sixin.module_p.ui.lihuo.holder.PdaLhViewHolder
|
||||
import com.sixin.module_p.ui.zuzhuang.PdaZuZhuangActivity
|
||||
import com.sixin.module_p.ui.zuzhuang.PdaZuZhuangViewModel
|
||||
import com.sixin.module_p.ui.zuzhuang.holder.PdaZuZhuangViewHolder
|
||||
import dev.DevUtils
|
||||
import me.jessyan.autosize.internal.CustomAdapt
|
||||
|
||||
class PdaLiHuoActivity : BasePdaActivity<ActivityPdaLiHuoBinding, PdaLiHuoViewModel>(),
|
||||
CustomAdapt {
|
||||
|
||||
override fun layoutId() = R.layout.activity_pda_li_huo
|
||||
|
||||
override fun viewModelClass(): Class<PdaLiHuoViewModel> {
|
||||
return PdaLiHuoViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国际进港开始理货")
|
||||
viewModel.init()
|
||||
binding.viewModel = viewModel
|
||||
|
||||
binding.rv.adapter = CommonAdapter(
|
||||
requireContext(),
|
||||
R.layout.item_pda_lh,
|
||||
PdaLhViewHolder::class.java
|
||||
)
|
||||
viewModel.pageModel.rv = binding.rv
|
||||
|
||||
binding.rv.addOnItemClickListener(object : IOnItemClickListener {
|
||||
override fun onItemClick(position: Int, type: Int) {
|
||||
Common.secondConfirmDialog(
|
||||
DevUtils.getTopActivity(),
|
||||
"是否确认删除该条信息?"
|
||||
) { dialog ->
|
||||
binding.rv.commonAdapter()!!.removeItem(position)
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun isBaseOnWidth() = true
|
||||
|
||||
override fun getSizeInDp(): Float = PDAHelper.PDA_WIDTH
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
val starter = Intent(context, PdaLiHuoActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,240 @@
|
||||
package com.sixin.module_p.ui.lihuo
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
||||
import com.lukouguoji.module_base.bean.FlatcarBean
|
||||
import com.lukouguoji.module_base.bean.GjjHandoverRecordBean
|
||||
import com.lukouguoji.module_base.bean.GjjTallyAddBean
|
||||
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.loge
|
||||
import com.lukouguoji.module_base.ktx.noNull
|
||||
import com.lukouguoji.module_base.ktx.showToast
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.sixin.module_p.helper.PDAHelper
|
||||
import com.sixin.module_p.model.PdaLhSelectDialogModel
|
||||
import dev.DevUtils
|
||||
import dev.utils.common.NumberUtils
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
|
||||
class PdaLiHuoViewModel : BasePageViewModel() {
|
||||
|
||||
// 平板车
|
||||
val car = MutableLiveData("")
|
||||
|
||||
// 平板车信息
|
||||
val flatcarBean = MutableLiveData<FlatcarBean>()
|
||||
|
||||
// 运单号
|
||||
val waybill = MutableLiveData("")
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private fun reset() {
|
||||
car.value = ""
|
||||
waybill.value = ""
|
||||
flatcarBean.value = FlatcarBean()
|
||||
pageModel.refresh()
|
||||
pageModel.handleDataList(emptyList())
|
||||
}
|
||||
|
||||
fun init() {
|
||||
// 监听扫描信息
|
||||
FlowBus.with<String>(ConstantEvent.SCAN_CODE_RESULT)
|
||||
.onEach {
|
||||
onPdaScan(it)
|
||||
}
|
||||
.launchIn(viewModelScope)
|
||||
}
|
||||
|
||||
/**
|
||||
* Pda扫码回调
|
||||
*/
|
||||
private fun onPdaScan(data: String) {
|
||||
val waybill = PDAHelper.getWaybillFormScan(data)
|
||||
if (waybill.isEmpty()) {
|
||||
car.value = data
|
||||
onCarChange(false)
|
||||
} else {
|
||||
this.waybill.value = waybill
|
||||
onWaybillChange(false)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空 点击
|
||||
*/
|
||||
fun clearClick() {
|
||||
car.value = ""
|
||||
}
|
||||
|
||||
fun onCarChange(focus: Boolean) {
|
||||
if (focus) {
|
||||
return
|
||||
}
|
||||
getFlatcarInfo(car.value!!)
|
||||
}
|
||||
|
||||
fun onWaybillChange(focused: Boolean = false) {
|
||||
if (focused || waybill.value!!.isEmpty()) {
|
||||
return
|
||||
}
|
||||
val code = waybill.value.noNull()
|
||||
if (NumberUtils.isNumber(code)) {
|
||||
// 运单号
|
||||
if (code.length == 11) {
|
||||
addWaybillInfo(code)
|
||||
}
|
||||
// 运单号 + 件号
|
||||
else if (code.length == 16) {
|
||||
addWaybillInfo(code.substring(0, 11), code.substring(11))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取运单信息
|
||||
* @param waybillCode 运单号
|
||||
* @param jianCode 件号
|
||||
*/
|
||||
private fun addWaybillInfo(waybillCode: String, jianCode: String = "") {
|
||||
val adapter = pageModel.rv!!.commonAdapter()!!
|
||||
if (adapter.itemCount > 0) {
|
||||
val bean = adapter.items.first() as GjjTallyAddBean
|
||||
if (bean.handoverRecordBean.getWaybillCode() == waybillCode) {
|
||||
bean.addJian(jianCode)
|
||||
} else {
|
||||
showToast("请先完成当前运单信息")
|
||||
}
|
||||
return
|
||||
}
|
||||
launchCollect({
|
||||
NetApply.api.getGjjTallyHandoverList(
|
||||
mapOf(
|
||||
"prefix" to waybillCode.substring(0, 3),
|
||||
"no" to waybillCode.substring(3),
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
if (it.verifySuccess() && !it.data.isNullOrEmpty()) {
|
||||
if (it.data!!.size == 1) {
|
||||
val bean = it.data!!.first()
|
||||
val addBean = GjjTallyAddBean(bean)
|
||||
if (jianCode.isNotEmpty()) {
|
||||
addBean.addJian(jianCode)
|
||||
}
|
||||
adapter.addItem(addBean)
|
||||
} else {
|
||||
showSelectDialog(DevUtils.getTopActivity(), it.data!!, jianCode)
|
||||
}
|
||||
} else {
|
||||
showToast(it.msg.noNull("获取运单信息失败"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示选择弹窗
|
||||
* 仅用于选择返回
|
||||
*/
|
||||
private fun showSelectDialog(
|
||||
context: Context,
|
||||
list: List<GjjHandoverRecordBean>,
|
||||
jianCode: String = ""
|
||||
) {
|
||||
val adapter = pageModel.rv!!.commonAdapter()!!
|
||||
loge("展示选择弹窗 : ${list.size}")
|
||||
PdaLhSelectDialogModel(list) { bean ->
|
||||
val addBean = GjjTallyAddBean(bean)
|
||||
if (jianCode.isNotEmpty()) {
|
||||
addBean.addJian(jianCode)
|
||||
}
|
||||
adapter.addItem(addBean)
|
||||
}.show(context)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取平板车数据
|
||||
*/
|
||||
private fun getFlatcarInfo(id: String) {
|
||||
if (id.isEmpty()) {
|
||||
return
|
||||
}
|
||||
launchCollect({
|
||||
NetApply.api
|
||||
.getFlatcarInfo(id)
|
||||
}) {
|
||||
onSuccess = {
|
||||
if (it.verifySuccess() && it.data != null) {
|
||||
flatcarBean.value = it.data
|
||||
} else {
|
||||
showToast(it.msg.noNull("获取平板车信息失败"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认点击
|
||||
*/
|
||||
fun confirmClick() {
|
||||
val adapter = pageModel.rv!!.commonAdapter()!!
|
||||
val count = adapter.itemCount
|
||||
if (flatcarBean.value == null) {
|
||||
showToast("请先扫描平板车")
|
||||
return
|
||||
}
|
||||
if (count <= 0) {
|
||||
showToast("请先添加运单信息")
|
||||
return
|
||||
}
|
||||
|
||||
val bean = adapter.items.first() as GjjTallyAddBean
|
||||
val jianListStr = bean.jianList.joinToString(",") { it.value }
|
||||
|
||||
showLoading()
|
||||
launchCollect({
|
||||
val requestBody = mapOf(
|
||||
"carID" to flatcarBean.value!!.carId,
|
||||
"isBatch" to "1",
|
||||
"list" to jianListStr,
|
||||
"mfId" to bean.handoverRecordBean.mfId,
|
||||
"no" to bean.handoverRecordBean.no,
|
||||
"organizationcode" to bean.handoverRecordBean.organizationCode,
|
||||
"pc" to bean.handoverRecordBean.pc,
|
||||
"prefix" to bean.handoverRecordBean.prefix,
|
||||
"weight" to bean.handoverRecordBean.weight,
|
||||
"pcID" to bean.handoverRecordBean.pcID,
|
||||
).toRequestBody()
|
||||
NetApply.api.gjjTallyConfirm(requestBody)
|
||||
}) {
|
||||
onSuccess = {
|
||||
dismissLoading()
|
||||
if (it.verifySuccess()) {
|
||||
showToast(it.msg.noNull("确认成功"))
|
||||
reset()
|
||||
} else {
|
||||
showToast(it.msg.noNull("确认失败"))
|
||||
}
|
||||
}
|
||||
|
||||
onComplete = {
|
||||
dismissLoading()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getData() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.sixin.module_p.ui.lihuo.holder
|
||||
|
||||
import android.view.View
|
||||
import androidx.databinding.ObservableArrayList
|
||||
import androidx.databinding.ObservableList
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.base.CommonAdapter
|
||||
import com.lukouguoji.module_base.bean.GjcBoxAddListBean
|
||||
import com.lukouguoji.module_base.bean.GjjTallyAddBean
|
||||
import com.lukouguoji.module_base.bean.JianBean
|
||||
import com.lukouguoji.module_base.ktx.refresh
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.databinding.ItemPdaLhBinding
|
||||
import com.sixin.module_p.databinding.ItemPdaZuZhuangBinding
|
||||
import com.sixin.module_p.ui.zuzhuang.holder.PdaJianViewHolder
|
||||
|
||||
class PdaLhViewHolder(view: View) :
|
||||
BaseViewHolder<GjjTallyAddBean, ItemPdaLhBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
val bean = getItemBean(item)!!
|
||||
binding.bean = bean.handoverRecordBean
|
||||
|
||||
binding.rv.adapter = CommonAdapter(
|
||||
requireContext(),
|
||||
R.layout.item_pda_jian,
|
||||
PdaJianViewHolder::class.java
|
||||
)
|
||||
binding.rv.refresh(bean.jianList)
|
||||
|
||||
binding.ivDown.setOnClickListener {
|
||||
val visible = if (binding.rv.visibility == View.VISIBLE) View.GONE else View.VISIBLE
|
||||
binding.rv.visibility = visible
|
||||
binding.tvJ.visibility = visible
|
||||
}
|
||||
|
||||
bean.jianList.addOnListChangedCallback(object :
|
||||
ObservableList.OnListChangedCallback<ObservableArrayList<JianBean>>() {
|
||||
override fun onChanged(sender: ObservableArrayList<JianBean>?) {
|
||||
binding.rv.refresh(bean.jianList)
|
||||
}
|
||||
|
||||
override fun onItemRangeChanged(
|
||||
sender: ObservableArrayList<JianBean>?,
|
||||
positionStart: Int,
|
||||
itemCount: Int
|
||||
) {
|
||||
binding.rv.refresh(bean.jianList)
|
||||
}
|
||||
|
||||
override fun onItemRangeInserted(
|
||||
sender: ObservableArrayList<JianBean>?,
|
||||
positionStart: Int,
|
||||
itemCount: Int
|
||||
) {
|
||||
binding.rv.refresh(bean.jianList)
|
||||
}
|
||||
|
||||
override fun onItemRangeMoved(
|
||||
sender: ObservableArrayList<JianBean>?,
|
||||
fromPosition: Int,
|
||||
toPosition: Int,
|
||||
itemCount: Int
|
||||
) {
|
||||
binding.rv.refresh(bean.jianList)
|
||||
}
|
||||
|
||||
override fun onItemRangeRemoved(
|
||||
sender: ObservableArrayList<JianBean>?,
|
||||
positionStart: Int,
|
||||
itemCount: Int
|
||||
) {
|
||||
binding.rv.refresh(bean.jianList)
|
||||
}
|
||||
})
|
||||
|
||||
notifyItemClick(position, binding.tvDeleteOrder)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.sixin.module_p.ui.set
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.common.ConstantEvent
|
||||
import com.lukouguoji.module_base.impl.FlowBus
|
||||
import com.lukouguoji.module_base.impl.observe
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.base.BasePdaActivity
|
||||
import com.sixin.module_p.databinding.ActivityPdaSetBinding
|
||||
import com.sixin.module_p.helper.PDAHelper
|
||||
import me.jessyan.autosize.internal.CustomAdapt
|
||||
|
||||
class PdaSetActivity : BasePdaActivity<ActivityPdaSetBinding, PdaSetViewModel>(),
|
||||
CustomAdapt {
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.activity_pda_set
|
||||
}
|
||||
|
||||
override fun viewModelClass(): Class<PdaSetViewModel> {
|
||||
return PdaSetViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("重置密码")
|
||||
|
||||
binding.viewModel = viewModel
|
||||
FlowBus.with<Any>(ConstantEvent.LOGOUT)
|
||||
.observe(this) {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun isBaseOnWidth() = true
|
||||
|
||||
override fun getSizeInDp(): Float = PDAHelper.PDA_WIDTH
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
val starter = Intent(context, PdaSetActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.sixin.module_p.ui.set
|
||||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.lukouguoji.module_base.base.BaseViewModel
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.common.ConstantEvent
|
||||
import com.lukouguoji.module_base.db.perference.SharedPreferenceUtil
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.impl.FlowBus
|
||||
import com.lukouguoji.module_base.ktx.launchCollect
|
||||
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.router.ARouterConstants
|
||||
import com.lukouguoji.module_base.service.repository.LoginRepository
|
||||
|
||||
class PdaSetViewModel : BaseViewModel() {
|
||||
|
||||
val account = SharedPreferenceUtil.getString(Constant.Share.userName).noNull()
|
||||
|
||||
val password = MutableLiveData("")
|
||||
val oldPassword = MutableLiveData("")
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* 确认 点击
|
||||
*/
|
||||
fun onConfirmClick() {
|
||||
if ((password.value.verifyNullOrEmpty("请输入新密码")
|
||||
|| oldPassword.value.verifyNullOrEmpty("请输入原密码"))
|
||||
) {
|
||||
return
|
||||
}
|
||||
showLoading()
|
||||
launchCollect({
|
||||
NetApply.api.modifyPassword(
|
||||
mapOf(
|
||||
"id" to "",
|
||||
"newPwd" to password.value,
|
||||
"oldPwd" to oldPassword.value,
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
if (it.verifySuccess()) {
|
||||
showToast(it.msg.noNull("密码修改成功"))
|
||||
LoginRepository.logout()
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_LOGIN).navigation()
|
||||
FlowBus.with<Any>(ConstantEvent.LOGOUT)
|
||||
.tryEmit(true)
|
||||
} else {
|
||||
showToast(it.msg.noNull("密码修改失败"))
|
||||
}
|
||||
}
|
||||
onComplete = {
|
||||
dismissLoading()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消点击
|
||||
*/
|
||||
fun onCancelClick() {
|
||||
password.value = ""
|
||||
oldPassword.value = ""
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出登录 点击
|
||||
*/
|
||||
fun onLogoutClick() {
|
||||
LoginRepository.logout()
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_LOGIN).navigation()
|
||||
FlowBus.with<Any>(ConstantEvent.LOGOUT)
|
||||
.tryEmit(true)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.sixin.module_p.ui.shouyun
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.base.BasePdaActivity
|
||||
import com.sixin.module_p.databinding.ActivityPdaShouYunBinding
|
||||
import com.sixin.module_p.helper.PDAHelper
|
||||
import me.jessyan.autosize.internal.CustomAdapt
|
||||
|
||||
class PdaShouYunActivity : BasePdaActivity<ActivityPdaShouYunBinding, PdaShouYunViewModel>(),
|
||||
CustomAdapt {
|
||||
|
||||
override fun layoutId() = R.layout.activity_pda_shou_yun
|
||||
|
||||
override fun viewModelClass(): Class<PdaShouYunViewModel> {
|
||||
return PdaShouYunViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国际出港开始收运")
|
||||
viewModel.init()
|
||||
binding.viewModel = viewModel
|
||||
}
|
||||
|
||||
override fun isBaseOnWidth() = true
|
||||
|
||||
override fun getSizeInDp(): Float = PDAHelper.PDA_WIDTH
|
||||
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
val starter = Intent(context, PdaShouYunActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
package com.sixin.module_p.ui.shouyun
|
||||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.lukouguoji.module_base.base.BaseViewModel
|
||||
import com.lukouguoji.module_base.bean.SYWaybillBean
|
||||
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.getLifecycleOwner
|
||||
import com.lukouguoji.module_base.ktx.launchCollect
|
||||
import com.lukouguoji.module_base.ktx.limit
|
||||
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.util.DictUtils
|
||||
import com.sixin.module_p.helper.PDAHelper
|
||||
import dev.DevUtils
|
||||
import dev.utils.app.info.KeyValue
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
|
||||
class PdaShouYunViewModel : BaseViewModel() {
|
||||
|
||||
val weight = MutableLiveData("0")
|
||||
|
||||
// 运单号
|
||||
val waybill = MutableLiveData("")
|
||||
|
||||
// 通道列表
|
||||
val channelList = MutableLiveData(emptyList<KeyValue>())
|
||||
private var channel = KeyValue("", "")
|
||||
|
||||
// 托盘重量
|
||||
val palletWeight = MutableLiveData("0")
|
||||
|
||||
// 运抵数量
|
||||
val arrivalCount = MutableLiveData("1")
|
||||
|
||||
// 运抵重量
|
||||
val arrivalWeight = MutableLiveData("0")
|
||||
|
||||
// 运抵体积
|
||||
val arrivalVolume = MutableLiveData("0")
|
||||
|
||||
// 备注
|
||||
val remark = MutableLiveData("")
|
||||
|
||||
// 运单信息
|
||||
val waybillBean = MutableLiveData<SYWaybillBean?>()
|
||||
|
||||
fun init() {
|
||||
// 获取通道列表
|
||||
DictUtils.getChannelList {
|
||||
channelList.postValue(listOf(KeyValue("请选择收运通道", "")) + it)
|
||||
}
|
||||
// 监听扫描信息
|
||||
FlowBus.with<String>(ConstantEvent.SCAN_CODE_RESULT)
|
||||
.onEach {
|
||||
getWaybillInfo(it)
|
||||
}
|
||||
.launchIn(viewModelScope)
|
||||
|
||||
// 监听地磅重量并赋值
|
||||
weight.observe(DevUtils.getTopActivity().getLifecycleOwner()) {
|
||||
computeArrivalWeight()
|
||||
}
|
||||
palletWeight.observe(DevUtils.getTopActivity().getLifecycleOwner()) {
|
||||
computeArrivalWeight()
|
||||
}
|
||||
arrivalWeight.observe(DevUtils.getTopActivity().getLifecycleOwner()) {
|
||||
arrivalVolume.value = ((it.toFloatOrNull() ?: 0f) / 220f).limit()
|
||||
}
|
||||
}
|
||||
|
||||
private fun computeArrivalWeight() {
|
||||
arrivalWeight.value = ((weight.value?.toFloatOrNull() ?: 0f)
|
||||
- (palletWeight.value?.toFloatOrNull() ?: 0f)).limit()
|
||||
}
|
||||
|
||||
/**
|
||||
* 通道 选中
|
||||
*/
|
||||
fun channelSelected(position: Int) {
|
||||
channel = channelList.value!![position]
|
||||
}
|
||||
|
||||
/**
|
||||
* 运单号 改变
|
||||
*/
|
||||
fun onWaybillChange(focused: Boolean = false) {
|
||||
if (focused) {
|
||||
return
|
||||
}
|
||||
getWaybillInfo(waybill.value.noNull())
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取运单信息
|
||||
*/
|
||||
private fun getWaybillInfo(data: String) {
|
||||
val waybill = PDAHelper.getWaybillFormScan(data)
|
||||
if (waybill.isEmpty()) {
|
||||
return
|
||||
}
|
||||
this@PdaShouYunViewModel.waybill.value = waybill
|
||||
launchCollect({
|
||||
NetApply.api.getSyWaybillInfo(waybill, arrivalWeight.value.noNull(""))
|
||||
}) {
|
||||
onSuccess = {
|
||||
if (!it.verifySuccess()) {
|
||||
showToast(it.msg.noNull("获取运单信息失败"))
|
||||
} else {
|
||||
it.data?.let { data ->
|
||||
waybillBean.postValue(data)
|
||||
|
||||
// arrivalCount.value = data.recheckCount.noNull("1")
|
||||
// arrivalWeight.value = data.arriveWeight.noNull("0")
|
||||
// arrivalVolume.value = data.arriveVolume.noNull("0")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认点击
|
||||
*/
|
||||
fun confirmClick() {
|
||||
if (waybillBean.value.verifyNullOrEmpty("请扫描运单")
|
||||
|| palletWeight.value.verifyNullOrEmpty("请输入托盘重量")
|
||||
|| arrivalCount.value.verifyNullOrEmpty("请输入运抵件数")
|
||||
|| arrivalWeight.value.verifyNullOrEmpty("请输入运抵重量")
|
||||
|| arrivalVolume.value.verifyNullOrEmpty("请输入运抵体积")
|
||||
) {
|
||||
return
|
||||
}
|
||||
val bean = waybillBean.value!!
|
||||
showLoading()
|
||||
launchCollect({
|
||||
NetApply.api.completionCollection(
|
||||
mapOf(
|
||||
"maWbId" to bean.maWbId,
|
||||
"wbNo" to bean.wbNo,
|
||||
"pclist" to bean.pclist,
|
||||
"agentCode" to bean.agent.noNull(bean.agentCode.noNull()),
|
||||
"goods" to bean.goods,
|
||||
"spCode" to bean.spCode,
|
||||
"businessType" to bean.businessType,
|
||||
"awbType" to bean.awbType,
|
||||
"pc" to bean.pc,
|
||||
"weight" to bean.grossWeight,
|
||||
"volume" to bean.volume,
|
||||
"arrivePc" to arrivalCount.value,
|
||||
"arriveWeight" to arrivalWeight.value,
|
||||
"arriveVolume" to arrivalVolume.value,
|
||||
"activeId" to bean.activeId,
|
||||
"remark" to remark.value,
|
||||
"dep" to bean.dep,
|
||||
"dest" to bean.dest,
|
||||
"dest1" to bean.dest1,
|
||||
"by1" to bean.by1,
|
||||
"checkIn" to bean.checkIn,
|
||||
).toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
if (it.verifySuccess()) {
|
||||
resetData()
|
||||
if (!it.msg.isNullOrEmpty()) {
|
||||
showToast(it.msg!!)
|
||||
}
|
||||
} else {
|
||||
showToast(it.msg.noNull("收运失败"))
|
||||
}
|
||||
}
|
||||
onComplete = {
|
||||
dismissLoading()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun resetData() {
|
||||
waybillBean.value = null
|
||||
palletWeight.value = "0"
|
||||
arrivalWeight.value = "0"
|
||||
arrivalCount.value = "1"
|
||||
arrivalVolume.value = "0"
|
||||
remark.value = ""
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.sixin.module_p.ui.user.about
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.base.BasePdaActivity
|
||||
import com.sixin.module_p.databinding.ActivityPdaAboutUsBinding
|
||||
|
||||
class PdaAboutUsActivity : BasePdaActivity<ActivityPdaAboutUsBinding, PdaAboutUsViewModel>() {
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.activity_pda_about_us
|
||||
}
|
||||
|
||||
override fun viewModelClass(): Class<PdaAboutUsViewModel> {
|
||||
return PdaAboutUsViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("关于我们")
|
||||
binding.viewModel = viewModel
|
||||
viewModel.onInit()
|
||||
}
|
||||
|
||||
companion object{
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
val starter = Intent(context, PdaAboutUsActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.sixin.module_p.ui.user.about
|
||||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.module_base.base.BaseViewModel
|
||||
import com.lukouguoji.module_base.ktx.loge
|
||||
import dev.DevUtils
|
||||
import dev.utils.app.AppUtils
|
||||
import dev.utils.app.info.KeyValue
|
||||
import java.security.Key
|
||||
|
||||
class PdaAboutUsViewModel : BaseViewModel() {
|
||||
|
||||
val version = MutableLiveData("V 1.0.0")
|
||||
|
||||
fun onInit() {
|
||||
version.value = "V ${AppUtils.getAppVersionName()}"
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.sixin.module_p.ui.user.message
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.module_base.base.BaseDialogModel
|
||||
import com.lukouguoji.module_base.ktx.formatDate
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.lxj.xpopup.XPopup
|
||||
import com.lxj.xpopup.enums.PopupPosition
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.databinding.DialogPdaMessageFilterBinding
|
||||
import dev.DevUtils
|
||||
import dev.utils.common.DateUtils
|
||||
import java.util.Calendar
|
||||
|
||||
class PdaMessageFilterDialogModel(
|
||||
private val callBack: () -> Unit
|
||||
) : BaseDialogModel<DialogPdaMessageFilterBinding>(DIALOG_TYPE_DRAWER) {
|
||||
|
||||
val date = MutableLiveData(DateUtils.getCurrentTime().formatDate())
|
||||
val beginDate = MutableLiveData(DateUtils.getCurrentTime().formatDate())
|
||||
val endDate = MutableLiveData(DateUtils.getCurrentTime().formatDate())
|
||||
val keyWord = MutableLiveData("")
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.dialog_pda_message_filter
|
||||
}
|
||||
|
||||
override fun onDialogCreated(context: Context) {
|
||||
binding.model = this
|
||||
}
|
||||
|
||||
override fun onBuild(builder: XPopup.Builder) {
|
||||
builder.popupPosition(PopupPosition.Right)
|
||||
}
|
||||
|
||||
fun onDateClick() {
|
||||
Common.onYearMonthDay(DevUtils.getTopActivity(), date.value) { year, month, day ->
|
||||
val calendar = Calendar.getInstance()
|
||||
calendar.set(year, month - 1, day)
|
||||
date.value = DateUtils.formatDate(calendar.time, "yyyy-MM-dd")
|
||||
}
|
||||
}
|
||||
fun onBeginDateClick() {
|
||||
Common.onYearMonthDay(DevUtils.getTopActivity(), beginDate.value) { year, month, day ->
|
||||
val calendar = Calendar.getInstance()
|
||||
calendar.set(year, month - 1, day)
|
||||
beginDate.value = DateUtils.formatDate(calendar.time, "yyyy-MM-dd")
|
||||
}
|
||||
}
|
||||
fun onEndDateClick() {
|
||||
Common.onYearMonthDay(DevUtils.getTopActivity(), endDate.value) { year, month, day ->
|
||||
val calendar = Calendar.getInstance()
|
||||
calendar.set(year, month - 1, day)
|
||||
endDate.value = DateUtils.formatDate(calendar.time, "yyyy-MM-dd")
|
||||
}
|
||||
}
|
||||
|
||||
fun onResetClick() {
|
||||
date.value = DateUtils.getCurrentTime().formatDate()
|
||||
keyWord.value = ""
|
||||
onConfirmClick()
|
||||
}
|
||||
|
||||
fun onConfirmClick() {
|
||||
callBack.invoke()
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.sixin.module_p.ui.user.message
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.lukouguoji.module_base.ktx.getLifecycleOwner
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.base.BasePdaActivity
|
||||
import com.sixin.module_p.databinding.ActivityPdaMessageBinding
|
||||
|
||||
class PdaMessageListActivity :
|
||||
BasePdaActivity<ActivityPdaMessageBinding, PdaMessageListViewModel>() {
|
||||
|
||||
override fun layoutId(): Int {
|
||||
return R.layout.activity_pda_message
|
||||
}
|
||||
|
||||
override fun viewModelClass(): Class<PdaMessageListViewModel> {
|
||||
return PdaMessageListViewModel::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, PdaMessageListActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.sixin.module_p.ui.user.message
|
||||
|
||||
import android.view.View
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.MessageBean
|
||||
import com.sixin.module_p.databinding.ItemPdaMessageBinding
|
||||
|
||||
class PdaMessageListViewHolder(view: View) :
|
||||
BaseViewHolder<MessageBean, ItemPdaMessageBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
binding.bean = getItemBean(item)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.sixin.module_p.ui.user.message
|
||||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
||||
import com.lukouguoji.module_base.bean.MessageBean
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.ktx.commonAdapter
|
||||
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.sixin.module_p.R
|
||||
import dev.utils.common.RandomUtils
|
||||
|
||||
class PdaMessageListViewModel : BasePageViewModel() {
|
||||
|
||||
val index = MutableLiveData(0)
|
||||
|
||||
val count = MutableLiveData(0)
|
||||
|
||||
val itemLayoutId = R.layout.item_pda_message
|
||||
val itemViewHolder = PdaMessageListViewHolder::class.java
|
||||
|
||||
val filterDialogModel by lazy {
|
||||
PdaMessageFilterDialogModel {
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
|
||||
fun onTabChanged(type: Int) {
|
||||
if (index.value != type) {
|
||||
index.value = type
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
|
||||
override fun getData() {
|
||||
val body = mapOf(
|
||||
"pageNum" to pageModel.page,
|
||||
"pageSize" to pageModel.limit,
|
||||
"state" to index.value,
|
||||
"beginDate" to filterDialogModel.beginDate.value,
|
||||
"endDate" to filterDialogModel.endDate.value,
|
||||
"content" to filterDialogModel.keyWord.value,
|
||||
).toRequestBody()
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getMessageList(
|
||||
body
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
pageModel.handleListBean(it)
|
||||
count.value = it.total
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onConfirmClick() {
|
||||
val list = pageModel.rv?.commonAdapter()?.items?.filter {
|
||||
(it as MessageBean).checked.get()
|
||||
} ?: emptyList()
|
||||
if (list.isEmpty()) {
|
||||
showToast("请选择需要处理的数据")
|
||||
return
|
||||
}
|
||||
launchLoadingCollect({
|
||||
NetApply.api.anyPost(
|
||||
"msg/handleList",
|
||||
list.map { (it as MessageBean).id }.toRequestBody()
|
||||
)
|
||||
}) {
|
||||
onSuccess = {
|
||||
showToast(it.msg.noNull("处理成功"))
|
||||
refresh()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onFilterClick() {
|
||||
filterDialogModel.show()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.sixin.module_p.ui.zuzhuang
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.res.Configuration
|
||||
import android.content.res.Resources
|
||||
import android.os.Build
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.base.CommonAdapter
|
||||
import com.lukouguoji.module_base.interfaces.IOnItemClickListener
|
||||
import com.lukouguoji.module_base.ktx.addOnItemClickListener
|
||||
import com.lukouguoji.module_base.ktx.commonAdapter
|
||||
import com.lukouguoji.module_base.ktx.refresh
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.base.BasePdaActivity
|
||||
import com.sixin.module_p.databinding.ActivityPdaZuZhuangBinding
|
||||
import com.sixin.module_p.helper.PDAHelper
|
||||
import com.sixin.module_p.ui.zuzhuang.holder.PdaZuZhuangViewHolder
|
||||
import dev.DevUtils
|
||||
import dev.utils.app.HandlerUtils
|
||||
import me.jessyan.autosize.AutoSizeCompat
|
||||
import me.jessyan.autosize.internal.CustomAdapt
|
||||
|
||||
class PdaZuZhuangActivity :
|
||||
BasePdaActivity<ActivityPdaZuZhuangBinding, PdaZuZhuangViewModel>(),
|
||||
CustomAdapt {
|
||||
|
||||
override fun layoutId() = R.layout.activity_pda_zu_zhuang
|
||||
|
||||
override fun viewModelClass(): Class<PdaZuZhuangViewModel> {
|
||||
return PdaZuZhuangViewModel::class.java
|
||||
}
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国际出港开始组装")
|
||||
viewModel.init()
|
||||
binding.viewModel = viewModel
|
||||
|
||||
binding.rv.adapter = CommonAdapter(
|
||||
requireContext(),
|
||||
R.layout.item_pda_zu_zhuang,
|
||||
PdaZuZhuangViewHolder::class.java
|
||||
)
|
||||
viewModel.pageModel.rv = binding.rv
|
||||
|
||||
binding.rv.addOnItemClickListener(object : IOnItemClickListener {
|
||||
override fun onItemClick(position: Int, type: Int) {
|
||||
Common.secondConfirmDialog(
|
||||
DevUtils.getTopActivity(),
|
||||
"是否确认删除该条信息?"
|
||||
) { dialog ->
|
||||
binding.rv.commonAdapter()!!.removeItem(position)
|
||||
dialog.dismiss()
|
||||
viewModel.computeTotal()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun isBaseOnWidth() = true
|
||||
|
||||
override fun getSizeInDp(): Float = PDAHelper.PDA_WIDTH
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
val starter = Intent(context, PdaZuZhuangActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,339 @@
|
||||
package com.sixin.module_p.ui.zuzhuang
|
||||
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
||||
import com.lukouguoji.module_base.bean.CarOrUldBean
|
||||
import com.lukouguoji.module_base.bean.GcjBoxAddReqBean
|
||||
import com.lukouguoji.module_base.bean.GjcBoxAddListBean
|
||||
import com.lukouguoji.module_base.bean.JianBean
|
||||
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.limit
|
||||
import com.lukouguoji.module_base.ktx.loge
|
||||
import com.lukouguoji.module_base.ktx.noNull
|
||||
import com.lukouguoji.module_base.ktx.showToast
|
||||
import com.lukouguoji.module_base.ktx.toJson
|
||||
import com.lukouguoji.module_base.ktx.toMap
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.sixin.module_p.helper.PDAHelper
|
||||
import com.sixin.module_p.model.PdaZzSelectDialogModel
|
||||
import dev.DevUtils
|
||||
import dev.utils.common.NumberUtils
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
|
||||
class PdaZuZhuangViewModel : BasePageViewModel() {
|
||||
|
||||
// 平板车或集装器
|
||||
val carUld = MutableLiveData("")
|
||||
|
||||
// 运单号
|
||||
val waybill = MutableLiveData("")
|
||||
|
||||
// 平板车和集装器 数据
|
||||
val carUldBean = MutableLiveData(CarOrUldBean())
|
||||
var insertId = ""
|
||||
|
||||
// 总件数
|
||||
val totalCount = MutableLiveData(0)
|
||||
|
||||
// 总重量
|
||||
val totalWeight = MutableLiveData(0.0)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 方法区
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private fun reset() {
|
||||
carUld.value = ""
|
||||
waybill.value = ""
|
||||
carUldBean.value = CarOrUldBean()
|
||||
insertId = ""
|
||||
totalCount.value = 0
|
||||
totalWeight.value = 0.0
|
||||
pageModel.refresh()
|
||||
pageModel.handleDataList(emptyList())
|
||||
}
|
||||
|
||||
fun init() {
|
||||
// 监听扫描信息
|
||||
FlowBus.with<String>(ConstantEvent.SCAN_CODE_RESULT)
|
||||
.onEach {
|
||||
onPdaScan(it)
|
||||
}
|
||||
.launchIn(viewModelScope)
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空 点击
|
||||
*/
|
||||
fun clearClick() {
|
||||
carUld.value = ""
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认点击
|
||||
*/
|
||||
fun confirmClick() {
|
||||
if (!verifyCarULD()) {
|
||||
return
|
||||
}
|
||||
val adapter = pageModel.rv!!.commonAdapter()!!
|
||||
val items = adapter.items as List<GjcBoxAddListBean>
|
||||
if (items.isEmpty()) {
|
||||
showToast("请扫描或选择运单")
|
||||
return
|
||||
}
|
||||
Common.secondConfirmDialog(
|
||||
DevUtils.getTopActivity(),
|
||||
"是否确认组装?"
|
||||
) { dialog ->
|
||||
dialog.dismiss()
|
||||
doConfirm(items)
|
||||
}
|
||||
}
|
||||
|
||||
private fun doConfirm(items: List<GjcBoxAddListBean>) {
|
||||
val bean = GcjBoxAddReqBean(locId = insertId)
|
||||
bean.setGjcBoxAddList(items, carUldBean.value!!.uldWeight.noNull("0.0"))
|
||||
showLoading()
|
||||
launchCollect({
|
||||
val map = bean.toMap()
|
||||
map["isAdd"] = true
|
||||
NetApply.api
|
||||
.gjcBoxAddConfirm(map.toRequestBody())
|
||||
}) {
|
||||
onSuccess = {
|
||||
if (it.verifySuccess()) {
|
||||
showToast("操作成功")
|
||||
FlowBus.with<Any>(ConstantEvent.GJC_BOX_ADD_SUCCESS)
|
||||
.tryEmit(true)
|
||||
reset()
|
||||
} else {
|
||||
showToast(it.msg.noNull("操作失败"))
|
||||
}
|
||||
}
|
||||
onComplete = {
|
||||
dismissLoading()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验当前平板车和ULD是否都扫描成功
|
||||
*/
|
||||
private fun verifyCarULD(): Boolean {
|
||||
if (carUldBean.value!!.carId.isNullOrEmpty() && carUldBean.value!!.uld.isNullOrEmpty()) {
|
||||
showToast("请扫描平板车或ULD信息")
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Pda扫码回调
|
||||
*/
|
||||
private fun onPdaScan(data: String) {
|
||||
val waybill = PDAHelper.getWaybillFormScan(data)
|
||||
if (waybill.isEmpty()) {
|
||||
carUld.value = data
|
||||
carUldChange(false)
|
||||
} else {
|
||||
this.waybill.value = waybill
|
||||
waybillChange(false)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 平板车/集装器 改变监听
|
||||
*/
|
||||
fun carUldChange(focus: Boolean) {
|
||||
if (focus) return
|
||||
carUld.value?.let {
|
||||
getCarOrUldData(it)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 运单号 改变监听
|
||||
*/
|
||||
fun waybillChange(focus: Boolean) {
|
||||
if (focus) return
|
||||
val code = waybill.value ?: return
|
||||
if (NumberUtils.isNumber(code)) {
|
||||
// 运单号
|
||||
if (code.length == 11) {
|
||||
addWaybillInfo(code)
|
||||
}
|
||||
// 运单号 + 件号
|
||||
else if (code.length == 16) {
|
||||
addWaybillInfo(code.substring(0, 11), code.substring(11))
|
||||
}
|
||||
}
|
||||
if (code.length > 16) {
|
||||
loge("件号 : $code")
|
||||
addWaybillInfo(code, code)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取运单信息
|
||||
* @param waybillCode 运单号
|
||||
* @param jianCode 件号
|
||||
* @param whid 仓库ID, 不为空,则视为更新
|
||||
*/
|
||||
private fun addWaybillInfo(waybillCode: String, jianCode: String = "", whid: String = "") {
|
||||
// 非更新
|
||||
if (whid.isEmpty()) {
|
||||
val find =
|
||||
(pageModel.rv!!.commonAdapter()!!.items as List<GjcBoxAddListBean>).find { it.waybillBean.getWaybillCode() == waybillCode }
|
||||
if (find != null) {
|
||||
if (jianCode.isEmpty()) {
|
||||
showToast("该运单已在列表中")
|
||||
} else {
|
||||
addJian(jianCode, find)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
launchCollect({
|
||||
NetApply.api.getGjcWaybillInfo(waybillCode)
|
||||
}) {
|
||||
onSuccess = {
|
||||
if (it.verifySuccess() && it.data != null && !it.data!!.whList.isNullOrEmpty()) {
|
||||
val filter = it.data!!.whList!!.filter { bean -> bean.location.isNullOrEmpty() }
|
||||
if (filter.isEmpty()) {
|
||||
showToast("该运单已装配到设备上")
|
||||
} else {
|
||||
// 重新获取列表
|
||||
val adapter = pageModel.rv!!.commonAdapter()!!
|
||||
val list = adapter.items as List<GjcBoxAddListBean>
|
||||
if (whid.isNotEmpty()) {
|
||||
// 更新数据
|
||||
filter.find { b -> b.whid == whid }?.let { b ->
|
||||
list.find { l -> l.waybillBean.whid == whid }?.let { f ->
|
||||
f.waybillBean = b
|
||||
adapter.notifyItemChanged(list.indexOf(f))
|
||||
addJian(jianCode, f)
|
||||
}
|
||||
}
|
||||
} else if (filter.size > 1) {
|
||||
PdaZzSelectDialogModel(filter) { b ->
|
||||
val listBean = GjcBoxAddListBean(b)
|
||||
adapter.addItem(listBean)
|
||||
loge("新增数据 ${b.whid} , 添加件 : $jianCode")
|
||||
addJian(jianCode, listBean)
|
||||
}.show(DevUtils.getTopActivity())
|
||||
} else {
|
||||
val first = filter.first()
|
||||
val listBean = GjcBoxAddListBean(first)
|
||||
adapter.addItem(listBean)
|
||||
loge("新增数据 ${first.whid} , 添加件 : $jianCode")
|
||||
addJian(jianCode, listBean)
|
||||
}
|
||||
}
|
||||
computeTotal()
|
||||
} else {
|
||||
showToast(it.msg.noNull("获取运单信息失败"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取平板车/集装器数据
|
||||
*/
|
||||
private fun getCarOrUldData(data: String) {
|
||||
if (data.isEmpty()) {
|
||||
return
|
||||
}
|
||||
launchCollect({
|
||||
NetApply.api
|
||||
.getCarOrUldInfoForSyZz(data)
|
||||
}) {
|
||||
onSuccess = {
|
||||
if (it.verifySuccess()) {
|
||||
val bean = carUldBean.value!!.createForMerge(it.data!!.data!!)
|
||||
insertCarOrULD(bean)
|
||||
} else {
|
||||
showToast(it.msg.noNull("获取数据失败"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入数据
|
||||
*/
|
||||
private fun insertCarOrULD(bean: CarOrUldBean) {
|
||||
val map = hashMapOf(
|
||||
"carid" to bean.carId,
|
||||
"carweight" to bean.carWeight,
|
||||
"locId" to insertId,
|
||||
"gjcLoading" to listOf(
|
||||
mapOf(
|
||||
"carid" to bean.carId,
|
||||
"locId" to insertId,
|
||||
"maxweight" to bean.maxWeight,
|
||||
"maxvolume" to bean.maxVolume,
|
||||
"uld" to bean.uld,
|
||||
"uldflag" to bean.uldFlag,
|
||||
"uldweight" to bean.uldWeight,
|
||||
)
|
||||
)
|
||||
)
|
||||
launchCollect({
|
||||
NetApply.api
|
||||
.gjcBoxInsert(map.toRequestBody())
|
||||
}) {
|
||||
onSuccess = {
|
||||
if (it.verifySuccess()) {
|
||||
it.data?.locId?.let { id -> insertId = id }
|
||||
carUldBean.value = bean
|
||||
loge("插入数据成功 : ${carUldBean.value.toJson()}")
|
||||
} else {
|
||||
showToast(it.msg.noNull("插入数据失败"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加件号
|
||||
*/
|
||||
private fun addJian(code: String, bean: GjcBoxAddListBean) {
|
||||
if (code.isEmpty()) {
|
||||
computeTotal()
|
||||
return
|
||||
}
|
||||
if (bean.jianList.find { b -> b.code == JianBean.getCode(code) } == null) {
|
||||
bean.jianList.add(JianBean.create(code))
|
||||
}
|
||||
computeTotal()
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算总数
|
||||
*/
|
||||
fun computeTotal(list: List<GjcBoxAddListBean>? = null) {
|
||||
val adapter = pageModel.rv!!.commonAdapter()!!
|
||||
val items = list ?: adapter.items as List<GjcBoxAddListBean>
|
||||
var count = 0
|
||||
var weight = 0.0
|
||||
items.forEach { bean ->
|
||||
count += if (bean.jianList.isEmpty()) bean.waybillBean.pc.noNull("0")
|
||||
.toInt() else bean.jianList.size
|
||||
weight += (bean.waybillBean.weight.noNull().toDouble())
|
||||
}
|
||||
totalCount.value = count
|
||||
totalWeight.value = weight.limit(2).toDouble()
|
||||
}
|
||||
|
||||
override fun getData() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.sixin.module_p.ui.zuzhuang.holder
|
||||
|
||||
import android.view.View
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.JianBean
|
||||
import com.sixin.module_p.databinding.ItemPdaJianBinding
|
||||
|
||||
class PdaJianViewHolder(view: View) : BaseViewHolder<JianBean, ItemPdaJianBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
val bean = getItemBean(item) ?: return
|
||||
binding.bean = bean
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.sixin.module_p.ui.zuzhuang.holder
|
||||
|
||||
import android.view.View
|
||||
import androidx.databinding.ObservableArrayList
|
||||
import androidx.databinding.ObservableList
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.base.CommonAdapter
|
||||
import com.lukouguoji.module_base.bean.GjcBoxAddListBean
|
||||
import com.lukouguoji.module_base.bean.JianBean
|
||||
import com.lukouguoji.module_base.ktx.refresh
|
||||
import com.sixin.module_p.R
|
||||
import com.sixin.module_p.databinding.ItemPdaZuZhuangBinding
|
||||
|
||||
class PdaZuZhuangViewHolder(view: View) :
|
||||
BaseViewHolder<GjcBoxAddListBean, ItemPdaZuZhuangBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
val bean = getItemBean(item)!!
|
||||
binding.bean = bean.waybillBean
|
||||
|
||||
binding.rv.adapter = CommonAdapter(
|
||||
requireContext(),
|
||||
R.layout.item_pda_jian,
|
||||
PdaJianViewHolder::class.java
|
||||
)
|
||||
binding.rv.refresh(bean.jianList)
|
||||
|
||||
binding.ivDown.setOnClickListener {
|
||||
val visible = if (binding.rv.visibility == View.VISIBLE) View.GONE else View.VISIBLE
|
||||
binding.rv.visibility = visible
|
||||
binding.tvJ.visibility = visible
|
||||
}
|
||||
|
||||
bean.jianList.addOnListChangedCallback(object :
|
||||
ObservableList.OnListChangedCallback<ObservableArrayList<JianBean>>(){
|
||||
override fun onChanged(sender: ObservableArrayList<JianBean>?) {
|
||||
binding.rv.refresh(bean.jianList)
|
||||
}
|
||||
|
||||
override fun onItemRangeChanged(
|
||||
sender: ObservableArrayList<JianBean>?,
|
||||
positionStart: Int,
|
||||
itemCount: Int
|
||||
) {
|
||||
binding.rv.refresh(bean.jianList)
|
||||
}
|
||||
|
||||
override fun onItemRangeInserted(
|
||||
sender: ObservableArrayList<JianBean>?,
|
||||
positionStart: Int,
|
||||
itemCount: Int
|
||||
) {
|
||||
binding.rv.refresh(bean.jianList)
|
||||
}
|
||||
|
||||
override fun onItemRangeMoved(
|
||||
sender: ObservableArrayList<JianBean>?,
|
||||
fromPosition: Int,
|
||||
toPosition: Int,
|
||||
itemCount: Int
|
||||
) {
|
||||
binding.rv.refresh(bean.jianList)
|
||||
}
|
||||
|
||||
override fun onItemRangeRemoved(
|
||||
sender: ObservableArrayList<JianBean>?,
|
||||
positionStart: Int,
|
||||
itemCount: Int
|
||||
) {
|
||||
binding.rv.refresh(bean.jianList)
|
||||
}
|
||||
})
|
||||
|
||||
notifyItemClick(position,binding.tvDeleteOrder)
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user