修改故障类

server_five_liuyunhu
dongxiaodong 2024-04-06 11:08:41 +08:00
parent 5184d57407
commit 10b15a6f99
6 changed files with 51 additions and 125 deletions

View File

@ -79,33 +79,6 @@ public class ModelMessage {
for (CoupletMsgData msgData : coupletMsgDataList) { for (CoupletMsgData msgData : coupletMsgDataList) {
log.info("解析到车辆数据:{}", msgData); log.info("解析到车辆数据:{}", msgData);
// // 使用CompletableFuture.runAsync()方法创建一个异步任务,该任务会在一个新的线程中执行
// CompletableFuture.runAsync(() ->{
// // 创建一个CoupletTroubleLog对象用于记录故障日志
// CoupletTroubleCode troubleCode = new CoupletTroubleCode();
// //判断状态是否为异常
// if (msgData.getVehicleStatus() !=1 || msgData.getEasStatus() !=1 || msgData.getHeatingStatus() !=1){
// String code = generateGTA();
// troubleCode.setTroubleCode(code);
// String vin = msgData.getVin();
// troubleCode.setTroubleVin(vin);
// String position = getPosition();
// troubleCode.setTroublePosition(position);
// troubleCode.setTroubleValue("00");
// String tag = getTag();
// troubleCode.setTroubleTag(tag);
// String type = getType();
// troubleCode.setTroubleType(type);
// troubleCode.setTroubleStartTime(new Date());
// // 如果车辆状态为正常状态为1则添加结束时间为当前时间
// if (msgData.getVehicleStatus() == 1){
// troubleCode.setTroubleEndTime(new Date());
// }
// }
// // 调用远程服务插入故障日志信息
// remoteCodeService.insertCode(troubleCode);
// });
// log.info("记录异常成功");
for (String string : strings) { for (String string : strings) {
IncidentService incidentService = SpringUtils.getBean(string); IncidentService incidentService = SpringUtils.getBean(string);
incidentService.incident(msgData); incidentService.incident(msgData);
@ -133,78 +106,6 @@ public class ModelMessage {
} }
} }
// /**
// *
// * 拼接GTA字符串
// * @return
// */
// public static String generateGTA() {
// // 生成以GTA开头的字符串
// String codefix = "GTA";
// // 删除4位数随机数字
// String s = generateRandomNumber(4);
// //拼接
// return codefix + s;
// }
//
// /**
// * 随机生成1到10位的数字
// * @param length
// * @return
// */
// public static String generateRandomNumber(int length) {
// Random random = new Random();
// StringBuilder builder = new StringBuilder();
// for (int i = 0; i < length; i++) {
// builder.append(random.nextInt(10));
// }
// return builder.toString();
// }
//
// /**
// * 生成 190 到 209 之间的随机数
// * @param
// * @return
// */
// public static String getPosition() {
// // 生成随机数对象
// Random rand = new Random();
//
// // 生成 190 到 209 之间的随机数
// int randomNumber = rand.nextInt(20) + 190;
//
// // 将随机数转换为字符串形式
// return String.valueOf(randomNumber);
// }
//
// public static String getTag() {
// // 创建一个字符串数组存储三个状态
// String[] statuses = {"车辆状态", "EAS(汽车防盗系统)状态", "DCDC(电力交换系统)"};
//
// // 生成随机数对象
// Random rand = new Random();
//
// // 生成一个范围在 0 到 2 之间的随机整数
// int randomIndex = rand.nextInt(3);
//
// return statuses[randomIndex];
// }
//
// public static String getType() {
// // 创建一个字符串数组存储三个状态
// String[] statuses = {"电池故障", "车体故障", "车尾故障","抽轮故障"};
//
// // 生成随机数对象
// Random rand = new Random();
//
// // 生成一个范围在 0 到 2 之间的随机整数
// int randomIndex = rand.nextInt(4);
//
// return statuses[randomIndex];
// }
/** /**
* 16ASCII * 16ASCII
* @param s 16 * @param s 16

View File

@ -9,6 +9,7 @@ import com.couplet.common.domain.CoupletTroubleGrade;
import com.couplet.common.domain.request.TroubleResp; import com.couplet.common.domain.request.TroubleResp;
import com.couplet.common.log.annotation.Log; import com.couplet.common.log.annotation.Log;
import com.couplet.common.log.enums.BusinessType; import com.couplet.common.log.enums.BusinessType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -23,6 +24,7 @@ import java.util.List;
*/ */
@RestController @RestController
@RequestMapping("trouble") @RequestMapping("trouble")
@Slf4j
public class SysTroubleController extends BaseController { public class SysTroubleController extends BaseController {
@Autowired @Autowired
private SysTroubleService troubleService; private SysTroubleService troubleService;
@ -74,7 +76,32 @@ public class SysTroubleController extends BaseController {
} }
/** /**
* *
* @param coupletTroubleCode
* @return
*/
@PostMapping("insertCode")
public Result<Integer> insertCode(@RequestBody CoupletTroubleCode coupletTroubleCode){
long start = System.currentTimeMillis();
int i = troubleService.insertMsgResq(coupletTroubleCode);
long end = System.currentTimeMillis();
log.info("记录异常信息成功,耗时:{}",(end-start));
return Result.success(i);
}
/**
*
*/
@PostMapping("cleanTroubleCode")
public Result<?> cleanTroubleCode(){
troubleService.cleanTroubleCode();
return Result.success();
}
/**
*
*/ */
@Log(title = "新增故障码",businessType = BusinessType.INSERT) @Log(title = "新增故障码",businessType = BusinessType.INSERT)
@PostMapping("/newFaultData") @PostMapping("/newFaultData")

View File

@ -3,7 +3,6 @@ package com.couplet.business.server.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.couplet.common.domain.CoupletTroubleCode; import com.couplet.common.domain.CoupletTroubleCode;
import com.couplet.common.domain.CoupletTroubleGrade; import com.couplet.common.domain.CoupletTroubleGrade;
import com.couplet.common.domain.CoupletTroubleType;
import com.couplet.common.domain.request.TroubleResp; import com.couplet.common.domain.request.TroubleResp;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@ -19,8 +18,6 @@ import java.util.List;
public interface SysTroubleMapper extends BaseMapper<CoupletTroubleCode> { public interface SysTroubleMapper extends BaseMapper<CoupletTroubleCode> {
List<CoupletTroubleCode> selectTroubleList(TroubleResp troubleReq); List<CoupletTroubleCode> selectTroubleList(TroubleResp troubleReq);
List<CoupletTroubleType> selectTroubleListByType();
List<CoupletTroubleGrade> selectTroubleListByGrade(); List<CoupletTroubleGrade> selectTroubleListByGrade();
/** /**
@ -29,8 +26,7 @@ public interface SysTroubleMapper extends BaseMapper<CoupletTroubleCode> {
*/ */
void newFaultData(CoupletTroubleCode code); void newFaultData(CoupletTroubleCode code);
int insertMsgResq(CoupletTroubleCode coupletTroubleCode);
// int addTrouble(TroubleAddReq troubleAddReq); void cleanTroubleCode();
// int updateTrouble(TroubleUpdReq troubleUpdReq);
} }

View File

@ -25,8 +25,7 @@ public interface SysTroubleService extends IService<CoupletTroubleCode> {
*/ */
void newFaultData(CoupletTroubleCode code); void newFaultData(CoupletTroubleCode code);
int insertMsgResq(CoupletTroubleCode coupletTroubleCode);
// int addTrouble (TroubleAddReq troubleAddReq); void cleanTroubleCode();
// int updateTrouble(TroubleUpdReq troubleUpdReq);
} }

View File

@ -51,24 +51,21 @@ public class SysTroubleServiceImpl extends ServiceImpl<SysTroubleMapper, Couplet
} }
/** /**
* *
// * @param troubleAddReq * @param coupletTroubleCode
* @return * @return
*/ */
// @Override @Override
// public int addTrouble(TroubleAddReq troubleAddReq) { public int insertMsgResq(CoupletTroubleCode coupletTroubleCode) {
// return sysTroubleMapper.addTrouble(troubleAddReq); return sysTroubleMapper.insertMsgResq(coupletTroubleCode);
// } }
//
// /**
// * 修改故障码数据
// * @param troubleUpdReq
// * @return
// */
// @Override
// public int updateTrouble(TroubleUpdReq troubleUpdReq) {
// return sysTroubleMapper.updateTrouble(troubleUpdReq);
// }
/**
*
*/
@Override
public void cleanTroubleCode() {
sysTroubleMapper.cleanTroubleCode();
}
} }

View File

@ -27,6 +27,12 @@
VALUES VALUES
(#{troubleVin}, #{troubleTag}, #{troubleStartTime}) (#{troubleVin}, #{troubleTag}, #{troubleStartTime})
</insert> </insert>
<insert id="insertMsgResq">
</insert>
<update id="cleanTroubleCode">
</update>
<select id="selectTroubleList" parameterType="com.couplet.business.server.mapper.SysTroubleMapper" resultMap="SysTroubleResult"> <select id="selectTroubleList" parameterType="com.couplet.business.server.mapper.SysTroubleMapper" resultMap="SysTroubleResult">
<include refid="selectTroubleVo"/> <include refid="selectTroubleVo"/>