报文解析
parent
fa64eefa03
commit
ad84ffb8c2
|
@ -29,8 +29,8 @@ public class CarMessageController {
|
||||||
*/
|
*/
|
||||||
@PostMapping("/selectCarMessageList")
|
@PostMapping("/selectCarMessageList")
|
||||||
@Operation(summary = "报文模板展示列表")
|
@Operation(summary = "报文模板展示列表")
|
||||||
public Result<List<CarMessage>> selectCarMessageList(){
|
public Result<List<CarMessage>> selectCarMessageList(Integer carMessageCartype){
|
||||||
List<CarMessage> carMessages = carMessageService.selectCarMessageList();
|
List<CarMessage> carMessages = carMessageService.selectCarMessageList(carMessageCartype);
|
||||||
return Result.success(carMessages);
|
return Result.success(carMessages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ public class CarMessageController {
|
||||||
*/
|
*/
|
||||||
public class MessageParser{
|
public class MessageParser{
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
String message = "01,02,03," +
|
String message = "01 02 03 " +
|
||||||
"04,05,06,07,08,09," +
|
"04,05,06,07,08,09," +
|
||||||
"10,11,12,13,14,15,16" +
|
"10,11,12,13,14,15,16" +
|
||||||
",17,18,19,20,21,22,23," +
|
",17,18,19,20,21,22,23," +
|
||||||
|
|
|
@ -1,99 +0,0 @@
|
||||||
package com.muyu.car.domain.resp;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Builder
|
|
||||||
public class CarReq {
|
|
||||||
|
|
||||||
private String EatImagtion;
|
|
||||||
private String imgTion;
|
|
||||||
private String EatIma6ion;
|
|
||||||
private String EatImagtFformion;
|
|
||||||
private String EatTailImagtion;
|
|
||||||
private String EatImagertion;
|
|
||||||
private String EatImagtodoion;
|
|
||||||
private String EatasImagtion;
|
|
||||||
private String EatImageartion;
|
|
||||||
private String imagtionId;
|
|
||||||
private String Eagtion;
|
|
||||||
private String EatImag;
|
|
||||||
private String tImag;
|
|
||||||
private String agtizyRon;
|
|
||||||
private String EatImagcdtion;
|
|
||||||
private String agtigagtion;
|
|
||||||
private String EatImfhgdfagtion;
|
|
||||||
private String EffatImagtion;
|
|
||||||
private String EatImadfggtion;
|
|
||||||
private String EatImagfgtion;
|
|
||||||
private String EatImaggdtion;
|
|
||||||
private String EatImagdfgtion;
|
|
||||||
private String EatImfdgadfggtion;
|
|
||||||
private String EatIfdgmagtion;
|
|
||||||
private String EatIfdgfgmagtion;
|
|
||||||
private String EatImagdffggtion;
|
|
||||||
private String EatImaggfdtion;
|
|
||||||
private String EatImagtigon;
|
|
||||||
private String EatImagtbjion;
|
|
||||||
private String EatImagt_fdgion;
|
|
||||||
private String EatrgImagtion;
|
|
||||||
private String EatIdgmagtion;
|
|
||||||
private String EatImafggtion;
|
|
||||||
private String EgatImgagtion;
|
|
||||||
private String EatImggagtion;
|
|
||||||
private String EatImagfdgtion;
|
|
||||||
private String EatdfgImadfggtion;
|
|
||||||
private String EatIgdmagtion;
|
|
||||||
private String EatImagd;
|
|
||||||
private String EatdfgImagtion;
|
|
||||||
private String EatIgfgmagtion;
|
|
||||||
private String EatIsdmagtion;
|
|
||||||
private String EatfImagtion;
|
|
||||||
private String EadatImagtion;
|
|
||||||
private String EatdgImagtion;
|
|
||||||
private String EatdImagtion;
|
|
||||||
private String EatIafmagtion;
|
|
||||||
private String EatIagffmagtion;
|
|
||||||
private String EatgsImagtion;
|
|
||||||
private String EatasdImagtion;
|
|
||||||
private String EatIadmagtion;
|
|
||||||
private String EatadImagtion;
|
|
||||||
private String EatIcvmagtion;
|
|
||||||
private String EatImagtfion;
|
|
||||||
private String EatImagation;
|
|
||||||
private String EatImfagtion;
|
|
||||||
private String EatImagyution;
|
|
||||||
private Integer other;
|
|
||||||
private Integer othjjer;
|
|
||||||
private Integer otmkdowedher;
|
|
||||||
private Integer desother;
|
|
||||||
private Integer otsmkeher;
|
|
||||||
private Integer othsmer;
|
|
||||||
private Integer oedednjihyther;
|
|
||||||
private Integer othhuer;
|
|
||||||
private Integer othmkjoer;
|
|
||||||
private Integer othnjiu8er;
|
|
||||||
private Integer othhubhyer;
|
|
||||||
private Integer othejkihjur;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -2,6 +2,7 @@ package com.muyu.car.mapper;
|
||||||
|
|
||||||
|
|
||||||
import com.muyu.car.domain.CarInformation;
|
import com.muyu.car.domain.CarInformation;
|
||||||
|
import com.muyu.car.domain.CarMessage;
|
||||||
import com.muyu.car.domain.req.CarInformationAddReq;
|
import com.muyu.car.domain.req.CarInformationAddReq;
|
||||||
import com.muyu.car.domain.req.CarInformationListReq;
|
import com.muyu.car.domain.req.CarInformationListReq;
|
||||||
import com.muyu.car.domain.req.CarInformationUpdReq;
|
import com.muyu.car.domain.req.CarInformationUpdReq;
|
||||||
|
@ -64,5 +65,4 @@ public interface CarInformationMapper {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package com.muyu.car.mapper;
|
package com.muyu.car.mapper;
|
||||||
|
|
||||||
|
import com.muyu.car.domain.CarInformation;
|
||||||
import com.muyu.car.domain.CarMessage;
|
import com.muyu.car.domain.CarMessage;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -12,7 +14,7 @@ public interface CarMessageMapper {
|
||||||
* @param
|
* @param
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<CarMessage> selectCarMessageList();
|
List<CarMessage> selectCarMessageList(@Param("carMessageCartype")Integer carMessageCartype);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,4 +33,24 @@ public interface CarMessageMapper {
|
||||||
*/
|
*/
|
||||||
Integer updateCarMessage(CarMessage carMessage);
|
Integer updateCarMessage(CarMessage carMessage);
|
||||||
|
|
||||||
|
|
||||||
|
//报文切割
|
||||||
|
/**
|
||||||
|
* 查询报文ID
|
||||||
|
* @param carInformationVIN
|
||||||
|
* @return
|
||||||
|
* 根据车辆VIN值查列表
|
||||||
|
* 根据给定的车辆VIN号获取对应的车辆类型ID-->模板参数
|
||||||
|
*/
|
||||||
|
List<CarInformation> selectcarInformationType(String carInformationVIN);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*根据VIN查询报文作用哪个车辆类型
|
||||||
|
*/
|
||||||
|
Long selectcarMessageCartype(String carInformationVIN);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.muyu.car.service;
|
package com.muyu.car.service;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
import com.muyu.car.domain.CarMessage;
|
import com.muyu.car.domain.CarMessage;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
|
|
||||||
|
@ -12,7 +13,7 @@ public interface CarMessageService {
|
||||||
* @param
|
* @param
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<CarMessage> selectCarMessageList();
|
List<CarMessage> selectCarMessageList(Integer carMessageCartype);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,9 +35,14 @@ public interface CarMessageService {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分割字符串获取报文模板信息
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分割字符串获取报文信息
|
||||||
|
*/
|
||||||
|
JSONObject inciseCarMessage(String testString);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,37 @@
|
||||||
package com.muyu.car.service.Impl;
|
package com.muyu.car.service.Impl;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.muyu.car.domain.CarInformation;
|
||||||
import com.muyu.car.domain.CarMessage;
|
import com.muyu.car.domain.CarMessage;
|
||||||
|
import com.muyu.car.mapper.CarInformationMapper;
|
||||||
import com.muyu.car.mapper.CarMessageMapper;
|
import com.muyu.car.mapper.CarMessageMapper;
|
||||||
import com.muyu.car.service.CarMessageService;
|
import com.muyu.car.service.CarMessageService;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@Log4j2
|
||||||
public class CarMessageServiceImpl implements CarMessageService {
|
public class CarMessageServiceImpl implements CarMessageService {
|
||||||
@Resource
|
@Resource
|
||||||
private CarMessageMapper carMessageMapper;
|
private CarMessageMapper carMessageMapper;
|
||||||
|
@Resource
|
||||||
|
private CarInformationMapper carInformationMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RedisTemplate<String, Objects> redisTemplate;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CarMessage> selectCarMessageList() {
|
public List<CarMessage> selectCarMessageList(Integer carMessageCartype) {
|
||||||
return carMessageMapper.selectCarMessageList();
|
return carMessageMapper.selectCarMessageList(carMessageCartype);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -47,9 +62,66 @@ public class CarMessageServiceImpl implements CarMessageService {
|
||||||
return Result.error( 402,"修改失败");
|
return Result.error( 402,"修改失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JSONObject inciseCarMessage(String testString) {
|
||||||
|
//根据空格拆分切割数据字符串
|
||||||
|
String[] split = testString.split(" ");
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
for (String conversion : split) {
|
||||||
|
//将16进制字符串转换为对应的10进制
|
||||||
|
int inciseindex = Integer.parseInt(conversion, 16);
|
||||||
|
// 将10进制转换为对应的字符
|
||||||
|
stringBuilder.append((char) inciseindex);
|
||||||
|
}
|
||||||
|
//切取车辆VIN
|
||||||
|
String substring = stringBuilder.substring(1, 18);
|
||||||
|
log.info("车辆的VIN码:" + substring);
|
||||||
|
//根据给定的vehicleVin(车辆VIN号)获取对应的模板车辆分类carMessageCartype
|
||||||
|
Integer selectcared = Math.toIntExact(carMessageMapper.selectcarMessageCartype(substring));
|
||||||
|
//根据给定的vehicleVin(车辆VIN号)获取对应的模板信息
|
||||||
|
List<CarInformation> carInformations = carMessageMapper.selectcarInformationType(substring);
|
||||||
|
|
||||||
|
List<CarMessage> carMessagesList = null;
|
||||||
|
|
||||||
|
if (redisTemplate.hasKey("carMessageList" + selectcared)){
|
||||||
|
List<CarMessage>arrayList = new ArrayList<>();
|
||||||
|
List<Objects> list = redisTemplate.opsForList().range("carMessageList" + selectcared, 0, -1);
|
||||||
|
for (Objects objstring : list) {
|
||||||
|
String objString = objstring.toString();
|
||||||
|
CarMessage carMessage = JSON.parseObject(objString, CarMessage.class);
|
||||||
|
arrayList.add(carMessage);
|
||||||
|
}
|
||||||
|
log.info("Redis查询到了");
|
||||||
|
carMessagesList = arrayList;
|
||||||
|
}else {
|
||||||
|
List<CarMessage> list = carMessageMapper.selectCarMessageList(selectcared);
|
||||||
|
for (CarMessage carMessage : list) {
|
||||||
|
redisTemplate.opsForList().rightPushAll("carMessageList" + selectcared , JSON.toJSONString(carMessage));
|
||||||
|
}
|
||||||
|
log.info("数据库查询成功");
|
||||||
|
|
||||||
|
carMessagesList = list;
|
||||||
|
}
|
||||||
|
//判断报文模板 列表 不为空
|
||||||
|
if(carMessagesList == null){
|
||||||
|
throw new RuntimeException("报文模版为空");
|
||||||
|
}
|
||||||
|
//存储报文模板解析后的数据
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
for (CarMessage carMessage : carMessagesList) {
|
||||||
|
//起始位下标
|
||||||
|
Integer startIndex = carMessage.getCarMessageStartIndex();
|
||||||
|
//结束位下标
|
||||||
|
Integer endIndex = carMessage.getCarMessageEndIndex();
|
||||||
|
//根据报文模板获取保温截取位置
|
||||||
|
String value = stringBuilder.substring(startIndex, endIndex);
|
||||||
|
//存入数据
|
||||||
|
jsonObject.put(carMessage.)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import java.util.List;
|
||||||
@Log4j2
|
@Log4j2
|
||||||
public class PackertemplateServiceImpl implements PackertemplateService {
|
public class PackertemplateServiceImpl implements PackertemplateService {
|
||||||
@Resource
|
@Resource
|
||||||
public PackettemplateMapper packettemplateMapper;
|
private PackettemplateMapper packettemplateMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*分类模板
|
*分类模板
|
||||||
|
|
|
@ -104,6 +104,8 @@
|
||||||
FROM `car_information`
|
FROM `car_information`
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<insert id="addCarInformation">
|
<insert id="addCarInformation">
|
||||||
INSERT INTO `car_information`
|
INSERT INTO `car_information`
|
||||||
(
|
(
|
||||||
|
|
|
@ -89,6 +89,46 @@
|
||||||
ON `car_message`.car_message_type = `car_message_type`.message_type_id
|
ON `car_message`.car_message_type = `car_message_type`.message_type_id
|
||||||
LEFT JOIN `car_type`
|
LEFT JOIN `car_type`
|
||||||
ON `car_message` .car_message_cartype = `car_type`.car_type_id
|
ON `car_message` .car_message_cartype = `car_type`.car_type_id
|
||||||
|
WHERE
|
||||||
|
`car_message`.car_message_cartype = #{carMessageCartype}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<select id="selectcarInformationType" resultType="com.muyu.car.domain.CarInformation">
|
||||||
|
SELECT
|
||||||
|
car_information_VIN,
|
||||||
|
car_information_type,
|
||||||
|
car_type_id,
|
||||||
|
car_type_name,
|
||||||
|
car_message_id,
|
||||||
|
car_message_cartype,
|
||||||
|
car_message_type,
|
||||||
|
car_message_start_index,
|
||||||
|
car_message_end_index,
|
||||||
|
message_type_class,
|
||||||
|
car_message_state
|
||||||
|
FROM `car_information`
|
||||||
|
LEFT JOIN `car_type`
|
||||||
|
ON `car_information`. car_information_type
|
||||||
|
=`car_type`. car_type_id
|
||||||
|
LEFT JOIN `car_message`
|
||||||
|
ON `car_message`.car_message_cartype
|
||||||
|
=`car_type`. car_type_id
|
||||||
|
WHERE
|
||||||
|
`car_information`.car_information_VIN = #{carInformationVIN}
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectcarMessageCartype" resultType="java.lang.Long">
|
||||||
|
SELECT car_message_type
|
||||||
|
FROM `car_information`
|
||||||
|
WHERE `car_information`.car_information_VIN = #{carInformationVIN}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
Loading…
Reference in New Issue