feat(): 修改故障方法
parent
25ca3bf5bb
commit
63df5297fd
|
@ -0,0 +1,40 @@
|
|||
package com.muyu.domain.req;
|
||||
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 故障管理列表请求参数
|
||||
* @Author: LiDongJia
|
||||
* @Package: com.muyu.domain.req
|
||||
* @Project: cloud-server
|
||||
* @name: FaultReq
|
||||
* @Date: 2024/10/8 20:16
|
||||
* @Description: 故障管理列表请求参数
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Tag(name = "故障管理列表请求参数")
|
||||
public class FaultReq {
|
||||
|
||||
/**
|
||||
* 车辆故障编码
|
||||
*/
|
||||
private String faultCode;
|
||||
|
||||
/**
|
||||
* 车辆故障名称
|
||||
*/
|
||||
private String faultName;
|
||||
|
||||
/**
|
||||
* 车辆故障类型
|
||||
*/
|
||||
private String faultType;
|
||||
}
|
|
@ -1,24 +1,25 @@
|
|||
package com.muyu.enterprise.controller;
|
||||
import com.muyu.enterprise.service.FaultService;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
|
||||
import com.muyu.domain.Fault;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import com.muyu.domain.req.FaultReq;
|
||||
import com.muyu.enterprise.service.FaultService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 故障管理表
|
||||
* @Author:ChenYan
|
||||
* @Project:2112-car-cloud-server
|
||||
* @Package:com.muyu.fault.controller
|
||||
|
@ -26,26 +27,25 @@ import java.util.List;
|
|||
* @Description TODO
|
||||
* @Date:2024/9/17 11:08
|
||||
*/
|
||||
|
||||
@Log4j2
|
||||
@RestController
|
||||
@Tag(name = "故障管理列", description = "故障管理列")
|
||||
@Tag(name = "故障管理表", description = "故障管理表")
|
||||
@RequestMapping("/fault")
|
||||
public class FaultController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private FaultService faultService;
|
||||
|
||||
|
||||
/**
|
||||
* 查询车辆故障管理列表
|
||||
* @param faultReq
|
||||
* @return
|
||||
*/
|
||||
@Log(title = "车辆故障管理", businessType = BusinessType.OTHER)
|
||||
@GetMapping("/list")
|
||||
@RequiresPermissions("fault:fault:list")
|
||||
@Operation(summary = "查询集合", description = "查询车辆故障管理列表")
|
||||
public Result<TableDataInfo<Fault>> list(Fault fault) {
|
||||
public Result<TableDataInfo<Fault>> list(@RequestBody FaultReq faultReq) {
|
||||
startPage();
|
||||
List<Fault> list = faultService.pageQuery(fault);
|
||||
List<Fault> list = faultService.pageQuery(faultReq);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
@ -54,9 +54,8 @@ public class FaultController extends BaseController {
|
|||
*/
|
||||
@Log(title = "车辆故障管理", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
@RequiresPermissions("fault:fault:export")
|
||||
public void export(HttpServletResponse response, Fault fault) {
|
||||
List<Fault> list = faultService.pageQuery(fault);
|
||||
public void export(HttpServletResponse response, FaultReq faultReq) {
|
||||
List<Fault> list = faultService.pageQuery(faultReq);
|
||||
ExcelUtil<Fault> util = new ExcelUtil<Fault>(Fault.class);
|
||||
util.exportExcel(response, list, "车辆故障管理数据");
|
||||
}
|
||||
|
@ -64,47 +63,38 @@ public class FaultController extends BaseController {
|
|||
/**
|
||||
* 获取车辆故障管理详细信息
|
||||
*/
|
||||
@Log(title = "车辆故障管理", businessType = BusinessType.OTHER)
|
||||
@GetMapping(value = "/{id}")
|
||||
public Result<String> getConfigKey (@PathVariable("id") String id) {
|
||||
return success(faultService.getById(id));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增车辆故障管理
|
||||
*/
|
||||
@Log(title = "车辆故障管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
@RequiresPermissions("fault:fault:add")
|
||||
public Result add(@RequestBody Fault fault) {
|
||||
faultService.save(fault);
|
||||
return Result.success(null,"成功");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 修改车故障管理
|
||||
*/
|
||||
@Log(title = "车辆故障管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
@RequiresPermissions("fault:fault:edit")
|
||||
public Result edit(@RequestBody Fault fault) {
|
||||
faultService.updateById(fault);
|
||||
return Result.success(null,"成功");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 删除车辆故障管理
|
||||
*/
|
||||
@Log(title = "车辆故障管理删除", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{id}")
|
||||
@RequiresPermissions("fault:fault:remove")
|
||||
public Result remove(@PathVariable("id") Long[] id) {
|
||||
return Result.success(faultService.removeBatchByIds(Arrays.asList(id)), "成功");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3,8 +3,7 @@ package com.muyu.enterprise.mapper;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.domain.FaultLog;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -20,11 +19,20 @@ import java.util.List;
|
|||
@Mapper
|
||||
public interface FaultLogMapper extends BaseMapper<FaultLog> {
|
||||
|
||||
@Select("select max(id) from faultlog where fault_code = #{faultCode} and vin = #{vin}")
|
||||
Long selectFaultId(FaultLog log);
|
||||
|
||||
|
||||
@Update("update faultlog set normal_time = #{normalTime} where id = #{id}")
|
||||
int updateFaultLogByTime(FaultLog log);
|
||||
|
||||
|
||||
@Insert({
|
||||
"<scripte>",
|
||||
"insert into faultlog (fault_code, vin, warning_time) values",
|
||||
"<foreach collection='logs' item='temp' separator=','>",
|
||||
"(#{temp.faultCode},#{temp.vin},#{temp.warningTime})",
|
||||
"</foreach>",
|
||||
"</scripte>"
|
||||
})
|
||||
void insertBatchFaultLog(@Param("logs") List<FaultLog> logs);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,10 @@ package com.muyu.enterprise.mapper;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.domain.*;
|
||||
import com.muyu.domain.vo.RuleVo;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -18,18 +21,84 @@ import java.util.List;
|
|||
*/
|
||||
@Mapper
|
||||
public interface RuleMapper extends BaseMapper<Rule> {
|
||||
|
||||
/**
|
||||
* 新增故障
|
||||
* @param faultInfo
|
||||
* @return
|
||||
*/
|
||||
@Insert("INSERT INTO `vehicle-basic`.`rule` ( `message_id`, `car_id`, `c_id`, `t_id`, `rule_value`)\n" +
|
||||
" VALUES ( #{messageId}, #{carId}, #{cId}, #{tId}, #{ruleValue})")
|
||||
int insertFault(Rule faultInfo);
|
||||
|
||||
/**
|
||||
* 更新故障
|
||||
* @param faultInfo
|
||||
* @return
|
||||
*/
|
||||
@Update("UPDATE `rule`\n" +
|
||||
" SET `message_id`=#{messageId},\n" +
|
||||
" `car_id` = #{carId},\n" +
|
||||
" `c_id` = #{cId},\n" +
|
||||
" `t_id` = #{tId},\n" +
|
||||
" `rule_value` = #{ruleValue}\n" +
|
||||
" WHERE `id` = #{id};")
|
||||
int updateFault(Rule faultInfo);
|
||||
|
||||
|
||||
/**
|
||||
* 查询故障
|
||||
* @param fault
|
||||
* @return
|
||||
*/
|
||||
@Select("SELECT\n" +
|
||||
" rule.id,\n" +
|
||||
" rule.car_id,\n" +
|
||||
" rule.c_id,\n" +
|
||||
" rule.t_id,\n" +
|
||||
" rule.message_id,\n" +
|
||||
" rule_value,\n" +
|
||||
" custom_name AS customName,\n" +
|
||||
" type_name AS typeName,\n" +
|
||||
" car.car_name AS carName,\n" +
|
||||
" message_value.message_label AS messageLabel\n" +
|
||||
" FROM\n" +
|
||||
" rule\n" +
|
||||
" LEFT JOIN custom ON rule.c_id = custom.c_id\n" +
|
||||
" LEFT JOIN type ON rule.t_id = type.t_id\n" +
|
||||
" LEFT JOIN car ON rule.car_id = car.car_id\n" +
|
||||
" LEFT JOIN message_value ON rule.message_id = message_value.message_id")
|
||||
List<RuleVo> pageQueryRule(RuleVo fault);
|
||||
|
||||
/**
|
||||
* 查询故障
|
||||
* @param fault
|
||||
* @return
|
||||
*/
|
||||
@Select("select * from custom")
|
||||
List<Custom> pageQueryList(Custom fault);
|
||||
|
||||
/**
|
||||
* 查询车辆
|
||||
* @param fault
|
||||
* @return
|
||||
*/
|
||||
@Select("select * from vehicle")
|
||||
List<Vehicle> pageQueryCar(Vehicle fault);
|
||||
|
||||
/**
|
||||
* 查询类型
|
||||
* @param fault
|
||||
* @return
|
||||
*/
|
||||
@Select("select * from type")
|
||||
List<Type> pageQueryType(Type fault);
|
||||
|
||||
/**
|
||||
* 查询报文值
|
||||
* @param fault
|
||||
* @return
|
||||
*/
|
||||
@Select("select * from message_value")
|
||||
List<MessageValue> pageQueryMessageValue(MessageValue fault);
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ package com.muyu.enterprise.service;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.domain.Fault;
|
||||
import com.muyu.domain.req.FaultReq;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -18,11 +19,10 @@ import java.util.List;
|
|||
public interface FaultService extends IService<Fault> {
|
||||
|
||||
/**
|
||||
* 查询车辆故障管理
|
||||
*
|
||||
* @param fault 车辆故障管理主键
|
||||
* 查询车辆故障管理列表
|
||||
* @param faultReq 车辆故障管理主键
|
||||
* @return 车辆故障管理
|
||||
*/
|
||||
List<Fault> pageQuery(Fault fault);
|
||||
List<Fault> pageQuery(FaultReq faultReq);
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.muyu.common.core.utils.StringUtils;
|
|||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
|
||||
import com.muyu.domain.Fault;
|
||||
import com.muyu.domain.req.FaultReq;
|
||||
import com.muyu.enterprise.mapper.FaultMapper;
|
||||
import com.muyu.enterprise.service.FaultService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -26,38 +27,27 @@ import java.util.Objects;
|
|||
@Service
|
||||
public class FaultServiceImpl extends ServiceImpl<FaultMapper, Fault> implements FaultService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private FaultMapper faultMapper;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param fault 车辆故障管理主键
|
||||
* @return fault
|
||||
* 查询车辆故障管理列表
|
||||
* @param faultReq 车辆故障管理主键
|
||||
* @return List<Fault>
|
||||
*/
|
||||
@Override
|
||||
public List<Fault> pageQuery(Fault fault) {
|
||||
public List<Fault> pageQuery(FaultReq faultReq) {
|
||||
LambdaQueryWrapper<Fault> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (StringUtils.isNotEmpty(fault.getFaultCode())) {
|
||||
queryWrapper.like(Fault::getFaultCode, fault.getFaultCode());
|
||||
// 查询条件
|
||||
if (StringUtils.isNotEmpty(faultReq.getFaultCode())) {
|
||||
queryWrapper.like(Fault::getFaultCode, faultReq.getFaultCode());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(fault.getFaultType())) {
|
||||
queryWrapper.like(Fault::getFaultType, fault.getFaultType());
|
||||
if (StringUtils.isNotEmpty(faultReq.getFaultType())) {
|
||||
queryWrapper.like(Fault::getFaultType, faultReq.getFaultType());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(fault.getFaultName())) {
|
||||
queryWrapper.like(Fault::getFaultName, fault.getFaultName());
|
||||
}
|
||||
|
||||
|
||||
Object beginTime = fault.getParams().get("beginTime");
|
||||
if (Objects.nonNull(beginTime) && beginTime instanceof Date beginDate) {
|
||||
queryWrapper.gt(BaseEntity::getCreateTime, beginDate);
|
||||
}
|
||||
Object endTime = fault.getParams().get("endTime");
|
||||
if (Objects.nonNull(endTime) && endTime instanceof Date endDate) {
|
||||
queryWrapper.lt(BaseEntity::getCreateTime, endDate);
|
||||
if (StringUtils.isNotEmpty(faultReq.getFaultName())) {
|
||||
queryWrapper.like(Fault::getFaultName, faultReq.getFaultName());
|
||||
}
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,29 +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.enterprise.mapper.FaultLogMapper">
|
||||
|
||||
<insert id="insertBatchFaultLog">
|
||||
insert into faultlog (fault_code, vin, warning_time)
|
||||
values
|
||||
<foreach collection="logs" item="temp" separator=",">
|
||||
(#{temp.faultCode},#{temp.vin},#{temp.warningTime})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<update id="updateFaultLogByTime">
|
||||
update faultlog
|
||||
set normal_time = #{normalTime}
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="selectFaultId" resultType="java.lang.Long">
|
||||
select max(id)
|
||||
from faultlog
|
||||
where fault_code = #{faultCode}
|
||||
and vin = #{vin}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
|
@ -1,54 +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.enterprise.mapper.RuleMapper">
|
||||
<insert id="insertFault">
|
||||
INSERT INTO `vehicle-basic`.`rule` ( `message_id`, `car_id`, `c_id`, `t_id`, `rule_value`)
|
||||
VALUES ( #{messageId}, #{carId}, #{cId}, #{tId}, #{ruleValue})
|
||||
|
||||
</insert>
|
||||
|
||||
<update id="updateFault">
|
||||
UPDATE `rule`
|
||||
SET `message_id`=#{messageId},
|
||||
`car_id` = #{carId},
|
||||
`c_id` = #{cId},
|
||||
`t_id` = #{tId},
|
||||
`rule_value` = #{ruleValue}
|
||||
WHERE `id` = #{id};
|
||||
|
||||
</update>
|
||||
<select id="pageQueryRule" resultType="com.muyu.domain.vo.RuleVo">
|
||||
SELECT
|
||||
rule.id,
|
||||
rule.car_id,
|
||||
rule.c_id,
|
||||
rule.t_id,
|
||||
rule.message_id,
|
||||
rule_value,
|
||||
custom_name AS customName,
|
||||
type_name AS typeName,
|
||||
car.car_name AS carName,
|
||||
message_value.message_label AS messageLabel
|
||||
FROM
|
||||
rule
|
||||
LEFT JOIN custom ON rule.c_id = custom.c_id
|
||||
LEFT JOIN type ON rule.t_id = type.t_id
|
||||
LEFT JOIN car ON rule.car_id = car.car_id
|
||||
LEFT JOIN message_value ON rule.message_id = message_value.message_id
|
||||
</select>
|
||||
<select id="pageQueryList" resultType="com.muyu.domain.Custom">
|
||||
select * from custom
|
||||
</select>
|
||||
<select id="pageQueryCar" resultType="com.muyu.domain.Vehicle">
|
||||
select * from vehicle
|
||||
</select>
|
||||
<select id="pageQueryType" resultType="com.muyu.domain.Type">
|
||||
select * from type
|
||||
</select>
|
||||
<select id="pageQueryMessageValue" resultType="com.muyu.domain.MessageValue">
|
||||
select * from message_value
|
||||
</select>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue