Commit a4f24889 by 崔彦峰

svn to git

0 parents
Showing 69 changed files with 4960 additions and 0 deletions
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.com.glsx.framework</groupId>
<artifactId>framework-rpc-api</artifactId>
<version>1.0.2-SNAPSHOT</version>
</parent>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-kafka-device-api</artifactId>
<version>0.0.2-SNAPSHOT</version>
<name>rpc-dj-kafka-device-api</name>
<properties>
<deploy.scanPackage>cn.com.glsx.dj.device.remote</deploy.scanPackage>
</properties>
<build>
<plugins>
<plugin>
<groupId>cn.com.glsx.framework</groupId>
<artifactId>rpc-api-deploy-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-kafka-device-api</artifactId>
<version>0.0.2-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.device.model;
import java.io.Serializable;
/**
* @Title: 告警模型实体
* @Description:告警模型实体
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-04-28 11:02:04
*/
public class Alarm implements Serializable{
/**
*
*/
private static final long serialVersionUID = -54752770290935635L;
/** 设备号*/
private String deviceNO;
/** 厂商码*/
private String facID;
/** 终端上传时间*/
private String time;
/** 有效性 'A' 有效 'V' 无效*/
private String isValid;
/** 经度*/
private String lng;
/** 纬度*/
private String lat;
/** 速度*/
private String speed;
/** 超速*/
private String overSpeed;
/** 低压*/
private String lowerVol;
/** 断电,拔出*/
private String blackOut;
/** gps开路*/
private String gpsOpen;
/** 劫警*/
private String rob;
/** 报警原始数据*/
private String alertInfo;
/** 电压*/
private String voltage;
/** gps故障报警*/
private String gpsfault;
public String getDeviceNO() {
return deviceNO;
}
public void setDeviceNO(String deviceNO) {
this.deviceNO = deviceNO;
}
public String getFacID() {
return facID;
}
public void setFacID(String facID) {
this.facID = facID;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getIsValid() {
return isValid;
}
public void setIsValid(String isValid) {
this.isValid = isValid;
}
public String getLng() {
return lng;
}
public void setLng(String lng) {
this.lng = lng;
}
public String getLat() {
return lat;
}
public void setLat(String lat) {
this.lat = lat;
}
public String getSpeed() {
return speed;
}
public void setSpeed(String speed) {
this.speed = speed;
}
public String getOverSpeed() {
return overSpeed;
}
public void setOverSpeed(String overSpeed) {
this.overSpeed = overSpeed;
}
public String getLowerVol() {
return lowerVol;
}
public void setLowerVol(String lowerVol) {
this.lowerVol = lowerVol;
}
public String getBlackOut() {
return blackOut;
}
public void setBlackOut(String blackOut) {
this.blackOut = blackOut;
}
public String getGpsOpen() {
return gpsOpen;
}
public void setGpsOpen(String gpsOpen) {
this.gpsOpen = gpsOpen;
}
public String getRob() {
return rob;
}
public void setRob(String rob) {
this.rob = rob;
}
public String getAlertInfo() {
return alertInfo;
}
public void setAlertInfo(String alertInfo) {
this.alertInfo = alertInfo;
}
public String getVoltage() {
return voltage;
}
public void setVoltage(String voltage) {
this.voltage = voltage;
}
public String getGpsfault() {
return gpsfault;
}
public void setGpsfault(String gpsfault) {
this.gpsfault = gpsfault;
}
@Override
public String toString() {
return "Alarm [deviceNO=" + deviceNO + ", facID=" + facID + ", time=" + time + ", isValid=" + isValid + ", lng="
+ lng + ", lat=" + lat + ", speed=" + speed + ", overSpeed=" + overSpeed + ", lowerVol=" + lowerVol
+ ", blackOut=" + blackOut + ", gpsOpen=" + gpsOpen + ", rob=" + rob + ", alertInfo=" + alertInfo
+ ", voltage=" + voltage + ", gpsfault=" + gpsfault + "]";
}
}
package cn.com.glsx.dj.device.model;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* @Title: 设备告警实体
* @Description:设备告警实体
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-04-28 11:02:04
*/
@Entity
@Table(name = "dj_device_alarm_rec")
public class DeviceAlarmRec implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* id:自增ID
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", unique = true, nullable = false)
private Integer id;
/**
* sn:SN唯一识别码
*/
@Column(name = "sn")
private String sn;
/**
* lng:经度
*/
@Column(name = "lng")
private String lng;
/**
* lat:纬度
*/
@Column(name = "lat")
private String lat;
/**
* speed:速度
*/
@Column(name = "speed")
private String speed;
/**
* direction:方向
*/
@Column(name = "direction")
private String direction;
/**
* alarm_type:预警类型 0:按钮报警 1:断电报警 2:驶入围栏 3:驶出围栏 4:盗警 5:劫警 6:电池电压过低 7:超速报警 8:停车超时报警 9:GPS开路
*/
@Column(name = "alarm_type")
private Integer alarmType;
/**
* city_name:预警城市
*/
@Column(name = "city_name")
private String cityName;
/**
* del_flag:是否有效 0:有效 1:处理 2:失效 3:记录中
*/
@Column(name = "del_flag")
private Integer delFlag;
/**
* last_time:最后预警时间
*/
@Column(name = "last_time")
private Date lastTime;
/**
* last_lng:最后经度
*/
@Column(name = "last_lng")
private String lastLng;
/**
* last_lat:最后纬度
*/
@Column(name = "last_lat")
private String lastLat;
/**
* alarm_no:报警次数
*/
@Column(name = "alarm_no")
private Integer alarmNo;
/**
* begin_time:预警时间
*/
@Column(name = "begin_time")
private Date beginTime;
/**
* update_time:更新时间
*/
@Column(name = "update_time")
private Date updateTime;
/**
* vehicle_id:车辆ID
*/
@Column(name = "vehicle_id")
private Integer vehicleId;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getSn() {
return sn;
}
public void setSn(String sn) {
this.sn = sn == null ? null : sn.trim();
}
public String getLng() {
return lng;
}
public void setLng(String lng) {
this.lng = lng == null ? null : lng.trim();
}
public String getLat() {
return lat;
}
public void setLat(String lat) {
this.lat = lat == null ? null : lat.trim();
}
public String getSpeed() {
return speed;
}
public void setSpeed(String speed) {
this.speed = speed == null ? null : speed.trim();
}
public String getDirection() {
return direction;
}
public void setDirection(String direction) {
this.direction = direction == null ? null : direction.trim();
}
public Integer getAlarmType() {
return alarmType;
}
public void setAlarmType(Integer alarmType) {
this.alarmType = alarmType;
}
public String getCityName() {
return cityName;
}
public void setCityName(String cityName) {
this.cityName = cityName == null ? null : cityName.trim();
}
public Integer getDelFlag() {
return delFlag;
}
public void setDelFlag(Integer delFlag) {
this.delFlag = delFlag;
}
public Date getLastTime() {
return lastTime;
}
public void setLastTime(Date lastTime) {
this.lastTime = lastTime;
}
public String getLastLng() {
return lastLng;
}
public void setLastLng(String lastLng) {
this.lastLng = lastLng == null ? null : lastLng.trim();
}
public String getLastLat() {
return lastLat;
}
public void setLastLat(String lastLat) {
this.lastLat = lastLat == null ? null : lastLat.trim();
}
public Integer getAlarmNo() {
return alarmNo;
}
public void setAlarmNo(Integer alarmNo) {
this.alarmNo = alarmNo;
}
public Date getBeginTime() {
return beginTime;
}
public void setBeginTime(Date beginTime) {
this.beginTime = beginTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public Integer getVehicleId() {
return vehicleId;
}
public void setVehicleId(Integer vehicleId) {
this.vehicleId = vehicleId;
}
@Override
public String toString() {
return "DeviceAlarmRec [id=" + id + ", sn=" + sn + ", lng=" + lng + ", lat=" + lat + ", speed=" + speed
+ ", direction=" + direction + ", alarmType=" + alarmType + ", cityName=" + cityName + ", delFlag="
+ delFlag + ", lastTime=" + lastTime + ", lastLng=" + lastLng + ", lastLat=" + lastLat + ", alarmNo="
+ alarmNo + ", beginTime=" + beginTime + ", updateTime=" + updateTime + ", vehicleId=" + vehicleId
+ "]";
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.device.model;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* @Title: 设备告警历史实体
* @Description:设备告警历史实体
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-04-28 11:02:04
*/
@Entity
@Table(name = "dj_device_alarm_rec_history")
public class DeviceAlarmRecHistory implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", unique = true, nullable = false)
private Integer id;
/**
* sn:SN唯一识别码
*/
@Column(name = "sn")
private String sn;
/**
* lng:经度
*/
@Column(name = "lng")
private String lng;
/**
* lat:纬度
*/
@Column(name = "lat")
private String lat;
/**
* speed:速度
*/
@Column(name = "speed")
private String speed;
/**
* direction:方向
*/
@Column(name = "direction")
private String direction;
/**
* alarm_type:预警类型 0:按钮报警 1:断电报警 2:驶入围栏 3:驶出围栏 4:盗警 5:劫警 6:电池电压过低 7:超速报警 8:停车超时报警 9:GPS开路
*/
@Column(name = "alarm_type")
private Integer alarmType;
/**
* city_name:预警城市
*/
@Column(name = "city_name")
private String cityName;
/**
* del_flag:是否有效 0:有效 1:处理 2:失效 3:记录中
*/
@Column(name = "del_flag")
private Integer delFlag;
/**
* last_time:最后预警时间
*/
@Column(name = "last_time")
private Date lastTime;
/**
* last_lng:最后经度
*/
@Column(name = "last_lng")
private String lastLng;
/**
* last_lat:最后纬度
*/
@Column(name = "last_lat")
private String lastLat;
/**
* alarm_no:报警次数
*/
@Column(name = "alarm_no")
private Integer alarmNo;
/**
* begin_time:预警时间
*/
@Column(name = "begin_time")
private Date beginTime;
@Column(name = "vehicle_id")
private Integer vehicleId;
@Column(name = "is_valid")
private String isValid;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getSn() {
return sn;
}
public void setSn(String sn) {
this.sn = sn == null ? null : sn.trim();
}
public String getLng() {
return lng;
}
public void setLng(String lng) {
this.lng = lng == null ? null : lng.trim();
}
public String getLat() {
return lat;
}
public void setLat(String lat) {
this.lat = lat == null ? null : lat.trim();
}
public String getSpeed() {
return speed;
}
public void setSpeed(String speed) {
this.speed = speed == null ? null : speed.trim();
}
public String getDirection() {
return direction;
}
public void setDirection(String direction) {
this.direction = direction == null ? null : direction.trim();
}
public Integer getAlarmType() {
return alarmType;
}
public void setAlarmType(Integer alarmType) {
this.alarmType = alarmType;
}
public String getCityName() {
return cityName;
}
public void setCityName(String cityName) {
this.cityName = cityName == null ? null : cityName.trim();
}
public Integer getDelFlag() {
return delFlag;
}
public void setDelFlag(Integer delFlag) {
this.delFlag = delFlag;
}
public Date getLastTime() {
return lastTime;
}
public void setLastTime(Date lastTime) {
this.lastTime = lastTime;
}
public String getLastLng() {
return lastLng;
}
public void setLastLng(String lastLng) {
this.lastLng = lastLng == null ? null : lastLng.trim();
}
public String getLastLat() {
return lastLat;
}
public void setLastLat(String lastLat) {
this.lastLat = lastLat == null ? null : lastLat.trim();
}
public Integer getAlarmNo() {
return alarmNo;
}
public void setAlarmNo(Integer alarmNo) {
this.alarmNo = alarmNo;
}
public Date getBeginTime() {
return beginTime;
}
public void setBeginTime(Date beginTime) {
this.beginTime = beginTime;
}
public Integer getVehicleId() {
return vehicleId;
}
public void setVehicleId(Integer vehicleId) {
this.vehicleId = vehicleId;
}
public String getIsValid() {
return isValid;
}
public void setIsValid(String isValid) {
this.isValid = isValid;
}
@Override
public String toString() {
return "DeviceAlarmRecHistory [id=" + id + ", sn=" + sn + ", lng=" + lng + ", lat=" + lat + ", speed=" + speed
+ ", direction=" + direction + ", alarmType=" + alarmType + ", cityName=" + cityName + ", delFlag="
+ delFlag + ", lastTime=" + lastTime + ", lastLng=" + lastLng + ", lastLat=" + lastLat + ", alarmNo="
+ alarmNo + ", beginTime=" + beginTime + ", vehicleId=" + vehicleId
+ ", isValid=" + isValid + "]";
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.device.model;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* @Title: 设备在线实体类
* @Description:设备在线实体类
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-04-28 11:02:04
*/
@Entity
@Table(name = "dj_device_login")
public class DeviceLogin implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* id:流水号ID
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", unique = true, nullable = false)
private Integer id;
/**
* sn:sn号
*/
@Column(name = "sn")
private String sn;
/**
* status:登录状态 0:在线 1:离线 2:定位无效 3:已休眠
*/
@Column(name = "status")
private Integer status;
/**
* last_login_time:最后登录时间
*/
@Column(name = "last_login_time")
private Date lastLoginTime;
/**
* last_gprs_time:最后gprs时间
*/
@Column(name = "last_gprs_time")
private Date lastGprsTime;
/**
* last_vilid_time:最后无效点时间
*/
@Column(name = "last_vilid_time")
private Date lastVilidTime;
/**
* last_rt_track:最后有效定位时间
*/
@Column(name = "last_rt_track")
private Date lastRtTrack;
/**
* first_histrack:最早有效定位时间
*/
@Column(name = "first_histrack")
private Date firstHistrack;
/**
* first_login_time:首次登陆时间
*/
@Column(name = "first_login_time")
private Date firstLoginTime;
/**
* device_status:终端状态 0:正常 1:不正常
*/
@Column(name = "device_status")
private Integer deviceStatus;
/**
* locate_status:定位状态 0:有效 1:无效
*/
@Column(name = "locate_status")
private Integer locateStatus;
/**
* sub_sn_switch_status:备机切换状态 1 设置启动 2 已启动 3 已撤销 4 设置休眠
*/
@Column(name = "sub_sn_switch_status")
private Integer subSnSwitchStatus;
/**
* sub_sn_time:备机预计启动时间
*/
@Column(name = "sub_sn_time")
private Date subSnTime;
/**
* speed:速度
*/
@Column(name = "speed")
private Integer speed;
/**
* mileage:里程,单位:公里
*/
@Column(name = "mileage")
private Double mileage;
/**
* merchant_id:门店ID
*/
@Column(name = "merchant_id")
private Integer merchantId;
/**
* created_by:创建人
*/
@Column(name = "created_by")
private String createdBy;
/**
* created_date:创建时间
*/
@Column(name = "created_date")
private Date createdDate;
/**
* updated_by:修改人
*/
@Column(name = "updated_by")
private String updatedBy;
/**
* updated_date:修改时间
*/
@Column(name = "updated_date")
private Date updatedDate;
/**
* deleted_flag:删除标示:D 已删除;N 未删除[默认]
*/
@Column(name = "deleted_flag")
private String deletedFlag;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getSn() {
return sn;
}
public void setSn(String sn) {
this.sn = sn == null ? null : sn.trim();
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Date getLastLoginTime() {
return lastLoginTime;
}
public void setLastLoginTime(Date lastLoginTime) {
this.lastLoginTime = lastLoginTime;
}
public Date getLastGprsTime() {
return lastGprsTime;
}
public void setLastGprsTime(Date lastGprsTime) {
this.lastGprsTime = lastGprsTime;
}
public Date getLastVilidTime() {
return lastVilidTime;
}
public void setLastVilidTime(Date lastVilidTime) {
this.lastVilidTime = lastVilidTime;
}
public Date getLastRtTrack() {
return lastRtTrack;
}
public void setLastRtTrack(Date lastRtTrack) {
this.lastRtTrack = lastRtTrack;
}
public Date getFirstHistrack() {
return firstHistrack;
}
public void setFirstHistrack(Date firstHistrack) {
this.firstHistrack = firstHistrack;
}
public Date getFirstLoginTime() {
return firstLoginTime;
}
public void setFirstLoginTime(Date firstLoginTime) {
this.firstLoginTime = firstLoginTime;
}
public Integer getDeviceStatus() {
return deviceStatus;
}
public void setDeviceStatus(Integer deviceStatus) {
this.deviceStatus = deviceStatus;
}
public Integer getLocateStatus() {
return locateStatus;
}
public void setLocateStatus(Integer locateStatus) {
this.locateStatus = locateStatus;
}
public Integer getSubSnSwitchStatus() {
return subSnSwitchStatus;
}
public void setSubSnSwitchStatus(Integer subSnSwitchStatus) {
this.subSnSwitchStatus = subSnSwitchStatus;
}
public Date getSubSnTime() {
return subSnTime;
}
public void setSubSnTime(Date subSnTime) {
this.subSnTime = subSnTime;
}
public Integer getSpeed() {
return speed;
}
public void setSpeed(Integer speed) {
this.speed = speed;
}
public Double getMileage() {
return mileage;
}
public void setMileage(Double mileage) {
this.mileage = mileage;
}
public Integer getMerchantId() {
return merchantId;
}
public void setMerchantId(Integer merchantId) {
this.merchantId = merchantId;
}
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy == null ? null : createdBy.trim();
}
public Date getCreatedDate() {
return createdDate;
}
public void setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}
public String getUpdatedBy() {
return updatedBy;
}
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy == null ? null : updatedBy.trim();
}
public Date getUpdatedDate() {
return updatedDate;
}
public void setUpdatedDate(Date updatedDate) {
this.updatedDate = updatedDate;
}
public String getDeletedFlag() {
return deletedFlag;
}
public void setDeletedFlag(String deletedFlag) {
this.deletedFlag = deletedFlag == null ? null : deletedFlag.trim();
}
@Override
public String toString() {
return "DeviceLogin [id=" + id + ", sn=" + sn + ", status=" + status + ", lastLoginTime=" + lastLoginTime
+ ", lastGprsTime=" + lastGprsTime + ", lastVilidTime=" + lastVilidTime + ", lastRtTrack=" + lastRtTrack
+ ", firstHistrack=" + firstHistrack + ", firstLoginTime=" + firstLoginTime + ", deviceStatus="
+ deviceStatus + ", locateStatus=" + locateStatus + ", subSnSwitchStatus=" + subSnSwitchStatus
+ ", subSnTime=" + subSnTime + ", speed=" + speed + ", mileage=" + mileage + ", merchantId="
+ merchantId + ", createdBy=" + createdBy + ", createdDate=" + createdDate + ", updatedBy=" + updatedBy
+ ", updatedDate=" + updatedDate + ", deletedFlag=" + deletedFlag + "]";
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.device.model;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* @Title: 设备实体类
* @Description:设备实体类
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-04-28 11:02:04
*/
@Entity
@Table(name = "dj_insure_device")
public class InsureDevice implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* id:主键
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", unique = true, nullable = false)
private Integer id;
/**
* imsi:imsi
*/
@Column(name = "imsi")
private String imsi;
/**
* sn:设备号
*/
@Column(name = "sn")
private String sn;
/**
* device_name:设备型号(GT7001等)
*/
@Column(name = "device_name")
private String deviceName;
/**
* product_type:见字典项,产品类型(有源无源)
*/
@Column(name = "product_type")
private String productType;
/**
* device_type:设备类型(1:OBD;2:DVD;3:E_DOG;5:TBOX;6:行车记录仪;7:BBOX;8:追踪器;9:车载WiFi;12134:智能云镜)
*/
@Column(name = "device_type")
private String deviceType;
/**
* active_date:激活日期
*/
@Column(name = "active_date")
private Date activeDate;
/**
* vehicle_id:车辆id(dj_insure_vehicle.id)
*/
@Column(name = "vehicle_id")
private Integer vehicleId;
/**
* iccid:iccid
*/
@Column(name = "iccid")
private String iccid;
@Column(name = "sim_phone")
private String simPhone;
/**
* check_code:验证码
*/
@Column(name = "check_code")
private String checkCode;
/**
* is_active:0-未激活,1-已激活
*/
@Column(name = "is_active")
private Integer isActive;
@Column(name = "model_id")
private Integer modelId;
/**
* validate_status:设备验证状态:0-验证成功;1-正在查询;2-验证失败
*/
@Column(name = "validate_status")
private Integer validateStatus;
/**
* is_sub:主设备 0, 从设备 1
*/
@Column(name = "is_sub")
private Integer isSub;
/**
* partner:合作厂商,如先锋-XF
*/
@Column(name = "partner")
private String partner;
/**
* validate_nums:设备验证次数
*/
@Column(name = "validate_nums")
private Integer validateNums;
/**
* created_date:创建时间
*/
@Column(name = "created_date")
private Date createdDate;
/**
* created_by:创建人
*/
@Column(name = "created_by")
private String createdBy;
/**
* updated_date:修改时间
*/
@Column(name = "updated_date")
private Date updatedDate;
/**
* updated_by:修改人
*/
@Column(name = "updated_by")
private String updatedBy;
/**
* deleted_flag:默认N,(已删除‘D’,未删除N)
*/
@Column(name = "deleted_flag")
private String deletedFlag;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getImsi() {
return imsi;
}
public void setImsi(String imsi) {
this.imsi = imsi == null ? null : imsi.trim();
}
public String getSn() {
return sn;
}
public void setSn(String sn) {
this.sn = sn == null ? null : sn.trim();
}
public String getDeviceName() {
return deviceName;
}
public void setDeviceName(String deviceName) {
this.deviceName = deviceName == null ? null : deviceName.trim();
}
public String getProductType() {
return productType;
}
public void setProductType(String productType) {
this.productType = productType == null ? null : productType.trim();
}
public String getDeviceType() {
return deviceType;
}
public void setDeviceType(String deviceType) {
this.deviceType = deviceType == null ? null : deviceType.trim();
}
public Date getActiveDate() {
return activeDate;
}
public void setActiveDate(Date activeDate) {
this.activeDate = activeDate;
}
public Integer getVehicleId() {
return vehicleId;
}
public void setVehicleId(Integer vehicleId) {
this.vehicleId = vehicleId;
}
public String getIccid() {
return iccid;
}
public void setIccid(String iccid) {
this.iccid = iccid == null ? null : iccid.trim();
}
public String getSimPhone() {
return simPhone;
}
public void setSimPhone(String simPhone) {
this.simPhone = simPhone == null ? null : simPhone.trim();
}
public String getCheckCode() {
return checkCode;
}
public void setCheckCode(String checkCode) {
this.checkCode = checkCode == null ? null : checkCode.trim();
}
public Integer getIsActive() {
return isActive;
}
public void setIsActive(Integer isActive) {
this.isActive = isActive;
}
public Integer getModelId() {
return modelId;
}
public void setModelId(Integer modelId) {
this.modelId = modelId;
}
public Integer getValidateStatus() {
return validateStatus;
}
public void setValidateStatus(Integer validateStatus) {
this.validateStatus = validateStatus;
}
public Integer getIsSub() {
return isSub;
}
public void setIsSub(Integer isSub) {
this.isSub = isSub;
}
public String getPartner() {
return partner;
}
public void setPartner(String partner) {
this.partner = partner == null ? null : partner.trim();
}
public Integer getValidateNums() {
return validateNums;
}
public void setValidateNums(Integer validateNums) {
this.validateNums = validateNums;
}
public Date getCreatedDate() {
return createdDate;
}
public void setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy == null ? null : createdBy.trim();
}
public Date getUpdatedDate() {
return updatedDate;
}
public void setUpdatedDate(Date updatedDate) {
this.updatedDate = updatedDate;
}
public String getUpdatedBy() {
return updatedBy;
}
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy == null ? null : updatedBy.trim();
}
public String getDeletedFlag() {
return deletedFlag;
}
public void setDeletedFlag(String deletedFlag) {
this.deletedFlag = deletedFlag == null ? null : deletedFlag.trim();
}
@Override
public String toString() {
return "InsureDevice [id=" + id + ", imsi=" + imsi + ", sn=" + sn + ", deviceName=" + deviceName
+ ", productType=" + productType + ", deviceType=" + deviceType + ", activeDate=" + activeDate
+ ", vehicleId=" + vehicleId + ", iccid=" + iccid + ", simPhone=" + simPhone + ", checkCode="
+ checkCode + ", isActive=" + isActive + ", modelId=" + modelId + ", validateStatus=" + validateStatus
+ ", isSub=" + isSub + ", partner=" + partner + ", validateNums=" + validateNums + ", createdDate="
+ createdDate + ", createdBy=" + createdBy + ", updatedDate=" + updatedDate + ", updatedBy=" + updatedBy
+ ", deletedFlag=" + deletedFlag + "]";
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.device.model;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
/**
* @Title: 断电告警实体类
* @Description:断电告警实体类
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-04-28 11:02:04
*/
@Entity
@Table(name = "dj_power_off_alarm")
public class PowerOffAlarm implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* id:自增ID
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", unique = true, nullable = false)
private Integer id;
/**
* sn:设备号
*/
@Column(name = "sn")
private String sn;
/**
* type:1.断电 2.恢复
*/
@Column(name = "type")
private Integer type;
/**
* restore_times:恢复次数
*/
@Column(name = "restore_times")
private Integer restoreTimes;
/**
* alarm_times:报警次数
*/
@Column(name = "alarm_times")
private Integer alarmTimes;
/**
* max_duration:最大断电时长
*/
@Column(name = "max_duration")
private Long maxDuration;
/**
* min_duration:最小断电时长
*/
@Column(name = "min_duration")
private Long minDuration;
/**
* avg_duration:平均断电时长
*/
@Column(name = "avg_duration")
private Long avgDuration;
/**
* alarm_time:报警时间
*/
@Column(name = "alarm_time")
private Date alarmTime;
/**
* voltage:上报电压值
*/
@Column(name = "voltage")
private Float voltage;
/**
* alarm_place:报警地点
*/
@Column(name = "alarm_place")
private String alarmPlace;
/**
* lng:经度
*/
@Column(name = "lng")
private String lng;
/**
* lat:纬度
*/
@Column(name = "lat")
private String lat;
/**
* merchant_id:门店ID
*/
@Column(name = "merchant_id")
private Integer merchantId;
/**
* created_by:创建人
*/
@Column(name = "created_by")
private String createdBy;
/**
* created_date:创建时间
*/
@Column(name = "created_date")
private Date createdDate;
/**
* updated_by:修改人
*/
@Column(name = "updated_by")
private String updatedBy;
/**
* updated_date:修改时间
*/
@Column(name = "updated_date")
private Date updatedDate;
/**
* deleted_flag:删除标示:D 已删除;N 未删除[默认]
*/
@Column(name = "deleted_flag")
private String deletedFlag;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getSn() {
return sn;
}
public void setSn(String sn) {
this.sn = sn == null ? null : sn.trim();
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public Integer getRestoreTimes() {
return restoreTimes;
}
public void setRestoreTimes(Integer restoreTimes) {
this.restoreTimes = restoreTimes;
}
public Integer getAlarmTimes() {
return alarmTimes;
}
public void setAlarmTimes(Integer alarmTimes) {
this.alarmTimes = alarmTimes;
}
public Long getMaxDuration() {
return maxDuration;
}
public void setMaxDuration(Long maxDuration) {
this.maxDuration = maxDuration;
}
public Long getMinDuration() {
return minDuration;
}
public void setMinDuration(Long minDuration) {
this.minDuration = minDuration;
}
public Long getAvgDuration() {
return avgDuration;
}
public void setAvgDuration(Long avgDuration) {
this.avgDuration = avgDuration;
}
public Date getAlarmTime() {
return alarmTime;
}
public void setAlarmTime(Date alarmTime) {
this.alarmTime = alarmTime;
}
public Float getVoltage() {
return voltage;
}
public void setVoltage(Float voltage) {
this.voltage = voltage;
}
public String getAlarmPlace() {
return alarmPlace;
}
public void setAlarmPlace(String alarmPlace) {
this.alarmPlace = alarmPlace == null ? null : alarmPlace.trim();
}
public String getLng() {
return lng;
}
public void setLng(String lng) {
this.lng = lng == null ? null : lng.trim();
}
public String getLat() {
return lat;
}
public void setLat(String lat) {
this.lat = lat == null ? null : lat.trim();
}
public Integer getMerchantId() {
return merchantId;
}
public void setMerchantId(Integer merchantId) {
this.merchantId = merchantId;
}
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy == null ? null : createdBy.trim();
}
public Date getCreatedDate() {
return createdDate;
}
public void setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}
public String getUpdatedBy() {
return updatedBy;
}
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy == null ? null : updatedBy.trim();
}
public Date getUpdatedDate() {
return updatedDate;
}
public void setUpdatedDate(Date updatedDate) {
this.updatedDate = updatedDate;
}
public String getDeletedFlag() {
return deletedFlag;
}
public void setDeletedFlag(String deletedFlag) {
this.deletedFlag = deletedFlag == null ? null : deletedFlag.trim();
}
@Override
public String toString() {
return "PowerOffAlarm [id=" + id + ", sn=" + sn + ", type=" + type + ", restoreTimes=" + restoreTimes
+ ", alarmTimes=" + alarmTimes + ", maxDuration=" + maxDuration + ", minDuration=" + minDuration
+ ", avgDuration=" + avgDuration + ", alarmTime=" + alarmTime + ", voltage=" + voltage + ", alarmPlace="
+ alarmPlace + ", lng=" + lng + ", lat=" + lat + ", merchantId=" + merchantId + ", createdBy="
+ createdBy + ", createdDate=" + createdDate + ", updatedBy=" + updatedBy + ", updatedDate="
+ updatedDate + ", deletedFlag=" + deletedFlag + "]";
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.device.vo;
import java.io.Serializable;
/**
* @Title: 设备在线记录sn
* @Description:设备在线记录sn
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-04-28 11:02:04
*/
public class DeviceSnVo implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private String sn;
public String getSn() {
return sn;
}
public void setSn(String sn) {
this.sn = sn;
}
@Override
public String toString() {
return "DeviceSnVo [sn=" + sn + "]";
}
}
# framework-archetype-rpc-api
RPC-API项目骨架
一、项目结构说明:
└─src
├─main
├─java
├─cn.com.glsx.dj.device.dto 数据传输模型层
├─cn.com.glsx.dj.device.enums 枚举定义
├─cn.com.glsx.dj.device.model 数据模型层
└─cn.com.glsx.dj.device.remote RPC暴露服务层
└─resources 资源文件目录
└─rpc
└─dubbo.xml dubbo接口配置
└─pom.xml pom文件
二、使用说明:
1、API改动后,请及时deploy到Maven仓库
三、注意事项:
1、rpc-api-deploy-maven-plugin api上报插件需配置当前api的jar包的引用。
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
</beans>
\ No newline at end of file \ No newline at end of file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.com.glsx.framework</groupId>
<artifactId>framework-rpc</artifactId>
<version>1.0.1-SNAPSHOT</version>
</parent>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-kafka-device</artifactId>
<version>0.0.2-SNAPSHOT</version>
<name>rpc-dj-kafka-device</name>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-kafka-device-api</artifactId>
<version>0.0.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.glsx.gps</groupId>
<artifactId>gps-common-utils</artifactId>
<version>0.0.4-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.glsx.gps.ice</groupId>
<artifactId>ice-tools</artifactId>
<version>1.0.10-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.glsx.gps.dubbo</groupId>
<artifactId>glsx-dubbo-api</artifactId>
<version>1.1.0-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>glsx-poi-search</groupId>
<artifactId>glsx-poi-search</artifactId>
<version>0.0.2-RELEASE</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.glsx.gps.dubbo</groupId>
<artifactId>glsx-dubbo-common</artifactId>
<version>1.0.6</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.glsx.obd</groupId>
<artifactId>glsx-obd-model</artifactId>
<version>1.0.4</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.glsx.poi</groupId>
<artifactId>glsx-poi-jar</artifactId>
<version>1.1.2-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.glsx.gps</groupId>
<artifactId>glsx-resident-tools</artifactId>
<version>1.0.3-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.glsx.ngp</groupId>
<artifactId>glsx-ngp-web</artifactId>
<version>1.0.2</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.glsx.gps.ice</groupId>
<artifactId>glsx-voltage-tools</artifactId>
<version>1.0.4</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>Ice</groupId>
<artifactId>Ice</artifactId>
<version>3.5.1</version>
</dependency>
<dependency>
<groupId>org.oreframework.boot</groupId>
<artifactId>ore-boot-starter-jms</artifactId>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.6.1</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.device;
import org.oreframework.boot.main.AbsOreBootStarter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.ComponentScan;
/**
* @Title: Main.java
* @Description:
* @author deployer name
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2015
*/
@SpringBootApplication
@ServletComponentScan
@ComponentScan(basePackages = {"com.glsx.ice","cn.com.glsx.dj.device"})
public class Main extends AbsOreBootStarter {
@Override
public void run(String[] args)
{
SpringApplication.run(Main.class, args);
}
public static void main(String[] args)
{
Main main = new Main();
main.run(args);
}
}
package cn.com.glsx.dj.device.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
/**
* @Title: 告警设备过滤规则配置读取
* @Description:告警设备过滤规则配置读取
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-04-28 11:02:04
*/
@Configuration
@ConfigurationProperties("alarm.filter")
public class AlarmFilterProperty {
private String batch;
private String deviceno;
public String getBatch() {
return batch;
}
public void setBatch(String batch) {
this.batch = batch;
}
public String getDeviceno() {
return deviceno;
}
public void setDeviceno(String deviceno) {
this.deviceno = deviceno;
}
}
package cn.com.glsx.dj.device.config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
/**
* @Title: spring上下文读取
* @Description:spring上下文读取
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-04-28 11:02:04
*/
@Component
public class ApplicationContextRegister implements ApplicationContextAware {
private static Logger logger = LoggerFactory.getLogger(ApplicationContextRegister.class);
private static ApplicationContext APPLICATION_CONTEXT;
/**
* 设置spring上下文
* @param applicationContext spring上下文
* @throws BeansException
* */
@Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
logger.debug("ApplicationContext registed-->{}", applicationContext);
APPLICATION_CONTEXT = applicationContext;
}
/**
* 获取容器
* @return
*/
public static ApplicationContext getApplicationContext() {
return APPLICATION_CONTEXT;
}
/**
* 获取容器对象
* @param type
* @param <T>
* @return
*/
public static <T> T getBean(Class<T> type) {
return APPLICATION_CONTEXT.getBean(type);
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.device.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
/**
* @Title: 读取阻塞队列大小配置
* @Description:读取阻塞队列大小配置
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-04-28 11:02:04
*/
@Configuration
@ConfigurationProperties("blocking.queue")
public class BlockingQueueProperty {
private int size;
public int getSize() {
return size;
}
public void setSize(int size) {
this.size = size;
}
}
package cn.com.glsx.dj.device.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
/**
* @Title: 消费实例配置
* @Description:消费实例配置
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-04-28 11:02:04
*/
@Configuration
@ConfigurationProperties("consumer.class")
public class ConsumerPropertys {
private String fullClassNames;
public String getFullClassNames() {
return fullClassNames;
}
public void setFullClassNames(String fullClassNames) {
this.fullClassNames = fullClassNames;
}
}
package cn.com.glsx.dj.device.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
/**
* @Title: DeviceProperty.java
* @Description:
* @author deployer name
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2017
*/
@Configuration
@ConfigurationProperties("ice")
public class DeviceProperty {
}
package cn.com.glsx.dj.device.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
/**
* @Title: 读取设备类型配置
* @Description:读取设备类型配置
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-04-28 11:02:04
*/
@Configuration
@ConfigurationProperties("device")
public class DevicenoFirstProperty {
private String gt700DevicenoFirst;
private String gt700BDevicenoFirst;
private String gt701aDevicenoFirst;
private String gt701cDevicenoFirst;
private String gt702DevicenoFirst;
private String gt703DevicenoFirst;
private String gt703BDevicenoFirst;
private String gt706DevicenoFirst;
private String gt803DevicenoFirst;
private String ddDevicenoFirst;
private String gt801cDevicenoFirst;
private String gt801dDevicenoFirst;
private String yyDevicenoFirst;
private String wyDevicenoFirst;
public String getGt700DevicenoFirst() {
return gt700DevicenoFirst;
}
public void setGt700DevicenoFirst(String gt700DevicenoFirst) {
this.gt700DevicenoFirst = gt700DevicenoFirst;
}
public String getGt700BDevicenoFirst() {
return gt700BDevicenoFirst;
}
public void setGt700BDevicenoFirst(String gt700bDevicenoFirst) {
gt700BDevicenoFirst = gt700bDevicenoFirst;
}
public String getGt701aDevicenoFirst() {
return gt701aDevicenoFirst;
}
public void setGt701aDevicenoFirst(String gt701aDevicenoFirst) {
this.gt701aDevicenoFirst = gt701aDevicenoFirst;
}
public String getGt701cDevicenoFirst() {
return gt701cDevicenoFirst;
}
public void setGt701cDevicenoFirst(String gt701cDevicenoFirst) {
this.gt701cDevicenoFirst = gt701cDevicenoFirst;
}
public String getGt702DevicenoFirst() {
return gt702DevicenoFirst;
}
public void setGt702DevicenoFirst(String gt702DevicenoFirst) {
this.gt702DevicenoFirst = gt702DevicenoFirst;
}
public String getGt703DevicenoFirst() {
return gt703DevicenoFirst;
}
public void setGt703DevicenoFirst(String gt703DevicenoFirst) {
this.gt703DevicenoFirst = gt703DevicenoFirst;
}
public String getGt703BDevicenoFirst() {
return gt703BDevicenoFirst;
}
public void setGt703BDevicenoFirst(String gt703bDevicenoFirst) {
gt703BDevicenoFirst = gt703bDevicenoFirst;
}
public String getGt706DevicenoFirst() {
return gt706DevicenoFirst;
}
public void setGt706DevicenoFirst(String gt706DevicenoFirst) {
this.gt706DevicenoFirst = gt706DevicenoFirst;
}
public String getGt803DevicenoFirst() {
return gt803DevicenoFirst;
}
public void setGt803DevicenoFirst(String gt803DevicenoFirst) {
this.gt803DevicenoFirst = gt803DevicenoFirst;
}
public String getDdDevicenoFirst() {
return ddDevicenoFirst;
}
public void setDdDevicenoFirst(String ddDevicenoFirst) {
this.ddDevicenoFirst = ddDevicenoFirst;
}
public String getGt801cDevicenoFirst() {
return gt801cDevicenoFirst;
}
public void setGt801cDevicenoFirst(String gt801cDevicenoFirst) {
this.gt801cDevicenoFirst = gt801cDevicenoFirst;
}
public String getGt801dDevicenoFirst() {
return gt801dDevicenoFirst;
}
public void setGt801dDevicenoFirst(String gt801dDevicenoFirst) {
this.gt801dDevicenoFirst = gt801dDevicenoFirst;
}
public String getYyDevicenoFirst() {
return yyDevicenoFirst;
}
public void setYyDevicenoFirst(String yyDevicenoFirst) {
this.yyDevicenoFirst = yyDevicenoFirst;
}
public String getWyDevicenoFirst() {
return wyDevicenoFirst;
}
public void setWyDevicenoFirst(String wyDevicenoFirst) {
this.wyDevicenoFirst = wyDevicenoFirst;
}
}
package cn.com.glsx.dj.device.config;
import org.springframework.context.annotation.Configuration;
/**
* @Title: DubboConfig.java
* @Description: Dubbo服务注册配置
* @author deployer name
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2018
*/
@Configuration
public class DubboConfig {
//@Autowired
//private ReferenceBuilderFactory factory;
/**
* 注册远程服务(示例)
* RpcRemote为需要调用的远程服务
* @return
*/
/*@Bean
public RpcRemote rpcApiMethodRemote(){
return factory.builder(RpcRemote.class).check(false).timeout(30000).build();
}*/
}
package cn.com.glsx.dj.device.config;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentMap;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import com.google.common.collect.MapMaker;
import cn.com.glsx.dj.device.enums.AlarmConstants;
import cn.com.glsx.dj.device.mapper.DeviceLoginMapper;
import cn.com.glsx.dj.device.mapper.InsureDeviceMapper;
import cn.com.glsx.dj.device.mapper.InsureVehicleMapper;
import cn.com.glsx.dj.device.model.DeviceAlarmRec;
import cn.com.glsx.dj.device.model.DeviceAlarmRecHistory;
import cn.com.glsx.dj.device.model.DeviceLogin;
import cn.com.glsx.dj.device.model.InsureDevice;
import cn.com.glsx.dj.device.model.InsureVehicle;
import cn.com.glsx.dj.device.vo.DeviceSnVo;
/**
* @Title: 启动执行 初始化数据到缓存中
* @Description:启动执行 初始化数据到缓存中
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-04-28 11:02:04
*/
@Component
public class InitData implements CommandLineRunner {
@Autowired
private InsureDeviceMapper insureDeviceMapper;
@Autowired
private InsureVehicleMapper insureVehicleMapper;
@Autowired
private DeviceLoginMapper deviceLoginMapper;
public static ConcurrentMap<String, DeviceLogin> deviceLoginMap = new MapMaker().makeMap();
public static ConcurrentMap<String, String> deviceLoginSnMap = new MapMaker().makeMap();
public static ConcurrentMap<String, DeviceAlarmRec> deviceAlarmRecMap = new MapMaker().makeMap();
public static ConcurrentMap<String, DeviceAlarmRecHistory> deviceAlarmRecHistoryMap = new MapMaker().makeMap();
public static ConcurrentMap<String, InsureDevice> cacheDeviceInfo= new MapMaker().makeMap();
public static ConcurrentMap<Integer, InsureVehicle> cacheVehicle = new MapMaker().makeMap();
public static List<Integer> listAlarm=new ArrayList<Integer>();
public static DeviceLogin getOneDeviceLogin(String sn) {
DeviceLogin deviceLogin = null;
if(null != sn && sn.length() >0) {
deviceLogin = deviceLoginMap.get(sn);
}
return deviceLogin;
}
public static void merge(String sn,DeviceLogin deviceLogin) {
DeviceLogin deviceLoginCache = deviceLoginMap.get(sn);
if(null != deviceLoginCache) {
if(null != deviceLogin.getLastLoginTime()) {
deviceLoginCache.setLastLoginTime(deviceLogin.getLastLoginTime());
}
if(null != deviceLogin.getFirstHistrack()) {
deviceLoginCache.setFirstHistrack(deviceLogin.getFirstHistrack());
}
if(null != deviceLogin.getLastGprsTime()) {
deviceLoginCache.setLastGprsTime(deviceLogin.getLastGprsTime());
}
if(null != deviceLogin.getLastRtTrack()) {
deviceLoginCache.setLastRtTrack(deviceLogin.getLastRtTrack());
}
if(null != deviceLogin.getLastVilidTime()) {
deviceLoginCache.setLastVilidTime(deviceLogin.getLastVilidTime());
}
if(null != deviceLogin.getDeviceStatus()) {
deviceLoginCache.setDeviceStatus(deviceLogin.getDeviceStatus());
}
if(null != deviceLogin.getStatus()) {
deviceLoginCache.setStatus(deviceLogin.getStatus());
}
if(null != deviceLogin.getLocateStatus()) {
deviceLoginCache.setLocateStatus(deviceLogin.getLocateStatus());
}
if(null != deviceLogin.getSubSnSwitchStatus()) {
deviceLoginCache.setSubSnSwitchStatus(deviceLogin.getSubSnSwitchStatus());
}
if(null != deviceLogin.getSubSnTime()) {
deviceLoginCache.setSubSnTime(deviceLogin.getSubSnTime());
}
if(null != deviceLogin.getFirstHistrack()) {
deviceLoginCache.setFirstHistrack(deviceLogin.getFirstHistrack());
}
deviceLoginMap.put(sn, deviceLoginCache);
} else {
deviceLoginMap.put(sn, deviceLogin);
}
}
@Override
public void run(String... args) throws Exception {
initVehicle();
initDeviceInfo();
initSn();
alarmType();
}
public void initVehicle() {
List<InsureVehicle> list = insureVehicleMapper.selectAll();
if(CollectionUtils.isNotEmpty(list)){
for (InsureVehicle vehicle : list) {
cacheVehicle.put(vehicle.getId(), vehicle);
}
}
}
public void initSn() {
List<DeviceSnVo> list = deviceLoginMapper.selectSnList();
if(CollectionUtils.isNotEmpty(list)){
for (DeviceSnVo sn : list) {
deviceLoginSnMap.put(sn.getSn(), sn.getSn());
}
}
}
public void initDeviceInfo() {
List<InsureDevice> list = insureDeviceMapper.selectAll();
if(CollectionUtils.isNotEmpty(list)){
for (InsureDevice device : list) {
if(null != device.getSn()) {
cacheDeviceInfo.put(device.getSn(), device);
}
}
}
}
public void alarmType(){
//只保留断电报警 20160414
// listAlarm.add(AlarmConstants.GPS_ALARM_OVERSPEED);
// listAlarm.add(AlarmConstants.GPS_ALARM_GPSOPEN);
listAlarm.add(AlarmConstants.GPS_ALARM_BLACKOUT);
// listAlarm.add(AlarmConstants.GPS_ALARM_LOWERVOL);
// listAlarm.add(AlarmConstants.GPS_ALARM_ROB);
listAlarm.add(AlarmConstants.GPS_ALARM_GPSOPEN);
listAlarm.add(AlarmConstants.GPS_ALARM_GPSFAULT);
}
}
package cn.com.glsx.dj.device.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
/**
* @Title: 特殊设备号开头配置
* @Description:特殊设备号开头配置
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-04-28 11:02:04
*/
@Configuration
@ConfigurationProperties("special.gt")
public class SpecialGtFirstProperty {
private String first;
public String getFirst() {
return first;
}
public void setFirst(String first) {
this.first = first;
}
}
package cn.com.glsx.dj.device.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
/**
* @Title: SystemProperty.java
* @Description:
* @author deployer name
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2017
*/
@Configuration
@ConfigurationProperties("system")
public class SystemProperty {
/**
* 对应配置项:system.name
*/
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package cn.com.glsx.dj.device.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
/**
* @Title: TopicProperty.java
* @Description:
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2019
*/
@Configuration
@ConfigurationProperties("topic")
public class TopicProperty {
/**
* 设备告警
*/
private String gpsAlarm;
/**
* 断电告警
*/
private String gpsAlarmPowerOff;
/**
* 基站
*/
private String gpsBaseStation;
/**
*
*/
private String gpsGpsandbs;
/**
* GPS数据
*/
private String gpsData;
/**
* 登陆
*/
private String gpsLogin;
/**
* 下线
*/
private String gpsLogout;
/**
* 上线
*/
private String gpsOnline;
/**
* 休眠
*/
private String gpsSleep;
public String getGpsAlarm() {
return gpsAlarm;
}
public void setGpsAlarm(String gpsAlarm) {
this.gpsAlarm = gpsAlarm;
}
public String getGpsAlarmPowerOff() {
return gpsAlarmPowerOff;
}
public void setGpsAlarmPowerOff(String gpsAlarmPowerOff) {
this.gpsAlarmPowerOff = gpsAlarmPowerOff;
}
public String getGpsBaseStation() {
return gpsBaseStation;
}
public void setGpsBaseStation(String gpsBaseStation) {
this.gpsBaseStation = gpsBaseStation;
}
public String getGpsGpsandbs() {
return gpsGpsandbs;
}
public void setGpsGpsandbs(String gpsGpsandbs) {
this.gpsGpsandbs = gpsGpsandbs;
}
public String getGpsData() {
return gpsData;
}
public void setGpsData(String gpsData) {
this.gpsData = gpsData;
}
public String getGpsLogin() {
return gpsLogin;
}
public void setGpsLogin(String gpsLogin) {
this.gpsLogin = gpsLogin;
}
public String getGpsLogout() {
return gpsLogout;
}
public void setGpsLogout(String gpsLogout) {
this.gpsLogout = gpsLogout;
}
public String getGpsOnline() {
return gpsOnline;
}
public void setGpsOnline(String gpsOnline) {
this.gpsOnline = gpsOnline;
}
public String getGpsSleep() {
return gpsSleep;
}
public void setGpsSleep(String gpsSleep) {
this.gpsSleep = gpsSleep;
}
@Override
public String toString() {
return "TopicProperty [gpsAlarm=" + gpsAlarm + ", gpsAlarmPowerOff=" + gpsAlarmPowerOff + ", gpsBaseStation="
+ gpsBaseStation + ", gpsGpsandbs=" + gpsGpsandbs + ", gpsData=" + gpsData + ", gpsLogin=" + gpsLogin
+ ", gpsLogout=" + gpsLogout + ", gpsOnline=" + gpsOnline + ", gpsSleep=" + gpsSleep + "]";
}
}
package cn.com.glsx.dj.device.enums;
/**
* 报警常量
* @author [叶廷荣]
* @version [1.0, 2014-8-25 下午02:13:58 ]
*
*/
public interface AlarmConstants {
// 0:按钮报警 1:断电报警 2:驶入围栏 3:驶出围栏 4:盗警 5:劫警 6:电池电压过低 7:超速报警 8:停车超时报警 9:GPS开路
/**劫警**/
int GPS_ALARM_ROB=5;
/**电池电压过低**/
int GPS_ALARM_LOWERVOL=6;
/**GPS开路**/
int GPS_ALARM_GPSOPEN=9;
/**断电报警**/
int GPS_ALARM_BLACKOUT=1;
/**超速报警**/
int GPS_ALARM_OVERSPEED= 7;
/**没有报警**/
String GPS_ALARM_IS="0";
/**有报警**/
String GPS_ALARM_NO="1";
/**有效轨迹**/
String GPS_IS="A";
/**连续2次**/
int GPS_SERIAL=2;
/**有效记录**/
int GPS_DEFLAG_ZERO=0;
/**处理**/
int GPS_DEFLAG_ONE=1;
/**失效**/
int GPS_DEFLAG_TWO=2;
/**记录中**/
int GPS_DEFLAG_THREE=3;
String GPS_ALARM="0";
/**gps故障报警**/
int GPS_ALARM_GPSFAULT=10;
String DEVICESNSTART17 = "17";
int ENDDEVICENO = 799;
int YEAR15 = 15;
int MONTH1 = 1;
int MONTH11 = 11;
int MONTH12 = 12;
String BINDDEVICECNTD = "-单";
String BINDDEVICECNTS = "-双";
double VOLTAGE100 = 100;
double VOLTAGE34 = 3.4;
double VOLTAGE41 = 4.1;
int ALARMNO2 = 2;
int ALARMNO5 = 5;
int THREADSIZE = 1;
}
package cn.com.glsx.dj.device.kafka;
import java.text.ParseException;
import java.util.Date;
import org.apache.commons.lang.time.DateFormatUtils;
import org.apache.commons.lang.time.DateUtils;
/**
* @Title: Unix时间转换
* @Description:Unix时间转换
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-5-6
*/
public class UnixTimeParse {
/**
* Unix时间戳(Unix timestamp) 转日期格式
*
* @param timestamp
* @return
*/
static final String DATE_PARTEN = "yyyy-MM-dd HH:mm:ss";
static final String[] PATTERNS = {"yyyy-MM-dd HH:mm:ss"};
public static String parseTimeStampDate(int timestamp) {
Date date = parseTimeStampDate2Date(timestamp);
return DateFormatUtils.format(date, DATE_PARTEN);
}
public static Date parseTimeStampDate2Date(int timestamp) {
Long timeLong = Long.valueOf(timestamp) * 1000;
Date date = new Date(timeLong);
return date;
}
/**
* 日期字符串解析出日期
*
* @param dateStr
* @return
*/
public static Date safeParseDate(String dateStr) {
try {
return DateUtils.parseDate(dateStr, PATTERNS);
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
public static String latlng(int value){
java.text.DecimalFormat df =new java.text.DecimalFormat("#.000000");
String l = df .format((double)value/1000000);
return l;
}
}
package cn.com.glsx.dj.device.kafka.consumer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import cn.com.glsx.dj.device.config.TopicProperty;
/**
* @Title: 定义kafka消费bean
* @Description:定义kafka消费bean
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-5-6
*/
@Configuration
public class ConsumerConfiguration {
@Autowired
private TopicProperty topicProperty;
@Bean
@Scope("prototype")
public GpsAlarmConsumer getGpsAlarmConsumer() {
String topic = topicProperty.getGpsAlarm();
return new GpsAlarmConsumer(topic);
}
@Bean
@Scope("prototype")
public GpsAlarmPowerOffConsumer getGpsAlarmPowerOffConsumer() {
String topic = topicProperty.getGpsAlarmPowerOff();
return new GpsAlarmPowerOffConsumer(topic);
}
@Bean
@Scope("prototype")
public GpsBasestationConsumer getGpsBasestationConsumer() {
String topic = topicProperty.getGpsBaseStation();
return new GpsBasestationConsumer(topic);
}
@Bean
@Scope("prototype")
public GpsGpsandbsConsumer getGpsGpsandbsConsumer() {
String topic = topicProperty.getGpsGpsandbs();
return new GpsGpsandbsConsumer(topic);
}
@Bean
@Scope("prototype")
public GpsGpsdataConsumer getGpsGpsdataConsumer() {
String topic = topicProperty.getGpsData();
return new GpsGpsdataConsumer(topic);
}
@Bean
@Scope("prototype")
public GpsLoginConsumer getGpsLoginConsumer() {
String topic = topicProperty.getGpsLogin();
return new GpsLoginConsumer(topic);
}
@Bean
@Scope("prototype")
public GpsLogoutConsumer getGpsLogoutConsumer() {
String topic = topicProperty.getGpsLogout();
return new GpsLogoutConsumer(topic);
}
@Bean
@Scope("prototype")
public GpsOnlineConsumer getGpsOnlineConsumer() {
String topic = topicProperty.getGpsOnline();
return new GpsOnlineConsumer(topic);
}
@Bean
@Scope("prototype")
public GpsSleepConsumer getGpsSleepConsumer() {
String topic = topicProperty.getGpsSleep();
return new GpsSleepConsumer(topic);
}
}
package cn.com.glsx.dj.device.kafka.consumer;
import cn.com.glsx.dj.device.kafka.UnixTimeParse;
import cn.com.glsx.dj.device.kafka.kafkaSvr;
import cn.com.glsx.dj.device.model.Alarm;
/**
* @Title: 实体转换
* @Description:实体转换
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-5-6
*/
public class ConsumerDataParse {
public static Alarm parse(byte[] data) {
try {
kafkaSvr.AlarmReq alarmReq = kafkaSvr.AlarmReq.parseFrom(data);
Alarm alarm = new Alarm();
alarm.setDeviceNO(alarmReq.getDevicesn());
alarm.setFacID(alarmReq.getFacid());
//报警位置
kafkaSvr.MINIGPSDATA minigpsData = alarmReq.getGpsdata();
alarm.setTime(UnixTimeParse.parseTimeStampDate(minigpsData.getTime()));
alarm.setLng(UnixTimeParse.latlng(minigpsData.getLongitude()));
alarm.setLat(UnixTimeParse.latlng(minigpsData.getLatitude()));
alarm.setSpeed(""+minigpsData.getSpeed());
alarm.setIsValid(minigpsData.getValid());
//报警数据
kafkaSvr.ALARMDATA alarmData = alarmReq.getAlarmdata();
alarm.setOverSpeed(""+alarmData.getOverspeed());
alarm.setLowerVol(""+alarmData.getLowervol());
alarm.setBlackOut(""+alarmData.getBlackout());
alarm.setGpsOpen(""+alarmData.getGpsopen());
alarm.setRob(""+alarmData.getRob());
alarm.setAlertInfo(alarmData.getInfo());
alarm.setVoltage(alarmReq.getVoltage());
alarm.setGpsfault(""+alarmData.getGpsfault());
return alarm;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
package cn.com.glsx.dj.device.kafka.consumer;
import cn.com.glsx.dj.device.kafka.KafkaAlarm;
import cn.com.glsx.dj.device.mapper.PowerOffAlarmMapper;
import cn.com.glsx.dj.device.model.PowerOffAlarm;
import com.glsx.dubbo.obd.pojo.TrackModel;
import com.glsx.ice.IceInstance;
import com.glsx.ice.IceManage;
import org.oreframework.jms.kafka.consumer.KafkaConsumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Date;
/**
* @Title: GpsAlarmPowerOffConsumer
* @Description:GpsAlarmPowerOffConsumer
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-5-6
*/
public class GpsAlarmPowerOffConsumer extends KafkaConsumer {
@Autowired
private PowerOffAlarmMapper powerOffAlarmMapper;
@Autowired
private IceManage iceManage;
private static final Logger LOGGER = LoggerFactory.getLogger(GpsAlarmPowerOffConsumer.class);
protected GpsAlarmPowerOffConsumer(String topic) {
super(topic,false);
}
@Override
public void processMessage(Object message) {
try {
KafkaAlarm.VoltageAlarmReq voltageAlarmReq = KafkaAlarm.VoltageAlarmReq.parseFrom(getMessage());
LOGGER.info("topic【gps_alarm_poweroff】comsumer param:{}",voltageAlarmReq);
String sn = voltageAlarmReq.getDevicesn();
if(null == sn || sn.length() == 0) {
return ;
}
PowerOffAlarm powerOffAlarm = powerOffAlarmMapper.selectPowerOffAlarmBySn(sn);
if(powerOffAlarm == null) {
powerOffAlarm = new PowerOffAlarm();
}
IceInstance iceInstance = iceManage.findAvailableIce(1000);
try{
//根据sn 查到经纬度 然后将地点设置进去 断电只有有源的
TrackModel rtTrack = iceInstance.findRTTrack(sn);
if(rtTrack != null){
String lng = rtTrack.getLng();
String lat = rtTrack.getLat();
powerOffAlarm.setLat(lat);
powerOffAlarm.setLng(lng);
String parserGpsAddress = iceInstance.parserGpsAddress(rtTrack);
powerOffAlarm.setAlarmPlace(parserGpsAddress);
}
}finally{
if(iceInstance != null){
iceInstance.close();
}
}
powerOffAlarm.setSn(sn);
powerOffAlarm.setType(voltageAlarmReq.getType());
powerOffAlarm.setRestoreTimes(voltageAlarmReq.getRestoretimes());
powerOffAlarm.setAlarmTimes(voltageAlarmReq.getAlarmtimes());
powerOffAlarm.setMinDuration((long)voltageAlarmReq.getMinduration() * 1000);
powerOffAlarm.setMaxDuration((long)voltageAlarmReq.getMaxduration() * 1000);
powerOffAlarm.setAvgDuration((long)voltageAlarmReq.getAvgduration() * 1000);
Date alarmDate = new Date((long)voltageAlarmReq.getAlarmtime() * 1000);
powerOffAlarm.setAlarmTime(alarmDate);
powerOffAlarm.setVoltage(voltageAlarmReq.getVoltage());
powerOffAlarm.setUpdatedDate(new Date());
powerOffAlarm.setDeletedFlag("N");
powerOffAlarm.setMerchantId(1);
powerOffAlarm.setCreatedBy("admin");
powerOffAlarm.setUpdatedBy("admin");
if(powerOffAlarm.getId() == null){
powerOffAlarm.setCreatedDate(new Date());
}
if(powerOffAlarm.getId()== null){
powerOffAlarmMapper.insert(powerOffAlarm);
} else {
powerOffAlarmMapper.updateByPrimaryKeySelective(powerOffAlarm);
}
} catch (Exception e) {
LOGGER.error("gps_alarm_poweroff消费异常==>", e);
e.printStackTrace();
}
}
}
package cn.com.glsx.dj.device.kafka.consumer;
import java.util.Date;
import org.oreframework.jms.kafka.consumer.KafkaConsumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.protobuf.InvalidProtocolBufferException;
import cn.com.glsx.dj.device.config.InitData;
import cn.com.glsx.dj.device.kafka.kafkaSvr;
import cn.com.glsx.dj.device.model.DeviceLogin;
/**
* @Title: GpsBasestationConsumer
* @Description:GpsBasestationConsumer
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-5-6
*/
public class GpsBasestationConsumer extends KafkaConsumer {
private static final Logger LOGGER = LoggerFactory.getLogger(GpsBasestationConsumer.class);
protected GpsBasestationConsumer(String topic) {
super(topic,false);
}
@Override
public void processMessage(Object message) {
try {
kafkaSvr.BaseStReq baseStReq = kafkaSvr.BaseStReq.parseFrom(getMessage());
LOGGER.info("topic【gps_basestation】comsumer param:{}",baseStReq);
String sn = baseStReq.getDevicesn();
DeviceLogin deviceLoginCache = InitData.getOneDeviceLogin(sn);
if(null == deviceLoginCache) {
deviceLoginCache = new DeviceLogin();
deviceLoginCache.setSn(sn);
}
deviceLoginCache.setLastGprsTime(new Date());
InitData.merge(sn, deviceLoginCache);
//InitData.deviceLoginMap.put(sn, deviceLoginCache);
//新增基站调频指令判断start
try {
baseStSetFrequency(baseStReq.getDevicesn());
} catch (Exception e) {
e.printStackTrace();
}
} catch (InvalidProtocolBufferException e) {
LOGGER.error("gps_basestation消费异常==>", e);
e.printStackTrace();
}
}
/***
* remark:基站调频处理
* @param sn 设备号
*/
public void baseStSetFrequency(String sn){
/*
if(StringUtils.isNotEmpty(sn)){
SetFrequency setFrequency=setFrequencyMapper.findSetFrequency(sn,-1,CodeConstants.COMMAND_STATUS_NOT_SEND);
if(null !=setFrequency){
//下发启动工作模式指令
//dubboDeviceService.setSubDeviceStartOrSleep(sn, "", CodeConstants.SUB_DEVICE_ACTION_TURN_ON);
dubboDeviceService.setStatusAndInterval(setFrequency.getSn(), CodeConstants.MSJ_FACTORY_ID, CodeConstants.SUB_DEVICE_ACTION_TURN_ON,"0", "0", "-1");
setFrequency.setBsStatus(CodeConstants.COMMAND_STATUS_SEND);
setFrequency.setIsSleepSend(CodeConstants.COMMAND_STATUS_NOT_SEND);
setFrequency.setBsTime(new Date());
setFrequency.setUpdateTime(new Date());
kafkaService.updateSetFrequencyById(setFrequency);
logger.debug("[setFrequency-baseStReq]-sn:"+sn);
}
}
*/
}
}
package cn.com.glsx.dj.device.kafka.consumer;
import java.util.Date;
import org.oreframework.jms.kafka.consumer.KafkaConsumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.protobuf.InvalidProtocolBufferException;
import cn.com.glsx.dj.device.config.InitData;
import cn.com.glsx.dj.device.enums.AlarmConstants;
import cn.com.glsx.dj.device.kafka.UnixTimeParse;
import cn.com.glsx.dj.device.kafka.kafkaSvr;
import cn.com.glsx.dj.device.model.DeviceLogin;
/**
* @Title: GpsGpsandbsConsumer
* @Description:GpsGpsandbsConsumer
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-5-6
*/
public class GpsGpsandbsConsumer extends KafkaConsumer {
private static final Logger LOGGER = LoggerFactory.getLogger(GpsGpsandbsConsumer.class);
protected GpsGpsandbsConsumer(String topic) {
super(topic,false);
}
@Override
public void processMessage(Object message) {
try {
kafkaSvr.GPSAndBSReq gpsAndbsReq = kafkaSvr.GPSAndBSReq.parseFrom(getMessage());
LOGGER.info("topic【gps_gpsandbs】comsumer param:{}",gpsAndbsReq);
kafkaSvr.GPSDATA gpsData = gpsAndbsReq.getGpsdata();
String sn = gpsAndbsReq.getDevicesn();
DeviceLogin deviceLoginCache = InitData.getOneDeviceLogin(sn);
if(null == deviceLoginCache) {
deviceLoginCache = new DeviceLogin();
deviceLoginCache.setSn(sn);
}
deviceLoginCache.setSpeed(gpsData.getSpeed());
deviceLoginCache.setLastGprsTime(new Date());
//是否为有效轨迹
if(gpsData.getValid().equals(AlarmConstants.GPS_IS)){
try {
Date gpsTime = UnixTimeParse.parseTimeStampDate2Date(gpsData.getTime());
if(deviceLoginCache.getFirstHistrack()==null){
deviceLoginCache.setFirstHistrack(gpsTime);
}
deviceLoginCache.setLocateStatus(0);
deviceLoginCache.setLastRtTrack(gpsTime);
} catch (Exception e1) {
e1.printStackTrace();
}
}else{
try {
deviceLoginCache.setLocateStatus(1);
deviceLoginCache.setLastVilidTime(new Date());
} catch (Exception e) {
e.printStackTrace();
}
}
InitData.merge(sn, deviceLoginCache);
//InitData.deviceLoginMap.put(sn, deviceLoginCache);
} catch (InvalidProtocolBufferException e) {
e.printStackTrace();
LOGGER.error("gps_gpsandbs消费异常:", e);
}
}
}
package cn.com.glsx.dj.device.kafka.consumer;
import java.util.Date;
import java.util.List;
import org.oreframework.jms.kafka.consumer.KafkaConsumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.protobuf.InvalidProtocolBufferException;
import cn.com.glsx.dj.device.config.InitData;
import cn.com.glsx.dj.device.enums.AlarmConstants;
import cn.com.glsx.dj.device.kafka.UnixTimeParse;
import cn.com.glsx.dj.device.kafka.kafkaSvr;
import cn.com.glsx.dj.device.model.DeviceLogin;
/**
* @Title: GpsGpsdataConsumer
* @Description:GpsGpsdataConsumer
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-5-6
*/
public class GpsGpsdataConsumer extends KafkaConsumer {
private static final Logger LOGGER = LoggerFactory.getLogger(GpsGpsdataConsumer.class);
protected GpsGpsdataConsumer(String topic) {
super(topic,false);
}
@Override
public void processMessage(Object message) {
try {
kafkaSvr.TrackDataReq trackDataReq = kafkaSvr.TrackDataReq.parseFrom(getMessage());
LOGGER.info("topic【gps_gpsdata】comsumer param:{}",trackDataReq);
List<kafkaSvr.GPSDATA> gpsDataList = trackDataReq.getGpsdataList();
String sn = trackDataReq.getDevicesn();
DeviceLogin deviceLoginCache = InitData.getOneDeviceLogin(sn);
if(null == deviceLoginCache) {
deviceLoginCache = new DeviceLogin();
deviceLoginCache.setSn(sn);
}
if (gpsDataList!=null && gpsDataList.size()>0 && gpsDataList.get(0)!=null){
kafkaSvr.GPSDATA gpsData = gpsDataList.get(0);
deviceLoginCache.setSpeed(gpsData.getSpeed());
if(gpsData.getValid().equals(AlarmConstants.GPS_IS)){
try {
Date gpsTime = UnixTimeParse.parseTimeStampDate2Date(gpsData.getTime());
if(deviceLoginCache.getFirstHistrack()==null){
deviceLoginCache.setFirstHistrack(gpsTime);
}
deviceLoginCache.setLocateStatus(0);
deviceLoginCache.setLastRtTrack(gpsTime);
} catch (Exception e1) {
e1.printStackTrace();
}
}else{
try {
deviceLoginCache.setLocateStatus(1);
deviceLoginCache.setLastVilidTime(new Date());
} catch (Exception e) {
e.printStackTrace();
}
}
deviceLoginCache.setLastGprsTime(new Date());
InitData.merge(sn, deviceLoginCache);
//InitData.deviceLoginMap.put(sn, deviceLoginCache);
}
} catch (InvalidProtocolBufferException e) {
e.printStackTrace();
LOGGER.error("gps_gpsdata消费异常:", e);
}
}
}
package cn.com.glsx.dj.device.kafka.consumer;
import java.util.Date;
import org.oreframework.jms.kafka.consumer.KafkaConsumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import cn.com.glsx.dj.device.config.InitData;
import cn.com.glsx.dj.device.kafka.UnixTimeParse;
import cn.com.glsx.dj.device.kafka.kafkaSvr;
import cn.com.glsx.dj.device.model.DeviceLogin;
/**
* @Title: 登录信息消费
* @Description:登录信息消费
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-5-6
*/
public class GpsLoginConsumer extends KafkaConsumer {
private static final Logger LOGGER = LoggerFactory.getLogger(GpsLoginConsumer.class);
protected GpsLoginConsumer(String topic) {
super(topic,false);
}
@Override
public void processMessage(Object message) {
try {
kafkaSvr.StatusReportReq statusReportReq = kafkaSvr.StatusReportReq.parseFrom(getMessage());
LOGGER.info("topic【gps_login】comsumer param:{}",statusReportReq);
String sn = statusReportReq.getDevicesn();
DeviceLogin deviceLoginCache = InitData.getOneDeviceLogin(sn);
if(null == deviceLoginCache) {
deviceLoginCache = new DeviceLogin();
}
deviceLoginCache.setSn(sn);
deviceLoginCache.setStatus(0);
deviceLoginCache.setSubSnSwitchStatus(2);
deviceLoginCache.setLastGprsTime(UnixTimeParse.parseTimeStampDate2Date(statusReportReq.getSvrtime()));
deviceLoginCache.setLastLoginTime(UnixTimeParse.parseTimeStampDate2Date(statusReportReq.getSvrtime()));
if (deviceLoginCache.getFirstLoginTime() == null) {
deviceLoginCache.setFirstLoginTime(UnixTimeParse.parseTimeStampDate2Date(statusReportReq.getSvrtime()));
}
if(null == deviceLoginCache.getLastGprsTime()) {
deviceLoginCache.setLastGprsTime(new Date());
}
InitData.merge(sn, deviceLoginCache);
//InitData.deviceLoginMap.put(sn, deviceLoginCache);
sn = null;
deviceLoginCache = null;
statusReportReq = null;
} catch (Exception e) {
e.printStackTrace();
LOGGER.error("gps_login消费异常:", e);
}
}
}
package cn.com.glsx.dj.device.kafka.consumer;
import java.util.Date;
import org.oreframework.jms.kafka.consumer.KafkaConsumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.protobuf.InvalidProtocolBufferException;
import cn.com.glsx.dj.device.config.InitData;
import cn.com.glsx.dj.device.kafka.kafkaSvr;
import cn.com.glsx.dj.device.model.DeviceLogin;
/**
* @Title: 下线信息消费
* @Description:下线信息消费
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-5-6
*/
public class GpsLogoutConsumer extends KafkaConsumer {
private static final Logger LOGGER = LoggerFactory.getLogger(GpsLogoutConsumer.class);
protected GpsLogoutConsumer(String topic) {
super(topic,false);
}
@Override
public void processMessage(Object message) {
try {
kafkaSvr.StatusReportReq statusReportReq = kafkaSvr.StatusReportReq.parseFrom(getMessage());
LOGGER.info("topic【gps_logout】comsumer param:{}",statusReportReq);
String sn = statusReportReq.getDevicesn();
DeviceLogin deviceLoginCache = InitData.getOneDeviceLogin(sn);
if(null == deviceLoginCache) {
deviceLoginCache = new DeviceLogin();
}
deviceLoginCache.setSn(sn);
deviceLoginCache.setStatus(1);
//下线是最后一次上点
deviceLoginCache.setLastGprsTime(new Date());
InitData.merge(sn, deviceLoginCache);
//InitData.deviceLoginMap.put(sn, deviceLoginCache);
sn = null;
deviceLoginCache = null;
statusReportReq = null;
} catch (InvalidProtocolBufferException e) {
e.printStackTrace();
LOGGER.error("gps_logout 消费异常:", e);
}
}
}
package cn.com.glsx.dj.device.kafka.consumer;
import java.util.Date;
import org.oreframework.jms.kafka.consumer.KafkaConsumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.protobuf.InvalidProtocolBufferException;
import cn.com.glsx.dj.device.config.InitData;
import cn.com.glsx.dj.device.kafka.UnixTimeParse;
import cn.com.glsx.dj.device.kafka.kafkaSvr;
import cn.com.glsx.dj.device.model.DeviceLogin;
/**
* @Title: 设备在线消费
* @Description:设备在线消费
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-5-6
*/
public class GpsOnlineConsumer extends KafkaConsumer {
private static final Logger LOGGER = LoggerFactory.getLogger(GpsOnlineConsumer.class);
protected GpsOnlineConsumer(String topic) {
super(topic,false);
}
@Override
public void processMessage(Object message) {
try {
kafkaSvr.StatusReportReq statusReportReq = kafkaSvr.StatusReportReq.parseFrom(getMessage());
LOGGER.info("topic【gps_online】comsumer param:{}",statusReportReq);
String sn = statusReportReq.getDevicesn();
DeviceLogin deviceLoginCache = InitData.getOneDeviceLogin(sn);
if(null == deviceLoginCache) {
deviceLoginCache = new DeviceLogin();
}
deviceLoginCache.setSn(sn);
deviceLoginCache.setStatus(0);
deviceLoginCache.setLastGprsTime(UnixTimeParse.parseTimeStampDate2Date(statusReportReq.getSvrtime()));
if(null == deviceLoginCache.getLastGprsTime()) {
deviceLoginCache.setLastGprsTime(new Date());
}
InitData.merge(sn, deviceLoginCache);
//InitData.deviceLoginMap.put(sn, deviceLoginCache);
sn = null;
deviceLoginCache = null;
statusReportReq = null;
} catch (InvalidProtocolBufferException e) {
e.printStackTrace();
LOGGER.error("gps_online消费异常:", e);
}
}
}
package cn.com.glsx.dj.device.kafka.consumer;
import java.util.Date;
import org.oreframework.jms.kafka.consumer.KafkaConsumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.protobuf.InvalidProtocolBufferException;
import cn.com.glsx.dj.device.config.InitData;
import cn.com.glsx.dj.device.kafka.UnixTimeParse;
import cn.com.glsx.dj.device.kafka.kafkaSvr;
import cn.com.glsx.dj.device.model.DeviceLogin;
/**
* @Title: 设备休眠消费
* @Description:设备休眠消费
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-5-6
*/
public class GpsSleepConsumer extends KafkaConsumer {
private static final Logger LOGGER = LoggerFactory.getLogger(GpsSleepConsumer.class);
protected GpsSleepConsumer(String topic) {
super(topic,false);
}
@Override
public void processMessage(Object message) {
try {
kafkaSvr.StatusReportReq statusReportReq = kafkaSvr.StatusReportReq.parseFrom(getMessage());
LOGGER.info("topic【gps_sleep】comsumer param:{}",statusReportReq);
String sn = statusReportReq.getDevicesn();
DeviceLogin deviceLoginCache = InitData.getOneDeviceLogin(sn);
if(null == deviceLoginCache) {
deviceLoginCache = new DeviceLogin();
}
deviceLoginCache.setSn(sn);
deviceLoginCache.setStatus(3);
deviceLoginCache.setLastGprsTime(UnixTimeParse.parseTimeStampDate2Date(statusReportReq.getSvrtime()));
if(null == deviceLoginCache.getLastGprsTime()) {
deviceLoginCache.setLastGprsTime(new Date());
}
InitData.merge(sn, deviceLoginCache);
//InitData.deviceLoginMap.put(sn, deviceLoginCache);
sn = null;
deviceLoginCache = null;
statusReportReq = null;
} catch (InvalidProtocolBufferException e) {
e.printStackTrace();
LOGGER.error("gps_sleep消费异常:", e);
}
}
}
package cn.com.glsx.dj.device.kafka.consumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import cn.com.glsx.dj.device.config.ApplicationContextRegister;
import cn.com.glsx.dj.device.config.ConsumerPropertys;
/**
* @Title: kafka消费初始化
* @Description:kafka消费初始化
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-5-6
*/
@Component
public class InitConsumerLineRunner implements CommandLineRunner {
private static final Logger LOGGER = LoggerFactory.getLogger(InitConsumerLineRunner.class);
private ConsumerPropertys consumerProperty;
@Override
public void run(String... args) throws Exception {
LOGGER.info("kafka消费程序初始化开始=========");
consumerProperty = ApplicationContextRegister.getBean(ConsumerPropertys.class);
if(null != consumerProperty) {
String fullClassNamesStr = consumerProperty.getFullClassNames();
if(null != fullClassNamesStr && fullClassNamesStr.length() >0) {
String[] fullClassNames = fullClassNamesStr.split(",");
for(String className : fullClassNames) {
try {
LOGGER.info("========="+className);
ApplicationContextRegister.getApplicationContext().getBean(Class.forName(className));
} catch (Exception e) {
LOGGER.error("初始化错误===", e);
}
}
}
}
LOGGER.info("kafka消费程序初始化结束=========");
}
}
This diff could not be displayed because it is too large.
package cn.com.glsx.dj.device.kafka.thread;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import cn.com.glsx.dj.device.enums.AlarmConstants;
/**
* @Title: 初始化线程
* @Description:初始化线程
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-5-6
*/
@Component
public class InitRunner implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("InitRunner-thread-call-runner-%d").build();
@SuppressWarnings("all")
ExecutorService executorService = new ThreadPoolExecutor(AlarmConstants.THREADSIZE,AlarmConstants.THREADSIZE,0L,TimeUnit.MILLISECONDS,new LinkedBlockingQueue(),namedThreadFactory);
for(int i=0;i<AlarmConstants.THREADSIZE;i++) {
MapToDbThread mapToDbThread = new MapToDbThread();
executorService.submit(mapToDbThread);
}
executorService.shutdown();
}
}
package cn.com.glsx.dj.device.kafka.thread;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentMap;
import org.apache.commons.lang.time.StopWatch;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.collect.MapMaker;
import cn.com.glsx.dj.device.config.ApplicationContextRegister;
import cn.com.glsx.dj.device.config.BlockingQueueProperty;
import cn.com.glsx.dj.device.config.InitData;
import cn.com.glsx.dj.device.mapper.DeviceLoginMapper;
import cn.com.glsx.dj.device.model.DeviceLogin;
/**
* @Title: 数据入库扫描线程
* @Description:数据入库扫描线程
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-5-6
*/
public class MapToDbThread implements Runnable {
private static final Logger LOGGER = LoggerFactory.getLogger(MapToDbThread.class);
public static BlockingQueue<DeviceLogin> deviceLoginQueue = null;
private DeviceLoginMapper deviceLoginMapper;
private BlockingQueueProperty blockingQueueProperty;
private static int qsize = 0;
public MapToDbThread() {
this.deviceLoginMapper = ApplicationContextRegister.getBean(DeviceLoginMapper.class);
this.blockingQueueProperty = ApplicationContextRegister.getBean(BlockingQueueProperty.class);
qsize = blockingQueueProperty.getSize();
deviceLoginQueue = new ArrayBlockingQueue<DeviceLogin>(qsize);
}
@Override
public void run() {
while(true) {
try {
int size = InitData.deviceLoginMap.size();
ConcurrentMap<String, DeviceLogin> deviceLoginMapTmp = new MapMaker().makeMap();
deviceLoginMapTmp.putAll(InitData.deviceLoginMap);
InitData.deviceLoginMap.clear();
int sizeTmp = deviceLoginMapTmp.size();
int pc = 1;
for(ConcurrentMap.Entry<String, DeviceLogin> entry:deviceLoginMapTmp.entrySet()){
if(deviceLoginQueue.size() == qsize) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
ArrayList<DeviceLogin> deviceLoginTempList = new ArrayList<DeviceLogin>(qsize);
deviceLoginQueue.drainTo(deviceLoginTempList);
if(null != deviceLoginTempList && deviceLoginTempList.size() >0) {
List<DeviceLogin> insertList = new ArrayList<DeviceLogin>();
List<DeviceLogin> updateList = new ArrayList<DeviceLogin>();
for(DeviceLogin d : deviceLoginTempList) {
if(InitData.deviceLoginSnMap.containsKey(d.getSn())) {
updateList.add(d);
} else {
insertList.add(d);
InitData.deviceLoginSnMap.put(d.getSn(), d.getSn());
}
}
if(insertList.size() > 0) {
deviceLoginMapper.batchInserts(insertList);
}
if(updateList.size() >0) {
deviceLoginMapper.batchUpdates(updateList);
}
}
stopWatch.stop();
LOGGER.info("tmpSize{},总数:{}条,当前是第{}批,设备登录数据缓存, 用时:{} ms", sizeTmp,size,pc, stopWatch.getTime());
pc++;
}
deviceLoginQueue.offer(entry.getValue());
}
if(deviceLoginQueue.size() > 0) {
ArrayList<DeviceLogin> deviceLoginTempList = new ArrayList<DeviceLogin>(deviceLoginQueue.size());
deviceLoginQueue.drainTo(deviceLoginTempList);
if(null != deviceLoginTempList && deviceLoginTempList.size() >0) {
List<DeviceLogin> insertList = new ArrayList<DeviceLogin>();
List<DeviceLogin> updateList = new ArrayList<DeviceLogin>();
for(DeviceLogin d : deviceLoginTempList) {
if(InitData.deviceLoginSnMap.containsKey(d.getSn())) {
updateList.add(d);
} else {
insertList.add(d);
InitData.deviceLoginSnMap.put(d.getSn(), d.getSn());
}
}
if(insertList.size() > 0) {
deviceLoginMapper.batchInserts(insertList);
}
if(updateList.size() >0) {
deviceLoginMapper.batchUpdates(updateList);
}
}
LOGGER.info("第{}批,剩余数:{},", pc,deviceLoginTempList.size());
}
Thread.sleep(2000*60);
} catch (Exception e) {
e.printStackTrace();
LOGGER.error("MapToDbThread线程数据入库异常:", e);
}
}
}
}
package cn.com.glsx.dj.device.manager;
import org.apache.commons.lang.StringUtils;
import cn.com.glsx.dj.device.enums.AlarmConstants;
import cn.com.glsx.dj.device.kafka.UnixTimeParse;
import cn.com.glsx.dj.device.model.Alarm;
import cn.com.glsx.dj.device.model.DeviceAlarmRec;
import cn.com.glsx.dj.device.model.DeviceAlarmRecHistory;
/**
* @Title: 数据转换
* @Description:数据转换
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-5-6
*/
public class GpsAlarmManager {
/**
* <p>show 过滤钻石配置中设备的断电报警(由于GT701 4161008这个批次有问题,供应链要求这批设备屏蔽断电报警)
* @Description:过滤钻石配置中设备的断电报警(由于GT701 4161008这个批次有问题,供应链要求这批设备屏蔽断电报警)
* @param alarm 数据对象
* @param filterBatch 批量设备开头
* @param filterDevice 设备开头
* @author huanggl
* @Time 2019-05-27 13:02:29
* @return boolean
*/
public static boolean deviceCheck(Alarm alarm,String filterBatch,String filterDevice) {
boolean isOk = false;
String deviceNO = alarm.getDeviceNO();
if(StringUtils.isBlank(deviceNO)){
isOk = true;
return isOk;
}
if(!AlarmConstants.GPS_ALARM_IS.equals(alarm.getBlackOut())){
try {
if(deviceNO.startsWith(filterBatch)){
int endDeviceNo=Integer.valueOf(deviceNO.substring(filterBatch.length(), deviceNO.length()));
if(0 <= endDeviceNo && endDeviceNo <= AlarmConstants.ENDDEVICENO){
isOk = true;
return isOk;
}
}
String [] filterDevices = filterDevice.split(",");
for(int i=0;i<filterDevices.length;i++){
if(deviceNO.startsWith(filterDevices[i])){
isOk = true;
return isOk;
}
}
} catch (NumberFormatException e) {
e.printStackTrace();
}
}
return isOk;
}
/**
* <p>show 设置值
* @Description:设置值
* @param alarm 数据对象
* @param alarmType 告警类型
* @param vehicleId 车辆ID
* @author huanggl
* @Time 2019-05-27 13:02:29
* @return boolean
*/
public static DeviceAlarmRec setDeviceAlarmRecCache(Alarm alarm,int alarmType,int vehicleId) {
String deviceNO = alarm.getDeviceNO();
DeviceAlarmRec deviceAlarmRecCache = new DeviceAlarmRec();
deviceAlarmRecCache.setVehicleId(vehicleId);
deviceAlarmRecCache.setAlarmNo(1);
deviceAlarmRecCache.setSn(deviceNO);
try {
deviceAlarmRecCache.setBeginTime(UnixTimeParse.safeParseDate(alarm.getTime()));
} catch (Exception e) {
e.printStackTrace();
}
if (alarm.getIsValid().equals(AlarmConstants.GPS_IS)) {
deviceAlarmRecCache.setLat(alarm.getLat());
deviceAlarmRecCache.setLng(alarm.getLng());
deviceAlarmRecCache.setLastLng(alarm.getLng());
deviceAlarmRecCache.setLastLat(alarm.getLat());
}
/** 此处去掉无效轨迹的开始时间设置,否则会导致时间显示的不合逻辑情况(wangchao add on 20170821) **/
deviceAlarmRecCache.setSpeed(alarm.getSpeed());
deviceAlarmRecCache.setDelFlag(AlarmConstants.GPS_DEFLAG_THREE);
deviceAlarmRecCache.setAlarmType(alarmType);
return deviceAlarmRecCache;
}
/**
* <p>show 设置值
* @Description:设置值
* @param alarm 数据对象
* @param alarmType 告警类型
* @param vehicleId 车辆ID
* @author huanggl
* @Time 2019-05-27 13:02:29
* @return boolean
*/
public static DeviceAlarmRec setDeviceAlarmRec(Alarm alarm,DeviceAlarmRec deviceAlarmRecCache,int alarmType) {
deviceAlarmRecCache.setLastTime(UnixTimeParse.safeParseDate(alarm.getTime()));
if (alarm.getIsValid().equals(AlarmConstants.GPS_IS)) {
deviceAlarmRecCache.setLat(alarm.getLat());
deviceAlarmRecCache.setLng(alarm.getLng());
deviceAlarmRecCache.setLastLng(alarm.getLng());
deviceAlarmRecCache.setLastLat(alarm.getLat());
}
deviceAlarmRecCache.setAlarmType(alarmType);
deviceAlarmRecCache.setSpeed(alarm.getSpeed());
deviceAlarmRecCache.setAlarmNo(deviceAlarmRecCache.getAlarmNo() + 1);
return deviceAlarmRecCache;
}
/**
* <p>show 设置历史值
* @Description:设置历史值
* @param alarm 数据对象
* @param alarmType 告警类型
* @param vehicleId 车辆ID
* @author huanggl
* @Time 2019-05-27 13:02:29
* @return boolean
*/
public static DeviceAlarmRecHistory setHistory(Alarm alarm,int alarmType,int vehicleId) {
String deviceNO = alarm.getDeviceNO();
DeviceAlarmRecHistory history = new DeviceAlarmRecHistory();
try {
history.setBeginTime(UnixTimeParse.safeParseDate(alarm.getTime()));
} catch (Exception e) {
e.printStackTrace();
}
history.setVehicleId(vehicleId);
if (alarm.getIsValid().equals(AlarmConstants.GPS_IS)) {
history.setLng(alarm.getLng());
history.setLat(alarm.getLat());
}
history.setSn(deviceNO);
history.setSpeed(alarm.getSpeed());
history.setAlarmType(alarmType);
history.setIsValid(alarm.getIsValid());
history.setDelFlag(AlarmConstants.GPS_DEFLAG_THREE);
history.setAlarmNo(1);
return history;
}
}
package cn.com.glsx.dj.device.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.oreframework.datasource.mybatis.mapper.OreMapper;
import cn.com.glsx.dj.device.model.DeviceAlarmRecHistory;
/**
* @Title: 设备告警历史表
* @Description:设备告警历史
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-5-6
*/
@Mapper
public interface DeviceAlarmRecHistoryMapper extends OreMapper<DeviceAlarmRecHistory> {
/**
* <p>show 查询设备历史告警记录
* @Description:查询设备历史告警记录
* @param condition 查询条件对象
* @author huanggl
* @Time 2019-05-27 13:02:29
* @return List
*/
List<DeviceAlarmRecHistory> getDeviceAlarmRecHistory(@Param("record")DeviceAlarmRecHistory condition);
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.device.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.oreframework.datasource.mybatis.mapper.OreMapper;
import cn.com.glsx.dj.device.model.DeviceAlarmRec;
/**
* @Title: 设备告警
* @Description:设备告警
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-5-6
*/
@Mapper
public interface DeviceAlarmRecMapper extends OreMapper<DeviceAlarmRec> {
/**
* <p>show 查询设备告警记录
* @Description:查询设备告警记录
* @param condition 查询条件对象
* @author huanggl
* @Time 2019-05-27 13:02:29
* @return List
*/
List<DeviceAlarmRec> getDeviceAlarmRec(@Param("record")DeviceAlarmRec condition);
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.device.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.oreframework.datasource.mybatis.mapper.OreMapper;
import cn.com.glsx.dj.device.model.DeviceLogin;
import cn.com.glsx.dj.device.vo.DeviceSnVo;
/**
* @Title: 设备登陆状态
* @Description:设备登陆状态
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-5-6
*/
@Mapper
public interface DeviceLoginMapper extends OreMapper<DeviceLogin> {
/**
* <p>show 更新或新增
* @Description:更新或新增
* @param list 新增或更新对象列表
* @author huanggl
* @Time 2019-05-27 13:02:29
* @return int
*/
int batchInsertOrUpdate(List<DeviceLogin> list);
/**
* <p>show 查询出所有的sn
* @Description:查询出所有的sn
* @author huanggl
* @Time 2019-05-27 13:02:29
* @return int
*/
List<DeviceSnVo> selectSnList();
/**
*<p>show 批量插入
* @Description:批量插入
* @param list 新增对象列表
* @author huanggl
* @Time 2019-05-27 13:02:29
* @return int
*/
int batchInserts(List<DeviceLogin> list);
/**
* <p>show 批量更新
* @Description:批量更新
* @param list 更新对象列表
* @author huanggl
* @Time 2019-05-27 13:02:29
* @return int
*/
int batchUpdates(List<DeviceLogin> list);
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.device.mapper;
import org.apache.ibatis.annotations.Mapper;
import org.oreframework.datasource.mybatis.mapper.OreMapper;
import cn.com.glsx.dj.device.model.InsureDevice;
/**
* @Title: 设备
* @Description:设备
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-5-6
*/
@Mapper
public interface InsureDeviceMapper extends OreMapper<InsureDevice> {
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.device.mapper;
import org.apache.ibatis.annotations.Mapper;
import org.oreframework.datasource.mybatis.mapper.OreMapper;
import cn.com.glsx.dj.device.model.InsureVehicle;
/**
* @Title: 车辆
* @Description:车辆
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-5-6
*/
@Mapper
public interface InsureVehicleMapper extends OreMapper<InsureVehicle> {
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.device.mapper;
import org.apache.ibatis.annotations.Mapper;
import org.oreframework.datasource.mybatis.mapper.OreMapper;
import cn.com.glsx.dj.device.model.PowerOffAlarm;
/**
* @Title: 断电告警
* @Description:断电告警
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-5-6
*/
@Mapper
public interface PowerOffAlarmMapper extends OreMapper<PowerOffAlarm> {
/**
* <p>show 通过设备号查询断电告警
* @Description:通过设备号查询断电告警
* @param sn 设备号
* @author huanggl
* @Time 2019-05-27 13:02:29
* @return int
*/
PowerOffAlarm selectPowerOffAlarmBySn(String sn);
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.device.util;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import cn.com.glsx.dj.device.config.ApplicationContextRegister;
import cn.com.glsx.dj.device.config.DevicenoFirstProperty;
import cn.com.glsx.dj.device.enums.AlarmConstants;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* <简述>业务工具类
*
* @author liuyf
* @version V1.0
* @date 2016/3/8
*/
public class BusinessUtils {
private static Logger logger = Logger.getLogger(BusinessUtils.class);
/**
* 根据sn号判断设备类型
*
* @param sn
* @return
*/
public static String getDeviceType(String sn) {
DevicenoFirstProperty devicenoFirstProperty = ApplicationContextRegister.getBean(DevicenoFirstProperty.class);
String gt700First = devicenoFirstProperty.getGt700DevicenoFirst();
String gt701aFirst = devicenoFirstProperty.getGt701aDevicenoFirst();;
String gt702First = devicenoFirstProperty.getGt702DevicenoFirst();
String gt703First = devicenoFirstProperty.getGt703DevicenoFirst();
String gt700bFirst = devicenoFirstProperty.getGt700BDevicenoFirst();
String gt703bFirst = devicenoFirstProperty.getGt703BDevicenoFirst();
String gt706First = devicenoFirstProperty.getGt706DevicenoFirst();
String gt701cFirst = devicenoFirstProperty.getGt701cDevicenoFirst();
String gt801dFirst = devicenoFirstProperty.getGt801dDevicenoFirst();
String gt801cFirst = devicenoFirstProperty.getGt801cDevicenoFirst();
String ddFirst = devicenoFirstProperty.getDdDevicenoFirst();
sn = sn.substring(0,2);
String deviceType = "";
//根据设备型号获得验证信息
try {
//针对GT701C和GT801C都存在17开头SN的特殊处理
if(StringUtils.isNotEmpty(sn) && AlarmConstants.DEVICESNSTART17.equals(sn)){
if(verifDeviceType(sn, gt701cFirst)){
deviceType = Constants.GT701C;
}
if(verifDeviceType(sn, gt801cFirst)){
deviceType = deviceType + "," +Constants.GT801C;
}
//返回两者并集关系
return deviceType;
}
if (StringUtils.isNotEmpty(sn)) {
if (verifDeviceType(sn, gt700First)) {
deviceType = Constants.GT700;
} else if (verifDeviceType(sn, gt701aFirst)) {
deviceType = Constants.GT701A;
} else if (verifDeviceType(sn, gt702First)) {
deviceType = Constants.GT702;
} else if (verifDeviceType(sn, gt703First)) {
deviceType = Constants.GT703;
} else if (verifDeviceType(sn, gt700bFirst)) {
deviceType = Constants.GT700B;
} else if (verifDeviceType(sn, gt703bFirst)) {
deviceType = Constants.GT703B;
} else if (verifDeviceType(sn, gt706First)) {
deviceType = Constants.GT706;
} else if (verifDeviceType(sn, gt701cFirst)) {
deviceType = Constants.GT701C;
} else if(verifDeviceType(sn, gt801dFirst)){
deviceType = Constants.GT801D;
} else if(verifDeviceType(sn, gt801cFirst)){
deviceType = Constants.GT801C;
} else if(verifDeviceType(sn, ddFirst)){
deviceType = Constants.DD_DEVICE;
}
}
} catch (Exception e) {
}
return deviceType;
}
/**
* 根据sn号,判断是否源设备
*
* @param sn
* @return
*/
public static String isMainDevice(String sn) {
DevicenoFirstProperty devicenoFirstProperty = ApplicationContextRegister.getBean(DevicenoFirstProperty.class);
//有源设备设备号首位
String cableFirst = devicenoFirstProperty.getYyDevicenoFirst();
//无源设备设备号首位
String wirelessFirst = devicenoFirstProperty.getWyDevicenoFirst();
String flag = "";
try {
if (StringUtils.isNotBlank(sn)) {
if (verifDeviceType(sn, cableFirst)) {
//有源设备
flag = Constants.HASSOURCE_Y;
}
if (verifDeviceType(sn, wirelessFirst)) {
//无源设备
flag = Constants.HASSOURCE_N;
}
}
} catch (Exception e) {
}
return flag;
}
/**
* 根据sn号,判断是否支持剩余电量
*
* @param sn
* @return
*/
public static boolean isSupportLastVoltage(String sn) {
boolean flag = false;
try {
if (Constants.GT702.equals(getDeviceType(sn))) {
int year = Integer.valueOf(sn.substring(1, 3));
int month = Integer.valueOf(sn.substring(3, 5));
if (year == AlarmConstants.YEAR15) {
if (month == AlarmConstants.MONTH11 || month == AlarmConstants.MONTH12) {
flag = true;
}
} else if (year > AlarmConstants.YEAR15) {
if (month >= AlarmConstants.MONTH1 && month <= AlarmConstants.MONTH12) {
flag = true;
}
}
}
} catch (Exception e) {
}
return flag;
}
/**
* 将电压值转为剩余电量百分比
*
* @param voltage
* @return
*/
public static String getPercentVoltage(double voltage) {
String percent = "";
try {
if (voltage < AlarmConstants.VOLTAGE34) {
percent = "0";
} else if (voltage > AlarmConstants.VOLTAGE41) {
percent = "100";
} else {
BigDecimal b = new BigDecimal((voltage - 3.4) / 0.7 * 100);
percent = b.setScale(0, BigDecimal.ROUND_HALF_UP).toString();
}
} catch (Exception e) {
}
return percent;
}
/**
* 将剩余电量百分比转为电压值
*
* @param voltage
* @return
*/
public static String getVoltage(double voltage) {
String percent = "";
try {
if (voltage >= 0 && voltage <= AlarmConstants.VOLTAGE100) {
BigDecimal b = new BigDecimal(voltage / 100 * 0.7 + 3.4);
percent = b.setScale(2, BigDecimal.ROUND_HALF_UP).toString();
} else {
logger.info("Voltage out of range!");
}
} catch (Exception e) {
}
return percent;
}
/**
* 获取绑定设备个数
*
* @param area
* @return
*/
public static int getBindDeviceCnt(String area) {
int bindDeviceCnt = 0;
if (StringUtils.isNotBlank(area)) {
if (area.contains(AlarmConstants.BINDDEVICECNTD)) {
bindDeviceCnt = 1;
} else if (area.contains(AlarmConstants.BINDDEVICECNTS)) {
bindDeviceCnt = 2;
}
}
return bindDeviceCnt;
}
/**
* 判断设备是否所属对应类型
*
* @param sn
* @param listIn
* @return
*/
public static boolean verifDeviceType(String sn, String listIn) {
boolean isSuccess = false;
List<String> list = new ArrayList<String>();
Collections.addAll(list, listIn.split(","));
for (String startNo : list) {
if (sn.startsWith(startNo)) {
isSuccess = true;
break;
}
}
return isSuccess;
}
}
package cn.com.glsx.dj.device.util;
/**
* 常量类
*
* @author liuyf@didihu.com.cn
* @version 1.0
* @history 2017年9月20日 create by liuyf@didihu.com.cn
*/
public final class Constants {
/**
* 系统根目录
*/
public final static String CONTEXT_PATH_KEY = "webAppRootKey";
public final static String CONTEXT_PATH_VALUE = "ggs.evn.webapp";
/**
* 超级管理员的登录id
*/
public final static int ADMIN_LOGINID = 1;
/**
* 生成随机种子
*/
public static final String NAME_SEED = "ABCDEFGHJKMNPQRSTUVWXYZ23456789";
/**
* 登录用户在SESSION中的KEY值
*/
public final static String SESSION_LOGIN_USER = "_session_user";
/**
* 用户可用状态
*/
public final static int USER_AVAILABLE_STATUS = 0;
/**
* 用户不可用状态
*/
public final static int USER_UNAVAILABLE_STATUS = 1;
/**
* 本季度
*/
public static final int TIMETYPE_CURRENT_QUARTER = 15;
/**
* 展业至今
*/
public static final int TIMETYPE_SOFAR = 16;
/**
* 今天
*/
public static final int TIMETYPE_TODAY = 1;
/**
* 昨天
*/
public static final int TIMETYPE_YESTERDAY = 2;
/**
* 本周
*/
public static final int TIMETYPE_THISWEEK = 3;
/**
* 上周
*/
public static final int TIMETYPE_LASTWEEK = 4;
/**
* 本月
*/
public static final int TIMETYPE_THISMONTH = 5;
/**
* 上月
*/
public static final int TIMETYPE_LASTMONTH = 6;
/**
* 时间段
*/
public static final int TIMETYPE_SCOPE = 7;
/**
* 时间范围 近12小时
*/
public static final int TIMETYPE_IN_12_HOURS = 8;
/**
* 时间范围 近24小时
*/
public static final int TIMETYPE_IN_24_HOURS = 9;
/**
* 近七天
*/
public static final int TIMETYPE_IN_7_DAYS = 10;
/**
* 近30天
*/
public static final int TIMETYPE_IN_30_DAYS = 11;
/**
* 时间段 带时间
*/
public static final int TIMETYPE_SCOPE_WITH_TIME = 12;
/**
* 今年
*/
public static final int TIMETYPE_YEAR = 14;
/**
* 主从设备标识:0主设备,1从设备
*/
public static final int TRACK_MAIN = 0;
public static final int TRACK_ISSUB = 1;
/**
* 设备激活状态:0未激活,1激活
*/
public static final int TRACK_NOT_ACTIVE = 0;
public static final String TRACK_NOT_ACTIVE_VALUE = "否";
public static final int TRACK_ACTIVE = 1;
public static final String TRACK_ACTIVE_VALUE = "是";
/**
* 车辆状态:0正常,1删除
*/
public static final int VEHICLE_NORMAL = 0;
public static final int VEHICLE_DELETE = 1;
/**
* 车辆使用中状态
*/
public static final int VEHICLE_ISUSE_NORMAL = 2;
/**
* 车辆工单状态:0:正常 1:已激活 2:已删除
*/
public static final int VEHICLE_WORKORDER_NORMAL = 0;
public static final int VEHICLE_WORKORDER_ACTIVE = 1;
public static final int VEHICLE_WORKORDER_DELETE = 2;
/**
* 车辆分类默认id
*/
public static final int CLASS_INITIAL_ID = 1;
/**
* 车辆分组默认id
*/
public static final int DEFAULT_GROUP_ID = 1;
/**
* 角色车辆关系类型:车辆分组
*/
public static final int ROLE_VEHICLE_TYPE_GROUP = 0;
/**
* 角色车辆关系类型:车辆分类
*/
public static final int ROLE_VEHICLE_TYPE_CLASS = 1;
/**
* 角色车辆关系类型:车辆
*/
public static final int ROLE_VEHICLE_TYPE_VEHICLE = 2;
/**
* 查询类型:0:无条件,1设备号,2:姓名,3:车架号,4:工单号
**/
public static final int QUERY_TYPE_NO = 0;
public static final int QUERY_TYPE_SN = 1;
public static final int QUERY_TYPE_SATANDNO = 2;
public static final int QUERY_TYPE_NAME = 3;
public static final int QUERY_TYPE_WORKORDER_NO = 4;
/**
* 是否有源设备:Y有源设备,N无源设备
*/
public static final String HASSOURCE_Y = "Y";
public static final String HASSOURCE_N = "N";
/**
* 设备型号类型
*/
/**
* 81 91 21
*/
public static final String GT700 = "GT700";
/**
* 15
*/
public static final String GT700B = "GT700B";
/**
* 22
*/
public static final String GT700C = "GT700C";
/**
* 11
*/
public static final String GT700F = "GT700F";
/**
* 13
*/
public static final String GT701 = "GT701";
/**
* 18 24
*/
public static final String GT701C = "GT701C";
/**
* 61 71
*/
public static final String GT702 = "GT702";
/**
* 31 51
*/
public static final String GT703 = "GT703";
/**
* 16 14 69
*/
public static final String GT703B = "GT703B";
/**
* 23
*/
public static final String GT703C = "GT703C";
/**
* 53
*/
public static final String GT703W = "GT703W";
/**
* 19
*/
public static final String GT705W = "GT705W";
/**
* 12
*/
public static final String GT706 = "GT706";
/**
* 41
*/
public static final String GT701A = "GT701A";
/**
* 25
*/
public static final String GT801 = "GT801";
/**
* 17
*/
public static final String GT801C = "GT801C";
/**
* 80
*/
public static final String GT801D = "GT801D";
/**
* 25
*/
public static final String GT800B = "GT800B";
/**
* 26
*/
public static final String GT803 = "GT803";
/**
* 29
*/
public static final String GT803B = "GT803B";
/**
* 79
*/
public static final String DD_DEVICE = "DD_DEVICE";
/**
* 数据切换,hbase或mysql
*/
public static final String HBASE_STRING = "hbase";
public static final String MYSQL_STRING = "mysql";
/**
* 电子栅栏,0关闭状态,1开启状态,2删除状态,3新增状态,4修改状态
*/
public static final int ELECTRIC_FENCE_CLOSE = 0;
public static final int ELECTRIC_FENCE_OPEN = 1;
public static final int ELECTRIC_FENCE_DELETE = 2;
public static final int ELECTRIC_FENCE_ADD = 3;
public static final int ELECTRIC_FENCE_UPDATE = 4;
/**
* 预警类型-电池电压过低
**/
public final static int GPS_ALARM_LOWERVOL = 6;
/**
* 预警类型-断电/拆除报警
**/
public final static int GPS_ALARM_BLACKOUT = 1;
/**
* 预警类型-断电/拆除报警/电压过低
**/
public final static int GPS_ALARM = 16;
/**
* 常驻地查询时间范围;1:一个月 2:三个月 3:半年内 4:截至到目前,5:自定义,-1测试用
*/
public static final String RESIDENT_TYPE_ONE = "1";
public static final String RESIDENT_TYPE_THREE = "2";
public static final String RESIDENT_TYPE_SIX = "3";
public static final String RESIDENT_TYPE_PRESENT = "4";
public static final String RESIDENT_TYPE_CUSTOM = "5";
public static final String RESIDENT_TYPE_TEST = "-1";
/**
* 参数标识
*/
public static final String LOG_TYPE_0 = "0";
public static final String LOG_TYPE_1 = "1";
public static final String LOG_TYPE_2 = "2";
/**
* 每个excel存放的数据量
*/
public static final int POI_DIVISION = 50000;
/**
* 工单同步到App操作状态
*/
public static final byte WORKORDER_SYNC_STATUS_ADD = 0;
public static final byte WORKORDER_SYNC_STATUS_UPDATE = 1;
public static final byte WORKORDER_SYNC_STATUS_DELETE = 2;
/**
* 广联返回成功码
*/
public static final String GLSX_RET_CODE_SUCCESS = "0";
/**
* 厂商ID-博实结
*/
public static final String BSJ_FACTORY_ID = "BSJ";
/**
* 0:树的父节点级别 1级(分组)
**/
public static final int TREE_PARENTNODE_LEVEL_ZERO = 0;
/**
* 1:树的父节点级别 2级(分类)
**/
public static final int TREE_PARENTNODE_LEVEL_ONE = 1;
public static final String IMPORT_MATCH_WORK_ORDER = "1";
public static final String IMPORT_VEHICLE_WORK_ORDER = "2";
public static final String DEVICE_TEMPLATE_FILE_NAME = "3";
/**
* 迪迪保单号管理导入
*/
public static final String IMPORT_DD_INSURANCENUMBER = "4";
/**
* 车辆验证状态
* 1:通过,2:不通过
*/
public static final int VALIDATE_PASS = 1;
public static final int VALIDATE_NOPASS = 2;
/**
* 绑定标识
*/
public static final String APP_BINDING = "1";
/**
* 解绑标识
*/
public static final String APP_UNBINDING = "2";
public static final Integer WORKORDER_ACTIVE = 1;
/**
* 车辆使用中状态
*/
public static final int ISUSE_NORMAL = 2;
/**
* 设备未激活
*/
public static final int TRACK_NOACTIVE = 0;
/**
* 车辆工单已删除状态
*/
public static final int VEHICLEWORKORDER_DELETE = 2;
public static final Integer MAX_FILE_SIZE = 10 * 1024 * 1024;
/**
* 厂商ID
*/
public static final String MSJ_FACTORY_ID = "msj";
/**
* 区域、省份、店面
*/
public static final int DIMENSION_REGION = 1;
public static final int DIMENSION_PROVINCE = 2;
public static final int DIMENSION_SHOPNAME = 3;
/**
* 客户种类:1 个人客户(身份证) 2公司客户(组织机构代码证),3个人客户(港澳返乡证),4个人客户(台胞证)
*/
public static final int CUSTOMERTYPE_PERSONAL = 1;
public static final int CUSTOMERTYPE_COMPANY = 2;
public static final int CUSTOMERTYPE_HONGKONG_MACAO = 3;
public static final int CUSTOMERTYPE_TAIWAN = 4;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.device.util;
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.dj.device.mapper.DeviceAlarmRecHistoryMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.dj.device.model.DeviceAlarmRecHistory">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="sn" jdbcType="VARCHAR" property="sn" />
<result column="lng" jdbcType="VARCHAR" property="lng" />
<result column="lat" jdbcType="VARCHAR" property="lat" />
<result column="speed" jdbcType="VARCHAR" property="speed" />
<result column="direction" jdbcType="VARCHAR" property="direction" />
<result column="alarm_type" jdbcType="INTEGER" property="alarmType" />
<result column="city_name" jdbcType="VARCHAR" property="cityName" />
<result column="del_flag" jdbcType="INTEGER" property="delFlag" />
<result column="last_time" jdbcType="TIMESTAMP" property="lastTime" />
<result column="last_lng" jdbcType="VARCHAR" property="lastLng" />
<result column="last_lat" jdbcType="VARCHAR" property="lastLat" />
<result column="alarm_no" jdbcType="INTEGER" property="alarmNo" />
<result column="begin_time" jdbcType="TIMESTAMP" property="beginTime" />
<result column="vehicle_id" jdbcType="INTEGER" property="vehicleId" />
<result column="is_valid" jdbcType="VARCHAR" property="isValid" />
</resultMap>
<sql id="Base_Column_List">
id, sn, lng, lat, speed, direction, alarm_type, city_name, del_flag, last_time, last_lng,
last_lat, alarm_no, begin_time, vehicle_id, is_valid
</sql>
<select id="getDeviceAlarmRecHistory" resultMap="BaseResultMap">
select <include refid="Base_Column_List"></include>
from dj_device_alarm_rec_history o
where o.sn=#{record.sn,jdbcType=VARCHAR}
and o.alarm_type=#{record.alarmType,jdbcType=INTEGER}
and o.del_flag=#{record.delFlag,jdbcType=INTEGER}
</select>
</mapper>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.dj.device.mapper.DeviceAlarmRecMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.dj.device.model.DeviceAlarmRec">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="sn" jdbcType="VARCHAR" property="sn" />
<result column="lng" jdbcType="VARCHAR" property="lng" />
<result column="lat" jdbcType="VARCHAR" property="lat" />
<result column="speed" jdbcType="VARCHAR" property="speed" />
<result column="direction" jdbcType="VARCHAR" property="direction" />
<result column="alarm_type" jdbcType="INTEGER" property="alarmType" />
<result column="city_name" jdbcType="VARCHAR" property="cityName" />
<result column="del_flag" jdbcType="INTEGER" property="delFlag" />
<result column="last_time" jdbcType="TIMESTAMP" property="lastTime" />
<result column="last_lng" jdbcType="VARCHAR" property="lastLng" />
<result column="last_lat" jdbcType="VARCHAR" property="lastLat" />
<result column="alarm_no" jdbcType="INTEGER" property="alarmNo" />
<result column="begin_time" jdbcType="TIMESTAMP" property="beginTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="vehicle_id" jdbcType="INTEGER" property="vehicleId" />
</resultMap>
<sql id="Base_Column_List">
id, sn, lng, lat, speed, direction, alarm_type, city_name, del_flag, last_time, last_lng,
last_lat, alarm_no, begin_time, update_time, vehicle_id
</sql>
<select id="getDeviceAlarmRec" resultMap="BaseResultMap">
select <include refid="Base_Column_List"></include>
from dj_device_alarm_rec o
where o.sn=#{record.sn,jdbcType=VARCHAR}
and o.alarm_type=#{record.alarmType,jdbcType=INTEGER}
and o.del_flag=#{record.delFlag,jdbcType=INTEGER}
</select>
</mapper>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.dj.device.mapper.DeviceLoginMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.dj.device.model.DeviceLogin">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="sn" jdbcType="VARCHAR" property="sn" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="last_login_time" jdbcType="TIMESTAMP" property="lastLoginTime" />
<result column="last_gprs_time" jdbcType="TIMESTAMP" property="lastGprsTime" />
<result column="last_vilid_time" jdbcType="TIMESTAMP" property="lastVilidTime" />
<result column="last_rt_track" jdbcType="TIMESTAMP" property="lastRtTrack" />
<result column="first_histrack" jdbcType="TIMESTAMP" property="firstHistrack" />
<result column="first_login_time" jdbcType="TIMESTAMP" property="firstLoginTime" />
<result column="device_status" jdbcType="INTEGER" property="deviceStatus" />
<result column="locate_status" jdbcType="INTEGER" property="locateStatus" />
<result column="sub_sn_switch_status" jdbcType="INTEGER" property="subSnSwitchStatus" />
<result column="sub_sn_time" jdbcType="TIMESTAMP" property="subSnTime" />
<result column="speed" jdbcType="INTEGER" property="speed" />
<result column="mileage" jdbcType="DECIMAL" property="mileage" />
<result column="merchant_id" jdbcType="INTEGER" property="merchantId" />
<result column="created_by" jdbcType="VARCHAR" property="createdBy" />
<result column="created_date" jdbcType="TIMESTAMP" property="createdDate" />
<result column="updated_by" jdbcType="VARCHAR" property="updatedBy" />
<result column="updated_date" jdbcType="TIMESTAMP" property="updatedDate" />
<result column="deleted_flag" jdbcType="CHAR" property="deletedFlag" />
</resultMap>
<resultMap id="BaseResultSnVoMap" type="cn.com.glsx.dj.device.vo.DeviceSnVo">
<result column="sn" jdbcType="VARCHAR" property="sn" />
</resultMap>
<sql id="Base_Column_List">
id, sn, status, last_login_time, last_gprs_time, last_vilid_time, last_rt_track,
first_histrack, first_login_time, device_status, locate_status, sub_sn_switch_status,
sub_sn_time, speed, mileage, merchant_id, created_by, created_date, updated_by, updated_date,
deleted_flag
</sql>
<select id="selectSnList" resultMap="BaseResultSnVoMap">
select sn from dj_device_login
</select>
<!-- 批量增加或更新 -->
<insert id="batchInsertOrUpdate" parameterType="java.util.List" >
insert into dj_device_login (
id,
sn,
status,
last_login_time,
last_gprs_time,
last_vilid_time,
last_rt_track,
first_histrack,
first_login_time,
device_status,
locate_status,
sub_sn_switch_status,
sub_sn_time,
speed,
mileage,
merchant_id,
created_by,
created_date,
updated_by,
updated_date,
deleted_flag
)
VALUES
<foreach collection="list" item="record" index="index" separator="," >
(
#{record.id, jdbcType=INTEGER},
#{record.sn, jdbcType=VARCHAR},
#{record.status,jdbcType=INTEGER},
#{record.lastLoginTime,jdbcType=TIMESTAMP},
#{record.lastGprsTime,jdbcType=TIMESTAMP},
#{record.lastVilidTime,jdbcType=TIMESTAMP},
#{record.lastRtTrack,jdbcType=TIMESTAMP},
#{record.firstHistrack, jdbcType=TIMESTAMP},
#{record.firstLoginTime,jdbcType=TIMESTAMP},
#{record.deviceStatus,jdbcType=INTEGER},
#{record.locateStatus,jdbcType=INTEGER},
#{record.subSnSwitchStatus,jdbcType=INTEGER},
#{record.subSnTime,jdbcType=TIMESTAMP},
#{record.speed,jdbcType=INTEGER},
#{record.mileage,jdbcType=DOUBLE},
#{record.merchantId,jdbcType=INTEGER},
#{record.createdBy,jdbcType=VARCHAR},
#{record.createdDate,jdbcType=TIMESTAMP},
#{record.updatedBy,jdbcType=VARCHAR},
#{record.updatedDate,jdbcType=TIMESTAMP},
#{record.deletedFlag,jdbcType=VARCHAR}
)
</foreach>
ON DUPLICATE KEY UPDATE
<if test="record.status != null">
status = VALUES(status),
</if>
<if test="record.lastLoginTime != null">
last_login_time = VALUES(last_login_time),
</if>
<if test="record.lastGprsTime != null">
last_gprs_time = VALUES(last_gprs_time),
</if>
<if test="record.lastVilidTime != null">
last_vilid_time = VALUES(last_vilid_time),
</if>
<if test="record.lastRtTrack != null">
last_rt_track = VALUES(last_rt_track),
</if>
<if test="record.firstHistrack != null">
first_histrack = VALUES(first_histrack),
</if>
<if test="record.firstLoginTime != null">
first_login_time = VALUES(first_login_time),
</if>
<if test="record.deviceStatus != null">
device_status = VALUES(device_status),
</if>
<if test="record.locateStatus != null">
locate_status = VALUES(locate_status),
</if>
<if test="record.subSnSwitchStatus != null">
sub_sn_switch_status = VALUES(sub_sn_switch_status),
</if>
<if test="record.subSnTime != null">
sub_sn_time = VALUES(sub_sn_time),
</if>
<if test="record.speed != null">
speed = VALUES(speed),
</if>
mileage = VALUES(mileage)
</insert>
<!-- 批量增加 -->
<insert id="batchInserts" parameterType="java.util.List" >
insert into dj_device_login (
sn,
status,
last_login_time,
last_gprs_time,
last_vilid_time,
last_rt_track,
first_histrack,
first_login_time,
device_status,
locate_status,
sub_sn_switch_status,
sub_sn_time,
speed,
mileage,
merchant_id,
created_by,
created_date,
updated_by,
updated_date,
deleted_flag
)
VALUES
<foreach collection="list" item="record" index="index" separator="," >
(
#{record.sn, jdbcType=VARCHAR},
#{record.status,jdbcType=INTEGER},
#{record.lastLoginTime,jdbcType=TIMESTAMP},
#{record.lastGprsTime,jdbcType=TIMESTAMP},
#{record.lastVilidTime,jdbcType=TIMESTAMP},
#{record.lastRtTrack,jdbcType=TIMESTAMP},
#{record.firstHistrack, jdbcType=TIMESTAMP},
#{record.firstLoginTime,jdbcType=TIMESTAMP},
#{record.deviceStatus,jdbcType=INTEGER},
#{record.locateStatus,jdbcType=INTEGER},
#{record.subSnSwitchStatus,jdbcType=INTEGER},
#{record.subSnTime,jdbcType=TIMESTAMP},
#{record.speed,jdbcType=INTEGER},
#{record.mileage,jdbcType=DOUBLE},
#{record.merchantId,jdbcType=INTEGER},
#{record.createdBy,jdbcType=VARCHAR},
#{record.createdDate,jdbcType=TIMESTAMP},
#{record.updatedBy,jdbcType=VARCHAR},
#{record.updatedDate,jdbcType=TIMESTAMP},
#{record.deletedFlag,jdbcType=VARCHAR}
)
</foreach>
</insert>
<!-- 批量修改 -->
<update id="batchUpdates" parameterType="java.util.List">
<foreach collection="list" item="record" index="index" open="" close="" separator=";">
UPDATE dj_device_login
<set>
<if test="record.status != null">
status = #{record.status,jdbcType=INTEGER},
</if>
<if test="record.lastLoginTime != null">
last_login_time = #{record.lastLoginTime,jdbcType=TIMESTAMP},
</if>
<if test="record.lastGprsTime != null">
last_gprs_time = #{record.lastGprsTime,jdbcType=TIMESTAMP},
</if>
<if test="record.lastVilidTime != null">
last_vilid_time = #{record.lastVilidTime,jdbcType=TIMESTAMP},
</if>
<if test="record.lastRtTrack != null">
last_rt_track = #{record.lastRtTrack,jdbcType=TIMESTAMP},
</if>
<if test="record.firstHistrack != null">
first_histrack = #{record.firstHistrack, jdbcType=TIMESTAMP},
</if>
<if test="record.firstLoginTime != null">
first_login_time = #{record.firstLoginTime,jdbcType=TIMESTAMP},
</if>
<if test="record.deviceStatus != null">
device_status = #{record.deviceStatus,jdbcType=INTEGER},
</if>
<if test="record.locateStatus != null">
locate_status = #{record.locateStatus,jdbcType=INTEGER},
</if>
<if test="record.subSnSwitchStatus != null">
sub_sn_switch_status = #{record.subSnSwitchStatus,jdbcType=INTEGER},
</if>
<if test="record.subSnTime != null">
sub_sn_time = #{record.subSnTime,jdbcType=TIMESTAMP},
</if>
<if test="record.speed != null">
speed = #{record.speed,jdbcType=INTEGER},
</if>
<if test="record.mileage != null">
mileage = #{record.mileage,jdbcType=DOUBLE}
</if>
</set>
WHERE sn = #{record.sn}
</foreach>
</update>
</mapper>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!