mirror of
https://github.com/ArvinLovegood/go-stock.git
synced 2025-07-19 00:00:09 +08:00
feat(market):增加龙虎榜上榜原因筛选功能并优化数据处理
- 在前端市场组件中添加龙虎榜上榜原因筛选功能 - 实现后台数据存储优化,避免重复插入相同数据 - 为 LongTigerRankData 模型添加索引,提高查询效率
This commit is contained in:
parent
e2e0ef2aad
commit
673d446b05
@ -365,6 +365,15 @@ func (m MarketNewsApi) LongTiger(date string) *[]models.LongTigerRankData {
|
|||||||
logger.SugaredLogger.Error(err)
|
logger.SugaredLogger.Error(err)
|
||||||
return ranks
|
return ranks
|
||||||
}
|
}
|
||||||
db.Dao.Create(*ranks)
|
for _, rankData := range *ranks {
|
||||||
|
temp := &models.LongTigerRankData{}
|
||||||
|
db.Dao.Model(temp).Where(&models.LongTigerRankData{
|
||||||
|
TRADEDATE: rankData.TRADEDATE,
|
||||||
|
SECUCODE: rankData.SECUCODE,
|
||||||
|
}).First(temp)
|
||||||
|
if temp.SECURITYTYPECODE == "" {
|
||||||
|
db.Dao.Model(temp).Create(&rankData)
|
||||||
|
}
|
||||||
|
}
|
||||||
return ranks
|
return ranks
|
||||||
}
|
}
|
||||||
|
@ -291,11 +291,11 @@ type LongTigerRankData struct {
|
|||||||
EXPLAIN string `json:"EXPLAIN"`
|
EXPLAIN string `json:"EXPLAIN"`
|
||||||
EXPLANATION string `json:"EXPLANATION"`
|
EXPLANATION string `json:"EXPLANATION"`
|
||||||
FREEMARKETCAP float64 `json:"FREE_MARKET_CAP"`
|
FREEMARKETCAP float64 `json:"FREE_MARKET_CAP"`
|
||||||
SECUCODE string `json:"SECUCODE"`
|
SECUCODE string `json:"SECUCODE" gorm:"index"`
|
||||||
SECURITYCODE string `json:"SECURITY_CODE"`
|
SECURITYCODE string `json:"SECURITY_CODE"`
|
||||||
SECURITYNAMEABBR string `json:"SECURITY_NAME_ABBR"`
|
SECURITYNAMEABBR string `json:"SECURITY_NAME_ABBR"`
|
||||||
SECURITYTYPECODE string `json:"SECURITY_TYPE_CODE"`
|
SECURITYTYPECODE string `json:"SECURITY_TYPE_CODE"`
|
||||||
TRADEDATE string `json:"TRADE_DATE"`
|
TRADEDATE string `json:"TRADE_DATE" gorm:"index"`
|
||||||
TURNOVERRATE float64 `json:"TURNOVERRATE"`
|
TURNOVERRATE float64 `json:"TURNOVERRATE"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,6 +65,7 @@ const nowTab = ref("市场快讯")
|
|||||||
const indexInterval = ref(null)
|
const indexInterval = ref(null)
|
||||||
const indexIndustryRank = ref(null)
|
const indexIndustryRank = ref(null)
|
||||||
const drawerShow= ref(false)
|
const drawerShow= ref(false)
|
||||||
|
const EXPLANATIONs = ref([])
|
||||||
|
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
const year = today.getFullYear();
|
const year = today.getFullYear();
|
||||||
@ -76,6 +77,7 @@ const formattedDate = `${year}-${month}-${day}`;
|
|||||||
|
|
||||||
const SearchForm= ref({
|
const SearchForm= ref({
|
||||||
dateValue: formattedDate,
|
dateValue: formattedDate,
|
||||||
|
EXPLANATION:null,
|
||||||
})
|
})
|
||||||
|
|
||||||
function getIndex() {
|
function getIndex() {
|
||||||
@ -102,9 +104,29 @@ function longTiger(date) {
|
|||||||
if (res.length === 0) {
|
if (res.length === 0) {
|
||||||
message.info("暂无数据,请切换日期")
|
message.info("暂无数据,请切换日期")
|
||||||
}
|
}
|
||||||
|
EXPLANATIONs.value=_.uniqBy(_.map(lhbList.value,function (item){
|
||||||
|
return {
|
||||||
|
label: item['EXPLANATION'],
|
||||||
|
value: item['EXPLANATION'],
|
||||||
|
}
|
||||||
|
}),'label');
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleEXPLANATION(value, option){
|
||||||
|
SearchForm.value.EXPLANATION = value
|
||||||
|
if(value){
|
||||||
|
LongTigerRank(SearchForm.value.dateValue).then(res => {
|
||||||
|
lhbList.value=_.filter(res, function(o) { return o['EXPLANATION']===value; });
|
||||||
|
if (res.length === 0) {
|
||||||
|
message.info("暂无数据,请切换日期")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}else{
|
||||||
|
longTiger(SearchForm.value.dateValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function sortLongTigerRank(e){
|
function sortLongTigerRank(e){
|
||||||
console.log(e.target.dataset)
|
console.log(e.target.dataset)
|
||||||
// let field= e.target.dataset.field;
|
// let field= e.target.dataset.field;
|
||||||
@ -580,11 +602,16 @@ function ReFlesh(source) {
|
|||||||
</n-tab-pane>
|
</n-tab-pane>
|
||||||
<n-tab-pane name="龙虎榜" tab="龙虎榜">
|
<n-tab-pane name="龙虎榜" tab="龙虎榜">
|
||||||
<n-form :model="SearchForm" >
|
<n-form :model="SearchForm" >
|
||||||
<n-form-item-gi label="日期" path="dateValue" label-placement="left">
|
<n-grid :cols="24" :x-gap="24">
|
||||||
<n-date-picker v-model:formatted-value="SearchForm.dateValue"
|
<n-form-item-gi :span="4" label="日期" path="dateValue" label-placement="left">
|
||||||
|
<n-date-picker v-model:formatted-value="SearchForm.dateValue"
|
||||||
value-format="yyyy-MM-dd" type="date" :on-update:value="(v,v2)=>longTiger(v2)"/>
|
value-format="yyyy-MM-dd" type="date" :on-update:value="(v,v2)=>longTiger(v2)"/>
|
||||||
</n-form-item-gi>
|
|
||||||
|
|
||||||
|
</n-form-item-gi>
|
||||||
|
<n-form-item-gi :span="8" label="上榜原因" path="EXPLANATION" label-placement="left">
|
||||||
|
<n-select clearable placeholder="上榜原因过滤" v-model:value="SearchForm.EXPLANATION" :options="EXPLANATIONs" :on-update:value="handleEXPLANATION"/>
|
||||||
|
</n-form-item-gi>
|
||||||
|
</n-grid>
|
||||||
</n-form>
|
</n-form>
|
||||||
<n-table :single-line="false" striped>
|
<n-table :single-line="false" striped>
|
||||||
<n-thead>
|
<n-thead>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user