feat(): 车辆报文解析初版
parent
f33be9fbcc
commit
ea9876fed9
|
@ -0,0 +1,51 @@
|
||||||
|
package com.muyu.customer.business.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报文详情对象 MessageDetail
|
||||||
|
*
|
||||||
|
* @author DeKangLiu
|
||||||
|
* Date 2024/6/26 20:48
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class MessageDetail {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报文id
|
||||||
|
*/
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报文key
|
||||||
|
*/
|
||||||
|
private String key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报文起始位
|
||||||
|
*/
|
||||||
|
private Integer startBit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报文结束位
|
||||||
|
*/
|
||||||
|
private Integer stopBit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报文标签
|
||||||
|
*/
|
||||||
|
private String lable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报文类型
|
||||||
|
*/
|
||||||
|
private String type;
|
||||||
|
}
|
|
@ -118,6 +118,9 @@ public class Vehicle extends BaseEntity {
|
||||||
@ApiModelProperty(name = "车辆类型", value = "车辆类型")
|
@ApiModelProperty(name = "车辆类型", value = "车辆类型")
|
||||||
private String vehicleType;
|
private String vehicleType;
|
||||||
|
|
||||||
|
// /** 报文详情对象 */
|
||||||
|
// private MessageDetail messageDetail;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询构造器
|
* 查询构造器
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.muyu.customer.business.domain.model;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆中间表 VehicleMiddle
|
||||||
|
*
|
||||||
|
* @author DeKangLiu
|
||||||
|
* Date 2024/6/27 09:53
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class VehicleMiddle {
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
private Integer vehicleId;
|
||||||
|
|
||||||
|
private Integer messageId;
|
||||||
|
}
|
|
@ -0,0 +1,88 @@
|
||||||
|
package com.muyu.customer.business.domain.model;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.muyu.common.core.annotation.Excel;
|
||||||
|
import com.muyu.customer.business.domain.MessageDetail;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆录入对象 VehicleModel
|
||||||
|
*
|
||||||
|
* @author DeKangLiu
|
||||||
|
* Date 2024/6/27 08:18
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class VehicleModel {
|
||||||
|
|
||||||
|
/** 车辆id */
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 车辆vin */
|
||||||
|
private String vin;
|
||||||
|
|
||||||
|
/** 品牌 */
|
||||||
|
private String brand;
|
||||||
|
|
||||||
|
/** 型号 */
|
||||||
|
private String model;
|
||||||
|
|
||||||
|
/** 生产日期 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
|
private Date productionDate;
|
||||||
|
|
||||||
|
/** 车身类型 */
|
||||||
|
private String bodyType;
|
||||||
|
|
||||||
|
/** 车身颜色 */
|
||||||
|
private String color;
|
||||||
|
|
||||||
|
/** 发动机排量 */
|
||||||
|
private BigDecimal engineCapacity;
|
||||||
|
|
||||||
|
/** 燃油类型 */
|
||||||
|
private String fuelType;
|
||||||
|
|
||||||
|
/** 变速器类型 */
|
||||||
|
private String transmission;
|
||||||
|
|
||||||
|
/** 驱动方式 */
|
||||||
|
private String driveType;
|
||||||
|
|
||||||
|
/** 行驶里程 */
|
||||||
|
private BigDecimal mileage;
|
||||||
|
|
||||||
|
/** 注册日期 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
|
private Date registrationDate;
|
||||||
|
|
||||||
|
/** 车牌号码 */
|
||||||
|
private String licenseNumber;
|
||||||
|
|
||||||
|
/** 持有者 */
|
||||||
|
private String holder;
|
||||||
|
|
||||||
|
/** 车辆类型 */
|
||||||
|
private String vehicleType;
|
||||||
|
|
||||||
|
/** 报文详情对象 */
|
||||||
|
private String[] messageDetail;
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.muyu.customer.business.domain.vo;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 故障日志条件查询 FaultRecordVo
|
||||||
|
*
|
||||||
|
* @author DeKangLiu
|
||||||
|
* Date 2024/6/24 19:32
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class FaultRecordVo {
|
||||||
|
/**
|
||||||
|
* 故障码
|
||||||
|
*/
|
||||||
|
private String faultCode;
|
||||||
|
/**
|
||||||
|
* 车辆vin
|
||||||
|
*/
|
||||||
|
private String vin;
|
||||||
|
private String count;
|
||||||
|
private String faultLabel;
|
||||||
|
}
|
|
@ -1,40 +0,0 @@
|
||||||
//package com.muyu.customer.business.domain;
|
|
||||||
//
|
|
||||||
//import com.muyu.common.core.annotation.Excel;
|
|
||||||
//import com.muyu.common.core.web.domain.BaseEntity;
|
|
||||||
//import lombok.AllArgsConstructor;
|
|
||||||
//import lombok.Data;
|
|
||||||
//import lombok.EqualsAndHashCode;
|
|
||||||
//import lombok.NoArgsConstructor;
|
|
||||||
//import lombok.experimental.SuperBuilder;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * 多数据源对象 EnterpriseInfo
|
|
||||||
// *
|
|
||||||
// * @author DeKangLiu
|
|
||||||
// * Date 2024/6/22 20:37
|
|
||||||
// */
|
|
||||||
//@Data
|
|
||||||
//@SuperBuilder
|
|
||||||
//@NoArgsConstructor
|
|
||||||
//@AllArgsConstructor
|
|
||||||
//@EqualsAndHashCode(callSuper = true)
|
|
||||||
////@TableName("entinfo")
|
|
||||||
//public class EnterPriseInfo extends BaseEntity {
|
|
||||||
// private static final long serialVersionUID = 1L;
|
|
||||||
//
|
|
||||||
// /** 数据源key */
|
|
||||||
// @Excel(name = "数据源key")
|
|
||||||
// private String entCode;
|
|
||||||
//
|
|
||||||
// /** 数据源ip */
|
|
||||||
// @Excel(name = "数据源ip")
|
|
||||||
// private String ip;
|
|
||||||
//
|
|
||||||
// /** 数据源端口 */
|
|
||||||
// @Excel(name = "数据源端口")
|
|
||||||
// private Integer port;
|
|
||||||
//
|
|
||||||
// /** 数据源ID */
|
|
||||||
// private Long id;
|
|
||||||
//}
|
|
|
@ -1,24 +0,0 @@
|
||||||
//package com.muyu.customer.business.remote;
|
|
||||||
//
|
|
||||||
//import com.muyu.common.core.constant.ServiceNameConstants;
|
|
||||||
//import com.muyu.customer.business.remote.factory.RemoteBusinessFallbackFactory;
|
|
||||||
//import org.springframework.cloud.openfeign.FeignClient;
|
|
||||||
//import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
//import com.muyu.net.working.domain.DataSource;
|
|
||||||
//import java.util.List;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * 用户服务 RemoteBusinessService
|
|
||||||
// *
|
|
||||||
// * @author DeKangLiu
|
|
||||||
// * Date 2024/6/22 20:39
|
|
||||||
// */
|
|
||||||
//@FeignClient(
|
|
||||||
// contextId = "remoteBusinessService",
|
|
||||||
// value = ServiceNameConstants.SYSTEM_BUSINESS,
|
|
||||||
// fallbackFactory = RemoteBusinessFallbackFactory.class
|
|
||||||
//)
|
|
||||||
//public interface RemoteBusinessService {
|
|
||||||
// @GetMapping("/datasource/listAll")
|
|
||||||
// public List<DataSource> listAll();
|
|
||||||
//}
|
|
|
@ -1,35 +0,0 @@
|
||||||
//package com.muyu.customer.business.remote.factory;
|
|
||||||
//
|
|
||||||
//import com.muyu.customer.business.remote.RemoteBusinessService;
|
|
||||||
//import com.muyu.net.working.domain.DataSource;
|
|
||||||
//import org.slf4j.Logger;
|
|
||||||
//import org.slf4j.LoggerFactory;
|
|
||||||
//import org.springframework.cloud.openfeign.FallbackFactory;
|
|
||||||
//import org.springframework.stereotype.Component;
|
|
||||||
//
|
|
||||||
//import java.util.List;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * 熔断器 RemoteBusinessFallbackFactory
|
|
||||||
// *
|
|
||||||
// * @author DeKangLiu
|
|
||||||
// * Date 2024/6/22 20:41
|
|
||||||
// */
|
|
||||||
//@Component
|
|
||||||
//public class RemoteBusinessFallbackFactory implements FallbackFactory<RemoteBusinessService> {
|
|
||||||
// private static final Logger log = LoggerFactory.getLogger(RemoteBusinessFallbackFactory.class);
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public RemoteBusinessService create (Throwable throwable) {
|
|
||||||
// log.error("用户服务调用失败:{}", throwable.getMessage());
|
|
||||||
// return new RemoteBusinessService() {
|
|
||||||
// /**
|
|
||||||
// * 获取所有企业信息
|
|
||||||
// */
|
|
||||||
// @Override
|
|
||||||
// public List<DataSource> listAll() {
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
//}
|
|
|
@ -92,13 +92,13 @@ public void consumptionStartMessage(Message message, Channel channel) {
|
||||||
.vin(split[0])
|
.vin(split[0])
|
||||||
.faultCode(split[1])
|
.faultCode(split[1])
|
||||||
.faultLevel(split[2])
|
.faultLevel(split[2])
|
||||||
.startTime(date)
|
.endTime(date)
|
||||||
.build();
|
.build();
|
||||||
FaultRecord faultRecordOne = faultRecordService.selectFault(build);
|
FaultRecord faultRecordOne = faultRecordService.selectFault(build);
|
||||||
log.info("查询到的故障为:{}",faultRecordOne);
|
log.info("查询到的故障为:{}",faultRecordOne);
|
||||||
faultRecordOne.setEndTime(faultRecord.getEndTime());
|
faultRecordOne.setEndTime(build.getEndTime());
|
||||||
// 进行修改故障表
|
// 进行修改故障表
|
||||||
faultRecordService.updateByFaultRecord(faultRecordOne);
|
faultRecordService.updateFault(faultRecordOne);
|
||||||
// 移除数据源,
|
// 移除数据源,
|
||||||
DynamicDataSourceHolder.removeDynamicDataSourceKey();
|
DynamicDataSourceHolder.removeDynamicDataSourceKey();
|
||||||
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
||||||
|
|
|
@ -7,6 +7,7 @@ import com.muyu.customer.business.domain.FaultRecord;
|
||||||
import com.muyu.customer.business.domain.req.FaultRecordEditReq;
|
import com.muyu.customer.business.domain.req.FaultRecordEditReq;
|
||||||
import com.muyu.customer.business.domain.req.FaultRecordQueryReq;
|
import com.muyu.customer.business.domain.req.FaultRecordQueryReq;
|
||||||
import com.muyu.customer.business.domain.req.FaultRecordSaveReq;
|
import com.muyu.customer.business.domain.req.FaultRecordSaveReq;
|
||||||
|
import com.muyu.customer.business.domain.vo.FaultRecordVo;
|
||||||
import com.muyu.customer.business.service.FaultRecordService;
|
import com.muyu.customer.business.service.FaultRecordService;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -108,4 +109,11 @@ public class FaultRecordController extends BaseController {
|
||||||
public Result<String> remove(@PathVariable List<Long> ids) {
|
public Result<String> remove(@PathVariable List<Long> ids) {
|
||||||
return toAjax(faultRecordService.removeBatchByIds(ids));
|
return toAjax(faultRecordService.removeBatchByIds(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Log(title = "柱状图",businessType = BusinessType.DELETE)
|
||||||
|
@GetMapping("/countList")
|
||||||
|
@ApiOperation("柱状图展示")
|
||||||
|
public Result<List<FaultRecordVo>> countList( ) {
|
||||||
|
return Result.success(faultRecordService.countList());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,13 @@ import java.util.concurrent.TimeUnit;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.muyu.common.core.utils.ServletUtils;
|
import com.muyu.common.core.utils.ServletUtils;
|
||||||
|
import com.muyu.common.redis.service.RedisService;
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
|
import com.muyu.customer.business.domain.MessageDetail;
|
||||||
|
import com.muyu.customer.business.domain.model.VehicleModel;
|
||||||
import com.muyu.customer.business.mapper.VehicleMapper;
|
import com.muyu.customer.business.mapper.VehicleMapper;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -27,6 +31,7 @@ import com.muyu.customer.business.domain.req.VehicleSaveReq;
|
||||||
import com.muyu.customer.business.domain.req.VehicleEditReq;
|
import com.muyu.customer.business.domain.req.VehicleEditReq;
|
||||||
import com.muyu.customer.business.service.VehicleService;
|
import com.muyu.customer.business.service.VehicleService;
|
||||||
import com.muyu.common.core.web.page.TableDataInfo;
|
import com.muyu.common.core.web.page.TableDataInfo;
|
||||||
|
import springfox.documentation.spring.web.json.Json;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 车辆录入Controller
|
* 车辆录入Controller
|
||||||
|
@ -44,6 +49,8 @@ public class VehicleController extends BaseController {
|
||||||
private HttpServletRequest request;
|
private HttpServletRequest request;
|
||||||
@Autowired
|
@Autowired
|
||||||
private StringRedisTemplate redisTemplate;
|
private StringRedisTemplate redisTemplate;
|
||||||
|
@Autowired
|
||||||
|
private RedisService redisService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询车辆录入列表
|
* 查询车辆录入列表
|
||||||
|
@ -69,6 +76,11 @@ public class VehicleController extends BaseController {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Integer enterpriseId = SecurityUtils.getLoginUser().getSysUser().getEnterpriseId();
|
||||||
|
for (Vehicle vehicle : list) {
|
||||||
|
List<MessageDetail> messageList = vehicleService.selectMessage(vehicle.getId());
|
||||||
|
redisTemplate.opsForHash().put(enterpriseId+"", vehicle.getVin(), JSON.toJSONString(messageList));
|
||||||
|
}
|
||||||
|
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
@ -93,8 +105,8 @@ public class VehicleController extends BaseController {
|
||||||
@RequiresPermissions("customerBusiness:vehicle:query")
|
@RequiresPermissions("customerBusiness:vehicle:query")
|
||||||
@GetMapping(value = "/{id}")
|
@GetMapping(value = "/{id}")
|
||||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
||||||
public Result<Vehicle> getInfo(@PathVariable("id") Long id) {
|
public Result<VehicleModel> getInfo(@PathVariable("id") Long id) {
|
||||||
return Result.success(vehicleService.getById(id));
|
return Result.success(vehicleService.selectById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -104,9 +116,9 @@ public class VehicleController extends BaseController {
|
||||||
@Log(title = "车辆录入", businessType = BusinessType.INSERT)
|
@Log(title = "车辆录入", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@ApiOperation("新增车辆录入")
|
@ApiOperation("新增车辆录入")
|
||||||
public Result<String> add(@RequestBody VehicleSaveReq vehicleSaveReq) {
|
public Result add(@RequestBody VehicleModel vehicleModel) {
|
||||||
|
|
||||||
return toAjax(vehicleService.save(Vehicle.saveBuild(vehicleSaveReq)));
|
return Result.success(vehicleService.add(vehicleModel));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -132,6 +144,15 @@ public class VehicleController extends BaseController {
|
||||||
return toAjax(vehicleService.removeBatchByIds(ids));
|
return toAjax(vehicleService.removeBatchByIds(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询报文详情列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/MessageList")
|
||||||
|
public Result<List<MessageDetail>> MessageList() {
|
||||||
|
return Result.success(vehicleService.MessageList());
|
||||||
|
}
|
||||||
|
|
||||||
// @Autowired
|
// @Autowired
|
||||||
// private VehicleMapper vehicleMapper;
|
// private VehicleMapper vehicleMapper;
|
||||||
//
|
//
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.customer.business.mapper;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.muyu.customer.business.domain.FaultRecord;
|
import com.muyu.customer.business.domain.FaultRecord;
|
||||||
|
import com.muyu.customer.business.domain.vo.FaultRecordVo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 故障记录Mapper接口
|
* 故障记录Mapper接口
|
||||||
|
@ -12,7 +13,10 @@ import com.muyu.customer.business.domain.FaultRecord;
|
||||||
*/
|
*/
|
||||||
public interface FaultRecordMapper extends BaseMapper<FaultRecord> {
|
public interface FaultRecordMapper extends BaseMapper<FaultRecord> {
|
||||||
|
|
||||||
void addRecord(FaultRecord build);
|
|
||||||
|
|
||||||
FaultRecord selectFault(FaultRecord build);
|
FaultRecord selectFault(FaultRecord build);
|
||||||
|
|
||||||
|
void updateFault(FaultRecord faultRecordOne);
|
||||||
|
|
||||||
|
List<FaultRecordVo> countList();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,11 @@ package com.muyu.customer.business.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.muyu.customer.business.domain.MessageDetail;
|
||||||
import com.muyu.customer.business.domain.Vehicle;
|
import com.muyu.customer.business.domain.Vehicle;
|
||||||
|
import com.muyu.customer.business.domain.model.VehicleMiddle;
|
||||||
|
import com.muyu.customer.business.domain.model.VehicleModel;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 车辆录入Mapper接口
|
* 车辆录入Mapper接口
|
||||||
|
@ -12,4 +16,15 @@ import com.muyu.customer.business.domain.Vehicle;
|
||||||
*/
|
*/
|
||||||
public interface VehicleMapper extends BaseMapper<Vehicle> {
|
public interface VehicleMapper extends BaseMapper<Vehicle> {
|
||||||
|
|
||||||
|
List<MessageDetail> MessageList();
|
||||||
|
|
||||||
|
void add(VehicleModel vehicleModel);
|
||||||
|
|
||||||
|
void addMiddle(@Param("id") Long id, @Param("integer") Integer integer);
|
||||||
|
|
||||||
|
List<VehicleMiddle> selectMessageList(@Param("id") Long id);
|
||||||
|
|
||||||
|
VehicleModel selectId(@Param("id") Long id);
|
||||||
|
|
||||||
|
List<MessageDetail> selectMessage(@Param("id") Long id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.customer.business.service;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.muyu.customer.business.domain.FaultRecord;
|
import com.muyu.customer.business.domain.FaultRecord;
|
||||||
|
import com.muyu.customer.business.domain.vo.FaultRecordVo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 故障记录Service接口
|
* 故障记录Service接口
|
||||||
|
@ -19,7 +20,10 @@ public interface FaultRecordService extends IService<FaultRecord> {
|
||||||
*/
|
*/
|
||||||
public List<FaultRecord> list(FaultRecord faultRecord);
|
public List<FaultRecord> list(FaultRecord faultRecord);
|
||||||
|
|
||||||
void addRecord(FaultRecord build);
|
|
||||||
|
|
||||||
FaultRecord selectFault(FaultRecord build);
|
FaultRecord selectFault(FaultRecord build);
|
||||||
|
|
||||||
|
void updateFault(FaultRecord faultRecordOne);
|
||||||
|
|
||||||
|
List<FaultRecordVo> countList();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
package com.muyu.customer.business.service;
|
package com.muyu.customer.business.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.muyu.customer.business.domain.MessageDetail;
|
||||||
import com.muyu.customer.business.domain.Vehicle;
|
import com.muyu.customer.business.domain.Vehicle;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.customer.business.domain.model.VehicleModel;
|
||||||
import com.muyu.customer.business.domain.req.VehicleQueryReq;
|
import com.muyu.customer.business.domain.req.VehicleQueryReq;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,4 +23,12 @@ public interface VehicleService extends IService<Vehicle> {
|
||||||
*/
|
*/
|
||||||
List<Vehicle> list(Vehicle vehicle);
|
List<Vehicle> list(Vehicle vehicle);
|
||||||
|
|
||||||
|
List<MessageDetail> MessageList();
|
||||||
|
|
||||||
|
|
||||||
|
String add(VehicleModel vehicleModel);
|
||||||
|
|
||||||
|
VehicleModel selectById(Long id);
|
||||||
|
|
||||||
|
List<MessageDetail> selectMessage(Long id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.muyu.common.core.utils.ObjUtils;
|
import com.muyu.common.core.utils.ObjUtils;
|
||||||
import com.muyu.customer.business.domain.FaultRecord;
|
import com.muyu.customer.business.domain.FaultRecord;
|
||||||
|
import com.muyu.customer.business.domain.vo.FaultRecordVo;
|
||||||
import com.muyu.customer.business.mapper.FaultRecordMapper;
|
import com.muyu.customer.business.mapper.FaultRecordMapper;
|
||||||
import com.muyu.customer.business.service.FaultRecordService;
|
import com.muyu.customer.business.service.FaultRecordService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
@ -49,13 +50,19 @@ public class FaultRecordServiceImpl extends ServiceImpl<FaultRecordMapper, Fault
|
||||||
return list(queryWrapper);
|
return list(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addRecord(FaultRecord build) {
|
|
||||||
faultRecordMapper.addRecord(build);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FaultRecord selectFault(FaultRecord build) {
|
public FaultRecord selectFault(FaultRecord build) {
|
||||||
return faultRecordMapper.selectFault(build);
|
return faultRecordMapper.selectFault(build);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateFault(FaultRecord faultRecordOne) {
|
||||||
|
faultRecordMapper.updateFault(faultRecordOne);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<FaultRecordVo> countList() {
|
||||||
|
return faultRecordMapper.countList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,11 @@ package com.muyu.customer.business.service.impl;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.muyu.common.core.utils.ObjUtils;
|
import com.muyu.common.core.utils.ObjUtils;
|
||||||
|
import com.muyu.customer.business.domain.MessageDetail;
|
||||||
|
import com.muyu.customer.business.domain.model.VehicleMiddle;
|
||||||
|
import com.muyu.customer.business.domain.model.VehicleModel;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.muyu.customer.business.mapper.VehicleMapper;
|
import com.muyu.customer.business.mapper.VehicleMapper;
|
||||||
import com.muyu.customer.business.domain.Vehicle;
|
import com.muyu.customer.business.domain.Vehicle;
|
||||||
|
@ -20,6 +24,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> implements VehicleService {
|
public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> implements VehicleService {
|
||||||
|
@Autowired
|
||||||
|
private VehicleMapper vehicleMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询车辆录入列表
|
* 查询车辆录入列表
|
||||||
|
@ -95,4 +101,36 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> imp
|
||||||
|
|
||||||
return list(queryWrapper);
|
return list(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MessageDetail> MessageList() {
|
||||||
|
return vehicleMapper.MessageList();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String add(VehicleModel vehicleModel) {
|
||||||
|
vehicleMapper.add(vehicleModel);
|
||||||
|
for (String s : vehicleModel.getMessageDetail()) {
|
||||||
|
vehicleMapper.addMiddle(vehicleModel.getId(),Integer.valueOf(s));
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println(vehicleModel.getId());
|
||||||
|
// MessageDetail messageDetail = vehicleModel.getMessageDetail();
|
||||||
|
|
||||||
|
return "成功";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VehicleModel selectById(Long id) {
|
||||||
|
List<VehicleMiddle> vehicleMiddleList= vehicleMapper.selectMessageList(id);
|
||||||
|
VehicleModel vehicleModel= vehicleMapper.selectId(id);
|
||||||
|
return vehicleModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MessageDetail> selectMessage(Long id) {
|
||||||
|
return vehicleMapper.selectMessage(id);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,14 +17,38 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<sql id="selectFaultRecordVo">
|
<sql id="selectFaultRecordVo">
|
||||||
select id, fault_code, vin, start_time, end_time, fault_level, fault_handle from fault_record
|
select id, fault_code, vin, start_time, end_time, fault_level, fault_handle from fault_record
|
||||||
</sql>
|
</sql>
|
||||||
<insert id="addRecord">
|
|
||||||
INSERT INTO fault_record
|
<update id="updateFault">
|
||||||
(`fault_code`, `vin`, `start_time`, `end_time`, `fault_level`, `fault_handle`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES
|
update fault_record set end_time=#{endTime} where id=#{id}
|
||||||
values(#{faultCode},#{vin},#{startTime},null,#{faultLevel},#{faultHandle},null,null,null,null,null)
|
</update>
|
||||||
</insert>
|
|
||||||
|
|
||||||
|
<select id="countList" resultType="com.muyu.customer.business.domain.vo.FaultRecordVo">
|
||||||
|
SELECT
|
||||||
|
fr.vin,
|
||||||
|
fr.fault_code,
|
||||||
|
COUNT(*) AS count,
|
||||||
|
fc.fault_label
|
||||||
|
FROM
|
||||||
|
fault_record fr
|
||||||
|
LEFT JOIN fault_code fc ON fr.fault_code = fc.fault_code
|
||||||
|
<where>
|
||||||
|
<if test=" max != null ">
|
||||||
|
and #{max} >= start_time
|
||||||
|
</if>
|
||||||
|
<if test=" min != null ">
|
||||||
|
and #{min} <= end_time
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
GROUP BY
|
||||||
|
fr.vin,
|
||||||
|
fr.fault_code,
|
||||||
|
fc.fault_label ORDER BY count
|
||||||
|
</select>
|
||||||
<select id="selectFault" resultType="com.muyu.customer.business.domain.FaultRecord">
|
<select id="selectFault" resultType="com.muyu.customer.business.domain.FaultRecord">
|
||||||
SELECT id,fault_code,vin,start_time,end_time,fault_level,fault_handle
|
SELECT id,fault_code,vin,start_time,end_time,fault_level,fault_handle
|
||||||
FROM fault_record
|
FROM fault_record
|
||||||
WHERE fault_code =#{faultCode} AND vin = #{vin} AND end_time is NULL
|
WHERE fault_code =#{faultCode} AND vin = #{vin} AND end_time is NULL
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -31,4 +31,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<sql id="selectVehicleVo">
|
<sql id="selectVehicleVo">
|
||||||
select id, vin, brand, model, production_date, body_type, color, engine_capacity, fuel_type, transmission, drive_type, mileage, registration_date, license_number, holder, vehicle_type, create_by, create_time, update_by, update_time, remark from vehicle
|
select id, vin, brand, model, production_date, body_type, color, engine_capacity, fuel_type, transmission, drive_type, mileage, registration_date, license_number, holder, vehicle_type, create_by, create_time, update_by, update_time, remark from vehicle
|
||||||
</sql>
|
</sql>
|
||||||
|
<insert id="add" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
insert into vehicle
|
||||||
|
(id, vin, brand, model, production_date, body_type, color, engine_capacity, fuel_type, transmission, drive_type, mileage, registration_date, license_number, holder, vehicle_type)
|
||||||
|
values
|
||||||
|
(#{id}, #{vin}, #{brand}, #{model}, #{productionDate}, #{bodyType}, #{color}, #{engineCapacity}, #{fuelType}, #{transmission}, #{driveType}, #{mileage}, #{registrationDate}, #{licenseNumber}, #{holder}, #{vehicleType})
|
||||||
|
</insert>
|
||||||
|
<insert id="addMiddle">
|
||||||
|
insert into vehicle_middle
|
||||||
|
(vehicle_id, message_id)
|
||||||
|
values
|
||||||
|
(#{id}, #{integer})
|
||||||
|
</insert>
|
||||||
|
<select id="MessageList" resultType="com.muyu.customer.business.domain.MessageDetail">
|
||||||
|
select * from message_detail
|
||||||
|
</select>
|
||||||
|
<select id="selectMessageList" resultType="com.muyu.customer.business.domain.model.VehicleMiddle">
|
||||||
|
select * from vehicle_middle where vehicle_id = #{id}
|
||||||
|
</select>
|
||||||
|
<select id="selectId" resultType="com.muyu.customer.business.domain.model.VehicleModel">
|
||||||
|
select * from vehicle where id = #{id}
|
||||||
|
</select>
|
||||||
|
<select id="selectMessage" resultType="com.muyu.customer.business.domain.MessageDetail">
|
||||||
|
select m.id,m.key,m.lable,m.start_bit,m.stop_bit,m.type
|
||||||
|
from message_detail m,vehicle_middle v where m.id = v.message_id and v.vehicle_id = #{id}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
Loading…
Reference in New Issue