yangys
2025-09-17 3907579a69079b5ee462d17799e3995d9cd77fd4
blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/entity/NcNode.java
@@ -1,9 +1,14 @@
package org.springblade.mdm.program.entity;
import com.alibaba.excel.util.StringUtils;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import org.springblade.core.mp.base.BizEntity;
import org.springblade.mdm.flow.entity.FlowProgramFile;
import java.util.Date;
@Setter
@Getter
@@ -38,7 +43,11 @@
   /**
    * 加工机床
    */
   public static final String TYPE_MACHINE_CODE = "50";
   //public static final String TYPE_MACHINE_CODE = "50";
   /**
    * 加工机床
    */
   public static final String TYPE_MACHINE_GROUP = "50";
   /**
    * 程序包名
    */
@@ -48,6 +57,28 @@
    * 程序文件
    */
   public static final String TYPE_PROGRAM_FILE = "70";
   /**
    * 未锁定
    */
   public static final int UNLOCK = 0;
   /**
    * 已锁定
    */
   public static final int LOCKED = 1;
   /**
    * 文件节点文件类型:程序
    */
   public static final String FILE_CATEGOAY_PROGRAM = "program";
   /**
    * 文件节点文件类型:其他
    */
   public static final String FILE_CATEGORY_OTHER = "other";
   /**
    * 文件节点文件类型:子程序
    */
   public static final String FILE_CATEGORY_SUBPROGRAM = "subprogram";
   private String name;
   private Long parentId;
@@ -61,8 +92,10 @@
    */
   private String machineCode;
   /**
    * 机床组字典吗
    */
   private String machineGroupCode;
   /**
    * 工序,如“精铣”
    */
@@ -93,11 +126,11 @@
   /**
    * 是否固化
    */
   private Integer isCured;
   private Integer isCured = 0;
   /**
    * 过期日期
    */
   //private LocalDate expireDate;
   private Date expireDate;
   /**
    * 是否锁定
    */
@@ -125,6 +158,11 @@
   private String programNo;
   /**
    * 历史序列号
    */
   private Long hisSerial;
   /**
    * 流程程序文件id,只有程序文件(70)类型的节点有此值
    */
   private Long flowProgramFileId;
@@ -133,4 +171,88 @@
    * 审批时的流程实例id,只有程序包节点有这个字段值
    */
   private String processInstanceId;
   /**
    * 偏离单号
    */
   private String deviation;
   /**
    * 版本号,更新一次(入升版,dnc导入),就会+1
    */
   private Integer versionNumber = 1;
   transient FlowProgramFile flowProgramFile;
   /**
    * 是否是偏离程序
    * @return 是否偏离
    */
   public boolean isDeviationProgram(){
      return StringUtils.isNotBlank(this.deviation);
   }
   /**
    * 根据当前版本号,获取新增版本号
    * @return 升级后的版本号
    */
   public int genNewVersionNumber(){
      if(this.versionNumber == null){
         return 1;
      }else{
         return this.versionNumber + 1;
      }
   }
   /**
    * 是否在有效期内
    * @return 是否
    */
   public boolean withinValidityPeriod() {
      if(expireDate == null){
         return true;
      }
      return expireDate.getTime() > System.currentTimeMillis();
   }
   /**
    * 是否已经固化
    * @return 是否
    */
   public boolean hasCured() {
      return this.isCured != null && this.isCured == 1;
   }
   public void upgradeVersionNumber() {
      this.versionNumber = genNewVersionNumber();
   }
   /**
    * 锁定节点
    */
   public void lock() {
      this.isLocked = LOCKED;
   }
   /**
    * 锁定节点
    * @param remark 锁定原因
    */
   public void lock(String remark) {
      this.isLocked = LOCKED;
      this.remark = remark;
   }
   public void unlock() {
      this.isLocked = UNLOCK;
   }
   /**
    * 是否已锁定
    * @return 是否
    */
    public boolean hasLocked() {
      return this.isLocked != null && this.isLocked == LOCKED;
    }
   public String subNodeParentIds(){
      return this.parentIds+","+this.getId();
   }
}