fix: trae修改代码

dev_refactor_0120
Lxy 4 months ago
parent 698887cba5
commit ae937f9519

@ -0,0 +1,91 @@
package com.ruoyi.newstocksystem.controller;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.newstocksystem.domain.StockHighLowStatus;
import com.ruoyi.newstocksystem.domain.IndustryIndex;
import com.ruoyi.newstocksystem.domain.StockDailyTrade;
import com.ruoyi.newstocksystem.domain.StockBasic;
import com.ruoyi.newstocksystem.service.IStockHighLowStatusService;
import com.ruoyi.newstocksystem.service.IIndustryIndexService;
import com.ruoyi.newstocksystem.service.IStockDailyTradeService;
import com.ruoyi.newstocksystem.service.IStockBasicService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.util.List;
@Controller
@RequestMapping("/newstock/data/import")
public class StockDataImportController extends BaseController {
@Resource
private IStockHighLowStatusService stockHighLowStatusService;
@Resource
private IIndustryIndexService industryIndexService;
@Resource
private IStockDailyTradeService stockDailyTradeService;
@Resource
private IStockBasicService stockBasicService;
@PostMapping("/highlow")
@ResponseBody
public AjaxResult importHighLowData(@RequestParam("file") MultipartFile file) {
try {
ExcelUtil<StockHighLowStatus> util = new ExcelUtil<>(StockHighLowStatus.class);
List<StockHighLowStatus> list = util.importExcel(file.getInputStream());
int count = stockHighLowStatusService.batchInsertStockHighLowStatus(list);
return AjaxResult.success("Import successful, " + count + " records imported");
} catch (Exception e) {
return AjaxResult.error("Import failed: " + e.getMessage());
}
}
@PostMapping("/industry")
@ResponseBody
public AjaxResult importIndustryData(@RequestParam("file") MultipartFile file) {
try {
ExcelUtil<IndustryIndex> util = new ExcelUtil<>(IndustryIndex.class);
List<IndustryIndex> list = util.importExcel(file.getInputStream());
int count = industryIndexService.batchInsertIndustryIndex(list);
return AjaxResult.success("Import successful, " + count + " records imported");
} catch (Exception e) {
return AjaxResult.error("Import failed: " + e.getMessage());
}
}
@PostMapping("/momentum")
@ResponseBody
public AjaxResult importMomentumData(@RequestParam("file") MultipartFile file) {
try {
ExcelUtil<StockDailyTrade> util = new ExcelUtil<>(StockDailyTrade.class);
List<StockDailyTrade> list = util.importExcel(file.getInputStream());
int count = stockDailyTradeService.batchInsertStockDailyTrade(list);
return AjaxResult.success("Import successful, " + count + " records imported");
} catch (Exception e) {
return AjaxResult.error("Import failed: " + e.getMessage());
}
}
@PostMapping("/basic")
@ResponseBody
public AjaxResult importBasicData(@RequestParam("file") MultipartFile file) {
try {
ExcelUtil<StockBasic> util = new ExcelUtil<>(StockBasic.class);
List<StockBasic> list = util.importExcel(file.getInputStream());
int count = stockBasicService.batchInsertStockBasic(list);
return AjaxResult.success("Import successful, " + count + " records imported");
} catch (Exception e) {
return AjaxResult.error("Import failed: " + e.getMessage());
}
}
}

@ -0,0 +1,141 @@
package com.ruoyi.newstocksystem.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.domain.BaseEntity;
import java.util.Date;
public class IndustryIndex extends BaseEntity {
private static final long serialVersionUID = 1L;
private String industryIndexCode;
private String industryIndexName;
private Integer componentCount;
@JsonFormat(pattern = "yyyy-MM-dd")
private Date tradeDate;
private Double openPrice;
private Double closePrice;
private Long volume;
private Double turnover;
private Double totalMarketCap;
private Double freeCirculationCap;
private Double priceChangeRate;
private Double peTtm;
private Double peTtmMedian;
public String getIndustryIndexCode() {
return industryIndexCode;
}
public void setIndustryIndexCode(String industryIndexCode) {
this.industryIndexCode = industryIndexCode;
}
public String getIndustryIndexName() {
return industryIndexName;
}
public void setIndustryIndexName(String industryIndexName) {
this.industryIndexName = industryIndexName;
}
public Integer getComponentCount() {
return componentCount;
}
public void setComponentCount(Integer componentCount) {
this.componentCount = componentCount;
}
public Date getTradeDate() {
return tradeDate;
}
public void setTradeDate(Date tradeDate) {
this.tradeDate = tradeDate;
}
public Double getOpenPrice() {
return openPrice;
}
public void setOpenPrice(Double openPrice) {
this.openPrice = openPrice;
}
public Double getClosePrice() {
return closePrice;
}
public void setClosePrice(Double closePrice) {
this.closePrice = closePrice;
}
public Long getVolume() {
return volume;
}
public void setVolume(Long volume) {
this.volume = volume;
}
public Double getTurnover() {
return turnover;
}
public void setTurnover(Double turnover) {
this.turnover = turnover;
}
public Double getTotalMarketCap() {
return totalMarketCap;
}
public void setTotalMarketCap(Double totalMarketCap) {
this.totalMarketCap = totalMarketCap;
}
public Double getFreeCirculationCap() {
return freeCirculationCap;
}
public void setFreeCirculationCap(Double freeCirculationCap) {
this.freeCirculationCap = freeCirculationCap;
}
public Double getPriceChangeRate() {
return priceChangeRate;
}
public void setPriceChangeRate(Double priceChangeRate) {
this.priceChangeRate = priceChangeRate;
}
public Double getPeTtm() {
return peTtm;
}
public void setPeTtm(Double peTtm) {
this.peTtm = peTtm;
}
public Double getPeTtmMedian() {
return peTtmMedian;
}
public void setPeTtmMedian(Double peTtmMedian) {
this.peTtmMedian = peTtmMedian;
}
}

