Ver código fonte

实现定位查询功能

Simon 2 anos atrás
pai
commit
2dc299bbe5

+ 63 - 52
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/TDataDisplayController.java

@@ -21,17 +21,17 @@ import org.springframework.web.bind.annotation.*;
 import javax.servlet.http.HttpServletResponse;
 import java.text.NumberFormat;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 数据大屏Controller
- * 
+ *
  * @author zhengjie
  * @date 2023-09-08
  */
 @RestController
 @RequestMapping("/system/display")
-public class TDataDisplayController extends BaseController
-{
+public class TDataDisplayController extends BaseController {
     @Autowired
     private ITShouhuanAlarmListService tShouhuanAlarmListService;
 
@@ -51,12 +51,11 @@ public class TDataDisplayController extends BaseController
      * 查询SOS预警处理列表
      */
     @GetMapping("/list")
-    public TableDataInfo list(DataAlarmListDto dataAlarmListDto)
-    {
+    public TableDataInfo list(DataAlarmListDto dataAlarmListDto) {
         startPage();
         List<DataAlarmListDto> list = tShouhuanAlarmListService.selectTShouhuanAlarmList(dataAlarmListDto);
         List<AlarmListDto> alarmListDtoList = new ArrayList<>();
-        for (DataAlarmListDto dto : list){
+        for (DataAlarmListDto dto : list) {
             AlarmListDto alarmListDto = new AlarmListDto();
             alarmListDto.setName(dto.getName());
             alarmListDto.setTelno(dto.getTel_one());
@@ -65,18 +64,16 @@ public class TDataDisplayController extends BaseController
             alarmListDto.setCreatetime(dto.getCreatetime());
             alarmListDtoList.add(alarmListDto);
         }
-        return getDataTable1(alarmListDtoList,tShouhuanAlarmListService.selectTShouhuanAlarmListCount());
+        return getDataTable1(alarmListDtoList, tShouhuanAlarmListService.selectTShouhuanAlarmListCount());
     }
 
     @GetMapping("/count")
-    public AjaxResult count()
-    {
+    public AjaxResult count() {
         return success(tShouhuanAlarmListService.selectTShouhuanAlarmListCount());
     }
 
     @GetMapping("/alarm")
-    public AjaxResult alarm()
-    {
+    public AjaxResult alarm() {
         AlarmStatusDto dto = new AlarmStatusDto();
         dto.setAlarmSOSSolve(tShouhuanAlarmListService.selectTShouhuanAlarmSOSSolve());
         dto.setUn_alarmSOSSolve(tShouhuanAlarmListService.selectTShouhuanAlarmSOS() - tShouhuanAlarmListService.selectTShouhuanAlarmSOSSolve());
@@ -94,22 +91,20 @@ public class TDataDisplayController extends BaseController
     }
 
     @GetMapping("/percent")
-    public AjaxResult percent()
-    {
+    public AjaxResult percent() {
         AlarmPercentDto dto = new AlarmPercentDto();
-        dto.setAlarmSOS(checkPercent(tShouhuanAlarmListService.selectTShouhuanAlarmSOSSolve(),tShouhuanAlarmListService.selectTShouhuanAlarmSOS()));
-        dto.setAlarmRail(checkPercent(tShouhuanAlarmListService.selectTShouhuanAlarmRailSolve(),tShouhuanAlarmListService.selectTShouhuanAlarmRail()));
-        dto.setAlarmFall(checkPercent(tShouhuanAlarmListService.selectTShouhuanAlarmFallSolve(),tShouhuanAlarmListService.selectTShouhuanAlarmFall()));
+        dto.setAlarmSOS(checkPercent(tShouhuanAlarmListService.selectTShouhuanAlarmSOSSolve(), tShouhuanAlarmListService.selectTShouhuanAlarmSOS()));
+        dto.setAlarmRail(checkPercent(tShouhuanAlarmListService.selectTShouhuanAlarmRailSolve(), tShouhuanAlarmListService.selectTShouhuanAlarmRail()));
+        dto.setAlarmFall(checkPercent(tShouhuanAlarmListService.selectTShouhuanAlarmFallSolve(), tShouhuanAlarmListService.selectTShouhuanAlarmFall()));
         int statusSum = tShouhuanAlarmListService.selectTShouhuanAlarmStatus() + tShouhuanAlarmListService.selectTShouhuanAlarmStatusSolve();
-        dto.setAlarmStauts(checkPercent(tShouhuanAlarmListService.selectTShouhuanAlarmStatus(),statusSum));
+        dto.setAlarmStauts(checkPercent(tShouhuanAlarmListService.selectTShouhuanAlarmStatus(), statusSum));
         int alarmAll = tShouhuanAlarmListService.selectTShouhuanAlarmSOSSolve() + tShouhuanAlarmListService.selectTShouhuanAlarmRailSolve() + tShouhuanAlarmListService.selectTShouhuanAlarmRailSolve() + tShouhuanAlarmListService.selectTShouhuanAlarmFallSolve() + tShouhuanAlarmListService.selectTShouhuanAlarmOtherSolve();
-        dto.setAlarmAll(checkPercent(alarmAll,tShouhuanAlarmListService.selectTShouhuanAlarmListCount()));
+        dto.setAlarmAll(checkPercent(alarmAll, tShouhuanAlarmListService.selectTShouhuanAlarmListCount()));
         return success(dto);
     }
 
     @GetMapping("/deviceView")
-    public AjaxResult deviceView()
-    {
+    public AjaxResult deviceView() {
         DeviceViewDto dto = new DeviceViewDto();
         dto.setDeviceCount(tShouhuanAlarmListService.selectTShouhuanAlarmStatus() + tShouhuanAlarmListService.selectTShouhuanAlarmStatusSolve());
         dto.setDeviceOnline(tShouhuanAlarmListService.selectTShouhuanAlarmStatus());
@@ -119,48 +114,68 @@ public class TDataDisplayController extends BaseController
     }
 
     @GetMapping("/deviceType")
-    public AjaxResult deviceType()
-    {
+    public AjaxResult deviceType() {
         Integer total = tDeviceListService.selectDeviceListCount();
         List<DeviceTypeDto> deviceListDto = tDeviceListService.selectDeviceListDto();
-        for (DeviceTypeDto listDto : deviceListDto){
+        for (DeviceTypeDto listDto : deviceListDto) {
             listDto.setDeviceStr(checkDeviceType(listDto.getDevice_model()));
-            listDto.setDevicePercent(checkPercent(listDto.getCount(),total));
+            listDto.setDevicePercent(checkPercent(listDto.getCount(), total));
         }
         AjaxResult ajax = new AjaxResult();
-        ajax.put("list",deviceListDto);
+        ajax.put("list", deviceListDto);
         ajax.put("total", total);
-        return AjaxResult.success("操作成功",ajax);
+        return AjaxResult.success("操作成功", ajax);
     }
 
     @GetMapping("/userAgeAll")
-    public AjaxResult userAgeAll()
-    {
+    public AjaxResult userAgeAll() {
         Integer total = userProfileService.selectuserAgeCount();
         List<UserAgeDto> dtoList = userProfileService.selectuserAgeDto();
         AjaxResult ajax = new AjaxResult();
-        ajax.put("list",dtoList);
+        ajax.put("list", dtoList);
         ajax.put("total", total);
-        return AjaxResult.success("操作成功",ajax);
+        return AjaxResult.success("操作成功", ajax);
     }
 
     @GetMapping("/mapGpsView")
-    public AjaxResult mapGpsView()
-    {
+    public AjaxResult mapGpsView() {
         List<MapGpsDto> dtoList = itShouhuanInfoService.selectMapGpsView();
         AjaxResult ajax = new AjaxResult();
         ajax.put("lnglat", dtoList);
         AjaxResult ajax1 = new AjaxResult();
-        ajax1.put("pointList",ajax);
-        return AjaxResult.success("操作成功",ajax1);
+        ajax1.put("pointList", ajax);
+        return AjaxResult.success("操作成功", ajax1);
+    }
+
+    @GetMapping("/mapGpsViewV2")
+    public AjaxResult mapGpsViewV2() {   //TODO 暂时写在Controller中
+        List<MapGpsDto> dtoList = itShouhuanInfoService.selectMapGpsView();
+        List<AjaxResult> collect = dtoList.stream()
+                .map(mapGpsDto -> {
+                    AjaxResult ajax = new AjaxResult();
+                    List<Float> list = new ArrayList<>();
+                    list.add(mapGpsDto.getGps_long());
+                    list.add(mapGpsDto.getGps_lat());
+                    ajax.put("lnglat", list);
+                    return ajax;
+                }).filter(
+                        person -> {
+                            List<Float> lngList = (List<Float>) person.get("lnglat");
+                            if (lngList != null && !lngList.isEmpty() && lngList.size() >= 2) {
+                                Float lng = lngList.get(0);
+                                Float lat = lngList.get(1);
+                                return lng > 0 && lat > 0;
+                            }
+                            return false;
+                        }).collect(Collectors.toList());
+        return AjaxResult.success("操作成功", collect);
     }
 
     /**
      * 用户新增
      */
     @GetMapping("/addUser")
-    public AjaxResult addUser()
-    {
+    public AjaxResult addUser() {
         List<AddUserDto> dtoList = userProfileService.selectAddUser();
         return success(dtoList);
     }
@@ -169,17 +184,15 @@ public class TDataDisplayController extends BaseController
      * 设备新增
      */
     @GetMapping("/addDevice")
-    public AjaxResult addDevice()
-    {
+    public AjaxResult addDevice() {
         List<AddDeviceDto> dtoList = tDeviceListService.selectAddDevice();
         return success(dtoList);
     }
 
     @GetMapping("/alarmStatusList")
-    public AjaxResult alarmStatusList()
-    {
+    public AjaxResult alarmStatusList() {
         List<AlarmStatusListDto> dtoList = tShouhuanAlarmListService.selectAlarmStatusListDto();
-        for (AlarmStatusListDto dto : dtoList){
+        for (AlarmStatusListDto dto : dtoList) {
             dto.setAlarm_msg(tDeviceListService.checkMessage(dto.getAlarm_type()));
         }
         return success(dtoList);
@@ -189,8 +202,7 @@ public class TDataDisplayController extends BaseController
      * 设备总览
      */
     @GetMapping("/deviceOver")
-    public AjaxResult deviceOver()
-    {
+    public AjaxResult deviceOver() {
         DeviceOverDto dto = new DeviceOverDto();
         dto.setBindDevice(tDeviceListService.selectDeviceListCount());
         dto.setBindUser(tDeviceListService.selectTDeviceListBandUser());
@@ -202,11 +214,10 @@ public class TDataDisplayController extends BaseController
      * 查询SOS预警处理列表
      */
     @GetMapping("/alarmList")
-    public AjaxResult alarmList(DataAlarmListDto dataAlarmListDto)
-    {
+    public AjaxResult alarmList(DataAlarmListDto dataAlarmListDto) {
         List<DataAlarmListDto> list = tShouhuanAlarmListService.selectTShouhuanAlarmList(dataAlarmListDto);
         List<MessageAlarmListDto> messageAlarmListDtoList = new ArrayList<>();
-        for (DataAlarmListDto dto : list){
+        for (DataAlarmListDto dto : list) {
             MessageAlarmListDto alarmListDto = new MessageAlarmListDto();
             alarmListDto.setName(dto.getName());
             alarmListDto.setAlarm_msg(tDeviceListService.checkMessage(dto.getAlarm_type()));
@@ -222,13 +233,13 @@ public class TDataDisplayController extends BaseController
     }
 
 
-
     /**
      * 逆地理编码
+     *
      * @param location
      * @return
      */
-    public String getCounterLocation(String location){
+    public String getCounterLocation(String location) {
 
         Map<String, String> params = new HashMap<>();
         params.put("location", location);
@@ -242,15 +253,15 @@ public class TDataDisplayController extends BaseController
     /**
      * 计算百分比
      */
-    public String checkPercent(int num1, int num2){
+    public String checkPercent(int num1, int num2) {
         NumberFormat numberFormat = NumberFormat.getInstance();
         numberFormat.setMaximumFractionDigits(2);
-        String result = numberFormat.format((float)num1/(float)num2*100);
+        String result = numberFormat.format((float) num1 / (float) num2 * 100);
         return result;
     }
 
-    public String checkDeviceType(Integer device_model){
-        switch (device_model){
+    public String checkDeviceType(Integer device_model) {
+        switch (device_model) {
             case 0:
                 return "S8";
             case 1:

+ 5 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/TSearchLocationInfoController.java

@@ -1,10 +1,14 @@
 package com.ruoyi.web.controller.system;
 
-import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.Collectors;
 import javax.servlet.http.HttpServletResponse;
 
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.bean.BeanUtils;
+import com.ruoyi.system.domain.TShouhuanInfo;
 import com.ruoyi.system.domain.vo.SearchLocationInfoVo;
+import com.ruoyi.system.service.ITShouhuanInfoService;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;

+ 28 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/TSearchLocationInfoVo.java

@@ -86,6 +86,16 @@ public class TSearchLocationInfoVo extends BaseEntity {
      */
     @Excel(name = "客户身份证ID")
     private String user_card_id;
+    /**
+     * 围栏id
+     */
+    @Excel(name = "围栏id")
+    private String fence_id;
+    /**
+     * 围栏gfid
+     */
+    @Excel(name = "围栏gfid")
+    private String fence_gfid;
 
     public Long getId() {
         return id;
@@ -183,6 +193,22 @@ public class TSearchLocationInfoVo extends BaseEntity {
         this.user_card_id = user_card_id;
     }
 
+    public String getFence_id() {
+        return fence_id;
+    }
+
+    public void setFence_id(String fence_id) {
+        this.fence_id = fence_id;
+    }
+
+    public String getFence_gfid() {
+        return fence_gfid;
+    }
+
+    public void setFence_gfid(String fence_gfid) {
+        this.fence_gfid = fence_gfid;
+    }
+
     @Override
     public String toString() {
         return new StringJoiner(", ", TSearchLocationInfoVo.class.getSimpleName() + "[", "]")
@@ -198,6 +224,8 @@ public class TSearchLocationInfoVo extends BaseEntity {
                 .add("user_tel_2='" + user_tel_2 + "'")
                 .add("user_tel_3='" + user_tel_3 + "'")
                 .add("user_card_id='" + user_card_id + "'")
+                .add("fence_id='" + fence_id + "'")
+                .add("fence_gfid='" + fence_gfid + "'")
                 .toString();
     }
 }

+ 179 - 17
ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/SearchLocationInfoVo.java

@@ -3,6 +3,8 @@ package com.ruoyi.system.domain.vo;
 import com.ruoyi.common.annotation.Excel;
 
 import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.List;
 import java.util.StringJoiner;
 
 /**
@@ -33,7 +35,7 @@ public class SearchLocationInfoVo implements Serializable {
      * 用户名电话号
      */
     @Excel(name = "用户名电话号")
-    private String userPhone;
+    private String deviceTel;
 
     /**
      * 查询内容
@@ -47,17 +49,78 @@ public class SearchLocationInfoVo implements Serializable {
     @Excel(name = "查询到的设备ID")
     private Long deviceId;
 
+    /**
+     * 查询到的设备手机号
+     */
+    @Excel(name = "查询到的设备手机号")
+    private String devicetel;
+
+    /**
+     * 查询到的设备手机号
+     */
+    @Excel(name = "查询到的设备身份证号")
+    private String deviceCardId;
+
     /**
      * 查询到的设备编号
      */
     @Excel(name = "查询到的设备编号")
-    private Long deviceIdCode;
+    private String deviceIdCode;
+
+    /**
+     * 查询到的会员姓名"
+     */
+    @Excel(name = "查询到的会员姓名")
+    private String userNickName;
+    /**
+     * 查询到的会员性别"
+     */
+    @Excel(name = "查询到的会员性别")
+    private Integer userGender;
+    /**
+     * 查询到的会员性别"
+     */
+    @Excel(name = "查询到的会员性别")
+    private Integer userTel1;
+    /**
+     * 查询到的紧急联系人"
+     */
+    @Excel(name = "查询到的紧急联系人")
+    private String userTel2;
+    /**
+     * 查询到的紧急联系人"
+     */
+    @Excel(name = "查询到的紧急联系人")
+    private String userTel3;
+    /**
+     * 查询到的紧急联系人"
+     */
+    @Excel(name = "查询到的紧急联系人")
+    private String userCardId;
+
+    /**
+     * 查询到的围栏id"
+     */
+    @Excel(name = "查询到的围栏id")
+    private Long fenceId;
 
     /**
      * 电子围栏VO
      */
     @Excel(name = "电子围栏VO")
-    private ElectronicFenceVo electronicFenceVo;
+    private List<AMapFenceVo> aMapFenceList;
+
+    /**
+     * 经度
+     */
+    @Excel(name = "经度")
+    private BigDecimal gpsLong;
+
+    /**
+     * 纬度
+     */
+    @Excel(name = "纬度")
+    private BigDecimal gpsLat;
 
     public Long getId() {
         return id;
@@ -83,12 +146,12 @@ public class SearchLocationInfoVo implements Serializable {
         this.userName = userName;
     }
 
-    public String getUserPhone() {
-        return userPhone;
+    public String getDeviceTel() {
+        return deviceTel;
     }
 
-    public void setUserPhone(String userPhone) {
-        this.userPhone = userPhone;
+    public void setDeviceTel(String deviceTel) {
+        this.deviceTel = deviceTel;
     }
 
     public String getSearchValue() {
@@ -107,20 +170,108 @@ public class SearchLocationInfoVo implements Serializable {
         this.deviceId = deviceId;
     }
 
-    public Long getDeviceIdCode() {
+    public String getDevicetel() {
+        return devicetel;
+    }
+
+    public void setDevicetel(String devicetel) {
+        this.devicetel = devicetel;
+    }
+
+    public String getDeviceCardId() {
+        return deviceCardId;
+    }
+
+    public void setDeviceCardId(String deviceCardId) {
+        this.deviceCardId = deviceCardId;
+    }
+
+    public String getDeviceIdCode() {
         return deviceIdCode;
     }
 
-    public void setDeviceIdCode(Long deviceIdCode) {
+    public void setDeviceIdCode(String deviceIdCode) {
         this.deviceIdCode = deviceIdCode;
     }
 
-    public ElectronicFenceVo getElectronicFenceVo() {
-        return electronicFenceVo;
+    public String getUserNickName() {
+        return userNickName;
+    }
+
+    public void setUserNickName(String userNickName) {
+        this.userNickName = userNickName;
+    }
+
+    public Integer getUserGender() {
+        return userGender;
+    }
+
+    public void setUserGender(Integer userGender) {
+        this.userGender = userGender;
+    }
+
+    public Integer getUserTel1() {
+        return userTel1;
+    }
+
+    public void setUserTel1(Integer userTel1) {
+        this.userTel1 = userTel1;
+    }
+
+    public String getUserTel2() {
+        return userTel2;
+    }
+
+    public void setUserTel2(String userTel2) {
+        this.userTel2 = userTel2;
+    }
+
+    public String getUserTel3() {
+        return userTel3;
+    }
+
+    public void setUserTel3(String userTel3) {
+        this.userTel3 = userTel3;
+    }
+
+    public String getUserCardId() {
+        return userCardId;
+    }
+
+    public void setUserCardId(String userCardId) {
+        this.userCardId = userCardId;
+    }
+
+    public Long getFenceId() {
+        return fenceId;
+    }
+
+    public void setFenceId(Long fenceId) {
+        this.fenceId = fenceId;
+    }
+
+    public List<AMapFenceVo> getaMapFenceList() {
+        return aMapFenceList;
+    }
+
+    public void setaMapFenceList(List<AMapFenceVo> aMapFenceList) {
+        this.aMapFenceList = aMapFenceList;
+    }
+
+    public BigDecimal getGpsLong() {
+        return gpsLong;
+    }
+
+    public void setGpsLong(BigDecimal gpsLong) {
+        this.gpsLong = gpsLong;
+    }
+
+    public BigDecimal getGpsLat() {
+        return gpsLat;
     }
 
-    public void setElectronicFenceVo(ElectronicFenceVo electronicFenceVo) {
-        this.electronicFenceVo = electronicFenceVo;
+    public void setGpsLat(BigDecimal gpsLat) {
+        this.gpsLat = gpsLat;
     }
 
     @Override
@@ -129,11 +280,22 @@ public class SearchLocationInfoVo implements Serializable {
                 .add("id=" + id)
                 .add("userId=" + userId)
                 .add("userName='" + userName + "'")
-                .add("userPhone='" + userPhone + "'")
+                .add("deviceTel='" + deviceTel + "'")
                 .add("searchValue='" + searchValue + "'")
-                .add("deviceId=" + deviceId)
-                .add("deviceIdCode=" + deviceIdCode)
-                .add("electronicFenceVo=" + electronicFenceVo)
+                .add("deviceId='" + deviceId + "'")
+                .add("devicetel='" + devicetel + "'")
+                .add("deviceCardId='" + deviceCardId + "'")
+                .add("deviceIdCode='" + deviceIdCode + "'")
+                .add("userNickName='" + userNickName + "'")
+                .add("userGender=" + userGender)
+                .add("userTel1=" + userTel1)
+                .add("userTel2='" + userTel2 + "'")
+                .add("userTel3='" + userTel3 + "'")
+                .add("userCardId='" + userCardId + "'")
+                .add("fenceId=" + fenceId)
+                .add("aMapFenceList=" + aMapFenceList)
+                .add("gpsLong=" + gpsLong)
+                .add("gpsLat=" + gpsLat)
                 .toString();
     }
 }

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TShouhuanInfoMapper.java

@@ -73,4 +73,6 @@ public interface TShouhuanInfoMapper
      * @return 结果
      */
     public List<MapGpsDto> selectMapGpsView();
+
+    List<TShouhuanInfo> selectTShouhuanInfoListBydeviceIdCode(String deviceIdCode);
 }

+ 8 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/ITShouhuanInfoService.java

@@ -28,6 +28,14 @@ public interface ITShouhuanInfoService
      */
     public List<TShouhuanInfo> selectTShouhuanInfoList(TShouhuanInfo tShouhuanInfo);
 
+    /**
+     * 查询手环信息 实时数据列表
+     *
+     * @param deviceIdCode 手环信息 实时数据
+     * @return 手环信息 实时数据集合
+     */
+    public List<TShouhuanInfo> selectTShouhuanInfoListBydeviceIdCode(String deviceIdCode);
+
     /**
      * 新增手环信息 实时数据
      * 

+ 66 - 17
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TSearchLocationInfoServiceImpl.java

@@ -7,18 +7,18 @@ import java.util.stream.Collectors;
 import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.TimeStampUtils;
+import com.ruoyi.common.utils.bean.BeanUtils;
+import com.ruoyi.system.domain.*;
+import com.ruoyi.system.domain.vo.AMapFenceVo;
 import com.ruoyi.system.domain.vo.SearchLocationInfoVo;
-import com.ruoyi.system.mapper.TUserProfileMapper;
-import com.ruoyi.system.service.ITDeviceListService;
-import com.ruoyi.system.service.ITShouhuanInfoService;
-import com.ruoyi.system.service.ITUserProfileService;
+import com.ruoyi.system.mapper.TElectronicFenceMapper;
+import com.ruoyi.system.service.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.ruoyi.system.mapper.TSearchLocationInfoMapper;
-import com.ruoyi.system.domain.TSearchLocationInfo;
-import com.ruoyi.system.service.ITSearchLocationInfoService;
 
 /**
  * 【请填写功能名称】Service业务层处理
@@ -37,10 +37,16 @@ public class TSearchLocationInfoServiceImpl implements ITSearchLocationInfoServi
     private ITDeviceListService tDeviceListService;
 
     @Autowired
-    private ITShouhuanInfoService itShouhuanInfoService;
+    private ITUserProfileService userProfileService;
 
     @Autowired
-    private ITUserProfileService userProfileService;
+    private ITShouhuanInfoService shouhuanInfoService;
+    @Autowired
+    private TElectronicFenceMapper tElectronicFenceMapper;
+    @Autowired
+    private ITElectronicFenceKeyService iElectronicFenceKeyService;
+    @Autowired
+    private ITElectronicFenceServiceService iElectronicFenceServiceService;
 
     /**
      * 查询【请填写功能名称】
@@ -120,14 +126,57 @@ public class TSearchLocationInfoServiceImpl implements ITSearchLocationInfoServi
         }
         //查询内容
         String searchValue = tSearchLocationInfo.getSearchValue();
-        List<SearchLocationInfoVo> searchLocationInfoVoList = tSearchLocationInfoMapper.selectSearchLocationInfoVoBySearchValue(searchValue);
-//        searchLocationInfoVoList.stream()
-//                .filter(predicate -> {
-//                    if (predicate.getDeviceIdCode() > 0) {
-//
-//                    }
-//                })
-//                .collect(Collectors.toList());
-        return searchLocationInfoVoList;
+        //查找所有搜索内容
+        List<SearchLocationInfoVo> list = tSearchLocationInfoMapper.selectSearchLocationInfoVoBySearchValue(searchValue);
+        if (list != null && !list.isEmpty()) {
+            return list.stream().map(
+                    mapper -> {
+                        //配置设备最新定位(经纬度)
+                        List<TShouhuanInfo> shouhuanInfos = shouhuanInfoService.selectTShouhuanInfoListBydeviceIdCode(mapper.getDeviceIdCode());
+                        if (shouhuanInfos != null && !shouhuanInfos.isEmpty()) {
+                            TShouhuanInfo shouhuanInfo = shouhuanInfos.get(0);
+                            mapper.setGpsLong(shouhuanInfo.getGpsLong());
+                            mapper.setGpsLat(shouhuanInfo.getGpsLat());
+                        }
+                        //配置设备电子围栏
+                        mapper.setaMapFenceList(getAMapFenceByDeviceId(mapper.getDeviceId()));
+                        return mapper;
+                    }
+            ).collect(Collectors.toList());
+        }
+        return list;
+    }
+
+    /**
+     * 配置设备电子围栏
+     *
+     * @param deviceId
+     * @return
+     */
+    private List<AMapFenceVo> getAMapFenceByDeviceId(Long deviceId) {
+        List<TElectronicFence> tElectronicFences = tElectronicFenceMapper.selectTElectronicFenceListByDeviceId(deviceId);
+        if (tElectronicFences != null && !tElectronicFences.isEmpty()) {
+            return tElectronicFences.stream()
+                    .map(tElectronicFence -> {
+                        TElectronicFenceService fenceService = iElectronicFenceServiceService.selectTElectronicFenceServiceById(tElectronicFence.getServiceId());
+                        TElectronicFenceKey tElectronicFenceKey = iElectronicFenceKeyService.selectTElectronicFenceKeyById(fenceService.getKeyId());
+                        AMapFenceVo aMapFenceVo = new AMapFenceVo();
+                        aMapFenceVo.setId(tElectronicFence.getId());
+                        aMapFenceVo.setKey(tElectronicFenceKey.getAmapKey());
+                        aMapFenceVo.setSid(fenceService.getAmapSid());
+                        aMapFenceVo.setGfid(tElectronicFence.getGfid());
+                        aMapFenceVo.setUserId(tElectronicFence.getUserId());
+                        aMapFenceVo.setDeviceId(tElectronicFence.getDeviceId());
+                        aMapFenceVo.setName(tElectronicFence.getName());
+                        aMapFenceVo.setStartTime(TimeStampUtils.convertToTodayDateTimeToMillis(tElectronicFence.getStartTime().getTime()));
+                        aMapFenceVo.setEndTime(TimeStampUtils.convertToTodayDateTimeToMillis(tElectronicFence.getEndTime().getTime()));
+                        aMapFenceVo.setState(tElectronicFence.geteState());
+                        aMapFenceVo.setType(tElectronicFence.geteType());
+                        aMapFenceVo.setDesc(tElectronicFence.geteDesc());
+                        return aMapFenceVo;
+                    })
+                    .collect(Collectors.toList());
+        }
+        return null;
     }
 }

+ 5 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TShouhuanInfoServiceImpl.java

@@ -45,6 +45,11 @@ public class TShouhuanInfoServiceImpl implements ITShouhuanInfoService
         return tShouhuanInfoMapper.selectTShouhuanInfoList(tShouhuanInfo);
     }
 
+    @Override
+    public List<TShouhuanInfo> selectTShouhuanInfoListBydeviceIdCode(String deviceIdCode) {
+        return tShouhuanInfoMapper.selectTShouhuanInfoListBydeviceIdCode(deviceIdCode);
+    }
+
     /**
      * 新增手环信息 实时数据
      * 

+ 30 - 21
ruoyi-system/src/main/resources/mapper/system/TSearchLocationInfoMapper.xml

@@ -13,19 +13,20 @@
         <result property="updateTime" column="update_time"/>
     </resultMap>
 
-    <resultMap type="TSearchLocationInfoVo" id="TSearchLocationInfoVoResult">
+    <resultMap type="SearchLocationInfoVo" id="TSearchLocationInfoVoResult">
         <result property="id" column="id"/>
-        <result property="device_id" column="device_id"/>
-        <result property="user_id" column="user_id"/>
-        <result property="device_tel" column="device_tel"/>
-        <result property="device_card_id" column="device_card_id"/>
-        <result property="device_id_code" column="device_id_code"/>
-        <result property="user_nick_name" column="user_nick_name"/>
-        <result property="user_gender" column="user_gender"/>
-        <result property="user_tel_1" column="user_tel_1"/>
-        <result property="user_tel_2" column="user_tel_2"/>
-        <result property="user_tel_3" column="user_tel_3"/>
-        <result property="user_card_id" column="user_card_id"/>
+        <result property="deviceId" column="device_id"/>
+        <result property="userId" column="user_id"/>
+        <result property="deviceTel" column="device_tel"/>
+        <result property="deviceCardId" column="device_card_id"/>
+        <result property="deviceIdCode" column="device_id_code"/>
+        <result property="userNickName" column="user_nick_name"/>
+        <result property="userGender" column="user_gender"/>
+        <result property="userTel1" column="user_tel_1"/>
+        <result property="userTel2" column="user_tel_2"/>
+        <result property="userTel3" column="user_tel_3"/>
+        <result property="userCardId" column="user_card_id"/>
+        <result property="fenceId" column="fence_id"/>
     </resultMap>
 
     <sql id="selectTSearchLocationInfoVo">
@@ -44,12 +45,17 @@
                t2.tel_one   AS user_tel_1,
                t2.tel_two   AS user_tel_2,
                t2.tel_three AS user_tel_3,
-               t2.sfzid     AS user_card_id
+               t2.sfzid     AS user_card_id,
+               t3.id		AS fence_id
         FROM t_device_list t1
-                 JOIN
+        JOIN
              t_user_profile t2
-             ON
-                 t1.userid = t2.id
+        ON
+             t1.userid = t2.id
+        JOIN
+             t_electronic_fence t3
+        ON
+             t1.id	= t3.device_id
     </sql>
 
     <select id="selectTSearchLocationInfoList" parameterType="TSearchLocationInfo"
@@ -70,11 +76,14 @@
     <select id="selectSearchLocationInfoVoBySearchValue" parameterType="String" resultMap="TSearchLocationInfoVoResult">
         <include refid="selectTSearchLocationInfoMainVo"/>
         WHERE
-        t2.`name` LIKE concat('%', #{searchValue}, '%')
-        OR
-        t1.telno LIKE concat('%', #{searchValue}, '%')
-        OR
-        t1.device_id LIKE concat('%', #{searchValue}, '%')
+        t3.del_state = 0
+        AND(
+            t2.`name` LIKE concat('%', #{searchValue}, '%')
+            OR
+            t1.telno LIKE concat('%', #{searchValue}, '%')
+            OR
+            t1.device_id LIKE concat('%', #{searchValue}, '%')
+        )
     </select>
 
     <insert id="insertTSearchLocationInfo" parameterType="TSearchLocationInfo" useGeneratedKeys="true" keyProperty="id">

+ 6 - 0
ruoyi-system/src/main/resources/mapper/system/TShouhuanInfoMapper.xml

@@ -102,6 +102,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectMapGpsView" resultType="com.ruoyi.system.domain.dto.MapGpsDto">
         SELECT gps_long,gps_lat FROM `t_shouhuan_info`
     </select>
+
+    <select id="selectTShouhuanInfoListBydeviceIdCode" parameterType="string"  resultMap="TShouhuanInfoResult">
+        <include refid="selectTShouhuanInfoVo"/>
+        where device_id_code = #{device_id_code}
+    </select>
+
     <insert id="insertTShouhuanInfo" parameterType="TShouhuanInfo" useGeneratedKeys="true" keyProperty="id">
         insert into t_shouhuan_info
         <trim prefix="(" suffix=")" suffixOverrides=",">