feat:first commit
This commit is contained in:
40
.gitignore
vendored
Normal file
40
.gitignore
vendored
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
!**/src/main/**/target/
|
||||||
|
!**/src/test/**/target/
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea/modules.xml
|
||||||
|
.idea/jarRepositories.xml
|
||||||
|
.idea/compiler.xml
|
||||||
|
.idea/libraries/
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### Eclipse ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
build/
|
||||||
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
### Mac OS ###
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
logs/
|
||||||
52
facade/pom.xml
Normal file
52
facade/pom.xml
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.xiang</groupId>
|
||||||
|
<artifactId>xservice-scirpt</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>facade</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!-- <!– 新版钉钉SDK –>-->
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>com.aliyun</groupId>-->
|
||||||
|
<!-- <artifactId>dingtalk</artifactId>-->
|
||||||
|
<!-- <version>2.2.16</version>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
|
||||||
|
<!-- 旧版的钉钉SDK-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.aliyun</groupId>
|
||||||
|
<artifactId>alibaba-dingtalk-service-sdk</artifactId>
|
||||||
|
<version>2.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<!-- 生成可执行的jar的名字:xxx-exec.jar -->
|
||||||
|
<!-- 不固定,写成abcd都可以 -->
|
||||||
|
<classifier>exec</classifier>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.xiang.dingTalk.common.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-09 15:54
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum DingTalkUrlEnum {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 钉钉接口枚举
|
||||||
|
*/
|
||||||
|
DING_TALK_GET_ENTERPRISE_INTER_TOKEN("https://oapi.dingtalk.com/gettoken", "获取企业内部应用Token"),
|
||||||
|
DING_TALK_ASYNC_SEND_MESSAGE("https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2", "异步发送工作通知"),
|
||||||
|
DING_TALK_CHAR_MESSAGE("https://oapi.dingtalk.com/chat/send", "发送消息到企业群旧版SDK"),
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
final String url;
|
||||||
|
|
||||||
|
final String desc;
|
||||||
|
|
||||||
|
DingTalkUrlEnum(String url, String desc) {
|
||||||
|
this.url = url;
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.xiang.dingTalk.common.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-09 16:00
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public enum HttpMethod {
|
||||||
|
|
||||||
|
GET("get"),
|
||||||
|
;
|
||||||
|
final String method;
|
||||||
|
|
||||||
|
HttpMethod(String method) {
|
||||||
|
this.method = method;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
package com.xiang.dingTalk.service;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.dingtalk.api.DefaultDingTalkClient;
|
||||||
|
import com.dingtalk.api.DingTalkClient;
|
||||||
|
import com.dingtalk.api.request.OapiChatSendRequest;
|
||||||
|
import com.dingtalk.api.request.OapiGettokenRequest;
|
||||||
|
import com.dingtalk.api.request.OapiMessageCorpconversationAsyncsendV2Request;
|
||||||
|
import com.dingtalk.api.response.OapiChatSendResponse;
|
||||||
|
import com.dingtalk.api.response.OapiGettokenResponse;
|
||||||
|
import com.dingtalk.api.response.OapiMessageCorpconversationAsyncsendV2Response;
|
||||||
|
import com.xiang.dingTalk.common.enums.DingTalkUrlEnum;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-09 15:06
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class DingTalkService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 应用凭证id
|
||||||
|
* https://open-dev.dingtalk.com/fe/ai?hash=%23%2Fapp%2F3fa4c9a7-27f2-4d6f-bbe7-41d2a17b5c11%2Fbaseinfo#/app/3fa4c9a7-27f2-4d6f-bbe7-41d2a17b5c11/baseinfo
|
||||||
|
*/
|
||||||
|
private static final String APP_ID = "3fa4c9a7-27f2-4d6f-bbe7-41d2a17b5c11";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 原企业内部应用AgentID
|
||||||
|
*/
|
||||||
|
private static final String AGENT_ID = "3829551658";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组织ID
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final String CORP_ID = "dingf2c4425cd179a26ef2c783f7214b6d69";
|
||||||
|
|
||||||
|
private static final String CLIENT_ID = "dingcc9fikz1c0e5wb9v";
|
||||||
|
|
||||||
|
private static final String CLIENT_SECRET = "wyapsH6y8P1K_wuTPKGKwG0mquj1uth9Dxn6HcRpta3sh8Syukl0C8nOmR1PeBzs";
|
||||||
|
|
||||||
|
private static final String GRANT_TYPE = "client_credentials";
|
||||||
|
|
||||||
|
private static final String USER_ID = "450841600726084717";
|
||||||
|
|
||||||
|
private static final String MSG_TYPE = "text";
|
||||||
|
|
||||||
|
// userID 450841600726084717
|
||||||
|
|
||||||
|
// chatID chatd16d8daeea33b36b73588c676d508096
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送消息到企业群
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String sendChatMessage(String chatId, String message) throws Exception{
|
||||||
|
String token = getToken();
|
||||||
|
DefaultDingTalkClient client = new DefaultDingTalkClient(DingTalkUrlEnum.DING_TALK_CHAR_MESSAGE.getUrl());
|
||||||
|
OapiChatSendRequest req = new OapiChatSendRequest();
|
||||||
|
req.setChatid(chatId);
|
||||||
|
OapiChatSendRequest.Msg msg = new OapiChatSendRequest.Msg();
|
||||||
|
OapiChatSendRequest.Text text = new OapiChatSendRequest.Text();
|
||||||
|
text.setContent(message);
|
||||||
|
msg.setText(text);
|
||||||
|
msg.setMsgtype("text");
|
||||||
|
req.setMsg(msg);
|
||||||
|
OapiChatSendResponse rsp = client.execute(req, token);
|
||||||
|
log.info("[DingTalk] send chat message, req:{}, token:{}, response:{}", JSONObject.toJSONString(req), token, JSONObject.toJSONString(rsp));
|
||||||
|
return rsp.getMessageId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 异步发送工作同志--文本类型
|
||||||
|
* @param userId
|
||||||
|
* @param message
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public String asyncSendMessage(String userId, String message) throws Exception {
|
||||||
|
String token = getToken();
|
||||||
|
DingTalkClient client = new DefaultDingTalkClient(DingTalkUrlEnum.DING_TALK_ASYNC_SEND_MESSAGE.getUrl());
|
||||||
|
OapiMessageCorpconversationAsyncsendV2Request req = new OapiMessageCorpconversationAsyncsendV2Request();
|
||||||
|
req.setAgentId(Long.parseLong(AGENT_ID));
|
||||||
|
req.setUseridList(userId);
|
||||||
|
req.setToAllUser(false);
|
||||||
|
OapiMessageCorpconversationAsyncsendV2Request.Msg obj1 = new OapiMessageCorpconversationAsyncsendV2Request.Msg();
|
||||||
|
obj1.setMsgtype(MSG_TYPE);
|
||||||
|
OapiMessageCorpconversationAsyncsendV2Request.Text obj2 = new OapiMessageCorpconversationAsyncsendV2Request.Text();
|
||||||
|
obj2.setContent(message);
|
||||||
|
obj1.setText(obj2);
|
||||||
|
req.setMsg(obj1);
|
||||||
|
log.info("send Ding Talk message, userId:{}, message:{}", userId, message);
|
||||||
|
OapiMessageCorpconversationAsyncsendV2Response rsp = client.execute(req, token);
|
||||||
|
log.info("send Ding Talk message response, taskId:{}", JSONObject.toJSONString(rsp));
|
||||||
|
return rsp.getTaskId().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取企业内部应用token
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public String getToken() throws Exception {
|
||||||
|
DingTalkClient client = new DefaultDingTalkClient(DingTalkUrlEnum.DING_TALK_GET_ENTERPRISE_INTER_TOKEN.getUrl());
|
||||||
|
OapiGettokenRequest req = new OapiGettokenRequest();
|
||||||
|
req.setAppkey(CLIENT_ID);
|
||||||
|
req.setAppsecret(CLIENT_SECRET);
|
||||||
|
req.setHttpMethod("GET");
|
||||||
|
OapiGettokenResponse rsp = client.execute(req);
|
||||||
|
return rsp.getAccessToken();
|
||||||
|
}
|
||||||
|
}
|
||||||
96
pom.xml
Normal file
96
pom.xml
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>com.xiang</groupId>
|
||||||
|
<artifactId>xservice-scirpt</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<modules>
|
||||||
|
<module>facade</module>
|
||||||
|
<module>script</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<spring.boot.version>2.7.18</spring.boot.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
|
<version>${spring.boot.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
<version>${spring.boot.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.18.32</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.fastjson2</groupId>
|
||||||
|
<artifactId>fastjson2</artifactId>
|
||||||
|
<version>2.0.51</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
|
<artifactId>httpclient</artifactId>
|
||||||
|
<version>4.5.13</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
<version>8.0.33</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis.spring.boot</groupId>
|
||||||
|
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||||
|
<version>2.3.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
<version>32.0.1-android</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-collections4</artifactId>
|
||||||
|
<version>4.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<version>3.15.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>2.3.2</version>
|
||||||
|
<configuration>
|
||||||
|
<source>${java.version}</source>
|
||||||
|
<target>${java.version}</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
55
script/pom.xml
Normal file
55
script/pom.xml
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.xiang</groupId>
|
||||||
|
<artifactId>xservice-scirpt</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<groupId>com.xiang</groupId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<artifactId>script</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.xiang</groupId>
|
||||||
|
<artifactId>facade</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<version>2.3.0.RELEASE</version>
|
||||||
|
<configuration>
|
||||||
|
<classifier>exec</classifier>
|
||||||
|
<!-- 指定该Main Class为全局的唯一入口 -->
|
||||||
|
<mainClass>com.xiang.ServiceScriptApplication</mainClass>
|
||||||
|
<layout>ZIP</layout>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal><!--可以把依赖的包都打包到生成的Jar包中-->
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
|
||||||
|
</project>
|
||||||
17
script/src/main/java/com/xiang/ServiceScriptApplication.java
Normal file
17
script/src/main/java/com/xiang/ServiceScriptApplication.java
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package com.xiang;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2024-10-23 10:56
|
||||||
|
*/
|
||||||
|
@SpringBootApplication
|
||||||
|
@EnableScheduling
|
||||||
|
public class ServiceScriptApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(ServiceScriptApplication.class, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
12
script/src/main/java/com/xiang/common/GladosConstants.java
Normal file
12
script/src/main/java/com/xiang/common/GladosConstants.java
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
package com.xiang.common;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-08 15:27
|
||||||
|
*/
|
||||||
|
public class GladosConstants {
|
||||||
|
|
||||||
|
public static final String GLADOS_COOKIE = "SL_G_WPT_TO=en; SL_GWPT_Show_Hide_tmp=1; SL_wptGlobTipTmp=1; koa:sess=eyJ1c2VySWQiOjU1OTg1MywiX2V4cGlyZSI6MTc3MjYwNDkyNjI4OCwiX21heEFnZSI6MjU5MjAwMDAwMDB9; koa:sess.sig=OdaqjpLkIp19lXn0lFuOsHX7vEM";
|
||||||
|
|
||||||
|
public static final String GLADOS_CHECK_IN_BODY = "{\"token\":\"glados.one\"}";
|
||||||
|
}
|
||||||
51
script/src/main/java/com/xiang/common/Result.java
Normal file
51
script/src/main/java/com/xiang/common/Result.java
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
package com.xiang.common;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-09 14:09
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class Result<T> {
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
private List<T> data;
|
||||||
|
|
||||||
|
public static Result<Void> success(String message) {
|
||||||
|
return new Result<Void>("200", message, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static <T> Result<T> success(String message, List<T> data) {
|
||||||
|
return new Result<T>("200", message, data);
|
||||||
|
}
|
||||||
|
public static <T> Result<T> success(String message, T data) {
|
||||||
|
return new Result<T>("200", message, Collections.singletonList(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> Result<T> error(String message) {
|
||||||
|
return new Result<T>("500", message, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> Result<T> error(String message, T data) {
|
||||||
|
return new Result<T>("500", message, Collections.singletonList(data));
|
||||||
|
}
|
||||||
|
public static <T> Result<T> error(String message, List<T> data) {
|
||||||
|
return new Result<T>("500", message, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Result<Void> error(String code, String message) {
|
||||||
|
return new Result<Void>(code, message, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
45
script/src/main/java/com/xiang/common/URLConstants.java
Normal file
45
script/src/main/java/com/xiang/common/URLConstants.java
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
package com.xiang.common;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-08 14:59
|
||||||
|
*/
|
||||||
|
public class URLConstants {
|
||||||
|
|
||||||
|
public static final String GLADOS_URL_PREFIX = "https://www.glados.one";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 签到
|
||||||
|
*/
|
||||||
|
public static final String GLADOS_CHECK_IN_URL = GLADOS_URL_PREFIX + "/api/user/checkin";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ====================
|
||||||
|
* =====江南体育中心=====
|
||||||
|
* ====================
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 江南体育中心请求前缀
|
||||||
|
*/
|
||||||
|
public static final String JNTYZX_URL_PREFIX = "https://";
|
||||||
|
/**
|
||||||
|
* 查询当天的场地
|
||||||
|
*/
|
||||||
|
public static final String JNTYZX_QUERY_TODAY_VENUE = "https://jntyzx.cn:8443/GYM-JN/multi/Subscribe/getSubscribeByToday?gid=03&isWeekend=1";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ====================
|
||||||
|
* =======小蓓养基======
|
||||||
|
* ====================
|
||||||
|
*/
|
||||||
|
public static final String XB_URL_PREFIX = "https://api.xiaobeiyangji.com/yangji-api/api";
|
||||||
|
/**
|
||||||
|
* 查询基金详情
|
||||||
|
*/
|
||||||
|
public static final String XB_QUERY_FUND_INFO = XB_URL_PREFIX + "/get-fund-rating-heat-v310";
|
||||||
|
|
||||||
|
public static final String XB_QUERY_LIST = XB_URL_PREFIX + "/get-gains";
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.xiang.common.factory.xb;
|
||||||
|
|
||||||
|
import java.util.concurrent.ThreadFactory;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-15 08:54
|
||||||
|
*/
|
||||||
|
public class QueryThreadFactory implements ThreadFactory {
|
||||||
|
|
||||||
|
private final String threadName;
|
||||||
|
private final boolean daemon;
|
||||||
|
|
||||||
|
private final AtomicInteger threadNum = new AtomicInteger();
|
||||||
|
|
||||||
|
public QueryThreadFactory(String threadName, boolean daemon) {
|
||||||
|
this.threadName = threadName;
|
||||||
|
this.daemon = daemon;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Thread newThread(Runnable r) {
|
||||||
|
Thread thread = new Thread(r, this.threadName + "[#" + threadNum.incrementAndGet() + "]");
|
||||||
|
thread.setDaemon(this.daemon);
|
||||||
|
return thread;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.xiang.controller;
|
||||||
|
|
||||||
|
import com.xiang.common.Result;
|
||||||
|
import com.xiang.entity.request.GladosCheckInReq;
|
||||||
|
import com.xiang.service.GLaDOSService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-08 14:57
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/system/glados")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class GLaDOSController {
|
||||||
|
|
||||||
|
|
||||||
|
private final GLaDOSService glaDOSService;
|
||||||
|
|
||||||
|
@PostMapping("/checkIn")
|
||||||
|
public Result<Void> checkIn(@RequestBody GladosCheckInReq request) {
|
||||||
|
return Result.success(glaDOSService.checkIn());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.xiang.controller;
|
||||||
|
|
||||||
|
import com.xiang.common.Result;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-13 10:08
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/system/demo")
|
||||||
|
public class IndexController {
|
||||||
|
|
||||||
|
@Value("${spring.profiles.active}")
|
||||||
|
private String env;
|
||||||
|
|
||||||
|
@Value("${server.port}")
|
||||||
|
private String port;
|
||||||
|
|
||||||
|
@Value("${spring.datasource.url}")
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
@GetMapping("/index")
|
||||||
|
public Result<Void> index() {
|
||||||
|
String msg = "已激活环境:" + env + ",web端口启用:" + port + "使用datasource:" + url;
|
||||||
|
return Result.success(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.xiang.controller;
|
||||||
|
|
||||||
|
import com.xiang.common.Result;
|
||||||
|
import com.xiang.service.JntyzxService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-14 15:13
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/system/jntyzx")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class JntyzxController {
|
||||||
|
|
||||||
|
private final JntyzxService jntyzxService;
|
||||||
|
|
||||||
|
@PostMapping("/queryVenue")
|
||||||
|
public Result<Void> queryVenue() throws Exception {
|
||||||
|
jntyzxService.queryAvailable();
|
||||||
|
return Result.success("success");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
59
script/src/main/java/com/xiang/controller/XBController.java
Normal file
59
script/src/main/java/com/xiang/controller/XBController.java
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
package com.xiang.controller;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.xiang.common.Result;
|
||||||
|
import com.xiang.entity.pojo.xb.XbFundList;
|
||||||
|
import com.xiang.entity.request.xb.fund.QueryFundInfoReq;
|
||||||
|
import com.xiang.entity.request.xb.fund.QueryFundListReq;
|
||||||
|
import com.xiang.entity.request.xb.fund.QueryXbFundListReq;
|
||||||
|
import com.xiang.entity.response.xbyj.fund.FundInfo;
|
||||||
|
import com.xiang.entity.response.xbyj.fund.FundList;
|
||||||
|
import com.xiang.service.FundService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-14 16:26
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping("/system/xb")
|
||||||
|
public class XBController {
|
||||||
|
|
||||||
|
private final FundService fundService;
|
||||||
|
|
||||||
|
@PostMapping("/queryFundList")
|
||||||
|
public Result<XbFundList> queryFundList(@RequestBody QueryXbFundListReq req) {
|
||||||
|
List<XbFundList> result = fundService.queryFundList(req.getType());
|
||||||
|
if (CollectionUtils.isEmpty(result)) {
|
||||||
|
return Result.error("基金列表信息为空!");
|
||||||
|
}
|
||||||
|
return Result.success("success", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/queryList")
|
||||||
|
public Result<FundList> queryList(@RequestBody QueryFundListReq req) {
|
||||||
|
List<FundList> result = fundService.queryTodayList(req.getDate(), req.getDataResources(), req.getDataSourceSwitch(), req.getCodeArr());
|
||||||
|
if (CollectionUtils.isEmpty(result)) {
|
||||||
|
return Result.error("基金列表信息为空!");
|
||||||
|
}
|
||||||
|
return Result.success("success", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/queryFundInfo")
|
||||||
|
public Result<FundInfo> queryFundInfo(@RequestBody QueryFundInfoReq req) {
|
||||||
|
FundInfo fundInfo = fundService.queryFundInfo(req.getCode());
|
||||||
|
if (Objects.nonNull(fundInfo)) {
|
||||||
|
return Result.success("success", Lists.newArrayList(fundInfo));
|
||||||
|
}
|
||||||
|
return Result.error("查询基金信息为空!");
|
||||||
|
}
|
||||||
|
}
|
||||||
47
script/src/main/java/com/xiang/entity/pojo/GladosRunLog.java
Normal file
47
script/src/main/java/com/xiang/entity/pojo/GladosRunLog.java
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
package com.xiang.entity.pojo;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-09 13:56
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
public class GladosRunLog {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户id
|
||||||
|
*/
|
||||||
|
private Integer userId;
|
||||||
|
/**
|
||||||
|
* 用户
|
||||||
|
*/
|
||||||
|
private String user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求的时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime time;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否成功(0: 失败 1:成功)
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
|
||||||
|
private Integer code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回的响应
|
||||||
|
*/
|
||||||
|
private String response;
|
||||||
|
|
||||||
|
}
|
||||||
22
script/src/main/java/com/xiang/entity/pojo/User.java
Normal file
22
script/src/main/java/com/xiang/entity/pojo/User.java
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
package com.xiang.entity.pojo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-09 13:49
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class User {
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
private String user;
|
||||||
|
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
private String cookie;
|
||||||
|
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
}
|
||||||
25
script/src/main/java/com/xiang/entity/pojo/xb/FundInfo.java
Normal file
25
script/src/main/java/com/xiang/entity/pojo/xb/FundInfo.java
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
package com.xiang.entity.pojo.xb;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-15 09:05
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
public class FundInfo {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String change;
|
||||||
|
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package com.xiang.entity.pojo.xb;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-14 17:13
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
public class FundMessage {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 基金名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 基金代码
|
||||||
|
*/
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
private String update;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 变化率
|
||||||
|
*/
|
||||||
|
private BigDecimal change;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新日期
|
||||||
|
*/
|
||||||
|
private String date;
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.xiang.entity.pojo.xb;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-21 14:06
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class XbFundCount {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* l_id
|
||||||
|
*/
|
||||||
|
private Long lId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* code
|
||||||
|
*/
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* name
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* change
|
||||||
|
*/
|
||||||
|
private BigDecimal change;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* update_time
|
||||||
|
*/
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package com.xiang.entity.pojo.xb;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-21 13:53
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class XbFundList {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* code
|
||||||
|
*/
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* name
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* status
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1:A, 2:港,3:美
|
||||||
|
*/
|
||||||
|
private Integer type;
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.xiang.entity.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-08 15:22
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class GladosCheckInReq {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cookie
|
||||||
|
*/
|
||||||
|
private String cookie;
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.xiang.entity.request.xb.fund;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-14 16:27
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class QueryFundInfoReq {
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.xiang.entity.request.xb.fund;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-14 16:39
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class QueryFundListReq {
|
||||||
|
private List<String> codeArr;
|
||||||
|
|
||||||
|
private String date;
|
||||||
|
|
||||||
|
private String dataResources;
|
||||||
|
|
||||||
|
private Boolean dataSourceSwitch;
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.xiang.entity.request.xb.fund;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-21 13:58
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class QueryXbFundListReq {
|
||||||
|
private Integer type;
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.xiang.entity.response;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-08 14:55
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class GLaDOSResponse<T> {
|
||||||
|
|
||||||
|
private Long code;
|
||||||
|
|
||||||
|
private Integer points;
|
||||||
|
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
private List<T> list;
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.xiang.entity.response.jntyzx;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-14 14:38
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class JntyzxResponse<T> {
|
||||||
|
private Boolean success;
|
||||||
|
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
private Integer code;
|
||||||
|
|
||||||
|
private T result;
|
||||||
|
|
||||||
|
private Long timestamp;
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.xiang.entity.response.jntyzx.venue.query;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-14 14:37
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class QueryVenueResponse {
|
||||||
|
private List<TimeList> timeList;
|
||||||
|
|
||||||
|
private List<VenueList> venue;
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package com.xiang.entity.response.jntyzx.venue.query;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-14 14:45
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SitePositionList {
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String ballCourtId;
|
||||||
|
|
||||||
|
private String sjName;
|
||||||
|
|
||||||
|
private String scheduleId;
|
||||||
|
|
||||||
|
private String placeName;
|
||||||
|
|
||||||
|
private Integer placeId;
|
||||||
|
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
private String className;
|
||||||
|
|
||||||
|
private String classCode;
|
||||||
|
|
||||||
|
private BigDecimal money;
|
||||||
|
|
||||||
|
private String contacts;
|
||||||
|
|
||||||
|
private String contactNumber;
|
||||||
|
|
||||||
|
private String memberNumber;
|
||||||
|
|
||||||
|
private String appointments;
|
||||||
|
|
||||||
|
private String operator;
|
||||||
|
|
||||||
|
private String endTime;
|
||||||
|
|
||||||
|
private String beginTime;
|
||||||
|
|
||||||
|
private Integer specOneTimes;
|
||||||
|
|
||||||
|
private String ctypeCode;
|
||||||
|
|
||||||
|
private String isWhole;
|
||||||
|
|
||||||
|
private Long orderId;
|
||||||
|
|
||||||
|
private Integer votesnum;
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.xiang.entity.response.jntyzx.venue.query;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-14 14:39
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class TimeList {
|
||||||
|
private Long id;
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String beginTime;
|
||||||
|
|
||||||
|
private String endTime;
|
||||||
|
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
private String isenable;
|
||||||
|
|
||||||
|
private String operator;
|
||||||
|
|
||||||
|
private String createtime;
|
||||||
|
|
||||||
|
private String remarks;
|
||||||
|
|
||||||
|
private String default01;
|
||||||
|
private String default02;
|
||||||
|
private String default03;
|
||||||
|
private String votesnum;
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.xiang.entity.response.jntyzx.venue.query;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-14 14:39
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class VenueList {
|
||||||
|
|
||||||
|
private Integer placeId;
|
||||||
|
|
||||||
|
private String placeName;
|
||||||
|
|
||||||
|
private List<SitePositionList> sitePosition;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package com.xiang.entity.response.xbyj.fund;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-14 16:20
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class FundInfo {
|
||||||
|
@JSONField(name = "_id")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private Long ratingPeople;
|
||||||
|
|
||||||
|
private Long view;
|
||||||
|
|
||||||
|
private Long evaluateGood;
|
||||||
|
|
||||||
|
private Long evaluateBad;
|
||||||
|
|
||||||
|
private Long heat;
|
||||||
|
|
||||||
|
private Long ratingPeopleReal;
|
||||||
|
|
||||||
|
private BigDecimal rating;
|
||||||
|
|
||||||
|
@JSONField(name = "_createTime")
|
||||||
|
private String createTime;
|
||||||
|
|
||||||
|
@JSONField(name = "_updateTime")
|
||||||
|
private String updateTime;
|
||||||
|
|
||||||
|
private String isNewId;
|
||||||
|
|
||||||
|
private Boolean isRating;
|
||||||
|
|
||||||
|
private Long ratingPeopleTotal;
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.xiang.entity.response.xbyj.fund;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-14 16:37
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class FundList {
|
||||||
|
|
||||||
|
@JSONField(name = "_id")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private BigDecimal change;
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
private String date;
|
||||||
|
|
||||||
|
private BigDecimal quote;
|
||||||
|
|
||||||
|
private String update;
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.xiang.entity.response.xbyj.fund;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-14 16:20
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class QueryFundInfoResponse {
|
||||||
|
|
||||||
|
private FundInfo data;
|
||||||
|
|
||||||
|
private String msg;
|
||||||
|
|
||||||
|
private Integer code;
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.xiang.entity.response.xbyj.fund;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-14 16:36
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class QueryFundListResponse {
|
||||||
|
private List<FundList> data;
|
||||||
|
|
||||||
|
private String msg;
|
||||||
|
|
||||||
|
private Integer code;
|
||||||
|
}
|
||||||
30
script/src/main/java/com/xiang/repository/GladosMapper.java
Normal file
30
script/src/main/java/com/xiang/repository/GladosMapper.java
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
package com.xiang.repository;
|
||||||
|
|
||||||
|
import com.xiang.entity.pojo.GladosRunLog;
|
||||||
|
import com.xiang.entity.pojo.User;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-09 13:49
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
@Repository
|
||||||
|
public interface GladosMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查找所有可用的用户
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<User> listAllUser();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 脚本运行记录
|
||||||
|
* @param gladosRunLog
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int insertScriptRunLog(GladosRunLog gladosRunLog);
|
||||||
|
}
|
||||||
31
script/src/main/java/com/xiang/repository/XBFundMapper.java
Normal file
31
script/src/main/java/com/xiang/repository/XBFundMapper.java
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
package com.xiang.repository;
|
||||||
|
|
||||||
|
import com.xiang.entity.pojo.xb.FundInfo;
|
||||||
|
import com.xiang.entity.pojo.xb.XbFundCount;
|
||||||
|
import com.xiang.entity.pojo.xb.XbFundList;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-15 09:26
|
||||||
|
*/
|
||||||
|
@Repository
|
||||||
|
@Mapper
|
||||||
|
public interface XBFundMapper {
|
||||||
|
|
||||||
|
List<FundInfo> queryListIn2Min();
|
||||||
|
|
||||||
|
int batchSave(List<FundInfo> list);
|
||||||
|
|
||||||
|
List<XbFundList> queryFundList(@Param("type") Integer type);
|
||||||
|
|
||||||
|
int addCounts(List<XbFundCount> list);
|
||||||
|
|
||||||
|
List<XbFundCount> queryFundInWeek();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.xiang.schedule;
|
||||||
|
|
||||||
|
import com.xiang.service.GLaDOSService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-08 15:24
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
|
public class GladosCheckInJob {
|
||||||
|
|
||||||
|
private final GLaDOSService glaDOSService;
|
||||||
|
|
||||||
|
@Scheduled(cron = "0 0 8,16 1/1 * ?")
|
||||||
|
// @Scheduled(cron = "0 0/1 * * * ?")
|
||||||
|
public void checkInJon() {
|
||||||
|
log.info("[job] Glados Check In Job start, time:{}", LocalDateTime.now());
|
||||||
|
glaDOSService.checkIn();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.xiang.schedule.jntyzx;
|
||||||
|
|
||||||
|
import com.xiang.service.JntyzxService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-14 15:34
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
|
public class QueryVenueJob {
|
||||||
|
private final JntyzxService jntyzxService;
|
||||||
|
|
||||||
|
// @Scheduled(cron = "0 0 14 1/1 * ?")
|
||||||
|
public void query() throws Exception{
|
||||||
|
log.info("[查询场地] 查询当天场地定时任务启动!");
|
||||||
|
jntyzxService.queryAvailable();
|
||||||
|
log.info("[查询场地] 查询当天场地定时任务结束!");
|
||||||
|
}
|
||||||
|
}
|
||||||
104
script/src/main/java/com/xiang/schedule/xb/FundCountJob.java
Normal file
104
script/src/main/java/com/xiang/schedule/xb/FundCountJob.java
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
package com.xiang.schedule.xb;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.xiang.dingTalk.service.DingTalkService;
|
||||||
|
import com.xiang.entity.pojo.xb.XbFundCount;
|
||||||
|
import com.xiang.entity.pojo.xb.XbFundList;
|
||||||
|
import com.xiang.entity.response.xbyj.fund.FundList;
|
||||||
|
import com.xiang.service.FundService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
import java.time.DayOfWeek;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-21 13:59
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
|
public class FundCountJob {
|
||||||
|
|
||||||
|
private final FundService fundService;
|
||||||
|
private final DingTalkService dingTalkService;
|
||||||
|
@Value("${DingTalk.chatId}")
|
||||||
|
private String chatId;
|
||||||
|
@Scheduled(cron = "0 0 22 * * ?")
|
||||||
|
public void countFundJob() {
|
||||||
|
// 周六周日过滤
|
||||||
|
if (Objects.equals(LocalDateTime.now().getDayOfWeek(), DayOfWeek.SATURDAY) ||
|
||||||
|
Objects.equals(LocalDateTime.now().getDayOfWeek(), DayOfWeek.SUNDAY)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
log.info("==========================[基金统计] 基金统计定时任务启动!==========================");
|
||||||
|
List<XbFundList> lists = fundService.queryFundList(null);
|
||||||
|
if (CollectionUtils.isEmpty(lists)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<XbFundCount> counts = Lists.newCopyOnWriteArrayList();
|
||||||
|
String date = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||||
|
lists.parallelStream().forEach(xbFundList -> {
|
||||||
|
List<FundList> fund = fundService.queryTodayList(date, "2", Boolean.TRUE, Collections.singletonList(xbFundList.getCode()));
|
||||||
|
if (CollectionUtils.isNotEmpty(fund)) {
|
||||||
|
XbFundCount xbFundCount = new XbFundCount();
|
||||||
|
xbFundCount.setLId(xbFundList.getId());
|
||||||
|
xbFundCount.setCode(xbFundList.getCode());
|
||||||
|
xbFundCount.setName(xbFundList.getName());
|
||||||
|
xbFundCount.setChange(fund.get(0).getChange());
|
||||||
|
xbFundCount.setUpdateTime(LocalDateTime.now());
|
||||||
|
counts.add(xbFundCount);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (CollectionUtils.isNotEmpty(counts)) {
|
||||||
|
log.info("[基金统计] 基金统计记录,需要插入的数据:{}", JSONObject.toJSONString(counts));
|
||||||
|
fundService.addCounts(counts);
|
||||||
|
}
|
||||||
|
log.info("==========================[基金统计] 基金统计定时任务结束!==========================");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Scheduled(cron = "0 40 14 * * ? ")
|
||||||
|
public void countFundInWeek() throws Exception {
|
||||||
|
log.info("==========================[基金统计] 基金本周涨跌幅消息发送定时任务启动!==========================");
|
||||||
|
List<XbFundCount> xbFundCounts = fundService.queryFundCountInWeek();
|
||||||
|
if (CollectionUtils.isEmpty(xbFundCounts)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
Map<String, List<XbFundCount>> map = xbFundCounts.stream().collect(Collectors.groupingBy(XbFundCount::getCode));
|
||||||
|
map.forEach((k, v) -> {
|
||||||
|
List<XbFundCount> fundCounts = map.get(k);
|
||||||
|
if (CollectionUtils.isNotEmpty(fundCounts)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<BigDecimal> decimals = fundCounts.stream().map(XbFundCount::getChange).collect(Collectors.toList());
|
||||||
|
BigDecimal sum = BigDecimal.ZERO;
|
||||||
|
for (BigDecimal decimal : decimals) {
|
||||||
|
sum = sum.add(decimal);
|
||||||
|
}
|
||||||
|
BigDecimal avg = sum.divide(BigDecimal.valueOf(decimals.size()), 2, RoundingMode.HALF_UP);
|
||||||
|
sb.append("【").append(fundCounts.get(0).getName()).append("】本周平均涨跌幅为:").append(avg).append("\n");
|
||||||
|
});
|
||||||
|
if (StringUtils.isNotBlank(sb)) {
|
||||||
|
dingTalkService.sendChatMessage(chatId, sb.toString());
|
||||||
|
}
|
||||||
|
log.info("==========================[基金统计] 基金本周涨跌幅消息发送定时任务结束!==========================");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
272
script/src/main/java/com/xiang/schedule/xb/FundInfoQueryJob.java
Normal file
272
script/src/main/java/com/xiang/schedule/xb/FundInfoQueryJob.java
Normal file
@@ -0,0 +1,272 @@
|
|||||||
|
package com.xiang.schedule.xb;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.xiang.common.factory.xb.QueryThreadFactory;
|
||||||
|
import com.xiang.dingTalk.service.DingTalkService;
|
||||||
|
import com.xiang.entity.pojo.xb.FundMessage;
|
||||||
|
import com.xiang.entity.pojo.xb.XbFundList;
|
||||||
|
import com.xiang.entity.response.xbyj.fund.FundInfo;
|
||||||
|
import com.xiang.entity.response.xbyj.fund.FundList;
|
||||||
|
import com.xiang.repository.XBFundMapper;
|
||||||
|
import com.xiang.service.FundService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
import java.time.DayOfWeek;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-14 17:15
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
|
public class FundInfoQueryJob {
|
||||||
|
|
||||||
|
private final FundService fundService;
|
||||||
|
private final DingTalkService dingTalkService;
|
||||||
|
private final XBFundMapper xbFundMapper;
|
||||||
|
private final ExecutorService es =
|
||||||
|
new ThreadPoolExecutor(
|
||||||
|
10,
|
||||||
|
20,
|
||||||
|
1000,
|
||||||
|
TimeUnit.MILLISECONDS,
|
||||||
|
new LinkedBlockingQueue<>(),
|
||||||
|
new QueryThreadFactory("xb-query-thread", Boolean.TRUE),
|
||||||
|
new ThreadPoolExecutor.AbortPolicy());
|
||||||
|
@Value("${xiaobei.codeArr}")
|
||||||
|
private String codeArr;
|
||||||
|
@Value("${DingTalk.chatId}")
|
||||||
|
private String chatId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 基金增长定时任务查询
|
||||||
|
* 半个小时一次 9点开始到3.30结束
|
||||||
|
*/
|
||||||
|
@Scheduled(cron = "0 1,31 9,10,11,13,14 * * ? ")
|
||||||
|
public void queryFundJob() throws Exception {
|
||||||
|
// 周六周日过滤
|
||||||
|
if (Objects.equals(LocalDateTime.now().getDayOfWeek(), DayOfWeek.SATURDAY) ||
|
||||||
|
Objects.equals(LocalDateTime.now().getDayOfWeek(), DayOfWeek.SUNDAY)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
log.info("==========================[基金查询] 基金查询定时任务启动!==========================");
|
||||||
|
List<FundMessage> result = queryFund(1);
|
||||||
|
if (CollectionUtils.isEmpty(result)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
log.info("查询的基金涨跌幅数据:{}", JSONObject.toJSONString(result));
|
||||||
|
result = result.stream().sorted(Comparator.comparing(FundMessage::getChange)).collect(Collectors.toList());
|
||||||
|
StringBuilder sb = new StringBuilder("今天的A股行情:");
|
||||||
|
for (FundMessage fundMessage : result) {
|
||||||
|
sb.append("基金名称:")
|
||||||
|
.append(fundMessage.getName())
|
||||||
|
.append("于")
|
||||||
|
.append(fundMessage.getUpdate())
|
||||||
|
.append("更新涨跌幅:")
|
||||||
|
.append(fundMessage.getChange()
|
||||||
|
.multiply(new BigDecimal("100"))
|
||||||
|
.setScale(2, RoundingMode.HALF_UP).toString())
|
||||||
|
.append("%\n");
|
||||||
|
}
|
||||||
|
dingTalkService.sendChatMessage(chatId, sb.toString());
|
||||||
|
log.info("==========================[基金查询] 基金查询定时任务结束!==========================");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 基金增长定时任务查询
|
||||||
|
* 半个小时一次 9点开始到3.30结束
|
||||||
|
*/
|
||||||
|
@Scheduled(cron = "0 0 9 * * ? ")
|
||||||
|
public void queryFundJob3() throws Exception {
|
||||||
|
// 周六周日过滤
|
||||||
|
if (Objects.equals(LocalDateTime.now().getDayOfWeek(), DayOfWeek.SATURDAY) ||
|
||||||
|
Objects.equals(LocalDateTime.now().getDayOfWeek(), DayOfWeek.SUNDAY)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
log.info("==========================[基金查询] 基金查询定时任务启动!==========================");
|
||||||
|
List<FundMessage> result = queryFund(3);
|
||||||
|
if (CollectionUtils.isEmpty(result)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
log.info("查询的美股基金涨跌幅数据:{}", JSONObject.toJSONString(result));
|
||||||
|
result = result.stream().sorted(Comparator.comparing(FundMessage::getChange)).collect(Collectors.toList());
|
||||||
|
StringBuilder sb = new StringBuilder("今天的美股行情:\n");
|
||||||
|
for (FundMessage fundMessage : result) {
|
||||||
|
sb.append("基金名称:")
|
||||||
|
.append(fundMessage.getName())
|
||||||
|
.append("于")
|
||||||
|
.append(fundMessage.getUpdate())
|
||||||
|
.append("更新涨跌幅:")
|
||||||
|
.append(fundMessage.getChange()
|
||||||
|
.multiply(new BigDecimal("100"))
|
||||||
|
.setScale(2, RoundingMode.HALF_UP).toString())
|
||||||
|
.append("%\n");
|
||||||
|
}
|
||||||
|
dingTalkService.sendChatMessage(chatId, sb.toString());
|
||||||
|
log.info("==========================[基金查询] 基金查询定时任务结束!==========================");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 基金增长定时任务查询
|
||||||
|
* 半个小时一次 9点开始到3.30结束
|
||||||
|
*/
|
||||||
|
@Scheduled(cron = "0 1,31 9,10,11,13,14,15 * * ? ")
|
||||||
|
public void queryFundJob2() throws Exception {
|
||||||
|
// 周六周日过滤
|
||||||
|
if (Objects.equals(LocalDateTime.now().getDayOfWeek(), DayOfWeek.SATURDAY) ||
|
||||||
|
Objects.equals(LocalDateTime.now().getDayOfWeek(), DayOfWeek.SUNDAY)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
log.info("==========================[基金查询] 基金查询定时任务启动!==========================");
|
||||||
|
List<FundMessage> result = queryFund(2);
|
||||||
|
if (CollectionUtils.isEmpty(result)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
log.info("查询的港股基金涨跌幅数据:{}", JSONObject.toJSONString(result));
|
||||||
|
result = result.stream().sorted(Comparator.comparing(FundMessage::getChange)).collect(Collectors.toList());
|
||||||
|
StringBuilder sb = new StringBuilder("今天的美股行情:\n");
|
||||||
|
for (FundMessage fundMessage : result) {
|
||||||
|
sb.append("基金名称:")
|
||||||
|
.append(fundMessage.getName())
|
||||||
|
.append("于")
|
||||||
|
.append(fundMessage.getUpdate())
|
||||||
|
.append("更新涨跌幅:")
|
||||||
|
.append(fundMessage.getChange()
|
||||||
|
.multiply(new BigDecimal("100"))
|
||||||
|
.setScale(2, RoundingMode.HALF_UP).toString())
|
||||||
|
.append("%\n");
|
||||||
|
}
|
||||||
|
dingTalkService.sendChatMessage(chatId, sb.toString());
|
||||||
|
log.info("==========================[基金查询] 基金查询定时任务结束!==========================");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 基金涨跌幅5分钟超过2%重点通知
|
||||||
|
*/
|
||||||
|
@Scheduled(cron = "0 0/5 * * * ? ")
|
||||||
|
public void queryFundEmergencyJob() throws Exception {
|
||||||
|
// 周六周日过滤
|
||||||
|
if (Objects.equals(LocalDateTime.now().getDayOfWeek(), DayOfWeek.SATURDAY) ||
|
||||||
|
Objects.equals(LocalDateTime.now().getDayOfWeek(), DayOfWeek.SUNDAY)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<com.xiang.entity.pojo.xb.FundInfo> fundInfos = xbFundMapper.queryListIn2Min();
|
||||||
|
if (CollectionUtils.isEmpty(fundInfos)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Map<String, List<com.xiang.entity.pojo.xb.FundInfo>> map = fundInfos.stream().collect(Collectors.groupingBy(com.xiang.entity.pojo.xb.FundInfo::getCode));
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
map.entrySet().parallelStream().forEach(entry -> {
|
||||||
|
List<com.xiang.entity.pojo.xb.FundInfo> infos = entry.getValue();
|
||||||
|
BigDecimal sum = new BigDecimal("0");
|
||||||
|
for (int i = 0; i < infos.size() - 1; i++) {
|
||||||
|
BigDecimal subtract = new BigDecimal(infos.get(i + 1).getChange()).subtract(new BigDecimal(infos.get(i).getChange()));
|
||||||
|
sum = sum.add(subtract);
|
||||||
|
}
|
||||||
|
BigDecimal avg = sum.divide(new BigDecimal(String.valueOf(infos.size())), 2, RoundingMode.HALF_UP);
|
||||||
|
if (avg.abs().compareTo(new BigDecimal("2")) > 0) {
|
||||||
|
sb.append("基金").append(entry.getValue().get(0).getName()).append("5分钟的平均涨跌幅超过2%,涨跌幅达到").append(avg).append("\n");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (StringUtils.isNotBlank(sb)) {
|
||||||
|
dingTalkService.sendChatMessage(chatId, sb.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 基金每分钟涨幅记录
|
||||||
|
*/
|
||||||
|
@Scheduled(cron = "0 0/1 9,10,11,13,14 * * ?")
|
||||||
|
public void queryFundInfoInMinJob() {
|
||||||
|
// 周六周日过滤
|
||||||
|
if (Objects.equals(LocalDateTime.now().getDayOfWeek(), DayOfWeek.SATURDAY) ||
|
||||||
|
Objects.equals(LocalDateTime.now().getDayOfWeek(), DayOfWeek.SUNDAY)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<FundMessage> fundMessageList = queryFund(null);
|
||||||
|
if (CollectionUtils.isEmpty(fundMessageList)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<CompletableFuture> futures = Lists.newArrayList();
|
||||||
|
List<com.xiang.entity.pojo.xb.FundInfo> fundInfoList = Lists.newCopyOnWriteArrayList();
|
||||||
|
fundMessageList.parallelStream().forEach(fundMessage -> {
|
||||||
|
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
|
||||||
|
FundInfo fundInfo = fundService.queryFundInfo(fundMessage.getCode());
|
||||||
|
|
||||||
|
com.xiang.entity.pojo.xb.FundInfo info = com.xiang.entity.pojo.xb.FundInfo.builder()
|
||||||
|
.code(fundMessage.getCode())
|
||||||
|
.name(fundInfo.getName())
|
||||||
|
.change(fundMessage.getChange().multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP).toString())
|
||||||
|
.updateTime(getTimeFromStr(fundMessage.getDate(), fundMessage.getUpdate()))
|
||||||
|
.build();
|
||||||
|
fundInfoList.add(info);
|
||||||
|
}, es);
|
||||||
|
futures.add(future);
|
||||||
|
});
|
||||||
|
|
||||||
|
CompletableFuture[] futureArr = futures
|
||||||
|
.toArray(futures.toArray(new CompletableFuture[0]));
|
||||||
|
CompletableFuture.allOf(futureArr).join();
|
||||||
|
|
||||||
|
if (CollectionUtils.isNotEmpty(fundInfoList)) {
|
||||||
|
log.info("[基金查询] 每分钟基金涨跌幅查询记录,需要插入的数据:{}", JSONObject.toJSONString(fundInfoList));
|
||||||
|
xbFundMapper.batchSave(fundInfoList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<FundMessage> queryFund(Integer type) {
|
||||||
|
String date = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||||
|
List<String> code = Lists.newArrayList();
|
||||||
|
List<XbFundList> lists = xbFundMapper.queryFundList(type);
|
||||||
|
if (CollectionUtils.isEmpty(lists)) {
|
||||||
|
if (Objects.equals(type, 1)) {
|
||||||
|
code = Arrays.stream(codeArr.split(", ")).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
code = lists.stream().map(XbFundList::getCode).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
List<FundList> fundLists = fundService.queryTodayList(date, "2", Boolean.TRUE, code);
|
||||||
|
if (CollectionUtils.isEmpty(fundLists)) {
|
||||||
|
return Lists.newArrayList();
|
||||||
|
}
|
||||||
|
List<FundMessage> result = Lists.newCopyOnWriteArrayList();
|
||||||
|
fundLists.parallelStream().forEach(fundList -> {
|
||||||
|
FundInfo fundInfo = fundService.queryFundInfo(fundList.getCode());
|
||||||
|
if (Objects.nonNull(fundInfo)) {
|
||||||
|
FundMessage fund = FundMessage.builder().name(fundInfo.getName()).date(fundList.getDate())
|
||||||
|
.code(fundList.getCode()).change(fundList.getChange()).update(fundList.getUpdate()).build();
|
||||||
|
result.add(fund);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private LocalDateTime getTimeFromStr(String date, String time) {
|
||||||
|
String dateTimeStr = date + " " + time;
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
|
return LocalDateTime.parse(dateTimeStr, formatter);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
42
script/src/main/java/com/xiang/service/FundService.java
Normal file
42
script/src/main/java/com/xiang/service/FundService.java
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
package com.xiang.service;
|
||||||
|
|
||||||
|
import com.xiang.entity.pojo.xb.XbFundCount;
|
||||||
|
import com.xiang.entity.pojo.xb.XbFundList;
|
||||||
|
import com.xiang.entity.response.xbyj.fund.FundInfo;
|
||||||
|
import com.xiang.entity.response.xbyj.fund.FundList;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-14 15:41
|
||||||
|
*/
|
||||||
|
public interface FundService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询列表情况
|
||||||
|
*/
|
||||||
|
List<FundList> queryTodayList(String date, String dataResources, Boolean dataSourceSwitch, List<String> codeArr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询基金详情
|
||||||
|
* @param code 基金代码
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
FundInfo queryFundInfo(String code);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询基金列表
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<XbFundList> queryFundList(Integer type);
|
||||||
|
|
||||||
|
int addCounts(List<XbFundCount> list);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询一周内基金统计
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<XbFundCount> queryFundCountInWeek();
|
||||||
|
}
|
||||||
112
script/src/main/java/com/xiang/service/FundServiceImpl.java
Normal file
112
script/src/main/java/com/xiang/service/FundServiceImpl.java
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
package com.xiang.service;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.xiang.common.URLConstants;
|
||||||
|
import com.xiang.entity.pojo.xb.XbFundCount;
|
||||||
|
import com.xiang.entity.pojo.xb.XbFundList;
|
||||||
|
import com.xiang.entity.response.xbyj.fund.FundInfo;
|
||||||
|
import com.xiang.entity.response.xbyj.fund.FundList;
|
||||||
|
import com.xiang.entity.response.xbyj.fund.QueryFundInfoResponse;
|
||||||
|
import com.xiang.entity.response.xbyj.fund.QueryFundListResponse;
|
||||||
|
import com.xiang.repository.XBFundMapper;
|
||||||
|
import com.xiang.utils.HttpUtils;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-14 15:42
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
|
public class FundServiceImpl implements FundService{
|
||||||
|
|
||||||
|
private final HttpUtils httpUtils;
|
||||||
|
|
||||||
|
private final XBFundMapper xbFundMapper;
|
||||||
|
|
||||||
|
@Value("${xiaobei.unionId}")
|
||||||
|
private String unionId;
|
||||||
|
|
||||||
|
@Value("${xiaobei.codeArr}")
|
||||||
|
private String codeArrStr;
|
||||||
|
|
||||||
|
private static final Integer SUCCESS_200 = 200;
|
||||||
|
private static final Integer SUCCESS_0= 0;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<FundList> queryTodayList(String date, String dataResources, Boolean dataSourceSwitch, List<String> codeArr) {
|
||||||
|
if (CollectionUtils.isEmpty(codeArr)) {
|
||||||
|
String[] split = codeArrStr.split(", ");
|
||||||
|
codeArr = Arrays.stream(split).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
json.put("date", date);
|
||||||
|
json.put("unionId", unionId);
|
||||||
|
json.put("dataResources", dataResources);
|
||||||
|
json.put("dataSourceSwitch", dataSourceSwitch);
|
||||||
|
json.put("codeArr", codeArr);
|
||||||
|
|
||||||
|
String resp = "";
|
||||||
|
try {
|
||||||
|
resp = httpUtils.doPost(URLConstants.XB_QUERY_LIST, null, JSONObject.toJSONString(json));
|
||||||
|
log.info("[基金列表查询] 查询成功, 请求地址:{}, 请求参数:{}, 请求结果:{}", URLConstants.XB_QUERY_LIST, JSONObject.toJSONString(json), resp);
|
||||||
|
if (StringUtils.isNotBlank(resp)) {
|
||||||
|
QueryFundListResponse response = JSONObject.parseObject(resp, QueryFundListResponse.class);
|
||||||
|
if (Objects.nonNull(response)) {
|
||||||
|
if (Objects.equals(SUCCESS_0, response.getCode())) {
|
||||||
|
return response.getData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("[查询基金列表],请求失败, 请求参数:{}, 请求结果:{}", JSONObject.toJSONString(json), resp);
|
||||||
|
}
|
||||||
|
return Lists.newArrayList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FundInfo queryFundInfo(String code) {
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("code", code);
|
||||||
|
jsonObject.put("unionId", unionId);
|
||||||
|
String resp = httpUtils.doPost(URLConstants.XB_QUERY_FUND_INFO, null, JSONObject.toJSONString(jsonObject));
|
||||||
|
if (StringUtils.isNotBlank(resp)) {
|
||||||
|
log.info("[小蓓养基] 基金详情查询:请求参数:{}, 请求结果:{}", JSONObject.toJSONString(jsonObject), resp);
|
||||||
|
QueryFundInfoResponse response = JSONObject.parseObject(resp, QueryFundInfoResponse.class);
|
||||||
|
if (Objects.nonNull(response)) {
|
||||||
|
if (Objects.equals(response.getCode(), SUCCESS_200)) {
|
||||||
|
return response.getData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<XbFundList> queryFundList(Integer type) {
|
||||||
|
return xbFundMapper.queryFundList(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int addCounts(List<XbFundCount> list) {
|
||||||
|
return xbFundMapper.addCounts(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<XbFundCount> queryFundCountInWeek() {
|
||||||
|
return xbFundMapper.queryFundInWeek();
|
||||||
|
}
|
||||||
|
}
|
||||||
13
script/src/main/java/com/xiang/service/GLaDOSService.java
Normal file
13
script/src/main/java/com/xiang/service/GLaDOSService.java
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package com.xiang.service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-08 14:38
|
||||||
|
*/
|
||||||
|
public interface GLaDOSService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 签到
|
||||||
|
*/
|
||||||
|
String checkIn();
|
||||||
|
}
|
||||||
119
script/src/main/java/com/xiang/service/GLaDOSServiceImpl.java
Normal file
119
script/src/main/java/com/xiang/service/GLaDOSServiceImpl.java
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
package com.xiang.service;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import com.xiang.common.GladosConstants;
|
||||||
|
import com.xiang.common.URLConstants;
|
||||||
|
import com.xiang.dingTalk.service.DingTalkService;
|
||||||
|
import com.xiang.entity.pojo.GladosRunLog;
|
||||||
|
import com.xiang.entity.pojo.User;
|
||||||
|
import com.xiang.entity.response.GLaDOSResponse;
|
||||||
|
import com.xiang.repository.GladosMapper;
|
||||||
|
import com.xiang.utils.HttpUtils;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-08 14:38
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class GLaDOSServiceImpl implements GLaDOSService{
|
||||||
|
|
||||||
|
private final HttpUtils httpUtils;
|
||||||
|
|
||||||
|
private final GladosMapper gladosMapper;
|
||||||
|
|
||||||
|
private final DingTalkService dingTalkService;
|
||||||
|
|
||||||
|
@Value("${DingTalk.userList}")
|
||||||
|
private String userList;
|
||||||
|
|
||||||
|
@Value("${DingTalk.chatId}")
|
||||||
|
private String chatId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 签到
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String checkIn() {
|
||||||
|
|
||||||
|
List<User> users = gladosMapper.listAllUser();
|
||||||
|
if (CollectionUtils.isEmpty(users)) {
|
||||||
|
return "user is empty";
|
||||||
|
}
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
users.parallelStream().forEach(user -> {
|
||||||
|
try {
|
||||||
|
checkIn(user, sb);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("签到失败,", e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkIn(User user, StringBuffer sb) {
|
||||||
|
|
||||||
|
Map<String, String> header = Maps.newHashMap();
|
||||||
|
header.put("Cookie", user.getCookie());
|
||||||
|
|
||||||
|
String response = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
response = httpUtils.doPost(URLConstants.GLADOS_CHECK_IN_URL, header, GladosConstants.GLADOS_CHECK_IN_BODY);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("http do post error, header:{}, jsonParams:{}", JSONObject.toJSONString(header), GladosConstants.GLADOS_CHECK_IN_BODY, e);
|
||||||
|
}
|
||||||
|
if (StringUtils.isEmpty(response)) {
|
||||||
|
log.error("http do post error, header:{}, jsonParams:{}", JSONObject.toJSONString(header), GladosConstants.GLADOS_CHECK_IN_BODY);
|
||||||
|
}
|
||||||
|
GLaDOSResponse gLaDOSResponse =JSONObject.parseObject(response, GLaDOSResponse.class);
|
||||||
|
if (Objects.nonNull(gLaDOSResponse)) {
|
||||||
|
log.info("http do post success, response:{}", response);
|
||||||
|
if (0 == gLaDOSResponse.getCode() && Objects.nonNull(gLaDOSResponse.getPoints())) {
|
||||||
|
log.info("签到成功, 签到积分:{}, 签到消息:{}", gLaDOSResponse.getPoints(), gLaDOSResponse.getMessage());
|
||||||
|
sb.append(user.getEmail()).append("签到成功,获得积分:").append(gLaDOSResponse.getPoints()).append("\n");
|
||||||
|
try {
|
||||||
|
dingTalkService.sendChatMessage(chatId, "[时间:" + LocalDateTime.now() + "] 用户: " +
|
||||||
|
user.getEmail() + "签到成功,获得积分:" + gLaDOSResponse.getPoints());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("发送钉钉消息失败", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (1 == gLaDOSResponse.getCode()) {
|
||||||
|
log.warn("签到失败,重复签到,用户:{}, 签到消息:{}", user.getEmail(), gLaDOSResponse.getMessage());
|
||||||
|
sb.append(user).append("签到失败,重复签到,用户:").append(user).append(",签到消息:").append(gLaDOSResponse.getMessage());
|
||||||
|
}
|
||||||
|
if (-2 == gLaDOSResponse.getCode()) {
|
||||||
|
log.warn("签到失败,用户:{}, cookie过期:{}", user.getEmail(), gLaDOSResponse.getMessage());
|
||||||
|
String message = "[时间:" + LocalDateTime.now() + "] 用户: " + user.getEmail() + ",签到消息: " + gLaDOSResponse.getMessage();
|
||||||
|
try {
|
||||||
|
dingTalkService.sendChatMessage(chatId, message);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("发送钉钉消息失败", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (gLaDOSResponse.getCode() != 1) {
|
||||||
|
log.warn("签到异常,返回的消息:{}", gLaDOSResponse.getMessage());
|
||||||
|
sb.append(user.getEmail()).append("签到异常,返回的消息:").append(gLaDOSResponse.getMessage()).append("\n");
|
||||||
|
}
|
||||||
|
GladosRunLog build = GladosRunLog.builder().time(LocalDateTime.now()).status(1).code(Integer.valueOf(gLaDOSResponse.getCode().toString())).response(response).user(user.getEmail()).userId(user.getId()).build();
|
||||||
|
gladosMapper.insertScriptRunLog(build);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
GladosRunLog build = GladosRunLog.builder().time(LocalDateTime.now()).status(0).response(response).user(user.getEmail()).userId(user.getId()).build();
|
||||||
|
gladosMapper.insertScriptRunLog(build);
|
||||||
|
}
|
||||||
|
}
|
||||||
13
script/src/main/java/com/xiang/service/JntyzxService.java
Normal file
13
script/src/main/java/com/xiang/service/JntyzxService.java
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package com.xiang.service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-14 14:06
|
||||||
|
*/
|
||||||
|
public interface JntyzxService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询可用场地
|
||||||
|
*/
|
||||||
|
void queryAvailable() throws Exception;
|
||||||
|
}
|
||||||
100
script/src/main/java/com/xiang/service/JntyzxServiceImpl.java
Normal file
100
script/src/main/java/com/xiang/service/JntyzxServiceImpl.java
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
package com.xiang.service;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import com.xiang.common.URLConstants;
|
||||||
|
import com.xiang.dingTalk.service.DingTalkService;
|
||||||
|
import com.xiang.entity.response.jntyzx.JntyzxResponse;
|
||||||
|
import com.xiang.entity.response.jntyzx.venue.query.QueryVenueResponse;
|
||||||
|
import com.xiang.entity.response.jntyzx.venue.query.SitePositionList;
|
||||||
|
import com.xiang.entity.response.jntyzx.venue.query.VenueList;
|
||||||
|
import com.xiang.utils.HttpUtils;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-14 14:07
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
|
public class JntyzxServiceImpl implements JntyzxService{
|
||||||
|
|
||||||
|
private final HttpUtils httpUtils;
|
||||||
|
|
||||||
|
private final DingTalkService dingTalkService;
|
||||||
|
|
||||||
|
@Value("${DingTalk.chatId}")
|
||||||
|
private String chatId;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void queryAvailable() throws Exception {
|
||||||
|
String url = URLConstants.JNTYZX_QUERY_TODAY_VENUE;
|
||||||
|
Map<String, String> header = Maps.newHashMap();
|
||||||
|
header.put("X-Access-Token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3NDcyMTAwNzQsInVzZXJuYW1lIjoid3hfb3Blbl9pZF9vMjFNWDR5N3doWENHanZVVEdQNkNUejJIYkQ4In0.0h_cAH_e5cCXDQlQN40jZDBgtfrzQWAmgl3YPQf0d-M");
|
||||||
|
String resp = null;
|
||||||
|
try {
|
||||||
|
resp = httpUtils.doGet(url, header, null);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("[doGet] 江南体育中心查询当天场地 请求失败, url:{}", url);
|
||||||
|
}
|
||||||
|
if (StringUtils.isEmpty(resp)) {
|
||||||
|
log.warn("[查询场地] 江南体育中心查询当天场地 请求结果为空, url:{}, resp:{}", url, resp);
|
||||||
|
}
|
||||||
|
JntyzxResponse response = JSONObject.parseObject(resp, JntyzxResponse.class);
|
||||||
|
String message = "";
|
||||||
|
if (Objects.nonNull(response)) {
|
||||||
|
if (response.getSuccess()) {
|
||||||
|
log.info("[查询场地] 江南体育中心查询当天场地 请求地址:{}, 请求结果:{}", url, resp);
|
||||||
|
JSONObject object = (JSONObject) response.getResult();
|
||||||
|
if (Objects.nonNull(object)) {
|
||||||
|
QueryVenueResponse result = object.toJavaObject(QueryVenueResponse.class);
|
||||||
|
if (Objects.nonNull(result)) {
|
||||||
|
List<VenueList> venueLists = result.getVenue();
|
||||||
|
if (!CollectionUtils.isEmpty(venueLists)) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (VenueList venue : venueLists) {
|
||||||
|
List<SitePositionList> positionList = venue.getSitePosition();
|
||||||
|
positionList = positionList.stream().filter(this::filterTime).collect(Collectors.toList());
|
||||||
|
for (SitePositionList sitePositionList : positionList) {
|
||||||
|
sb.append(venue.getPlaceName()).append(":").append(sitePositionList.getSjName()).append(":预定人:").append(sitePositionList.getContacts()).append(",电话:").append(sitePositionList.getContactNumber()).append("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
message = sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(message)) {
|
||||||
|
dingTalkService.sendChatMessage(chatId, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Boolean filterTime(SitePositionList sitePositionList) {
|
||||||
|
if (StringUtils.equals("18:00-19:00", sitePositionList.getSjName())) {
|
||||||
|
return Boolean.TRUE;
|
||||||
|
}
|
||||||
|
if (StringUtils.equals("19:00-20:00", sitePositionList.getSjName())) {
|
||||||
|
return Boolean.TRUE;
|
||||||
|
}
|
||||||
|
if (StringUtils.equals("20:00-21:00", sitePositionList.getSjName())) {
|
||||||
|
return Boolean.TRUE;
|
||||||
|
}
|
||||||
|
if (StringUtils.equals("21:00-22:00", sitePositionList.getSjName())) {
|
||||||
|
return Boolean.TRUE;
|
||||||
|
}
|
||||||
|
return Boolean.FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
143
script/src/main/java/com/xiang/utils/HttpUtils.java
Normal file
143
script/src/main/java/com/xiang/utils/HttpUtils.java
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
package com.xiang.utils;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.xiang.common.URLConstants;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.MapUtils;
|
||||||
|
import org.apache.http.client.config.RequestConfig;
|
||||||
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
|
import org.apache.http.client.methods.HttpGet;
|
||||||
|
import org.apache.http.client.methods.HttpPost;
|
||||||
|
import org.apache.http.entity.StringEntity;
|
||||||
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
|
import org.apache.http.impl.client.HttpClients;
|
||||||
|
import org.apache.http.util.EntityUtils;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-08 14:39
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class HttpUtils {
|
||||||
|
|
||||||
|
private int socketTimeOut = 60 * 1000;
|
||||||
|
private int connectTimeout = 60 * 1000;
|
||||||
|
private int connectionRequestTimeout = 15 * 1000;
|
||||||
|
private int defaultMaxPerRoute = 500;
|
||||||
|
private int maxTotal = 2000;
|
||||||
|
|
||||||
|
public String doPost(String url, Map<String, String> header, String jsonParams) {
|
||||||
|
RequestConfig requestConfig = RequestConfig.custom()
|
||||||
|
// 设置连接超时时间
|
||||||
|
.setConnectTimeout(connectTimeout)
|
||||||
|
// 设置Socket超时时间
|
||||||
|
.setSocketTimeout(socketTimeOut)
|
||||||
|
.setConnectionRequestTimeout(connectionRequestTimeout)
|
||||||
|
.build();
|
||||||
|
//创建httpClient对象
|
||||||
|
CloseableHttpClient httpClient = HttpClients.custom().setDefaultRequestConfig(requestConfig).build();
|
||||||
|
CloseableHttpResponse response = null;
|
||||||
|
String result = "";
|
||||||
|
try {
|
||||||
|
// 创建http请求
|
||||||
|
HttpPost httpPost = new HttpPost(url);
|
||||||
|
httpPost.addHeader("Content-Type", "application/json");
|
||||||
|
// 创建请求内容
|
||||||
|
StringEntity entity = new StringEntity(jsonParams, "utf-8");
|
||||||
|
entity.setContentType("application/json");
|
||||||
|
httpPost.setEntity(entity);
|
||||||
|
// 设置请求头
|
||||||
|
if (null != header && !header.isEmpty()) {
|
||||||
|
Set<Map.Entry<String, String>> entries = header.entrySet();
|
||||||
|
for (Map.Entry<String, String> e : entries) {
|
||||||
|
httpPost.setHeader(e.getKey(), e.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
response = httpClient.execute(httpPost);
|
||||||
|
result = EntityUtils.toString(response.getEntity(), "utf-8");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("doPost异常", e);
|
||||||
|
} finally {
|
||||||
|
//关闭资源
|
||||||
|
closeResource(response, httpClient);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String doGet(String url, Map<String, String> header, Map<String, String> param) {
|
||||||
|
RequestConfig requestConfig = RequestConfig.custom()
|
||||||
|
// 设置连接超时时间
|
||||||
|
.setConnectTimeout(connectTimeout)
|
||||||
|
// 设置Socket超时时间
|
||||||
|
.setSocketTimeout(socketTimeOut)
|
||||||
|
.setConnectionRequestTimeout(connectionRequestTimeout)
|
||||||
|
.build();
|
||||||
|
CloseableHttpClient httpClient = HttpClients.custom().setDefaultRequestConfig(requestConfig).build();
|
||||||
|
CloseableHttpResponse response;
|
||||||
|
String result = "";
|
||||||
|
try {
|
||||||
|
String request = "";
|
||||||
|
if (MapUtils.isNotEmpty(param)) {
|
||||||
|
StringBuilder req = new StringBuilder("?");
|
||||||
|
for (Map.Entry<String, String> entry : param.entrySet()) {
|
||||||
|
req.append(entry.getKey()).append("=").append(entry.getValue()).append("&");
|
||||||
|
}
|
||||||
|
request = req.substring(0, req.length() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
HttpGet httpGet = new HttpGet(url + request);
|
||||||
|
httpGet.addHeader("Content-Type", "application/json");
|
||||||
|
if (MapUtils.isNotEmpty(header)) {
|
||||||
|
for (Map.Entry<String, String> entry : header.entrySet()) {
|
||||||
|
httpGet.setHeader(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.info("doGet请求:请求地址:{}", url + request);
|
||||||
|
response = httpClient.execute(httpGet);
|
||||||
|
result = EntityUtils.toString(response.getEntity(), "utf-8");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("doGet异常:", e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description 关闭资源
|
||||||
|
*/
|
||||||
|
private void closeResource(Closeable... resources) {
|
||||||
|
try {
|
||||||
|
for (Closeable resource : resources) {
|
||||||
|
if (resource != null) {
|
||||||
|
resource.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// HttpUtils httpUtils = new HttpUtils();
|
||||||
|
// Map<String, String> map = new HashMap<>();
|
||||||
|
// map.put("Cookie", "SL_G_WPT_TO=en; SL_GWPT_Show_Hide_tmp=1; SL_wptGlobTipTmp=1; koa:sess=eyJ1c2VySWQiOjU1OTg1MywiX2V4cGlyZSI6MTc3MjYwNDkyNjI4OCwiX21heEFnZSI6MjU5MjAwMDAwMDB9; koa:sess.sig=OdaqjpLkIp19lXn0lFuOsHX7vEM");
|
||||||
|
// String response = httpUtils.doPost("https://www.glados.one/api/user/checkin", map, "{\"token\":\"glados.one\"}");
|
||||||
|
// System.out.println(response);
|
||||||
|
HttpUtils httpUtils = new HttpUtils();
|
||||||
|
// Map<String, String> header = Maps.newHashMap();
|
||||||
|
// header.put("X-Access-Token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3NDcyMTAwNzQsInVzZXJuYW1lIjoid3hfb3Blbl9pZF9vMjFNWDR5N3doWENHanZVVEdQNkNUejJIYkQ4In0.0h_cAH_e5cCXDQlQN40jZDBgtfrzQWAmgl3YPQf0d-M");
|
||||||
|
// System.out.println(httpUtils.doGet("https://jntyzx.cn:8443/GYM-JN/multi/Subscribe/getSubscribeByToday?gid=03&isWeekend=1", header, null));
|
||||||
|
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("code", "012414");
|
||||||
|
jsonObject.put("unionId", "o896o5y8bJZYMh2gdKhDdmUKc0Wk");
|
||||||
|
String resp = httpUtils.doPost(URLConstants.XB_QUERY_FUND_INFO, null, JSONObject.toJSONString(jsonObject));
|
||||||
|
System.out.println(resp);
|
||||||
|
}
|
||||||
|
}
|
||||||
6
script/src/main/resources/application-local.yml
Normal file
6
script/src/main/resources/application-local.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
spring:
|
||||||
|
datasource:
|
||||||
|
url: jdbc:mysql:///xservice-script?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
|
||||||
|
username: root
|
||||||
|
password: 123456
|
||||||
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
6
script/src/main/resources/application-prod.yml
Normal file
6
script/src/main/resources/application-prod.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
spring:
|
||||||
|
datasource:
|
||||||
|
url: jdbc:mysql://172.28.159.213:3306/xservice-script?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
|
||||||
|
username: root
|
||||||
|
password: 123456
|
||||||
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
24
script/src/main/resources/application.yml
Normal file
24
script/src/main/resources/application.yml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
mybatis:
|
||||||
|
mapper-locations:
|
||||||
|
- classpath*:mapper/*.xml
|
||||||
|
configuration:
|
||||||
|
map-underscore-to-camel-case: true
|
||||||
|
|
||||||
|
DingTalk:
|
||||||
|
# 钉钉消息用户,用逗号隔开
|
||||||
|
userList: "450841600726084717"
|
||||||
|
# 钉钉消息群ID,需要调用/chat/create api创建群返回
|
||||||
|
chatId: "chatd16d8daeea33b36b73588c676d508096"
|
||||||
|
|
||||||
|
xiaobei:
|
||||||
|
unionId: o896o5y8bJZYMh2gdKhDdmUKc0Wk
|
||||||
|
codeArr: "010364, 022150, 013224, 008960, 013841, 015528, 012414, 020412, 014662, 016814, 014422, 015596, 007844,
|
||||||
|
023521, 016496, 016387, 021608, 008282, 012769, 021580, 017811, 007467, 017516, 018125, 016531, 021091,
|
||||||
|
021688, 021536, 019571, 168204, 020741, 013594"
|
||||||
|
|
||||||
|
server:
|
||||||
|
port: 8080
|
||||||
|
|
||||||
|
spring:
|
||||||
|
profiles:
|
||||||
|
active: local
|
||||||
102
script/src/main/resources/logback-spring.xml
Normal file
102
script/src/main/resources/logback-spring.xml
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration debug="false">
|
||||||
|
|
||||||
|
<!-- 应用名称:和统一配置中的项目代码保持一致(小写) -->
|
||||||
|
<property name="APP_NAME" value="xservice-script"/>
|
||||||
|
<contextName>${APP_NAME}</contextName>
|
||||||
|
|
||||||
|
<!--日志文件保留天数 -->
|
||||||
|
<property name="LOG_MAX_HISTORY" value="30"/>
|
||||||
|
<!--应用日志文件保存路径 -->
|
||||||
|
<!--在没有定义${LOG_HOME}系统变量的时候,可以设置此本地变量。提交测试、上线时,要将其注释掉,使用系统变量。 -->
|
||||||
|
<property name="LOG_HOME" value="logs/${APP_NAME}"/>
|
||||||
|
<!--<property name="LOG_HOME" msg="/home/logs/${APP_NAME}" />-->
|
||||||
|
|
||||||
|
<!--控制台输出appender-->
|
||||||
|
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<!--设置输出格式-->
|
||||||
|
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||||
|
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
|
||||||
|
<pattern>%boldGreen(%contextName): %boldCyan(%d{yyyy-MM-dd HH:mm:ss:SSS}) %highlight([%c]) %boldMagenta([%t]) %boldCyan([%L]) %highlight([traceId:%X{traceId:-},spanId:%X{spanId:-},localIp:%X{localIp:-}]) %boldGreen([%p]) - %msg%n
|
||||||
|
</pattern>
|
||||||
|
<!--设置编码-->
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 按照每天生成日志文件:主项目日志 -->
|
||||||
|
<appender name="APP_DEBUG" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!--日志文件输出的文件名 -->
|
||||||
|
<FileNamePattern>${LOG_HOME}/debug-%d{yyyy-MM-dd}.log</FileNamePattern>
|
||||||
|
<!--日志文件保留天数 -->
|
||||||
|
<MaxHistory>${LOG_MAX_HISTORY}</MaxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||||
|
<!--格式化输出:%d表示日期,%c类名,%t表示线程名,%L行, %p日志级别 %msg:日志消息,%n是换行符 -->
|
||||||
|
<pattern>%contextName: %d{yyyy-MM-dd HH:mm:ss.SSS} [%c][%t][%L][%p] [traceId:%X{traceId:-},spanId:%X{spanId:-},localIp:%X{localIp:-}] - %msg%n</pattern>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
</encoder>
|
||||||
|
<!-- 此日志文件只记录debug级别的 -->
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<level>debug</level>
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 按照每天生成日志文件:主项目日志 -->
|
||||||
|
<appender name="APP_INFO" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!--日志文件输出的文件名 -->
|
||||||
|
<FileNamePattern>${LOG_HOME}/info-%d{yyyy-MM-dd}.log</FileNamePattern>
|
||||||
|
<!--日志文件保留天数 -->
|
||||||
|
<MaxHistory>${LOG_MAX_HISTORY}</MaxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||||
|
<!--格式化输出:%d表示日期,%c类名,%t表示线程名,%L行, %p日志级别 %msg:日志消息,%n是换行符 -->
|
||||||
|
<pattern>%contextName: %d{yyyy-MM-dd HH:mm:ss.SSS} [%c][%t][%L][%p] [traceId:%X{traceId:-},spanId:%X{spanId:-},localIp:%X{localIp:-}] - %msg%n</pattern>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
</encoder>
|
||||||
|
|
||||||
|
<!-- 此日志文件只记录info级别的 -->
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<level>info</level>
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 按照每天生成日志文件:主项目日志 -->
|
||||||
|
<appender name="APP_ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!--日志文件输出的文件名 -->
|
||||||
|
<FileNamePattern>${LOG_HOME}/error-%d{yyyy-MM-dd}.log</FileNamePattern>
|
||||||
|
<!--日志文件保留天数 -->
|
||||||
|
<MaxHistory>${LOG_MAX_HISTORY}</MaxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||||
|
<!--格式化输出:%d表示日期,%c类名,%t表示线程名,%L行, %p日志级别 %msg:日志消息,%n是换行符 -->
|
||||||
|
<pattern>%contextName: %d{yyyy-MM-dd HH:mm:ss.SSS} [%c][%t][%L][%p] [traceId:%X{traceId:-},spanId:%X{spanId:-},localIp:%X{localIp:-}] - %msg%n</pattern>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
</encoder>
|
||||||
|
<!-- 此日志文件只记录error级别的 -->
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<level>error</level>
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!--日志输出到文件-->
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="APP_DEBUG"/>
|
||||||
|
<appender-ref ref="APP_INFO"/>
|
||||||
|
<appender-ref ref="APP_ERROR"/>
|
||||||
|
<appender-ref ref="console"/>
|
||||||
|
</root>
|
||||||
|
|
||||||
|
<!-- mybatis 日志级别 -->
|
||||||
|
<logger name="com.xiang" level="debug"/>
|
||||||
|
|
||||||
|
</configuration>
|
||||||
32
script/src/main/resources/mapper/GladosMapper.xml
Normal file
32
script/src/main/resources/mapper/GladosMapper.xml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?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.repository.GladosMapper">
|
||||||
|
|
||||||
|
<resultMap id="BaseResultMap" type="com.xiang.entity.pojo.User" >
|
||||||
|
<result column="id" property="id"/>
|
||||||
|
<result column="user" property="user" />
|
||||||
|
<result column="email" property="email" />
|
||||||
|
<result column="cookie" property="cookie" />
|
||||||
|
<result column="status" property="status" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
id, user,
|
||||||
|
email,
|
||||||
|
cookie,
|
||||||
|
status
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<insert id="insertScriptRunLog" keyProperty="id" useGeneratedKeys="true" parameterType="com.xiang.entity.pojo.GladosRunLog">
|
||||||
|
insert into scirpt_glados_run(time, status, response, user, user_id, code) values (#{time}, #{status}, #{response}, #{user}, #{userId}, #{code})
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="listAllUser" resultMap="BaseResultMap">
|
||||||
|
SELECT <include refid="Base_Column_List" />
|
||||||
|
FROM script_glados_user
|
||||||
|
where status = 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
59
script/src/main/resources/mapper/XBFundMapper.xml
Normal file
59
script/src/main/resources/mapper/XBFundMapper.xml
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<?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.repository.XBFundMapper">
|
||||||
|
|
||||||
|
<resultMap id="BaseResultMap" type="com.xiang.entity.pojo.xb.FundInfo" >
|
||||||
|
<result column="id" property="id"/>
|
||||||
|
<result column="code" property="code" />
|
||||||
|
<result column="name" property="name" />
|
||||||
|
<result column="change" property="change" />
|
||||||
|
<result column="update_time" property="updateTime" />
|
||||||
|
</resultMap>
|
||||||
|
<resultMap id="XbFundListMap" type="com.xiang.entity.pojo.xb.XbFundList">
|
||||||
|
<result column="id" property="id"/>
|
||||||
|
<result column="code" property="code" />
|
||||||
|
<result column="name" property="name" />
|
||||||
|
<result column="status" property="status" />
|
||||||
|
<result column="type" property="type" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
id, code,
|
||||||
|
name,
|
||||||
|
`change`,
|
||||||
|
update_time
|
||||||
|
</sql>
|
||||||
|
<insert id="batchSave">
|
||||||
|
insert into xb_fund_info(code, name, `change`, update_time) values
|
||||||
|
<foreach collection="list" item="item" separator=",">
|
||||||
|
(#{item.code}, #{item.name}, #{item.change}, #{item.updateTime})
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
<insert id="addCounts">
|
||||||
|
insert into xb_fund_count(l_id, code, name, `change`, update_time) values
|
||||||
|
<foreach collection="list" item="item" separator=",">
|
||||||
|
(#{item.lId}, #{item.code}, #{item.name}, #{item.change}, #{item.updateTime})
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<select id="queryListIn2Min" resultMap="BaseResultMap">
|
||||||
|
select <include refid="Base_Column_List"/>
|
||||||
|
from xb_fund_info
|
||||||
|
where update_time >= NOW() - INTERVAL 3 MINUTE
|
||||||
|
order by update_time desc
|
||||||
|
</select>
|
||||||
|
<select id="queryFundList" resultMap="XbFundListMap" parameterType="Integer">
|
||||||
|
select * from xb_fund_list
|
||||||
|
where status = 1
|
||||||
|
<if test="type != null">
|
||||||
|
and type = #{type}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
<select id="queryFundInWeek" resultType="com.xiang.entity.pojo.xb.XbFundCount">
|
||||||
|
select * from xb_fund_count
|
||||||
|
where update_time between NOW() - INTERVAL 7 DAY and NOW()
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user