fix (farm): 微信端设备统计接口
-
This commit is contained in:
@@ -77,6 +77,15 @@ public class WxController {
|
|||||||
this.companyConf = companyConf;
|
this.companyConf = companyConf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/device-info/statistics")
|
||||||
|
@Operation(summary = "获取设备统计")
|
||||||
|
@Parameter(name = "baseId", description = "基地编号")
|
||||||
|
public CommonResult<List<DeviceStatisticsInfoRespVO>> getDeviceStatisticsList(@RequestParam("baseId") String baseId) {
|
||||||
|
List<DeviceStatisticsInfoRespVO> res = deviceInfoService.getDeviceStatisticsList(baseId);
|
||||||
|
|
||||||
|
return success(res);
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/device-info/get")
|
@GetMapping("/device-info/get")
|
||||||
@Operation(summary = "获取设备信息")
|
@Operation(summary = "获取设备信息")
|
||||||
@Parameter(name = "baseId", description = "基地编号")
|
@Parameter(name = "baseId", description = "基地编号")
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package cn.iocoder.yudao.module.farm.controller.admin.wx.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: TODO
|
||||||
|
* @author: binda
|
||||||
|
* @date: 2025/10/15 22:33
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class DeviceStatisticsInfoRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "设备分类名称")
|
||||||
|
private String deviceTypeName;
|
||||||
|
@Schema(description = "设备总数")
|
||||||
|
private int totalNum;
|
||||||
|
@Schema(description = "在线设备数")
|
||||||
|
private int onlineNum;
|
||||||
|
@Schema(description = "离线设备数")
|
||||||
|
private int offlineNum;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.farm.controller.admin.deviceinfo.vo.v2.DeviceStat
|
|||||||
import cn.iocoder.yudao.module.farm.controller.admin.deviceinfo.vo.v2.UpdateDevicePropertiesForWfReqVO;
|
import cn.iocoder.yudao.module.farm.controller.admin.deviceinfo.vo.v2.UpdateDevicePropertiesForWfReqVO;
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.digitalcockpit.vo.DeviceInfoRespVO;
|
import cn.iocoder.yudao.module.farm.controller.admin.digitalcockpit.vo.DeviceInfoRespVO;
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.digitalcockpit.vo.DeviceMonitorDataRespVO;
|
import cn.iocoder.yudao.module.farm.controller.admin.digitalcockpit.vo.DeviceMonitorDataRespVO;
|
||||||
|
import cn.iocoder.yudao.module.farm.controller.admin.wx.vo.DeviceStatisticsInfoRespVO;
|
||||||
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.module.farm.manager.equipmentproducer.dto.RealTimeDataResponse;
|
import cn.iocoder.yudao.module.farm.manager.equipmentproducer.dto.RealTimeDataResponse;
|
||||||
@@ -139,4 +140,10 @@ public interface DeviceInfoService {
|
|||||||
List<DeviceMonitorDataRespVO> deviceList();
|
List<DeviceMonitorDataRespVO> deviceList();
|
||||||
List<DeviceMonitorDataRespVO> deviceList(String plotId);
|
List<DeviceMonitorDataRespVO> deviceList(String plotId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备统计信息
|
||||||
|
* @param baseId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<DeviceStatisticsInfoRespVO> getDeviceStatisticsList(String baseId);
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,7 @@ import cn.iocoder.yudao.module.farm.controller.admin.deviceinfo.vo.v2.DeviceStat
|
|||||||
import cn.iocoder.yudao.module.farm.controller.admin.deviceinfo.vo.v2.UpdateDevicePropertiesForWfReqVO;
|
import cn.iocoder.yudao.module.farm.controller.admin.deviceinfo.vo.v2.UpdateDevicePropertiesForWfReqVO;
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.digitalcockpit.vo.DeviceInfoRespVO;
|
import cn.iocoder.yudao.module.farm.controller.admin.digitalcockpit.vo.DeviceInfoRespVO;
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.digitalcockpit.vo.DeviceMonitorDataRespVO;
|
import cn.iocoder.yudao.module.farm.controller.admin.digitalcockpit.vo.DeviceMonitorDataRespVO;
|
||||||
|
import cn.iocoder.yudao.module.farm.controller.admin.wx.vo.DeviceStatisticsInfoRespVO;
|
||||||
import cn.iocoder.yudao.module.farm.dal.dataobject.baseinfo.BaseInfoDO;
|
import cn.iocoder.yudao.module.farm.dal.dataobject.baseinfo.BaseInfoDO;
|
||||||
import cn.iocoder.yudao.module.farm.dal.dataobject.deviceclassify.DeviceClassifyDO;
|
import cn.iocoder.yudao.module.farm.dal.dataobject.deviceclassify.DeviceClassifyDO;
|
||||||
import cn.iocoder.yudao.module.farm.dal.dataobject.plotinfo.PlotInfoDO;
|
import cn.iocoder.yudao.module.farm.dal.dataobject.plotinfo.PlotInfoDO;
|
||||||
@@ -43,10 +44,7 @@ import cn.iocoder.yudao.framework.security.core.LoginUser;
|
|||||||
|
|
||||||
import cn.iocoder.yudao.module.farm.dal.mysql.deviceinfo.DeviceInfoMapper;
|
import cn.iocoder.yudao.module.farm.dal.mysql.deviceinfo.DeviceInfoMapper;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
@@ -372,6 +370,46 @@ public class DeviceInfoServiceImpl implements DeviceInfoService {
|
|||||||
return execute(doList);
|
return execute(doList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DeviceStatisticsInfoRespVO> getDeviceStatisticsList(String baseId) {
|
||||||
|
|
||||||
|
LambdaQueryWrapperX<DeviceInfoDO> wrapperX = new LambdaQueryWrapperX<>();
|
||||||
|
wrapperX.eq(DeviceInfoDO::getBaseId, baseId);
|
||||||
|
wrapperX.eq(DeviceInfoDO::getDeleted, CommonConstants.NO_CODE);
|
||||||
|
|
||||||
|
List<DeviceInfoDO> doList = deviceInfoMapper.selectList(wrapperX);
|
||||||
|
Map<String, List<DeviceInfoDO>> orderedGroup = doList.stream()
|
||||||
|
.collect(Collectors.groupingBy(
|
||||||
|
DeviceInfoDO::getDeviceType,
|
||||||
|
LinkedHashMap::new,
|
||||||
|
Collectors.toList()
|
||||||
|
));
|
||||||
|
|
||||||
|
|
||||||
|
List<DeviceStatisticsInfoRespVO> res = new ArrayList<>();
|
||||||
|
Map<String, String> typeNameMap = deviceClassifyService.getTypeNameMap();
|
||||||
|
for (Map.Entry<String, List<DeviceInfoDO>> entry : orderedGroup.entrySet()) {
|
||||||
|
String key = entry.getKey();
|
||||||
|
String keyName = typeNameMap.get(key);
|
||||||
|
|
||||||
|
List<DeviceInfoDO> list = entry.getValue();
|
||||||
|
|
||||||
|
int onlineCount = list.stream()
|
||||||
|
.filter(device -> device.getDeviceState() == 1)
|
||||||
|
.mapToInt(DeviceInfoDO::getDeviceState)
|
||||||
|
.sum();
|
||||||
|
|
||||||
|
int offlineCount = list.stream()
|
||||||
|
.filter(device -> device.getDeviceState() != 1)
|
||||||
|
.mapToInt(DeviceInfoDO::getDeviceState)
|
||||||
|
.sum();
|
||||||
|
|
||||||
|
res.add(new DeviceStatisticsInfoRespVO(keyName,list.size(),onlineCount,offlineCount));
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
private List<DeviceMonitorDataRespVO> execute(List<DeviceInfoDO> doList) {
|
private List<DeviceMonitorDataRespVO> execute(List<DeviceInfoDO> doList) {
|
||||||
Map<String, List<DeviceInfoDO>> groupedByDeviceType = doList.stream().collect(Collectors.groupingBy(DeviceInfoDO::getDeviceType));
|
Map<String, List<DeviceInfoDO>> groupedByDeviceType = doList.stream().collect(Collectors.groupingBy(DeviceInfoDO::getDeviceType));
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public class PlotInfoServiceImpl implements PlotInfoService {
|
|||||||
plotInfo.setTenantId(String.valueOf(user.getTenantId()));
|
plotInfo.setTenantId(String.valueOf(user.getTenantId()));
|
||||||
plotInfoMapper.insert(plotInfo);
|
plotInfoMapper.insert(plotInfo);
|
||||||
|
|
||||||
PlotLesseeSaveReqVO plotLesseeSaveReqVO = createReqVO.getPlotLesseeSaveReqVO();
|
PlotLesseeSaveReqVO plotLesseeSaveReqVO = createReqVO.getPlotLessee();
|
||||||
PlotLesseeDO plotLesseeDO = BeanUtils.toBean(plotLesseeSaveReqVO, PlotLesseeDO.class);
|
PlotLesseeDO plotLesseeDO = BeanUtils.toBean(plotLesseeSaveReqVO, PlotLesseeDO.class);
|
||||||
insertLessee(plotLesseeDO, createReqVO.getBaseId(), plotInfo.getId(), plotInfo.getPlotName());
|
insertLessee(plotLesseeDO, createReqVO.getBaseId(), plotInfo.getId(), plotInfo.getPlotName());
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ public class PlotInfoServiceImpl implements PlotInfoService {
|
|||||||
Set<String> collect = doList.stream().map(e-> e.getLeaseIdCard()).collect(Collectors.toSet());
|
Set<String> collect = doList.stream().map(e-> e.getLeaseIdCard()).collect(Collectors.toSet());
|
||||||
|
|
||||||
// 指定当前的租户状态为: 已租
|
// 指定当前的租户状态为: 已租
|
||||||
PlotLesseeSaveReqVO plotLesseeSaveReqVO = updateReqVO.getPlotLesseeSaveReqVO();
|
PlotLesseeSaveReqVO plotLesseeSaveReqVO = updateReqVO.getPlotLessee();
|
||||||
String idCard = plotLesseeSaveReqVO.getLeaseIdCard();
|
String idCard = plotLesseeSaveReqVO.getLeaseIdCard();
|
||||||
PlotLesseeDO plotLesseeDO = BeanUtils.toBean(plotLesseeSaveReqVO, PlotLesseeDO.class);
|
PlotLesseeDO plotLesseeDO = BeanUtils.toBean(plotLesseeSaveReqVO, PlotLesseeDO.class);
|
||||||
if (collect.contains(idCard)) {
|
if (collect.contains(idCard)) {
|
||||||
@@ -180,7 +180,7 @@ public class PlotInfoServiceImpl implements PlotInfoService {
|
|||||||
|
|
||||||
PlotInfoDO plotInfoDO = this.getPlotInfo(id);
|
PlotInfoDO plotInfoDO = this.getPlotInfo(id);
|
||||||
PlotLesseeInfoRespVO plotLesseeDetailsRespVO = BeanUtils.toBean(plotInfoDO, PlotLesseeInfoRespVO.class);
|
PlotLesseeInfoRespVO plotLesseeDetailsRespVO = BeanUtils.toBean(plotInfoDO, PlotLesseeInfoRespVO.class);
|
||||||
plotLesseeDetailsRespVO.setPlotLesseeDetailsRespVO(subLesseeInfo);
|
plotLesseeDetailsRespVO.setPlotLessee(subLesseeInfo);
|
||||||
plotLesseeDetailsRespVO.setPlotLeaseStatusName(LEASE_STATUS_MAP.get(plotLesseeDetailsRespVO.getPlotLeaseStatus()));
|
plotLesseeDetailsRespVO.setPlotLeaseStatusName(LEASE_STATUS_MAP.get(plotLesseeDetailsRespVO.getPlotLeaseStatus()));
|
||||||
return plotLesseeDetailsRespVO;
|
return plotLesseeDetailsRespVO;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user