diff --git a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-common/src/main/java/com/muyu/domain/req/FaultReq.java b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-common/src/main/java/com/muyu/domain/req/FaultReq.java new file mode 100644 index 0000000..8f57ef3 --- /dev/null +++ b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-common/src/main/java/com/muyu/domain/req/FaultReq.java @@ -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; +} diff --git a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/controller/FaultController.java b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/controller/FaultController.java index 339b885..99b9362 100644 --- a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/controller/FaultController.java +++ b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/controller/FaultController.java @@ -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> list(Fault fault) { + public Result> list(@RequestBody FaultReq faultReq) { startPage(); - List list = faultService.pageQuery(fault); + List 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 list = faultService.pageQuery(fault); + public void export(HttpServletResponse response, FaultReq faultReq) { + List list = faultService.pageQuery(faultReq); ExcelUtil util = new ExcelUtil(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 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)), "成功"); } - - } diff --git a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/mapper/FaultLogMapper.java b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/mapper/FaultLogMapper.java index 52b1d3a..597b764 100644 --- a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/mapper/FaultLogMapper.java +++ b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/mapper/FaultLogMapper.java @@ -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 { + @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({ + "", + "insert into faultlog (fault_code, vin, warning_time) values", + "", + "(#{temp.faultCode},#{temp.vin},#{temp.warningTime})", + "", + "" + }) void insertBatchFaultLog(@Param("logs") List logs); } diff --git a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/mapper/RuleMapper.java b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/mapper/RuleMapper.java index ebd96e4..c6eb0bc 100644 --- a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/mapper/RuleMapper.java +++ b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/mapper/RuleMapper.java @@ -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 { + + /** + * 新增故障 + * @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 pageQueryRule(RuleVo fault); + /** + * 查询故障 + * @param fault + * @return + */ + @Select("select * from custom") List pageQueryList(Custom fault); + /** + * 查询车辆 + * @param fault + * @return + */ + @Select("select * from vehicle") List pageQueryCar(Vehicle fault); + + /** + * 查询类型 + * @param fault + * @return + */ + @Select("select * from type") List pageQueryType(Type fault); + /** + * 查询报文值 + * @param fault + * @return + */ + @Select("select * from message_value") List pageQueryMessageValue(MessageValue fault); } diff --git a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/service/FaultService.java b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/service/FaultService.java index bfeb93a..501bf20 100644 --- a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/service/FaultService.java +++ b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/service/FaultService.java @@ -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 { /** - * 查询车辆故障管理 - * - * @param fault 车辆故障管理主键 + * 查询车辆故障管理列表 + * @param faultReq 车辆故障管理主键 * @return 车辆故障管理 */ - List pageQuery(Fault fault); + List pageQuery(FaultReq faultReq); } diff --git a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/service/impl/FaultServiceImpl.java b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/service/impl/FaultServiceImpl.java index d4d15d5..db88782 100644 --- a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/service/impl/FaultServiceImpl.java +++ b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/java/com/muyu/enterprise/service/impl/FaultServiceImpl.java @@ -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 implements FaultService { - @Autowired private FaultMapper faultMapper; /** - * - * @param fault 车辆故障管理主键 - * @return fault + * 查询车辆故障管理列表 + * @param faultReq 车辆故障管理主键 + * @return List */ @Override - public List pageQuery(Fault fault) { + public List pageQuery(FaultReq faultReq) { LambdaQueryWrapper 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); } - } diff --git a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/resources/mapper/car/FaultLogMapper.xml b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/resources/mapper/car/FaultLogMapper.xml deleted file mode 100644 index 9de29e6..0000000 --- a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/resources/mapper/car/FaultLogMapper.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - insert into faultlog (fault_code, vin, warning_time) - values - - (#{temp.faultCode},#{temp.vin},#{temp.warningTime}) - - - - - update faultlog - set normal_time = #{normalTime} - where id = #{id} - - - - - - diff --git a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/resources/mapper/car/RuleMapper.xml b/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/resources/mapper/car/RuleMapper.xml deleted file mode 100644 index 089eaa2..0000000 --- a/cloud-modules/cloud-modules-enterprise/cloud-modules-enterprise-server/src/main/resources/mapper/car/RuleMapper.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - INSERT INTO `vehicle-basic`.`rule` ( `message_id`, `car_id`, `c_id`, `t_id`, `rule_value`) - VALUES ( #{messageId}, #{carId}, #{cId}, #{tId}, #{ruleValue}) - - - - - UPDATE `rule` - SET `message_id`=#{messageId}, - `car_id` = #{carId}, - `c_id` = #{cId}, - `t_id` = #{tId}, - `rule_value` = #{ruleValue} - WHERE `id` = #{id}; - - - - - - - - -