|
@@ -1,15 +1,20 @@
|
|
|
package jt809.handle;
|
|
package jt809.handle;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.extra.spring.SpringUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import jt809.common.util.CommonUtils;
|
|
import jt809.common.util.CommonUtils;
|
|
|
import jt809.packet.JT809Packet0x1202;
|
|
import jt809.packet.JT809Packet0x1202;
|
|
|
import io.netty.channel.ChannelHandlerContext;
|
|
import io.netty.channel.ChannelHandlerContext;
|
|
|
import io.netty.channel.SimpleChannelInboundHandler;
|
|
import io.netty.channel.SimpleChannelInboundHandler;
|
|
|
|
|
+import net.sourceforge.pinyin4j.PinyinHelper;
|
|
|
|
|
+import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
|
|
|
|
|
+import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
|
|
|
import org.dromara.system.domain.GpsData;
|
|
import org.dromara.system.domain.GpsData;
|
|
|
import org.dromara.util.CamelDataUtil;
|
|
import org.dromara.util.CamelDataUtil;
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.context.annotation.Import;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @Author: Xiuming Lee
|
|
* @Author: Xiuming Lee
|
|
@@ -17,26 +22,54 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
* @Version 1.0
|
|
* @Version 1.0
|
|
|
* @Describe:
|
|
* @Describe:
|
|
|
*/
|
|
*/
|
|
|
|
|
+@Import(cn.hutool.extra.spring.SpringUtil.class)
|
|
|
public class JT809Packet0x1202Handle extends SimpleChannelInboundHandler<JT809Packet0x1202> {
|
|
public class JT809Packet0x1202Handle extends SimpleChannelInboundHandler<JT809Packet0x1202> {
|
|
|
private static Logger log = LoggerFactory.getLogger(JT809Packet0x1202Handle.class);
|
|
private static Logger log = LoggerFactory.getLogger(JT809Packet0x1202Handle.class);
|
|
|
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private CamelDataUtil camelDataUtil;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
protected void channelRead0(ChannelHandlerContext ctx, JT809Packet0x1202 msg) {
|
|
protected void channelRead0(ChannelHandlerContext ctx, JT809Packet0x1202 msg) {
|
|
|
log.info("车辆定位信息:{}", msg.toString());
|
|
log.info("车辆定位信息:{}", msg.toString());
|
|
|
if (msg.getVec1() > 0 || msg.getVec2() > 0) {
|
|
if (msg.getVec1() > 0 || msg.getVec2() > 0) {
|
|
|
GpsData gpsData = new GpsData();
|
|
GpsData gpsData = new GpsData();
|
|
|
- gpsData.setDevicecode(msg.getVehicleNo().trim());
|
|
|
|
|
|
|
+ gpsData.setDevicecode(convertToPinyin(msg.getVehicleNo().trim()));
|
|
|
gpsData.setLat((double) (msg.getLat()/1000000));
|
|
gpsData.setLat((double) (msg.getLat()/1000000));
|
|
|
gpsData.setLng((double) (msg.getLon()/1000000));
|
|
gpsData.setLng((double) (msg.getLon()/1000000));
|
|
|
gpsData.setAlt(0.0);
|
|
gpsData.setAlt(0.0);
|
|
|
gpsData.setSpeed((double) (msg.getVec1() > 0?msg.getVec1():msg.getVec2()));
|
|
gpsData.setSpeed((double) (msg.getVec1() > 0?msg.getVec1():msg.getVec2()));
|
|
|
|
|
+
|
|
|
|
|
+ final CamelDataUtil camelDataUtil = SpringUtil.getBean("camelDataUtil");
|
|
|
camelDataUtil.processGpsData(gpsData);
|
|
camelDataUtil.processGpsData(gpsData);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ public static String convertToPinyin(String chinese) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ StringBuilder pinyin = new StringBuilder();
|
|
|
|
|
+ char[] chars = chinese.toCharArray();
|
|
|
|
|
+ HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
|
|
|
|
|
+ format.setToneType(net.sourceforge.pinyin4j.format.HanyuPinyinToneType.WITHOUT_TONE);
|
|
|
|
|
+
|
|
|
|
|
+ for (char c : chars) {
|
|
|
|
|
+ String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(c, format);
|
|
|
|
|
+
|
|
|
|
|
+ if (pinyinArray != null) {
|
|
|
|
|
+ pinyin.append(pinyinArray[0]);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ pinyin.append(c);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return pinyin.toString().trim();
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ return "car_";
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|