潘志宝
2024-12-25 e2b151e9bed2b6798cfc1ed499e98bcb0665d6ec
iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mdk/sample/SampleInfoConstructor.java
@@ -100,7 +100,7 @@
                break;
            case NORMALITEM:
            case MERGEITEM:
                dateTime = calculateTime(originalTime, true, columnItem.getDataLength(), 60);
                dateTime = calendar.getTime();
                break;
            case IND:
                dateTime = calculateTime(originalTime, true, columnItem.getDataLength(), 60);
@@ -132,25 +132,17 @@
        calendar.setTime(originalTime);
        switch (ModelParamType.getEumByCode(columnItem.getParamType())) {
            case DATAPOINT:
                ApiPointDTO dataPoint = pointMap.get(columnItem.getParamId());
                if (dataPoint == null) {
                    return null;
                }
                dateTime = calendar.getTime();
                break;
            case NORMALITEM:
            case MERGEITEM:
                dateTime = calendar.getTime();
                dateTime = calculateTime(originalTime, false, columnItem.getDataLength(), 60);
                break;
            case IND:
                dateTime = calendar.getTime();
                break;
            case PLAN:
                ApiPlanItemDTO apiPlanItemDTO = planMap.get(columnItem.getParamId());
                if (apiPlanItemDTO == null) {
                    return null;
                }
                dateTime = calculateDate(originalTime, false, columnItem.getDataLength(), TimeGranularitySecEnum.getEumByCode(apiPlanItemDTO.getTimeGranularity()).getValue());
                dateTime = calendar.getTime();
                break;
            default:
                break;
@@ -213,22 +205,6 @@
        calendar.set(Calendar.MILLISECOND, 0);
        // 数据长度 * 粒度
        calendar.add(Calendar.SECOND, timeLength * granularity);
        return calendar.getTime();
    }
    public Date calculateDate(Date originalTime, Boolean backward, int dataLength, int field) {
        int timeLength;
        if (backward) {
            timeLength = (-1) * dataLength;
        } else {
            timeLength = dataLength - 1;
        }
        Date desTime = originalTime;
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(desTime);
        calendar.set(Calendar.MILLISECOND, 0);
        // 数据长度 * 粒度
        calendar.add(Calendar.SECOND, timeLength);
        return calendar.getTime();
    }
}