fix (farm): 设备中心
- 基地与地块列表
This commit is contained in:
@@ -111,8 +111,8 @@ public class BaseInfoController {
|
|||||||
|
|
||||||
@GetMapping("/base/plot/list")
|
@GetMapping("/base/plot/list")
|
||||||
@Operation(summary = "基地-地块列表")
|
@Operation(summary = "基地-地块列表")
|
||||||
public CommonResult<List<BaseInfoForWxRespVO>> getBasePlotList() {
|
public CommonResult<List<BaseAndPlotNamesRespVO>> getBasePlotList() {
|
||||||
List<BaseInfoForWxRespVO> res = baseInfoService.getBaseListForWx();
|
List<BaseAndPlotNamesRespVO> res = baseInfoService.getBasePlotList();
|
||||||
return success(res);
|
return success(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package cn.iocoder.yudao.module.farm.controller.admin.baseinfo.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description:
|
||||||
|
* @author: binda
|
||||||
|
* @date: 2025/9/22 10:02
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class BaseAndPlotNamesRespVO {
|
||||||
|
private String baseId;
|
||||||
|
private String baseName;
|
||||||
|
private String basePoint;
|
||||||
|
private BigDecimal baseArea;
|
||||||
|
private List<BaseAndPlotNamesRespVO.PLotInfo> pLotInfos;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public static class PLotInfo{
|
||||||
|
@Schema(description = "地块ID")
|
||||||
|
private String plotId;
|
||||||
|
@Schema(description = "地块名称")
|
||||||
|
private String plotName;
|
||||||
|
@Schema(description = "地块面积")
|
||||||
|
private BigDecimal plotArea;
|
||||||
|
@Schema(description = "地块坐标")
|
||||||
|
private String plotPoint;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -32,6 +32,7 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode DEVICE_INFO_NOT_EXISTS_FOR_ALARM_NOTICE_RECORD= new ErrorCode(1_050_004_004, "获取设备报警通知记录失败");
|
ErrorCode DEVICE_INFO_NOT_EXISTS_FOR_ALARM_NOTICE_RECORD= new ErrorCode(1_050_004_004, "获取设备报警通知记录失败");
|
||||||
ErrorCode DEVICE_INFO_NOT_EXISTS_FOR_WF_LOGIN= new ErrorCode(1_050_004_005, "水肥机登录失败");
|
ErrorCode DEVICE_INFO_NOT_EXISTS_FOR_WF_LOGIN= new ErrorCode(1_050_004_005, "水肥机登录失败");
|
||||||
ErrorCode DEVICE_TYPE_ERROR= new ErrorCode(1_050_004_006, "未找到对应的设备类型");
|
ErrorCode DEVICE_TYPE_ERROR= new ErrorCode(1_050_004_006, "未找到对应的设备类型");
|
||||||
|
ErrorCode DEVICE_CLASS_TYPE_ERROR= new ErrorCode(1_050_004_007, "设备分类不存在");
|
||||||
|
|
||||||
// ========== 设备地块关系 1-050-005-000 ==========
|
// ========== 设备地块关系 1-050-005-000 ==========
|
||||||
ErrorCode DEVICE_PLOT_RELATION_NOT_EXISTS = new ErrorCode(1_050_005_000, "设备地块关系不存在");
|
ErrorCode DEVICE_PLOT_RELATION_NOT_EXISTS = new ErrorCode(1_050_005_000, "设备地块关系不存在");
|
||||||
|
|||||||
@@ -107,4 +107,10 @@ public interface BaseInfoService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<BaseInfoForWxRespVO> getBaseListForWx();
|
List<BaseInfoForWxRespVO> getBaseListForWx();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 基地 and 地块 坐标
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<BaseAndPlotNamesRespVO> getBasePlotList();
|
||||||
}
|
}
|
||||||
@@ -405,4 +405,28 @@ public class BaseInfoServiceImpl implements BaseInfoService {
|
|||||||
}).toList();
|
}).toList();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BaseAndPlotNamesRespVO> getBasePlotList() {
|
||||||
|
|
||||||
|
long tenantId = getLoginUser().getTenantId();
|
||||||
|
LambdaQueryWrapperX<BaseInfoDO> wrapperX = new LambdaQueryWrapperX<>();
|
||||||
|
wrapperX.eq(BaseInfoDO::getTenantId, tenantId);
|
||||||
|
wrapperX.eq(BaseInfoDO::getDeleted, CommonConstants.NO_CODE);
|
||||||
|
List<BaseInfoDO> list = baseInfoMapper.selectList(wrapperX);
|
||||||
|
|
||||||
|
return list.stream().map(e -> {
|
||||||
|
String baseId = e.getId();
|
||||||
|
List<PlotInfoDO> plotInfos = plotInfoService.getPlotInfos(baseId);
|
||||||
|
List<BaseAndPlotNamesRespVO.PLotInfo> pLotInfos = plotInfos.stream().map(p -> new BaseAndPlotNamesRespVO.PLotInfo(p.getId(), p.getPlotName(), p.getPlotArea(),p.getPoint())).toList();
|
||||||
|
|
||||||
|
BaseAndPlotNamesRespVO b = new BaseAndPlotNamesRespVO();
|
||||||
|
b.setBaseId(e.getId());
|
||||||
|
b.setBaseName(e.getName());
|
||||||
|
b.setBaseArea(e.getArea());
|
||||||
|
b.setBasePoint(e.getPoint());
|
||||||
|
b.setPLotInfos(pLotInfos);
|
||||||
|
return b;
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
|
|
||||||
import cn.iocoder.yudao.module.farm.dal.dataobject.deviceinfo.DeviceInfoDO;
|
import cn.iocoder.yudao.module.farm.dal.dataobject.deviceinfo.DeviceInfoDO;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
||||||
|
|
||||||
@@ -27,9 +26,8 @@ import cn.iocoder.yudao.module.farm.dal.mysql.deviceinfo.DeviceInfoMapper;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.diffList;
|
|
||||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
|
||||||
|
import static cn.iocoder.yudao.module.farm.enums.ErrorCodeConstants.DEVICE_CLASS_TYPE_ERROR;
|
||||||
import static cn.iocoder.yudao.module.farm.enums.ErrorCodeConstants.DEVICE_INFO_NOT_EXISTS;
|
import static cn.iocoder.yudao.module.farm.enums.ErrorCodeConstants.DEVICE_INFO_NOT_EXISTS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -101,15 +99,17 @@ private void validateDeviceInfoExists(String id) {
|
|||||||
@Override
|
@Override
|
||||||
public DeviceInfoDO getDeviceInfo(String id) {
|
public DeviceInfoDO getDeviceInfo(String id) {
|
||||||
DeviceInfoDO deviceInfo = deviceInfoMapper.selectById(id);
|
DeviceInfoDO deviceInfo = deviceInfoMapper.selectById(id);
|
||||||
if (deviceInfo != null) {
|
if (deviceInfo == null) {
|
||||||
// 触发图片集合转换,确保返回的DO对象包含转换后的图片集合
|
throw exception(DEVICE_INFO_NOT_EXISTS);
|
||||||
// deviceInfo.getImageList();
|
}
|
||||||
// deviceInfo.getAlarmImageList();
|
|
||||||
// deviceInfo.getOfflineImageList();
|
|
||||||
DeviceClassifyDO dc = deviceClassifyMapper.selectOne(DeviceClassifyDO::getId, deviceInfo.getDeviceType());
|
DeviceClassifyDO dc = deviceClassifyMapper.selectOne(DeviceClassifyDO::getId, deviceInfo.getDeviceType());
|
||||||
|
if (dc == null) {
|
||||||
|
throw exception(DEVICE_CLASS_TYPE_ERROR);
|
||||||
|
}
|
||||||
deviceInfo.setImage(dc.getImage());
|
deviceInfo.setImage(dc.getImage());
|
||||||
deviceInfo.setImageList(dc.getImageList());
|
deviceInfo.setImageList(dc.getImageList());
|
||||||
}
|
|
||||||
|
// TODO: 2025/9/21 获取设备的实时/历史数据
|
||||||
return deviceInfo;
|
return deviceInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user