dev.protocol.parsing
chentaisen 2024-09-26 23:54:48 +08:00
parent f5b153f32c
commit 04285aea80
31 changed files with 325 additions and 458 deletions

View File

@ -4,7 +4,7 @@ server:
# nacos线上地址 # nacos线上地址
nacos: nacos:
addr: 127.0.0.1:8848 addr: 47.116.173.119:8848
user-name: nacos user-name: nacos
password: nacos password: nacos
namespace: one-saas namespace: one-saas

View File

@ -4,7 +4,7 @@ server:
# nacos线上地址 # nacos线上地址
nacos: nacos:
addr: 127.0.0.1:8848 addr: 47.116.173.119:8848
user-name: nacos user-name: nacos
password: nacos password: nacos
namespace: one-saas namespace: one-saas

View File

@ -18,6 +18,11 @@
</properties> </properties>
<dependencies> <dependencies>
<!-- MQTT-->
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-mqtt</artifactId>
</dependency>
<!-- SpringCloud Alibaba Nacos --> <!-- SpringCloud Alibaba Nacos -->
<dependency> <dependency>

View File

@ -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";
}

View File

@ -11,6 +11,7 @@ import com.muyu.car.domain.SysMessageType;
import com.muyu.car.domain.VO.SysMessageVO; import com.muyu.car.domain.VO.SysMessageVO;
import com.muyu.car.service.ISysCarMessageService; import com.muyu.car.service.ISysCarMessageService;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import javax.annotation.Resource; import javax.annotation.Resource;
import jakarta.servlet.http.HttpSession; import jakarta.servlet.http.HttpSession;
@ -39,57 +40,86 @@ import com.muyu.common.core.web.page.TableDataInfo;
*/ */
@RestController @RestController
@RequestMapping("/messageInfo") @RequestMapping("/messageInfo")
public class SysCarMessageController extends BaseController public class SysCarMessageController extends BaseController {
{
@Resource @Resource
private ISysCarMessageService sysCarMessageService; private ISysCarMessageService sysCarMessageService;
@Autowired @Autowired
private HttpSession session; 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"; 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") @RequiresPermissions("message:message:test")
@GetMapping("/test") @GetMapping("/test")
public Result test() throws InterruptedException, ExecutionException { public Result test() throws InterruptedException, ExecutionException {
List<SysCarMessage> list = (List<SysCarMessage>) session.getAttribute("list"); List<SysCarMessage> list = (List<SysCarMessage>) session.getAttribute("list");
// 检查 list 是否为空 // 检查 list 是否为空
if (list == null || list.isEmpty()) { if (list == null || list.isEmpty()) {
return Result.success(new String[0]); // 或者返回一个适当的错误消息 return Result.success(new String[0]); // 或者返回一个适当的错误消息
} }
String[] test = TEST.split(" "); String[] test = TEST.split(" ");
String[] results = new String[list.size()]; String[] results = new String[list.size()];
List<CompletableFuture<String>> futures = new ArrayList<>(); List<CompletableFuture<String>> futures = new ArrayList<>();
for (SysCarMessage carMessage : list) { for (SysCarMessage carMessage : list) {
futures.add(CompletableFuture.supplyAsync(() -> { futures.add(CompletableFuture.supplyAsync(() -> {
int startIndex = Integer.parseInt(carMessage.getMessageStartIndex()) - 1; int startIndex = Integer.parseInt(carMessage.getMessageStartIndex()) - 1;
int endIndex = Integer.parseInt(carMessage.getMessageEndIndex()); int endIndex = Integer.parseInt(carMessage.getMessageEndIndex());
StringBuilder hexBuilder = new StringBuilder(); StringBuilder hexBuilder = new StringBuilder();
for (int j = startIndex; j < endIndex; j++) { for (int j = startIndex; j < endIndex; j++) {
hexBuilder.append(test[j]); hexBuilder.append(test[j]);
} }
String hex = hexBuilder.toString(); String hex = hexBuilder.toString();
char[] result = new char[hex.length() / 2]; char[] result = new char[hex.length() / 2];
for (int x = 0; x < hex.length(); x += 2) { for (int x = 0; x < hex.length(); x += 2) {
int high = Character.digit(hex.charAt(x), 16); int high = Character.digit(hex.charAt(x), 16);
int low = Character.digit(hex.charAt(x + 1), 16); int low = Character.digit(hex.charAt(x + 1), 16);
result[x / 2] = (char) ((high << 4) + low); result[x / 2] = (char) ((high << 4) + low);
} }
return new String(result); return new String(result);
})); }));
} }
for (int i = 0; i < futures.size(); i++) { for (int i = 0; i < futures.size(); i++) {
results[i] = futures.get(i).get(); 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); return Result.success(results);
} }
@ -99,8 +129,7 @@ public class SysCarMessageController extends BaseController
*/ */
@RequiresPermissions("message:message:list") @RequiresPermissions("message:message:list")
@GetMapping("/list") @GetMapping("/list")
public Result<List<SysCarMessage>> list(SysCarMessage sysCarMessage) public Result<List<SysCarMessage>> list(SysCarMessage sysCarMessage) {
{
List<SysCarMessage> list = sysCarMessageService.selectSysCarMessageList(sysCarMessage); List<SysCarMessage> list = sysCarMessageService.selectSysCarMessageList(sysCarMessage);
session.setAttribute("list", list); session.setAttribute("list", list);
return Result.success(list); return Result.success(list);
@ -108,8 +137,7 @@ public class SysCarMessageController extends BaseController
@RequiresPermissions("message:message:dobList") @RequiresPermissions("message:message:dobList")
@GetMapping("/dobList") @GetMapping("/dobList")
public Result<List<SysMessageVO>> dobList(SysMessageVO sysMessageVO) public Result<List<SysMessageVO>> dobList(SysMessageVO sysMessageVO) {
{
List<SysMessageVO> list = sysCarMessageService.dobList(sysMessageVO); List<SysMessageVO> list = sysCarMessageService.dobList(sysMessageVO);
return Result.success(list); return Result.success(list);
} }
@ -120,8 +148,7 @@ public class SysCarMessageController extends BaseController
*/ */
@RequiresPermissions("message:message:export") @RequiresPermissions("message:message:export")
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, SysCarMessage sysCarMessage) public void export(HttpServletResponse response, SysCarMessage sysCarMessage) {
{
List<SysCarMessage> list = sysCarMessageService.selectSysCarMessageList(sysCarMessage); List<SysCarMessage> list = sysCarMessageService.selectSysCarMessageList(sysCarMessage);
ExcelUtil<SysCarMessage> util = new ExcelUtil<SysCarMessage>(SysCarMessage.class); ExcelUtil<SysCarMessage> util = new ExcelUtil<SysCarMessage>(SysCarMessage.class);
util.exportExcel(response, list, "车辆报文记录数据"); util.exportExcel(response, list, "车辆报文记录数据");
@ -132,8 +159,7 @@ public class SysCarMessageController extends BaseController
*/ */
@RequiresPermissions("message:message:query") @RequiresPermissions("message:message:query")
@GetMapping(value = "/{id}") @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)); return success(sysCarMessageService.selectSysCarMessageById(id));
} }
@ -143,8 +169,7 @@ public class SysCarMessageController extends BaseController
@RequiresPermissions("message:message:add") @RequiresPermissions("message:message:add")
@PostMapping @PostMapping
public Result<Integer> add( public Result<Integer> add(
@Validated @RequestBody SysCarMessage sysCarMessage) @Validated @RequestBody SysCarMessage sysCarMessage) {
{
if (sysCarMessageService.checkIdUnique(sysCarMessage)) { if (sysCarMessageService.checkIdUnique(sysCarMessage)) {
return error("新增 车辆报文记录 '" + sysCarMessage + "'失败,车辆报文记录已存在"); return error("新增 车辆报文记录 '" + sysCarMessage + "'失败,车辆报文记录已存在");
} }
@ -157,8 +182,7 @@ public class SysCarMessageController extends BaseController
@RequiresPermissions("message:message:edit") @RequiresPermissions("message:message:edit")
@PutMapping @PutMapping
public Result<Integer> edit( public Result<Integer> edit(
@Validated @RequestBody SysCarMessage sysCarMessage) @Validated @RequestBody SysCarMessage sysCarMessage) {
{
if (!sysCarMessageService.checkIdUnique(sysCarMessage)) { if (!sysCarMessageService.checkIdUnique(sysCarMessage)) {
return error("修改 车辆报文记录 '" + sysCarMessage + "'失败,车辆报文记录不存在"); return error("修改 车辆报文记录 '" + sysCarMessage + "'失败,车辆报文记录不存在");
} }
@ -170,8 +194,7 @@ public class SysCarMessageController extends BaseController
*/ */
@RequiresPermissions("message:message:remove") @RequiresPermissions("message:message:remove")
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
public Result<Integer> remove(@PathVariable("ids") Long[] ids) public Result<Integer> remove(@PathVariable("ids") Long[] ids) {
{
sysCarMessageService.removeBatchByIds(Arrays.asList(ids)); sysCarMessageService.removeBatchByIds(Arrays.asList(ids));
return success(); return success();
} }

View File

@ -31,8 +31,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
*/ */
@RestController @RestController
@RequestMapping("/messageType") @RequestMapping("/messageType")
public class SysMessageTypeController extends BaseController public class SysMessageTypeController extends BaseController {
{
@Resource @Resource
private ISysMessageTypeService sysMessageTypeService; private ISysMessageTypeService sysMessageTypeService;

View File

@ -13,14 +13,11 @@ import lombok.*;
@Data @Data
public class SysMessageVO { public class SysMessageVO {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Long id; private Long id;
private String modelCode; private String modelCode;
private String messageTypeCode; private String messageTypeCode;
private String messageStartIndex; private String messageStartIndex;
private String messageEndIndex; private String messageEndIndex;
private String messageType; private String messageType;
private String messageName; private String messageName;
} }

View File

@ -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("发布消息成功");
}
}

View File

@ -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;
/**
* connectmqtt
*
* @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));
}
}

View File

@ -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);
}
}
}

View File

@ -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));
}
}

View File

@ -25,7 +25,7 @@ public class SysMessageTypeServiceImpl
/** /**
* *
* *
* @param id * @param
* @return * @return
*/ */
@Override @Override

View File

@ -4,7 +4,7 @@ server:
# nacos线上地址 # nacos线上地址
nacos: nacos:
addr: 127.0.0.1:8848 addr: 47.116.173.119:8848
user-name: nacos user-name: nacos
password: nacos password: nacos
namespace: one-saas namespace: one-saas

View File

@ -4,7 +4,7 @@ server:
# nacos线上地址 # nacos线上地址
nacos: nacos:
addr: 127.0.0.1:8848 addr: 47.116.173.119:8848
user-name: nacos user-name: nacos
password: nacos password: nacos
namespace: one-saas namespace: one-saas

View File

@ -4,7 +4,7 @@ server:
# nacos线上地址 # nacos线上地址
nacos: nacos:
addr: 127.0.0.1:8848 addr: 47.116.173.119:8848
user-name: nacos user-name: nacos
password: nacos password: nacos
namespace: one-saas namespace: one-saas

View File

@ -4,7 +4,7 @@ server:
# nacos线上地址 # nacos线上地址
nacos: nacos:
addr: 127.0.0.1:8848 addr: 47.116.173.119:8848
user-name: nacos user-name: nacos
password: nacos password: nacos
namespace: one-saas namespace: one-saas

View File

@ -129,10 +129,5 @@
<artifactId>fastjson2</artifactId> <artifactId>fastjson2</artifactId>
<version>2.0.43</version> <version>2.0.43</version>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>com.github.yulichang</groupId>-->
<!-- <artifactId>mybatis-plus-join-boot-starter</artifactId>-->
<!-- <version>1.4.11</version>-->
<!-- </dependency>-->
</dependencies> </dependencies>
</project> </project>

View File

@ -3,19 +3,15 @@ package com.muyu.warning.domain;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.muyu.common.core.annotation.Excel; import com.muyu.common.core.annotation.Excel;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
/** /**
* @ClassName WarnRule * @ClassName WarnRuleDTO
* @Description * @Description
* @Author Chen * @Author Chen
* @Date 2024/9/22 11:53 * @Date 2024/9/22 11:53
*/ */
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
public class WarnRuleDTO { public class WarnRuleDTO {
/** 规则id */ /** 规则id */
@TableId( type = IdType.AUTO) @TableId( type = IdType.AUTO)

View File

@ -22,11 +22,6 @@
<artifactId>cloud-warn-common</artifactId> <artifactId>cloud-warn-common</artifactId>
<version>3.6.3</version> <version>3.6.3</version>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>com.github.yulichang</groupId>-->
<!-- <artifactId>mybatis-plus-join</artifactId>-->
<!-- <version>1.2.4</version>-->
<!-- </dependency>-->
<dependency> <dependency>
<groupId>com.github.yulichang</groupId> <groupId>com.github.yulichang</groupId>
<artifactId>mybatis-plus-join-boot-starter</artifactId> <artifactId>mybatis-plus-join-boot-starter</artifactId>

View File

@ -5,8 +5,6 @@ import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.yulichang.query.MPJLambdaQueryWrapper; 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 com.muyu.warning.domain.WarnStrategy;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
@ -46,14 +44,9 @@ public class WarnRuleController extends BaseController {
*/ */
@RequiresPermissions("warning:list") @RequiresPermissions("warning:list")
@GetMapping("/list") @GetMapping("/list")
public Result<TableDataInfo<WarnRuleDTO>> list(WarnRuleDTO warnRuleDTO) { public Result<TableDataInfo<WarnRule>> list(WarnRule warnRule) {
startPage(); startPage();
List<WarnRuleDTO> list = warnRuleService.selectWarnRuleList(warnRuleDTO); List<WarnRule> list = warnRuleService.selectWarnRuleList(warnRule);
// MPJLambdaQueryWrapper<WarnRule> objectMPJLambdaQueryWrapper = new MPJLambdaQueryWrapper<>()
// .selectAll(WarnRule.class)
// .select(WarnStrategy::getStrategyName)
// .leftJoin(WarnStrategy.class, WarnStrategy::getId, WarnRule::getStrategyId)
// .stringQuery();
return getDataTable(list); return getDataTable(list);
} }
@ -62,9 +55,9 @@ public class WarnRuleController extends BaseController {
*/ */
@RequiresPermissions("warning:export") @RequiresPermissions("warning:export")
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, WarnRuleDTO warnRuleDTO) { public void export(HttpServletResponse response, WarnRule warnRule) {
List<WarnRuleDTO> list = warnRuleService.selectWarnRuleList(warnRuleDTO); List<WarnRule> list = warnRuleService.selectWarnRuleList(warnRule);
ExcelUtil<WarnRuleDTO> util = new ExcelUtil<WarnRuleDTO>(WarnRuleDTO.class); ExcelUtil<WarnRule> util = new ExcelUtil<WarnRule>(WarnRule.class);
util.exportExcel(response, list, "预警规则数据"); util.exportExcel(response, list, "预警规则数据");
} }
@ -83,11 +76,11 @@ public class WarnRuleController extends BaseController {
@RequiresPermissions("warning:add") @RequiresPermissions("warning:add")
@PostMapping @PostMapping
public Result<Integer> add( public Result<Integer> add(
@Validated @RequestBody WarnRuleDTO warnRuleDTO) { @Validated @RequestBody WarnRule warnRule) {
if (warnRuleService.checkIdUnique(warnRuleDTO)) { if (warnRuleService.checkIdUnique(warnRule)) {
return error("新增 预警规则 '" + warnRuleDTO + "'失败,预警规则已存在"); 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") @RequiresPermissions("warning:edit")
@PutMapping @PutMapping
public Result<Integer> edit( public Result<Integer> edit(
@Validated @RequestBody WarnRuleDTO warnRuleDTO) { @Validated @RequestBody WarnRule warnRule) {
if (!warnRuleService.checkIdUnique(warnRuleDTO)) { if (!warnRuleService.checkIdUnique(warnRule)) {
return error("修改 预警规则 '" + warnRuleDTO + "'失败,预警规则不存在"); return error("修改 预警规则 '" + warnRule + "'失败,预警规则不存在");
} }
return toAjax(warnRuleService.updateById(warnRuleDTO)); return toAjax(warnRuleService.updateById(warnRule));
} }
/** /**

View File

@ -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);
}
}

View File

@ -2,11 +2,8 @@ package com.muyu.warning.controller;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.PutMapping;
@ -32,7 +29,8 @@ import com.muyu.common.core.web.page.TableDataInfo;
*/ */
@RestController @RestController
@RequestMapping("/strategy") @RequestMapping("/strategy")
public class WarnStrategyController extends BaseController { public class WarnStrategyController extends BaseController
{
@Resource @Resource
private IWarnStrategyService warnStrategyService; private IWarnStrategyService warnStrategyService;
@ -41,7 +39,8 @@ public class WarnStrategyController extends BaseController {
*/ */
@RequiresPermissions("warning:strategy:list") @RequiresPermissions("warning:strategy:list")
@GetMapping("/list") @GetMapping("/list")
public Result<TableDataInfo<WarnStrategy>> list(WarnStrategy warnStrategy) { public Result<TableDataInfo<WarnStrategy>> list(WarnStrategy warnStrategy)
{
startPage(); startPage();
List<WarnStrategy> list = warnStrategyService.selectWarnStrategyList(warnStrategy); List<WarnStrategy> list = warnStrategyService.selectWarnStrategyList(warnStrategy);
return getDataTable(list); return getDataTable(list);
@ -52,7 +51,8 @@ public class WarnStrategyController extends BaseController {
*/ */
@RequiresPermissions("warning:strategy:export") @RequiresPermissions("warning:strategy:export")
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, WarnStrategy warnStrategy) { public void export(HttpServletResponse response, WarnStrategy warnStrategy)
{
List<WarnStrategy> list = warnStrategyService.selectWarnStrategyList(warnStrategy); List<WarnStrategy> list = warnStrategyService.selectWarnStrategyList(warnStrategy);
ExcelUtil<WarnStrategy> util = new ExcelUtil<WarnStrategy>(WarnStrategy.class); ExcelUtil<WarnStrategy> util = new ExcelUtil<WarnStrategy>(WarnStrategy.class);
util.exportExcel(response, list, "预警策略数据"); util.exportExcel(response, list, "预警策略数据");
@ -63,7 +63,8 @@ public class WarnStrategyController extends BaseController {
*/ */
@RequiresPermissions("warning:strategy:query") @RequiresPermissions("warning:strategy:query")
@GetMapping(value = "/{id}") @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)); return success(warnStrategyService.selectWarnStrategyById(id));
} }
@ -73,7 +74,8 @@ public class WarnStrategyController extends BaseController {
@RequiresPermissions("warning:strategy:add") @RequiresPermissions("warning:strategy:add")
@PostMapping @PostMapping
public Result<Integer> add( public Result<Integer> add(
@Validated @RequestBody WarnStrategy warnStrategy) { @Validated @RequestBody WarnStrategy warnStrategy)
{
if (warnStrategyService.checkIdUnique(warnStrategy)) { if (warnStrategyService.checkIdUnique(warnStrategy)) {
return error("新增 预警策略 '" + warnStrategy + "'失败,预警策略已存在"); return error("新增 预警策略 '" + warnStrategy + "'失败,预警策略已存在");
} }
@ -86,7 +88,8 @@ public class WarnStrategyController extends BaseController {
@RequiresPermissions("warning:strategy:edit") @RequiresPermissions("warning:strategy:edit")
@PutMapping @PutMapping
public Result<Integer> edit( public Result<Integer> edit(
@Validated @RequestBody WarnStrategy warnStrategy) { @Validated @RequestBody WarnStrategy warnStrategy)
{
if (!warnStrategyService.checkIdUnique(warnStrategy)) { if (!warnStrategyService.checkIdUnique(warnStrategy)) {
return error("修改 预警策略 '" + warnStrategy + "'失败,预警策略不存在"); return error("修改 预警策略 '" + warnStrategy + "'失败,预警策略不存在");
} }
@ -98,7 +101,8 @@ public class WarnStrategyController extends BaseController {
*/ */
@RequiresPermissions("warning:strategy:remove") @RequiresPermissions("warning:strategy:remove")
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
public Result<Integer> remove(@PathVariable("ids") Long[] ids) { public Result<Integer> remove(@PathVariable("ids") Long[] ids)
{
warnStrategyService.removeBatchByIds(Arrays.asList(ids)); warnStrategyService.removeBatchByIds(Arrays.asList(ids));
return success(); return success();
} }

View File

@ -3,8 +3,6 @@ package com.muyu.warning.mapper;
import com.github.yulichang.base.MPJBaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import com.muyu.warning.domain.WarnRule; import com.muyu.warning.domain.WarnRule;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; 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; import org.apache.ibatis.annotations.Mapper;
/** /**
@ -14,6 +12,6 @@ import org.apache.ibatis.annotations.Mapper;
* @date 2024-09-20 * @date 2024-09-20
*/ */
@Mapper @Mapper
public interface WarnRuleMapper extends BaseMapper<WarnRuleDTO> { public interface WarnRuleMapper extends BaseMapper<WarnRule> {
} }

View File

@ -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);
}

View File

@ -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);
}

View File

@ -1,39 +1,39 @@
package com.muyu.warning.service; 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 java.util.List;
import com.github.yulichang.base.MPJBaseService;
import com.muyu.warning.domain.WarnRule;
import com.baomidou.mybatisplus.extension.service.IService;
/** /**
* Service * Service
* *
* @author muyu * @author muyu
* @date 2024-09-20 * @date 2024-09-20
*/ */
public interface IWarnRuleService extends IService<WarnRuleDTO> { public interface IWarnRuleService extends IService<WarnRule> {
/** /**
* *
* *
* @param id * @param id
* @return * @return
*/ */
public WarnRuleDTO selectWarnRuleById(Long id); public WarnRule selectWarnRuleById(Long id);
/** /**
* *
* *
* @param warnRuleDTO * @param warnRule
* @return * @return
*/ */
public List<WarnRuleDTO> selectWarnRuleList(WarnRuleDTO warnRuleDTO); public List<WarnRule> selectWarnRuleList(WarnRule warnRule);
/** /**
* id * id
* @param warnRuleDTO * @param warnRule
* @return * @return
*/ */
Boolean checkIdUnique(WarnRuleDTO warnRuleDTO); Boolean checkIdUnique(WarnRule warnRule);
} }

View File

@ -1,18 +1,23 @@
package com.muyu.warning.service.impl; package com.muyu.warning.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.base.MPJBaseServiceImpl; 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.WarnRuleDTO;
import com.muyu.warning.domain.WarnStrategy;
import com.muyu.warning.mapper.WarnRuleMapper; import com.muyu.warning.mapper.WarnRuleMapper;
import com.muyu.warning.service.IWarnRuleService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; 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 org.springframework.util.Assert;
import java.util.List;
/** /**
* Service * Service
* *
@ -21,9 +26,10 @@ import java.util.List;
*/ */
@Service @Service
public class WarnRuleServiceImpl public class WarnRuleServiceImpl
extends ServiceImpl<WarnRuleMapper, WarnRuleDTO> extends ServiceImpl<WarnRuleMapper, WarnRule>
implements IWarnRuleService { implements IWarnRuleService {
@Autowired
private WarnRuleMapper warnRuleMapper;
/** /**
* *
@ -32,10 +38,10 @@ public class WarnRuleServiceImpl
* @return * @return
*/ */
@Override @Override
public WarnRuleDTO selectWarnRuleById(Long id) { public WarnRule selectWarnRuleById(Long id) {
LambdaQueryWrapper<WarnRuleDTO> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<WarnRule> queryWrapper = new LambdaQueryWrapper<>();
Assert.notNull(id, "id不可为空"); Assert.notNull(id, "id不可为空");
queryWrapper.eq(WarnRuleDTO::getId, id); queryWrapper.eq(WarnRule::getId, id);
return this.getOne(queryWrapper); return this.getOne(queryWrapper);
} }
@ -43,65 +49,44 @@ public class WarnRuleServiceImpl
/** /**
* *
* *
* @param warnRuleDTO * @param warnRule
* @return * @return
*/ */
@Override @Override
public List<WarnRuleDTO> selectWarnRuleList(WarnRuleDTO warnRuleDTO) { public List<WarnRule> selectWarnRuleList(WarnRule warnRule) {
// MPJLambdaWrapper<WarnRule> queryWrapper = new MPJLambdaWrapper<WarnRule>() LambdaQueryWrapper<WarnRule> queryWrapper = new LambdaQueryWrapper<>();
// .selectAll(WarnRule.class) if (StringUtils.isNotEmpty(warnRule.getRuleName())) {
// .select(WarnStrategy::getStrategyName) queryWrapper.like(WarnRule::getRuleName, warnRule.getRuleName());
// .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());
} }
if (StringUtils.isNotNull(warnRuleDTO.getMsgTypeId())) { if (StringUtils.isNotNull(warnRule.getMsgTypeId())) {
queryWrapper.eq(WarnRuleDTO::getMsgTypeId, warnRuleDTO.getMsgTypeId()); queryWrapper.eq(WarnRule::getMsgTypeId, warnRule.getMsgTypeId());
} }
if (StringUtils.isNotNull(warnRuleDTO.getSlideTime())) { if (StringUtils.isNotNull(warnRule.getSlideTime())) {
queryWrapper.eq(WarnRuleDTO::getSlideTime, warnRuleDTO.getSlideTime()); queryWrapper.eq(WarnRule::getSlideTime, warnRule.getSlideTime());
} }
if (StringUtils.isNotNull(warnRuleDTO.getSlideFrequency())) { if (StringUtils.isNotNull(warnRule.getSlideFrequency())) {
queryWrapper.eq(WarnRuleDTO::getSlideFrequency, warnRuleDTO.getSlideFrequency()); queryWrapper.eq(WarnRule::getSlideFrequency, warnRule.getSlideFrequency());
} }
if (StringUtils.isNotNull(warnRuleDTO.getMaxValue())) { if (StringUtils.isNotNull(warnRule.getMaxValue())) {
queryWrapper.eq(WarnRuleDTO::getMaxValue, warnRuleDTO.getMaxValue()); queryWrapper.eq(WarnRule::getMaxValue, warnRule.getMaxValue());
} }
if (StringUtils.isNotNull(warnRuleDTO.getMinValue())) { if (StringUtils.isNotNull(warnRule.getMinValue())) {
queryWrapper.eq(WarnRuleDTO::getMinValue, warnRuleDTO.getMinValue()); queryWrapper.eq(WarnRule::getMinValue, warnRule.getMinValue());
} }
return this.list(queryWrapper); return this.list(queryWrapper);
} }
/** /**
* *
* *
* @param warnRuleDTO * @param warnRule
* @return * @return
*/ */
@Override @Override
public Boolean checkIdUnique(WarnRuleDTO warnRuleDTO) { public Boolean checkIdUnique(WarnRule warnRule) {
LambdaQueryWrapper<WarnRuleDTO> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<WarnRule> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(WarnRuleDTO::getId, warnRuleDTO.getId()); queryWrapper.eq(WarnRule::getId, warnRule.getId());
return this.count(queryWrapper) > 0; return this.count(queryWrapper) > 0;
} }

View File

@ -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;
}
}

View File

@ -4,10 +4,10 @@ server:
# nacos线上地址 # nacos线上地址
nacos: nacos:
addr: 127.0.0.1:8848 addr: 47.116.173.119:8848
user-name: nacos user-name: nacos
password: nacos password: nacos
namespace: one namespace: one-saas
# Spring # Spring
spring: spring:

View File

@ -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>

View File

@ -4,7 +4,7 @@ server:
# nacos线上地址 # nacos线上地址
nacos: nacos:
addr: 127.0.0.1:8848 addr: 47.116.173.119:8848
user-name: nacos user-name: nacos
password: nacos password: nacos
namespace: one-saas namespace: one-saas