@ -0,0 +1,91 @@
package com.ruoyi.newstocksystem.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.domain.BaseEntity;
import java.util.Date;
public class StockBasic extends BaseEntity {
private static final long serialVersionUID = 1L;
private String stockCode;
private String stockName;
@JsonFormat(pattern = "yyyy-MM-dd")
private Date listingDate;
private Integer listingDays;
private Integer isSt;
private Integer isStarSt;
private String industryIndexCode;
private String industryIndexName;
public String getStockCode() {
return stockCode;
}
public void setStockCode(String stockCode) {
this.stockCode = stockCode;
}
public String getStockName() {
return stockName;
}
public void setStockName(String stockName) {
this.stockName = stockName;
}
public Date getListingDate() {
return listingDate;
}
public void setListingDate(Date listingDate) {
this.listingDate = listingDate;
}
public Integer getListingDays() {
return listingDays;
}
public void setListingDays(Integer listingDays) {
this.listingDays = listingDays;
}
public Integer getIsSt() {
return isSt;
}
public void setIsSt(Integer isSt) {
this.isSt = isSt;
}
public Integer getIsStarSt() {
return isStarSt;
}
public void setIsStarSt(Integer isStarSt) {
this.isStarSt = isStarSt;
}
public String getIndustryIndexCode() {
return industryIndexCode;
}
public void setIndustryIndexCode(String industryIndexCode) {
this.industryIndexCode = industryIndexCode;
}
public String getIndustryIndexName() {
return industryIndexName;
}
public void setIndustryIndexName(String industryIndexName) {
this.industryIndexName = industryIndexName;
}
}

@ -0,0 +1,161 @@
package com.ruoyi.newstocksystem.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.domain.BaseEntity;
import java.util.Date;
public class StockDailyTrade extends BaseEntity {
private static final long serialVersionUID = 1L;
private String stockCode;
@JsonFormat(pattern = "yyyy-MM-dd")
private Date tradeDate;
private Double openPrice;
private Double closePrice;
private Double highPrice;
private Double lowPrice;
private Double priceChangeRate;
private Long volume;
private Double turnover;
private Double freeCirculationCap;
private Integer isLimitUp;
private Integer isLimitDown;
private Double momentum10d;
private Double momentum20d;
private Double momentum60d;
public String getStockCode() {
return stockCode;
}
public void setStockCode(String stockCode) {
this.stockCode = stockCode;
}
public Date getTradeDate() {
return tradeDate;
}
public void setTradeDate(Date tradeDate) {
this.tradeDate = tradeDate;
}
public Double getOpenPrice() {
return openPrice;
}
public void setOpenPrice(Double openPrice) {
this.openPrice = openPrice;
}
public Double getClosePrice() {
return closePrice;
}
public void setClosePrice(Double closePrice) {
this.closePrice = closePrice;
}
public Double getHighPrice() {
return highPrice;
}
public void setHighPrice(Double highPrice) {
this.highPrice = highPrice;
}
public Double getLowPrice() {
return lowPrice;
}
public void setLowPrice(Double lowPrice) {
this.lowPrice = lowPrice;
}
public Double getPriceChangeRate() {
return priceChangeRate;
}
public void setPriceChangeRate(Double priceChangeRate) {
this.priceChangeRate = priceChangeRate;
}
public Long getVolume() {
return volume;
}
public void setVolume(Long volume) {
this.volume = volume;
}
public Double getTurnover() {
return turnover;
}
public void setTurnover(Double turnover) {
this.turnover = turnover;
}
public Double getFreeCirculationCap() {
return freeCirculationCap;
}
public void setFreeCirculationCap(Double freeCirculationCap) {
this.freeCirculationCap = freeCirculationCap;
}
public Integer getIsLimitUp() {
return isLimitUp;
}
public void setIsLimitUp(Integer isLimitUp) {
this.isLimitUp = isLimitUp;
}
public Integer getIsLimitDown() {
return isLimitDown;
}
public void setIsLimitDown(Integer isLimitDown) {
this.isLimitDown = isLimitDown;
}
public Double getMomentum10d() {
return momentum10d;
}
public void setMomentum10d(Double momentum10d) {
this.momentum10d = momentum10d;
}
public Double getMomentum20d() {
return momentum20d;
}
public void setMomentum20d(Double momentum20d) {
this.momentum20d = momentum20d;
}
public Double getMomentum60d() {
return momentum60d;
}
public void setMomentum60d(Double momentum60d) {
this.momentum60d = momentum60d;
}
}

@ -0,0 +1,73 @@
package com.ruoyi.newstocksystem.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.domain.BaseEntity;
import java.util.Date;
public class StockHighLowStatus extends BaseEntity {
private static final long serialVersionUID = 1L;
private String stockCode;
@JsonFormat(pattern = "yyyy-MM-dd")
private Date tradeDate;
private Integer isNewHigh;
@JsonFormat(pattern = "yyyy-MM-dd")
private Date newHighDate;
private Integer isNewLow;
@JsonFormat(pattern = "yyyy-MM-dd")
private Date newLowDate;
public String getStockCode() {
return stockCode;
}
public void setStockCode(String stockCode) {
this.stockCode = stockCode;
}
public Date getTradeDate() {
return tradeDate;
}
public void setTradeDate(Date tradeDate) {
this.tradeDate = tradeDate;
}
public Integer getIsNewHigh() {
return isNewHigh;
}
public void setIsNewHigh(Integer isNewHigh) {
this.isNewHigh = isNewHigh;
}
public Date getNewHighDate() {
return newHighDate;
}
public void setNewHighDate(Date newHighDate) {
this.newHighDate = newHighDate;
}
public Integer getIsNewLow() {
return isNewLow;
}
public void setIsNewLow(Integer isNewLow) {
this.isNewLow = isNewLow;
}
public Date getNewLowDate() {
return newLowDate;
}
public void setNewLowDate(Date newLowDate) {
this.newLowDate = newLowDate;
}
}

@ -0,0 +1,20 @@
package com.ruoyi.newstocksystem.mapper;
import com.ruoyi.newstocksystem.domain.IndustryIndex;
import java.util.Date;
import java.util.List;
public interface IndustryIndexMapper {
int insertIndustryIndex(IndustryIndex industryIndex);
int updateIndustryIndex(IndustryIndex industryIndex);
int deleteIndustryIndex(String industryIndexCode, Date tradeDate);
IndustryIndex selectIndustryIndexByCodeAndDate(String industryIndexCode, Date tradeDate);
List<IndustryIndex> selectIndustryIndexList(IndustryIndex industryIndex);
List<IndustryIndex> selectIndustryIndexByDate(Date tradeDate);
}

@ -0,0 +1,19 @@
package com.ruoyi.newstocksystem.mapper;
import com.ruoyi.newstocksystem.domain.StockBasic;
import java.util.List;
public interface StockBasicMapper {
int insertStockBasic(StockBasic stockBasic);
int updateStockBasic(StockBasic stockBasic);
int deleteStockBasic(String stockCode);
StockBasic selectStockBasicByCode(String stockCode);
List<StockBasic> selectStockBasicList(StockBasic stockBasic);
List<StockBasic> selectStockBasicByIndustry(String industryIndexCode);
}

