package com.njcn.event.utils;

import cn.hutool.core.collection.CollectionUtil;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * pqs-event
 * 公共方法
 * @author cdf
 * @date 2022/6/30
 */
@Component
public class CommUtil {

    /**
     * 组装为influxdb监测点参数
     *
     * @param lineIds 监测点参数
     * @return StringBuilder
     */
    public static StringBuilder assToInfluxParam(List<String> lineIds){
        StringBuilder lineIdsStr = new StringBuilder("(");
        for (int i = 0; i < lineIds.size(); i++) {
            if (lineIds.size() - i != 1) {
                lineIdsStr.append("line_id ='").append(lineIds.get(i)).append("' or ");
            } else {
                lineIdsStr.append("line_id ='").append(lineIds.get(i)).append("') ");
            }
        }
        return lineIdsStr;
    }
}
