Merge branch 'master' of https://gitea.qinmian.online/first-dev/smart-cloud-server
# Conflicts: # zhilian-common/zhilian-common-business/src/main/java/com/zhilian/business/remote/RemoteVehicleService.java # zhilian-common/zhilian-common-business/src/main/java/com/zhilian/business/remote/factory/RemoteVehicleFallbackFactory.java # zhilian-modules/zhilian-business/src/main/java/com/zhilian/business/controller/VehicleMarkersController.java # zhilian-modules/zhilian-business/src/main/java/com/zhilian/business/controller/VehicleTypeController.java # zhilian-modules/zhilian-business/src/main/java/com/zhilian/business/mapper/VehicleTypeMapper.java # zhilian-modules/zhilian-business/src/main/java/com/zhilian/business/service/VehicleMarkersService.java # zhilian-modules/zhilian-business/src/main/java/com/zhilian/business/service/impl/MarkersFenceServiceImpl.java # zhilian-modules/zhilian-business/src/main/java/com/zhilian/business/service/impl/VehicleMarkersServiceImpl.java # zhilian-modules/zhilian-business/src/main/java/com/zhilian/business/service/impl/VehicleServiceImpl.javamaster_suzejing
commit
3c1b9cef33
|
@ -0,0 +1,43 @@
|
||||||
|
package com.zhilian.business.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName Break
|
||||||
|
* @Description 故障实体类
|
||||||
|
* @Author YuanYongH
|
||||||
|
* @Date 2024/4/4 9:40
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class Break {
|
||||||
|
/**
|
||||||
|
* 故障id
|
||||||
|
**/
|
||||||
|
private Integer breakId;
|
||||||
|
/**
|
||||||
|
* 故障码
|
||||||
|
**/
|
||||||
|
private String breakCode;
|
||||||
|
/**
|
||||||
|
* 车辆VIN
|
||||||
|
**/
|
||||||
|
private String breakVin;
|
||||||
|
/**
|
||||||
|
* 开始报警时间
|
||||||
|
**/
|
||||||
|
private Date breakDate;
|
||||||
|
/**
|
||||||
|
* 结束报警时间
|
||||||
|
**/
|
||||||
|
private Date breakTime;
|
||||||
|
/**
|
||||||
|
* 故障类型
|
||||||
|
**/
|
||||||
|
private String breakType;
|
||||||
|
/**
|
||||||
|
* 故障状态 是否警告
|
||||||
|
**/
|
||||||
|
private Integer breakState;
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.zhilian.business.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName BreakLog
|
||||||
|
* @Description TODO
|
||||||
|
* @Author YuanYongH
|
||||||
|
* @Date 2024/4/8 15:07
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class BreakLog {
|
||||||
|
|
||||||
|
/** 故障日志id */
|
||||||
|
private Integer breakLogId;
|
||||||
|
/** 故障码 */
|
||||||
|
private String breakCode;
|
||||||
|
/** 车辆VIN */
|
||||||
|
private String breakVin;
|
||||||
|
/** 故障类型 */
|
||||||
|
private String breakType;
|
||||||
|
/** 结束报警时间 */
|
||||||
|
private String breakTime;
|
||||||
|
/** 开始报警时间 */
|
||||||
|
private String breakDate;
|
||||||
|
/** 是否报警 */
|
||||||
|
private String breakState;
|
||||||
|
}
|
|
@ -0,0 +1,113 @@
|
||||||
|
package com.zhilian.business.domain;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.zhilian.common.core.annotation.Excel;
|
||||||
|
import com.zhilian.common.core.web.domain.BaseEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 故障对象 business_break
|
||||||
|
*
|
||||||
|
* @author Yy
|
||||||
|
* @date 2024-04-07
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class BusinessBreak extends BaseEntity
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** id */
|
||||||
|
private Long breakId;
|
||||||
|
|
||||||
|
/** 故障码 */
|
||||||
|
@Excel(name = "故障码")
|
||||||
|
private String breakCode;
|
||||||
|
|
||||||
|
/** 车辆VIN */
|
||||||
|
@Excel(name = "车辆VIN")
|
||||||
|
private String breakVin;
|
||||||
|
|
||||||
|
/** 结束报警时间 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
@Excel(name = "结束报警时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
|
private Date breakTime;
|
||||||
|
|
||||||
|
/** 故障类型 */
|
||||||
|
@Excel(name = "故障类型")
|
||||||
|
private String breakType;
|
||||||
|
|
||||||
|
/** 开始报警时间 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
@Excel(name = "开始报警时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
|
private Date breakDate;
|
||||||
|
|
||||||
|
/** 是否警告 */
|
||||||
|
@Excel(name = "是否警告")
|
||||||
|
private String breakState;
|
||||||
|
|
||||||
|
public void setBreakId(Long breakId)
|
||||||
|
{
|
||||||
|
this.breakId = breakId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getBreakId()
|
||||||
|
{
|
||||||
|
return breakId;
|
||||||
|
}
|
||||||
|
public void setBreakCode(String breakCode)
|
||||||
|
{
|
||||||
|
this.breakCode = breakCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBreakCode()
|
||||||
|
{
|
||||||
|
return breakCode;
|
||||||
|
}
|
||||||
|
public void setBreakVin(String breakVin)
|
||||||
|
{
|
||||||
|
this.breakVin = breakVin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBreakVin()
|
||||||
|
{
|
||||||
|
return breakVin;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setBreakType(String breakType)
|
||||||
|
{
|
||||||
|
this.breakType = breakType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBreakType()
|
||||||
|
{
|
||||||
|
return breakType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBreakState(String breakState)
|
||||||
|
{
|
||||||
|
this.breakState = breakState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBreakState()
|
||||||
|
{
|
||||||
|
return breakState;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
.append("breakId", getBreakId())
|
||||||
|
.append("breakCode", getBreakCode())
|
||||||
|
.append("breakVin", getBreakVin())
|
||||||
|
.append("breakTime", getBreakTime())
|
||||||
|
.append("breakType", getBreakType())
|
||||||
|
.append("breakDate", getBreakDate())
|
||||||
|
.append("breakState", getBreakState())
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.zhilian.business.remote;
|
||||||
|
|
||||||
|
import com.zhilian.business.domain.Break;
|
||||||
|
import com.zhilian.business.domain.BusinessBreak;
|
||||||
|
import com.zhilian.business.remote.factory.RemoteBreakFallbackFactory;
|
||||||
|
import com.zhilian.common.core.constant.ServiceNameConstants;
|
||||||
|
import com.zhilian.common.core.domain.Result;
|
||||||
|
import lombok.extern.java.Log;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
|
@FeignClient(contextId = "remoteBreakService", value = ServiceNameConstants.BUSINESS_SERVICE, fallbackFactory = RemoteBreakFallbackFactory.class)
|
||||||
|
public interface RemoteBreakService {
|
||||||
|
/**
|
||||||
|
* 新增故障
|
||||||
|
*/
|
||||||
|
@PostMapping
|
||||||
|
public Result add(@RequestBody BusinessBreak businessBreak);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.zhilian.business.remote;
|
||||||
|
|
||||||
|
import com.zhilian.business.domain.Vehicle;
|
||||||
|
import com.zhilian.business.remote.factory.RemoteVehicleFallbackFactory;
|
||||||
|
import com.zhilian.common.core.constant.ServiceNameConstants;
|
||||||
|
import com.zhilian.common.core.domain.Result;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
|
@FeignClient(contextId = "remoteVehicleService", value = ServiceNameConstants.VIEHICLE_SERVICE, fallbackFactory = RemoteVehicleFallbackFactory.class)
|
||||||
|
public interface RemoteVehicleService {
|
||||||
|
// @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||||
|
// public Result<SysFile> upload (@RequestPart(value = "file") MultipartFile file);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据VIN获取车辆信息
|
||||||
|
* @param vehicleVIN
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/vehicle/getMarkersByVIN/{vehicleVIN}")
|
||||||
|
public Result<Vehicle> getVehicleByVIN(@PathVariable("vehicleVIN") String vehicleVIN);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新车辆状态
|
||||||
|
* @param vehicle
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/vehicle/updateState")
|
||||||
|
public Result updateState(@RequestBody Vehicle vehicle);
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.zhilian.business.remote.factory;
|
||||||
|
|
||||||
|
import com.zhilian.business.domain.BusinessBreak;
|
||||||
|
import com.zhilian.business.remote.RemoteBreakService;
|
||||||
|
import com.zhilian.common.core.domain.Result;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class RemoteBreakFallbackFactory implements FallbackFactory<RemoteBreakService> {
|
||||||
|
@Override
|
||||||
|
public RemoteBreakService create(Throwable cause) {
|
||||||
|
return new RemoteBreakService() {
|
||||||
|
@Override
|
||||||
|
public Result add(BusinessBreak businessBreak) {
|
||||||
|
log.error("故障日志服务调用失败");
|
||||||
|
return Result.error("故障日志服务调用失败");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.zhilian.business.remote.factory;
|
||||||
|
|
||||||
|
|
||||||
|
import com.zhilian.business.domain.Vehicle;
|
||||||
|
import com.zhilian.business.remote.RemoteVehicleService;
|
||||||
|
import com.zhilian.common.core.domain.Result;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class RemoteVehicleFallbackFactory implements FallbackFactory<RemoteVehicleService> {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(RemoteVehicleFallbackFactory.class);
|
||||||
|
@Override
|
||||||
|
public RemoteVehicleService create(Throwable throwable) {
|
||||||
|
log.error("用户服务调用失败:{}", throwable.getMessage());
|
||||||
|
return new RemoteVehicleService() {
|
||||||
|
@Override
|
||||||
|
public Result<Vehicle> getVehicleByVIN(String vehicleVIN) {
|
||||||
|
return Result.error("获取车辆信息失败:" + throwable.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result updateState(Vehicle vehicle) {
|
||||||
|
return Result.error("更新车辆状态失败:" + throwable.getMessage());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -1 +1,3 @@
|
||||||
com.zhilian.common.business.remote.factory.RemoteVehicleFallbackFactory
|
com.zhilian.business.remote.factory.RemoteBreakFallbackFactory
|
||||||
|
com.zhilian.business.remote.factory.RemoteFenceFallbackFactory
|
||||||
|
com.zhilian.business.remote.factory.RemoteVehicleFallbackFactory
|
||||||
|
|
|
@ -20,6 +20,11 @@ public class ServiceNameConstants {
|
||||||
* 文件服务的serviceid
|
* 文件服务的serviceid
|
||||||
*/
|
*/
|
||||||
public static final String FILE_SERVICE = "zhilian-file";
|
public static final String FILE_SERVICE = "zhilian-file";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 业务服务的serviceid
|
||||||
|
*/
|
||||||
|
public static final String BUSINESS_SERVICE = "zhilian-business";
|
||||||
/**
|
/**
|
||||||
* 车辆服务的serviceid
|
* 车辆服务的serviceid
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.zhilian.business.controller;
|
package com.zhilian.business.controller;
|
||||||
|
|
||||||
|
import com.zhilian.business.domain.middle.VehicleMarkers;
|
||||||
import com.zhilian.business.service.VehicleMarkersService;
|
import com.zhilian.business.service.VehicleMarkersService;
|
||||||
import com.zhilian.common.core.domain.Result;
|
import com.zhilian.common.core.domain.Result;
|
||||||
import com.zhilian.common.core.web.controller.BaseController;
|
import com.zhilian.common.core.web.controller.BaseController;
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
package com.zhilian.business.mapper;
|
package com.zhilian.business.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.zhilian.business.domain.Fence;
|
import com.zhilian.business.domain.Fence;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
package com.zhilian.business.mapper;
|
package com.zhilian.business.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.zhilian.business.domain.middle.MarkersFence;
|
import com.zhilian.business.domain.middle.MarkersFence;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
package com.zhilian.business.mapper;
|
package com.zhilian.business.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.zhilian.business.domain.Markers;
|
import com.zhilian.business.domain.Markers;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
package com.zhilian.business.mapper;
|
package com.zhilian.business.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.zhilian.business.domain.middle.VehicleMarkers;
|
import com.zhilian.business.domain.middle.VehicleMarkers;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.zhilian.business.service;
|
package com.zhilian.business.service;
|
||||||
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.zhilian.business.domain.Markers;
|
import com.zhilian.business.domain.Markers;
|
||||||
import com.zhilian.business.domain.middle.MarkersFence;
|
import com.zhilian.business.domain.middle.MarkersFence;
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
import com.zhilian.business.domain.Vehicle;
|
import com.zhilian.business.domain.Vehicle;
|
||||||
import com.zhilian.business.domain.middle.VehicleMarkers;
|
import com.zhilian.business.domain.middle.VehicleMarkers;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.zhilian.business.service;
|
package com.zhilian.business.service;
|
||||||
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.zhilian.business.domain.VehicleType;
|
import com.zhilian.business.domain.VehicleType;
|
||||||
|
|
||||||
|
|
|
@ -10,11 +10,12 @@ import com.zhilian.business.service.MarkersFenceService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class MarkersFenceServiceImpl extends ServiceImpl<MarkersFenceMapper, MarkersFence> implements MarkersFenceService {
|
public class MarkersFenceServiceImpl extends ServiceImpl<MarkersFenceMapper, MarkersFence> implements MarkersFenceService {
|
||||||
|
@Autowired
|
||||||
|
private MarkersFenceMapper markersFenceMapper;
|
||||||
|
|
||||||
@Override public boolean insert(Markers markers) {
|
@Override public boolean insert(Markers markers) {
|
||||||
ArrayList<MarkersFence> markersFences = new ArrayList<>();
|
ArrayList<MarkersFence> markersFences = new ArrayList<>();
|
||||||
|
|
|
@ -38,7 +38,6 @@ public class VehicleMarkersServiceImpl extends ServiceImpl<VehicleMarkersMapper,
|
||||||
@Transactional(rollbackFor=Exception.class)
|
@Transactional(rollbackFor=Exception.class)
|
||||||
@Override
|
@Override
|
||||||
public boolean insert(Vehicle vehicle) {
|
public boolean insert(Vehicle vehicle) {
|
||||||
ArrayList<VehicleMarkers> list = new ArrayList<>();
|
|
||||||
vehicle.getMarkersIds().forEach(markerId -> {
|
vehicle.getMarkersIds().forEach(markerId -> {
|
||||||
VehicleMarkers vehicleMarkers = new VehicleMarkers();
|
VehicleMarkers vehicleMarkers = new VehicleMarkers();
|
||||||
vehicleMarkers.setVehicleId(vehicle.getVehicleId());
|
vehicleMarkers.setVehicleId(vehicle.getVehicleId());
|
||||||
|
|
|
@ -130,6 +130,7 @@
|
||||||
<artifactId>spring-kafka</artifactId>
|
<artifactId>spring-kafka</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -7,6 +7,7 @@ import com.zhilian.common.swagger.annotation.EnableCustomSwagger2;
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,9 +19,12 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
@EnableCustomConfig
|
@EnableCustomConfig
|
||||||
@EnableCustomSwagger2
|
@EnableCustomSwagger2
|
||||||
@EnableScheduling
|
@EnableScheduling
|
||||||
@EnableMyFeignClients
|
@EnableMyFeignClients(basePackages = {"com.zhilian.business.remote","com.zhilian.common.system.remote"})
|
||||||
@MapperScan({"com.zhilian.resolver.mapper", "com.zhilian.resolver.resolverReport"})
|
@MapperScan({"com.zhilian.resolver.mapper", "com.zhilian.resolver.resolverReport"})
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
|
//com.zhilian.business.remote.factory.RemoteBreakFallbackFactory
|
||||||
|
//com.zhilian.business.remote.factory.RemoteFenceFallbackFactory
|
||||||
|
//com.zhilian.business.remote.factory.RemoteVehicleFallbackFactory
|
||||||
public class ZhiLianResolverApplication {
|
public class ZhiLianResolverApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(ZhiLianResolverApplication.class,args);
|
SpringApplication.run(ZhiLianResolverApplication.class,args);
|
||||||
|
|
|
@ -1,97 +1,97 @@
|
||||||
package com.zhilian.resolver.model;
|
//package com.zhilian.resolver.model;
|
||||||
import com.zhilian.common.core.utils.SpringUtils;
|
//import com.zhilian.common.core.utils.SpringUtils;
|
||||||
import com.zhilian.common.redis.service.RedisService;
|
//import com.zhilian.common.redis.service.RedisService;
|
||||||
import com.zhilian.common.resolver.domain.ResolverReportData;
|
//import com.zhilian.common.resolver.domain.ResolverReportData;
|
||||||
import com.zhilian.resolver.service.ResolverEventService;
|
//import com.zhilian.resolver.service.ResolverEventService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
//import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.kafka.clients.consumer.ConsumerConfig;
|
//import org.apache.kafka.clients.consumer.ConsumerConfig;
|
||||||
import org.apache.kafka.clients.consumer.ConsumerRecords;
|
//import org.apache.kafka.clients.consumer.ConsumerRecords;
|
||||||
import org.apache.kafka.clients.consumer.KafkaConsumer;
|
//import org.apache.kafka.clients.consumer.KafkaConsumer;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
//import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Component;
|
//import org.springframework.stereotype.Component;
|
||||||
|
//
|
||||||
import javax.annotation.PostConstruct;
|
//import javax.annotation.PostConstruct;
|
||||||
import java.time.Duration;
|
//import java.time.Duration;
|
||||||
import java.util.*;
|
//import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
//import java.util.stream.Collectors;
|
||||||
|
//
|
||||||
import static com.zhilian.resolver.utils.ConvertUtils.hexStringToString;
|
//import static com.zhilian.resolver.utils.ConvertUtils.hexStringToString;
|
||||||
import static com.zhilian.resolver.utils.ConvertUtils.parseVehicleData;
|
//import static com.zhilian.resolver.utils.ConvertUtils.parseVehicleData;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* @ClassName ModelsKafkaMessage
|
// * @ClassName ModelsKafkaMessage
|
||||||
* @Description 描述
|
// * @Description 描述
|
||||||
* @Author Can.J
|
// * @Author Can.J
|
||||||
* @Date 2024/4/8
|
// * @Date 2024/4/8
|
||||||
*/
|
// */
|
||||||
@Component
|
//@Component
|
||||||
@Slf4j
|
//@Slf4j
|
||||||
public class ModelsKafkaMessage {
|
//public class ModelsKafkaMessage {
|
||||||
@Autowired
|
// @Autowired
|
||||||
private RedisService redisService;
|
// private RedisService redisService;
|
||||||
private static final String TOPIC_NAME = "vehicle-topic";
|
// private static final String TOPIC_NAME = "vehicle-topic";
|
||||||
private static final String BOOTSTRAP_SERVERS = "10.10.25.5:9092";
|
// private static final String BOOTSTRAP_SERVERS = "10.10.25.5:9092";
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* 消费者配置
|
// * 消费者配置
|
||||||
* @return
|
// * @return
|
||||||
*/
|
// */
|
||||||
@PostConstruct
|
// @PostConstruct
|
||||||
private void consumerMessages() {
|
// private void consumerMessages() {
|
||||||
Thread kafkaConsumerThread = new Thread(() -> {
|
// Thread kafkaConsumerThread = new Thread(() -> {
|
||||||
log.info("启动线程");
|
// log.info("启动线程");
|
||||||
Properties props = new Properties();
|
// Properties props = new Properties();
|
||||||
props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, BOOTSTRAP_SERVERS);
|
// props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, BOOTSTRAP_SERVERS);
|
||||||
props.put(ConsumerConfig.GROUP_ID_CONFIG, "my-consumer-group");
|
// props.put(ConsumerConfig.GROUP_ID_CONFIG, "my-consumer-group");
|
||||||
props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer");
|
// props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer");
|
||||||
props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer");
|
// props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringDeserializer");
|
||||||
|
//
|
||||||
//创建消费者
|
// //创建消费者
|
||||||
KafkaConsumer<String, String> consumer = new KafkaConsumer<>(props);
|
// KafkaConsumer<String, String> consumer = new KafkaConsumer<>(props);
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
|
//
|
||||||
//订阅主题
|
// //订阅主题
|
||||||
consumer.subscribe(Collections.singletonList(TOPIC_NAME));
|
// consumer.subscribe(Collections.singletonList(TOPIC_NAME));
|
||||||
|
//
|
||||||
//持续消费消息
|
// //持续消费消息
|
||||||
while (true) {
|
// while (true) {
|
||||||
ConsumerRecords<String, String> records = consumer.poll(Duration.ofMillis(100));
|
// ConsumerRecords<String, String> records = consumer.poll(Duration.ofMillis(100));
|
||||||
records.forEach(record -> {
|
// records.forEach(record -> {
|
||||||
System.out.println("接收到的数据:" + record.value());
|
// System.out.println("接收到的数据:" + record.value());
|
||||||
String str = hexStringToString(record.value());
|
// String str = hexStringToString(record.value());
|
||||||
List<ResolverReportData> resolverReportDataList = parseVehicleData(str);
|
// List<ResolverReportData> resolverReportDataList = parseVehicleData(str);
|
||||||
for (ResolverReportData vehicleData : resolverReportDataList) {
|
// for (ResolverReportData vehicleData : resolverReportDataList) {
|
||||||
log.info("解析到车辆数据:{}", vehicleData);
|
// log.info("解析到车辆数据:{}", vehicleData);
|
||||||
|
//
|
||||||
//获取vin
|
// //获取vin
|
||||||
String vin = vehicleData.getVin();
|
// String vin = vehicleData.getVin();
|
||||||
//获取事件集
|
// //获取事件集
|
||||||
Set<Object> cacheSet = redisService.getCacheSet("vehicle-event:" + vin);
|
// Set<Object> cacheSet = redisService.getCacheSet("vehicle-event:" + vin);
|
||||||
List<String> events = cacheSet.stream().map(item -> {
|
// List<String> events = cacheSet.stream().map(item -> {
|
||||||
return String.valueOf(item);
|
// return String.valueOf(item);
|
||||||
}).collect(Collectors.toList());
|
// }).collect(Collectors.toList());
|
||||||
log.info("事件集合:{}",events);
|
// log.info("事件集合:{}",events);
|
||||||
|
//
|
||||||
log.info("解析到车辆数据:{}", vehicleData);
|
// log.info("解析到车辆数据:{}", vehicleData);
|
||||||
for (String stringEvent : events) {
|
// for (String stringEvent : events) {
|
||||||
ResolverEventService resolverEventService =SpringUtils.getBean(stringEvent);
|
// ResolverEventService resolverEventService =SpringUtils.getBean(stringEvent);
|
||||||
resolverEventService.execute(vehicleData);
|
// resolverEventService.execute(vehicleData);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
log.error("Error occurred in Kafka consumer thread", e);
|
// log.error("Error occurred in Kafka consumer thread", e);
|
||||||
} finally {
|
// } finally {
|
||||||
consumer.close();
|
// consumer.close();
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
kafkaConsumerThread.start();
|
// kafkaConsumerThread.start();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,8 +1,9 @@
|
||||||
package com.zhilian.resolver.service.impl.eventMalfunction;
|
package com.zhilian.resolver.service.impl.eventMalfunction;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.zhilian.business.domain.BusinessBreak;
|
||||||
|
import com.zhilian.business.remote.RemoteBreakService;
|
||||||
import com.zhilian.common.redis.service.RedisService;
|
import com.zhilian.common.redis.service.RedisService;
|
||||||
import com.zhilian.common.resolver.domain.ErrorCar;
|
|
||||||
import com.zhilian.common.resolver.domain.ResolverReportData;
|
import com.zhilian.common.resolver.domain.ResolverReportData;
|
||||||
import com.zhilian.resolver.mapper.UserMapper;
|
import com.zhilian.resolver.mapper.UserMapper;
|
||||||
import com.zhilian.resolver.service.ResolverEventService;
|
import com.zhilian.resolver.service.ResolverEventService;
|
||||||
|
@ -11,6 +12,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,109 +39,179 @@ public class MalfunctionEventServiceImpl implements ResolverEventService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ResolverReportInfoService resolverReportInfoService;
|
private ResolverReportInfoService resolverReportInfoService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RemoteBreakService remoteBreakService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(ResolverReportData vehicleData) {
|
public void execute(ResolverReportData vehicleData) {
|
||||||
log.info("故障事件开始执行");
|
log.info("故障事件开始执行");
|
||||||
if(isAnyFieldZero(vehicleData)){
|
if(isAnyFieldZero(vehicleData)){
|
||||||
resolverReportInfoService.saveDataToDatabaseByMalfunction(vehicleData);
|
resolverReportInfoService.saveDataToDatabaseByMalfunction(vehicleData);
|
||||||
|
|
||||||
|
BusinessBreak businessBreak = new BusinessBreak();
|
||||||
ErrorCar errorCar = new ErrorCar();
|
businessBreak.setBreakVin(vehicleData.getVin());
|
||||||
errorCar.setVin(vehicleData.getVin());
|
|
||||||
// * 车辆状态 1:正常 0:故障
|
// * 车辆状态 1:正常 0:故障
|
||||||
if(vehicleData.getVehicleStatus()==0){
|
if(vehicleData.getVehicleStatus()==0){
|
||||||
errorCar.setCode("GZ001");
|
businessBreak.setBreakCode("CL001");
|
||||||
errorCar.setLevel(1);
|
businessBreak.setBreakDate(new Date());
|
||||||
|
businessBreak.setBreakType("车体故障");
|
||||||
|
businessBreak.setBreakState("1");
|
||||||
|
remoteBreakService.add(businessBreak);
|
||||||
}
|
}
|
||||||
|
|
||||||
// * 充电状态 1:正常 0:故障
|
// * 充电状态 1:正常 0:故障
|
||||||
// private int chargingStatus;
|
// private int chargingStatus;
|
||||||
if(vehicleData.getChargingStatus()==0){
|
if(vehicleData.getChargingStatus()==0){
|
||||||
errorCar.setCode("GZ001");
|
businessBreak.setBreakCode("CD001");
|
||||||
errorCar.setLevel(1);
|
businessBreak.setBreakDate(new Date());
|
||||||
|
businessBreak.setBreakType("电池故障");
|
||||||
|
businessBreak.setBreakState("1");
|
||||||
|
remoteBreakService.add(businessBreak);
|
||||||
}
|
}
|
||||||
|
|
||||||
// * 运行状态 1:正常 0:故障
|
// * 运行状态 1:正常 0:故障
|
||||||
if(vehicleData.getOperatingStatus()==0){
|
if(vehicleData.getOperatingStatus()==0){
|
||||||
errorCar.setCode("GZ002");
|
businessBreak.setBreakCode("DW001");
|
||||||
errorCar.setLevel(3);
|
businessBreak.setBreakDate(new Date());
|
||||||
|
businessBreak.setBreakType("行驶故障");
|
||||||
|
businessBreak.setBreakState("1");
|
||||||
|
remoteBreakService.add(businessBreak);
|
||||||
}
|
}
|
||||||
|
|
||||||
// * SOC 状态 1:正常 0:故障
|
// * SOC 状态 1:正常 0:故障
|
||||||
if(vehicleData.getSocStatus()==0){
|
if(vehicleData.getSocStatus()==0){
|
||||||
errorCar.setCode("GZ003");
|
businessBreak.setBreakCode("SOC001");
|
||||||
errorCar.setLevel(3);
|
businessBreak.setBreakDate(new Date());
|
||||||
|
businessBreak.setBreakType("电池故障");
|
||||||
|
businessBreak.setBreakState("1");
|
||||||
|
remoteBreakService.add(businessBreak);
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// /**
|
// 可充电储能装置工作状态 1:正常 0:故障;
|
||||||
// * 可充电储能装置工作状态 1:正常 0:故障
|
if(vehicleData.getChargingEnergyStorageStatus()==0){
|
||||||
// */
|
businessBreak.setBreakCode("CDC001");
|
||||||
// private int chargingEnergyStorageStatus;
|
businessBreak.setBreakDate(new Date());
|
||||||
//
|
businessBreak.setBreakType("电池故障");
|
||||||
// /**
|
businessBreak.setBreakState("1");
|
||||||
// * 驱动电机状态 1:正常 0:故障
|
remoteBreakService.add(businessBreak);
|
||||||
// */
|
}
|
||||||
// private int driveMotorStatus;
|
|
||||||
//
|
// 驱动电机状态 1:正常 0:故障
|
||||||
// /**
|
if(vehicleData.getDriveMotorStatus()==0){
|
||||||
// * 定位是否有效 1:有效 0:无效
|
businessBreak.setBreakCode("DJ001");
|
||||||
// */
|
businessBreak.setBreakDate(new Date());
|
||||||
// private int positionStatus;
|
businessBreak.setBreakType("电机故障");
|
||||||
//
|
businessBreak.setBreakState("1");
|
||||||
// /**
|
remoteBreakService.add(businessBreak);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 定位是否有效 1:有效 0:无效
|
||||||
|
if(vehicleData.getPositionStatus()==0){
|
||||||
|
businessBreak.setBreakCode("SOC001");
|
||||||
|
businessBreak.setBreakDate(new Date());
|
||||||
|
businessBreak.setBreakType("定位故障");
|
||||||
|
businessBreak.setBreakState("1");
|
||||||
|
remoteBreakService.add(businessBreak);
|
||||||
|
}
|
||||||
|
|
||||||
// * EAS(汽车防盗系统)状态 1:正常 0:故障
|
// * EAS(汽车防盗系统)状态 1:正常 0:故障
|
||||||
// */
|
if(vehicleData.getEasStatus()==0){
|
||||||
// private int easStatus;
|
businessBreak.setBreakCode("EAS001");
|
||||||
//
|
businessBreak.setBreakDate(new Date());
|
||||||
// /**
|
businessBreak.setBreakType("EAS故障");
|
||||||
|
businessBreak.setBreakState("1");
|
||||||
|
remoteBreakService.add(businessBreak);
|
||||||
|
}
|
||||||
|
|
||||||
// * PTC(电动加热器)状态 1:正常 0:故障
|
// * PTC(电动加热器)状态 1:正常 0:故障
|
||||||
// */
|
if(vehicleData.getPtcStatus()==0){
|
||||||
// private int ptcStatus;
|
businessBreak.setBreakCode("PTC001");
|
||||||
//
|
businessBreak.setBreakDate(new Date());
|
||||||
// /**
|
businessBreak.setBreakType("加热故障");
|
||||||
|
businessBreak.setBreakState("1");
|
||||||
|
remoteBreakService.add(businessBreak);
|
||||||
|
}
|
||||||
|
|
||||||
// * EPS(电动助力系统)状态 1:正常 0:故障
|
// * EPS(电动助力系统)状态 1:正常 0:故障
|
||||||
// */
|
if(vehicleData.getEpsStatus()==0){
|
||||||
// private int epsStatus;
|
businessBreak.setBreakCode("EPS001");
|
||||||
//
|
businessBreak.setBreakDate(new Date());
|
||||||
// /**
|
businessBreak.setBreakType("电动助力故障");
|
||||||
|
businessBreak.setBreakState("1");
|
||||||
|
remoteBreakService.add(businessBreak);
|
||||||
|
}
|
||||||
|
|
||||||
// * ABS(防抱死)状态 1:正常 0:故障
|
// * ABS(防抱死)状态 1:正常 0:故障
|
||||||
// */
|
if(vehicleData.getAbsStatus()==0){
|
||||||
// private int absStatus;
|
businessBreak.setBreakCode("ABS001");
|
||||||
//
|
businessBreak.setBreakDate(new Date());
|
||||||
// /**
|
businessBreak.setBreakType("ABS故障");
|
||||||
|
businessBreak.setBreakState("1");
|
||||||
|
remoteBreakService.add(businessBreak);
|
||||||
|
}
|
||||||
|
|
||||||
// * MCU(电机/逆变器)状态 1:正常 0:故障
|
// * MCU(电机/逆变器)状态 1:正常 0:故障
|
||||||
// */
|
if(vehicleData.getMcuStatus()==0){
|
||||||
// private int mcuStatus;
|
businessBreak.setBreakCode("MCU001");
|
||||||
//
|
businessBreak.setBreakDate(new Date());
|
||||||
// /**
|
businessBreak.setBreakType("MCU故障");
|
||||||
|
businessBreak.setBreakState("1");
|
||||||
|
remoteBreakService.add(businessBreak);
|
||||||
|
}
|
||||||
|
|
||||||
// * 动力电池加热状态 1:正常 0:故障
|
// * 动力电池加热状态 1:正常 0:故障
|
||||||
// */
|
if(vehicleData.getHeatingStatus()==0){
|
||||||
// private int heatingStatus;
|
businessBreak.setBreakCode("DC002");
|
||||||
//
|
businessBreak.setBreakDate(new Date());
|
||||||
// /**
|
businessBreak.setBreakType("电池故障");
|
||||||
|
businessBreak.setBreakState("1");
|
||||||
|
remoteBreakService.add(businessBreak);
|
||||||
|
}
|
||||||
|
|
||||||
// * 动力电池当前状态 1:正常 0:故障
|
// * 动力电池当前状态 1:正常 0:故障
|
||||||
// */
|
if(vehicleData.getBatteryStatus()==0){
|
||||||
// private int batteryStatus;
|
businessBreak.setBreakCode("DC003");
|
||||||
//
|
businessBreak.setBreakDate(new Date());
|
||||||
// /**
|
businessBreak.setBreakType("电池故障");
|
||||||
|
businessBreak.setBreakState("1");
|
||||||
|
remoteBreakService.add(businessBreak);
|
||||||
|
}
|
||||||
|
|
||||||
// * 动力电池保温状态 1:正常 0:故障
|
// * 动力电池保温状态 1:正常 0:故障
|
||||||
// */
|
if(vehicleData.getBatteryInsulationStatus()==0){
|
||||||
// private int batteryInsulationStatus;
|
businessBreak.setBreakCode("DC004");
|
||||||
//
|
businessBreak.setBreakDate(new Date());
|
||||||
// /**
|
businessBreak.setBreakType("电池故障");
|
||||||
|
businessBreak.setBreakState("1");
|
||||||
|
remoteBreakService.add(businessBreak);
|
||||||
|
}
|
||||||
|
|
||||||
// * DCDC(电力交换系统) 状态 1:正常 0:故障
|
// * DCDC(电力交换系统) 状态 1:正常 0:故障
|
||||||
// */
|
if(vehicleData.getDcdcStatus()==0){
|
||||||
// private int dcdcStatus;
|
businessBreak.setBreakCode("DCDC005");
|
||||||
//
|
businessBreak.setBreakDate(new Date());
|
||||||
// /**
|
businessBreak.setBreakType("电力故障");
|
||||||
|
businessBreak.setBreakState("1");
|
||||||
|
remoteBreakService.add(businessBreak);
|
||||||
|
}
|
||||||
|
|
||||||
// * CHG(充电机)状态 1:正常 0:故障
|
// * CHG(充电机)状态 1:正常 0:故障
|
||||||
// */
|
if(vehicleData.getChgStatus()==0){
|
||||||
// private int chgStatus;
|
businessBreak.setBreakCode("CDJ005");
|
||||||
String key = "breakdown";
|
businessBreak.setBreakDate(new Date());
|
||||||
String value = JSON.toJSONString(errorCar);
|
businessBreak.setBreakType("电力故障");
|
||||||
redisService.setCacheObject(key,value);
|
businessBreak.setBreakState("1");
|
||||||
|
remoteBreakService.add(businessBreak);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// String key = "breakdown";
|
||||||
|
String value = JSON.toJSONString(businessBreak);
|
||||||
|
redisService.setCacheObject("breakdown:gz:"+vehicleData.getVin(),value);
|
||||||
long expireTime = 30;
|
long expireTime = 30;
|
||||||
redisService.expire(key, expireTime, TimeUnit.MINUTES);
|
redisService.expire("breakdown:gz:"+vehicleData.getVin(), expireTime, TimeUnit.MINUTES);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue