yangys
2024-01-19 1f01f18c6cff2edca99b95474fcab52d5a1409e0
更换id生成器
已修改13个文件
已添加3个文件
293 ■■■■■ 文件已修改
mdc-parent/mdc-collect/pom.xml 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
mdc-parent/mdc-collect/src/main/java/com/qianwen/mdc/config/WFGIdGeneratorConfig.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
mdc-parent/mdc-collect/src/main/java/com/qianwen/mdc/config/WfgProperties.java 89 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
mdc-parent/mdc-collect/src/main/java/com/qianwen/mdc/domain/Machine.java 46 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
mdc-parent/mdc-collect/src/main/java/com/qianwen/mdc/domain/MachineFocas.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
mdc-parent/mdc-collect/src/main/java/com/qianwen/mdc/domain/MachineModbus.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
mdc-parent/mdc-collect/src/main/java/com/qianwen/mdc/domain/MachineOpcua.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
mdc-parent/mdc-collect/src/main/java/com/qianwen/mdc/domain/MachineProtocol.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
mdc-parent/mdc-collect/src/main/java/com/qianwen/mdc/domain/MachiningData.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
mdc-parent/mdc-collect/src/main/java/com/qianwen/mdc/mapper/MachiningDataMapper.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
mdc-parent/mdc-collect/src/main/java/com/qianwen/mdc/mybatis/MybatisPlusWFGIdGenerator.java 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
mdc-parent/mdc-collect/src/main/java/com/qianwen/mdc/service/jdmon/JDMonThread.java 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
mdc-parent/mdc-collect/src/main/java/com/qianwen/mdc/service/siemenslib/SiemensLibThread.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
mdc-parent/mdc-show/pom.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
mdc-parent/mdc-show/src/main/java/com/qianwen/mdc/domain/MachineAccount.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
mdc-parent/pom.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
mdc-parent/mdc-collect/pom.xml
@@ -107,7 +107,10 @@
        </dependency>
        <!--mybatis-->
        <dependency>
            <groupId>io.github.lmlx66</groupId>
            <artifactId>yitter-idgenerator-spring-boot-starter</artifactId>
        </dependency>
        <!--nekohtml-->
        <dependency>
            <groupId>net.sourceforge.nekohtml</groupId>
mdc-parent/mdc-collect/src/main/java/com/qianwen/mdc/config/WFGIdGeneratorConfig.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,34 @@
package com.qianwen.mdc.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.hy.properties.IdGeneratorOptions;
/**
 * æ¼‚移雪花算法的option生成配置
 */