@ -0,0 +1,22 @@
package com.ruoyi.newstocksystem.mapper;
import com.ruoyi.newstocksystem.domain.StockDailyTrade;
import java.util.Date;
import java.util.List;
public interface StockDailyTradeMapper {
int insertStockDailyTrade(StockDailyTrade stockDailyTrade);
int updateStockDailyTrade(StockDailyTrade stockDailyTrade);
int deleteStockDailyTrade(String stockCode, Date tradeDate);
StockDailyTrade selectStockDailyTradeByCodeAndDate(String stockCode, Date tradeDate);
List<StockDailyTrade> selectStockDailyTradeList(StockDailyTrade stockDailyTrade);
List<StockDailyTrade> selectStockDailyTradeByDate(Date tradeDate);
List<StockDailyTrade> selectStockDailyTradeByCode(String stockCode);
}

@ -0,0 +1,22 @@
package com.ruoyi.newstocksystem.mapper;
import com.ruoyi.newstocksystem.domain.StockHighLowStatus;
import java.util.Date;
import java.util.List;
public interface StockHighLowStatusMapper {
int insertStockHighLowStatus(StockHighLowStatus stockHighLowStatus);
int updateStockHighLowStatus(StockHighLowStatus stockHighLowStatus);
int deleteStockHighLowStatus(String stockCode, Date tradeDate);
StockHighLowStatus selectStockHighLowStatusByCodeAndDate(String stockCode, Date tradeDate);
List<StockHighLowStatus> selectStockHighLowStatusList(StockHighLowStatus stockHighLowStatus);
List<StockHighLowStatus> selectNewHighStocks(Date tradeDate);
List<StockHighLowStatus> selectNewLowStocks(Date tradeDate);
}

@ -0,0 +1,22 @@
package com.ruoyi.newstocksystem.service;
import com.ruoyi.newstocksystem.domain.IndustryIndex;
import java.util.Date;
import java.util.List;
public interface IIndustryIndexService {
int insertIndustryIndex(IndustryIndex industryIndex);
int updateIndustryIndex(IndustryIndex industryIndex);
int deleteIndustryIndex(String industryIndexCode, Date tradeDate);
IndustryIndex selectIndustryIndexByCodeAndDate(String industryIndexCode, Date tradeDate);
List<IndustryIndex> selectIndustryIndexList(IndustryIndex industryIndex);
List<IndustryIndex> selectIndustryIndexByDate(Date tradeDate);
int batchInsertIndustryIndex(List<IndustryIndex> industryIndexList);
}

@ -0,0 +1,21 @@
package com.ruoyi.newstocksystem.service;
import com.ruoyi.newstocksystem.domain.StockBasic;
import java.util.List;
public interface IStockBasicService {
int insertStockBasic(StockBasic stockBasic);
int updateStockBasic(StockBasic stockBasic);
int deleteStockBasic(String stockCode);
StockBasic selectStockBasicByCode(String stockCode);
List<StockBasic> selectStockBasicList(StockBasic stockBasic);
List<StockBasic> selectStockBasicByIndustry(String industryIndexCode);
int batchInsertStockBasic(List<StockBasic> stockBasicList);
}

@ -0,0 +1,24 @@
package com.ruoyi.newstocksystem.service;
import com.ruoyi.newstocksystem.domain.StockDailyTrade;
import java.util.Date;
import java.util.List;
public interface IStockDailyTradeService {
int insertStockDailyTrade(StockDailyTrade stockDailyTrade);
int updateStockDailyTrade(StockDailyTrade stockDailyTrade);
int deleteStockDailyTrade(String stockCode, Date tradeDate);
StockDailyTrade selectStockDailyTradeByCodeAndDate(String stockCode, Date tradeDate);
List<StockDailyTrade> selectStockDailyTradeList(StockDailyTrade stockDailyTrade);
List<StockDailyTrade> selectStockDailyTradeByDate(Date tradeDate);
List<StockDailyTrade> selectStockDailyTradeByCode(String stockCode);
int batchInsertStockDailyTrade(List<StockDailyTrade> stockDailyTradeList);
}

@ -0,0 +1,24 @@
package com.ruoyi.newstocksystem.service;
import com.ruoyi.newstocksystem.domain.StockHighLowStatus;
import java.util.Date;
import java.util.List;
public interface IStockHighLowStatusService {
int insertStockHighLowStatus(StockHighLowStatus stockHighLowStatus);
int updateStockHighLowStatus(StockHighLowStatus stockHighLowStatus);
int deleteStockHighLowStatus(String stockCode, Date tradeDate);
StockHighLowStatus selectStockHighLowStatusByCodeAndDate(String stockCode, Date tradeDate);
List<StockHighLowStatus> selectStockHighLowStatusList(StockHighLowStatus stockHighLowStatus);
List<StockHighLowStatus> selectNewHighStocks(Date tradeDate);
List<StockHighLowStatus> selectNewLowStocks(Date tradeDate);
int batchInsertStockHighLowStatus(List<StockHighLowStatus> stockHighLowStatusList);
}

@ -0,0 +1,56 @@
package com.ruoyi.newstocksystem.service.impl;
import com.ruoyi.newstocksystem.domain.IndustryIndex;
import com.ruoyi.newstocksystem.mapper.IndustryIndexMapper;
import com.ruoyi.newstocksystem.service.IIndustryIndexService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@Service
public class IndustryIndexServiceImpl implements IIndustryIndexService {
@Resource
private IndustryIndexMapper industryIndexMapper;
@Override
public int insertIndustryIndex(IndustryIndex industryIndex) {
return industryIndexMapper.insertIndustryIndex(industryIndex);
}
@Override
public int updateIndustryIndex(IndustryIndex industryIndex) {
return industryIndexMapper.updateIndustryIndex(industryIndex);
}
@Override
public int deleteIndustryIndex(String industryIndexCode, Date tradeDate) {
return industryIndexMapper.deleteIndustryIndex(industryIndexCode, tradeDate);
}
@Override
public IndustryIndex selectIndustryIndexByCodeAndDate(String industryIndexCode, Date tradeDate) {
return industryIndexMapper.selectIndustryIndexByCodeAndDate(industryIndexCode, tradeDate);
}
@Override
public List<IndustryIndex> selectIndustryIndexList(IndustryIndex industryIndex) {
return industryIndexMapper.selectIndustryIndexList(industryIndex);
}
@Override
public List<IndustryIndex> selectIndustryIndexByDate(Date tradeDate) {
return industryIndexMapper.selectIndustryIndexByDate(tradeDate);
}
@Override
public int batchInsertIndustryIndex(List<IndustryIndex> industryIndexList) {
int count = 0;
for (IndustryIndex industryIndex : industryIndexList) {
count += industryIndexMapper.insertIndustryIndex(industryIndex);
}
return count;
}
}

