master
commit
369a99e269
|
@ -21,6 +21,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
|||
@EnableCustomConfig
|
||||
@EnableCustomSwagger2
|
||||
@EnableMyFeignClients
|
||||
@EnableScheduling
|
||||
@SpringBootApplication(exclude = {DynamicDataSourceAutoConfiguration.class, DataSourceAutoConfiguration.class })
|
||||
public class ZhiLianVehicleApplication {
|
||||
public static void main (String[] args) {
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
package com.zhiLian.vehicle.controller;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.zhiLian.common.core.domain.Result;
|
||||
import com.zhiLian.common.core.utils.poi.ExcelUtil;
|
||||
import com.zhiLian.common.core.web.controller.BaseController;
|
||||
import com.zhiLian.common.core.web.page.TableDataInfo;
|
||||
import com.zhiLian.common.log.annotation.Log;
|
||||
import com.zhiLian.common.log.enums.BusinessType;
|
||||
import com.zhiLian.common.security.annotation.RequiresPermissions;
|
||||
import com.zhiLian.vehicle.domain.FaultCode;
|
||||
import com.zhiLian.vehicle.domain.req.FaultCodeEditReq;
|
||||
import com.zhiLian.vehicle.domain.req.FaultCodeQueryReq;
|
||||
import com.zhiLian.vehicle.domain.req.FaultCodeSaveReq;
|
||||
import com.zhiLian.vehicle.service.FaultCodeService;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
/**
|
||||
* 车辆故障码Controller
|
||||
*
|
||||
* @author chx
|
||||
* @date 2024-06-20
|
||||
*/
|
||||
@Api(tags = "车辆故障码")
|
||||
@RestController
|
||||
@RequestMapping("/faultCode")
|
||||
public class FaultCodeController extends BaseController {
|
||||
@Autowired
|
||||
private FaultCodeService faultCodeService;
|
||||
|
||||
/**
|
||||
* 查询车辆故障码列表
|
||||
*/
|
||||
@ApiOperation("获取车辆故障码列表")
|
||||
// @RequiresPermissions("client:faultCode:list")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<FaultCode>> list(FaultCodeQueryReq faultCodeQueryReq) {
|
||||
startPage();
|
||||
List<FaultCode> list = faultCodeService.list(FaultCode.queryBuild(faultCodeQueryReq));
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出车辆故障码列表
|
||||
*/
|
||||
@ApiOperation("导出车辆故障码列表")
|
||||
// @RequiresPermissions("client:faultCode:export")
|
||||
@Log(title = "车辆故障码", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, FaultCode faultCode) {
|
||||
List<FaultCode> list = faultCodeService.list(faultCode);
|
||||
ExcelUtil<FaultCode> util = new ExcelUtil<FaultCode>(FaultCode.class);
|
||||
util.exportExcel(response, list, "车辆故障码数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取车辆故障码详细信息
|
||||
*/
|
||||
@ApiOperation("获取车辆故障码详细信息")
|
||||
// @RequiresPermissions("client:faultCode:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
||||
public Result<FaultCode> getInfo(@PathVariable("id") Long id) {
|
||||
return Result.success(faultCodeService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增车辆故障码
|
||||
*/
|
||||
// @RequiresPermissions("client:faultCode:add")
|
||||
@Log(title = "车辆故障码", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
@ApiOperation("新增车辆故障码")
|
||||
public Result<String> add(@RequestBody FaultCodeSaveReq faultCodeSaveReq) {
|
||||
return toAjax(faultCodeService.save(FaultCode.saveBuild(faultCodeSaveReq)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改车辆故障码
|
||||
*/
|
||||
// @RequiresPermissions("client:faultCode:edit")
|
||||
@Log(title = "车辆故障码", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/{id}")
|
||||
@ApiOperation("修改车辆故障码")
|
||||
public Result<String> edit(@PathVariable Long id, @RequestBody FaultCodeEditReq faultCodeEditReq) {
|
||||
return toAjax(faultCodeService.updateById(FaultCode.editBuild(id,faultCodeEditReq)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除车辆故障码
|
||||
*/
|
||||
// @RequiresPermissions("client:faultCode:remove")
|
||||
@Log(title = "车辆故障码", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
@ApiOperation("删除车辆故障码")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
|
||||
public Result<String> remove(@PathVariable List<Long> ids) {
|
||||
return toAjax(faultCodeService.removeBatchByIds(ids));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,122 @@
|
|||
package com.zhiLian.vehicle.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.zhiLian.common.core.domain.Result;
|
||||
import com.zhiLian.common.core.utils.poi.ExcelUtil;
|
||||
import com.zhiLian.common.core.web.controller.BaseController;
|
||||
import com.zhiLian.common.core.web.page.TableDataInfo;
|
||||
import com.zhiLian.common.log.annotation.Log;
|
||||
import com.zhiLian.common.log.enums.BusinessType;
|
||||
import com.zhiLian.common.security.annotation.RequiresPermissions;
|
||||
import com.zhiLian.vehicle.domain.FaultRecord;
|
||||
import com.zhiLian.vehicle.domain.req.FaultRecordEditReq;
|
||||
import com.zhiLian.vehicle.domain.req.FaultRecordQueryReq;
|
||||
import com.zhiLian.vehicle.domain.req.FaultRecordReqVo;
|
||||
import com.zhiLian.vehicle.domain.req.FaultRecordSaveReq;
|
||||
import com.zhiLian.vehicle.domain.vo.FaultRecordVo;
|
||||
import com.zhiLian.vehicle.service.FaultRecordService;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
/**
|
||||
* 故障记录Controller
|
||||
*
|
||||
* @author chx
|
||||
* @date 2024-06-20
|
||||
*/
|
||||
@Api(tags = "故障记录")
|
||||
@RestController
|
||||
@RequestMapping("/faultRecord")
|
||||
public class FaultRecordController extends BaseController {
|
||||
@Autowired
|
||||
private FaultRecordService faultRecordService;
|
||||
|
||||
/**
|
||||
* 查询故障记录列表
|
||||
*/
|
||||
@ApiOperation("获取故障记录列表")
|
||||
// @RequiresPermissions("client:faultRecord:list")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<FaultRecord>> list(FaultRecordQueryReq faultRecordQueryReq) {
|
||||
startPage();
|
||||
List<FaultRecord> list = faultRecordService.list(FaultRecord.queryBuild(faultRecordQueryReq));
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出故障记录列表
|
||||
*/
|
||||
@ApiOperation("导出故障记录列表")
|
||||
// @RequiresPermissions("client:faultRecord:export")
|
||||
@Log(title = "故障记录", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, FaultRecord faultRecord) {
|
||||
List<FaultRecord> list = faultRecordService.list(faultRecord);
|
||||
ExcelUtil<FaultRecord> util = new ExcelUtil<FaultRecord>(FaultRecord.class);
|
||||
util.exportExcel(response, list, "故障记录数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取故障记录详细信息
|
||||
*/
|
||||
@ApiOperation("获取故障记录详细信息")
|
||||
// @RequiresPermissions("client:faultRecord:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
||||
public Result<FaultRecord> getInfo(@PathVariable("id") Long id) {
|
||||
return Result.success(faultRecordService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增故障记录
|
||||
*/
|
||||
// @RequiresPermissions("client:faultRecord:add")
|
||||
@Log(title = "故障记录", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
@ApiOperation("新增故障记录")
|
||||
public Result<String> add(@RequestBody FaultRecordSaveReq faultRecordSaveReq) {
|
||||
return toAjax(faultRecordService.save(FaultRecord.saveBuild(faultRecordSaveReq)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改故障记录
|
||||
*/
|
||||
// @RequiresPermissions("client:faultRecord:edit")
|
||||
@Log(title = "故障记录", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/{id}")
|
||||
@ApiOperation("修改故障记录")
|
||||
public Result<String> edit(@PathVariable Long id, @RequestBody FaultRecordEditReq faultRecordEditReq) {
|
||||
return toAjax(faultRecordService.updateById(FaultRecord.editBuild(id,faultRecordEditReq)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除故障记录
|
||||
*/
|
||||
// @RequiresPermissions("client:faultRecord:remove")
|
||||
@Log(title = "故障记录", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
@ApiOperation("删除故障记录")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
|
||||
public Result<String> remove(@PathVariable List<Long> ids) {
|
||||
return toAjax(faultRecordService.removeBatchByIds(ids));
|
||||
}
|
||||
|
||||
@Log(title = "图",businessType = BusinessType.DELETE)
|
||||
@PostMapping("/countList")
|
||||
@ApiOperation("图展示")
|
||||
public Result<List<FaultRecordVo>> countList(@RequestBody FaultRecordReqVo recordReqVo) {
|
||||
return Result.success(faultRecordService.countList(recordReqVo));
|
||||
}
|
||||
}
|
|
@ -37,6 +37,7 @@ public class VehicleController extends BaseController
|
|||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<Vehicle>> list(Vehicle vehicle)
|
||||
{
|
||||
|
||||
startPage();
|
||||
List<Vehicle> list = vehicleService.selectVehicleList(vehicle);
|
||||
return getDataTable(list);
|
||||
|
|
|
@ -36,8 +36,11 @@ public class VehicleInfoController extends BaseController
|
|||
@GetMapping("/list/{vin}")
|
||||
public Result vehicleInfoAllList(@PathVariable String vin){
|
||||
|
||||
String lastElement = redisTemplate.opsForList().index(vin, -1);
|
||||
VehicleInfo vehicleInfo = JSON.parseObject(lastElement, VehicleInfo.class);
|
||||
return Result.success(vehicleInfo);
|
||||
if (redisTemplate.hasKey(vin)){
|
||||
String lastElement = redisTemplate.opsForList().index(vin, -1);
|
||||
VehicleInfo vehicleInfo = JSON.parseObject(lastElement, VehicleInfo.class);
|
||||
return Result.success(vehicleInfo);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import lombok.extern.log4j.Log4j2;
|
|||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.rabbit.annotation.Queue;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
@ -24,10 +25,7 @@ import org.springframework.data.redis.core.RedisTemplate;
|
|||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* BingRui.Hou
|
||||
|
@ -45,7 +43,8 @@ public class ManyDataSource {
|
|||
@Autowired
|
||||
private RemoteBusinessService remoteBusinessService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
|
||||
//调用注解 添加队列名称
|
||||
@RabbitListener(queuesToDeclare = {@Queue(name = "zhiLian-vehicle-exchange")})
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
package com.zhiLian.vehicle.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.zhiLian.common.core.annotation.Excel;
|
||||
import com.zhiLian.common.core.web.domain.BaseEntity;
|
||||
import com.zhiLian.vehicle.domain.req.FaultCodeEditReq;
|
||||
import com.zhiLian.vehicle.domain.req.FaultCodeQueryReq;
|
||||
import com.zhiLian.vehicle.domain.req.FaultCodeSaveReq;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
/**
|
||||
* 车辆故障码对象 fault_code
|
||||
* @date 2024-06-20
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("fault_code")
|
||||
@ApiModel(value = "FaultCode", description = "车辆故障码")
|
||||
public class FaultCode {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键 */
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
@ApiModelProperty(name = "主键", value = "主键")
|
||||
private Long id;
|
||||
|
||||
/** 故障码 */
|
||||
@Excel(name = "故障码")
|
||||
@ApiModelProperty(name = "故障码", value = "故障码")
|
||||
private String faultCode;
|
||||
|
||||
/** 故障标签 */
|
||||
@Excel(name = "故障标签")
|
||||
@ApiModelProperty(name = "故障标签", value = "故障标签")
|
||||
private String faultLabel;
|
||||
|
||||
/** 故障位 */
|
||||
@Excel(name = "故障位")
|
||||
@ApiModelProperty(name = "故障位", value = "故障位")
|
||||
private Long faultBit;
|
||||
|
||||
/** 故障值 */
|
||||
@Excel(name = "故障值")
|
||||
@ApiModelProperty(name = "故障值", value = "故障值")
|
||||
private Long faultValue;
|
||||
|
||||
/**
|
||||
* 查询构造器
|
||||
*/
|
||||
public static FaultCode queryBuild( FaultCodeQueryReq faultCodeQueryReq){
|
||||
return FaultCode.builder()
|
||||
.faultCode(faultCodeQueryReq.getFaultCode())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加构造器
|
||||
*/
|
||||
public static FaultCode saveBuild(FaultCodeSaveReq faultCodeSaveReq){
|
||||
return FaultCode.builder()
|
||||
.faultCode(faultCodeSaveReq.getFaultCode())
|
||||
.faultLabel(faultCodeSaveReq.getFaultLabel())
|
||||
.faultBit(faultCodeSaveReq.getFaultBit())
|
||||
.faultValue(faultCodeSaveReq.getFaultValue())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改构造器
|
||||
*/
|
||||
public static FaultCode editBuild(Long id, FaultCodeEditReq faultCodeEditReq){
|
||||
return FaultCode.builder()
|
||||
.id(id)
|
||||
.faultCode(faultCodeEditReq.getFaultCode())
|
||||
.faultLabel(faultCodeEditReq.getFaultLabel())
|
||||
.faultBit(faultCodeEditReq.getFaultBit())
|
||||
.faultValue(faultCodeEditReq.getFaultValue())
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
package com.zhiLian.vehicle.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.zhiLian.common.core.annotation.Excel;
|
||||
import com.zhiLian.vehicle.domain.req.FaultRecordEditReq;
|
||||
import com.zhiLian.vehicle.domain.req.FaultRecordQueryReq;
|
||||
import com.zhiLian.vehicle.domain.req.FaultRecordSaveReq;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
/**
|
||||
* 故障记录对象 fault_record
|
||||
* @date 2024-06-20
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("fault_record")
|
||||
@ApiModel(value = "FaultRecord", description = "故障记录")
|
||||
public class FaultRecord {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键 */
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
@ApiModelProperty(name = "主键", value = "主键")
|
||||
private Long id;
|
||||
|
||||
/** 故障码 */
|
||||
@Excel(name = "故障码")
|
||||
@ApiModelProperty(name = "故障码", value = "故障码")
|
||||
private String faultCode;
|
||||
|
||||
/** 车辆vin */
|
||||
@Excel(name = "车辆vin")
|
||||
@ApiModelProperty(name = "车辆vin", value = "车辆vin")
|
||||
private String vin;
|
||||
|
||||
/** 故障开始时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "故障开始时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(name = "故障开始时间", value = "故障开始时间")
|
||||
private Date startTime;
|
||||
|
||||
/** 故障结束时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "故障结束时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(name = "故障结束时间", value = "故障结束时间")
|
||||
private Date endTime;
|
||||
|
||||
/** 故障级别 */
|
||||
@Excel(name = "故障级别")
|
||||
@ApiModelProperty(name = "故障级别", value = "故障级别")
|
||||
private String faultLevel;
|
||||
|
||||
/** 故障是否处理 */
|
||||
@Excel(name = "故障是否处理")
|
||||
@ApiModelProperty(name = "故障是否处理", value = "故障是否处理")
|
||||
private String faultHandle;
|
||||
|
||||
/**
|
||||
* 查询构造器
|
||||
*/
|
||||
public static FaultRecord queryBuild( FaultRecordQueryReq faultRecordQueryReq){
|
||||
return FaultRecord.builder()
|
||||
.faultCode(faultRecordQueryReq.getFaultCode())
|
||||
.vin(faultRecordQueryReq.getVin())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加构造器
|
||||
*/
|
||||
public static FaultRecord saveBuild(FaultRecordSaveReq faultRecordSaveReq){
|
||||
return FaultRecord.builder()
|
||||
.faultCode(faultRecordSaveReq.getFaultCode())
|
||||
.vin(faultRecordSaveReq.getVin())
|
||||
.startTime(faultRecordSaveReq.getStartTime())
|
||||
.endTime(faultRecordSaveReq.getEndTime())
|
||||
.faultLevel(faultRecordSaveReq.getFaultLevel())
|
||||
.faultHandle(faultRecordSaveReq.getFaultHandle())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改构造器
|
||||
*/
|
||||
public static FaultRecord editBuild(Long id, FaultRecordEditReq faultRecordEditReq){
|
||||
return FaultRecord.builder()
|
||||
.id(id)
|
||||
.faultCode(faultRecordEditReq.getFaultCode())
|
||||
.vin(faultRecordEditReq.getVin())
|
||||
.startTime(faultRecordEditReq.getStartTime())
|
||||
.endTime(faultRecordEditReq.getEndTime())
|
||||
.faultLevel(faultRecordEditReq.getFaultLevel())
|
||||
.faultHandle(faultRecordEditReq.getFaultHandle())
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
|
@ -19,8 +19,6 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* 围栏对象 fence
|
||||
*
|
||||
* @author muyu
|
||||
* @date 2024-05-31
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -17,8 +17,6 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
|||
|
||||
/**
|
||||
* 围栏组对象 group
|
||||
*
|
||||
* @author muyu
|
||||
* @date 2024-06-02
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.zhiLian.vehicle.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.zhiLian.common.core.annotation.Excel;
|
||||
import com.zhiLian.common.core.web.domain.BaseEntity;
|
||||
|
@ -13,8 +14,6 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
|||
|
||||
/**
|
||||
* 车辆录入对象 vehicle
|
||||
*
|
||||
* @author muyu
|
||||
* @date 2024-05-27
|
||||
*/
|
||||
@Data
|
||||
|
@ -59,8 +58,9 @@ public class Vehicle extends BaseEntity
|
|||
private Long batteryNumber;
|
||||
|
||||
/** 企业ID */
|
||||
// @Excel(name = "企业ID")
|
||||
// private Long businessId;
|
||||
@Excel(name = "企业ID")
|
||||
@TableField(value = "business_id")
|
||||
private Long businessId;
|
||||
|
||||
@Excel(name="围栏组ID")
|
||||
private Long groupId;
|
||||
|
|
|
@ -7,7 +7,6 @@ import lombok.experimental.SuperBuilder;
|
|||
|
||||
/**
|
||||
* 车辆信息
|
||||
* @author YunFei.Du
|
||||
* @date 9:03 2024/6/4
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
package com.zhiLian.vehicle.domain.req;
|
||||
|
||||
import com.zhiLian.common.core.web.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
/**
|
||||
* 车辆故障码对象 fault_code
|
||||
*
|
||||
* @author hbr
|
||||
* @date 2024-06-20
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "FaultCodeEditReq", description = "车辆故障码")
|
||||
public class FaultCodeEditReq {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 故障码 */
|
||||
@ApiModelProperty(name = "故障码", value = "故障码")
|
||||
private String faultCode;
|
||||
|
||||
/** 故障标签 */
|
||||
@ApiModelProperty(name = "故障标签", value = "故障标签")
|
||||
private String faultLabel;
|
||||
|
||||
/** 故障位 */
|
||||
@ApiModelProperty(name = "故障位", value = "故障位")
|
||||
private Long faultBit;
|
||||
|
||||
/** 故障值 */
|
||||
@ApiModelProperty(name = "故障值", value = "故障值")
|
||||
private Long faultValue;
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.zhiLian.vehicle.domain.req;
|
||||
|
||||
import com.zhiLian.common.core.web.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
/**
|
||||
* 车辆故障码对象 fault_code
|
||||
*
|
||||
* @author hbr
|
||||
* @date 2024-06-20
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "FaultCodeQueryReq", description = "车辆故障码")
|
||||
public class FaultCodeQueryReq {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 故障码 */
|
||||
@ApiModelProperty(name = "故障码", value = "故障码")
|
||||
private String faultCode;
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package com.zhiLian.vehicle.domain.req;
|
||||
|
||||
import com.zhiLian.common.core.web.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 车辆故障码对象 fault_code
|
||||
*
|
||||
* @author hbr
|
||||
* @date 2024-06-20
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "FaultCodeSaveReq", description = "车辆故障码")
|
||||
public class FaultCodeSaveReq {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键 */
|
||||
|
||||
@ApiModelProperty(name = "主键", value = "主键")
|
||||
private Long id;
|
||||
|
||||
/** 故障码 */
|
||||
|
||||
@ApiModelProperty(name = "故障码", value = "故障码")
|
||||
private String faultCode;
|
||||
|
||||
/** 故障标签 */
|
||||
|
||||
@ApiModelProperty(name = "故障标签", value = "故障标签")
|
||||
private String faultLabel;
|
||||
|
||||
/** 故障位 */
|
||||
|
||||
@ApiModelProperty(name = "故障位", value = "故障位")
|
||||
private Long faultBit;
|
||||
|
||||
/** 故障值 */
|
||||
|
||||
@ApiModelProperty(name = "故障值", value = "故障值")
|
||||
private Long faultValue;
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.zhiLian.vehicle.domain.req;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
/**
|
||||
* 故障记录对象 fault_record
|
||||
*
|
||||
* @author hbr
|
||||
* @date 2024-06-20
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "FaultRecordEditReq", description = "故障记录")
|
||||
public class FaultRecordEditReq {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 故障码 */
|
||||
@ApiModelProperty(name = "故障码", value = "故障码")
|
||||
private String faultCode;
|
||||
|
||||
/** 车辆vin */
|
||||
@ApiModelProperty(name = "车辆vin", value = "车辆vin")
|
||||
private String vin;
|
||||
|
||||
/** 故障开始时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@ApiModelProperty(name = "故障开始时间", value = "故障开始时间")
|
||||
private Date startTime;
|
||||
|
||||
/** 故障结束时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@ApiModelProperty(name = "故障结束时间", value = "故障结束时间")
|
||||
private Date endTime;
|
||||
|
||||
/** 故障级别 */
|
||||
@ApiModelProperty(name = "故障级别", value = "故障级别")
|
||||
private String faultLevel;
|
||||
|
||||
/** 故障是否处理 */
|
||||
@ApiModelProperty(name = "故障是否处理", value = "故障是否处理")
|
||||
private String faultHandle;
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.zhiLian.vehicle.domain.req;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
|
||||
/**
|
||||
* 故障记录对象 fault_record
|
||||
*
|
||||
* @author hbr
|
||||
* @date 2024-06-20
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "FaultRecordQueryReq", description = "故障记录")
|
||||
public class FaultRecordQueryReq {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 故障码 */
|
||||
@ApiModelProperty(name = "故障码", value = "故障码")
|
||||
private String faultCode;
|
||||
|
||||
/** 车辆vin */
|
||||
@ApiModelProperty(name = "车辆vin", value = "车辆vin")
|
||||
private String vin;
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package com.zhiLian.vehicle.domain.req;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 故障记录对象 fault_record
|
||||
*
|
||||
* @author hbr
|
||||
* @date 2024-06-20
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class FaultRecordReqVo {
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date max;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date min;
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package com.zhiLian.vehicle.domain.req;
|
||||
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
/**
|
||||
* 故障记录对象 fault_record
|
||||
*
|
||||
* @author hbr
|
||||
* @date 2024-06-20
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel(value = "FaultRecordSaveReq", description = "故障记录")
|
||||
public class FaultRecordSaveReq {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键 */
|
||||
|
||||
@ApiModelProperty(name = "主键", value = "主键")
|
||||
private Long id;
|
||||
|
||||
/** 故障码 */
|
||||
|
||||
@ApiModelProperty(name = "故障码", value = "故障码")
|
||||
private String faultCode;
|
||||
|
||||
/** 车辆vin */
|
||||
|
||||
@ApiModelProperty(name = "车辆vin", value = "车辆vin")
|
||||
private String vin;
|
||||
|
||||
/** 故障开始时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
|
||||
@ApiModelProperty(name = "故障开始时间", value = "故障开始时间")
|
||||
private Date startTime;
|
||||
|
||||
/** 故障结束时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
|
||||
@ApiModelProperty(name = "故障结束时间", value = "故障结束时间")
|
||||
private Date endTime;
|
||||
|
||||
/** 故障级别 */
|
||||
|
||||
@ApiModelProperty(name = "故障级别", value = "故障级别")
|
||||
private String faultLevel;
|
||||
|
||||
/** 故障是否处理 */
|
||||
|
||||
@ApiModelProperty(name = "故障是否处理", value = "故障是否处理")
|
||||
private String faultHandle;
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.zhiLian.vehicle.domain.vo;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* BingRui.Hou
|
||||
*
|
||||
* @Description 描述
|
||||
* @ClassName FaultRecordVo
|
||||
* @Date 2024/06/21 11:44
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class FaultRecordVo {
|
||||
private String faultCode;
|
||||
|
||||
private String vin;
|
||||
|
||||
private Integer count;
|
||||
|
||||
private String faultLabel;
|
||||
}
|
|
@ -8,8 +8,6 @@ import lombok.experimental.SuperBuilder;
|
|||
|
||||
/**
|
||||
* 车辆录入对象 vehicle
|
||||
*
|
||||
* @author muyu
|
||||
* @date 2024-05-27
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -11,8 +11,6 @@ import lombok.experimental.SuperBuilder;
|
|||
|
||||
/**
|
||||
* 车辆录入对象 vehicle
|
||||
*
|
||||
* @author muyu
|
||||
* @date 2024-05-27
|
||||
*/
|
||||
@Data
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
package com.zhiLian.vehicle.job;
|
||||
|
||||
|
||||
import com.zhiLian.common.redis.service.RedisService;
|
||||
import com.zhiLian.vehicle.datasource.config.holder.DynamicDataSourceHolder;
|
||||
import com.zhiLian.vehicle.domain.Vehicle;
|
||||
import com.zhiLian.vehicle.mapper.VehicleMapper;
|
||||
import com.zhiLian.vehicle.service.IVehicleService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* BingRui.Hou
|
||||
*
|
||||
* @Description 描述
|
||||
* @ClassName ManyJob
|
||||
* @Date 2024/06/20 17:34
|
||||
*/
|
||||
@Component
|
||||
@Log4j2
|
||||
public class ManyJob {
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<String,String> redisTemplate;
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
@Autowired
|
||||
private VehicleMapper vehicleService;
|
||||
|
||||
@Scheduled(cron = "0 0 0 * * ?")// 每10分钟执行一次
|
||||
public void manyJob(){
|
||||
DynamicDataSourceHolder.setDynamicDataSourceKey("test_00");
|
||||
List<Vehicle> list = vehicleService.selectVehicleListAll(new Vehicle());
|
||||
ExecutorService executor = Executors.newFixedThreadPool(list.size());
|
||||
list.forEach(vehicle -> {
|
||||
executor.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
redisTemplate
|
||||
.opsForValue()
|
||||
.set(vehicle.getNumber()+"1",
|
||||
String.valueOf(vehicle.getBusinessId()));
|
||||
}
|
||||
});
|
||||
});
|
||||
DynamicDataSourceHolder.removeDynamicDataSourceKey();
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.zhiLian.vehicle.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zhiLian.vehicle.domain.FaultCode;
|
||||
|
||||
/**
|
||||
* 车辆故障码Mapper接口
|
||||
*
|
||||
* @author chx
|
||||
* @date 2024-06-20
|
||||
*/
|
||||
public interface FaultCodeMapper extends BaseMapper<FaultCode> {
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.zhiLian.vehicle.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zhiLian.vehicle.domain.FaultRecord;
|
||||
import com.zhiLian.vehicle.domain.req.FaultRecordReqVo;
|
||||
import com.zhiLian.vehicle.domain.vo.FaultRecordVo;
|
||||
|
||||
/**
|
||||
* 故障记录Mapper接口
|
||||
*
|
||||
* @author chx
|
||||
* @date 2024-06-20
|
||||
*/
|
||||
public interface FaultRecordMapper extends BaseMapper<FaultRecord> {
|
||||
|
||||
void updateByFaultRecord(FaultRecord build);
|
||||
|
||||
FaultRecord getByFaultRecord(FaultRecord faultRecord);
|
||||
|
||||
List<FaultRecordVo> countList(FaultRecordReqVo recordReqVo);
|
||||
|
||||
|
||||
}
|
|
@ -61,4 +61,6 @@ public interface VehicleMapper extends BaseMapper<Vehicle>
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteVehicleByIds(Long[] ids);
|
||||
|
||||
List<Vehicle> selectVehicleListAll(Vehicle vehicle);
|
||||
}
|
||||
|
|
|
@ -1,66 +0,0 @@
|
|||
//package com.zhiLian.vehicle.rabbitmq.config;//package com.bwie.sms.config;
|
||||
//
|
||||
//
|
||||
//import com.rabbitmq.client.Channel;
|
||||
//import lombok.extern.log4j.Log4j2;
|
||||
//import org.springframework.amqp.core.Message;
|
||||
//import org.springframework.amqp.rabbit.annotation.Queue;
|
||||
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.data.redis.core.RedisTemplate;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//import java.io.IOException;
|
||||
//import java.util.HashMap;
|
||||
//
|
||||
///**
|
||||
// * @BelongsProject: Bob_Up_Like_A_Cork
|
||||
// * @BelongsPackage: com.bwie.sms.config
|
||||
// * @Author: zhangquan
|
||||
// * @CreateTime: 2023/7/30 20:48
|
||||
// */
|
||||
//@Component
|
||||
//@Log4j2
|
||||
//public class SendCodeConfig {
|
||||
// @Autowired
|
||||
// private RedisTemplate<String, String> redisTemplate;
|
||||
//
|
||||
// //调用注解 添加队列名称
|
||||
// @RabbitListener(queuesToDeclare = {@Queue(name = "zhiLian-vehicle-exchange")})
|
||||
// public void smsConfig(String msg, Message message, Channel channel){
|
||||
// //获取消息的ID
|
||||
// String messageId = message.getMessageProperties().getMessageId();
|
||||
// try {
|
||||
// //添加消息id到redis set集合中 添加成功返回1 表示未消费 添加失败返回0 表示已消费
|
||||
// Long count = redisTemplate.opsForSet().add("messageId", messageId);
|
||||
// //添加成功 正常消费信息
|
||||
// if (count == 1) {
|
||||
// log.info("开始消费");
|
||||
// //将业务层接受的数据反序列为请求类对象
|
||||
//
|
||||
// //调用工具类发送验证码
|
||||
//
|
||||
// //反序列化
|
||||
//
|
||||
//
|
||||
// //判断是否发送成功 不成功继续发送
|
||||
//
|
||||
// //确认消费
|
||||
// channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
|
||||
// log.info("消费成功");
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// //删除队列ID
|
||||
//
|
||||
// log.info("消费重复");
|
||||
// try {
|
||||
// //回退消息
|
||||
// channel.basicReject(message.getMessageProperties().getDeliveryTag(),true);
|
||||
// log.info("消费失败");
|
||||
// } catch (IOException ex) {
|
||||
// //回退失败
|
||||
// log.info("消费异常");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
|
@ -0,0 +1,152 @@
|
|||
package com.zhiLian.vehicle.rabbitmq.producer;
|
||||
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import com.zhiLian.vehicle.datasource.config.holder.DynamicDataSourceHolder;
|
||||
import com.zhiLian.vehicle.domain.FaultRecord;
|
||||
import com.zhiLian.vehicle.domain.Vehicle;
|
||||
import com.zhiLian.vehicle.mapper.VehicleMapper;
|
||||
import com.zhiLian.vehicle.service.FaultRecordService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.rabbit.annotation.Queue;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
/**
|
||||
* @BelongsProject: Bob_Up_Like_A_Cork
|
||||
* @BelongsPackage: com.bwie.sms.config
|
||||
* @Author: zhangquan
|
||||
* @CreateTime: 2023/7/30 20:48
|
||||
*/
|
||||
@Component
|
||||
@Log4j2
|
||||
public class VehicleProducer {
|
||||
@Autowired
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
|
||||
@Autowired
|
||||
private FaultRecordService faultRecordService;
|
||||
|
||||
@Autowired
|
||||
private VehicleMapper vehicleService;
|
||||
|
||||
|
||||
public void manyJob(){
|
||||
DynamicDataSourceHolder.setDynamicDataSourceKey("test_00");
|
||||
List<Vehicle> list = vehicleService.selectVehicleListAll(new Vehicle());
|
||||
ExecutorService executor = Executors.newFixedThreadPool(list.size());
|
||||
list.forEach(vehicle -> {
|
||||
executor.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
redisTemplate
|
||||
.opsForValue()
|
||||
.set(vehicle.getNumber()+"1",
|
||||
String.valueOf(vehicle.getBusinessId()));
|
||||
}
|
||||
});
|
||||
});
|
||||
DynamicDataSourceHolder.removeDynamicDataSourceKey();
|
||||
|
||||
}
|
||||
//调用注解 添加队列名称
|
||||
@RabbitListener(queuesToDeclare = {@Queue(name = "zhiLian-vehicle-start")})
|
||||
public void smsConfigStart(String msg, Message message, Channel channel){
|
||||
//获取消息的ID
|
||||
String messageId = message.getMessageProperties().getMessageId();
|
||||
try {
|
||||
Long count = redisTemplate.opsForSet().add("messageId", messageId);
|
||||
if (count==1) {
|
||||
log.info("故障开始消费!{}", msg);
|
||||
manyJob();
|
||||
FaultRecord faultRecord = JSON.parseObject(msg, FaultRecord.class);
|
||||
//判断车辆属于哪个企业
|
||||
String s = redisTemplate.opsForValue().get(faultRecord.getVin()+"1");
|
||||
// 进行添加故障表
|
||||
Executors.newFixedThreadPool(1).execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
//选择数据源,切换数据源,
|
||||
DynamicDataSourceHolder.setDynamicDataSourceKey("test_"+Integer.valueOf(s));
|
||||
FaultRecord build = FaultRecord
|
||||
.builder()
|
||||
.faultCode(faultRecord.getFaultCode())
|
||||
.vin(faultRecord.getVin())
|
||||
.startTime(faultRecord.getStartTime()).build();
|
||||
faultRecordService.save(build);
|
||||
// 移除数据源,
|
||||
DynamicDataSourceHolder.removeDynamicDataSourceKey();
|
||||
}
|
||||
});
|
||||
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
|
||||
log.info("消费成功!数据源为:{}",message);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.info("消费失败,{}",e.getMessage());
|
||||
try {
|
||||
//回退消息
|
||||
channel.basicReject(message.getMessageProperties().getDeliveryTag(),false);
|
||||
log.info("回退成功");
|
||||
}catch (IOException ex){
|
||||
log.info("回退失败:{}",ex.getMessage());
|
||||
}
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
@RabbitListener(queuesToDeclare = {@Queue(name = "zhiLian-vehicle-end")})
|
||||
public void smsConfigEnt(String msg, Message message, Channel channel){
|
||||
//获取消息的ID
|
||||
String messageId = message.getMessageProperties().getMessageId();
|
||||
try {
|
||||
//添加消息id到redis set集合中 添加成功返回1 表示未消费 添加失败返回0 表示已消费
|
||||
Long count = redisTemplate.opsForSet().add("messageId", messageId);
|
||||
//添加成功 正常消费信息
|
||||
if (count == 1) {
|
||||
log.info("故障结束消费:{}",msg);
|
||||
manyJob();
|
||||
FaultRecord faultRecord = JSON.parseObject(msg, FaultRecord.class);
|
||||
//判断车辆属于哪个企业
|
||||
String s = redisTemplate.opsForValue().get(faultRecord.getVin()+"1");
|
||||
|
||||
Executors.newFixedThreadPool(1).execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
//选择数据源,切换数据源,
|
||||
DynamicDataSourceHolder.setDynamicDataSourceKey("test_"+Integer.valueOf(s));
|
||||
// 进行查询故障表
|
||||
FaultRecord faultRecordOne = faultRecordService.getByFaultRecord(faultRecord);
|
||||
log.info("查询到的故障为:{}",faultRecordOne);
|
||||
faultRecordOne.setEndTime(faultRecord.getEndTime());
|
||||
// 进行修改故障表
|
||||
faultRecordService.updateByFaultRecord(faultRecordOne);
|
||||
// 移除数据源,
|
||||
DynamicDataSourceHolder.removeDynamicDataSourceKey();
|
||||
}
|
||||
});
|
||||
//确认消费
|
||||
channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
|
||||
log.info("消费成功");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//删除队列ID
|
||||
log.info("消费失败,{}",e.getMessage());
|
||||
try {
|
||||
//回退消息
|
||||
channel.basicReject(message.getMessageProperties().getDeliveryTag(),false);
|
||||
log.info("回退消息");
|
||||
} catch (IOException ex) {
|
||||
//回退失败
|
||||
log.info("回退失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.zhiLian.vehicle.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zhiLian.vehicle.domain.FaultCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 车辆故障码Service接口
|
||||
*
|
||||
* @author chx
|
||||
* @date 2024-06-20
|
||||
*/
|
||||
public interface FaultCodeService extends IService<FaultCode> {
|
||||
/**
|
||||
* 查询车辆故障码列表
|
||||
*
|
||||
* @param faultCode 车辆故障码
|
||||
* @return 车辆故障码集合
|
||||
*/
|
||||
public List<FaultCode> list(FaultCode faultCode);
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.zhiLian.vehicle.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zhiLian.vehicle.domain.FaultRecord;
|
||||
import com.zhiLian.vehicle.domain.req.FaultRecordReqVo;
|
||||
import com.zhiLian.vehicle.domain.vo.FaultRecordVo;
|
||||
|
||||
/**
|
||||
* 故障记录Service接口
|
||||
*
|
||||
* @author chx
|
||||
* @date 2024-06-20
|
||||
*/
|
||||
public interface FaultRecordService extends IService<FaultRecord> {
|
||||
/**
|
||||
* 查询故障记录列表
|
||||
*
|
||||
* @param faultRecord 故障记录
|
||||
* @return 故障记录集合
|
||||
*/
|
||||
public List<FaultRecord> list(FaultRecord faultRecord);
|
||||
|
||||
void updateByFaultRecord(FaultRecord build);
|
||||
|
||||
FaultRecord getByFaultRecord(FaultRecord faultRecord);
|
||||
|
||||
List<FaultRecordVo> countList(FaultRecordReqVo recordReqVo);
|
||||
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package com.zhiLian.vehicle.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import com.zhiLian.common.core.utils.StringUtils;
|
||||
import com.zhiLian.vehicle.domain.FaultCode;
|
||||
import com.zhiLian.vehicle.mapper.FaultCodeMapper;
|
||||
import com.zhiLian.vehicle.service.FaultCodeService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
|
||||
/**
|
||||
* 车辆故障码Service业务层处理
|
||||
*
|
||||
* @author chx
|
||||
* @date 2024-06-20
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class FaultCodeServiceImpl extends ServiceImpl<FaultCodeMapper, FaultCode> implements FaultCodeService {
|
||||
|
||||
/**
|
||||
* 查询车辆故障码列表
|
||||
*
|
||||
* @param faultCode 车辆故障码
|
||||
* @return 车辆故障码
|
||||
*/
|
||||
@Override
|
||||
public List<FaultCode> list(FaultCode faultCode) {
|
||||
LambdaQueryWrapper<FaultCode> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
|
||||
if (StringUtils.isNotEmpty(faultCode.getFaultCode())){
|
||||
queryWrapper.eq(FaultCode::getFaultCode, faultCode.getFaultCode());
|
||||
}
|
||||
|
||||
|
||||
|
||||
return list(queryWrapper);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package com.zhiLian.vehicle.service.impl;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhiLian.common.core.utils.StringUtils;
|
||||
import com.zhiLian.vehicle.domain.FaultRecord;
|
||||
import com.zhiLian.vehicle.domain.req.FaultRecordReqVo;
|
||||
import com.zhiLian.vehicle.domain.vo.FaultRecordVo;
|
||||
import com.zhiLian.vehicle.mapper.FaultRecordMapper;
|
||||
import com.zhiLian.vehicle.service.FaultRecordService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 故障记录Service业务层处理
|
||||
*
|
||||
* @author chx
|
||||
* @date 2024-06-20
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class FaultRecordServiceImpl extends ServiceImpl<FaultRecordMapper, FaultRecord> implements FaultRecordService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private FaultRecordMapper faultRecordMapper;
|
||||
/**
|
||||
* 查询故障记录列表
|
||||
*
|
||||
* @param faultRecord 故障记录
|
||||
* @return 故障记录
|
||||
*/
|
||||
@Override
|
||||
public List<FaultRecord> list(FaultRecord faultRecord) {
|
||||
LambdaQueryWrapper<FaultRecord> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
|
||||
if (StringUtils.isNotEmpty(faultRecord.getFaultCode())){
|
||||
queryWrapper.eq(FaultRecord::getFaultCode, faultRecord.getFaultCode());
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(faultRecord.getVin())){
|
||||
queryWrapper.eq(FaultRecord::getVin, faultRecord.getVin());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByFaultRecord(FaultRecord build) {
|
||||
faultRecordMapper.updateByFaultRecord(build);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FaultRecord getByFaultRecord(FaultRecord faultRecord) {
|
||||
return faultRecordMapper.getByFaultRecord(faultRecord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FaultRecordVo> countList(FaultRecordReqVo recordReqVo) {
|
||||
return faultRecordMapper.countList(recordReqVo);
|
||||
}
|
||||
}
|
|
@ -15,6 +15,7 @@ spring:
|
|||
prefetch: 1 # 每次只能获取一条,处理完成才能获取下一条
|
||||
publisher-confirm-type: correlated #确认消息已发送到交换机(Exchange)
|
||||
publisher-returns: true #确
|
||||
|
||||
main:
|
||||
allow-circular-references: true
|
||||
application:
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
<?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.zhiLian.vehicle.mapper.FaultRecordMapper">
|
||||
|
||||
<resultMap type="com.zhiLian.vehicle.domain.FaultRecord" id="FaultRecordResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="faultCode" column="fault_code" />
|
||||
<result property="vin" column="vin" />
|
||||
<result property="startTime" column="start_time" />
|
||||
<result property="endTime" column="end_time" />
|
||||
<result property="faultLevel" column="fault_level" />
|
||||
<result property="faultHandle" column="fault_handle" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectFaultRecordVo">
|
||||
select id, fault_code, vin, start_time, end_time, fault_level, fault_handle from fault_record
|
||||
</sql>
|
||||
<update id="updateByFaultRecord">
|
||||
update fault_record set end_time=#{endTime} where id=#{id}
|
||||
</update>
|
||||
<select id="getByFaultRecord" resultType="com.zhiLian.vehicle.domain.FaultRecord">
|
||||
SELECT id,fault_code,vin,start_time,end_time,fault_level,fault_handle
|
||||
FROM fault_record
|
||||
WHERE fault_code =#{faultCode} AND vin = #{vin} AND end_time is NULL
|
||||
</select>
|
||||
<select id="countList" resultType="com.zhiLian.vehicle.domain.vo.FaultRecordVo">
|
||||
SELECT
|
||||
fr.vin,
|
||||
fr.fault_code,
|
||||
fc.fault_label,
|
||||
COUNT(*) AS count
|
||||
FROM
|
||||
fault_record fr
|
||||
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>
|
||||
</mapper>
|
|
@ -0,0 +1,18 @@
|
|||
<?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.zhiLian.vehicle.mapper.FaultCodeMapper">
|
||||
|
||||
<resultMap type="com.zhiLian.vehicle.domain.FaultCode" id="FaultCodeResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="faultCode" column="fault_code" />
|
||||
<result property="faultLabel" column="fault_label" />
|
||||
<result property="faultBit" column="fault_bit" />
|
||||
<result property="faultValue" column="fault_value" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectFaultCodeVo">
|
||||
select id, fault_code, fault_label, fault_bit, fault_value from fault_code
|
||||
</sql>
|
||||
</mapper>
|
|
@ -46,6 +46,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<include refid="selectVehicleVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
<select id="selectVehicleListAll" resultType="com.zhiLian.vehicle.domain.Vehicle">
|
||||
select * from vehicle
|
||||
</select>
|
||||
|
||||
<insert id="insertVehicle" parameterType="com.zhiLian.vehicle.domain.Vehicle">
|
||||
insert into vehicle
|
||||
|
|
Loading…
Reference in New Issue