添加车辆查看故障接口

dev
Number7 2024-09-22 20:47:23 +08:00
parent e7e9f73ef5
commit f6c9db3a2a
11 changed files with 90 additions and 24 deletions

View File

@ -2,11 +2,16 @@ package com.muyu.controller;
import com.muyu.common.core.domain.Result; import com.muyu.common.core.domain.Result;
import com.muyu.domain.SysCar; import com.muyu.domain.SysCar;
import com.muyu.domain.SysCarFaultLog;
import com.muyu.domain.req.SysCarReq; import com.muyu.domain.req.SysCarReq;
import com.muyu.domain.resp.SysCarVo;
import com.muyu.service.SysCarService; import com.muyu.service.SysCarService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController @RestController
@RequestMapping("/sysCar") @RequestMapping("/sysCar")
@ -44,5 +49,14 @@ public class SysCarController {
return i>0?Result.success():Result.error(); return i>0?Result.success():Result.error();
} }
/**
* VIN
* @param carVin
* @return
*/
@PostMapping("/findFenceByCarVin")
public Result<List<SysCarFaultLog>> findFenceByCarVin(@RequestParam("carVin") String carVin){
return Result.success(sysCarService.findFenceByCarVin(carVin));
}
} }

View File

@ -0,0 +1,44 @@
package com.muyu.domain;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
import lombok.experimental.SuperBuilder;
import java.util.Date;
/**
* @Authorliuxinyue
* @Packagecom.muyu.domain
* @Projectcloud-server
* @nameSysCarFault
* @Date2024/9/22 20:11
*/
@Data
@Setter
@Getter
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class SysCarFaultLog{
/**
*
*/
private Integer id;
/**
*
*/
private String faultCode;
/**
*
*/
private Date startTime;
/**
*
*/
private Date endTime;
/**
* VIN
*/
private String vin;
}

View File

@ -3,7 +3,9 @@ package com.muyu.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.domain.SysCar; import com.muyu.domain.SysCar;
import com.muyu.domain.SysCarFaultLog;
import com.muyu.domain.req.SysCarReq; import com.muyu.domain.req.SysCarReq;
import com.muyu.domain.resp.SysCarVo; import com.muyu.domain.resp.SysCarVo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -14,7 +16,8 @@ import java.util.List;
public interface SysCarMapper extends BaseMapper<SysCar> { public interface SysCarMapper extends BaseMapper<SysCar> {
List<SysCarVo> selectSysCarVoList(SysCarReq sysCarReq); List<SysCarVo> selectSysCarVoList(SysCarReq sysCarReq);
SysCarVo selectSysCarVoById(@Param("id") Long id); SysCarVo selectSysCarVoById(@Param("id") Long id);
List<SysCarFaultLog> findFenceByCarVin(@Param("carVin") String carVin);
} }

View File

@ -1,7 +1,9 @@
package com.muyu.service; package com.muyu.service;
import com.muyu.domain.SysCar; import com.muyu.domain.SysCar;
import com.muyu.domain.SysCarFaultLog;
import com.muyu.domain.req.SysCarReq; import com.muyu.domain.req.SysCarReq;
import com.muyu.domain.resp.SysCarVo; import com.muyu.domain.resp.SysCarVo;
import java.util.List; import java.util.List;
@ -16,4 +18,7 @@ public interface SysCarService {
int deleteSysCarById(Long id); int deleteSysCarById(Long id);
int updateSysCar(SysCar sysCar); int updateSysCar(SysCar sysCar);
List<SysCarFaultLog> findFenceByCarVin(String carVin);
} }

View File

@ -2,7 +2,9 @@ package com.muyu.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.domain.SysCar; import com.muyu.domain.SysCar;
import com.muyu.domain.SysCarFaultLog;
import com.muyu.domain.req.SysCarReq; import com.muyu.domain.req.SysCarReq;
import com.muyu.domain.resp.SysCarVo; import com.muyu.domain.resp.SysCarVo;
import com.muyu.mapper.SysCarMapper; import com.muyu.mapper.SysCarMapper;
import com.muyu.service.SysCarService; import com.muyu.service.SysCarService;
@ -39,4 +41,9 @@ public class SysCarServiceImpl extends ServiceImpl<SysCarMapper,SysCar> impleme
public int updateSysCar(SysCar sysCar) { public int updateSysCar(SysCar sysCar) {
return sysCarMapper.updateById(sysCar); return sysCarMapper.updateById(sysCar);
} }
@Override
public List<SysCarFaultLog> findFenceByCarVin(String carVin) {
return sysCarMapper.findFenceByCarVin(carVin);
}
} }