@ -0,0 +1,55 @@
package com.ruoyi.newstocksystem.service.impl;
import com.ruoyi.newstocksystem.domain.StockBasic;
import com.ruoyi.newstocksystem.mapper.StockBasicMapper;
import com.ruoyi.newstocksystem.service.IStockBasicService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class StockBasicServiceImpl implements IStockBasicService {
@Resource
private StockBasicMapper stockBasicMapper;
@Override
public int insertStockBasic(StockBasic stockBasic) {
return stockBasicMapper.insertStockBasic(stockBasic);
}
@Override
public int updateStockBasic(StockBasic stockBasic) {
return stockBasicMapper.updateStockBasic(stockBasic);
}
@Override
public int deleteStockBasic(String stockCode) {
return stockBasicMapper.deleteStockBasic(stockCode);
}
@Override
public StockBasic selectStockBasicByCode(String stockCode) {
return stockBasicMapper.selectStockBasicByCode(stockCode);
}
@Override
public List<StockBasic> selectStockBasicList(StockBasic stockBasic) {
return stockBasicMapper.selectStockBasicList(stockBasic);
}
@Override
public List<StockBasic> selectStockBasicByIndustry(String industryIndexCode) {
return stockBasicMapper.selectStockBasicByIndustry(industryIndexCode);
}
@Override
public int batchInsertStockBasic(List<StockBasic> stockBasicList) {
int count = 0;
for (StockBasic stockBasic : stockBasicList) {
count += stockBasicMapper.insertStockBasic(stockBasic);
}
return count;
}
}

@ -0,0 +1,61 @@
package com.ruoyi.newstocksystem.service.impl;
import com.ruoyi.newstocksystem.domain.StockDailyTrade;
import com.ruoyi.newstocksystem.mapper.StockDailyTradeMapper;
import com.ruoyi.newstocksystem.service.IStockDailyTradeService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@Service
public class StockDailyTradeServiceImpl implements IStockDailyTradeService {
@Resource
private StockDailyTradeMapper stockDailyTradeMapper;
@Override
public int insertStockDailyTrade(StockDailyTrade stockDailyTrade) {
return stockDailyTradeMapper.insertStockDailyTrade(stockDailyTrade);
}
@Override
public int updateStockDailyTrade(StockDailyTrade stockDailyTrade) {
return stockDailyTradeMapper.updateStockDailyTrade(stockDailyTrade);
}
@Override
public int deleteStockDailyTrade(String stockCode, Date tradeDate) {
return stockDailyTradeMapper.deleteStockDailyTrade(stockCode, tradeDate);
}
@Override
public StockDailyTrade selectStockDailyTradeByCodeAndDate(String stockCode, Date tradeDate) {
return stockDailyTradeMapper.selectStockDailyTradeByCodeAndDate(stockCode, tradeDate);
}
@Override
public List<StockDailyTrade> selectStockDailyTradeList(StockDailyTrade stockDailyTrade) {
return stockDailyTradeMapper.selectStockDailyTradeList(stockDailyTrade);
}
@Override
public List<StockDailyTrade> selectStockDailyTradeByDate(Date tradeDate) {
return stockDailyTradeMapper.selectStockDailyTradeByDate(tradeDate);
}
@Override
public List<StockDailyTrade> selectStockDailyTradeByCode(String stockCode) {
return stockDailyTradeMapper.selectStockDailyTradeByCode(stockCode);
}
@Override
public int batchInsertStockDailyTrade(List<StockDailyTrade> stockDailyTradeList) {
int count = 0;
for (StockDailyTrade stockDailyTrade : stockDailyTradeList) {
count += stockDailyTradeMapper.insertStockDailyTrade(stockDailyTrade);
}
return count;
}
}

@ -0,0 +1,61 @@
package com.ruoyi.newstocksystem.service.impl;
import com.ruoyi.newstocksystem.domain.StockHighLowStatus;
import com.ruoyi.newstocksystem.mapper.StockHighLowStatusMapper;
import com.ruoyi.newstocksystem.service.IStockHighLowStatusService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@Service
public class StockHighLowStatusServiceImpl implements IStockHighLowStatusService {
@Resource
private StockHighLowStatusMapper stockHighLowStatusMapper;
@Override
public int insertStockHighLowStatus(StockHighLowStatus stockHighLowStatus) {
return stockHighLowStatusMapper.insertStockHighLowStatus(stockHighLowStatus);
}
@Override
public int updateStockHighLowStatus(StockHighLowStatus stockHighLowStatus) {
return stockHighLowStatusMapper.updateStockHighLowStatus(stockHighLowStatus);
}
@Override
public int deleteStockHighLowStatus(String stockCode, Date tradeDate) {
return stockHighLowStatusMapper.deleteStockHighLowStatus(stockCode, tradeDate);
}
@Override
public StockHighLowStatus selectStockHighLowStatusByCodeAndDate(String stockCode, Date tradeDate) {
return stockHighLowStatusMapper.selectStockHighLowStatusByCodeAndDate(stockCode, tradeDate);
}
@Override
public List<StockHighLowStatus> selectStockHighLowStatusList(StockHighLowStatus stockHighLowStatus) {
return stockHighLowStatusMapper.selectStockHighLowStatusList(stockHighLowStatus);
}
@Override
public List<StockHighLowStatus> selectNewHighStocks(Date tradeDate) {
return stockHighLowStatusMapper.selectNewHighStocks(tradeDate);
}
@Override
public List<StockHighLowStatus> selectNewLowStocks(Date tradeDate) {
return stockHighLowStatusMapper.selectNewLowStocks(tradeDate);
}
@Override
public int batchInsertStockHighLowStatus(List<StockHighLowStatus> stockHighLowStatusList) {
int count = 0;
for (StockHighLowStatus stockHighLowStatus : stockHighLowStatusList) {
count += stockHighLowStatusMapper.insertStockHighLowStatus(stockHighLowStatus);
}
return count;
}
}

