Merge branch 'MCUT' of https://gitea.mjm-staging.developers-homelab.net/BIMS/BIMS into MCUT
This commit is contained in:
commit
ac2b16d127
@ -16,7 +16,17 @@
|
||||
|
||||
</div>
|
||||
<div class="col-sm-12 col-xl-10">
|
||||
<div class="row bg-dark p-2 mb-5">
|
||||
<div class="row bg-dark p-2">
|
||||
<div>
|
||||
<div class="py-2 col-12" id="his_building">
|
||||
<div
|
||||
class="item btn-group btn-group-toggle"
|
||||
data-toggle="buttons"
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row bg-dark p-2 mb-5 align-items-center">
|
||||
<div class="col-auto">
|
||||
<div class="btn-group">
|
||||
<button type="button" onclick="setDateType('day', this)" class="btn btn-secondary waves-effect waves-themed">日期</button>
|
||||
@ -70,9 +80,20 @@
|
||||
|
||||
<script>
|
||||
var historyTable = null;
|
||||
var buildingTag = null;
|
||||
$(function () {
|
||||
initList();
|
||||
let html = "";
|
||||
for (let building of pageAct.buildList) {
|
||||
html += `<label class="btn btn-secondary">
|
||||
<input type="radio" name="buildingRadio" id="radio_${building.building_tag}" value="${building.building_tag}" onChange="SelectBuild(this,'${building.building_tag}')"> ${building.full_name}
|
||||
</label>`;
|
||||
}
|
||||
$("#his_building").find(".item").empty();
|
||||
$("#his_building").find(".item").append(html);
|
||||
if ($("#his_building .item label").first())
|
||||
$("#his_building .item label").first().click()
|
||||
|
||||
initList();
|
||||
// default list filter
|
||||
initApp.listFilter($('#js_default_list'), $('#js_default_list_filter'));
|
||||
// custom response message
|
||||
@ -161,11 +182,13 @@
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function initList() {
|
||||
$(loadEle).Loading("start");
|
||||
let sendData = {
|
||||
building_tag: pageAct.buiTag
|
||||
building_tag: buildingTag
|
||||
}
|
||||
objSendData.Data = sendData;
|
||||
let url = baseApiUrl + "/api/History/GetMainSub";
|
||||
@ -178,9 +201,9 @@
|
||||
strHtml += `<li>
|
||||
<a href="#" data-filter-tags="${val.full_name.toLowerCase()}" data-maintag="${val.main_system_tag}">
|
||||
<span class="nav-link-text">${val.full_name}</span>
|
||||
</a>
|
||||
<ul style="${index == 0 ? `display:block;` : ``}">`;
|
||||
|
||||
</a>
|
||||
<ul style="${index == 0 ? `display:block;` : ``}">`;
|
||||
|
||||
i1 = (val.history_Sub_systems != null && i1 == null) ? index : null;
|
||||
}
|
||||
|
||||
@ -232,6 +255,7 @@
|
||||
$('#js_nested_list').html(strHtml);
|
||||
$(`[data-tabname="hisListItem"]`).YTTab();
|
||||
}
|
||||
$(loadEle).Loading("close");
|
||||
ytAjax = new YourTeam.Ajax(url, objSendData, success, null, "POST").send();
|
||||
}
|
||||
|
||||
@ -266,7 +290,6 @@
|
||||
var edt = new Date(new Date().setDate(sdt.getDate() + 1));
|
||||
start = start ?? sdt.toLocaleDateString();
|
||||
end = end ?? edt.toLocaleDateString();
|
||||
$(loadEle).Loading("start");
|
||||
callBackFromHistory()
|
||||
getHistoryDataByBaja(pageAct.deviceNumber + "_" + pageAct.deviceItem,
|
||||
new Date(start).getTime(),
|
||||
@ -277,9 +300,7 @@
|
||||
}
|
||||
|
||||
function callBackFromHistory(res = '{"count":0,"data":[]}') {
|
||||
// console.log("@H1",res)
|
||||
res = JSON.parse(res);
|
||||
// console.log("@history",res.data)
|
||||
loadTable(res.data);
|
||||
if (historyTable != null) {
|
||||
let t = $('#historyTable').dataTable();
|
||||
@ -288,7 +309,6 @@
|
||||
if (res.data.length > 0)
|
||||
t.fnAddData(res.data);
|
||||
}
|
||||
$(loadEle).Loading("close");
|
||||
}
|
||||
|
||||
function setValue(deviceNumber, deviceName, deviceItem, elem) {
|
||||
@ -388,9 +408,10 @@
|
||||
}
|
||||
|
||||
function loadTable(data) {
|
||||
$(loadEle).Loading("start");
|
||||
|
||||
if (data) {
|
||||
$.each(data, function (i, v) {
|
||||
// console.log("loadTable",pageAct.devicePoiName.split(" ")[0])
|
||||
v.type = pageAct.devicePoiName.split(" ")[0];
|
||||
});
|
||||
|
||||
@ -425,7 +446,6 @@
|
||||
"title": "紀錄時間",
|
||||
"data": "timestamp",
|
||||
"render": function (data) {
|
||||
// console.log(data)
|
||||
return displayDate(data, "datetime");
|
||||
}
|
||||
}
|
||||
@ -433,6 +453,7 @@
|
||||
|
||||
historyTable = new YourTeam.JqDataTables.getTableByStatic(tag, data, columns, column_defs, null, null, null, null, "tpi");
|
||||
}
|
||||
$(loadEle).Loading("close");
|
||||
}
|
||||
|
||||
function exportExcel() {
|
||||
@ -450,4 +471,26 @@
|
||||
location.href = baseApiUrl + "/api/df?path=" + rel.data.split('/')[0] + "&fileName=" + rel.data.split('/')[1] + "&token=" + cookies.get("JWT-Authorization");
|
||||
}, null, "POST").send();
|
||||
}
|
||||
|
||||
//選擇棟別
|
||||
function SelectBuild(e, building_tag) {
|
||||
checkIsSelectedBuilding();
|
||||
}
|
||||
|
||||
function checkIsSelectedBuilding() {
|
||||
let result = false;
|
||||
let buildingRadios = $("[name=buildingRadio]:checked");
|
||||
buildingTag = null;
|
||||
if (buildingRadios && buildingRadios.length > 0) {
|
||||
$("[name=buildingRadio]").parent().removeClass("btn-info");
|
||||
$("[name=buildingRadio]").parent().addClass("btn-secondary");
|
||||
$("[name=buildingRadio]:checked").parent().removeClass("btn-secondary");
|
||||
$("[name=buildingRadio]:checked").parent().addClass("btn-info");
|
||||
buildingTag = buildingRadios.prop("id").split("_")[1]; //building tag
|
||||
initList();
|
||||
result = true;
|
||||
} else {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
</script>
|
File diff suppressed because it is too large
Load Diff
@ -156,7 +156,7 @@ namespace FrontendWebApi.ApiControllers
|
||||
try
|
||||
{
|
||||
var dbsub = await frontendRepository.GetAllAsync<HistoryDBMainSub>(
|
||||
@$"select distinct build.full_name as building_name, d.device_building_tag, v1.system_key main_name, v1.system_value main_system_tag, v2.system_key sub_name,
|
||||
@$"select distinct build.full_name as building_name, build.priority as buildPriority, d.device_building_tag, v1.system_key main_name, v1.system_value main_system_tag, v2.system_key sub_name,
|
||||
v2.system_value sub_system_tag, v1.system_priority, v2.system_priority,
|
||||
dk.device_normal_color, dk.device_close_color, dk.device_error_color,dk.device_normal_flashing, dk.device_close_flashing, dk.device_error_flashing,
|
||||
dk.device_normal_text, dk.device_close_text, dk.device_error_text,dk.device_normal_point_name, dk.device_close_point_name, dk.device_error_point_name,
|
||||
@ -176,7 +176,7 @@ namespace FrontendWebApi.ApiControllers
|
||||
select distinct main_system_tag, sub_system_tag from building_menu where is_link = 1
|
||||
) as bm on v2.system_value = bm.sub_system_tag and v1.system_value = bm.main_system_tag
|
||||
where c.account = @account
|
||||
order by v2.system_priority", new { @account = "webUser", @sub_system_type = sub_system_type, @main_system_type = main_system_type });
|
||||
order by build.priority, v2.system_priority", new { @account = myUser.account, @sub_system_type = sub_system_type, @main_system_type = main_system_type });
|
||||
var building = dbsub.GroupBy(x => x.device_building_tag).ToList();
|
||||
apiResult.Data = new List<History_Building>();
|
||||
|
||||
|
@ -13,6 +13,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Ionic.Zip;
|
||||
using System.Collections.Immutable;
|
||||
|
||||
namespace FrontendWebApi.ApiControllers
|
||||
{
|
||||
@ -408,13 +409,13 @@ namespace FrontendWebApi.ApiControllers
|
||||
[Route("api/ExportElectricList")]
|
||||
public FileResult OpeExportExcelElec([FromBody] HydroMeterInput input)
|
||||
{
|
||||
input = new HydroMeterInput();
|
||||
input.building_tag = "G6";
|
||||
input.floor_tag = new List<string>();
|
||||
input.startTime = "2023-06";
|
||||
input.tableType = "day";
|
||||
|
||||
var result = this.ElectricList(input).Result.Value.Data.ToList();
|
||||
List<List<HydroMeterOutput>> result = new List<List<HydroMeterOutput>>();
|
||||
var building = backendRepository.GetAllAsync<HydroBuildList>("select * from building where deleted = 0").Result;
|
||||
foreach(var b in building)
|
||||
{
|
||||
input.building_tag = b.building_tag;
|
||||
result.Add(this.ElectricList(input).Result.Value.Data.ToList());
|
||||
}
|
||||
List<Dictionary<string, byte[]>> docFile = new List<Dictionary<string, byte[]>>();
|
||||
|
||||
var workbook = new XSSFWorkbook();
|
||||
@ -459,92 +460,95 @@ namespace FrontendWebApi.ApiControllers
|
||||
stylein12.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
stylein12.WrapText = true;
|
||||
#endregion
|
||||
|
||||
var sheet = workbook.CreateSheet("電表報表");
|
||||
int RowPosition = 0;
|
||||
if (result.Count > 0)
|
||||
foreach (var r in result)
|
||||
{
|
||||
#region set cell
|
||||
IRow row = sheet.CreateRow(RowPosition);
|
||||
sheet.SetColumnWidth(0, 4 * 160 * 12);
|
||||
sheet.SetColumnWidth(1, 4 * 160 * 12);
|
||||
sheet.SetColumnWidth(2, 4 * 160 * 12);
|
||||
|
||||
int i = 0;
|
||||
ICell cell = row.CreateCell(i++);
|
||||
cell.SetCellValue("棟別");
|
||||
cell.CellStyle = styleLine12;
|
||||
cell = row.CreateCell(i++);
|
||||
cell.SetCellValue("樓層");
|
||||
cell.CellStyle = styleLine12;
|
||||
cell = row.CreateCell(i++);
|
||||
cell.SetCellValue("設備");
|
||||
cell.CellStyle = styleLine12;
|
||||
|
||||
foreach (var rr in result.FirstOrDefault().rawData)
|
||||
string buildingName = r.Select(x => x.building_name).FirstOrDefault();
|
||||
var sheet = workbook.CreateSheet($"{buildingName}電表報表");
|
||||
int RowPosition = 0;
|
||||
if (result.Count > 0)
|
||||
{
|
||||
cell = row.CreateCell(i++);
|
||||
cell.SetCellValue(rr.timeStamp);
|
||||
#region set cell
|
||||
IRow row = sheet.CreateRow(RowPosition);
|
||||
sheet.SetColumnWidth(0, 4 * 160 * 12);
|
||||
sheet.SetColumnWidth(1, 4 * 160 * 12);
|
||||
sheet.SetColumnWidth(2, 4 * 160 * 12);
|
||||
|
||||
int i = 0;
|
||||
ICell cell = row.CreateCell(i++);
|
||||
cell.SetCellValue("棟別");
|
||||
cell.CellStyle = styleLine12;
|
||||
}
|
||||
|
||||
cell = row.CreateCell(i++);
|
||||
cell.SetCellValue("小計");
|
||||
cell.CellStyle = styleLine12;
|
||||
cell = row.CreateCell(i++);
|
||||
cell.SetCellValue("單價");
|
||||
cell.CellStyle = styleLine12;
|
||||
cell = row.CreateCell(i++);
|
||||
cell.SetCellValue("金額總計");
|
||||
cell.CellStyle = styleLine12;
|
||||
#endregion
|
||||
|
||||
foreach (var r in result)
|
||||
{
|
||||
RowPosition += 1;
|
||||
int k = 3;
|
||||
row = sheet.CreateRow(RowPosition);
|
||||
for (int j = 0; j <= i; j++)
|
||||
cell = row.CreateCell(i++);
|
||||
cell.SetCellValue("樓層");
|
||||
cell.CellStyle = styleLine12;
|
||||
cell = row.CreateCell(i++);
|
||||
cell.SetCellValue("設備");
|
||||
cell.CellStyle = styleLine12;
|
||||
|
||||
foreach (var rr in r.FirstOrDefault().rawData)
|
||||
{
|
||||
cell = row.CreateCell(j);
|
||||
if (j == 0)
|
||||
{
|
||||
cell.SetCellValue(r.building_name);
|
||||
}
|
||||
if (j == 1)
|
||||
{
|
||||
cell.SetCellValue(r.floor_tag);
|
||||
}
|
||||
if (j == 2)
|
||||
{
|
||||
cell.SetCellValue(r.device_full_name);
|
||||
}
|
||||
|
||||
if (j == 3)
|
||||
{
|
||||
foreach (var rr in r.rawData)
|
||||
{
|
||||
cell.SetCellValue(rr.avg_rawdata.ToString());
|
||||
j++;
|
||||
k++;
|
||||
cell = row.CreateCell(j);
|
||||
}
|
||||
}
|
||||
|
||||
if (j == k)
|
||||
{
|
||||
cell.SetCellValue(r.total);
|
||||
}
|
||||
if (j == k+1)
|
||||
{
|
||||
cell.SetCellValue(r.price);
|
||||
}
|
||||
if (j == k+2)
|
||||
{
|
||||
cell.SetCellValue(r.total_price);
|
||||
}
|
||||
cell = row.CreateCell(i++);
|
||||
cell.SetCellValue(rr.timeStamp);
|
||||
cell.CellStyle = styleLine12;
|
||||
}
|
||||
|
||||
cell.CellStyle = style12;
|
||||
cell = row.CreateCell(i++);
|
||||
cell.SetCellValue("小計");
|
||||
cell.CellStyle = styleLine12;
|
||||
cell = row.CreateCell(i++);
|
||||
cell.SetCellValue("單價");
|
||||
cell.CellStyle = styleLine12;
|
||||
cell = row.CreateCell(i++);
|
||||
cell.SetCellValue("金額總計");
|
||||
cell.CellStyle = styleLine12;
|
||||
#endregion
|
||||
|
||||
foreach (var rr in r)
|
||||
{
|
||||
RowPosition += 1;
|
||||
int k = 3;
|
||||
row = sheet.CreateRow(RowPosition);
|
||||
for (int j = 0; j <= i; j++)
|
||||
{
|
||||
cell = row.CreateCell(j);
|
||||
if (j == 0)
|
||||
{
|
||||
cell.SetCellValue(rr.building_name);
|
||||
}
|
||||
if (j == 1)
|
||||
{
|
||||
cell.SetCellValue(rr.floor_tag);
|
||||
}
|
||||
if (j == 2)
|
||||
{
|
||||
cell.SetCellValue(rr.device_full_name);
|
||||
}
|
||||
|
||||
if (j == 3)
|
||||
{
|
||||
foreach (var rrr in rr.rawData)
|
||||
{
|
||||
cell.SetCellValue(rrr.avg_rawdata.ToString());
|
||||
j++;
|
||||
k++;
|
||||
cell = row.CreateCell(j);
|
||||
}
|
||||
}
|
||||
|
||||
if (j == k)
|
||||
{
|
||||
cell.SetCellValue(rr.total);
|
||||
}
|
||||
if (j == k+1)
|
||||
{
|
||||
cell.SetCellValue(rr.price);
|
||||
}
|
||||
if (j == k+2)
|
||||
{
|
||||
cell.SetCellValue(rr.total_price);
|
||||
}
|
||||
|
||||
cell.CellStyle = style12;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -556,33 +560,48 @@ namespace FrontendWebApi.ApiControllers
|
||||
workbook.Write(ms);
|
||||
ms.Flush();
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
docFile.Add(new Dictionary<string, byte[]>() { { "電表報表", ms.ToArray() } });
|
||||
|
||||
var memoryStream = new MemoryStream();
|
||||
using (Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile(System.Text.Encoding.UTF8))
|
||||
{
|
||||
foreach(var d in docFile)
|
||||
{
|
||||
foreach(var dic in d)
|
||||
{
|
||||
zip.AddEntry(dic.Key, dic.Value);
|
||||
}
|
||||
}
|
||||
zip.Save(memoryStream);
|
||||
}
|
||||
|
||||
Response.Headers.Add("Access-Control-Expose-Headers", "Content-Disposition");
|
||||
return File(memoryStream, "application/octet-stream", "電表報表.zip");
|
||||
return File(ms, "application/vnd.ms", "電表報表.xlsx");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("api/ExportElectricCompareList")]
|
||||
public FileResult OpeExportCompareExcelElec([FromBody] List<HydroMeterInput> input)
|
||||
{
|
||||
var result = new List<HydroMeterOutput>();
|
||||
var result1 = this.ElectricList(input[0]).Result.Value.Data.ToList();
|
||||
var result2 = this.ElectricList(input[1]).Result.Value.Data.ToList();
|
||||
List<HydroMeterOutput> result = new List<HydroMeterOutput>();
|
||||
List<List<HydroMeterOutput>> result1 = new List<List<HydroMeterOutput>>();
|
||||
List<List<HydroMeterOutput>> result2 = new List<List<HydroMeterOutput>>();
|
||||
List<Dictionary<string, byte[]>> docFile = new List<Dictionary<string, byte[]>>();
|
||||
var building = backendRepository.GetAllAsync<HydroBuildList>("select * from building where deleted = 0").Result;
|
||||
|
||||
foreach (var b in building)
|
||||
{
|
||||
input[0].building_tag = b.building_tag;
|
||||
input[1].building_tag = b.building_tag;
|
||||
result1.Add(this.ElectricList(input[0]).Result.Value.Data.ToList());
|
||||
result2.Add(this.ElectricList(input[1]).Result.Value.Data.ToList());
|
||||
}
|
||||
|
||||
Dictionary<string, List<string>> compareDict = new Dictionary<string, List<string>>();
|
||||
var rawDataTitle = new List<string>();
|
||||
|
||||
if (input[0].tableType == "month")
|
||||
{
|
||||
for (var i = 1; i <= 12; i++)
|
||||
{
|
||||
rawDataTitle.Add(input[0].startTime + "-" + i.ToString().PadLeft(2, '0'));
|
||||
rawDataTitle.Add(input[1].startTime + "-" + i.ToString().PadLeft(2, '0'));
|
||||
}
|
||||
}
|
||||
else if (input[0].tableType == "day")
|
||||
{
|
||||
var days = GetDayInMonth(input[0].startTime);
|
||||
for (var i = 1 ;i <= days ; i++) {
|
||||
rawDataTitle.Add(input[0].startTime + "-" + i.ToString().PadLeft(2, '0'));
|
||||
rawDataTitle.Add(input[1].startTime + "-" + i.ToString().PadLeft(2, '0'));
|
||||
}
|
||||
}
|
||||
|
||||
var workbook = new XSSFWorkbook();
|
||||
#region excel設定
|
||||
IFont font12 = workbook.CreateFont();
|
||||
@ -625,157 +644,145 @@ namespace FrontendWebApi.ApiControllers
|
||||
stylein12.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
stylein12.WrapText = true;
|
||||
#endregion
|
||||
var rawDataTitle = new List<string>();
|
||||
|
||||
if (input[0].tableType == "month")
|
||||
foreach (var b in building)
|
||||
{
|
||||
for (var i = 1; i <= 12; i++)
|
||||
var res1 = result1.Where(x => x.Select(x => x.building_tag).Contains(b.building_tag)).ToList();
|
||||
var res2 = result2.Where(x => x.Select(x => x.building_tag).Contains(b.building_tag)).ToList();
|
||||
if (res1.Count > 0 || res2.Count > 0)
|
||||
{
|
||||
rawDataTitle.Add(input[0].startTime + "-" + i.ToString().PadLeft(2, '0'));
|
||||
rawDataTitle.Add(input[1].startTime + "-" + i.ToString().PadLeft(2, '0'));
|
||||
}
|
||||
}
|
||||
else if (input[0].tableType == "day")
|
||||
{
|
||||
var days = GetDayInMonth(input[0].startTime);
|
||||
for (var i = 1 ;i <= days ; i++) {
|
||||
rawDataTitle.Add(input[0].startTime + "-" + i.ToString().PadLeft(2, '0'));
|
||||
rawDataTitle.Add(input[1].startTime + "-" + i.ToString().PadLeft(2, '0'));
|
||||
}
|
||||
}
|
||||
|
||||
var sheet = workbook.CreateSheet("電表報表");
|
||||
int RowPosition = 0;
|
||||
if (result1.Count > 0 || result2.Count > 0)
|
||||
{
|
||||
result = result1;
|
||||
foreach (var r2 in result2)
|
||||
{
|
||||
var target = result.Where(r => r.building_tag == r2.building_tag && r.device_serial_tag == r2.device_serial_tag && r.floor_tag == r2.floor_tag).FirstOrDefault();
|
||||
compareDict[r2.building_tag + r2.floor_tag + r2.device_serial_tag] = new List<string>() { r2.total, r2.price, r2.total_price };
|
||||
if (target != null)
|
||||
var sheet = workbook.CreateSheet($"{b.full_name}電表報表");
|
||||
int RowPosition = 0;
|
||||
result = res1.FirstOrDefault() ?? new List<HydroMeterOutput>();
|
||||
var r2 = res2.FirstOrDefault() ?? new List<HydroMeterOutput>();
|
||||
foreach (var r in r2)
|
||||
{
|
||||
target.rawData = target.rawData.Concat(r2.rawData).ToList();
|
||||
var target = result.Where(x => x.building_tag == r.building_tag && x.device_serial_tag == r.device_serial_tag && x.floor_tag == r.floor_tag && x.device_number == r.device_number).FirstOrDefault();
|
||||
compareDict[r.building_tag + r.floor_tag + r.device_serial_tag + r.device_number] = new List<string>() { r.total, r.price, r.total_price };
|
||||
if (target != null)
|
||||
{
|
||||
target.rawData = target.rawData.Concat(r.rawData).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
r.total = null;
|
||||
r.price = null;
|
||||
r.total_price = null;
|
||||
result.Add(r);
|
||||
}
|
||||
}
|
||||
else {
|
||||
r2.total = null;
|
||||
r2.price = null;
|
||||
r2.total_price= null;
|
||||
result.Add(r2);
|
||||
}
|
||||
|
||||
}
|
||||
#region set cell
|
||||
IRow row = sheet.CreateRow(RowPosition);
|
||||
sheet.SetColumnWidth(0, 4 * 160 * 12);
|
||||
sheet.SetColumnWidth(1, 4 * 160 * 12);
|
||||
sheet.SetColumnWidth(2, 4 * 160 * 12);
|
||||
#region set cell
|
||||
IRow row = sheet.CreateRow(RowPosition);
|
||||
sheet.SetColumnWidth(0, 4 * 160 * 12);
|
||||
sheet.SetColumnWidth(1, 4 * 160 * 12);
|
||||
sheet.SetColumnWidth(2, 4 * 160 * 12);
|
||||
|
||||
int i = 0;
|
||||
ICell cell = row.CreateCell(i++);
|
||||
cell.SetCellValue("棟別");
|
||||
cell.CellStyle = styleLine12;
|
||||
cell = row.CreateCell(i++);
|
||||
cell.SetCellValue("樓層");
|
||||
cell.CellStyle = styleLine12;
|
||||
cell = row.CreateCell(i++);
|
||||
cell.SetCellValue("設備");
|
||||
cell.CellStyle = styleLine12;
|
||||
|
||||
foreach (var rr in rawDataTitle)
|
||||
{
|
||||
sheet.SetColumnWidth(i, 2 * 160 * 12);
|
||||
cell = row.CreateCell(i++);
|
||||
cell.SetCellValue(rr);
|
||||
int i = 0;
|
||||
ICell cell = row.CreateCell(i++);
|
||||
cell.SetCellValue("棟別");
|
||||
cell.CellStyle = styleLine12;
|
||||
cell = row.CreateCell(i++);
|
||||
cell.SetCellValue("樓層");
|
||||
cell.CellStyle = styleLine12;
|
||||
cell = row.CreateCell(i++);
|
||||
cell.SetCellValue("設備");
|
||||
cell.CellStyle = styleLine12;
|
||||
}
|
||||
|
||||
cell = row.CreateCell(i++);
|
||||
cell.SetCellValue(input[0].startTime + "小計");
|
||||
sheet.SetColumnWidth(i-1, 2 * 160 * 12);
|
||||
cell.CellStyle = styleLine12;
|
||||
cell = row.CreateCell(i++);
|
||||
cell.SetCellValue(input[1].startTime + "小計");
|
||||
sheet.SetColumnWidth(i - 1, 2 * 160 * 12);
|
||||
cell.CellStyle = styleLine12;
|
||||
cell = row.CreateCell(i++);
|
||||
cell.SetCellValue(input[0].startTime + "單價");
|
||||
sheet.SetColumnWidth(i - 1, 2 * 160 * 12);
|
||||
cell.CellStyle = styleLine12;
|
||||
cell = row.CreateCell(i++);
|
||||
cell.SetCellValue(input[1].startTime + "單價");
|
||||
sheet.SetColumnWidth(i - 1, 2 * 160 * 12);
|
||||
cell.CellStyle = styleLine12;
|
||||
cell = row.CreateCell(i++);
|
||||
cell.SetCellValue(input[0].startTime + "金額總計");
|
||||
sheet.SetColumnWidth(i - 1, 2 * 160 * 12);
|
||||
cell.CellStyle = styleLine12;
|
||||
cell = row.CreateCell(i++);
|
||||
cell.SetCellValue(input[1].startTime + "金額總計");
|
||||
sheet.SetColumnWidth(i - 1, 2 * 160 * 12);
|
||||
cell.CellStyle = styleLine12;
|
||||
#endregion
|
||||
|
||||
foreach (var r in result)
|
||||
{
|
||||
string compareDictKey = r.building_tag + r.floor_tag + r.device_serial_tag;
|
||||
RowPosition += 1;
|
||||
int k = 3;
|
||||
row = sheet.CreateRow(RowPosition);
|
||||
for (int j = 0; j <= i; j++)
|
||||
foreach (var rr in rawDataTitle)
|
||||
{
|
||||
cell = row.CreateCell(j);
|
||||
if (j == 0)
|
||||
{
|
||||
cell.SetCellValue(r.building_name);
|
||||
}
|
||||
if (j == 1)
|
||||
{
|
||||
cell.SetCellValue(r.floor_tag);
|
||||
}
|
||||
if (j == 2)
|
||||
{
|
||||
cell.SetCellValue(r.device_serial_tag);
|
||||
}
|
||||
sheet.SetColumnWidth(i, 2 * 160 * 12);
|
||||
cell = row.CreateCell(i++);
|
||||
cell.SetCellValue(rr);
|
||||
cell.CellStyle = styleLine12;
|
||||
}
|
||||
|
||||
if (j == 3)
|
||||
cell = row.CreateCell(i++);
|
||||
cell.SetCellValue(input[0].startTime + "小計");
|
||||
sheet.SetColumnWidth(i - 1, 2 * 160 * 12);
|
||||
cell.CellStyle = styleLine12;
|
||||
cell = row.CreateCell(i++);
|
||||
cell.SetCellValue(input[1].startTime + "小計");
|
||||
sheet.SetColumnWidth(i - 1, 2 * 160 * 12);
|
||||
cell.CellStyle = styleLine12;
|
||||
cell = row.CreateCell(i++);
|
||||
cell.SetCellValue(input[0].startTime + "單價");
|
||||
sheet.SetColumnWidth(i - 1, 2 * 160 * 12);
|
||||
cell.CellStyle = styleLine12;
|
||||
cell = row.CreateCell(i++);
|
||||
cell.SetCellValue(input[1].startTime + "單價");
|
||||
sheet.SetColumnWidth(i - 1, 2 * 160 * 12);
|
||||
cell.CellStyle = styleLine12;
|
||||
cell = row.CreateCell(i++);
|
||||
cell.SetCellValue(input[0].startTime + "金額總計");
|
||||
sheet.SetColumnWidth(i - 1, 2 * 160 * 12);
|
||||
cell.CellStyle = styleLine12;
|
||||
cell = row.CreateCell(i++);
|
||||
cell.SetCellValue(input[1].startTime + "金額總計");
|
||||
sheet.SetColumnWidth(i - 1, 2 * 160 * 12);
|
||||
cell.CellStyle = styleLine12;
|
||||
#endregion
|
||||
|
||||
foreach (var r in result)
|
||||
{
|
||||
string compareDictKey = r.building_tag + r.floor_tag + r.device_serial_tag + r.device_number;
|
||||
RowPosition += 1;
|
||||
int k = 3;
|
||||
row = sheet.CreateRow(RowPosition);
|
||||
for (int j = 0; j <= i; j++)
|
||||
{
|
||||
foreach (var rr in rawDataTitle)
|
||||
cell = row.CreateCell(j);
|
||||
if (j == 0)
|
||||
{
|
||||
var targetRaw = r.rawData.Where(rd => rd.timeStamp == rr).FirstOrDefault();
|
||||
cell.SetCellValue(targetRaw?.avg_rawdata.ToString() ?? "");
|
||||
j++;
|
||||
k++;
|
||||
cell = row.CreateCell(j);
|
||||
cell.SetCellValue(r.building_name);
|
||||
}
|
||||
if (j == 1)
|
||||
{
|
||||
cell.SetCellValue(r.floor_tag);
|
||||
}
|
||||
if (j == 2)
|
||||
{
|
||||
cell.SetCellValue(r.device_full_name);
|
||||
}
|
||||
}
|
||||
|
||||
if (j == k)
|
||||
{
|
||||
cell.SetCellValue(r.total);
|
||||
}
|
||||
if (j == k + 1)
|
||||
{
|
||||
cell.SetCellValue(compareDict.ContainsKey(compareDictKey) ? compareDict[compareDictKey][0] : "");
|
||||
}
|
||||
if (j == k + 2)
|
||||
{
|
||||
cell.SetCellValue(r.price);
|
||||
}
|
||||
if (j == k + 3)
|
||||
{
|
||||
cell.SetCellValue(compareDict.ContainsKey(compareDictKey) ? compareDict[compareDictKey][1] : "");
|
||||
}
|
||||
if (j == k + 4)
|
||||
{
|
||||
cell.SetCellValue(r.total_price);
|
||||
}
|
||||
if (j == k + 5)
|
||||
{
|
||||
cell.SetCellValue(compareDict.ContainsKey(compareDictKey) ? compareDict[compareDictKey][2] : "");
|
||||
}
|
||||
if (j == 3)
|
||||
{
|
||||
foreach (var rr in rawDataTitle)
|
||||
{
|
||||
var targetRaw = r.rawData.Where(rd => rd.timeStamp == rr).FirstOrDefault();
|
||||
cell.SetCellValue(targetRaw?.avg_rawdata.ToString() ?? "");
|
||||
j++;
|
||||
k++;
|
||||
cell = row.CreateCell(j);
|
||||
}
|
||||
}
|
||||
|
||||
cell.CellStyle = style12;
|
||||
if (j == k)
|
||||
{
|
||||
cell.SetCellValue(r.total);
|
||||
}
|
||||
if (j == k + 1)
|
||||
{
|
||||
cell.SetCellValue(compareDict.ContainsKey(compareDictKey) ? compareDict[compareDictKey][0] : "");
|
||||
}
|
||||
if (j == k + 2)
|
||||
{
|
||||
cell.SetCellValue(r.price);
|
||||
}
|
||||
if (j == k + 3)
|
||||
{
|
||||
cell.SetCellValue(compareDict.ContainsKey(compareDictKey) ? compareDict[compareDictKey][1] : "");
|
||||
}
|
||||
if (j == k + 4)
|
||||
{
|
||||
cell.SetCellValue(r.total_price);
|
||||
}
|
||||
if (j == k + 5)
|
||||
{
|
||||
cell.SetCellValue(compareDict.ContainsKey(compareDictKey) ? compareDict[compareDictKey][2] : "");
|
||||
}
|
||||
|
||||
cell.CellStyle = style12;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -54,4 +54,10 @@ namespace FrontendWebApi.Models
|
||||
{
|
||||
public List<HydroMeterCompareOutput> exportList { get; set; }
|
||||
}
|
||||
|
||||
public class HydroBuildList
|
||||
{
|
||||
public string full_name { get; set; }
|
||||
public string building_tag { get; set; }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user