feat():预警

dev
SuiXxx 2024-09-22 11:20:14 +08:00
parent e5a5340313
commit cf7c7efddd
20 changed files with 233 additions and 71 deletions

View File

@ -32,7 +32,7 @@ public class SysCarController {
return Result.success(sysCarService.addSysCar(sysCar));
}
@PutMapping("/updateSysCar")
@PostMapping("/updateSysCar")
public Result updateSysCar(@RequestBody SysCar sysCar){
return Result.success(sysCarService.updateSysCar(sysCar));
}

View File

@ -15,6 +15,6 @@ public class CarType {
@TableId(value = "id",type = IdType.AUTO)
private Long id;
private String typeName;
private Long messageId;
private Long templateId;
}

View File

@ -4,6 +4,7 @@ import java.util.Arrays;
import java.util.List;
import javax.annotation.Resource;
import com.muyu.domain.resp.WarnRuleResp;
import com.muyu.service.WarnRuleService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@ -33,11 +34,10 @@ public class WarnRuleController extends BaseController
/**
*
*/
@GetMapping("/list")
public Result list(@RequestBody WarnRule warnRule)
@GetMapping("/selectWarnRuleResplist")
public Result selectWarnRuleResplist()
{
List<WarnRule> list = warnRuleService.selectWarnRuleList(warnRule);
return getDataTable(list);
return Result.success(warnRuleService.selectWarnRuleResplist());
}
/**
@ -65,8 +65,8 @@ public class WarnRuleController extends BaseController
*
*/
@PutMapping
public Result<Integer> updWarnRule(@RequestBody WarnRule warnRule)
@PostMapping("/updWarnRule")
public Result updWarnRule(@RequestBody WarnRule warnRule)
{
int i = warnRuleService.updWarnRule(warnRule);
return i>0?Result.success():Result.error();
@ -76,9 +76,17 @@ public class WarnRuleController extends BaseController
*
*/
@DeleteMapping("/{ids}")
public Result<Integer> remove(@PathVariable("ids") Long[] ids)
public Result remove(@PathVariable("ids") Long[] ids)
{
warnRuleService.removeBatchByIds(Arrays.asList(ids));
return success();
}
//根据策略ID查规则
@GetMapping("/selectListByStrategyId/{strategyId}")
public Result selectListByStrategyId(@PathVariable("strategyId") Long strategyId){
return Result.success(warnRuleService.selectListByStrategyId(strategyId));
}
}

View File

@ -4,6 +4,7 @@ import java.util.Arrays;
import java.util.List;
import com.muyu.domain.req.WarnStrategyReq;
import com.muyu.domain.resp.WarnStrategyResp;
import com.muyu.service.WarnStrategyService;
import jakarta.servlet.http.HttpServletResponse;
import javax.annotation.Resource;
@ -38,12 +39,10 @@ public class WarnStrategyController extends BaseController
/**
*
*/
@GetMapping("/list")
public Result<TableDataInfo<WarnStrategy>> list(@RequestBody WarnStrategyReq warnStrategyReq)
@GetMapping("/selectWarnStrategyList")
public Result selectWarnStrategyList(@RequestBody WarnStrategyReq warnStrategyReq)
{
startPage();
List<WarnStrategy> list = warnStrategyService.selectWarnStrategyList(warnStrategyReq);
return getDataTable(list);
return Result.success(warnStrategyService.selectWarnStrategyList(warnStrategyReq));
}
@ -63,10 +62,7 @@ public class WarnStrategyController extends BaseController
public Result addWarnStrategy(@RequestBody WarnStrategy warnStrategy)
{
Integer i = warnStrategyService.addWarnStrategy(warnStrategy);
if (i>0){
return Result.success("修改成功");
}
return Result.error("修改失败");
return i>0?Result.success():Result.error();
}
/**
@ -76,19 +72,26 @@ public class WarnStrategyController extends BaseController
public Result updWarnStrategy(@RequestBody WarnStrategy warnStrategy)
{
Integer i = warnStrategyService.updWarnStrategy(warnStrategy);
if (i>0){
return Result.success("修改成功");
}
return Result.error("修改失败");
return i>0?Result.success():Result.error();
}
/**
*
*/
@DeleteMapping("/{ids}")
public Result remove(@PathVariable("ids") Long[] ids)
@DeleteMapping("deleteWarnStrategy/{id}")
public Result deleteWarnStrategy(@PathVariable("id") Long id)
{
warnStrategyService.removeBatchByIds(Arrays.asList(ids));
return success();
Integer i = warnStrategyService.deleteWarnStrategy(id);
return i>0?Result.success():Result.error();
}
/**
* ID
*/
@GetMapping("/selectListByCarType/{carTypeId}")
public Result selectListByCarType(@PathVariable("carTypeId") Long carTypeId) {
return Result.success(warnStrategyService.selectListByCarType(carTypeId));
}
}

