From abb11eb117721b182a1f86e09c58c4842e50c6cd Mon Sep 17 00:00:00 2001 From: tanghaihao <850814414@qq.com> Date: Fri, 21 Jul 2023 13:50:34 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=AE=9A=E4=B9=89=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=80=92=E5=BA=8F=E6=8E=92=E5=BA=8F=20=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E4=BF=A1=E6=81=AF=E5=AF=BC=E5=85=A5=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E8=B0=83=E6=95=B4=20=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=B7=BB=E5=8A=A0=E6=A0=91=E7=BB=93=E6=9E=84?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=8E=A5=E5=8F=A3=20=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=9F=A5=E7=9C=8B=E5=B7=A1=E6=A3=80=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E6=8E=A5=E5=8F=A3=E6=B7=BB=E5=8A=A0=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hnac/hzims/equipment/entity/EmInfoEntity.java | 9 ++++- .../hnac/hzims/equipment/entity/EmTreeEntity.java | 2 +- .../controller/EmDefinitionController.java | 1 + .../equipment/controller/EmInfoController.java | 47 ++++++++++++++++++++++ .../hnac/hzims/equipment/mapper/EmInfoMapper.java | 2 +- .../hnac/hzims/equipment/mapper/EmInfoMapper.xml | 2 +- .../equipment/service/impl/EmInfoServiceImpl.java | 8 ++-- .../hnac/hzims/equipment/vo/EmInfoContentVO.java | 2 + 8 files changed, 65 insertions(+), 8 deletions(-) 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 @@