Sfoglia il codice sorgente

修改client下载文件逻辑

xusl 10 mesi fa
parent
commit
45a77566ce
17 ha cambiato i file con 22 aggiunte e 1280 eliminazioni
  1. 5 5
      ipp-client/pom.xml
  2. 11 2
      ipp-client/src/main/java/com/jiayue/ipfcst/client/Schedule/Task.java
  3. 0 61
      ipp-client/src/main/java/com/jiayue/ipfcst/client/controller/ProtocolController.java
  4. 0 54
      ipp-client/src/main/java/com/jiayue/ipfcst/client/protocol2file/GatherModbusRtuByTcpServerTunnelInfo.java
  5. 0 177
      ipp-client/src/main/java/com/jiayue/ipfcst/client/protocol2file/GenerateFileTunnel.java
  6. 0 34
      ipp-client/src/main/java/com/jiayue/ipfcst/client/protocol2file/GenerateFileTunnelInfo.java
  7. 0 109
      ipp-client/src/main/java/com/jiayue/ipfcst/client/protocol2file/GenerateFileUtil.java
  8. 0 213
      ipp-client/src/main/java/com/jiayue/ipfcst/client/protocol2file/ModbusRtuDataGatherWithTcpServer.java
  9. 0 74
      ipp-client/src/main/java/com/jiayue/ipfcst/client/protocol2file/ModbusRtuMasterWithTcpServer.java
  10. 0 73
      ipp-client/src/main/java/com/jiayue/ipfcst/client/protocol2file/ModbusRtuMasterWithTcpServerHandler.java
  11. 0 18
      ipp-client/src/main/java/com/jiayue/ipfcst/client/protocol2file/MyDataPoint.java
  12. 0 182
      ipp-client/src/main/java/com/jiayue/ipfcst/client/protocol2file/MyReadConfigFile.java
  13. 0 142
      ipp-client/src/main/java/com/jiayue/ipfcst/client/protocol2file/PackageWindTowerOrWeatherStationData.java
  14. 0 133
      ipp-client/src/main/java/com/jiayue/ipfcst/client/protocol2file/StartPro2File.java
  15. 1 1
      ipp-client/src/main/java/com/jiayue/ipfcst/client/utils/ClientFileUtils.java
  16. 1 0
      ipp-client/src/main/java/com/jiayue/ipfcst/client/utils/UtilTools.java
  17. 4 2
      ipp-client/src/main/resources/application.yml

+ 5 - 5
ipp-client/pom.xml

@@ -64,11 +64,11 @@
             <artifactId>lombok</artifactId>
             <optional>true</optional>
         </dependency>
-        <dependency>
-            <groupId>com.syjy</groupId>
-            <artifactId>protocolconverter</artifactId>
-            <version>[0.0.9,)</version>
-        </dependency>
+<!--        <dependency>-->
+<!--            <groupId>com.syjy</groupId>-->
+<!--            <artifactId>protocolconverter</artifactId>-->
+<!--            <version>[0.0.9,)</version>-->
+<!--        </dependency>-->
         <dependency>
             <groupId>commons-net</groupId>
             <artifactId>commons-net</artifactId>

+ 11 - 2
ipp-client/src/main/java/com/jiayue/ipfcst/client/Schedule/Task.java