View File

@ -1,16 +1,15 @@
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.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.muyu.common.core.annotation.Excel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* warn_logs

View File

@ -1,14 +1,12 @@
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.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.muyu.common.core.annotation.Excel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* warn_rule

View File

@ -1,10 +1,12 @@
package com.muyu.domain;
import com.muyu.common.core.annotation.Excel;
import lombok.*;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.muyu.common.core.annotation.Excel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* warn_strategy
@ -34,7 +36,7 @@ public class WarnStrategy {
/** 报文模版id */
@Excel(name = "报文模版id")
private Long msgId;
private Long templateId;

View File

@ -1,8 +1,5 @@
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;
@ -31,7 +28,7 @@ public class WarnStrategyReq {
/** 报文模版id */
@Excel(name = "报文模版id")
private Long msgId;
private Long templateId;

View File

@ -0,0 +1,17 @@
package com.muyu.domain.resp;
import com.muyu.common.core.annotation.Excel;
import com.muyu.domain.WarnLogs;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class WarnLogsResq extends WarnLogs {
/** 规则名称 */
@Excel(name = "规则名称")
private String ruleName;
}

View File

@ -0,0 +1,15 @@
package com.muyu.domain.resp;
import com.muyu.common.core.annotation.Excel;
import com.muyu.domain.WarnRule;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class WarnRuleResp extends WarnRule {
@Excel(name = "策略名称")
private String strategyName;
}

View File

@ -0,0 +1,24 @@
package com.muyu.domain.resp;
import com.muyu.common.core.annotation.Excel;
import com.muyu.domain.WarnStrategy;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class WarnStrategyResp extends WarnStrategy {
/** 车辆类型名称 */
private String typeName;
/** 策略名称 */
@Excel(name = "策略名称")
private String strategyName;
/** 报文模版id */
@Excel(name = "报文模版名称")
private String templateName;
}

View File

@ -3,7 +3,9 @@ package com.muyu.mapper;
import java.util.List;
import com.muyu.domain.WarnRule ;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.domain.resp.WarnRuleResp;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* Mapper
@ -14,4 +16,10 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface WarnRuleMapper extends BaseMapper<WarnRule>{
//规则列表
List<WarnRuleResp> selectWarnRuleResplist();
//根据策略ID查规则
List<WarnRuleResp> selectListByStrategyId(@Param("strategyId")Long strategyId);
}

View File

@ -2,7 +2,12 @@ package com.muyu.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.domain.WarnStrategy;
import com.muyu.domain.req.WarnStrategyReq;
import com.muyu.domain.resp.WarnStrategyResp;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* Mapper
@ -12,5 +17,10 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface WarnStrategyMapper extends BaseMapper<WarnStrategy> {
//列表
List<WarnStrategyResp> selectWarnStrategyList(WarnStrategyReq warnStrategyReq);
//根据车辆类型查询策略
List<WarnStrategyResp> selectListByCarType(@Param("carTypeId")Long carTypeId);
}

View File

@ -3,6 +3,8 @@ package com.muyu.service;
import java.util.List;
import com.muyu.domain.WarnRule;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.domain.resp.WarnRuleResp;
import org.apache.ibatis.annotations.Param;
/**
* Service
@ -21,11 +23,9 @@ public interface WarnRuleService extends IService<WarnRule> {
/**
*
*
* @param warnRule
* @return
*/
public List<WarnRule> selectWarnRuleList(WarnRule warnRule);
List<WarnRuleResp> selectWarnRuleResplist();
/**
@ -39,4 +39,7 @@ public interface WarnRuleService extends IService<WarnRule> {
*/
Integer updWarnRule(WarnRule warnRule);
//根据策略ID查规则
List<WarnRuleResp> selectListByStrategyId(Long strategyId);
}

View File

@ -4,6 +4,8 @@ import java.util.List;
import com.muyu.domain.WarnStrategy;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.domain.req.WarnStrategyReq;
import com.muyu.domain.resp.WarnStrategyResp;
import org.apache.ibatis.annotations.Param;
/**
* Service
@ -23,10 +25,15 @@ public interface WarnStrategyService extends IService<WarnStrategy> {
/**
*
*
* @param warnStrategy
* @param warnStrategyReq
* @return
*/
public List<WarnStrategy> selectWarnStrategyList(WarnStrategyReq warnStrategyReq);
public List<WarnStrategyResp> selectWarnStrategyList(WarnStrategyReq warnStrategyReq);
/**
*
*/
public Integer deleteWarnStrategy(Long id);
@ -40,4 +47,9 @@ public interface WarnStrategyService extends IService<WarnStrategy> {
*/
Integer addWarnStrategy(WarnStrategy warnStrategy);
/**
* ID
*/
List<WarnStrategyResp> selectListByCarType(Long carTypeId);
}

View File

@ -2,6 +2,7 @@ package com.muyu.service.impl;
import java.util.List;
import com.muyu.domain.resp.WarnRuleResp;
import com.muyu.mapper.WarnRuleMapper;
import com.muyu.service.WarnRuleService;
import org.springframework.beans.factory.annotation.Autowired;
@ -40,14 +41,13 @@ public class WarnRuleServiceImpl
/**
*
*
* @param warnRule
* @param
* @return
*/
@Override
public List<WarnRule> selectWarnRuleList(WarnRule warnRule)
public List<WarnRuleResp> selectWarnRuleResplist()
{
LambdaQueryWrapper<WarnRule> queryWrapper = new LambdaQueryWrapper<>();
return warnRuleMapper.selectList(queryWrapper);
return warnRuleMapper.selectWarnRuleResplist();
}
@Override
@ -61,5 +61,10 @@ public class WarnRuleServiceImpl
return warnRuleMapper.update(queryWrapper);
}
@Override
public List<WarnRuleResp> selectListByStrategyId(Long strategyId) {
return warnRuleMapper.selectListByStrategyId(strategyId);
}
}

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.muyu.domain.WarnStrategy;
import com.muyu.domain.req.WarnStrategyReq;
import com.muyu.domain.resp.WarnStrategyResp;
import com.muyu.mapper.WarnLogsMapper;
import com.muyu.mapper.WarnStrategyMapper;
import com.muyu.service.WarnStrategyService;
@ -49,21 +50,15 @@ public class WarnStrategyServiceImpl
* @return
*/
@Override
public List<WarnStrategy> selectWarnStrategyList(WarnStrategyReq warnStrategyReq)
public List<WarnStrategyResp> selectWarnStrategyList(WarnStrategyReq warnStrategyReq)
{
LambdaQueryWrapper<WarnStrategy> 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);
return warnStrategyMapper.selectWarnStrategyList(warnStrategyReq);
}
@Override
public Integer deleteWarnStrategy(Long id) {
return warnStrategyMapper.deleteById(id);
}
/**
@ -82,4 +77,14 @@ public class WarnStrategyServiceImpl
}
/**
* ID
*/
@Override
public List<WarnStrategyResp> selectListByCarType(Long carTypeId) {
return warnStrategyMapper.selectListByCarType(carTypeId);
}
}

