增加业务1

master
冯凯 2023-12-07 09:52:43 +08:00
parent 4a5d2a5746
commit a274db959a
4 changed files with 32 additions and 11 deletions

View File

@ -0,0 +1,21 @@
package com.dragon.car.domain.req;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author
* @version 1.0
* @description:
* @date 2023/12/7 9:37
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class FaultRecordReq {
private String faultCode;
}

View File

@ -5,8 +5,6 @@ import com.dragon.car.domain.FaultCode;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.Date;
/** /**
* @author zhn * @author zhn
* *
@ -14,5 +12,5 @@ import java.util.Date;
@Mapper @Mapper
public interface FaultMapper extends BaseMapper<FaultCode> { public interface FaultMapper extends BaseMapper<FaultCode> {
void insertFaultRecord(@Param("vin") String vin, @Param("faultCode") String faultCode, @Param("startTime") Date startTime); void insertFaultRecord(@Param("vin") String vin, @Param("faultCode") String faultCode, @Param("startTime") String startTime);
} }

View File

@ -11,6 +11,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
/** /**
@ -25,9 +28,13 @@ public class ListenFaultCode {
@Autowired @Autowired
private FaultService faultService; private FaultService faultService;
@RabbitListener(queuesToDeclare = {@Queue(value = "fault_Dqueue")}) @RabbitListener(queuesToDeclare = {@Queue(value = "fault_Dqueue")})
public void consumerSubscribe(String mesg, Message message, Channel channel) { public void consumerSubscribe(String mesg, Message message, Channel channel) {
HashMap hashMap = JSONObject.parseObject(mesg, HashMap.class); HashMap hashMap = JSONObject.parseObject(mesg, HashMap.class);
String string = (String) hashMap.get("startTime");
faultService.insertFaultRecord(hashMap);
log.info("收到消息【{}】", hashMap); log.info("收到消息【{}】", hashMap);
try { try {
faultService.insertFaultRecord(hashMap); faultService.insertFaultRecord(hashMap);
@ -36,4 +43,6 @@ public class ListenFaultCode {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
} }

View File

@ -125,13 +125,6 @@ public class FaultServiceImpl implements FaultService {
} catch (ParseException e) { } catch (ParseException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
faultMapper.insertFaultRecord(map.get("vin"),map.get("faultCode"),startTime); faultMapper.insertFaultRecord(map.get("vin"),map.get("faultCode"),s);
}
public static void main(String[] args) throws ParseException {
String time="2021-09-23 10:00:00";
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date parse = format.parse(time);
System.out.println(parse);
} }
} }