Administrator
2023-12-19 f41d94d3e05e221182623361d967f884737c0171
Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV
4个文件已修改
81 ■■■■■ 已修改文件
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/util/IDLongGenerator.java 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/PipIrrMwAcceptApplication.java 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/rmiClient/RmiClUnit.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/TcpClUnit.java 45 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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 Long generate(){
        return doGenerate() ;
        synchronized (synObj){
            //Long id = doGenerate() ;
            //log.info("产生ID = " + id);
            //return id ;
            return doGenerate() ;
        }
    }
    /**
     * 设置后缀,不同子系统设置不同的后缀
@@ -96,9 +105,9 @@
    /**
     * 执行生成
     * @return ID
     * @return ID 20231218 104504 06900
     */
    private synchronized Long doGenerate(){
    private Long doGenerate(){
        long id ;
        long now = current() ;
        if(now != last){
pipIrr-platform/pipIrr-mw/pipIrr-mw-accept/src/main/java/com/dy/aceMw/PipIrrMwAcceptApplication.java
@@ -8,12 +8,17 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.FilterType;
@SpringBootApplication
@EnableAspectJAutoProxy
//@EnableAspectJAutoProxy(exposeProxy=true)//见https://blog.csdn.net/qq_32590703/article/details/109320381
@EnableMultiDataSource
@ComponentScan(basePackages = {"com.dy.common", "com.dy.pipIrrGlobal", "com.dy.aceMw"})
@ComponentScan(basePackages = {"com.dy.common", "com.dy.pipIrrGlobal", "com.dy.aceMw"},
        excludeFilters = {@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {
                com.dy.common.apiDoc.SpringApiConfig.class
        }) })
//@ComponentScan(basePackages = {"com.dy.common", "com.dy.pipIrrGlobal", "com.dy.aceMw"})
@MapperScan(basePackages={"com.dy.pipIrrGlobal.test","com.dy.pipIrrGlobal.daoRm"})
public class PipIrrMwAcceptApplication implements CommandLineRunner {
@@ -23,15 +28,17 @@
    /**
     * Spring容器启动完成后,执行下面方法
     * @param args
     * @throws Exception
     * @param args 参数
     * @throws Exception 异常
     */
    @Override
    public void run(String... args) throws Exception {
        try{
            //等待数据库初始化完成
            Thread.sleep(1000L);
        }catch (Exception e){}
        }catch (Exception e){
            e.printStackTrace();
        }
        finally {
            this.startAceSv() ;
        }
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();
    }