فهرست منبع

1、委托单数据显示出来了

ProGo 4 سال پیش
والد
کامیت
8388aa8009

+ 2 - 1
RMA/app/src/main/java/cn/muchinfo/rma/business/future/FutureManager.kt

@@ -129,7 +129,7 @@ class FutureManager {
             type = "1",
             callback = object : ResponseCallback<BaseResult<List<FutureEntrustData>>>(){
                 override fun onResponse(response: BaseResult<List<FutureEntrustData>>?, id: Int) {
-                    GlobalDataCollection.instance?.futureEntrustData = response?.data as ArrayList<FutureEntrustData>?
+                    GlobalDataCollection.instance?.futureHisEntrustData = response?.data as ArrayList<FutureEntrustData>?
                     responseBack(true, response?.data, null)
                 }
 
@@ -184,6 +184,7 @@ class FutureManager {
             type = "1",
             callback = object : ResponseCallback<BaseResult<List<FutureEntrustData>>>(){
                 override fun onResponse(response: BaseResult<List<FutureEntrustData>>?, id: Int) {
+                    GlobalDataCollection.instance?.futureEntrustData = response?.data as ArrayList<FutureEntrustData>?
                     responseBack(true, response?.data, null)
                 }
 

+ 16 - 0
RMA/app/src/main/java/cn/muchinfo/rma/global/BaseGlobalData.java

@@ -79,6 +79,7 @@ public class BaseGlobalData {
     private ArrayList<FutureDetailsData> tradePositionList;
 
     private ArrayList<FutureEntrustData> futureEntrustData;
+    private ArrayList<FutureEntrustData> futureHisEntrustData;
 
 
     public ArrayList<FutureDetailsData> getTradePositionList() {
@@ -186,4 +187,19 @@ public class BaseGlobalData {
     public void setFutureEntrustData(ArrayList<FutureEntrustData> futureEntrustData) {
         this.futureEntrustData = futureEntrustData;
     }
+
+    /**
+     * 历史委托单
+     * @return
+     */
+    public ArrayList<FutureEntrustData> getFutureHisEntrustData() {
+        if (futureHisEntrustData == null) {
+            futureHisEntrustData = new ArrayList<>();
+        }
+        return futureHisEntrustData;
+    }
+
+    public void setFutureHisEntrustData(ArrayList<FutureEntrustData> futureHisEntrustData) {
+        this.futureHisEntrustData = futureHisEntrustData;
+    }
 }

+ 1 - 1
RMA/app/src/main/java/cn/muchinfo/rma/global/data/futureOrders/FutureEntrustData.kt

@@ -4,7 +4,7 @@ package cn.muchinfo.rma.global.data.futureOrders
  * 委托单
  */
 data class FutureEntrustData(
-    var accountid: Int = 0, // 账户ID
+    var accountid: Long = 0, // 账户ID
     var buyorsell: Int = 0, // 买卖 - 0:买 1:卖
     var channelbuildtype: Int = 0, // 开平标志 - 0:无 1:建仓 2:平仓
     var channelinnerorderstatus: Int = 0, // 委托状态 - 1:委托请求 2:冻结成功 3:委托失败 4:委托部成部失败 5:委托成功 6:全部撤销 7:部成部撤 8:部成部撤部失败 9:全部成交

+ 12 - 12
RMA/app/src/main/java/cn/muchinfo/rma/view/base/future/entrusts/EntrustChildFragment.kt

@@ -4,31 +4,24 @@ import android.os.Bundle
 import android.view.LayoutInflater
 import android.view.View
 import android.view.ViewGroup
-import androidx.lifecycle.MutableLiveData
-import androidx.recyclerview.widget.LinearLayoutManager
 import androidx.recyclerview.widget.RecyclerView
 import cn.muchinfo.rma.R
-import cn.muchinfo.rma.business.future.FutureManager
-import cn.muchinfo.rma.global.GlobalDataCollection
 import cn.muchinfo.rma.global.data.futureOrders.FutureEntrustData
 import cn.muchinfo.rma.lifecycle.bindOptional
 import cn.muchinfo.rma.view.autoWidget.*
 import cn.muchinfo.rma.view.base.BaseFragment
-import com.blankj.utilcode.util.ToastUtils
-import mtp.polymer.com.autowidget.utils.TaskUiModel
 import org.jetbrains.anko.linearLayout
 import org.jetbrains.anko.matchParent
 import org.jetbrains.anko.support.v4.UI
-import java.util.ArrayList
 
 /**
  * 今日委托和今日可撤
  */
-class EntrustChildFragment(type: String) : BaseFragment<EntrustChildViewModel>() {
-    private var type: String? = type
+class EntrustChildFragment(type: EntrustFragment.EntrustType) : BaseFragment<EntrustChildViewModel>() {
+    private var type: EntrustFragment.EntrustType? = type
 
     companion object {
-        fun getInstance(type: String) = EntrustChildFragment(type)
+        fun getInstance(type: EntrustFragment.EntrustType) = EntrustChildFragment(type)
     }
 
     private lateinit var swipeToLayout: SwipeToLoadLayout
@@ -65,12 +58,19 @@ class EntrustChildFragment(type: String) : BaseFragment<EntrustChildViewModel>()
             }
 
             // 有数据来了,就通知刷新
-            viewModel.entrustLiveData.bindOptional(context!!) {
-                idEntrustList?.adapter?.notifyDataSetChanged()
+            viewModel.entrustLiveData.bindOptional(context!!) { data ->
+
+                (idEntrustList?.adapter as EntrustChildViewModel.EntrustAdapter).update(data as ArrayList<FutureEntrustData>?)
+                if (swipeToLayout.getIsRefreshing()) {
+                    swipeToLayout.finishRefresh()
+                }
             }
             // 没有数据,就显示无数据
             viewModel.noDataLiveData.bindOptional(context!!) {
                 statusLayout.showEmpty()
+                if (swipeToLayout.getIsRefreshing()) {
+                    swipeToLayout.finishRefresh()
+                }
             }
 
         }.view

+ 35 - 15
RMA/app/src/main/java/cn/muchinfo/rma/view/base/future/entrusts/EntrustChildViewModel.kt

@@ -13,14 +13,16 @@ import cn.muchinfo.rma.global.GlobalDataCollection
 import cn.muchinfo.rma.global.data.futureOrders.FutureEntrustData
 import cn.muchinfo.rma.view.base.BaseViewModel
 import cn.muchinfo.rma.view.base.future.interfaces.OnItemClickListener
-import com.blankj.utilcode.util.LogUtils
-import mtp.polymer.com.autowidget.utils.TaskUiModel
 import org.jetbrains.anko.backgroundColor
+import java.text.SimpleDateFormat
+import java.util.*
+import kotlin.collections.ArrayList
 
 /**
  * 今日委托和今日可撤model
  */
 class EntrustChildViewModel : BaseViewModel() {
+    private var type: EntrustFragment.EntrustType? = EntrustFragment.EntrustType.TODAY_CANCEL_TYPE // 默认进入可撤
 
     val entrustLiveData: MutableLiveData<List<FutureEntrustData>> = MutableLiveData() // 加载状态控制
     val noDataLiveData: MutableLiveData<Boolean> = MutableLiveData() // 如果没有数据
@@ -33,20 +35,20 @@ class EntrustChildViewModel : BaseViewModel() {
     /**
      * 获取配置器。
      */
-    fun getAdapter(): RecyclerView.Adapter<HoldAdapter.EntrustHolder> {
-        return HoldAdapter(context)
+    fun getAdapter(): RecyclerView.Adapter<EntrustAdapter.EntrustHolder> {
+        return EntrustAdapter(context)
     }
 
     /**     * 通用的适配器。
      */
-    inner class HoldAdapter(context: Context?) : RecyclerView.Adapter<HoldAdapter.EntrustHolder>() {
+    inner class EntrustAdapter(context: Context?) : RecyclerView.Adapter<EntrustAdapter.EntrustHolder>() {
         private var list: ArrayList<FutureEntrustData>? = null
         private var inflater: LayoutInflater? = null
         private var context: Context? = null
         private var selectedColor: Int = 0
 
         init {
-            this.list = list
+            this.list = GlobalDataCollection.instance?.futureHisEntrustData
             this.inflater = LayoutInflater.from(context)
             this.context = context
             selectedColor = context?.getColor(R.color.p_select_bg_color)!!
@@ -56,6 +58,11 @@ class EntrustChildViewModel : BaseViewModel() {
             return list?.size ?: 0
         }
 
+        fun update(list: ArrayList<FutureEntrustData>?) {
+            this.list = list
+            notifyDataSetChanged()
+        }
+
         inner class EntrustHolder(itemView: View?) : RecyclerView.ViewHolder(itemView!!) {
             var idGoodsName = itemView?.findViewById<TextView>(R.id.id_goods_name)
             var idStatus = itemView?.findViewById<TextView>(R.id.id_status)
@@ -75,8 +82,8 @@ class EntrustChildViewModel : BaseViewModel() {
 
             entrust.idGoodsName?.text = list?.get(position)?.goodsname
 //            entrust.idStatus?.text = list?.get(position)?.status
-//            entrust.idEntrustType?.text = list?.get(position)?.entrustType
-            entrust.idDate?.text = list?.get(position)?.ordertime
+            entrust.idEntrustType?.text = getType(list?.get(position)!!)
+            entrust.idDate?.text = getTime(list?.get(position)!!)
             entrust.idEntrustPrice?.text = list?.get(position)?.orderprice.toString()
             entrust.idEntrustNum?.text = list?.get(position)?.orderqty.toString()
 //            entrust.idEntrustPl?.text = list?.get(position)?.pl.toString()
@@ -115,6 +122,18 @@ class EntrustChildViewModel : BaseViewModel() {
 
         }
 
+        fun getType(_data: FutureEntrustData): String {
+            val buyOrSell = _data.buyorsell
+            val channelBuildType = _data.channelbuildtype
+            return ""
+        }
+
+        fun getTime(_data: FutureEntrustData): String {
+            val sdf = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss+08:00", Locale.CHINA)
+            val sdf1 = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA)
+            return sdf1.format(sdf.parse(_data.ordertime)!!)
+        }
+
         override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): EntrustHolder {
             return EntrustHolder(inflater?.inflate(R.layout.entrust_item, parent, false))
         }
@@ -150,13 +169,14 @@ class EntrustChildViewModel : BaseViewModel() {
             }
         }
 
-        FutureManager().queryErmcpHisEntrustDetails { _isSuccess, _respData, _ ->
-            if (_isSuccess && !_respData!!.isNullOrEmpty()) { // 查询成功
-                entrustLiveData.value = _respData
-            } else { // 查询失败
-                noDataLiveData.value = true
-            }
-        }
+//        FutureManager().queryErmcpHisEntrustDetails { _isSuccess, _respData, _ ->
+//            if (_isSuccess && !_respData!!.isNullOrEmpty()) { // 查询成功
+//                list = _respData as ArrayList<FutureEntrustData>?
+//                entrustLiveData.value = _respData
+//            } else { // 查询失败
+//                noDataLiveData.value = true
+//            }
+//        }
     }
 
     //endregion

+ 7 - 2
RMA/app/src/main/java/cn/muchinfo/rma/view/base/future/entrusts/EntrustFragment.kt

@@ -23,6 +23,11 @@ import com.qmuiteam.qmui.widget.tab.QMUITabSegment
  */
 class EntrustFragment: BaseFragment<EntrustViewModel>() {
 
+    enum class EntrustType {
+        TODAY_CANCEL_TYPE, // 今日可撤
+        TODAY_TYPE // 今日委托
+    }
+
     companion object {
         fun getInstance() = EntrustFragment()
     }
@@ -33,8 +38,8 @@ class EntrustFragment: BaseFragment<EntrustViewModel>() {
         MyApplication.getInstance()?.resources?.getString(R.string.str_entrust_today) // 今日委托
     )
     private val tabFragments: Array<Fragment> = arrayOf(
-        EntrustChildFragment.getInstance(MyApplication.getInstance()?.resources?.getString(R.string.str_can_cancel_today)!!),
-        EntrustChildFragment.getInstance(MyApplication.getInstance()?.resources?.getString(R.string.str_entrust_today)!!)
+        EntrustChildFragment.getInstance(EntrustType.TODAY_CANCEL_TYPE),
+        EntrustChildFragment.getInstance(EntrustType.TODAY_TYPE)
     )
 //endregion
 

+ 10 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/future/enums/ChannelBuildType.kt

@@ -0,0 +1,10 @@
+package cn.muchinfo.rma.view.base.future.enums
+
+/**
+ * 开平标志 - 0:无 1:建仓 2:平仓
+ */
+enum class ChannelBuildType {
+    NONE, // 无
+    OPEN, // 建仓
+    CLOSE, // 平仓
+}

+ 16 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/future/enums/ChannelInnerOrderStatus.kt

@@ -0,0 +1,16 @@
+package cn.muchinfo.rma.view.base.future.enums
+
+/**
+ * 委托状态 - 1:委托请求 2:冻结成功 3:委托失败 4:委托部成部失败 5:委托成功 6:全部撤销 7:部成部撤 8:部成部撤部失败 9:全部成交
+ */
+enum class ChannelInnerOrderStatus {
+    ENTRUST_REQUEST, // 委托请求
+    FREEZING_SUCCESS, // 冻结成功
+    ENTRUST_UN_SUCCESS, // 委托失败
+    ENTRUST_PART_DEAL, // 委托部成部失败
+    ENTRUST_SUCCESS, // 委托成功
+    ENTRUST_CANCEL_ALL, // 全部撤销
+    ENTRUST_PART_IN_OUT, // 部成部撤
+    ENTRUST_PART_IN_OUT_UN_SUCCESS, //部成部撤部失败
+    ENTRUST_ALL_DEAL, // 全部成交
+}

+ 10 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/future/enums/ChannelOperateType.kt

@@ -0,0 +1,10 @@
+package cn.muchinfo.rma.view.base.future.enums
+
+/**
+ * 操作类型 - 1:正常委托 2:斩仓委托 3:强平委托
+ */
+enum class ChannelOperateType {
+    ENTRUST_NORMAL, // 正常委托
+    CUTTING_POSITIONS, // 斩仓委托
+    FORCE_CLOSING_COMMISSION, // 强平委托
+}

+ 13 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/future/enums/CloseType.kt

@@ -0,0 +1,13 @@
+package cn.muchinfo.rma.view.base.future.enums
+
+import cn.muchinfo.rma.R
+import cn.muchinfo.rma.view.MyApplication
+
+/**
+ * 平仓方式 - 0:无 1:平今 2:平昨
+ */
+enum class CloseType(val index: Int, val aliasName: String) {
+    NONE(1, MyApplication.getInstance()?.resources?.getString(R.string.str_none)!!), // 无
+    CLOSE_TODAY(2, MyApplication.getInstance()?.resources?.getString(R.string.str_close_today)!!), // 平今
+    CLOSE_YESTERDAY(3, MyApplication.getInstance()?.resources?.getString(R.string.str_close_yesterday)!!), // 平昨
+}

+ 9 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/future/enums/PriceMode.kt

@@ -0,0 +1,9 @@
+package cn.muchinfo.rma.view.base.future.enums
+
+/**
+ * 取价方式 - 1:市价 2: 限价
+ */
+enum class PriceMode {
+    MARKET_PRICE, // 市价
+    LIMIT_PRICE, // 限价
+}

+ 3 - 0
RMA/app/src/main/res/values/strings.xml

@@ -103,5 +103,8 @@
     <string name="str_am">金额</string>
     <string name="str_cancel">撤单</string>
     <string name="str_chart">图表</string>
+    <string name="str_none">无</string>
+    <string name="str_close_today">平今</string>
+    <string name="str_close_yesterday">平昨</string>
 
 </resources>