Browse Source

fix:设备树接口

zhongwei
haungxing 7 months ago
parent
commit
235ff2467f
  1. 3
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmInfoEntity.java
  2. 31
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/vo/EmInfoTreeVO.java
  3. 8
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/controller/EmInfoController.java
  4. 4
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.java
  5. 31
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.xml
  6. 2
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java
  7. 9
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java
  8. 2
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/vo/EmInfoAddVo.java
  9. 2
      hzims-service/equipment/src/main/resources/db/2.0.1.sql

3
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;
/**
* 设备负责人

31
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<EmInfoTreeVO> children;
}

8
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<List<EmInfoEntity>> select(@RequestParam(value = "deptId",required = false) Long deptId) {
return R.data(em_infoService.select(deptId));
}
@GetMapping("/getEmInfoTree")
@ApiOperationSupport(order = 14)
@ApiOperation(value = "获取设备树")
public R<List<EmInfoTreeVO>> getEmInfoTree(EmInfoEntity req) {
return R.data(em_infoService.getEmInfoTree(req));
}
}

4
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<EmInfoEntity> {
Integer getMaxEmIndexByPid(@Param("department") Long department, @Param("emGrade") Integer emGrade);
List<SparePartVO> getSparePart(@Param("path") String path, @Param("startTime") String startTime, @Param("endTime") String endTime);
List<EmInfoTreeVO> getEmInfoTree(@Param("ew") Wrapper ew);
}

31
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/mapper/EmInfoMapper.xml

@ -40,6 +40,14 @@
<result column="STATUS" property="status"/>
<result column="CREATE_DEPT" property="createDept"/>
</resultMap>
<resultMap id="emInfoTreeMap" type="com.hnac.hzims.equipment.vo.EmInfoTreeVO">
<result column="id" property="id"/>
<result column="number" property="number"/>
<result column="name" property="name"/>
<collection property="children" column="path" select="getEmInfoChildren" />
</resultMap>
<select id="selectInstenceIdGroup" resultType="java.lang.String">
select INSTANCE_ID from hzims_em_info WHERE IS_DELETED = 0 group by INSTANCE_ID
</select>
@ -143,4 +151,27 @@
</where>
GROUP BY info.id, basic.`CODE`
</select>
<select id="getEmInfoTree" resultMap="emInfoTreeMap">
select `id`,`number`,`name`,`path`
from `hzims_em_info`
<where>
`is_deleted` = 0 and `path` is not null
<if test="ew!=null and ew.sqlSegment!=null and ew.sqlSegment != ''">
and ${ew.sqlSegment}
</if>
</where>
</select>
<select id="getEmInfoChildren" resultMap="emInfoTreeMap">
select `id`,`number`,`name`
from `hzims_em_info`
<where>
`is_deleted` = 0
<if test="path != null">
and `path` = CONCAT(#{path},'/',`NUMBER`)
</if>
</where>
order by `create_time` desc
</select>
</mapper>

2
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/IEmInfoService.java

@ -96,4 +96,6 @@ public interface IEmInfoService extends BaseService<EmInfoEntity> {
List<EmInfoEntity> deviceByPath(String emCode);
List<EmInfoEntity> select(Long deptId);
List<EmInfoTreeVO> getEmInfoTree(EmInfoEntity req);
}

9
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<EmInfoMapper, EmInfoEntit
this.validEmInfo(em_info);
EmInfoEntity infoEntity = em_info.getInfo();
infoEntity.setNumber(emInfoCodePrefix + IdWorker.getId());
infoEntity.setPath("/" + infoEntity.getNumber());
infoEntity.setPath(Optional.ofNullable(em_info.getParentPath()).orElse("") + "/" + infoEntity.getNumber());
if (this.save(infoEntity)) {
this.getStationCodeStoreRedis();
Long infoId = em_info.getInfo().getId();
@ -942,4 +943,10 @@ public class EmInfoServiceImpl extends BaseServiceImpl<EmInfoMapper, EmInfoEntit
);
}
@Override
public List<EmInfoTreeVO> getEmInfoTree(EmInfoEntity req) {
LambdaQueryWrapper<EmInfoEntity> queryWrapper = com.hnac.hzims.common.utils.Condition.getQueryWrapper(EmInfoEntity.class, req);
return this.baseMapper.getEmInfoTree(queryWrapper);
}
}

2
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;
}

2
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
Loading…
Cancel
Save