diff --git a/social/src/main/java/com/jiagutech/ams/controller/DeviceController.java b/social/src/main/java/com/jiagutech/ams/controller/DeviceController.java index 367b9a5..87aca55 100644 --- a/social/src/main/java/com/jiagutech/ams/controller/DeviceController.java +++ b/social/src/main/java/com/jiagutech/ams/controller/DeviceController.java @@ -7,6 +7,7 @@ import com.jiagutech.ams.model.common.PageResult; import com.jiagutech.ams.model.common.R; import com.jiagutech.ams.model.dto.DeviceDTO; import com.jiagutech.ams.model.request.JobPageRequest; +import com.jiagutech.ams.model.response.DeviceDetail; import com.jiagutech.ams.model.response.DeviceInfo; import com.jiagutech.ams.service.DeviceService; import io.swagger.v3.oas.annotations.Operation; @@ -57,5 +58,10 @@ public class DeviceController { return R.ok(deviceService.deviceList()); } + @Operation(summary = "获取设备详情") + @GetMapping("/detail/{deviceId}") + public R detail(@PathVariable Integer deviceId) { + return R.ok(deviceService.deviceDetail(deviceId)); + } } diff --git a/social/src/main/java/com/jiagutech/ams/mapper/DeviceMapper.java b/social/src/main/java/com/jiagutech/ams/mapper/DeviceMapper.java index 4db59b3..34c6e61 100644 --- a/social/src/main/java/com/jiagutech/ams/mapper/DeviceMapper.java +++ b/social/src/main/java/com/jiagutech/ams/mapper/DeviceMapper.java @@ -1,8 +1,11 @@ package com.jiagutech.ams.mapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.jiagutech.ams.model.dto.DeviceDTO; +import com.jiagutech.ams.model.response.DeviceDetail; import com.jiagutech.ams.model.response.DeviceInfo; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -10,4 +13,5 @@ public interface DeviceMapper extends BaseMapper { List queryDeviceList(Long detpId); + DeviceDetail selectDetail(@Param("ew") QueryWrapper queryWrapper); } diff --git a/social/src/main/java/com/jiagutech/ams/model/response/DeviceDetail.java b/social/src/main/java/com/jiagutech/ams/model/response/DeviceDetail.java new file mode 100644 index 0000000..f9068aa --- /dev/null +++ b/social/src/main/java/com/jiagutech/ams/model/response/DeviceDetail.java @@ -0,0 +1,48 @@ +package com.jiagutech.ams.model.response; + + +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +@Data +@NoArgsConstructor +@Accessors(chain = true) +public class DeviceDetail { + + private Integer deviceId; + + private String deviceName; + + private String licensePlate; + + private String boxNum; + + private Long farmerId; + + private String farmerName; + + private String farmerPhone; + + private String operatorName; + + private Long operatorId; + + private String operatorPhone; + + private double lng; + + private double lat; + + private Integer deptId; + + private String deptName; + + private Long jobId; + + private int typeId; + + private String typeName; + + +} diff --git a/social/src/main/java/com/jiagutech/ams/service/DeviceService.java b/social/src/main/java/com/jiagutech/ams/service/DeviceService.java index 77ce3db..1c81258 100644 --- a/social/src/main/java/com/jiagutech/ams/service/DeviceService.java +++ b/social/src/main/java/com/jiagutech/ams/service/DeviceService.java @@ -3,6 +3,7 @@ package com.jiagutech.ams.service; import com.jiagutech.ams.model.common.PageRequest; import com.jiagutech.ams.model.common.PageResult; import com.jiagutech.ams.model.dto.DeviceDTO; +import com.jiagutech.ams.model.response.DeviceDetail; import com.jiagutech.ams.model.response.DeviceInfo; import java.util.List; @@ -13,4 +14,6 @@ public interface DeviceService { PageResult page(PageRequest pageRequest); List deviceList(); + + DeviceDetail deviceDetail(Integer deviceId); } diff --git a/social/src/main/java/com/jiagutech/ams/service/DeviceServiceImpl.java b/social/src/main/java/com/jiagutech/ams/service/DeviceServiceImpl.java index 2e8f297..b3f1852 100644 --- a/social/src/main/java/com/jiagutech/ams/service/DeviceServiceImpl.java +++ b/social/src/main/java/com/jiagutech/ams/service/DeviceServiceImpl.java @@ -1,5 +1,6 @@ package com.jiagutech.ams.service; +import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson2.JSON; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; @@ -13,6 +14,7 @@ import com.jiagutech.ams.model.common.PageRequest; import com.jiagutech.ams.model.common.PageResult; import com.jiagutech.ams.model.dto.DeviceDTO; import com.jiagutech.ams.model.dto.RoleDTO; +import com.jiagutech.ams.model.response.DeviceDetail; import com.jiagutech.ams.model.response.DeviceInfo; import com.jiagutech.ams.utils.LoginUtil; import lombok.RequiredArgsConstructor; @@ -120,4 +122,20 @@ public class DeviceServiceImpl implements DeviceService { return deviceInfos; } + + + @Override + public DeviceDetail deviceDetail(Integer deviceId) { + + QueryWrapper queryWrapper = Wrappers.query(); + queryWrapper.eq("d.id", deviceId); + DeviceDetail deviceDetail = deviceMapper.selectDetail(queryWrapper); + if (ObjectUtil.isNotEmpty(deviceDetail.getJobId())) { + String track = stringRedisTemplate.opsForValue().get("mtrack:" + deviceDetail.getBoxNum()); + TrackDataJG trackDataJG = JSON.parseObject(track, TrackDataJG.class); + assert trackDataJG != null; + deviceDetail.setLat(trackDataJG.getLat()).setLng(trackDataJG.getLng()); + } + return deviceDetail; + } } diff --git a/social/src/main/resources/mapper/DeviceMapper.xml b/social/src/main/resources/mapper/DeviceMapper.xml index 01ecb11..ec3705e 100644 --- a/social/src/main/resources/mapper/DeviceMapper.xml +++ b/social/src/main/resources/mapper/DeviceMapper.xml @@ -11,4 +11,38 @@ left join ams_job_info j on d.id = j.device_id where d.dept_id = #{deptId} + \ No newline at end of file