feat:gnshyx数据拉取

This commit is contained in:
xiang
2025-09-17 21:49:06 +08:00
parent 7c2e648831
commit e00916399d
16 changed files with 480 additions and 7 deletions

View File

@@ -15,7 +15,8 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@MapperScan(basePackages = { @MapperScan(basePackages = {
"com.xiang.xservice.fwd.mapper", "com.xiang.xservice.fwd.mapper",
"com.xiang.xservice.glados.repository", "com.xiang.xservice.glados.repository",
"com.xiang.xservice.xb.repository" "com.xiang.xservice.xb.repository",
"com.xiang.xservice.stock.gnshyx.mapper",
}) })
@ConfigurationPropertiesScan(basePackages = { @ConfigurationPropertiesScan(basePackages = {
"com.xiang.xservice.config" "com.xiang.xservice.config"

View File

@@ -29,13 +29,13 @@ public class IndexController {
private String url; private String url;
@GetMapping("/index") @GetMapping("/index")
public Result<Void> index() { public Result<String> index() {
String msg = "已激活环境:" + env + "web端口启用" + port + "使用datasource:" + url; String msg = "已激活环境:" + env + "web端口启用" + port + "使用datasource:" + url;
return Result.success(msg); return Result.success(msg);
} }
@GetMapping("/redisTest") @GetMapping("/redisTest")
private Result<Void> redisTest() { private Result<String> redisTest() {
redisTemplate.opsForValue().set("2222", "231"); redisTemplate.opsForValue().set("2222", "231");
return Result.success("redis获取到key为test的值为" + redisTemplate.opsForValue().get("2222")); return Result.success("redis获取到key为test的值为" + redisTemplate.opsForValue().get("2222"));

View File

@@ -41,7 +41,7 @@ public class DynamicDomainController {
} }
@PostMapping("/ddns") @PostMapping("/ddns")
public Result<Void> dynamicDomainAnalysis() { public Result<String> dynamicDomainAnalysis() {
try { try {
String publicIp = IpUtils.getPublicIp(); String publicIp = IpUtils.getPublicIp();
log.info("获取公网IP成功time:{}, ip:{}", LocalDateTime.now(), publicIp); log.info("获取公网IP成功time:{}, ip:{}", LocalDateTime.now(), publicIp);

View File

@@ -29,7 +29,7 @@ public class FwdDataController {
private final IPerformServiceHttp performServiceHttp; private final IPerformServiceHttp performServiceHttp;
@PostMapping("/refreshData") @PostMapping("/refreshData")
public Result<Void> refreshData() { public Result<String> refreshData() {
List<FPerformConfig> availablePerforms = performService.getAvailablePerform(); List<FPerformConfig> availablePerforms = performService.getAvailablePerform();
for (FPerformConfig availablePerform : availablePerforms) { for (FPerformConfig availablePerform : availablePerforms) {
ProjectInfoResp info = performServiceHttp.getProjectInfoFromHttp(availablePerform.getProjectId()); ProjectInfoResp info = performServiceHttp.getProjectInfoFromHttp(availablePerform.getProjectId());

View File

@@ -50,7 +50,7 @@ public class FwdOuterController {
} }
@PostMapping("/createOrder") @PostMapping("/createOrder")
public Result<Void> createOrder(Long projectId) throws Exception { public Result<String> createOrder(Long projectId) throws Exception {
if (performService.createProjectOrder(projectId, FREQUENT_IDS)) { if (performService.createProjectOrder(projectId, FREQUENT_IDS)) {
return Result.success("下单成功!"); return Result.success("下单成功!");
} }

View File

@@ -22,7 +22,7 @@ public class GLaDOSController {
private final GLaDOSService glaDOSService; private final GLaDOSService glaDOSService;
@PostMapping("/checkIn") @PostMapping("/checkIn")
public Result<Void> checkIn(@RequestBody GladosCheckInReq request) { public Result<String> checkIn(@RequestBody GladosCheckInReq request) {
return Result.success(glaDOSService.checkIn()); return Result.success(glaDOSService.checkIn());
} }

View File

@@ -0,0 +1,12 @@
package com.xiang.xservice.stock.gnshyx.common.constants;
public class UrlConstant {
public final static String BASE_URL = "https://gnshyx.cloudgn.com";
public final static String URL_PREFIX = "/prod-api";
public final static String LAST_PRICE = BASE_URL + "/price/lastprice";
public final static String LAST_LIST = BASE_URL + URL_PREFIX + "/public/stockDailySelection/listLast";
}

View File

@@ -0,0 +1,78 @@
package com.xiang.xservice.stock.gnshyx.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class StockGnshyxRecordDataDO {
/**
* id
*/
private Long id;
/**
* 名称
*/
private String symbolName;
/**
* 股票名称
*/
private String stockName;
/**
* 目标价格
*/
private BigDecimal attentionPrice;
/**
* 关注价格低位
*/
private BigDecimal targetPriceLow;
/**
* 关注价格高位
*/
private BigDecimal targetPriceHigh;
/**
* 止损价位
*/
private BigDecimal stopPrice;
/**
* 系统每日选择id
*/
private Long stockDailySelectionId;
/**
* 股票代码
*/
private String stockCode;
/**
* 生成时间
*/
private LocalDateTime selectionTime;
/**
* maximum_increase
*/
private String maximumIncrease;
/**
* maximum_increase_seven
*/
private String maximumIncreaseSeven;
/**
* 创建时间
*/
private LocalDateTime createTime;
}

View File

@@ -0,0 +1,21 @@
package com.xiang.xservice.stock.gnshyx.entity.resp;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class GnshyxBaseResp {
private Integer code;
private String msg;
@JSONField(name = "server_time")
private Long serverTime;
private String data;
}

View File

@@ -0,0 +1,63 @@
package com.xiang.xservice.stock.gnshyx.entity.resp;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ListLastDataResp {
/**
* 选择id
*/
private Long stockDailySelectionId;
/**
* 股票代码
*/
private String stockCode;
/**
* 股票名称
*/
private String stockName;
/**
* 标识名称
*/
private String symbolName;
/**
* 目标价格
*/
private BigDecimal attentionPrice;
/**
* 关注价格低位
*/
private BigDecimal targetPriceLow;
/**
* 关注价格高位
*/
private BigDecimal targetPriceHigh;
/**
* 止损价格
*/
private BigDecimal stopPrice;
private String maximumIncrease;
private String maximumIncreaseSeven;
/**
* 生成时间
*/
private String selectionTime;
}

View File

@@ -0,0 +1,6 @@
package com.xiang.xservice.stock.gnshyx.enums;
public enum GnshyxUrlEnum {
}

View File

@@ -0,0 +1,20 @@
package com.xiang.xservice.stock.gnshyx.mapper;
import com.xiang.xservice.stock.gnshyx.entity.StockGnshyxRecordDataDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
@Mapper
public interface StockGnshyxRecordDataMapper {
/**
* 批量新增
* @param entities
* @return
*/
int batchInsertRecord(@Param("list") List<StockGnshyxRecordDataDO> entities);
}

View File

@@ -0,0 +1,69 @@
package com.xiang.xservice.stock.gnshyx.schedule;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.xiang.xservice.basic.utils.DateUtils;
import com.xiang.xservice.basic.utils.HttpUtils;
import com.xiang.xservice.stock.gnshyx.common.constants.UrlConstant;
import com.xiang.xservice.stock.gnshyx.entity.StockGnshyxRecordDataDO;
import com.xiang.xservice.stock.gnshyx.entity.resp.ListLastDataResp;
import com.xiang.xservice.stock.gnshyx.service.ICloudRecordDataService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.List;
@Slf4j
@RequiredArgsConstructor
@Component
public class CloudRecordDataJob {
private final ICloudRecordDataService cloudRecordDataService;
@Scheduled(cron = "0 0/1 * * * ? ")
public void gnshyxRecordDataPullJob() {
log.info("<<<<<gnshyx数据拉取定时任务开始>>>>> 时间戳:{}", System.currentTimeMillis());
String resp = HttpUtils.doGet(UrlConstant.LAST_LIST, null, null);
if (StringUtils.isBlank(resp)) {
log.error("{}请求失败,响应结果为空, time:{}", UrlConstant.LAST_LIST, System.currentTimeMillis());
return;
}
JSONObject jsonObject = JSONObject.parseObject(resp);
Integer code = (Integer) jsonObject.get("code");
if (200 == code) {
String data = JSON.toJSONString(jsonObject.get("data"));
log.info("查询到的数据结果:{}", data);
List<ListLastDataResp> dataRespList = JSON.parseArray(data, ListLastDataResp.class);
if (CollectionUtils.isNotEmpty(dataRespList)) {
List<StockGnshyxRecordDataDO> results = Lists.newArrayList();
for (ListLastDataResp listLastDataResp : dataRespList) {
StockGnshyxRecordDataDO stockGnshyxRecordDataDO = new StockGnshyxRecordDataDO();
stockGnshyxRecordDataDO.setSymbolName(listLastDataResp.getSymbolName());
stockGnshyxRecordDataDO.setStockName(listLastDataResp.getStockName());
stockGnshyxRecordDataDO.setAttentionPrice(listLastDataResp.getAttentionPrice());
stockGnshyxRecordDataDO.setTargetPriceLow(listLastDataResp.getTargetPriceLow());
stockGnshyxRecordDataDO.setTargetPriceHigh(listLastDataResp.getTargetPriceHigh());
stockGnshyxRecordDataDO.setStopPrice(listLastDataResp.getStopPrice());
stockGnshyxRecordDataDO.setStockDailySelectionId(listLastDataResp.getStockDailySelectionId());
stockGnshyxRecordDataDO.setStockCode(listLastDataResp.getStockCode());
stockGnshyxRecordDataDO.setSelectionTime(DateUtils.getDateTimeFromStr(listLastDataResp.getSelectionTime()));
stockGnshyxRecordDataDO.setMaximumIncrease(listLastDataResp.getMaximumIncrease());
stockGnshyxRecordDataDO.setMaximumIncreaseSeven(listLastDataResp.getMaximumIncreaseSeven());
stockGnshyxRecordDataDO.setCreateTime(LocalDateTime.now());
results.add(stockGnshyxRecordDataDO);
}
if (CollectionUtils.isNotEmpty(results)) {
cloudRecordDataService.batchInsertRecord(results);
}
}
}
}
}

View File

@@ -0,0 +1,18 @@
package com.xiang.xservice.stock.gnshyx.service;
import com.xiang.xservice.stock.gnshyx.entity.StockGnshyxRecordDataDO;
import com.xiang.xservice.stock.gnshyx.mapper.StockGnshyxRecordDataMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@RequiredArgsConstructor
public class CloudRecordDataServiceImpl implements ICloudRecordDataService {
private final StockGnshyxRecordDataMapper stockGnshyxRecordDataMapper;
@Override
public Boolean batchInsertRecord(List<StockGnshyxRecordDataDO> list) {
return stockGnshyxRecordDataMapper.batchInsertRecord(list) > 0;
}
}

View File

@@ -0,0 +1,10 @@
package com.xiang.xservice.stock.gnshyx.service;
import com.xiang.xservice.stock.gnshyx.entity.StockGnshyxRecordDataDO;
import java.util.List;
public interface ICloudRecordDataService {
Boolean batchInsertRecord(List<StockGnshyxRecordDataDO> list);
}

View File

@@ -0,0 +1,175 @@
<?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.xiang.xservice.stock.gnshyx.mapper.StockGnshyxRecordDataMapper">
<resultMap id="BaseResultMap" type="com.xiang.xservice.stock.gnshyx.entity.StockGnshyxRecordDataDO" >
<result column="id" property="id" />
<result column="symbol_name" property="symbolName" />
<result column="stock_name" property="stockName" />
<result column="attention_price" property="attentionPrice" />
<result column="target_price_low" property="targetPriceLow" />
<result column="target_price_high" property="targetPriceHigh" />
<result column="stop_price" property="stopPrice" />
<result column="stock_daily_selection_id" property="stockDailySelectionId" />
<result column="stock_code" property="stockCode" />
<result column="selection_time" property="selectionTime" />
<result column="maximum_increase" property="maximumIncrease" />
<result column="maximum_increase_seven" property="maximumIncreaseSeven" />
<result column="create_time" property="createTime" />
</resultMap>
<sql id="Base_Column_List">
id,
symbol_name,
stock_name,
attention_price,
target_price_low,
target_price_high,
stop_price,
stock_daily_selection_id,
stock_code,
selection_time,
maximum_increase,
maximum_increase_seven,
create_time
</sql>
<insert id="insert" useGeneratedKeys="true" keyColumn="id" keyProperty="id" parameterType="com.xiang.xservice.stock.gnshyx.entity.StockGnshyxRecordDataDO">
INSERT INTO stock_gnshyx_record_data
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="null != symbolName and '' != symbolName">
symbol_name,
</if>
<if test="null != stockName and '' != stockName">
stock_name,
</if>
<if test="null != attentionPrice ">
attention_price,
</if>
<if test="null != targetPriceLow ">
target_price_low,
</if>
<if test="null != targetPriceHigh ">
target_price_high,
</if>
<if test="null != stopPrice ">
stop_price,
</if>
<if test="null != stockDailySelectionId ">
stock_daily_selection_id,
</if>
<if test="null != stockCode and '' != stockCode">
stock_code,
</if>
<if test="null != selectionTime ">
selection_time,
</if>
<if test="null != maximumIncrease and '' != maximumIncrease">
maximum_increase,
</if>
<if test="null != maximumIncreaseSeven and '' != maximumIncreaseSeven">
maximum_increase_seven,
</if>
<if test="null != createTime ">
create_time
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="null != symbolName and '' != symbolName">
#{symbolName},
</if>
<if test="null != stockName and '' != stockName">
#{stockName},
</if>
<if test="null != attentionPrice ">
#{attentionPrice},
</if>
<if test="null != targetPriceLow ">
#{targetPriceLow},
</if>
<if test="null != targetPriceHigh ">
#{targetPriceHigh},
</if>
<if test="null != stopPrice ">
#{stopPrice},
</if>
<if test="null != stockDailySelectionId ">
#{stockDailySelectionId},
</if>
<if test="null != stockCode and '' != stockCode">
#{stockCode},
</if>
<if test="null != selectionTime ">
#{selectionTime},
</if>
<if test="null != maximumIncrease and '' != maximumIncrease">
#{maximumIncrease},
</if>
<if test="null != maximumIncreaseSeven and '' != maximumIncreaseSeven">
#{maximumIncreaseSeven},
</if>
<if test="null != createTime ">
#{createTime}
</if>
</trim>
</insert>
<insert id="batchInsertRecord">
insert into stock_gnshyx_record_data(symbol_name,
stock_name,
attention_price,
target_price_low,
target_price_high,
stop_price,
stock_daily_selection_id,
stock_code,
selection_time,
maximum_increase,
maximum_increase_seven,
create_time)
values
<foreach collection="list" item="item" separator=",">
(
#{item.symbolName},
#{item.stockName},
#{item.attentionPrice},
#{item.targetPriceLow},
#{item.targetPriceHigh},
#{item.stopPrice},
#{item.stockDailySelectionId},
#{item.stockCode},
#{item.selectionTime},
#{item.maximumIncrease},
#{item.maximumIncreaseSeven},
#{item.createTime}
)
</foreach>
</insert>
<delete id="delete" >
DELETE FROM stock_gnshyx_record_data
WHERE id = #{id}
</delete>
<update id="update" parameterType="com.xiang.xservice.stock.gnshyx.entity.StockGnshyxRecordDataDO">
UPDATE stock_gnshyx_record_data
<set>
<if test="null != symbolName and '' != symbolName">symbol_name = #{symbolName},</if>
<if test="null != stockName and '' != stockName">stock_name = #{stockName},</if>
<if test="null != attentionPrice ">attention_price = #{attentionPrice},</if>
<if test="null != targetPriceLow ">target_price_low = #{targetPriceLow},</if>
<if test="null != targetPriceHigh ">target_price_high = #{targetPriceHigh},</if>
<if test="null != stopPrice ">stop_price = #{stopPrice},</if>
<if test="null != stockDailySelectionId ">stock_daily_selection_id = #{stockDailySelectionId},</if>
<if test="null != stockCode and '' != stockCode">stock_code = #{stockCode},</if>
<if test="null != selectionTime ">selection_time = #{selectionTime},</if>
<if test="null != maximumIncrease and '' != maximumIncrease">maximum_increase = #{maximumIncrease},</if>
<if test="null != maximumIncreaseSeven and '' != maximumIncreaseSeven">maximum_increase_seven = #{maximumIncreaseSeven},</if>
<if test="null != createTime ">create_time = #{createTime}</if>
</set>
WHERE id = #{id}
</update>
</mapper>