Commit bcc380a2 by 杜发飞

1

parent 58e16078
{"appId":"test123456789","businessTime":"2019-09-09 17:02:10","dataType":"UP_WARN_MSG_ADPT_INFO","infoContent":"报警信息内容:2019-09-09 17:02:10","infoId":"3780","msgId":"UP_WARN_MSG","vehicleColor":"4","vehicleNo":"浙AL0Z96","warnSrc":"2","warnTime":"2019-09-09 17:02:10","warnType":"9"}
kafka写入数据
/home/kafka/soft/kafka_2.11/bin/kafka-console-producer.sh --broker-list 10.197.236.154:9092 --topic operating_vehicle
kafka消费数据
/home/kafka/soft/kafka_2.11/bin/kafka-console-consumer.sh --bootstrap-server 10.197.236.154:9092 --topic operating_vehicle --from-beginning
mavan打包
mvn clean scala:compile compile package
ignite使用注意事项
1.
......@@ -18,8 +14,3 @@ WARN TcpCommunicationSpi: Message queue limit is set to 0 which may lead to pote
class org.apache.ignite.binary.BinaryInvalidTypeException: TestIgnite$1
每个闭包都是一个特定类的对象。当它要被发送时会序列化成二进制的形式,通过线路发送到一个远程节点然后在那里反序列化。该远程节点在类路径中应该有该闭包类,或者开启peerClassLoading以从发送端加载该类。
cdh - spark2 目录
mvn clean scala:compile compile package
/opt/cloudera-manager/cloudera/parcels/SPARK2-2.4.0.cloudera2-1.cdh5.13.3.p0.1041012/bin/spark2-submit
......@@ -40,8 +40,8 @@ public class AttachmentInfo implements Serializable {
@QuerySqlField
private String businessTime; //业务发生时间,格式 yyyy-MM-dd HH:mm:ss
public AttachmentInfo(String appId, String vehicleNo, String vehicleColor, String vehicleType, String deviceId, String warnTime, String warnSeq, String fileCount, String fileIndex, String filePath, String businessTime) {
public AttachmentInfo(String appId, String vehicleNo, String vehicleColor, String vehicleType, String deviceId, String warnTime, String warnSeq,
String fileCount, String fileIndex, String filePath, String businessTime) {
this.appId = appId;
this.vehicleNo = vehicleNo;
this.vehicleColor = vehicleColor;
......
......@@ -2,7 +2,9 @@ package com.hikcreate.ignite.domain.alarm;
import org.apache.ignite.cache.query.annotations.QuerySqlField;
import java.io.Serializable;
/**
* 每日报警数
*/
public class DailyAlarm implements Serializable {
private static final long serialVersionUID = 1L;
......@@ -23,14 +25,14 @@ public class DailyAlarm implements Serializable {
private String date; //统计日期 - 当天
@QuerySqlField
private Long alarmNumber; //对应报警数
private Long number; //对应报警数
public DailyAlarm(String province, String city, String area, String useNature, String date, Long alarmNumber) {
public DailyAlarm(String province, String city, String area, String useNature, String date, Long number) {
this.province = province;
this.city = city;
this.area = area;
this.useNature = useNature;
this.date = date;
this.alarmNumber = alarmNumber;
this.number = number;
}
}
......@@ -3,7 +3,9 @@ package com.hikcreate.ignite.domain.alarm;
import org.apache.ignite.cache.query.annotations.QuerySqlField;
import java.io.Serializable;
/**
* 每日报警处理处
*/
public class DailyAlarmDeal implements Serializable {
private static final long serialVersionUID = 1L;
......
......@@ -2,7 +2,9 @@ package com.hikcreate.ignite.domain.alarm;
import org.apache.ignite.cache.query.annotations.QuerySqlField;
import java.io.Serializable;
/**
* 每日报警详情
*/
public class DailyAlarmDetail implements Serializable {
private static final long serialVersionUID = 1L;
......@@ -29,15 +31,15 @@ public class DailyAlarmDetail implements Serializable {
private String deviceId; //终端ID
@QuerySqlField
private String warnTime; //报警时间
@QuerySqlField
private Double lon; //经度
@QuerySqlField
private Double lat; //纬度
@QuerySqlField
private String warnTime; //报警时间
@QuerySqlField
private Long warnType; //报警类型
@QuerySqlField
......
package com.hikcreate.ignite.processor;
package com.hikcreate.ignite.domain.alarm.processor;
import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.binary.BinaryObjectBuilder;
......
package com.hikcreate.ignite.processor;
package com.hikcreate.ignite.domain.alarm.processor;
import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.binary.BinaryObjectBuilder;
......@@ -20,25 +20,23 @@ public class DailyAlarmUpdate implements CacheEntryProcessor<BinaryObject,Binary
public Void process(MutableEntry<BinaryObject, BinaryObject> mutableEntry, Object... objects) throws EntryProcessorException {
BinaryObject value = mutableEntry.getValue();
BinaryObjectBuilder builder = value.toBuilder();
LocalDate today = LocalDate.now(); //今日日期
LocalDate statisticalDate = LocalDate.parse(value.<String>field("date"),DateTimeFormat.forPattern("yyyy-MM-dd")); //统计日期
LocalDateTime eventTime = LocalDateTime.parse(time,DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"));//事件日期
LocalDate eventDate = eventTime.toLocalDate();
LocalDate today = LocalDate.now();//今日日期
LocalDate statisticalDate = LocalDate.parse(value.<String>field("date"),DateTimeFormat.forPattern("yyyy-MM-dd"));//统计日期
LocalDateTime eventTime = LocalDateTime.parse(time,DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"));
LocalDate eventDate = eventTime.toLocalDate();//事件日期
if(statisticalDate.isBefore(today)){ //统计时间不是当前日,需要重置
builder.setField("date",today.toString("yyyy-MM-dd"));
if(eventDate.equals(today)){
builder.setField("alarmNumber",1L);
builder.setField("number",1L);
mutableEntry.setValue(builder.build());
}else{
builder.setField("alarmNumber",0L);
builder.setField("number",0L);
mutableEntry.setValue(builder.build());
}
}else{
if(eventDate.equals(today)){
Long old = value.<Long>field("alarmNumber");
builder.setField("alarmNumber",old +1);
Long old = value.<Long>field("number");
builder.setField("number",old +1);
mutableEntry.setValue(builder.build());
}
}
......
......@@ -3,7 +3,7 @@ package com.hikcreate.ignite.domain.vehicles;
import org.apache.ignite.cache.query.annotations.QuerySqlField;
import java.io.Serializable;
public class DailyMileage implements Serializable {
public class DailyTravel implements Serializable {
private static final long serialVersionUID = 1L;
......@@ -37,7 +37,17 @@ public class DailyMileage implements Serializable {
@QuerySqlField
private Long travelTime; //当日累计行驶时间,单位秒
public DailyMileage(String province, String city, String area, String useNature, String date, Double lat, Double lng, String time, Double travelMileage, Long travelTime) {
@QuerySqlField
private String gpsProvince; //车牌当前所处省
@QuerySqlField
private String gpsCity; //车牌当前所处市
@QuerySqlField
private String gpsArea; //车牌当前所处区
public DailyTravel(String province, String city, String area, String useNature, String date, Double lat, Double lng, String time,
Double travelMileage, Long travelTime, String gpsProvince, String gpsCity, String gpsArea) {
this.province = province;
this.city = city;
this.area = area;
......@@ -48,5 +58,8 @@ public class DailyMileage implements Serializable {
this.time = time;
this.travelMileage = travelMileage;
this.travelTime = travelTime;
this.gpsProvince = gpsProvince;
this.gpsCity = gpsCity;
this.gpsArea = gpsArea;
}
}
package com.hikcreate.ignite.processor;
package com.hikcreate.ignite.domain.vehicles.processor;
import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.binary.BinaryObjectBuilder;
......
package com.hikcreate.ignite.processor;
package com.hikcreate.ignite.domain.vehicles.processor;
import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.binary.BinaryObjectBuilder;
......@@ -8,13 +8,13 @@ import org.joda.time.format.DateTimeFormat;
import javax.cache.processor.EntryProcessorException;
import javax.cache.processor.MutableEntry;
public class DailyMileageUpdate implements CacheEntryProcessor<BinaryObject,BinaryObject,Void> {
public class DailyTravelUpdate implements CacheEntryProcessor<BinaryObject,BinaryObject,Void> {
private double lat;
private double lng;
private String time;
public DailyMileageUpdate(double lat, double lng, String time){
public DailyTravelUpdate(double lat, double lng, String time){
this.lat = lat;
this.lng = lng;
this.time = time;
......@@ -24,18 +24,15 @@ public class DailyMileageUpdate implements CacheEntryProcessor<BinaryObject,Bina
public Void process(MutableEntry<BinaryObject, BinaryObject> mutableEntry, Object... objects) throws EntryProcessorException {
BinaryObject value = mutableEntry.getValue();
BinaryObjectBuilder builder = value.toBuilder();
LocalDate today = LocalDate.now(); //今日日期
LocalDate statisticalDate = LocalDate.parse(value.<String>field("date"),DateTimeFormat.forPattern("yyyy-MM-dd")); //统计日期
DateTime eventTime = DateTime.parse(time,DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss")); //事件日期
time = eventTime.toString("yyyy-MM-dd HH:mm:ss");
LocalDate eventDate = eventTime.toLocalDate();
if(statisticalDate.isBefore(today)){ //统计时间不是当前日,需要重置
builder.setField("date",today.toString("yyyy-MM-dd"));
builder.setField("travelMileage",0D);
builder.setField("travelTime",0L);
if(eventDate.equals(today)){ //代表这条数据是今天的
builder.setField("lat",lat);
builder.setField("lng",lng);
......@@ -47,7 +44,6 @@ public class DailyMileageUpdate implements CacheEntryProcessor<BinaryObject,Bina
builder.setField("time",null);
mutableEntry.setValue(builder.build());
}
}else if(eventDate.equals(today)){
if(value.<Double>field("lat") == null){
builder.setField("lat",lat);
......@@ -55,9 +51,7 @@ public class DailyMileageUpdate implements CacheEntryProcessor<BinaryObject,Bina
builder.setField("time",time);
mutableEntry.setValue(builder.build());
}else{
DateTime lastTime = DateTime.parse(value.<String>field("time"),DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"));
if(lastTime.isBefore(eventTime)){
Double differDistance = getDistance(value.<Double>field("lat"), value.<Double>field("lng"), lat, lng);
Interval interval = new Interval(lastTime,eventTime);
......
......@@ -3,14 +3,13 @@ package com.hikcreate.data.client
import java.util.concurrent.TimeUnit
import com.hikcreate.ignite.domain.PrimaryKey
import com.hikcreate.ignite.domain.alarm.{AttachmentInfo, DailyAlarm, DailyAlarmDeal, DailyAlarmDetail}
import com.hikcreate.ignite.domain.alarm._
import com.hikcreate.ignite.domain.alarm.processor.{DailyAlarmDealUpdate, DailyAlarmUpdate}
import com.hikcreate.ignite.domain.basic._
import com.hikcreate.ignite.domain.vehicles.{AlarmNumber, DailyMileage, DriverNumber, VehicleNumber}
import com.hikcreate.ignite.processor._
import javax.cache.expiry.{CreatedExpiryPolicy, Duration}
import com.hikcreate.ignite.domain.vehicles.processor.{AlarmNumberUpdate, DailyTravelUpdate}
import com.hikcreate.ignite.domain.vehicles._
import org.apache.ignite.binary.BinaryObject
import org.apache.ignite.cache.CacheMode
import org.apache.ignite.cache.query.SqlFieldsQuery
import org.apache.ignite.configuration.CacheConfiguration
import org.apache.ignite.{Ignite, IgniteCache, Ignition}
......@@ -33,9 +32,6 @@ object IgniteClient {
}
binary.build()
}
ignite.destroyCache("AlarmInfo")
/*********************************基础信息表****************************************************************/
//平台基础信息表
lazy val basicPlatformInfo: IgniteCache[Long, PlatformInfo] = ignite.getOrCreateCache(
......@@ -46,7 +42,6 @@ object IgniteClient {
.setCacheMode(CacheMode.REPLICATED)
.setIndexedTypes(classOf[Long],classOf[PlatformInfo])
)
//企业基础信息表--企业接入情况
lazy val basicEnterpriseInfo: IgniteCache[Long, EnterpriseInfo] = ignite.getOrCreateCache(
new CacheConfiguration[Long,EnterpriseInfo]()
......@@ -56,7 +51,6 @@ object IgniteClient {
.setCacheMode(CacheMode.REPLICATED)
.setIndexedTypes(classOf[Long],classOf[EnterpriseInfo])
)
//车辆基础信息表--接入车辆数
lazy val basicVehicleInfo: IgniteCache[Long, VehicleInfo] = ignite.getOrCreateCache(
new CacheConfiguration[Long,VehicleInfo]()
......@@ -66,7 +60,6 @@ object IgniteClient {
.setCacheMode(CacheMode.REPLICATED)
.setIndexedTypes(classOf[Long],classOf[VehicleInfo])
)
//报警类型配置基础表
lazy val basicAlarmTypeInfo: IgniteCache[Long, AlarmTypeInfo] = ignite.getOrCreateCache(
new CacheConfiguration[Long,AlarmTypeInfo]()
......@@ -78,28 +71,25 @@ object IgniteClient {
)
/*********************************营运车辆监测****************************************************************/
/**
* 今日车辆在线情况 累计行驶 累计安全行驶里程 当前在线车辆 --完成
* 今日车辆在线情况 累计行驶 累计安全行驶里程
* 主键:车牌号 + 车牌颜色(定义唯一一辆车)
* 注意:此处的省市区来源于车辆信息基本表
* 数据来源:实时上传车辆定位消息 关联 车辆信息基本表 获取车辆的省 市 区 使用性质
* 注意:今日车辆在线情况 累计行驶 累计安全行驶里程的省市区来源于车辆信息基本表
*/
lazy val mileageCache: IgniteCache[PrimaryKey, DailyMileage] = ignite.getOrCreateCache(
new CacheConfiguration[PrimaryKey,DailyMileage]()
lazy val dailyTravelCache: IgniteCache[PrimaryKey,DailyTravel] = ignite.getOrCreateCache(
new CacheConfiguration[PrimaryKey,DailyTravel]()
.setSqlSchema("Integrated")
.setName("DailyMileage")
.setIndexedTypes(classOf[PrimaryKey],classOf[DailyMileage])
.setName("DailyTravel")
.setIndexedTypes(classOf[PrimaryKey],classOf[DailyTravel])
.setDataRegionName("500MB_Region")
.setCacheMode(CacheMode.REPLICATED)
)
def updateMileageCache(key: BinaryObject,lat:Double,lng:Double,time:String): Unit = {
mileageCache
dailyTravelCache
.withKeepBinary()
.invoke(key,new DailyMileageUpdate(lat,lng,time))
.invoke(key,new DailyTravelUpdate(lat,lng,time))
}
/**
* 接入驾驶人数 -完成
* 主键:身份证号码 - 去重
......@@ -151,7 +141,6 @@ object IgniteClient {
}
/*********************************安全行驶报警监测****************************************************************/
/**
* 附件历史记录
* 主键:车牌号 车牌颜色 设备ID 报警时间 序列号
......@@ -185,7 +174,6 @@ object IgniteClient {
.withKeepBinary()
.invoke(key,new DailyAlarmUpdate(time))
}
/**
* 今日报警处理数
* 主键:车牌号 车牌颜色 报警督办ID
......@@ -206,7 +194,6 @@ object IgniteClient {
.withKeepBinary()
.invoke(key,new DailyAlarmDealUpdate(map))
}
/**
* 今日报警详情
* 主键:车牌号 车牌颜色 报警时间
......@@ -253,18 +240,73 @@ object IgniteClient {
val value2 = new DailyAlarmDeal("01","2","","003","2019-10-20 12:00:00",true)
IgniteClient.dailyAlarmDealCache.withKeepBinary().putIfAbsent(getBinaryObject(new PrimaryKey("01","2","003")),value2)*/
/*val dailyAlarmDetail = new DailyAlarmDetail(
"33","08","01","01","2","",
"0x00","2019-10-20 10:00:00",100.00,100.00,1L,"CES")
IgniteClient.dailyAlarmDetailCache.withKeepBinary().put(getBinaryObject(new PrimaryKey("01","2","2019-10-20 10:00:00")),dailyAlarmDetail)*/
val dailyAlarmDetail = new DailyAlarmDetail(
"33","01","01","01","2","",
"0x00","2019-10-21 10:00:00",119.980300,30.003100,1L,"CES")
IgniteClient.dailyAlarmDetailCache.withKeepBinary().put(getBinaryObject(new PrimaryKey("01","2","2019-10-20 10:00:00")),dailyAlarmDetail)
val attachmentInfo = new AttachmentInfo("100","01","2","1","0x00","2019-10-21 10:00:00","1","2","1","group1/M00/00/04/CsXsyV2pVeCAFrzkAAmT9ee1rNo169.mp4","")
attachmentCache.withKeepBinary().put(getBinaryObject(new PrimaryKey("xxxxxxxxxx1")),attachmentInfo)
val attachmentInfo1 = new AttachmentInfo("100","01","2","1","0x00","2019-10-21 10:00:00","1","2","2","group1/M00/00/00/CsXswl2pVcOAZmznAAD1j-V9mnE916.jpg","")
attachmentCache.withKeepBinary().put(getBinaryObject(new PrimaryKey("xxxxxxxxxx2")),attachmentInfo1)
val dailyAlarmDetail1 = new DailyAlarmDetail(
"33","01","01","01","2","",
"0x00","2019-10-21 10:10:00",119.980300,30.003100,1L,"CES1")
IgniteClient.dailyAlarmDetailCache.withKeepBinary().put(getBinaryObject(new PrimaryKey("01","2","2019-10-21 10:10:00")),dailyAlarmDetail1)
val attachmentInfo2 = new AttachmentInfo("100","01","3","1","0x00","2019-10-21 10:10:00","1","2","1","group1/M00/00/04/CsXsyV2pVeCAFrzkAAmT9ee1rNo169.mp4","")
attachmentCache.withKeepBinary().put(getBinaryObject(new PrimaryKey("xxxxxxxxxx3")),attachmentInfo2)
val attachmentInfo3 = new AttachmentInfo("100","01","4","1","0x00","2019-10-21 10:10:00","1","2","2","group1/M00/00/00/CsXswl2pVcOAZmznAAD1j-V9mnE916.jpg","")
attachmentCache.withKeepBinary().put(getBinaryObject(new PrimaryKey("xxxxxxxxxx4")),attachmentInfo3)
val dailyAlarmDetail2 = new DailyAlarmDetail(
"33","01","01","01","2","",
"0x00","2019-10-21 10:20:00",119.981400,30.103200,1L,"CES2")
IgniteClient.dailyAlarmDetailCache.withKeepBinary().put(getBinaryObject(new PrimaryKey("01","2","2019-10-20 10:20:00")),dailyAlarmDetail2)
val attachmentInfo4 = new AttachmentInfo("100","01","2","1","0x00","2019-10-21 10:20:00","1","2","1","group1/M00/00/04/CsXsyV2pVeCAFrzkAAmT9ee1rNo169.mp4","")
attachmentCache.withKeepBinary().put(getBinaryObject(new PrimaryKey("xxxxxxxxxx5")),attachmentInfo4)
val attachmentInfo5 = new AttachmentInfo("100","01","2","1","0x00","2019-10-21 10:20:00","1","2","2","group1/M00/00/00/CsXswl2pVcOAZmznAAD1j-V9mnE916.jpg","")
attachmentCache.withKeepBinary().put(getBinaryObject(new PrimaryKey("xxxxxxxxxx6")),attachmentInfo5)
val dailyAlarmDetail3 = new DailyAlarmDetail(
"33","01","01","01","2","",
"0x00","2019-10-21 10:30:00",119.990300,30.113100,1L,"CES")
IgniteClient.dailyAlarmDetailCache.withKeepBinary().put(getBinaryObject(new PrimaryKey("01","2","2019-10-21 10:30:00")),dailyAlarmDetail3)
val attachmentInfo6 = new AttachmentInfo("100","01","2","1","0x00","2019-10-21 10:30:00","1","2","1","group1/M00/00/04/CsXsyV2pVeCAFrzkAAmT9ee1rNo169.mp4","")
attachmentCache.withKeepBinary().put(getBinaryObject(new PrimaryKey("xxxxxxxxxx7")),attachmentInfo6)
val attachmentInfo17 = new AttachmentInfo("100","01","2","1","0x00","2019-10-21 10:30:00","1","2","2","group1/M00/00/00/CsXswl2pVcOAZmznAAD1j-V9mnE916.jpg","")
attachmentCache.withKeepBinary().put(getBinaryObject(new PrimaryKey("xxxxxxxxxx8")),attachmentInfo17)
val dailyAlarmDetail4 = new DailyAlarmDetail(
"33","01","01","01","2","",
"0x00","2019-10-21 10:40:00",119.960300,30.113110,1L,"CES")
IgniteClient.dailyAlarmDetailCache.withKeepBinary().put(getBinaryObject(new PrimaryKey("01","2","2019-10-21 10:40:00")),dailyAlarmDetail4)
val attachmentInfo8 = new AttachmentInfo("100","01","2","1","0x00","2019-10-21 10:40:00","1","2","1","group1/M00/00/04/CsXsyV2pVeCAFrzkAAmT9ee1rNo169.mp4","")
attachmentCache.withKeepBinary().put(getBinaryObject(new PrimaryKey("xxxxxxxxxx9")),attachmentInfo8)
val attachmentInfo19 = new AttachmentInfo("100","01","2","1","0x00","2019-10-21 10:40:00","1","2","2","group1/M00/00/00/CsXswl2pVcOAZmznAAD1j-V9mnE916.jpg","")
attachmentCache.withKeepBinary().put(getBinaryObject(new PrimaryKey("xxxxxxxxxx10")),attachmentInfo19)
/*val attachmentInfo = new AttachmentInfo("100","01","2","1","0x00","2019-10-20 10:00:00","1","1","1","/opt/a.txt","")
attachmentCache.withKeepBinary().put(getBinaryObject(new PrimaryKey("xxxxxxxxxx")),attachmentInfo)*/
//val query = new SqlFieldsQuery("select count(*) from DailyAlarmDeal where isDeal = true")
val me = new DailyMileage("33","08","01","","2019-10-12",200.00,200.00,"",10.00,1L)
mileageCache.withKeepBinary().withKeepBinary().put(getBinaryObject(new PrimaryKey("")),me)
/*val me = new DailyTravel("33","08","01","","2019-10-12",200.00,200.00,"2019-10-20 17:02:00",10.00,1L,"11","22","33")
dailyTravelCache.withKeepBinary().withKeepBinary().put(getBinaryObject(new PrimaryKey("111")),me)
val d = new VehicleNumber("33","01","01","")
vehicleNumberCache.withKeepBinary().put(getBinaryObject(new PrimaryKey("1")),d)*/
ignite.close()
}
}
......@@ -7,12 +7,13 @@ import com.hikcreate.data.constant.Const
import com.hikcreate.data.model.TableKey
import com.hikcreate.data.util.{Tools, ZkManager}
import com.hikcreate.ignite.domain.PrimaryKey
import com.hikcreate.ignite.domain.alarm.{AttachmentInfo, DailyAlarm, DailyAlarmDeal, DailyAlarmDetail}
import com.hikcreate.ignite.domain.vehicles.{AlarmNumber, DailyMileage, DriverNumber, VehicleNumber}
import com.hikcreate.ignite.domain.alarm._
import com.hikcreate.ignite.domain.vehicles._
import org.apache.spark.streaming.kafka010._
import org.apache.spark.streaming.{Seconds, StreamingContext}
import org.joda.time.DateTime
import org.joda.time.format.DateTimeFormat
import scala.collection.mutable.ArrayBuffer
object SyncIgnite extends Sparking with Logging{
......@@ -54,39 +55,26 @@ object SyncIgnite extends Sparking with Logging{
val lon = json.getDouble("lon")/1000000
val lat = json.getDouble("lat")/1000000
val code = Tools.getLocationCode(lon,lat)
val time = json.getString("dateTime")//定位时间
val date = DateTime.parse(time,DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss")).toLocalDate.toString("yyyy-MM-dd")
val dateTime = DateTime.parse(json.getString("dateTime"),DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"))//定位时间
val time = dateTime.toString("yyyy-MM-dd HH:mm:ss")
val date = dateTime.toLocalDate.toString("yyyy-MM-dd")
val vehicleInfoOptional = Tools.getVehicleInfo(vehicleNo,vehicleColor)
val vehicleProvince = vehicleInfoOptional.map(x=>x.getProvince).getOrElse("无")
val vehicleCity = vehicleInfoOptional.map(x=>x.getCity).getOrElse("无")
val vehicleArea = vehicleInfoOptional.map(x=>x.getArea).getOrElse("无")
val useNature = vehicleInfoOptional.map(x=>x.getUseNature).getOrElse("无")
//累计行驶车辆数
val vehicleNumberKey = IgniteClient.getBinaryObject(new PrimaryKey(code._1,code._2,code._3,vehicleNo,vehicleColor))
val vehicleNumberValue = new VehicleNumber(code._1,code._2,code._3,useNature)
IgniteClient.vehicleNumberCache.withKeepBinary().put(vehicleNumberKey,vehicleNumberValue)
//当前在线车辆 今日车辆在线情况 累计行驶 累计安全行驶里程
val mileageKey = IgniteClient.getBinaryObject(new PrimaryKey(vehicleNo,vehicleColor))
val mileageValue = new DailyMileage("33","01","22",useNature,date,lat,lon,time,0D,0L)
if(!IgniteClient.mileageCache.withKeepBinary().putIfAbsent(mileageKey,mileageValue)){
IgniteClient.updateMileageCache(mileageKey,lat,lon,time)
}
/*
if(vehicleInfoOptional.isDefined){
val vehicleInfo = vehicleInfoOptional.get
val vehicleProvince = vehicleInfo.getProvince
val vehicleCity = vehicleInfo.getCity
val vehicleArea = vehicleInfo.getArea
val useNature = vehicleInfo.getUseNature
val vehicleNumberKey = new PrimaryKey(code._1,code._2,code._3,vehicleNo,vehicleColor)
val vehicleNumberValue = new VehicleNumber(code._1,code._2,code._3,useNature)
IgniteClient.vehicleNumberCache.put(vehicleNumberKey,vehicleNumberValue)//累计行驶车辆数
//累计行驶 累计安全行驶里程 今日车辆在线情况
val mileageKey = IgniteClient.getBinaryObject(new PrimaryKey(vehicleNo,vehicleColor))
if(!IgniteClient.mileageCache.withKeepBinary().containsKey(mileageKey)){
val mileageValue = new DailyMileage(vehicleProvince,vehicleCity,vehicleArea,useNature,date,lat,lon,time,0D,0L)
IgniteClient.mileageCache.withKeepBinary().put(mileageKey,mileageValue)
}else{
//val mileageValue = new DailyTravel(vehicleProvince,vehicleCity,vehicleArea,useNature,date,lat,lon,time,0D,0L)
val mileageValue = new DailyTravel("33","01","02",useNature,date,lat,lon,time,
0D,0L,code._1,code._2,code._3)
if(!IgniteClient.dailyTravelCache.withKeepBinary().putIfAbsent(mileageKey,mileageValue)){
IgniteClient.updateMileageCache(mileageKey,lat,lon,time)
}
}*/
//车辆定位消息补报
case tableKey if tableKey == TableKey(Some("0x1200"),Some("0x1203")) =>
Tools.addLocation(json).foreach{ x =>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment