From 53bab33a665a9b22ee6912b5b95dbc019e86e298 Mon Sep 17 00:00:00 2001 From: SuiXxx <1752599835@qq.com> Date: Sat, 21 Sep 2024 11:52:56 +0800 Subject: [PATCH] =?UTF-8?q?feat():=E6=8C=87=E6=A0=87=E9=A2=84=E8=AD=A6?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/muyu/domain/CarType.java | 3 +- .../src/main/java/com/muyu/domain/SysCar.java | 13 +-- .../main/java/com/muyu/domain/SysCarLog.java | 4 +- .../java/com/muyu/domain/req/SysCarReq.java | 3 + cloud-modules/cloud-modules-warn/pom.xml | 109 ++++++++++++++++++ .../java/com/muyu/WarnCarApplication.java | 15 +++ .../muyu/controller/WarnLogsController.java | 66 +++++++++++ .../muyu/controller/WarnRuleController.java | 84 ++++++++++++++ .../controller/WarnStrategyController.java | 94 +++++++++++++++ .../main/java/com/muyu/domain/WarnLogs.java | 73 ++++++++++++ .../main/java/com/muyu/domain/WarnRule.java | 60 ++++++++++ .../java/com/muyu/domain/WarnStrategy.java | 42 +++++++ .../com/muyu/domain/req/WarnStrategyReq.java | 39 +++++++ .../java/com/muyu/mapper/WarnLogsMapper.java | 17 +++ .../java/com/muyu/mapper/WarnRuleMapper.java | 17 +++ .../com/muyu/mapper/WarnStrategyMapper.java | 16 +++ .../com/muyu/service/WarnLogsService.java | 36 ++++++ .../com/muyu/service/WarnRuleService.java | 42 +++++++ .../com/muyu/service/WarnStrategyService.java | 43 +++++++ .../service/impl/WarnLogsServiceImpl.java | 63 ++++++++++ .../service/impl/WarnRuleServiceImpl.java | 65 +++++++++++ .../service/impl/WarnStrategyServiceImpl.java | 85 ++++++++++++++ .../src/main/resources/logback/dev.xml | 74 ++++++++++++ .../src/main/resources/logback/prod.xml | 81 +++++++++++++ .../src/main/resources/logback/test.xml | 81 +++++++++++++ cloud-modules/pom.xml | 1 + 26 files changed, 1213 insertions(+), 13 deletions(-) create mode 100644 cloud-modules/cloud-modules-warn/pom.xml create mode 100644 cloud-modules/cloud-modules-warn/src/main/java/com/muyu/WarnCarApplication.java create mode 100644 cloud-modules/cloud-modules-warn/src/main/java/com/muyu/controller/WarnLogsController.java create mode 100644 cloud-modules/cloud-modules-warn/src/main/java/com/muyu/controller/WarnRuleController.java create mode 100644 cloud-modules/cloud-modules-warn/src/main/java/com/muyu/controller/WarnStrategyController.java create mode 100644 cloud-modules/cloud-modules-warn/src/main/java/com/muyu/domain/WarnLogs.java create mode 100644 cloud-modules/cloud-modules-warn/src/main/java/com/muyu/domain/WarnRule.java create mode 100644 cloud-modules/cloud-modules-warn/src/main/java/com/muyu/domain/WarnStrategy.java create mode 100644 cloud-modules/cloud-modules-warn/src/main/java/com/muyu/domain/req/WarnStrategyReq.java create mode 100644 cloud-modules/cloud-modules-warn/src/main/java/com/muyu/mapper/WarnLogsMapper.java create mode 100644 cloud-modules/cloud-modules-warn/src/main/java/com/muyu/mapper/WarnRuleMapper.java create mode 100644 cloud-modules/cloud-modules-warn/src/main/java/com/muyu/mapper/WarnStrategyMapper.java create mode 100644 cloud-modules/cloud-modules-warn/src/main/java/com/muyu/service/WarnLogsService.java create mode 100644 cloud-modules/cloud-modules-warn/src/main/java/com/muyu/service/WarnRuleService.java create mode 100644 cloud-modules/cloud-modules-warn/src/main/java/com/muyu/service/WarnStrategyService.java create mode 100644 cloud-modules/cloud-modules-warn/src/main/java/com/muyu/service/impl/WarnLogsServiceImpl.java create mode 100644 cloud-modules/cloud-modules-warn/src/main/java/com/muyu/service/impl/WarnRuleServiceImpl.java create mode 100644 cloud-modules/cloud-modules-warn/src/main/java/com/muyu/service/impl/WarnStrategyServiceImpl.java create mode 100644 cloud-modules/cloud-modules-warn/src/main/resources/logback/dev.xml create mode 100644 cloud-modules/cloud-modules-warn/src/main/resources/logback/prod.xml create mode 100644 cloud-modules/cloud-modules-warn/src/main/resources/logback/test.xml diff --git a/cloud-modules/cloud-modules-car/src/main/java/com/muyu/domain/CarType.java b/cloud-modules/cloud-modules-car/src/main/java/com/muyu/domain/CarType.java index 11989b3..46c9ec6 100644 --- a/cloud-modules/cloud-modules-car/src/main/java/com/muyu/domain/CarType.java +++ b/cloud-modules/cloud-modules-car/src/main/java/com/muyu/domain/CarType.java @@ -1,5 +1,6 @@ package com.muyu.domain; +import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.AllArgsConstructor; @@ -11,7 +12,7 @@ import lombok.NoArgsConstructor; @NoArgsConstructor @TableName(value = "car_type",autoResultMap = true) public class CarType { - @TableId(value = "id") + @TableId(value = "id",type = IdType.AUTO) private Long id; private String typeName; private Long messageId; diff --git a/cloud-modules/cloud-modules-car/src/main/java/com/muyu/domain/SysCar.java b/cloud-modules/cloud-modules-car/src/main/java/com/muyu/domain/SysCar.java index 573d321..e54ea7d 100644 --- a/cloud-modules/cloud-modules-car/src/main/java/com/muyu/domain/SysCar.java +++ b/cloud-modules/cloud-modules-car/src/main/java/com/muyu/domain/SysCar.java @@ -1,5 +1,6 @@ package com.muyu.domain; +import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.muyu.common.core.web.domain.BaseEntity; @@ -14,7 +15,7 @@ import lombok.NoArgsConstructor; @EqualsAndHashCode(callSuper = true) @TableName(value = "sys_car",autoResultMap = true) public class SysCar extends BaseEntity { - @TableId(value = "id") + @TableId(value = "id",type = IdType.AUTO) private Long id; private String carVin; private Long carTypeId; @@ -25,14 +26,4 @@ public class SysCar extends BaseEntity { private String carBatteryManufacturer; private String carBatteryModel; - - - - - - - - - - } diff --git a/cloud-modules/cloud-modules-car/src/main/java/com/muyu/domain/SysCarLog.java b/cloud-modules/cloud-modules-car/src/main/java/com/muyu/domain/SysCarLog.java index 62d4dc2..dfc2d7f 100644 --- a/cloud-modules/cloud-modules-car/src/main/java/com/muyu/domain/SysCarLog.java +++ b/cloud-modules/cloud-modules-car/src/main/java/com/muyu/domain/SysCarLog.java @@ -1,5 +1,7 @@ package com.muyu.domain; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.AllArgsConstructor; @@ -13,7 +15,7 @@ import java.util.Date; @NoArgsConstructor @TableName(value = "sys_car_log",autoResultMap = true) public class SysCarLog { - + @TableId(value = "id",type = IdType.AUTO) private String id; private String carVin; @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") diff --git a/cloud-modules/cloud-modules-car/src/main/java/com/muyu/domain/req/SysCarReq.java b/cloud-modules/cloud-modules-car/src/main/java/com/muyu/domain/req/SysCarReq.java index 46acd38..c43efab 100644 --- a/cloud-modules/cloud-modules-car/src/main/java/com/muyu/domain/req/SysCarReq.java +++ b/cloud-modules/cloud-modules-car/src/main/java/com/muyu/domain/req/SysCarReq.java @@ -11,8 +11,11 @@ import lombok.NoArgsConstructor; @NoArgsConstructor public class SysCarReq { private String carVin; + private String state; private String carMotorManufacturer; private String carMotorModel; private String carBatteryManufacturer; private String carBatteryModel; + + } diff --git a/cloud-modules/cloud-modules-warn/pom.xml b/cloud-modules/cloud-modules-warn/pom.xml new file mode 100644 index 0000000..fbe5d4b --- /dev/null +++ b/cloud-modules/cloud-modules-warn/pom.xml @@ -0,0 +1,109 @@ + + + 4.0.0 + + com.muyu + cloud-modules + 3.6.3 + + + cloud-modules-warn + + + 17 + 17 + UTF-8 + + + + + + + org.springframework.cloud + spring-cloud-starter-bootstrap + 4.1.2 + + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-sentinel + + + + + org.springframework.boot + spring-boot-starter-actuator + + + + + com.mysql + mysql-connector-j + + + + + com.muyu + cloud-common-datasource + + + + + com.muyu + cloud-common-datascope + + + + + com.muyu + cloud-common-log + + + + + com.muyu + cloud-common-api-doc + + + + + com.muyu + cloud-common-rabbit + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + + + diff --git a/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/WarnCarApplication.java b/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/WarnCarApplication.java new file mode 100644 index 0000000..f61ce30 --- /dev/null +++ b/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/WarnCarApplication.java @@ -0,0 +1,15 @@ +package com.muyu; + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.openfeign.EnableFeignClients; + +@SpringBootApplication +@EnableFeignClients +@MapperScan(value = "com.muyu.mapper") +public class WarnCarApplication { + public static void main(String[] args) { + SpringApplication.run(WarnCarApplication.class,args); + } +} diff --git a/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/controller/WarnLogsController.java b/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/controller/WarnLogsController.java new file mode 100644 index 0000000..2693484 --- /dev/null +++ b/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/controller/WarnLogsController.java @@ -0,0 +1,66 @@ +package com.muyu.controller; + + +import java.util.List; +import com.muyu.service.WarnLogsService; + + +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.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.muyu.common.security.annotation.RequiresPermissions; +import com.muyu.domain.WarnLogs ; +import com.muyu.common.core.web.controller.BaseController; +import com.muyu.common.core.domain.Result; +import com.muyu.common.core.utils.poi.ExcelUtil; +import org.springframework.validation.annotation.Validated; +import com.muyu.common.core.web.page.TableDataInfo; + +/** + * 预警日志Controller + * + * @author sx + * @date 2024-09-20 + */ +@RestController +@RequestMapping("/logs") +public class WarnLogsController extends BaseController +{ + @Autowired + private WarnLogsService warnLogsService; + + /** + * 查询预警日志列表 + */ + @GetMapping("/list") + public Result> list(@RequestBody WarnLogs warnLogs) + { + List list = warnLogsService.selectWarnLogsList(warnLogs); + return getDataTable(list); + } + + + /** + * 获取预警日志详细信息 + */ + @GetMapping(value = "selectWarnLogsById/{id}") + public Result> selectWarnLogsById(@PathVariable("id") Long id) + { + return success(warnLogsService.selectWarnLogsById(id)); + } + + /** + * 新增预警日志 + */ + @PostMapping("/addWarnLogs") + public Result addWarnLogs(@RequestBody WarnLogs warnLogs) + { + int i = warnLogsService.addWarnLogs(warnLogs); + return i>0?Result.success():Result.error(); + } + +} diff --git a/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/controller/WarnRuleController.java b/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/controller/WarnRuleController.java new file mode 100644 index 0000000..722606d --- /dev/null +++ b/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/controller/WarnRuleController.java @@ -0,0 +1,84 @@ +package com.muyu.controller; + +import java.util.Arrays; +import java.util.List; +import javax.annotation.Resource; + +import com.muyu.service.WarnRuleService; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.muyu.common.core.web.controller.BaseController; +import com.muyu.common.core.domain.Result; +import com.muyu.domain.WarnRule; + +/** + * 预警规则Controller + * + * @author sx + * @date 2024-09-20 + */ +@RestController +@RequestMapping("/rule") +public class WarnRuleController extends BaseController +{ + @Resource + private WarnRuleService warnRuleService; + + /** + * 查询预警规则列表 + */ + @GetMapping("/list") + public Result list(@RequestBody WarnRule warnRule) + { + List list = warnRuleService.selectWarnRuleList(warnRule); + return getDataTable(list); + } + + /** + * 获取预警规则详细信息 + */ + + @GetMapping(value = "selectById/{id}") + public Result> selectById(@PathVariable("id") Long id) + { + return success(warnRuleService.selectWarnRuleById(id)); + } + + /** + * 新增预警规则 + */ + + @PostMapping("/addWarnRule") + public Result addWarnRule(@RequestBody WarnRule warnRule) + { + int i = warnRuleService.addWarnRule(warnRule); + return i>0?Result.success():Result.error(); + } + + /** + * 修改预警规则 + */ + + @PutMapping + public Result updWarnRule(@RequestBody WarnRule warnRule) + { + int i = warnRuleService.updWarnRule(warnRule); + return i>0?Result.success():Result.error(); + } + + /** + * 删除预警规则 + */ + @DeleteMapping("/{ids}") + public Result remove(@PathVariable("ids") Long[] ids) + { + warnRuleService.removeBatchByIds(Arrays.asList(ids)); + return success(); + } +} diff --git a/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/controller/WarnStrategyController.java b/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/controller/WarnStrategyController.java new file mode 100644 index 0000000..95ff34c --- /dev/null +++ b/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/controller/WarnStrategyController.java @@ -0,0 +1,94 @@ +package com.muyu.controller; + +import java.util.Arrays; +import java.util.List; + +import com.muyu.domain.req.WarnStrategyReq; +import com.muyu.service.WarnStrategyService; +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; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.muyu.common.security.annotation.RequiresPermissions; +import com.muyu.domain.WarnStrategy; +import com.muyu.common.core.web.controller.BaseController; +import com.muyu.common.core.domain.Result; +import org.springframework.validation.annotation.Validated; +import com.muyu.common.core.web.page.TableDataInfo; + +/** + * 预警策略Controller + * + * @author sx + * @date 2024-09-20 + */ +@RestController +@RequestMapping("/strategy") +public class WarnStrategyController extends BaseController +{ + @Resource + private WarnStrategyService warnStrategyService; + + /** + * 查询预警策略列表 + */ + @GetMapping("/list") + public Result> list(@RequestBody WarnStrategyReq warnStrategyReq) + { + startPage(); + List list = warnStrategyService.selectWarnStrategyList(warnStrategyReq); + return getDataTable(list); + } + + + /** + * 获取预警策略详细信息 + */ + @GetMapping( "selectById/{id}") + public Result selectById(@PathVariable("id") Long id) + { + return success(warnStrategyService.selectWarnStrategyById(id)); + } + + /** + * 新增预警策略 + */ + @PostMapping("/addWarnStrategy") + public Result addWarnStrategy(@RequestBody WarnStrategy warnStrategy) + { + Integer i = warnStrategyService.addWarnStrategy(warnStrategy); + if (i>0){ + return Result.success("修改成功"); + } + return Result.error("修改失败"); + } + + /** + * 修改预警策略 + */ + @PostMapping("/updWarnStrategy") + public Result updWarnStrategy(@RequestBody WarnStrategy warnStrategy) + { + Integer i = warnStrategyService.updWarnStrategy(warnStrategy); + if (i>0){ + return Result.success("修改成功"); + } + return Result.error("修改失败"); + } + + /** + * 删除预警策略 + */ + @DeleteMapping("/{ids}") + public Result remove(@PathVariable("ids") Long[] ids) + { + warnStrategyService.removeBatchByIds(Arrays.asList(ids)); + return success(); + } +} diff --git a/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/domain/WarnLogs.java b/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/domain/WarnLogs.java new file mode 100644 index 0000000..3196667 --- /dev/null +++ b/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/domain/WarnLogs.java @@ -0,0 +1,73 @@ +package com.muyu.domain; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.muyu.common.core.annotation.Excel; +import com.muyu.common.core.web.domain.BaseEntity; +import lombok.*; +import lombok.experimental.SuperBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; + +/** + * 预警日志对象 warn_logs + * + * @author muyu + * @date 2024-09-20 + */ + +@Data +@NoArgsConstructor +@AllArgsConstructor +@TableName("warn_logs") +public class WarnLogs{ + private static final long serialVersionUID = 1L; + + /** 预警日志id */ + @TableId( type = IdType.AUTO) + private Long id; + + /** 车辆vin码 */ + @Excel(name = "车辆vin码") + private String vin; + + /** 规则id */ + @Excel(name = "规则id") + private Long warnRuleId; + + /** 开始时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date startTime; + + /** 结束时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "结束时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date endTime; + + /** 最大值 */ + @Excel(name = "最大值") + private Long maxValue; + + /** 最小值 */ + @Excel(name = "最小值") + private Long minValue; + + /** 平均值 */ + @Excel(name = "平均值") + private Long avgValue; + + /** 中位数 */ + @Excel(name = "中位数") + private Long medianValue; + + /** 是否发送预警 */ + @Excel(name = "是否发送预警") + private Long status; + + + +} diff --git a/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/domain/WarnRule.java b/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/domain/WarnRule.java new file mode 100644 index 0000000..cd16342 --- /dev/null +++ b/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/domain/WarnRule.java @@ -0,0 +1,60 @@ +package com.muyu.domain; + +import com.muyu.common.core.annotation.Excel; +import com.muyu.common.core.web.domain.BaseEntity; +import lombok.*; +import lombok.experimental.SuperBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; + +/** + * 预警规则对象 warn_rule + * + * @author muyu + * @date 2024-09-20 + */ + +@Data +@NoArgsConstructor +@AllArgsConstructor +@TableName("warn_rule") +public class WarnRule { + private static final long serialVersionUID = 1L; + + /** 规则id */ + @TableId( type = IdType.AUTO) + private Long id; + + /** 规则名称 */ + @Excel(name = "规则名称") + private String ruleName; + + /** 策略id */ + @Excel(name = "策略id") + private Long strategyId; + + /** 报文数据类型id */ + @Excel(name = "报文数据类型id") + private Long msgTypeId; + + /** 滑窗时间 */ + @Excel(name = "滑窗时间") + private Long slideTime; + + /** 滑窗频率 */ + @Excel(name = "滑窗频率") + private Long slideFrequency; + + /** 最大值 */ + @Excel(name = "最大值") + private Long maxValue; + + /** 最小值 */ + @Excel(name = "最小值") + private Long minValue; + + +} diff --git a/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/domain/WarnStrategy.java b/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/domain/WarnStrategy.java new file mode 100644 index 0000000..c0f56bd --- /dev/null +++ b/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/domain/WarnStrategy.java @@ -0,0 +1,42 @@ +package com.muyu.domain; + +import com.muyu.common.core.annotation.Excel; +import lombok.*; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.IdType; + +/** + * 预警策略对象 warn_strategy + * + * @author muyu + * @date 2024-09-20 + */ + +@Data +@NoArgsConstructor +@AllArgsConstructor +@TableName("warn_strategy") +public class WarnStrategy { + private static final long serialVersionUID = 1L; + + /** 策略id */ + @TableId( type = IdType.AUTO) + private Long id; + + /** 车辆类型id */ + @Excel(name = "车辆类型id") + private Long carTypeId; + + /** 策略名称 */ + @Excel(name = "策略名称") + private String strategyName; + + /** 报文模版id */ + @Excel(name = "报文模版id") + private Long msgId; + + + + +} diff --git a/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/domain/req/WarnStrategyReq.java b/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/domain/req/WarnStrategyReq.java new file mode 100644 index 0000000..f753d52 --- /dev/null +++ b/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/domain/req/WarnStrategyReq.java @@ -0,0 +1,39 @@ +package com.muyu.domain.req; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.muyu.common.core.annotation.Excel; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 预警策略对象 warn_strategy + * + * @author muyu + * @date 2024-09-20 + */ + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class WarnStrategyReq { + private static final long serialVersionUID = 1L; + + /** 车辆类型id */ + @Excel(name = "车辆类型id") + private Long carTypeId; + + /** 策略名称 */ + @Excel(name = "策略名称") + private String strategyName; + + /** 报文模版id */ + @Excel(name = "报文模版id") + private Long msgId; + + + + +} diff --git a/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/mapper/WarnLogsMapper.java b/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/mapper/WarnLogsMapper.java new file mode 100644 index 0000000..86e66ab --- /dev/null +++ b/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/mapper/WarnLogsMapper.java @@ -0,0 +1,17 @@ +package com.muyu.mapper; + +import java.util.List; +import com.muyu.domain.WarnLogs ; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + * 预警日志Mapper接口 + * + * @author muyu + * @date 2024-09-20 + */ +@Mapper +public interface WarnLogsMapper extends BaseMapper{ + +} diff --git a/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/mapper/WarnRuleMapper.java b/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/mapper/WarnRuleMapper.java new file mode 100644 index 0000000..d739cff --- /dev/null +++ b/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/mapper/WarnRuleMapper.java @@ -0,0 +1,17 @@ +package com.muyu.mapper; + +import java.util.List; +import com.muyu.domain.WarnRule ; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + * 预警规则Mapper接口 + * + * @author muyu + * @date 2024-09-20 + */ +@Mapper +public interface WarnRuleMapper extends BaseMapper{ + +} diff --git a/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/mapper/WarnStrategyMapper.java b/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/mapper/WarnStrategyMapper.java new file mode 100644 index 0000000..152a315 --- /dev/null +++ b/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/mapper/WarnStrategyMapper.java @@ -0,0 +1,16 @@ +package com.muyu.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.muyu.domain.WarnStrategy; +import org.apache.ibatis.annotations.Mapper; + +/** + * 预警策略Mapper接口 + * + * @author muyu + * @date 2024-09-20 + */ +@Mapper +public interface WarnStrategyMapper extends BaseMapper { + +} diff --git a/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/service/WarnLogsService.java b/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/service/WarnLogsService.java new file mode 100644 index 0000000..f25601e --- /dev/null +++ b/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/service/WarnLogsService.java @@ -0,0 +1,36 @@ +package com.muyu.service; + +import java.util.List; +import com.muyu.domain.WarnLogs ; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * 预警日志Service接口 + * + * @author muyu + * @date 2024-09-20 + */ +public interface WarnLogsService extends IService { + /** + * 精确查询预警日志 + * + * @param id 预警日志主键 + * @return 预警日志 + */ + public WarnLogs selectWarnLogsById(Long id); + + /** + * 查询预警日志列表 + * + * @param warnLogs 预警日志 + * @return 预警日志集合 + */ + public List selectWarnLogsList(WarnLogs warnLogs); + + + /** + * 添加 + */ + Integer addWarnLogs(WarnLogs warnLogs); + +} diff --git a/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/service/WarnRuleService.java b/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/service/WarnRuleService.java new file mode 100644 index 0000000..da252e6 --- /dev/null +++ b/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/service/WarnRuleService.java @@ -0,0 +1,42 @@ +package com.muyu.service; + +import java.util.List; +import com.muyu.domain.WarnRule; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * 预警规则Service接口 + * + * @author muyu + * @date 2024-09-20 + */ +public interface WarnRuleService extends IService { + /** + * 精确查询预警规则 + * + * @param id 预警规则主键 + * @return 预警规则 + */ + public WarnRule selectWarnRuleById(Long id); + + /** + * 查询预警规则列表 + * + * @param warnRule 预警规则 + * @return 预警规则集合 + */ + public List selectWarnRuleList(WarnRule warnRule); + + + /** + * 添加 + */ + Integer addWarnRule(WarnRule warnRule); + + + /** + * 修改 + */ + Integer updWarnRule(WarnRule warnRule); + +} diff --git a/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/service/WarnStrategyService.java b/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/service/WarnStrategyService.java new file mode 100644 index 0000000..a347cf2 --- /dev/null +++ b/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/service/WarnStrategyService.java @@ -0,0 +1,43 @@ +package com.muyu.service; + +import java.util.List; +import com.muyu.domain.WarnStrategy; +import com.baomidou.mybatisplus.extension.service.IService; +import com.muyu.domain.req.WarnStrategyReq; + +/** + * 预警策略Service接口 + * + * @author muyu + * @date 2024-09-20 + */ +public interface WarnStrategyService extends IService { + /** + * 精确查询预警策略 + * + * @param id 预警策略主键 + * @return 预警策略 + */ + public WarnStrategy selectWarnStrategyById(Long id); + + /** + * 查询预警策略列表 + * + * @param warnStrategy 预警策略 + * @return 预警策略集合 + */ + public List selectWarnStrategyList(WarnStrategyReq warnStrategyReq); + + + + /** + * 修改 + */ + Integer updWarnStrategy(WarnStrategy warnStrategy); + + /** + * 添加 + */ + Integer addWarnStrategy(WarnStrategy warnStrategy); + +} diff --git a/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/service/impl/WarnLogsServiceImpl.java b/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/service/impl/WarnLogsServiceImpl.java new file mode 100644 index 0000000..4432f27 --- /dev/null +++ b/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/service/impl/WarnLogsServiceImpl.java @@ -0,0 +1,63 @@ +package com.muyu.service.impl; + +import java.util.List; + +import com.muyu.common.core.utils.StringUtils; +import com.muyu.mapper.WarnLogsMapper; +import com.muyu.service.WarnLogsService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.muyu.domain.WarnLogs ; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.util.Assert; + +/** + * 预警日志Service业务层处理 + * + * @author muyu + * @date 2024-09-20 + */ +@Service +public class WarnLogsServiceImpl + extends ServiceImpl + implements WarnLogsService { + @Autowired + private WarnLogsMapper warnLogsMapper; + + /** + * 精确查询预警日志 + * + * @param id 预警日志主键 + * @return 预警日志 + */ + @Override + public WarnLogs selectWarnLogsById(Long id) + { + return warnLogsMapper.selectById(id); + } + + + /** + * 查询预警日志列表 + * + * @param warnLogs 预警日志 + * @return 预警日志 + */ + @Override + public List selectWarnLogsList(WarnLogs warnLogs) + { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + if (StringUtils.isNotEmpty(warnLogs.getVin())){ + queryWrapper.eq(WarnLogs::getVin, warnLogs.getVin()); + } + return warnLogsMapper.selectList(queryWrapper); + } + + @Override + public Integer addWarnLogs(WarnLogs warnLogs) { + return warnLogsMapper.insert(warnLogs); + } + + +} diff --git a/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/service/impl/WarnRuleServiceImpl.java b/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/service/impl/WarnRuleServiceImpl.java new file mode 100644 index 0000000..8878136 --- /dev/null +++ b/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/service/impl/WarnRuleServiceImpl.java @@ -0,0 +1,65 @@ +package com.muyu.service.impl; + +import java.util.List; + +import com.muyu.mapper.WarnRuleMapper; +import com.muyu.service.WarnRuleService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.muyu.domain.WarnRule ; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.util.Assert; + +/** + * 预警规则Service业务层处理 + * + * @author muyu + * @date 2024-09-20 + */ +@Service +public class WarnRuleServiceImpl + extends ServiceImpl + implements WarnRuleService { + @Autowired + private WarnRuleMapper warnRuleMapper; + + /** + * 精确查询预警规则 + * + * @param id 预警规则主键 + * @return 预警规则 + */ + @Override + public WarnRule selectWarnRuleById(Long id) + { + return warnRuleMapper.selectById(id); + } + + + /** + * 查询预警规则列表 + * + * @param warnRule 预警规则 + * @return 预警规则 + */ + @Override + public List selectWarnRuleList(WarnRule warnRule) + { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + return warnRuleMapper.selectList(queryWrapper); + } + + @Override + public Integer addWarnRule(WarnRule warnRule) { + return warnRuleMapper.insert(warnRule); + } + + @Override + public Integer updWarnRule(WarnRule warnRule) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + return warnRuleMapper.update(queryWrapper); + } + + +} diff --git a/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/service/impl/WarnStrategyServiceImpl.java b/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/service/impl/WarnStrategyServiceImpl.java new file mode 100644 index 0000000..1099c69 --- /dev/null +++ b/cloud-modules/cloud-modules-warn/src/main/java/com/muyu/service/impl/WarnStrategyServiceImpl.java @@ -0,0 +1,85 @@ +package com.muyu.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.muyu.domain.WarnStrategy; + +import com.muyu.domain.req.WarnStrategyReq; +import com.muyu.mapper.WarnLogsMapper; +import com.muyu.mapper.WarnStrategyMapper; +import com.muyu.service.WarnStrategyService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +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业务层处理 + * + * @author muyu + * @date 2024-09-20 + */ +@Service +public class WarnStrategyServiceImpl + extends ServiceImpl + implements WarnStrategyService { + @Autowired + private WarnStrategyMapper warnStrategyMapper; + + /** + * 精确查询预警策略 + * + * @param id 预警策略主键 + * @return 预警策略 + */ + @Override + public WarnStrategy selectWarnStrategyById(Long id) + { + return warnStrategyMapper.selectById(id); + } + + + /** + * 查询预警策略列表 + * + * @param warnStrategyReq 预警策略 + * @return 预警策略 + */ + @Override + public List selectWarnStrategyList(WarnStrategyReq warnStrategyReq) + { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + if (warnStrategyReq.getCarTypeId()!=null){ + queryWrapper.eq(WarnStrategy::getCarTypeId, warnStrategyReq.getCarTypeId()); + } + if (StringUtils.isNotEmpty(warnStrategyReq.getStrategyName())){ + queryWrapper.like(WarnStrategy::getStrategyName, warnStrategyReq.getStrategyName()); + } + if (warnStrategyReq.getMsgId()!=null){ + queryWrapper.eq(WarnStrategy::getMsgId, warnStrategyReq.getMsgId()); + } + return this.list(queryWrapper); + } + + + + /** + * 修改 + */ + public Integer updWarnStrategy(WarnStrategy warnStrategy){ + QueryWrapper wrapper = new QueryWrapper<>(warnStrategy); + return warnStrategyMapper.update(wrapper); + } + + /** + * 添加 + */ + public Integer addWarnStrategy(WarnStrategy warnStrategy){ + return warnStrategyMapper.insert(warnStrategy); + } + + +} diff --git a/cloud-modules/cloud-modules-warn/src/main/resources/logback/dev.xml b/cloud-modules/cloud-modules-warn/src/main/resources/logback/dev.xml new file mode 100644 index 0000000..621579c --- /dev/null +++ b/cloud-modules/cloud-modules-warn/src/main/resources/logback/dev.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + ${log.pattern} + + + + + + ${log.path}/info.log + + + + ${log.path}/info.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + INFO + + ACCEPT + + DENY + + + + + ${log.path}/error.log + + + + ${log.path}/error.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + ERROR + + ACCEPT + + DENY + + + + + + + + + + + + + + + + + + diff --git a/cloud-modules/cloud-modules-warn/src/main/resources/logback/prod.xml b/cloud-modules/cloud-modules-warn/src/main/resources/logback/prod.xml new file mode 100644 index 0000000..2419bf9 --- /dev/null +++ b/cloud-modules/cloud-modules-warn/src/main/resources/logback/prod.xml @@ -0,0 +1,81 @@ + + + + + + + + + + + + ${log.sky.pattern} + + + + + + ${log.path}/info.log + + + + ${log.path}/info.%d{yyyy-MM-dd}.log + + 60 + + + + + INFO + + ACCEPT + + DENY + + + + + ${log.path}/error.log + + + + ${log.path}/error.%d{yyyy-MM-dd}.log + + 60 + + + + + ERROR + + ACCEPT + + DENY + + + + + + + + ${log.sky.pattern} + + + + + + + + + + + + + + + + + + + + diff --git a/cloud-modules/cloud-modules-warn/src/main/resources/logback/test.xml b/cloud-modules/cloud-modules-warn/src/main/resources/logback/test.xml new file mode 100644 index 0000000..2419bf9 --- /dev/null +++ b/cloud-modules/cloud-modules-warn/src/main/resources/logback/test.xml @@ -0,0 +1,81 @@ + + + + + + + + + + + + ${log.sky.pattern} + + + + + + ${log.path}/info.log + + + + ${log.path}/info.%d{yyyy-MM-dd}.log + + 60 + + + + + INFO + + ACCEPT + + DENY + + + + + ${log.path}/error.log + + + + ${log.path}/error.%d{yyyy-MM-dd}.log + + 60 + + + + + ERROR + + ACCEPT + + DENY + + + + + + + + ${log.sky.pattern} + + + + + + + + + + + + + + + + + + + + diff --git a/cloud-modules/pom.xml b/cloud-modules/pom.xml index 4bcfb77..6bdc01f 100644 --- a/cloud-modules/pom.xml +++ b/cloud-modules/pom.xml @@ -16,6 +16,7 @@ cloud-modules-template cloud-modules-fence cloud-car + cloud-modules-warn cloud-modules