dev.protocol.parsing
parent
f5b153f32c
commit
04285aea80
|
@ -4,7 +4,7 @@ server:
|
|||
|
||||
# nacos线上地址
|
||||
nacos:
|
||||
addr: 127.0.0.1:8848
|
||||
addr: 47.116.173.119:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: one-saas
|
||||
|
|
|
@ -4,7 +4,7 @@ server:
|
|||
|
||||
# nacos线上地址
|
||||
nacos:
|
||||
addr: 127.0.0.1:8848
|
||||
addr: 47.116.173.119:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: one-saas
|
||||
|
|
|
@ -18,6 +18,11 @@
|
|||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- MQTT-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.integration</groupId>
|
||||
<artifactId>spring-integration-mqtt</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
package com.muyu.car.constant;
|
||||
|
||||
public class RedisConstant {
|
||||
|
||||
public static final String MESSAGE_DETAIL = "messageDetail";
|
||||
|
||||
public static final String VEHICLE_ENTERPRISE = "vehicleEnterprise";
|
||||
|
||||
public static final String INDEX_WARNING = "indexWarning";
|
||||
}
|
|
@ -11,6 +11,7 @@ import com.muyu.car.domain.SysMessageType;
|
|||
import com.muyu.car.domain.VO.SysMessageVO;
|
||||
import com.muyu.car.service.ISysCarMessageService;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
|
@ -39,57 +40,86 @@ import com.muyu.common.core.web.page.TableDataInfo;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/messageInfo")
|
||||
public class SysCarMessageController extends BaseController
|
||||
{
|
||||
public class SysCarMessageController extends BaseController {
|
||||
@Resource
|
||||
private ISysCarMessageService sysCarMessageService;
|
||||
@Autowired
|
||||
private HttpSession session;
|
||||
|
||||
static String TEST = "7E 56 45 48 49 43 4C 45 5F 4D 53 47 3A 56 49 4E 31 32 B6 A1 C0 F2 B3 E5 D9 A8 C1 B2 E3 F4 A6 D7 C9 F1 E0 A3 B5 C8 D4 E2 A1 F5 B6 C7 E8 D9 A0 E3 B2 C4 F5 D6 A8 C0 E1 F2 B7 D8 A4 E3 C2 B1 A5 D9 F6 C8 E7 A0 B2 C3 D1 F4 E5 A9 3F 2A 7B D9 1E C8 4D A3 6F 5B 9A 0C 3E 7D F2 8B 46 1A 5E 9F 2D 73 8C 4A B1 6C 5D E2 7E C4 39 0B AD 7C 1F 0E 3C 68 92 B4 5A 7F 6E 81 0D 4B A5 E3 F9 2E 8A 37 6D 14 5C 73 8E D2 04 9B 3A 6C F1 70 BF 29 5F 8C 43 61 24 5D 7A 9C 0A D5 1B 3D 6E F4 78 3E 5B";
|
||||
|
||||
/**
|
||||
* 解析
|
||||
*
|
||||
* @return
|
||||
* @throws InterruptedException
|
||||
* @throws ExecutionException
|
||||
*/
|
||||
@RequiresPermissions("message:message:test")
|
||||
@GetMapping("/test")
|
||||
public Result test() throws InterruptedException, ExecutionException {
|
||||
List<SysCarMessage> list = (List<SysCarMessage>) session.getAttribute("list");
|
||||
|
||||
// 检查 list 是否为空
|
||||
if (list == null || list.isEmpty()) {
|
||||
return Result.success(new String[0]); // 或者返回一个适当的错误消息
|
||||
}
|
||||
|
||||
String[] test = TEST.split(" ");
|
||||
String[] results = new String[list.size()];
|
||||
|
||||
List<CompletableFuture<String>> futures = new ArrayList<>();
|
||||
|
||||
for (SysCarMessage carMessage : list) {
|
||||
futures.add(CompletableFuture.supplyAsync(() -> {
|
||||
int startIndex = Integer.parseInt(carMessage.getMessageStartIndex()) - 1;
|
||||
int endIndex = Integer.parseInt(carMessage.getMessageEndIndex());
|
||||
StringBuilder hexBuilder = new StringBuilder();
|
||||
|
||||
for (int j = startIndex; j < endIndex; j++) {
|
||||
hexBuilder.append(test[j]);
|
||||
}
|
||||
|
||||
String hex = hexBuilder.toString();
|
||||
char[] result = new char[hex.length() / 2];
|
||||
|
||||
for (int x = 0; x < hex.length(); x += 2) {
|
||||
int high = Character.digit(hex.charAt(x), 16);
|
||||
int low = Character.digit(hex.charAt(x + 1), 16);
|
||||
result[x / 2] = (char) ((high << 4) + low);
|
||||
}
|
||||
|
||||
return new String(result);
|
||||
}));
|
||||
}
|
||||
|
||||
for (int i = 0; i < futures.size(); i++) {
|
||||
results[i] = futures.get(i).get();
|
||||
}
|
||||
return Result.success(results);
|
||||
}
|
||||
|
||||
@GetMapping("/test")
|
||||
public Result test01() throws ExecutionException, InterruptedException {
|
||||
List<SysCarMessage> list = (List<SysCarMessage>) session.getAttribute("list");
|
||||
//检查list是否为空
|
||||
if (list == null || list.isEmpty()) {
|
||||
return Result.success(new String[0]);//或者返回一个适当的错误消息
|
||||
}
|
||||
String[] test = TEST.split(" ");
|
||||
String[] results = new String[list.size()];
|
||||
ArrayList<CompletableFuture<String>> futures = new ArrayList<>();
|
||||
for (SysCarMessage carMessage : list) {
|
||||
futures.add(CompletableFuture.supplyAsync(() -> {
|
||||
int startIndex = Integer.parseInt(carMessage.getMessageStartIndex()) - 1;
|
||||
int endIndex = Integer.parseInt(carMessage.getMessageEndIndex());
|
||||
StringBuilder hexBuilder = new StringBuilder();
|
||||
for (int j = startIndex; j < endIndex; j++) {
|
||||
hexBuilder.append(test[j]);
|
||||
}
|
||||
String hex = hexBuilder.toString();
|
||||
char[] result = new char[hex.length() / 2];
|
||||
for (int x = 0; x < hex.length(); x++) {
|
||||
int high = Character.digit(hex.charAt(x), 16);
|
||||
int low = Character.digit(hex.charAt(x + 1), 16);
|
||||
result[x / 2] = (char) ((high << 4) + low);
|
||||
}
|
||||
return new String(result);
|
||||
}));
|
||||
}
|
||||
for (int i = 0; i < futures.size(); i++) {
|
||||
results[i] = futures.get(i).get();
|
||||
}
|
||||
return Result.success(results);
|
||||
}
|
||||
|
||||
|
@ -99,8 +129,7 @@ public class SysCarMessageController extends BaseController
|
|||
*/
|
||||
@RequiresPermissions("message:message:list")
|
||||
@GetMapping("/list")
|
||||
public Result<List<SysCarMessage>> list(SysCarMessage sysCarMessage)
|
||||
{
|
||||
public Result<List<SysCarMessage>> list(SysCarMessage sysCarMessage) {
|
||||
List<SysCarMessage> list = sysCarMessageService.selectSysCarMessageList(sysCarMessage);
|
||||
session.setAttribute("list", list);
|
||||
return Result.success(list);
|
||||
|
@ -108,8 +137,7 @@ public class SysCarMessageController extends BaseController
|
|||
|
||||
@RequiresPermissions("message:message:dobList")
|
||||
@GetMapping("/dobList")
|
||||
public Result<List<SysMessageVO>> dobList(SysMessageVO sysMessageVO)
|
||||
{
|
||||
public Result<List<SysMessageVO>> dobList(SysMessageVO sysMessageVO) {
|
||||
List<SysMessageVO> list = sysCarMessageService.dobList(sysMessageVO);
|
||||
return Result.success(list);
|
||||
}
|
||||
|
@ -120,8 +148,7 @@ public class SysCarMessageController extends BaseController
|
|||
*/
|
||||
@RequiresPermissions("message:message:export")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysCarMessage sysCarMessage)
|
||||
{
|
||||
public void export(HttpServletResponse response, SysCarMessage sysCarMessage) {
|
||||
List<SysCarMessage> list = sysCarMessageService.selectSysCarMessageList(sysCarMessage);
|
||||
ExcelUtil<SysCarMessage> util = new ExcelUtil<SysCarMessage>(SysCarMessage.class);
|
||||
util.exportExcel(response, list, "车辆报文记录数据");
|
||||
|
@ -132,8 +159,7 @@ public class SysCarMessageController extends BaseController
|
|||
*/
|
||||
@RequiresPermissions("message:message:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
public Result<List<SysCarMessage>> getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
public Result<List<SysCarMessage>> getInfo(@PathVariable("id") Long id) {
|
||||
return success(sysCarMessageService.selectSysCarMessageById(id));
|
||||
}
|
||||
|
||||
|
@ -143,8 +169,7 @@ public class SysCarMessageController extends BaseController
|
|||
@RequiresPermissions("message:message:add")
|
||||
@PostMapping
|
||||
public Result<Integer> add(
|
||||
@Validated @RequestBody SysCarMessage sysCarMessage)
|
||||
{
|
||||
@Validated @RequestBody SysCarMessage sysCarMessage) {
|
||||
if (sysCarMessageService.checkIdUnique(sysCarMessage)) {
|
||||
return error("新增 车辆报文记录 '" + sysCarMessage + "'失败,车辆报文记录已存在");
|
||||
}
|
||||
|
@ -157,8 +182,7 @@ public class SysCarMessageController extends BaseController
|
|||
@RequiresPermissions("message:message:edit")
|
||||
@PutMapping
|
||||
public Result<Integer> edit(
|
||||
@Validated @RequestBody SysCarMessage sysCarMessage)
|
||||
{
|
||||
@Validated @RequestBody SysCarMessage sysCarMessage) {
|
||||
if (!sysCarMessageService.checkIdUnique(sysCarMessage)) {
|
||||
return error("修改 车辆报文记录 '" + sysCarMessage + "'失败,车辆报文记录不存在");
|
||||
}
|
||||
|
@ -170,8 +194,7 @@ public class SysCarMessageController extends BaseController
|
|||
*/
|
||||
@RequiresPermissions("message:message:remove")
|
||||
@DeleteMapping("/{ids}")
|
||||
public Result<Integer> remove(@PathVariable("ids") Long[] ids)
|
||||
{
|
||||
public Result<Integer> remove(@PathVariable("ids") Long[] ids) {
|
||||
sysCarMessageService.removeBatchByIds(Arrays.asList(ids));
|
||||
return success();
|
||||
}
|
||||
|
|
|
@ -31,8 +31,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/messageType")
|
||||
public class SysMessageTypeController extends BaseController
|
||||
{
|
||||
public class SysMessageTypeController extends BaseController {
|
||||
@Resource
|
||||
private ISysMessageTypeService sysMessageTypeService;
|
||||
|
||||
|
|
|
@ -13,14 +13,11 @@ import lombok.*;
|
|||
@Data
|
||||
public class SysMessageVO {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
|
||||
private String modelCode;
|
||||
private String messageTypeCode;
|
||||
private String messageStartIndex;
|
||||
private String messageEndIndex;
|
||||
private String messageType;
|
||||
|
||||
private String messageName;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
package com.muyu.car.mqtt;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
|
||||
import org.eclipse.paho.client.mqttv3.MqttCallback;
|
||||
import org.eclipse.paho.client.mqttv3.MqttMessage;
|
||||
|
||||
/**
|
||||
* @ClassName Callback
|
||||
* @Description 描述
|
||||
* @Author Chen
|
||||
* @Date 2024/9/26 19:31
|
||||
*/
|
||||
@Slf4j
|
||||
public class Callback implements MqttCallback {
|
||||
/**
|
||||
* MQTT 断开连接会执行此方法
|
||||
*
|
||||
* @param throwable
|
||||
*/
|
||||
@Override
|
||||
public void connectionLost(Throwable throwable) {
|
||||
log.info("断开了MQTT连接:{}", throwable.getMessage());
|
||||
log.error(throwable.getMessage(), throwable);
|
||||
}
|
||||
|
||||
/**
|
||||
* publish发布成功后会执行到这里
|
||||
* @param
|
||||
* @param mqttMessage
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public void messageArrived(String topic, MqttMessage mqttMessage) throws Exception {
|
||||
log.info("收到来自 "+topic+"的消息:{}",new String(mqttMessage.getPayload()));
|
||||
}
|
||||
|
||||
/**
|
||||
* subscribe订阅后得到的消息会执行到这里
|
||||
* @param iMqttDeliveryToken
|
||||
*/
|
||||
@Override
|
||||
public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
|
||||
log.info("发布消息成功");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
package com.muyu.car.mqtt;
|
||||
|
||||
|
||||
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.paho.client.mqttv3.*;
|
||||
import org.eclipse.paho.client.mqttv3.internal.wire.MqttConnect;
|
||||
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
/**
|
||||
* @ClassName MqttTest
|
||||
* @Description MQTT
|
||||
* @Author Chen
|
||||
* @Date 2024/9/26 16:01
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class MQTTConnect {
|
||||
//mqtt服务器的地址和端口
|
||||
private String HOST = "tcp://127.0.0.1:1883";
|
||||
private final String clientId = "DC" + (int) (Math.random() * 100000000);
|
||||
private MqttClient mqttClient;
|
||||
|
||||
/**
|
||||
* 客户端connect连接mqtt服务器
|
||||
*
|
||||
* @param userName
|
||||
* @param password
|
||||
* @param mqttCallback
|
||||
* @throws MqttException
|
||||
*/
|
||||
public void setMqttClient(String userName, String password, MqttCallback mqttCallback) throws MqttException {
|
||||
MqttConnectOptions options = mqttConnectOptions(userName, password);
|
||||
if (mqttCallback == null) {
|
||||
mqttClient.setCallback(new Callback());
|
||||
} else {
|
||||
mqttClient.setCallback(mqttCallback);
|
||||
}
|
||||
mqttClient.connect(options);
|
||||
}
|
||||
|
||||
/**
|
||||
* MQTT连接参数设置
|
||||
*
|
||||
* @param userName
|
||||
* @param password
|
||||
* @return
|
||||
* @throws MqttException
|
||||
*/
|
||||
private MqttConnectOptions mqttConnectOptions(String userName, String password) throws MqttException {
|
||||
mqttClient = new MqttClient(HOST, clientId, new MemoryPersistence());
|
||||
MqttConnectOptions options = new MqttConnectOptions();
|
||||
options.setUserName(userName);
|
||||
options.setPassword(password.toCharArray());
|
||||
options.setConnectionTimeout(10);
|
||||
options.setAutomaticReconnect(true);
|
||||
options.setCleanSession(true);
|
||||
return options;
|
||||
}
|
||||
|
||||
/**
|
||||
* 消息
|
||||
*/
|
||||
public void put(String topic, String msg) throws MqttException {
|
||||
MqttMessage mqttMessage = new MqttMessage();
|
||||
mqttMessage.setPayload(msg.getBytes());
|
||||
MqttTopic mqttTopic = mqttClient.getTopic(topic);
|
||||
MqttDeliveryToken token = mqttTopic.publish(mqttMessage);
|
||||
token.waitForCompletion();
|
||||
}
|
||||
|
||||
public void pub(String topic, String msg, int qos) throws MqttException {
|
||||
MqttMessage mqttMessage = new MqttMessage();
|
||||
mqttMessage.setQos(qos);
|
||||
mqttMessage.setPayload(msg.getBytes());
|
||||
MqttTopic mqttTopic = mqttClient.getTopic(topic);
|
||||
MqttDeliveryToken token = mqttTopic.publish(mqttMessage);
|
||||
token.waitForCompletion();
|
||||
}
|
||||
|
||||
|
||||
public void sub(String topic) throws MqttException {
|
||||
mqttClient.subscribe(topic);
|
||||
}
|
||||
|
||||
public void sub(String topic, int qos) throws MqttException {
|
||||
mqttClient.subscribe(topic, qos);
|
||||
}
|
||||
public static void main(String[] args) throws MqttException {
|
||||
MQTTConnect mqttConnect = new MQTTConnect();
|
||||
mqttConnect.setMqttClient("admin","public",new Callback());
|
||||
mqttConnect.sub("com/iot/init");
|
||||
// mqttConnect.pub("com/iot/init","aa"+(int)(Math.random()*100000000));
|
||||
mqttConnect.put("com/iot/init", "Mr.Qu" + (int) (Math.random() * 100000000));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package com.muyu.car.mqtt;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.paho.client.mqttv3.MqttException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
/**
|
||||
* 项目启动 监听主题
|
||||
*
|
||||
* @author Mr.Qu
|
||||
* @since 2020/1/10
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class MQTTListener implements ApplicationListener<ContextRefreshedEvent> {
|
||||
|
||||
private final MQTTConnect server;
|
||||
|
||||
@Autowired
|
||||
public MQTTListener(MQTTConnect server) {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
|
||||
try {
|
||||
server.setMqttClient("admin", "public", new Callback());
|
||||
server.sub("com/iot/init");
|
||||
} catch (MqttException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,157 +0,0 @@
|
|||
package com.muyu.car.redis;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
|
||||
import com.muyu.car.constant.RedisConstant;
|
||||
import com.muyu.car.domain.VehicleMessage;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class RedisInitialize {
|
||||
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<String,String>redisTemplate;
|
||||
|
||||
@PostConstruct
|
||||
public void a() {
|
||||
|
||||
new Thread(()->{
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
}catch (Exception exception){
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
});
|
||||
VehicleMessage message1 = new VehicleMessage();
|
||||
message1.setStartTime(System.currentTimeMillis());
|
||||
message1.setSpeed("50");
|
||||
message1.setLongitude("126.397428");
|
||||
message1.setLatitude("37.90923");
|
||||
message1.setTotalMileage("1010");
|
||||
message1.setTotalVoltage("22.5");
|
||||
message1.setAcceleratorPedalTravelValue("1.5");
|
||||
message1.setBrakePedalTravelValue("1.2");
|
||||
message1.setSpecificFuelConsumption("1.8");
|
||||
message1.setMotorControllerTemperature("59");
|
||||
message1.setMotorSpeed("850");
|
||||
message1.setMotorTorque("110");
|
||||
message1.setMotorTemperature("53");
|
||||
message1.setMotorVoltage("12.5");
|
||||
message1.setMotorCurrent("1.1");
|
||||
message1.setPowerBatteryRemainingSOC("88");
|
||||
message1.setMaximumPower("999");
|
||||
message1.setMaximumDischargePower("950");
|
||||
message1.setDcdc("2");
|
||||
message1.setChg("2");
|
||||
message1.setBMSSelfCheckCounter("2");
|
||||
message1.setElectricCurrent("2.3");
|
||||
message1.setTotalVoltageV3("13.1");
|
||||
message1.setSingleMaximumVoltage("14.1");
|
||||
message1.setMinimumVoltageOfABattery("12.2");
|
||||
message1.setMaximumBatteryTemperature("85");
|
||||
message1.setMinimumBatteryTemperature("51");
|
||||
message1.setPowerBatteryAvailableCapacity("560");
|
||||
message1.setCombinedCurrent("1.1");
|
||||
message1.setRunningState("2");
|
||||
message1.setWorkStatus("2");
|
||||
message1.setDriveMotorCondition("1");
|
||||
message1.setVehicleStatus("1");
|
||||
message1.setChargingState("1");
|
||||
message1.setHeatingState("1");
|
||||
message1.setCarVin("1HGCM826X3A004352");
|
||||
|
||||
redisTemplate.opsForValue().set(RedisConstant.VEHICLE_ENTERPRISE + message1.getCarVin(), JSON.toJSONString(message1));
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void initialize() {
|
||||
|
||||
|
||||
//
|
||||
// new Thread(() -> {
|
||||
// try {
|
||||
// Thread.sleep(500);
|
||||
// } catch (InterruptedException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// List<VehicleMessageMiddle> vehicleMessageMiddleList = vehicleMessageMiddleService.list();
|
||||
// vehicleMessageMiddleList.forEach(vehicleMessageMiddle -> {
|
||||
// List<MessageDetail> messageDetailList = messageDetailService.list(new LambdaQueryWrapper<>() {{
|
||||
// in(MessageDetail::getId, Arrays.asList(vehicleMessageMiddle.getMessageIds().split(",")));
|
||||
// }});
|
||||
// String jsonString = JSON.toJSONString(messageDetailList);
|
||||
// redisTemplate.opsForHash().put(RedisConstant.MESSAGE_DETAIL, vehicleMessageMiddle.getCarVin(), jsonString);
|
||||
// });
|
||||
// });
|
||||
|
||||
// MessageDetail messageDetail = new MessageDetail();
|
||||
// messageDetail.setKeyCode("1");
|
||||
// messageDetail.setLabel("测试");
|
||||
// messageDetail.setStartBit(0);
|
||||
// messageDetail.setStopBit(8);
|
||||
// messageDetail.setType("1");
|
||||
|
||||
// List<VehicleMessageMiddle> list = vehicleMessageMiddleService.list();
|
||||
// list.forEach(vehicleMessageMiddle -> {
|
||||
// List<MessageDetail> messageDetailList = messageDetailService.list(new LambdaQueryWrapper<>() {{
|
||||
// in(MessageDetail::getId, Arrays.asList(vehicleMessageMiddle.getMessageIds().split(",")));
|
||||
// });
|
||||
// String jsonString = JSON.toJSONString(messageDetailList);
|
||||
// redisTemplate.opsForHash().put(RedisConstant.VEHICLE_ENTERPRISE, message1.getCarVin(), String.valueOf(jsonString));
|
||||
|
||||
new Thread(()->{
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
}catch (Exception exception){
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
});
|
||||
VehicleMessage message1 = new VehicleMessage();
|
||||
message1.setStartTime(System.currentTimeMillis());
|
||||
message1.setSpeed("50");
|
||||
message1.setLongitude("116.397428");
|
||||
message1.setLatitude("39.90923");
|
||||
message1.setTotalMileage("1000");
|
||||
message1.setTotalVoltage("12.5");
|
||||
message1.setAcceleratorPedalTravelValue("0.5");
|
||||
message1.setBrakePedalTravelValue("0.2");
|
||||
message1.setSpecificFuelConsumption("0.8");
|
||||
message1.setMotorControllerTemperature("60");
|
||||
message1.setMotorSpeed("800");
|
||||
message1.setMotorTorque("100");
|
||||
message1.setMotorTemperature("70");
|
||||
message1.setMotorVoltage("12.6");
|
||||
message1.setMotorCurrent("1.2");
|
||||
message1.setPowerBatteryRemainingSOC("80");
|
||||
message1.setMaximumPower("1000");
|
||||
message1.setMaximumDischargePower("900");
|
||||
message1.setDcdc("1");
|
||||
message1.setChg("1");
|
||||
message1.setBMSSelfCheckCounter("1");
|
||||
message1.setElectricCurrent("2.5");
|
||||
message1.setTotalVoltageV3("13.5");
|
||||
message1.setSingleMaximumVoltage("14.5");
|
||||
message1.setMinimumVoltageOfABattery("12.0");
|
||||
message1.setMaximumBatteryTemperature("80");
|
||||
message1.setMinimumBatteryTemperature("50");
|
||||
message1.setPowerBatteryAvailableCapacity("800");
|
||||
message1.setCombinedCurrent("1.5");
|
||||
message1.setRunningState("1");
|
||||
message1.setWorkStatus("1");
|
||||
message1.setDriveMotorCondition("1");
|
||||
message1.setVehicleStatus("1");
|
||||
message1.setChargingState("1");
|
||||
message1.setHeatingState("1");
|
||||
message1.setCarVin("1HGCM826X3A004352");
|
||||
|
||||
redisTemplate.opsForValue().set(RedisConstant.VEHICLE_ENTERPRISE + message1.getCarVin(), JSON.toJSONString(message1));
|
||||
}
|
||||
}
|
|
@ -25,7 +25,7 @@ public class SysMessageTypeServiceImpl
|
|||
/**
|
||||
* 精确查询车辆报文类型
|
||||
*
|
||||
* @param id 车辆报文类型主键
|
||||
* @param
|
||||
* @return 车辆报文类型
|
||||
*/
|
||||
@Override
|
||||
|
|
|
@ -4,7 +4,7 @@ server:
|
|||
|
||||
# nacos线上地址
|
||||
nacos:
|
||||
addr: 127.0.0.1:8848
|
||||
addr: 47.116.173.119:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: one-saas
|
||||
|
|
|
@ -4,7 +4,7 @@ server:
|
|||
|
||||
# nacos线上地址
|
||||
nacos:
|
||||
addr: 127.0.0.1:8848
|
||||
addr: 47.116.173.119:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: one-saas
|
||||
|
|
|
@ -4,7 +4,7 @@ server:
|
|||
|
||||
# nacos线上地址
|
||||
nacos:
|
||||
addr: 127.0.0.1:8848
|
||||
addr: 47.116.173.119:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: one-saas
|
||||
|
|
|
@ -4,7 +4,7 @@ server:
|
|||
|
||||
# nacos线上地址
|
||||
nacos:
|
||||
addr: 127.0.0.1:8848
|
||||
addr: 47.116.173.119:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: one-saas
|
||||
|
|
|
@ -129,10 +129,5 @@
|
|||
<artifactId>fastjson2</artifactId>
|
||||
<version>2.0.43</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.github.yulichang</groupId>-->
|
||||
<!-- <artifactId>mybatis-plus-join-boot-starter</artifactId>-->
|
||||
<!-- <version>1.4.11</version>-->
|
||||
<!-- </dependency>-->
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -3,19 +3,15 @@ package com.muyu.warning.domain;
|
|||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @ClassName WarnRule
|
||||
* @ClassName WarnRuleDTO
|
||||
* @Description 描述
|
||||
* @Author Chen
|
||||
* @Date 2024/9/22 11:53
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class WarnRuleDTO {
|
||||
/** 规则id */
|
||||
@TableId( type = IdType.AUTO)
|
||||
|
|
|
@ -22,11 +22,6 @@
|
|||
<artifactId>cloud-warn-common</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.github.yulichang</groupId>-->
|
||||
<!-- <artifactId>mybatis-plus-join</artifactId>-->
|
||||
<!-- <version>1.2.4</version>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>com.github.yulichang</groupId>
|
||||
<artifactId>mybatis-plus-join-boot-starter</artifactId>
|
||||
|
|
|
@ -5,8 +5,6 @@ import java.util.List;
|
|||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.yulichang.query.MPJLambdaQueryWrapper;
|
||||
import com.muyu.warning.domain.WarnRule;
|
||||
import com.muyu.warning.domain.WarnRuleDTO;
|
||||
import com.muyu.warning.domain.WarnStrategy;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
|
@ -46,14 +44,9 @@ public class WarnRuleController extends BaseController {
|
|||
*/
|
||||
@RequiresPermissions("warning:list")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<WarnRuleDTO>> list(WarnRuleDTO warnRuleDTO) {
|
||||
public Result<TableDataInfo<WarnRule>> list(WarnRule warnRule) {
|
||||
startPage();
|
||||
List<WarnRuleDTO> list = warnRuleService.selectWarnRuleList(warnRuleDTO);
|
||||
// MPJLambdaQueryWrapper<WarnRule> objectMPJLambdaQueryWrapper = new MPJLambdaQueryWrapper<>()
|
||||
// .selectAll(WarnRule.class)
|
||||
// .select(WarnStrategy::getStrategyName)
|
||||
// .leftJoin(WarnStrategy.class, WarnStrategy::getId, WarnRule::getStrategyId)
|
||||
// .stringQuery();
|
||||
List<WarnRule> list = warnRuleService.selectWarnRuleList(warnRule);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
@ -62,9 +55,9 @@ public class WarnRuleController extends BaseController {
|
|||
*/
|
||||
@RequiresPermissions("warning:export")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, WarnRuleDTO warnRuleDTO) {
|
||||
List<WarnRuleDTO> list = warnRuleService.selectWarnRuleList(warnRuleDTO);
|
||||
ExcelUtil<WarnRuleDTO> util = new ExcelUtil<WarnRuleDTO>(WarnRuleDTO.class);
|
||||
public void export(HttpServletResponse response, WarnRule warnRule) {
|
||||
List<WarnRule> list = warnRuleService.selectWarnRuleList(warnRule);
|
||||
ExcelUtil<WarnRule> util = new ExcelUtil<WarnRule>(WarnRule.class);
|
||||
util.exportExcel(response, list, "预警规则数据");
|
||||
}
|
||||
|
||||
|
@ -83,11 +76,11 @@ public class WarnRuleController extends BaseController {
|
|||
@RequiresPermissions("warning:add")
|
||||
@PostMapping
|
||||
public Result<Integer> add(
|
||||
@Validated @RequestBody WarnRuleDTO warnRuleDTO) {
|
||||
if (warnRuleService.checkIdUnique(warnRuleDTO)) {
|
||||
return error("新增 预警规则 '" + warnRuleDTO + "'失败,预警规则已存在");
|
||||
@Validated @RequestBody WarnRule warnRule) {
|
||||
if (warnRuleService.checkIdUnique(warnRule)) {
|
||||
return error("新增 预警规则 '" + warnRule + "'失败,预警规则已存在");
|
||||
}
|
||||
return toAjax(warnRuleService.save(warnRuleDTO));
|
||||
return toAjax(warnRuleService.save(warnRule));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -96,11 +89,11 @@ public class WarnRuleController extends BaseController {
|
|||
@RequiresPermissions("warning:edit")
|
||||
@PutMapping
|
||||
public Result<Integer> edit(
|
||||
@Validated @RequestBody WarnRuleDTO warnRuleDTO) {
|
||||
if (!warnRuleService.checkIdUnique(warnRuleDTO)) {
|
||||
return error("修改 预警规则 '" + warnRuleDTO + "'失败,预警规则不存在");
|
||||
@Validated @RequestBody WarnRule warnRule) {
|
||||
if (!warnRuleService.checkIdUnique(warnRule)) {
|
||||
return error("修改 预警规则 '" + warnRule + "'失败,预警规则不存在");
|
||||
}
|
||||
return toAjax(warnRuleService.updateById(warnRuleDTO));
|
||||
return toAjax(warnRuleService.updateById(warnRule));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
package com.muyu.warning.controller;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.warning.domain.WarnRule;
|
||||
import com.muyu.warning.domain.WarnRuleDTO;
|
||||
import com.muyu.warning.service.IWarRulesService;
|
||||
import lombok.val;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName WarnRulesController
|
||||
* @Description 描述
|
||||
* @Author Chen
|
||||
* @Date 2024/9/23 21:07
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/rules")
|
||||
public class WarnRulesController {
|
||||
@Autowired
|
||||
private IWarRulesService warnRulesService;
|
||||
|
||||
/**
|
||||
* 联查策略规则 联查
|
||||
*/
|
||||
|
||||
@GetMapping("/list")
|
||||
public Result<List<WarnRuleDTO>> list() {
|
||||
List<WarnRuleDTO> list = warnRulesService.selectWarnRulesList();
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 联查
|
||||
*
|
||||
* @param warnRuleDTO
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/listAll")
|
||||
public Result<List<WarnRuleDTO>> listAll(WarnRuleDTO warnRuleDTO) {
|
||||
List<WarnRuleDTO> list = warnRulesService.selectWarnRulesListAll(warnRuleDTO);
|
||||
return Result.success(list);
|
||||
}
|
||||
}
|
|
@ -2,11 +2,8 @@ package com.muyu.warning.controller;
|
|||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
|
@ -32,7 +29,8 @@ import com.muyu.common.core.web.page.TableDataInfo;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/strategy")
|
||||
public class WarnStrategyController extends BaseController {
|
||||
public class WarnStrategyController extends BaseController
|
||||
{
|
||||
@Resource
|
||||
private IWarnStrategyService warnStrategyService;
|
||||
|
||||
|
@ -41,7 +39,8 @@ public class WarnStrategyController extends BaseController {
|
|||
*/
|
||||
@RequiresPermissions("warning:strategy:list")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<WarnStrategy>> list(WarnStrategy warnStrategy) {
|
||||
public Result<TableDataInfo<WarnStrategy>> list(WarnStrategy warnStrategy)
|
||||
{
|
||||
startPage();
|
||||
List<WarnStrategy> list = warnStrategyService.selectWarnStrategyList(warnStrategy);
|
||||
return getDataTable(list);
|
||||
|
@ -52,7 +51,8 @@ public class WarnStrategyController extends BaseController {
|
|||
*/
|
||||
@RequiresPermissions("warning:strategy:export")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, WarnStrategy warnStrategy) {
|
||||
public void export(HttpServletResponse response, WarnStrategy warnStrategy)
|
||||
{
|
||||
List<WarnStrategy> list = warnStrategyService.selectWarnStrategyList(warnStrategy);
|
||||
ExcelUtil<WarnStrategy> util = new ExcelUtil<WarnStrategy>(WarnStrategy.class);
|
||||
util.exportExcel(response, list, "预警策略数据");
|
||||
|
@ -63,7 +63,8 @@ public class WarnStrategyController extends BaseController {
|
|||
*/
|
||||
@RequiresPermissions("warning:strategy:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
public Result<List<WarnStrategy>> getInfo(@PathVariable("id") Long id) {
|
||||
public Result<List<WarnStrategy>> getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return success(warnStrategyService.selectWarnStrategyById(id));
|
||||
}
|
||||
|
||||
|
@ -73,7 +74,8 @@ public class WarnStrategyController extends BaseController {
|
|||
@RequiresPermissions("warning:strategy:add")
|
||||
@PostMapping
|
||||
public Result<Integer> add(
|
||||
@Validated @RequestBody WarnStrategy warnStrategy) {
|
||||
@Validated @RequestBody WarnStrategy warnStrategy)
|
||||
{
|
||||
if (warnStrategyService.checkIdUnique(warnStrategy)) {
|
||||
return error("新增 预警策略 '" + warnStrategy + "'失败,预警策略已存在");
|
||||
}
|
||||
|
@ -86,7 +88,8 @@ public class WarnStrategyController extends BaseController {
|
|||
@RequiresPermissions("warning:strategy:edit")
|
||||
@PutMapping
|
||||
public Result<Integer> edit(
|
||||
@Validated @RequestBody WarnStrategy warnStrategy) {
|
||||
@Validated @RequestBody WarnStrategy warnStrategy)
|
||||
{
|
||||
if (!warnStrategyService.checkIdUnique(warnStrategy)) {
|
||||
return error("修改 预警策略 '" + warnStrategy + "'失败,预警策略不存在");
|
||||
}
|
||||
|
@ -98,7 +101,8 @@ public class WarnStrategyController extends BaseController {
|
|||
*/
|
||||
@RequiresPermissions("warning:strategy:remove")
|
||||
@DeleteMapping("/{ids}")
|
||||
public Result<Integer> remove(@PathVariable("ids") Long[] ids) {
|
||||
public Result<Integer> remove(@PathVariable("ids") Long[] ids)
|
||||
{
|
||||
warnStrategyService.removeBatchByIds(Arrays.asList(ids));
|
||||
return success();
|
||||
}
|
||||
|
|
|
@ -3,8 +3,6 @@ package com.muyu.warning.mapper;
|
|||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.muyu.warning.domain.WarnRule;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.warning.domain.WarnRule;
|
||||
import com.muyu.warning.domain.WarnRuleDTO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
|
@ -14,6 +12,6 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
* @date 2024-09-20
|
||||
*/
|
||||
@Mapper
|
||||
public interface WarnRuleMapper extends BaseMapper<WarnRuleDTO> {
|
||||
public interface WarnRuleMapper extends BaseMapper<WarnRule> {
|
||||
|
||||
}
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
package com.muyu.warning.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.warning.domain.WarnRuleDTO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName WarnRulesMapper
|
||||
* @Description 描述
|
||||
* @Author Chen
|
||||
* @Date 2024/9/23 21:07
|
||||
*/
|
||||
@Mapper
|
||||
public interface WarnRulesMapper extends BaseMapper<WarnRuleDTO> {
|
||||
@Select("select r.*,s.id,s.strategy_name FROM warn_rule r left join warn_strategy s on r.strategy_id=s.id where r.strategy_id = #{s.id}")
|
||||
List<WarnRuleDTO> selectWarnRulesListAll(WarnRuleDTO warnRuleDTO);
|
||||
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
package com.muyu.warning.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.warning.domain.WarnRule;
|
||||
import com.muyu.warning.domain.WarnRuleDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IWarRulesService extends IService<WarnRuleDTO> {
|
||||
List<WarnRuleDTO> selectWarnRulesList();
|
||||
//联查
|
||||
List<WarnRuleDTO> selectWarnRulesListAll(WarnRuleDTO warnRuleDTO);
|
||||
|
||||
}
|
|
@ -1,39 +1,39 @@
|
|||
package com.muyu.warning.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.github.yulichang.base.MPJBaseService;
|
||||
import com.muyu.warning.domain.WarnRuleDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseService;
|
||||
import com.muyu.warning.domain.WarnRule;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* 预警规则Service接口
|
||||
*
|
||||
* @author muyu
|
||||
* @date 2024-09-20
|
||||
*/
|
||||
public interface IWarnRuleService extends IService<WarnRuleDTO> {
|
||||
public interface IWarnRuleService extends IService<WarnRule> {
|
||||
/**
|
||||
* 精确查询预警规则
|
||||
*
|
||||
* @param id 预警规则主键
|
||||
* @return 预警规则
|
||||
*/
|
||||
public WarnRuleDTO selectWarnRuleById(Long id);
|
||||
public WarnRule selectWarnRuleById(Long id);
|
||||
|
||||
/**
|
||||
* 查询预警规则列表
|
||||
*
|
||||
* @param warnRuleDTO 预警规则
|
||||
* @param warnRule 预警规则
|
||||
* @return 预警规则集合
|
||||
*/
|
||||
public List<WarnRuleDTO> selectWarnRuleList(WarnRuleDTO warnRuleDTO);
|
||||
public List<WarnRule> selectWarnRuleList(WarnRule warnRule);
|
||||
|
||||
/**
|
||||
* 判断 预警规则 id是否唯一
|
||||
* @param warnRuleDTO 预警规则
|
||||
* @param warnRule 预警规则
|
||||
* @return 结果
|
||||
*/
|
||||
Boolean checkIdUnique(WarnRuleDTO warnRuleDTO);
|
||||
Boolean checkIdUnique(WarnRule warnRule);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,18 +1,23 @@
|
|||
package com.muyu.warning.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import java.util.List;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseServiceImpl;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.github.yulichang.query.MPJLambdaQueryWrapper;
|
||||
import com.github.yulichang.query.MPJQueryWrapper;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.muyu.warning.domain.WarnRuleDTO;
|
||||
import com.muyu.warning.domain.WarnStrategy;
|
||||
import com.muyu.warning.mapper.WarnRuleMapper;
|
||||
import com.muyu.warning.service.IWarnRuleService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.muyu.warning.domain.WarnRule;
|
||||
import com.muyu.warning.service.IWarnRuleService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 预警规则Service业务层处理
|
||||
*
|
||||
|
@ -21,9 +26,10 @@ import java.util.List;
|
|||
*/
|
||||
@Service
|
||||
public class WarnRuleServiceImpl
|
||||
extends ServiceImpl<WarnRuleMapper, WarnRuleDTO>
|
||||
extends ServiceImpl<WarnRuleMapper, WarnRule>
|
||||
implements IWarnRuleService {
|
||||
|
||||
@Autowired
|
||||
private WarnRuleMapper warnRuleMapper;
|
||||
|
||||
/**
|
||||
* 精确查询预警规则
|
||||
|
@ -32,10 +38,10 @@ public class WarnRuleServiceImpl
|
|||
* @return 预警规则
|
||||
*/
|
||||
@Override
|
||||
public WarnRuleDTO selectWarnRuleById(Long id) {
|
||||
LambdaQueryWrapper<WarnRuleDTO> queryWrapper = new LambdaQueryWrapper<>();
|
||||
public WarnRule selectWarnRuleById(Long id) {
|
||||
LambdaQueryWrapper<WarnRule> queryWrapper = new LambdaQueryWrapper<>();
|
||||
Assert.notNull(id, "id不可为空");
|
||||
queryWrapper.eq(WarnRuleDTO::getId, id);
|
||||
queryWrapper.eq(WarnRule::getId, id);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
|
@ -43,65 +49,44 @@ public class WarnRuleServiceImpl
|
|||
/**
|
||||
* 查询预警规则列表
|
||||
*
|
||||
* @param warnRuleDTO 预警规则
|
||||
* @param warnRule 预警规则
|
||||
* @return 预警规则
|
||||
*/
|
||||
@Override
|
||||
public List<WarnRuleDTO> selectWarnRuleList(WarnRuleDTO warnRuleDTO) {
|
||||
public List<WarnRule> selectWarnRuleList(WarnRule warnRule) {
|
||||
|
||||
// MPJLambdaWrapper<WarnRule> queryWrapper = new MPJLambdaWrapper<WarnRule>()
|
||||
// .selectAll(WarnRule.class)
|
||||
// .select(WarnStrategy::getStrategyName)
|
||||
// .selectAs(WarnStrategy::getStrategyName, WarnRule::getStrategyName);
|
||||
// List<WarnRule> list = warnRuleMapper.selectJoinList(WarnRule.class, queryWrapper);
|
||||
// return list;
|
||||
// MPJLambdaWrapper<WarnRule> wrapper = JoinWrappers.lambda(WarnRule.class)
|
||||
// .selectAll(WarnRule.class)
|
||||
// .select(WarnStrategy::getStrategyName)
|
||||
// .leftJoin(WarnStrategy.class, WarnStrategy::getId, WarnRule::getId);
|
||||
// return warnRuleMapper.selectJoinList(WarnRule.class, wrapper);
|
||||
// MPJQueryWrapper<WarnRule> queryWrapper = new MPJQueryWrapper<>();
|
||||
// if (StringUtils.isNotEmpty(warnRule.getRuleName())) {
|
||||
//// queryWrapper.like(WarnRule::getRuleName, warnRule.getRuleName());
|
||||
// queryWrapper.like("rule_name", warnRule.getRuleName());
|
||||
// }
|
||||
//
|
||||
|
||||
LambdaQueryWrapper<WarnRuleDTO> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (StringUtils.isNotNull(warnRuleDTO.getStrategyId())) {
|
||||
queryWrapper.eq(WarnRuleDTO::getStrategyId, warnRuleDTO.getStrategyId());
|
||||
// queryWrapper.eq("strategy_id", warnRule.getStrategyId());
|
||||
LambdaQueryWrapper<WarnRule> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (StringUtils.isNotEmpty(warnRule.getRuleName())) {
|
||||
queryWrapper.like(WarnRule::getRuleName, warnRule.getRuleName());
|
||||
}
|
||||
if (StringUtils.isNotNull(warnRuleDTO.getMsgTypeId())) {
|
||||
queryWrapper.eq(WarnRuleDTO::getMsgTypeId, warnRuleDTO.getMsgTypeId());
|
||||
if (StringUtils.isNotNull(warnRule.getMsgTypeId())) {
|
||||
queryWrapper.eq(WarnRule::getMsgTypeId, warnRule.getMsgTypeId());
|
||||
}
|
||||
if (StringUtils.isNotNull(warnRuleDTO.getSlideTime())) {
|
||||
queryWrapper.eq(WarnRuleDTO::getSlideTime, warnRuleDTO.getSlideTime());
|
||||
if (StringUtils.isNotNull(warnRule.getSlideTime())) {
|
||||
queryWrapper.eq(WarnRule::getSlideTime, warnRule.getSlideTime());
|
||||
}
|
||||
if (StringUtils.isNotNull(warnRuleDTO.getSlideFrequency())) {
|
||||
queryWrapper.eq(WarnRuleDTO::getSlideFrequency, warnRuleDTO.getSlideFrequency());
|
||||
if (StringUtils.isNotNull(warnRule.getSlideFrequency())) {
|
||||
queryWrapper.eq(WarnRule::getSlideFrequency, warnRule.getSlideFrequency());
|
||||
}
|
||||
if (StringUtils.isNotNull(warnRuleDTO.getMaxValue())) {
|
||||
queryWrapper.eq(WarnRuleDTO::getMaxValue, warnRuleDTO.getMaxValue());
|
||||
if (StringUtils.isNotNull(warnRule.getMaxValue())) {
|
||||
queryWrapper.eq(WarnRule::getMaxValue, warnRule.getMaxValue());
|
||||
}
|
||||
if (StringUtils.isNotNull(warnRuleDTO.getMinValue())) {
|
||||
queryWrapper.eq(WarnRuleDTO::getMinValue, warnRuleDTO.getMinValue());
|
||||
if (StringUtils.isNotNull(warnRule.getMinValue())) {
|
||||
queryWrapper.eq(WarnRule::getMinValue, warnRule.getMinValue());
|
||||
}
|
||||
return this.list(queryWrapper);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 唯一 判断
|
||||
*
|
||||
* @param warnRuleDTO 预警规则
|
||||
* @param warnRule 预警规则
|
||||
* @return 预警规则
|
||||
*/
|
||||
@Override
|
||||
public Boolean checkIdUnique(WarnRuleDTO warnRuleDTO) {
|
||||
LambdaQueryWrapper<WarnRuleDTO> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(WarnRuleDTO::getId, warnRuleDTO.getId());
|
||||
public Boolean checkIdUnique(WarnRule warnRule) {
|
||||
LambdaQueryWrapper<WarnRule> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(WarnRule::getId, warnRule.getId());
|
||||
return this.count(queryWrapper) > 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
package com.muyu.warning.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.muyu.warning.domain.WarnRule;
|
||||
import com.muyu.warning.domain.WarnRuleDTO;
|
||||
import com.muyu.warning.domain.WarnStrategy;
|
||||
import com.muyu.warning.mapper.WarnRulesMapper;
|
||||
import com.muyu.warning.service.IWarRulesService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName WarnRulesServiceImpl
|
||||
* @Description 描述
|
||||
* @Author Chen
|
||||
* @Date 2024/9/23 22:02
|
||||
*/
|
||||
@Service
|
||||
public class WarnRulesServiceImpl
|
||||
extends ServiceImpl <WarnRulesMapper, WarnRuleDTO>
|
||||
implements IWarRulesService {
|
||||
|
||||
@Autowired
|
||||
private WarnRulesMapper warnRulesMapper;
|
||||
|
||||
@Override
|
||||
public List<WarnRuleDTO> selectWarnRulesList() {
|
||||
MPJLambdaWrapper<WarnRuleDTO> wrapper = new MPJLambdaWrapper<WarnRuleDTO>()
|
||||
.selectAll(WarnRule.class)
|
||||
.selectAs(WarnStrategy::getStrategyName, WarnRuleDTO::getStrategyName)
|
||||
.leftJoin(WarnStrategy.class, WarnStrategy::getId, WarnRule::getStrategyId);
|
||||
return this.list(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 双表查询
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<WarnRuleDTO> selectWarnRulesListAll(WarnRuleDTO warnRuleDTO) {
|
||||
List<WarnRuleDTO> list = warnRulesMapper.selectWarnRulesListAll(warnRuleDTO);
|
||||
return list;
|
||||
}
|
||||
}
|
|
@ -4,10 +4,10 @@ server:
|
|||
|
||||
# nacos线上地址
|
||||
nacos:
|
||||
addr: 127.0.0.1:8848
|
||||
addr: 47.116.173.119:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: one
|
||||
namespace: one-saas
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
<?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.muyu.warning.mapper.WarnRulesMapper">
|
||||
|
||||
|
||||
<select id="selectWarnRulesListAll" resultType="com.muyu.warning.domain.WarnRuleDTO"></select>
|
||||
</mapper>
|
|
@ -4,7 +4,7 @@ server:
|
|||
|
||||
# nacos线上地址
|
||||
nacos:
|
||||
addr: 127.0.0.1:8848
|
||||
addr: 47.116.173.119:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: one-saas
|
||||
|
|
Loading…
Reference in New Issue