liding
2025-04-23 bc1b3ee367f7e9aef88fc59647a9631f39eca6b5
1.数采 2.国产网分仪
已修改4个文件
已添加5个文件
1765 ■■■■■ 文件已修改
cnas-device/src/main/java/com/ruoyi/device/controller/DeviceController.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-device/src/main/java/com/ruoyi/device/controller/NA7672LTCPController.java 109 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-device/src/main/java/com/ruoyi/device/pojo/NA7672LQueryBean.java 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-device/src/main/java/com/ruoyi/device/pojo/NA7672LRequestBean.java 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-device/src/main/java/com/ruoyi/device/pojo/NA7672LValueVO.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-device/src/main/java/com/ruoyi/device/service/DeviceService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-device/src/main/java/com/ruoyi/device/service/impl/DeviceServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-device/src/main/java/com/ruoyi/device/utils/DataAcquisition.java 470 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-device/src/main/java/com/ruoyi/device/utils/NA7672LTCPClientUtils.java 1053 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cnas-device/src/main/java/com/ruoyi/device/controller/DeviceController.java
@@ -155,6 +155,12 @@
        return deviceService.dataAcquisition(request, dto);
    }
    @ApiOperation("/数采-数据采集")
    @PostMapping("/dataCollection1")
    public Result<?> dataCollection1(HttpServletRequest request, @RequestBody DeviceCollectionDto dto) {
        return deviceService.dataCollection1(request, dto);
    }
    @ApiOperation(value = "维护数采配置")
    @PostMapping("/saveDataAcquisitionConfiguration")
    public Result<?> saveDataAcquisitionConfiguration(@RequestBody DataConfigDto dataConfigList) {
cnas-device/src/main/java/com/ruoyi/device/controller/NA7672LTCPController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,109 @@
package com.ruoyi.device.controller;
import com.ruoyi.common.core.domain.Result;
import com.ruoyi.device.pojo.NA7672LRequestBean;
import com.ruoyi.device.pojo.NA7672LValueVO;
import com.ruoyi.device.utils.NA7672LTCPClientUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.core.io.ClassPathResource;
import org.springframework.web.bind.annotation.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
 * demo è¡¨
 *
 * @author pig
 * @date 2023-07-31 14:07:58
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("tcpClient")
@Api(value = "tcp", tags = "读取网分仪数据")
public class NA7672LTCPController {
    @ApiOperation(value = "获取网分仪所有值", notes = "获取网分仪所有值")
    @PostMapping("/getTCPValuesNew")
    public Result<?> getTCPValuesNew(@RequestBody NA7672LRequestBean requestBean) throws IOException, InterruptedException {
        List<NA7672LValueVO> valueList = new ArrayList<>();
        //设置默认配置,可在yml里进行配置
        String serverIp = requestBean.getServerIp();
        int serverPort = requestBean.getServerPort();
        NA7672LTCPClientUtils tcpClient = new NA7672LTCPClientUtils(serverIp, serverPort);
        //设置全部通道(界面save/recall-调式2,需要本地有state02文件)
        tcpClient.initMemory(requestBean.getMemoryDir());
        String valueUnit = this.getMemoryDirName(requestBean.getMemoryDir());
        //延迟两秒再取值
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        List<NA7672LValueVO> rs = new ArrayList<>();
        if (valueUnit.equals("state01")) {
            rs = tcpClient.getState01AllValue(requestBean);
        } else if (valueUnit.equals("state02")) {
            rs = tcpClient.getState02AllValue(requestBean);
        } else if (valueUnit.equals("state03")) {
            rs = tcpClient.getState03AllValue(requestBean);
        } else if (valueUnit.equals("state04")) {
            rs = tcpClient.getState04AllValue(requestBean);
        } else if (valueUnit.equals("state05")) {
            rs = tcpClient.getState05AllValue(requestBean);
        } else if (valueUnit.equals("state06")) {
            rs = tcpClient.getState06AllValue(requestBean);
        } else if (valueUnit.equals("state07")) {
            rs = tcpClient.getState07AllValue(requestBean);
        } else if (valueUnit.equals("state08")) {
            rs = tcpClient.getState08AllValue(requestBean);
        } else if (valueUnit.equals("autorec")) {
            rs = tcpClient.getStateAutoRecAllValue(requestBean);
        } else {
        }
        return Result.success(rs);
    }
    /*依照约定把前端传递的查询转化为后端接口查询*/
    private String decayLabelOrg2Label(String labelOrg) {
        String label = "decay_0m";
        Pattern pattern = Pattern.compile("(\\d*)M");
        Matcher matcher = pattern.matcher(labelOrg);
        String valueUnit = null;
        if (matcher.find()) {
            valueUnit = matcher.group();
        }
        if (valueUnit != null) {
            label = "decay_" + valueUnit.substring(0, valueUnit.length() - 1) + "m";
        }
        return label;
    }
    /*使用memory_dir的路径解析出类别*/
    private String getMemoryDirName(String pathName) {
        String[] splitString = pathName.split("/");
        String filename_1 = splitString[splitString.length - 1];
        String[] filename_2 = filename_1.split("\\.");
        String filename_3 = filename_2[0];
        return filename_3;
        /*Pattern pattern = Pattern.compile("state(\\d*)");
        Matcher matcher = pattern.matcher(pathName);
        String valueUnit = null;
        if (matcher.find()) {
            valueUnit = matcher.group();
        }
        return valueUnit;*/
    }
}
cnas-device/src/main/java/com/ruoyi/device/pojo/NA7672LQueryBean.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,47 @@
package com.ruoyi.device.pojo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel("NA7672L设备的远程获取查询条件")
public class NA7672LQueryBean {
    @ApiModelProperty("获取类型:1为衰减;2为阻抗;3为驻波比;4为相位差")
    private int fetchType;
    @ApiModelProperty("通道值")
    private int channel;
    @ApiModelProperty("轨迹线")
    private int trace;
    @ApiModelProperty("查询字符,例如decay_400m")
    private String queryLabel;
    @ApiModelProperty("输入的温度")
    private double temperture;
    @ApiModelProperty("输入的长度")
    private double length;
    @ApiModelProperty("输入的周期")
    private double cycle;
    @ApiModelProperty("输入的相位差")
    private double phaValue;
    @ApiModelProperty("输入的电容值")
    private double capacity;
    @ApiModelProperty("预留字段1")
    private int backup1;
    @ApiModelProperty("预留字段2")
    private int backup2;
}
cnas-device/src/main/java/com/ruoyi/device/pojo/NA7672LRequestBean.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,38 @@
package com.ruoyi.device.pojo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
@ApiModel("NA7672L设备的初始化配置")
public class NA7672LRequestBean {
    @ApiModelProperty("地址")
    private String serverIp;
    @ApiModelProperty("端口")
    private int serverPort;
    @ApiModelProperty("配置地址")
    private String memoryDir;
    @ApiModelProperty("查询条件")
    List<NA7672LQueryBean> queryBeans;
    @ApiModelProperty("配置地址")
    private Double temperture;
    @ApiModelProperty("配置地址")
    private Double length;
    @ApiModelProperty("配置地址")
    private Double cycle;
    @ApiModelProperty("配置地址")
    private Double capacity;
}
cnas-device/src/main/java/com/ruoyi/device/pojo/NA7672LValueVO.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,35 @@
package com.ruoyi.device.pojo;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class NA7672LValueVO {
    /*类别,获取类型:1为衰减;2为阻抗;3为驻波比;4为相位差*/
    private int fetchType;
    /*通道*/
    Integer channel;
    /*轨迹线*/
    Integer trace;
    /*markId*/
    Integer mark;
    /*标签*/
    String label;
    /*原始标签*/
    String labelOrg;
    /*整数值*/
    Integer intVal;
    /*浮点值*/
    BigDecimal decimalVal;
    /*测量值*/
    BigDecimal measureValue;
    /*其他值*/
    BigDecimal calculateValue;
    /*单位*/
    String unit;
    /*是否合法,1为合法,0为不合法*/
    int ifLegal = 1;
}
cnas-device/src/main/java/com/ruoyi/device/service/DeviceService.java
@@ -70,4 +70,6 @@
     * @return
     */
    Result<?> determineWhetherToCollectData(String managementNumber, HttpServletRequest request);
    Result<?> dataCollection1(HttpServletRequest request, DeviceCollectionDto dto);
}
cnas-device/src/main/java/com/ruoyi/device/service/impl/DeviceServiceImpl.java
@@ -554,6 +554,11 @@
        }
    }
    @Override
    public Result<?> dataCollection1(HttpServletRequest request, DeviceCollectionDto dto) {
        return null;
    }
    private Map<String, Integer> queryUserMap(List<Device> batch) {
        Set<String> managerNames = batch.stream()
                .map(Device::getEquipmentManagerName)
cnas-device/src/main/java/com/ruoyi/device/utils/DataAcquisition.java
@@ -15,6 +15,7 @@
import javax.script.ScriptEngineManager;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
@@ -139,6 +140,9 @@
                case ".pdf":
                    map = readPdfString(data, userMap, device);
                    break;
                case ".et":
                    map = readEtString(data, userMap, device);
                    break;
                default:
                    map = null;
                    break;
@@ -152,40 +156,262 @@
        }
    }
    private static Map<String, Object> readPdfString(String data, Map<String, List<DataConfig>> dataConfig, Device device) {
    private static Map<String, Object> readEtString(String data, Map<String, List<DataConfig>> dataConfig, Device device) {
        Map<String, Object> map = new HashMap<>();
        // å®šä¹‰ RoHS æŒ‡æ ‡åˆ—表
        List<String> rohsIndicators = Arrays.asList("RoHS指标,镉(Cd)", "RoHS指标,总溴联苯(Br)", "RoHS指标,总铬(Cr)", "RoHS指标,汞(Hg)", "RoHS指标,铅(Pb)");
        dataConfig.forEach((k, v) -> {
            List<Object> list = new ArrayList<>();
            for (int config = 0; config < v.size(); config++) {
                String referx = getRefer(v.get(config).getReferx());
                String result = null;
                // é€šè¿‡\n将字符串分割为行
                String[] aColumnY = data.split("\n");
                List<String> list1 = new ArrayList<>();
                // è¯¥å¾ªçŽ¯å¾—å‡ºç”¨æˆ·é…ç½®çš„yè½´
                for (int i = 0; i < aColumnY.length; i++) {
                    String addDataWithSpaces = referx.replaceAll("", " ");
                    int x = getXOrY(v.get(config).getX(), k, "X");
                    if (aColumnY[i].contains(addDataWithSpaces)) {
                        Matcher matcher = SPATTERN.matcher(aColumnY[i]);
                        while (matcher.find()) {
                            String group = matcher.group();
                            list1.add(group);
                        }
                    }
                    if (ObjectUtils.isNotEmpty(list1)) {
                        result = list1.get(x);
                    }
            List<Object> list;
            boolean containsRoHS = false;
            for (DataConfig item : v) {
                if (rohsIndicators.contains(item.getInsProductItem())) {
                    containsRoHS = true;
                    break;
                }
                if (ObjectUtils.isNotEmpty(result)) {
                    list.add(result);
                }
            }
            if (containsRoHS) {
                list = analyzeEt1Data(data, v, splitIdentifier);
            } else {
                list = analyzeEtData(data, v, splitIdentifier);
            }
            // è¿›è¡Œå…¬å¼è®¡ç®—
            Object resultValue = calculationFormula(list, v.get(0), k, device);
            map.put(k, resultValue);
        });
        return map;
    }
    /**
     * è§å…‰å…‰è°±ä»ª .et文件
     *
     * @param data
     * @param v
     * @param splitIdentifier
     * @return
     */
    private static List<Object> analyzeEt1Data(String data, List<DataConfig> v, String splitIdentifier) {
        List<Object> finalResult = new ArrayList<>();
        List<String> matchingLines = new ArrayList<>();
        // éåކ DataConfig åˆ—表
        for (DataConfig config : v) {
            String referx = getRefer(config.getReferx());
            if (ObjectUtils.isEmpty(referx)) {
                continue;
            }
            // ä½¿ç”¨æ­£åˆ™è¡¨è¾¾å¼æž„建完整匹配的模式
            String regex = "\\b" + Pattern.quote(referx) + "\\b";
            Pattern pattern = Pattern.compile(regex);
            String[] lines = data.replaceAll(" ", "").split("\n");
            // ç­›é€‰å‡ºåŒ…含 referx çš„行
            for (String line : lines) {
                if (pattern.matcher(line).find()) {
                    matchingLines.add(line);
                }
            }
        }
        // éåŽ†åŒ¹é…çš„è¡Œï¼Œæå– splitIdentifier ç¬¬ä¸ƒä¸ªå’Œç¬¬å…«ä¸ªåˆ†éš”符中间的值
        for (String line : matchingLines) {
            int startIndex = -1;
            int endIndex = -1;
            int count = 0;
            int index = 0;
            while ((index = line.indexOf(splitIdentifier, index)) != -1) {
                count++;
                if (count == 7) {
                    startIndex = index + splitIdentifier.length();
                } else if (count == 8) {
                    endIndex = index;
                    break;
                }
                index++;
            }
            if (startIndex != -1 && endIndex != -1) {
                finalResult.add(line.substring(startIndex, endIndex));
            }
        }
        // ç¡®ä¿è¿”回值为数组格式
        if (finalResult.size() == 1) {
            List<Object> singleResultAsArray = new ArrayList<>();
            singleResultAsArray.add(finalResult.get(0));
            return singleResultAsArray;
        }
        return finalResult;
    }
    /**
     * æ‹‰åŠ›æœº.et文件
     *
     * @param data
     * @param v
     * @param splitIdentifier
     * @return
     */
    public static List<Object> analyzeEtData(String data, List<DataConfig> v, String splitIdentifier) {
        List<Object> finalResult = new ArrayList<>();
        for (DataConfig config : v) {
            String referx = getRefer(config.getReferx());
            if (ObjectUtils.isEmpty(referx)) {
                continue;
            }
            String[] lines = data.replaceAll(" ", "").split("\n");
            boolean foundReferx = false;
            List<String> validLines = new ArrayList<>();
            int referxColumnIndex = -1; // ç”¨äºŽå­˜å‚¨referx所在列索引
            // å…ˆæ‰¾å‡ºreferx所在列索引
            for (String line : lines) {
                String[] parts = line.split(splitIdentifier);
                for (int i = 0; i < parts.length; i++) {
                    if (parts[i].contains(referx)) {
                        referxColumnIndex = i;
                        break;
                    }
                }
                if (referxColumnIndex != -1) {
                    break;
                }
            }
            // è‹¥æœªæ‰¾åˆ°åŒ¹é…çš„referx,抛出异常
            if (referxColumnIndex == -1) {
                throw new IllegalArgumentException("请输入正确的x值,文件中未找到与 " + referx + " åŒ¹é…çš„值。");
            }
            for (int i = 0; i < lines.length; i++) {
                String line = lines[i];
                String[] parts = line.split(splitIdentifier, 2);
                if (!foundReferx) {
                    if (containsReferx(parts, referx)) {
                        foundReferx = true;
                    }
                    continue;
                }
                if (i > 0 && foundReferx) {
                    if (parts.length > 0 && isNumeric(parts[0])) {
                        validLines.add(line);
                    }
                }
            }
            for (String line : validLines) {
                String[] parts = line.split(splitIdentifier);
                if (referxColumnIndex < parts.length) {
                    String value = parts[referxColumnIndex].trim();
                    if (value.isEmpty()) {
                        value = "";
                    }
                    finalResult.add(value);
                } else {
                    finalResult.add("");
                }
            }
        }
        return finalResult;
    }
    private static boolean containsReferx(String[] parts, String referx) {
        for (String part : parts) {
            if (part.contains(referx)) {
                return true;
            }
        }
        return false;
    }
    private static boolean isNumeric(String str) {
        try {
            Double.parseDouble(str);
            return true;
        } catch (NumberFormatException e) {
            return false;
        }
    }
    /**
     * è‰²è°±pdf文件需要定位x,y
     *
     * @param data
     * @param dataConfig
     * @param device
     * @return
     */
    private static Map<String, Object> readPdfString(String data, Map<String, List<DataConfig>> dataConfig, Device device) {
        Map<String, Object> map = new HashMap<>();
        dataConfig.forEach((k, v) -> {
            List<Object> list = new ArrayList<>();
            for (int config = 0; config < v.size(); config++) {
                String referX = getRefer(v.get(config).getReferx());
                String referY = getRefer(v.get(config).getRefery());
                String[] aColumnY = data.split("\n");
                for (String line : aColumnY) {
                    if (line.contains(referX) || line.contains(referY)) {
                        list.add(line);
                    }
                }
                int referYColumnIndex = -1;
                for (Object item : list) {
                    // ä½¿ç”¨æ­£åˆ™è¡¨è¾¾å¼ \\s+ åˆ†å‰²å­—符串
                    String[] columns = ((String) item).split("\\s+");
                    for (int i = 0; i < columns.length; i++) {
                        if (columns[i].equals(referY)) {
                            referYColumnIndex = i;
                            break;
                        }
                    }
                    if (referYColumnIndex != -1) {
                        break;
                    }
                }
                List<Object> targetColumnValues = new ArrayList<>();
                if (referYColumnIndex != -1) {
                    for (Object item : list) {
                        String line = (String) item;
                        // è¿‡æ»¤æŽ‰åŒ…含 referY çš„行
                        if (!line.contains(referY)) {
                            String[] columns = line.split("\\s+");
                            if (columns.length > referYColumnIndex) {
                                targetColumnValues.add(columns[referYColumnIndex]);
                            }
                        }
                    }
                }
                Object resultValue = calculationFormula(targetColumnValues, v.get(0), k, device);
                map.put(k, resultValue);
            }
        });
        return map;
    }
    public static List<Object> extractColumnValues(List<Object> list, String columnName) {
        List<Object> columnValues = new ArrayList<>();
        if (list.isEmpty()) {
            return columnValues;
        }
        String[] headers = ((String) list.get(0)).split(",");
        int columnIndex = -1;
        for (int i = 0; i < headers.length; i++) {
            if (headers[i].equals(columnName)) {
                columnIndex = i;
                break;
            }
        }
        if (columnIndex == -1) {
            return columnValues;
        }
        for (int i = 1; i < list.size(); i++) {
            String[] columns = ((String) list.get(i)).split(",");
            if (columnIndex < columns.length) {
                columnValues.add(columns[columnIndex]);
            }
        }
        return columnValues;
    }
    public static Map<String, Object> createFrequency(String entrustCode, String sampleCode, Map<String, Object> map) {
@@ -465,7 +691,7 @@
        ArrayList<Object> listResult = new ArrayList<>();
        Map<String, Object> hashMap = new HashMap<>();
        // å¦‚果不为空,进行公式计算
        if (ObjectUtils.isNotEmpty(dataConfig.getFormula())) {
        if (ObjectUtils.isNotEmpty(dataConfig.getFormula()) && !"(null)".equals(dataConfig.getFormula())) {
            // å¦åˆ™ï¼šæ²¡æœ‰å…¬å¼ä»£è¡¨ä¸éœ€è¦è®¡ç®—,直接提取List里面的数据
            if (ObjectUtils.isEmpty(device.getEntrustCode()) && ObjectUtils.isEmpty(device.getSampleCode())) {
                String s = calculationFormulaList(list, dataConfig.getFormula());
@@ -568,18 +794,194 @@
        Map<String, Object> map = new HashMap<>();
        dataConfig.forEach((k, v) -> {
            List<Object> list = new ArrayList<>();
            // å§”托编号与样品编号不存在,定:1、Y定范围,X定横坐标;2、只存在Y;3、只存在X
            if (ObjectUtils.isEmpty(device.getEntrustCode()) && ObjectUtils.isEmpty(device.getSampleCode())) {
                list = analyzeXlsData(data, v, k, splitIdentifier);
                // å§”托编号与样品编号存在
            } else if (ObjectUtils.isNotEmpty(device.getEntrustCode()) && ObjectUtils.isNotEmpty(device.getSampleCode())) {
                list = analyzeDataEntrustCodAndSampleCode(data, v, k, splitIdentifier, device, entrustCode, sampleCode);
            }
//            // å§”托编号与样品编号不存在,定:1、Y定范围,X定横坐标;2、只存在Y;3、只存在X
//            if (ObjectUtils.isEmpty(device.getEntrustCode()) && ObjectUtils.isEmpty(device.getSampleCode())) {
//                list = analyzeXlsData(data, v, k, splitIdentifier);
//                // å§”托编号与样品编号存在
//            } else if (ObjectUtils.isNotEmpty(device.getEntrustCode()) && ObjectUtils.isNotEmpty(device.getSampleCode())) {
//                list = analyzeDataEntrustCodAndSampleCode(data, v, k, splitIdentifier, device, entrustCode, sampleCode);
//            }
            list = analyzeXlsx1Data(data, v, k, splitIdentifier);
            // è¿›è¡Œå…¬å¼è®¡ç®—
            Object resultValue = calculationFormula(list, v.get(0), k, device);
            map.put(k, resultValue);
        });
        return map;
    }
    private static List<Object> analyzeXlsx1Data(String data, List<DataConfig> v, String k, String splitIdentifier) {
        List<Object> finalResult = new ArrayList<>();
        if (data == null || data.isEmpty()) {
            throw new IllegalArgumentException("输入的数据为空,请检查输入。");
        }
        // åˆ†å‰²æ•°æ®ä¸ºè¡Œ
        String[] lines = data.replaceAll(" ", "").split("\n");
        if (lines.length == 0) {
            throw new IllegalArgumentException("输入的数据没有有效的行,请检查输入。");
        }
        // èŽ·å–è¡¨å¤´
        String[] headers = lines[0].split("\\s+");
        if (headers.length == 0) {
            throw new IllegalArgumentException("表头数据为空,请检查输入格式。");
        }
        // æŸ¥æ‰¾æµ‹è¯•时间列的索引
        int testTimeIndex = -1;
        for (int i = 0; i < headers.length; i++) {
            if (headers[i].contains("测试时间")) {
                testTimeIndex = i;
                break;
            }
        }
        // è‹¥æœªæ‰¾åˆ°æµ‹è¯•时间列,抛出异常
        if (testTimeIndex == -1) {
            throw new IllegalArgumentException("未找到包含 '测试时间' çš„列,请检查表头。");
        }
        // ç”¨äºŽå­˜å‚¨æµ‹è¯•时间为 2400 çš„行数据
        String[] targetLine = null;
        // æŸ¥æ‰¾æµ‹è¯•时间为 2400 çš„行
        for (int i = 1; i < lines.length; i++) {
            try {
                String[] lineData = lines[i].split("\\s+");
                double testTime = Double.parseDouble(lineData[testTimeIndex]);
                if (testTime == 2400) {
                    targetLine = lineData;
                    break;
                }
            } catch (NumberFormatException e) {
                throw new RuntimeException("第 " + (i + 1) + " è¡Œçš„ '测试时间' åˆ—数据无法转换为数字,请检查数据格式。", e);
            } catch (ArrayIndexOutOfBoundsException e) {
                throw new RuntimeException("第 " + (i + 1) + " è¡Œçš„æ•°æ®åˆ—数不足,无法获取 '测试时间' åˆ—,请检查数据格式。", e);
            }
        }
        // è‹¥æœªæ‰¾åˆ°æµ‹è¯•时间为 2400 çš„行,抛出异常
        if (targetLine == null) {
            throw new RuntimeException("未找到测试时间为 2400 çš„æ•°æ®ï¼Œè¯·æ£€æŸ¥æ•°æ®å†…容。");
        }
        for (DataConfig config : v) {
            String referx = getRefer(config.getReferx());
            if (ObjectUtils.isEmpty(referx)) {
                continue;
            }
            // æŸ¥æ‰¾ referx åˆ—的索引
            int referxIndex = -1;
            for (int i = 0; i < headers.length; i++) {
                if (headers[i].trim().contains(referx.trim())) {
                    referxIndex = i;
                    break;
                }
            }
            // è‹¥æœªæ‰¾åˆ° referx åˆ—,抛出异常
            if (referxIndex == -1) {
                throw new IllegalArgumentException("未找到 '" + referx + "' åˆ—,请检查表头和配置。");
            }
            try {
                double value = Double.parseDouble(targetLine[referxIndex]);
                // å››èˆäº”入保留两位小数
                DecimalFormat df = new DecimalFormat("#.00");
                String formattedValue = df.format(value);
                finalResult.add(Double.parseDouble(formattedValue));
            } catch (NumberFormatException e) {
                throw new RuntimeException("'测试时间' ä¸º 2400 çš„行中,'" + referx + "' åˆ—的数据无法转换为数字,请检查数据格式。", e);
            } catch (ArrayIndexOutOfBoundsException e) {
                throw new RuntimeException("'测试时间' ä¸º 2400 çš„行的数据列数不足,无法获取 '" + referx + "' åˆ—,请检查数据格式。", e);
            }
        }
        return finalResult;
    }
    private static List<Object> analyzeXlsxData(String data, List<DataConfig> v, String k, String splitIdentifier) {
        List<Object> finalResult = new ArrayList<>();
        String ss = k;
        // å­˜å‚¨ç¬¦åˆæµ‹è¯•时间范围的数据行
        List<String[]> validLines = new ArrayList<>();
        String[] lines = data.replaceAll(" ", "").split("\n");
        String[] headers = lines[0].split("\\s+");
        int testTimeIndex = -1;
        for (int i = 0; i < headers.length; i++) {
            if ("测试时间".equals(headers[i])) {
                testTimeIndex = i;
                break;
            }
        }
        if (testTimeIndex == -1) {
            return finalResult;
        }
        // ç­›é€‰å‡ºæµ‹è¯•时间在 300 åˆ° 1500 ä¹‹é—´çš„æ•°æ®è¡Œ
        for (int i = 1; i < lines.length; i++) {
            String[] lineData = lines[i].split("\\s+");
            try {
                double testTime = Double.parseDouble(lineData[testTimeIndex]);
                if (testTime > 300 && testTime <= 1500) {
                    validLines.add(lineData);
                } else if (testTime > 1500) {
                    break;
                }
            } catch (NumberFormatException e) {
                continue;
            }
        }
        for (DataConfig config : v) {
            String referx = getRefer(config.getReferx());
            if (ObjectUtils.isEmpty(referx)) {
                continue;
            }
            int referxIndex = -1;
            for (int i = 0; i < headers.length; i++) {
                if (referx.equals(headers[i])) {
                    referxIndex = i;
                    break;
                }
            }
            if (referxIndex == -1) {
                continue;
            }
            List<Double> values = new ArrayList<>();
            for (String[] lineData : validLines) {
                try {
                    double value = Double.parseDouble(lineData[referxIndex]);
                    values.add(value);
                } catch (NumberFormatException e) {
                    continue;
                }
            }
            Object result;
            if ("HRR".equals(referx) || "SPR".equals(referx) || "FIGRA".equals(referx)) {
                result = values.stream().mapToDouble(Double::doubleValue).max().orElse(0);
            } else if ("THR".equals(referx) || "TSP".equals(referx)) {
                result = values.stream().mapToDouble(Double::doubleValue).sum();
            } else {
                continue;
            }
            if (result != null) {
                // å››èˆäº”入保留两位小数
                DecimalFormat df = new DecimalFormat("#.00");
                result = Double.parseDouble(df.format(result));
                finalResult.add(result);
            }
        }
        return finalResult;
    }
    /**
@@ -590,7 +992,7 @@
     * @return
     */
    public static Map<String, Object> analysisXlsList(String data, Map<String, List<DataConfig>> dataConfig,
                                                   Device device, String entrustCode, String sampleCode) {
                                                      Device device, String entrustCode, String sampleCode) {
        Map<String, Object> map = new HashMap<>();
        dataConfig.forEach((k, v) -> {
            List<Object> list = new ArrayList<>();
cnas-device/src/main/java/com/ruoyi/device/utils/NA7672LTCPClientUtils.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,1053 @@
package com.ruoyi.device.utils;
import cn.hutool.core.bean.BeanUtil;
import com.ruoyi.device.pojo.NA7672LRequestBean;
import com.ruoyi.device.pojo.NA7672LValueVO;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class NA7672LTCPClientUtils {
    private Socket socket = null;
    private String serverIP = null;
    private int serverPort;
    public NA7672LTCPClientUtils(String serverIP, int serverPort) {
        this.serverIP = serverIP;
        this.serverPort = serverPort;
    }
    public void initTCP() throws IOException {
        this.socket = new Socket(this.serverIP, this.serverPort);
        this.socket.setSoTimeout(5000);
    }
    public void closeTcp() throws IOException {
        this.socket.close();
        this.socket = null;
    }
    //设置全部通道(界面save/recall-调式2,需要本地有state02文件)
    public void initMemory(String filePath) throws IOException {
        try {
            this.initTCP();
            InputStream inputStream = this.socket.getInputStream();
            OutputStream outputStream = this.socket.getOutputStream();
            // æŠŠå­—节流转换成字符流
            PrintWriter printWriter = new PrintWriter(outputStream);
            Scanner inFromSocket = new Scanner(inputStream);
            String requestString = ":MMEM:LOAD " + filePath;
            printWriter.println(requestString);
            printWriter.flush();
            this.closeTcp();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    //获取01配置里的所有值
    public List<NA7672LValueVO> getState01AllValue(NA7672LRequestBean requestBean) {
        List<NA7672LValueVO> rs = new ArrayList<>();
        List<NA7672LValueVO> c1_t1 = this.getListValue(1, 1, 3, "swr", 1);
        //写入
        rs.addAll(c1_t1);
        return rs;
    }
    //获取02配置里的所有值
    public List<NA7672LValueVO> getState02AllValue(NA7672LRequestBean requestBean) {
        List<NA7672LValueVO> rs = new ArrayList<>();
        /*判断是否需要衰减的计算值*/
        int ifNeedDecay = 0;
        if (requestBean.getTemperture() != null) {
            ifNeedDecay = 1;
        }
        List<NA7672LValueVO> c1_t1 = this.getListValue(1, 1, 1, "decay", 16);
        if (ifNeedDecay == 1) {
            for (NA7672LValueVO one : c1_t1) {
                /*衰减的温度系数换算公式 = 1+0.002×(实际温度-20℃)测试值÷长度÷温度系数×100*/
                double wd = 1 + 0.002 * (requestBean.getTemperture() - 20);
                double decay_cal = one.getDecimalVal().doubleValue() / requestBean.getLength() / wd * 100;
                one.setMeasureValue(new BigDecimal(decay_cal).setScale(4, RoundingMode.HALF_UP));
            }
        }
        List<NA7672LValueVO> c3_t1 = this.getListValue(3, 1, 3, "swr", 1);
        List<NA7672LValueVO> c3_t2 = this.getListValue(3, 2, 3, "swr", 1);
        List<NA7672LValueVO> c4_t1 = this.getListValue(4, 1, 3, "swr", 1);
        List<NA7672LValueVO> c4_t2 = this.getListValue(4, 2, 3, "swr", 1);
        List<NA7672LValueVO> c5_t1 = this.getListValue(5, 1, 3, "swr", 1);
        List<NA7672LValueVO> c5_t2 = this.getListValue(5, 2, 3, "swr", 1);
        List<NA7672LValueVO> c6_t1 = this.getListValue(6, 1, 3, "swr", 1);
        List<NA7672LValueVO> c6_t2 = this.getListValue(6, 2, 3, "swr", 1);
        List<NA7672LValueVO> c8_t1 = this.getListValue(8, 1, 3, "swr", 1);
        List<NA7672LValueVO> c8_t2 = this.getListValue(8, 2, 3, "swr", 1);
        rs.addAll(c1_t1);
        rs.addAll(c4_t1);
        rs.addAll(c4_t2);
        rs.addAll(c5_t1);
        rs.addAll(c5_t2);
        rs.addAll(c6_t1);
        rs.addAll(c6_t2);
        rs.addAll(c8_t1);
        rs.addAll(c8_t2);
        /*判断是否需要计算相位差和平均特性阻抗*/
        int ifNeedPHA = 0;
        if (requestBean.getCycle() != null) {
            ifNeedPHA = 1;
        } else {
            ifNeedPHA = 0;
        }
        if (ifNeedPHA == 1) {
            NA7672LValueVO pha = this.getPhaseAndImpedanceCalculate(7, 1, requestBean.getCycle(), requestBean.getCapacity());
            NA7672LValueVO imp_1 = this.getImpedance(2, 1);
            NA7672LValueVO imp_2 = this.getImpedance(2, 2);
            imp_1.setCalculateValue(pha.getCalculateValue());
            imp_2.setCalculateValue(pha.getCalculateValue());
            rs.add(pha);
            rs.add(imp_1);
            rs.add(imp_2);
        } else {
        }
        return rs;
    }
    //获取03配置里的所有值(老的03)
    public List<NA7672LValueVO> getState03AllValueOld(NA7672LRequestBean requestBean) {
        List<NA7672LValueVO> rs = new ArrayList<>();
        List<NA7672LValueVO> c1_t1 = this.getListValue(1, 1, 3, "swr", 1);
        /*判断是否需要衰减的计算值*/
        int ifNeedDecay = 0;
        if (requestBean.getTemperture() != null) {
            ifNeedDecay = 1;
        }
        List<NA7672LValueVO> c1_t2 = this.getListValue(1, 2, 1, "decay", 16);
        NA7672LValueVO c2_t1 = this.getImpedance(2, 1);
        NA7672LValueVO c2_t2 = this.getImpedance(2, 2);
        List<NA7672LValueVO> c3 = this.getListValue(5, 1, 1, "decay", 16);
        if (ifNeedDecay == 1) {
            for (NA7672LValueVO one : c1_t2) {
                double wd = 1 + 0.002 * (requestBean.getTemperture() - 20);
                double decay_cal = one.getDecimalVal().doubleValue() / requestBean.getLength() / wd * 100;
                one.setMeasureValue(new BigDecimal(decay_cal).setScale(4, RoundingMode.HALF_UP));
            }
            for (NA7672LValueVO one : c3) {
                double wd = 1 + 0.002 * (requestBean.getTemperture() - 20);
                double decay_cal = one.getDecimalVal().doubleValue() / requestBean.getLength() / wd * 100;
                one.setMeasureValue(new BigDecimal(decay_cal).setScale(4, RoundingMode.HALF_UP));
            }
        }
        //写入
        rs.addAll(c1_t1);
        rs.addAll(c1_t2);
        rs.add(c2_t1);
        rs.add(c2_t2);
        rs.addAll(c3);
        return rs;
    }
    //获取03配置里的所有值(新的)
    public List<NA7672LValueVO> getState03AllValue(NA7672LRequestBean requestBean) {
        List<NA7672LValueVO> rs = new ArrayList<>();
        List<NA7672LValueVO> c1_t1 = this.getListValue(1, 1, 1, "decay", 16);
        List<NA7672LValueVO> c2_t1 = this.getListValue(2, 1, 1, "decay", 16);
        List<NA7672LValueVO> c4_t1 = this.getListValue(4, 1, 3, "swr", 1);
        List<NA7672LValueVO> c4_t2 = this.getListValue(4, 2, 3, "swr", 1);
        List<NA7672LValueVO> c5_t1 = this.getListValue(5, 1, 4, "swr", 1);
        List<NA7672LValueVO> c5_t2 = this.getListValue(5, 2, 3, "swr", 1);
        List<NA7672LValueVO> c6_t1 = this.getListValue(6, 1, 3, "swr", 1);
        List<NA7672LValueVO> c6_t2 = this.getListValue(6, 2, 3, "swr", 1);
        List<NA7672LValueVO> c7_t1 = this.getListValue(7, 1, 3, "swr", 1);
        List<NA7672LValueVO> c7_t2 = this.getListValue(7, 2, 3, "swr", 1);
        List<NA7672LValueVO> c8_t1 = this.getListValue(8, 1, 3, "swr", 1);
        List<NA7672LValueVO> c8_t2 = this.getListValue(8, 2, 3, "swr", 1);
        for (NA7672LValueVO one : c1_t1) {
            double wd = 1 + 0.002 * (requestBean.getTemperture() - 20);
            double decay_cal = one.getDecimalVal().doubleValue() / requestBean.getLength() / wd * 100;
            one.setMeasureValue(new BigDecimal(decay_cal).setScale(4, RoundingMode.HALF_UP));
        }
        for (NA7672LValueVO one : c2_t1) {
            double wd = 1 + 0.002 * (requestBean.getTemperture() - 20);
            double decay_cal = one.getDecimalVal().doubleValue() / requestBean.getLength() / wd * 100;
            one.setMeasureValue(new BigDecimal(decay_cal).setScale(4, RoundingMode.HALF_UP));
        }
        //特性阻抗
        NA7672LValueVO c3_t1 = this.getImpedance(3, 1);
        NA7672LValueVO c3_t2 = this.getImpedance(3, 2);
        //写入
        rs.addAll(c1_t1);
        rs.addAll(c2_t1);
        rs.add(c3_t1);
        rs.add(c3_t2);
        rs.addAll(c4_t1);
        rs.addAll(c4_t2);
        rs.addAll(c5_t1);
        rs.addAll(c5_t2);
        rs.addAll(c6_t1);
        rs.addAll(c6_t2);
        rs.addAll(c7_t1);
        rs.addAll(c7_t2);
        rs.addAll(c8_t1);
        rs.addAll(c8_t2);
        return rs;
    }
    //获取04配置里的所有值
    public List<NA7672LValueVO> getState04AllValue(NA7672LRequestBean requestBean) {
        List<NA7672LValueVO> rs = new ArrayList<>();
        List<NA7672LValueVO> c1_t1 = this.getListValue(1, 1, 3, "swr", 1);
        List<NA7672LValueVO> c1_t2 = this.getListValue(1, 2, 3, "swr", 1);
        List<NA7672LValueVO> c3_t1 = this.getListValue(3, 1, 3, "swr", 1);
        List<NA7672LValueVO> c3_t2 = this.getListValue(3, 2, 3, "swr", 1);
        List<NA7672LValueVO> c4_t1 = this.getListValue(4, 1, 3, "swr", 1);
        List<NA7672LValueVO> c4_t2 = this.getListValue(4, 2, 3, "swr", 1);
        List<NA7672LValueVO> c5_t1 = this.getListValue(5, 1, 4, "swr", 1);
        List<NA7672LValueVO> c5_t2 = this.getListValue(5, 2, 3, "swr", 1);
        List<NA7672LValueVO> c6_t1 = this.getListValue(6, 1, 3, "swr", 1);
        List<NA7672LValueVO> c6_t2 = this.getListValue(6, 2, 3, "swr", 1);
        List<NA7672LValueVO> c7_t1 = this.getListValue(7, 1, 3, "swr", 1);
        List<NA7672LValueVO> c7_t2 = this.getListValue(7, 2, 3, "swr", 1);
        List<NA7672LValueVO> c8_t1 = this.getListValue(8, 1, 3, "swr", 1);
        List<NA7672LValueVO> c8_t2 = this.getListValue(8, 2, 3, "swr", 1);
        //特性阻抗
        NA7672LValueVO c2_t1 = this.getImpedance(2, 1);
        NA7672LValueVO c2_t2 = this.getImpedance(2, 2);
        //写入
        rs.addAll(c1_t1);
        rs.addAll(c1_t2);
        rs.addAll(c3_t1);
        rs.addAll(c3_t2);
        rs.addAll(c4_t1);
        rs.addAll(c4_t2);
        rs.addAll(c5_t1);
        rs.addAll(c5_t2);
        rs.addAll(c6_t1);
        rs.addAll(c6_t2);
        rs.addAll(c7_t1);
        rs.addAll(c7_t2);
        rs.addAll(c8_t1);
        rs.addAll(c8_t2);
        rs.add(c2_t1);
        rs.add(c2_t2);
        return rs;
    }
    //获取05配置里的所有值
    public List<NA7672LValueVO> getState05AllValue(NA7672LRequestBean requestBean) {
        List<NA7672LValueVO> rs = new ArrayList<>();
        /*判断是否需要衰减的计算值*/
        int ifNeedDecay = 0;
        if (requestBean.getTemperture() != null) {
            ifNeedDecay = 1;
        }
        List<NA7672LValueVO> c1_t1 = this.getListValue(1, 1, 1, "decay", 16);
        List<NA7672LValueVO> c1_t2 = this.getListValue(1, 2, 1, "decay", 16);
        List<NA7672LValueVO> c2_t1 = this.getListValue(2, 1, 1, "decay", 16);
        List<NA7672LValueVO> c2_t2 = this.getListValue(2, 2, 1, "decay", 16);
        List<NA7672LValueVO> c4_t1 = this.getListValue(4, 1, 1, "decay", 16);
        List<NA7672LValueVO> c4_t2 = this.getListValue(4, 2, 1, "decay", 16);
        List<NA7672LValueVO> c5_t1 = this.getListValue(5, 1, 1, "decay", 16);
        List<NA7672LValueVO> c5_t2 = this.getListValue(5, 2, 1, "decay", 16);
        List<NA7672LValueVO> c6_t1 = this.getListValue(6, 1, 1, "decay", 16);
        List<NA7672LValueVO> c6_t2 = this.getListValue(6, 2, 1, "decay", 16);
        if (ifNeedDecay == 1) {
            for (NA7672LValueVO one : c1_t1) {
                double wd = 1 + 0.002 * (requestBean.getTemperture() - 20);
                double decay_cal = one.getDecimalVal().doubleValue() / requestBean.getLength() / wd * 100;
                one.setMeasureValue(new BigDecimal(decay_cal).setScale(4, RoundingMode.HALF_UP));
            }
            for (NA7672LValueVO one : c1_t2) {
                double wd = 1 + 0.002 * (requestBean.getTemperture() - 20);
                double decay_cal = one.getDecimalVal().doubleValue() / requestBean.getLength() / wd * 100;
                one.setMeasureValue(new BigDecimal(decay_cal).setScale(4, RoundingMode.HALF_UP));
            }
            for (NA7672LValueVO one : c2_t1) {
                double wd = 1 + 0.002 * (requestBean.getTemperture() - 20);
                double decay_cal = one.getDecimalVal().doubleValue() / requestBean.getLength() / wd * 100;
                one.setMeasureValue(new BigDecimal(decay_cal).setScale(4, RoundingMode.HALF_UP));
            }
            for (NA7672LValueVO one : c2_t2) {
                double wd = 1 + 0.002 * (requestBean.getTemperture() - 20);
                double decay_cal = one.getDecimalVal().doubleValue() / requestBean.getLength() / wd * 100;
                one.setMeasureValue(new BigDecimal(decay_cal).setScale(4, RoundingMode.HALF_UP));
            }
            for (NA7672LValueVO one : c4_t1) {
                double wd = 1 + 0.002 * (requestBean.getTemperture() - 20);
                double decay_cal = one.getDecimalVal().doubleValue() / requestBean.getLength() / wd * 100;
                one.setMeasureValue(new BigDecimal(decay_cal).setScale(4, RoundingMode.HALF_UP));
            }
            for (NA7672LValueVO one : c4_t2) {
                double wd = 1 + 0.002 * (requestBean.getTemperture() - 20);
                double decay_cal = one.getDecimalVal().doubleValue() / requestBean.getLength() / wd * 100;
                one.setMeasureValue(new BigDecimal(decay_cal).setScale(4, RoundingMode.HALF_UP));
            }
            for (NA7672LValueVO one : c5_t1) {
                double wd = 1 + 0.002 * (requestBean.getTemperture() - 20);
                double decay_cal = one.getDecimalVal().doubleValue() / requestBean.getLength() / wd * 100;
                one.setMeasureValue(new BigDecimal(decay_cal).setScale(4, RoundingMode.HALF_UP));
            }
            for (NA7672LValueVO one : c5_t2) {
                double wd = 1 + 0.002 * (requestBean.getTemperture() - 20);
                double decay_cal = one.getDecimalVal().doubleValue() / requestBean.getLength() / wd * 100;
                one.setMeasureValue(new BigDecimal(decay_cal).setScale(4, RoundingMode.HALF_UP));
            }
            for (NA7672LValueVO one : c6_t1) {
                double wd = 1 + 0.002 * (requestBean.getTemperture() - 20);
                double decay_cal = one.getDecimalVal().doubleValue() / requestBean.getLength() / wd * 100;
                one.setMeasureValue(new BigDecimal(decay_cal).setScale(4, RoundingMode.HALF_UP));
            }
            for (NA7672LValueVO one : c6_t2) {
                double wd = 1 + 0.002 * (requestBean.getTemperture() - 20);
                double decay_cal = one.getDecimalVal().doubleValue() / requestBean.getLength() / wd * 100;
                one.setMeasureValue(new BigDecimal(decay_cal).setScale(4, RoundingMode.HALF_UP));
            }
        }
        //特性阻抗
        NA7672LValueVO c3_t1 = this.getImpedance(3, 1);
        NA7672LValueVO c3_t2 = this.getImpedance(3, 2);
        //写入
        rs.addAll(c1_t1);
        rs.addAll(c1_t2);
        rs.addAll(c2_t1);
        rs.addAll(c2_t2);
        rs.add(c3_t1);
        rs.add(c3_t2);
        rs.addAll(c4_t1);
        rs.addAll(c4_t2);
        rs.addAll(c5_t1);
        rs.addAll(c5_t2);
        rs.addAll(c6_t1);
        rs.addAll(c6_t2);
        return rs;
    }
    //获取06配置里的所有值
    public List<NA7672LValueVO> getState06AllValue(NA7672LRequestBean requestBean) {
        List<NA7672LValueVO> rs = new ArrayList<>();
        List<NA7672LValueVO> c1 = this.getListValue(1, 1, 1, "swr", 1);
        rs.addAll(c1);
        return rs;
    }
    //获取07配置里的所有值
    public List<NA7672LValueVO> getState07AllValue(NA7672LRequestBean requestBean) {
        List<NA7672LValueVO> rs = new ArrayList<>();
        List<NA7672LValueVO> c1_t1 = this.getListValue(1, 1, 3, "swr", 1);
        List<NA7672LValueVO> c1_t2 = this.getListValue(1, 2, 1, "decay", 16);
        List<NA7672LValueVO> c2_t1 = this.getListValue(2, 1, 3, "swr", 1);
        List<NA7672LValueVO> c2_t2 = this.getListValue(2, 2, 1, "decay", 16);
        List<NA7672LValueVO> c4_t1 = this.getListValue(4, 1, 1, "decay", 16);
        /*判断是否需要衰减的计算值*/
        int ifNeedDecay = 0;
        if (requestBean.getTemperture() != null) {
            ifNeedDecay = 1;
        }
        if (ifNeedDecay == 1) {
            for (NA7672LValueVO one : c1_t2) {
                double wd = 1 + 0.002 * (requestBean.getTemperture() - 20);
                double decay_cal = one.getDecimalVal().doubleValue() / requestBean.getLength() / wd * 100;
                one.setMeasureValue(new BigDecimal(decay_cal).setScale(4, RoundingMode.HALF_UP));
            }
            for (NA7672LValueVO one : c2_t2) {
                double wd = 1 + 0.002 * (requestBean.getTemperture() - 20);
                double decay_cal = one.getDecimalVal().doubleValue() / requestBean.getLength() / wd * 100;
                one.setMeasureValue(new BigDecimal(decay_cal).setScale(4, RoundingMode.HALF_UP));
            }
            for (NA7672LValueVO one : c4_t1) {
                double wd = 1 + 0.002 * (requestBean.getTemperture() - 20);
                double decay_cal = one.getDecimalVal().doubleValue() / requestBean.getLength() / wd * 100;
                one.setMeasureValue(new BigDecimal(decay_cal).setScale(4, RoundingMode.HALF_UP));
            }
        }
        rs.addAll(c1_t1);
        rs.addAll(c1_t2);
        rs.addAll(c2_t1);
        rs.addAll(c2_t2);
        rs.addAll(c4_t1);
        //特性阻抗
        NA7672LValueVO c3_t1 = this.getImpedance(3, 1);
        NA7672LValueVO c3_t2 = this.getImpedance(3, 2);
        rs.add(c3_t1);
        rs.add(c3_t2);
        return rs;
    }
    //获取08配置里的所有值
    public List<NA7672LValueVO> getState08AllValue(NA7672LRequestBean requestBean) {
        List<NA7672LValueVO> rs = new ArrayList<>();
        /*判断是否需要衰减的计算值*/
        int ifNeedDecay = 0;
        if (requestBean.getTemperture() != null) {
            ifNeedDecay = 1;
        }
        List<NA7672LValueVO> c1_t1 = this.getListValue(1, 1, 1, "decay", 16);
        if (ifNeedDecay == 1) {
            for (NA7672LValueVO one : c1_t1) {
                /*获取计算值*/
            /*衰减的温度系数换算公式 = 1+0.002×(实际温度-20℃)
            æµ‹è¯•值÷长度÷温度系数×100*/
                double wd = 1 + 0.002 * (requestBean.getTemperture() - 20);
                double decay_cal = one.getDecimalVal().doubleValue() / requestBean.getLength() / wd * 100;
                one.setMeasureValue(new BigDecimal(decay_cal).setScale(4, RoundingMode.HALF_UP));
            }
        }
        //获取驻波比
        List<NA7672LValueVO> c3_t1 = this.getListValue(3, 1, 3, "swr", 1);
        List<NA7672LValueVO> c3_t2 = this.getListValue(3, 2, 3, "swr", 1);
        List<NA7672LValueVO> c4_t1 = this.getListValue(4, 1, 3, "swr", 1);
        List<NA7672LValueVO> c4_t2 = this.getListValue(4, 2, 3, "swr", 1);
        List<NA7672LValueVO> c5_t1 = this.getListValue(5, 1, 3, "swr", 1);
        List<NA7672LValueVO> c5_t2 = this.getListValue(5, 2, 3, "swr", 1);
        List<NA7672LValueVO> c6_t1 = this.getListValue(6, 1, 3, "swr", 1);
        List<NA7672LValueVO> c6_t2 = this.getListValue(6, 2, 3, "swr", 1);
        List<NA7672LValueVO> c8_t1 = this.getListValue(8, 1, 3, "swr", 1);
        List<NA7672LValueVO> c8_t2 = this.getListValue(8, 2, 3, "swr", 1);
        rs.addAll(c1_t1);
        rs.addAll(c3_t1);
        rs.addAll(c3_t2);
        rs.addAll(c4_t1);
        rs.addAll(c4_t2);
        rs.addAll(c5_t1);
        rs.addAll(c5_t2);
        rs.addAll(c6_t1);
        rs.addAll(c6_t2);
        rs.addAll(c8_t1);
        rs.addAll(c8_t2);
        /*判断是否需要计算相位差和平均特性阻抗*/
        int ifNeedPHA = 0;
        if (requestBean.getCycle() != null) {
            ifNeedPHA = 1;
        } else {
            ifNeedPHA = 0;
        }
        if (ifNeedPHA == 1) {
            NA7672LValueVO pha = this.getPhaseAndImpedanceCalculate(7, 1, requestBean.getCycle(), requestBean.getCapacity());
            NA7672LValueVO imp_1 = this.getImpedance(2, 1);
            NA7672LValueVO imp_2 = this.getImpedance(2, 2);
            imp_1.setCalculateValue(pha.getCalculateValue());
            imp_2.setCalculateValue(pha.getCalculateValue());
            rs.add(pha);
            rs.add(imp_1);
            rs.add(imp_2);
        } else {
        }
        return rs;
    }
    //获取autorec配置里的所有值
    public List<NA7672LValueVO> getStateAutoRecAllValue(NA7672LRequestBean requestBean) {
        List<NA7672LValueVO> rs = new ArrayList<>();
        /*判断是否需要衰减的计算值*/
        int ifNeedDecay = 0;
        if (requestBean.getTemperture() != null) {
            ifNeedDecay = 1;
        }
        List<NA7672LValueVO> c1_t1 = this.getListValue(1, 1, 1, "decay", 16);
        List<NA7672LValueVO> c2_t1 = this.getListValue(2, 1, 1, "decay", 16);
        if (ifNeedDecay == 1) {
            for (NA7672LValueVO one : c1_t1) {
                /*获取计算值*/
            /*衰减的温度系数换算公式 = 1+0.002×(实际温度-20℃)
            æµ‹è¯•值÷长度÷温度系数×100*/
                double wd = 1 + 0.002 * (requestBean.getTemperture() - 20);
                double decay_cal = one.getDecimalVal().doubleValue() / requestBean.getLength() / wd * 100;
                one.setMeasureValue(new BigDecimal(decay_cal).setScale(4, RoundingMode.HALF_UP));
            }
            for (NA7672LValueVO one : c2_t1) {
                /*获取计算值*/
            /*衰减的温度系数换算公式 = 1+0.002×(实际温度-20℃)
            æµ‹è¯•值÷长度÷温度系数×100*/
                double wd = 1 + 0.002 * (requestBean.getTemperture() - 20);
                double decay_cal = one.getDecimalVal().doubleValue() / requestBean.getLength() / wd * 100;
                one.setMeasureValue(new BigDecimal(decay_cal).setScale(4, RoundingMode.HALF_UP));
            }
        }
        List<NA7672LValueVO> c4_t1 = this.getListValue(4, 1, 3, "swr", 1);
        List<NA7672LValueVO> c4_t2 = this.getListValue(4, 2, 3, "swr", 1);
        List<NA7672LValueVO> c5_t1 = this.getListValue(5, 1, 3, "swr", 1);
        List<NA7672LValueVO> c5_t2 = this.getListValue(5, 2, 3, "swr", 1);
        List<NA7672LValueVO> c6_t1 = this.getListValue(6, 1, 3, "swr", 1);
        List<NA7672LValueVO> c6_t2 = this.getListValue(6, 2, 3, "swr", 1);
        List<NA7672LValueVO> c7_t1 = this.getListValue(7, 1, 3, "swr", 1);
        List<NA7672LValueVO> c7_t2 = this.getListValue(7, 2, 3, "swr", 1);
        List<NA7672LValueVO> c8_t1 = this.getListValue(8, 1, 3, "swr", 1);
        List<NA7672LValueVO> c8_t2 = this.getListValue(8, 2, 3, "swr", 1);
        rs.addAll(c1_t1);
        rs.addAll(c2_t1);
        rs.addAll(c4_t1);
        rs.addAll(c4_t2);
        rs.addAll(c5_t1);
        rs.addAll(c5_t2);
        rs.addAll(c6_t1);
        rs.addAll(c6_t2);
        rs.addAll(c7_t1);
        rs.addAll(c7_t2);
        rs.addAll(c8_t1);
        rs.addAll(c8_t2);
        /*判断是否需要计算相位差和平均特性阻抗*/
        int ifNeedPHA = 0;
        if (requestBean.getCycle() != null) {
            ifNeedPHA = 1;
        } else {
            ifNeedPHA = 0;
        }
        if (ifNeedPHA == 1) {
            NA7672LValueVO pha = this.getPhaseAndImpedanceCalculate(9, 1, requestBean.getCycle(), requestBean.getCapacity());
            NA7672LValueVO imp_1 = this.getImpedance(3, 1);
            NA7672LValueVO imp_2 = this.getImpedance(3, 2);
            imp_1.setCalculateValue(pha.getCalculateValue());
            imp_2.setCalculateValue(pha.getCalculateValue());
            rs.add(pha);
            rs.add(imp_1);
            rs.add(imp_2);
        } else {
        }
        return rs;
    }
    /*获取相位差和特性阻抗计算值*/
    public NA7672LValueVO getPhaseAndImpedanceCalculate(int channelId, int traceId, double cycle, double capacity) {
        NA7672LValueVO phaseMeatured = this.getPHA(channelId, traceId);
        NA7672LValueVO impedanceCalculate = this.getImpedanceCalculateVal(cycle, phaseMeatured.getDecimalVal().doubleValue(), capacity);
        phaseMeatured.setCalculateValue(impedanceCalculate.getMeasureValue());
        return phaseMeatured;
    }
    /*获取衰减(新)*/
    public List<NA7672LValueVO> getDecayListNew(int channelId, int traceId, int fetchType, String returnType, double temperture, double length) {
        List<NA7672LValueVO> returnValueList = new ArrayList<>();
        try {
            this.initTCP();
            InputStream inputStream = this.socket.getInputStream();
            OutputStream outputStream = this.socket.getOutputStream();
            // æŠŠå­—节流转换成字符流
            PrintWriter printWriter = new PrintWriter(outputStream);
            Scanner inFromSocket = new Scanner(inputStream);
            //获取mark的x
            for (int markId = 1; markId <= 16; markId++) {
                NA7672LValueVO returnValue = new NA7672LValueVO();
                String requestString = ":CALC" + channelId + ":TRAC" + traceId + ":MARK" + markId + ":X?";
                printWriter.println(requestString);
                printWriter.flush();
                String responseString = inFromSocket.next();
                BigDecimal val = new BigDecimal(responseString);
                BigDecimal valRound = val.divide(new BigDecimal(1000 * 1000), 0, RoundingMode.CEILING);
                returnValue.setLabel(returnType + "_" + valRound.toString() + "m");
                //获取mark的y
                requestString = ":CALC" + channelId + ":TRAC" + traceId + ":MARK" + markId + ":Y?";
                printWriter.println(requestString);
                printWriter.flush();
                responseString = inFromSocket.next();
                String[] valList = responseString.split(",");
                val = new BigDecimal(valList[0]);
                val.setScale(4, RoundingMode.HALF_UP);
                returnValue.setDecimalVal(val);
                /*类别衰减、通道、轨迹线、mark*/
                returnValue.setFetchType(fetchType);
                returnValue.setChannel(channelId);
                returnValue.setTrace(traceId);
                returnValue.setChannel(channelId);
                returnValue.setMark(markId);
                returnValueList.add(returnValue);
            }
            this.closeTcp();
        } catch (IOException e) {
            e.printStackTrace();
        }
        for (NA7672LValueVO one : returnValueList) {
            /*获取计算值*/
            /*衰减的温度系数换算公式 = 1+0.002×(实际温度-20℃)
            æµ‹è¯•值÷长度÷温度系数×100*/
            double wd = 1 + 0.002 * (temperture - 20);
            double decay_cal = one.getDecimalVal().doubleValue() / length / wd * 100;
            one.setMeasureValue(new BigDecimal(decay_cal).setScale(4, RoundingMode.HALF_UP));
        }
        return returnValueList;
    }
    /*获取驻波比(新)*/
    public NA7672LValueVO getSWRNew(int channelId, int fetchType) {
        NA7672LValueVO swr1 = this.getSWR(channelId, 1, 1);
        NA7672LValueVO swr2 = this.getSWR(channelId, 2, 1);
        BigDecimal p1 = swr1.getDecimalVal();
        BigDecimal p2 = swr2.getDecimalVal();
        BigDecimal p3 = new BigDecimal(0.0);
        if (p1.compareTo(p2) == 1) {
            p3 = p1;
        } else {
            p3 = p2;
        }
        swr1.setMeasureValue(swr2.getDecimalVal());
        swr1.setCalculateValue(p3);
        swr1.setFetchType(fetchType);
        return swr1;
    }
    /*获取列表值*/
    public List<NA7672LValueVO> getListValue(int channelId, int traceId, int fetchType, String returnType, int fetchNum) {
        List<NA7672LValueVO> returnValueList = new ArrayList<>();
        try {
            this.initTCP();
            InputStream inputStream = this.socket.getInputStream();
            OutputStream outputStream = this.socket.getOutputStream();
            // æŠŠå­—节流转换成字符流
            PrintWriter printWriter = new PrintWriter(outputStream);
            Scanner inFromSocket = new Scanner(inputStream);
            //获取mark的x
            for (int markId = 1; markId <= fetchNum; markId++) {
                NA7672LValueVO returnValue = new NA7672LValueVO();
                String requestString = ":CALC" + channelId + ":TRAC" + traceId + ":MARK" + markId + ":X?";
                printWriter.println(requestString);
                printWriter.flush();
                String responseString = inFromSocket.next();
                BigDecimal val = new BigDecimal(responseString);
                BigDecimal valRound = val.divide(new BigDecimal(1000 * 1000), 0, RoundingMode.CEILING);
                returnValue.setLabel(returnType + "_" + valRound.toString() + "m");
                //获取mark的y
                requestString = ":CALC" + channelId + ":TRAC" + traceId + ":MARK" + markId + ":Y?";
                printWriter.println(requestString);
                printWriter.flush();
                responseString = inFromSocket.next();
                String[] valList = responseString.split(",");
                val = new BigDecimal(valList[0]);
                val.setScale(4, RoundingMode.HALF_UP);
                returnValue.setDecimalVal(val);
                /*类别衰减、通道、轨迹线、mark*/
                returnValue.setFetchType(fetchType);
                returnValue.setChannel(channelId);
                returnValue.setTrace(traceId);
                returnValue.setChannel(channelId);
                returnValue.setMark(markId);
                returnValueList.add(returnValue);
            }
            this.closeTcp();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return returnValueList;
    }
    /*获取单一均值*/
    public NA7672LValueVO getMeanValue(int channelId, int traceId) {
        NA7672LValueVO returnValue = new NA7672LValueVO();
        try {
            this.initTCP();
            InputStream inputStream = this.socket.getInputStream();
            OutputStream outputStream = this.socket.getOutputStream();
            // æŠŠå­—节流转换成字符流
            PrintWriter printWriter = new PrintWriter(outputStream);
            Scanner inFromSocket = new Scanner(inputStream);
            //获取阻抗
            String requestString = ":CALC" + channelId + ":TRAC" + traceId + ":MST:DATA?";
            printWriter.println(requestString);
            printWriter.flush();
            String responseString = inFromSocket.next();
            String[] valList = responseString.split(",");
            BigDecimal val = new BigDecimal(valList[0]);
            val.setScale(4, RoundingMode.HALF_UP);
            returnValue.setDecimalVal(val);
            returnValue.setLabel("impedance_mean");
            /*类别阻抗、通道、轨迹线、mark*/
            returnValue.setFetchType(2);
            returnValue.setChannel(channelId);
            returnValue.setTrace(traceId);
            returnValue.setChannel(channelId);
            returnValue.setMark(-1);
            this.closeTcp();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return returnValue;
    }
    /*测试1,错误的例子*/
    public void test1() {
        try {
            this.initTCP();
            InputStream inputStream = socket.getInputStream();
            OutputStream outputStream = socket.getOutputStream();
            // æŠŠå­—节流转换成字符流
            PrintWriter printWriter = new PrintWriter(outputStream);
            Scanner inFromSocket = new Scanner(inputStream);
            String requestString = ":CALC1:TRAC1:MARK100:Y?";
            // 2,写入请求
            printWriter.println(requestString);
            printWriter.flush();
            // 3,读取请求
            String responseString = inFromSocket.next();
            // æŽ§åˆ¶å° æ‰“印请求字符串 + å“åº”字符串
            System.out.println(requestString + " + " + responseString);
            this.closeTcp();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    /*测试2,正确的例子*/
    public void test2() {
        try {
            this.initTCP();
            InputStream inputStream = socket.getInputStream();
            OutputStream outputStream = socket.getOutputStream();
            // æŠŠå­—节流转换成字符流
            PrintWriter printWriter = new PrintWriter(outputStream);
            Scanner inFromSocket = new Scanner(inputStream);
            String requestString = ":CALC1:TRAC1:MARK1:Y?";
            // 2,写入请求
            printWriter.println(requestString);
            printWriter.flush();
            // 3,读取请求
            String responseString = inFromSocket.next();
            // æŽ§åˆ¶å° æ‰“印请求字符串 + å“åº”字符串
            System.out.println(requestString + " + " + responseString);
            this.closeTcp();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    /*获取衰减*/
    public NA7672LValueVO getDecay(int channelId, int traceId, int markId) {
        NA7672LValueVO returnValue = new NA7672LValueVO();
        try {
            this.initTCP();
            InputStream inputStream = this.socket.getInputStream();
            OutputStream outputStream = this.socket.getOutputStream();
            // æŠŠå­—节流转换成字符流
            PrintWriter printWriter = new PrintWriter(outputStream);
            Scanner inFromSocket = new Scanner(inputStream);
            //获取mark的x
            String requestString = ":CALC" + channelId + ":TRAC" + traceId + ":MARK" + markId + ":X?";
            printWriter.println(requestString);
            printWriter.flush();
            String responseString = inFromSocket.next();
            BigDecimal val = new BigDecimal(responseString);
            BigDecimal valRound = val.divide(new BigDecimal(1000 * 1000), 0, RoundingMode.CEILING);
            returnValue.setLabel("decay_" + valRound.toString() + "m");
            //获取mark的y
            requestString = ":CALC" + channelId + ":TRAC" + traceId + ":MARK" + markId + ":Y?";
            printWriter.println(requestString);
            printWriter.flush();
            responseString = inFromSocket.next();
            String[] valList = responseString.split(",");
            val = new BigDecimal(valList[0]);
            val.setScale(4, RoundingMode.HALF_UP);
            returnValue.setDecimalVal(val);
            /*类别衰减、通道、轨迹线、mark*/
            returnValue.setFetchType(1);
            returnValue.setChannel(channelId);
            returnValue.setTrace(traceId);
            returnValue.setChannel(channelId);
            returnValue.setMark(markId);
            this.closeTcp();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return returnValue;
    }
    /*获取衰减列表*/
    public List<NA7672LValueVO> getDecayList(int channelId, int traceId) {
        List<NA7672LValueVO> returnValueList = new ArrayList<>();
        try {
            this.initTCP();
            InputStream inputStream = this.socket.getInputStream();
            OutputStream outputStream = this.socket.getOutputStream();
            // æŠŠå­—节流转换成字符流
            PrintWriter printWriter = new PrintWriter(outputStream);
            Scanner inFromSocket = new Scanner(inputStream);
            //获取mark的x
            for (int markId = 1; markId <= 16; markId++) {
                NA7672LValueVO returnValue = new NA7672LValueVO();
                String requestString = ":CALC" + channelId + ":TRAC" + traceId + ":MARK" + markId + ":X?";
                printWriter.println(requestString);
                printWriter.flush();
                String responseString = inFromSocket.next();
                BigDecimal val = new BigDecimal(responseString);
                BigDecimal valRound = val.divide(new BigDecimal(1000 * 1000), 0, RoundingMode.CEILING);
                returnValue.setLabel("decay_" + valRound.toString() + "m");
                //获取mark的y
                requestString = ":CALC" + channelId + ":TRAC" + traceId + ":MARK" + markId + ":Y?";
                printWriter.println(requestString);
                printWriter.flush();
                responseString = inFromSocket.next();
                String[] valList = responseString.split(",");
                val = new BigDecimal(valList[0]);
                val.setScale(4, RoundingMode.HALF_UP);
                returnValue.setDecimalVal(val);
                /*类别衰减、通道、轨迹线、mark*/
                returnValue.setFetchType(1);
                returnValue.setChannel(channelId);
                returnValue.setTrace(traceId);
                returnValue.setChannel(channelId);
                returnValue.setMark(markId);
                returnValueList.add(returnValue);
            }
            this.closeTcp();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return returnValueList;
    }
    /*通过label获取衰减*/
    public NA7672LValueVO getDecayByLabel(int channelId, int traceId, String label, double temperture, double length) {
        NA7672LValueVO returnVale = new NA7672LValueVO();
        List<NA7672LValueVO> list = this.getDecayList(channelId, traceId);
        int ifFind = 0;
        for (NA7672LValueVO one : list) {
            if (one.getLabel().equals(label)) {
                BeanUtil.copyProperties(one, returnVale);
                /*获取计算值*/
                /*衰减的温度系数换算公式 = 1+0.002×(实际温度-20℃)
                æµ‹è¯•值÷长度÷温度系数×100*/
                double wd = 1 + 0.002 * (temperture - 20);
                double decay_cal = one.getDecimalVal().doubleValue() / length / wd * 100;
                returnVale.setMeasureValue(new BigDecimal(decay_cal).setScale(4, RoundingMode.HALF_UP));
                ifFind = 1;
                break;
            }
        }
        if (ifFind == 0) {
            returnVale.setIfLegal(0);
            returnVale.setLabel(label);
        }
        return returnVale;
    }
    /*获取阻抗*/
    public NA7672LValueVO getImpedance(int channelId, int traceId) {
        NA7672LValueVO returnValue = new NA7672LValueVO();
        try {
            this.initTCP();
            InputStream inputStream = this.socket.getInputStream();
            OutputStream outputStream = this.socket.getOutputStream();
            // æŠŠå­—节流转换成字符流
            PrintWriter printWriter = new PrintWriter(outputStream);
            Scanner inFromSocket = new Scanner(inputStream);
            //获取阻抗
            String requestString = ":CALC" + channelId + ":TRAC" + traceId + ":MST:DATA?";
            printWriter.println(requestString);
            printWriter.flush();
            String responseString = inFromSocket.next();
            String[] valList = responseString.split(",");
            BigDecimal val = new BigDecimal(valList[0]);
            val.setScale(4, RoundingMode.HALF_UP);
            returnValue.setDecimalVal(val);
            returnValue.setLabel("impedance_mean");
            /*类别阻抗、通道、轨迹线、mark*/
            returnValue.setFetchType(2);
            returnValue.setChannel(channelId);
            returnValue.setTrace(traceId);
            returnValue.setChannel(channelId);
            returnValue.setMark(-1);
            this.closeTcp();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return returnValue;
    }
    /*获取驻波比*/
    public NA7672LValueVO getSWR(int channelId, int traceId, int markId) {
        NA7672LValueVO returnValue = new NA7672LValueVO();
        try {
            this.initTCP();
            InputStream inputStream = this.socket.getInputStream();
            OutputStream outputStream = this.socket.getOutputStream();
            // æŠŠå­—节流转换成字符流
            PrintWriter printWriter = new PrintWriter(outputStream);
            Scanner inFromSocket = new Scanner(inputStream);
            //获取mark的x
            String requestString = ":CALC" + channelId + ":TRAC" + traceId + ":MARK" + markId + ":X?";
            printWriter.println(requestString);
            printWriter.flush();
            String responseString = inFromSocket.next();
            BigDecimal val = new BigDecimal(responseString);
            BigDecimal valRound = val.divide(new BigDecimal(1000 * 1000), 0, RoundingMode.CEILING);
            returnValue.setLabel("swr_" + valRound.toString() + "m");
            //获取mark的y
            requestString = ":CALC" + channelId + ":TRAC" + traceId + ":MARK" + markId + ":Y?";
            printWriter.println(requestString);
            printWriter.flush();
            responseString = inFromSocket.next();
            String[] valList = responseString.split(",");
            val = new BigDecimal(valList[0]);
            val.setScale(4, RoundingMode.HALF_UP);
            returnValue.setDecimalVal(val);
            /*类别衰减、通道、轨迹线、mark*/
            returnValue.setFetchType(3);
            returnValue.setChannel(channelId);
            returnValue.setTrace(traceId);
            returnValue.setChannel(channelId);
            returnValue.setMark(markId);
            this.closeTcp();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return returnValue;
    }
    /*获取驻波比列表*/
    public List<NA7672LValueVO> getSWRList(int channelId, int traceId) {
        List<NA7672LValueVO> returnValueList = new ArrayList<>();
        try {
            this.initTCP();
            InputStream inputStream = this.socket.getInputStream();
            OutputStream outputStream = this.socket.getOutputStream();
            // æŠŠå­—节流转换成字符流
            PrintWriter printWriter = new PrintWriter(outputStream);
            Scanner inFromSocket = new Scanner(inputStream);
            //获取mark的x
            for (int markId = 1; markId <= 16; markId++) {
                NA7672LValueVO returnValue = new NA7672LValueVO();
                String requestString = ":CALC" + channelId + ":TRAC" + traceId + ":MARK" + markId + ":X?";
                printWriter.println(requestString);
                printWriter.flush();
                String responseString = inFromSocket.next();
                BigDecimal val = new BigDecimal(responseString);
                BigDecimal valRound = val.divide(new BigDecimal(1000 * 1000), 0, RoundingMode.CEILING);
                returnValue.setLabel("swr_" + valRound.toString() + "m");
                //获取mark的y
                requestString = ":CALC" + channelId + ":TRAC" + traceId + ":MARK" + markId + ":Y?";
                printWriter.println(requestString);
                printWriter.flush();
                responseString = inFromSocket.next();
                String[] valList = responseString.split(",");
                val = new BigDecimal(valList[0]);
                val.setScale(4, RoundingMode.HALF_UP);
                returnValue.setDecimalVal(val);
                /*类别衰减、通道、轨迹线、mark*/
                returnValue.setFetchType(1);
                returnValue.setChannel(channelId);
                returnValue.setTrace(traceId);
                returnValue.setChannel(channelId);
                returnValue.setMark(markId);
                returnValueList.add(returnValue);
            }
            this.closeTcp();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return returnValueList;
    }
    /*通过label获取驻波比*/
    public NA7672LValueVO getSWRByLabel(int channelId, int traceId, String label) {
        NA7672LValueVO returnVale = new NA7672LValueVO();
        List<NA7672LValueVO> list = this.getSWRList(channelId, traceId);
        int ifFind = 0;
        for (NA7672LValueVO one : list) {
            if (one.getLabel().equals(label)) {
                BeanUtil.copyProperties(one, returnVale);
                ifFind = 1;
                break;
            }
        }
        if (ifFind == 0) {
            returnVale.setIfLegal(0);
            returnVale.setLabel(label);
        }
        return returnVale;
    }
    /*获取相位差*/
    public NA7672LValueVO getPHA(int channelId, int traceId) {
        NA7672LValueVO returnValue = new NA7672LValueVO();
        try {
            this.initTCP();
            InputStream inputStream = this.socket.getInputStream();
            OutputStream outputStream = this.socket.getOutputStream();
            // æŠŠå­—节流转换成字符流
            PrintWriter printWriter = new PrintWriter(outputStream);
            Scanner inFromSocket = new Scanner(inputStream);
            //先设置触发是连续模式,默认是单点
            String requestString = ":INIT" + channelId + ":CONT 1";
            printWriter.println(requestString);
            printWriter.flush();
            //再设置数据统计状态设置为开启,默认是关闭状态
            requestString = ":CALC" + channelId + ":TRAC" + traceId + ":MST 1";
            printWriter.println(requestString);
            printWriter.flush();
            //需要暂停一刻
            Thread.sleep(1000);
            //获取相位差
            requestString = ":CALC" + channelId + ":TRAC" + traceId + ":MST:DATA?";
            printWriter.println(requestString);
            printWriter.flush();
            String responseString = inFromSocket.next();
            String[] valList = responseString.split(",");
            BigDecimal val = new BigDecimal(valList[0]);
            val.setScale(4, RoundingMode.HALF_UP);
            returnValue.setDecimalVal(val);
            returnValue.setLabel("pha_mean");
            /*类别阻抗、通道、轨迹线、mark*/
            returnValue.setFetchType(4);
            returnValue.setChannel(channelId);
            returnValue.setTrace(traceId);
            returnValue.setChannel(channelId);
            returnValue.setMark(-1);
            this.closeTcp();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return returnValue;
    }
    /*获取特性阻抗计算值*/
    public NA7672LValueVO getImpedanceCalculateVal(double cycle, double phaValue, double capacity) {
        //平均特性阻抗 = å‘¨æœŸæ•°Ã·ï¼ˆç›¸ä½å·®å€¼/1000000)÷(电容测)×1000
        NA7672LValueVO returnValue = new NA7672LValueVO();
        returnValue.setFetchType(5);
        BigDecimal val = new BigDecimal(cycle / (phaValue / 1000000) / capacity * 1000);
        BigDecimal newVal = val.setScale(4, RoundingMode.HALF_UP);
        returnValue.setMeasureValue(newVal);
        return returnValue;
    }
    /*获取所有数值*/
    /*public static void main(String[] args) throws IOException {
        String serverIp = "10.88.15.169";
        int serverPort = 5025;
        NA7672LTCPClientUtils tcpClient = new NA7672LTCPClientUtils(serverIp, serverPort);
        tcpClient.initMemory("D:/state03.sta");
        *//*
        tcpClient.test1();
        tcpClient.test2();
        *//*
        *//*单个测试*//*
        *//*
        NA7672LValueVO decay = tcpClient.getDecay(1, 1, 1);
        NA7672LValueVO impedance = tcpClient.getImpedance(2, 1);
        NA7672LValueVO swr = tcpClient.getSWR(3, 1, 1);
        NA7672LValueVO pha=tcpClient.getPHA(7,1);
        *//*
        *//*列表测试*//*
        *//*List<NA7672LValueVO> decayList = tcpClient.getDecayList(1, 1);
        List<NA7672LValueVO> swrList = tcpClient.getSWRList(3, 1);*//*
        *//*使用的接口测试*//*
//        NA7672LValueVO decay = tcpClient.getDecayByLabel(1, 1, "decay_400m", 37.5, 100);
        NA7672LValueVO impedance = tcpClient.getImpedance(2, 1);
//        NA7672LValueVO swr = tcpClient.getSWRByLabel(3, 1, "swr_1000m");
//        NA7672LValueVO pha = tcpClient.getPHA(7, 1);
//        System.out.println("eqweqwe");
    }*/
}