|
|
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.company.model.*;
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.jdbc.core.PreparedStatementSetter;
|
|
|
import org.springframework.jdbc.core.RowMapper;
|
|
|
@@ -18,9 +19,11 @@ import java.io.IOException;
|
|
|
import java.sql.PreparedStatement;
|
|
|
import java.sql.ResultSet;
|
|
|
import java.sql.SQLException;
|
|
|
+import java.sql.Timestamp;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
@Controller
|
|
|
public class DeviceInfoController {
|
|
|
@@ -183,7 +186,7 @@ public class DeviceInfoController {
|
|
|
String sql = "SELECT a.mo,B.name,a.mp,a.IMEI,idx,[direct1],[direct2],[tow_num],[zzj_type],[mt_ext_loca]," +
|
|
|
"[mt_ext_no],[zl_1_loca],[zl_1_no],[zl_2_loca],[zl_2_no],[zl_3_no],e.[updatetime],C.up,D.name," +
|
|
|
"e.version AS up_name,zzjno,epos,install_1,install_2,install_3,isnull(p1,1) p1,isnull(p2,1) p2,isnull(p3,1) p3,isnull(d1,0) d1,isnull(d2,0) d2," +
|
|
|
- "isnull(d3,0) d3,1 as is_alive " +
|
|
|
+ "isnull(d3,0) d3 " +
|
|
|
"FROM rm_map AS A LEFT JOIN rm_mo AS B ON A.mo = B.id " +
|
|
|
"LEFT JOIN rm_mo AS C ON A.mo = C.id " +
|
|
|
"LEFT JOIN rm_mo AS D ON c.up = D.id " +
|
|
|
@@ -221,7 +224,10 @@ public class DeviceInfoController {
|
|
|
r.setZl_2_loca(resultSet.getString(j++));
|
|
|
r.setZl_2_no(resultSet.getString(j++));
|
|
|
r.setZl_3_no(resultSet.getString(j++));
|
|
|
- r.setUpdatetime(resultSet.getTimestamp(j++));
|
|
|
+ // 之前的时间
|
|
|
+ Timestamp previous_timestamp = resultSet.getTimestamp(j++);
|
|
|
+ r.setUpdatetime(previous_timestamp);
|
|
|
+ //
|
|
|
r.setUp(resultSet.getString(j++));
|
|
|
r.setUp_name(resultSet.getString(j++));
|
|
|
r.setVersion(resultSet.getString(j++));
|
|
|
@@ -236,7 +242,20 @@ public class DeviceInfoController {
|
|
|
r.setD1(resultSet.getInt(j++));
|
|
|
r.setD2(resultSet.getInt(j++));
|
|
|
r.setD3(resultSet.getInt(j++));
|
|
|
- r.setIs_alive(resultSet.getInt(j++));
|
|
|
+ // dif返回millisecond
|
|
|
+ if (Objects.isNull(previous_timestamp))
|
|
|
+ {
|
|
|
+ r.setIs_alive(1);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ long dif = (new Date()).getTime() - previous_timestamp.getTime();
|
|
|
+ if (dif > 300000) //超过300秒设备超时
|
|
|
+ {
|
|
|
+ r.setIs_alive(0);
|
|
|
+ } else {
|
|
|
+ r.setIs_alive(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
return r;
|
|
|
}
|
|
|
});
|
|
|
@@ -333,7 +352,10 @@ public class DeviceInfoController {
|
|
|
r.setZl_2_loca(resultSet.getString(j++));
|
|
|
r.setZl_2_no(resultSet.getString(j++));
|
|
|
r.setZl_3_no(resultSet.getString(j++));
|
|
|
- r.setUpdatetime(resultSet.getTimestamp(j++));
|
|
|
+ // 之前的时间
|
|
|
+ Timestamp previous_timestamp = resultSet.getTimestamp(j++);
|
|
|
+ r.setUpdatetime(previous_timestamp);
|
|
|
+ //
|
|
|
r.setUp(resultSet.getString(j++));
|
|
|
r.setUp_name(resultSet.getString(j++));
|
|
|
r.setVersion(resultSet.getString(j++));
|
|
|
@@ -342,6 +364,26 @@ public class DeviceInfoController {
|
|
|
r.setInstall_1(resultSet.getInt(j++));
|
|
|
r.setInstall_2(resultSet.getInt(j++));
|
|
|
r.setInstall_3(resultSet.getInt(j++));
|
|
|
+ r.setP1(resultSet.getInt(j++));
|
|
|
+ r.setP2(resultSet.getInt(j++));
|
|
|
+ r.setP3(resultSet.getInt(j++));
|
|
|
+ r.setD1(resultSet.getInt(j++));
|
|
|
+ r.setD2(resultSet.getInt(j++));
|
|
|
+ r.setD3(resultSet.getInt(j++));
|
|
|
+ // dif返回millisecond
|
|
|
+ if (Objects.isNull(previous_timestamp))
|
|
|
+ {
|
|
|
+ r.setIs_alive(1);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ long dif = (new Date()).getTime() - previous_timestamp.getTime();
|
|
|
+ if (dif > 300000) //超过300秒设备超时
|
|
|
+ {
|
|
|
+ r.setIs_alive(0);
|
|
|
+ } else {
|
|
|
+ r.setIs_alive(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
return r;
|
|
|
}
|
|
|
});
|