@Configuration
public class WFGIdGeneratorConfig {
    @Autowired
    private WfgProperties wftProperties;
    @Bean(name="idGeneratorOptions") //bean的name必须为该值!!!
    public IdGeneratorOptions buildOptions() {
        IdGeneratorOptions options = new IdGeneratorOptions();
        options.setBaseTime(wftProperties.getBaseTime());
        options.setWorkerId(wftProperties.getWorkerId());
        options.setDataCenterId((short)wftProperties.getDataCenterId());
        options.setDataCenterIdBitLength(wftProperties.getDataCenterIdBitLength());
        options.setMaxSeqNumber(wftProperties.getMaxSeqNumber());
        options.setMethod(wftProperties.getMethod());
        options.setMinSeqNumber(wftProperties.getMinSeqNumber());
        options.setSeqBitLength(wftProperties.getSeqBitLength());
        options.setTopOverCostCount(wftProperties.getTopOverCostCount());
        options.setWorkerIdBitLength(wftProperties.getWorkerIdBitLength());
        return options;
    }
}
mdc-parent/mdc-collect/src/main/java/com/qianwen/mdc/config/WfgProperties.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,89 @@
package com.qianwen.mdc.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Component
@ConfigurationProperties(prefix = "wfg")
public class WfgProperties {
    private short method;
    private short workerId;
    private long baseTime;
    // # æ•°æ®ä¸­å¿ƒid
    private short dataCenterId;
    // # æ•°æ®ä¸­å¿ƒid位长,默认为0表示不开启数据中心id功能
    private byte dataCenterIdBitLength;
    // # æœºå™¨ç ï¼ˆå½“前系统的机器码)
    // # æœºå™¨ç ä½é•¿ï¼ˆèƒ½è¡¨ç¤ºæœºå™¨ç çš„æœ€å¤§å€¼ï¼‰
    private byte workerIdBitLength;
    // # åºåˆ—数位长(能表示机器码的最大序列数)
    private byte seqBitLength;
    // # æœ€å¤§åºåˆ—数(含)
    private short minSeqNumber;
    // # æœ€å°åºåˆ—数(含)
    private short maxSeqNumber;
    // # æœ€å¤§æ¼‚移次数,与计算能力有关
    private short topOverCostCount;
    public short getMethod() {
        return method;
    }
    public void setMethod(short method) {
        this.method = method;
    }
    public short getWorkerId() {
        return workerId;
    }
    public void setWorkerId(short workerId) {
        this.workerId = workerId;
    }
    public long getBaseTime() {
        return baseTime;
    }
    public void setBaseTime(long baseTime) {
        this.baseTime = baseTime;
    }
    public short getDataCenterId() {
        return dataCenterId;
    }
    public void setDataCenterId(short dataCenterId) {
        this.dataCenterId = dataCenterId;
    }
    public byte getDataCenterIdBitLength() {
        return dataCenterIdBitLength;
    }
    public void setDataCenterIdBitLength(byte dataCenterIdBitLength) {
        this.dataCenterIdBitLength = dataCenterIdBitLength;
    }
    public byte getWorkerIdBitLength() {
        return workerIdBitLength;
    }
    public void setWorkerIdBitLength(byte workerIdBitLength) {
        this.workerIdBitLength = workerIdBitLength;
    }
    public byte getSeqBitLength() {
        return seqBitLength;
    }
    public void setSeqBitLength(byte seqBitLength) {
        this.seqBitLength = seqBitLength;
    }
    public short getMinSeqNumber() {
        return minSeqNumber;
    }
    public void setMinSeqNumber(short minSeqNumber) {
        this.minSeqNumber = minSeqNumber;
    }
    public short getMaxSeqNumber() {
        return maxSeqNumber;
    }
    public void setMaxSeqNumber(short maxSeqNumber) {
        this.maxSeqNumber = maxSeqNumber;
    }
    public short getTopOverCostCount() {
        return topOverCostCount;
    }
    public void setTopOverCostCount(short topOverCostCount) {
        this.topOverCostCount = topOverCostCount;
    }
}
mdc-parent/mdc-collect/src/main/java/com/qianwen/mdc/domain/Machine.java
@@ -15,22 +15,20 @@
    //public static final String STATE_FLAG_REMOVED = "REMOVED";
    
    /**
     * id,实际上引用台账中的machine_id
     * id,与台账中的machine_id相同
     */
    //@Id
    //@GeneratedValue(strategy = GenerationType.IDENTITY)
    @TableId(type=IdType.INPUT)
    private Integer id;
    private Long id;
    /**
     * machine ip address
     * IP地址
     */
    private String ip;
    /**
     * machine port
     * é‡‡é›†ç«¯å£
     */
    private Integer port;
@@ -102,21 +100,6 @@
    //@Column(name = "trans_mode")
    private int transMode;
    /**
     * æœºåºŠæ‰€å çš„第一个位置
     */
    //private Integer firstPosition;
    /*
    public Integer getFirstPosition() {
        return firstPosition;
    }
    public void setFirstPosition(Integer firstPosition) {
        this.firstPosition = firstPosition;
    }
    */
    /**
     * å…³æ³¨çŠ¶æ€ï¼ˆ0.不关注;1.关注)默认为0
     */
