Commit 31ea1d93 by levphon

围栏管理完善

1 parent 6bb79bd7
package cn.com.glsx.admin.modules.controller;
import cn.com.glsx.admin.modules.model.ElectricFenceDTO;
import cn.com.glsx.admin.modules.model.ElectricFenceDetailsDTO;
import cn.com.glsx.admin.modules.model.ElectricFenceSnsDTO;
import cn.com.glsx.admin.modules.model.SimpleFenceDTO;
import cn.com.glsx.admin.modules.model.*;
import cn.com.glsx.admin.modules.model.export.ElectricFenceExport;
import cn.com.glsx.admin.modules.model.imports.BaseImportInfo;
import cn.com.glsx.admin.modules.model.imports.ElectricFenceSnsImport;
import cn.com.glsx.admin.modules.model.imports.ElectricFenceSnsImportListener;
import cn.com.glsx.admin.modules.model.param.ElectricFenceBO;
import cn.com.glsx.admin.modules.model.param.ElectricFenceSearch;
import cn.com.glsx.admin.modules.model.param.ElectricFenceSnsSearch;
import cn.com.glsx.admin.modules.model.param.VehicleSearch;
import cn.com.glsx.admin.modules.service.ElectricFenceService;
import cn.com.glsx.admin.modules.service.VehicleService;
import com.alibaba.excel.EasyExcel;
import com.github.pagehelper.PageInfo;
import com.glsx.plat.common.annotation.SysLog;
......@@ -42,6 +40,9 @@ public class ElectricFenceController extends AbstractController {
private final static String MODULE = "围栏管理";
@Autowired
private VehicleService vehicleService;
@Autowired
private ElectricFenceService electricFenceService;
@ApiOperation(value = "围栏列表查询")
......@@ -103,14 +104,14 @@ public class ElectricFenceController extends AbstractController {
/**
* 围栏详情-围栏关联设备
*
* @param search
* @param fenceId
* @return
*/
@GetMapping(value = "/linkedDevices")
@ApiOperation(value = "查看围栏详情")
public R linkedDevices(ElectricFenceSnsSearch search) {
PageInfo<ElectricFenceSnsDTO> pageInfo = electricFenceService.linkedDevices(search);
return R.ok().putPageData(pageInfo);
public R linkedDevices(@RequestParam("fenceId") Long fenceId) {
List<ElectricFenceSnsDTO> snsList = electricFenceService.linkedDevices(fenceId);
return R.ok().data(snsList);
}
/**
......@@ -154,6 +155,14 @@ public class ElectricFenceController extends AbstractController {
return R.ok();
}
@ApiOperation(value = "车辆设备关联列表查询")
@GetMapping("/linksns/search")
public R search(VehicleSearch search) {
search.setDeviceSource(1);//有线设备
PageInfo<VehicleLinkSnsDTO> pageInfo = vehicleService.linkSnsSearch(search);
return R.ok().putPageData(pageInfo);
}
/**
* 批量删除关联设备
*
......
......@@ -12,7 +12,6 @@ import cn.com.glsx.admin.modules.model.param.*;
import cn.com.glsx.admin.modules.model.view.VehiclePermitDTO;
import cn.com.glsx.admin.modules.service.DeviceService;
import cn.com.glsx.admin.modules.service.UserApiService;
import cn.com.glsx.admin.modules.service.VehicleMonitorService;
import cn.com.glsx.admin.modules.service.VehicleService;
import cn.com.glsx.admin.modules.utils.FileIOUtil;
import cn.com.glsx.auth.utils.ShieldContextHolder;
......@@ -211,6 +210,7 @@ public class VehicleController {
if (StringUtils.isNotEmpty(shopId)) {
search.setShopId(shopId.replaceAll("u", ""));
}
search.setTrialType(1);//只查试驾车辆
PageInfo<VehicleLinkSnsDTO> pageInfo = vehicleService.linkSnsSearch(search);
return R.ok().putPageData(pageInfo);
}
......
......@@ -19,7 +19,6 @@ import cn.com.glsx.admin.modules.model.export.ElectricFenceExport;
import cn.com.glsx.admin.modules.model.imports.ElectricFenceSnsImport;
import cn.com.glsx.admin.modules.model.param.ElectricFenceBO;
import cn.com.glsx.admin.modules.model.param.ElectricFenceSearch;
import cn.com.glsx.admin.modules.model.param.ElectricFenceSnsSearch;
import cn.com.glsx.auth.utils.ShieldContextHolder;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
......@@ -277,15 +276,6 @@ public class ElectricFenceService {
return snsList;
}
public PageInfo<ElectricFenceSnsDTO> linkedDevices(ElectricFenceSnsSearch search) {
PageHelper.startPage(search.getPageNumber(), search.getPageSize());
List<ElectricFenceSnsDTO> list = this.linkedDevices(search.getFenceId());
return new PageInfo<>(list);
}
/**
* 启用停用围栏
*
......
......@@ -221,8 +221,10 @@ public class VehicleService extends AbstractCommonService {
}
public PageInfo<VehicleLinkSnsDTO> linkSnsSearch(VehicleSearch search) {
setOrgCheckedAuth(search);
PageHelper.startPage(search.getPageNumber(), search.getPageSize());
search.setTrialType(1);
List<VehicleLinkSnsDTO> list = vehicleMapper.linkSnsSearch(search);
return new PageInfo<>(list);
}
......@@ -1290,6 +1292,7 @@ public class VehicleService extends AbstractCommonService {
/**
* 处理设备绑定和解绑逻辑
*
* @param vehicle
* @param vehicleInfoVo
* @param vehicleLogList
......@@ -1301,7 +1304,7 @@ public class VehicleService extends AbstractCommonService {
log.info("vehicle bindAndUnbind source vehicleDevice info:{}", JSONObject.toJSONString(sourceVehicleDeviceList));
Map<String, VehicleDevice> vehicleDeviceMap = new HashMap<>();
if (CollectionUtil.isNotEmpty(sourceVehicleDeviceList)) {
vehicleDeviceMap = sourceVehicleDeviceList.stream().collect(Collectors.toMap(VehicleDevice::getSn, Function.identity(), (v1, v2)->v1));
vehicleDeviceMap = sourceVehicleDeviceList.stream().collect(Collectors.toMap(VehicleDevice::getSn, Function.identity(), (v1, v2) -> v1));
}
Map<String, DeviceInfoDto> currentDeviceInfoDtoMap = new HashMap<>();
......@@ -1368,7 +1371,7 @@ public class VehicleService extends AbstractCommonService {
List<String> deleteSnList = new ArrayList<>();
for (VehicleDevice vehicleDevice : sourceVehicleDeviceList) {
DeviceInfoDto deviceInfoDto = deviceInfoDtoMap.get(vehicleDevice.getSn());
if (deviceInfoDto!=null) {
if (deviceInfoDto != null) {
continue;
}
vehicleDevice.setBindStatus(ConstantsDevice.UN_BIND_VEHICLE_STATUS);
......
......@@ -123,9 +123,13 @@
select tv.owner_name name, tv.vin, tv.owner_tel userTel, tvd.sn sns
from t_vehicle tv
left join t_vehicle_device tvd on tv.id = tvd.vehicle_id
left join t_workorder tw on tw.id = tv.workorder_id
left join t_device td on tvd.sn = td.sn
where tv.del_flag = 0 and tvd.del_flag = 0
and tvd.bind_status = 1
<if test="checkedUserIdsStr != null and checkedUserIdsStr !=''">
and find_in_set(tv.created_by,#{checkedUserIdsStr})
</if>
<if test="term != null and term != ''">
<choose>
<when test="termType == 1">
......@@ -134,8 +138,17 @@
<when test="termType == 2">
and tv.vin like concat('%',#{term},'%')
</when>
<when test="termType == 3">
and tv.owner_name like concat('%',#{term},'%')
</when>
<when test="termType == 4">
and tw.partner_order_no like concat('%',#{term},'%')
</when>
</choose>
</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
and DATE_FORMAT(tvd.created_date,'%Y-%m-%d') between #{startTime} and #{endTime}
</if>
<if test="shopId != null">
and tv.created_by = #{shopId}
</if>
......@@ -419,7 +432,8 @@
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_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
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
......@@ -453,10 +467,12 @@
<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)
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)
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}
......@@ -491,7 +507,8 @@
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_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
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
......@@ -525,10 +542,12 @@
<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)
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)
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}
......@@ -759,7 +778,7 @@
tdjo.distance as distance
from t_vehicle tv
left join t_vehicle_device tvd on tvd.vehicle_id = tv.id
left join t_device_journey_overview tdjo on tvd.id = tdjo.vd_id
left join t_device_journey_overview tdjo on tvd.id = tdjo.vd_id
left join t_device td on td.sn = tvd.sn
left join t_workorder tw on tw.id = tv.workorder_id and tw.del_flag = 0
where tv.del_flag = 0
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!