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 6263434..a7d69a7 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 @@ -12,6 +12,8 @@ import lombok.Builder; import lombok.Data; import lombok.EqualsAndHashCode; import org.hibernate.validator.constraints.Range; +import org.springblade.core.mp.support.QueryField; +import org.springblade.core.mp.support.SqlCondition; import org.springblade.core.tenant.mp.TenantEntity; import org.springblade.core.tool.utils.DateUtil; import org.springframework.format.annotation.DateTimeFormat; @@ -121,6 +123,7 @@ public class EmInfoEntity extends TenantEntity { */ @ApiModelProperty(value = "设备负责部门") @JsonSerialize(nullsUsing = NullSerializer.class) + @QueryField(condition = SqlCondition.EQUAL) private Long department; /** * 设备负责人 diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/vo/EmInfoTreeVO.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/vo/EmInfoTreeVO.java new file mode 100644 index 0000000..43483bd --- /dev/null +++ b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/vo/EmInfoTreeVO.java @@ -0,0 +1,31 @@ +package com.hnac.hzims.equipment.vo; + +import com.hnac.hzims.common.pojo.Tree; +import com.hnac.hzims.equipment.entity.EmInfoEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @Author: huangxing + * @Date: 2024/04/23 17:08 + */ +@Data +@ApiModel("设备树信息") +public class EmInfoTreeVO { + + @ApiModelProperty("设备ID") + private Long id; + + @ApiModelProperty("设备编号") + private String number; + + @ApiModelProperty("设备名称") + private String name; + + @ApiModelProperty("子设备") + private List children; + +} 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 ca50cc4..30f817f 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 @@ -13,6 +13,7 @@ import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.service.IEmInfoService; import com.hnac.hzims.equipment.vo.EmInfoAddVo; import com.hnac.hzims.equipment.vo.EmInfoContentVO; +import com.hnac.hzims.equipment.vo.EmInfoTreeVO; import com.hnac.hzims.equipment.vo.EmInfoVO; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.feign.IStationClient; @@ -428,4 +429,11 @@ public class EmInfoController extends BladeController { public R> select(@RequestParam(value = "deptId",required = false) Long deptId) { return R.data(em_infoService.select(deptId)); } + + @GetMapping("/getEmInfoTree") + @ApiOperationSupport(order = 14) + @ApiOperation(value = "获取设备树") + public R> getEmInfoTree(EmInfoEntity req) { + return R.data(em_infoService.getEmInfoTree(req)); + } } 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 f9b826b..b252014 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 @@ -1,8 +1,10 @@ package com.hnac.hzims.equipment.mapper; +import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.vo.EmInfoExtendVo; import com.hnac.hzims.equipment.vo.DeviceVO; +import com.hnac.hzims.equipment.vo.EmInfoTreeVO; import com.hnac.hzims.equipment.vo.EminfoAndEmParamVo; import com.hnac.hzims.spare.vo.SparePartVO; import org.apache.ibatis.annotations.Param; @@ -53,4 +55,6 @@ public interface EmInfoMapper extends UserDataScopeBaseMapper { Integer getMaxEmIndexByPid(@Param("department") Long department, @Param("emGrade") Integer emGrade); List getSparePart(@Param("path") String path, @Param("startTime") String startTime, @Param("endTime") String endTime); + + List getEmInfoTree(@Param("ew") Wrapper ew); } 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 e9d738a..d57a7d1 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 @@ -40,6 +40,14 @@ + + + + + + + + @@ -143,4 +151,27 @@ GROUP BY info.id, basic.`CODE` + + + + diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java index 662b737..ead9dee 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java @@ -96,4 +96,6 @@ public interface IEmInfoService extends BaseService { List deviceByPath(String emCode); List select(Long deptId); + + List getEmInfoTree(EmInfoEntity req); } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java index be202cf..fb6fb04 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java @@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.google.common.collect.Lists; +import com.hnac.hzims.common.support.utils.Condition; import com.hnac.hzims.equipment.EquipmentContants; import com.hnac.hzims.equipment.dto.DeviceTreeDTO; import com.hnac.hzims.equipment.dto.EmTreeIdsDTO; @@ -171,7 +172,7 @@ public class EmInfoServiceImpl extends BaseServiceImpl getEmInfoTree(EmInfoEntity req) { + LambdaQueryWrapper queryWrapper = com.hnac.hzims.common.utils.Condition.getQueryWrapper(EmInfoEntity.class, req); + return this.baseMapper.getEmInfoTree(queryWrapper); + } + } diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/vo/EmInfoAddVo.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/vo/EmInfoAddVo.java index af3329b..bc39243 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/vo/EmInfoAddVo.java +++ b/hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/vo/EmInfoAddVo.java @@ -32,5 +32,7 @@ public class EmInfoAddVo implements Serializable { private String modelName; @ApiModelProperty(value = "母版类型") private Integer modelType; + @ApiModelProperty(value = "父设备path") + private String parentPath; } diff --git a/hzims-service/equipment/src/main/resources/db/2.0.1.sql b/hzims-service/equipment/src/main/resources/db/2.0.1.sql new file mode 100644 index 0000000..1905851 --- /dev/null +++ b/hzims-service/equipment/src/main/resources/db/2.0.1.sql @@ -0,0 +1,2 @@ +-- 批量处理设备历史数据,将其设为一级设备 +update hzims_em_info set `path` = CONCAT('/',`NUMBER`) where `path` is null and `is_deleted` = 0 \ No newline at end of file