@@ -139,11 +122,11 @@
    }
    private static final long serialVersionUID = 1L;
    public Integer getId() {
    public Long getId() {
        return id;
    }
    public void setId(Integer id) {
    public void setId(Long id) {
        this.id = id;
    }
@@ -171,23 +154,6 @@
    public void setProtocolId(Integer protocolId) {
        this.protocolId = protocolId;
    }
    public Integer getWorkshopId() {
        return workshopId;
    }
    public void setWorkshopId(Integer workshopId) {
        this.workshopId = workshopId;
    }
    public Integer getSectionId() {
        return sectionId;
    }
    public void setSectionId(Integer sectionId) {
        this.sectionId = sectionId;
    }
    public Integer getShiftType() {
mdc-parent/mdc-collect/src/main/java/com/qianwen/mdc/domain/MachineFocas.java
@@ -8,11 +8,10 @@
@TableName("mdc_machine_focas")
public class MachineFocas implements Serializable {
  @TableId(type=IdType.AUTO)
  @TableId(type=IdType.INPUT)
  private Long id;
  
  //@Column(name = "machine_id")
  private Integer machineId;
  private Long machineId;
  
  //@Column(name = "cnc_type")
  private String cncType;
@@ -31,11 +30,11 @@
    this.id = id;
  }
  
  public Integer getMachineId() {
  public Long getMachineId() {
    return this.machineId;
  }
  
  public void setMachineId(Integer machineId) {
  public void setMachineId(Long machineId) {
    this.machineId = machineId;
  }
  
mdc-parent/mdc-collect/src/main/java/com/qianwen/mdc/domain/MachineModbus.java
@@ -8,14 +8,13 @@
@TableName("machine_modbus")
public class MachineModbus implements Serializable {
    @TableId(type=IdType.AUTO)
    @TableId(type=IdType.ASSIGN_ID)
    private Long id;
    //@Column(name = "machine_id")
    private Integer machineId;
    private Long machineId;
    //@Column(name = "unit_id")
    private Integer unitId;
    private Integer type;
    //@Column(name = "sp_threshold")
    private Float spThreshold;
    private static final long serialVersionUID = 1;
@@ -27,11 +26,11 @@
        this.id = id;
    }
    public Integer getMachineId() {
    public Long getMachineId() {
        return this.machineId;
    }
    public void setMachineId(Integer machineId) {
    public void setMachineId(Long machineId) {
        this.machineId = machineId;
    }
mdc-parent/mdc-collect/src/main/java/com/qianwen/mdc/domain/MachineOpcua.java
@@ -8,10 +8,10 @@
@TableName("machine_opcua")
public class MachineOpcua implements Serializable {
    @TableId(type=IdType.AUTO)
    @TableId(type=IdType.ASSIGN_ID)
    private Long id;
    //@Column(name = "machine_id")
    private Integer machineId;
    private Long machineId;
    private String version;
    private String account;
    private String password;
@@ -25,11 +25,11 @@
        this.id = id;
    }
    public Integer getMachineId() {
    public Long getMachineId() {
        return this.machineId;
    }
    public void setMachineId(Integer machineId) {
    public void setMachineId(Long machineId) {
        this.machineId = machineId;
    }
mdc-parent/mdc-collect/src/main/java/com/qianwen/mdc/domain/MachineProtocol.java
@@ -10,8 +10,8 @@
@TableName("machine_protocol")//TODO ä¸´æ—¶çš„
public class MachineProtocol implements Serializable {
    @TableId(type=IdType.AUTO)
    private Integer id;
    @TableId(type=IdType.INPUT)
    private Long id;
    /**
     * åè®®åç§°
@@ -46,17 +46,13 @@
    private static final long serialVersionUID = 1L;
    /**
     * èŽ·å–primary key
     *
     * @return id - primary key
     */
    public Integer getId() {
    public Long getId() {
        return id;
    }
   
    public void setId(Integer id) {
    public void setId(Long id) {
        this.id = id;
    }
mdc-parent/mdc-collect/src/main/java/com/qianwen/mdc/domain/MachiningData.java
@@ -13,11 +13,10 @@
    public static final String STATE_RUN = "RUN";
    public static final String STATE_IDLE = "STATE_IDLE";
    @TableId(type = IdType.AUTO)
    @TableId(type = IdType.INPUT)
    private Long id;
    // @Column(name = "machine_id")
    private Integer machineId;
    private Long machineId;
    // @Column(name = "mdc_time")
    private Integer mdcTime;
@@ -102,11 +101,11 @@
        this.id = id;
    }
    public Integer getMachineId() {
    public Long getMachineId() {
        return this.machineId;
    }
    public void setMachineId(Integer machineId) {
    public void setMachineId(Long machineId) {
        this.machineId = machineId;
    }
mdc-parent/mdc-collect/src/main/java/com/qianwen/mdc/mapper/MachiningDataMapper.java
@@ -5,5 +5,5 @@
public interface MachiningDataMapper extends BaseMapper<MachiningData>{
    
    MachiningData lastOneByMachineId(int machineId);
    MachiningData lastOneByMachineId(Long machineId);
}
mdc-parent/mdc-collect/src/main/java/com/qianwen/mdc/mybatis/MybatisPlusWFGIdGenerator.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,25 @@
package com.qianwen.mdc.mybatis;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
import com.hy.corecode.idgen.WFGIdGenerator;
/**
 * mp拦截器用于注入id请求
 */
@Component
public class MybatisPlusWFGIdGenerator implements IdentifierGenerator {
    @Autowired
    private WFGIdGenerator wFGIdGenerator;
    @Override
    public Long nextId(Object entity) {
       return wFGIdGenerator.next();
    }
}
mdc-parent/mdc-collect/src/main/java/com/qianwen/mdc/service/jdmon/JDMonThread.java
@@ -1,20 +1,19 @@
package com.qianwen.mdc.service.jdmon;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import com.alibaba.fastjson.JSONObject;
import com.qianwen.mdc.domain.Machine;
import com.qianwen.mdc.domain.MachiningData;
import com.qianwen.mdc.mapper.MachiningDataMapper;
import com.qianwen.mdc.service.jdmon.BasicModalInfo;
import com.qianwen.mdc.service.jdmon.JDMonService;
import com.qianwen.mdc.utils.TimestampUtils;
import com.qianwen.mdc.utils.redis.RedisUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
/**
 * åŒ—京精雕系统采集线程
mdc-parent/mdc-collect/src/main/java/com/qianwen/mdc/service/siemenslib/SiemensLibThread.java
@@ -1,19 +1,19 @@
package com.qianwen.mdc.service.siemenslib;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import com.alibaba.fastjson.JSONObject;
import com.qianwen.mdc.domain.Machine;
import com.qianwen.mdc.domain.MachiningData;
import com.qianwen.mdc.mapper.MachiningDataMapper;
import com.qianwen.mdc.service.siemenslib.SiemensLibClient;
import com.qianwen.mdc.utils.TimestampUtils;
import com.qianwen.mdc.utils.redis.RedisUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
public class SiemensLibThread implements Runnable {
  private final Machine mdcMachine;
mdc-parent/mdc-show/pom.xml
@@ -129,7 +129,6 @@
        <dependency>
            <groupId>io.github.lmlx66</groupId>
            <artifactId>yitter-idgenerator-spring-boot-starter</artifactId>
            <version>1.1.3-RELEASE</version>
        </dependency>
        
        <!--pagehelper-->
mdc-parent/mdc-show/src/main/java/com/qianwen/mdc/domain/MachineAccount.java
@@ -15,7 +15,7 @@
@TableName("machine_account")
public class MachineAccount implements Serializable {
    @TableId(type=IdType.ASSIGN_ID)//使用雪花漂移算法
    @TableId(type=IdType.ASSIGN_ID)
    private Long id;
    /**
mdc-parent/pom.xml
@@ -53,6 +53,11 @@
            <artifactId>commons-pool2</artifactId>
            <version>2.12.0</version>
        </dependency>
        <dependency>
            <groupId>io.github.lmlx66</groupId>
            <artifactId>yitter-idgenerator-spring-boot-starter</artifactId>
            <version>1.1.3-RELEASE</version>
        </dependency>
      </dependencies>
  </dependencyManagement>
</project>