View File

@ -0,0 +1,2 @@
Spring Boot Version: ${spring-boot.version}
Spring Application Name: ${spring.application.name}

View File

@ -0,0 +1,19 @@
<?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.mapper.WarnRuleMapper">
<select id="selectListByStrategyId" resultType="com.muyu.domain.resp.WarnRuleResp">
SELECT * ,warn_strategy.strategy_name
FROM `warn_rule`
LEFT JOIN warn_strategy ON warn_rule.strategy_id=warn_strategy.id
WHERE warn_rule.strategy_id=#{strategyId}
</select>
<select id="selectWarnRuleResplist" resultType="com.muyu.domain.resp.WarnRuleResp">
SELECT * ,warn_strategy.strategy_name
FROM `warn_rule`
LEFT JOIN warn_strategy ON warn_rule.strategy_id=warn_strategy.id
</select>
</mapper>

View File

@ -0,0 +1,35 @@
<?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.mapper.WarnStrategyMapper">
<select id="selectWarnStrategyList" resultType="com.muyu.domain.resp.WarnStrategyResp">
SELECT *,
car_type.type_name,
t_template.template_name
FROM `warn_strategy`
LEFT JOIN car_type ON warn_strategy.car_type_id=car_type.id
LEFT JOIN t_template ON warn_strategy.template_id=t_template.template_id
<where>
<if test="carTypeId!=null and carTypeId!=''">
car_type.id=#{carTypeId}
</if>
<if test="strategyName!=null and strategyName!=''">
and warn_strategy.strategy_name=#{strategyName}
</if>
<if test="templateId!=null and templateId!=''">
and t_template.template_id=#{templateId}
</if>
</where>
</select>
<select id="selectListByCarType" resultType="com.muyu.domain.resp.WarnStrategyResp">
SELECT *,
car_type.type_name,
t_template.template_name
FROM `warn_strategy`
LEFT JOIN car_type ON warn_strategy.car_type_id=car_type.id
LEFT JOIN t_template ON warn_strategy.template_id=t_template.template_id
where warn_strategy.car_type_id=#{carTypeId}
</select>
</mapper>