// See https://aka.ms/new-console-template for more information
//儿童BMI数据导入

//#define DEBUG

using MiniExcelLibs;
using System.Text;
//DEBUG是环境变量,是内置值
#if DEBUG
string bmifilepath = @"H:\liuzl_ybhdmob\YBDevice\ExcelImport\3~16岁儿童青少年标准.xlsx";
var query = await MiniExcel.QueryAsync(bmifilepath, sheetName: "Sheet1");
var list = query.ToList();
StringBuilder sb = new StringBuilder();
StringBuilder sb2 = new StringBuilder();
StringBuilder sb3 = new StringBuilder();
StringBuilder sb4 = new StringBuilder();
StringBuilder sb5 = new StringBuilder();
for (var i = 2; i < list.Count() - 1; i++)
{
    var row = list[i];
    double age = row.A;
    double nthin = row.B;
    double nnormal = row.C;
    double noverweight = row.D;
    double nfat = row.E;
    double vthin = row.F;
    double vnormal = row.G;
    double voverweight = row.H;
    double vfat = row.I;
    //BMI标准
    if (i > 2)
    {
        sb.Append("or ");
        sb2.Append("or ");
        sb3.Append("or ");
        sb4.Append("or ");

    }
    sb.Append($"(1,>={age * 12} and <{age * 12 + 6},<={nthin}m) \r\n");
    sb.Append($"or (2,>={age * 12} and <{age * 12 + 6},<={vthin}m) \r\n");

    sb2.Append($"(1,>={age * 12} and <{age * 12 + 6},>{nthin}m and <={noverweight}m) \r\n");
    sb2.Append($"or (2,>={age * 12} and <{age * 12 + 6},>{vthin}m and <={voverweight}m) \r\n");

    sb3.Append($"(1,>={age * 12} and <{age * 12 + 6},>{noverweight}m and <={nfat}m) \r\n");
    sb3.Append($"or (2,>={age * 12} and <{age * 12 + 6},>{voverweight}m and <={vfat}m) \r\n");

    sb4.Append($"(1,>={age * 12} and <{age * 12 + 6},>{nfat}m and <=50m) \r\n");
    sb4.Append($"or (2,>={age * 12} and <{age * 12 + 6},>{vfat}m and <=50m) \r\n");
    //BMI范围
    sb5.Append($"(1,>={age * 12} and <{age * 12 + 6})");
    string bmitext = $"=>new List<MeasureInfoItemValue>{{new MeasureInfoItemValue{{maxvalue={nthin}m,minvalue=0,text=BMILevel.Thin,color=BMILevelColor.Thin}},new MeasureInfoItemValue{{maxvalue={noverweight}m,minvalue={nnormal}m,text=BMILevel.Normal,color=BMILevelColor.Normal}},new MeasureInfoItemValue{{maxvalue={nfat}m,minvalue={noverweight}m,text=BMILevel.OverWeight,color=BMILevelColor.OverWeight}}, new MeasureInfoItemValue{{maxvalue=50,minvalue={nfat}m,text=BMILevel.Fat,color=BMILevelColor.Fat}}}},\r\n";
    sb5.Append(bmitext);
    sb5.Append($"(2,>={age * 12} and <{age * 12 + 6})");
    bmitext = $"=>new List<MeasureInfoItemValue>{{new MeasureInfoItemValue{{maxvalue={vthin}m,minvalue=0,text=BMILevel.Thin,color=BMILevelColor.Thin}},new MeasureInfoItemValue{{maxvalue={voverweight}m,minvalue={vnormal}m,text=BMILevel.Normal,color=BMILevelColor.Normal}},new MeasureInfoItemValue{{maxvalue={vfat}m,minvalue={voverweight}m,text=BMILevel.OverWeight,color=BMILevelColor.OverWeight}}, new MeasureInfoItemValue{{maxvalue=50,minvalue={vfat}m,text=BMILevel.Fat,color=BMILevelColor.Fat}}}},\r\n";
    sb5.Append(bmitext);
}
sb.Append(" => BMILevel.Thin,\r\n");
sb2.Append(" => BMILevel.Normal,\r\n");
sb3.Append(" => BMILevel.OverWeight,\r\n");
sb4.Append(" => BMILevel.Fat,\r\n");
sb4.Append("_ =>BMILevel.Error");
var str = $"{sb.ToString()}{sb2.ToString()}{sb3.ToString()}{sb4.ToString()}";

var standstr = sb5.ToString();

Console.WriteLine(str);

#else
Console.WriteLine("这里是条件编译");
#endif
Console.ReadLine();