فهرست منبع

fix 获取盘面会导致行情不更新的情况

li.shaoyi 3 سال پیش
والد
کامیت
ae3110cf45
2فایلهای تغییر یافته به همراه17 افزوده شده و 3 حذف شده
  1. 14 2
      src/services/go/quote/index.ts
  2. 3 1
      src/services/socket/quota/adapter/index.ts

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

@@ -1,6 +1,7 @@
 import APP from '@/services';
 import { commonSearch_go } from '../index';
 import * as type from './interface';
+import { mergeObj } from '@/utils/objHandle'
 /**
  * 查询行情历史数据
  * @param param QueryHistoryDatas
@@ -25,8 +26,19 @@ export function QueryHistoryTikDatas(param: type.QueryHistoryTikDatas): Promise<
  * @returns QueryQuoteDay
  */
 export function QueryQuoteDay(goodsCodes: string): Promise<string> {
-    return commonSearch_go('/Quote/QueryQuoteDay', { goodsCodes }).then(res => {
-        APP.set('quoteDayInfo', res)
+    return commonSearch_go('/Quote/QueryQuoteDay', { goodsCodes }).then((res: type.QueryQuoteDayRsp[]) => {
+        console.log('获取商品盘面信息', res)
+        const quoteDayInfo = APP.getRef('quoteDayInfo');
+
+        res.forEach((item) => {
+            const quote = quoteDayInfo.value.find((e: type.QueryQuoteDayRsp) => e.goodscode === item.goodscode);
+            if (quote) {
+                mergeObj(quote, item);
+            } else {
+                quoteDayInfo.value.push(item);
+            }
+        })
+
         return 'ok'
     }).catch(err => { throw new Error(`获取商品盘面信息失败:${err}`) })
 }

+ 3 - 1
src/services/socket/quota/adapter/index.ts

@@ -101,6 +101,9 @@ export function parseReceivePush(quotationData: any) {
     if (rows === null) {
         return;
     }
+
+    const quoteDayInfo = APP.getRef('quoteDayInfo');
+
     for (const low of rows) {
         // 获取 key value 表列
         const keys: any = low.match(regKey);
@@ -122,7 +125,6 @@ export function parseReceivePush(quotationData: any) {
             setQuoteTikFieldByByte(goodsQuoteTik, key, value);
         }
 
-        const quoteDayInfo = APP.getRef('quoteDayInfo');
         const itemQuote = quoteDayInfo.value.find((el: QueryQuoteDayRsp) => {
             const goodcode = el.refgoodscode || el.goodscode
             // console.log(el.goodscode, el.refgoodscode, goodsQuoteTik.goodscode)