pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/IDLongGenerator.java
@@ -1,11 +1,15 @@ package com.dy.common.util; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import java.util.Calendar; @Slf4j @Component public class IDLongGenerator { private static final Object synObj = new Object() ; private static final int yearLenght = 4 ;//4:年度取四位, 3:年度取三位, 2:年度取两位, 1:年度取一位, 0:年度取0位 @@ -24,11 +28,16 @@ } /** * 23 10 28 09 14 40 00000 * 长度16的ID,年度取两位,长度18的ID,年度取四位,17位数字超出了javascript的表数范围,javascript会表数不正确 * 2023 10 28 09 14 40 00000 * 长度19的ID,年度取两位,长度18的ID,年度取四位,17位数字超出了javascript的表数范围,javascript会表数不正确 */ public synchronized Long generate(){ return doGenerate() ; public Long generate(){ synchronized (synObj){ //Long id = doGenerate() ; //log.info("产生ID = " + id); //return id ; return doGenerate() ; } } /** * 设置后缀,不同子系统设置不同的后缀 @@ -96,7 +105,7 @@ /** * 执行生成 * @return ID * @return ID 20231218 104504 06900 */ private Long doGenerate(){ long id ; pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/rmiClient/RmiClUnit.java
@@ -73,6 +73,8 @@ } public RmiFrameWork getRmiFrameWork(){ System.setProperty("java.rmi.server.hostname", confVo.svUrl) ; System.out.println("Rmi建立连接请求服务端:" + confVo.svUrl + ":" + confVo.svPort + "/" + confVo.svContext); RmiClient rmiCl = new RmiClient(confVo.svUrl, confVo.svPort, confVo.svContext) ; return rmiCl.getRmiInterface() ; } pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/TcpClUnit.java
@@ -83,10 +83,13 @@ log.info("共模拟了" + totalRtuClientCount + "台RTU"); Collection<MyThreadJob> collection = jobMap.values() ; int connectedCount = 0 ; for(MyThreadJob job : collection){ connectServer(job) ; connectedCount++ ; log.info("当前建立与通信中间件连接的RTU数量为:" + connectedCount); } log.info("启动所有RTU连接通信中间件"); log.info("所有RTU已与通信中间件建立连接"); while (true){ int noConnectedCount = checkConnected() ; @@ -99,6 +102,7 @@ } startJob() ; while(true){ if(totalOverClientCount.longValue() >= totalRtuClientCount.longValue()){ Long seconds = (System.currentTimeMillis() - startTime)/1000 ; @@ -176,30 +180,27 @@ } private void startJob(){ new Thread(new Runnable(){ @Override public void run() { try { int notOverCount; while(true){ notOverCount = 0 ; Collection<MyThreadJob> collection = jobMap.values() ; for(MyThreadJob job : collection){ if(!job.isOver){ notOverCount++ ; pool.putJob(job); } } if(notOverCount > 0){ log.info("当前还有" + notOverCount + "台RTU未完成任务"); Thread.sleep(ServerProperties.sendInterval * 1000); }else{ break ; new Thread(() -> { try { int notOverCount; while(true){ notOverCount = 0 ; Collection<MyThreadJob> collection = jobMap.values() ; for(MyThreadJob job : collection){ if(!job.isOver){ notOverCount++ ; pool.putJob(job); } } } catch (Exception e) { e.printStackTrace(); if(notOverCount > 0){ log.info("当前还有" + notOverCount + "台RTU未完成任务"); Thread.sleep(ServerProperties.sendInterval * 1000); }else{ break ; } } } catch (Exception e) { e.printStackTrace(); } }).start(); }