|
|
@@ -0,0 +1,1215 @@
|
|
|
+package cn.muchinfo.rma.view.base.tjmd
|
|
|
+
|
|
|
+import androidx.lifecycle.MutableLiveData
|
|
|
+import cn.muchinfo.rma.global.GlobalDataCollection
|
|
|
+import cn.muchinfo.rma.global.data.*
|
|
|
+import cn.muchinfo.rma.global.data.account.loginQeruy.GoodsInfo
|
|
|
+import cn.muchinfo.rma.global.database.DataBase
|
|
|
+import cn.muchinfo.rma.global.isBlankString
|
|
|
+import cn.muchinfo.rma.global.toPercentage
|
|
|
+import cn.muchinfo.rma.global.toShowTime3
|
|
|
+import cn.muchinfo.rma.netManage.base.InteractiveException
|
|
|
+import cn.muchinfo.rma.protobuf.protoclasses.WarehouseTradeMI1
|
|
|
+import cn.muchinfo.rma.view.MyApplication
|
|
|
+import cn.muchinfo.rma.view.base.BaseViewModel
|
|
|
+import cn.muchinfo.rma.view.base.warehousereceipt.dialog.ListedData
|
|
|
+import com.blankj.utilcode.util.LogUtils
|
|
|
+import kotlinx.coroutines.GlobalScope
|
|
|
+import kotlinx.coroutines.launch
|
|
|
+import mtp.polymer.com.autowidget.dialog.SelectData
|
|
|
+import mtp.polymer.com.autowidget.utils.TaskUiModel
|
|
|
+
|
|
|
+/**
|
|
|
+ * 天津麦顿的市场fragmentviewmodel
|
|
|
+ */
|
|
|
+class TjmdMarketViewModel : BaseViewModel(){
|
|
|
+
|
|
|
+ //-----------------------------------仓单贸易相关-----------------------------------------------
|
|
|
+ //选择的履约模版数据
|
|
|
+ val selectPerformanceStepData : MutableLiveData<PermancePlanTmpData> = MutableLiveData()
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 加载状态控制
|
|
|
+ */
|
|
|
+ val loadingDialogStatus: MutableLiveData<TaskUiModel> = MutableLiveData()
|
|
|
+
|
|
|
+ //用于控制挂牌弹窗的消失 当值设置为true时,控制dialog隐藏
|
|
|
+ val controlDialogDisappear : MutableLiveData<Boolean> = MutableLiveData<Boolean>().apply { value = false }
|
|
|
+
|
|
|
+ //一口价报价牌数据
|
|
|
+ val onePrcieDataList : MutableLiveData<List<OrderQuoteData>> = MutableLiveData()
|
|
|
+
|
|
|
+ //浮动价报价牌数据
|
|
|
+ val floatProceDataList : MutableLiveData<List<OrderQuoteData>> = MutableLiveData()
|
|
|
+
|
|
|
+ //品种品类筛选框列表
|
|
|
+ val ftDeliveryGoodsDataList : MutableLiveData<List<FtDeliveryGoodsData>> = MutableLiveData()
|
|
|
+
|
|
|
+ //选择的商品
|
|
|
+ val selectWrFtWrstandardData : MutableLiveData<WrFtWrstandard> = MutableLiveData()
|
|
|
+
|
|
|
+ //要素定义项
|
|
|
+ val WrStandardFactoryItemDataList : MutableLiveData<List<FtDeliveryGoodsDataListData>> = MutableLiveData()
|
|
|
+
|
|
|
+ //选择的商品组列表
|
|
|
+ val goodsGroupList : MutableLiveData<List<SelectData>> = MutableLiveData()
|
|
|
+ //选择的商品组实体
|
|
|
+ val selectGoodsGroupData : MutableLiveData<SelectData> = MutableLiveData()
|
|
|
+
|
|
|
+ //选择的商品列表
|
|
|
+ val goodsInfoList : MutableLiveData<List<SelectData>> = MutableLiveData()
|
|
|
+ //选择的期货合约实体
|
|
|
+ val selectGoodsInfoData : MutableLiveData<SelectData> = MutableLiveData()
|
|
|
+ /**
|
|
|
+ * 当前选择的资金账户
|
|
|
+ */
|
|
|
+ val usedAccountData : MutableLiveData<AccountData> = MutableLiveData()
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 交易页面的当前商品的盘面信息
|
|
|
+ */
|
|
|
+ val quoteDayData: MutableLiveData<QuoteDayData> = MutableLiveData()
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 库存明细
|
|
|
+ */
|
|
|
+ val detailsWarehouseContentDataList: MutableLiveData<List<HoldLBData>> = MutableLiveData()
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 贸易圈卖挂牌单据数据
|
|
|
+ */
|
|
|
+ val circleSellContentDataList: MutableLiveData<List<OrderQuoteMyqData>> = MutableLiveData()
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 贸易圈买挂牌单据数据
|
|
|
+ */
|
|
|
+ val circleBuyContentDataList: MutableLiveData<List<OrderQuoteMyqData>> = MutableLiveData()
|
|
|
+
|
|
|
+
|
|
|
+ //-----------------贸易圈买挂牌-----------------
|
|
|
+ /**
|
|
|
+ * 查询贸易圈买挂牌
|
|
|
+ */
|
|
|
+ fun queryOrderBuyQuoteMyq(wrstandardid : String = "",dgitemname : String = ""){
|
|
|
+ val params = mutableMapOf<String,String>().apply {
|
|
|
+ put("userid", GlobalDataCollection.instance?.loginRsp?.userID.toString())
|
|
|
+ put("buyorsell","0")
|
|
|
+ put("haswr","1")
|
|
|
+ if (wrstandardid.isNotEmpty()){
|
|
|
+ put("wrstandardid",wrstandardid)
|
|
|
+ }
|
|
|
+ if (dgitemname.isNotEmpty()){
|
|
|
+ put("dgitemname",dgitemname)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ MyApplication.getInstance()?.quoteManager?.queryOrderQuoteMyq(params = params){isSuccess, respData, error ->
|
|
|
+ if (isSuccess){
|
|
|
+ circleBuyContentDataList.postValue(getcircleContentDataListRightData(respData ?: arrayListOf()))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询贸易圈买挂牌-筛选挂牌时
|
|
|
+ */
|
|
|
+ fun queryOrderBuyQuoteMyqByListed(wrstandardid : String = "",dgitemname : String = ""){
|
|
|
+ val params = mutableMapOf<String,String>().apply {
|
|
|
+ put("userid", GlobalDataCollection.instance?.loginRsp?.userID.toString())
|
|
|
+ put("buyorsell","0")
|
|
|
+ put("haswr","1")
|
|
|
+ if (wrstandardid.isNotEmpty()){
|
|
|
+ put("wrstandardid",wrstandardid)
|
|
|
+ }
|
|
|
+ if (dgitemname.isNotEmpty()){
|
|
|
+ put("dgitemname",dgitemname)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ MyApplication.getInstance()?.quoteManager?.queryOrderQuoteMyq(params = params){isSuccess, respData, error ->
|
|
|
+ if (isSuccess){
|
|
|
+ if (respData.isNullOrEmpty().not()){
|
|
|
+ circleDataByListed.postValue(respData?.get(0))
|
|
|
+ }else{
|
|
|
+ noWRFactorTypeIdDataForListed.postValue(ListedData(DeliveryGoodsID = getDeliveryGoodsIDByWRStandardID(wrstandardid),WrFtWrstandard = getWrFtWrstandardByWRStandardID(wrstandardid),FactoryItemsList = WrStandardFactoryItemDataList.value ?: arrayListOf()))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //-----------------贸易圈卖挂牌-----------------
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询贸易圈卖挂牌-筛选挂牌
|
|
|
+ */
|
|
|
+ fun queryOrderSellQuoteMyqByListed(wrstandardid : String = "",dgitemname : String = ""){
|
|
|
+ val params = mutableMapOf<String,String>().apply {
|
|
|
+ put("userid", GlobalDataCollection.instance?.loginRsp?.userID.toString())
|
|
|
+ put("buyorsell","1")
|
|
|
+ put("haswr","1")
|
|
|
+ if (wrstandardid.isNotEmpty()){
|
|
|
+ put("wrstandardid",wrstandardid)
|
|
|
+ }
|
|
|
+ if (dgitemname.isNotEmpty()){
|
|
|
+ put("dgitemname",dgitemname)
|
|
|
+ }
|
|
|
+ put("deliverygoodsid",getDeliveryGoodsIDByWRStandardID(wrstandardid))
|
|
|
+ }
|
|
|
+ MyApplication.getInstance()?.quoteManager?.queryOrderQuoteMyq(params = params){isSuccess, respData, error ->
|
|
|
+ if (isSuccess){
|
|
|
+ if (respData.isNullOrEmpty().not()){
|
|
|
+ circleDataByListed.postValue(respData?.get(0))
|
|
|
+ }else{
|
|
|
+ noWRFactorTypeIdDataForListed.postValue(ListedData(DeliveryGoodsID = getDeliveryGoodsIDByWRStandardID(wrstandardid),WrFtWrstandard = getWrFtWrstandardByWRStandardID(wrstandardid),FactoryItemsList = WrStandardFactoryItemDataList.value ?: arrayListOf()))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询贸易圈卖挂牌
|
|
|
+ */
|
|
|
+ fun queryOrderSellQuoteMyq(wrstandardid : String = "",dgitemname : String = ""){
|
|
|
+ val params = mutableMapOf<String,String>().apply {
|
|
|
+ put("userid", GlobalDataCollection.instance?.loginRsp?.userID.toString())
|
|
|
+ put("buyorsell","1")
|
|
|
+ put("haswr","1")
|
|
|
+ if (wrstandardid.isNotEmpty()){
|
|
|
+ put("wrstandardid",wrstandardid)
|
|
|
+ }
|
|
|
+ if (dgitemname.isNotEmpty()){
|
|
|
+ put("dgitemname",dgitemname)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ MyApplication.getInstance()?.quoteManager?.queryOrderQuoteMyq(params = params){isSuccess, respData, error ->
|
|
|
+ if (isSuccess){
|
|
|
+ circleSellContentDataList.postValue(getcircleContentDataListRightData(respData ?: arrayListOf()))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 贸易圈卖挂牌组装右侧数据 "挂牌方","价格","数量","议价","整单","挂牌有效期","履约保证金","履约方式","仓库"
|
|
|
+ */
|
|
|
+ fun getcircleContentDataListRightData(respData: List<OrderQuoteMyqData>) : List<OrderQuoteMyqData>{
|
|
|
+ val newList = arrayListOf<OrderQuoteMyqData>()
|
|
|
+ respData.forEach {
|
|
|
+ val newRightData = arrayListOf<String>()
|
|
|
+ //履约方式
|
|
|
+ newRightData.add(it.templatename?.isBlankString() ?: "-")
|
|
|
+ //价格
|
|
|
+ newRightData.add(it.fixedprice ?: "-")
|
|
|
+ //数量
|
|
|
+ newRightData.add(it.orderqty ?: "-")
|
|
|
+ //议价
|
|
|
+ newRightData.add(if (it.canbargain == "0"){"否"}else{"是"})
|
|
|
+ //整单
|
|
|
+ newRightData.add(if (it.canpart == "0"){"是"}else{"否"})
|
|
|
+ //挂牌有效期
|
|
|
+ newRightData.add(it.validtime?.toShowTime3() ?: "-")
|
|
|
+ //履约保证金
|
|
|
+ newRightData.add(it.marginvalue?.toPercentage() ?: "-")
|
|
|
+ //挂牌方
|
|
|
+ newRightData.add(it.userid + it.username ?: "-")
|
|
|
+ //仓库
|
|
|
+ newRightData.add(it.warehousename ?: "-")
|
|
|
+ val newData = it.copy(rightData = newRightData)
|
|
|
+ newList.add(newData)
|
|
|
+ }
|
|
|
+ return newList
|
|
|
+ }
|
|
|
+
|
|
|
+ //重新赋值资金账户
|
|
|
+ fun resetAccountData(){
|
|
|
+ val accountDataList = GlobalDataCollection.instance?.accountDataList
|
|
|
+ if (accountDataList.isNullOrEmpty().not()) {
|
|
|
+ val accountData = GlobalDataCollection.instance?.accountData
|
|
|
+ accountData?.clearData()
|
|
|
+ accountData?.setNormalData()
|
|
|
+ usedAccountData.postValue(accountData)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //重新赋值资金账户
|
|
|
+ fun resetAccountDataBySelect(data : AccountData){
|
|
|
+ data.clearData()
|
|
|
+ data.setNormalData()
|
|
|
+ usedAccountData.postValue(data)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 持仓挂牌
|
|
|
+ * @param LadingBillId Long
|
|
|
+ * @param TradeDate String
|
|
|
+ * @param SubNum Long
|
|
|
+ * @param WRFactorTypeId Long
|
|
|
+ * @param UserID Int
|
|
|
+ * @param AccountID Long
|
|
|
+ * @param IsSpecified Int
|
|
|
+ * @param MatchAccIDs List<Long>
|
|
|
+ * @param OrderQty Long
|
|
|
+ * @param DeliveryGoodsID Int
|
|
|
+ * @param WRPriceType Int
|
|
|
+ * @param FixedPrice Double
|
|
|
+ * @param WRTradeGoods WRGoodsInfo
|
|
|
+ * @param PriceFactor Double
|
|
|
+ * @param PriceMove Double
|
|
|
+ * @param TimevalidType Int
|
|
|
+ * @param FirstRatio Double
|
|
|
+ * @param PerformanceTemplateID Long
|
|
|
+ * @param BuyOrSell Int
|
|
|
+ * @param PriceDisplayMode Int
|
|
|
+ * @param CanBargain Int
|
|
|
+ * @param Attachment1 String
|
|
|
+ * @param Attachment2 String
|
|
|
+ * @param Remark String
|
|
|
+ * @param ApplyID Long
|
|
|
+ * @param CanPart Int
|
|
|
+ * @param HasWr Int
|
|
|
+ * @param WRStandardID Int
|
|
|
+ * @param isSuccess Function1<[@kotlin.ParameterName] Boolean, Unit>
|
|
|
+ */
|
|
|
+ fun requeryWRListingOrderReq(
|
|
|
+ LadingBillId: Long = 0,//提单id(wrholdlb的LadingBillId字段),卖的时候填写
|
|
|
+ TradeDate: String = "",//交易日
|
|
|
+ SubNum: Long = 0,// 提单子单号(wrholdlb的SubNum字段),卖的时候填写
|
|
|
+ WRFactorTypeId: Long = 0,//仓单要素ID(wrholdlb的WRFactorTypeId字段),卖的时候填写
|
|
|
+ UserID: Int = 0,//用户ID
|
|
|
+ AccountID: Long = 0,//资金账号
|
|
|
+ IsSpecified: Int = 0,//是否指定对手 0 不指定 1 指定
|
|
|
+ OrderQty: Long = 0,//委托数量(可挂部分数据量)
|
|
|
+ DeliveryGoodsID: Int = 0,//交割商品商品ID
|
|
|
+ WRPriceType: Int = 0,//价格方式
|
|
|
+ FixedPrice: Double = 0.0,//固定价格
|
|
|
+ WRTradeGoods: WarehouseTradeMI1.WRGoodsInfo,//仓单贸易商品配置集合(浮动价时填写)
|
|
|
+ PriceFactor: Double = 0.0,//价格系数(浮动价时填写) - [挂牌]
|
|
|
+ PriceMove: Double = 0.0,//升贴水(浮动价时填写)
|
|
|
+ TimevalidType: Int = 0,//时间有效类型
|
|
|
+ FirstRatio: Double = 0.0,//首付比例
|
|
|
+ PerformanceTemplateID: Long = 0,//履约计划模板ID
|
|
|
+ BuyOrSell: Int = 0,// 买卖方向
|
|
|
+ PriceDisplayMode: Int = 0,//浮动价显示方式
|
|
|
+ CanBargain: Int = 0,//挂牌是否可议价0:不可1:可-摘牌是否议价
|
|
|
+ Attachment1: String = "",//附件1
|
|
|
+ Attachment2: String = "",//附件2
|
|
|
+ Remark: String = "",//备注
|
|
|
+ ApplyID: Long = 0,//申请ID
|
|
|
+ CanPart: Int = 0,//是否允许部份摘牌0:不允许;1:允许
|
|
|
+ MatchAccIDsString : List<String> = arrayListOf(),//仓单贸易对手用户ID集合(指定对手时填写)
|
|
|
+ DeliveryMonth : String = "",//交收月
|
|
|
+ HasWr: Int = 0,//是否有仓单-0:没有仓单 1:有仓单
|
|
|
+ DelistMinQty : Long = 0,//起摘数量
|
|
|
+ WRStandardID: Int = 0,//现货品种ID
|
|
|
+ MarginFlag : Int = 0,//挂牌是否指定保证金 0:否 1:是
|
|
|
+ MarginAlgorithm : Int = 0,//指定保证金方式 1:比率 2:固定
|
|
|
+ MarginValue : Double = 0.0,//指定保证金设置值
|
|
|
+ AllFriendsFlag : Int = 0,//是否全好友可见 0:否 1:是
|
|
|
+ FactoryItems : List<WarehouseTradeMI1.DGFactoryItems>,//要素类型明细集合(没有仓单要素ID填写)
|
|
|
+ isSuccess: (isCompleted: Boolean) -> Unit
|
|
|
+ ){
|
|
|
+ loadingDialogStatus.value = TaskUiModel.inFlight()
|
|
|
+ GlobalScope.launch {
|
|
|
+ MyApplication.getInstance()?.warehouseManager?.HdWROrderReq(
|
|
|
+ MarginFlag = MarginFlag,
|
|
|
+ MarginAlgorithm = MarginAlgorithm,
|
|
|
+ MarginValue = MarginValue,
|
|
|
+ AllFriendsFlag = AllFriendsFlag,
|
|
|
+ LadingBillId = LadingBillId,
|
|
|
+ TradeDate = TradeDate,
|
|
|
+ AccountID = AccountID,
|
|
|
+ OrderQty = OrderQty,
|
|
|
+ IsSpecified = IsSpecified,
|
|
|
+ SubNum = SubNum,
|
|
|
+ DeliveryMonth = DeliveryMonth,
|
|
|
+ DeliveryGoodsID = DeliveryGoodsID,
|
|
|
+ WRFactorTypeId = WRFactorTypeId,
|
|
|
+ UserID = UserID,
|
|
|
+ MatchAccIDsString = MatchAccIDsString,
|
|
|
+ WRPriceType = WRPriceType,
|
|
|
+ FixedPrice = FixedPrice,
|
|
|
+ WRTradeGoods = WRTradeGoods,
|
|
|
+ PriceFactor = PriceFactor,
|
|
|
+ PriceMove = PriceMove,
|
|
|
+ DelistMinQty = DelistMinQty,
|
|
|
+ TimevalidType = TimevalidType,
|
|
|
+ FirstRatio = FirstRatio,
|
|
|
+ PerformanceTemplateID = PerformanceTemplateID,
|
|
|
+ BuyOrSell = BuyOrSell,
|
|
|
+ CanPart = CanPart,
|
|
|
+ HasWr = HasWr,
|
|
|
+ WRStandardID = WRStandardID,
|
|
|
+ PriceDisplayMode = PriceDisplayMode,
|
|
|
+ CanBargain = CanBargain,
|
|
|
+ Attachment1 = Attachment1,
|
|
|
+ Attachment2 = Attachment2,
|
|
|
+ Remark = Remark,
|
|
|
+ ApplyID = ApplyID,
|
|
|
+ FactoryItems = FactoryItems
|
|
|
+ ) { isCompleted, err ->
|
|
|
+ if (isCompleted) {
|
|
|
+ loadingDialogStatus.postValue(TaskUiModel.success(msg = "请求成功"))
|
|
|
+ isSuccess(true)
|
|
|
+ } else {
|
|
|
+ loadingDialogStatus.postValue(
|
|
|
+ TaskUiModel.failed(
|
|
|
+ InteractiveException(
|
|
|
+ errorMessage = err?.message!!
|
|
|
+ )
|
|
|
+ )
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 查询现货明细
|
|
|
+ */
|
|
|
+ fun querydetailsWarehouseWrPosition(data : ListedData){
|
|
|
+ val params = mutableMapOf<String,String>().apply {
|
|
|
+ put("accountid", GlobalDataCollection.instance?.accountId.toString())
|
|
|
+ put("warehouseid",data.getWarehouseid())
|
|
|
+ put("deliverygoodsid", data.DeliveryGoodsID ?: "")
|
|
|
+ put("wrstandardid",data.WrFtWrstandard?.wrstandardid ?: "")
|
|
|
+ }
|
|
|
+ MyApplication.getInstance()?.warehouseManager?.queryHoldLB(params = params){isSuccess, respData, error ->
|
|
|
+ if (isSuccess){
|
|
|
+ detailsWarehouseContentDataList.postValue(respData)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取选择的仓库ID和选择的要素类型
|
|
|
+ //type 为1是仓库 type 为2是其他要素
|
|
|
+ fun getSelectWarehouseOrFactoryid(type : String) : String{
|
|
|
+ var returnString = ""
|
|
|
+ WrStandardFactoryItemDataList.value?.forEach {
|
|
|
+ if (type == "1"){//取仓库id
|
|
|
+ if (it.dgfactoryitemtypeid == "1"){
|
|
|
+ it.itemlst?.forEach { data ->
|
|
|
+ if (data.isSelect == 1){
|
|
|
+ returnString = data.warehouseid ?: ""
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if (it.dgfactoryitemtypeid != "1"){
|
|
|
+ it.itemlst?.forEach { data ->
|
|
|
+ if (data.isSelect == 1){
|
|
|
+ returnString = returnString + "," + data.dgfactoryitemvalue
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return returnString
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取选择的仓库ID和选择的要素类型 是否全部选择
|
|
|
+ fun getSelectBooble() : Boolean{
|
|
|
+ var selectNum = 0
|
|
|
+ var returnBooble = false
|
|
|
+ WrStandardFactoryItemDataList.value?.forEach {
|
|
|
+ it.itemlst?.forEach { data ->
|
|
|
+ if (data.isSelect == 1){
|
|
|
+ selectNum = selectNum.plus(1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ returnBooble = selectNum >= WrStandardFactoryItemDataList.value?.size ?: 0
|
|
|
+ return returnBooble
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //根据选择的商品组组织商品选择列表
|
|
|
+ fun setGoodsInfoList(goodsgroupid : String){
|
|
|
+ val newGoodsInfoList = arrayListOf<SelectData>()
|
|
|
+ val goodsInfoList1 = DataBase.getInstance().goodsInfoDao().all
|
|
|
+ goodsInfoList1?.forEach {
|
|
|
+ if (it?.goodsgroupid.toString() == goodsgroupid){
|
|
|
+ newGoodsInfoList.add(SelectData(id = it?.goodsid.toString(),value = it?.goodsname.toString(),goodsCode = it.goodscode ?: ""))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ goodsInfoList.postValue(newGoodsInfoList)
|
|
|
+ }
|
|
|
+
|
|
|
+ //针对期货合约的 设置商品组选择的列表
|
|
|
+ fun setGoodsGroupAndGoodsInfoList(){
|
|
|
+ val newgoodsGroupList = arrayListOf<SelectData>()
|
|
|
+ val marketData = GlobalDataCollection.instance?.loginQueryData?.market?.find { it.trademode == 99 }//找出trademode 为99的市场
|
|
|
+ GlobalDataCollection.instance?.loginQueryData?.goodsgroups?.forEach {
|
|
|
+ if (it.marketid == marketData?.marketid){
|
|
|
+ newgoodsGroupList.add(SelectData(id = it.marketid.toString(),value = it.goodsgroupname,goodsgroupid = it.goodsgroupid.toString()))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ goodsGroupList.postValue(newgoodsGroupList)
|
|
|
+ }
|
|
|
+
|
|
|
+ //重置品种品类筛选框列表
|
|
|
+ fun resetFtDeliveryGoodsDataList(){
|
|
|
+ ftDeliveryGoodsDataList.postValue(ftDeliveryGoodsDataList.value)
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 针对仓库,要素等的item点击
|
|
|
+ */
|
|
|
+ fun setOnRightItemClick(
|
|
|
+ dgfactoryitemtypeid : String,
|
|
|
+ dgfactoryitemid : String
|
|
|
+ ){
|
|
|
+ val newWrStandardFactoryItemDataList = arrayListOf<FtDeliveryGoodsDataListData>()
|
|
|
+ WrStandardFactoryItemDataList.value?.forEach {
|
|
|
+ val sonItemList = arrayListOf<WrStandardFactoryItem>()
|
|
|
+ if (it.dgfactoryitemtypeid == dgfactoryitemtypeid){
|
|
|
+ it.itemlst?.forEach { data ->
|
|
|
+ if (dgfactoryitemid == data.dgfactoryitemid){
|
|
|
+ sonItemList.add(data.copy(isSelect = 1))
|
|
|
+ }else{
|
|
|
+ sonItemList.add(data.copy(isSelect = 0))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ newWrStandardFactoryItemDataList.add(it.copy(itemlst = sonItemList))
|
|
|
+ }else{
|
|
|
+ newWrStandardFactoryItemDataList.add(it)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ WrStandardFactoryItemDataList.postValue(newWrStandardFactoryItemDataList)
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 对左侧商品列表进行选择后的刷新
|
|
|
+ */
|
|
|
+ fun setOnItemClick(deliverygoodsid : String,wrstandardid : String){
|
|
|
+ val newftDeliveryGoodsDataList = arrayListOf<FtDeliveryGoodsData>()
|
|
|
+ ftDeliveryGoodsDataList.value?.forEach {
|
|
|
+ val sonItemList = arrayListOf<WrFtWrstandard>()
|
|
|
+ if (it.deliverygoodsid == deliverygoodsid){
|
|
|
+ it.wdlst?.forEach { data ->
|
|
|
+ if (wrstandardid == data.wrstandardid){
|
|
|
+ sonItemList.add(data.copy(isSelect = 1))
|
|
|
+ }else{
|
|
|
+ sonItemList.add(data.copy(isSelect = 0))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ newftDeliveryGoodsDataList.add(it.copy(wdlst = sonItemList))
|
|
|
+ }else{
|
|
|
+ it.wdlst?.forEach { data ->
|
|
|
+ sonItemList.add(data.copy(isSelect = 0))
|
|
|
+ }
|
|
|
+ newftDeliveryGoodsDataList.add(it.copy(wdlst = sonItemList))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ftDeliveryGoodsDataList.postValue(newftDeliveryGoodsDataList)
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询品种品类筛选框列表
|
|
|
+ */
|
|
|
+ fun queryWrStandardFactoryItem(wrstandardid : String){
|
|
|
+ val params = mutableMapOf<String,String>().apply {
|
|
|
+ put("wrstandardid",wrstandardid)
|
|
|
+ }
|
|
|
+ MyApplication.getInstance()?.quoteManager?.queryWrStandardFactoryItem(params = params){isSuccess, respData, error ->
|
|
|
+ if (isSuccess){
|
|
|
+ WrStandardFactoryItemDataList.postValue(respData)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询品种品类筛选框列表
|
|
|
+ */
|
|
|
+ fun queryFtDeliveryGoods(){
|
|
|
+ val params = mutableMapOf<String,String>().apply {
|
|
|
+ put("userid", GlobalDataCollection.instance?.loginRsp?.userID.toString())
|
|
|
+ }
|
|
|
+ MyApplication.getInstance()?.quoteManager?.queryFtDeliveryGoods(params = params){isSuccess, respData, error ->
|
|
|
+ if (isSuccess){
|
|
|
+ ftDeliveryGoodsDataList.postValue(respData)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 对做完筛选或者挂牌操作后针对已选择的项进行重置
|
|
|
+ */
|
|
|
+ fun resetSelectContent(){
|
|
|
+ selectWrFtWrstandardData.postValue(WrFtWrstandard())
|
|
|
+ WrStandardFactoryItemDataList.postValue(arrayListOf())
|
|
|
+ selectGoodsGroupData.postValue(SelectData(id = "",value = ""))
|
|
|
+ selectGoodsInfoData.postValue(SelectData(id = "",value = ""))
|
|
|
+ }
|
|
|
+
|
|
|
+ //贸易圈左侧菜单挂牌信息
|
|
|
+ val circleDataByListed : MutableLiveData<OrderQuoteMyqData> = MutableLiveData()
|
|
|
+
|
|
|
+ //左侧菜单所有的挂牌信息
|
|
|
+ val orderQuoteDataByListed : MutableLiveData<OrderQuoteData> = MutableLiveData()
|
|
|
+
|
|
|
+ //点击挂牌后若找不到相应的信息则组装无仓单要素id的挂牌信息
|
|
|
+ val noWRFactorTypeIdDataForListed : MutableLiveData<ListedData> = MutableLiveData()
|
|
|
+
|
|
|
+ //通过选择的wrstandardid查找相对应的DeliveryGoodsID
|
|
|
+ fun getDeliveryGoodsIDByWRStandardID(wrstandardid : String = "") : String{
|
|
|
+ var deliverygoodsid = ""
|
|
|
+ ftDeliveryGoodsDataList.value?.forEach {
|
|
|
+ it.wdlst?.forEach { data ->
|
|
|
+ if (data.wrstandardid == wrstandardid){
|
|
|
+ deliverygoodsid = it.deliverygoodsid ?: ""
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return deliverygoodsid
|
|
|
+ }
|
|
|
+
|
|
|
+ //通过选择的wrstandardid查找相对应的实体
|
|
|
+ fun getWrFtWrstandardByWRStandardID(wrstandardid : String = "") : WrFtWrstandard{
|
|
|
+ var WrFtWrstandard = WrFtWrstandard()
|
|
|
+ ftDeliveryGoodsDataList.value?.forEach {
|
|
|
+ it.wdlst?.forEach { data ->
|
|
|
+ if (data.wrstandardid == wrstandardid){
|
|
|
+ WrFtWrstandard = data
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return WrFtWrstandard
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询一口价报价牌用余挂牌时的筛选
|
|
|
+ * wrstandardid 品类id
|
|
|
+ * warehouseid 仓库id(筛选条件)
|
|
|
+ * dgitemname 商品要素项名称模糊匹配, 逗号隔开, 如 产地1,品牌1,规格12mm
|
|
|
+ */
|
|
|
+ fun queryOneOrderQuoteByListed(wrstandardid : String = "",warehouseid : String = "",dgitemname : String = ""){
|
|
|
+ val params = mutableMapOf<String,String>().apply {
|
|
|
+ put("marketid","17201")
|
|
|
+ put("wrpricetype","1")
|
|
|
+ put("haswr","1")
|
|
|
+ if (wrstandardid.isNotEmpty()){
|
|
|
+ put("wrstandardid",wrstandardid)
|
|
|
+ }
|
|
|
+ if (warehouseid.isNotEmpty()){
|
|
|
+ put("warehouseid",warehouseid)
|
|
|
+ }
|
|
|
+ if (dgitemname.isNotEmpty()){
|
|
|
+ put("dgitemname",dgitemname)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ MyApplication.getInstance()?.quoteManager?.queryOrderQuote(params = params){isSuccess, respData, error ->
|
|
|
+ if (isSuccess){
|
|
|
+ if (respData.isNullOrEmpty().not()){
|
|
|
+ orderQuoteDataByListed.postValue(respData?.get(0))
|
|
|
+ }else{
|
|
|
+ noWRFactorTypeIdDataForListed.postValue(ListedData(DeliveryGoodsID = getDeliveryGoodsIDByWRStandardID(wrstandardid),WrFtWrstandard = getWrFtWrstandardByWRStandardID(wrstandardid),FactoryItemsList = WrStandardFactoryItemDataList.value ?: arrayListOf()))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询一口价报价牌
|
|
|
+ * wrstandardid 品类id
|
|
|
+ * warehouseid 仓库id(筛选条件)
|
|
|
+ * dgitemname 商品要素项名称模糊匹配, 逗号隔开, 如 产地1,品牌1,规格12mm
|
|
|
+ */
|
|
|
+ fun queryOneOrderQuote(wrstandardid : String = "",warehouseid : String = "",dgitemname : String = ""){
|
|
|
+ val params = mutableMapOf<String,String>().apply {
|
|
|
+ put("marketid","17201")
|
|
|
+ put("wrpricetype","1")
|
|
|
+ put("haswr","1")
|
|
|
+ if (wrstandardid.isNotEmpty()){
|
|
|
+ put("wrstandardid",wrstandardid)
|
|
|
+ }
|
|
|
+ if (warehouseid.isNotEmpty()){
|
|
|
+ put("warehouseid",warehouseid)
|
|
|
+ }
|
|
|
+ if (dgitemname.isNotEmpty()){
|
|
|
+ put("dgitemname",dgitemname)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ MyApplication.getInstance()?.quoteManager?.queryOrderQuote(params = params){isSuccess, respData, error ->
|
|
|
+ if (isSuccess){
|
|
|
+ onePrcieDataList.postValue(respData)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询浮动价报价牌用于挂牌
|
|
|
+ */
|
|
|
+ fun queryFloatOrderQuoteByListed(wrstandardid : String = "",warehouseid : String = "",dgitemname : String = ""){
|
|
|
+ val params = mutableMapOf<String,String>().apply {
|
|
|
+ put("marketid","17201")
|
|
|
+ put("wrpricetype","2")//价格方式 - 1:固定价 2-浮动价
|
|
|
+ put("haswr","1")//0:仓单预售 1:仓单贸易
|
|
|
+ if (wrstandardid.isNotEmpty()){
|
|
|
+ put("wrstandardid",wrstandardid)
|
|
|
+ }
|
|
|
+ if (warehouseid.isNotEmpty()){
|
|
|
+ put("warehouseid",warehouseid)
|
|
|
+ }
|
|
|
+ if (dgitemname.isNotEmpty()){
|
|
|
+ put("dgitemname",dgitemname)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ MyApplication.getInstance()?.quoteManager?.queryOrderQuote(params = params){isSuccess, respData, error ->
|
|
|
+ if (isSuccess){
|
|
|
+ if (respData.isNullOrEmpty().not()){
|
|
|
+ orderQuoteDataByListed.postValue(respData?.get(0))
|
|
|
+
|
|
|
+ }else{
|
|
|
+ noWRFactorTypeIdDataForListed.postValue(ListedData(goodsId = selectGoodsInfoData.value?.id ?: "",goodsCode = selectGoodsInfoData.value?.goodsCode ?: "",DeliveryGoodsID = getDeliveryGoodsIDByWRStandardID(wrstandardid),WrFtWrstandard = getWrFtWrstandardByWRStandardID(wrstandardid),FactoryItemsList = WrStandardFactoryItemDataList.value ?: arrayListOf()))
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询浮动价报价牌
|
|
|
+ */
|
|
|
+ fun queryFloatOrderQuote(wrstandardid : String = "",warehouseid : String = "",dgitemname : String = ""){
|
|
|
+ val params = mutableMapOf<String,String>().apply {
|
|
|
+ put("marketid","17201")
|
|
|
+ put("wrpricetype","2")//价格方式 - 1:固定价 2-浮动价
|
|
|
+ put("haswr","1")//0:仓单预售 1:仓单贸易
|
|
|
+ if (wrstandardid.isNotEmpty()){
|
|
|
+ put("wrstandardid",wrstandardid)
|
|
|
+ }
|
|
|
+ if (warehouseid.isNotEmpty()){
|
|
|
+ put("warehouseid",warehouseid)
|
|
|
+ }
|
|
|
+ if (dgitemname.isNotEmpty()){
|
|
|
+ put("dgitemname",dgitemname)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ MyApplication.getInstance()?.quoteManager?.queryOrderQuote(params = params){isSuccess, respData, error ->
|
|
|
+ if (isSuccess){
|
|
|
+ floatProceDataList.postValue(respData)
|
|
|
+ //说是不订阅行情,靠轮询10秒查
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //-----------------------------------------仓单预售-----------------------------------------------
|
|
|
+
|
|
|
+ //一口价报价牌数据
|
|
|
+ val ysonePrcieDataList : MutableLiveData<List<OrderQuoteData>> = MutableLiveData()
|
|
|
+
|
|
|
+ //浮动价报价牌数据
|
|
|
+ val ysfloatProceDataList : MutableLiveData<List<OrderQuoteData>> = MutableLiveData()
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 在无仓单预售下的情况下查询是否有相应的预售仓单持仓
|
|
|
+ */
|
|
|
+ val summaryWrPositionDataByDialog : MutableLiveData<HnstWrPositionData> = MutableLiveData()
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 贸易圈卖挂牌单据数据
|
|
|
+ */
|
|
|
+ val yscircleSellContentDataList: MutableLiveData<List<OrderQuoteMyqData>> = MutableLiveData()
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 贸易圈买挂牌单据数据
|
|
|
+ */
|
|
|
+ val yscircleBuyContentDataList: MutableLiveData<List<OrderQuoteMyqData>> = MutableLiveData()
|
|
|
+
|
|
|
+
|
|
|
+ //-----------------贸易圈买挂牌-----------------
|
|
|
+ /**
|
|
|
+ * 查询贸易圈卖挂牌
|
|
|
+ */
|
|
|
+ fun queryysOrderBuyQuoteMyq(wrstandardid : String = "",dgitemname : String = ""){
|
|
|
+ val params = mutableMapOf<String,String>().apply {
|
|
|
+ put("userid",GlobalDataCollection.instance?.loginRsp?.userID.toString())
|
|
|
+ put("buyorsell","0")
|
|
|
+ put("haswr","0")
|
|
|
+ if (wrstandardid.isNotEmpty()){
|
|
|
+ put("wrstandardid",wrstandardid)
|
|
|
+ }
|
|
|
+ if (dgitemname.isNotEmpty()){
|
|
|
+ put("dgitemname",dgitemname)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ MyApplication.getInstance()?.quoteManager?.queryOrderQuoteMyq(params = params){isSuccess, respData, error ->
|
|
|
+ if (isSuccess){
|
|
|
+ yscircleBuyContentDataList.postValue(getyscircleContentDataListRightData(respData ?: arrayListOf()))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询贸易圈买挂牌-筛选挂牌时
|
|
|
+ */
|
|
|
+ fun queryysOrderBuyQuoteMyqByListed(wrstandardid : String = "",dgitemname : String = ""){
|
|
|
+ val params = mutableMapOf<String,String>().apply {
|
|
|
+ put("userid",GlobalDataCollection.instance?.loginRsp?.userID.toString())
|
|
|
+ put("buyorsell","0")
|
|
|
+ put("haswr","0")
|
|
|
+ if (wrstandardid.isNotEmpty()){
|
|
|
+ put("wrstandardid",wrstandardid)
|
|
|
+ }
|
|
|
+ if (dgitemname.isNotEmpty()){
|
|
|
+ put("dgitemname",dgitemname)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ MyApplication.getInstance()?.quoteManager?.queryOrderQuoteMyq(params = params){isSuccess, respData, error ->
|
|
|
+ if (isSuccess){
|
|
|
+ if (respData.isNullOrEmpty().not()){
|
|
|
+ circleDataByListed.postValue(respData?.get(0))
|
|
|
+ }else{
|
|
|
+ noWRFactorTypeIdDataForListed.postValue(ListedData(goodsCode = selectGoodsInfoData.value?.goodsCode,DeliveryGoodsID = getDeliveryGoodsIDByWRStandardID(wrstandardid),WrFtWrstandard = getWrFtWrstandardByWRStandardID(wrstandardid),FactoryItemsList = WrStandardFactoryItemDataList.value ?: arrayListOf()))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //-----------------贸易圈卖挂牌-----------------
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询贸易圈卖挂牌-筛选挂牌
|
|
|
+ */
|
|
|
+ fun queryysOrderSellQuoteMyqByListed(wrstandardid : String = "",dgitemname : String = ""){
|
|
|
+ val params = mutableMapOf<String,String>().apply {
|
|
|
+ put("userid",GlobalDataCollection.instance?.loginRsp?.userID.toString())
|
|
|
+ put("buyorsell","1")
|
|
|
+ put("haswr","0")
|
|
|
+ if (wrstandardid.isNotEmpty()){
|
|
|
+ put("wrstandardid",wrstandardid)
|
|
|
+ }
|
|
|
+ if (dgitemname.isNotEmpty()){
|
|
|
+ put("dgitemname",dgitemname)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ MyApplication.getInstance()?.quoteManager?.queryOrderQuoteMyq(params = params){isSuccess, respData, error ->
|
|
|
+ if (isSuccess){
|
|
|
+ if (respData.isNullOrEmpty().not()){
|
|
|
+ circleDataByListed.postValue(respData?.get(0))
|
|
|
+ }else{
|
|
|
+ noWRFactorTypeIdDataForListed.postValue(ListedData(goodsCode = selectGoodsInfoData.value?.goodsCode,DeliveryGoodsName = getDeliveryGoodsNameByWRStandardID(wrstandardid),DeliveryGoodsID = getDeliveryGoodsIDByWRStandardID(wrstandardid),WrFtWrstandard = getWrFtWrstandardByWRStandardID(wrstandardid),FactoryItemsList = WrStandardFactoryItemDataList.value ?: arrayListOf()))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询贸易圈卖挂牌
|
|
|
+ */
|
|
|
+ fun queryysOrderSellQuoteMyq(wrstandardid : String = "",dgitemname : String = ""){
|
|
|
+ val params = mutableMapOf<String,String>().apply {
|
|
|
+ put("userid",GlobalDataCollection.instance?.loginRsp?.userID.toString())
|
|
|
+ put("buyorsell","1")
|
|
|
+ put("haswr","0")
|
|
|
+ if (wrstandardid.isNotEmpty()){
|
|
|
+ put("wrstandardid",wrstandardid)
|
|
|
+ }
|
|
|
+ if (dgitemname.isNotEmpty()){
|
|
|
+ put("dgitemname",dgitemname)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ MyApplication.getInstance()?.quoteManager?.queryOrderQuoteMyq(params = params){isSuccess, respData, error ->
|
|
|
+ if (isSuccess){
|
|
|
+ yscircleSellContentDataList.postValue(getyscircleContentDataListRightData(respData ?: arrayListOf()))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 贸易圈卖挂牌组装右侧数据 "挂牌方","价格","数量","议价","整单","挂牌有效期","履约保证金","履约方式","仓库"
|
|
|
+ */
|
|
|
+ fun getyscircleContentDataListRightData(respData: List<OrderQuoteMyqData>) : List<OrderQuoteMyqData>{
|
|
|
+ val newList = arrayListOf<OrderQuoteMyqData>()
|
|
|
+ respData.forEach {
|
|
|
+ val newRightData = arrayListOf<String>()
|
|
|
+ //挂牌方
|
|
|
+ newRightData.add(it.userid + it.username ?: "-")
|
|
|
+ //价格
|
|
|
+ newRightData.add(it.fixedprice ?: "-")
|
|
|
+ //数量
|
|
|
+ newRightData.add(it.orderqty ?: "-")
|
|
|
+ //议价
|
|
|
+ newRightData.add(if (it.canbargain == "0"){"否"}else{"是"})
|
|
|
+ //整单
|
|
|
+ newRightData.add(if (it.canpart == "0"){"是"}else{"否"})
|
|
|
+ //挂牌有效期
|
|
|
+ newRightData.add(it.validtime?.toShowTime3() ?: "-")
|
|
|
+ //履约保证金
|
|
|
+ newRightData.add(it.marginvalue?.toPercentage() ?: "-")
|
|
|
+ //履约方式
|
|
|
+ newRightData.add(it.templatename ?: "-")
|
|
|
+ //仓库
|
|
|
+ newRightData.add(it.warehousename ?: "-")
|
|
|
+ val newData = it.copy(rightData = newRightData)
|
|
|
+ newList.add(newData)
|
|
|
+ }
|
|
|
+ return newList
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询相应要素下的预售仓单
|
|
|
+ */
|
|
|
+ fun queryysorderSummaryWrPosition(deliverygoodsid : String = "",warehouseid : String = "",wrstandardid : String = "",dgitemname : String = ""){
|
|
|
+ val params = mutableMapOf<String,String>().apply {
|
|
|
+ put("userid", GlobalDataCollection.instance?.loginRsp?.userID.toString())
|
|
|
+ put("querytype","2")
|
|
|
+ put("haswr","0")
|
|
|
+ put("deliverygoodsid",deliverygoodsid)
|
|
|
+ put("warehouseid",warehouseid)
|
|
|
+ put("wrstandardid",wrstandardid)
|
|
|
+ put("dgitemname",dgitemname)
|
|
|
+ }
|
|
|
+ MyApplication.getInstance()?.warehouseManager?.queryWrPosition(params = params){ isSuccess, respData, error ->
|
|
|
+ if (isSuccess){
|
|
|
+ if (respData?.isNotEmpty() == true){
|
|
|
+ summaryWrPositionDataByDialog.postValue(respData.get(0))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //通过选择的wrstandardid查找相对应的DeliveryGoodsName
|
|
|
+ fun getDeliveryGoodsNameByWRStandardID(wrstandardid : String = "") : String{
|
|
|
+ var deliveryGoodsName = ""
|
|
|
+ ftDeliveryGoodsDataList.value?.forEach {
|
|
|
+ it.wdlst?.forEach { data ->
|
|
|
+ if (data.wrstandardid == wrstandardid){
|
|
|
+ deliveryGoodsName = it.deliverygoodsname ?: ""
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return deliveryGoodsName
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询一口价报价牌筛选
|
|
|
+ */
|
|
|
+ fun queryysOneOrderQuoteByListed(wrstandardid : String = "",warehouseid : String = "",dgitemname : String = "",deliverymonth : String = ""){
|
|
|
+ val params = mutableMapOf<String,String>().apply {
|
|
|
+ put("marketid","17201")
|
|
|
+ put("wrpricetype","1")
|
|
|
+ put("haswr","0")
|
|
|
+ if (wrstandardid.isNotEmpty()){
|
|
|
+ put("wrstandardid",wrstandardid)
|
|
|
+ }
|
|
|
+ if (warehouseid.isNotEmpty()){
|
|
|
+ put("warehouseid",warehouseid)
|
|
|
+ }
|
|
|
+ if (dgitemname.isNotEmpty()){
|
|
|
+ put("dgitemname",dgitemname)
|
|
|
+ }
|
|
|
+ if (deliverymonth.isNotEmpty()){
|
|
|
+ put("deliverymonth",deliverymonth)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ MyApplication.getInstance()?.quoteManager?.queryOrderQuote(params = params){ isSuccess, respData, error ->
|
|
|
+ if (isSuccess){
|
|
|
+ if (respData.isNullOrEmpty().not()){
|
|
|
+ orderQuoteDataByListed.postValue(respData?.get(0))
|
|
|
+ }else{
|
|
|
+ noWRFactorTypeIdDataForListed.postValue(ListedData(DeliveryMonth = deliverymonth,DeliveryGoodsID = getDeliveryGoodsIDByWRStandardID(wrstandardid),WrFtWrstandard = getWrFtWrstandardByWRStandardID(wrstandardid),FactoryItemsList = WrStandardFactoryItemDataList.value ?: arrayListOf()))
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询一口价报价牌
|
|
|
+ */
|
|
|
+ fun queryysOneOrderQuote(wrstandardid : String = "",warehouseid : String = "",dgitemname : String = "",deliverymonth : String = ""){
|
|
|
+ val params = mutableMapOf<String,String>().apply {
|
|
|
+ put("marketid","17201")
|
|
|
+ put("wrpricetype","1")
|
|
|
+ put("haswr","0")
|
|
|
+ if (wrstandardid.isNotEmpty()){
|
|
|
+ put("wrstandardid",wrstandardid)
|
|
|
+ }
|
|
|
+ if (warehouseid.isNotEmpty()){
|
|
|
+ put("warehouseid",warehouseid)
|
|
|
+ }
|
|
|
+ if (dgitemname.isNotEmpty()){
|
|
|
+ put("dgitemname",dgitemname)
|
|
|
+ }
|
|
|
+ if (deliverymonth.isNotEmpty()){
|
|
|
+ put("deliverymonth",deliverymonth)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ MyApplication.getInstance()?.quoteManager?.queryOrderQuote(params = params){ isSuccess, respData, error ->
|
|
|
+ if (isSuccess){
|
|
|
+ ysonePrcieDataList.postValue(respData)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询浮动价报价牌筛选
|
|
|
+ */
|
|
|
+ fun queryysFloatOrderQuoteByListed(wrstandardid : String = "",warehouseid : String = "",dgitemname : String = "",deliverymonth : String = ""){
|
|
|
+ val params = mutableMapOf<String,String>().apply {
|
|
|
+ put("marketid","17201")
|
|
|
+ put("wrpricetype","2")//价格方式 - 1:固定价 2-浮动价
|
|
|
+ put("haswr","0")//0:仓单预售 1:仓单贸易
|
|
|
+ if (wrstandardid.isNotEmpty()){
|
|
|
+ put("wrstandardid",wrstandardid)
|
|
|
+ }
|
|
|
+ if (warehouseid.isNotEmpty()){
|
|
|
+ put("warehouseid",warehouseid)
|
|
|
+ }
|
|
|
+ if (dgitemname.isNotEmpty()){
|
|
|
+ put("dgitemname",dgitemname)
|
|
|
+ }
|
|
|
+ if (deliverymonth.isNotEmpty()){
|
|
|
+ put("deliverymonth",deliverymonth)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ MyApplication.getInstance()?.quoteManager?.queryOrderQuote(params = params){ isSuccess, respData, error ->
|
|
|
+ if (isSuccess){
|
|
|
+ if (respData.isNullOrEmpty().not()){
|
|
|
+ orderQuoteDataByListed.postValue(respData?.get(0))
|
|
|
+
|
|
|
+ }else{
|
|
|
+ noWRFactorTypeIdDataForListed.postValue(ListedData(goodsCode = selectGoodsInfoData.value?.goodsCode,DeliveryMonth = deliverymonth,DeliveryGoodsID = getDeliveryGoodsIDByWRStandardID(wrstandardid),WrFtWrstandard = getWrFtWrstandardByWRStandardID(wrstandardid),FactoryItemsList = WrStandardFactoryItemDataList.value ?: arrayListOf()))
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询浮动价报价牌
|
|
|
+ */
|
|
|
+ fun queryysFloatOrderQuote(wrstandardid : String = "",warehouseid : String = "",dgitemname : String = "",deliverymonth : String = ""){
|
|
|
+ val params = mutableMapOf<String,String>().apply {
|
|
|
+ put("marketid","17201")
|
|
|
+ put("wrpricetype","2")//价格方式 - 1:固定价 2-浮动价
|
|
|
+ put("haswr","0")//0:仓单预售 1:仓单贸易
|
|
|
+ if (wrstandardid.isNotEmpty()){
|
|
|
+ put("wrstandardid",wrstandardid)
|
|
|
+ }
|
|
|
+ if (warehouseid.isNotEmpty()){
|
|
|
+ put("warehouseid",warehouseid)
|
|
|
+ }
|
|
|
+ if (dgitemname.isNotEmpty()){
|
|
|
+ put("dgitemname",dgitemname)
|
|
|
+ }
|
|
|
+ if (deliverymonth.isNotEmpty()){
|
|
|
+ put("deliverymonth",deliverymonth)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ MyApplication.getInstance()?.quoteManager?.queryOrderQuote(params = params){ isSuccess, respData, error ->
|
|
|
+ if (isSuccess){
|
|
|
+ ysfloatProceDataList.postValue(respData)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //------------------------------------------挂牌点选相关--------------------------------------------
|
|
|
+ //挂牌转让数据列表
|
|
|
+ val transferDataList : MutableLiveData<List<GoodsInfo>> = MutableLiveData()
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 初始化列表
|
|
|
+ * @param tag String
|
|
|
+ * @param callback Function2<[@kotlin.ParameterName] Boolean, [@kotlin.ParameterName] Error?, Unit>
|
|
|
+ */
|
|
|
+ fun initData(tag: String,callback: (isCompleted: Boolean, err: Error?) -> Unit){
|
|
|
+ val list = arrayListOf<GoodsInfo>()
|
|
|
+ val allList = DataBase.getInstance().goodsInfoDao().all
|
|
|
+ val deliveryRelationList = GlobalDataCollection.instance?.deliveryRelationDataArrayList
|
|
|
+ allList.forEach {data ->
|
|
|
+ if (data.trademode == 16 && data.goodsstatus == 3){
|
|
|
+ list.add(data)
|
|
|
+// val deliveryRelationData = deliveryRelationList?.find { it?.goodsid == data.goodsid.toString() }
|
|
|
+// if (deliveryRelationData?.goodsid.isNullOrEmpty().not()){
|
|
|
+// if (deliveryRelationData?.deliverytype != "2" && deliveryRelationData?.deliverytype != "4"){////交割模式 - 1:X交割 2:X+P交割 3:X+C交割 4:X+P+C交割 1,3为云融大宗的挂牌转让 2,4为云融大宗的基差点价
|
|
|
+// list.add(data)
|
|
|
+// }
|
|
|
+// }else{
|
|
|
+//
|
|
|
+// }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ transferDataList.postValue(list)
|
|
|
+ if (list.size > 10){
|
|
|
+ queryQuoteDay(tag,0,10,list){isCompleted, err ->
|
|
|
+ callback(isCompleted, err)
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ queryQuoteDay(tag,0,list.size,list){isCompleted, err ->
|
|
|
+ callback(isCompleted, err)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //---------------------------------------掉期商品相关--------------------------------------------
|
|
|
+ //掉期数据列表
|
|
|
+ val swapsDataList : MutableLiveData<List<GoodsInfo>> = MutableLiveData()
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 初始化列表
|
|
|
+ * @param tag String
|
|
|
+ * @param callback Function2<[@kotlin.ParameterName] Boolean, [@kotlin.ParameterName] Error?, Unit>
|
|
|
+ */
|
|
|
+ fun initswapsData(tag: String,callback: (isCompleted: Boolean, err: Error?) -> Unit){
|
|
|
+ val list = arrayListOf<GoodsInfo>()
|
|
|
+ val allList = DataBase.getInstance().goodsInfoDao().all
|
|
|
+ val deliveryRelationList = GlobalDataCollection.instance?.quoteGoodsListDataArrayList
|
|
|
+ //需要知道掉期trademodel
|
|
|
+ allList.forEach {data ->
|
|
|
+ if (data.trademode == 46 && data.goodsstatus == 3){
|
|
|
+ list.add(data)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ swapsDataList.postValue(list)
|
|
|
+ if (list.size > 10){
|
|
|
+ queryQuoteDay(tag,0,10,list){isCompleted, err ->
|
|
|
+ callback(isCompleted, err)
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ queryQuoteDay(tag,0,list.size,list){isCompleted, err ->
|
|
|
+ callback(isCompleted, err)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 请求盘面信息
|
|
|
+ * @param first Int
|
|
|
+ * @param last Int
|
|
|
+ * @param callback Function2<[@kotlin.ParameterName] Boolean, [@kotlin.ParameterName] Error?, Unit>
|
|
|
+ */
|
|
|
+ fun queryQuoteDay(
|
|
|
+ tag: String,
|
|
|
+ first: Int,
|
|
|
+ last: Int,
|
|
|
+ list : List<GoodsInfo> = arrayListOf(),
|
|
|
+ callback: (isCompleted: Boolean, err: Error?) -> Unit
|
|
|
+ ) {
|
|
|
+ val goodsCodes = getgoodsCodes(first, last,list)
|
|
|
+ val params = mutableMapOf<String, String>().apply {
|
|
|
+ put("goodsCodes", goodsCodes)
|
|
|
+ }
|
|
|
+ MyApplication.getInstance()?.futureManager?.queryQuoteDay(params = params) { isSuccess, respData, error ->
|
|
|
+ if (isSuccess) {
|
|
|
+ callback(true, null)
|
|
|
+ } else {
|
|
|
+ callback(false, error)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ list.subList(first, last).let { addSubscriptQuote(tag = tag, goodsInfoList = it) }
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取本商品的盘面信息的同时,还要获取关联商品的盘面信息
|
|
|
+ fun getgoodsCodes(first: Int, last: Int,list : List<GoodsInfo>): String {
|
|
|
+ var goodsCodes = ""
|
|
|
+ val newList = list.subList(first, last)
|
|
|
+ newList.forEach {
|
|
|
+ goodsCodes = goodsCodes + it.goodscode.toUpperCase() + ","
|
|
|
+ }
|
|
|
+ return goodsCodes
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 订阅行情
|
|
|
+ * @param tag String
|
|
|
+ * @param goodsInfoList List<GoodsInfo>
|
|
|
+ */
|
|
|
+ fun addSubscriptQuote(tag: String, goodsInfoList: List<GoodsInfo>) {
|
|
|
+ GlobalScope.launch {
|
|
|
+ MyApplication.getInstance()?.quoteManager?.addSubscriptQuote(
|
|
|
+ tag = tag, goodsCodeSet = goodsInfoList.map { it.goodscode.toUpperCase() ?: "" }.toSet()
|
|
|
+ ) { _, _ ->
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 请求盘面信息
|
|
|
+ * @param first Int
|
|
|
+ * @param last Int
|
|
|
+ * @param callback Function2<[@kotlin.ParameterName] Boolean, [@kotlin.ParameterName] Error?, Unit>
|
|
|
+ */
|
|
|
+ fun queryQuoteDayByListed(
|
|
|
+ tag: String,
|
|
|
+ goodsCodes: String,
|
|
|
+ isShowLoading: Boolean
|
|
|
+ ) {
|
|
|
+ if (isShowLoading) {
|
|
|
+ loadingDialogStatus.postValue(TaskUiModel.inFlight())
|
|
|
+ }
|
|
|
+
|
|
|
+ val params = mutableMapOf<String, String>().apply {
|
|
|
+ put("goodsCodes", goodsCodes)
|
|
|
+ }
|
|
|
+ MyApplication.getInstance()?.futureManager?.queryQuoteDay(params = params) { isSuccess, respData, error ->
|
|
|
+ if (isSuccess) {
|
|
|
+ if (respData?.isEmpty()?.not() == true) {
|
|
|
+ quoteDayData.postValue(respData[0])
|
|
|
+ }
|
|
|
+ if (isShowLoading) {
|
|
|
+ loadingDialogStatus.postValue(TaskUiModel.success(msg = "数据请求成功"))
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ if (isShowLoading) {
|
|
|
+ loadingDialogStatus.postValue(
|
|
|
+ TaskUiModel.failed(
|
|
|
+ InteractiveException(
|
|
|
+ errorMessage = "数据请求失败"
|
|
|
+ )
|
|
|
+ )
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ addSubscriptQuoteByListed(tag = tag, goodsCodes = setOf(goodsCodes))
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 订阅行情
|
|
|
+ * @param tag String
|
|
|
+ * @param goodsInfoList List<GoodsInfo>
|
|
|
+ */
|
|
|
+ fun addSubscriptQuoteByListed(tag: String, goodsCodes: Set<String>) {
|
|
|
+ GlobalScope.launch {
|
|
|
+ MyApplication.getInstance()?.quoteManager?.addSubscriptQuote(
|
|
|
+ tag = tag, goodsCodeSet = goodsCodes
|
|
|
+ ) { _, _ ->
|
|
|
+ LogUtils.eTag("订阅行情", goodsCodes)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 取消订阅
|
|
|
+ * @param tag String
|
|
|
+ */
|
|
|
+ fun removeSubscriptQuote(tag: String) {
|
|
|
+ GlobalScope.launch {
|
|
|
+ MyApplication.getInstance()?.quoteManager?.removeSubscriptQuote(
|
|
|
+ tag = tag
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|