API接口全部完成
This commit is contained in:
parent
c6ee4fd46a
commit
cfe5755a07
32
pom.xml
32
pom.xml
@ -54,21 +54,6 @@
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.13</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.hazelcast</groupId>
|
||||
<artifactId>hazelcast</artifactId>
|
||||
<version>5.3.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.hazelcast</groupId>
|
||||
<artifactId>hazelcast-sql</artifactId>
|
||||
<version>5.3.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.hazelcast</groupId>
|
||||
<artifactId>hazelcast-spring</artifactId>
|
||||
<version>5.3.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
@ -95,19 +80,6 @@
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.8.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jsoup</groupId>
|
||||
<artifactId>jsoup</artifactId>
|
||||
<version>1.9.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tencentcloudapi</groupId>
|
||||
<artifactId>tencentcloud-sdk-java</artifactId>
|
||||
<!-- go to https://search.maven.org/search?q=tencentcloud-sdk-java and get the latest version. -->
|
||||
<!-- 请到https://search.maven.org/search?q=tencentcloud-sdk-java查询所有版本,最新版本如下 -->
|
||||
<version>3.1.1142</version>
|
||||
</dependency>
|
||||
|
||||
<!-- SLF4J API: 用于记录日志 -->
|
||||
<dependency>
|
||||
@ -144,7 +116,7 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<mainClass>com.syzb.startup.Main</mainClass>
|
||||
<mainClass>com.diagnose.startup.Main</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
@ -158,7 +130,7 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<mainClass>com.syzb.startup.Main</mainClass>
|
||||
<mainClass>com.diagnose.startup.Main</mainClass>
|
||||
<layout>ZIP</layout>
|
||||
<includes>
|
||||
<include>
|
||||
|
||||
@ -1,47 +0,0 @@
|
||||
package com.diagnose.common.config.cache;
|
||||
|
||||
import com.hazelcast.config.InMemoryFormat;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.diagnose.common.config.cache.CacheKey.DISTRIBUTED_LOCK;
|
||||
|
||||
public class CacheConfig {
|
||||
|
||||
public static final String DEFAULT_MAP_NAME = "default";
|
||||
|
||||
public static class LocalMapConfig {
|
||||
public final int maxSize;
|
||||
public final int liveSeconds;
|
||||
public final InMemoryFormat inMemoryFormat;
|
||||
|
||||
LocalMapConfig(int maxSize, int liveSeconds) {
|
||||
this.maxSize = maxSize;
|
||||
this.liveSeconds = liveSeconds;
|
||||
this.inMemoryFormat = InMemoryFormat.BINARY;
|
||||
}
|
||||
|
||||
LocalMapConfig(int maxSize, int liveSeconds, InMemoryFormat inMemoryFormat) {
|
||||
this.maxSize = maxSize;
|
||||
this.liveSeconds = liveSeconds;
|
||||
this.inMemoryFormat = inMemoryFormat;
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<String, LocalMapConfig> getConfigMap() {
|
||||
// 设置近地缓存实时同步,不采用批量提交策略
|
||||
System.setProperty("hazelcast.map.invalidation.batch.enabled", "false");
|
||||
// PER_NODE:max-size指定单个集群成员中map条目的最大数量。这是max-size的默认策略。如果使用这个配置,需要注意max-size的值必须大于分区的数量(默认为271)。
|
||||
// PER_PARTITION:max-size指定每个分区存储的map条目最大数。这个策略建议不要在小规模的集群中使用,因为小规模的集群,单个节点包含了大量的分区,在执行回收策略时,会去按照分区的划分组个检查回收条件,导致效率低下。
|
||||
// USED_HEAP_SIZE:指在每个Hazelcast实例中,max-size指定map所占用的内存堆的(以megabytes计算,兆字节)最大值。需要注意这个策略不能工作在in-memory-format=OBJECT,因为当数据被设置为OBJECT时,无法确定所占用的内存大小。
|
||||
// USED_HEAP_PERCENTAGE:每个Hazelcast实例中,max-size指定map占用内存堆的百分比。例如,JVM被设置有1000MB,而这个值设置为max-size=10,当map条目数占用的堆数据超过100MB时,Hazelcast开始执行数据释放工作。需要注意的是当使用这个策略时,不能将in-memory-format设置为OBJECT,理由同上。
|
||||
// FREE_HEAP_SIZE:max-size指定了单个JVM的堆最小空闲空间,单位为megabytes。
|
||||
// FREE_HEAP_PERCENTAGE:max-size指定单个JVM的最小空闲空间的百分比。例如JVM分配了1000MB的空间,这个值设置为10,当空闲堆只有100MB时,会引发map的数据清除放行为。
|
||||
// 当map条数超过10000,会引发map的数据清除行为
|
||||
Map<String, LocalMapConfig> configMap = new HashMap<>();
|
||||
configMap.put(DISTRIBUTED_LOCK, new LocalMapConfig(1000, 0));
|
||||
|
||||
return configMap;
|
||||
}
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
package com.diagnose.common.config.cache;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class CacheKey {
|
||||
|
||||
public static class OnlyKeyObj implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj instanceof OnlyKeyObj;
|
||||
}
|
||||
}
|
||||
|
||||
// 缓存空对象,防止缓存穿透
|
||||
public static final Object ONLY_KEY_OBJ = new OnlyKeyObj();
|
||||
|
||||
// 分布式锁
|
||||
public static final String DISTRIBUTED_LOCK = "distributed_lock";
|
||||
|
||||
public static class LockKey {
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,91 +0,0 @@
|
||||
package com.diagnose.common.config.cache;
|
||||
|
||||
import com.hazelcast.config.*;
|
||||
import com.hazelcast.core.Hazelcast;
|
||||
import com.hazelcast.core.HazelcastInstance;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
import java.util.*;
|
||||
|
||||
@Configuration
|
||||
public class HazelcastConfiguration {
|
||||
|
||||
@Value("${hazelcast.members}")
|
||||
private String members;
|
||||
|
||||
@Value("${hazelcast.serverPort}")
|
||||
private Integer serverPort;
|
||||
|
||||
private Set<String> cacheNameSet = new HashSet<>();
|
||||
|
||||
@Bean
|
||||
public HazelcastInstance hazelcastInstance() {
|
||||
List<String> memberList = Arrays.asList(members.split(","));
|
||||
Config config = new Config();
|
||||
// hazelcast作为缓存服务端监听的端口
|
||||
config.getNetworkConfig().setPort(serverPort);
|
||||
// 如果目标缓存端口被占用,禁止重试其他端口
|
||||
config.getNetworkConfig().setPortAutoIncrement(false);
|
||||
config.getNetworkConfig().getJoin().getAutoDetectionConfig().setEnabled(false);
|
||||
config.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(true).setMembers(memberList);
|
||||
config.getJetConfig().setEnabled(true);
|
||||
String clusterName = "hazelcast-cluster";
|
||||
String instanceName = clusterName + "." + "localIP";
|
||||
config.setInstanceName(instanceName);
|
||||
config.setClusterName(clusterName);
|
||||
for (Map.Entry<String, CacheConfig.LocalMapConfig> entry : CacheConfig.getConfigMap().entrySet()) {
|
||||
String cacheName = entry.getKey();
|
||||
cacheNameSet.add(cacheName);
|
||||
config.addMapConfig(new MapConfig()
|
||||
.setName(cacheName)
|
||||
.setEvictionConfig(new EvictionConfig()
|
||||
.setEvictionPolicy(EvictionPolicy.LRU)
|
||||
.setSize(entry.getValue().maxSize)
|
||||
.setMaxSizePolicy(MaxSizePolicy.PER_NODE))
|
||||
.setTimeToLiveSeconds(entry.getValue().liveSeconds)
|
||||
// 近地缓存设置
|
||||
.setNearCacheConfig(new NearCacheConfig()
|
||||
.setInMemoryFormat(entry.getValue().inMemoryFormat)
|
||||
.setCacheLocalEntries(true)
|
||||
.setTimeToLiveSeconds(entry.getValue().liveSeconds / 2)
|
||||
.setEvictionConfig(new EvictionConfig()
|
||||
.setMaxSizePolicy(MaxSizePolicy.ENTRY_COUNT)
|
||||
.setSize(entry.getValue().maxSize / 2))
|
||||
// 预加载近地缓存,防止近地缓存穿透(暂时不启用)
|
||||
// .setPreloaderConfig(new NearCachePreloaderConfig()
|
||||
// .setEnabled(true))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// 默认map配置,主要用于USER_VIDEO_TOTAL_ONLINE + videoId
|
||||
config.addMapConfig(new MapConfig()
|
||||
.setName(CacheConfig.DEFAULT_MAP_NAME)
|
||||
.setNearCacheConfig(new NearCacheConfig()
|
||||
.setInMemoryFormat(InMemoryFormat.OBJECT)
|
||||
.setCacheLocalEntries(true)
|
||||
.setTimeToLiveSeconds(3600 * 10)
|
||||
.setMaxIdleSeconds(3600 * 2)
|
||||
.setEvictionConfig(new EvictionConfig()
|
||||
.setMaxSizePolicy(MaxSizePolicy.ENTRY_COUNT)
|
||||
.setSize(100000))
|
||||
));
|
||||
HazelcastInstance instance = Hazelcast.newHazelcastInstance(config);
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void cleanCache() {
|
||||
for (String cacheName : cacheNameSet) {
|
||||
hazelcastInstance().getMap(cacheName).clear();
|
||||
}
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void destroy() {
|
||||
hazelcastInstance().shutdown();
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
package com.diagnose.common.constant;
|
||||
|
||||
public enum ScheduleLogResult {
|
||||
|
||||
RUNNING(1, "执行中"),
|
||||
SUCCESS(2, "成功"),
|
||||
FAILURE(3, "失败");
|
||||
public final Integer value;
|
||||
|
||||
public final String name;
|
||||
|
||||
ScheduleLogResult(Integer value, String name) {
|
||||
this.value = value;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,208 +0,0 @@
|
||||
package com.diagnose.common.entity;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.diagnose.common.constant.ScheduleLogResult;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author helloSyzb
|
||||
* @since 2022-11-09
|
||||
*/
|
||||
public class ScheduleLog implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* 同步记录ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 服务名
|
||||
*/
|
||||
@TableField("server_name")
|
||||
private String serverName;
|
||||
|
||||
/**
|
||||
* 定时任务名称
|
||||
*/
|
||||
@TableField("schedule_name")
|
||||
private String scheduleName;
|
||||
|
||||
/**
|
||||
* 执行时间
|
||||
*/
|
||||
private LocalDate date;
|
||||
|
||||
/**
|
||||
* 实际开始时间
|
||||
*/
|
||||
@TableField("start_time")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
/**
|
||||
* 实际结束时间
|
||||
*/
|
||||
@TableField("end_time")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
/**
|
||||
* 执行结果:1:执行中 2:成功 3:失败
|
||||
*/
|
||||
private Integer result;
|
||||
|
||||
/**
|
||||
* 附加信息json
|
||||
*/
|
||||
private String ext;
|
||||
|
||||
/**
|
||||
* 异常信息
|
||||
*/
|
||||
private String error;
|
||||
|
||||
/**
|
||||
* 执行机器IP
|
||||
*/
|
||||
private String ip;
|
||||
|
||||
public static ScheduleLog start(String scheduleName, String ip) {
|
||||
String server = System.getProperty("server.server");
|
||||
ScheduleLog log = new ScheduleLog();
|
||||
log.setServerName(server);
|
||||
log.setScheduleName(scheduleName);
|
||||
log.setDate(LocalDate.now());
|
||||
log.setStartTime(LocalDateTime.now());
|
||||
log.setResult(ScheduleLogResult.RUNNING.value);
|
||||
log.setIp(ip);
|
||||
return log;
|
||||
}
|
||||
|
||||
public static ScheduleLog success(Integer id, String ext) {
|
||||
ScheduleLog log = new ScheduleLog();
|
||||
log.setId(id);
|
||||
log.setEndTime(LocalDateTime.now());
|
||||
log.setResult(ScheduleLogResult.SUCCESS.value);
|
||||
if (StrUtil.isNotEmpty(ext)) {
|
||||
log.setExt(ext);
|
||||
}
|
||||
return log;
|
||||
}
|
||||
|
||||
public static ScheduleLog error(Integer id, String error) {
|
||||
ScheduleLog log = new ScheduleLog();
|
||||
log.setId(id);
|
||||
log.setEndTime(LocalDateTime.now());
|
||||
log.setResult(ScheduleLogResult.FAILURE.value);
|
||||
if (StrUtil.isNotEmpty(error)) {
|
||||
log.setError(error);
|
||||
}
|
||||
return log;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getServerName() {
|
||||
return serverName;
|
||||
}
|
||||
|
||||
public void setServerName(String serverName) {
|
||||
this.serverName = serverName;
|
||||
}
|
||||
|
||||
public String getScheduleName() {
|
||||
return scheduleName;
|
||||
}
|
||||
|
||||
public void setScheduleName(String scheduleName) {
|
||||
this.scheduleName = scheduleName;
|
||||
}
|
||||
|
||||
public LocalDate getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(LocalDate date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public LocalDateTime getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(LocalDateTime startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public LocalDateTime getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(LocalDateTime endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public Integer getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(Integer result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public String getExt() {
|
||||
return ext;
|
||||
}
|
||||
|
||||
public void setExt(String ext) {
|
||||
this.ext = ext;
|
||||
}
|
||||
|
||||
public String getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
public void setError(String error) {
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ScheduleLog{" +
|
||||
"id=" + id +
|
||||
", serverName=" + serverName +
|
||||
", scheduleName=" + scheduleName +
|
||||
", date=" + date +
|
||||
", startTime=" + startTime +
|
||||
", endTime=" + endTime +
|
||||
", result=" + result +
|
||||
", ext=" + ext +
|
||||
", error=" + error +
|
||||
", ip=" + ip +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
package com.diagnose.common.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.diagnose.common.entity.ScheduleLog;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author helloSyzb
|
||||
* @since 2021-11-23
|
||||
*/
|
||||
public interface ScheduleLogMapper extends BaseMapper<ScheduleLog> {
|
||||
|
||||
}
|
||||
@ -1,62 +0,0 @@
|
||||
package com.diagnose.common.query;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class ListScheduleLogQuery {
|
||||
|
||||
private String serverName;
|
||||
|
||||
private String scheduleName;
|
||||
|
||||
@NotEmpty
|
||||
@NotNull
|
||||
private LocalDate date;
|
||||
|
||||
private Integer result;
|
||||
|
||||
@NotEmpty
|
||||
@NotNull
|
||||
private String token;
|
||||
|
||||
public String getServerName() {
|
||||
return serverName;
|
||||
}
|
||||
|
||||
public void setServerName(String serverName) {
|
||||
this.serverName = serverName;
|
||||
}
|
||||
|
||||
public String getScheduleName() {
|
||||
return scheduleName;
|
||||
}
|
||||
|
||||
public void setScheduleName(String scheduleName) {
|
||||
this.scheduleName = scheduleName;
|
||||
}
|
||||
|
||||
public LocalDate getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(LocalDate date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public Integer getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(Integer result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
}
|
||||
@ -1,317 +0,0 @@
|
||||
package com.diagnose.common.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.diagnose.common.config.cache.CacheKey;
|
||||
import com.diagnose.common.entity.ScheduleLog;
|
||||
import com.diagnose.common.handler.BizException;
|
||||
import com.diagnose.common.util.logger.LoggerUtil;
|
||||
import com.hazelcast.collection.ISet;
|
||||
import com.hazelcast.core.HazelcastInstance;
|
||||
import com.hazelcast.crdt.pncounter.PNCounter;
|
||||
import com.hazelcast.instance.impl.HazelcastInstanceProxy;
|
||||
import com.hazelcast.map.IMap;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.diagnose.common.config.cache.CacheKey.ONLY_KEY_OBJ;
|
||||
|
||||
@Component
|
||||
public class CacheService {
|
||||
|
||||
@Resource
|
||||
private ScheduleLogService scheduleLogService;
|
||||
|
||||
@Resource
|
||||
private HazelcastInstance hazelcastInstance;
|
||||
|
||||
private static final int UNLOCK_SLEEP_TIME = 5000;
|
||||
|
||||
private static final Set<String> loadedSet = new HashSet<>();
|
||||
|
||||
/**
|
||||
* 从缓存加载数据,未找到则执行load回调
|
||||
*
|
||||
* @param mapName cacheMap的名字
|
||||
* @param key cacheKey
|
||||
* @param load 加载数据回调
|
||||
* @param <T> 数据类型
|
||||
* @return
|
||||
*/
|
||||
public <T> T get(String mapName, String key, Callable<T> load) {
|
||||
Map<String, Object> cacheMap = hazelcastInstance.getMap(mapName);
|
||||
return this.get(cacheMap, key, load);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从缓存加载数据,未找到则执行load回调
|
||||
*
|
||||
* @param cacheMap cacheMap
|
||||
* @param key cacheKey
|
||||
* @param load 加载数据回调
|
||||
* @param <T> 数据类型
|
||||
* @return
|
||||
*/
|
||||
public <T> T get(Map<String, Object> cacheMap, String key, Callable<T> load) {
|
||||
Object obj = cacheMap.get(key);
|
||||
if (obj == null) {
|
||||
T result;
|
||||
try {
|
||||
result = load.call();
|
||||
} catch (BizException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (result == null) {
|
||||
// 防止缓存穿透
|
||||
cacheMap.put(key, ONLY_KEY_OBJ);
|
||||
return null;
|
||||
}
|
||||
cacheMap.put(key, result);
|
||||
return result;
|
||||
} else if (ONLY_KEY_OBJ.equals(obj)) {
|
||||
return null;
|
||||
}
|
||||
return (T) obj;
|
||||
}
|
||||
|
||||
public <T> ISet<T> getSet(String key, Callable<Set<T>> load) {
|
||||
ISet<T> iSet = hazelcastInstance.getSet(key);
|
||||
if (loadedSet.contains(key) || !iSet.isEmpty()) {
|
||||
loadedSet.add(key);
|
||||
return iSet;
|
||||
}
|
||||
simpleLock("task-getSet-" + key,
|
||||
0, TimeUnit.SECONDS,
|
||||
10, TimeUnit.SECONDS,
|
||||
() -> {
|
||||
try {
|
||||
Set<T> set = load.call();
|
||||
iSet.addAll(set);
|
||||
loadedSet.add(key);
|
||||
} catch (BizException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
return iSet;
|
||||
}
|
||||
|
||||
public <K, V> IMap<K, V> getMap(String key, Callable<Map<K, V>> load) {
|
||||
IMap<K, V> iMap = hazelcastInstance.getMap(key);
|
||||
if (loadedSet.contains(key) || !iMap.isEmpty()) {
|
||||
loadedSet.add(key);
|
||||
return iMap;
|
||||
}
|
||||
simpleLock("task-getMap-" + key,
|
||||
0, TimeUnit.SECONDS,
|
||||
10, TimeUnit.SECONDS,
|
||||
() -> {
|
||||
try {
|
||||
Map<K, V> map = load.call();
|
||||
iMap.clear();
|
||||
iMap.putAll(map);
|
||||
loadedSet.add(key);
|
||||
} catch (BizException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
return iMap;
|
||||
}
|
||||
|
||||
public Integer getLong(String key, Callable<Integer> load, int delta) {
|
||||
PNCounter counter = hazelcastInstance.getPNCounter(key);
|
||||
long v = counter.get();
|
||||
if (loadedSet.contains(key) || v != 0) {
|
||||
loadedSet.add(key);
|
||||
if (delta == 0) {
|
||||
return (int) v;
|
||||
}
|
||||
return (int) counter.addAndGet(delta);
|
||||
}
|
||||
simpleLock("task-getLong-" + key,
|
||||
0, TimeUnit.SECONDS,
|
||||
10, TimeUnit.SECONDS,
|
||||
() -> {
|
||||
try {
|
||||
int value = load.call();
|
||||
counter.reset();
|
||||
counter.addAndGet(value + delta);
|
||||
loadedSet.add(key);
|
||||
} catch (BizException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
return (int) counter.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果key不存在则执行load回调并返回执行结果,如果存在返回默认值(一般用于防止缓存穿透)
|
||||
*
|
||||
* @param cacheMap cacheMap
|
||||
* @param key cacheKey
|
||||
* @param load 回调方法
|
||||
* @param defaultValue 默认值
|
||||
* @param <T> 数据类型
|
||||
* @return
|
||||
*/
|
||||
public <T> T runNx(Map<String, Object> cacheMap, String key, Callable<T> load, T defaultValue) {
|
||||
Object obj = cacheMap.get(key);
|
||||
if (obj == null) {
|
||||
T result;
|
||||
try {
|
||||
result = load.call();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
// 防止缓存穿透
|
||||
cacheMap.put(key, ONLY_KEY_OBJ);
|
||||
return result;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* 多线程锁
|
||||
*
|
||||
* @param taskName 任务名字
|
||||
* @param time 加锁时间值
|
||||
* @param timeunit 加锁时间类型
|
||||
* @param leaseTime 自动释放时间值
|
||||
* @param leaseTimeunit 自动释放时间类型
|
||||
* @param fn 加锁成功后执行的方法
|
||||
* @param <T> 类型
|
||||
*/
|
||||
public <T> void lock(String taskName,
|
||||
long time, @Nullable TimeUnit timeunit,
|
||||
long leaseTime, @Nullable TimeUnit leaseTimeunit,
|
||||
Callable<T> fn) {
|
||||
try {
|
||||
IMap<String, Integer> map = hazelcastInstance.getMap(CacheKey.DISTRIBUTED_LOCK);
|
||||
boolean lock = map.tryLock(taskName, time, timeunit, leaseTime, leaseTimeunit);
|
||||
if (lock) {
|
||||
String host = ((HazelcastInstanceProxy) hazelcastInstance).getOriginal().getLocalEndpoint().getAddress().getHost();
|
||||
Integer logId = null;
|
||||
long runTime = 0;
|
||||
try {
|
||||
logId = scheduleLogService.save(ScheduleLog.start(taskName, host));
|
||||
long startTime = System.currentTimeMillis();
|
||||
LoggerUtil.data.info(taskName + "-开始");
|
||||
T result = fn.call();
|
||||
runTime = System.currentTimeMillis() - startTime;
|
||||
String resultJSON = JSONObject.toJSONString(result);
|
||||
LoggerUtil.data.info(taskName + "-结束:" + runTime, resultJSON);
|
||||
scheduleLogService.save(ScheduleLog.success(logId, result == null ? null : resultJSON));
|
||||
} catch (Exception e) {
|
||||
LoggerUtil.error.error(taskName + "-异常:" + ExceptionUtils.getStackTrace(e));
|
||||
scheduleLogService.save(ScheduleLog.error(logId, ExceptionUtils.getStackTrace(e)));
|
||||
} finally {
|
||||
if (runTime >= UNLOCK_SLEEP_TIME) {
|
||||
map.forceUnlock(taskName);
|
||||
} else if (lock) {
|
||||
TimeUnit.MILLISECONDS.sleep(UNLOCK_SLEEP_TIME - runTime);
|
||||
if (map.isLocked(taskName)) {
|
||||
map.unlock(taskName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LoggerUtil.error.error(taskName + "-异常:" + ExceptionUtils.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 多线程锁
|
||||
*
|
||||
* @param taskName 任务名字
|
||||
* @param time 加锁时间值
|
||||
* @param timeunit 加锁时间类型
|
||||
* @param leaseTime 自动释放时间值
|
||||
* @param leaseTimeunit 自动释放时间类型
|
||||
* @param fn 加锁成功后执行的方法
|
||||
*/
|
||||
public void lock(String taskName,
|
||||
long time, @Nullable TimeUnit timeunit,
|
||||
long leaseTime, @Nullable TimeUnit leaseTimeunit,
|
||||
Runnable fn) {
|
||||
try {
|
||||
IMap<String, Integer> map = hazelcastInstance.getMap(CacheKey.DISTRIBUTED_LOCK);
|
||||
long runTime = 0;
|
||||
boolean lock = map.tryLock(taskName, time, timeunit, leaseTime, leaseTimeunit);
|
||||
if (lock) {
|
||||
String host = ((HazelcastInstanceProxy) hazelcastInstance).getOriginal().getLocalEndpoint().getAddress().getHost();
|
||||
Integer logId = null;
|
||||
try {
|
||||
logId = scheduleLogService.save(ScheduleLog.start(taskName, host));
|
||||
long startTime = System.currentTimeMillis();
|
||||
LoggerUtil.data.info(taskName + "-开始");
|
||||
fn.run();
|
||||
runTime = System.currentTimeMillis() - startTime;
|
||||
LoggerUtil.data.info(taskName + "-结束:" + runTime);
|
||||
scheduleLogService.save(ScheduleLog.success(logId, null));
|
||||
} catch (Exception e) {
|
||||
LoggerUtil.error.error(taskName + "-异常:" + ExceptionUtils.getStackTrace(e));
|
||||
scheduleLogService.save(ScheduleLog.error(logId, ExceptionUtils.getStackTrace(e)));
|
||||
} finally {
|
||||
if (runTime >= UNLOCK_SLEEP_TIME) {
|
||||
map.forceUnlock(taskName);
|
||||
} else if (lock) {
|
||||
TimeUnit.MILLISECONDS.sleep(UNLOCK_SLEEP_TIME - runTime);
|
||||
if (map.isLocked(taskName)) {
|
||||
map.unlock(taskName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LoggerUtil.error.error(taskName + "-异常:" + ExceptionUtils.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
public void simpleLock(String key, long time, @Nullable TimeUnit timeunit, long leaseTime, @Nullable TimeUnit leaseTimeunit, Runnable fn) {
|
||||
IMap<String, Integer> map = hazelcastInstance.getMap(CacheKey.DISTRIBUTED_LOCK);
|
||||
boolean lock = false;
|
||||
try {
|
||||
lock = map.tryLock(key, time, timeunit, leaseTime, leaseTimeunit);
|
||||
if (lock) {
|
||||
fn.run();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
if (lock && map.isLocked(key)) {
|
||||
map.unlock(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Integer getLong(String cacheKey, int delta) {
|
||||
PNCounter counter = hazelcastInstance.getPNCounter(cacheKey);
|
||||
return (int) counter.addAndGet(delta);
|
||||
}
|
||||
|
||||
public void clearCache(String mapName, List<String> cacheKeys) {
|
||||
Map<String, Object> cacheMap = hazelcastInstance.getMap(mapName);
|
||||
cacheKeys.forEach(cacheMap::remove);
|
||||
}
|
||||
|
||||
public void clearCache(String mapName, String cacheKey) {
|
||||
Map<String, Object> cacheMap = hazelcastInstance.getMap(mapName);
|
||||
cacheMap.remove(cacheKey);
|
||||
}
|
||||
}
|
||||
@ -1,70 +0,0 @@
|
||||
package com.diagnose.common.service;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.diagnose.common.entity.ScheduleLog;
|
||||
import com.diagnose.common.handler.BizException;
|
||||
import com.diagnose.common.mapper.ScheduleLogMapper;
|
||||
import com.diagnose.common.query.ListScheduleLogQuery;
|
||||
import com.diagnose.common.result.ResponseStatus;
|
||||
import com.diagnose.common.util.CodecUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class ScheduleLogService {
|
||||
|
||||
private static final String salt = "UP_OEM_SCHEDULE_LOG";
|
||||
|
||||
@Resource
|
||||
private ScheduleLogMapper scheduleLogMapper;
|
||||
|
||||
public List<ScheduleLog> list(ListScheduleLogQuery query) {
|
||||
checkToken(query);
|
||||
String serverName = query.getServerName();
|
||||
String scheduleName = query.getScheduleName();
|
||||
LocalDate date = query.getDate();
|
||||
Integer result = query.getResult();
|
||||
QueryWrapper<ScheduleLog> wrapper = Wrappers.query();
|
||||
wrapper.eq(StrUtil.isNotEmpty(serverName), "server_name", serverName)
|
||||
.eq(StrUtil.isNotEmpty(scheduleName), "schedule_name", scheduleName)
|
||||
.eq(date != null, "date", date)
|
||||
.eq(result != null && result != 0, "result", result);
|
||||
return scheduleLogMapper.selectList(wrapper);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Integer save(ScheduleLog log) {
|
||||
if (log.getId() == null) {
|
||||
scheduleLogMapper.insert(log);
|
||||
} else {
|
||||
scheduleLogMapper.updateById(log);
|
||||
}
|
||||
return log.getId();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void clearHistory(int saveDays) {
|
||||
LocalDate saveDate = LocalDate.now().minusDays(saveDays);
|
||||
QueryWrapper<ScheduleLog> wrapper = Wrappers.query();
|
||||
wrapper.lt("date", saveDate);
|
||||
scheduleLogMapper.delete(wrapper);
|
||||
}
|
||||
|
||||
private void checkToken(ListScheduleLogQuery query) {
|
||||
String token = query.getToken();
|
||||
LocalDate date = query.getDate();
|
||||
String dateStr = date.format(DateTimeFormatter.BASIC_ISO_DATE);
|
||||
String hash = CodecUtil.md5(dateStr + salt);
|
||||
if (!hash.equals(token)) {
|
||||
throw new BizException(ResponseStatus.AUTH_FAIL);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,28 +0,0 @@
|
||||
package com.diagnose.common.util;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.safety.Whitelist;
|
||||
|
||||
public class TextUtil {
|
||||
|
||||
public static String removeHtmlTags(String text) {
|
||||
text = Jsoup.parse(text).text();
|
||||
return text.replaceAll("\\s*|\t|\r|\n| ", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理富文本中的XSS攻击内容
|
||||
*
|
||||
* @param unsafeHtml 富文本内容
|
||||
* @return 清洗后的文本内容
|
||||
*/
|
||||
public static String cleanUnsafeHtml(String unsafeHtml) {
|
||||
if (StrUtil.isEmpty(unsafeHtml)) {
|
||||
return unsafeHtml;
|
||||
}
|
||||
Whitelist whitelist = Whitelist.relaxed();
|
||||
return Jsoup.clean(unsafeHtml, whitelist);
|
||||
}
|
||||
|
||||
}
|
||||
@ -73,4 +73,18 @@ public class DiagnoseController {
|
||||
return CommonResult.success(vo);
|
||||
}
|
||||
|
||||
@ApiOperation("市场热度")
|
||||
@GetMapping("/diagnose/marketSentiment")
|
||||
public CommonResult<MarketSentimentVO> marketSentiment(@RequestParam("证券统一编码") @Validated @NotNull @ApiParam(required = true) Long stkUniCode) {
|
||||
MarketSentimentVO vo = stockService.marketSentiment(stkUniCode);
|
||||
return CommonResult.success(vo);
|
||||
}
|
||||
|
||||
@ApiOperation("主力动向")
|
||||
@GetMapping("/diagnose/institutionalActivity")
|
||||
public CommonResult<InstitutionalActivityVO> institutionalActivity(@RequestParam("证券统一编码") @Validated @NotNull @ApiParam(required = true) Long stkUniCode) {
|
||||
InstitutionalActivityVO vo = stockService.institutionalActivity(stkUniCode);
|
||||
return CommonResult.success(vo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,10 +1,7 @@
|
||||
package com.diagnose.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.diagnose.vo.DiagnoseBackTestVO;
|
||||
import com.diagnose.vo.DiagnoseRankVO;
|
||||
import com.diagnose.vo.DiagnoseValuationVO;
|
||||
import com.diagnose.vo.QuantitativeAnalysisVO;
|
||||
import com.diagnose.vo.*;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
@ -15,27 +12,39 @@ public interface DiagnoseMapper extends BaseMapper<DiagnoseRankVO> {
|
||||
|
||||
@Select("SELECT * FROM (" +
|
||||
" SELECT *, ROW_NUMBER() OVER (PARTITION BY stk_uni_code ORDER BY trade_date DESC) AS rn\n" +
|
||||
" FROM _fe_stk_diag_rank\n" +
|
||||
" FROM fe_stk_diag_rank\n" +
|
||||
" WHERE stk_uni_code = #{stkUniCode} AND isvalid = 1\n" +
|
||||
") t WHERE t.rn = 1")
|
||||
DiagnoseRankVO selectRank(@Param("stkUniCode") Long stkUniCode);
|
||||
|
||||
@Select("SELECT max(total_indu_rank) AS _total_indu_rank FROM _fe_stk_diag_rank WHERE plate_uni_code = #{plateUniCode}")
|
||||
@Select("SELECT MAX(total_indu_rank) AS max_total_indu_rank\n" +
|
||||
"FROM (\n" +
|
||||
" SELECT total_indu_rank,\n" +
|
||||
" RANK() OVER (PARTITION BY plate_uni_code ORDER BY trade_date DESC) AS rk\n" +
|
||||
" FROM fe_stk_diag_rank\n" +
|
||||
" WHERE plate_uni_code = #{plateUniCode}\n" +
|
||||
") t WHERE rk = 1")
|
||||
Integer selectTotalInduCount(@Param("plateUniCode") Long plateUniCode);
|
||||
|
||||
@Select("SELECT max(total_mkt_rank) AS _total_mkt_rank FROM _fe_stk_diag_rank")
|
||||
@Select("SELECT MAX(total_mkt_rank) AS max_total_mkt_rank\n" +
|
||||
"FROM fe_stk_diag_rank\n" +
|
||||
"WHERE trade_date = (\n" +
|
||||
" SELECT MAX(trade_date)\n" +
|
||||
" FROM fe_stk_diag_rank\n" +
|
||||
")")
|
||||
Integer selectTotalMktCount();
|
||||
|
||||
@Select("SELECT * FROM (" +
|
||||
" SELECT *, RANK() OVER (ORDER BY trade_date DESC) AS rk\n" +
|
||||
" FROM _fe_stk_diag_backtest\n" +
|
||||
" WHERE star = #{star} AND isvalid = 1\n" +
|
||||
") t WHERE t.rk = 1")
|
||||
@Select("SELECT time_span, avg_excess_ret, win_rate\n" +
|
||||
"FROM fe_stk_diag_backtest\n" +
|
||||
"WHERE trade_date = (\n" +
|
||||
" SELECT MAX(trade_date)\n" +
|
||||
" FROM fe_stk_diag_rank\n) " +
|
||||
"AND star = #{star} AND isvalid = 1")
|
||||
List<DiagnoseBackTestVO> selectBackTest(@Param("star") BigDecimal star);
|
||||
|
||||
@Select("SELECT * FROM (" +
|
||||
" SELECT TIME_SPAN, Q_30_PE, Q_70_PE, CURRENT_Q_PE, Q_30_PB, Q_70_PB, CURRENT_Q_PB, RANK() OVER (PARTITION BY stk_uni_code ORDER BY trade_date DESC) AS rk\n" +
|
||||
" FROM _fe_stk_diag_valuation\n" +
|
||||
" SELECT time_span, q_30_pe, q_70_pe, current_q_pe, q_30_pb, q_70_pb, current_q_pb, RANK() OVER (PARTITION BY stk_uni_code ORDER BY trade_date DESC) AS rk\n" +
|
||||
" FROM fe_stk_diag_valuation\n" +
|
||||
" WHERE stk_uni_code = #{stkUniCode} AND isvalid = 1\n" +
|
||||
") t WHERE t.rk = 1")
|
||||
List<DiagnoseValuationVO> selectDiagnoseValuation(@Param("stkUniCode") Long stkUniCode);
|
||||
@ -47,4 +56,31 @@ public interface DiagnoseMapper extends BaseMapper<DiagnoseRankVO> {
|
||||
") t WHERE t.rn = 1")
|
||||
QuantitativeAnalysisVO selectQuantitativeAnalysis(@Param("stkCode") String stkCode, @Param("mktNum") Integer mktNum);
|
||||
|
||||
@Select("SELECT * FROM (" +
|
||||
" SELECT mhot_sum_mac, score, ROW_NUMBER() OVER (PARTITION BY stk_code, mkt_num ORDER BY trd_date DESC) AS rn\n" +
|
||||
" FROM mhot_fac\n" +
|
||||
" WHERE stk_code = #{stkCode} AND mkt_num = #{mktNum}\n" +
|
||||
") t WHERE t.rn = 1")
|
||||
MarketSentimentVO selectMarketSentiment(@Param("stkCode") String stkCode, @Param("mktNum") Integer mktNum);
|
||||
|
||||
@Select("SELECT count_date, stk_hot_index\n" +
|
||||
"FROM stk_mqhot_index_day\n" +
|
||||
"WHERE stk_uni_code = #{stkUniCode} AND count_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH)\n" +
|
||||
"ORDER BY count_date")
|
||||
List<SentimentTrendVO> selectSentimentTrend(@Param("stkUniCode") Long stkUniCode);
|
||||
|
||||
@Select("SELECT DATE_FORMAT(STR_TO_DATE(decl_date, '%Y-%m-%d'), '%Y-%m-01') AS decl_date, res_rate_par, COUNT(0) AS count\n" +
|
||||
"FROM res_stk_fore\n" +
|
||||
"WHERE stk_code = #{stkCode} AND sec_mar_par = #{secMarPar} AND decl_date >= DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 5 MONTH), '%Y-%m-01')\n" +
|
||||
"GROUP BY DATE_FORMAT(STR_TO_DATE(decl_date, '%Y-%m-%d'), '%Y-%m-01'), res_rate_par\n" +
|
||||
"ORDER BY decl_date")
|
||||
List<InstitutionalRatingVO> selectInstitutionalRating(@Param("stkCode") String stkCode, @Param("secMarPar") Integer secMarPar);
|
||||
|
||||
@Select("SELECT * FROM (" +
|
||||
" SELECT main_trend_sum_mac, score, ROW_NUMBER() OVER (PARTITION BY stk_code, mkt_num ORDER BY trd_date DESC) AS rn\n" +
|
||||
" FROM main_trend_fac\n" +
|
||||
" WHERE stk_code = #{stkCode} AND mkt_num = #{mktNum}\n" +
|
||||
") t WHERE t.rn = 1")
|
||||
InstitutionalActivityVO selectInstitutionalActivity(@Param("stkCode") String stkCode, @Param("mktNum") Integer mktNum);
|
||||
|
||||
}
|
||||
|
||||
@ -14,28 +14,28 @@ public interface FinanceMapper extends BaseMapper<FinancialValuationVO> {
|
||||
|
||||
@Select("SELECT * FROM (" +
|
||||
" SELECT fin_sum_mac, score, ROW_NUMBER() OVER (PARTITION BY stk_code, mkt_num ORDER BY trd_date DESC) AS rn\n" +
|
||||
" FROM _fin_val_fac\n" +
|
||||
" FROM fin_val_fac\n" +
|
||||
" WHERE stk_code = #{stkCode} AND mkt_num = #{mktNum}\n" +
|
||||
") t WHERE t.rn = 1")
|
||||
FinancialValuationVO selectFinancialValuation(@Param("stkCode") String stkCode, @Param("mktNum") Integer mktNum);
|
||||
|
||||
@Select("SELECT * FROM (" +
|
||||
" SELECT *, ROW_NUMBER() OVER (PARTITION BY stk_code, sec_mar_par ORDER BY end_date DESC) AS rn\n" +
|
||||
" FROM _fin_idx_ana\n" +
|
||||
" FROM fin_idx_ana\n" +
|
||||
" WHERE stk_code = #{stkCode} AND sec_mar_par = #{secMarPar}\n" +
|
||||
") t WHERE t.rn <= 5")
|
||||
List<FinanceIndexAnalysisVO> selectFinanceIndexAnalysis(@Param("stkCode") String stkCode, @Param("secMarPar") Integer secMarPar);
|
||||
|
||||
@Select("SELECT * FROM (" +
|
||||
" SELECT *, ROW_NUMBER() OVER (PARTITION BY stk_code, sec_mar_par ORDER BY end_date DESC) AS rn\n" +
|
||||
" FROM _fin_cash_short\n" +
|
||||
" FROM fin_cash_short\n" +
|
||||
" WHERE stk_code = #{stkCode} AND sec_mar_par = #{secMarPar}\n" +
|
||||
") t WHERE t.rn <= 5")
|
||||
List<FinanceCashShortVO> selectFinanceCashShort(@Param("stkCode") String stkCode, @Param("secMarPar") Integer secMarPar);
|
||||
|
||||
@Select("SELECT * FROM (" +
|
||||
" SELECT profit_indu_rank, growth_indu_rank, operate_indu_rank, debt_indu_rank, cash_indu_rank, ROW_NUMBER() OVER (PARTITION BY stk_uni_code ORDER BY end_date DESC) AS rn\n" +
|
||||
" FROM _fe_stk_diag_fin_rank\n" +
|
||||
" FROM fe_stk_diag_fin_rank\n" +
|
||||
" WHERE stk_uni_code = #{stkUniCode}\n" +
|
||||
") t WHERE t.rn = 1")
|
||||
FinanceRankVO selectFinanceRank(@Param("stkUniCode") Long stkUniCode);
|
||||
|
||||
@ -1,10 +1,7 @@
|
||||
package com.diagnose.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.diagnose.vo.KLineVO;
|
||||
import com.diagnose.vo.StockPriceVO;
|
||||
import com.diagnose.vo.StockVO;
|
||||
import com.diagnose.vo.ValuationAnalysisVO;
|
||||
import com.diagnose.vo.*;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
@ -13,11 +10,18 @@ import java.util.List;
|
||||
public interface StockMapper extends BaseMapper<StockVO> {
|
||||
|
||||
@Select("SELECT sc.sec_uni_code, sc.sec_code, sc.sec_short_name, sc.sec_spe_short_name, sc.mkt_type_par, pi.plate_uni_code, pi.plate_name, pi.plate_code\n" +
|
||||
"FROM _pub_sec_code sc\n" +
|
||||
"JOIN _pub_sec_plate sp\n" +
|
||||
"FROM pub_sec_code sc\n" +
|
||||
"JOIN (SELECT sec_uni_code, plate_uni_code FROM (\n" +
|
||||
" SELECT sec_uni_code, plate_uni_code, ROW_NUMBER() OVER (PARTITION BY sec_uni_code ORDER BY plate_uni_code) AS rn \n" +
|
||||
" FROM pub_sec_plate\n" +
|
||||
" WHERE sec_uni_code IN (SELECT sec_uni_code FROM pub_sec_code WHERE sec_type_par = 1 AND sec_small_type_par = 101 AND isvalid = 1) \n" +
|
||||
" AND plate_uni_code IN (SELECT plate_uni_code FROM pub_plate_info where fat_uni_code = 5004150000 AND isvalid = 1) \n" +
|
||||
" AND isvalid = 1\n" +
|
||||
") t WHERE t.rn = 1) sp\n" +
|
||||
"ON sc.sec_uni_code = sp.sec_uni_code\n" +
|
||||
"JOIN pub_plate_info pi\n" +
|
||||
"ON sp.plate_uni_code = pi.plate_uni_code")
|
||||
"ON sp.plate_uni_code = pi.plate_uni_code\n" +
|
||||
"WHERE sc.sec_type_par = 1 AND sc.sec_small_type_par = 101 AND sc.list_status_par = 7 AND sc.isvalid = 1")
|
||||
List<StockVO> selectAllStock();
|
||||
|
||||
@Select("SELECT * FROM (\n" +
|
||||
@ -52,5 +56,28 @@ public interface StockMapper extends BaseMapper<StockVO> {
|
||||
" AND s.trade_date >= DATE_SUB(CURDATE(), INTERVAL #{month} MONTH)\n" +
|
||||
" AND s.isvalid = 1\n" +
|
||||
"ORDER BY s.trade_date")
|
||||
List<KLineVO> selectKLine(@Param("tableName") String tableName, @Param("stkUniCode") Long stkUniCode, @Param("month") int month);
|
||||
List<KLineVO> selectKLine(@Param("tableName") String tableName,
|
||||
@Param("stkUniCode") Long stkUniCode,
|
||||
@Param("month") int month);
|
||||
|
||||
@Select("SELECT i.trd_date, i.main_btm_net, p.close_price\n" +
|
||||
"FROM stk_zjlx_info i\n" +
|
||||
"JOIN ${tableName} p\n" +
|
||||
"ON i.trd_date = p.end_date\n" +
|
||||
"WHERE i.stk_code = #{stkCode}\n" +
|
||||
" AND i.sec_mar_par = #{secMarPar}\n" +
|
||||
" AND i.trd_date >= DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 1 MONTH), '%Y-%m-%d 00:00:00')\n" +
|
||||
" AND p.stk_uni_code = #{stkUniCode}\n" +
|
||||
" AND p.end_date >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH)\n" +
|
||||
" AND p.isvalid = 1\n" +
|
||||
" AND i.trd_date = DATE_FORMAT(p.end_date, '%Y-%m-%d 00:00:00')\n" +
|
||||
"ORDER BY i.trd_date")
|
||||
List<InstitutionalFundFlowVO> selectInstitutionalFundFlow(@Param("tableName") String tableName, @Param("stkUniCode") Long stkUniCode, @Param("stkCode") String stkCode, @Param("secMarPar") Integer secMarPar);
|
||||
|
||||
@Select("SELECT * FROM (" +
|
||||
" SELECT tot_hld_num, avg_share, ROW_NUMBER() OVER (PARTITION BY stk_code, sec_mar_par ORDER BY end_date DESC) AS rn\n" +
|
||||
" FROM com_hld_tot\n" +
|
||||
" WHERE stk_code = #{stkCode} AND sec_mar_par = #{secMarPar}\n" +
|
||||
") t WHERE t.rn <= 5")
|
||||
List<ShareholderVO> selectShareholderList(@Param("stkCode") String stkCode, @Param("secMarPar") Integer secMarPar);
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ import com.diagnose.vo.*;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -57,6 +58,7 @@ public class StockService {
|
||||
return stockMapCache.get(stkUniCode);
|
||||
}
|
||||
|
||||
// 得分排名
|
||||
public DiagnoseRankVO rank(StockVO stock) {
|
||||
DiagnoseRankVO diagnoseRankVO = diagnoseMapper.selectRank(stock.getSecUniCode());
|
||||
if (diagnoseRankVO == null) {
|
||||
@ -69,6 +71,7 @@ public class StockService {
|
||||
return diagnoseRankVO;
|
||||
}
|
||||
|
||||
// 综合评分
|
||||
public ComprehensiveEvaluationVO comprehensiveEvaluation(Long stkUniCode) {
|
||||
StockVO stock = getStock(stkUniCode);
|
||||
if (stock == null) {
|
||||
@ -87,6 +90,7 @@ public class StockService {
|
||||
return vo;
|
||||
}
|
||||
|
||||
// 财务估值
|
||||
public FinancialValuationVO financialValuation(Long stkUniCode) {
|
||||
StockVO stock = getStock(stkUniCode);
|
||||
if (stock == null) {
|
||||
@ -113,6 +117,7 @@ public class StockService {
|
||||
return vo;
|
||||
}
|
||||
|
||||
// 财务估值-更多
|
||||
public FinancialValuationExtendVO financialValuationExtend(Long stkUniCode) {
|
||||
StockVO stock = getStock(stkUniCode);
|
||||
if (stock == null) {
|
||||
@ -148,6 +153,7 @@ public class StockService {
|
||||
return vo;
|
||||
}
|
||||
|
||||
// 估值分析
|
||||
public List<ValuationAnalysisVO> financialValuationAnalysis(Long stkUniCode, Integer timeSpan, Integer type) {
|
||||
StockVO stock = getStock(stkUniCode);
|
||||
if (stock == null) {
|
||||
@ -156,10 +162,12 @@ public class StockService {
|
||||
String tableName = stock.getPriceTableName();
|
||||
String stockValueColumn = getStockValueColumn(type);
|
||||
Long plateUniCode = stock.getPlateUniCode();
|
||||
// 估值分析
|
||||
List<ValuationAnalysisVO> list = stockMapper.selectFinancialValuationAnalysis(tableName, stockValueColumn, stkUniCode, plateUniCode, timeSpan, type);
|
||||
return list;
|
||||
}
|
||||
|
||||
// 量化分析
|
||||
public QuantitativeAnalysisVO quantitativeAnalysis(Long stkUniCode) {
|
||||
StockVO stock = getStock(stkUniCode);
|
||||
if (stock == null) {
|
||||
@ -167,16 +175,42 @@ public class StockService {
|
||||
}
|
||||
String secCode = stock.getSecCode();
|
||||
Integer mktNum = stock.getMktNum();
|
||||
// 量化分析
|
||||
QuantitativeAnalysisVO vo = diagnoseMapper.selectQuantitativeAnalysis(secCode, mktNum);
|
||||
if (vo == null) {
|
||||
return null;
|
||||
}
|
||||
String tableName = stock.getPriceTableName();
|
||||
// K线
|
||||
List<KLineVO> kLineList = stockMapper.selectKLine(tableName, stkUniCode, kLineMonth);
|
||||
vo.setkLineList(kLineList);
|
||||
return vo;
|
||||
}
|
||||
|
||||
// 市场热度
|
||||
public MarketSentimentVO marketSentiment(@NotNull Long stkUniCode) {
|
||||
StockVO stock = getStock(stkUniCode);
|
||||
if (stock == null) {
|
||||
return null;
|
||||
}
|
||||
Long secUniCode = stock.getSecUniCode();
|
||||
String secCode = stock.getSecCode();
|
||||
Integer mktNum = stock.getMktNum();
|
||||
Integer secMarPar = stock.getSecMarPar();
|
||||
// 市场热度分析
|
||||
MarketSentimentVO vo = diagnoseMapper.selectMarketSentiment(secCode, mktNum);
|
||||
if (vo == null) {
|
||||
return null;
|
||||
}
|
||||
// 热度趋势
|
||||
List<SentimentTrendVO> sentimentTrendList = diagnoseMapper.selectSentimentTrend(secUniCode);
|
||||
vo.setSentimentTrendList(sentimentTrendList);
|
||||
// 机构评级
|
||||
List<InstitutionalRatingVO> institutionalRatingList = diagnoseMapper.selectInstitutionalRating(secCode, secMarPar);
|
||||
vo.setInstitutionalRatingList(institutionalRatingList);
|
||||
return vo;
|
||||
}
|
||||
|
||||
private String getStockValueColumn(Integer type) {
|
||||
if (type == 2) {
|
||||
return "stk_per_ttm";
|
||||
@ -186,4 +220,24 @@ public class StockService {
|
||||
throw new BizException(ResponseStatus.PARM_ERROR, "类型错误");
|
||||
}
|
||||
|
||||
public InstitutionalActivityVO institutionalActivity(Long stkUniCode) {
|
||||
StockVO stock = getStock(stkUniCode);
|
||||
if (stock == null) {
|
||||
return null;
|
||||
}
|
||||
String secCode = stock.getSecCode();
|
||||
Integer mktNum = stock.getMktNum();
|
||||
Integer secMarPar = stock.getSecMarPar();
|
||||
Long secUniCode = stock.getSecUniCode();
|
||||
String tableName = stock.getPriceTableName();
|
||||
InstitutionalActivityVO vo = diagnoseMapper.selectInstitutionalActivity(secCode, mktNum);
|
||||
if (vo == null) {
|
||||
return null;
|
||||
}
|
||||
List<InstitutionalFundFlowVO> institutionalFundFlowList = stockMapper.selectInstitutionalFundFlow(tableName, secUniCode, secCode, secMarPar);
|
||||
vo.setInstitutionalFundFlowList(institutionalFundFlowList);
|
||||
List<ShareholderVO> shareholderList = stockMapper.selectShareholderList(secCode, secMarPar);
|
||||
vo.setShareholderList(shareholderList);
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
package com.diagnose.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@ApiModel("估值分析")
|
||||
public class DiagnoseValuationVO implements Serializable {
|
||||
|
||||
@ApiModelProperty("分析周期")
|
||||
|
||||
@ -3,8 +3,10 @@ package com.diagnose.vo;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@ApiModel("现金流量")
|
||||
public class FinanceCashShortVO {
|
||||
public class FinanceCashShortVO implements Serializable {
|
||||
|
||||
@ApiModelProperty("截止日期")
|
||||
private String endDate;
|
||||
|
||||
@ -3,10 +3,11 @@ package com.diagnose.vo;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel("财务估值")
|
||||
public class FinancialValuationExtendVO {
|
||||
public class FinancialValuationExtendVO implements Serializable {
|
||||
|
||||
@ApiModelProperty("总结性机器语")
|
||||
private String finSumMac;
|
||||
|
||||
55
src/main/java/com/diagnose/vo/InstitutionalActivityVO.java
Normal file
55
src/main/java/com/diagnose/vo/InstitutionalActivityVO.java
Normal file
@ -0,0 +1,55 @@
|
||||
package com.diagnose.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel("主力动向")
|
||||
public class InstitutionalActivityVO implements Serializable {
|
||||
|
||||
@ApiModelProperty("总结性机器语")
|
||||
private String mainTrendSumMac;
|
||||
|
||||
@ApiModelProperty("得分")
|
||||
private Integer score;
|
||||
|
||||
@ApiModelProperty("主力资金")
|
||||
private List<InstitutionalFundFlowVO> institutionalFundFlowList;
|
||||
|
||||
@ApiModelProperty("股东户数")
|
||||
private List<ShareholderVO> shareholderList;
|
||||
|
||||
public String getMainTrendSumMac() {
|
||||
return mainTrendSumMac;
|
||||
}
|
||||
|
||||
public void setMainTrendSumMac(String mainTrendSumMac) {
|
||||
this.mainTrendSumMac = mainTrendSumMac;
|
||||
}
|
||||
|
||||
public Integer getScore() {
|
||||
return score;
|
||||
}
|
||||
|
||||
public void setScore(Integer score) {
|
||||
this.score = score;
|
||||
}
|
||||
|
||||
public List<InstitutionalFundFlowVO> getInstitutionalFundFlowList() {
|
||||
return institutionalFundFlowList;
|
||||
}
|
||||
|
||||
public void setInstitutionalFundFlowList(List<InstitutionalFundFlowVO> institutionalFundFlowList) {
|
||||
this.institutionalFundFlowList = institutionalFundFlowList;
|
||||
}
|
||||
|
||||
public List<ShareholderVO> getShareholderList() {
|
||||
return shareholderList;
|
||||
}
|
||||
|
||||
public void setShareholderList(List<ShareholderVO> shareholderList) {
|
||||
this.shareholderList = shareholderList;
|
||||
}
|
||||
}
|
||||
45
src/main/java/com/diagnose/vo/InstitutionalFundFlowVO.java
Normal file
45
src/main/java/com/diagnose/vo/InstitutionalFundFlowVO.java
Normal file
@ -0,0 +1,45 @@
|
||||
package com.diagnose.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
@ApiModel("主力资金")
|
||||
public class InstitutionalFundFlowVO implements Serializable {
|
||||
|
||||
@ApiModelProperty("交易日")
|
||||
private LocalDate trdDate;
|
||||
|
||||
@ApiModelProperty("主力买盘净成交额")
|
||||
private BigDecimal mainBtmNet;
|
||||
|
||||
@ApiModelProperty("收盘价")
|
||||
private BigDecimal closePrice;
|
||||
|
||||
public LocalDate getTrdDate() {
|
||||
return trdDate;
|
||||
}
|
||||
|
||||
public void setTrdDate(LocalDate trdDate) {
|
||||
this.trdDate = trdDate;
|
||||
}
|
||||
|
||||
public BigDecimal getMainBtmNet() {
|
||||
return mainBtmNet;
|
||||
}
|
||||
|
||||
public void setMainBtmNet(BigDecimal mainBtmNet) {
|
||||
this.mainBtmNet = mainBtmNet;
|
||||
}
|
||||
|
||||
public BigDecimal getClosePrice() {
|
||||
return closePrice;
|
||||
}
|
||||
|
||||
public void setClosePrice(BigDecimal closePrice) {
|
||||
this.closePrice = closePrice;
|
||||
}
|
||||
}
|
||||
44
src/main/java/com/diagnose/vo/InstitutionalRatingVO.java
Normal file
44
src/main/java/com/diagnose/vo/InstitutionalRatingVO.java
Normal file
@ -0,0 +1,44 @@
|
||||
package com.diagnose.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
|
||||
@ApiModel("机构评级")
|
||||
public class InstitutionalRatingVO implements Serializable {
|
||||
|
||||
@ApiModelProperty("发布日期")
|
||||
private LocalDate declDate;
|
||||
|
||||
@ApiModelProperty("评级参数 1买入 2增持 3中性 4减持 5卖出")
|
||||
private Integer resRatePar;
|
||||
|
||||
@ApiModelProperty("数量")
|
||||
private Integer count;
|
||||
|
||||
public LocalDate getDeclDate() {
|
||||
return declDate;
|
||||
}
|
||||
|
||||
public void setDeclDate(LocalDate declDate) {
|
||||
this.declDate = declDate;
|
||||
}
|
||||
|
||||
public Integer getResRatePar() {
|
||||
return resRatePar;
|
||||
}
|
||||
|
||||
public void setResRatePar(Integer resRatePar) {
|
||||
this.resRatePar = resRatePar;
|
||||
}
|
||||
|
||||
public Integer getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setCount(Integer count) {
|
||||
this.count = count;
|
||||
}
|
||||
}
|
||||
56
src/main/java/com/diagnose/vo/MarketSentimentVO.java
Normal file
56
src/main/java/com/diagnose/vo/MarketSentimentVO.java
Normal file
@ -0,0 +1,56 @@
|
||||
package com.diagnose.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel("市场热度")
|
||||
public class MarketSentimentVO implements Serializable {
|
||||
|
||||
@ApiModelProperty("总结性机器语")
|
||||
private String mhotSumMac;
|
||||
|
||||
@ApiModelProperty("市场热度得分")
|
||||
private Integer score;
|
||||
|
||||
@ApiModelProperty("热度趋势")
|
||||
private List<SentimentTrendVO> sentimentTrendList;
|
||||
|
||||
@ApiModelProperty("机构评级")
|
||||
private List<InstitutionalRatingVO> institutionalRatingList;
|
||||
|
||||
public String getMhotSumMac() {
|
||||
return mhotSumMac;
|
||||
}
|
||||
|
||||
public void setMhotSumMac(String mhotSumMac) {
|
||||
this.mhotSumMac = mhotSumMac;
|
||||
}
|
||||
|
||||
public Integer getScore() {
|
||||
return score;
|
||||
}
|
||||
|
||||
public void setScore(Integer score) {
|
||||
this.score = score;
|
||||
}
|
||||
|
||||
public List<SentimentTrendVO> getSentimentTrendList() {
|
||||
return sentimentTrendList;
|
||||
}
|
||||
|
||||
public void setSentimentTrendList(List<SentimentTrendVO> sentimentTrendList) {
|
||||
this.sentimentTrendList = sentimentTrendList;
|
||||
}
|
||||
|
||||
public List<InstitutionalRatingVO> getInstitutionalRatingList() {
|
||||
return institutionalRatingList;
|
||||
}
|
||||
|
||||
public void setInstitutionalRatingList(List<InstitutionalRatingVO> institutionalRatingList) {
|
||||
this.institutionalRatingList = institutionalRatingList;
|
||||
}
|
||||
|
||||
}
|
||||
35
src/main/java/com/diagnose/vo/SentimentTrendVO.java
Normal file
35
src/main/java/com/diagnose/vo/SentimentTrendVO.java
Normal file
@ -0,0 +1,35 @@
|
||||
package com.diagnose.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
@ApiModel("热度趋势")
|
||||
public class SentimentTrendVO implements Serializable {
|
||||
|
||||
@ApiModelProperty("统计时间")
|
||||
private LocalDate countDate;
|
||||
|
||||
@ApiModelProperty("热度指数")
|
||||
private BigDecimal stkHotIndex;
|
||||
|
||||
public LocalDate getCountDate() {
|
||||
return countDate;
|
||||
}
|
||||
|
||||
public void setCountDate(LocalDate countDate) {
|
||||
this.countDate = countDate;
|
||||
}
|
||||
|
||||
public BigDecimal getStkHotIndex() {
|
||||
return stkHotIndex;
|
||||
}
|
||||
|
||||
public void setStkHotIndex(BigDecimal stkHotIndex) {
|
||||
this.stkHotIndex = stkHotIndex;
|
||||
}
|
||||
|
||||
}
|
||||
45
src/main/java/com/diagnose/vo/ShareholderVO.java
Normal file
45
src/main/java/com/diagnose/vo/ShareholderVO.java
Normal file
@ -0,0 +1,45 @@
|
||||
package com.diagnose.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
@ApiModel("股东户数")
|
||||
public class ShareholderVO implements Serializable {
|
||||
|
||||
@ApiModelProperty("截止日期")
|
||||
private LocalDate endDate;
|
||||
|
||||
@ApiModelProperty("股东总数")
|
||||
private Integer totHldNum;
|
||||
|
||||
@ApiModelProperty("人均流通股")
|
||||
private BigDecimal avgShare;
|
||||
|
||||
public LocalDate getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(LocalDate endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
public Integer getTotHldNum() {
|
||||
return totHldNum;
|
||||
}
|
||||
|
||||
public void setTotHldNum(Integer totHldNum) {
|
||||
this.totHldNum = totHldNum;
|
||||
}
|
||||
|
||||
public BigDecimal getAvgShare() {
|
||||
return avgShare;
|
||||
}
|
||||
|
||||
public void setAvgShare(BigDecimal avgShare) {
|
||||
this.avgShare = avgShare;
|
||||
}
|
||||
}
|
||||
@ -3,11 +3,12 @@ package com.diagnose.vo;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
@ApiModel("行情估值")
|
||||
public class StockPriceVO {
|
||||
public class StockPriceVO implements Serializable {
|
||||
|
||||
@ApiModelProperty("结算日")
|
||||
private LocalDate endDate;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.diagnose.vo;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.diagnose.constant.MktNum;
|
||||
import com.diagnose.constant.MktTypePar;
|
||||
import com.diagnose.constant.PriceTableName;
|
||||
@ -22,21 +23,25 @@ public class StockVO implements Serializable {
|
||||
private String secShortName;
|
||||
|
||||
@ApiModelProperty("证券拼音简称")
|
||||
@JSONField(serialize = false)
|
||||
private String secSpeShortName;
|
||||
|
||||
@ApiModelProperty("证券市场 1:深圳证券交易所 2:上海证券交易所 190:北京证券交易所")
|
||||
private Integer mktTypePar;
|
||||
|
||||
@ApiModelProperty("板块统一编码")
|
||||
@JSONField(serialize = false)
|
||||
private Long plateUniCode;
|
||||
|
||||
@ApiModelProperty("板块名称")
|
||||
private String plateName;
|
||||
|
||||
@ApiModelProperty("板块代码")
|
||||
@JSONField(serialize = false)
|
||||
private String plateCode;
|
||||
|
||||
// 股票所属市场 0:深圳 1:上海
|
||||
@JSONField(serialize = false)
|
||||
public Integer getMktNum() {
|
||||
if (mktTypePar == null) {
|
||||
return null;
|
||||
@ -51,6 +56,7 @@ public class StockVO implements Serializable {
|
||||
return null;
|
||||
}
|
||||
|
||||
@JSONField(serialize = false)
|
||||
// 股票市场 1:深圳 2:上海 8:北京
|
||||
public Integer getSecMarPar() {
|
||||
if (mktTypePar == null) {
|
||||
@ -66,6 +72,8 @@ public class StockVO implements Serializable {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 股票价格表名
|
||||
@JSONField(serialize = false)
|
||||
public String getPriceTableName() {
|
||||
if (mktTypePar == null) {
|
||||
return null;
|
||||
|
||||
@ -1,11 +1,14 @@
|
||||
package com.diagnose.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class ValuationAnalysisVO {
|
||||
@ApiModel
|
||||
public class ValuationAnalysisVO implements Serializable {
|
||||
|
||||
@ApiModelProperty("日期")
|
||||
private LocalDate date;
|
||||
|
||||
@ -1,6 +1,3 @@
|
||||
hazelcast:
|
||||
members: 127.0.0.1:5709 #缓存集群的ip端口号
|
||||
serverPort: 5709 #自己作为缓存服务器监听的端口号
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
call-setters-on-nulls: true #如果查询结果中包含空值的列,则 MyBatis 在映射的时候,不会映射这个字段
|
||||
|
||||
@ -1,6 +1,3 @@
|
||||
hazelcast:
|
||||
members: 172.26.1.9,172.26.1.15 #缓存集群的ip端口号
|
||||
serverPort: 5709 #自己作为缓存服务器监听的端口号
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
call-setters-on-nulls: true #如果查询结果中包含空值的列,则 MyBatis 在映射的时候,不会映射这个字段
|
||||
@ -32,8 +29,8 @@ spring:
|
||||
master:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://172.26.1.2:3306/db_upsync?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=GMT%2B8
|
||||
username: tgdba
|
||||
password: szTGdb@20250210
|
||||
username: upsync
|
||||
password: UPsync#20250310
|
||||
mvc:
|
||||
pathmatch:
|
||||
matching-strategy: ant_path_matcher #Springfox 使用的路径匹配是基于AntPathMatcher的,而Spring Boot 2.6.X使用的是PathPatternMatcher。
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user