Jelajahi Sumber

解决部分bug:各种问题

yu.jie 3 tahun lalu
induk
melakukan
1b8460804f

+ 2 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/MainActivity.kt

@@ -475,6 +475,8 @@ class MainActivity : BaseActivity<MainViewModel>() {
     fun onMessageEvent(messageEvent: MessageEvent) {
         if (messageEvent.messageType == EventConstent.FID_MoneyChangedNtf) {//服务给的资金账号变化通知
             viewModel.getTaAccounts()
+        }else if (messageEvent.messageType == EventConstent.FID_OrderDealedNtf){
+            viewModel.queryContractTradePosition("2")
         }
     }
 }

+ 34 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/MainViewModel.kt

@@ -400,4 +400,38 @@ class MainViewModel : BaseViewModel() {
             }
         }
     }
+
+    /**
+     * 查询合约汇总
+     * 1 是商品订单 2 是掉期订单
+     */
+    fun queryContractTradePosition(type : String){
+        val params = mutableMapOf<String,String>().apply {
+            put("accountID", GlobalDataCollection.instance?.accountId?.toString() ?: "")
+            if (type == "2"){
+                put("tradeMode","46")
+            }
+        }
+        MyApplication.getInstance()?.contractGoodsManager?.queryContractTradePosition(params = params){ isSuccess, respData, error ->
+            if (isSuccess){
+                resetPositionDataList(respData ?: arrayListOf())
+            }
+        }
+    }
+
+    //根据合约汇总单去插入响应的关联商品
+    fun resetPositionDataList(list : List<ContractTradePositionData>){
+        val newList = arrayListOf<ContractTradePositionData>()
+        val quoteGoodsListDataArrayList = GlobalDataCollection.instance?.quoteGoodsListDataArrayList
+        list.forEach {data ->
+            val quoteGoodsListData = quoteGoodsListDataArrayList?.find { data.goodsid.toString() == it.goodsid }
+            if (quoteGoodsListData?.refgoodscode.isNullOrEmpty().not()){
+                newList.add(data.copy(refgoodsId = quoteGoodsListData?.refgoodsid?.toInt() ?: 0,refgoodsCode = quoteGoodsListData?.refgoodscode))
+            }else{
+                newList.add(data)
+            }
+        }
+//        positionDataList.postValue(newList)
+//        queryPositionQuoteDay(Constant.position_tag,newList)
+    }
 }

+ 10 - 2
RMA/app/src/main/java/cn/muchinfo/rma/view/base/hnstmain/HnstMainFragment.kt

@@ -70,6 +70,7 @@ class HnstMainFragment : BaseFragment<HnstMainViewmodel>() {
         super.onResume()
         viewModel.getUserAccount()
         viewModel.resetAccountData()
+        viewModel.queryContractTradePosition("2")
     }
 
     override fun onDestroy() {
@@ -86,6 +87,8 @@ class HnstMainFragment : BaseFragment<HnstMainViewmodel>() {
         } else if (messageEvent.messageType == EventConstent.FID_MoneyChangedNtf) {//资金账号变化通知
             viewModel.getUserAccount()
             viewModel.resetAccountData()
+        } else if (messageEvent.messageType == EventConstent.FID_OrderDealedNtf){
+            viewModel.queryContractTradePosition("2")
         }
     }
 
@@ -100,11 +103,16 @@ class HnstMainFragment : BaseFragment<HnstMainViewmodel>() {
             if (goodsInfo?.goodsid.isNullOrEmpty().not()) {
                 viewModel.getUserAccount()
                 // resolve bug  #3429
-                viewModel.resetAccountData()
+                // 减少频率
+                if(TimeUtils.getNowMills() - requestTime > 3500){
+                    viewModel.resetAccountData()
+                    requestTime = TimeUtils.getNowMills()
+                }
+
             }
         }
     }
-
+    private var requestTime = TimeUtils.getNowMills()
     @SuppressLint("MissingPermission", "RtlHardcoded", "SetTextI18n")
     override fun onCreateView(
         inflater: LayoutInflater,

+ 35 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/hnstmain/HnstMainViewmodel.kt

@@ -124,4 +124,39 @@ class HnstMainViewmodel : BaseViewModel(){
         }
     }
 
+    /**
+     * 查询合约汇总
+     * 1 是商品订单 2 是掉期订单
+     */
+    fun queryContractTradePosition(type : String){
+        val params = mutableMapOf<String,String>().apply {
+            put("accountID", GlobalDataCollection.instance?.accountId?.toString() ?: "")
+            if (type == "2"){
+                put("tradeMode","46")
+            }
+        }
+        MyApplication.getInstance()?.contractGoodsManager?.queryContractTradePosition(params = params){ isSuccess, respData, error ->
+            if (isSuccess){
+                resetPositionDataList(respData ?: arrayListOf())
+            }
+        }
+    }
+
+    //根据合约汇总单去插入响应的关联商品
+    fun resetPositionDataList(list : List<ContractTradePositionData>){
+        val newList = arrayListOf<ContractTradePositionData>()
+        val quoteGoodsListDataArrayList = GlobalDataCollection.instance?.quoteGoodsListDataArrayList
+        list.forEach {data ->
+            val quoteGoodsListData = quoteGoodsListDataArrayList?.find { data.goodsid.toString() == it.goodsid }
+            if (quoteGoodsListData?.refgoodscode.isNullOrEmpty().not()){
+                newList.add(data.copy(refgoodsId = quoteGoodsListData?.refgoodsid?.toInt() ?: 0,refgoodsCode = quoteGoodsListData?.refgoodscode))
+            }else{
+                newList.add(data)
+            }
+        }
+//        positionDataList.postValue(newList)
+//        queryPositionQuoteDay(Constant.position_tag,newList)
+    }
+
+
 }

+ 8 - 2
RMA/app/src/main/java/cn/muchinfo/rma/view/base/yrdzpurchase/swaps/listed/SwapsListedActivity.kt

@@ -33,6 +33,7 @@ import cn.muchinfo.rma.view.eventbus.EventConstent
 import cn.muchinfo.rma.view.eventbus.MessageEvent
 import cn.muchinfo.rma.view.eventbus.QuoteMessageEvent
 import com.blankj.utilcode.util.ConvertUtils
+import com.blankj.utilcode.util.TimeUtils
 import com.blankj.utilcode.util.ToastUtils
 import com.qmuiteam.qmui.util.QMUIDisplayHelper
 import com.qmuiteam.qmui.widget.tab.QMUITabIndicator
@@ -142,11 +143,16 @@ class SwapsListedActivity : BaseActivity<SwapsListedViewModel>() {
             if (goodsInfo?.goodsid.isNullOrEmpty().not()) {
                 // resolve bug  #3429
                 viewModel.resetAccountData()
-                viewModel.getTaAccounts()
+
+                if(TimeUtils.getNowMills() - requestTime > 3500){
+                    viewModel.getTaAccounts()
+                    requestTime = TimeUtils.getNowMills()
+                }
+
             }
         }
     }
-
+    private var requestTime = TimeUtils.getNowMills()
     override fun onDestroy() {
         super.onDestroy()
         viewModel.removeSubscriptQuote(thisTag)