@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.ruoyi.newstocksystem.mapper.IndustryIndexMapper">
<resultMap type="com.ruoyi.newstocksystem.domain.IndustryIndex" id="IndustryIndexResult">
<id property="industryIndexCode" column="industry_index_code"/>
<result property="industryIndexName" column="industry_index_name"/>
<result property="componentCount" column="component_count" />
<result property="tradeDate" column="trade_date" />
<result property="openPrice" column="open_price" />
<result property="closePrice" column="close_price" />
<result property="volume" column="volume" />
<result property="turnover" column="turnover" />
<result property="totalMarketCap" column="total_market_cap" />
<result property="freeCirculationCap" column="free_circulation_cap"/>
<result property="priceChangeRate" column="price_change_rate" />
<result property="peTtm" column="pe_ttm" />
<result property="peTtmMedian" column="pe_ttm_median" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectIndustryIndexVo">
select industry_index_code, industry_index_name, component_count, trade_date, open_price, close_price, volume, turnover, total_market_cap, free_circulation_cap, price_change_rate, pe_ttm, pe_ttm_median, create_time, update_time
from t_industry_index
</sql>
<select id="selectIndustryIndexByCodeAndDate" resultMap="IndustryIndexResult">
<include refid="selectIndustryIndexVo" />
where industry_index_code = #{industryIndexCode} and trade_date = #{tradeDate}
</select>
<select id="selectIndustryIndexList" parameterType="com.ruoyi.newstocksystem.domain.IndustryIndex" resultMap="IndustryIndexResult">
<include refid="selectIndustryIndexVo" />
<where>
<if test="industryIndexCode != null and industryIndexCode != ''">
and industry_index_code = #{industryIndexCode}
</if>
<if test="industryIndexName != null and industryIndexName != ''">
and industry_index_name like concat('%', #{industryIndexName}, '%')
</if>
<if test="tradeDate != null">
and trade_date = #{tradeDate}
</if>
</where>
</select>
<select id="selectIndustryIndexByDate" parameterType="date" resultMap="IndustryIndexResult">
<include refid="selectIndustryIndexVo" />
where trade_date = #{tradeDate}
</select>
<insert id="insertIndustryIndex" parameterType="com.ruoyi.newstocksystem.domain.IndustryIndex">
insert into t_industry_index
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="industryIndexCode != null">industry_index_code,</if>
<if test="industryIndexName != null">industry_index_name,</if>
<if test="componentCount != null">component_count,</if>
<if test="tradeDate != null">trade_date,</if>
<if test="openPrice != null">open_price,</if>
<if test="closePrice != null">close_price,</if>
<if test="volume != null">volume,</if>
<if test="turnover != null">turnover,</if>
<if test="totalMarketCap != null">total_market_cap,</if>
<if test="freeCirculationCap != null">free_circulation_cap,</if>
<if test="priceChangeRate != null">price_change_rate,</if>
<if test="peTtm != null">pe_ttm,</if>
<if test="peTtmMedian != null">pe_ttm_median,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="industryIndexCode != null">#{industryIndexCode},</if>
<if test="industryIndexName != null">#{industryIndexName},</if>
<if test="componentCount != null">#{componentCount},</if>
<if test="tradeDate != null">#{tradeDate},</if>
<if test="openPrice != null">#{openPrice},</if>
<if test="closePrice != null">#{closePrice},</if>
<if test="volume != null">#{volume},</if>
<if test="turnover != null">#{turnover},</if>
<if test="totalMarketCap != null">#{totalMarketCap},</if>
<if test="freeCirculationCap != null">#{freeCirculationCap},</if>
<if test="priceChangeRate != null">#{priceChangeRate},</if>
<if test="peTtm != null">#{peTtm},</if>
<if test="peTtmMedian != null">#{peTtmMedian},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateIndustryIndex" parameterType="com.ruoyi.newstocksystem.domain.IndustryIndex">
update t_industry_index
<set>
<if test="industryIndexName != null">industry_index_name = #{industryIndexName},</if>
<if test="componentCount != null">component_count = #{componentCount},</if>
<if test="openPrice != null">open_price = #{openPrice},</if>
<if test="closePrice != null">close_price = #{closePrice},</if>
<if test="volume != null">volume = #{volume},</if>
<if test="turnover != null">turnover = #{turnover},</if>
<if test="totalMarketCap != null">total_market_cap = #{totalMarketCap},</if>
<if test="freeCirculationCap != null">free_circulation_cap = #{freeCirculationCap},</if>
<if test="priceChangeRate != null">price_change_rate = #{priceChangeRate},</if>
<if test="peTtm != null">pe_ttm = #{peTtm},</if>
<if test="peTtmMedian != null">pe_ttm_median = #{peTtmMedian},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</set>
where industry_index_code = #{industryIndexCode} and trade_date = #{tradeDate}
</update>
<delete id="deleteIndustryIndex">
delete from t_industry_index
where industry_index_code = #{industryIndexCode} and trade_date = #{tradeDate}
</delete>
</mapper>

@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.ruoyi.newstocksystem.mapper.StockBasicMapper">
<resultMap type="com.ruoyi.newstocksystem.domain.StockBasic" id="StockBasicResult">
<id property="stockCode" column="stock_code" />
<result property="stockName" column="stock_name" />
<result property="listingDate" column="listing_date" />
<result property="listingDays" column="listing_days" />
<result property="isSt" column="is_st" />
<result property="isStarSt" column="is_star_st" />
<result property="industryIndexCode" column="industry_index_code"/>
<result property="industryIndexName" column="industry_index_name"/>
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectStockBasicVo">
select stock_code, stock_name, listing_date, listing_days, is_st, is_star_st, industry_index_code, industry_index_name, create_time, update_time
from t_stock_basic
</sql>
<select id="selectStockBasicByCode" parameterType="string" resultMap="StockBasicResult">
<include refid="selectStockBasicVo" />
where stock_code = #{stockCode}
</select>
<select id="selectStockBasicList" parameterType="com.ruoyi.newstocksystem.domain.StockBasic" resultMap="StockBasicResult">
<include refid="selectStockBasicVo" />
<where>
<if test="stockCode != null and stockCode != ''">
and stock_code = #{stockCode}
</if>
<if test="stockName != null and stockName != ''">
and stock_name like concat('%', #{stockName}, '%')
</if>
<if test="industryIndexCode != null and industryIndexCode != ''">
and industry_index_code = #{industryIndexCode}
</if>
<if test="industryIndexName != null and industryIndexName != ''">
and industry_index_name like concat('%', #{industryIndexName}, '%')
</if>
</where>
</select>
<select id="selectStockBasicByIndustry" parameterType="string" resultMap="StockBasicResult">
<include refid="selectStockBasicVo" />
where industry_index_code = #{industryIndexCode}
</select>
<insert id="insertStockBasic" parameterType="com.ruoyi.newstocksystem.domain.StockBasic">
insert into t_stock_basic
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="stockCode != null">stock_code,</if>
<if test="stockName != null">stock_name,</if>
<if test="listingDate != null">listing_date,</if>
<if test="listingDays != null">listing_days,</if>
<if test="isSt != null">is_st,</if>
<if test="isStarSt != null">is_star_st,</if>
<if test="industryIndexCode != null">industry_index_code,</if>
<if test="industryIndexName != null">industry_index_name,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="stockCode != null">#{stockCode},</if>
<if test="stockName != null">#{stockName},</if>
<if test="listingDate != null">#{listingDate},</if>
<if test="listingDays != null">#{listingDays},</if>
<if test="isSt != null">#{isSt},</if>
<if test="isStarSt != null">#{isStarSt},</if>
<if test="industryIndexCode != null">#{industryIndexCode},</if>
<if test="industryIndexName != null">#{industryIndexName},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateStockBasic" parameterType="com.ruoyi.newstocksystem.domain.StockBasic">
update t_stock_basic
<set>
<if test="stockName != null">stock_name = #{stockName},</if>
<if test="listingDate != null">listing_date = #{listingDate},</if>
<if test="listingDays != null">listing_days = #{listingDays},</if>
<if test="isSt != null">is_st = #{isSt},</if>
<if test="isStarSt != null">is_star_st = #{isStarSt},</if>
<if test="industryIndexCode != null">industry_index_code = #{industryIndexCode},</if>
<if test="industryIndexName != null">industry_index_name = #{industryIndexName},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</set>
where stock_code = #{stockCode}
</update>
<delete id="deleteStockBasic" parameterType="string">
delete from t_stock_basic
where stock_code = #{stockCode}
</delete>
</mapper>

@ -0,0 +1,126 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.ruoyi.newstocksystem.mapper.StockDailyTradeMapper">
<resultMap type="com.ruoyi.newstocksystem.domain.StockDailyTrade" id="StockDailyTradeResult">
<id property="stockCode" column="stock_code" />
<result property="tradeDate" column="trade_date" />
<result property="openPrice" column="open_price" />
<result property="closePrice" column="close_price" />
<result property="highPrice" column="high_price" />
<result property="lowPrice" column="low_price" />
<result property="priceChangeRate" column="price_change_rate" />
<result property="volume" column="volume" />
<result property="turnover" column="turnover" />
<result property="freeCirculationCap" column="free_circulation_cap"/>
<result property="isLimitUp" column="is_limit_up" />
<result property="isLimitDown" column="is_limit_down" />
<result property="momentum10d" column="momentum_10d" />
<result property="momentum20d" column="momentum_20d" />
<result property="momentum60d" column="momentum_60d" />
<result property="createTime" column="create_time" />
</resultMap>
<sql id="selectStockDailyTradeVo">
select stock_code, trade_date, open_price, close_price, high_price, low_price, price_change_rate, volume, turnover, free_circulation_cap, is_limit_up, is_limit_down, momentum_10d, momentum_20d, momentum_60d, create_time
from t_stock_daily_trade
</sql>
<select id="selectStockDailyTradeByCodeAndDate" resultMap="StockDailyTradeResult">
<include refid="selectStockDailyTradeVo" />
where stock_code = #{stockCode} and trade_date = #{tradeDate}
</select>
<select id="selectStockDailyTradeList" parameterType="com.ruoyi.newstocksystem.domain.StockDailyTrade" resultMap="StockDailyTradeResult">
<include refid="selectStockDailyTradeVo" />
<where>
<if test="stockCode != null and stockCode != ''">
and stock_code = #{stockCode}
</if>
<if test="tradeDate != null">
and trade_date = #{tradeDate}
</if>
<if test="isLimitUp != null">
and is_limit_up = #{isLimitUp}
</if>
<if test="isLimitDown != null">
and is_limit_down = #{isLimitDown}
</if>
</where>
</select>
<select id="selectStockDailyTradeByDate" parameterType="date" resultMap="StockDailyTradeResult">
<include refid="selectStockDailyTradeVo" />
where trade_date = #{tradeDate}
</select>
<select id="selectStockDailyTradeByCode" parameterType="string" resultMap="StockDailyTradeResult">
<include refid="selectStockDailyTradeVo" />
where stock_code = #{stockCode}
order by trade_date desc
</select>
<insert id="insertStockDailyTrade" parameterType="com.ruoyi.newstocksystem.domain.StockDailyTrade">
insert into t_stock_daily_trade
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="stockCode != null">stock_code,</if>
<if test="tradeDate != null">trade_date,</if>
<if test="openPrice != null">open_price,</if>
<if test="closePrice != null">close_price,</if>
<if test="highPrice != null">high_price,</if>
<if test="lowPrice != null">low_price,</if>
<if test="priceChangeRate != null">price_change_rate,</if>
<if test="volume != null">volume,</if>
<if test="turnover != null">turnover,</if>
<if test="freeCirculationCap != null">free_circulation_cap,</if>
<if test="isLimitUp != null">is_limit_up,</if>
<if test="isLimitDown != null">is_limit_down,</if>
<if test="momentum10d != null">momentum_10d,</if>
<if test="momentum20d != null">momentum_20d,</if>
<if test="momentum60d != null">momentum_60d,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="stockCode != null">#{stockCode},</if>
<if test="tradeDate != null">#{tradeDate},</if>
<if test="openPrice != null">#{openPrice},</if>
<if test="closePrice != null">#{closePrice},</if>
<if test="highPrice != null">#{highPrice},</if>
<if test="lowPrice != null">#{lowPrice},</if>
<if test="priceChangeRate != null">#{priceChangeRate},</if>
<if test="volume != null">#{volume},</if>
<if test="turnover != null">#{turnover},</if>
<if test="freeCirculationCap != null">#{freeCirculationCap},</if>
<if test="isLimitUp != null">#{isLimitUp},</if>
<if test="isLimitDown != null">#{isLimitDown},</if>
<if test="momentum10d != null">#{momentum10d},</if>
<if test="momentum20d != null">#{momentum20d},</if>
<if test="momentum60d != null">#{momentum60d},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<update id="updateStockDailyTrade" parameterType="com.ruoyi.newstocksystem.domain.StockDailyTrade">
update t_stock_daily_trade
<set>
<if test="openPrice != null">open_price = #{openPrice},</if>
<if test="closePrice != null">close_price = #{closePrice},</if>
<if test="highPrice != null">high_price = #{highPrice},</if>
<if test="lowPrice != null">low_price = #{lowPrice},</if>
<if test="priceChangeRate != null">price_change_rate = #{priceChangeRate},</if>
<if test="volume != null">volume = #{volume},</if>
<if test="turnover != null">turnover = #{turnover},</if>
<if test="freeCirculationCap != null">free_circulation_cap = #{freeCirculationCap},</if>
<if test="isLimitUp != null">is_limit_up = #{isLimitUp},</if>
<if test="isLimitDown != null">is_limit_down = #{isLimitDown},</if>
<if test="momentum10d != null">momentum_10d = #{momentum10d},</if>
<if test="momentum20d != null">momentum_20d = #{momentum20d},</if>
<if test="momentum60d != null">momentum_60d = #{momentum60d},</if>
</set>
where stock_code = #{stockCode} and trade_date = #{tradeDate}
</update>
<delete id="deleteStockDailyTrade">
delete from t_stock_daily_trade
where stock_code = #{stockCode} and trade_date = #{tradeDate}
</delete>
</mapper>

@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.ruoyi.newstocksystem.mapper.StockHighLowStatusMapper">
<resultMap type="com.ruoyi.newstocksystem.domain.StockHighLowStatus" id="StockHighLowStatusResult">
<id property="stockCode" column="stock_code" />
<result property="tradeDate" column="trade_date" />
<result property="isNewHigh" column="is_new_high" />
<result property="newHighDate" column="new_high_date" />
<result property="isNewLow" column="is_new_low" />
<result property="newLowDate" column="new_low_date" />
<result property="createTime" column="create_time" />
</resultMap>
<sql id="selectStockHighLowStatusVo">
select stock_code, trade_date, is_new_high, new_high_date, is_new_low, new_low_date, create_time
from t_stock_high_low_status
</sql>
<select id="selectStockHighLowStatusByCodeAndDate" resultMap="StockHighLowStatusResult">
<include refid="selectStockHighLowStatusVo" />
where stock_code = #{stockCode} and trade_date = #{tradeDate}
</select>
<select id="selectStockHighLowStatusList" parameterType="com.ruoyi.newstocksystem.domain.StockHighLowStatus" resultMap="StockHighLowStatusResult">
<include refid="selectStockHighLowStatusVo" />
<where>
<if test="stockCode != null and stockCode != ''">
and stock_code = #{stockCode}
</if>
<if test="tradeDate != null">
and trade_date = #{tradeDate}
</if>
<if test="isNewHigh != null">
and is_new_high = #{isNewHigh}
</if>
<if test="isNewLow != null">
and is_new_low = #{isNewLow}
</if>
</where>
</select>
<select id="selectNewHighStocks" parameterType="date" resultMap="StockHighLowStatusResult">
<include refid="selectStockHighLowStatusVo" />
where is_new_high = 1 and trade_date = #{tradeDate}
</select>
<select id="selectNewLowStocks" parameterType="date" resultMap="StockHighLowStatusResult">
<include refid="selectStockHighLowStatusVo" />
where is_new_low = 1 and trade_date = #{tradeDate}
</select>
<insert id="insertStockHighLowStatus" parameterType="com.ruoyi.newstocksystem.domain.StockHighLowStatus">
insert into t_stock_high_low_status
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="stockCode != null">stock_code,</if>
<if test="tradeDate != null">trade_date,</if>
<if test="isNewHigh != null">is_new_high,</if>
<if test="newHighDate != null">new_high_date,</if>
<if test="isNewLow != null">is_new_low,</if>
<if test="newLowDate != null">new_low_date,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="stockCode != null">#{stockCode},</if>
<if test="tradeDate != null">#{tradeDate},</if>
<if test="isNewHigh != null">#{isNewHigh},</if>
<if test="newHighDate != null">#{newHighDate},</if>
<if test="isNewLow != null">#{isNewLow},</if>
<if test="newLowDate != null">#{newLowDate},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<update id="updateStockHighLowStatus" parameterType="com.ruoyi.newstocksystem.domain.StockHighLowStatus">
update t_stock_high_low_status
<set>
<if test="isNewHigh != null">is_new_high = #{isNewHigh},</if>
<if test="newHighDate != null">new_high_date = #{newHighDate},</if>
<if test="isNewLow != null">is_new_low = #{isNewLow},</if>
<if test="newLowDate != null">new_low_date = #{newLowDate},</if>
</set>
where stock_code = #{stockCode} and trade_date = #{tradeDate}
</update>
<delete id="deleteStockHighLowStatus">
delete from t_stock_high_low_status
where stock_code = #{stockCode} and trade_date = #{tradeDate}
</delete>
</mapper>

@ -1,34 +1,38 @@
-- 个股每日交易数据表大表按“交易日期”按月分区MySQL原生分区
-- 个股每日交易数据表分区表去掉外键解决MySQL限制
-- t_stock_daily_trade stock_code t_stock_basic
--
-- 在执行 LOAD DATA INFILE 导入数据前,先通过 SQL 过滤掉 “不存在的 stock_code”适用于每日批量导入场景与你之前的导入脚本结合
CREATE TABLE `t_stock_daily_trade` (
`stock_code` VARCHAR(20) NOT NULL COMMENT '证券代码关联t_stock_basic',
`trade_date` DATE NOT NULL COMMENT '交易日期',
`open_price` DECIMAL(10,2) NULL COMMENT '开盘价(单位:元)',
`close_price` DECIMAL(10,2) NOT NULL COMMENT '收盘价(单位:元)',
`high_price` DECIMAL(10,2) NULL COMMENT '最高价(单位:元)',
`low_price` DECIMAL(10,2) NULL COMMENT '最低价(单位:元)',
`price_change_rate` DECIMAL(6,4) NULL COMMENT '当日涨跌幅(百分比)',
`volume` BIGINT NULL COMMENT '成交量(单位:股)',
`turnover` DECIMAL(20,2) NULL COMMENT '成交额(单位:万元)',
`free_circulation_cap` DECIMAL(20,2) NULL COMMENT '自由流通市值(单位:万元)',
`is_limit_up` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否涨停1=是0=否)',
`is_limit_down` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否跌停1=是0=否)',
`momentum_10d` DECIMAL(6,4) NULL COMMENT '10日动量涨跌幅',
`momentum_20d` DECIMAL(6,4) NULL COMMENT '20日动量涨跌幅',
`momentum_60d` DECIMAL(6,4) NULL COMMENT '60日动量涨跌幅',
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '数据创建时间',
-- 复合主键:确保“个股代码+日期”唯一
PRIMARY KEY (`stock_code`, `trade_date`),
-- 外键:关联个股基础表,确保个股代码有效性
FOREIGN KEY (`stock_code`)
REFERENCES `t_stock_basic` (`stock_code`)
ON UPDATE RESTRICT ON DELETE RESTRICT,
-- 索引:优化按日期查询所有个股交易数据的场景
INDEX `idx_t_stock_daily_trade_date` (`trade_date`)
`stock_code` VARCHAR(20) NOT NULL COMMENT '证券代码关联t_stock_basic通过应用层校验一致性',
`trade_date` DATE NOT NULL COMMENT '交易日期',
`open_price` DECIMAL(10,2) NULL COMMENT '开盘价(单位:元)',
`close_price` DECIMAL(10,2) NOT NULL COMMENT '收盘价(单位:元)',
`high_price` DECIMAL(10,2) NULL COMMENT '最高价(单位:元)',
`low_price` DECIMAL(10,2) NULL COMMENT '最低价(单位:元)',
`price_change_rate` DECIMAL(6,4) NULL COMMENT '当日涨跌幅(百分比)',
`volume` BIGINT NULL COMMENT '成交量(单位:股)',
`turnover` DECIMAL(20,2) NULL COMMENT '成交额(单位:万元)',
`free_circulation_cap` DECIMAL(20,2) NULL COMMENT '自由流通市值(单位:万元)',
`is_limit_up` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否涨停1=是0=否)',
`is_limit_down` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否跌停1=是0=否)',
`momentum_10d` DECIMAL(6,4) NULL COMMENT '10日动量涨跌幅',
`momentum_20d` DECIMAL(6,4) NULL COMMENT '20日动量涨跌幅',
`momentum_60d` DECIMAL(6,4) NULL COMMENT '60日动量涨跌幅',
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '数据创建时间',
-- 复合主键:确保“个股代码+日期”唯一(保留原设计)
PRIMARY KEY (`stock_code`, `trade_date`),
-- 索引:优化按日期、个股代码的查询(保留原设计)
INDEX `idx_t_stock_daily_trade_date` (`trade_date`),
INDEX `idx_t_stock_daily_trade_code` (`stock_code`) -- 新增:优化按个股查询的效率
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
-- 按“交易日期”按月分区示例2024年12月-2025年3月后续可扩展
-- 表注释:移到分区前(之前已修复的语法问题)
COMMENT='A股个股每日交易数据-按月分区'
-- 按月分区(保留原设计,确保性能优势)
PARTITION BY RANGE (TO_DAYS(`trade_date`)) (
PARTITION `p202412` VALUES LESS THAN (TO_DAYS('2025-01-01')) COMMENT '2024年12月数据',
PARTITION `p202501` VALUES LESS THAN (TO_DAYS('2025-02-01')) COMMENT '2025年1月数据',
PARTITION `p202502` VALUES LESS THAN (TO_DAYS('2025-03-01')) COMMENT '2025年2月数据',
PARTITION `p202503` VALUES LESS THAN (TO_DAYS('2025-04-01')) COMMENT '2025年3月数据'
) COMMENT='A股个股每日交易数据按月分区';
);

