Compare commits
2 Commits
f67dd4d40a
...
52c5533043
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
52c5533043 | ||
|
|
3692245745 |
0
.idea/.gitignore
vendored
Normal file
0
.idea/.gitignore
vendored
Normal file
2
.idea/cloud-battery-manage.iml
Normal file
2
.idea/cloud-battery-manage.iml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4" />
|
||||||
36
.idea/compiler.xml
Normal file
36
.idea/compiler.xml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<annotationProcessing>
|
||||||
|
<profile name="Maven default annotation processors profile" enabled="true">
|
||||||
|
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||||
|
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||||
|
<outputRelativeToContentRoot value="true" />
|
||||||
|
<module name="common-mybatis" />
|
||||||
|
<module name="authorization-server" />
|
||||||
|
<module name="resource-server" />
|
||||||
|
<module name="gateway-server" />
|
||||||
|
<module name="admin-server" />
|
||||||
|
<module name="common-web" />
|
||||||
|
<module name="wechat-server" />
|
||||||
|
<module name="cloud-manage-server" />
|
||||||
|
<module name="common-redis" />
|
||||||
|
<module name="common-core" />
|
||||||
|
</profile>
|
||||||
|
</annotationProcessing>
|
||||||
|
</component>
|
||||||
|
<component name="JavacSettings">
|
||||||
|
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
|
||||||
|
<module name="admin-server" options="-parameters" />
|
||||||
|
<module name="authorization-server" options="-parameters" />
|
||||||
|
<module name="cloud-manage-server" options="-parameters" />
|
||||||
|
<module name="common-core" options="-parameters" />
|
||||||
|
<module name="common-mybatis" options="-parameters" />
|
||||||
|
<module name="common-redis" options="-parameters" />
|
||||||
|
<module name="common-web" options="-parameters" />
|
||||||
|
<module name="gateway-server" options="-parameters" />
|
||||||
|
<module name="resource-server" options="-parameters" />
|
||||||
|
<module name="wechat-server" options="-parameters" />
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
19
.idea/encodings.xml
Normal file
19
.idea/encodings.xml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding">
|
||||||
|
<file url="file://$PROJECT_DIR$/admin-server/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/authorization-server/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/base-commons/common-core/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/base-commons/common-mybatis/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/base-commons/common-redis/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/base-commons/common-web/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/base-commons/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/base-commons/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/cloud-manage-server/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/gateway-server/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/resource-server/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/wechat-server/src/main/java" charset="UTF-8" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
35
.idea/jarRepositories.xml
Normal file
35
.idea/jarRepositories.xml
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RemoteRepositoriesConfiguration">
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="central" />
|
||||||
|
<option name="url" value="https://maven.aliyun.com/nexus/content/groups/public" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Maven Central repository" />
|
||||||
|
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="jboss.community" />
|
||||||
|
<option name="name" value="JBoss Community repository" />
|
||||||
|
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="rdc-releases" />
|
||||||
|
<option name="name" value="rdc-releases" />
|
||||||
|
<option name="url" value="https://packages.aliyun.com/maven/repository/2038145-release-RKrdrG/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="rdc-snapshots" />
|
||||||
|
<option name="name" value="rdc-snapshots" />
|
||||||
|
<option name="url" value="https://packages.aliyun.com/maven/repository/2038145-snapshot-hRO31q/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="snapshots" />
|
||||||
|
<option name="name" value="snapshots" />
|
||||||
|
<option name="url" value="https://maven.aliyun.com/nexus/content/groups/public" />
|
||||||
|
</remote-repository>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
12
.idea/misc.xml
Normal file
12
.idea/misc.xml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
|
<component name="MavenProjectsManager">
|
||||||
|
<option name="originalFiles">
|
||||||
|
<list>
|
||||||
|
<option value="$PROJECT_DIR$/pom.xml" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_14" project-jdk-name="17 (2)" project-jdk-type="JavaSDK" />
|
||||||
|
</project>
|
||||||
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@ -30,7 +30,8 @@ public enum RequestFunctionTypesEnum {
|
|||||||
FUN_PREORDER("preOrder", "preOrderResponse", "站端预约订单"),
|
FUN_PREORDER("preOrder", "preOrderResponse", "站端预约订单"),
|
||||||
FUN_ORDERBYPLATENUM("orderByPlateNum", "orderByPlateNumResponse", "站端用车牌号查询订单"),
|
FUN_ORDERBYPLATENUM("orderByPlateNum", "orderByPlateNumResponse", "站端用车牌号查询订单"),
|
||||||
FUN_CANCELORDER("cancelOrder", "cancelOrderResponse", "站端取消订单"),
|
FUN_CANCELORDER("cancelOrder", "cancelOrderResponse", "站端取消订单"),
|
||||||
FUN_STARTSWAP("BatterySwapReq", "BatterySwapResponse", "站端回复开始换电");
|
FUN_STARTSWAP("BatterySwapReq", "BatterySwapResponse", "站端回复开始换电"),
|
||||||
|
FUN_STRATEGY_INFO("strategyInfo", "strategyInfoResponse", "站端查询充电策略");
|
||||||
|
|
||||||
String function;
|
String function;
|
||||||
String reFunction;
|
String reFunction;
|
||||||
|
|||||||
@ -0,0 +1,53 @@
|
|||||||
|
package com.evotech.hd.cloud.mqtt.message.dto.newer.req;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @desc:
|
||||||
|
* @ClassName:MqttResponse
|
||||||
|
* @date: 2025年04月08日 12:44
|
||||||
|
* @author: andy.shi
|
||||||
|
* @contact: 17330188597
|
||||||
|
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class MqttResponse<T> implements Serializable {
|
||||||
|
|
||||||
|
private Integer code;
|
||||||
|
|
||||||
|
private String msg;
|
||||||
|
|
||||||
|
private T data;
|
||||||
|
|
||||||
|
|
||||||
|
static final Integer SUCCESS = 1;
|
||||||
|
|
||||||
|
static final Integer ERROR = 0;
|
||||||
|
|
||||||
|
static final Integer PARAMS_ERROR = 2;
|
||||||
|
|
||||||
|
public MqttResponse() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public MqttResponse<T> success(T data){
|
||||||
|
this.code=SUCCESS;
|
||||||
|
this.msg="成功";
|
||||||
|
this.data=data;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MqttResponse<T> error(String errorMessage){
|
||||||
|
this.code=ERROR;
|
||||||
|
this.msg=errorMessage;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MqttResponse<T> paramsError(String errorMessage){
|
||||||
|
this.code=PARAMS_ERROR;
|
||||||
|
this.msg=errorMessage;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,12 +1,10 @@
|
|||||||
package com.evotech.hd.cloud.mqtt.message.handle;
|
package com.evotech.hd.cloud.mqtt.message.handle;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.evotech.hd.cloud.mqtt.message.processor.MqttMessageRequestExchangeProcessor;
|
||||||
import com.evotech.hd.common.core.entity.cloud.request.BatterySwapResponse;
|
import com.evotech.hd.common.core.entity.cloud.request.BatterySwapResponse;
|
||||||
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.battery.*;
|
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.battery.*;
|
||||||
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.order.*;
|
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.order.*;
|
||||||
@ -16,8 +14,11 @@ import com.evotech.hd.common.core.entity.wechat.WechatUser;
|
|||||||
import com.evotech.hd.common.redis.utils.RedisUtil;
|
import com.evotech.hd.common.redis.utils.RedisUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
@ -69,6 +70,9 @@ public class RequestMessageService {
|
|||||||
private OrderSwapBatteryService orderSwapBatteryService;
|
private OrderSwapBatteryService orderSwapBatteryService;
|
||||||
@Resource
|
@Resource
|
||||||
private RedisUtil redisUtil;
|
private RedisUtil redisUtil;
|
||||||
|
@Autowired
|
||||||
|
private ApplicationContext applicationContext;
|
||||||
|
|
||||||
@Async("taskExecutor")
|
@Async("taskExecutor")
|
||||||
public void request(MessageTopic topic, MqttMessageHeader header, JSONObject dataBody) {
|
public void request(MessageTopic topic, MqttMessageHeader header, JSONObject dataBody) {
|
||||||
switch (Objects.requireNonNull(RequestFunctionTypesEnum.getFunctionType(header.getFunction()))) {
|
switch (Objects.requireNonNull(RequestFunctionTypesEnum.getFunctionType(header.getFunction()))) {
|
||||||
@ -96,8 +100,16 @@ public class RequestMessageService {
|
|||||||
BatterySwapResponse battery = JSONUtil.toBean(dataBody, BatterySwapResponse.class);
|
BatterySwapResponse battery = JSONUtil.toBean(dataBody, BatterySwapResponse.class);
|
||||||
handlStartSwap(topic,header,battery);
|
handlStartSwap(topic,header,battery);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Map<String, MqttMessageRequestExchangeProcessor> mqttMessageRequestExchangeProcessorMap = applicationContext.getBeansOfType(MqttMessageRequestExchangeProcessor.class);
|
||||||
|
if(CollectionUtils.isEmpty(mqttMessageRequestExchangeProcessorMap)){
|
||||||
|
log.error("mqttRequestExchangeProcessorMap is empty, 没有找到当前的请求信息, 请求接口{}, 请求参数{}", JSONUtil.toJsonStr(header), JSONUtil.toJsonStr(dataBody));
|
||||||
|
}
|
||||||
|
for (MqttMessageRequestExchangeProcessor processor : mqttMessageRequestExchangeProcessorMap.values()) {
|
||||||
|
if(processor.accept(header.getFunction())){
|
||||||
|
processor.exchange(topic, header, dataBody);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,49 @@
|
|||||||
|
package com.evotech.hd.cloud.mqtt.message.processor;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DatePattern;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.json.JSONConfig;
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.evotech.hd.cloud.mqtt.enums.MqttMessageTypeEnum;
|
||||||
|
import com.evotech.hd.cloud.mqtt.enums.RequestFunctionTypesEnum;
|
||||||
|
import com.evotech.hd.cloud.mqtt.message.MessageTopic;
|
||||||
|
import com.evotech.hd.cloud.mqtt.message.MqttMessageHeader;
|
||||||
|
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.MqttResponse;
|
||||||
|
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.order.CancelOrderReq;
|
||||||
|
import com.evotech.hd.cloud.mqtt.message.handle.MessageUtilService;
|
||||||
|
import com.evotech.hd.cloud.utils.SpringUtil;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @desc: 处理mqtt请求接口
|
||||||
|
* @ClassName:MqttMessageRequestExchangeProcessor
|
||||||
|
* @date: 2025年04月08日 11:28
|
||||||
|
* @author: andy.shi
|
||||||
|
* @contact: 17330188597
|
||||||
|
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface MqttMessageRequestExchangeProcessor {
|
||||||
|
|
||||||
|
Logger logger = LoggerFactory.getLogger(MqttMessageRequestExchangeProcessor.class);
|
||||||
|
|
||||||
|
boolean accept(String functionName);
|
||||||
|
|
||||||
|
void exchange(MessageTopic topic, MqttMessageHeader header, JSONObject dataBody);
|
||||||
|
|
||||||
|
default void sendAESMessage(MessageTopic topic, MqttMessageHeader header, RequestFunctionTypesEnum typesEnum, MqttResponse response){
|
||||||
|
MessageUtilService messageUtilService = SpringUtil.getBean(MessageUtilService.class);
|
||||||
|
// 发送
|
||||||
|
topic.setDataDirection("M2S");
|
||||||
|
topic.setMessageType(MqttMessageTypeEnum.RESPONSE.getType());
|
||||||
|
header.setFunction(typesEnum.getReFunction());
|
||||||
|
header.setTimeStamp(DateUtil.format(new Date(), DatePattern.NORM_DATETIME_FORMATTER));
|
||||||
|
logger.info("\r\n=====>>>站端取消订单--MQTT发送到消息主题:{},头部信息:{},message:{}", topic,header, JSONUtil.parseObj(response, new JSONConfig().setDateFormat(DatePattern.NORM_DATETIME_PATTERN)));
|
||||||
|
messageUtilService.publishAESMessage(topic, header, JSONUtil.parseObj(response, new JSONConfig().setDateFormat(DatePattern.NORM_DATETIME_PATTERN)));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,53 @@
|
|||||||
|
package com.evotech.hd.cloud.mqtt.message.processor.impl;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.evotech.hd.cloud.mqtt.enums.RequestFunctionTypesEnum;
|
||||||
|
import com.evotech.hd.cloud.mqtt.message.MessageTopic;
|
||||||
|
import com.evotech.hd.cloud.mqtt.message.MqttMessageHeader;
|
||||||
|
import com.evotech.hd.cloud.mqtt.message.dto.newer.req.MqttResponse;
|
||||||
|
import com.evotech.hd.cloud.mqtt.message.processor.MqttMessageRequestExchangeProcessor;
|
||||||
|
import com.evotech.hd.cloud.service.BatteryStationCdStrategyService;
|
||||||
|
import com.evotech.hd.common.core.entity.cloud.BatteryStationCdStrategy;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mqtt查询充电策略
|
||||||
|
* @ClassName:StrategyMqttMessageRequestExchangeProcessorImpl
|
||||||
|
* @date: 2025年04月08日 11:36
|
||||||
|
* @author: andy.shi
|
||||||
|
* @contact: 17330188597
|
||||||
|
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class StrategyMqttMessageRequestExchangeProcessorImpl implements MqttMessageRequestExchangeProcessor {
|
||||||
|
@Resource
|
||||||
|
BatteryStationCdStrategyService batteryStationCdStrategyService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean accept(String functionName) {
|
||||||
|
return RequestFunctionTypesEnum.FUN_STRATEGY_INFO.getReFunction().equals(functionName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void exchange(MessageTopic topic, MqttMessageHeader header, JSONObject dataBody) {
|
||||||
|
log.info("StrategyMqttMessageRequestExchangeProcessorImpl-->>>>> 请求参数{}", JSONUtil.toJsonStr(dataBody));
|
||||||
|
MqttResponse response = null;
|
||||||
|
String stationCode = dataBody.getStr("stationCode");
|
||||||
|
if(StringUtils.isEmpty(stationCode)){
|
||||||
|
log.error("StrategyMqttMessageRequestExchangeProcessorImpl-->>>>> stationCode is null");
|
||||||
|
response = new MqttResponse<>().paramsError("stationCode is null");
|
||||||
|
}else{
|
||||||
|
List<BatteryStationCdStrategy> list = batteryStationCdStrategyService.chargeStationFindList(stationCode);
|
||||||
|
log.info("StrategyMqttMessageRequestExchangeProcessorImpl-->>>>> 查询到的策略信息{}", JSONUtil.toJsonStr(list));
|
||||||
|
response = new MqttResponse<List<BatteryStationCdStrategy>>().success(list);
|
||||||
|
}
|
||||||
|
sendAESMessage(topic, header, RequestFunctionTypesEnum.FUN_STRATEGY_INFO, response);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -24,4 +24,6 @@ public interface BatteryStationCdStrategyService {
|
|||||||
|
|
||||||
public Result<List<BatteryStationCdStrategyDetail>> listDetail(Integer strategyId);
|
public Result<List<BatteryStationCdStrategyDetail>> listDetail(Integer strategyId);
|
||||||
|
|
||||||
|
public List<BatteryStationCdStrategy> chargeStationFindList(String stationCode);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
package com.evotech.hd.cloud.service.impl;
|
package com.evotech.hd.cloud.service.impl;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@ -106,4 +108,17 @@ public class BatteryStationCdStrategyServiceImpl implements BatteryStationCdStra
|
|||||||
return new Result<List<BatteryStationCdStrategyDetail>>().success(list);
|
return new Result<List<BatteryStationCdStrategyDetail>>().success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BatteryStationCdStrategy> chargeStationFindList(String stationCode) {
|
||||||
|
List<BatteryStationCdStrategy> list = strategyDao.listCdStrategy(stationCode, 1);
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
list.stream().forEach(data ->{
|
||||||
|
data.setDetailList(strategyDetailDao.selectList(new LambdaQueryWrapper<BatteryStationCdStrategyDetail>()
|
||||||
|
.eq(BatteryStationCdStrategyDetail::getStrategyId, data.getPkId())));
|
||||||
|
});
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,51 @@
|
|||||||
|
package com.evotech.hd.cloud.utils;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.BeansException;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.ApplicationContextAware;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @desc:
|
||||||
|
* @ClassName:SpringUtil
|
||||||
|
* @date: 2025年04月08日 12:33
|
||||||
|
* @author: andy.shi
|
||||||
|
* @contact: 17330188597
|
||||||
|
* @remark: 开发人员联系方式 1042025947@qq.com/微信同步
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class SpringUtil implements ApplicationContextAware {
|
||||||
|
|
||||||
|
private static ApplicationContext applicationContext = null;
|
||||||
|
@Override
|
||||||
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||||
|
setGlobalApplicationContext(applicationContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
private synchronized static void setGlobalApplicationContext(ApplicationContext applicationContext) {
|
||||||
|
if(SpringUtil.applicationContext == null){
|
||||||
|
SpringUtil.applicationContext = applicationContext;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ApplicationContext getApplicationContext() {
|
||||||
|
return applicationContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Object getBean(String name) {
|
||||||
|
return getApplicationContext().getBean(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> T getBean(Class<T> clazz) {
|
||||||
|
T b = null;
|
||||||
|
try {
|
||||||
|
b=getApplicationContext().getBean(clazz);
|
||||||
|
} catch (BeansException e) {
|
||||||
|
log.info(e.getMessage());
|
||||||
|
}
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -6,6 +6,11 @@ import java.util.Date;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import com.evotech.hd.cloud.mqtt.enums.RequestFunctionTypesEnum;
|
||||||
|
import com.evotech.hd.cloud.mqtt.message.MessageTopic;
|
||||||
|
import com.evotech.hd.cloud.mqtt.message.handle.RequestMessageService;
|
||||||
|
import com.evotech.hd.cloud.service.BatteryStationCdStrategyService;
|
||||||
import org.eclipse.paho.client.mqttv3.MqttClient;
|
import org.eclipse.paho.client.mqttv3.MqttClient;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
@ -70,7 +75,7 @@ import cn.hutool.json.JSONObject;
|
|||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
|
||||||
@SpringBootTest
|
@SpringBootTest(classes = CloudManageServerApplication.class)
|
||||||
public class AddTestData {
|
public class AddTestData {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
@ -123,6 +128,16 @@ public class AddTestData {
|
|||||||
private MqttClient testClient;
|
private MqttClient testClient;
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BatteryStationCdStrategyService batteryStationCdStrategyService;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void strategyFind(){
|
||||||
|
System.out.println(batteryStationCdStrategyService.chargeStationFindList("123456"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// @Test
|
// @Test
|
||||||
void addDC() {
|
void addDC() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user