Compare commits
26 Commits
fd30c72a73
...
fix/glados
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
217dc6879d | ||
|
|
12728d5c84 | ||
|
|
8928c076c5 | ||
|
|
ec6723070f | ||
|
|
5b9ac21ecf | ||
|
|
f3637a80f2 | ||
|
|
4bc549eebe | ||
|
|
237fcc7139 | ||
|
|
4277106d00 | ||
|
|
7932222f8e | ||
|
|
6d19b1a021 | ||
|
|
57a28b4049 | ||
|
|
a3c9e2eb51 | ||
|
|
93969624c1 | ||
|
|
4904be16da | ||
|
|
c4915b17c8 | ||
|
|
7fce8c91f2 | ||
|
|
d942b31c8b | ||
|
|
d7b49281c1 | ||
|
|
c6817b23fc | ||
|
|
69257b5c80 | ||
|
|
1cd24c78e7 | ||
|
|
12c4ccdd5d | ||
|
|
d5c096e7a5 | ||
|
|
b7ecbdfa7a | ||
|
|
454d93b5cc |
4
pom.xml
4
pom.xml
@@ -48,9 +48,9 @@
|
|||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.xiang</groupId>
|
<groupId>com.xiang.starter</groupId>
|
||||||
<artifactId>xmc-http-starter</artifactId>
|
<artifactId>xmc-http-starter</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>2.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.xiang</groupId>
|
<groupId>com.xiang</groupId>
|
||||||
|
|||||||
@@ -8,5 +8,5 @@ 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_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\"}";
|
public static final String GLADOS_CHECK_IN_BODY = "{\"token\":\"glados.cloud\"}";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ public class URLConstants {
|
|||||||
/**
|
/**
|
||||||
* glados 主域名
|
* glados 主域名
|
||||||
*/
|
*/
|
||||||
public static final String GLADOS_URL_PREFIX = "https://www.glados.one";
|
public static final String GLADOS_URL_PREFIX = "https://glados.cloud";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 签到
|
* 签到
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
package com.xiang.xservice.application.script.glados.controller;
|
package com.xiang.xservice.application.script.glados.controller;
|
||||||
|
|
||||||
import com.xiang.xservice.basic.common.resp.Result;
|
|
||||||
import com.xiang.xservice.application.script.glados.entity.req.GladosCheckInReq;
|
|
||||||
import com.xiang.xservice.application.script.glados.service.GLaDOSService;
|
import com.xiang.xservice.application.script.glados.service.GLaDOSService;
|
||||||
|
import com.xiang.xservice.basic.common.resp.Result;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@@ -21,9 +19,10 @@ public class GLaDOSController {
|
|||||||
|
|
||||||
private final GLaDOSService glaDOSService;
|
private final GLaDOSService glaDOSService;
|
||||||
|
|
||||||
@PostMapping("/checkIn")
|
@GetMapping("/checkIn")
|
||||||
public Result<String> checkIn(@RequestBody GladosCheckInReq request) {
|
public Result<Void> checkIn() {
|
||||||
return Result.success(glaDOSService.checkIn());
|
glaDOSService.checkInV2();
|
||||||
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.xiang.xservice.application.script.glados.entity.resp;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2026-01-23 09:21
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class CheckInResp {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private Long userId;
|
||||||
|
private Long time;
|
||||||
|
private String asset;
|
||||||
|
private String business;
|
||||||
|
private String change;
|
||||||
|
private String balance;
|
||||||
|
private String detail;
|
||||||
|
}
|
||||||
@@ -22,6 +22,6 @@ public class GladosCheckInJob {
|
|||||||
@Scheduled(cron = "0 0 7 1/1 * ?")
|
@Scheduled(cron = "0 0 7 1/1 * ?")
|
||||||
public void checkInJon() {
|
public void checkInJon() {
|
||||||
log.info("[job] Glados Check In Job start, time:{}", LocalDateTime.now());
|
log.info("[job] Glados Check In Job start, time:{}", LocalDateTime.now());
|
||||||
glaDOSService.checkIn();
|
glaDOSService.checkInV2();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,4 +10,9 @@ public interface GLaDOSService {
|
|||||||
* 签到
|
* 签到
|
||||||
*/
|
*/
|
||||||
String checkIn();
|
String checkIn();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 签到
|
||||||
|
*/
|
||||||
|
void checkInV2();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
package com.xiang.xservice.application.script.glados.service;
|
package com.xiang.xservice.application.script.glados.service;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.alibaba.fastjson2.TypeReference;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
import com.xiang.xmc.service.http.helper.BaseHttpHelp;
|
||||||
|
import com.xiang.xmc.service.http.helper.HttpHelperFactory;
|
||||||
import com.xiang.xservice.application.script.glados.common.GladosConstants;
|
import com.xiang.xservice.application.script.glados.common.GladosConstants;
|
||||||
import com.xiang.xservice.application.script.glados.common.URLConstants;
|
import com.xiang.xservice.application.script.glados.common.URLConstants;
|
||||||
import com.xiang.xservice.application.script.glados.entity.GladosRunLog;
|
import com.xiang.xservice.application.script.glados.entity.GladosRunLog;
|
||||||
|
import com.xiang.xservice.application.script.glados.entity.resp.CheckInResp;
|
||||||
import com.xiang.xservice.application.script.glados.entity.resp.GLaDOSResponse;
|
import com.xiang.xservice.application.script.glados.entity.resp.GLaDOSResponse;
|
||||||
import com.xiang.xservice.application.script.glados.repository.GladosMapper;
|
import com.xiang.xservice.application.script.glados.repository.GladosMapper;
|
||||||
import com.xiang.xservice.application.script.xb.entity.pojo.User;
|
import com.xiang.xservice.application.script.xb.entity.pojo.User;
|
||||||
@@ -33,6 +37,8 @@ public class GLaDOSServiceImpl implements GLaDOSService{
|
|||||||
|
|
||||||
private final DingTalkScriptGladosService dingTalkService;
|
private final DingTalkScriptGladosService dingTalkService;
|
||||||
|
|
||||||
|
private final BaseHttpHelp httpHelp = HttpHelperFactory.createSimpleHttp();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 签到
|
* 签到
|
||||||
*/
|
*/
|
||||||
@@ -63,6 +69,91 @@ public class GLaDOSServiceImpl implements GLaDOSService{
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void checkInV2() {
|
||||||
|
List<User> users = gladosMapper.listAllUser();
|
||||||
|
if (CollectionUtils.isEmpty(users)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (User user : users) {
|
||||||
|
try {
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
if (checkInV2(user)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Thread.sleep(10000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
log.error("线程暂停10s失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("签到失败,", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean checkInV2(User user) {
|
||||||
|
Map<String, String> header = Maps.newHashMap();
|
||||||
|
header.put("Cookie", user.getCookie());
|
||||||
|
|
||||||
|
String response = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
response = httpHelp.doPost(URLConstants.GLADOS_CHECK_IN_URL, header, GladosConstants.GLADOS_CHECK_IN_BODY);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("http请求异常:{}", user.getEmail());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (org.apache.commons.lang3.StringUtils.isBlank(response)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
GLaDOSResponse<CheckInResp> gLaDOSResponse = JSONObject.parseObject(response, new TypeReference<GLaDOSResponse<CheckInResp>>() {
|
||||||
|
});
|
||||||
|
if (Objects.isNull(gLaDOSResponse)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0 == gLaDOSResponse.getCode()) {
|
||||||
|
// 成功请求
|
||||||
|
if (Objects.nonNull(gLaDOSResponse.getPoints()) && 0 != gLaDOSResponse.getPoints()) {
|
||||||
|
// 签到成功
|
||||||
|
dingTalkService.sendScriptMsg("[时间:" + LocalDateTime.now() + "] 用户: " +
|
||||||
|
user.getEmail() + "签到成功,获得积分:" + gLaDOSResponse.getPoints());
|
||||||
|
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 Boolean.TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gLaDOSResponse.getMessage().contains("Repeats")) {
|
||||||
|
if (!CollectionUtils.isEmpty(gLaDOSResponse.getList())) {
|
||||||
|
dingTalkService.sendScriptMsg("用户:" + user.getEmail() + "当前已签到。结果:" + gLaDOSResponse.getList().get(0));
|
||||||
|
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 true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-2 == gLaDOSResponse.getCode()) {
|
||||||
|
log.warn("签到失败,用户:{}, cookie过期:{}", user.getEmail(), gLaDOSResponse.getMessage());
|
||||||
|
String message = "[时间:" + LocalDateTime.now() + "] 用户: " + user.getEmail() + ",签到消息: " + gLaDOSResponse.getMessage() + "手动请求:http://general.xiangtech.xyz:30026/system/glados/checkIn";
|
||||||
|
try {
|
||||||
|
dingTalkService.sendScriptMsg(message);
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("发送钉钉消息失败", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 请求异常
|
||||||
|
dingTalkService.sendScriptMsg("用户:" + user.getEmail() + "请求异常,响应结果:" + gLaDOSResponse.getMessage());
|
||||||
|
GladosRunLog build = GladosRunLog.builder().time(LocalDateTime.now()).status(0).code(Integer.valueOf(gLaDOSResponse.getCode().toString())).response(response).user(user.getEmail()).userId(user.getId()).build();
|
||||||
|
gladosMapper.insertScriptRunLog(build);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean checkIn(User user, StringBuffer sb) {
|
private boolean checkIn(User user, StringBuffer sb) {
|
||||||
|
|
||||||
Map<String, String> header = Maps.newHashMap();
|
Map<String, String> header = Maps.newHashMap();
|
||||||
@@ -83,18 +174,26 @@ public class GLaDOSServiceImpl implements GLaDOSService{
|
|||||||
log.info("http do post success, response:{}", response);
|
log.info("http do post success, response:{}", response);
|
||||||
|
|
||||||
// 成功签到记录
|
// 成功签到记录
|
||||||
if (0 == gLaDOSResponse.getCode() && Objects.nonNull(gLaDOSResponse.getPoints())) {
|
if (0 == gLaDOSResponse.getCode()) {
|
||||||
log.info("签到成功, 签到积分:{}, 签到消息:{}", gLaDOSResponse.getPoints(), gLaDOSResponse.getMessage());
|
if (Objects.nonNull(gLaDOSResponse.getPoints())) {
|
||||||
sb.append(user.getEmail()).append("签到成功,获得积分:").append(gLaDOSResponse.getPoints()).append("\n");
|
log.info("签到成功, 签到积分:{}, 签到消息:{}", gLaDOSResponse.getPoints(), gLaDOSResponse.getMessage());
|
||||||
try {
|
sb.append(user.getEmail()).append("签到成功,获得积分:").append(gLaDOSResponse.getPoints()).append("\n");
|
||||||
dingTalkService.sendScriptMsg("[时间:" + LocalDateTime.now() + "] 用户: " +
|
try {
|
||||||
user.getEmail() + "签到成功,获得积分:" + gLaDOSResponse.getPoints());
|
dingTalkService.sendScriptMsg("[时间:" + LocalDateTime.now() + "] 用户: " +
|
||||||
} catch (Exception e) {
|
user.getEmail() + "签到成功,获得积分:" + gLaDOSResponse.getPoints());
|
||||||
log.error("发送钉钉消息失败", e);
|
} catch (Exception e) {
|
||||||
|
log.error("发送钉钉消息失败", e);
|
||||||
|
}
|
||||||
|
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 Boolean.TRUE;
|
||||||
|
} else {
|
||||||
|
log.info("签到异常, 签到消息:{}", gLaDOSResponse.getMessage());
|
||||||
|
sb.append(user.getEmail()).append("签到异常,消息:").append(gLaDOSResponse.getMessage());
|
||||||
|
GladosRunLog build = GladosRunLog.builder().time(LocalDateTime.now()).status(0).code(Integer.valueOf(gLaDOSResponse.getCode().toString())).response(response).user(user.getEmail()).userId(user.getId()).build();
|
||||||
|
gladosMapper.insertScriptRunLog(build);
|
||||||
|
return Boolean.FALSE;
|
||||||
}
|
}
|
||||||
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 Boolean.TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重复签到,表示当日签到成功
|
// 重复签到,表示当日签到成功
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
package com.xiang.xservice.application.script.jntyzx.entity.resp;
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package com.xiang.xservice.application.script.jntyzx.entity.resp.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;
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
package com.xiang.xservice.application.script.jntyzx.entity.resp.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;
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package com.xiang.xservice.application.script.jntyzx.entity.resp.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;
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
package com.xiang.xservice.application.script.jntyzx.entity.resp.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;
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package com.xiang.xservice.application.script.jntyzx.service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author: xiang
|
|
||||||
* @Date: 2025-05-14 14:06
|
|
||||||
*/
|
|
||||||
public interface JntyzxService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询可用场地
|
|
||||||
*/
|
|
||||||
void queryAvailable() throws Exception;
|
|
||||||
}
|
|
||||||
@@ -1,99 +0,0 @@
|
|||||||
package com.xiang.xservice.application.script.jntyzx.service;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import com.xiang.xmc.service.message.dingTalk.service.DingTalkService;
|
|
||||||
import com.xiang.xservice.application.script.jntyzx.entity.resp.JntyzxResponse;
|
|
||||||
import com.xiang.xservice.application.script.jntyzx.entity.resp.query.QueryVenueResponse;
|
|
||||||
import com.xiang.xservice.application.script.jntyzx.entity.resp.query.SitePositionList;
|
|
||||||
import com.xiang.xservice.application.script.jntyzx.entity.resp.query.VenueList;
|
|
||||||
import com.xiang.xservice.application.script.xb.common.URLConstants;
|
|
||||||
import com.xiang.xservice.basic.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 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.xiang.xservice.common.service;
|
||||||
|
|
||||||
|
import com.xiang.xservice.common.entity.SysConfigDO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-16 11:19
|
||||||
|
*/
|
||||||
|
public interface ISysConfigService {
|
||||||
|
|
||||||
|
SysConfigDO getByName(String name);
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.xiang.xservice.common.service;
|
||||||
|
|
||||||
|
import com.xiang.xservice.common.entity.SysConfigDO;
|
||||||
|
import com.xiang.xservice.common.mapper.SysConfigMapper;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-16 11:20
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class SysConfigServiceImpl implements ISysConfigService {
|
||||||
|
private final SysConfigMapper sysConfigMapper;
|
||||||
|
@Override
|
||||||
|
public SysConfigDO getByName(String name) {
|
||||||
|
return sysConfigMapper.getByName(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.xiang.xservice.config;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-15 15:20
|
||||||
|
*/
|
||||||
|
@ConfigurationProperties(prefix = "dingtalk.robot.venue")
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class DingTalkRobotVenueConfig {
|
||||||
|
private String token;
|
||||||
|
private String secret;
|
||||||
|
private List<String> users;
|
||||||
|
}
|
||||||
@@ -49,5 +49,10 @@ dingtalk:
|
|||||||
xb:
|
xb:
|
||||||
token: ad21ead99f0fdc63aa00d6732b7b0888c17590f7612c68297edfcb71844d1437
|
token: ad21ead99f0fdc63aa00d6732b7b0888c17590f7612c68297edfcb71844d1437
|
||||||
secret: SECc09d8aad6635f1a4cbadb7c0ab365523c46299f138438cd885e445e0f5f4d730
|
secret: SECc09d8aad6635f1a4cbadb7c0ab365523c46299f138438cd885e445e0f5f4d730
|
||||||
|
users:
|
||||||
|
- 450841600726084717
|
||||||
|
venue:
|
||||||
|
token: 6a218646972c684c75832b0229ea93a234778af537d7469ce96bef290faf530e
|
||||||
|
secret: SEC9018755ba86d3e5c1ed2fbfa1d6953d84bb2a6c8ebe7ed4e318457bfed5e0465
|
||||||
users:
|
users:
|
||||||
- 450841600726084717
|
- 450841600726084717
|
||||||
@@ -51,5 +51,10 @@ dingtalk:
|
|||||||
xb:
|
xb:
|
||||||
token: 340a9d39a5b0b6a52ba2262f9c27179cf50e3c8cfe6883ca082649d306038f41
|
token: 340a9d39a5b0b6a52ba2262f9c27179cf50e3c8cfe6883ca082649d306038f41
|
||||||
secret: SECe10ade3058880b84df5c6f46ab072c11f4ac2a5ef9f134d684705c2a3b004de2
|
secret: SECe10ade3058880b84df5c6f46ab072c11f4ac2a5ef9f134d684705c2a3b004de2
|
||||||
|
users:
|
||||||
|
- 450841600726084717
|
||||||
|
venue:
|
||||||
|
token: 6a218646972c684c75832b0229ea93a234778af537d7469ce96bef290faf530e
|
||||||
|
secret: SEC9018755ba86d3e5c1ed2fbfa1d6953d84bb2a6c8ebe7ed4e318457bfed5e0465
|
||||||
users:
|
users:
|
||||||
- 450841600726084717
|
- 450841600726084717
|
||||||
Reference in New Issue
Block a user