@ -1,23 +1,20 @@
-- 个股新高新低状态表存储300天新高新低信息
-- 个股新高新低状态表去掉外键兼容MySQL分区表限制
-- 同样需要增加导入前检验
CREATE TABLE `t_stock_high_low_status` (
`stock_code` VARCHAR(20) NOT NULL COMMENT '证券代码关联t_stock_basic',
`trade_date` DATE NOT NULL COMMENT '交易日期',
`is_new_high` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否创阶段新高1=是0=否)',
`new_high_date` DATE NULL COMMENT '区间最高价日(创新高时填充)',
`is_new_low` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否创阶段新低1=是0=否)',
`new_low_date` DATE NULL COMMENT '区间最低价日(创新低时填充)',
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '数据创建时间',
-- 复合主键:确保“个股代码+日期”唯一
PRIMARY KEY (`stock_code`, `trade_date`),
-- 外键1关联个股基础表
FOREIGN KEY (`stock_code`)
REFERENCES `t_stock_basic` (`stock_code`)
ON UPDATE RESTRICT ON DELETE RESTRICT,
-- 外键2关联个股交易表确保“个股+日期”的交易数据存在
FOREIGN KEY (`stock_code`, `trade_date`)
REFERENCES `t_stock_daily_trade` (`stock_code`, `trade_date`)
ON UPDATE RESTRICT ON DELETE RESTRICT,
-- 索引:优化“查询某日所有新高/新低个股”的场景
INDEX `idx_t_stock_high_low_high` (`is_new_high`, `trade_date`),
INDEX `idx_t_stock_high_low_low` (`is_new_low`, `trade_date`)
`stock_code` VARCHAR(20) NOT NULL COMMENT '证券代码关联t_stock_basic导入前校验',
`trade_date` DATE NOT NULL COMMENT '交易日期',
`is_new_high` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否创阶段新高1=是0=否)',
`new_high_date` DATE NULL COMMENT '区间最高价日(创新高时填充)',
`is_new_low` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否创阶段新低1=是0=否)',
`new_low_date` DATE NULL COMMENT '区间最低价日(创新低时填充)',
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '数据创建时间',
-- 复合主键:确保“个股代码+日期”唯一(保留原设计)
PRIMARY KEY (`stock_code`, `trade_date`),
-- 索引:优化新高/新低查询(保留原设计)
INDEX `idx_t_stock_high_low_high` (`is_new_high`, `trade_date`),
INDEX `idx_t_stock_high_low_low` (`is_new_low`, `trade_date`),
-- 新增索引优化关联t_stock_daily_trade的查询效率
INDEX `idx_t_stock_high_low_code_date` (`stock_code`, `trade_date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='A股个股300天新高新低状态';
Loading…
Cancel
Save