|
|
@@ -7,8 +7,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.zksy.base.domain.*;
|
|
|
-import com.zksy.base.mapper.*;
|
|
|
import com.zksy.base.alarm.domain.WarningThreshold;
|
|
|
import com.zksy.base.alarm.mapper.WarningThresholdMapper;
|
|
|
import com.zksy.base.domain.*;
|
|
|
@@ -18,9 +16,11 @@ import com.zksy.base.manhole.mapper.ManholeDataMapper;
|
|
|
import com.zksy.base.mapper.*;
|
|
|
import com.zksy.base.service.EquipmentBaseService;
|
|
|
import com.zksy.common.exception.ServiceException;
|
|
|
+import com.zksy.manhole.dto.in.EquipmentCountByTypeInDTO;
|
|
|
import com.zksy.manhole.dto.in.ManholeDeviceListInDTO;
|
|
|
import com.zksy.manhole.dto.in.ManholeDevicePageInDTO;
|
|
|
import com.zksy.manhole.dto.out.EquipmentBaseOutDTO;
|
|
|
+import com.zksy.manhole.dto.out.EquipmentCountByTypeOutDTO;
|
|
|
import com.zksy.manhole.dto.out.EquipmentStatusOutDTO;
|
|
|
import com.zksy.manhole.dto.out.ManholeDataOutDTO;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -31,7 +31,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
-import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -610,4 +609,57 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
|
|
|
|
|
|
return this.listByIds(equipmentIds);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据设备类别分组统计设备数量
|
|
|
+ * @param inDTO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<EquipmentCountByTypeOutDTO> countByType(EquipmentCountByTypeInDTO inDTO) {
|
|
|
+ log.info("根据设备类别分组统计设备数量-入参:{}", inDTO);
|
|
|
+ String equipmentTypeId = inDTO.getEquipmentTypeId();
|
|
|
+ List<EquipmentCountByTypeOutDTO> result = new ArrayList<>();
|
|
|
+ if(StringUtils.isEmpty(equipmentTypeId)){
|
|
|
+ // 设备类别ID为空:统计所有类别的设备数量
|
|
|
+ List<EquipmentType> allTypes = equipmentTypeMapper.selectList(null);
|
|
|
+ for(EquipmentType type : allTypes){
|
|
|
+ long count = this.count(new LambdaQueryWrapper<EquipmentBase>()
|
|
|
+ .eq(EquipmentBase::getEquipmentTypeId, type.getTypeId()));
|
|
|
+ EquipmentCountByTypeOutDTO outDTO = new EquipmentCountByTypeOutDTO();
|
|
|
+ outDTO.setEquipmentTypeId(type.getTypeId());
|
|
|
+ outDTO.setEquipmentTypeName(type.getTypeName());
|
|
|
+ outDTO.setDeviceCount((int) count);
|
|
|
+ result.add(outDTO);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 查询子类别
|
|
|
+ List<EquipmentType> childTypes = equipmentTypeMapper.selectList(
|
|
|
+ new LambdaQueryWrapper<EquipmentType>()
|
|
|
+ .eq(EquipmentType::getParentTypeId, equipmentTypeId));
|
|
|
+ if(CollUtil.isNotEmpty(childTypes)){
|
|
|
+ // 有子类别:按子类别分组统计
|
|
|
+ for(EquipmentType childType : childTypes){
|
|
|
+ long count = this.count(new LambdaQueryWrapper<EquipmentBase>()
|
|
|
+ .eq(EquipmentBase::getEquipmentTypeId, childType.getTypeId()));
|
|
|
+ EquipmentCountByTypeOutDTO outDTO = new EquipmentCountByTypeOutDTO();
|
|
|
+ outDTO.setEquipmentTypeId(childType.getTypeId());
|
|
|
+ outDTO.setEquipmentTypeName(childType.getTypeName());
|
|
|
+ outDTO.setDeviceCount((int) count);
|
|
|
+ result.add(outDTO);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 无子类别:直接统计该类别的设备数量
|
|
|
+ EquipmentType equipmentType = equipmentTypeMapper.selectById(equipmentTypeId);
|
|
|
+ long count = this.count(new LambdaQueryWrapper<EquipmentBase>()
|
|
|
+ .eq(EquipmentBase::getEquipmentTypeId, equipmentTypeId));
|
|
|
+ EquipmentCountByTypeOutDTO outDTO = new EquipmentCountByTypeOutDTO();
|
|
|
+ outDTO.setEquipmentTypeId(equipmentTypeId);
|
|
|
+ outDTO.setEquipmentTypeName(equipmentType != null ? equipmentType.getTypeName() : null);
|
|
|
+ outDTO.setDeviceCount((int) count);
|
|
|
+ result.add(outDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|