|
@@ -184,7 +184,7 @@ namespace Ropin.Inspection.Api
|
|
|
if (dict.ContainsKey("RunWhetherNormal"))
|
|
|
{
|
|
|
var RunWhetherNormal = dict["RunWhetherNormal"].ToString();
|
|
|
- dict["RunWhetherNormal"] = RunWhetherNormal.ToLower() == "true" ? "是" : "否";
|
|
|
+ dict["RunWhetherNormal"] = RunWhetherNormal.ToLower() == "true" ? "异常" : "正常";
|
|
|
}
|
|
|
var trueList = tabs?.Where(t => t.BReadDevSpot == true);
|
|
|
foreach (var item in trueList)
|
|
@@ -391,8 +391,9 @@ namespace Ropin.Inspection.Api
|
|
|
}
|
|
|
if (tabs[j].Name== "RunWhetherNormal")
|
|
|
{
|
|
|
- cels[j] = itemVal?.ToLower() == "true" ? "是" : "否";
|
|
|
- }else if (tabs[j].Name == "Date")
|
|
|
+ cels[j] = itemVal?.ToLower() == "true" ? "异常" : "正常";
|
|
|
+ }
|
|
|
+ else if (tabs[j].Name == "Date")
|
|
|
{
|
|
|
cels[j] = Convert.ToDateTime(itemVal).ToString("yyyy-MM-dd");
|
|
|
}
|
|
@@ -577,104 +578,271 @@ namespace Ropin.Inspection.Api
|
|
|
try
|
|
|
{
|
|
|
var devOpeAccountList = await _TdevDevOpeAccountService.GetConditionAsync(searchModel);
|
|
|
- var contentList = from c in devOpeAccountList.Select(t => t.C_Content)
|
|
|
- select JsonConvert.DeserializeObject<TdevDevOpeContentViewModel>(c);
|
|
|
-
|
|
|
IWorkbook workbook = new XSSFWorkbook();
|
|
|
- ISheet sheet = workbook.CreateSheet("sheet1");
|
|
|
- sheet.AddMergedRegion(new NPOI.SS.Util.CellRangeAddress(0, 0, 0, 12));
|
|
|
- var titleRow = sheet.CreateRow(0);
|
|
|
- titleRow.Height = 20 * 25;
|
|
|
- ICell titleCell = titleRow.CreateCell(0);
|
|
|
- titleCell.SetCellValue("设各台账记录");
|
|
|
-
|
|
|
+ ISheet sheet = workbook.CreateSheet();
|
|
|
+ #region
|
|
|
+
|
|
|
IFont font = workbook.CreateFont();
|
|
|
font.IsBold = true;
|
|
|
- font.FontHeightInPoints = 16;
|
|
|
+ font.FontHeightInPoints = 25;
|
|
|
font.FontName = "宋体";
|
|
|
ICellStyle titleCellStyle = workbook.CreateCellStyle();
|
|
|
titleCellStyle.SetFont(font);
|
|
|
titleCellStyle.Alignment = HorizontalAlignment.Center;
|
|
|
|
|
|
- titleCellStyle.BorderBottom = BorderStyle.Thin;
|
|
|
- titleCellStyle.BorderLeft = BorderStyle.Thin;
|
|
|
- titleCellStyle.BorderRight = BorderStyle.Thin;
|
|
|
- titleCellStyle.BorderTop = BorderStyle.Thin;
|
|
|
- titleCell.CellStyle = titleCellStyle;
|
|
|
-
|
|
|
- var headRow = sheet.CreateRow(1);
|
|
|
-
|
|
|
- headRow.CreateCell(0).SetCellValue("日期");
|
|
|
- headRow.CreateCell(1).SetCellValue("排污口编号");
|
|
|
- headRow.CreateCell(2).SetCellValue("设备名称");
|
|
|
- headRow.CreateCell(3).SetCellValue("参数名称");
|
|
|
- headRow.CreateCell(4).SetCellValue("设计值");
|
|
|
- headRow.CreateCell(5).SetCellValue("单位");
|
|
|
- headRow.CreateCell(6).SetCellValue("污染因子");
|
|
|
- headRow.CreateCell(7).SetCellValue("数据来源");
|
|
|
- headRow.CreateCell(8).SetCellValue("烟气筒高度(m)");
|
|
|
- headRow.CreateCell(9).SetCellValue("排放温度(°C)");
|
|
|
- headRow.CreateCell(10).SetCellValue("压力");
|
|
|
- headRow.CreateCell(11).SetCellValue("开机时间");
|
|
|
- headRow.CreateCell(12).SetCellValue("关机时间");
|
|
|
-
|
|
|
+ titleCellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
|
|
|
+ titleCellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
|
|
|
+ titleCellStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
|
|
|
+ titleCellStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
|
|
|
+ titleCellStyle.WrapText = true;
|
|
|
+ #endregion
|
|
|
+ #region
|
|
|
+
|
|
|
IFont font1 = workbook.CreateFont();
|
|
|
font1.IsBold = true;
|
|
|
- font1.FontHeightInPoints = 12;
|
|
|
+ font1.FontHeightInPoints = 14;
|
|
|
font1.FontName = "宋体";
|
|
|
ICellStyle headCellStyle = workbook.CreateCellStyle();
|
|
|
headCellStyle.SetFont(font1);
|
|
|
+ headCellStyle.Alignment = HorizontalAlignment.Center;
|
|
|
+ headCellStyle.VerticalAlignment = VerticalAlignment.Center;
|
|
|
|
|
|
- headCellStyle.BorderBottom = BorderStyle.Thin;
|
|
|
- headCellStyle.BorderLeft = BorderStyle.Thin;
|
|
|
- headCellStyle.BorderRight = BorderStyle.Thin;
|
|
|
- headCellStyle.BorderTop = BorderStyle.Thin;
|
|
|
- foreach (var item in headRow.Cells)
|
|
|
- {
|
|
|
- item.CellStyle = headCellStyle;
|
|
|
- }
|
|
|
+ headCellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
|
|
|
+ headCellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
|
|
|
+ headCellStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
|
|
|
+ headCellStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
|
|
|
+ headCellStyle.WrapText = true;
|
|
|
+ #endregion
|
|
|
+ #region
|
|
|
+
|
|
|
+ IFont font2 = workbook.CreateFont();
|
|
|
+ font2.IsBold = false;
|
|
|
+ font2.FontHeightInPoints = 12;
|
|
|
+ font2.FontName = "宋体";
|
|
|
+ ICellStyle rowCellStyle = workbook.CreateCellStyle();
|
|
|
+ rowCellStyle.SetFont(font2);
|
|
|
+ rowCellStyle.Alignment = HorizontalAlignment.Center;
|
|
|
+
|
|
|
+ rowCellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
|
|
|
+ rowCellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
|
|
|
+ rowCellStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
|
|
|
+ rowCellStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
|
|
|
+ rowCellStyle.WrapText = true;
|
|
|
+ #endregion
|
|
|
|
|
|
- int start = 2;
|
|
|
- IFont font3 = workbook.CreateFont();
|
|
|
- font3.FontHeightInPoints = 9;
|
|
|
- font3.FontName = "宋体";
|
|
|
- ICellStyle contentCellStyle = workbook.CreateCellStyle();
|
|
|
- contentCellStyle.SetFont(font3);
|
|
|
-
|
|
|
- contentCellStyle.BorderBottom = BorderStyle.Thin;
|
|
|
- contentCellStyle.BorderLeft = BorderStyle.Thin;
|
|
|
- contentCellStyle.BorderRight = BorderStyle.Thin;
|
|
|
- contentCellStyle.BorderTop = BorderStyle.Thin;
|
|
|
- foreach (var item in contentList)
|
|
|
+ IRow title = sheet.CreateRow(0);
|
|
|
+ title.Height = 30 * 25;
|
|
|
+ title.CreateCell(0).SetCellValue("VOCs治理设施基本信息与维保管理信息表");
|
|
|
+ foreach (var item in title.Cells)
|
|
|
{
|
|
|
- var row = sheet.CreateRow(start);
|
|
|
- row.CreateCell(0).SetCellValue(item.Date.ToString("yyyy-MM-dd hh:mm:ss"));
|
|
|
- row.CreateCell(1).SetCellValue(item.DrainOutletNumber);
|
|
|
- row.CreateCell(2).SetCellValue(item.DevStoreName);
|
|
|
- row.CreateCell(3).SetCellValue(item.DevStoreType);
|
|
|
- row.CreateCell(4).SetCellValue(item.SpecificationsParameterName);
|
|
|
- row.CreateCell(5).SetCellValue(item.SpecificationsDesignValue);
|
|
|
- row.CreateCell(6).SetCellValue(item.PollutionFactor);
|
|
|
- row.CreateCell(7).SetCellValue(item.DataSources);
|
|
|
- row.CreateCell(8).SetCellValue(item.HeightOfFlue);
|
|
|
- row.CreateCell(9).SetCellValue(item.DischargeTemperature);
|
|
|
- row.CreateCell(10).SetCellValue(item.Pressure);
|
|
|
- row.CreateCell(11).SetCellValue(item.RunStartTime.ToString("yyyy-MM-dd hh:mm:ss"));
|
|
|
- row.CreateCell(12).SetCellValue(item.RunEndTime.ToString("yyyy-MM-dd hh:mm:ss"));
|
|
|
- start++;
|
|
|
- foreach (var cell in row.Cells)
|
|
|
- {
|
|
|
- cell.CellStyle = contentCellStyle;
|
|
|
- }
|
|
|
+ item.CellStyle = titleCellStyle;
|
|
|
}
|
|
|
-
|
|
|
- for (int i = 0; i < sheet.LastRowNum; i++)
|
|
|
+ if (devOpeAccountList == null || devOpeAccountList.Count() == 0)
|
|
|
{
|
|
|
- sheet.AutoSizeRow(i);
|
|
|
+ IRow content1 = sheet.CreateRow(1);
|
|
|
+ content1.CreateCell(0).SetCellValue("暂无数据");
|
|
|
+ content1.Cells[0].CellStyle = headCellStyle;
|
|
|
+ sheet.AddMergedRegion(new NPOI.SS.Util.CellRangeAddress(1, 1, 0, 15));
|
|
|
+ sheet.AddMergedRegion(new NPOI.SS.Util.CellRangeAddress(0, 0, 0, 15));
|
|
|
}
|
|
|
- for (int i = 0; i < 12; i++)
|
|
|
+ else
|
|
|
{
|
|
|
- sheet.AutoSizeColumn(i, true);
|
|
|
+ List<RunSpotConfigName> tabs = new List<RunSpotConfigName>();
|
|
|
+ var confCode = searchModel.C_DevOpeAccountConfigCode;
|
|
|
+ IRow head = sheet.CreateRow(1);
|
|
|
+ IRow head2 = sheet.CreateRow(2);
|
|
|
+ IRow head3 = sheet.CreateRow(3);
|
|
|
+ head.Height = 30 * 20;
|
|
|
+ head2.Height = 30 * 20;
|
|
|
+ head3.Height = 30 * 20;
|
|
|
+ if (!string.IsNullOrEmpty(confCode))
|
|
|
+ {
|
|
|
+ head.CreateCell(0).SetCellValue("日期");
|
|
|
+ tabs.Add(new RunSpotConfigName { Label = "日期", Name = "Date", BReadDevSpot = false });
|
|
|
+ sheet.AddMergedRegion(new CellRangeAddress(1, 3, 0, 0));
|
|
|
+ int cel = 1;
|
|
|
+ var content = await _devDevOpeAccountConfigService.GetEntityByID(confCode);
|
|
|
+ if (content != null && !string.IsNullOrEmpty(content.C_Config))
|
|
|
+ {
|
|
|
+ var RunSpotConfig = JsonConvert.DeserializeObject<TdevDevOpeAccountConfigNameViewModel>(content.C_Config);
|
|
|
+ List<RunSpotConfigName> CtabColumns = new List<RunSpotConfigName>();
|
|
|
+ int headerNum = 1;
|
|
|
+ foreach (var item in RunSpotConfig?.RunSpotConfigList.ToList())
|
|
|
+ {
|
|
|
+ if (item != null)
|
|
|
+ {
|
|
|
+ headerNum = item.Label.Split("@").Count();
|
|
|
+ if (item.BReadDevSpot)
|
|
|
+ {
|
|
|
+ headerNum++;
|
|
|
+ tabs.Add(new RunSpotConfigName { Label = item.Label + "@平均值", Name = item.Name, BReadDevSpot = item.BReadDevSpot });
|
|
|
+ tabs.Add(new RunSpotConfigName { Label = item.Label + "@最大值", Name = item.Name + "_Max", BReadDevSpot = item.BReadDevSpot });
|
|
|
+ tabs.Add(new RunSpotConfigName { Label = item.Label + "@最小值", Name = item.Name + "_Min", BReadDevSpot = item.BReadDevSpot });
|
|
|
+
|
|
|
+ CtabColumns.Add(new RunSpotConfigName { Label = item.Label + "@平均值", Name = item.Name, BReadDevSpot = item.BReadDevSpot });
|
|
|
+ CtabColumns.Add(new RunSpotConfigName { Label = item.Label + "@最大值", Name = item.Name + "_Max", BReadDevSpot = item.BReadDevSpot });
|
|
|
+ CtabColumns.Add(new RunSpotConfigName { Label = item.Label + "@最小值", Name = item.Name + "_Min", BReadDevSpot = item.BReadDevSpot });
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ tabs.Add(item);
|
|
|
+ CtabColumns.Add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ bool IsVal = false; int merge = 0;
|
|
|
+ bool IsVal2 = false; int merge2 = 0;
|
|
|
+ foreach (var tab in CtabColumns)
|
|
|
+ {
|
|
|
+ if (tab != null)
|
|
|
+ {
|
|
|
+ var vals = tab.Label;
|
|
|
+ if (vals.Contains("@"))
|
|
|
+ {
|
|
|
+ string[] tmp = vals.Split('@');
|
|
|
+ if (tmp.Count() == 3)
|
|
|
+ {
|
|
|
+ var getCel = sheet.GetRow(1).GetCell(cel - 1 - merge).ToString();
|
|
|
+ var getCel2 = sheet.GetRow(2).GetCell(cel - 1 - merge2).ToString();
|
|
|
+ if (getCel == tmp[0].ToString())
|
|
|
+ {
|
|
|
+ head.CreateCell(cel).SetCellValue("");
|
|
|
+ merge++;
|
|
|
+ IsVal = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ IsVal = false;
|
|
|
+ head.CreateCell(cel).SetCellValue(tmp[0].ToString());
|
|
|
+ }
|
|
|
+ if (getCel2 == tmp[1].ToString())
|
|
|
+ {
|
|
|
+ head2.CreateCell(cel).SetCellValue("");
|
|
|
+ merge2++;
|
|
|
+ IsVal2 = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ head2.CreateCell(cel).SetCellValue(tmp[1].ToString());
|
|
|
+ IsVal2 = false;
|
|
|
+ }
|
|
|
+ head3.CreateCell(cel).SetCellValue(tmp[2].ToString());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ IsVal2 = false;
|
|
|
+ var getCel = sheet.GetRow(1).GetCell(cel - 1 - merge).ToString();
|
|
|
+ if (getCel == tmp[0].ToString())
|
|
|
+ {
|
|
|
+ head.CreateCell(cel).SetCellValue("");
|
|
|
+ merge++;
|
|
|
+ IsVal = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ IsVal = false;
|
|
|
+ head.CreateCell(cel).SetCellValue(tmp[0].ToString());
|
|
|
+ }
|
|
|
+ head2.CreateCell(cel).SetCellValue(tmp[1].ToString());
|
|
|
+ head3.CreateCell(cel).SetCellValue("");
|
|
|
+ sheet.AddMergedRegion(new CellRangeAddress(2, 3, cel, cel));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ IsVal = false;
|
|
|
+ IsVal2 = false;
|
|
|
+ head.CreateCell(cel).SetCellValue(vals);
|
|
|
+ head2.CreateCell(cel).SetCellValue("");
|
|
|
+ head3.CreateCell(cel).SetCellValue("");
|
|
|
+ sheet.AddMergedRegion(new CellRangeAddress(1, 3, cel, cel));
|
|
|
+ }
|
|
|
+ if (!IsVal && merge > 0)
|
|
|
+ {
|
|
|
+ sheet.AddMergedRegion(new CellRangeAddress(1, 1, cel - merge - 1, cel - 1));
|
|
|
+ merge = 0;
|
|
|
+ }
|
|
|
+ if (!IsVal2 && merge2 > 0)
|
|
|
+ {
|
|
|
+ sheet.AddMergedRegion(new CellRangeAddress(2, 2, cel - merge2 - 1, cel - 1));
|
|
|
+ merge2 = 0;
|
|
|
+ }
|
|
|
+ cel++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (cel == CtabColumns.Count + 1 && merge > 0 && IsVal)
|
|
|
+ {
|
|
|
+ sheet.AddMergedRegion(new CellRangeAddress(1, 1, cel - merge - 1, cel - 1));
|
|
|
+ merge = 0; IsVal = false;
|
|
|
+ }
|
|
|
+ if (cel == CtabColumns.Count + 1 && merge2 > 0 && IsVal2)
|
|
|
+ {
|
|
|
+ sheet.AddMergedRegion(new CellRangeAddress(1, 2, cel - merge2 - 1, cel - 1));
|
|
|
+ merge2 = 0; IsVal2 = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ foreach (var item in head.Cells)
|
|
|
+ {
|
|
|
+ item.CellStyle = headCellStyle;
|
|
|
+ }
|
|
|
+ foreach (var item in head2.Cells)
|
|
|
+ {
|
|
|
+ item.CellStyle = headCellStyle;
|
|
|
+ }
|
|
|
+ foreach (var item in head3.Cells)
|
|
|
+ {
|
|
|
+ item.CellStyle = headCellStyle;
|
|
|
+ }
|
|
|
+ int rowNumber = 4;
|
|
|
+ var confData = devOpeAccountList.Select(t => t.C_Content).ToList();
|
|
|
+ for (int i = 0; i < confData.Count; i++)
|
|
|
+ {
|
|
|
+ IRow content = sheet.CreateRow(rowNumber);
|
|
|
+ Dictionary<string, object> dict = JsonConvert.DeserializeObject<Dictionary<string, object>>(confData[i]);
|
|
|
+ int forCount = dict.Count + 1;
|
|
|
+ if (tabs.Count() > dict.Count) { forCount = tabs.Count() + 1; }
|
|
|
+ for (int j = 0; j < forCount; j++)
|
|
|
+ {
|
|
|
+ if (j < tabs.Count)
|
|
|
+ {
|
|
|
+ string celVal = "";
|
|
|
+ if (dict.ContainsKey(tabs[j].Name))
|
|
|
+ {
|
|
|
+ celVal = dict[tabs[j].Name]?.ToString();
|
|
|
+ }
|
|
|
+ if (tabs[j].Name == "RunWhetherNormal")
|
|
|
+ {
|
|
|
+ celVal = celVal.ToLower() == "true" ? "异常" : "正常";
|
|
|
+ content.CreateCell(j).SetCellValue(celVal);
|
|
|
+ }
|
|
|
+ else if (tabs[j].Name == "Date")
|
|
|
+ {
|
|
|
+ content.CreateCell(j).SetCellValue(Convert.ToDateTime(celVal).ToString("yyyy-MM-dd"));
|
|
|
+ }
|
|
|
+ else if (DateTime.TryParse(celVal, out DateTime dt) && celVal.Length >= 10)
|
|
|
+ {
|
|
|
+ content.CreateCell(j).SetCellValue(dt.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ content.CreateCell(j).SetCellValue(celVal);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ foreach (var item in content.Cells)
|
|
|
+ {
|
|
|
+ item.CellStyle = rowCellStyle;
|
|
|
+ }
|
|
|
+ rowNumber++;
|
|
|
+ }
|
|
|
+
|
|
|
+ sheet.AddMergedRegion(new NPOI.SS.Util.CellRangeAddress(0, 0, 0, tabs.Count - 1));
|
|
|
+ for (int i = 0; i <= tabs.Count; i++)
|
|
|
+ {
|
|
|
+ sheet.SetColumnWidth(i, 5000);
|
|
|
+ }
|
|
|
}
|
|
|
using (var stream = new NpoiMemoryStream())
|
|
|
{
|
|
@@ -938,7 +1106,7 @@ namespace Ropin.Inspection.Api
|
|
|
}
|
|
|
if (tabs[j].Name == "RunWhetherNormal")
|
|
|
{
|
|
|
- celVal = celVal.ToLower() == "true" ? "是" : "否";
|
|
|
+ celVal = celVal.ToLower() == "true" ? "异常" : "正常";
|
|
|
content.CreateCell(j).SetCellValue(celVal);
|
|
|
}else if (tabs[j].Name == "Date")
|
|
|
{
|