Prechádzať zdrojové kódy

* 二进制流id位数限制的bug

chen.cheng 5 mesiacov pred
rodič
commit
6f4b870f78
21 zmenil súbory, kde vykonal 426 pridanie a 61 odobranie
  1. 5 1
      bd-park/park-backend/park-application/src/main/java/com/huashe/park/application/web/controller/cons/PileMachineInfoController.java
  2. 4 2
      bd-park/park-backend/park-collect/src/main/resources/application.yml
  3. 116 0
      bd-park/park-backend/park-common/src/main/java/com/huashe/park/common/EnhancedIDGenerator.java
  4. 2 0
      bd-park/park-backend/park-core/src/main/java/com/huashe/park/core/mapper/ConsUnitInfoMapper.java
  5. 5 4
      bd-park/park-backend/park-core/src/main/java/com/huashe/park/core/mapper/PileMachineInfoMapper.java
  6. 2 2
      bd-park/park-backend/park-core/src/main/java/com/huashe/park/core/service/IConsUnitInfoService.java
  7. 5 3
      bd-park/park-backend/park-core/src/main/java/com/huashe/park/core/service/IPileMachineInfoService.java
  8. 8 0
      bd-park/park-backend/park-core/src/main/java/com/huashe/park/core/service/impl/ConsPileHoleInfoServiceImpl.java
  9. 10 5
      bd-park/park-backend/park-core/src/main/java/com/huashe/park/core/service/impl/ConsUnitInfoServiceImpl.java
  10. 35 10
      bd-park/park-backend/park-core/src/main/java/com/huashe/park/core/service/impl/PileMachineInfoServiceImpl.java
  11. 7 0
      bd-park/park-backend/park-core/src/main/resources/mapper/cons/ConsPileHoleInfoMapper.xml
  12. 10 0
      bd-park/park-backend/park-core/src/main/resources/mapper/cons/ConsUnitInfoMapper.xml
  13. 10 0
      bd-park/park-backend/park-core/src/main/resources/mapper/cons/PileMachineInfoMapper.xml
  14. 49 0
      bd-park/park-backend/park-domain/src/main/java/com/huashe/park/domain/dto/cons/ConsPileHoleInfoVO.java
  15. 45 16
      bd-park/park-backend/park-domain/src/main/java/com/huashe/park/domain/dto/cons/ConstUnitNode.java
  16. 5 17
      bd-park/park-backend/park-domain/src/main/java/com/huashe/park/domain/dto/cons/MachineBiz.java
  17. 58 0
      bd-park/park-backend/park-domain/src/main/java/com/huashe/park/domain/dto/cons/PileMachineVO.java
  18. 14 0
      bd-park/park-backend/park-domain/src/main/java/com/huashe/park/domain/entity/ConsPileHoleInfo.java
  19. 11 1
      bd-park/park-backend/park-domain/src/main/java/com/huashe/park/domain/entity/ConsUnitInfo.java
  20. 10 0
      bd-park/park-backend/park-domain/src/main/java/com/huashe/park/domain/entity/PileMachineInfo.java
  21. 15 0
      bd-park/park-backend/park-infrastructure/src/main/java/com/huashe/park/infrastructure/cfg/ids/IdCfg.java

+ 5 - 1
bd-park/park-backend/park-application/src/main/java/com/huashe/park/application/web/controller/cons/PileMachineInfoController.java

@@ -4,6 +4,8 @@ import java.util.List;
 
 import javax.servlet.http.HttpServletResponse;
 
+import cn.hutool.core.bean.BeanUtil;
+import com.huashe.park.domain.dto.cons.PileMachineVO;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -139,8 +141,10 @@ public class PileMachineInfoController extends BaseController {
         SecurityContextHolder.getContext().setAuthentication(authenticationToken);
         String token = tokenService.createToken(machineAuth);
         pileMachineInfo.setToken(token);
+        PileMachineVO pileMachineInfoVo = new PileMachineVO();
+        BeanUtil.copyProperties(pileMachineInfo, pileMachineInfoVo);
         // 生成token
-        return AjaxResult.success(pileMachineInfo);
+        return AjaxResult.success(pileMachineInfoVo);
     }
 
     @PostMapping("/terminal/workSection")

+ 4 - 2
bd-park/park-backend/park-collect/src/main/resources/application.yml

@@ -1,4 +1,3 @@
-
 # Spring配置
 spring:
   application:
@@ -103,4 +102,7 @@ mqtt:
     keep-alive-secs: 60
     clean-session: true
     ssl:
-      enabled: false
+      enabled: false
+id:
+  generator:
+    machine-id: 2

+ 116 - 0
bd-park/park-backend/park-common/src/main/java/com/huashe/park/common/EnhancedIDGenerator.java

