feat:查询江体小程序场地信息
This commit is contained in:
@@ -0,0 +1,19 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.constants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-15 13:46
|
||||||
|
*/
|
||||||
|
public class UrlConstant {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 江南体育中心基础URL
|
||||||
|
*/
|
||||||
|
private final static String GNTYZX_BASE_URL = "https://jntyzx.cn:8443";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询当天的场地信息
|
||||||
|
*/
|
||||||
|
public final static String QUERY_SUBSCRIBE_URL = GNTYZX_BASE_URL + "/GYM-JN/multi/Subscribe/getSubscribeByToday";
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.controller;
|
||||||
|
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.dto.VenueListDTO;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.service.JntyzxService;
|
||||||
|
import com.xiang.xservice.basic.common.resp.Result;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-15 14:28
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class VenueController {
|
||||||
|
|
||||||
|
private final JntyzxService jntyzxService;
|
||||||
|
|
||||||
|
@PostMapping("/queryVenue")
|
||||||
|
public Result<VenueListDTO> queryVenue() {
|
||||||
|
List<VenueListDTO> venueListDTOS = jntyzxService.queryAvailable();
|
||||||
|
return Result.success(venueListDTOS);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.entity.dto;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-15 13:55
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class VenueListDTO {
|
||||||
|
/**
|
||||||
|
* 时间
|
||||||
|
*/
|
||||||
|
private String date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 场地名称
|
||||||
|
*/
|
||||||
|
private String placeName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 联系人
|
||||||
|
*/
|
||||||
|
private String contacts;
|
||||||
|
}
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
package com.xiang.xservice.application.script.jntyzx.service;
|
package com.xiang.xservice.application.script.jntyzx.service;
|
||||||
|
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.dto.VenueListDTO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: xiang
|
* @Author: xiang
|
||||||
* @Date: 2025-05-14 14:06
|
* @Date: 2025-05-14 14:06
|
||||||
@@ -9,5 +13,5 @@ public interface JntyzxService {
|
|||||||
/**
|
/**
|
||||||
* 查询可用场地
|
* 查询可用场地
|
||||||
*/
|
*/
|
||||||
void queryAvailable() throws Exception;
|
List<VenueListDTO> queryAvailable();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,25 @@
|
|||||||
package com.xiang.xservice.application.script.jntyzx.service;
|
package com.xiang.xservice.application.script.jntyzx.service;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.xiang.xmc.service.message.dingTalk.service.DingTalkService;
|
import com.xiang.xmc.service.http.helper.HttpHelper;
|
||||||
import com.xiang.xservice.application.script.jntyzx.entity.resp.JntyzxResponse;
|
import com.xiang.xservice.application.script.jntyzx.constants.UrlConstant;
|
||||||
import com.xiang.xservice.application.script.jntyzx.entity.resp.query.QueryVenueResponse;
|
import com.xiang.xservice.application.script.jntyzx.entity.dto.VenueListDTO;
|
||||||
import com.xiang.xservice.application.script.jntyzx.entity.resp.query.SitePositionList;
|
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.jntyzx.entity.resp.query.VenueList;
|
||||||
import com.xiang.xservice.application.script.xb.common.URLConstants;
|
import com.xiang.xservice.basic.utils.DateUtils;
|
||||||
import com.xiang.xservice.basic.utils.HttpUtils;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: xiang
|
* @Author: xiang
|
||||||
@@ -30,54 +30,63 @@ import java.util.stream.Collectors;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class JntyzxServiceImpl implements JntyzxService{
|
public class JntyzxServiceImpl implements JntyzxService{
|
||||||
|
|
||||||
|
|
||||||
private final DingTalkService dingTalkService;
|
|
||||||
|
|
||||||
@Value("${dingtalk.chatId}")
|
|
||||||
private String chatId;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void queryAvailable() throws Exception {
|
public List<VenueListDTO> queryAvailable() {
|
||||||
String url = URLConstants.JNTYZX_QUERY_TODAY_VENUE;
|
String url = UrlConstant.QUERY_SUBSCRIBE_URL;
|
||||||
Map<String, String> header = Maps.newHashMap();
|
Map<String, String> header = Maps.newHashMap();
|
||||||
header.put("X-Access-Token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3NDcyMTAwNzQsInVzZXJuYW1lIjoid3hfb3Blbl9pZF9vMjFNWDR5N3doWENHanZVVEdQNkNUejJIYkQ4In0.0h_cAH_e5cCXDQlQN40jZDBgtfrzQWAmgl3YPQf0d-M");
|
header.put("X-Access-Token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3NjU3ODQ1NjMsInVzZXJuYW1lIjoid3hfb3Blbl9pZF9vMjFNWDR5N3doWENHanZVVEdQNkNUejJIYkQ4In0.QBzNQNvJZQPZZnzmbU8K5Liz0piHwercrDIq3kirUJk");
|
||||||
String resp = null;
|
String resp = null;
|
||||||
|
Map<String, String> params = Maps.newHashMap();
|
||||||
|
params.put("gid", "03");
|
||||||
|
params.put("isWeekend", "1");
|
||||||
try {
|
try {
|
||||||
resp = HttpUtils.doGet(url, header, null);
|
resp = HttpHelper.doGet(url, header, params);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("[doGet] 江南体育中心查询当天场地 请求失败, url:{}", url);
|
log.error("[doGet] 江南体育中心查询当天场地 请求失败, url:{}", url);
|
||||||
|
return Lists.newArrayList();
|
||||||
}
|
}
|
||||||
if (StringUtils.isEmpty(resp)) {
|
if (StringUtils.isEmpty(resp)) {
|
||||||
log.warn("[查询场地] 江南体育中心查询当天场地 请求结果为空, url:{}, resp:{}", url, resp);
|
log.warn("[查询场地] 江南体育中心查询当天场地 请求结果为空, url:{}, resp:{}", url, resp);
|
||||||
|
return Lists.newArrayList();
|
||||||
}
|
}
|
||||||
JntyzxResponse response = JSONObject.parseObject(resp, JntyzxResponse.class);
|
JSONObject jsonObject = JSON.parseObject(resp);
|
||||||
String message = "";
|
if (Objects.isNull(jsonObject)) {
|
||||||
if (Objects.nonNull(response)) {
|
return Lists.newArrayList();
|
||||||
if (response.getSuccess()) {
|
}
|
||||||
log.info("[查询场地] 江南体育中心查询当天场地 请求地址:{}, 请求结果:{}", url, resp);
|
String resultStr = JSON.toJSONString(jsonObject.get("result"));
|
||||||
JSONObject object = (JSONObject) response.getResult();
|
if (StringUtils.isBlank(resultStr)) {
|
||||||
if (Objects.nonNull(object)) {
|
return Lists.newArrayList();
|
||||||
QueryVenueResponse result = object.toJavaObject(QueryVenueResponse.class);
|
}
|
||||||
if (Objects.nonNull(result)) {
|
JSONObject result = JSON.parseObject(resultStr);
|
||||||
List<VenueList> venueLists = result.getVenue();
|
if (Objects.isNull(result)) {
|
||||||
if (!CollectionUtils.isEmpty(venueLists)) {
|
return Lists.newArrayList();
|
||||||
StringBuilder sb = new StringBuilder();
|
}
|
||||||
for (VenueList venue : venueLists) {
|
String venueStr = JSON.toJSONString(result.get("venue"));
|
||||||
List<SitePositionList> positionList = venue.getSitePosition();
|
if (StringUtils.isBlank(venueStr)) {
|
||||||
positionList = positionList.stream().filter(this::filterTime).collect(Collectors.toList());
|
return Lists.newArrayList();
|
||||||
for (SitePositionList sitePositionList : positionList) {
|
}
|
||||||
sb.append(venue.getPlaceName()).append(":").append(sitePositionList.getSjName()).append(":预定人:").append(sitePositionList.getContacts()).append(",电话:").append(sitePositionList.getContactNumber()).append("\n");
|
List<VenueList> venueLists = JSON.parseArray(venueStr, VenueList.class);
|
||||||
}
|
if (CollectionUtils.isEmpty(venueLists)) {
|
||||||
}
|
return Lists.newArrayList();
|
||||||
message = sb.toString();
|
}
|
||||||
}
|
List<VenueListDTO> res = Lists.newArrayList();
|
||||||
}
|
for (VenueList venueList : venueLists) {
|
||||||
|
List<SitePositionList> sitePositionList = venueList.getSitePosition();
|
||||||
|
if (CollectionUtils.isEmpty(sitePositionList)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (SitePositionList sitePosition : sitePositionList) {
|
||||||
|
if (!filterTime(sitePosition)) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
VenueListDTO venueListDTO = new VenueListDTO();
|
||||||
|
venueListDTO.setDate(DateUtils.getDateFromDate(LocalDate.now()) + " " + sitePosition.getSjName());
|
||||||
|
venueListDTO.setPlaceName(sitePosition.getPlaceName());
|
||||||
|
venueListDTO.setContacts(sitePosition.getContacts());
|
||||||
|
res.add(venueListDTO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotBlank(message)) {
|
return res;
|
||||||
dingTalkService.sendChatMessage(chatId, message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user