添加车辆查看故障接口
parent
e7e9f73ef5
commit
f6c9db3a2a
|
@ -2,11 +2,16 @@ package com.muyu.controller;
|
|||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.domain.SysCar;
|
||||
import com.muyu.domain.SysCarFaultLog;
|
||||
import com.muyu.domain.req.SysCarReq;
|
||||
|
||||
import com.muyu.domain.resp.SysCarVo;
|
||||
import com.muyu.service.SysCarService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/sysCar")
|
||||
|
@ -44,5 +49,14 @@ public class SysCarController {
|
|||
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));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package com.muyu.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author:liuxinyue
|
||||
* @Package:com.muyu.domain
|
||||
* @Project:cloud-server
|
||||
* @name:SysCarFault
|
||||
* @Date:2024/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;
|
||||
}
|
|
@ -3,7 +3,9 @@ package com.muyu.mapper;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.domain.SysCar;
|
||||
|
||||
import com.muyu.domain.SysCarFaultLog;
|
||||
import com.muyu.domain.req.SysCarReq;
|
||||
|
||||
import com.muyu.domain.resp.SysCarVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
@ -14,7 +16,8 @@ import java.util.List;
|
|||
public interface SysCarMapper extends BaseMapper<SysCar> {
|
||||
List<SysCarVo> selectSysCarVoList(SysCarReq sysCarReq);
|
||||
|
||||
|
||||
SysCarVo selectSysCarVoById(@Param("id") Long id);
|
||||
|
||||
List<SysCarFaultLog> findFenceByCarVin(@Param("carVin") String carVin);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package com.muyu.service;
|
||||
|
||||
import com.muyu.domain.SysCar;
|
||||
import com.muyu.domain.SysCarFaultLog;
|
||||
import com.muyu.domain.req.SysCarReq;
|
||||
|
||||
import com.muyu.domain.resp.SysCarVo;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -16,4 +18,7 @@ public interface SysCarService {
|
|||
int deleteSysCarById(Long id);
|
||||
|
||||
int updateSysCar(SysCar sysCar);
|
||||
|
||||
List<SysCarFaultLog> findFenceByCarVin(String carVin);
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package com.muyu.service.impl;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.domain.SysCar;
|
||||
import com.muyu.domain.SysCarFaultLog;
|
||||
import com.muyu.domain.req.SysCarReq;
|
||||
|
||||
import com.muyu.domain.resp.SysCarVo;
|
||||
import com.muyu.mapper.SysCarMapper;
|
||||
import com.muyu.service.SysCarService;
|
||||
|
@ -39,4 +41,9 @@ public class SysCarServiceImpl extends ServiceImpl<SysCarMapper,SysCar> impleme
|
|||
public int updateSysCar(SysCar sysCar) {
|
||||
return sysCarMapper.updateById(sysCar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysCarFaultLog> findFenceByCarVin(String carVin) {
|
||||
return sysCarMapper.findFenceByCarVin(carVin);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,4 +38,13 @@
|
|||
LEFT JOIN tb_fence ON sys_car.fence_id=tb_fence.fence_id
|
||||
where sys_car.id=#{id}
|
||||
</select>
|
||||
<select id="findFenceByCarVin" resultType="com.muyu.domain.SysCarFaultLog">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
sys_car_fault_log
|
||||
WHERE
|
||||
vin = #{carVin};
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -110,16 +110,7 @@
|
|||
<artifactId>cloud-common-api-doc</artifactId>
|
||||
</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>
|
||||
|
||||
<build>
|
||||
|
@ -138,5 +129,4 @@
|
|||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
package com.template.controller;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.template.domain.CarType;
|
||||
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.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @Author:liuxinyue
|
||||
* @Package:com.template.controller
|
||||
|
|
|
@ -20,7 +20,6 @@ import java.util.Date;
|
|||
@NoArgsConstructor
|
||||
public class Template {
|
||||
|
||||
|
||||
/**
|
||||
* 模版ID
|
||||
*/
|
||||
|
|
|
@ -30,4 +30,5 @@ public class CarServiceImpl implements CarService {
|
|||
public CarType findCarTypeById(Long carTypeId) {
|
||||
return carMapper.carMapper(carTypeId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
package com.template.service.impl;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.template.domain.*;
|
||||
import com.template.mapper.TemplateMapper;
|
||||
|
@ -36,8 +37,8 @@ public class TemplateServiceImpl implements TemplateService{
|
|||
|
||||
@Override
|
||||
public void messageParsing(String templateMessage) {
|
||||
//新能源车里面有的配置
|
||||
MessageTemplate messageTemplate = new MessageTemplate();
|
||||
//给一个JSON对象
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
//先截取出VIN码 然后根据VIN码查询这个车属于什么类型
|
||||
if(templateMessage.length()<18){
|
||||
throw new RuntimeException("The vehicle message is incorrect");
|
||||
|
@ -69,15 +70,10 @@ public class TemplateServiceImpl implements TemplateService{
|
|||
Integer startIndex = messageTemplateType.getStartIndex();
|
||||
//结束位置
|
||||
Integer endIndex = messageTemplateType.getEndIndex();
|
||||
//车辆VIN码
|
||||
if(messageTemplateType.getMessageField().equals("vinCode")){
|
||||
messageTemplate.setVinCode(result.substring(startIndex, endIndex-1));
|
||||
}
|
||||
if(messageTemplateType.getMessageField().equals("latitude")){
|
||||
messageTemplate.setLatitude(result.substring(startIndex, endIndex-1));
|
||||
}
|
||||
//将每个解析后的字段都存入到JSON对象中
|
||||
jsonObject.put(messageTemplateType.getMessageField(), result.substring(startIndex, endIndex-1));
|
||||
}
|
||||
System.out.println("解析后的报文是:"+messageTemplate);
|
||||
System.out.println("解析后的报文是:"+jsonObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue