package org.jeecg.modules.mdc.model; import io.swagger.annotations.ApiModel; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; import org.jeecg.modules.mdc.entity.MdcEquipment; import org.jeecg.modules.system.model.MdcProductionTreeModel; import org.jeecg.modules.system.model.SysDepartTreeModel; import java.io.Serializable; import java.util.ArrayList; import java.util.List; /** * 设备树 * * @author: LiuS * @create: 2023-03-29 17:11 */ @Data @EqualsAndHashCode(callSuper = false) @Accessors(chain = true) @ApiModel(value = "设备树结构数据实体", description = "设备") public class MdcEquipmentTree implements Serializable { private static final long serialVersionUID = -5202127219834067917L; /** * 前端数据树中的key */ private String key; /** * 前端数据树中的value */ private String value; /** * 前端数据树中的title */ private String title; /** * 是否是子节点 */ private boolean isLeaf; /** * 设备编号(前端定位用) */ private String equipmentId; /** * 设备名称(前端定位用) */ private String equipmentName; /** * 父级id(前端请求用) */ private String parentId; private List children = new ArrayList<>(); /** * 将设备数据放在该对象中 * @param mdcEquipment * @return */ public MdcEquipmentTree convert(MdcEquipment mdcEquipment) { this.key = mdcEquipment.getId(); this.value = mdcEquipment.getId(); this.title = mdcEquipment.getEquipmentId() + "/" + mdcEquipment.getEquipmentName(); this.equipmentId = mdcEquipment.getEquipmentId(); this.equipmentName = mdcEquipment.getEquipmentName(); this.isLeaf = true; return this; } /** * 将SysDepartTreeModel的部分数据放在该对象当中 * @param treeModel * @return */ public MdcEquipmentTree convertByDepart(SysDepartTreeModel treeModel) { this.key = treeModel.getId(); this.value = treeModel.getId(); this.title = treeModel.getDepartName(); return this; } /** * 将mdcProductionTreeModel的部分数据放在该对象当中 * @param treeModel * @return */ public MdcEquipmentTree convertByProduction(MdcProductionTreeModel treeModel) { this.key = treeModel.getId(); this.value = treeModel.getId(); this.title = treeModel.getProductionName(); return this; } }