YiTongGPSDevice.java 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. package com.tidecloud.dataacceptance.entity;
  2. import java.io.Serializable;
  3. import java.text.ParseException;
  4. import java.text.SimpleDateFormat;
  5. import java.util.Date;
  6. import com.tidecloud.dataacceptance.common.DateUtil;
  7. /**
  8. * @author: chudk
  9. * @date: 2017年9月18日 上午11:04:09
  10. */
  11. public class YiTongGPSDevice implements Serializable{
  12. private static final long serialVersionUID = 684382625782853174L;
  13. private String deviceId;
  14. private String date;
  15. private Byte gpsCount;
  16. private Integer lat;
  17. private Integer lng;
  18. private Byte speedbyte;
  19. private String speed;
  20. private Short courseStatus;
  21. private Short mcc;
  22. private Byte mnc;
  23. private Short lac;
  24. private Integer cellId;
  25. private Byte acc;
  26. private Double mileage;
  27. private Byte reportModel;
  28. private Byte ismendMsg;
  29. private Double voltage;
  30. private Integer dataType;
  31. public YiTongGPSDevice() {
  32. }
  33. public YiTongGPSDevice(String deviceId, String date, Byte gpsCount, Integer lat, Integer lng, Byte speedbyte,
  34. String speed, Short courseStatus, Short mcc, Byte mnc, Short lac, Integer cellId, Byte acc, Double mileage,
  35. Byte reportModel, Byte ismendMsg, Double voltage, Integer dataType) {
  36. super();
  37. this.deviceId = deviceId;
  38. this.date = date;
  39. this.gpsCount = gpsCount;
  40. this.lat = lat;
  41. this.lng = lng;
  42. this.speedbyte = speedbyte;
  43. this.speed = speed;
  44. this.courseStatus = courseStatus;
  45. this.mcc = mcc;
  46. this.mnc = mnc;
  47. this.lac = lac;
  48. this.cellId = cellId;
  49. this.acc = acc;
  50. this.mileage = mileage;
  51. this.reportModel = reportModel;
  52. this.ismendMsg = ismendMsg;
  53. this.voltage = voltage;
  54. this.dataType = dataType;
  55. }
  56. public String getDeviceId() {
  57. return deviceId;
  58. }
  59. public void setDeviceId(String deviceId) {
  60. this.deviceId = deviceId;
  61. }
  62. public String getDate() {
  63. return date;
  64. }
  65. public void setDate(String date) {
  66. this.date = date;
  67. }
  68. public Byte getGpsCount() {
  69. return gpsCount;
  70. }
  71. public void setGpsCount(Byte gpsCount) {
  72. this.gpsCount = gpsCount;
  73. }
  74. public Integer getLat() {
  75. return lat;
  76. }
  77. public void setLat(Integer lat) {
  78. this.lat = lat;
  79. }
  80. public Integer getLng() {
  81. return lng;
  82. }
  83. public void setLng(Integer lng) {
  84. this.lng = lng;
  85. }
  86. public Byte getSpeedbyte() {
  87. return speedbyte;
  88. }
  89. public void setSpeedbyte(Byte speedbyte) {
  90. this.speedbyte = speedbyte;
  91. }
  92. public String getSpeed() {
  93. return speed;
  94. }
  95. public void setSpeed(String speed) {
  96. this.speed = speed;
  97. }
  98. public Short getCourseStatus() {
  99. return courseStatus;
  100. }
  101. public void setCourseStatus(Short courseStatus) {
  102. this.courseStatus = courseStatus;
  103. }
  104. public Short getMcc() {
  105. return mcc;
  106. }
  107. public void setMcc(Short mcc) {
  108. this.mcc = mcc;
  109. }
  110. public Byte getMnc() {
  111. return mnc;
  112. }
  113. public void setMnc(Byte mnc) {
  114. this.mnc = mnc;
  115. }
  116. public Short getLac() {
  117. return lac;
  118. }
  119. public void setLac(Short lac) {
  120. this.lac = lac;
  121. }
  122. public Integer getCellId() {
  123. return cellId;
  124. }
  125. public void setCellId(Integer cellId) {
  126. this.cellId = cellId;
  127. }
  128. public Byte getAcc() {
  129. return acc;
  130. }
  131. public void setAcc(Byte acc) {
  132. this.acc = acc;
  133. }
  134. public Double getMileage() {
  135. return mileage;
  136. }
  137. public void setMileage(Double mileage) {
  138. this.mileage = mileage;
  139. }
  140. public Byte getReportModel() {
  141. return reportModel;
  142. }
  143. public void setReportModel(Byte reportModel) {
  144. this.reportModel = reportModel;
  145. }
  146. public Byte getIsmendMsg() {
  147. return ismendMsg;
  148. }
  149. public void setIsmendMsg(Byte ismendMsg) {
  150. this.ismendMsg = ismendMsg;
  151. }
  152. public Double getVoltage() {
  153. return voltage;
  154. }
  155. public void setVoltage(Double voltage) {
  156. this.voltage = voltage;
  157. }
  158. public Integer getDataType() {
  159. return dataType;
  160. }
  161. public void setDataType(Integer dataType) {
  162. this.dataType = dataType;
  163. }
  164. public static String buildDeviceStr(YiTongGPSDevice device){
  165. // [设备号] [日期] [gpsCount] [经度] [维度] [速度] [里程] [是否补传] [数据上报模式] [移动基站] [LAC] [MCC] [信息类型 1代表location, 0代表电压] [电压]
  166. SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHHmmss");
  167. Date date = new Date();
  168. try {
  169. date = sdf.parse(device.getDate());
  170. } catch (ParseException e) {
  171. e.printStackTrace();
  172. }
  173. date = DateUtil.calculateByHour(date, 8);
  174. String dateStr = sdf.format(date);
  175. StringBuilder builder = new StringBuilder();
  176. builder.append(checkoutNullObject(device.getDeviceId())).append(",");
  177. builder.append(checkoutNullObject(dateStr)).append(",");
  178. builder.append(checkoutNullObject(device.getGpsCount())).append(",");
  179. builder.append(checkoutNullObject(device.getLng())).append(",");
  180. builder.append(checkoutNullObject(device.getLat())).append(",");
  181. builder.append(checkoutNullObject(device.getSpeedbyte())).append(",");
  182. builder.append(checkoutNullObject(device.getMileage())).append(",");
  183. builder.append(checkoutNullObject(device.getIsmendMsg())).append(",");
  184. builder.append(checkoutNullObject(device.getReportModel())).append(",");
  185. builder.append(checkoutNullObject(device.getAcc())).append(",");
  186. builder.append(checkoutNullObject(device.getLac())).append(",");
  187. builder.append(checkoutNullObject(device.getMcc())).append(",");
  188. builder.append(checkoutNullObject(device.getDataType())).append(",");
  189. builder.append(checkoutNullObject(device.getVoltage()));
  190. return builder.toString();
  191. }
  192. private static String checkoutNullObject(Object t){
  193. if (t == null) {
  194. return "";
  195. }
  196. return String.valueOf(t);
  197. }
  198. }