request = NoHttp.createStringRequest(Contans.IP + Contans.REAL_TIME_PD);
- if(spinnerSon.getSelectedItem()!=null&&(!TextUtils.isEmpty(spinnerSon.getSelectedItem().toString()))){
+ if (spinnerSon.getSelectedItem() != null && (!TextUtils.isEmpty(spinnerSon.getSelectedItem().toString()))) {
request.add("UDBINNUM", spinnerSon.getSelectedItem().toString());
- }else{
+ } else {
request.add("UDBINNUM", "");
}
request.add("ITEMNUM", UiUtlis.getText(etXmh));
@@ -663,6 +660,21 @@ public class HjpdActivity extends BaseActivity implements RealTimeKcpdAdapter.Ca
* 1K103
* 1K101-034
* IT16159
+ *
+ * 1K101
+ * 1K101-043
+ * IT63867
+ *
+ * 1K102
+ * 1K101-013
+ * IT62209
+ * IT62210
+ * IT62211
+ * IT60669
+ *
+ * 1K103
+ * 1K101-034
+ * IT16159
*/
/**
diff --git a/app/src/main/java/com/rehome/zhdcoa/ui/activity/RealTimeKcpdHistoryActivity.kt b/app/src/main/java/com/rehome/zhdcoa/ui/activity/RealTimeKcpdHistoryActivity.kt
new file mode 100644
index 0000000..ef4d0d7
--- /dev/null
+++ b/app/src/main/java/com/rehome/zhdcoa/ui/activity/RealTimeKcpdHistoryActivity.kt
@@ -0,0 +1,289 @@
+package com.rehome.zhdcoa.ui.activity
+
+import android.content.Intent
+import android.text.TextUtils
+import android.view.View
+import android.widget.ArrayAdapter
+import androidx.activity.result.ActivityResultLauncher
+import androidx.activity.result.contract.ActivityResultContracts
+import com.rehome.zhdcoa.App
+import com.rehome.zhdcoa.Contans
+import com.rehome.zhdcoa.R
+import com.rehome.zhdcoa.adapter.RealTimeKcpdHistoryAdapter
+import com.rehome.zhdcoa.base.BaseActivityOaToolbarViewBinding
+import com.rehome.zhdcoa.bean.OneLevelShelvesBean
+import com.rehome.zhdcoa.bean.RealTimeKcpdHistoryBean
+import com.rehome.zhdcoa.bean.RealTimeKcpdHistoryItem
+import com.rehome.zhdcoa.bean.TwoLevelShelvesBean
+import com.rehome.zhdcoa.databinding.ActivityRealTimeKcpdHistoryBinding
+import com.rehome.zhdcoa.utils.GsonUtils
+import com.rehome.zhdcoa.utils.HttpListener
+import com.rehome.zhdcoa.utils.NohttpUtils
+import com.rehome.zhdcoa.utils.UiUtlis
+import com.rehome.zhdcoa.weiget.DateTimePickDialog
+import com.yolanda.nohttp.NoHttp
+import com.yolanda.nohttp.RequestMethod
+import com.yolanda.nohttp.rest.Response
+import java.text.SimpleDateFormat
+import java.util.Calendar
+import java.util.function.Consumer
+
+class RealTimeKcpdHistoryActivity : BaseActivityOaToolbarViewBinding() {
+
+ private var datas: MutableList = mutableListOf()
+
+ var spinnerSonList: MutableList = mutableListOf()
+
+ private lateinit var adapter: RealTimeKcpdHistoryAdapter
+ private lateinit var manid: String
+ private lateinit var headView: View
+
+ private lateinit var launcherResultMHJ: ActivityResultLauncher
+ private lateinit var launcherResultZHJ: ActivityResultLauncher
+
+ override fun getViewBinding() = ActivityRealTimeKcpdHistoryBinding.inflate(layoutInflater)
+
+ override fun getToolbar() = binding.toolbarView.toolbar
+
+ override fun initView() {
+ launcherResultMHJ = createActivityResultLauncherMHJ()
+ launcherResultZHJ = createActivityResultLauncherZHJ()
+ initToolbar("实时盘点记录数据", "") {
+
+ }
+ headView = View.inflate(context, R.layout.pdlb_item, null)
+ headView.findViewById(R.id.head).visibility = View.VISIBLE
+ manid = App.getInstance().userInfo.manid
+
+ binding.btnItqz.setOnClickListener(View.OnClickListener {
+ binding.etXmh.setText("IT")
+ })
+
+ binding.btnQuery.setOnClickListener(View.OnClickListener {
+ getListData()
+ })
+
+ binding.tvSys.setOnClickListener(View.OnClickListener {
+ val intentMHJ = Intent(this, MipcaActivityCapture::class.java)
+ launcherResultMHJ.launch(intentMHJ)
+ })
+ binding.tvSyswz.setOnClickListener(View.OnClickListener {
+ val intentZHJ = Intent(this, MipcaActivityCapture::class.java)
+ launcherResultZHJ.launch(intentZHJ)
+ })
+
+ setAdapter()
+ }
+
+ override fun initData() {
+ val calendar = Calendar.getInstance()
+ //设置为前3月
+ //calendar.add(Calendar.MONTH, -3)
+ // 将日期设置为该月的第一天
+ calendar.set(Calendar.DAY_OF_MONTH, 1);
+
+ val calendarEndTime = Calendar.getInstance()
+ //设置为后3月
+ //calendarEndTime.add(Calendar.MONTH, +3)
+ // 将日期设置为该月的最后一天
+ calendarEndTime.set(Calendar.DAY_OF_MONTH, 1);
+ calendarEndTime.add(Calendar.MONTH, 1);
+ calendarEndTime.add(Calendar.DATE, -1);
+
+
+
+ val df = SimpleDateFormat("yyyy-MM-dd")
+ binding.tvSt.text = df.format(calendar.time)
+ binding.tvEt.text = df.format(calendarEndTime.time)
+ binding.tvSt.setOnClickListener(View.OnClickListener {
+ val dialog = DateTimePickDialog(
+ context
+ ) { outPutDate: String?, outPutDate1: String?, outPutDate2: String? ->
+ binding.tvSt.text = outPutDate1
+ getListData()
+ }
+ dialog.show()
+ })
+ binding.tvEt.setOnClickListener(View.OnClickListener {
+ val dialog = DateTimePickDialog(
+ context
+ ) { outPutDate: String?, outPutDate1: String?, outPutDate2: String? ->
+ binding.tvEt.text = outPutDate1
+ getListData()
+ }
+ dialog.show()
+ })
+ getListData()
+ }
+
+ //创建一个ActivityResultLauncher
+ private fun createActivityResultLauncherMHJ(): ActivityResultLauncher {
+ //kotlin写法
+ return registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
+ val resultIntent = it.data
+ val resultCode = it.resultCode
+ if (resultCode == RESULT_OK) {
+ val resultText = resultIntent?.getStringExtra("result") ?: ""
+ binding.etHgtm.setText(resultText)
+ if (!TextUtils.isEmpty(resultText)) {
+ getSpinnerParentData(resultText)
+ }
+ }
+ }
+ }
+
+ //创建一个ActivityResultLauncher
+ private fun createActivityResultLauncherZHJ(): ActivityResultLauncher {
+ //kotlin写法
+ return registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
+ val resultIntent = it.data
+ val resultCode = it.resultCode
+ if (resultCode == RESULT_OK) {
+ val resultText = resultIntent?.getStringExtra("result") ?: ""
+ binding.etXmh.setText(resultText)
+ }
+ }
+ }
+
+ private fun getListData() {
+ val url: String = Contans.IP + Contans.REAL_TIME_PD_HISTORY_LIST
+ val request = NoHttp.createStringRequest(url, RequestMethod.GET)
+ request.set("TIMES",binding.tvSt.text.toString().trim())
+ request.set("TIMEE",binding.tvEt.text.toString().trim())
+ if(!TextUtils.isEmpty(binding.etHgtm.text)){
+ request.set("BINNUM",binding.etHgtm.text.toString().trim())
+ }else{
+ request.set("BINNUM","")
+ }
+ if(binding.spinnerSon.selectedItem!=null){
+ if(!TextUtils.isEmpty(binding.spinnerSon.selectedItem.toString())){
+ request.set("UDBINNUM",binding.spinnerSon.selectedItem.toString())
+ }else{
+ request.set("UDBINNUM","")
+ }
+ }else{
+ request.set("UDBINNUM","")
+ }
+
+ if(!TextUtils.isEmpty(binding.etXmh.text)){
+ request.set("ITEMNUM",binding.etXmh.text.toString().trim())
+ }else{
+ request.set("ITEMNUM","")
+ }
+
+ NohttpUtils.getInstance().add(this, 0, request, object : HttpListener {
+ override fun onSucceed(what: Int, response: Response?) {
+ if(response!=null){
+ val result= response.get()
+ showLog(result)
+ val bean = GsonUtils.GsonToBean(result, RealTimeKcpdHistoryBean::class.java)
+ if(bean.flag){
+ datas.clear()
+ datas.addAll(bean.Datas)
+ adapter.notifyDataSetChanged()
+ showLog("size:"+bean.Datas.count())
+ }else{
+ datas.clear()
+ adapter.notifyDataSetChanged()
+ }
+ }
+ }
+
+ override fun onFailed(what: Int, response: Response?) {
+
+ }
+
+ }, true, true, "正在加载数据....")
+ }
+
+ private fun setAdapter() {
+ adapter = RealTimeKcpdHistoryAdapter(context, datas)
+ binding.lv.addHeaderView(headView, null, false)
+ binding.lv.adapter = adapter
+ }
+
+ //获取母货架
+ private fun getSpinnerParentData(qccode: String) {
+ val url = Contans.IP + Contans.GET_SPINNER_PARENT_UDBIN_URL
+ val request = NoHttp.createStringRequest(url, RequestMethod.GET)
+ request.add("QCCODE", qccode)
+ NohttpUtils.getInstance()
+ .add(this, 2, request, object : HttpListener {
+
+ override fun onSucceed(what: Int, response: Response?) {
+ if (what == 2) {
+ val result = response?.get()
+ showLog(result?:"")
+ val oneLevelShelvesBean = GsonUtils.GsonToBean(
+ result,
+ OneLevelShelvesBean::class.java
+ )
+ if (oneLevelShelvesBean != null) {
+ if (oneLevelShelvesBean.isFlag && oneLevelShelvesBean.datas != null && oneLevelShelvesBean.datas.size > 0) {
+ val BINNUM = oneLevelShelvesBean.datas[0].binnum
+ getSpinnerSonData(BINNUM)
+ } else {
+ showToast("查询不到子货架号,请确认母货架号是否正确")
+ }
+ }
+ }
+ }
+
+ override fun onFailed(what: Int, response: Response?) {
+ showLog("错误" + what + "==" + response?.get())
+ }
+ }, true, true, UiUtlis.getString(context, R.string.loading))
+ }
+
+ //获取子货架
+ private fun getSpinnerSonData(binnum: String) {
+ val url = Contans.IP + Contans.GET_SPINNER_SON_UDBIN_URL
+ val request = NoHttp.createStringRequest(url, RequestMethod.GET)
+ request.add("BINNUM", binnum)
+ NohttpUtils.getInstance()
+ .add(this, 3, request, object : HttpListener {
+
+ override fun onSucceed(what: Int, response: Response?) {
+ if (what == 3) {
+ val result = response?.get()
+ showLog(result?:"")
+ val twoLevelShelvesBean = GsonUtils.GsonToBean(
+ result,
+ TwoLevelShelvesBean::class.java
+ )
+ if (twoLevelShelvesBean != null) {
+ if (twoLevelShelvesBean.isFlag && twoLevelShelvesBean.datas != null && twoLevelShelvesBean.datas.size > 0) {
+ spinnerSonList.clear()
+ spinnerSonList.addAll(twoLevelShelvesBean.datas)
+
+ // 在我们的这个位置的话创建我们的数组
+ //val arrayModel = mu(spinnerSonList.size)
+ val listText = mutableListOf()
+ for (item in spinnerSonList) {
+ listText.add(
+ item.text
+ )
+ }
+ //listText.toArray(arrayModel)
+ val arrayModel = listText.toTypedArray()
+
+ // 然后的话创建一个我们的一个数组适配器并且的话这个数组适配器使我们的字符串类型的
+ val adapter = ArrayAdapter(
+ context,
+ android.R.layout.simple_spinner_item,
+ arrayModel
+ )
+ // 设置我们的数组下拉时的选项的样式
+ adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
+ binding.spinnerSon.adapter = adapter
+ }
+ }
+ }
+ }
+
+ override fun onFailed(what: Int, response: Response?) {
+ showLog("错误" + what + "==" + response?.get())
+ }
+ }, true, true, UiUtlis.getString(context, R.string.loading))
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_real_time_kcpd_history.xml b/app/src/main/res/layout/activity_real_time_kcpd_history.xml
new file mode 100644
index 0000000..f4f5c8e
--- /dev/null
+++ b/app/src/main/res/layout/activity_real_time_kcpd_history.xml
@@ -0,0 +1,176 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/adapter_real_time_kcpd_history.xml b/app/src/main/res/layout/adapter_real_time_kcpd_history.xml
new file mode 100644
index 0000000..5cbdf14
--- /dev/null
+++ b/app/src/main/res/layout/adapter_real_time_kcpd_history.xml
@@ -0,0 +1,189 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+