huangbin 4 yıl önce
ebeveyn
işleme
dbbc46ec22

+ 2 - 0
src/services/go/quote/index.ts

@@ -25,7 +25,9 @@ export function QueryHistoryTikDatas(param: type.QueryHistoryTikDatas): Promise<
  * @returns QueryQuoteDay
  */
 export function QueryQuoteDay(goodsCodes: string): Promise<string> {
+    console.log('goodsCodes', goodsCodes)
     return commonSearch_go('/Quote/QueryQuoteDay', { goodsCodes }).then(res => {
+        console.log('获取商品盘面信息', res)
         APP.set('quoteDayInfo', res)
         return 'ok'
     }).catch(err => { throw new Error(`获取商品盘面信息失败:${err}`) })

+ 5 - 0
src/services/go/quote/interface.ts

@@ -218,6 +218,11 @@ export interface QueryQuoteDayRsp {
     totalturnover: number;
     totalvolume: number;
     utclasttime: string;
+
+    goodsname?: string;
+    goodsid?: number
+    refgoodsname?: string;
+    refgoodscode?: string;
 }
 
 export interface QueryQuoteDay extends QueryQuoteDayRsp {

+ 38 - 20
src/services/socket/quota/adapter/index.ts

@@ -122,36 +122,39 @@ export function parseReceivePush(quotationData: any) {
             setQuoteTikFieldByByte(goodsQuoteTik, key, value);
         }
         const quoteDayInfo = APP.getRef('quoteDayInfo');
-        const itemQuote = quoteDayInfo.value.find((el: QueryQuoteDayRsp) => el.goodscode === goodsQuoteTik.goodscode);
+        const itemQuote = quoteDayInfo.value.find((el: QueryQuoteDayRsp) => {
+            const goodcode = el.refgoodscode || el.goodscode
+            // console.log(el.goodscode, el.refgoodscode, goodsQuoteTik.goodscode)
+            return goodcode === goodsQuoteTik.goodscode
+        });
         // debugger
         if (itemQuote) {
             const goods = getGoodsByCode(itemQuote.goodscode);
             if (goods) {
-                console.log('goodsQuoteTik', goodsQuoteTik)
-                // 判断是一下行情时间是否比现在的要早
-                const quoteTime = moment(goodsQuoteTik.lasttime, 'YYYY-MM-DD HH:mm:ss')
-                const localTime = moment(itemQuote.lasttime, 'YYYY-MM-DD HH:mm:ss')
-                if (quoteTime >= localTime) {
+                // 处理报价小数为
+                const decimalplace = goods.decimalplace
+                const num = Math.pow(10, decimalplace)
+                const fn = (value: number) => +(value / num).toFixed(decimalplace)
+                //
+                // 处理 报价小数位
+                const handleDeimalplace = (key: string) => {
+                    return goodsQuoteTik[key] ? fn(goodsQuoteTik[key]) : itemQuote[key]
+                }
+                // 处理 如果有值则更新值,没有的话,则取上次的值
+                const handleNoneValue = (key: string) => {
+                    return goodsQuoteTik[key] ? goodsQuoteTik[key] : itemQuote[key]
+                }
+
+                const changeValue = () => {
                     // 实时行情由于行情源的问题可能不会下发现量,这时用盘面的总量来计算
                     if (!goodsQuoteTik.lastvolume) {
                         if (itemQuote.totalvolume) {
                             itemQuote.lastvolume = goodsQuoteTik.totalvolume - itemQuote.totalvolume;
                         }
                     }
+                    // console.log('goodsQuoteTik', goodsQuoteTik)
                     // mergeObj(itemQuote, goodsQuoteTik);
-                    // 处理报价小数为
-                    const decimalplace = goods.decimalplace
-                    const num = Math.pow(10, decimalplace)
-                    const fn = (value: number) => +(value / num).toFixed(decimalplace)
-                    //
-                    // 处理 报价小数位
-                    const handleDeimalplace = (key: string) => {
-                        return goodsQuoteTik[key] ? fn(goodsQuoteTik[key]) : itemQuote[key]
-                    }
-                    // 处理 如果有值则更新值,没有的话,则取上次的值
-                    const handleNoneValue = (key: string) => {
-                        return goodsQuoteTik[key] ? goodsQuoteTik[key] : itemQuote[key]
-                    }
+
                     // 处理价格
                     itemQuote.decimalplace = decimalplace
                     itemQuote.last = handleDeimalplace('last')
@@ -254,6 +257,20 @@ export function parseReceivePush(quotationData: any) {
                     itemQuote.totalvolume = handleNoneValue('totalvolume')
                 }
 
+                // 判断是一下行情时间是否比现在的要早
+                if (goodsQuoteTik.lasttime) {
+                    const quoteTime = moment(goodsQuoteTik.lasttime, 'YYYY-MM-DD HH:mm:ss')
+                    const localTime = moment(itemQuote.lasttime, 'YYYY-MM-DD HH:mm:ss')
+                    if (quoteTime >= localTime) {
+                        changeValue()
+                        itemQuote.lasttime = handleNoneValue('lasttime')
+                    }
+                } else {
+                    // 委托单 没有 行情变更时间
+                    changeValue()
+                }
+
+
 
                 // goodsQuoteTik.averageprice = goodsQuoteTik.averageprice ? (fn(goodsQuoteTik.averageprice)) : '--'
                 // goodsQuoteTik.grepmarketprice = goodsQuoteTik.grepmarketprice ? (fn(goodsQuoteTik.grepmarketprice)) : '--'
@@ -297,7 +314,8 @@ export function parseReceivePush(quotationData: any) {
             // }
         } else {
             // 此处 待优化(存在字段变化问题)
-            quoteDayInfo.push(itemQuote);
+            // console.log('itemQuote', itemQuote)
+            // quoteDayInfo.value.push(itemQuote);
         }
     }
 }

+ 4 - 3
src/views/market/spot_trade/spot_trade_order_transaction/spot_trade_order_transaction_swap/index.vue

@@ -82,6 +82,7 @@ import { contextMenu, defineAsyncComponent, defineComponent } from '@/common/exp
 import { handleTableEventAndData } from '@/common/setup/table/compose';
 import { TableParam } from '@/common/setup/table/interface';
 import { handleQuotePriceColor, handleSubcriteOnDemandQuote, quoteAmplitude, quoteAmplituOfVibration, quoteChange } from '@/common/setup/table/tableQuote';
+import { QueryQuoteDayRsp } from '@/services/go/quote/interface';
 import { RefGoodsList } from './interface';
 import { columnsList, getBtnList, useSwapList } from './setup';
 
@@ -104,18 +105,18 @@ export default defineComponent({
         };
 
         // 行情按需订阅
-        let stopSubcribe = handleSubcriteOnDemandQuote<RefGoodsList>(goodsList, 'refgoodscode');
+        let stopSubcribe = handleSubcriteOnDemandQuote<QueryQuoteDayRsp>(goodsList, 'refgoodscode');
         // 过滤标的合约
         function goodsChange(value: string) {
             filterGoodsList(value);
             // 停止上次订阅
             stopSubcribe();
             // 重新发起订阅
-            stopSubcribe = handleSubcriteOnDemandQuote<RefGoodsList>(goodsList, 'refgoodscode');
+            stopSubcribe = handleSubcriteOnDemandQuote<QueryQuoteDayRsp>(goodsList, 'refgoodscode');
         }
         return {
             isBottom,
-            ...handleTableEventAndData<RefGoodsList>(param),
+            ...handleTableEventAndData<QueryQuoteDayRsp>(param),
             btnList: getBtnList(true),
             handleQuotePriceColor,
             quoteChange,

+ 10 - 9
src/views/market/spot_trade/spot_trade_order_transaction/spot_trade_order_transaction_swap/setup.ts

@@ -2,16 +2,16 @@ import { BtnListType } from "@/common/components/btnList/interface"
 import { TradeMode } from "@/common/constants/enumCommon"
 import { initData } from "@/common/methods"
 import { queryTableList } from "@/common/setup/table"
-import { getQuoteDayInfoByCode } from "@/services/bus/goods"
+import { getAllQuoteDayInfo, getQuoteDayInfoByCode } from "@/services/bus/goods"
 import { getMarketIdsByTradeMode } from "@/services/bus/market"
 import { getUserAccountType } from "@/services/bus/user"
+import { QueryQuoteDayRsp } from "@/services/go/quote/interface"
 import { queryQuoteGoodsList } from "@/services/go/Tjmd"
 import { QueryQuoteGoodsListReq, QueryQuoteGoodsListRsp } from "@/services/go/Tjmd/interface"
 import { ref } from "vue"
-import { RefGoodsList } from './interface'
 
 const refGoods = ref<QueryQuoteGoodsListRsp[]>([])
-const allGoodsList = ref<RefGoodsList[]>([])
+const allGoodsList = ref<QueryQuoteDayRsp[]>([])
 
 export function findItemGoods(goodscode: string) {
     return refGoods.value.find(el => el.goodscode === goodscode)!
@@ -34,28 +34,29 @@ export function getSwapList() {
 // 获取 商品掉期 商品列表
 export const useSwapList = () => {
     // 行情商品
-    const goodsList = ref<RefGoodsList[]>([])
+    const goodsList = ref<QueryQuoteDayRsp[]>([])
     initData(() => {
         // 开始查询 商品掉期
         getSwapList().then(res => {
             refGoods.value = res
             goodsList.value.length = 0
             allGoodsList.value.length = 0
+            console.log('getAllQuoteDayInfo()', getAllQuoteDayInfo())
             res.forEach(el => {
                 // 找到盘面数据
                 const quote = getQuoteDayInfoByCode(el.refgoodscode);
                 if (quote) {
-                    const result: RefGoodsList = {
-                        ...quote,
+                    const obj = {
                         goodsname: el.goodsname,
                         goodsid: el.goodsid,
-                        goodscode: el.goodscode,
                         refgoodsname: el.refgoodsname,
                         refgoodscode: el.refgoodscode
                     }
-                    goodsList.value.push(result)
-                    allGoodsList.value.push(result)
+                    Object.assign(quote, obj)
+                    goodsList.value.push(quote)
+                    allGoodsList.value.push(quote)
                 }
+                console.log('allGoodsList.value', allGoodsList.value)
             })
             console.log('商品掉期', res)
         })