@@ -0,0 +1,116 @@
+package com.huashe.park.common;
+
+import java.time.Instant;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.slf4j.Logger;
+
+public class EnhancedIDGenerator {
+    private static final Logger log = org.slf4j.LoggerFactory.getLogger(EnhancedIDGenerator.class);
+
+    // 基础参数配置(可通过构造函数注入)
+    private static final long EPOCH = Instant.parse("2025-01-01T00:00:00Z").toEpochMilli();
+
+    private static final int TIMESTAMP_BITS = 35; // 支持到2060年
+
+    private static final int SEQUENCE_BITS = 12; // 4096/ms
+
+    private static final int MACHINE_BITS = 4; // 支持16台机器
+
+    private static final long MAX_SEQUENCE = (1L << SEQUENCE_BITS) - 1;
+
+    // 分布式机器ID(0~15)
+    private final long machineId;
+
+    private final AtomicLong lastTimestamp = new AtomicLong(-1L);
+
+    private final AtomicLong sequence = new AtomicLong(0);
+
+    public EnhancedIDGenerator(int machineId) {
+        if (machineId < 0 || machineId >= (1 << MACHINE_BITS)) {
+            throw new IllegalArgumentException("机器ID范围 0~15");
+        }
+        this.machineId = machineId;
+    }
+
+    public String generate() {
+        long currentTimestamp;
+        long lastStamp;
+        long currentSequence;
+
+        do {
+            currentTimestamp = System.currentTimeMillis() - EPOCH;
+            lastStamp = lastTimestamp.get();
+
+            // 处理时间回拨(最大容忍100ms)
+            if (currentTimestamp < lastStamp) {
+                handleClockDrift(lastStamp - currentTimestamp);
+                currentTimestamp = System.currentTimeMillis() - EPOCH;
+            }
+
+            // 序列号重置条件
+            if (currentTimestamp != lastStamp) {
+                sequence.set(0);
+            }
+
+            currentSequence = sequence.getAndIncrement();
+            if (currentSequence > MAX_SEQUENCE) {
+                Thread.yield(); // 让出CPU等待下一毫秒
+                currentTimestamp = System.currentTimeMillis() - EPOCH;
+                sequence.set(0);
+                currentSequence = 0;
+            }
+
+        }
+        while (!lastTimestamp.compareAndSet(lastStamp, currentTimestamp));
+
+        // 组合数值:35位时间戳 + 4位机器ID + 12位序列号 = 51位
+        long combined = (currentTimestamp << (MACHINE_BITS + SEQUENCE_BITS)) | (machineId << SEQUENCE_BITS)
+            | currentSequence;
+
+        return encodeBase36(combined);
+    }
+
+    // 改进型Base36编码(消除前导零)
+    private String encodeBase36(long number) {
+        char[] buffer = new char[8];
+        for (int i = 7; i >= 0; i--) {
+            int digit = (int) (number % 36);
+            buffer[i] = (digit < 10) ? (char) ('0' + digit) : (char) ('a' + digit - 10);
+            number /= 36;
+        }
+        return new String(buffer);
+    }
+
+    // 时间回拨容错机制
+    private void handleClockDrift(long driftMillis) {
+        if (driftMillis > 100) {
+            throw new IllegalStateException("检测到超过100ms的时间回拨");
+        }
+        try {
+            Thread.sleep(driftMillis);
+        }
+        catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
+        }
+    }
+
+    public static void main(String[] args) {
+        // 分布式测试示例
+        EnhancedIDGenerator node1 = new EnhancedIDGenerator(1);
+        EnhancedIDGenerator node2 = new EnhancedIDGenerator(2);
+
+        System.out.println("节点1 ID: " + node1.generate()); // 示例:02H3D9MF
+        System.out.println("节点2 ID: " + node2.generate()); // 示例:12K8F7LZ
+        ThreadPoolExecutor threadPoolTaskExecutor = new ThreadPoolExecutor(10, 10, 100, TimeUnit.SECONDS,
+            new LinkedBlockingQueue<>(100));
+        for (int i = 0; i < 100; i++) {
+            threadPoolTaskExecutor.execute(() -> {
+                log.info(node1.generate());
+            });
+        }
+    }
+}

+ 2 - 0
bd-park/park-backend/park-core/src/main/java/com/huashe/park/core/mapper/ConsUnitInfoMapper.java

