Merge remote-tracking branch 'origin/server_five_dongxiaodong' into server_five

# Conflicts:
#	couplet-modules/couplet-business/src/main/resources/bootstrap.yml
server_five_liuyunhu
lijiayao 2024-04-06 21:54:44 +08:00
commit 8803a91628
6 changed files with 122 additions and 21 deletions

View File

@ -46,12 +46,6 @@ public class CoupletTroubleCode {
@Excel(name = "vin")
private String troubleVin;
/**
*
*/
@Excel(name = "故障标签")
private Integer troubleTag;
/**
*
*/
@ -65,4 +59,10 @@ public class CoupletTroubleCode {
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date troubleEndTime;
/**
*
*/
@Excel(name = "故障位置")
private String troublePosition;
}

View File

@ -17,5 +17,6 @@ import org.springframework.scheduling.annotation.EnableScheduling;
public class CoupletMsgApplication {
public static void main(String[] args) {
SpringApplication.run(CoupletMsgApplication.class);
System.out.println("解析系统启动成功");
}
}

View File

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.couplet.analyze.msg.contents.StateConstant;
import com.couplet.analyze.msg.domain.CoupletMsgData;
import com.couplet.analyze.msg.service.IncidentService;
import com.couplet.analyze.msg.utils.MsgUtils;
import com.couplet.common.domain.CoupletTroubleCode;
import com.couplet.remote.RemoteTroubleService;
import org.slf4j.Logger;
@ -107,9 +108,95 @@ public class BreakdownServiceImpl extends KeyExpirationEventMessageListener impl
if (breakdownIds.size()==0){
CoupletTroubleCode troubleCode = new CoupletTroubleCode();
troubleCode.setTroubleStartTime(new Date());
// 插入数据库
troubleCode.setTroubleTag(0);
troubleCode.setTroubleVin(code.getVin());
// 随机生成故障码
String faultCode = MsgUtils.generateGTA();
troubleCode.setTroubleCode(faultCode);
// 检查车辆状态若为0则设置故障位置为"190"
if(code.getVehicleStatus() == 0) {
troubleCode.setTroublePosition("190");
}
// 检查充电状态若为0则设置故障位置为"191"
if (code.getChargingStatus() == 0) {
troubleCode.setTroublePosition("191");
}
// 检查运行状态若为0则设置故障位置为"192"
if (code.getOperatingStatus() == 0) {
troubleCode.setTroublePosition("192");
}
// 检查电池荷电状态SOC, 若为0则设置故障位置为"193"
if (code.getSocStatus() == 0) {
troubleCode.setTroublePosition("193");
}
// 检查充电能源存储状态若为0则设置故障位置为"194"
if (code.getChargingEnergyStorageStatus() == 0) {
troubleCode.setTroublePosition("194");
}
// 检查驱动电机状态若为0则设置故障位置为"195"
if (code.getDriveMotorStatus() == 0) {
troubleCode.setTroublePosition("195");
}
// 检查定位状态若为0则设置故障位置为"196"
if (code.getPositionStatus() == 0) {
troubleCode.setTroublePosition("196");
}
// 检查电子驻车系统EAS状态若为0则设置故障位置为"197"
if (code.getEasStatus() == 0) {
troubleCode.setTroublePosition("197");
}
// 检查PTC正温度系数热敏电阻状态若为0则设置故障位置为"198"
if (code.getPtcStatus() == 0) {
troubleCode.setTroublePosition("198");
}
// 检查电动助力转向系统EPS状态若为0则设置故障位置为"199"
if (code.getEpsStatus() == 0) {
troubleCode.setTroublePosition("199");
}
// 检查防抱死制动系统ABS状态若为0则设置故障位置为"200"
if (code.getAbsStatus() == 0) {
troubleCode.setTroublePosition("200");
}
// 检查主控制器MCU状态若为0则设置故障位置为"201"
if (code.getMcuStatus() == 0) {
troubleCode.setTroublePosition("201");
}
// 检查加热状态若为0则设置故障位置为"202"
if (code.getHeatingStatus() == 0) {
troubleCode.setTroublePosition("202");
}
// 检查电池状态若为0则设置故障位置为"203"
if (code.getBatteryStatus() == 0) {
troubleCode.setTroublePosition("203");
}
// 检查电池绝缘状态若为0则设置故障位置为"204"
if (code.getBatteryInsulationStatus() == 0) {
troubleCode.setTroublePosition("204");
}
// 检查直流-直流转换器DC/DC状态若为0则设置故障位置为"205"
if (code.getDcdcStatus() == 0) {
troubleCode.setTroublePosition("205");
}
// 检查充电机CHG状态若为0则设置故障位置为"206"
if (code.getChgStatus() == 0) {
troubleCode.setTroublePosition("206");
}
remoteTroubleService.newFaultData(troubleCode);
redisTemplate.opsForSet().add(code.getVin(), code.getVin()+":"+code);
long expireTime = 30;

View File

@ -8,6 +8,7 @@ import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;
/**
* @author DongXiaoDong
@ -18,6 +19,26 @@ import java.util.List;
@Slf4j
public class MsgUtils {
public static String generateGTA() {
// 生成四位以"GTA"开头的字符串
String prefix = "GTA";
// 生成三位随机数字
String randomNumber = generateRandomNumber(4);
// 拼接字符串
return prefix + randomNumber;
}
public static String generateRandomNumber(int length) {
// 生成随机数
Random random = new Random();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < length; i++) {
// 生成0到9之间的随机数字并转换为字符串
sb.append(random.nextInt(10));
}
return sb.toString();
}
/**
* 16ASCII
* @param s 16

View File

@ -29,12 +29,4 @@ public interface SysTroubleMapper extends BaseMapper<CoupletTroubleCode> {
void newFaultData(CoupletTroubleCode code);
void cleanTroubleCode();
int insertMsgResq(CoupletTroubleCode coupletTroubleCode);
// int addTrouble(TroubleAddReq troubleAddReq);
// int updateTrouble(TroubleUpdReq troubleUpdReq);
}

View File

@ -14,17 +14,17 @@
</resultMap>
<sql id="selectTroubleVo">
select * from couplet_trouble_code
select t.*,f.trouble_fault_type,f.trouble_fault_tag from couplet_trouble_code t
LEFT JOIN couplet_trouble_fault f on t.trouble_position = f.trouble_fault_position
</sql>
<insert id="newFaultData">
INSERT INTO `couplet-cloud`.`couplet_trouble_code`
(`trouble_vin`, `trouble_tag`,
`trouble_start_time`)
(`trouble_code`,`trouble_vin`,`trouble_position`,`trouble_start_time`)
VALUES
(#{troubleVin}, #{troubleTag}, #{troubleStartTime})
(#{troubleCode},#{troubleVin}, #{troublePosition},#{troubleStartTime})
</insert>
<update id="cleanTroubleCode">
truncate table couplet_trouble_code
</update>
<select id="selectTroubleList" parameterType="com.couplet.business.server.mapper.SysTroubleMapper" resultMap="SysTroubleResult">