@@ -170,8 +170,13 @@ public class Task {
                     Long size = downloadFileByMinioOrCloud(tempFilePath + File.separatorChar + fileCreateLog.getStationCode(), curentFileName, fileCreateLog.getId(), fileCreateLog.getFileDownloadUrl());
 
                     if (size > 0) {
-
                         String filePath = tempFilePath + File.separatorChar + fileCreateLog.getStationCode() + File.separatorChar + curentFileName;
+                        // 传输给四方nwp
+                        if (curentFileName.startsWith("NWP")){
+                            // 拷贝文件到四方目录/home/syjy/ipp/sfnwp/场站编号
+                            FileUtils.copyFile(new File(filePath), new File("/home/syjy/ipp/sfnwp/"+fileCreateLog.getStationCode()+ File.separatorChar + curentFileName));
+                        }
+
                         log.info("成功下载文件到:{}", filePath);
                         //文件下载成功缓存文件名称,避免再次下载  ,
                         Constant.alreadyDownFilesList.add(fileCreateLog.getStationCode()+curentFileName);
@@ -198,7 +203,11 @@ public class Task {
             if (Constant.filedownLoadList.size() > 0) {
                 for (String fpath : Constant.filedownLoadList) {
                     int startIndex = fpath.indexOf("J00");
+                    if (startIndex==-1){
+                        startIndex = fpath.indexOf("T00");
+                    }
                     int endIndex = startIndex + 6;
+                    // result是6位的场站编号
                     String result = fpath.substring(startIndex, endIndex);
                     UtilTools.mvFile(fpath, fxglFilePath + File.separator + result + File.separator + "new");
                 }
@@ -560,7 +569,7 @@ public class Task {
     }
 
 
-    @Scheduled(fixedRate = 60000l)
+//    @Scheduled(fixedRate = 60000l)
     public void realPowerForQr() {
 
         File zxglPathFile = new File(zxglPath + File.separator + "new");

+ 0 - 61
ipp-client/src/main/java/com/jiayue/ipfcst/client/controller/ProtocolController.java

@@ -1,61 +0,0 @@
-package com.jiayue.ipfcst.client.controller;
-
-import com.alibaba.fastjson.JSONObject;
-import com.syjy.container.ProtocolDataContainer;
-import com.syjy.container.ProtocolTunnelContainer;
-import com.syjy.tunnelinfo.TunnelStatus;
-import com.syjy.tunnelinfo.TunnelType;
-import com.syjy.tunnelworker.BaseProtocolTunnel;
-import org.joda.time.DateTime;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.ResponseBody;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.TreeMap;
-
-
-/**
- * 协议的controller
- *
- * @author xiuwei
- * @date 2022/04/12
- */
-@Controller
-@RequestMapping("protocol")
-public class ProtocolController {
-
-	@RequestMapping("")
-	public String page() {
-		return "protocol";
-	}
-
-	@ResponseBody
-	@GetMapping("getRealTimeData")
-	public JSONObject getRealTimeData(){
-		JSONObject jsonObject=new JSONObject();
-		Map<String,String> tunnels=new HashMap<>();
-		for(Map.Entry<String, BaseProtocolTunnel>  e: ProtocolTunnelContainer.getInstance().getAllTunnel().entrySet()){
-			if(TunnelType.GENERATEFILE==e.getValue().getTunnelType()){
-				if(TunnelStatus.CONNECTEDANDCOMMERROR==e.getValue().getTunnelStatus()){
-					tunnels.put(e.getValue().getTunnelInfo().getTunnelName(),"生成文件滞留");
-				}else{
-					tunnels.put(e.getValue().getTunnelInfo().getTunnelName(),"传输文件正常");
-				}
-			}else{
-				tunnels.put(e.getValue().getTunnelInfo().getTunnelName(),e.getValue().getTunnelStatus().getCnDescribe());
-			}
-		}
-		jsonObject.put("tunnel", tunnels);
-		TreeMap<Integer,Object> dataValue=new TreeMap();
-		dataValue.putAll(ProtocolDataContainer.getInstance().getAllBooleans());
-		dataValue.putAll(ProtocolDataContainer.getInstance().getAllNumbers());
-		jsonObject.put("dataValue",dataValue);
-		jsonObject.put("time", DateTime.now().toString("yyyy-MM-dd HH:mm:ss"));
-		return jsonObject;
-	}
-
-
-}

+ 0 - 54
ipp-client/src/main/java/com/jiayue/ipfcst/client/protocol2file/GatherModbusRtuByTcpServerTunnelInfo.java

@@ -1,54 +0,0 @@
-package com.jiayue.ipfcst.client.protocol2file;
-
-
-import com.syjy.DataExchangeException;
-import com.syjy.ReadConfigFile;
-import com.syjy.tunnelinfo.BaseTunnelInfo;
-import com.syjy.tunnelinfo.TunnelType;
-import jxl.Cell;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-
-/**
- * modbus协议tcp采集通道
- *
- * @author 修唯xiuwei
- * @version 3.0
- */
-@EqualsAndHashCode(callSuper = true)
-@Data
-public class GatherModbusRtuByTcpServerTunnelInfo extends BaseTunnelInfo {
-
-
-	/**
-	 * 初始化时确定通道类型
-	 */
-	public GatherModbusRtuByTcpServerTunnelInfo() {
-		this.setTunnelType(TunnelType.MODBUSRTUMASTERWITHTCPSERVER);
-	}
-
-
-	/**
-	 * 自身的端口
-	 */
-	private Integer selfPort;
-
-	/**
-	 * 功能码
-	 */
-	private Integer functionCode = 3;
-
-
-	/**
-	 * 设备地址
-	 */
-	private Integer slaveId = 1;
-
-
-	@Override
-	public void setByRow(Cell[] cells) throws DataExchangeException {
-		this.setSelfPort(Integer.parseInt(ReadConfigFile.getCellContext(cells[0])));
-		this.setSlaveId(Integer.parseInt(ReadConfigFile.getCellContext(cells[1])));
-		this.setFunctionCode(Integer.parseInt(ReadConfigFile.getCellContext(cells[2])));
-	}
-}

+ 0 - 177
ipp-client/src/main/java/com/jiayue/ipfcst/client/protocol2file/GenerateFileTunnel.java

@@ -1,177 +0,0 @@
-package com.jiayue.ipfcst.client.protocol2file;
-
-import com.syjy.DataExchangeException;
-import com.syjy.container.ProtocolDataContainer;
-import com.syjy.container.ProtocolTunnelContainer;
-import com.syjy.container.RecurringTaskContainer;
-import com.syjy.tunnelinfo.DataPoint;
-import com.syjy.tunnelinfo.TunnelStatus;
-import com.syjy.tunnelworker.BaseProtocolTunnel;
-import com.syjy.tunnelworker.senders.DataSenderInterface;
-import org.joda.time.DateTime;
-import org.joda.time.format.DateTimeFormat;
-import org.joda.time.format.DateTimeFormatter;
-import wei.yigulu.netty.BaseProtocolBuilder;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.Comparator;
-import java.util.Map;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-/**
- * @author: xiuwei
- * @version:
- */
-public class GenerateFileTunnel extends BaseProtocolTunnel<GenerateFileTunnelInfo, BaseProtocolBuilder> implements DataSenderInterface {
-
-    private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormat.forPattern("yyyyMMddHHmmss");
-
-    private final ScheduledExecutorService pool = Executors.newScheduledThreadPool(5);
-
-
-    /**
-     * 顶层的构造方法
-     *
-     * @param tunnelInfo 通道信息
-     */
-    public GenerateFileTunnel(GenerateFileTunnelInfo tunnelInfo) {
-        super(tunnelInfo);
-    }
-
-    @Override
-    public BaseProtocolTunnel startTunnel() throws DataExchangeException {
-        setTunnelStatus(TunnelStatus.CONNECTED);
-        protocolTunnelContainer.addUpdateDateTask(this);
-        checkFileIsPassedTask();
-        return this;
-    }
-
-    @Override
-    public BaseProtocolTunnel buildTunnel() throws DataExchangeException {
-        return protocolTunnelContainer.addTunnel(this);
-    }
-
-    @Override
-    public void parseGatherDataPoint() throws DataExchangeException {
-        this.tunnelInfo.getDataPoints().sort(Comparator.comparingInt(DataPoint::getProtocolPoint));
-    }
-
-    @Override
-    public void updateData2Protocol() throws DataExchangeException {
-        //获取各通道状态
-        Map<String, BaseProtocolTunnel> allTunnel = ProtocolTunnelContainer.getInstance().getAllTunnel();
-        String tunnelStatus = "correct";
-        for (Map.Entry<String, BaseProtocolTunnel> e : allTunnel.entrySet()) {
-            if (!TunnelStatus.CORRECT_STATUS.contains(e.getValue().getTunnelStatus())) {
-                tunnelStatus = "error";
-            }
-        }
-        StringBuffer stringBuffer = new StringBuffer();
-        stringBuffer.append("<Data date=" + DATE_TIME_FORMATTER.print(DateTime.now()) + ">\n" +
-                "@id value\n");
-        for (int i = 1; i <= this.tunnelInfo.getDataPoints().size(); i++) {
-            stringBuffer.append("#");
-            stringBuffer.append(i);
-            stringBuffer.append("\t");
-            stringBuffer.append(ProtocolDataContainer.getInstance().getNumber(this.tunnelInfo.getDataPoints().get(i - 1).getId()));
-            stringBuffer.append("\n");
-        }
-        stringBuffer.append("</Data>");
-        stringBuffer.append("\n");
-        stringBuffer.append("<TunnelStatus>");
-        stringBuffer.append("\n");
-        stringBuffer.append("#");
-        stringBuffer.append(tunnelStatus);
-        stringBuffer.append("\n");
-        stringBuffer.append("</TunnelStatus>");
-        String fileName = "CFT" + tunnelInfo.getTunnelId() + "_" + DateTime.now().toString("yyyyMMddHHmmss") + "." + tunnelInfo.getFileType();
-        try {
-            log.info("向{}{}文件写入数据{}", tunnelInfo.getFilePath(), fileName, stringBuffer.toString());
-            write2File(tunnelInfo.getFilePath(), fileName, stringBuffer.toString());
-            pool.schedule(() -> {
-                File fileFind = new File(tunnelInfo.getFilePath() + File.separator + fileName);
-                if (fileFind.exists()) {
-                    fileFind.renameTo(new File(tunnelInfo.getFilePath() + File.separator + "CFT" + tunnelInfo.getTunnelId() + "_" + DateTime.now().toString("yyyyMMddHHmmss") + "." + tunnelInfo.getFileType()));
-                }
-            }, 3, TimeUnit.SECONDS);
-            log.info("向{}{}文件写入完成", tunnelInfo.getFilePath(), fileName);
-        } catch (IOException e) {
-            log.error("向{}{}文件写入失败", tunnelInfo.getFilePath(), fileName);
-            e.printStackTrace();
-        }
-    }
-
-
-    /**
-     * 定时检查文件是否传输完成 穿过隔离文件
-     */
-    public void checkFileIsPassedTask() {
-        File file = new File(this.tunnelInfo.getFilePath());
-        if (file.exists() && file.isDirectory()) {
-            RecurringTaskContainer.getInstance().addRecurringTask(60, "查看本通道文件是否被隔离传输成功", () -> {
-                File[] files = file.listFiles();
-                String fileName = "";
-                DateTime fileTime;
-                //遍历反向隔离扫描路径 查看是否有本通道生成的文件,如果有一分钟之前本通道生成的文件仍没被传输走,便认为通道被阻断,
-                for (File f : files) {
-                    try {
-                        fileName = f.getName();
-                        if (fileName.startsWith("CFT" + this.tunnelInfo.getTunnelId())) {
-                            if (fileName.contains("_")) {
-                                fileTime = DateTime.parse(fileName.substring(fileName.indexOf("_") + 1, fileName.indexOf(".")), DATE_TIME_FORMATTER);
-                                if (fileTime.plusMinutes(1).isBeforeNow()) {
-                                    setTunnelStatus(TunnelStatus.CONNECTEDANDCOMMERROR);
-                                   log.warn("存在未被反向隔离传输的文件{}",fileName);
-                                    //TODO 文件滞留处理逻辑
-                                    return null;
-                                }
-                            }
-                        }
-                    }catch (Exception e){
-                        log.error("检查生成协议数据文件传输情况时发生异常",e);
-                    }
-                }
-                setTunnelStatus(TunnelStatus.CONNECTED);
-                return null;
-            });
-        }
-
-
-    }
-
-
-    public void write2File(String path, String fileName, String context) throws IOException {
-        boolean f = System.getProperty("os.name").toLowerCase().contains("windows");
-        if (!f) {
-            String c = "echo \"" + context + "\" >" + path + File.separator + fileName;
-            log.info("执行命令: " + c);
-            String[] command = {"/bin/sh", "-c", c};
-            try {
-                Runtime.getRuntime().exec(command);
-            } catch (Exception e) {
-                log.warn("发生异常", e);
-            }
-        } else {
-            File directory = new File(path);
-            if (!directory.exists()) {
-                directory.mkdirs();
-            }
-            File file = new File(path + "/" + fileName);
-            if (!file.exists()) {
-                try {
-                    file.createNewFile();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-            PrintStream stream = new PrintStream(file);
-            stream.print(context);
-            stream.flush();
-            stream.close();
-        }
-    }
-}

+ 0 - 34
ipp-client/src/main/java/com/jiayue/ipfcst/client/protocol2file/GenerateFileTunnelInfo.java

@@ -1,34 +0,0 @@
-package com.jiayue.ipfcst.client.protocol2file;
-
-import com.syjy.DataExchangeException;
-import com.syjy.ReadConfigFile;
-import com.syjy.tunnelinfo.BaseTunnelInfo;
-import com.syjy.tunnelinfo.TunnelType;
-import jxl.Cell;
-import lombok.Data;
-
-/**
- * @author: xiuwei
- * @version:
- */
-@Data
-public class GenerateFileTunnelInfo extends BaseTunnelInfo {
-	public  GenerateFileTunnelInfo(){
-		this.tunnelType=TunnelType.GENERATEFILE;
-	}
-
-	String tunnelId;
-
-	String filePath;
-
-	//文件后缀名
-	String fileType;
-
-
-	@Override
-	public void setByRow(Cell[] cells) throws DataExchangeException {
-		this.setTunnelId(ReadConfigFile.getCellContext(cells[0]));
-		this.setFilePath(ReadConfigFile.getCellContext(cells[2]));
-		this.setFileType(ReadConfigFile.getCellContext(cells[5]));
-	}
-}

+ 0 - 109
ipp-client/src/main/java/com/jiayue/ipfcst/client/protocol2file/GenerateFileUtil.java

@@ -1,109 +0,0 @@
-package com.jiayue.ipfcst.client.protocol2file;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-
-/**
- * 生成文件的工具类
- *
- * @author: xiuwei
- * @version:
- */
-public class GenerateFileUtil {
-
-
-	/**
-	 * 读取字串的编码格式
-	 */
-	private static final String DEFAULT_ENCODING = "GBK";
-
-	/**
-	 * 最长读取字节
-	 */
-	private static final int PROTECTED_LENGTH = 51200;
-
-	private GenerateFileUtil() {
-	}
-
-	public static final GenerateFileUtil getInstance() {
-		return LazyHolder.INSTANCE;
-	}
-
-	/**
-	 * 为了单例的内部类
-	 *
-	 * @return 实例
-	 */
-	private static class LazyHolder {
-		private static final GenerateFileUtil INSTANCE = new GenerateFileUtil();
-	}
-
-
-	private String demoFileContent;
-
-
-	/**
-	 * 读取输入流里面的字符串
-	 *
-	 * @param input
-	 * @return
-	 * @throws Exception
-	 */
-	public String readInfoStream(InputStream input) throws Exception {
-		if (input == null) {
-			throw new Exception("输入流为null");
-		}
-		//字节数组
-		byte[] bcache = new byte[2048];
-		//每次读取的字节长度
-		int readSize = 0;
-		//总字节长度
-		int totalSize = 0;
-		ByteArrayOutputStream infoStream = new ByteArrayOutputStream();
-		try {
-			//一次性读取2048字节
-			while ((readSize = input.read(bcache)) > 0) {
-				totalSize += readSize;
-				if (totalSize > PROTECTED_LENGTH) {
-					throw new Exception("输入流超出50K大小限制");
-				}
-				//将bcache中读取的input数据写入infoStream
-				infoStream.write(bcache, 0, readSize);
-			}
-		} catch (IOException e1) {
-			throw new Exception("输入流读取异常");
-		} finally {
-			try {
-				//输入流关闭
-				input.close();
-			} catch (IOException e) {
-				throw new Exception("输入流关闭异常");
-			}
-		}
-
-		try {
-			return infoStream.toString(DEFAULT_ENCODING);
-		} catch (UnsupportedEncodingException e) {
-			throw new Exception("输出异常");
-		}
-	}
-
-
-	/**
-	 * 获取模版文件的内容
-	 *
-	 * @return
-	 * @throws Exception
-	 */
-	public String getDemoFileContent() throws Exception {
-		if (demoFileContent == null) {
-			InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("example.xml");
-			demoFileContent = readInfoStream(inputStream);
-		}
-		return demoFileContent;
-	}
-
-
-}

+ 0 - 213
ipp-client/src/main/java/com/jiayue/ipfcst/client/protocol2file/ModbusRtuDataGatherWithTcpServer.java

@@ -1,213 +0,0 @@
-package com.jiayue.ipfcst.client.protocol2file;
-
-
-import com.syjy.DataExchangeException;
-import com.syjy.container.ProtocolDataContainer;
-import com.syjy.tunnelinfo.DataPoint;
-import com.syjy.tunnelinfo.TunnelStatus;
-import com.syjy.tunnelworker.BaseProtocolTunnel;
-import com.syjy.tunnelworker.gathers.DataGatherInterface;
-import com.syjy.tunnelworker.workassist.SingleThreadPoolExecutorUtil;
-import wei.yigulu.modbus.domain.FunctionCode;
-import wei.yigulu.modbus.domain.Obj4RequestCoil;
-import wei.yigulu.modbus.domain.Obj4RequestRegister;
-import wei.yigulu.modbus.domain.datatype.BooleanModbusDataInRegister;
-import wei.yigulu.modbus.domain.datatype.IModbusDataType;
-import wei.yigulu.modbus.domain.datatype.ModbusDataTypeEnum;
-import wei.yigulu.modbus.domain.datatype.NumericModbusData;
-import wei.yigulu.modbus.exceptiom.ModbusException;
-import wei.yigulu.modbus.utils.ModbusRequestDataUtils;
-import wei.yigulu.netty.MasterInterface;
-
-import java.math.BigDecimal;
-import java.net.InetSocketAddress;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * modbus协议TCP数据采集
- *
- * @author 修唯xiuwei
- * @version 3.0
- */
-
-public class ModbusRtuDataGatherWithTcpServer extends BaseProtocolTunnel<GatherModbusRtuByTcpServerTunnelInfo, ModbusRtuMasterWithTcpServer> implements DataGatherInterface {
-
-	/**
-	 * 通道点位  ---- 点位对象
-	 */
-	Map<Integer, DataPoint> dataPointMap;
-
-
-	/**
-	 * 0: 线圈   1:寄存器
-	 */
-	private  int functionFlag ;
-
-	/**
-	 * 向modbus slave端发送的请求
-	 */
-	private List<Obj4RequestRegister> requestRegisterList;
-
-
-	/**
-	 * 向modbus slave端发送线圈的请求
-	 */
-	private List<Obj4RequestCoil> requestCoilList;
-
-
-	/**
-	 * 构造方法
-	 *
-	 * @param gatherModbusRtuByTcpServerTunnelInfo 通道信息
-	 */
-	public ModbusRtuDataGatherWithTcpServer(final GatherModbusRtuByTcpServerTunnelInfo gatherModbusRtuByTcpServerTunnelInfo) {
-		super(gatherModbusRtuByTcpServerTunnelInfo);
-	}
-
-	@Override
-	public ModbusRtuDataGatherWithTcpServer buildTunnel() throws DataExchangeException {
-		protocolBuilder = new MyModbusRtuMasterWithTcpServer(tunnelInfo.getSelfPort());
-		protocolBuilder.setLog(this.log);
-		setTunnelStatus(TunnelStatus.BUILT);
-		protocolTunnelContainer.addTunnel(this);
-		log.info("成功创建ModbusTCPMaster通道对象:{}", this.tunnelInfo.getTunnelName());
-		return this;
-	}
-
-	@Override
-	public void parseGatherDataPoint() throws DataExchangeException {
-		log.info("解析该通道下所管理的点位");
-		List<DataPoint> dataPoints = this.tunnelInfo.getDataPoints();
-		if (dataPoints == null || dataPoints.size() == 0) {
-			return;
-		}
-		if (this.tunnelInfo.getFunctionCode() == 1 || this.tunnelInfo.getFunctionCode() == 2) {
-			functionFlag =0;
-		}else {
-			functionFlag =1;
-		}
-		Map<Integer, ModbusDataTypeEnum> points = new HashMap<>();
-		List<Integer> coilPoints = new ArrayList<>();
-		this.dataPointMap = new HashMap<>();
-		if (functionFlag ==0) {
-			for (DataPoint d : dataPoints) {
-				this.dataPointMap.put(d.getProtocolPoint(), d);
-				coilPoints.add(d.getProtocolPoint());
-			}
-			try {
-				this.requestCoilList=ModbusRequestDataUtils.splitModbusRequest(coilPoints, this.tunnelInfo.getSlaveId(), FunctionCode.valueOf(this.tunnelInfo.getFunctionCode()));
-			} catch (ModbusException e) {
-				throw new DataExchangeException(e.getCode(), e.getMsg());
-			}
-		} else {
-			for (DataPoint d : dataPoints) {
-				this.dataPointMap.put(d.getProtocolPoint(), d);
-				points.put(d.getProtocolPoint(), d.getDataType());
-			}
-			try {
-				this.requestRegisterList=ModbusRequestDataUtils.splitModbusRequest(points, this.tunnelInfo.getSlaveId(), FunctionCode.valueOf(this.tunnelInfo.getFunctionCode()));
-			} catch (ModbusException e) {
-				throw new DataExchangeException(e.getCode(), e.getMsg());
-			}
-		}
-		log.info("解析该通道下所管理的点位完成");
-	}
-
-
-	@Override
-	public ModbusRtuDataGatherWithTcpServer startTunnel() throws DataExchangeException {
-		log.info("modbus TCP master {} 通道开始连接", getTunnelInfo().getTunnelName());
-		protocolTunnelContainer.addUpdateDateTask(this);
-		try {
-			SingleThreadPoolExecutorUtil.executeBySingleThreadExecutor(() -> {
-				try {
-					this.protocolBuilder.create();
-					log.error("modbus TCP master  创建通道失败");
-					setTunnelStatus(TunnelStatus.LISTENPORTFAIL);
-				} catch (Exception e) {
-					log.error("modbus TCP master  创建通道失败", e);
-					setTunnelStatus(TunnelStatus.LISTENPORTFAIL);
-				}
-			});
-		} catch (Exception e) {
-			log.error("modbus TCP master 创建通道失败", e);
-			setTunnelStatus(TunnelStatus.LISTENPORTFAIL);
-			throw new DataExchangeException(10007, "modbus TCP master创建通道失败");
-		}
-		if (!TunnelStatus.LISTENPORTFAIL.equals(getTunnelStatus())) {
-			setTunnelStatus(TunnelStatus.LISTENPORTSUCCESS);
-		}
-		return this;
-	}
-
-
-	@Override
-	public BaseProtocolTunnel tunnelStop() throws DataExchangeException {
-		if (this.protocolBuilder != null) {
-			this.protocolBuilder.stop();
-		}
-		log.info("关闭 modbus TCP master 通道 {}", this.tunnelInfo.getTunnelName());
-		return super.tunnelStop();
-	}
-
-
-	@Override
-	public void getDataFromProtocol() throws DataExchangeException {
-		if (this.protocolBuilder.getChannels().size() == 0) {
-			log.trace("当前没有客户端联入");
-			setTunnelStatus(TunnelStatus.LISTENPORTSUCCESSANDNOCONN);
-			return;
-		}
-		log.info("获取到从通道中获取的点位");
-		try {
-			if(functionFlag ==1  && this.requestRegisterList!=null) {
-				Map<Integer, IModbusDataType> map = ModbusRequestDataUtils.getRegisterData((MasterInterface) this.protocolBuilder, this.requestRegisterList);
-				if (map==null ||map.size()==0){
-					this.setTunnelStatus(TunnelStatus.LISTENPORTSUCCESSANDCONNANDCOMMERROR);
-				}else{
-					this.setTunnelStatus(TunnelStatus.LISTENPORTSUCCESSANDCONN);
-				}
-				for (Integer i : map.keySet()) {
-					if (map.get(i) instanceof NumericModbusData) {
-						if (map==null ||map.size()==0){
-							this.setTunnelStatus(TunnelStatus.LISTENPORTSUCCESSANDCONNANDCOMMERROR);
-						}else{
-							this.setTunnelStatus(TunnelStatus.LISTENPORTSUCCESSANDCONN);
-						}
-						ProtocolDataContainer.getInstance().putNumber(dataPointMap.get(i).getId(), ((NumericModbusData) map.get(i)).getValue().multiply(BigDecimal.valueOf(dataPointMap.get(i).getMag())));
-					} else {
-						ProtocolDataContainer.getInstance().putBoolean(dataPointMap.get(i).getId(), ((BooleanModbusDataInRegister) map.get(i)).getValue(0));
-					}
-				}
-			}else if(functionFlag==0 && this.requestCoilList!=null){
-				Map<Integer, Boolean> map = ModbusRequestDataUtils.getCoilData(this.protocolBuilder, this.requestCoilList);
-				for (Integer i : map.keySet()) {
-						ProtocolDataContainer.getInstance().putBoolean(dataPointMap.get(i).getId(), map.get(i));
-				}
-			}
-		} catch (ModbusException e) {
-			if("无客户端连接".equals(e.getMsg())){
-				this.setTunnelStatus(TunnelStatus.LISTENPORTSUCCESSANDNOCONN);
-			}
-			this.setTunnelStatus(TunnelStatus.LISTENPORTSUCCESSANDCONNANDCOMMERROR);
-			throw new DataExchangeException(0,e.getMsg());
-		}
-	}
-
-
-
-	class MyModbusRtuMasterWithTcpServer extends ModbusRtuMasterWithTcpServer{
-
-		public MyModbusRtuMasterWithTcpServer(int port) {
-			super(port);
-		}
-
-		public void connected(InetSocketAddress ipSocket) {
-			setTunnelStatus(TunnelStatus.LISTENPORTSUCCESSANDCONN);
-		}
-	}
-
-}

+ 0 - 74
ipp-client/src/main/java/com/jiayue/ipfcst/client/protocol2file/ModbusRtuMasterWithTcpServer.java

@@ -1,74 +0,0 @@
-package com.jiayue.ipfcst.client.protocol2file;
-
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-import io.netty.channel.Channel;
-import wei.yigulu.modbus.domain.synchronouswaitingroom.RtuSynchronousWaitingRoom;
-import wei.yigulu.modbus.domain.synchronouswaitingroom.SynchronousWaitingRoom;
-import wei.yigulu.modbus.exceptiom.ModbusException;
-import wei.yigulu.modbus.netty.ModbusMasterBuilderInterface;
-import wei.yigulu.modbus.netty.ModbusRtuMasterDelimiterHandler;
-import wei.yigulu.netty.AbstractTcpServerBuilder;
-import wei.yigulu.netty.MasterInterface;
-import wei.yigulu.netty.ProtocolChannelInitializer;
-import wei.yigulu.utils.DataConvertor;
-
-/**
- * 以TCPserver的通讯方式  传输RTU协议  Master角色
- *
- * @author: xiuwei
- * @version:
- */
-public class ModbusRtuMasterWithTcpServer extends AbstractTcpServerBuilder implements ModbusMasterBuilderInterface, MasterInterface {
-
-	private SynchronousWaitingRoom synchronousWaitingRoom;
-
-	public ModbusRtuMasterWithTcpServer(int port) {
-		super(port);
-	}
-
-	@Override
-	protected ProtocolChannelInitializer getOrCreateChannelInitializer() {
-		return new ProtocolChannelInitializer(this) {
-			@Override
-			protected void initChannel(Channel ch) throws Exception {
-				ch.pipeline().addLast(new ModbusRtuMasterDelimiterHandler().setLog(getLog()));
-				ch.pipeline().addLast(new ModbusRtuMasterWithTcpServerHandler((ModbusRtuMasterWithTcpServer) builder));
-			}
-		};
-	}
-
-	@Override
-	public SynchronousWaitingRoom getOrCreateSynchronousWaitingRoom() throws ModbusException {
-		if (this.synchronousWaitingRoom == null) {
-			this.synchronousWaitingRoom = new RtuSynchronousWaitingRoom();
-		}
-		return this.synchronousWaitingRoom;
-	}
-
-	@Override
-	public void sendFrameToOpposite(byte[] bytes) {
-		if(getChannels().size()>0){
-			getChannels().forEach(c->{
-				getLog().info("se ==> "+c.remoteAddress()+" :" + DataConvertor.Byte2String(bytes));
-				c.writeAndFlush(Unpooled.copiedBuffer(bytes));
-			});
-		}else{
-			throw new RuntimeException("无客户端连接");
-		}
-	}
-
-	@Override
-	public void sendFrameToOpposite(ByteBuf byteBuf) {
-		if(getChannels().size()>0){
-			getChannels().forEach(c->{
-				getLog().info("se ==> "+c.remoteAddress()+" :" + DataConvertor.ByteBuf2String(byteBuf));
-				c.writeAndFlush(Unpooled.copiedBuffer(byteBuf));
-			});
-		}else{
-			throw new RuntimeException("无客户端连接");
-		}
-	}
-
-
-}

+ 0 - 73
ipp-client/src/main/java/com/jiayue/ipfcst/client/protocol2file/ModbusRtuMasterWithTcpServerHandler.java

@@ -1,73 +0,0 @@
-package com.jiayue.ipfcst.client.protocol2file;
-
-import io.netty.buffer.ByteBuf;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.SimpleChannelInboundHandler;
-import org.slf4j.Logger;
-import wei.yigulu.modbus.netty.ModbusMasterBuilderInterface;
-import wei.yigulu.utils.DataConvertor;
-
-import java.net.InetSocketAddress;
-
-/**
- * 以TCPserver的通讯方式  传输RTU协议  Master角色 处理器
- * @author: xiuwei
- * @version:
- */
-public class ModbusRtuMasterWithTcpServerHandler extends SimpleChannelInboundHandler<ByteBuf> {
-
-	protected Logger log;
-
-	/**
-	 * Slave 104 handle
-	 *
-	 * @param builder slaver builder
-	 */
-	public ModbusRtuMasterWithTcpServerHandler(ModbusRtuMasterWithTcpServer builder) {
-		this.builder = builder;
-		this.log = builder.getLog();
-	}
-
-	protected ModbusRtuMasterWithTcpServer builder;
-
-
-	@Override
-	public void channelRead0(ChannelHandlerContext ctx, ByteBuf byteBuf) throws Exception {
-		//收数据
-		log.info("re <== " + DataConvertor.ByteBuf2String(byteBuf));
-		((ModbusMasterBuilderInterface) this.builder).getOrCreateSynchronousWaitingRoom().setData(byteBuf.nioBuffer());
-	}
-
-
-	@Override
-	public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
-		log.error("ModbusSlave交互时发生异常", cause);
-	}
-
-
-	@Override
-	public void channelActive(ChannelHandlerContext ctx) throws Exception {
-		InetSocketAddress ipSocket = (InetSocketAddress) ctx.channel().remoteAddress();
-		String clientIp = ipSocket.getAddress().getHostAddress();
-		Integer clientPort = ipSocket.getPort();
-		if (!this.builder.getConnectFilterManager().verdict(ctx.channel())) {
-			ctx.channel().close();
-			log.info(clientIp + ":" + clientPort + "客户端被过滤链拦截,已关闭通道");
-			return;
-		}
-		log.info(clientIp + ":" + clientPort + "客户端连接");
-		this.builder.connected(ipSocket);
-		this.builder.getChannels().add(ctx.channel());
-	}
-
-
-	@Override
-	public void channelInactive(ChannelHandlerContext ctx) throws Exception {
-		InetSocketAddress ipSocket = (InetSocketAddress) ctx.channel().remoteAddress();
-		String clientIp = ipSocket.getAddress().getHostAddress();
-		Integer clientPort = ipSocket.getPort();
-		log.info(clientIp + ":" + clientPort + "客户端断开连接");
-		this.builder.getChannels().remove(ctx.channel());
-		this.builder.disconnected(ipSocket);
-	}
-}

+ 0 - 18
ipp-client/src/main/java/com/jiayue/ipfcst/client/protocol2file/MyDataPoint.java

@@ -1,18 +0,0 @@
-package com.jiayue.ipfcst.client.protocol2file;
-
-import com.syjy.tunnelinfo.DataPoint;
-import lombok.Getter;
-import lombok.Setter;
-
-public class MyDataPoint extends DataPoint {
-
-    @Setter
-    @Getter
-    EquipmentType equipmentType;
-
-    @Setter
-    @Getter
-    String equipmentAttr;
-
-
-}

+ 0 - 182
ipp-client/src/main/java/com/jiayue/ipfcst/client/protocol2file/MyReadConfigFile.java

@@ -1,182 +0,0 @@
-package com.jiayue.ipfcst.client.protocol2file;
-
-import com.syjy.DataExchangeException;
-import com.syjy.FileUtils;
-import com.syjy.tunnelinfo.BaseTunnelInfo;
-import com.syjy.tunnelinfo.DataPoint;
-import com.syjy.tunnelinfo.gathertunnelinfo.*;
-import jxl.Cell;
-import jxl.Sheet;
-import jxl.Workbook;
-import jxl.WorkbookSettings;
-import jxl.read.biff.BiffException;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
-import wei.yigulu.modbus.domain.datatype.ModbusDataTypeEnum;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * 读取配置文件
- *
- * @author: xiuwei
- * @version:
- */
-@Slf4j
-public class MyReadConfigFile {
-
-
-    public static List<BaseTunnelInfo> readConfigFile() throws IOException, BiffException {
-        List<BaseTunnelInfo> tunnelInfos = new ArrayList<>();
-        File configFile = getConfigFile();
-        if (configFile == null) {
-            return tunnelInfos;
-        }
-        InputStream is = new FileInputStream(configFile);
-        WorkbookSettings ws = new WorkbookSettings();
-        ws.setCellValidationDisabled(true);
-        Workbook wb = Workbook.getWorkbook(is, ws);
-        Sheet[] sheets = wb.getSheets();
-        String cellValue;
-        BaseTunnelInfo tunnelInfo;
-        List<DataPoint> dataPoints;
-        MyDataPoint dataPoint;
-        ModbusDataTypeEnum dataType;
-        int sheetI = 1;
-        for (Sheet sheet : sheets) {
-            if ("attribute".equals(sheet.getName())) {
-                continue;
-            }
-            try {
-                cellValue = getCellContext(sheet.getCell(1, 0));
-                switch (cellValue) {
-                    case "104M":
-                        tunnelInfo = new Gather104TcpTunnelInfo();
-                        break;
-                    case "ModbusTCPM":
-                        tunnelInfo = new GatherModbusTcpTunnelInfo();
-                        break;
-                    case "ModbusTCPM_锦州阳光":
-                        tunnelInfo = new GatherModbusRtuByTcpServerTunnelInfo();
-                        break;
-                    case "ModbusRTUM":
-                        tunnelInfo = new GatherModbusRtuTunnelInfo();
-                        break;
-                    case "CDTM":
-                        tunnelInfo = new GatherCdtRtuTunnelInfo();
-                        break;
-                    case "GenFile":
-                        tunnelInfo = new GenerateFileTunnelInfo();
-                        break;
-                    case "Calculator":
-                        tunnelInfo = new CalculatorTunnelInfo();
-                        break;
-                    case "气象站":
-                        continue;
-                    default:
-                        throw new DataExchangeException(4002, "通道类型异常");
-                }
-                tunnelInfo.setId(sheetI + "");
-                tunnelInfo.setTunnelName(sheet.getName() + sheetI);
-                tunnelInfo.setByRow(sheet.getRow(2));
-                tunnelInfo.setRefreshInterval(Integer.parseInt(getCellContext(sheet.getCell(3, 0))));
-                dataPoints = new ArrayList<>();
-                for (int i = 4; i < sheet.getRows(); i++) {
-                    dataPoint = new MyDataPoint();
-                    try {
-                        dataPoint.setId(Integer.parseInt(getCellContext(sheet.getCell(0, i))));
-                    } catch (DataExchangeException e) {
-                        continue;
-                    }
-                    if ("Calculator".equals(getCellContext(sheet.getCell(1, 0)))) {
-                        dataPoint.setFormula(getCellContext(sheet.getCell(1, i)));
-                    } else {
-                        dataPoint.setProtocolPoint(Integer.parseInt(getCellContext(sheet.getCell(1, i))));
-                    }
-                    cellValue = getCellContext(sheet.getCell(2, i));
-                    if ("遥信".equals(cellValue)) {
-                        dataType = ModbusDataTypeEnum.A16;
-                    } else if ("遥测".equals(cellValue)) {
-                        dataType = ModbusDataTypeEnum.ABCD;
-                    } else {
-                        dataType = ModbusDataTypeEnum.valueOf(cellValue);
-                    }
-                    dataPoint.setDataType(dataType);
-                    dataPoint.setMag(Double.parseDouble(getCellContext(sheet.getCell(3, i))));
-                    if (sheet.getRow(i).length > 5) {
-                        if ("测风塔".equals(sheet.getCell(4, i).getContents())) {
-                            dataPoint.setEquipmentType(EquipmentType.WIND_TOWER);
-                            dataPoint.setEquipmentAttr(sheet.getCell(5, i).getContents());
-                        } else if ("气象站".equals(sheet.getCell(4, i).getContents())) {
-                            dataPoint.setEquipmentType(EquipmentType.WEATHER_STATION);
-                            dataPoint.setEquipmentAttr(sheet.getCell(5, i).getContents());
-                        }
-                    }
-                    if (sheet.getRow(i).length > 6 && sheet.getCell(6, i) != null && !"".equals(sheet.getCell(6, i).getContents())) {
-                        dataPoint.setSlaveId(Integer.parseInt(getCellContext(sheet.getCell(6, i))));
-                    }
-                    dataPoints.add(dataPoint);
-                }
-                tunnelInfo.setDataPoints(dataPoints);
-                tunnelInfos.add(tunnelInfo);
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-            sheetI++;
-        }
-        return tunnelInfos;
-    }
-
-    public static String getCellContext(Cell cell) throws DataExchangeException {
-        if (cell == null) {
-            throw new DataExchangeException(4001, "配置文件缺少配置内容," + cell.getRow() + "行" + cell.getColumn() + "列");
-        }
-        String val = cell.getContents();
-        if (StringUtils.isNoneEmpty(val)) {
-            return val;
-        } else {
-            throw new DataExchangeException(4001, "配置文件缺少配置内容," + cell.getRow() + "行" + cell.getColumn() + "列");
-        }
-    }
-
-    public static File getConfigFile() {
-        // configFile1 是jar包同级目录
-        File configFile1 = new File(FileUtils.getResourcesPath(MyReadConfigFile.class));
-        //configFile2 是jar包的父级目录的同级目录
-        File configFile2 = null;
-        if (configFile1 != null) {
-            configFile2 = configFile1.getParentFile();
-        }
-        File[] files = new File[0];
-        if (configFile2 != null) {
-            files = configFile2.listFiles();
-        }
-        if (files != null) {
-            for (File f : files) {
-                if (f.getName().contains("pointconfig.xls")) {
-                    log.info("在jar包上层目录发现点表配置文件");
-                    return f;
-                }
-            }
-        }
-        if (configFile1 != null) {
-            files = configFile1.listFiles();
-        }
-        if (files != null) {
-            for (File f : files) {
-                if (f.getName().contains("pointconfig.xls")) {
-                    log.info("在jar包同级目录发现点表配置文件");
-                    return f;
-                }
-            }
-        }
-        return null;
-    }
-
-
-}

+ 0 - 142
ipp-client/src/main/java/com/jiayue/ipfcst/client/protocol2file/PackageWindTowerOrWeatherStationData.java

@@ -1,142 +0,0 @@
-package com.jiayue.ipfcst.client.protocol2file;
-
-import com.jiayue.ipfcst.client.domain.entity.BaseStatusData;
-import com.jiayue.ipfcst.client.utils.Constant;
-import com.syjy.container.ProtocolDataContainer;
-import lombok.extern.slf4j.Slf4j;
-import org.joda.time.DateTime;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * 包风塔或气象站数据
- *
- * @author xiuwei
- * @date 2022/04/22
- */
-@Slf4j
-public class PackageWindTowerOrWeatherStationData<T extends BaseStatusData> {
-
-    private  final  T t ;
-
-    public PackageWindTowerOrWeatherStationData(T t){
-        this.t=t;
-        this.equipmentType= this.t.getEquipmentType();
-    }
-
-    /**
-     * 环境监测仪attrs
-     */
-    private static final Map<String,String> WEATHER_STATION_ATTRS =new HashMap<>();
-
-   static {
-       WEATHER_STATION_ATTRS.put("总辐射","globalR");
-       WEATHER_STATION_ATTRS.put("直辐射","directR");
-       WEATHER_STATION_ATTRS.put("散辐射","diffuseR");
-       WEATHER_STATION_ATTRS.put("斜辐射","obliqueR");
-       WEATHER_STATION_ATTRS.put("总辐射累积","globalRDA");
-       WEATHER_STATION_ATTRS.put("直辐射累积","directRDA");
-       WEATHER_STATION_ATTRS.put("散辐射累积","diffuseRDA");
-       WEATHER_STATION_ATTRS.put("斜辐射累积","obliqueRDA");
-       WEATHER_STATION_ATTRS.put("日照小时数","hourDA");
-       WEATHER_STATION_ATTRS.put("环境温度","airT");
-       WEATHER_STATION_ATTRS.put("背板温度","cellT");
-       WEATHER_STATION_ATTRS.put("湿度","rh");
-       WEATHER_STATION_ATTRS.put("气压","p");
-   }
-
-
-    /**
-     * 测风塔attrs
-     */
-    private static final Map<String,String> WIND_TOWER_ATTRS =new HashMap<>();
-
-    static {
-        WIND_TOWER_ATTRS.put("10M风速","wsInst10");
-        WIND_TOWER_ATTRS.put("10M风向","wdInst10");
-        WIND_TOWER_ATTRS.put("30M风速","wsInst30");
-        WIND_TOWER_ATTRS.put("30M风向","wdInst30");
-        WIND_TOWER_ATTRS.put("50M风速","wsInst50");
-        WIND_TOWER_ATTRS.put("50M风向","wdInst50");
-        WIND_TOWER_ATTRS.put("70M风速","wsInst70");
-        WIND_TOWER_ATTRS.put("70M风向","wdInst70");
-        WIND_TOWER_ATTRS.put("90M风速","wsInst90");
-        WIND_TOWER_ATTRS.put("90M风向","wdInst90");
-        WIND_TOWER_ATTRS.put("100M风速","wsInst100");
-        WIND_TOWER_ATTRS.put("100M风向","wdInst100");
-        WIND_TOWER_ATTRS.put("110M风速","wsInst110");
-        WIND_TOWER_ATTRS.put("110M风向","wdInst110");
-        WIND_TOWER_ATTRS.put("120M风速","wsInst120");
-        WIND_TOWER_ATTRS.put("120M风向","wdInst120");
-        WIND_TOWER_ATTRS.put("温度","tInst");
-        WIND_TOWER_ATTRS.put("湿度","rhInst");
-        WIND_TOWER_ATTRS.put("气压","paInst");
-    }
-
-
-
-    Map<String,MyDataPoint> fileNameAndPoint= new HashMap<>();
-
-
-    /**
-     * 设备类型
-     */
-    private EquipmentType equipmentType;
-
-
-    /**
-     * 数据点位
-     */
-    public List<MyDataPoint> dataPointList =new ArrayList<>();
-
-
-
-    public void addDataPoint(MyDataPoint dataPoint){
-        if(dataPoint.getEquipmentType()!=null && this.equipmentType==dataPoint.getEquipmentType()){
-            this.dataPointList.add(dataPoint);
-        }
-    }
-
-    public void  init(){
-        if(dataPointList!=null && dataPointList.size()!=0 && fileNameAndPoint.size()==0){
-            Map<String,String> map=equipmentType==EquipmentType.WIND_TOWER?WIND_TOWER_ATTRS:WEATHER_STATION_ATTRS;
-            for(MyDataPoint p: this.dataPointList){
-                if(map.containsKey(p.getEquipmentAttr())){
-                    this.fileNameAndPoint.put(map.get(p.getEquipmentAttr()),p);
-                }
-            }
-        }
-    }
-
-
-    public T packageData(){
-        T t1 = null;
-        try {
-            t1= (T) t.getClass().newInstance();
-        } catch (InstantiationException e) {
-            e.printStackTrace();
-        } catch (IllegalAccessException e) {
-            e.printStackTrace();
-        }
-        for (Map.Entry<String,MyDataPoint> e :fileNameAndPoint.entrySet()){
-            try {
-                t1.putNumberValueByFiled(e.getKey(), ProtocolDataContainer.getInstance().getNumber(e.getValue().getId()));
-            }catch (Exception exception){
-                log.error("组装设备数据过程出错",e);
-            }
-        }
-        t1.setStationCode(Constant.cacheClientConfig.getStationCode());
-        t1.setTime(DateTime.now().withSecondOfMinute(0).withMillisOfSecond(0).toDate());
-        return t1;
-    }
-
-
-
-
-
-
-
-}

+ 0 - 133
ipp-client/src/main/java/com/jiayue/ipfcst/client/protocol2file/StartPro2File.java

@@ -1,133 +0,0 @@
-package com.jiayue.ipfcst.client.protocol2file;
-
-import cn.hutool.http.HttpUtil;
-import com.alibaba.fastjson.JSONObject;
-import com.jiayue.ipfcst.client.domain.entity.BaseStatusData;
-import com.jiayue.ipfcst.client.domain.entity.WeatherStationStatusData;
-import com.jiayue.ipfcst.client.domain.entity.WindTowerStatusData;
-import com.jiayue.ipfcst.client.utils.Constant;
-import com.syjy.FileUtils;
-import com.syjy.TunnelBuilder;
-import com.syjy.container.ProtocolDataContainer;
-import com.syjy.container.ProtocolTunnelContainer;
-import com.syjy.container.RecurringTaskContainer;
-import com.syjy.tunnelinfo.BaseTunnelInfo;
-import com.syjy.tunnelinfo.DataPoint;
-import com.syjy.tunnelinfo.TunnelStatus;
-import com.syjy.tunnelinfo.TunnelType;
-import com.syjy.tunnelworker.BaseProtocolTunnel;
-import lombok.extern.slf4j.Slf4j;
-import org.joda.time.DateTime;
-import org.springframework.boot.ApplicationArguments;
-import org.springframework.boot.ApplicationRunner;
-import org.springframework.stereotype.Component;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author: xiuwei
- * @version:
- */
-@Component
-@Slf4j
-public class StartPro2File implements ApplicationRunner {
-
-    PackageWindTowerOrWeatherStationData packageWindTowerOrWeatherStationData;
-
-
-    @Override
-    public void run(ApplicationArguments args) throws Exception {
-        List<BaseTunnelInfo> tunnels = MyReadConfigFile.readConfigFile();
-        if (tunnels.size() == 0) {
-            return;
-        }
-        for (BaseTunnelInfo tunnelInfo : tunnels) {
-            if (tunnelInfo instanceof GenerateFileTunnelInfo) {
-                new GenerateFileTunnel((GenerateFileTunnelInfo) tunnelInfo).buildTunnel().startTunnel();
-            } else if (tunnelInfo instanceof GatherModbusRtuByTcpServerTunnelInfo) {
-                new ModbusRtuDataGatherWithTcpServer((GatherModbusRtuByTcpServerTunnelInfo) tunnelInfo).buildTunnel().startTunnel();
-            } else {
-                TunnelBuilder.buildTunnel(tunnelInfo).startTunnel();
-            }
-            MyDataPoint mp;
-            for (DataPoint d : tunnelInfo.getDataPoints()) {
-                mp = (MyDataPoint) d;
-                if (mp.getEquipmentType() != null) {
-                    if (packageWindTowerOrWeatherStationData == null) {
-                        if (mp.getEquipmentType() == EquipmentType.WEATHER_STATION) {
-                            packageWindTowerOrWeatherStationData = new PackageWindTowerOrWeatherStationData(new WeatherStationStatusData());
-                        } else {
-                            packageWindTowerOrWeatherStationData = new PackageWindTowerOrWeatherStationData(new WindTowerStatusData());
-                        }
-                    } else {
-                        this.packageWindTowerOrWeatherStationData.addDataPoint(mp);
-                    }
-
-                }
-            }
-        }
-        if (this.packageWindTowerOrWeatherStationData != null) {
-            this.packageWindTowerOrWeatherStationData.init();
-        }
-        RecurringTaskContainer.getInstance().addRecurringTask(10, "打印实时数据入文件", () -> {
-            FileUtils.write2File(FileUtils.getResourcesPath(), "realTimeData.log", ProtocolDataContainer.getInstance().toStringFormatted());
-            return null;
-        });
-
-        RecurringTaskContainer.getInstance().addRecurringTask(60, "向云平台上报通道状态", () -> {
-            reportTunnelStatus();
-            return null;
-        });
-        Thread.sleep(30000L);
-
-        RecurringTaskContainer.getInstance().addRecurringTask(60, "向云平台上报设备数据", () -> {
-            if (packageWindTowerOrWeatherStationData != null) {
-                JSONObject jsonObject = new JSONObject();
-                BaseStatusData baseStatusData = packageWindTowerOrWeatherStationData.packageData();
-                jsonObject.put("equipmentType", baseStatusData.getEquipmentType());
-                jsonObject.put("equipmentData", baseStatusData);
-                String resp = HttpUtil.post(Constant.cacheClientConfig.getCloudAddr() + "/environmentDatas", jsonObject.toJSONString());
-                if ("0".equals(JSONObject.parseObject(resp).getString("code"))) {
-                    log.info("上报环境数据至云平台正常");
-                } else {
-                    log.info("上报环境数据至云平台异常");
-                }
-            }
-            return null;
-        });
-    }
-
-
-    /**
-     * 上报通道状态
-     */
-    public void reportTunnelStatus() {
-        Map<String, Object> tunnels = new HashMap<>();
-        for (Map.Entry<String, BaseProtocolTunnel> e : ProtocolTunnelContainer.getInstance().getAllTunnel().entrySet()) {
-            if (TunnelType.GENERATEFILE == e.getValue().getTunnelType()) {
-                if (TunnelStatus.CONNECTEDANDCOMMERROR == e.getValue().getTunnelStatus()) {
-                    tunnels.put(e.getValue().getTunnelInfo().getTunnelName(), "生成文件滞留");
-                } else {
-                    tunnels.put(e.getValue().getTunnelInfo().getTunnelName(), "传输文件正常");
-                }
-            } else {
-                tunnels.put(e.getValue().getTunnelInfo().getTunnelName(), e.getValue().getTunnelStatus().getCnDescribe());
-            }
-            tunnels.put("time", DateTime.now().toString("yyyy-MM-dd HH:mm:ss"));
-        }
-        JSONObject jsonObject = new JSONObject();
-        jsonObject.put("stationCode", Constant.cacheClientConfig.getStationCode());
-        jsonObject.put("tunnelStatus", tunnels);
-        String resp = HttpUtil.post(Constant.cacheClientConfig.getCloudAddr() + "tunnelStatus/", jsonObject.toJSONString());
-        if ("0".equals(JSONObject.parseObject(resp).getString("code"))) {
-            log.info("上报通道状态至云平台正常");
-        } else {
-            log.info("上报通道状态至云平台异常");
-        }
-
-
-    }
-
-}

+ 1 - 1
ipp-client/src/main/java/com/jiayue/ipfcst/client/utils/ClientFileUtils.java

@@ -158,7 +158,7 @@ public class ClientFileUtils {
             try {
                 ClientFileUtils clientFileUtils = new ClientFileUtils();
                 File settingFile ;
-                String stationCode = "J00582";
+                String stationCode = "T00001";
 //                //应对AB机情况的外网初始化场站编码配置
 //                String externalUrl = "http://localhost:8082/api/forcast";
 //                if(clientFileUtils.getPath().contains(gangB)){

+ 1 - 0
ipp-client/src/main/java/com/jiayue/ipfcst/client/utils/UtilTools.java

@@ -83,6 +83,7 @@ public class UtilTools {
                 Thread.sleep(1000);
                 md.renameTo(new File(newFileName));
             }
+            fs.delete();
         } catch (Exception e) {
             log.error("文件移动错误", e);
         }

+ 4 - 2
ipp-client/src/main/resources/application.yml

@@ -1,3 +1,5 @@
+server:
+  port: 6000
 spring:
   devtools:
     restart:
@@ -46,6 +48,6 @@ logging:
 
 downLoadFile:
   #  多个场站下载NWP和DQ以英文逗号分割
-  stationCode: J00580,J00581,J00582
+  stationCode: T00001,J00580,J00581,J00582
 
-zxglPath: D://code//ipp-ahhn//zxgl
+zxglPath: D://code//ipp-ahhn//zxgl