zhuo
2024-07-23 5ed5f51d479989d5b2149b09c82b6b3ea495b589
cnas-server/src/main/java/com/yuanchu/mom/utils/DataAcquisition.java
@@ -84,10 +84,10 @@
            }
            // 如果存在存储地址,则移动地址
            if (ObjectUtils.isNotEmpty(device.getStorageUrl())) {
                String s = HTTP + ip + MOVEFILE + "?startFilePath=" + device.getCollectUrl() + "&endFilePath=" + device.getStorageUrl();
                String s = HTTP + ip + MOVEFILE + "?startFilePath=" + device.getCollectUrl() + "&endFilePath=" + device.getStorageUrl() + "&fileType=" + device.getFileType();
                String storageUrlResult = HttpUtil.get(s);
                JSONObject storageUrlResultJson = JSON.parseObject(storageUrlResult);
                if (Objects.equals(storageUrlResultJson.get("code"), 1)) {
                if (Objects.equals(storageUrlResultJson.get("code"), 0)) {
                    if (ObjectUtils.isEmpty(storageUrlResultJson.get("msg"))) {
                        throw new ErrorException("存储地址错误,可能文件路径配置错误!");
                    } else {
@@ -95,13 +95,11 @@
                    }
                }
            }
            String frequency = createFrequency(entrustCode, sampleCode);
            map.put("frequency", frequency);
            return map;
        }
    }
    private static String createFrequency(String entrustCode, String sampleCode) {
    public static String createFrequency(String entrustCode, String sampleCode) {
        String key = frequency + ":" + entrustCode + ":" + sampleCode;
        boolean b = RedisUtil.hasKey(key);
        String frequencyValue;
@@ -142,8 +140,17 @@
                JSONObject jsonObject1 = JSON.parseObject(dataList.get(y).toString());
                Object o = jsonObject1.get(key);
                if (ObjectUtils.isNotEmpty(o)) {
                    // 小数点进三位
                    double v1 = 0;
                    try {
                        v1 = Double.parseDouble(o.toString());
                        double v2 = v1 / 1000;
                        list.add(v2);
                    } catch (NumberFormatException e) {
                    list.add(o);
                }
                }
            }
            // 进行公式计算
            String resultValue = calculationFormula(list, v.get(0), k);