Commit 07d49356 by levphon

围栏管理-完善

1 parent 97b7006f
......@@ -108,9 +108,9 @@ public class ElectricFenceController extends AbstractController {
* @return
*/
@GetMapping(value = "/linkedDevices")
@ApiOperation(value = "查看围栏详情")
@ApiOperation(value = "查看围栏详情-关联设备")
public R linkedDevices(@RequestParam("fenceId") Long fenceId) {
List<ElectricFenceSnsDTO> snsList = electricFenceService.linkedDevices(fenceId);
List<ElectricFenceSnsModel> snsList = electricFenceService.linkedDevices(fenceId);
return R.ok().data(snsList);
}
......
......@@ -96,6 +96,6 @@ public class ElectricFenceDetailsDTO {
/**
* 电子栅栏与sn关联集合
*/
private List<ElectricFenceSnsDTO> snList = new ArrayList<>();
private List<ElectricFenceSnsModel> snList = new ArrayList<>();
}
package cn.com.glsx.admin.modules.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
@Data
public class ElectricFenceSnsModel {
public class ElectricFenceSnsModel extends ElectricSnLocationDTO {
/**
* 设备号
......@@ -26,27 +23,6 @@ public class ElectricFenceSnsModel {
*/
private String userTel;
/**
* gps上点时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date time;
/**
* 解析位置
*/
private String address;
/**
* 经度
*/
private String lng;
/**
* 纬度
*/
private String lat;
private Boolean checked;
}
......@@ -3,7 +3,12 @@ package cn.com.glsx.admin.modules.model;
import lombok.Data;
@Data
public class ElectricFenceSnsDTO extends ElectricFenceSnsModel {
public class ElectricSnLocationDTO {
/**
* gps上点时间
*/
private String time;
/**
* 经度
......@@ -15,4 +20,9 @@ public class ElectricFenceSnsDTO extends ElectricFenceSnsModel {
*/
private String lat;
/**
* 解析位置
*/
private String address;
}
......@@ -3,7 +3,7 @@ package cn.com.glsx.admin.modules.model;
import lombok.Data;
@Data
public class VehicleLinkSnsDTO {
public class VehicleLinkSnsDTO extends ElectricSnLocationDTO {
/**
* 姓名
......
......@@ -21,12 +21,14 @@ 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.auth.utils.ShieldContextHolder;
import cn.com.glsx.devicemonitor.api.dto.response.DeviceLocationDTO;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.glsx.plat.common.utils.DateUtils;
import com.glsx.plat.common.utils.StringUtils;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
......@@ -61,6 +63,9 @@ public class ElectricFenceService {
@Autowired
private VehicleDeviceMapper vehicleDeviceMapper;
@Autowired
private DeviceMonitorApiService deviceMonitorApiService;
public PageInfo<ElectricFenceDTO> search(ElectricFenceSearch search) {
Page page = PageHelper.startPage(search.getPageNumber(), search.getPageSize());
List<ElectricFenceDTO> list = electricFenceMapper.search(search);
......@@ -190,7 +195,7 @@ public class ElectricFenceService {
fence.setBizFenceType(fenceBO.getBizFenceType());
fence.setTriggerType(fenceBO.getTriggerType() == null ? 3 : fenceBO.getTriggerType());
fence.setLocationType(1);
fence.setRecord(localFence.getRecord() + "操作时间:" + DateUtils.formatNormal(new Date())
fence.setRecord(StringUtils.isNullOrEmpty(localFence.getRecord()) ? "" : localFence.getRecord() + "操作时间:" + DateUtils.formatNormal(new Date())
+ " 操作人:" + ShieldContextHolder.getUsername() + "(" + ShieldContextHolder.getAccount() + ")"
+ "<br/>");
if (fenceBO.getShopId() != null && fenceBO.getShopId() != 0) {//试驾或门店围栏的特约店账号id
......@@ -229,19 +234,21 @@ public class ElectricFenceService {
snsList.add(fenceSns);
});
} else {
//自动关联试驾设备
List<VehicleLinkSnsDTO> linkSnsDTOList = vehicleMapper.selectVehicleLinkSnsByUserId(fence.getCreatedBy(), 1);
log.info("围栏{}自动关联设备{}", fence.getId(), JSON.toJSONString(linkSnsDTOList));
linkSnsDTOList.forEach(efsm -> {
ElectricFenceSns fenceSns = new ElectricFenceSns();
fenceSns.setFenceId(fence.getId());
fenceSns.setSn(efsm.getSns());
fenceSns.setName(efsm.getName());
fenceSns.setVin(efsm.getVin());
fenceSns.setUserTel(efsm.getUserTel());
fenceSns.setCreatedDate(now);
snsList.add(fenceSns);
});
if (!BizFenceTypeEnum.ALARM_FENCE.getCode().equals(fence.getBizFenceType())) {
//非警情围栏自动关联试驾设备
List<VehicleLinkSnsDTO> linkSnsDTOList = vehicleMapper.selectVehicleLinkSnsByUserId(fence.getCreatedBy(), 1);
log.info("围栏{}自动关联设备{}", fence.getId(), JSON.toJSONString(linkSnsDTOList));
linkSnsDTOList.forEach(efsm -> {
ElectricFenceSns fenceSns = new ElectricFenceSns();
fenceSns.setFenceId(fence.getId());
fenceSns.setSn(efsm.getSns());
fenceSns.setName(efsm.getName());
fenceSns.setVin(efsm.getVin());
fenceSns.setUserTel(efsm.getUserTel());
fenceSns.setCreatedDate(now);
snsList.add(fenceSns);
});
}
}
return snsList;
}
......@@ -256,7 +263,7 @@ public class ElectricFenceService {
//门店围栏、试驾围栏直接返回设备
if (!BizFenceTypeEnum.ALARM_FENCE.getCode().equals(electricFence.getBizFenceType())) {
List<ElectricFenceSnsDTO> snsList = linkedDevices(fenceId);
List<ElectricFenceSnsModel> snsList = linkedDevices(fenceId);
detailsDTO.setSnList(snsList);
}
......@@ -264,19 +271,54 @@ public class ElectricFenceService {
return detailsDTO;
}
public List<ElectricFenceSnsDTO> linkedDevices(Long fenceId) {
List<ElectricFenceSnsDTO> snsList = Lists.newLinkedList();
public List<ElectricFenceSnsModel> linkedDevices(Long fenceId) {
List<ElectricFenceSnsModel> snsList = Lists.newLinkedList();
List<ElectricFenceSns> fenceSnsList = electricFenceSnsMapper.selectByFenceId(fenceId);
fenceSnsList.forEach(fs -> {
ElectricFenceSnsDTO snsDTO = new ElectricFenceSnsDTO();
BeanUtils.copyProperties(fs, snsDTO);
snsList.add(snsDTO);
});
if (CollectionUtils.isNotEmpty(fenceSnsList)) {
Set<String> vehicleSnSet = fenceSnsList.stream().map(ElectricFenceSns::getSn).collect(Collectors.toSet());
Map<String, DeviceLocationDTO> locationMap = getLocationMap(StringUtils.join(vehicleSnSet, ','));
fenceSnsList.forEach(fs -> {
ElectricFenceSnsModel snsDTO = new ElectricFenceSnsModel();
BeanUtils.copyProperties(fs, snsDTO);
DeviceLocationDTO location = locationMap.get(fs.getSn());
setLocationInfo(snsDTO, location);
snsList.add(snsDTO);
});
}
return snsList;
}
/**
* 批量获取位置信息(实际ice单个调用)
*
* @param sns
* @return
*/
public Map<String, DeviceLocationDTO> getLocationMap(String sns) {
List<DeviceLocationDTO> locationDTOS = deviceMonitorApiService.listDeviceMonitorInfo(sns);
Map<String, DeviceLocationDTO> locationMap = locationDTOS.stream().collect(Collectors.toMap(DeviceLocationDTO::getSn, Function.identity(), (k1, k2) -> k2));
return locationMap;
}
public void setLocationInfo(ElectricSnLocationDTO locationDTO, DeviceLocationDTO location) {
if (location != null && location.getGpsLocation() != null) {
locationDTO.setLng(location.getGpsLocation().getLng());
locationDTO.setLat(location.getGpsLocation().getLat());
locationDTO.setAddress(location.getGpsLocation().getAddress());
locationDTO.setTime(location.getGpsLocation().getDateTime());
}
}
/**
* 启用停用围栏
*
* @param fenceId
......
......@@ -9,7 +9,10 @@ import cn.com.glsx.admin.common.exception.AdminException;
import cn.com.glsx.admin.modules.component.EFenceComponent;
import cn.com.glsx.admin.modules.entity.*;
import cn.com.glsx.admin.modules.mapper.*;
import cn.com.glsx.admin.modules.model.*;
import cn.com.glsx.admin.modules.model.ElectricFenceSnsModel;
import cn.com.glsx.admin.modules.model.RouteFenceDTO;
import cn.com.glsx.admin.modules.model.RouteFenceDetailsDTO;
import cn.com.glsx.admin.modules.model.VehicleLinkSnsDTO;
import cn.com.glsx.admin.modules.model.export.RouteFenceExport;
import cn.com.glsx.admin.modules.model.param.ApprovalBo;
import cn.com.glsx.admin.modules.model.param.ElectricFenceBO;
......@@ -389,11 +392,11 @@ public class TrialRouteService {
detailsDTO = new RouteFenceDetailsDTO();
BeanUtils.copyProperties(electricFence, detailsDTO);
List<ElectricFenceSnsDTO> snsList = Lists.newLinkedList();
List<ElectricFenceSnsModel> snsList = Lists.newLinkedList();
List<ElectricFenceSns> fenceSnsList = electricFenceSnsMapper.selectByFenceId(fenceId);
fenceSnsList.forEach(fs -> {
ElectricFenceSnsDTO snsDTO = new ElectricFenceSnsDTO();
ElectricFenceSnsModel snsDTO = new ElectricFenceSnsModel();
BeanUtils.copyProperties(fs, snsDTO);
snsList.add(snsDTO);
});
......@@ -418,11 +421,11 @@ public class TrialRouteService {
detailsDTO = new RouteFenceDetailsDTO();
BeanUtils.copyProperties(fenceCopy, detailsDTO);
List<ElectricFenceSnsDTO> snsList = Lists.newLinkedList();
List<ElectricFenceSnsModel> snsList = Lists.newLinkedList();
List<ElectricFenceSnsCopy> fenceSnsList = electricFenceSnsCopyMapper.selectByFenceId(bizId);
fenceSnsList.forEach(fs -> {
ElectricFenceSnsDTO snsDTO = new ElectricFenceSnsDTO();
ElectricFenceSnsModel snsDTO = new ElectricFenceSnsModel();
BeanUtils.copyProperties(fs, snsDTO);
snsList.add(snsDTO);
});
......
......@@ -25,6 +25,7 @@ import cn.com.glsx.alarm.services.model.DevicePowerBo;
import cn.com.glsx.alarm.services.model.DevicePowerDto;
import cn.com.glsx.auth.utils.ShieldContextHolder;
import cn.com.glsx.devicemonitor.api.dto.response.DeviceDTO;
import cn.com.glsx.devicemonitor.api.dto.response.DeviceLocationDTO;
import cn.com.glsx.devicemonitor.api.dto.response.DeviceStatusModel;
import cn.com.glsx.devicemonitor.api.enums.DeviceStatusEnum;
import cn.com.glsx.devicemonitor.api.feign.DeviceFeignService;
......@@ -226,6 +227,18 @@ public class VehicleService extends AbstractCommonService {
PageHelper.startPage(search.getPageNumber(), search.getPageSize());
List<VehicleLinkSnsDTO> list = vehicleMapper.linkSnsSearch(search);
if (CollectionUtils.isNotEmpty(list)) {
Set<String> vehicleSnSet = list.stream().map(VehicleLinkSnsDTO::getSns).collect(Collectors.toSet());
Map<String, DeviceLocationDTO> locationMap = fenceService.getLocationMap(StringUtils.join(vehicleSnSet, ','));
list.forEach(vls -> {
DeviceLocationDTO location = locationMap.get(vls.getSns());
fenceService.setLocationInfo(vls, location);
});
}
return new PageInfo<>(list);
}
......@@ -1321,7 +1334,7 @@ public class VehicleService extends AbstractCommonService {
if (vehicleDevice == null) {
VehicleDevice unbindVehicleDevice = vehicleDeviceService.getUnbindVehicleDevice(vehicle.getId(), deviceInfoDto.getSn());
// 如果存在已解绑的数据,则直接修改绑定状态
if (unbindVehicleDevice!=null) {
if (unbindVehicleDevice != null) {
log.info("车辆修改绑定状态:{}", JSONObject.toJSONString(unbindVehicleDevice));
unbindVehicleDevice.setBindStatus(ConstantsDevice.BIND_VEHICLE_STATUS);
vehicleDeviceService.updateByPrimaryKey(unbindVehicleDevice);
......@@ -1376,7 +1389,7 @@ public class VehicleService extends AbstractCommonService {
private void updateDeviceActiveStatus(String sn, Long updatedBy, int deviceStatus) {
Device deviceInfo = deviceService.getDeviceBySn(sn);
log.info("设置设备激活状态:{}, updateBy:{}, lastStatus:{}", JSONObject.toJSONString(deviceInfo), updatedBy, deviceStatus);
if (deviceInfo==null) {
if (deviceInfo == null) {
return;
}
......@@ -1384,9 +1397,9 @@ public class VehicleService extends AbstractCommonService {
deviceInfo.setUpdatedBy(updatedBy);
deviceInfo.setUpdatedDate(new Date());
// 激活状态:0未激活,1激活
if (deviceStatus==ConstantsDevice.DEVICE_ACTIVED) {
if (deviceStatus == ConstantsDevice.DEVICE_ACTIVED) {
deviceInfo.setActivateTime(new Date());
} else if (deviceStatus==ConstantsDevice.DEVICE_UN_ACTIVED) {
} else if (deviceStatus == ConstantsDevice.DEVICE_UN_ACTIVED) {
deviceInfo.setActivateTime(null);
}
deviceService.updateDevice(deviceInfo);
......
......@@ -31,6 +31,7 @@
from t_electric_fence_sns
where fence_id = #{fenceId}
and del_flag = 0
order by id
</select>
<select id="selectLinkFenceBySn" resultMap="BaseResultMap">
......
......@@ -158,7 +158,7 @@
<if test="trialType != null">
and tvd.trial_type = #{trialType}
</if>
order by tv.id,tvd.sn
order by tv.created_date desc,tv.id desc
</select>
<select id="selectVehicleLinkSnsByUserId" resultType="cn.com.glsx.admin.modules.model.VehicleLinkSnsDTO">
......
......@@ -12,11 +12,11 @@ import cn.com.glsx.admin.modules.model.param.ElectricFenceBO;
import cn.com.glsx.admin.modules.model.param.TrialDriveShopBO;
import cn.com.glsx.admin.modules.service.ElectricFenceService;
import cn.com.glsx.admin.modules.service.TrialDriveShopService;
import cn.com.glsx.admin.modules.service.VehicleMonitorService;
import cn.com.glsx.admin.modules.utils.JsonUtils;
import cn.com.glsx.admin.modules.utils.fileupload.FileConstants;
import cn.com.glsx.admin.modules.utils.fileupload.FileUploadServerData;
import cn.com.glsx.admin.modules.utils.fileupload.FileUploadUtil;
import cn.com.glsx.admin.modules.service.VehicleMonitorService;
import cn.com.glsx.admin.modules.utils.JsonUtils;
import cn.com.glsx.auth.model.Department;
import cn.com.glsx.auth.model.SyntheticUser;
import cn.com.glsx.auth.utils.ShieldContextHolder;
......@@ -114,7 +114,7 @@ public class AdminApplicationTests {
snsModel.setName("刘建平");
snsModel.setVin("LBEYFAKD2CY146068");
snsModel.setUserTel("13800138000");
snsModel.setTime(new Date());
snsModel.setTime("");
snsModel.setAddress("测试地址");
snList.add(snsModel);
fenceBO.setSnList(snList);
......@@ -207,7 +207,7 @@ public class AdminApplicationTests {
snsModel.setName("刘建平");
snsModel.setVin("LBEYFAKD2CY146068");
snsModel.setUserTel("13800138000");
snsModel.setTime(new Date());
snsModel.setTime("");
snsModel.setAddress("测试地址");
snList.add(snsModel);
shopBO.setSnList(snList);
......@@ -255,7 +255,7 @@ public class AdminApplicationTests {
@Test
public void testUploadFile() throws Exception {
byte[] data = null;
FileInputStream fis = new FileInputStream(FileUtils.getFile("H:\\RequirementsDoc\\3.32.0\\虎哥E盾-3.32.0 平安融租接口协议对接-featurelist.xls"));
FileInputStream fis = new FileInputStream(FileUtils.getFile("C:\\Users\\liuyu\\Desktop\\批量导入关联设备模板.xlsx"));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int len;
byte[] buffer = new byte[1024];
......@@ -265,7 +265,7 @@ public class AdminApplicationTests {
data = baos.toByteArray();
String property = PropertiesUtils.getProperty(FileConstants.FILE_UPLOAD_URL);
System.out.println("property = " + property);
FileUploadServerData uploadServerData = FileUploadUtil.uploadToFileSystem("精准授权模板(车架+业务工单)", data, FileConstants.EXCEL_TYPE_XLSX);
FileUploadServerData uploadServerData = FileUploadUtil.uploadToFileSystem("批量导入关联设备模板", data, FileConstants.EXCEL_TYPE_XLSX);
fis.close();
baos.close();
System.out.println("uploadServerData = " + JSONUtil.toJsonStr(uploadServerData));
......
......@@ -43,7 +43,7 @@ public class RestTest {
snsModel.setName("刘建平");
snsModel.setVin("LBEYFAKD2CY146068");
snsModel.setUserTel("13800138000");
snsModel.setTime(new Date());
snsModel.setTime("");
snsModel.setAddress("测试地址");
snList.add(snsModel);
fenceBO.setSnList(snList);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!