View File

@ -38,4 +38,13 @@
LEFT JOIN tb_fence ON sys_car.fence_id=tb_fence.fence_id LEFT JOIN tb_fence ON sys_car.fence_id=tb_fence.fence_id
where sys_car.id=#{id} where sys_car.id=#{id}
</select> </select>
<select id="findFenceByCarVin" resultType="com.muyu.domain.SysCarFaultLog">
SELECT
*
FROM
sys_car_fault_log
WHERE
vin = #{carVin};
</select>
</mapper> </mapper>

View File

@ -110,16 +110,7 @@
<artifactId>cloud-common-api-doc</artifactId> <artifactId>cloud-common-api-doc</artifactId>
</dependency> </dependency>
<!-- XllJob定时任务 -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-xxl</artifactId>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-rabbit</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>
@ -138,5 +129,4 @@
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

View File

@ -1,5 +1,4 @@
package com.template.controller; package com.template.controller;
import com.muyu.common.core.domain.Result; import com.muyu.common.core.domain.Result;
import com.template.domain.CarType; import com.template.domain.CarType;
import com.template.domain.SysCar; import com.template.domain.SysCar;
@ -9,7 +8,6 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
/** /**
* @Authorliuxinyue * @Authorliuxinyue
* @Packagecom.template.controller * @Packagecom.template.controller

View File

@ -20,7 +20,6 @@ import java.util.Date;
@NoArgsConstructor @NoArgsConstructor
public class Template { public class Template {
/** /**
* ID * ID
*/ */

View File

@ -30,4 +30,5 @@ public class CarServiceImpl implements CarService {
public CarType findCarTypeById(Long carTypeId) { public CarType findCarTypeById(Long carTypeId) {
return carMapper.carMapper(carTypeId); return carMapper.carMapper(carTypeId);
} }
} }

View File

@ -1,4 +1,5 @@
package com.template.service.impl; package com.template.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.muyu.common.core.domain.Result; import com.muyu.common.core.domain.Result;
import com.template.domain.*; import com.template.domain.*;
import com.template.mapper.TemplateMapper; import com.template.mapper.TemplateMapper;
@ -36,8 +37,8 @@ public class TemplateServiceImpl implements TemplateService{
@Override @Override
public void messageParsing(String templateMessage) { public void messageParsing(String templateMessage) {
//新能源车里面有的配置 //给一个JSON对象
MessageTemplate messageTemplate = new MessageTemplate(); JSONObject jsonObject = new JSONObject();
//先截取出VIN码 然后根据VIN码查询这个车属于什么类型 //先截取出VIN码 然后根据VIN码查询这个车属于什么类型
if(templateMessage.length()<18){ if(templateMessage.length()<18){
throw new RuntimeException("The vehicle message is incorrect"); throw new RuntimeException("The vehicle message is incorrect");
@ -69,15 +70,10 @@ public class TemplateServiceImpl implements TemplateService{
Integer startIndex = messageTemplateType.getStartIndex(); Integer startIndex = messageTemplateType.getStartIndex();
//结束位置 //结束位置
Integer endIndex = messageTemplateType.getEndIndex(); Integer endIndex = messageTemplateType.getEndIndex();
//车辆VIN码 //将每个解析后的字段都存入到JSON对象中
if(messageTemplateType.getMessageField().equals("vinCode")){ jsonObject.put(messageTemplateType.getMessageField(), result.substring(startIndex, endIndex-1));
messageTemplate.setVinCode(result.substring(startIndex, endIndex-1));
} }
if(messageTemplateType.getMessageField().equals("latitude")){ System.out.println("解析后的报文是:"+jsonObject);
messageTemplate.setLatitude(result.substring(startIndex, endIndex-1));
}
}
System.out.println("解析后的报文是:"+messageTemplate);
} }
} }