Commit 74645984 by 杨林龙

Merge remote-tracking branch 'origin/v1.6.0' into v1.6.0

2 parents 65019870 c5493c42
...@@ -14,22 +14,11 @@ public final class ConstantsDevice { ...@@ -14,22 +14,11 @@ public final class ConstantsDevice {
* 设备绑定车辆状态:2解绑 * 设备绑定车辆状态:2解绑
*/ */
public static final int UN_BIND_VEHICLE_STATUS = 2; public static final int UN_BIND_VEHICLE_STATUS = 2;
/** /**
* 设备在线状态 (0 行驶中) * 设备离线时间:三天 单位 s/秒
*/
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 在线)
*/ */
public static final int DEVICE_STATUS_ONLINE = 3; public static final long OFFLINE_TIME = 3 * 24 * 3600L;
/** /**
* 定位类型:gps:1 * 定位类型:gps:1
...@@ -39,14 +28,6 @@ public final class ConstantsDevice { ...@@ -39,14 +28,6 @@ public final class ConstantsDevice {
* 定位类型:基站:2 * 定位类型:基站:2
*/ */
public static final int DEVICE_LOCATION_BS = 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:非试驾设备 * 试驾设备类型 0:非试驾设备
...@@ -73,8 +54,4 @@ public final class ConstantsDevice { ...@@ -73,8 +54,4 @@ public final class ConstantsDevice {
*/ */
public static final int NOT_DEL_FLAG = 0; 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; ...@@ -2,7 +2,7 @@ package cn.com.glsx.admin.common.constants;
public final class ConstantsElectricFence { 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 "--";
}
}
...@@ -87,17 +87,9 @@ public class JourneyController { ...@@ -87,17 +87,9 @@ public class JourneyController {
@ApiOperation(value = "查询通用里程详情列表") @ApiOperation(value = "查询通用里程详情列表")
public R<List<JourneyDetailExport>> findJourneyDetailList(JourneyDetailSearch journeyDetailSearch) { public R<List<JourneyDetailExport>> findJourneyDetailList(JourneyDetailSearch journeyDetailSearch) {
checkQueryParams(journeyDetailSearch); checkQueryParams(journeyDetailSearch);
Page<Object> page = PageHelper.startPage(journeyDetailSearch.getPageNumber(), journeyDetailSearch.getPageSize(), true);
List<JourneyDetailExport> journeyDetailList = journeyService.findJourneyDetailList(journeyDetailSearch); List<JourneyDetailExport> journeyDetailList = journeyService.findJourneyDetailList(journeyDetailSearch);
int pageSize = journeyDetailSearch.getPageSize(); return R.ok().putPageData(journeyDetailList, page.getTotal());
int pageNumber = journeyDetailSearch.getPageNumber();
int startIndex = pageSize * (pageNumber - 1);
int endIndex = pageSize * pageNumber;
if (endIndex > journeyDetailList.size()) {
endIndex = journeyDetailList.size();
}
log.info("findJourneyDetailList startIndex:" + startIndex + "endIndex:" + endIndex);
List<JourneyDetailExport> journeyDetailPageList = journeyDetailList.subList(startIndex, endIndex);
return R.ok().putPageData(journeyDetailPageList, journeyDetailList.size());
} }
/** /**
......
package cn.com.glsx.admin.modules.mapper; package cn.com.glsx.admin.modules.mapper;
import cn.com.glsx.admin.modules.entity.DeviceJourney; import cn.com.glsx.admin.modules.entity.DeviceJourney;
import cn.com.glsx.devicemonitor.api.dto.response.JourneyDailyDTO;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper; import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
......
...@@ -31,6 +31,11 @@ public class VehicleInfoSearch extends BasicSearch { ...@@ -31,6 +31,11 @@ public class VehicleInfoSearch extends BasicSearch {
private Integer deviceType; private Integer deviceType;
/** /**
* 离线时间阈值
*/
private Long offlineTime;
/**
* 设备状态 0 行驶中 1 静止 2离线 3 在线 * 设备状态 0 行驶中 1 静止 2离线 3 在线
*/ */
private Integer deviceState; private Integer deviceState;
......
...@@ -12,9 +12,15 @@ import lombok.Data; ...@@ -12,9 +12,15 @@ import lombok.Data;
public class VehicleLocationDTO extends DeviceLocationDTO { public class VehicleLocationDTO extends DeviceLocationDTO {
/** /**
* 加密的设备号
*/
private String encryptSn;
/**
* 车架号 * 车架号
*/ */
private String vin; private String vin;
/** /**
* 车主姓名 * 车主姓名
*/ */
...@@ -30,5 +36,4 @@ public class VehicleLocationDTO extends DeviceLocationDTO { ...@@ -30,5 +36,4 @@ public class VehicleLocationDTO extends DeviceLocationDTO {
*/ */
private String licensePlate; private String licensePlate;
} }
package cn.com.glsx.admin.modules.remote; 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.dto.response.DeviceStatusModel;
import cn.com.glsx.devicemonitor.api.feign.DeviceFeignService; import cn.com.glsx.devicemonitor.api.feign.DeviceFeignService;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
...@@ -29,11 +29,15 @@ public class RemoteFeignDeviceService { ...@@ -29,11 +29,15 @@ public class RemoteFeignDeviceService {
@Autowired @Autowired
private DeviceFeignService deviceFeignService; private DeviceFeignService deviceFeignService;
/**
* 获取设备状态
*
* @param sns
* @return
*/
public Map<String, DeviceStatusModel> listDeviceStatusBySns(Collection<String> sns) { public Map<String, DeviceStatusModel> listDeviceStatusBySns(Collection<String> sns) {
log.info("调用监控服务获取设备在线和离线的状态===" + JSONUtil.toJsonStr(sns)); log.info("调用监控服务获取设备在线和离线的状态===" + JSONUtil.toJsonStr(sns));
DeviceSearchDTO deviceSearchDTO = new DeviceSearchDTO(); R<List<DeviceStatusModel>> listDeviceStatusBySnsR = deviceFeignService.listDeviceStatusBySns(new DeviceStatusRequest(sns));
deviceSearchDTO.setSns(sns);
R<List<DeviceStatusModel>> listDeviceStatusBySnsR = deviceFeignService.listDeviceStatusBySns(deviceSearchDTO);
List<DeviceStatusModel> listDeviceStatusBySnsDataList = listDeviceStatusBySnsR.getDataList(new TypeToken<List<DeviceStatusModel>>() { List<DeviceStatusModel> listDeviceStatusBySnsDataList = listDeviceStatusBySnsR.getDataList(new TypeToken<List<DeviceStatusModel>>() {
}.getType()); }.getType());
...@@ -43,4 +47,24 @@ public class RemoteFeignDeviceService { ...@@ -43,4 +47,24 @@ public class RemoteFeignDeviceService {
} }
return deviceStatusBsDataMap; 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; ...@@ -21,6 +21,7 @@ import cn.com.glsx.admin.modules.utils.fileupload.FileUploadUtil;
import cn.com.glsx.auth.utils.ShieldContextHolder; import cn.com.glsx.auth.utils.ShieldContextHolder;
import cn.com.glsx.devicemonitor.api.dto.response.DeviceStatusModel; import cn.com.glsx.devicemonitor.api.dto.response.DeviceStatusModel;
import cn.com.glsx.devicemonitor.api.dto.response.GpsBsData; 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.com.glsx.stdinterface.enums.FakeOfficeTypeEnum;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
...@@ -58,9 +59,6 @@ public class FakeOfflineService extends AbstractCommonService { ...@@ -58,9 +59,6 @@ public class FakeOfflineService extends AbstractCommonService {
private RemoteFeignDeviceService remoteFeignDeviceService; private RemoteFeignDeviceService remoteFeignDeviceService;
@Autowired @Autowired
private VehicleMonitorService vehicleMonitorService;
@Autowired
private OrganizationApiService organizationApiService; private OrganizationApiService organizationApiService;
@Autowired @Autowired
...@@ -145,7 +143,7 @@ public class FakeOfflineService extends AbstractCommonService { ...@@ -145,7 +143,7 @@ public class FakeOfflineService extends AbstractCommonService {
DeviceStatusModel deviceStatusModel = deviceStatusMap.get(sn); DeviceStatusModel deviceStatusModel = deviceStatusMap.get(sn);
if (deviceStatusModel != null) { if (deviceStatusModel != null) {
Integer status = deviceStatusModel.getStatus(); 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(") "); builder.append(sn).append("(").append(TypeConverseEunm.SourceStatusEnum.getStrBySourceType(deviceStatusModel.getSource())).append(") ");
} }
} }
......
...@@ -111,15 +111,15 @@ public class JourneyService { ...@@ -111,15 +111,15 @@ public class JourneyService {
* @return * @return
*/ */
public List<JourneyDetailExport> findJourneyDetailList(JourneyDetailSearch journeyDetailSearch) { public List<JourneyDetailExport> findJourneyDetailList(JourneyDetailSearch journeyDetailSearch) {
List<JourneyDetailExport> journeyDetailList = Lists.newArrayList(); // List<JourneyDetailExport> journeyDetailList = Lists.newArrayList();
if (journeyDetailSearch.getOrgId() != null) { if (journeyDetailSearch.getOrgId() != null) {
journeyDetailSearch.setCheckedOrgIds(Lists.newArrayList(journeyDetailSearch.getOrgId())); journeyDetailSearch.setCheckedOrgIds(Lists.newArrayList(journeyDetailSearch.getOrgId()));
userApiService.setCheckedOrgUsers(journeyDetailSearch); userApiService.setCheckedOrgUsers(journeyDetailSearch);
} }
List<JourneyDetailExport> journeyDetailExportList = vehicleMapper.findJourneyDetailList(journeyDetailSearch); List<JourneyDetailExport> journeyDetailExportList = vehicleMapper.findJourneyDetailList(journeyDetailSearch);
log.info("journeyDetailExportList size()大小===" + journeyDetailExportList.size()); log.info("journeyDetailExportList size()大小===" + journeyDetailExportList.size());
getDeviceDetailMileage(journeyDetailList, journeyDetailExportList, journeyDetailSearch); //getDeviceDetailMileage(journeyDetailList, journeyDetailExportList, journeyDetailSearch);
return journeyDetailList; return journeyDetailExportList;
} }
private void getDeviceDetailMileage(List<JourneyDetailExport> dataList, List<JourneyDetailExport> journeyDetailList, JourneyDetailSearch journeyDetailSearch) { private void getDeviceDetailMileage(List<JourneyDetailExport> dataList, List<JourneyDetailExport> journeyDetailList, JourneyDetailSearch journeyDetailSearch) {
......
...@@ -15,6 +15,7 @@ import cn.com.glsx.usercenter.api.dto.tree.OrgTreeModel; ...@@ -15,6 +15,7 @@ import cn.com.glsx.usercenter.api.dto.tree.OrgTreeModel;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.glsx.plat.common.model.TreeModel; import com.glsx.plat.common.model.TreeModel;
import com.glsx.plat.common.utils.TreeModelUtil; import com.glsx.plat.common.utils.TreeModelUtil;
import com.glsx.plat.common.utils.encryption.EncryptUtils;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -306,7 +307,10 @@ public class VehicleMonitorService { ...@@ -306,7 +307,10 @@ public class VehicleMonitorService {
} }
VehicleLocationDTO vehicleBo = new VehicleLocationDTO(); VehicleLocationDTO vehicleBo = new VehicleLocationDTO();
BeanUtils.copyProperties(deviceBo, vehicleBo); BeanUtils.copyProperties(deviceBo, vehicleBo);
String sn = deviceBo.getSn(); String sn = deviceBo.getSn();
vehicleBo.setEncryptSn(EncryptUtils.PBEEncrypt(sn));
List<Vehicle> vehicleList = vehicleMapper.findVehicleInfoBySn(sn); List<Vehicle> vehicleList = vehicleMapper.findVehicleInfoBySn(sn);
if (CollectionUtils.isNotEmpty(vehicleList)) { if (CollectionUtils.isNotEmpty(vehicleList)) {
Vehicle vehicle = vehicleList.get(0); Vehicle vehicle = vehicleList.get(0);
......
...@@ -407,6 +407,7 @@ ...@@ -407,6 +407,7 @@
tv.vin , tv.vin ,
tvd.sn , tvd.sn ,
td.source deviceType, 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 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, concat(tv.sub_brand_name,'/',tv.series_name,'/',tv.type_name) end modelName,
tv.vehicle_type vehicleType, tv.vehicle_type vehicleType,
...@@ -416,9 +417,9 @@ ...@@ -416,9 +417,9 @@
from t_vehicle tv from t_vehicle tv
left join t_vehicle_device tvd on tvd.vehicle_id = tv.id 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_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 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 left join t_device_location tdl on tdl.sn = tvd.sn
on ddf.vehicle_id = tv.id and ddf.sn = td.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 where tv.del_flag = 0
and tvd.bind_status = 1 and tvd.bind_status = 1
and tvd.del_flag = 0 and tvd.del_flag = 0
...@@ -446,6 +447,25 @@ ...@@ -446,6 +447,25 @@
<if test="vehicleUsages != null"> <if test="vehicleUsages != null">
and tv.vehicle_usages = #{vehicleUsages} and tv.vehicle_usages = #{vehicleUsages}
</if> </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 order by tvd.created_date desc,tv.id,vdId
</select> </select>
...@@ -459,8 +479,8 @@ ...@@ -459,8 +479,8 @@
tv.vin , tv.vin ,
tvd.sn , tvd.sn ,
td.source deviceType, td.source deviceType,
case when tv.type_id is null then tv.model_name else case when td.source = 1 then '有线' when td.source = 0 then '无线' else '--' end as deviceTypeStr,
concat(tv.sub_brand_name,'/',tv.series_name,'/',tv.type_name) end as modelName, 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_type vehicleType,
tv.vehicle_usages vehicleUsages, tv.vehicle_usages vehicleUsages,
tvd.created_date activateTime, tvd.created_date activateTime,
...@@ -470,8 +490,8 @@ ...@@ -470,8 +490,8 @@
left join t_vehicle_device tvd on tvd.vehicle_id = tv.id 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_workorder tw on tw.id = tv.workorder_id
left join t_device td on td.sn = tvd.sn 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 left join t_device_location tdl on tdl.sn = tvd.sn
on ddf.vehicle_id = tv.id and ddf.sn = td.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 where tv.del_flag = 0
and tvd.bind_status = 1 and tvd.bind_status = 1
and tvd.del_flag = 0 and tvd.del_flag = 0
...@@ -499,6 +519,25 @@ ...@@ -499,6 +519,25 @@
<if test="vehicleUsages != null"> <if test="vehicleUsages != null">
and tv.vehicle_usages = #{vehicleUsages} and tv.vehicle_usages = #{vehicleUsages}
</if> </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 order by tvd.created_date desc,tv.id,vdId
</select> </select>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!