init: init proj
This commit is contained in:
@@ -0,0 +1,529 @@
|
||||
package com.lukouguoji.gjj.activity
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.EditText
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.alibaba.android.arouter.facade.annotation.Autowired
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.alibaba.fastjson.JSONObject
|
||||
import com.lukouguoji.gjj.R
|
||||
import com.lukouguoji.gjj.adapt.GjjCangDanInfoAdapter
|
||||
import com.lukouguoji.gjj.common.GjjCommon
|
||||
import com.lukouguoji.gjj.model.GjjCangDanInfoItemModel
|
||||
import com.lukouguoji.gjj.viewModel.GjjCangDanInfoViewModel
|
||||
import com.lukouguoji.module_base.BaseActivity
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.common.String.isValidInt
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_GJJ_CANG_DAN_INFO)
|
||||
class GjjCangDanInfoActivity : BaseActivity(), View.OnClickListener {
|
||||
private lateinit var viewModel: GjjCangDanInfoViewModel
|
||||
private lateinit var adapter: GjjCangDanInfoAdapter
|
||||
private val collectList = ArrayList<GjjCangDanInfoItemModel>()
|
||||
|
||||
private lateinit var receive: EditText
|
||||
private lateinit var cardNo: EditText
|
||||
private lateinit var telPhone: EditText
|
||||
|
||||
private lateinit var cancel: TextView
|
||||
private lateinit var submit: TextView
|
||||
|
||||
|
||||
@JvmField
|
||||
@Autowired
|
||||
var id: String? = null
|
||||
|
||||
@JvmField
|
||||
@Autowired
|
||||
var ref: String? = null
|
||||
|
||||
@JvmField
|
||||
@Autowired
|
||||
var fid: Int = -9999
|
||||
|
||||
@JvmField
|
||||
@Autowired
|
||||
var prefix: String? = null
|
||||
|
||||
private fun initView() {
|
||||
viewModel = ViewModelProvider(this).get(GjjCangDanInfoViewModel::class.java)
|
||||
viewModel.waybillFormNetWork["prefix"] = prefix
|
||||
|
||||
val layoutManager = GridLayoutManager(this, 2)
|
||||
adapter = GjjCangDanInfoAdapter(this, collectList)
|
||||
var recyclerView: RecyclerView = findViewById(R.id.collectList)
|
||||
recyclerView.layoutManager = layoutManager
|
||||
recyclerView.adapter = adapter
|
||||
|
||||
receive = findViewById(R.id.receive)
|
||||
cardNo = findViewById(R.id.cardNo)
|
||||
telPhone = findViewById(R.id.telPhone)
|
||||
cancel = findViewById(R.id.cancel)
|
||||
submit = findViewById(R.id.submit)
|
||||
|
||||
cancel.setOnClickListener(this)
|
||||
submit.setOnClickListener(this)
|
||||
|
||||
cardNo.onFocusChangeListener = View.OnFocusChangeListener { v, hasFocus ->
|
||||
if (!hasFocus) {
|
||||
//失去焦点
|
||||
var cardNoStr = cardNo.text.toString()
|
||||
if (cardNoStr != "" && !Common.isIDNumber(cardNoStr)) {
|
||||
Common.showToast(this, "请输入正确的身份证号!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
telPhone.onFocusChangeListener = View.OnFocusChangeListener { v, hasFocus ->
|
||||
if (!hasFocus) {
|
||||
//失去焦点
|
||||
var telPhoneStr = telPhone.text.toString()
|
||||
if (telPhoneStr != "" && !Common.isPhoneNum(telPhoneStr)) {
|
||||
Common.showToast(this, "请输入正确的电话号码!")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_gjj_cang_dan_info)
|
||||
initView()
|
||||
|
||||
|
||||
//1.新增
|
||||
if (id == null) {
|
||||
// if (true) {
|
||||
setBackArrow("新增国际进港舱单")
|
||||
|
||||
selObserve()
|
||||
initData(GjjCommon.CangDan.Info.add)
|
||||
|
||||
viewModel.saveFestGjjCangDanObserver.observe(this) {
|
||||
loadingCancel()
|
||||
val status = it.getString("status")
|
||||
val msg = it.getString("msg")
|
||||
if (Constant.Result.succ == status) {
|
||||
val dataStatus = it.getString("data")
|
||||
if (Constant.Result.succ == dataStatus) {
|
||||
Common.showToast(this, "新增成功!")
|
||||
reset()
|
||||
} else if (Constant.Result.code2 == dataStatus) {
|
||||
Common.showToast(this, "没有选择航班,请选择航班!")
|
||||
} else {
|
||||
Common.showToast(this, "新增失败!")
|
||||
}
|
||||
} else {
|
||||
Common.showToast(this, "新增失败!")
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
//2.查看
|
||||
if (id != null && id != "" && ref != null && ref == GjjCommon.CangDan.Ref.read) {
|
||||
// if (true) {
|
||||
setBackArrow("国际进港舱单详情")
|
||||
|
||||
initNetWork(id, null, GjjCommon.CangDan.Info.read)
|
||||
receive.isEnabled = false
|
||||
receive.setBackgroundResource(R.drawable.gjj_cang_dan_info_edit_disable_shape)
|
||||
cardNo.isEnabled = false
|
||||
cardNo.setBackgroundResource(R.drawable.gjj_cang_dan_info_edit_disable_shape)
|
||||
telPhone.isEnabled = false
|
||||
telPhone.setBackgroundResource(R.drawable.gjj_cang_dan_info_edit_disable_shape)
|
||||
|
||||
cancel.visibility = View.GONE
|
||||
submit.visibility = View.GONE
|
||||
return
|
||||
}
|
||||
//3.编辑
|
||||
if (id != null && id != "" && ref != null && ref != GjjCommon.CangDan.Ref.read) {
|
||||
setBackArrow("国际进港舱单详情")
|
||||
|
||||
initNetWork(id, null, GjjCommon.CangDan.Info.update)
|
||||
|
||||
viewModel.updateFestGjjCangDanObserver.observe(this) {
|
||||
loadingCancel()
|
||||
val status = it.getString("status")
|
||||
val msg = it.getString("msg")
|
||||
if (Constant.Result.succ == status) {
|
||||
var dataStatus = it.getString("data")
|
||||
if (Constant.Result.succ == dataStatus) {
|
||||
Common.showToast(this, "修改成功!")
|
||||
} else if (Constant.Result.code2 == dataStatus) {
|
||||
Common.showToast(this, "没有选择航班,请选择航班!")
|
||||
} else {
|
||||
Common.showToast(this, "修改失败!")
|
||||
}
|
||||
} else {
|
||||
Common.showToast(this, "修改失败!")
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
v?.let {
|
||||
when (it.id) {
|
||||
R.id.cancel -> {
|
||||
finish()
|
||||
}
|
||||
R.id.submit -> {
|
||||
submit()
|
||||
}
|
||||
else -> {
|
||||
Toast.makeText(this, "未找到对应操作", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 监听运单详情返回数据
|
||||
*
|
||||
* write = false 只读 true 可写
|
||||
*/
|
||||
private fun waybillObserve(status: String) {
|
||||
viewModel.waybillLiveData.observe(this) {
|
||||
val resStatus = it.getString("status")
|
||||
if (Constant.Result.succ == resStatus) {
|
||||
viewModel.waybillFormNetWork = it.getJSONObject("data")
|
||||
|
||||
val consignee = viewModel.waybillFormNetWork.getString("consignee") ?: ""//收货人
|
||||
val cneeId = viewModel.waybillFormNetWork.getString("cneeId") ?: ""//收货人身份证号
|
||||
val cneeTel = viewModel.waybillFormNetWork.getString("cneeTel") ?: ""//收货人电话
|
||||
|
||||
initData(status)
|
||||
|
||||
////收获 信息
|
||||
receive.setText(consignee)
|
||||
cardNo.setText(cneeId)
|
||||
telPhone.setText(cneeTel)
|
||||
|
||||
} else {
|
||||
//无数据
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下拉框赋值
|
||||
*/
|
||||
private fun selObserve() {
|
||||
/////////////// 下拉框 start
|
||||
viewModel.agentCode(System.currentTimeMillis().toString())
|
||||
viewModel.agentCodeObserver.observe(this) { vd ->
|
||||
val noneObj = JSONObject()
|
||||
noneObj["name"] = "请选择代理人"
|
||||
noneObj["code"] = ""
|
||||
viewModel.agentCodeList.add(noneObj)
|
||||
viewModel.agentCodeList.addAll(vd.getJSONArray("data"))
|
||||
|
||||
totalRequestNotifyAdapter()
|
||||
}
|
||||
|
||||
viewModel.business(Constant.businessType.II)
|
||||
viewModel.businessObserver.observe(this) { vd ->
|
||||
val noneObj = JSONObject()
|
||||
noneObj["name"] = "请选择业务类型"
|
||||
noneObj["code"] = ""
|
||||
viewModel.businessList.add(noneObj)
|
||||
viewModel.businessList.addAll(vd.getJSONArray("data"))
|
||||
|
||||
totalRequestNotifyAdapter()
|
||||
}
|
||||
|
||||
viewModel.specialCode(System.currentTimeMillis().toString())
|
||||
viewModel.specialCodeObserver.observe(this) { vd ->
|
||||
val noneObj = JSONObject()
|
||||
noneObj["name"] = "请选择特码"
|
||||
noneObj["code"] = ""
|
||||
viewModel.specialCodeList.add(noneObj)
|
||||
viewModel.specialCodeList.addAll(vd.getJSONArray("data"))
|
||||
|
||||
totalRequestNotifyAdapter()
|
||||
}
|
||||
|
||||
val noneObj = JSONObject()
|
||||
noneObj["name"] = "请选择运单类型"
|
||||
noneObj["code"] = ""
|
||||
val noneObj2 = JSONObject()
|
||||
noneObj2["name"] = "国际进港(国内中转)"
|
||||
noneObj2["code"] = "CIII1"
|
||||
val noneObj3 = JSONObject()
|
||||
noneObj3["name"] = "国际进港(国际直航)"
|
||||
noneObj3["code"] = "IIII1"
|
||||
val noneObj4 = JSONObject()
|
||||
noneObj4["name"] = "国际进港(直航中转)"
|
||||
noneObj4["code"] = "IIIO1"
|
||||
viewModel.awbList.add(noneObj)
|
||||
viewModel.awbList.add(noneObj2)
|
||||
viewModel.awbList.add(noneObj3)
|
||||
viewModel.awbList.add(noneObj4)
|
||||
/* viewModel.awb(System.currentTimeMillis().toString())
|
||||
viewModel.awbObserver.observe(this) { vd ->
|
||||
val noneObj = JSONObject()
|
||||
noneObj["name"] = "请选择运单类型"
|
||||
noneObj["code"] = ""
|
||||
viewModel.awbList.add(noneObj)
|
||||
viewModel.awbList.addAll(vd.getJSONArray("data"))
|
||||
|
||||
totalRequestNotifyAdapter()
|
||||
}*/
|
||||
/////////////// 下拉框 end
|
||||
}
|
||||
|
||||
/**
|
||||
* 所有请求结束,更细adpter 只适用于刚开始加载
|
||||
*/
|
||||
private fun totalRequestNotifyAdapter() {
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化网络请求
|
||||
*/
|
||||
private fun initNetWork(id: String?, wbNo: String?, status: String) {
|
||||
selObserve()
|
||||
viewModel.queryWaybillById(id!!.toInt(), wbNo)
|
||||
waybillObserve(status)
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交
|
||||
*/
|
||||
private fun submit() {
|
||||
for ((index, c) in collectList.withIndex()) {
|
||||
val titleName = c.titleName//标题
|
||||
val inputContent = c.inputContent//输入内容
|
||||
val selContentCode = c.selContentCode//选择内容
|
||||
val must = c.isMust//是否必填
|
||||
val sel = c.isSel//是否下拉框
|
||||
val titleCodePre = c.titleCodePre//前缀
|
||||
val inputContentPre = c.inputContentPre//前缀
|
||||
//下拉框
|
||||
if (sel) {
|
||||
if (must && selContentCode == "") {
|
||||
Common.showToast(this, "请选择$titleName")
|
||||
return
|
||||
}
|
||||
viewModel.waybillFormNetWork[c.titleCode] = selContentCode
|
||||
}
|
||||
//输入框
|
||||
else {
|
||||
if (must && inputContent == "") {
|
||||
Common.showToast(this, "请输入$titleName")
|
||||
return
|
||||
}
|
||||
viewModel.waybillFormNetWork[c.titleCode] = inputContent
|
||||
//前缀不为空时,赋值
|
||||
if (titleCodePre != null && titleCodePre != "" && inputContentPre != null && inputContentPre != "") {
|
||||
viewModel.waybillFormNetWork[titleCodePre] = inputContentPre
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//1.新增
|
||||
if (id == null) {
|
||||
//身份证、电话号码校验
|
||||
val cardNoStr = cardNo.text.toString()
|
||||
val telPhoneStr = telPhone.text.toString()
|
||||
if (cardNoStr != "" && !Common.isIDNumber(cardNoStr)) {
|
||||
Common.showToast(this, "请输入正确的身份证号!")
|
||||
return
|
||||
}
|
||||
if (telPhoneStr != "" && !Common.isPhoneNum(telPhoneStr)) {
|
||||
Common.showToast(this, "请输入正确的电话号码!")
|
||||
return
|
||||
}
|
||||
//输入运单号,需要校验规则,判断前7位除以7得到的余数是否等于第8位,是即符合规则,否则提示
|
||||
val prefixStr = viewModel.waybillFormNetWork.getString("prefix")
|
||||
if (prefixStr.length != 3 || !prefixStr.isValidInt()) {
|
||||
Common.showToast(this, "请输入正确的运单号前缀格式!")
|
||||
return
|
||||
}
|
||||
val checkWaybill = viewModel.waybillFormNetWork.getString("no")
|
||||
if (checkWaybill.length != 8 || !checkWaybill.isValidInt()) {
|
||||
Common.showToast(this, "请输入正确的运单号格式!")
|
||||
return
|
||||
}
|
||||
var subSequence = checkWaybill.subSequence(0, 7).toString().toInt()
|
||||
var subSequence2 = checkWaybill[7].toString().toInt()
|
||||
if (subSequence % 7 != subSequence2) {
|
||||
Common.showToast(this, "请输入正确的运单号格式!")
|
||||
return
|
||||
}
|
||||
|
||||
loading()
|
||||
viewModel.saveFestGjjCangDan(
|
||||
fid, viewModel.waybillFormNetWork.getString("prefix"), viewModel.waybillFormNetWork.getString("no"),
|
||||
viewModel.waybillFormNetWork.getString("agentCode"), viewModel.waybillFormNetWork.getString("spCode"),
|
||||
viewModel.waybillFormNetWork.getString("location"), viewModel.waybillFormNetWork.getIntValue("totalPc"),
|
||||
viewModel.waybillFormNetWork.getIntValue("pc"), viewModel.waybillFormNetWork.getDoubleValue("weight"),
|
||||
viewModel.waybillFormNetWork.getString("goods"), viewModel.waybillFormNetWork.getString("origin"),
|
||||
viewModel.waybillFormNetWork.getString("dest"), viewModel.waybillFormNetWork.getString("businessType"),
|
||||
viewModel.waybillFormNetWork.getString("remark"), viewModel.waybillFormNetWork.getString("awbType"),
|
||||
viewModel.waybillFormNetWork.getDoubleValue("cashWeight"), receive.text.toString(), cardNoStr, telPhoneStr
|
||||
)
|
||||
return
|
||||
}
|
||||
//2.查看
|
||||
if (id != null && id != "" && ref != null && ref == GjjCommon.CangDan.Ref.read) {
|
||||
finish()
|
||||
return
|
||||
}
|
||||
//3.编辑
|
||||
if (id != null && id != "" && ref != null && ref != GjjCommon.CangDan.Ref.read) {
|
||||
|
||||
//身份证、电话号码校验
|
||||
val cardNoStr = cardNo.text.toString()
|
||||
val telPhoneStr = telPhone.text.toString()
|
||||
if (cardNoStr != "" && !Common.isIDNumber(cardNoStr)) {
|
||||
Common.showToast(this, "请输入正确的身份证号!")
|
||||
return
|
||||
}
|
||||
if (telPhoneStr != "" && !Common.isPhoneNum(telPhoneStr)) {
|
||||
Common.showToast(this, "请输入正确的电话号码!")
|
||||
return
|
||||
}
|
||||
loading()
|
||||
viewModel.updateFestGjjCangDan(
|
||||
id!!.toInt(),
|
||||
fid, viewModel.waybillFormNetWork.getString("prefix"), viewModel.waybillFormNetWork.getString("no"),
|
||||
viewModel.waybillFormNetWork.getString("agentCode"), viewModel.waybillFormNetWork.getString("spCode"),
|
||||
viewModel.waybillFormNetWork.getString("location"), viewModel.waybillFormNetWork.getIntValue("totalPc"),
|
||||
viewModel.waybillFormNetWork.getIntValue("pc"), viewModel.waybillFormNetWork.getDoubleValue("weight"),
|
||||
viewModel.waybillFormNetWork.getString("goods"), viewModel.waybillFormNetWork.getString("origin"),
|
||||
viewModel.waybillFormNetWork.getString("dest"), viewModel.waybillFormNetWork.getString("businessType"),
|
||||
viewModel.waybillFormNetWork.getString("remark"), viewModel.waybillFormNetWork.getString("awbType"),
|
||||
viewModel.waybillFormNetWork.getDoubleValue("cashWeight"), receive.text.toString(), cardNoStr, telPhoneStr
|
||||
)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化列表数据
|
||||
*/
|
||||
private fun initData(status: String) {
|
||||
var write = false
|
||||
var waybillOperator = false
|
||||
when (status) {
|
||||
GjjCommon.CangDan.Info.read -> {
|
||||
write = false
|
||||
waybillOperator = false
|
||||
}
|
||||
GjjCommon.CangDan.Info.add -> {
|
||||
write = true
|
||||
waybillOperator = true
|
||||
}
|
||||
GjjCommon.CangDan.Info.update -> {
|
||||
write = true
|
||||
waybillOperator = false
|
||||
}
|
||||
}
|
||||
|
||||
collectList.clear()
|
||||
collectList.add(
|
||||
GjjCangDanInfoItemModel(
|
||||
true, waybillOperator, "运单号", "no", viewModel.waybillFormNetWork.getString("no") ?: "",
|
||||
"prefix", viewModel.waybillFormNetWork.getString("prefix") ?: ""
|
||||
)
|
||||
)
|
||||
collectList.add(
|
||||
GjjCangDanInfoItemModel(
|
||||
true,
|
||||
write,
|
||||
"代理",
|
||||
"agentCode",
|
||||
viewModel.agentCodeList,
|
||||
viewModel.waybillFormNetWork.getString("agentCode") ?: "", viewModel.waybillFormNetWork.getString("agentName") ?: ""
|
||||
)
|
||||
)
|
||||
collectList.add(
|
||||
GjjCangDanInfoItemModel(
|
||||
true,
|
||||
write,
|
||||
"业务类型",
|
||||
"businessType",
|
||||
viewModel.businessList,
|
||||
viewModel.waybillFormNetWork.getString("businessType") ?: "", ""
|
||||
)
|
||||
)
|
||||
collectList.add(
|
||||
GjjCangDanInfoItemModel(
|
||||
true,
|
||||
write,
|
||||
"总件数",
|
||||
"totalPc",
|
||||
viewModel.waybillFormNetWork.getString("totalPc") ?: ""
|
||||
)
|
||||
)
|
||||
collectList.add(GjjCangDanInfoItemModel(true, write, "实到件数", "pc", viewModel.waybillFormNetWork.getString("pc") ?: ""))
|
||||
collectList.add(
|
||||
GjjCangDanInfoItemModel(
|
||||
true,
|
||||
write,
|
||||
"实到重量",
|
||||
"weight",
|
||||
viewModel.waybillFormNetWork.getString("weight") ?: ""
|
||||
)
|
||||
)
|
||||
collectList.add(GjjCangDanInfoItemModel(true, write, "品名", "goods", viewModel.waybillFormNetWork.getString("goods") ?: ""))
|
||||
collectList.add(
|
||||
GjjCangDanInfoItemModel(
|
||||
false,
|
||||
write,
|
||||
"计费重量",
|
||||
"cashWeight",
|
||||
viewModel.waybillFormNetWork.getString("cashWeight") ?: ""
|
||||
)
|
||||
)
|
||||
collectList.add(
|
||||
GjjCangDanInfoItemModel(
|
||||
false,
|
||||
write,
|
||||
"特码",
|
||||
"spCode",
|
||||
viewModel.specialCodeList,
|
||||
viewModel.waybillFormNetWork.getString("spCode") ?: "", ""
|
||||
)
|
||||
)
|
||||
collectList.add(GjjCangDanInfoItemModel(true, write, "始发港", "origin", viewModel.waybillFormNetWork.getString("origin") ?: ""))
|
||||
collectList.add(GjjCangDanInfoItemModel(true, write, "目的港", "dest", viewModel.waybillFormNetWork.getString("dest") ?: ""))
|
||||
collectList.add(
|
||||
GjjCangDanInfoItemModel(
|
||||
true,
|
||||
write,
|
||||
"运单类型",
|
||||
"awbType",
|
||||
viewModel.awbList,
|
||||
viewModel.waybillFormNetWork.getString("awbType") ?: "", ""
|
||||
)
|
||||
)
|
||||
collectList.add(GjjCangDanInfoItemModel(false, write, "库位", "location", viewModel.waybillFormNetWork.getString("location") ?: ""))
|
||||
collectList.add(GjjCangDanInfoItemModel(false, write, "备注", "remark", viewModel.waybillFormNetWork.getString("remark") ?: ""))
|
||||
|
||||
totalRequestNotifyAdapter()
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空数据
|
||||
*/
|
||||
private fun reset() {
|
||||
//1.清空数据
|
||||
viewModel.waybillFormNetWork.clear()
|
||||
receive.setText("")
|
||||
cardNo.setText("")
|
||||
telPhone.setText("")
|
||||
initData(GjjCommon.CangDan.Info.add)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,477 @@
|
||||
package com.lukouguoji.gjj.activity
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.alibaba.fastjson.JSONArray
|
||||
import com.alibaba.fastjson.JSONObject
|
||||
import com.lukouguoji.gjj.R
|
||||
import com.lukouguoji.gjj.adapt.GjjCangDanListAdapter
|
||||
import com.lukouguoji.gjj.model.GjjCangDanListModel
|
||||
import com.lukouguoji.gjj.viewModel.GjjCangDanListViewModel
|
||||
import com.lukouguoji.module_base.ActivityCollector
|
||||
import com.lukouguoji.module_base.BaseActivity
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.lukouguoji.module_base.util.SwipeDeleteRecyclerView
|
||||
import com.scwang.smart.refresh.footer.ClassicsFooter
|
||||
import com.scwang.smart.refresh.header.ClassicsHeader
|
||||
import com.scwang.smart.refresh.layout.api.RefreshLayout
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_GJJ_CANG_DAN_LIST)
|
||||
class GjjCangDanListActivity : BaseActivity(), View.OnClickListener {
|
||||
private lateinit var viewModel: GjjCangDanListViewModel
|
||||
private lateinit var adapter: GjjCangDanListAdapter
|
||||
private val collectList = ArrayList<GjjCangDanListModel>()
|
||||
private lateinit var refreshLayout: RefreshLayout
|
||||
private var currentPage = 1
|
||||
private var pageSize = 10
|
||||
private var totalPage = 0
|
||||
private var totalCount = 0 //总条数
|
||||
private val calendar = Calendar.getInstance()
|
||||
private val ymdSdf = SimpleDateFormat("yyyy-MM-dd")//年月日
|
||||
private val ymdHmsSdf = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")//年月日 时分秒
|
||||
|
||||
|
||||
//搜索
|
||||
private lateinit var fdate: TextView
|
||||
private lateinit var startDateIcon: ImageView
|
||||
private lateinit var fno: EditText
|
||||
private lateinit var fdep: EditText
|
||||
private lateinit var dest: EditText
|
||||
private lateinit var endDate: TextView
|
||||
private lateinit var searchLayout: LinearLayout
|
||||
private lateinit var addIcon: ImageView
|
||||
private lateinit var checkIcon: ImageView
|
||||
private lateinit var quickSearch: EditText
|
||||
private var isAllCheck = false
|
||||
|
||||
//列表
|
||||
private lateinit var listLayout: LinearLayout
|
||||
private lateinit var totalLayout: LinearLayout
|
||||
|
||||
//底部
|
||||
private lateinit var totalPc: TextView
|
||||
private lateinit var selPc: TextView
|
||||
private lateinit var send: TextView
|
||||
|
||||
private fun initView() {
|
||||
viewModel = ViewModelProvider(this).get(GjjCangDanListViewModel::class.java)
|
||||
val layoutManager = LinearLayoutManager(this)
|
||||
adapter = GjjCangDanListAdapter(this, viewModel, collectList)
|
||||
var recyclerView: SwipeDeleteRecyclerView = findViewById(R.id.collectList)
|
||||
recyclerView.layoutManager = layoutManager
|
||||
recyclerView.adapter = adapter
|
||||
refreshLayout = findViewById(R.id.refreshLayout)
|
||||
|
||||
fdate = findViewById(R.id.fdate)
|
||||
startDateIcon = findViewById(R.id.startDateIcon)
|
||||
fno = findViewById(R.id.fno)
|
||||
fdep = findViewById(R.id.fdep)
|
||||
dest = findViewById(R.id.dest)
|
||||
endDate = findViewById(R.id.endDate)
|
||||
searchLayout = findViewById(R.id.searchLayout)
|
||||
addIcon = findViewById(R.id.addIcon)
|
||||
checkIcon = findViewById(R.id.checkIcon)
|
||||
quickSearch = findViewById(R.id.quickSearch)
|
||||
//列表
|
||||
listLayout = findViewById(R.id.listLayout)
|
||||
totalLayout = findViewById(R.id.totalLayout)
|
||||
//底部
|
||||
totalPc = findViewById(R.id.totalPc)
|
||||
selPc = findViewById(R.id.selPc)
|
||||
send = findViewById(R.id.send)
|
||||
|
||||
fdate.setOnClickListener(this)
|
||||
startDateIcon.setOnClickListener(this)
|
||||
endDate.setOnClickListener(this)
|
||||
searchLayout.setOnClickListener(this)
|
||||
addIcon.setOnClickListener(this)
|
||||
checkIcon.setOnClickListener(this)
|
||||
send.setOnClickListener(this)
|
||||
|
||||
quickSearch.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
if (s != null && s.toString() != "") {
|
||||
val filterCollectionList = collectList.filter { c -> c.wbNo.contains(s.toString()) }
|
||||
recyclerView.adapter = GjjCangDanListAdapter(
|
||||
ActivityCollector.getLastActivity()!!,
|
||||
viewModel,
|
||||
filterCollectionList as MutableList<GjjCangDanListModel>
|
||||
)
|
||||
} else {
|
||||
recyclerView.adapter = GjjCangDanListAdapter(
|
||||
ActivityCollector.getLastActivity()!!,
|
||||
viewModel,
|
||||
collectList
|
||||
)
|
||||
}
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
fno.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun afterTextChanged(editable: Editable?) {
|
||||
val originText = editable.toString()
|
||||
if (originText != null && originText != "") {
|
||||
val regularExpression = "(^([A-Z0-9]+)$)"
|
||||
val matches = originText.matches(regularExpression.toRegex())
|
||||
if(!matches){
|
||||
val regularExpression2 = "([^A-Za-z0-9]+)"
|
||||
val replaceStr = originText.replace(regularExpression2.toRegex(),"")
|
||||
val replaceStrToUpper = replaceStr.uppercase(Locale.ROOT)//小写转大写
|
||||
fno.setText(replaceStrToUpper)
|
||||
fno.setSelection(replaceStrToUpper.length)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
fdate.text = ymdSdf.format(Date())//tw2022年6月13日15:57:10 要求航班日期默认当天
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_gjj_cang_dan_list)
|
||||
setBackArrow("国际进港舱单")
|
||||
initView()
|
||||
|
||||
//查询返回结果
|
||||
viewModel.searchParamLive.observe(this) {
|
||||
loadingCancel()
|
||||
//1.获取数据
|
||||
var listArr: JSONArray = it["list"] as JSONArray
|
||||
totalCount = it.getIntValue("total")
|
||||
totalPage = it["pages"] as Int
|
||||
// var listArr :JSONArray =it["list"] as JSONArray
|
||||
if (listArr.size > 0) {
|
||||
listLayout.visibility = View.VISIBLE
|
||||
totalLayout.visibility = View.VISIBLE
|
||||
|
||||
//2.循环遍历塞入collectList
|
||||
listArr.forEach {
|
||||
val itemObj = it as JSONObject
|
||||
|
||||
val mfId = itemObj.getIntValue("mfId")
|
||||
val no = itemObj.getString("wbNo") ?: ""
|
||||
val goods = itemObj.getString("goods") ?: ""
|
||||
val awbType = itemObj.getString("awbType") ?: ""
|
||||
val startPort = itemObj.getString("origin") ?: ""
|
||||
val destPort = itemObj.getString("dest") ?: ""
|
||||
val agentCode = itemObj.getString("agentCode") ?: ""
|
||||
val spCode = itemObj.getString("spCode") ?: ""
|
||||
val totalPc = itemObj.getIntValue("totalPc")
|
||||
val pc = itemObj.getIntValue("pc")
|
||||
val acWeight = itemObj.getDoubleValue("weight")//实到重量
|
||||
val chWight = itemObj.getDoubleValue("cashWeight")//计费重量
|
||||
|
||||
val ref = itemObj.getString("ref") ?: ""// 1查看
|
||||
|
||||
//列表赋值
|
||||
collectList.add(
|
||||
GjjCangDanListModel(
|
||||
mfId.toString(),
|
||||
no,
|
||||
goods,
|
||||
awbType,
|
||||
startPort,
|
||||
destPort,
|
||||
agentCode,
|
||||
spCode,
|
||||
totalPc,
|
||||
pc,
|
||||
acWeight,
|
||||
chWight,
|
||||
false,
|
||||
ref
|
||||
)
|
||||
)
|
||||
}
|
||||
//3.调adpter展示
|
||||
if (currentPage == 1) {
|
||||
val layoutManager = LinearLayoutManager(this)
|
||||
adapter = GjjCangDanListAdapter(this, viewModel, collectList)
|
||||
var recyclerView: SwipeDeleteRecyclerView = findViewById(R.id.collectList)
|
||||
recyclerView.layoutManager = layoutManager
|
||||
recyclerView.adapter = adapter
|
||||
} else {
|
||||
adapter.notifyItemRangeInserted((currentPage - 1) * 10, collectList.size)
|
||||
}
|
||||
refreshLayout.finishRefresh()
|
||||
refreshLayout.finishLoadMore()
|
||||
|
||||
}
|
||||
|
||||
totalPc.text = totalCount.toString()
|
||||
resetSelCount(false)
|
||||
}
|
||||
|
||||
//航班返回结果
|
||||
viewModel.intFlightGjjCangDanObserver.observe(this) {
|
||||
loadingCancel()
|
||||
val status = it.getString("status")
|
||||
if (Constant.Result.succ == status) {
|
||||
var jsonObject = it.getJSONObject("data")
|
||||
viewModel.fid = jsonObject.getInteger("fid")
|
||||
viewModel.prefix = jsonObject.getString("prefix")
|
||||
val actualArrival = jsonObject.getString("actualArrival")
|
||||
val fdepParam = jsonObject.getString("fdep")//始发港
|
||||
val fdest = jsonObject.getString("fdest")//目的港
|
||||
|
||||
fdep.setText(fdepParam)
|
||||
dest.setText(fdest)
|
||||
endDate.text = actualArrival
|
||||
|
||||
if (viewModel.fid != null) {
|
||||
listLayout.visibility = View.VISIBLE
|
||||
totalLayout.visibility = View.VISIBLE
|
||||
resetSearch()
|
||||
}
|
||||
|
||||
} else {
|
||||
//无数据
|
||||
}
|
||||
}
|
||||
|
||||
//删除行 返回结果
|
||||
viewModel.deleteFestGjjCangDanObserver.observe(this) {
|
||||
loadingCancel()
|
||||
val positionDel = it.getInteger("positionDel")
|
||||
val status = it.getString("status")
|
||||
val msg = it.getString("msg")
|
||||
if (Constant.Result.succ == status) {
|
||||
collectList.removeAt(positionDel)
|
||||
adapter.notifyItemRemoved(positionDel)
|
||||
resetSelCount(false)
|
||||
val dataStatus = it.getString("data")
|
||||
if (Constant.Result.succ == dataStatus) {
|
||||
Common.showToast(this, "删除成功!")
|
||||
|
||||
} else if (Constant.Result.code2 == dataStatus) {
|
||||
Common.showToast(this, "货物已发放,不允许删除!")
|
||||
} else {
|
||||
Common.showToast(this, "删除失败!")
|
||||
}
|
||||
} else {
|
||||
Common.showToast(this, "删除失败!")
|
||||
}
|
||||
}
|
||||
|
||||
//货物发放 返回结果
|
||||
viewModel.provideGjjCangDanObserver.observe(this) {
|
||||
loadingCancel()
|
||||
val status = it.getString("status")
|
||||
val msg = it.getString("msg")
|
||||
if (Constant.Result.succ == status) {
|
||||
val data = it.getString("data")
|
||||
if (Constant.Result.succ == data) {
|
||||
if (msg != null && msg != "") {
|
||||
Common.showToast(this, msg)
|
||||
} else {
|
||||
Common.showToast(this, "货物发放成功!")
|
||||
}
|
||||
resetSearch()
|
||||
} else {
|
||||
if (msg != null && msg != "") {
|
||||
Common.showToast(this, msg)
|
||||
} else {
|
||||
Common.showToast(this, "货物发放失败!")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (msg != null && msg != "") {
|
||||
Common.showToast(this, msg)
|
||||
} else {
|
||||
Common.showToast(this, "货物发放失败!")
|
||||
}
|
||||
}
|
||||
//重新搜索
|
||||
resetSearch()
|
||||
}
|
||||
|
||||
//监听 复选框选中
|
||||
viewModel.checkCount.observe(this) {
|
||||
selPc.text = it.toString()
|
||||
}
|
||||
|
||||
/////////////////////////////// 加载刷新的布局
|
||||
refreshLayout.setRefreshHeader(ClassicsHeader(this))
|
||||
refreshLayout.setRefreshFooter(ClassicsFooter(this))
|
||||
/////////////////////////////// 下拉刷新
|
||||
refreshLayout.setOnRefreshListener {
|
||||
resetSearch()
|
||||
}
|
||||
/////////////////////////////// 上拉加载
|
||||
refreshLayout.setOnLoadMoreListener {
|
||||
if (currentPage < totalPage) {
|
||||
currentPage++
|
||||
//初始化查询
|
||||
searchFun()
|
||||
} else {
|
||||
refreshLayout.finishLoadMoreWithNoMoreData()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
v?.let {
|
||||
when (it.id) {
|
||||
R.id.fdate -> {
|
||||
Common.onYearMonthDay(this, fdate.text.toString()) { year, month, day ->
|
||||
calendar.set(year, month - 1, day)
|
||||
fdate.text = ymdSdf.format(calendar.time)
|
||||
}
|
||||
}
|
||||
R.id.startDateIcon -> {
|
||||
fdate.text = ""
|
||||
}
|
||||
R.id.endDate -> {
|
||||
Common.onYearMonthDay(this, endDate.text.toString()) { year, month, day ->
|
||||
calendar.set(year, month - 1, day)
|
||||
endDate.text = ymdSdf.format(calendar.time)
|
||||
}
|
||||
}
|
||||
R.id.searchLayout -> {
|
||||
endDate.text = ""
|
||||
dest.setText("")
|
||||
doFlight()
|
||||
}
|
||||
R.id.addIcon -> {
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GJJ_CANG_DAN_INFO).withString("id", null).withString("ref", null)
|
||||
.withInt("fid", viewModel.fid ?: -9999).withString("prefix", viewModel.prefix)
|
||||
.navigation(this, Constant.RequestCode.gjj_cang_dan_list)
|
||||
}
|
||||
R.id.checkIcon -> {
|
||||
//重置 isAllCheck
|
||||
isAllCheck = !isAllCheck
|
||||
resetSelCount(isAllCheck)
|
||||
}
|
||||
R.id.send -> {
|
||||
val ids = collectList.filter { c -> c.isCheck }.map { c -> c.id.toInt() }
|
||||
viewModel.provideGjjCangDan(viewModel.fid!!, ids)
|
||||
}
|
||||
else -> {
|
||||
Toast.makeText(this, "未找到对应操作", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* onActivityResult 回调
|
||||
*/
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (requestCode == Constant.RequestCode.gjj_cang_dan_list && resultCode == RESULT_OK) {
|
||||
resetSearch()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 搜索
|
||||
*/
|
||||
private fun searchFun() {
|
||||
/*if (fdate.text.toString() == "" || fno.text.toString() == "") {
|
||||
Common.showToast(this, "航班日期和航班号不可为空!")
|
||||
return
|
||||
}*/
|
||||
loading()
|
||||
viewModel.search(
|
||||
pageSize,
|
||||
currentPage,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
fdate.text.toString(),
|
||||
fno.text.toString(),
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置数据,搜索
|
||||
*/
|
||||
private fun resetSearch() {
|
||||
//recyclerView 清除所有数据数据
|
||||
viewModel.setCheckCount(0)
|
||||
refreshLayout.setNoMoreData(false)
|
||||
adapter.notifyItemRangeRemoved(0, collectList.size)
|
||||
collectList.clear()
|
||||
currentPage = 1
|
||||
searchFun()
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询航班是否存在
|
||||
*/
|
||||
private fun doFlight() {
|
||||
if (fdate.text.toString() == "" || fno.text.toString() == "") {
|
||||
Common.showToast(this, "航班日期和航班号不可为空!")
|
||||
return
|
||||
}
|
||||
loading()
|
||||
listLayout.visibility = View.GONE
|
||||
totalLayout.visibility = View.GONE
|
||||
viewModel.intFlightGjjCangDan(fdate.text.toString(), fno.text.toString())
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新计算选中数量
|
||||
* isAllCheckParam true:全选 false:全部全效选择
|
||||
*/
|
||||
private fun resetSelCount(isAllCheckParam: Boolean) {
|
||||
var selCount = 0
|
||||
collectList.forEach { c ->
|
||||
//不是出库 并且 选中,可以选
|
||||
if (c.ref != "1" && isAllCheckParam) {
|
||||
c.isCheck = isAllCheckParam
|
||||
++selCount
|
||||
} else {
|
||||
c.isCheck = false
|
||||
}
|
||||
}
|
||||
if (isAllCheckParam) {
|
||||
viewModel.setCheckCount(selCount)
|
||||
} else {
|
||||
viewModel.setCheckCount(0)
|
||||
}
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,544 @@
|
||||
package com.lukouguoji.gjj.activity
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.alibaba.fastjson.JSONArray
|
||||
import com.alibaba.fastjson.JSONObject
|
||||
import com.lukouguoji.gjj.R
|
||||
import com.lukouguoji.gjj.adapt.GjjChuKuListAdapter
|
||||
import com.lukouguoji.gjj.model.GjjChuKuListModel
|
||||
import com.lukouguoji.gjj.viewModel.GjjChuKuListViewModel
|
||||
import com.lukouguoji.module_base.ActivityCollector
|
||||
import com.lukouguoji.module_base.BaseActivity
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.scwang.smart.refresh.footer.ClassicsFooter
|
||||
import com.scwang.smart.refresh.header.ClassicsHeader
|
||||
import com.scwang.smart.refresh.layout.api.RefreshLayout
|
||||
import kotlinx.coroutines.launch
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_GJJ_CHU_KU_LIST)
|
||||
class GjjChuKuListActivity : BaseActivity(), View.OnClickListener {
|
||||
private val currentTitleName = "国际进港出库"
|
||||
|
||||
private lateinit var viewModel: GjjChuKuListViewModel
|
||||
private lateinit var adapter: GjjChuKuListAdapter
|
||||
private val collectList = ArrayList<GjjChuKuListModel>()
|
||||
private lateinit var refreshLayout: RefreshLayout
|
||||
private var currentPage = 1
|
||||
private var pageSize = 10
|
||||
private var totalPage = 0
|
||||
private var totalCount = 0 //总条数
|
||||
private val calendar = Calendar.getInstance()
|
||||
private val ymdSdf = SimpleDateFormat("yyyy-MM-dd")//年月日
|
||||
private val ymdHmsSdf = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")//年月日 时分秒
|
||||
|
||||
//标题
|
||||
private lateinit var toolBack: LinearLayout
|
||||
private lateinit var titleName: TextView
|
||||
|
||||
|
||||
//搜索
|
||||
private lateinit var startDate: TextView
|
||||
private lateinit var endDate: TextView
|
||||
private lateinit var wbNo: EditText
|
||||
private lateinit var pickNo: EditText
|
||||
private lateinit var scanIcon: ImageView
|
||||
private lateinit var searchLayout: LinearLayout
|
||||
private lateinit var checkIcon: ImageView
|
||||
private lateinit var quickSearch: EditText
|
||||
private var isAllCheck = true
|
||||
|
||||
//筛选页
|
||||
private lateinit var searchListFragment: LinearLayout
|
||||
private lateinit var filtrateLayout: LinearLayout
|
||||
private lateinit var filtrateFragment: LinearLayout
|
||||
private lateinit var agentCode: TextView
|
||||
private var agentCodeValue = ""
|
||||
private lateinit var submit: TextView
|
||||
private lateinit var reset: TextView
|
||||
|
||||
//列表
|
||||
private lateinit var listLayout: LinearLayout
|
||||
private lateinit var totalLayout: LinearLayout
|
||||
|
||||
//底部
|
||||
private lateinit var totalPc: TextView
|
||||
private lateinit var selPc: TextView
|
||||
private lateinit var send: TextView
|
||||
|
||||
private fun initView() {
|
||||
viewModel = ViewModelProvider(this).get(GjjChuKuListViewModel::class.java)
|
||||
val layoutManager = LinearLayoutManager(this)
|
||||
adapter = GjjChuKuListAdapter(this, viewModel, collectList)
|
||||
var recyclerView: RecyclerView = findViewById(R.id.collectList)
|
||||
recyclerView.layoutManager = layoutManager
|
||||
recyclerView.adapter = adapter
|
||||
refreshLayout = findViewById(R.id.refreshLayout)
|
||||
|
||||
//标题
|
||||
toolBack = findViewById(R.id.tool_back)
|
||||
titleName = findViewById(R.id.title_name)
|
||||
|
||||
startDate = findViewById(R.id.startDate)
|
||||
endDate = findViewById(R.id.endDate)
|
||||
wbNo = findViewById(R.id.wbNo)
|
||||
pickNo = findViewById(R.id.pickNo)
|
||||
scanIcon = findViewById(R.id.scanIcon)
|
||||
|
||||
searchLayout = findViewById(R.id.searchLayout)
|
||||
filtrateLayout = findViewById(R.id.filtrateLayout)
|
||||
checkIcon = findViewById(R.id.checkIcon)
|
||||
quickSearch = findViewById(R.id.quickSearch)
|
||||
|
||||
//筛选页
|
||||
searchListFragment = findViewById(R.id.searchListFragment)
|
||||
filtrateFragment = findViewById(R.id.filtrateFragment)
|
||||
agentCode = findViewById(R.id.agentCode)
|
||||
submit = findViewById(R.id.submit)
|
||||
reset = findViewById(R.id.reset)
|
||||
|
||||
//列表
|
||||
listLayout = findViewById(R.id.listLayout)
|
||||
totalLayout = findViewById(R.id.totalLayout)
|
||||
//底部
|
||||
totalPc = findViewById(R.id.totalPc)
|
||||
selPc = findViewById(R.id.selPc)
|
||||
send = findViewById(R.id.send)
|
||||
|
||||
toolBack.setOnClickListener(this)
|
||||
|
||||
startDate.setOnClickListener(this)
|
||||
endDate.setOnClickListener(this)
|
||||
scanIcon.setOnClickListener(this)
|
||||
|
||||
searchLayout.setOnClickListener(this)
|
||||
checkIcon.setOnClickListener(this)
|
||||
send.setOnClickListener(this)
|
||||
|
||||
filtrateLayout.setOnClickListener(this)
|
||||
agentCode.setOnClickListener(this)
|
||||
submit.setOnClickListener(this)
|
||||
reset.setOnClickListener(this)
|
||||
|
||||
wbNo.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
if (s != null && s.toString() != "" && s.length == 4) {
|
||||
viewModel.queryWbNoGjjChuKu(s.toString())
|
||||
}
|
||||
}
|
||||
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
quickSearch.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
if (s != null && s.toString() != "") {
|
||||
val filterCollectionList = collectList.filter { c -> c.wbNo.contains(s.toString()) }
|
||||
recyclerView.adapter = GjjChuKuListAdapter(
|
||||
ActivityCollector.getLastActivity()!!,
|
||||
viewModel,
|
||||
filterCollectionList as MutableList<GjjChuKuListModel>
|
||||
)
|
||||
} else {
|
||||
recyclerView.adapter = GjjChuKuListAdapter(
|
||||
ActivityCollector.getLastActivity()!!,
|
||||
viewModel,
|
||||
collectList
|
||||
)
|
||||
}
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
startDate.text = "${ymdSdf.format(Date())} 00:00:00"
|
||||
endDate.text ="${ymdSdf.format(Date())} 23:59:59"
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_gjj_chu_ku_list)
|
||||
initView()
|
||||
//查询返回结果
|
||||
viewModel.searchParamLive.observe(this) {
|
||||
loadingCancel()
|
||||
//1.获取数据
|
||||
var listArr: JSONArray = it["list"] as JSONArray
|
||||
totalCount = it.getIntValue("total")
|
||||
totalPage = it["pages"] as Int
|
||||
// var listArr :JSONArray =it["list"] as JSONArray
|
||||
if (listArr.size > 0) {
|
||||
listLayout.visibility = View.VISIBLE
|
||||
totalLayout.visibility = View.VISIBLE
|
||||
//2.循环遍历塞入collectList
|
||||
listArr.forEach {
|
||||
val itemObj = it as JSONObject
|
||||
|
||||
val id = itemObj.getIntValue("id")
|
||||
val pkId = itemObj.getString("pkId") ?: ""
|
||||
val no = itemObj.getString("wbNo") ?: ""
|
||||
val fno = itemObj.getString("fno") ?: ""
|
||||
val pc = itemObj.getIntValue("pc")
|
||||
val weight = itemObj.getDoubleValue("weight")//实到重量
|
||||
|
||||
val goods = itemObj.getString("goods") ?: ""
|
||||
val agentCode = itemObj.getString("agentCode") ?: ""
|
||||
val spCode = itemObj.getString("spCode") ?: ""
|
||||
val pickDate = itemObj.getString("chargeTime") ?: ""
|
||||
|
||||
//列表赋值
|
||||
collectList.add(
|
||||
GjjChuKuListModel(
|
||||
id,
|
||||
no,
|
||||
pkId,
|
||||
fno,
|
||||
pc,
|
||||
weight,
|
||||
goods,
|
||||
agentCode,
|
||||
spCode,
|
||||
pickDate, false
|
||||
)
|
||||
)
|
||||
}
|
||||
//3.调adpter展示
|
||||
if (currentPage == 1) {
|
||||
adapter.notifyDataSetChanged()
|
||||
} else {
|
||||
adapter.notifyItemRangeInserted((currentPage - 1) * 10, collectList.size)
|
||||
}
|
||||
refreshLayout.finishRefresh()
|
||||
refreshLayout.finishLoadMore()
|
||||
|
||||
}
|
||||
|
||||
totalPc.text = totalCount.toString()
|
||||
selPc.text = viewModel.checkCount.value.toString()
|
||||
}
|
||||
|
||||
//查询运单号四位返回结果
|
||||
viewModel.viewModelScope.launch {
|
||||
viewModel.queryWbNoGjjChuKuParamLive.collect {
|
||||
//1.获取数据
|
||||
if (it["status"] == Constant.Result.succ && it.getJSONArray("data").size > 0) {
|
||||
val tempArr = JSONArray()
|
||||
it.getJSONArray("data").forEach { wayNo ->
|
||||
val tempObj = JSONObject()
|
||||
tempObj["name"] = wayNo.toString()
|
||||
tempObj["code"] = wayNo.toString()
|
||||
tempArr.add(tempObj)
|
||||
}
|
||||
|
||||
Common.singleSelect(ActivityCollector.getLastActivity()!!, "请选择运单号", tempArr, "") { _, item ->
|
||||
val jsonObject = item as JSONObject
|
||||
val name = jsonObject.getString("name")
|
||||
val code = jsonObject.getString("code")
|
||||
wbNo.setText(code)
|
||||
resetSearch()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//根据id返回结果
|
||||
viewModel.queryPickByIdGjjChuKuObserver.observe(this) {
|
||||
loadingCancel()
|
||||
//1.获取数据
|
||||
var status = it.getString("status")
|
||||
if (status == Constant.Result.succ) {
|
||||
var itemObj = it.getJSONObject("data")
|
||||
val id = itemObj.getIntValue("id")
|
||||
val pkId = itemObj.getString("pkId") ?: ""
|
||||
val no = itemObj.getString("wbNo") ?: ""
|
||||
val fno = itemObj.getString("fno") ?: ""
|
||||
val pc = itemObj.getIntValue("pc")
|
||||
val weight = itemObj.getDoubleValue("weight")//实到重量
|
||||
|
||||
val goods = itemObj.getString("goods") ?: ""
|
||||
val agentCode = itemObj.getString("agentCode") ?: ""
|
||||
val spCode = itemObj.getString("spCode") ?: ""
|
||||
val pickDate = itemObj.getString("chargeTime") ?: ""
|
||||
|
||||
//列表赋值
|
||||
collectList.add(
|
||||
GjjChuKuListModel(
|
||||
id,
|
||||
no,
|
||||
pkId,
|
||||
fno,
|
||||
pc,
|
||||
weight,
|
||||
goods,
|
||||
agentCode,
|
||||
spCode,
|
||||
pickDate, false
|
||||
)
|
||||
)
|
||||
|
||||
//3.调adpter展示
|
||||
adapter.notifyDataSetChanged()
|
||||
refreshLayout.finishRefresh()
|
||||
refreshLayout.finishLoadMore()
|
||||
|
||||
totalCount = 1
|
||||
viewModel.setCheckCount(0)
|
||||
totalPc.text = totalCount.toString()
|
||||
selPc.text = viewModel.checkCount.value.toString()
|
||||
}
|
||||
}
|
||||
|
||||
//货物发放 返回结果
|
||||
viewModel.completedGjjChuKuObserver.observe(this) {
|
||||
loadingCancel()
|
||||
val status = it.getString("status")
|
||||
val msg = it.getString("msg")
|
||||
if (Constant.Result.succ == status) {
|
||||
var dataStatus = it.getString("data")
|
||||
if (Constant.Result.succ == dataStatus) {
|
||||
if (msg != null && msg != "") {
|
||||
Common.showToast(this, msg)
|
||||
} else {
|
||||
Common.showToast(this, "出库成功!")
|
||||
}
|
||||
} else {
|
||||
if (msg != null && msg != "") {
|
||||
Common.showToast(this, msg)
|
||||
} else {
|
||||
Common.showToast(this, "出库失败!")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (msg != null && msg != "") {
|
||||
Common.showToast(this, msg)
|
||||
} else {
|
||||
Common.showToast(this, "出库失败!")
|
||||
}
|
||||
}
|
||||
//重新刷新列表
|
||||
resetSearch()
|
||||
}
|
||||
|
||||
//监听 复选框选中
|
||||
viewModel.checkCount.observe(this) {
|
||||
selPc.text = it.toString()
|
||||
}
|
||||
|
||||
//搜索
|
||||
resetSearch()
|
||||
|
||||
/////////////////////////////// 加载刷新的布局
|
||||
refreshLayout.setRefreshHeader(ClassicsHeader(this))
|
||||
refreshLayout.setRefreshFooter(ClassicsFooter(this))
|
||||
/////////////////////////////// 下拉刷新
|
||||
refreshLayout.setOnRefreshListener {
|
||||
resetSearch()
|
||||
}
|
||||
/////////////////////////////// 上拉加载
|
||||
refreshLayout.setOnLoadMoreListener {
|
||||
if (currentPage < totalPage) {
|
||||
currentPage++
|
||||
//初始化查询
|
||||
searchFun()
|
||||
} else {
|
||||
refreshLayout.finishLoadMoreWithNoMoreData()
|
||||
}
|
||||
}
|
||||
|
||||
/////////////// 下拉框 start
|
||||
viewModel.agentCode(System.currentTimeMillis().toString())
|
||||
viewModel.agentCodeObserver.observe(this) { vd ->
|
||||
val noneObj = JSONObject()
|
||||
noneObj["name"] = "请选择代理人"
|
||||
noneObj["code"] = ""
|
||||
viewModel.agentCodeList.add(noneObj)
|
||||
viewModel.agentCodeList.addAll(vd.getJSONArray("data"))
|
||||
}
|
||||
/////////////// 下拉框 end
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
v?.let {
|
||||
when (it.id) {
|
||||
R.id.tool_back -> {
|
||||
if (searchListFragment.visibility == View.GONE && filtrateFragment.visibility == View.VISIBLE) {
|
||||
searchListFragment.visibility = View.VISIBLE
|
||||
filtrateFragment.visibility = View.GONE
|
||||
titleName.text = currentTitleName
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
R.id.startDate -> {
|
||||
Common.onYearMonthDayTime(this, startDate.text.toString()) { year, month, day, hour, minute, second ->
|
||||
calendar.set(year, month - 1, day, hour, minute, second)
|
||||
startDate.text = ymdHmsSdf.format(calendar.time)
|
||||
}
|
||||
}
|
||||
R.id.endDate -> {
|
||||
Common.onYearMonthDayTime(this, endDate.text.toString()) { year, month, day, hour, minute, second ->
|
||||
calendar.set(year, month - 1, day, hour, minute, second)
|
||||
endDate.text = ymdHmsSdf.format(calendar.time)
|
||||
}
|
||||
}
|
||||
R.id.scanIcon -> {
|
||||
scanCode(Constant.RequestCode.gnj_chu_ku_list)
|
||||
}
|
||||
R.id.searchLayout -> {
|
||||
// viewModel.queryPickByIdGnjChuKu("M000995643")
|
||||
resetSearch()
|
||||
}
|
||||
R.id.filtrateLayout -> {
|
||||
if (searchListFragment.visibility == View.VISIBLE && filtrateFragment.visibility == View.GONE) {
|
||||
searchListFragment.visibility = View.GONE
|
||||
filtrateFragment.visibility = View.VISIBLE
|
||||
titleName.text = "搜索"
|
||||
} else {
|
||||
searchListFragment.visibility = View.VISIBLE
|
||||
filtrateFragment.visibility = View.GONE
|
||||
titleName.text = currentTitleName
|
||||
}
|
||||
}
|
||||
R.id.checkIcon -> {
|
||||
collectList.forEach { c ->
|
||||
c.isCheck = isAllCheck
|
||||
}
|
||||
if (isAllCheck) {
|
||||
viewModel.setCheckCount(totalCount)
|
||||
} else {
|
||||
viewModel.setCheckCount(0)
|
||||
}
|
||||
//重置 isAllCheck
|
||||
isAllCheck = !isAllCheck
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
R.id.send -> {
|
||||
val ids = collectList.filter { c -> c.isCheck }.map { c -> c.id }
|
||||
viewModel.completedGjjChuKu(ids)
|
||||
}
|
||||
R.id.agentCode -> {
|
||||
Common.singleSelect(this, "代理", viewModel.agentCodeList, agentCodeValue) { _, item ->
|
||||
val jsonObject = item as JSONObject
|
||||
val name = jsonObject.getString("name")
|
||||
val code = jsonObject.getString("code")
|
||||
agentCode.text = name
|
||||
agentCodeValue = code
|
||||
}
|
||||
}
|
||||
R.id.submit -> {
|
||||
//筛选页隐藏
|
||||
searchListFragment.visibility = View.VISIBLE
|
||||
filtrateFragment.visibility = View.GONE
|
||||
titleName.text = currentTitleName
|
||||
//搜索
|
||||
resetSearch()
|
||||
}
|
||||
R.id.reset -> {
|
||||
resetFun()
|
||||
}
|
||||
else -> {
|
||||
Toast.makeText(this, "未找到对应操作", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 扫码返回的结果
|
||||
*/
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
// 扫描二维码/条码回传
|
||||
if (resultCode == RESULT_OK && data != null) {
|
||||
val content = data.getStringExtra(com.yzq.zxinglibrary.common.Constant.CODED_CONTENT)
|
||||
if (content == null) {
|
||||
Common.showToast(this, "条码错误!")
|
||||
return
|
||||
}
|
||||
when (requestCode) {
|
||||
Constant.RequestCode.gnj_chu_ku_list -> {
|
||||
collectList.clear()
|
||||
currentPage = 1
|
||||
refreshLayout.setNoMoreData(false)
|
||||
pickNo.setText("$content")
|
||||
viewModel.queryPickByIdGjjChuKu(content)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索
|
||||
*/
|
||||
private fun searchFun() {
|
||||
loading()
|
||||
listLayout.visibility = View.GONE
|
||||
totalLayout.visibility = View.GONE
|
||||
viewModel.search(
|
||||
pageSize,
|
||||
currentPage,
|
||||
wbNo.text.toString(),
|
||||
agentCode.text.toString(),
|
||||
pickNo.text.toString(),
|
||||
startDate.text.toString(),
|
||||
endDate.text.toString()
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置数据,搜索
|
||||
*/
|
||||
private fun resetSearch() {
|
||||
//recyclerView 清除所有数据数据
|
||||
viewModel.setCheckCount(0)
|
||||
refreshLayout.setNoMoreData(false)
|
||||
adapter.notifyItemRangeRemoved(0, collectList.size)
|
||||
collectList.clear()
|
||||
currentPage = 1
|
||||
searchFun()
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置筛选条件
|
||||
*/
|
||||
private fun resetFun() {
|
||||
currentPage = 1
|
||||
startDate.text = "${ymdSdf.format(Date())} 00:00:00"
|
||||
endDate.text ="${ymdSdf.format(Date())} 23:59:59"
|
||||
wbNo.setText("")
|
||||
pickNo.setText("")
|
||||
|
||||
agentCode.text = ""
|
||||
agentCodeValue = ""
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.lukouguoji.gjj.activity
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import com.lukouguoji.gjj.R
|
||||
import com.lukouguoji.gjj.databinding.ActivityGjjGoodsAddBinding
|
||||
import com.lukouguoji.gjj.viewModel.GjjGoodsAddViewModel
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.ktx.addOnItemClickListener
|
||||
|
||||
class GjjGoodsAddActivity :
|
||||
BaseBindingActivity<ActivityGjjGoodsAddBinding, GjjGoodsAddViewModel>() {
|
||||
|
||||
override fun layoutId() = R.layout.activity_gjj_goods_add
|
||||
|
||||
override fun viewModelClass() = GjjGoodsAddViewModel::class.java
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国际进港货物开始交接")
|
||||
binding.viewModel = viewModel
|
||||
|
||||
viewModel.pageModel.bindSmartRefreshLayout(binding.srl, binding.rv, viewModel, this)
|
||||
binding.rv.addOnItemClickListener(viewModel)
|
||||
viewModel.getData()
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
val starter = Intent(context, GjjGoodsAddActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.lukouguoji.gjj.activity
|
||||
|
||||
import android.os.Bundle
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.lukouguoji.gjj.R
|
||||
import com.lukouguoji.gjj.databinding.ActivityGjjGoodsListBinding
|
||||
import com.lukouguoji.gjj.holder.GjjGoodsListViewHolder
|
||||
import com.lukouguoji.gjj.viewModel.GjjGoodsListViewModel
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.base.CommonAdapter
|
||||
import com.lukouguoji.module_base.ktx.addOnItemClickListener
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_GJJ_GOODS)
|
||||
class GjjGoodsListActivity :
|
||||
BaseBindingActivity<ActivityGjjGoodsListBinding, GjjGoodsListViewModel>() {
|
||||
|
||||
override fun layoutId() = R.layout.activity_gjj_goods_list
|
||||
|
||||
override fun viewModelClass() = GjjGoodsListViewModel::class.java
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国际进港货物交接")
|
||||
binding.viewModel = viewModel
|
||||
|
||||
binding.rv.addOnItemClickListener(viewModel)
|
||||
viewModel.pageModel.bindSmartRefreshLayout(binding.srl, binding.rv, viewModel, this)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
viewModel.refresh()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.lukouguoji.gjj.activity
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import com.lukouguoji.gjj.R
|
||||
import com.lukouguoji.gjj.databinding.ActivityGjjGoodsManifestBinding
|
||||
import com.lukouguoji.gjj.viewModel.GjjGoodsManifestViewModel
|
||||
import com.lukouguoji.module_base.adapter.loadImage
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.common.ConstantEvent
|
||||
import com.lukouguoji.module_base.impl.FlowBus
|
||||
import com.lukouguoji.module_base.impl.observe
|
||||
import com.lukouguoji.module_base.ktx.noNull
|
||||
import com.yzq.zxinglibrary.encode.CodeCreator
|
||||
|
||||
class GjjGoodsManifestActivity :
|
||||
BaseBindingActivity<ActivityGjjGoodsManifestBinding, GjjGoodsManifestViewModel>() {
|
||||
|
||||
override fun layoutId() = R.layout.activity_gjj_goods_manifest
|
||||
override fun viewModelClass() = GjjGoodsManifestViewModel::class.java
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
viewModel.id = intent.getStringExtra(Constant.Key.ID).noNull()
|
||||
binding.viewModel = viewModel
|
||||
|
||||
viewModel.pageModel.rv = binding.rv
|
||||
viewModel.getData()
|
||||
|
||||
CodeCreator.createQRCode("123456", 400, 400, null)?.let {
|
||||
loadImage(binding.iv, it)
|
||||
}
|
||||
|
||||
FlowBus.with<String>(ConstantEvent.SIGNATURE_SUCCESS)
|
||||
.observe(this) {
|
||||
viewModel.signature.postValue(it)
|
||||
viewModel.submitSignature(requireContext(), it)
|
||||
}
|
||||
|
||||
viewModel.resultSign.observe(this) {
|
||||
loadImage(binding.ivSign, it)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context, id: String) {
|
||||
val starter = Intent(context, GjjGoodsManifestActivity::class.java)
|
||||
.putExtra(Constant.Key.ID, id)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.lukouguoji.gjj.activity
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import com.lukouguoji.gjj.R
|
||||
import com.lukouguoji.gjj.databinding.ActivityGjjManifestAddBinding
|
||||
import com.lukouguoji.gjj.viewModel.GjjManifestAddViewModel
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.ktx.noNull
|
||||
|
||||
class GjjManifestAddActivity :
|
||||
BaseBindingActivity<ActivityGjjManifestAddBinding, GjjManifestAddViewModel>() {
|
||||
|
||||
override fun layoutId() = R.layout.activity_gjj_manifest_add
|
||||
|
||||
override fun viewModelClass() = GjjManifestAddViewModel::class.java
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国际进港舱单新增")
|
||||
viewModel.fid = intent.getStringExtra(Constant.Key.ID).noNull()
|
||||
viewModel.departure.value = intent.getStringExtra(Constant.Key.DEPARTURE).noNull()
|
||||
viewModel.destination.value = intent.getStringExtra(Constant.Key.DESTINATION).noNull()
|
||||
binding.viewModel = viewModel
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context, fid: String = "", dep: String, dest: String) {
|
||||
val starter = Intent(context, GjjManifestAddActivity::class.java)
|
||||
.putExtra(Constant.Key.ID, fid)
|
||||
.putExtra(Constant.Key.DEPARTURE, dep)
|
||||
.putExtra(Constant.Key.DESTINATION, dest)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.lukouguoji.gjj.activity
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import com.lukouguoji.gjj.R
|
||||
import com.lukouguoji.gjj.databinding.ActivityGjjManifestDetailsBinding
|
||||
import com.lukouguoji.gjj.viewModel.GjjManifestDetailsViewModel
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.ktx.noNull
|
||||
|
||||
class GjjManifestDetailsActivity :
|
||||
BaseBindingActivity<ActivityGjjManifestDetailsBinding, GjjManifestDetailsViewModel>() {
|
||||
|
||||
override fun layoutId() = R.layout.activity_gjj_manifest_details
|
||||
|
||||
override fun viewModelClass() = GjjManifestDetailsViewModel::class.java
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国际进港舱单详情")
|
||||
viewModel.id = intent.getStringExtra(Constant.Key.ID).noNull()
|
||||
|
||||
binding.viewModel = viewModel
|
||||
|
||||
viewModel.getData()
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context, id: String) {
|
||||
val starter = Intent(context, GjjManifestDetailsActivity::class.java)
|
||||
.putExtra(Constant.Key.ID, id)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.lukouguoji.gjj.activity
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.lukouguoji.gjj.R
|
||||
import com.lukouguoji.gjj.databinding.ActivityGjjManifestBinding
|
||||
import com.lukouguoji.gjj.holder.GjjManifestListViewHolder
|
||||
import com.lukouguoji.gjj.viewModel.GjjManifestListViewModel
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.base.CommonAdapter
|
||||
import com.lukouguoji.module_base.ktx.addOnItemClickListener
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_GJJ_MANIFEST)
|
||||
class GjjManifestListActivity :
|
||||
BaseBindingActivity<ActivityGjjManifestBinding, GjjManifestListViewModel>() {
|
||||
|
||||
override fun layoutId() = R.layout.activity_gjj_manifest
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国际进港舱单")
|
||||
binding.viewModel = viewModel
|
||||
|
||||
binding.rv.addOnItemClickListener(viewModel)
|
||||
|
||||
viewModel.pageModel.bindSmartRefreshLayout(binding.srl, binding.rv, viewModel, this)
|
||||
|
||||
viewModel.init(requireContext())
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
viewModel.refresh()
|
||||
}
|
||||
|
||||
override fun viewModelClass() = GjjManifestListViewModel::class.java
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
val starter = Intent(context, GjjManifestListActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.lukouguoji.gjj.activity
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.lukouguoji.gjj.R
|
||||
import com.lukouguoji.gjj.databinding.ActivityGjjPacketParseBinding
|
||||
import com.lukouguoji.gjj.viewModel.GjjPacketParseViewModel
|
||||
import com.lukouguoji.module_base.BaseActivity
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.ktx.addOnItemClickListener
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_GJJ_PACKET_PARSE)
|
||||
class GjjPacketParseActivity :
|
||||
BaseBindingActivity<ActivityGjjPacketParseBinding, GjjPacketParseViewModel>() {
|
||||
|
||||
override fun layoutId() = R.layout.activity_gjj_packet_parse
|
||||
|
||||
override fun viewModelClass() = GjjPacketParseViewModel::class.java
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国际进港电报解析")
|
||||
binding.viewModel = viewModel
|
||||
|
||||
viewModel.pageModel.bindSmartRefreshLayout(binding.srl, binding.rv, viewModel, this)
|
||||
binding.rv.addOnItemClickListener(viewModel)
|
||||
|
||||
viewModel.flightNo.observe(this) {
|
||||
viewModel.getDepartureDictList()
|
||||
}
|
||||
|
||||
viewModel.init(requireContext())
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
package com.lukouguoji.gjj.activity
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.core.widget.NestedScrollView
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.alibaba.android.arouter.facade.annotation.Autowired
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.alibaba.fastjson.JSONObject
|
||||
import com.lukouguoji.gjj.R
|
||||
import com.lukouguoji.gjj.adapt.GjjQueryInfoListAdapter
|
||||
import com.lukouguoji.gjj.adapt.GjjQueryInfoWhListAdapter
|
||||
import com.lukouguoji.gjj.model.GjjQueryInfo
|
||||
import com.lukouguoji.gjj.model.GjjQueryInfoWh
|
||||
import com.lukouguoji.gjj.viewModel.GjjQueryInfoViewModel
|
||||
import com.lukouguoji.module_base.BaseActivity
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_GJJ_QUERY_INFO)
|
||||
class GjjQueryInfoActivity : BaseActivity(), View.OnClickListener {
|
||||
|
||||
private lateinit var viewModel: GjjQueryInfoViewModel
|
||||
|
||||
private lateinit var scrollView: NestedScrollView
|
||||
private lateinit var queryInfoList: RecyclerView
|
||||
private lateinit var adapter: GjjQueryInfoListAdapter
|
||||
private val queryInfoAdapterList = arrayListOf<GjjQueryInfo>()
|
||||
|
||||
private lateinit var submit: TextView
|
||||
|
||||
private lateinit var refWareHouseInfo: LinearLayout
|
||||
private lateinit var wareHouseInfoLayout: LinearLayout
|
||||
private lateinit var queryWareHouseInfoList: RecyclerView
|
||||
private lateinit var wareHouseInfoAdapter: GjjQueryInfoWhListAdapter
|
||||
private val queryWareHouseInfoAdapterList = arrayListOf<GjjQueryInfoWh>()
|
||||
|
||||
@JvmField
|
||||
@Autowired
|
||||
var id: Int = -9999
|
||||
|
||||
@JvmField
|
||||
@Autowired
|
||||
var wbNoParam: String? = null
|
||||
|
||||
private fun initView() {
|
||||
viewModel = ViewModelProvider(this).get(GjjQueryInfoViewModel::class.java)
|
||||
|
||||
scrollView = findViewById(R.id.scrollView)
|
||||
refWareHouseInfo = findViewById(R.id.refWareHouseInfo)
|
||||
wareHouseInfoLayout = findViewById(R.id.wareHouseInfoLayout)
|
||||
submit = findViewById(R.id.submit)
|
||||
|
||||
val layoutManager = GridLayoutManager(this, 2)
|
||||
adapter = GjjQueryInfoListAdapter(this, queryInfoAdapterList)
|
||||
queryInfoList = findViewById(R.id.gncQueryInfoList)
|
||||
queryInfoList.adapter = adapter
|
||||
queryInfoList.layoutManager = layoutManager
|
||||
|
||||
val wareHouseLayoutManager = LinearLayoutManager(this)
|
||||
wareHouseInfoAdapter = GjjQueryInfoWhListAdapter(this, queryWareHouseInfoAdapterList)
|
||||
queryWareHouseInfoList = findViewById(R.id.gncQueryWareHouseInfoList)
|
||||
queryWareHouseInfoList.adapter = wareHouseInfoAdapter
|
||||
queryWareHouseInfoList.layoutManager = wareHouseLayoutManager
|
||||
|
||||
refWareHouseInfo.setOnClickListener(this)
|
||||
submit.setOnClickListener(this)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_gjj_query_info)
|
||||
setBackArrow("国际进港查询详情")
|
||||
initView()
|
||||
|
||||
// initData()
|
||||
|
||||
viewModel.queryWaybillById(id, wbNoParam)
|
||||
viewModel.waybillLiveData.observe(this) {
|
||||
val status = it.getString("status")
|
||||
if (Constant.Result.succ == status) {
|
||||
viewModel.wayBillInfo = it.getJSONObject("data")
|
||||
//主运单详情
|
||||
val maWbObj = viewModel.wayBillInfo.getJSONObject("maWb")
|
||||
val wbNo =
|
||||
(maWbObj.getString("prefix") ?: "") + (maWbObj.getString("no") ?: "")
|
||||
adapter.append(GjjQueryInfo(1, "运单号", wbNo))
|
||||
viewModel.wbNo = wbNo
|
||||
adapter.append(GjjQueryInfo(1, "总件数", maWbObj.getIntValue("pc").toString()))
|
||||
adapter.append(
|
||||
GjjQueryInfo(
|
||||
1,
|
||||
"总重量",
|
||||
"${maWbObj.getDoubleValue("grossweight")} KG"
|
||||
)
|
||||
)
|
||||
adapter.append(GjjQueryInfo(1, "承运人", maWbObj.getString("carrier") ?: ""))
|
||||
adapter.append(GjjQueryInfo(1, "目的港", maWbObj.getString("dest") ?: ""))
|
||||
adapter.append(GjjQueryInfo(1, "品名(英)", maWbObj.getString("goods") ?: ""))
|
||||
adapter.append(GjjQueryInfo(1, "特码", maWbObj.getString("spcode") ?: ""))
|
||||
adapter.append(GjjQueryInfo(1, "代理", maWbObj.getString("agent") ?: ""))
|
||||
adapter.append(GjjQueryInfo(1, "运单类型", maWbObj.getString("awbtype") ?: ""))
|
||||
adapter.append(GjjQueryInfo(1, "业务类型", maWbObj.getString("businesstype") ?: ""))
|
||||
adapter.append(GjjQueryInfo(1, "包装类型", maWbObj.getString("packagecode") ?: ""))
|
||||
/*adapter.append(GjjQueryInfo(1, "卸货港", maWbObj.getString("dest1") ?: ""))
|
||||
adapter.append(GjjQueryInfo(1, "危险品描述", maWbObj.getString("dgrDetail") ?: ""))
|
||||
adapter.append(GjjQueryInfo(1, "危险品库位", maWbObj.getString("dgrLocation") ?: ""))
|
||||
adapter.append(GjjQueryInfo(1, "航班", maWbObj.getString("flight") ?: ""))
|
||||
adapter.append(GjjQueryInfo(1, "入库时间", maWbObj.getString("opDate") ?: ""))
|
||||
adapter.append(GjjQueryInfo(1, "出库时间", maWbObj.getString("mclose") ?: ""))
|
||||
adapter.append(GjjQueryInfo(1, "收运人", maWbObj.getString("opId") ?: ""))*/
|
||||
|
||||
//关联仓库详情
|
||||
val whListArr = viewModel.wayBillInfo.getJSONArray("whList")
|
||||
whListArr.forEach { waybill ->
|
||||
val waybillObj = waybill as JSONObject
|
||||
wareHouseInfoAdapter.append(
|
||||
GjjQueryInfoWh(
|
||||
1,
|
||||
waybillObj.getString("wbNo") ?: "",
|
||||
waybillObj.getString("location") ?: "",
|
||||
waybillObj.getIntValue("pc"),
|
||||
waybillObj.getDoubleValue("weight"),
|
||||
waybillObj.getString("flight") ?: "",
|
||||
waybillObj.getString("opDate") ?: "",
|
||||
waybillObj.getString("handtime") ?: "",
|
||||
waybillObj.getString("opId") ?: ""
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
} else {
|
||||
//无数据
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun initData() {
|
||||
queryInfoAdapterList.add(GjjQueryInfo(1, "入库时间", "2021-04-05 15:22:33"))
|
||||
queryInfoAdapterList.add(GjjQueryInfo(1, "运单号", "A014d384"))
|
||||
queryInfoAdapterList.add(GjjQueryInfo(1, "代理人", "张三"))
|
||||
queryInfoAdapterList.add(GjjQueryInfo(1, "特码", "A06"))
|
||||
queryInfoAdapterList.add(GjjQueryInfo(1, "件数", "39件"))
|
||||
queryInfoAdapterList.add(GjjQueryInfo(1, "重量", "30kg"))
|
||||
queryInfoAdapterList.add(GjjQueryInfo(1, "品名", "TF"))
|
||||
queryInfoAdapterList.add(GjjQueryInfo(1, "目的港", "白云国际机场"))
|
||||
queryInfoAdapterList.add(GjjQueryInfo(1, "航班号", "U23"))
|
||||
queryInfoAdapterList.add(GjjQueryInfo(1, "运单类型", "配载单"))
|
||||
queryInfoAdapterList.add(GjjQueryInfo(1, "承运人", "SF"))
|
||||
queryInfoAdapterList.add(GjjQueryInfo(1, "包装", "木箱"))
|
||||
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
v?.let {
|
||||
when (it.id) {
|
||||
R.id.refWareHouseInfo -> {
|
||||
//开关关联列表
|
||||
if (wareHouseInfoLayout.visibility == View.GONE) {
|
||||
wareHouseInfoLayout.visibility = View.VISIBLE
|
||||
} else {
|
||||
wareHouseInfoLayout.visibility = View.GONE
|
||||
}
|
||||
scrollView.post { scrollView.scrollTo(0, scrollView.bottom) }
|
||||
}
|
||||
R.id.submit -> {
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_CARGO_TRACKING)
|
||||
.withString("countryTypeParam", Constant.CargoTracking.gjStatus)
|
||||
.withString("ieFlagParam", Constant.CargoTracking.importStatus)
|
||||
.withString("wbNoParam", viewModel.wbNo)
|
||||
.navigation()
|
||||
}
|
||||
else -> {
|
||||
Toast.makeText(this, "未找到对应操作", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,502 @@
|
||||
package com.lukouguoji.gjj.activity
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.alibaba.fastjson.JSONArray
|
||||
import com.alibaba.fastjson.JSONObject
|
||||
import com.lukouguoji.gjj.R
|
||||
import com.lukouguoji.gjj.adapt.GjjQueryListAdapter
|
||||
import com.lukouguoji.gjj.model.GjjQueryList
|
||||
import com.lukouguoji.gjj.viewModel.GjjQueryListViewModel
|
||||
import com.lukouguoji.module_base.ActivityCollector
|
||||
import com.lukouguoji.module_base.BaseActivity
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.scwang.smart.refresh.footer.ClassicsFooter
|
||||
import com.scwang.smart.refresh.header.ClassicsHeader
|
||||
import com.scwang.smart.refresh.layout.api.RefreshLayout
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_GJJ_QUERY_LIST)
|
||||
class GjjQueryListActivity : BaseActivity(), View.OnClickListener {
|
||||
private val currentTitleName = "国际进港查询"
|
||||
|
||||
private lateinit var viewModel: GjjQueryListViewModel
|
||||
|
||||
private lateinit var adapter: GjjQueryListAdapter
|
||||
private val collectList = ArrayList<GjjQueryList>()
|
||||
|
||||
private var currentPage = 1
|
||||
private var pageSize = 10
|
||||
private var totalPage = 0
|
||||
private lateinit var refreshLayout: RefreshLayout
|
||||
|
||||
//标题
|
||||
private lateinit var toolBack: LinearLayout
|
||||
private lateinit var titleName: TextView
|
||||
|
||||
//搜索条件
|
||||
private lateinit var beginDate: TextView
|
||||
private lateinit var beginDateIcon: ImageView
|
||||
private lateinit var endDate: TextView
|
||||
private lateinit var endDateIcon: ImageView
|
||||
private lateinit var searchListFragment: LinearLayout
|
||||
private lateinit var filtrateLayout: LinearLayout
|
||||
private lateinit var wbNo: EditText
|
||||
private lateinit var fno: EditText
|
||||
private lateinit var mudiGang: EditText
|
||||
private lateinit var searchLayout: LinearLayout
|
||||
|
||||
//筛选页
|
||||
private lateinit var filtrateFragment: LinearLayout
|
||||
|
||||
|
||||
private lateinit var spCode: TextView
|
||||
private var spCodeValue = ""
|
||||
private lateinit var agentCode: TextView
|
||||
private var agentCodeValue = ""
|
||||
private lateinit var goods: EditText
|
||||
private lateinit var awbType: TextView
|
||||
private var awbTypeValue = ""
|
||||
private lateinit var businessType: TextView
|
||||
private var businessTypeValue = ""
|
||||
|
||||
private lateinit var submit: TextView
|
||||
private lateinit var reset: TextView
|
||||
|
||||
|
||||
private val ymdSdf = SimpleDateFormat("yyyy-MM-dd")//年月日
|
||||
private val ymdHmsSdf = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")//年月日 时分秒
|
||||
private val calendar = Calendar.getInstance()
|
||||
|
||||
private fun initView() {
|
||||
viewModel = ViewModelProvider(this).get(GjjQueryListViewModel::class.java)
|
||||
val layoutManager = LinearLayoutManager(this)
|
||||
adapter = GjjQueryListAdapter(this, collectList)
|
||||
var recyclerView: RecyclerView = findViewById(R.id.recyclerList)
|
||||
recyclerView.layoutManager = layoutManager
|
||||
recyclerView.adapter = adapter
|
||||
|
||||
//标题
|
||||
toolBack = findViewById(R.id.tool_back)
|
||||
titleName = findViewById(R.id.title_name)
|
||||
//搜索列表页
|
||||
searchListFragment = findViewById(R.id.searchListFragment)
|
||||
wbNo = findViewById(R.id.wbNo)
|
||||
fno = findViewById(R.id.fno)
|
||||
beginDate = findViewById(R.id.beginDate)
|
||||
beginDateIcon = findViewById(R.id.beginDateIcon)
|
||||
endDate = findViewById(R.id.endDate)
|
||||
endDateIcon = findViewById(R.id.endDateIcon)
|
||||
mudiGang = findViewById(R.id.mudiGang)
|
||||
searchLayout = findViewById(R.id.searchLayout)
|
||||
filtrateLayout = findViewById(R.id.filtrateLayout)
|
||||
//筛选页
|
||||
filtrateFragment = findViewById(R.id.filtrateFragment)
|
||||
goods = findViewById(R.id.goods)
|
||||
spCode = findViewById(R.id.spCode)
|
||||
agentCode = findViewById(R.id.agentCode)
|
||||
businessType = findViewById(R.id.businessType)
|
||||
awbType = findViewById(R.id.awbType)
|
||||
submit = findViewById(R.id.submit)
|
||||
reset = findViewById(R.id.reset)
|
||||
|
||||
toolBack.setOnClickListener(this)
|
||||
searchLayout.setOnClickListener(this)
|
||||
beginDate.setOnClickListener(this)
|
||||
beginDateIcon.setOnClickListener(this)
|
||||
endDate.setOnClickListener(this)
|
||||
endDateIcon.setOnClickListener(this)
|
||||
|
||||
spCode.setOnClickListener(this)
|
||||
agentCode.setOnClickListener(this)
|
||||
businessType.setOnClickListener(this)
|
||||
awbType.setOnClickListener(this)
|
||||
// isCangDan.setOnClickListener(this)
|
||||
filtrateLayout.setOnClickListener(this)
|
||||
submit.setOnClickListener(this)
|
||||
reset.setOnClickListener(this)
|
||||
|
||||
wbNo.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
if (s != null && s.toString().length > 11) {
|
||||
Common.alertDialog(ActivityCollector.getLastActivity()!!, "运单号不能超过11位!") { dialog ->
|
||||
wbNo.setText(s.toString().substring(0, 11))
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
fno.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun afterTextChanged(editable: Editable?) {
|
||||
val originText = editable.toString()
|
||||
if (originText != null && originText != "") {
|
||||
val regularExpression = "(^([A-Z0-9]+)$)"
|
||||
val matches = originText.matches(regularExpression.toRegex())
|
||||
if(!matches){
|
||||
val regularExpression2 = "([^A-Za-z0-9]+)"
|
||||
val replaceStr = originText.replace(regularExpression2.toRegex(),"")
|
||||
val replaceStrToUpper = replaceStr.uppercase(Locale.ROOT)//小写转大写
|
||||
fno.setText(replaceStrToUpper)
|
||||
fno.setSelection(replaceStrToUpper.length)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
mudiGang.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun afterTextChanged(editable: Editable?) {
|
||||
val originText = editable.toString()
|
||||
if (originText != null && originText != "") {
|
||||
val regularExpression = "(^([A-Z]+)$)"
|
||||
val matches = originText.matches(regularExpression.toRegex())
|
||||
if(!matches){
|
||||
val regularExpression2 = "([^A-Za-z]+)"
|
||||
val replaceStr = originText.replace(regularExpression2.toRegex(),"")
|
||||
val replaceStrToUpper = replaceStr.uppercase(Locale.ROOT)//小写转大写
|
||||
mudiGang.setText(replaceStrToUpper)
|
||||
mudiGang.setSelection(replaceStrToUpper.length)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
beginDate.text = ymdSdf.format(Date())//tw2022年6月13日15:57:10 要求航班日期默认当天
|
||||
endDate.text = ymdSdf.format(Date())//tw2022年6月13日15:57:10 要求航班日期默认当天
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_gjj_query_list)
|
||||
initView()
|
||||
|
||||
//初始化查询
|
||||
searchFun()
|
||||
loading()
|
||||
viewModel.searchParamLive.observe(this) {
|
||||
loadingCancel()
|
||||
//1.获取数据
|
||||
var listArr: JSONArray = it["list"] as JSONArray
|
||||
totalPage = it["pages"] as Int
|
||||
// var listArr :JSONArray =it["list"] as JSONArray
|
||||
if (listArr.size > 0) {
|
||||
//2.循环遍历塞入collectList
|
||||
listArr.forEach {
|
||||
val itemObj = it as JSONObject
|
||||
val id = itemObj.getIntValue("mawbid")
|
||||
val wbNo = (itemObj.getString("prefix") ?: "") + (itemObj.getString("no") ?: "")
|
||||
val agentCode = itemObj.getString("agent") ?: ""
|
||||
val spCode = itemObj.getString("spCode") ?: ""
|
||||
val goods = itemObj.getString("goods") ?: ""
|
||||
val flight = itemObj.getString("flight") ?: ""
|
||||
val range = itemObj.getString("range") ?: ""
|
||||
val pc = itemObj.getString("pc") ?: ""
|
||||
val weight = itemObj.getString("weight") ?: ""
|
||||
|
||||
collectList.add(GjjQueryList(id, wbNo, agentCode, spCode, goods, flight, range,pc,weight))
|
||||
}
|
||||
//3.调adpter展示
|
||||
if (currentPage == 1) {
|
||||
adapter.notifyDataSetChanged()
|
||||
} else {
|
||||
adapter.notifyItemRangeInserted((currentPage - 1) * 10, collectList.size)
|
||||
}
|
||||
refreshLayout.finishRefresh()
|
||||
refreshLayout.finishLoadMore()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/////////////// 下拉框 start
|
||||
viewModel.agentCode(System.currentTimeMillis().toString())
|
||||
viewModel.agentCodeObserver.observe(this) { vd ->
|
||||
val noneObj = JSONObject()
|
||||
noneObj["name"] = "请选择代理人"
|
||||
noneObj["code"] = ""
|
||||
viewModel.agentCodeList.add(noneObj)
|
||||
viewModel.agentCodeList.addAll(vd.getJSONArray("data"))
|
||||
}
|
||||
|
||||
viewModel.business(Constant.businessType.II)
|
||||
viewModel.businessObserver.observe(this) { vd ->
|
||||
val noneObj = JSONObject()
|
||||
noneObj["name"] = "请选择业务类型"
|
||||
noneObj["code"] = ""
|
||||
viewModel.businessList.add(noneObj)
|
||||
viewModel.businessList.addAll(vd.getJSONArray("data"))
|
||||
}
|
||||
|
||||
viewModel.specialCode(System.currentTimeMillis().toString())
|
||||
viewModel.specialCodeObserver.observe(this) { vd ->
|
||||
val noneObj = JSONObject()
|
||||
noneObj["name"] = "请选择特码"
|
||||
noneObj["code"] = ""
|
||||
viewModel.specialCodeList.add(noneObj)
|
||||
viewModel.specialCodeList.addAll(vd.getJSONArray("data"))
|
||||
}
|
||||
|
||||
viewModel.awb(Constant.businessType.II)
|
||||
viewModel.awbObserver.observe(this) { vd ->
|
||||
val noneObj = JSONObject()
|
||||
noneObj["name"] = "请选择运单类型"
|
||||
noneObj["code"] = ""
|
||||
viewModel.awbList.add(noneObj)
|
||||
viewModel.awbList.addAll(vd.getJSONArray("data"))
|
||||
}
|
||||
/////////////// 下拉框 end
|
||||
|
||||
/////////////////////////////// 加载刷新的布局
|
||||
refreshLayout = findViewById<View>(R.id.refreshLayout) as RefreshLayout
|
||||
refreshLayout.setRefreshHeader(ClassicsHeader(this))
|
||||
refreshLayout.setRefreshFooter(ClassicsFooter(this))
|
||||
/////////////////////////////// 下拉刷新
|
||||
refreshLayout.setOnRefreshListener {
|
||||
resetSearch()
|
||||
}
|
||||
/////////////////////////////// 上拉加载
|
||||
refreshLayout.setOnLoadMoreListener {
|
||||
if (currentPage < totalPage) {
|
||||
currentPage++
|
||||
//初始化查询
|
||||
searchFun()
|
||||
} else {
|
||||
refreshLayout.finishLoadMoreWithNoMoreData()
|
||||
}
|
||||
}
|
||||
|
||||
//点击扫码
|
||||
/*scanCodeImg.setOnClickListener {
|
||||
scanCode(Constant.RequestCode.gnc_query_list)
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
* onActivityResult 回调
|
||||
*/
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
|
||||
// 扫描二维码/条码回传
|
||||
/*if (requestCode == Constant.RequestCode.gnc_query_list && resultCode == RESULT_OK) {
|
||||
if (data != null) {
|
||||
val content = data.getStringExtra(com.yzq.zxinglibrary.common.Constant.CODED_CONTENT)
|
||||
searchContent.setText("$content")
|
||||
|
||||
//调用接口查询进入详情页
|
||||
if (content != null && content != "") {
|
||||
ARouter.getInstance().build(ARouterConstants.ACTIVITY_URL_GNC_QUERY_INFO).withString("wbNoParam", content)
|
||||
.navigation(this)
|
||||
}
|
||||
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
v?.let {
|
||||
when (it.id) {
|
||||
R.id.tool_back -> {
|
||||
if (searchListFragment.visibility == View.GONE && filtrateFragment.visibility == View.VISIBLE) {
|
||||
searchListFragment.visibility = View.VISIBLE
|
||||
filtrateFragment.visibility = View.GONE
|
||||
titleName.text = currentTitleName
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
R.id.searchLayout -> {
|
||||
resetSearch()
|
||||
}
|
||||
R.id.filtrateLayout -> {
|
||||
if (searchListFragment.visibility == View.VISIBLE && filtrateFragment.visibility == View.GONE) {
|
||||
searchListFragment.visibility = View.GONE
|
||||
filtrateFragment.visibility = View.VISIBLE
|
||||
titleName.text = "搜索"
|
||||
} else {
|
||||
searchListFragment.visibility = View.VISIBLE
|
||||
filtrateFragment.visibility = View.GONE
|
||||
titleName.text = currentTitleName
|
||||
}
|
||||
// Common.showToast(this,"筛选")
|
||||
}
|
||||
R.id.beginDate -> {
|
||||
Common.onYearMonthDay(this, beginDate.text.toString()) { year, month, day ->
|
||||
calendar.set(year, month - 1, day)
|
||||
beginDate.text = ymdSdf.format(calendar.time)
|
||||
}
|
||||
}
|
||||
R.id.beginDateIcon -> {
|
||||
beginDate.text = ""
|
||||
}
|
||||
R.id.endDate -> {
|
||||
Common.onYearMonthDay(this, endDate.text.toString()) { year, month, day ->
|
||||
calendar.set(year, month - 1, day)
|
||||
endDate.text = ymdSdf.format(calendar.time)
|
||||
}
|
||||
}
|
||||
R.id.endDateIcon -> {
|
||||
endDate.text = ""
|
||||
}
|
||||
/* R.id.startDateParam -> {
|
||||
Common.onYearMonthDayTime(this, startDateParam.text.toString()) { year, month, day, hour, minute, second ->
|
||||
calendar.set(year, month - 1, day, hour, minute, second)
|
||||
startDateParam.text = ymdHmsSdf.format(calendar.time)
|
||||
}
|
||||
}
|
||||
R.id.endDateParam -> {
|
||||
Common.onYearMonthDayTime(this, endDateParam.text.toString()) { year, month, day, hour, minute, second ->
|
||||
calendar.set(year, month - 1, day, hour, minute, second)
|
||||
endDateParam.text = ymdHmsSdf.format(calendar.time)
|
||||
}
|
||||
}*/
|
||||
R.id.agentCode -> {
|
||||
Common.singleSelect(this, "代理", viewModel.agentCodeList, agentCodeValue) { _, item ->
|
||||
val jsonObject = item as JSONObject
|
||||
val name = jsonObject.getString("name")
|
||||
val code = jsonObject.getString("code")
|
||||
agentCode.text = name
|
||||
agentCodeValue = code
|
||||
}
|
||||
}
|
||||
R.id.businessType -> {
|
||||
Common.singleSelect(this, "业务类型", viewModel.businessList, businessTypeValue) { _, item ->
|
||||
val jsonObject = item as JSONObject
|
||||
val name = jsonObject.getString("name")
|
||||
val code = jsonObject.getString("code")
|
||||
businessType.text = name
|
||||
businessTypeValue = code
|
||||
}
|
||||
}
|
||||
R.id.spCode -> {
|
||||
Common.singleSelect(this, "特码", viewModel.specialCodeList, spCodeValue) { _, item ->
|
||||
val jsonObject = item as JSONObject
|
||||
val name = jsonObject.getString("name")
|
||||
val code = jsonObject.getString("code")
|
||||
spCode.text = name
|
||||
spCodeValue = code
|
||||
}
|
||||
}
|
||||
R.id.awbType -> {
|
||||
Common.singleSelect(this, "运单类型", viewModel.awbList, awbTypeValue) { _, item ->
|
||||
val jsonObject = item as JSONObject
|
||||
val name = jsonObject.getString("name")
|
||||
val code = jsonObject.getString("code")
|
||||
awbType.text = name
|
||||
awbTypeValue = code
|
||||
}
|
||||
}
|
||||
R.id.submit -> {
|
||||
//筛选页隐藏
|
||||
searchListFragment.visibility = View.VISIBLE
|
||||
filtrateFragment.visibility = View.GONE
|
||||
titleName.text = currentTitleName
|
||||
//搜索
|
||||
resetSearch()
|
||||
}
|
||||
R.id.reset -> {
|
||||
resetFun()
|
||||
}
|
||||
else -> {
|
||||
Toast.makeText(this, "未找到对应操作", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索
|
||||
*/
|
||||
private fun searchFun() {
|
||||
viewModel.search(
|
||||
pageSize,
|
||||
currentPage,
|
||||
"", // carrier.text.toString(),
|
||||
agentCodeValue,
|
||||
awbTypeValue,
|
||||
beginDate.text.toString(),// startDateParam.text.toString(),
|
||||
endDate.text.toString(),// endDateParam.text.toString(),
|
||||
"",
|
||||
fno.text.toString(),
|
||||
mudiGang.text.toString(),
|
||||
"",// kuWei.text.toString(),
|
||||
"",// hangCheng.text.toString(),
|
||||
businessTypeValue,
|
||||
"",// isCangDanStatus,
|
||||
wbNo.text.toString(),
|
||||
spCodeValue,
|
||||
goods.text.toString()
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置数据,搜索
|
||||
*/
|
||||
private fun resetSearch() {
|
||||
//recyclerView 清除所有数据数据
|
||||
refreshLayout.setNoMoreData(false)
|
||||
adapter.notifyItemRangeRemoved(0, collectList.size)
|
||||
collectList.clear()
|
||||
currentPage = 1
|
||||
searchFun()
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置筛选条件
|
||||
*/
|
||||
private fun resetFun() {
|
||||
currentPage = 1
|
||||
|
||||
wbNo.setText("")
|
||||
mudiGang.setText("")
|
||||
|
||||
beginDate.text = ""
|
||||
endDate.text = ""
|
||||
fno.setText("")
|
||||
|
||||
spCode.text = ""
|
||||
spCodeValue = ""
|
||||
agentCode.text = ""
|
||||
agentCodeValue = ""
|
||||
goods.setText("")
|
||||
businessType.text = ""
|
||||
businessTypeValue = ""
|
||||
awbType.text = ""
|
||||
awbTypeValue = ""
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.lukouguoji.gjj.activity
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import com.lukouguoji.gjj.R
|
||||
import com.lukouguoji.gjj.databinding.ActivityGjjTallyAddBinding
|
||||
import com.lukouguoji.gjj.viewModel.GjjTallyAddViewModel
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.bean.GjjTallyBean
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.ktx.addOnItemClickListener
|
||||
import com.lukouguoji.module_base.ktx.toJson
|
||||
|
||||
class GjjTallyAddActivity :
|
||||
BaseBindingActivity<ActivityGjjTallyAddBinding, GjjTallyAddViewModel>() {
|
||||
|
||||
override fun layoutId() = R.layout.activity_gjj_tally_add
|
||||
|
||||
override fun viewModelClass() = GjjTallyAddViewModel::class.java
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国际进港开始理货")
|
||||
intent.getStringExtra(Constant.Key.DATA)?.let {
|
||||
viewModel.tallyBean = NetApply.gson.fromJson(it, GjjTallyBean::class.java)
|
||||
viewModel.getData()
|
||||
}
|
||||
|
||||
binding.viewModel = viewModel
|
||||
viewModel.pageModel.bindSmartRefreshLayout(binding.srl, binding.rv, viewModel, this)
|
||||
binding.rv.addOnItemClickListener(viewModel)
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context, bean: GjjTallyBean? = null) {
|
||||
val starter = Intent(context, GjjTallyAddActivity::class.java)
|
||||
bean?.let {
|
||||
starter.putExtra(Constant.Key.DATA, it.toJson(false))
|
||||
}
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.lukouguoji.gjj.activity
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import com.lukouguoji.gjj.R
|
||||
import com.lukouguoji.gjj.databinding.ActivityGjjTallyDetailsBinding
|
||||
import com.lukouguoji.gjj.viewModel.GjjTallyDetailsViewModel
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.ktx.noNull
|
||||
|
||||
class GjjTallyDetailsActivity :
|
||||
BaseBindingActivity<ActivityGjjTallyDetailsBinding, GjjTallyDetailsViewModel>() {
|
||||
|
||||
override fun layoutId() = R.layout.activity_gjj_tally_details
|
||||
|
||||
override fun viewModelClass() = GjjTallyDetailsViewModel::class.java
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国际进港理货详情")
|
||||
viewModel.mfId = intent.getStringExtra(Constant.Key.ID).noNull()
|
||||
viewModel.waybillNo = intent.getStringExtra(Constant.Key.WAYBILL).noNull()
|
||||
binding.viewModel = viewModel
|
||||
|
||||
viewModel.pageModel.bindSmartRefreshLayout(binding.srl, binding.rv, viewModel, this)
|
||||
viewModel.refresh()
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context, mfId: String, waybillNo: String) {
|
||||
val starter = Intent(context, GjjTallyDetailsActivity::class.java)
|
||||
.putExtra(Constant.Key.ID, mfId)
|
||||
.putExtra(Constant.Key.WAYBILL, waybillNo)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.lukouguoji.gjj.activity
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.lukouguoji.gjj.R
|
||||
import com.lukouguoji.gjj.databinding.ActivityGjjManifestBinding
|
||||
import com.lukouguoji.gjj.databinding.ActivityGjjTallyListBinding
|
||||
import com.lukouguoji.gjj.holder.GjjManifestListViewHolder
|
||||
import com.lukouguoji.gjj.holder.GjjTallyListViewHolder
|
||||
import com.lukouguoji.gjj.viewModel.GjjManifestListViewModel
|
||||
import com.lukouguoji.gjj.viewModel.GjjTallyViewModel
|
||||
import com.lukouguoji.module_base.BaseActivity
|
||||
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.router.ARouterConstants
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_GJJ_Tally)
|
||||
class GjjTallyListActivity : BaseBindingActivity<ActivityGjjTallyListBinding, GjjTallyViewModel>() {
|
||||
|
||||
override fun layoutId() = R.layout.activity_gjj_tally_list
|
||||
override fun viewModelClass() = GjjTallyViewModel::class.java
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国际进港理货")
|
||||
|
||||
binding.viewModel = viewModel
|
||||
|
||||
viewModel.pageModel.bindSmartRefreshLayout(binding.srl, binding.rv, viewModel, this)
|
||||
|
||||
// 条目点击事件
|
||||
binding.rv.addOnItemClickListener(object : IOnItemClickListener {
|
||||
override fun onItemClick(position: Int, type: Int) {
|
||||
viewModel.onItemClick(position, type)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
viewModel.refresh()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,462 @@
|
||||
package com.lukouguoji.gjj.activity
|
||||
|
||||
import android.os.Bundle
|
||||
import android.text.Editable
|
||||
import android.text.TextWatcher
|
||||
import android.view.View
|
||||
import android.widget.EditText
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.alibaba.fastjson.JSONArray
|
||||
import com.alibaba.fastjson.JSONObject
|
||||
import com.lukouguoji.gjj.R
|
||||
import com.lukouguoji.gjj.adapt.GjjWareHouseListAdapter
|
||||
import com.lukouguoji.gjj.model.GjjWareHouseList
|
||||
import com.lukouguoji.gjj.viewModel.GjjWareHouseListViewModel
|
||||
import com.lukouguoji.module_base.ActivityCollector
|
||||
import com.lukouguoji.module_base.BaseActivity
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
import com.lukouguoji.module_base.util.Common
|
||||
import com.scwang.smart.refresh.footer.ClassicsFooter
|
||||
import com.scwang.smart.refresh.header.ClassicsHeader
|
||||
import com.scwang.smart.refresh.layout.api.RefreshLayout
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_GJJ_WARE_HOUSE)
|
||||
class GjjWareHouseActivity : BaseActivity(), View.OnClickListener {
|
||||
private lateinit var viewModel: GjjWareHouseListViewModel
|
||||
private val currentTitleName = "国际进港仓库管理"
|
||||
|
||||
private lateinit var adapter: GjjWareHouseListAdapter
|
||||
private val collectList = ArrayList<GjjWareHouseList>()
|
||||
|
||||
private lateinit var refreshLayout: RefreshLayout
|
||||
private var currentPage = 1
|
||||
private var pageSize = 10
|
||||
private var totalPage = 0
|
||||
|
||||
//是否刷新
|
||||
private var refresh = false
|
||||
|
||||
//标题
|
||||
private lateinit var toolBack: LinearLayout
|
||||
private lateinit var titleName: TextView
|
||||
|
||||
//搜索条件
|
||||
private lateinit var searchListFragment: LinearLayout
|
||||
|
||||
private lateinit var wayNo: EditText
|
||||
private lateinit var agentCode: TextView
|
||||
private var agentCodeValue = ""
|
||||
private lateinit var carrier: EditText
|
||||
private lateinit var location: EditText
|
||||
private lateinit var searchLayout: LinearLayout
|
||||
private lateinit var summaryText: TextView
|
||||
|
||||
//筛选页
|
||||
private lateinit var filtrateLayout: LinearLayout
|
||||
private lateinit var filtrateFragment: LinearLayout
|
||||
private lateinit var fdep: EditText
|
||||
private lateinit var isGroup: TextView
|
||||
private var isGroupStatus = ""
|
||||
private val isGroupArr = JSONArray()
|
||||
|
||||
private lateinit var submit: TextView
|
||||
private lateinit var reset: TextView
|
||||
|
||||
private val ymdSdf = SimpleDateFormat("yyyy-MM-dd")//年月日
|
||||
private val ymdHmsSdf = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")//年月日 时分秒
|
||||
private val calendar = Calendar.getInstance()
|
||||
|
||||
private fun initView() {
|
||||
viewModel = ViewModelProvider(this).get(GjjWareHouseListViewModel::class.java)
|
||||
|
||||
val layoutManager = LinearLayoutManager(this)
|
||||
adapter = GjjWareHouseListAdapter(this, collectList)
|
||||
var recyclerView: RecyclerView = findViewById(R.id.guo_nei_collect_list)
|
||||
recyclerView.layoutManager = layoutManager
|
||||
recyclerView.adapter = adapter
|
||||
|
||||
refreshLayout = findViewById(R.id.refreshLayout)
|
||||
|
||||
//标题
|
||||
toolBack = findViewById(R.id.tool_back)
|
||||
titleName = findViewById(R.id.title_name)
|
||||
|
||||
//搜索列表页
|
||||
searchListFragment = findViewById(R.id.searchListFragment)
|
||||
wayNo = findViewById(R.id.waybillNo)
|
||||
agentCode = findViewById(R.id.agentCode)
|
||||
carrier = findViewById(R.id.carrier)
|
||||
location = findViewById(R.id.location)
|
||||
searchLayout = findViewById(R.id.searchLayout)
|
||||
filtrateLayout = findViewById(R.id.filtrateLayout)
|
||||
summaryText = findViewById(R.id.summaryText)
|
||||
//筛选页
|
||||
filtrateFragment = findViewById(R.id.filtrateFragment)
|
||||
fdep = findViewById(R.id.fdep)
|
||||
isGroup = findViewById(R.id.isGroup)
|
||||
|
||||
submit = findViewById(R.id.submit)
|
||||
reset = findViewById(R.id.reset)
|
||||
|
||||
toolBack.setOnClickListener(this)
|
||||
searchLayout.setOnClickListener(this)
|
||||
filtrateLayout.setOnClickListener(this)
|
||||
submit.setOnClickListener(this)
|
||||
reset.setOnClickListener(this)
|
||||
isGroup.setOnClickListener(this)
|
||||
agentCode.setOnClickListener(this)
|
||||
|
||||
wayNo.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
if (s != null && s.toString().length > 11) {
|
||||
Common.alertDialog(ActivityCollector.getLastActivity()!!, "运单号不能超过11位!") { dialog ->
|
||||
wayNo.setText(s.toString().substring(0, 11))
|
||||
dialog.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
carrier.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
|
||||
}
|
||||
|
||||
override fun afterTextChanged(editable: Editable?) {
|
||||
val originText = editable.toString()
|
||||
if (originText != null && originText != "") {
|
||||
val regularExpression = "(^([A-Z]+)$)"
|
||||
val matches = originText.matches(regularExpression.toRegex())
|
||||
if(!matches){
|
||||
val regularExpression2 = "([^A-Za-z]+)"
|
||||
val replaceStr = originText.replace(regularExpression2.toRegex(),"")
|
||||
val replaceStrToUpper = replaceStr.uppercase(Locale.ROOT)//小写转大写
|
||||
carrier.setText(replaceStrToUpper)
|
||||
carrier.setSelection(replaceStrToUpper.length)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
//赋值
|
||||
//是否上舱单
|
||||
val noneGroup = JSONObject()
|
||||
noneGroup["name"] = "请选择分组类型"
|
||||
noneGroup["code"] = ""
|
||||
val yesGroup = JSONObject()
|
||||
yesGroup["name"] = "航程"
|
||||
yesGroup["code"] = "dest"
|
||||
val noGroup = JSONObject()
|
||||
noGroup["name"] = "库位"
|
||||
noGroup["code"] = "location"
|
||||
val dateGroup = JSONObject()
|
||||
dateGroup["name"] = "入库时间"
|
||||
dateGroup["code"] = "date"
|
||||
isGroupArr.add(noneGroup)
|
||||
isGroupArr.add(yesGroup)
|
||||
isGroupArr.add(noGroup)
|
||||
isGroupArr.add(dateGroup)
|
||||
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_gjj_ware_house)
|
||||
initView()
|
||||
|
||||
//查询返回结果
|
||||
viewModel.searchParamLive.observe(this) {
|
||||
loadingCancel()
|
||||
//1.获取数据
|
||||
var listArr = JSONArray()
|
||||
try {
|
||||
listArr = it["list"] as JSONArray
|
||||
} catch (e: Exception) {
|
||||
return@observe
|
||||
}
|
||||
totalPage = it["pages"] as Int
|
||||
// var listArr :JSONArray =it["list"] as JSONArray
|
||||
if (listArr.size > 0) {
|
||||
//2.循环遍历塞入collectList
|
||||
listArr.forEach {
|
||||
val itemObj = it as JSONObject
|
||||
val whId = itemObj.getIntValue("whid")
|
||||
val no = itemObj.getString("wbNo") ?: ""
|
||||
val weight = itemObj.getDouble("weight")
|
||||
val pc = itemObj.getIntValue("pc")
|
||||
val fno = itemObj.getString("fno") ?: ""
|
||||
val flight = itemObj.getString("flight") ?: ""
|
||||
val opDate = itemObj.getString("opDate") ?: ""
|
||||
val gdate = itemObj.getString("gdate") ?: ""
|
||||
val locStatus = itemObj.getString("locStatus") ?: ""
|
||||
val dest = itemObj.getString("dest") ?: ""
|
||||
val location = itemObj.getString("location") ?: ""
|
||||
val goods = itemObj.getString("goods") ?: ""
|
||||
val spCode = itemObj.getString("spCode") ?: ""
|
||||
val agentCode = itemObj.getString("agentCode") ?: ""
|
||||
val by1 = itemObj.getString("by1") ?: ""
|
||||
val origin = itemObj.getString("origin") ?: ""
|
||||
val awbType = itemObj.getString("awbType") ?: ""
|
||||
val businessType = itemObj.getString("businessType") ?: ""
|
||||
val status = itemObj.getString("status") ?: ""
|
||||
val days = itemObj.getIntValue("days")
|
||||
|
||||
|
||||
var groupTitle = ""
|
||||
var groupName = ""
|
||||
var daysString: String? = null
|
||||
when (isGroupStatus) {
|
||||
"dest" -> {
|
||||
groupTitle = "目的港:"
|
||||
groupName = dest
|
||||
}
|
||||
"location" -> {
|
||||
groupTitle = "库位:"
|
||||
groupName = location
|
||||
}
|
||||
"date" -> {
|
||||
groupTitle = "入库时间:"
|
||||
groupName = "$gdate,入库天数:"
|
||||
daysString = days.toString()
|
||||
}
|
||||
else -> {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
collectList.add(
|
||||
GjjWareHouseList(
|
||||
whId,
|
||||
no,
|
||||
pc,
|
||||
weight,
|
||||
fno,
|
||||
flight,
|
||||
opDate,
|
||||
locStatus,
|
||||
groupTitle,
|
||||
groupName,
|
||||
daysString,
|
||||
goods,
|
||||
spCode,
|
||||
agentCode,
|
||||
by1,
|
||||
origin,
|
||||
location,
|
||||
awbType,
|
||||
businessType,
|
||||
status,
|
||||
)
|
||||
)
|
||||
}
|
||||
//3.调adpter展示
|
||||
if (currentPage == 1) {
|
||||
adapter.notifyDataSetChanged()
|
||||
} else {
|
||||
adapter.notifyItemRangeInserted((currentPage - 1) * 10, collectList.size)
|
||||
}
|
||||
refreshLayout.finishRefresh()
|
||||
refreshLayout.finishLoadMore()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//汇总返回结果
|
||||
viewModel.summaryObserver.observe(this) {
|
||||
loadingCancel()
|
||||
val status = it.getString("status")
|
||||
if (Constant.Result.succ == status) {
|
||||
var jsonObject = it.getJSONObject("data")
|
||||
val totalTemp = jsonObject.getIntValue("total")
|
||||
val totalPcTemp = jsonObject.getIntValue("pc")
|
||||
val totalWeightTemp = jsonObject.getDoubleValue("weight")
|
||||
summaryText.text = "总票数:$totalTemp,总件数:$totalPcTemp,总重量:$totalWeightTemp"
|
||||
} else {
|
||||
//无数据
|
||||
}
|
||||
}
|
||||
|
||||
//初始化查询
|
||||
searchFun()
|
||||
loading()
|
||||
|
||||
/////////////// 下拉框 start
|
||||
viewModel.agentCode(System.currentTimeMillis().toString())
|
||||
viewModel.agentCodeObserver.observe(this) { vd ->
|
||||
val noneObj = JSONObject()
|
||||
noneObj["name"] = "请选择代理人"
|
||||
noneObj["code"] = ""
|
||||
viewModel.agentCodeList.add(noneObj)
|
||||
viewModel.agentCodeList.addAll(vd.getJSONArray("data"))
|
||||
}
|
||||
|
||||
viewModel.business(Constant.businessType.II)
|
||||
viewModel.businessObserver.observe(this) { vd ->
|
||||
val noneObj = JSONObject()
|
||||
noneObj["name"] = "请选择业务类型"
|
||||
noneObj["code"] = ""
|
||||
viewModel.businessList.add(noneObj)
|
||||
viewModel.businessList.addAll(vd.getJSONArray("data"))
|
||||
}
|
||||
/////////////// 下拉框 end
|
||||
|
||||
/////////////////////////////// 加载刷新的布局
|
||||
refreshLayout.setRefreshHeader(ClassicsHeader(this))
|
||||
refreshLayout.setRefreshFooter(ClassicsFooter(this))
|
||||
/////////////////////////////// 下拉刷新
|
||||
refreshLayout.setOnRefreshListener {
|
||||
refresh = true
|
||||
resetSearch()
|
||||
}
|
||||
/////////////////////////////// 上拉加载
|
||||
refreshLayout.setOnLoadMoreListener {
|
||||
refresh = false
|
||||
if (currentPage < totalPage) {
|
||||
currentPage++
|
||||
//初始化查询
|
||||
searchFun()
|
||||
} else {
|
||||
refreshLayout.finishLoadMoreWithNoMoreData()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
v?.let {
|
||||
when (it.id) {
|
||||
R.id.tool_back -> {
|
||||
if (searchListFragment.visibility == View.GONE && filtrateFragment.visibility == View.VISIBLE) {
|
||||
searchListFragment.visibility = View.VISIBLE
|
||||
filtrateFragment.visibility = View.GONE
|
||||
titleName.text = currentTitleName
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
R.id.searchLayout -> {
|
||||
resetSearch()
|
||||
}
|
||||
R.id.filtrateLayout -> {
|
||||
if (searchListFragment.visibility == View.VISIBLE && filtrateFragment.visibility == View.GONE) {
|
||||
searchListFragment.visibility = View.GONE
|
||||
filtrateFragment.visibility = View.VISIBLE
|
||||
titleName.text = "搜索"
|
||||
} else {
|
||||
searchListFragment.visibility = View.VISIBLE
|
||||
filtrateFragment.visibility = View.GONE
|
||||
titleName.text = currentTitleName
|
||||
}
|
||||
}
|
||||
R.id.isGroup -> {
|
||||
Common.singleSelect(this, "分组类型", isGroupArr, isGroupStatus) { position, item ->
|
||||
val jsonObject = item as JSONObject
|
||||
val name = jsonObject.getString("name")
|
||||
val code = jsonObject.getString("code")
|
||||
isGroup.text = name
|
||||
isGroupStatus = code
|
||||
}
|
||||
}
|
||||
R.id.agentCode -> {
|
||||
Common.singleSelect(this, "代理", viewModel.agentCodeList, agentCodeValue) { _, item ->
|
||||
val jsonObject = item as JSONObject
|
||||
val name = jsonObject.getString("name")
|
||||
val code = jsonObject.getString("code")
|
||||
agentCode.text = name
|
||||
agentCodeValue = code
|
||||
}
|
||||
}
|
||||
R.id.submit -> {
|
||||
//筛选页隐藏
|
||||
searchListFragment.visibility = View.VISIBLE
|
||||
filtrateFragment.visibility = View.GONE
|
||||
titleName.text = currentTitleName
|
||||
//搜索
|
||||
resetSearch()
|
||||
}
|
||||
R.id.reset -> {
|
||||
resetFun()
|
||||
}
|
||||
else -> {
|
||||
Toast.makeText(this, "未找到对应操作", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 搜索
|
||||
*/
|
||||
private fun searchFun() {
|
||||
viewModel.search(
|
||||
pageSize,
|
||||
currentPage,
|
||||
carrier.text.toString(),
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
fdep.text.toString(),
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",//isCangDanStatus
|
||||
wayNo.text.toString(),
|
||||
isGroupStatus,
|
||||
agentCodeValue,
|
||||
location.text.toString()
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置数据,搜索
|
||||
*/
|
||||
private fun resetSearch() {
|
||||
//recyclerView 清除所有数据数据
|
||||
refreshLayout.setNoMoreData(false)
|
||||
adapter.notifyItemRangeRemoved(0, collectList.size)
|
||||
collectList.clear()
|
||||
currentPage = 1
|
||||
searchFun()
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置筛选条件
|
||||
*/
|
||||
private fun resetFun() {
|
||||
currentPage = 1
|
||||
wayNo.setText("")
|
||||
agentCode.text = ""
|
||||
agentCodeValue = ""
|
||||
carrier.setText("")
|
||||
location.setText("")
|
||||
|
||||
fdep.setText("")
|
||||
isGroup.text = ""
|
||||
isGroupStatus = ""
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package com.lukouguoji.gjj.activity
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.core.widget.NestedScrollView
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.alibaba.android.arouter.facade.annotation.Autowired
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.lukouguoji.gjj.R
|
||||
import com.lukouguoji.gjj.adapt.GjjWareHouseInfoListAdapter
|
||||
import com.lukouguoji.gjj.model.GjjWareHouseInfo
|
||||
import com.lukouguoji.gjj.viewModel.GjjWareHouseInfoViewModel
|
||||
import com.lukouguoji.module_base.BaseActivity
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_GJJ_WARE_HOUSE_INFO)
|
||||
class GjjWareHouseInfoActivity : BaseActivity(), View.OnClickListener {
|
||||
private lateinit var viewModel: GjjWareHouseInfoViewModel
|
||||
|
||||
private lateinit var scrollView: NestedScrollView
|
||||
private lateinit var gncQueryInfoList: RecyclerView
|
||||
private lateinit var adapter: GjjWareHouseInfoListAdapter
|
||||
private val queryInfoAdapterList = arrayListOf<GjjWareHouseInfo>()
|
||||
|
||||
@JvmField
|
||||
@Autowired
|
||||
var id: Int = -9999
|
||||
|
||||
private fun initView() {
|
||||
viewModel = ViewModelProvider(this).get(GjjWareHouseInfoViewModel::class.java)
|
||||
|
||||
scrollView = findViewById(R.id.scrollView)
|
||||
|
||||
val layoutManager = GridLayoutManager(this, 2)
|
||||
adapter = GjjWareHouseInfoListAdapter(this, queryInfoAdapterList)
|
||||
gncQueryInfoList = findViewById(R.id.gncQueryInfoList)
|
||||
gncQueryInfoList.adapter = adapter
|
||||
gncQueryInfoList.layoutManager = layoutManager
|
||||
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_gjj_ware_house_info)
|
||||
setBackArrow("仓库管理详情")
|
||||
initView()
|
||||
|
||||
viewModel.queryInfoByIdWareHouse(id)
|
||||
viewModel.queryInfoByIdWareHouseObserver.observe(this) {
|
||||
val status = it.getString("status")
|
||||
if (Constant.Result.succ == status) {
|
||||
viewModel.wayBillInfo = it.getJSONObject("data")
|
||||
//运单号、
|
||||
adapter.append(GjjWareHouseInfo(1, "运单号", viewModel.wayBillInfo.getString("wbNo") ?: ""))
|
||||
// 件数、
|
||||
adapter.append(GjjWareHouseInfo(1, "件数", viewModel.wayBillInfo.getString("pc") ?: ""))
|
||||
// 重量、
|
||||
adapter.append(GjjWareHouseInfo(1, "重量", "${viewModel.wayBillInfo.getDoubleValue("weight")} KG"))
|
||||
// 品名、
|
||||
adapter.append(GjjWareHouseInfo(1, "品名(英)", viewModel.wayBillInfo.getString("goods") ?: ""))
|
||||
// 特码、
|
||||
adapter.append(GjjWareHouseInfo(1, "特码", viewModel.wayBillInfo.getString("spCode") ?: ""))
|
||||
// 代理人、
|
||||
adapter.append(GjjWareHouseInfo(1, "代理人", viewModel.wayBillInfo.getString("agentName") ?: ""))
|
||||
// 承运人、
|
||||
adapter.append(GjjWareHouseInfo(1, "承运人", viewModel.wayBillInfo.getString("carrier") ?: ""))
|
||||
//始发港、
|
||||
adapter.append(GjjWareHouseInfo(1, "目的港", viewModel.wayBillInfo.getString("dest") ?: ""))
|
||||
// 航班、
|
||||
adapter.append(GjjWareHouseInfo(1, "航班", viewModel.wayBillInfo.getString("flight") ?: ""))
|
||||
// 库位
|
||||
// adapter.append(GjjWareHouseInfo(1, "库位", viewModel.wayBillInfo.getString("location") ?: ""))
|
||||
// 运单类型、
|
||||
adapter.append(GjjWareHouseInfo(1, "运单类型", viewModel.wayBillInfo.getString("awbType") ?: ""))
|
||||
// 业务类型、
|
||||
adapter.append(GjjWareHouseInfo(1, "业务类型", viewModel.wayBillInfo.getString("businessType") ?: ""))
|
||||
// 包装类型
|
||||
adapter.append(GjjWareHouseInfo(1, "包装类型", viewModel.wayBillInfo.getString("packageName") ?: ""))
|
||||
// 状态、
|
||||
// adapter.append(GjjWareHouseInfo(1, "状态", viewModel.wayBillInfo.getString("ref") ?: ""))
|
||||
// 入库时间
|
||||
adapter.append(GjjWareHouseInfo(1, "入库时间", viewModel.wayBillInfo.getString("opDate") ?: ""))
|
||||
|
||||
} else {
|
||||
//无数据
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
v?.let {
|
||||
when (it.id) {
|
||||
else -> {
|
||||
Toast.makeText(this, "未找到对应操作", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user