@@ -21,6 +21,8 @@ public interface ConsUnitInfoMapper {
      */
     ConsUnitInfo selectConsUnitInfoById(Long id);
 
+    ConsUnitInfo selectConsUnitInfoByByteId(String byteId);
+
     /**
      * 查询施工单元列表
      * 

+ 5 - 4
bd-park/park-backend/park-core/src/main/java/com/huashe/park/core/mapper/PileMachineInfoMapper.java

@@ -1,17 +1,16 @@
 package com.huashe.park.core.mapper;
 
-import com.huashe.park.domain.entity.PileMachineInfo;
-
 import java.util.List;
 
+import com.huashe.park.domain.entity.PileMachineInfo;
+
 /**
  * 施工桩机信息Mapper接口
  * 
  * @author ruoyi
  * @date 2025-02-12
  */
-public interface PileMachineInfoMapper 
-{
+public interface PileMachineInfoMapper {
     /**
      * 查询施工桩机信息
      * 
@@ -20,6 +19,8 @@ public interface PileMachineInfoMapper
      */
     public PileMachineInfo selectPileMachineInfoById(Long id);
 
+    public PileMachineInfo selectPileMachineInfoByByteId(String byteId);
+
     /**
      * 查询施工桩机信息列表
      * 

+ 2 - 2
bd-park/park-backend/park-core/src/main/java/com/huashe/park/core/service/IConsUnitInfoService.java

@@ -3,8 +3,6 @@ package com.huashe.park.core.service;
 import java.util.List;
 
 import com.huashe.park.domain.dto.cons.ConsUnitMachine;
-import com.huashe.park.domain.dto.cons.MachineBiz;
-import com.huashe.park.domain.entity.ConsPileHoleInfo;
 import com.huashe.park.domain.entity.ConsUnitInfo;
 
 /**
@@ -22,6 +20,8 @@ public interface IConsUnitInfoService {
      */
     ConsUnitMachine selectConsUnitInfoById(Long id);
 
+    ConsUnitInfo selectConsUnitInfoByByteId(String byteId);
+
     /**
      * 查询施工单元列表
      * 

+ 5 - 3
bd-park/park-backend/park-core/src/main/java/com/huashe/park/core/service/IPileMachineInfoService.java

@@ -2,9 +2,9 @@ package com.huashe.park.core.service;
 
 import java.util.List;
 
+import com.huashe.park.domain.dto.cons.ConsPileHoleInfoVO;
 import com.huashe.park.domain.dto.cons.ConstUnitNode;
 import com.huashe.park.domain.dto.cons.MachineBiz;
-import com.huashe.park.domain.entity.ConsPileHoleInfo;
 import com.huashe.park.domain.entity.PileMachineInfo;
 
 /**
@@ -22,6 +22,8 @@ public interface IPileMachineInfoService {
      */
     PileMachineInfo selectPileMachineInfoById(Long id);
 
+    PileMachineInfo selectPileMachineInfoByByteId(String byteId);
+
     /**
      * 查询施工桩机信息列表
      * 
@@ -63,7 +65,7 @@ public interface IPileMachineInfoService {
     int deletePileMachineInfoById(Long id);
 
 
-    List<ConstUnitNode> qryMachineAssignedUnit(Long machineId);
+    List<ConstUnitNode> qryMachineAssignedUnit(String machineId);
 
-    List<ConsPileHoleInfo> machineUnitPileHole(MachineBiz machineBiz);
+    List<ConsPileHoleInfoVO> machineUnitPileHole(MachineBiz machineBiz);
 }

+ 8 - 0
bd-park/park-backend/park-core/src/main/java/com/huashe/park/core/service/impl/ConsPileHoleInfoServiceImpl.java

@@ -5,6 +5,7 @@ import java.util.List;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import com.huashe.park.common.EnhancedIDGenerator;
 import com.huashe.park.core.mapper.ConsPileHoleInfoMapper;
 import com.huashe.park.core.service.IConsPileHoleInfoService;
 import com.huashe.park.domain.entity.ConsPileHoleInfo;
@@ -20,6 +21,9 @@ public class ConsPileHoleInfoServiceImpl implements IConsPileHoleInfoService {
     @Autowired
     private ConsPileHoleInfoMapper consPileHoleInfoMapper;
 
+    @Autowired
+    private EnhancedIDGenerator byte8Id;
+
     /**
      * 查询施工桩点信息
      * 
@@ -55,6 +59,7 @@ public class ConsPileHoleInfoServiceImpl implements IConsPileHoleInfoService {
      */
     @Override
     public int insertConsPileHoleInfo(ConsPileHoleInfo consPileHoleInfo) {
+        consPileHoleInfo.setByteId(byte8Id.generate());
         return consPileHoleInfoMapper.insertConsPileHoleInfo(consPileHoleInfo);
     }
 
@@ -98,6 +103,9 @@ public class ConsPileHoleInfoServiceImpl implements IConsPileHoleInfoService {
 
     @Override
     public void importConsPileHole(List<ConsPileHoleInfo> consPileHoleInfo) {
+        consPileHoleInfo.forEach((d) -> {
+            d.setByteId(byte8Id.generate());
+        });
         consPileHoleInfoMapper.batchInsertConsPileHoleInfo(consPileHoleInfo);
     }
 }

+ 10 - 5
bd-park/park-backend/park-core/src/main/java/com/huashe/park/core/service/impl/ConsUnitInfoServiceImpl.java

@@ -1,6 +1,5 @@
 package com.huashe.park.core.service.impl;
 
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -13,14 +12,13 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 import com.huashe.common.exception.ServiceException;
-import com.huashe.park.common.consts.enums.ConsStatus;
+import com.huashe.park.common.EnhancedIDGenerator;
 import com.huashe.park.common.i18n.MessageUtils;
 import com.huashe.park.core.mapper.ConsUnitInfoMapper;
 import com.huashe.park.core.service.IConsPileHoleInfoService;
 import com.huashe.park.core.service.IConsUnitInfoService;
 import com.huashe.park.core.service.IConsUnitMachineRelService;
 import com.huashe.park.domain.dto.cons.ConsUnitMachine;
-import com.huashe.park.domain.dto.cons.MachineBiz;
 import com.huashe.park.domain.entity.ConsPileHoleInfo;
 import com.huashe.park.domain.entity.ConsUnitInfo;
 import com.huashe.park.domain.entity.ConsUnitMachineRel;
@@ -50,6 +48,9 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
 
     private final static String PROFILE = "/profile";
 
+    @Autowired
+    private EnhancedIDGenerator byte8Id;
+
     /**
      * 查询施工单元
      * 
@@ -67,6 +68,11 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
         return result;
     }
 
+    @Override
+    public ConsUnitInfo selectConsUnitInfoByByteId(String byteId) {
+        return consUnitInfoMapper.selectConsUnitInfoByByteId(byteId);
+    }
+
     /**
      * 查询施工单元列表
      * 
@@ -90,6 +96,7 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
         // 处理施工单元信息
         ConsUnitInfo parentConsUnit = consUnitInfoMapper.selectConsUnitInfoById(consUnitInfo.getParentId());
         consUnitInfo.setAncestors(parentConsUnit.getAncestors() + "," + parentConsUnit.getId());
+        consUnitInfo.setByteId(byte8Id.generate());
         int cnt = consUnitInfoMapper.insertConsUnitInfo(consUnitInfo);
         // 处理施工单元关联信息
         handleMachine(consUnitInfo);
@@ -182,8 +189,6 @@ public class ConsUnitInfoServiceImpl implements IConsUnitInfoService {
         return consUnitInfoMapper.qryConsUnitInfoByIds(unitIds);
     }
 
-
-
     private void updateConsUnitChildren(Long id, String newAncestors, String oldAncestors) {
         List<ConsUnitInfo> children = consUnitInfoMapper.selectChildrenById(id);
         if (CollectionUtils.isEmpty(children)) {

+ 35 - 10
bd-park/park-backend/park-core/src/main/java/com/huashe/park/core/service/impl/PileMachineInfoServiceImpl.java

@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
 import com.huashe.common.utils.StringUtils;
+import com.huashe.park.common.EnhancedIDGenerator;
 import com.huashe.park.common.consts.enums.ConsStatus;
 import com.huashe.park.core.mapper.PileMachineInfoMapper;
 import com.huashe.park.core.service.IConsPileHoleInfoService;
@@ -18,6 +19,7 @@ import com.huashe.park.core.service.IConsUnitInfoService;
 import com.huashe.park.core.service.IConsUnitMachineRelService;
 import com.huashe.park.core.service.IPileMachineInfoService;
 import com.huashe.park.core.service.IProjectCoordinateInfoService;
+import com.huashe.park.domain.dto.cons.ConsPileHoleInfoVO;
 import com.huashe.park.domain.dto.cons.ConstUnitNode;
 import com.huashe.park.domain.dto.cons.MachineBiz;
 import com.huashe.park.domain.entity.ConsPileHoleInfo;
@@ -26,6 +28,8 @@ import com.huashe.park.domain.entity.ConsUnitMachineRel;
 import com.huashe.park.domain.entity.PileMachineInfo;
 import com.huashe.park.domain.entity.ProjectCoordinateInfo;
 
+import cn.hutool.core.bean.BeanUtil;
+
 /**
  * 施工桩机信息Service业务层处理
  * 
@@ -49,6 +53,9 @@ public class PileMachineInfoServiceImpl implements IPileMachineInfoService {
     @Autowired
     private IProjectCoordinateInfoService projectCoordinateInfoService;
 
+    @Autowired
+    private EnhancedIDGenerator byte8Id;
+
     /**
      * 查询施工桩机信息
      * 
@@ -60,6 +67,11 @@ public class PileMachineInfoServiceImpl implements IPileMachineInfoService {
         return pileMachineInfoMapper.selectPileMachineInfoById(id);
     }
 
+    @Override
+    public PileMachineInfo selectPileMachineInfoByByteId(String byteId) {
+        return pileMachineInfoMapper.selectPileMachineInfoByByteId(byteId);
+    }
+
     /**
      * 查询施工桩机信息列表
      * 
@@ -80,6 +92,7 @@ public class PileMachineInfoServiceImpl implements IPileMachineInfoService {
     @Override
     public int insertPileMachineInfo(PileMachineInfo pileMachineInfo) {
         pileMachineInfo.setPwd(pileMachineInfo.getSn() + "381.2371");
+        pileMachineInfo.setByteId(byte8Id.generate());
         return pileMachineInfoMapper.insertPileMachineInfo(pileMachineInfo);
     }
 
@@ -118,8 +131,9 @@ public class PileMachineInfoServiceImpl implements IPileMachineInfoService {
     }
 
     @Override
-    public List<ConstUnitNode> qryMachineAssignedUnit(Long machineId) {
-        List<ConsUnitInfo> consUnitInfos = consUnitInfoService.machineAssignedUnit(machineId);
+    public List<ConstUnitNode> qryMachineAssignedUnit(String machineId) {
+        PileMachineInfo pileMachineInfo = selectPileMachineInfoByByteId(machineId);
+        List<ConsUnitInfo> consUnitInfos = consUnitInfoService.machineAssignedUnit(pileMachineInfo.getId());
         List<ProjectCoordinateInfo> projectCoordinateInfos = projectCoordinateInfoService
             .selectProjectCoordinateInfoList(new ProjectCoordinateInfo());
         ProjectCoordinateInfo projectCoordinateInfo = projectCoordinateInfos.get(0);
@@ -136,23 +150,34 @@ public class PileMachineInfoServiceImpl implements IPileMachineInfoService {
     }
 
     @Override
-    public List<ConsPileHoleInfo> machineUnitPileHole(MachineBiz machineBiz) {
+    public List<ConsPileHoleInfoVO> machineUnitPileHole(MachineBiz machineBiz) {
+        List<ConsPileHoleInfoVO> result = new ArrayList<>();
+        ConsUnitInfo consUnitInfo = consUnitInfoService.selectConsUnitInfoByByteId(machineBiz.getDesignId());
+        PileMachineInfo pileMachineInfo = selectPileMachineInfoByByteId(machineBiz.getMachineId());
         List<ConsUnitMachineRel> consUnitMachineRels = consUnitMachineRelService
             .selectConsUnitMachineRelList(new ConsUnitMachineRel() {
                 {
-                    setConsUnitId(machineBiz.getDesignId());
-                    setMachineId(machineBiz.getMachineId());
+                    setConsUnitId(consUnitInfo.getId());
+                    setMachineId(pileMachineInfo.getId());
                 }
             });
         if (CollectionUtils.isEmpty(consUnitMachineRels)) {
             return new ArrayList<>();
         }
-        return pileHoleInfoService.selectNonConsPileHoleInfo(new ConsPileHoleInfo() {
-            {
-                setConsUnitId(machineBiz.getDesignId());
-                setConsStatus(ConsStatus.CONS_STATUS_00.getCode());
-            }
+        List<ConsPileHoleInfo> consPileHoleInfos = pileHoleInfoService
+            .selectNonConsPileHoleInfo(new ConsPileHoleInfo() {
+                {
+                    setConsUnitId(consUnitInfo.getId());
+                    setConsStatus(ConsStatus.CONS_STATUS_00.getCode());
+                }
+            });
+
+        consPileHoleInfos.forEach(item -> {
+            ConsPileHoleInfoVO consPileHoleInfoVO = new ConsPileHoleInfoVO();
+            BeanUtil.copyProperties(item, consPileHoleInfoVO);
+            result.add(consPileHoleInfoVO);
         });
+        return result;
     }
 
     private List<ConstUnitNode> buildConsUnitTree(List<ConstUnitNode> consUnitInfos) {

+ 7 - 0
bd-park/park-backend/park-core/src/main/resources/mapper/cons/ConsPileHoleInfoMapper.xml

@@ -6,6 +6,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     
     <resultMap type="ConsPileHoleInfo" id="ConsPileHoleInfoResult">
         <result property="id"    column="id"    />
+        <result property="byteId"    column="byte_id"    />
         <result property="holeKey"    column="hole_key"    />
         <result property="holeNum"    column="hole_num"    />
         <result property="deltaX"    column="delta_x"    />
@@ -26,6 +27,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <sql id="selectConsPileHoleInfoVo">
         select id,
+               byte_id,
                hole_key,
                hole_num,
                delta_x,
@@ -69,6 +71,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <insert id="insertConsPileHoleInfo" parameterType="ConsPileHoleInfo" useGeneratedKeys="true" keyProperty="id">
         insert into cons_pile_hole_info
         <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="byteId != null and byteId != ''">byte_id,</if>
             <if test="holeKey != null and holeKey != ''">hole_key,</if>
             <if test="holeNum != null and holeNum != ''">hole_num,</if>
             <if test="deltaX != null">delta_x,</if>
@@ -86,6 +89,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateBy != null">update_by,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="byteId != null and byteId != ''">#{byteId},</if>
             <if test="holeKey != null and holeKey != ''">#{holeKey},</if>
             <if test="holeNum != null and holeNum != ''">#{holeNum},</if>
             <if test="deltaX != null">#{deltaX},</if>
@@ -106,6 +110,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <insert id="batchInsertConsPileHoleInfo" parameterType="List" useGeneratedKeys="true" keyProperty="id">
         insert into cons_pile_hole_info
         (
+        byte_id,
         hole_key,
         hole_num,
         delta_x,
@@ -123,6 +128,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         )
         values
         <foreach collection="list" item="item" open="(" close=")" separator=",">
+            #{item.byteId},
             #{item.holeKey},
             #{item.holeNum},
             #{item.deltaX},
@@ -151,6 +157,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <update id="updateConsPileHoleInfo" parameterType="ConsPileHoleInfo">
         update cons_pile_hole_info
         <trim prefix="SET" suffixOverrides=",">
+            <if test="byteId != null and byteId != ''">byte_id = #{byteId},</if>
             <if test="holeKey != null and holeKey != ''">hole_key = #{holeKey},</if>
             <if test="holeNum != null and holeNum != ''">hole_num = #{holeNum},</if>
             <if test="deltaX != null">delta_x = #{deltaX},</if>

+ 10 - 0
bd-park/park-backend/park-core/src/main/resources/mapper/cons/ConsUnitInfoMapper.xml

@@ -6,6 +6,7 @@
 
     <resultMap type="ConsUnitInfo" id="ConsUnitInfoResult">
         <result property="id" column="id"/>
+        <result property="byteId" column="byte_id"/>
         <result property="penningType" column="penning_type"/>
         <result property="type" column="type"/>
         <result property="parentId" column="parent_id"/>
@@ -22,6 +23,7 @@
 
     <sql id="selectConsUnitInfoVo">
         select id,
+               byte_id,
                penning_type,
                type,
                parent_id,
@@ -49,9 +51,15 @@
         where id = #{id}
     </select>
 
+    <select id="selectConsUnitInfoByByteId" resultMap="ConsUnitInfoResult">
+        <include refid="selectConsUnitInfoVo"/>
+        where byte_id = #{byteId}
+    </select>
+
     <insert id="insertConsUnitInfo" parameterType="ConsUnitInfo" useGeneratedKeys="true" keyProperty="id">
         insert into cons_cons_unit_info
         <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="byteId !=null ">byte_id,</if>
             <if test="penningType != null">penning_type,</if>
             <if test="type != null">type,</if>
             <if test="parentId != null">parent_id,</if>
@@ -66,6 +74,7 @@
             <if test="updateBy != null">update_by,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="byteId !=null ">#{byteId},</if>
             <if test="penningType != null">#{penningType},</if>
             <if test="type != null">#{type},</if>
             <if test="parentId != null">#{parentId},</if>
@@ -83,6 +92,7 @@
     <update id="updateConsUnitInfo" parameterType="ConsUnitInfo">
         update cons_cons_unit_info
         <trim prefix="SET" suffixOverrides=",">
+            <if test="byteId !=null ">byte_id = #{byteId},</if>
             <if test="penningType != null">penning_type = #{penningType},</if>
             <if test="type != null">type = #{type},</if>
             <if test="parentId != null">parent_id = #{parentId},</if>

+ 10 - 0
bd-park/park-backend/park-core/src/main/resources/mapper/cons/PileMachineInfoMapper.xml

@@ -6,6 +6,7 @@
 
     <resultMap type="PileMachineInfo" id="PileMachineInfoResult">
         <result property="id" column="id"/>
+        <result property="byteId" column="byte_id"/>
         <result property="machineNum" column="machine_num"/>
         <result property="equipment" column="equipment"/>
         <result property="no" column="no"/>
@@ -26,6 +27,7 @@
 
     <sql id="selectPileMachineInfoVo">
         select id,
+               byte_id,
                machine_num,
                equipment, no, pwd, sn, product_key, device_secret, topic, server_host, server_port, server_user_name, server_password, update_time, create_time, create_by, update_by
         from cons_pile_machine_info
@@ -45,9 +47,15 @@
         where id = #{id}
     </select>
 
+    <select id="selectPileMachineInfoByByteId" parameterType="String" resultMap="PileMachineInfoResult">
+        <include refid="selectPileMachineInfoVo"/>
+        where byte_id = #{byteId}
+    </select>
+
     <insert id="insertPileMachineInfo" parameterType="PileMachineInfo" useGeneratedKeys="true" keyProperty="id">
         insert into cons_pile_machine_info
         <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="byteId != null and byteId != ''">byte_id,</if>
             <if test="machineNum != null and machineNum != ''">machine_num,</if>
             <if test="equipment != null and equipment != ''">equipment,</if>
             <if test="no != null">no,</if>
@@ -66,6 +74,7 @@
             <if test="updateBy != null">update_by,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="byteId != null and byteId != ''">#{byteId},</if>
             <if test="machineNum != null and machineNum != ''">#{machineNum},</if>
             <if test="equipment != null and equipment != ''">#{equipment},</if>
             <if test="no != null">#{no},</if>
@@ -88,6 +97,7 @@
     <update id="updatePileMachineInfo" parameterType="PileMachineInfo">
         update cons_pile_machine_info
         <trim prefix="SET" suffixOverrides=",">
+            <if test="byteId != null and byteId != ''">byte_id = #{byteId},</if>
             <if test="machineNum != null and machineNum != ''">machine_num = #{machineNum},</if>
             <if test="equipment != null and equipment != ''">equipment = #{equipment},</if>
             <if test="no != null">no = #{no},</if>

+ 49 - 0
bd-park/park-backend/park-domain/src/main/java/com/huashe/park/domain/dto/cons/ConsPileHoleInfoVO.java

@@ -0,0 +1,49 @@
+package com.huashe.park.domain.dto.cons;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import lombok.Data;
+
+/**
+ * 施工桩点信息对象 cons_pile_hole_info
+ * 
+ * @author ruoyi
+ * @date 2025-02-13
+ */
+@Data
+public class ConsPileHoleInfoVO {
+    private static final long serialVersionUID = 1L;
+
+    @JsonProperty("id")
+    private String byteId;
+
+    @JsonProperty("name")
+    private String holeNum;
+
+    /**
+     * //类型: CFG桩-200, 旋挖钻-203, 振动沉管碎石桩-210 , 潜孔钻-211, 静压桩-202, 光伏桩-201, 插板桩-206, 灰土挤密桩-20
+     */
+    private Integer type = 200;
+
+    /** dx */
+    @JsonProperty("x")
+    private Double deltaX;
+
+    /** dy */
+    @JsonProperty("y")
+    private Double deltaY;
+
+    @JsonProperty("z")
+    private Double deltaZ = 0D;
+
+    /** 设计深度 */
+    @JsonProperty("len")
+    private Long desDept;
+
+    /** 桩径 */
+    @JsonProperty("diameter")
+    private Long diameter;
+
+    private Integer count = 0;
+
+}

+ 45 - 16
bd-park/park-backend/park-domain/src/main/java/com/huashe/park/domain/dto/cons/ConstUnitNode.java

@@ -2,27 +2,56 @@ package com.huashe.park.domain.dto.cons;
 
 import java.util.List;
 
-import com.huashe.park.domain.entity.ConsUnitInfo;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.huashe.common.annotation.Excel;
 import com.huashe.park.domain.entity.ProjectCoordinateInfo;
 
-public class ConstUnitNode extends ConsUnitInfo {
-    private List<ConstUnitNode> child;
+import lombok.Data;
 
-    private ProjectCoordinateInfo coordinateModel;
+@Data
+public class ConstUnitNode {
+
+    /** 编号 */
+    @JsonIgnore
+    private Long id;
+
+    @JsonProperty("id")
+    private String byteId;
+
+    /** 强夯类型 */
+    @Excel(name = "强夯类型")
+    private Integer penningType;
+
+    /** 类型 */
+    @Excel(name = "类型")
+    private String type;
+
+    /** 父节点 */
+    @Excel(name = "父节点")
+    private Long parentId;
 
-    public List<ConstUnitNode> getChild() {
-        return child;
-    }
+    /** 创建类型 */
+    @Excel(name = "创建类型")
+    private Integer createType;
 
-    public void setChild(List<ConstUnitNode> child) {
-        this.child = child;
-    }
+    /** 设计文件类型 */
+    @Excel(name = "设计文件类型")
+    private Integer classifyType;
 
-    public ProjectCoordinateInfo getCoordinateModel() {
-        return coordinateModel;
-    }
+    /** 施工单元名称 */
+    @Excel(name = "施工单元名称")
+    private String name;
+
+    @JsonIgnore
+    private String ancestors;
+
+    private Long projectId;
+
+    private String fileId;
+
+    private List<ConstUnitNode> child;
+
+    private ProjectCoordinateInfo coordinateModel;
 
-    public void setCoordinateModel(ProjectCoordinateInfo coordinateModel) {
-        this.coordinateModel = coordinateModel;
-    }
 }

+ 5 - 17
bd-park/park-backend/park-domain/src/main/java/com/huashe/park/domain/dto/cons/MachineBiz.java

@@ -1,23 +1,11 @@
 package com.huashe.park.domain.dto.cons;
 
-public class MachineBiz {
-    private Long designId;
-
-    private Long machineId;
+import lombok.Data;
 
-    public Long getDesignId() {
-        return designId;
-    }
-
-    public void setDesignId(Long designId) {
-        this.designId = designId;
-    }
+@Data
+public class MachineBiz {
+    private String designId;
 
-    public Long getMachineId() {
-        return machineId;
-    }
+    private String machineId;
 
-    public void setMachineId(Long machineId) {
-        this.machineId = machineId;
-    }
 }

+ 58 - 0
bd-park/park-backend/park-domain/src/main/java/com/huashe/park/domain/dto/cons/PileMachineVO.java

@@ -0,0 +1,58 @@
+package com.huashe.park.domain.dto.cons;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.huashe.common.annotation.Excel;
+
+import lombok.Data;
+
+@Data
+public class PileMachineVO {
+    private static final long serialVersionUID = 1L;
+
+    @JsonProperty("id")
+    private String byteId;
+
+    /** 桩机编号 */
+    @Excel(name = "桩机编号")
+    private String machineNum;
+
+    /** 设备信息 */
+    @Excel(name = "设备信息")
+    @JsonProperty("name")
+    private String equipment;
+
+    private String no;
+
+    @JsonIgnore
+    private String pwd;
+
+    private String sn;
+
+    @JsonProperty("token")
+    private String token;
+
+    @JsonProperty("serverHost")
+    private String serverHost;
+
+    @JsonProperty("serverPort")
+    private String serverPort;
+
+    @JsonProperty("serverUserName")
+    private String serverUserName;
+
+    @JsonProperty("serverPassword")
+    private String serverPassword;
+
+    @JsonProperty("topic")
+    private String topic;
+
+    @JsonProperty("constructionP4")
+    private String constructionP4;
+
+    @JsonProperty("productKey")
+    private String productKey;
+
+    @JsonProperty("deviceSecret")
+    private String deviceSecret;
+}

+ 14 - 0
bd-park/park-backend/park-domain/src/main/java/com/huashe/park/domain/entity/ConsPileHoleInfo.java

@@ -2,6 +2,7 @@ package com.huashe.park.domain.entity;
 
 import java.util.Date;
 
+import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 
@@ -24,6 +25,8 @@ public class ConsPileHoleInfo extends BaseEntity {
     /** 编号 */
     private Long id;
 
+    private String byteId;
+
     /** 桩点编号 */
     @Excel(name = "桩点编号")
     @JSONField(name = "name")
@@ -94,6 +97,14 @@ public class ConsPileHoleInfo extends BaseEntity {
         return id;
     }
 
+    public void setByteId(String byteId) {
+        this.byteId = byteId;
+    }
+
+    public String getByteId() {
+        return byteId;
+    }
+
     public void setHoleNum(String holeNum) {
         this.holeNum = holeNum;
     }
@@ -103,6 +114,9 @@ public class ConsPileHoleInfo extends BaseEntity {
     }
 
     public String getHoleKey() {
+        if (ObjectUtils.isEmpty(deltaX) || ObjectUtils.isEmpty(deltaY)) {
+            return null;
+        }
         return deltaY.toString() + deltaX.toString();
     }
 

+ 11 - 1
bd-park/park-backend/park-domain/src/main/java/com/huashe/park/domain/entity/ConsUnitInfo.java

@@ -1,9 +1,9 @@
 package com.huashe.park.domain.entity;
 
-import com.fasterxml.jackson.annotation.JsonIgnore;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 
+import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.huashe.common.annotation.Excel;
 import com.huashe.common.domain.BaseEntity;
 
@@ -19,6 +19,8 @@ public class ConsUnitInfo extends BaseEntity {
     /** 编号 */
     private Long id;
 
+    private String byteId;
+
     /** 强夯类型 */
     @Excel(name = "强夯类型")
     private Integer penningType;
@@ -50,6 +52,14 @@ public class ConsUnitInfo extends BaseEntity {
 
     private String fileId;
 
+    public String getByteId() {
+        return byteId;
+    }
+
+    public void setByteId(String byteId) {
+        this.byteId = byteId;
+    }
+
     public Long getId() {
         return id;
     }

+ 10 - 0
bd-park/park-backend/park-domain/src/main/java/com/huashe/park/domain/entity/PileMachineInfo.java

@@ -20,6 +20,8 @@ public class PileMachineInfo extends BaseEntity {
     /** 编号 */
     private Long id;
 
+    private String byteId;
+
     /** 桩机编号 */
     @Excel(name = "桩机编号")
     private String machineNum;
@@ -71,6 +73,14 @@ public class PileMachineInfo extends BaseEntity {
         return id;
     }
 
+    public String getByteId() {
+        return byteId;
+    }
+
+    public void setByteId(String byteId) {
+        this.byteId = byteId;
+    }
+
     public void setMachineNum(String machineNum) {
         this.machineNum = machineNum;
     }

+ 15 - 0
bd-park/park-backend/park-infrastructure/src/main/java/com/huashe/park/infrastructure/cfg/ids/IdCfg.java

@@ -0,0 +1,15 @@
+package com.huashe.park.infrastructure.cfg.ids;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import com.huashe.park.common.EnhancedIDGenerator;
+
+@Configuration
+public class IdCfg {
+    @Bean
+    public EnhancedIDGenerator byte8Id(@Value("${id.generator.machine-id:1}") int machineId) {
+        return new EnhancedIDGenerator(machineId);
+    }
+}