Browse Source

完善功能

master
zhangyeguang 3 months ago
parent
commit
fd56846c1e
  1. 6
      social/src/main/java/com/jiagutech/ams/controller/DeviceController.java
  2. 4
      social/src/main/java/com/jiagutech/ams/mapper/DeviceMapper.java
  3. 48
      social/src/main/java/com/jiagutech/ams/model/response/DeviceDetail.java
  4. 3
      social/src/main/java/com/jiagutech/ams/service/DeviceService.java
  5. 18
      social/src/main/java/com/jiagutech/ams/service/DeviceServiceImpl.java
  6. 34
      social/src/main/resources/mapper/DeviceMapper.xml

6
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<DeviceDetail> detail(@PathVariable Integer deviceId) {
return R.ok(deviceService.deviceDetail(deviceId));
}
}

4
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<DeviceDTO> {
List<DeviceInfo> queryDeviceList(Long detpId);
DeviceDetail selectDetail(@Param("ew") QueryWrapper<DeviceDetail> queryWrapper);
}

48
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;
}

3
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<DeviceDTO> page(PageRequest<Void> pageRequest);
List<DeviceInfo> deviceList();
DeviceDetail deviceDetail(Integer deviceId);
}

18
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<DeviceDetail> 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;
}
}

34
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}
</select>
<select id="selectDetail" resultType="com.jiagutech.ams.model.response.DeviceDetail">
select d.id as deviceId,
d.name as deviceName,
d.license_plate,
d.box_num,
d.dept_id,
d.lng,
d.lat,
de.name as deptName,
j.id as job_id,
j.farmer_id,
u1.nick_name as farmerName,
case u1.phone
when null then u1.contact_phone
when '' then u1.contact_phone
else u1.phone end as farmerPhone,
j.operator_id,
u2.nick_name as operatorName,
u2.phone,
j.job_type typeId,
t.name as typeName
from ams_device_info d
left join ams_dept de on d.dept_id = de.id
left join ams_job_info j on j.device_id = d.id
and j.status = 1
left join ams_user u1 on j.farmer_id = u1.id
and u1.del_flag = 0
left join ams_user u2 on j.operator_id = u2.id
and u2.del_flag = 0
left join ams_job_type t on j.job_type = t.id
${ew.getCustomSqlSegment}
</select>
</mapper>
Loading…
Cancel
Save