diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmInfoEntity.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmInfoEntity.java index 3581439..088f2db 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmInfoEntity.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmInfoEntity.java @@ -127,12 +127,17 @@ public class EmInfoEntity extends TenantEntity { @JsonSerialize(nullsUsing = NullSerializer.class) private Long manager; /** - * 设备等级(01:一类设备,02:二类设备,03:三类设备) + * 设备类别(01:一类设备,02:二类设备,03:三类设备) */ - @ApiModelProperty(value = "设备等级(01:一类设备,02:二类设备,03:三类设备)") + @ApiModelProperty(value = "设备类别(01:一类设备,02:二类设备,03:三类设备)") @EnumValue(strValues = {"01", "02", "03"}, message = "值只能为01、02、03") private String gradeCode; /** + *设备等级(0:一级设备,1:二级设备,2:三级设备) + */ + @ApiModelProperty(value = "设备等级(0:一级设备,1:二级设备,2:三级设备)") + private Integer emGrade; + /** * 安装时间 */ @ApiModelProperty(value = "安装时间") diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmTreeEntity.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmTreeEntity.java index 87027f2..6053448 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmTreeEntity.java +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmTreeEntity.java @@ -51,7 +51,7 @@ public class EmTreeEntity extends TenantEntity { @ApiModelProperty(value = "所属组织") private Long refOreanization; - @ApiModelProperty(value = "设备等级") + @ApiModelProperty(value = "设备等级(0:一级设备,1:二级设备,2:三级设备)") private Integer emGrade; @ApiModelProperty(value = "巡检标准") diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmDefinitionController.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmDefinitionController.java index b746354..2fc3672 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmDefinitionController.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmDefinitionController.java @@ -65,6 +65,7 @@ public class EmDefinitionController extends BladeController { if (Func.isNotEmpty(emDefinition.getStatus())) { wrapper.eq(EmDefinitionEntity::getStatus, emDefinition.getStatus()); } + wrapper.orderByDesc(EmDefinitionEntity::getCreateTime); IPage pages = emDefinitionService.page(Condition.getPage(query), wrapper); for (EmDefinitionEntity definition : pages.getRecords()) { User createUser = UserCache.getUser(definition.getCreateUser()); diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmInfoController.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmInfoController.java index aedbbf7..c7eaa21 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmInfoController.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmInfoController.java @@ -9,6 +9,7 @@ import com.hnac.hzims.common.logs.enums.BusinessType; import com.hnac.hzims.common.logs.enums.OperatorType; import com.hnac.hzims.equipment.dto.DeviceTreeDTO; import com.hnac.hzims.equipment.entity.EmInfoEntity; +import com.hnac.hzims.equipment.entity.EmTreeEntity; import com.hnac.hzims.equipment.service.IEmInfoService; import com.hnac.hzims.equipment.vo.EmInfoAddVo; import com.hnac.hzims.equipment.vo.EmInfoContentVO; @@ -35,6 +36,7 @@ import springfox.documentation.annotations.ApiIgnore; import javax.validation.Valid; import java.util.*; +import java.util.stream.Collectors; /** * 设备控制器 @@ -176,6 +178,51 @@ public class EmInfoController extends BladeController { } /** + * 获取所有设备列表(树结构) + * @param refDept 站点机构 + * @param name 设备名称 + * @return + */ + @ApiLog + @RequestMapping(value = "/getEmInfoTreeList") + @ApiOperationSupport(order = 3) + @ApiOperation(value = "获取所有设备列表(树结构)", notes = "传入设备id") + public R> getEmInfoTreeList(Long refDept, String name) { + List resultList = new ArrayList<>(); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + if (Func.isNotEmpty(refDept)) { + wrapper.eq(EmInfoEntity::getDepartment, refDept); + } + if (Func.isNotEmpty(name)) { + wrapper.like(EmInfoEntity::getName, name); + } + List list = em_infoService.list(wrapper); + if (Func.isNotEmpty(name)) { + for (EmInfoEntity emInfo : list) { + LambdaQueryWrapper sonWrapper = new LambdaQueryWrapper<>(); + sonWrapper.likeRight(EmInfoEntity::getPath, emInfo.getPath()); + List sonList = em_infoService.list(sonWrapper); + // 把List结构数据转换成树结构 + Map> emInfoMap = sonList.stream().collect(Collectors.groupingBy(EmInfoEntity::getGpid)); + sonList.forEach(emTree -> { + emTree.setInfoChildren(emInfoMap.get(emTree.getId())); + }); + sonList = sonList.stream().filter(item -> item.getGpid().equals(emInfo.getGpid())).collect(Collectors.toList()); + resultList.addAll(sonList); + } + } else { + // 把List结构数据转换成树结构 + Map> emInfoMap = list.stream().collect(Collectors.groupingBy(EmInfoEntity::getGpid)); + list.forEach(emTree -> { + emTree.setInfoChildren(emInfoMap.get(emTree.getId())); + }); + resultList = list.stream().filter(item -> item.getGpid().equals(0L)).collect(Collectors.toList()); + } + + return R.data(resultList); + } + + /** * 新增 */ @PostMapping("/save") diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.java index 387e821..3f2cb5c 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.java @@ -50,7 +50,7 @@ public interface EmInfoMapper extends UserDataScopeBaseMapper { List listByTenantId(@Param("tenantId") String tenantId); - Integer getMaxEmIndexByPid(@Param("pid") Long pid); + Integer getMaxEmIndexByPid(@Param("department") Long department, @Param("emGrade") Integer emGrade); List getSparePart(@Param("path") String path, @Param("startTime") String startTime, @Param("endTime") String endTime); } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.xml b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.xml index e90bc2a..db7e24d 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.xml +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.xml @@ -117,7 +117,7 @@