Commit e1e2d2e9 by levphon

车辆管理-车辆查询、导出条件加上车辆归属、设备状态

1 parent b97f28e7
......@@ -14,22 +14,11 @@ public final class ConstantsDevice {
* 设备绑定车辆状态:2解绑
*/
public static final int UN_BIND_VEHICLE_STATUS = 2;
/**
* 设备在线状态 (0 行驶中)
*/
public static final int DEVICE_STATUS_DRIVING = 0;
/**
* 设备在线状态 (1 静止)
*/
public static final int DEVICE_STATUS_STATIC = 1;
/**
* 设备在线状态 (2 离线)
*/
public static final int DEVICE_STATUS_OFFLINE = 2;
/**
* 设备在线状态 (3 在线)
* 设备离线时间:三天 单位 s/秒
*/
public static final int DEVICE_STATUS_ONLINE = 3;
public static final long OFFLINE_TIME = 3 * 24 * 3600L;
/**
* 定位类型:gps:1
......@@ -39,14 +28,6 @@ public final class ConstantsDevice {
* 定位类型:基站:2
*/
public static final int DEVICE_LOCATION_BS = 2;
/**
* 1有源
*/
public static final int SOURCE_HAS = 1;
/**
* 0无源
*/
public static final int SOURCE_NO = 0;
/**
* 试驾设备类型 0:非试驾设备
......@@ -73,8 +54,4 @@ public final class ConstantsDevice {
*/
public static final int NOT_DEL_FLAG = 0;
/**
* 删除标记 1=删除
*/
public static final int DEL_FLAG = 1;
}
......@@ -2,7 +2,7 @@ package cn.com.glsx.admin.common.constants;
public final class ConstantsElectricFence {
//围栏形状类型 1.圆形(默认) 2.矩形 3.多边形 4.行政区域
//围栏形状类型 1.圆形(默认) 3.多边形 4行政区域(大数据侧没有4,我方以areaCode判断)
/**
* 围栏形状 圆形
*/
......
package cn.com.glsx.admin.common.enums;
import lombok.Getter;
@Getter
public enum VehicleTypeEnum {
TRIAL(1, "试驶车"),
DEEP(2, "深度体验车"),
SERVER(3, "服务车"),
WALK(4, "代步车"),
HELP(5, "救援车"),
OFFICE(5, "办公车"),
OTHER(5, "其他");
private final Integer code;
private final String name;
VehicleTypeEnum(Integer code, String name) {
this.code = code;
this.name = name;
}
public static String getNameByCode(Integer code) {
for (VehicleTypeEnum typeEnum : VehicleTypeEnum.values()) {
if (typeEnum.getCode().equals(code)) {
return typeEnum.getName();
}
}
return "--";
}
}
package cn.com.glsx.admin.common.enums;
import lombok.Getter;
@Getter
public enum VehicleUsageEnum {
TRIAL(1, "专属用途"),
DEEP(2, "非专属用途");
private final Integer code;
private final String name;
VehicleUsageEnum(Integer code, String name) {
this.code = code;
this.name = name;
}
public static String getNameByCode(Integer code) {
for (VehicleUsageEnum typeEnum : VehicleUsageEnum.values()) {
if (typeEnum.getCode().equals(code)) {
return typeEnum.getName();
}
}
return "--";
}
}
......@@ -31,6 +31,11 @@ public class VehicleInfoSearch extends BasicSearch {
private Integer deviceType;
/**
* 离线时间阈值
*/
private Long offlineTime;
/**
* 设备状态 0 行驶中 1 静止 2离线 3 在线
*/
private Integer deviceState;
......
package cn.com.glsx.admin.modules.remote;
import cn.com.glsx.devicemonitor.api.dto.response.DeviceSearchDTO;
import cn.com.glsx.devicemonitor.api.dto.request.DeviceStatusRequest;
import cn.com.glsx.devicemonitor.api.dto.response.DeviceStatusModel;
import cn.com.glsx.devicemonitor.api.feign.DeviceFeignService;
import cn.hutool.json.JSONUtil;
......@@ -29,11 +29,15 @@ public class RemoteFeignDeviceService {
@Autowired
private DeviceFeignService deviceFeignService;
/**
* 获取设备状态
*
* @param sns
* @return
*/
public Map<String, DeviceStatusModel> listDeviceStatusBySns(Collection<String> sns) {
log.info("调用监控服务获取设备在线和离线的状态===" + JSONUtil.toJsonStr(sns));
DeviceSearchDTO deviceSearchDTO = new DeviceSearchDTO();
deviceSearchDTO.setSns(sns);
R<List<DeviceStatusModel>> listDeviceStatusBySnsR = deviceFeignService.listDeviceStatusBySns(deviceSearchDTO);
R<List<DeviceStatusModel>> listDeviceStatusBySnsR = deviceFeignService.listDeviceStatusBySns(new DeviceStatusRequest(sns));
List<DeviceStatusModel> listDeviceStatusBySnsDataList = listDeviceStatusBySnsR.getDataList(new TypeToken<List<DeviceStatusModel>>() {
}.getType());
......@@ -43,4 +47,24 @@ public class RemoteFeignDeviceService {
}
return deviceStatusBsDataMap;
}
/**
* 获取设备状态
*
* @param snsMap
* @return
*/
public Map<String, DeviceStatusModel> getDeviceStatusBySns(Map<String, Integer> snsMap) {
log.info("调用监控服务获取设备在线和离线的状态===" + JSONUtil.toJsonStr(snsMap));
R<List<DeviceStatusModel>> listDeviceStatusBySnsR = deviceFeignService.listDeviceStatusBySns(new DeviceStatusRequest(snsMap));
List<DeviceStatusModel> deviceStatusList = listDeviceStatusBySnsR.getDataList(new TypeToken<List<DeviceStatusModel>>() {
}.getType());
Map<String, DeviceStatusModel> deviceStatusMap = Maps.newHashMap();
if (CollectionUtils.isNotEmpty(deviceStatusList)) {
deviceStatusMap = deviceStatusList.stream().collect(Collectors.toMap(DeviceStatusModel::getSn, Function.identity(), (k1, k2) -> k2));
}
return deviceStatusMap;
}
}
......@@ -21,6 +21,7 @@ import cn.com.glsx.admin.modules.utils.fileupload.FileUploadUtil;
import cn.com.glsx.auth.utils.ShieldContextHolder;
import cn.com.glsx.devicemonitor.api.dto.response.DeviceStatusModel;
import cn.com.glsx.devicemonitor.api.dto.response.GpsBsData;
import cn.com.glsx.devicemonitor.api.enums.DeviceStatusEnum;
import cn.com.glsx.stdinterface.enums.FakeOfficeTypeEnum;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.json.JSONUtil;
......@@ -58,9 +59,6 @@ public class FakeOfflineService extends AbstractCommonService {
private RemoteFeignDeviceService remoteFeignDeviceService;
@Autowired
private VehicleMonitorService vehicleMonitorService;
@Autowired
private OrganizationApiService organizationApiService;
@Autowired
......@@ -145,7 +143,7 @@ public class FakeOfflineService extends AbstractCommonService {
DeviceStatusModel deviceStatusModel = deviceStatusMap.get(sn);
if (deviceStatusModel != null) {
Integer status = deviceStatusModel.getStatus();
if (status != null && ConstantsDevice.DEVICE_STATUS_OFFLINE != status) {
if (status != null && !Objects.equals(DeviceStatusEnum.OFFLINE.getCode(), status)) {
builder.append(sn).append("(").append(TypeConverseEunm.SourceStatusEnum.getStrBySourceType(deviceStatusModel.getSource())).append(") ");
}
}
......
......@@ -407,6 +407,7 @@
tv.vin ,
tvd.sn ,
td.source deviceType,
case when td.source = 1 then '有线' when td.source = 0 then '无线' else '--' end as deviceTypeStr,
case when tv.type_id is null then tv.model_name else
concat(tv.sub_brand_name,'/',tv.series_name,'/',tv.type_name) end modelName,
tv.vehicle_type vehicleType,
......@@ -416,9 +417,9 @@
from t_vehicle tv
left join t_vehicle_device tvd on tvd.vehicle_id = tv.id
left join t_workorder tw on tw.id = tv.workorder_id
left join t_device td on td.sn = tvd.sn and td.del_flag = 0
left join (select * from (SELECT * FROM t_device_freq order by created_date desc) temp GROUP BY temp.sn) ddf
on ddf.vehicle_id = tv.id and ddf.sn = td.sn
left join t_device td on td.sn = tvd.sn
left join t_device_location tdl on tdl.sn = tvd.sn
left join (select vehicle_id, sn, status from (SELECT * FROM t_device_freq order by created_date desc) temp GROUP BY temp.sn) ddf on ddf.vehicle_id = tv.id and ddf.sn = td.sn
where tv.del_flag = 0
and tvd.bind_status = 1
and tvd.del_flag = 0
......@@ -446,6 +447,25 @@
<if test="vehicleUsages != null">
and tv.vehicle_usages = #{vehicleUsages}
</if>
<if test="checkedUserIdsStr != null and checkedUserIdsStr !=''">
and find_in_set(tv.created_by,#{checkedUserIdsStr})
</if>
<if test="deviceState != null">
<choose>
<when test="deviceState == 0"> <!-- 行驶中-->
and (td.source=1) and speed>0 and ((timestampdiff(SECOND,tdl.last_gps_time,now())) <![CDATA[<]]> 600 or (timestampdiff(SECOND,tdl.last_bs_time,now())) <![CDATA[<]]> 600)
</when>
<when test="deviceState == 1"> <!-- 静止-->
and (td.source=1) and (speed=0 or speed is null) and ((timestampdiff(SECOND,tdl.last_gps_time,now())) <![CDATA[<]]> 600 or (timestampdiff(SECOND,tdl.last_bs_time,now())) <![CDATA[<]]> 600)
</when>
<when test="deviceState == 2"> <!-- 离线-->
and (timestampdiff(SECOND,tdl.last_gps_time,now())) &gt; #{offlineTime} and (timestampdiff(SECOND,tdl.last_bs_time,now())) &gt; #{offlineTime}
</when>
<when test="deviceState == 3"> <!-- 在线-->
and (timestampdiff(SECOND,tdl.last_gps_time,now()) &lt; #{offlineTime} or timestampdiff(SECOND,tdl.last_bs_time,now()) &lt; #{offlineTime})
</when>
</choose>
</if>
order by tvd.created_date desc,tv.id,vdId
</select>
......@@ -459,8 +479,8 @@
tv.vin ,
tvd.sn ,
td.source deviceType,
case when tv.type_id is null then tv.model_name else
concat(tv.sub_brand_name,'/',tv.series_name,'/',tv.type_name) end as modelName,
case when td.source = 1 then '有线' when td.source = 0 then '无线' else '--' end as deviceTypeStr,
case when tv.type_id is null then tv.model_name else concat(tv.sub_brand_name,'/',tv.series_name,'/',tv.type_name) end as modelName,
tv.vehicle_type vehicleType,
tv.vehicle_usages vehicleUsages,
tvd.created_date activateTime,
......@@ -470,8 +490,8 @@
left join t_vehicle_device tvd on tvd.vehicle_id = tv.id
left join t_workorder tw on tw.id = tv.workorder_id
left join t_device td on td.sn = tvd.sn
left join (select * from (SELECT * FROM t_device_freq order by created_date desc) temp GROUP BY temp.sn) ddf
on ddf.vehicle_id = tv.id and ddf.sn = td.sn
left join t_device_location tdl on tdl.sn = tvd.sn
left join (select vehicle_id, sn, status from (SELECT * FROM t_device_freq order by created_date desc) temp GROUP BY temp.sn) ddf on ddf.vehicle_id = tv.id and ddf.sn = td.sn
where tv.del_flag = 0
and tvd.bind_status = 1
and tvd.del_flag = 0
......@@ -499,6 +519,25 @@
<if test="vehicleUsages != null">
and tv.vehicle_usages = #{vehicleUsages}
</if>
<if test="checkedUserIdsStr != null and checkedUserIdsStr !=''">
and find_in_set(tv.created_by,#{checkedUserIdsStr})
</if>
<if test="deviceState != null">
<choose>
<when test="deviceState == 0"> <!-- 行驶中-->
and (td.source=1) and speed>0 and ((timestampdiff(SECOND,tdl.last_gps_time,now())) <![CDATA[<]]> 600 or (timestampdiff(SECOND,tdl.last_bs_time,now())) <![CDATA[<]]> 600)
</when>
<when test="deviceState == 1"> <!-- 静止-->
and (td.source=1) and (speed=0 or speed is null) and ((timestampdiff(SECOND,tdl.last_gps_time,now())) <![CDATA[<]]> 600 or (timestampdiff(SECOND,tdl.last_bs_time,now())) <![CDATA[<]]> 600)
</when>
<when test="deviceState == 2"> <!-- 离线-->
and (timestampdiff(SECOND,tdl.last_gps_time,now())) &gt; #{offlineTime} and (timestampdiff(SECOND,tdl.last_bs_time,now())) &gt; #{offlineTime}
</when>
<when test="deviceState == 3"> <!-- 在线-->
and (timestampdiff(SECOND,tdl.last_gps_time,now()) &lt; #{offlineTime} or timestampdiff(SECOND,tdl.last_bs_time,now()) &lt; #{offlineTime})
</when>
</choose>
</if>
order by tvd.created_date desc,tv.id,vdId
</select>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!