package org.jeecg.modules.stm.common.vo;

import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

/**
 * @Author: yzh
 * @Date 2023/4/3 20:24
 * @Description:
 */
@Data
public class QueryVo {
    private Integer id;
    private String name;
    private String bizNo;
    private String scdesc;
    private String sctype;
    private String tag;
    private String lableNames;
    private List<Lable> lables;
    private String[] names;
    private Integer fileId;
    private String fileName;
    private String filePath;

    public void setNames() {
        if(this.name!=null && !this.name.trim().equals("")) {
            this.names = this.name.split(" ");
        }
    }

    public void buildLable(String lableIds,String lableNames, String name) {
        String [] labelatts = lableNames.split(",");
        String [] labeCodeAry = lableIds.split(",");
        List<Lable> lables = new ArrayList<>();
        for(int i=0;i<labeCodeAry.length;i++){
            Lable lable = new Lable();
            lable.setName(labelatts[i]);
            lable.setCode(labeCodeAry[i]);
            String lname = labelatts[i];
            if(StringUtils.isNotEmpty(name) && (lname.toLowerCase().contains(name.toUpperCase())||lname.toLowerCase().contains(name.toLowerCase()))){
                lable.setColor("#FF0000");
            }
            lables.add(lable);
        }
        this.lables = lables;
    }

    class Lable {
        private String name;
        private String color;
        private String code;

        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.name = name;
        }

        public String getCode() {
            return code;
        }
        public void setCode(String code) {
            this.code = code;
        }

        public String getColor() {
            return color;
        }

        public void setColor(String color) {
            this.color = color;
        }
    }

}
