From 718f2768f75359501da79719e58c4543771631b0 Mon Sep 17 00:00:00 2001 From: "jay.chang" Date: Tue, 23 Jan 2024 09:12:08 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=B0=B4=E9=9B=BB?= =?UTF-8?q?=E5=A0=B1=E8=A1=A8Controller?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/TenantBillController.cs | 300 ++++++++++++++++++ FrontendWebApi/Models/Bill.cs | 55 ++++ 2 files changed, 355 insertions(+) create mode 100644 FrontendWebApi/ApiControllers/TenantBillController.cs create mode 100644 FrontendWebApi/Models/Bill.cs diff --git a/FrontendWebApi/ApiControllers/TenantBillController.cs b/FrontendWebApi/ApiControllers/TenantBillController.cs new file mode 100644 index 0000000..d60593a --- /dev/null +++ b/FrontendWebApi/ApiControllers/TenantBillController.cs @@ -0,0 +1,300 @@ +using FrontendWebApi.Models; +using Microsoft.AspNetCore.Mvc; +using Repository.BackendRepository.Interface; +using Repository.FrontendRepository.Interface; +using System.Collections.Generic; +using System.Threading.Tasks; +using System; +using System.IO; +using static FrontendWebApi.Models.Bill; +using Microsoft.Extensions.Logging; +using System.Text.Json; + + +// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 + +namespace FrontendWebApi.ApiControllers +{ + //[Route("api/[controller]")] + //[ApiController] + public class TenantBillController + //public class TenantBillController : MyBaseApiController + { + private readonly IBackendRepository backendRepository; + + + const string TenantListtable = "archive_electric_meter_tenant_list"; + const string TenantBilltable = "archive_electric_meter_tenant_bill"; + + + public TenantBillController(IBackendRepository backendRepository, IFrontendRepository frontendRepository) + { + this.backendRepository = backendRepository; + + } + + [HttpPost] + public async Task>> GetTenantList() + { + ApiResult> apiResult = new ApiResult>(); + List tenantList = new List(); + try + { + var sqlString = $"SELECT tenant_guid,tenant_id,tenant_name,bill_perKWH,bill_perRCV " + + $"from {TenantListtable} order by created_at"; + + tenantList = await backendRepository.GetAllAsync(sqlString); + + + apiResult.Code = "0000"; + apiResult.Data = tenantList; + } + catch (Exception exception) + { + apiResult.Code = "9999"; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; + //Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + } + + return apiResult; + } + + [HttpPost] + public async Task> AddOneTenantList(TenantList tl) + { + ApiResult apiResult = new ApiResult(); + + try + { + var tenant_guid = Guid.NewGuid(); + var tenant_name = tl.tenant_name; + var bill_perKWH = tl.bill_perKWH; + var bill_perRCV = tl.bill_perRCV; + var created_at = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + + var sqlString = $"INSERT INTO {TenantListtable} (tenant_guid,tenant_id,tenant_name, bill_perKWH, bill_perRCV, created_by,created_at) " + + $"VALUES ('{tenant_guid}',{tl.tenant_id},'{tenant_name}', {bill_perKWH}, {bill_perRCV},'{tl.created_by}', '{created_at}')"; + + + await backendRepository.ExecuteSql(sqlString); + apiResult.Code = "0000"; + apiResult.Data = "新增成功"; + } + catch (Exception exception) + { + apiResult.Code = "9999"; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。" + exception.Message; + //Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + } + + return apiResult; + } + + [HttpPost] + public async Task> UpdateOneTenantList(TenantList tl) + { + ApiResult apiResult = new ApiResult(); + + try + { + var updated_at = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + var sqlString = $"UPDATE {TenantListtable} SET " + + $"`tenant_name` = '{tl.tenant_name}', " + + $"`bill_perKWH` = {tl.bill_perKWH}, " + + $"`bill_perRCV` = {tl.bill_perRCV}, " + + $"`updated_by` = {tl.updated_by}, " + + $"`updated_at` = '{updated_at}' " + + $"WHERE `tenant_guid` = '{tl.tenant_guid}'"; + + + await backendRepository.ExecuteSql(sqlString); + apiResult.Code = "0000"; + apiResult.Data = "修改成功"; + } + catch (Exception exception) + { + apiResult.Code = "9999"; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; + //Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + } + + return apiResult; + } + + [HttpPost] + public async Task> DelOneTenantList(TenantList tl) + { + ApiResult apiResult = new ApiResult(); + + try + { + var sqlString = $"delete from {TenantListtable} WHERE tenant_guid = '{tl.tenant_guid}' "; + + await backendRepository.ExecuteSql(sqlString); + apiResult.Code = "0000"; + apiResult.Data = "刪除成功"; + } + catch (Exception exception) + { + apiResult.Code = "9999"; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; + //Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + } + + return apiResult; + } + + [HttpPost] + public async Task>> GetTenantBill(string tableType, string building_tag) + { + ApiResult> apiResult = new ApiResult>(); + List tenantBill = new List(); + try + { + string ElecOrWater = tableType == "elec" ? "E4" : "W1"; + string sqlString = null; + if (building_tag == "ALL") + { + sqlString = + $"SELECT tenant_id,a.device_number,a.full_name,start_timestamp,end_timestamp,result,bill,tenant_name " + + $"from {TenantBilltable} a join device b on a.device_number =b.device_number" + + $"where a.device_name_tag = '{ElecOrWater}' "; + } + else if (building_tag == "D2") + { + sqlString = + $"SELECT tenant_id,a.device_number,a.full_name,start_timestamp,end_timestamp,result,bill,tenant_name " + + $"from {TenantBilltable} a join device b on a.device_number =b.device_number " + + $"where device_building_tag = 'D1' and a.device_name_tag = '{ElecOrWater}' || device_building_tag = 'D2' and a.device_name_tag = '{ElecOrWater}'"; + } + else + { + sqlString = + $"SELECT tenant_id,a.device_number,a.full_name,start_timestamp,end_timestamp,result,bill,tenant_name " + + $"from {TenantBilltable} a join device b on a.device_number =b.device_number " + + $"where device_building_tag = '{building_tag}' and a.device_name_tag = '{ElecOrWater}' "; + } + + + tenantBill = await backendRepository.GetAllAsync(sqlString); + + + apiResult.Code = "0000"; + apiResult.Data = tenantBill; + } + catch (Exception exception) + { + apiResult.Code = "9999"; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; + //Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + } + + return apiResult; + } + + [HttpPost] + public async Task> UpdateTenantBill(TenantBill tb, string tableType) + { + ApiResult apiResult = new ApiResult(); + + try + { + string bill_per = tableType == "elec" ? "bill_perKWH" : "bill_perRCV"; + var updated_at = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + var start_timestamp = tb.start_timestamp.ToString("yyyy-MM-dd HH:mm:ss"); + var end_timestamp = tb.end_timestamp.ToString("yyyy-MM-dd HH:mm:ss"); + string sqlString = null; + + string startMonth = tb.start_timestamp.Year.ToString() + tb.start_timestamp.Month.ToString("D2"); + string endMonth = tb.end_timestamp.Year.ToString() + tb.end_timestamp.Month.ToString("D2"); + if (startMonth == endMonth) + { + sqlString = + $"UPDATE {TenantBilltable} " + + $"set tenant_id = {tb.tenant_id} ,tenant_name = '{tb.tenant_name}', start_timestamp = '{start_timestamp}',end_timestamp = '{end_timestamp}' , " + + $"result= " + + $"(select sum(sub_result) " + + $"from archive_electric_water_meter_day_{startMonth} " + + $"WHERE device_number = '{tb.device_number}' and start_timestamp BETWEEN '{start_timestamp}' and '{end_timestamp}' " + + $"GROUP BY device_number) , " + + $"bill = " + + $"ROUND(result *(SELECT {bill_per} from {TenantListtable} WHERE tenant_guid = '{tb.tenant_guid}') ), " + + $"updated_by = '{tb.updated_by}', " + + $"updated_at = '{updated_at}', " + + $"tenant_guid = '{tb.tenant_guid}' " + + $"WHERE device_number = '{tb.device_number}'"; + } + else + { + sqlString = + $"UPDATE {TenantBilltable} " + + $"set tenant_id = {tb.tenant_id} ,tenant_name = '{tb.tenant_name}', start_timestamp = '{start_timestamp}',end_timestamp = '{end_timestamp}' , " + + $"result= " + + $"(SELECT sum(sub_result) " + + $"FROM ( " + + $" SELECT start_timestamp,device_number, sub_result " + + $" FROM archive_electric_water_meter_day_{startMonth} " + + $" WHERE device_number = '{tb.device_number}' " + + $" UNION ALL " + + $" SELECT start_timestamp,device_number, sub_result " + + $" FROM archive_electric_water_meter_day_{endMonth} " + + $" WHERE device_number = '{tb.device_number}' " + + $") combined_result " + + $"WHERE start_timestamp BETWEEN '{start_timestamp}' and '{end_timestamp}' " + + $"GROUP BY device_number) ," + + $"bill = " + + $"ROUND(result *(SELECT {bill_per} from {TenantListtable} WHERE tenant_guid = '{tb.tenant_guid}') ), " + + $"updated_by = '{tb.updated_by}', " + + $"updated_at = '{updated_at}', " + + $"tenant_guid = '{tb.tenant_guid}' " + + $"WHERE device_number = '{tb.device_number}'"; + + } + + + await backendRepository.ExecuteSql(sqlString); + + + apiResult.Code = "0000"; + apiResult.Data = "修改成功"; + } + catch (Exception exception) + { + apiResult.Code = "9999"; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; + //Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + } + + return apiResult; + } + + [HttpPost] + public async Task>> OutputTenantBill() + { + ApiResult> apiResult = new ApiResult>(); + List outputBill = new List(); + + try + { + string sqlString = + $"SELECT distinct a.tenant_guid,b.tenant_name,start_timestamp,end_timestamp,bill_perKWH,bill_perRCV,sum(result) as name_result,sum(bill) as name_bill " + + $"from archive_electric_meter_tenant_bill a join archive_electric_meter_tenant_list b on a.tenant_guid = b.tenant_guid " + + $"WHERE a.tenant_guid = '37639e92-20ce-4064-956b-b6b0eaa7d7d2' " + + $"group by a.device_name_tag"; + + outputBill = await backendRepository.GetAllAsync(sqlString); + + apiResult.Code = "0000"; + apiResult.Data = outputBill; + } + catch (Exception exception) + { + apiResult.Code = "9999"; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; + //Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + } + + return apiResult; + } + } +} \ No newline at end of file diff --git a/FrontendWebApi/Models/Bill.cs b/FrontendWebApi/Models/Bill.cs new file mode 100644 index 0000000..f4f81fe --- /dev/null +++ b/FrontendWebApi/Models/Bill.cs @@ -0,0 +1,55 @@ +using System; + +namespace FrontendWebApi.Models +{ + public class Bill + { + public class TenantList + { + public string tenant_guid { get; set; } + public int tenant_id { get; set; } + public string tenant_name { get; set; } + public decimal bill_perKWH { get; set; } + public decimal bill_perRCV { get; set; } + public string created_by { get; set; } + public DateTime created_at { get; set; } + public string updated_by { get; set; } + public DateTime? updated_at { get; set; } + + } + + public class TenantBill + { + public int tenant_id { get; set; } + public string tenant_name { get; set; } + public string device_number { get; set; } + public string full_name { get; set; } + public DateTime start_timestamp { get; set; } + public DateTime end_timestamp { get; set; } + public string device_name_tag { get; set; } + public decimal result { get; set; } + public int bill { get; set; } + public string created_by { get; set; } + public DateTime created_at { get; set; } + public string updated_by { get; set; } + public DateTime? updated_at { get; set; } + public string tenant_guid { get; set; } + + } + public class OutputBill + { + public string tenant_name { get; set; } + public DateTime start_timestamp { get; set; } + public DateTime end_timestamp { get; set; } + public decimal kwh_total { get; set; } + public decimal bill_perKWH { get; set; } + public int electric_total { get; set; } + public decimal rcv_total { get; set; } + public decimal bill_perRCV { get; set; } + public int water_total { get; set; } + public int all_total { get; set; } + + } + + } +} \ No newline at end of file From 5c8abc1f191ef0cdf1cd0bf04d42a0e9cf798961 Mon Sep 17 00:00:00 2001 From: "jay.chang" Date: Tue, 23 Jan 2024 14:41:38 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=B0=B4=E9=9B=BB?= =?UTF-8?q?=E5=A0=B1=E8=A1=A8api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/TenantBillController.cs | 25 ++++-- FrontendWebApi/FrontendWebApi.csproj | 1 + FrontendWebApi/Models/Bill.cs | 3 + FrontendWebApi/appsettings.Development.json | 59 +++++++------- FrontendWebApi/appsettings.json | 80 +++++++++---------- 5 files changed, 86 insertions(+), 82 deletions(-) diff --git a/FrontendWebApi/ApiControllers/TenantBillController.cs b/FrontendWebApi/ApiControllers/TenantBillController.cs index d60593a..6e17d1a 100644 --- a/FrontendWebApi/ApiControllers/TenantBillController.cs +++ b/FrontendWebApi/ApiControllers/TenantBillController.cs @@ -9,6 +9,7 @@ using System.IO; using static FrontendWebApi.Models.Bill; using Microsoft.Extensions.Logging; using System.Text.Json; +using Newtonsoft.Json.Linq; // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 @@ -17,8 +18,8 @@ namespace FrontendWebApi.ApiControllers { //[Route("api/[controller]")] //[ApiController] - public class TenantBillController - //public class TenantBillController : MyBaseApiController + //public class TenantBillController + public class TenantBillController : MyBaseApiController { private readonly IBackendRepository backendRepository; @@ -60,7 +61,7 @@ namespace FrontendWebApi.ApiControllers } [HttpPost] - public async Task> AddOneTenantList(TenantList tl) + public async Task> AddOneTenantList([FromBody] TenantList tl) { ApiResult apiResult = new ApiResult(); @@ -91,7 +92,7 @@ namespace FrontendWebApi.ApiControllers } [HttpPost] - public async Task> UpdateOneTenantList(TenantList tl) + public async Task> UpdateOneTenantList([FromBody] TenantList tl) { ApiResult apiResult = new ApiResult(); @@ -122,7 +123,7 @@ namespace FrontendWebApi.ApiControllers } [HttpPost] - public async Task> DelOneTenantList(TenantList tl) + public async Task> DelOneTenantList([FromBody] TenantList tl) { ApiResult apiResult = new ApiResult(); @@ -144,13 +145,21 @@ namespace FrontendWebApi.ApiControllers return apiResult; } + public class MyJsonData + { + public string Name { get; set; } + public int Age { get; set; } + } + [HttpPost] - public async Task>> GetTenantBill(string tableType, string building_tag) + public async Task>> GetTenantBill([FromBody] TenantBill tb) { ApiResult> apiResult = new ApiResult>(); List tenantBill = new List(); try { + string tableType = tb.tableType; + string building_tag = tb.building_tag; string ElecOrWater = tableType == "elec" ? "E4" : "W1"; string sqlString = null; if (building_tag == "ALL") @@ -193,13 +202,13 @@ namespace FrontendWebApi.ApiControllers } [HttpPost] - public async Task> UpdateTenantBill(TenantBill tb, string tableType) + public async Task> UpdateTenantBill([FromBody] TenantBill tb) { ApiResult apiResult = new ApiResult(); try { - string bill_per = tableType == "elec" ? "bill_perKWH" : "bill_perRCV"; + string bill_per = tb.tableType == "elec" ? "bill_perKWH" : "bill_perRCV"; var updated_at = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); var start_timestamp = tb.start_timestamp.ToString("yyyy-MM-dd HH:mm:ss"); var end_timestamp = tb.end_timestamp.ToString("yyyy-MM-dd HH:mm:ss"); diff --git a/FrontendWebApi/FrontendWebApi.csproj b/FrontendWebApi/FrontendWebApi.csproj index fe797d3..8ca452a 100644 --- a/FrontendWebApi/FrontendWebApi.csproj +++ b/FrontendWebApi/FrontendWebApi.csproj @@ -11,6 +11,7 @@ + diff --git a/FrontendWebApi/Models/Bill.cs b/FrontendWebApi/Models/Bill.cs index f4f81fe..2b58ded 100644 --- a/FrontendWebApi/Models/Bill.cs +++ b/FrontendWebApi/Models/Bill.cs @@ -34,8 +34,11 @@ namespace FrontendWebApi.Models public string updated_by { get; set; } public DateTime? updated_at { get; set; } public string tenant_guid { get; set; } + public string tableType { get; set; } + public string building_tag { get; set; } } + public class OutputBill { public string tenant_name { get; set; } diff --git a/FrontendWebApi/appsettings.Development.json b/FrontendWebApi/appsettings.Development.json index 8798a2e..0e905a9 100644 --- a/FrontendWebApi/appsettings.Development.json +++ b/FrontendWebApi/appsettings.Development.json @@ -13,40 +13,39 @@ "JwtLifeSeconds": 3600 }, "DBConfig": { - "MySqlDBConfig": { - "Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201 - "Port": "js2LutKe+rdjzdxMPQUrvQ==", - //"Database": "VJB2XC+lAtzuHObDGMVOAA==", //30 + "MySqlDBConfig": { + "Server": "CYGthbCeGtAXT4s1NOSJHQ==", //0.132 + "Port": "mkF51jVbg40V5K5eTh2Ckw==", + //"Database": "VJB2XC+lAtzuHObDGMVOAA==", //30 //"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp - //"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome - "Database": "+5RAiFLJVU+LRyDxF1K/pcLZaoZa4k/thZqF6xKoCag=", //dome_online_0821 + "Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome //"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel - //"Database": "iuaY0h0+TWkir44/eZLDqw==", //tpe_dome_office - //"Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //MCUT + //"Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //mcut + //"Database": "XZ2fOBnta9kdVGEb7y92cg==", //ibms_mcut "Root": "SzdxEgaJJ7tcTCrUl2zKsA==", "Password": "FVAPxztxpY4gJJKQ/se4bQ==" } - //"MSSqlDBConfig": { - // "Server": "avZg8PA8C9GVgYZBgEKzCg==", - // "Port": "lJA0KPkG6RvFfTgWiXFyUw==", - // "Database": "VvfWH/59gQguY2eA2xBCug==", - // "Root": "sD8GZ9UPiIQGU6dU011/4A==", - // "Password": "2gi7rOmGha2VdXC5vtHxhg==" - //} + //"MSSqlDBConfig": { + // "Server": "avZg8PA8C9GVgYZBgEKzCg==", + // "Port": "lJA0KPkG6RvFfTgWiXFyUw==", + // "Database": "VvfWH/59gQguY2eA2xBCug==", + // "Root": "sD8GZ9UPiIQGU6dU011/4A==", + // "Password": "2gi7rOmGha2VdXC5vtHxhg==" + //} - //"MSSqlDBConfig": { //172.16.220.250 - // "Server": "zp3Nilx0PISEEC4caZWqCg==", - // "Port": "7puf4kd9qJ/q0fq2QASWeQ==", - // "Database": "VvfWH/59gQguY2eA2xBCug==", - // "Root": "sD8GZ9UPiIQGU6dU011/4A==", - // "Password": "Jue6jMFRi11meN6xbdKwDA==" - //} - //"MSSqlDBConfig": { - // "Server": "FPhyer7n0h/pw/yCMzKcPQ==", - // "Port": "7puf4kd9qJ/q0fq2QASWeQ==", - // "Database": "VvfWH/59gQguY2eA2xBCug==", - // "Root": "sD8GZ9UPiIQGU6dU011/4A==", - // "Password": "Jue6jMFRi11meN6xbdKwDA==" - //} + //"MSSqlDBConfig": { //172.16.220.250 + // "Server": "zp3Nilx0PISEEC4caZWqCg==", + // "Port": "7puf4kd9qJ/q0fq2QASWeQ==", + // "Database": "VvfWH/59gQguY2eA2xBCug==", + // "Root": "sD8GZ9UPiIQGU6dU011/4A==", + // "Password": "Jue6jMFRi11meN6xbdKwDA==" + //} + //"MSSqlDBConfig": { + // "Server": "FPhyer7n0h/pw/yCMzKcPQ==", + // "Port": "7puf4kd9qJ/q0fq2QASWeQ==", + // "Database": "VvfWH/59gQguY2eA2xBCug==", + // "Root": "sD8GZ9UPiIQGU6dU011/4A==", + // "Password": "Jue6jMFRi11meN6xbdKwDA==" + //} + } } -} diff --git a/FrontendWebApi/appsettings.json b/FrontendWebApi/appsettings.json index 56ec028..caa3d53 100644 --- a/FrontendWebApi/appsettings.json +++ b/FrontendWebApi/appsettings.json @@ -11,49 +11,41 @@ "SignKey": "TaipeiDome123456", //ñ��//�̤�16�r�� "JwtLifeSeconds": 86400 }, - "DBConfig": { - //"MySqlDBConfig": { - // "Server": "avZg8PA8C9GVgYZBgEKzCg==", - // "Port": "JKuuq+uwXTv3d/3a4itt6A==", - // "Database": "VvfWH/59gQguY2eA2xBCug==", - // "Root": "HHJtgEbqTcvCJtK4Lzg1Jg==", - // "Password": "2gi7rOmGha2VdXC5vtHxhg==" - //}, - "MySqlDBConfig": { - "Server": "FYlY+w0XDIz+jmF2rlZWJw==", //0.201 - "Port": "js2LutKe+rdjzdxMPQUrvQ==", - //"Database": "VJB2XC+lAtzuHObDGMVOAA==", //三菱 - //"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp - //"Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //MCUT - //"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome - //"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel - //"Database": "iuaY0h0+TWkir44/eZLDqw==", //tpe_dome_office - "Database": "+5RAiFLJVU+LRyDxF1K/pcLZaoZa4k/thZqF6xKoCag=", //dome_online_0821 - "Root": "SzdxEgaJJ7tcTCrUl2zKsA==", - "Password": "FVAPxztxpY4gJJKQ/se4bQ==" - }, - "MSSqlDBConfig": { - "Server": "bJm+UAtbeaTjDmp/A5ep2w==", //0.130 - "Port": "S5cUXKnKOacFtFy9+0dtpw==", - "Database": "VvfWH/59gQguY2eA2xBCug==", //taipei_dome - "Root": "4GCCJGAXzLa8ecdmPAkYKg==", - "Password": "0O24es2ZRF5uoJ4aU+YCdg==" + "DBConfig": { + "MySqlDBConfig": { + "Server": "CYGthbCeGtAXT4s1NOSJHQ==", //0.132 + "Port": "mkF51jVbg40V5K5eTh2Ckw==", + //"Database": "VJB2XC+lAtzuHObDGMVOAA==", //30 + //"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp + "Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome + //"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel + //"Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //mcut + //"Database": "XZ2fOBnta9kdVGEb7y92cg==", //ibms_mcut + "Root": "SzdxEgaJJ7tcTCrUl2zKsA==", + "Password": "FVAPxztxpY4gJJKQ/se4bQ==" + }, + "MSSqlDBConfig": { + "Server": "bJm+UAtbeaTjDmp/A5ep2w==", //0.130 + "Port": "S5cUXKnKOacFtFy9+0dtpw==", + "Database": "VvfWH/59gQguY2eA2xBCug==", //taipei_dome + "Root": "4GCCJGAXzLa8ecdmPAkYKg==", + "Password": "0O24es2ZRF5uoJ4aU+YCdg==" + } + //"MSSqlDBConfig": { + // "Server": "avZg8PA8C9GVgYZBgEKzCg==", + // "Port": "lJA0KPkG6RvFfTgWiXFyUw==", + // "Database": "VvfWH/59gQguY2eA2xBCug==", + // "Root": "sD8GZ9UPiIQGU6dU011/4A==", + // "Password": "2gi7rOmGha2VdXC5vtHxhg==" + //} + //"MSSqlDBConfig": { + // "Server": "ueFp+VFb200lhh1Uctc97WH0/tX6tfXYU2v1oxCWuuM=", + // "Port": "S5cUXKnKOacFtFy9+0dtpw==", + // "Database": "VvfWH/59gQguY2eA2xBCug==", + // "Root": "+plVKQ+enAqt7BYV2uMQng==", + // "Password": "0O24es2ZRF5uoJ4aU+YCdg==" + //} } - //"MSSqlDBConfig": { - // "Server": "avZg8PA8C9GVgYZBgEKzCg==", - // "Port": "lJA0KPkG6RvFfTgWiXFyUw==", - // "Database": "VvfWH/59gQguY2eA2xBCug==", - // "Root": "sD8GZ9UPiIQGU6dU011/4A==", - // "Password": "2gi7rOmGha2VdXC5vtHxhg==" - //} - //"MSSqlDBConfig": { - // "Server": "ueFp+VFb200lhh1Uctc97WH0/tX6tfXYU2v1oxCWuuM=", - // "Port": "S5cUXKnKOacFtFy9+0dtpw==", - // "Database": "VvfWH/59gQguY2eA2xBCug==", - // "Root": "+plVKQ+enAqt7BYV2uMQng==", - // "Password": "0O24es2ZRF5uoJ4aU+YCdg==" - //} + + } - - -} From 61d9b8f2c05f8fe62387782f5ca01aeb8d1ca991 Mon Sep 17 00:00:00 2001 From: "jay.chang" Date: Tue, 23 Jan 2024 18:21:53 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B0=B4=E9=9B=BB?= =?UTF-8?q?=E5=A0=B1=E8=A1=A8Api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/TenantBillController.cs | 32 +++++++++---------- FrontendWebApi/Models/Bill.cs | 12 +++---- FrontendWebApi/Startup.cs | 7 ++++ 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/FrontendWebApi/ApiControllers/TenantBillController.cs b/FrontendWebApi/ApiControllers/TenantBillController.cs index 6e17d1a..09da3a9 100644 --- a/FrontendWebApi/ApiControllers/TenantBillController.cs +++ b/FrontendWebApi/ApiControllers/TenantBillController.cs @@ -18,8 +18,8 @@ namespace FrontendWebApi.ApiControllers { //[Route("api/[controller]")] //[ApiController] - //public class TenantBillController - public class TenantBillController : MyBaseApiController + public class TenantBillController + //public class TenantBillController : MyBaseApiController { private readonly IBackendRepository backendRepository; @@ -41,7 +41,7 @@ namespace FrontendWebApi.ApiControllers List tenantList = new List(); try { - var sqlString = $"SELECT tenant_guid,tenant_id,tenant_name,bill_perKWH,bill_perRCV " + + var sqlString = $"SELECT tenant_guid,list_id,tenant_name,bill_perKWH,bill_perRCV " + $"from {TenantListtable} order by created_at"; tenantList = await backendRepository.GetAllAsync(sqlString); @@ -73,8 +73,8 @@ namespace FrontendWebApi.ApiControllers var bill_perRCV = tl.bill_perRCV; var created_at = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); - var sqlString = $"INSERT INTO {TenantListtable} (tenant_guid,tenant_id,tenant_name, bill_perKWH, bill_perRCV, created_by,created_at) " + - $"VALUES ('{tenant_guid}',{tl.tenant_id},'{tenant_name}', {bill_perKWH}, {bill_perRCV},'{tl.created_by}', '{created_at}')"; + var sqlString = $"INSERT INTO {TenantListtable} (tenant_guid,list_id,tenant_name, bill_perKWH, bill_perRCV, created_by,created_at) " + + $"VALUES ('{tenant_guid}',{tl.list_id},'{tenant_name}', {bill_perKWH}, {bill_perRCV},'{tl.created_by}', '{created_at}')"; await backendRepository.ExecuteSql(sqlString); @@ -103,7 +103,7 @@ namespace FrontendWebApi.ApiControllers $"`tenant_name` = '{tl.tenant_name}', " + $"`bill_perKWH` = {tl.bill_perKWH}, " + $"`bill_perRCV` = {tl.bill_perRCV}, " + - $"`updated_by` = {tl.updated_by}, " + + $"`updated_by` = '{tl.updated_by}', " + $"`updated_at` = '{updated_at}' " + $"WHERE `tenant_guid` = '{tl.tenant_guid}'"; @@ -165,26 +165,26 @@ namespace FrontendWebApi.ApiControllers if (building_tag == "ALL") { sqlString = - $"SELECT tenant_id,a.device_number,a.full_name,start_timestamp,end_timestamp,result,bill,tenant_name " + + $"SELECT bill_id,a.device_number,a.full_name,start_timestamp,end_timestamp,result,bill,tenant_name " + $"from {TenantBilltable} a join device b on a.device_number =b.device_number" + $"where a.device_name_tag = '{ElecOrWater}' "; } else if (building_tag == "D2") { sqlString = - $"SELECT tenant_id,a.device_number,a.full_name,start_timestamp,end_timestamp,result,bill,tenant_name " + + $"SELECT bill_id,a.device_number,a.full_name,start_timestamp,end_timestamp,result,bill,tenant_name " + $"from {TenantBilltable} a join device b on a.device_number =b.device_number " + $"where device_building_tag = 'D1' and a.device_name_tag = '{ElecOrWater}' || device_building_tag = 'D2' and a.device_name_tag = '{ElecOrWater}'"; } else { sqlString = - $"SELECT tenant_id,a.device_number,a.full_name,start_timestamp,end_timestamp,result,bill,tenant_name " + + $"SELECT bill_id,a.device_number,a.full_name,start_timestamp,end_timestamp,result,bill,tenant_name " + $"from {TenantBilltable} a join device b on a.device_number =b.device_number " + $"where device_building_tag = '{building_tag}' and a.device_name_tag = '{ElecOrWater}' "; } - + tenantBill = await backendRepository.GetAllAsync(sqlString); @@ -210,17 +210,17 @@ namespace FrontendWebApi.ApiControllers { string bill_per = tb.tableType == "elec" ? "bill_perKWH" : "bill_perRCV"; var updated_at = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); - var start_timestamp = tb.start_timestamp.ToString("yyyy-MM-dd HH:mm:ss"); - var end_timestamp = tb.end_timestamp.ToString("yyyy-MM-dd HH:mm:ss"); + var start_timestamp = tb.start_timestamp; + var end_timestamp = tb.end_timestamp; string sqlString = null; - string startMonth = tb.start_timestamp.Year.ToString() + tb.start_timestamp.Month.ToString("D2"); - string endMonth = tb.end_timestamp.Year.ToString() + tb.end_timestamp.Month.ToString("D2"); + string startMonth = tb.start_timestamp.Split("-")[0] + tb.start_timestamp.Split("-")[1]; + string endMonth = tb.end_timestamp.Split("-")[0] + tb.end_timestamp.Split("-")[1]; if (startMonth == endMonth) { sqlString = $"UPDATE {TenantBilltable} " + - $"set tenant_id = {tb.tenant_id} ,tenant_name = '{tb.tenant_name}', start_timestamp = '{start_timestamp}',end_timestamp = '{end_timestamp}' , " + + $"set bill_id = {tb.bill_id} ,tenant_name = '{tb.tenant_name}', start_timestamp = '{start_timestamp}',end_timestamp = '{end_timestamp}' , " + $"result= " + $"(select sum(sub_result) " + $"from archive_electric_water_meter_day_{startMonth} " + @@ -237,7 +237,7 @@ namespace FrontendWebApi.ApiControllers { sqlString = $"UPDATE {TenantBilltable} " + - $"set tenant_id = {tb.tenant_id} ,tenant_name = '{tb.tenant_name}', start_timestamp = '{start_timestamp}',end_timestamp = '{end_timestamp}' , " + + $"set bill_id = {tb.bill_id} ,tenant_name = '{tb.tenant_name}', start_timestamp = '{start_timestamp}',end_timestamp = '{end_timestamp}' , " + $"result= " + $"(SELECT sum(sub_result) " + $"FROM ( " + diff --git a/FrontendWebApi/Models/Bill.cs b/FrontendWebApi/Models/Bill.cs index 2b58ded..d933d4d 100644 --- a/FrontendWebApi/Models/Bill.cs +++ b/FrontendWebApi/Models/Bill.cs @@ -7,7 +7,7 @@ namespace FrontendWebApi.Models public class TenantList { public string tenant_guid { get; set; } - public int tenant_id { get; set; } + public int list_id { get; set; } public string tenant_name { get; set; } public decimal bill_perKWH { get; set; } public decimal bill_perRCV { get; set; } @@ -20,12 +20,12 @@ namespace FrontendWebApi.Models public class TenantBill { - public int tenant_id { get; set; } + public int bill_id { get; set; } public string tenant_name { get; set; } public string device_number { get; set; } public string full_name { get; set; } - public DateTime start_timestamp { get; set; } - public DateTime end_timestamp { get; set; } + public string start_timestamp { get; set; } + public string end_timestamp { get; set; } public string device_name_tag { get; set; } public decimal result { get; set; } public int bill { get; set; } @@ -42,8 +42,8 @@ namespace FrontendWebApi.Models public class OutputBill { public string tenant_name { get; set; } - public DateTime start_timestamp { get; set; } - public DateTime end_timestamp { get; set; } + public string start_timestamp { get; set; } + public string end_timestamp { get; set; } public decimal kwh_total { get; set; } public decimal bill_perKWH { get; set; } public int electric_total { get; set; } diff --git a/FrontendWebApi/Startup.cs b/FrontendWebApi/Startup.cs index 7ae8075..f2c656e 100644 --- a/FrontendWebApi/Startup.cs +++ b/FrontendWebApi/Startup.cs @@ -24,6 +24,8 @@ using System.IdentityModel.Tokens.Jwt; using System.Linq; using System.Text; using System.Threading.Tasks; +using WkHtmlToPdfDotNet.Contracts; +using WkHtmlToPdfDotNet; using static FrontendWebApi.Jwt.JwtHelpers; namespace FrontendWebApi @@ -81,6 +83,11 @@ namespace FrontendWebApi .AddConsole(); }); + #region htmlPDF `J + services.AddSingleton(typeof(IConverter), new SynchronizedConverter(new PdfTools())); + #endregion + + #region DBHelper `J services.Configure(Configuration.GetSection("DBConfig")); services.AddTransient(); From 2a894546288565f776d5fc69b98060191194d42c Mon Sep 17 00:00:00 2001 From: "jay.chang" Date: Fri, 26 Jan 2024 11:35:13 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=B5=90=E7=AE=97?= =?UTF-8?q?=E8=A1=A8SQL=E8=AA=9E=E6=B3=95=EF=BC=8C=E6=96=B0=E5=A2=9Epdf?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E8=B7=9F=E5=84=B2=E5=AD=98=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/TenantBillController.cs | 252 +++++++++++++++--- FrontendWebApi/Models/Bill.cs | 15 +- FrontendWebApi/StaticFiles/import.html | 104 ++++++++ FrontendWebApi/appsettings.Development.json | 50 ++-- .../upload/OutputFormTemplate/import.html | 104 ++++++++ 5 files changed, 462 insertions(+), 63 deletions(-) create mode 100644 FrontendWebApi/StaticFiles/import.html create mode 100644 FrontendWebApi/wwwroot/upload/OutputFormTemplate/import.html diff --git a/FrontendWebApi/ApiControllers/TenantBillController.cs b/FrontendWebApi/ApiControllers/TenantBillController.cs index 09da3a9..5e7b31f 100644 --- a/FrontendWebApi/ApiControllers/TenantBillController.cs +++ b/FrontendWebApi/ApiControllers/TenantBillController.cs @@ -10,6 +10,17 @@ using static FrontendWebApi.Models.Bill; using Microsoft.Extensions.Logging; using System.Text.Json; using Newtonsoft.Json.Linq; +using System.Security.Cryptography; +using WkHtmlToPdfDotNet.Contracts; +using WkHtmlToPdfDotNet; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.SignalR; +using Microsoft.Extensions.Configuration; +using Serilog.Core; +using static FrontendWebApi.ApiControllers.TenantBillController; +using System.Reflection; + + // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 @@ -22,15 +33,26 @@ namespace FrontendWebApi.ApiControllers //public class TenantBillController : MyBaseApiController { private readonly IBackendRepository backendRepository; + private readonly ILogger _logger; + private readonly IConfiguration Configuration; + private IWebHostEnvironment _webHostEnvironment; + private readonly IConverter _converter; const string TenantListtable = "archive_electric_meter_tenant_list"; const string TenantBilltable = "archive_electric_meter_tenant_bill"; - public TenantBillController(IBackendRepository backendRepository, IFrontendRepository frontendRepository) + public TenantBillController(IBackendRepository backendRepository, IFrontendRepository frontendRepository, ILogger logger, + IConfiguration configuration, + IWebHostEnvironment webHostEnvironment, + IConverter converter) { this.backendRepository = backendRepository; + this._logger = logger; + Configuration = configuration; + _webHostEnvironment = webHostEnvironment; + _converter = converter; } @@ -53,7 +75,7 @@ namespace FrontendWebApi.ApiControllers catch (Exception exception) { apiResult.Code = "9999"; - apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。" + exception.Message; //Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); } @@ -74,7 +96,7 @@ namespace FrontendWebApi.ApiControllers var created_at = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); var sqlString = $"INSERT INTO {TenantListtable} (tenant_guid,list_id,tenant_name, bill_perKWH, bill_perRCV, created_by,created_at) " + - $"VALUES ('{tenant_guid}',{tl.list_id},'{tenant_name}', {bill_perKWH}, {bill_perRCV},'{tl.created_by}', '{created_at}')"; + $"VALUES ('{tenant_guid}','{tl.list_id}','{tenant_name}', {bill_perKWH}, {bill_perRCV},'{tl.created_by}', '{created_at}')"; await backendRepository.ExecuteSql(sqlString); @@ -85,6 +107,10 @@ namespace FrontendWebApi.ApiControllers { apiResult.Code = "9999"; apiResult.Msg = "系統內部錯誤,請聯絡管理者。" + exception.Message; + if (exception.Message.Contains($" for key 'PRIMARY'")) + { + apiResult.Msg = "已有相同使用者。"; + } //Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); } @@ -103,7 +129,6 @@ namespace FrontendWebApi.ApiControllers $"`tenant_name` = '{tl.tenant_name}', " + $"`bill_perKWH` = {tl.bill_perKWH}, " + $"`bill_perRCV` = {tl.bill_perRCV}, " + - $"`updated_by` = '{tl.updated_by}', " + $"`updated_at` = '{updated_at}' " + $"WHERE `tenant_guid` = '{tl.tenant_guid}'"; @@ -115,7 +140,11 @@ namespace FrontendWebApi.ApiControllers catch (Exception exception) { apiResult.Code = "9999"; - apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。" + exception.Message; + if (exception.Message.Contains($"a foreign key constraint")) + { + apiResult.Msg = "水電報表仍有該用戶,無法修改名稱。"; + } //Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); } @@ -138,18 +167,17 @@ namespace FrontendWebApi.ApiControllers catch (Exception exception) { apiResult.Code = "9999"; - apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。" + exception.Message; + if (exception.Message.Contains($"a foreign key constraint")) + { + apiResult.Msg = "水電報表仍有該用戶,無法刪除。"; + } //Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); } return apiResult; } - public class MyJsonData - { - public string Name { get; set; } - public int Age { get; set; } - } [HttpPost] public async Task>> GetTenantBill([FromBody] TenantBill tb) @@ -165,21 +193,21 @@ namespace FrontendWebApi.ApiControllers if (building_tag == "ALL") { sqlString = - $"SELECT bill_id,a.device_number,a.full_name,start_timestamp,end_timestamp,result,bill,tenant_name " + + $"SELECT bill_id,a.device_number,a.full_name,start_timestamp,end_timestamp,result,bill,tenant_name,tenant_guid " + $"from {TenantBilltable} a join device b on a.device_number =b.device_number" + $"where a.device_name_tag = '{ElecOrWater}' "; } else if (building_tag == "D2") { sqlString = - $"SELECT bill_id,a.device_number,a.full_name,start_timestamp,end_timestamp,result,bill,tenant_name " + + $"SELECT bill_id,a.device_number,a.full_name,start_timestamp,end_timestamp,result,bill,tenant_name,tenant_guid " + $"from {TenantBilltable} a join device b on a.device_number =b.device_number " + $"where device_building_tag = 'D1' and a.device_name_tag = '{ElecOrWater}' || device_building_tag = 'D2' and a.device_name_tag = '{ElecOrWater}'"; } else { sqlString = - $"SELECT bill_id,a.device_number,a.full_name,start_timestamp,end_timestamp,result,bill,tenant_name " + + $"SELECT bill_id,a.device_number,a.full_name,start_timestamp,end_timestamp,result,bill,tenant_name,tenant_guid " + $"from {TenantBilltable} a join device b on a.device_number =b.device_number " + $"where device_building_tag = '{building_tag}' and a.device_name_tag = '{ElecOrWater}' "; } @@ -194,7 +222,7 @@ namespace FrontendWebApi.ApiControllers catch (Exception exception) { apiResult.Code = "9999"; - apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。" + exception.Message; //Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); } @@ -213,14 +241,25 @@ namespace FrontendWebApi.ApiControllers var start_timestamp = tb.start_timestamp; var end_timestamp = tb.end_timestamp; string sqlString = null; + string startMonth = ""; + string endMonth = ""; + if (start_timestamp != "" && end_timestamp != "") + { + startMonth = tb.start_timestamp.Split("-")[0] + tb.start_timestamp.Split("-")[1]; + endMonth = tb.end_timestamp.Split("-")[0] + tb.end_timestamp.Split("-")[1]; + } + else + { + apiResult.Code = "9999"; + apiResult.Msg = "請選擇日期。"; + return apiResult; + } - string startMonth = tb.start_timestamp.Split("-")[0] + tb.start_timestamp.Split("-")[1]; - string endMonth = tb.end_timestamp.Split("-")[0] + tb.end_timestamp.Split("-")[1]; if (startMonth == endMonth) { sqlString = $"UPDATE {TenantBilltable} " + - $"set bill_id = {tb.bill_id} ,tenant_name = '{tb.tenant_name}', start_timestamp = '{start_timestamp}',end_timestamp = '{end_timestamp}' , " + + $"set tenant_name = (SELECT tenant_name from archive_electric_meter_tenant_list WHERE tenant_guid = '{tb.tenant_guid}'), start_timestamp = '{start_timestamp}',end_timestamp = '{end_timestamp}' , " + $"result= " + $"(select sum(sub_result) " + $"from archive_electric_water_meter_day_{startMonth} " + @@ -228,7 +267,6 @@ namespace FrontendWebApi.ApiControllers $"GROUP BY device_number) , " + $"bill = " + $"ROUND(result *(SELECT {bill_per} from {TenantListtable} WHERE tenant_guid = '{tb.tenant_guid}') ), " + - $"updated_by = '{tb.updated_by}', " + $"updated_at = '{updated_at}', " + $"tenant_guid = '{tb.tenant_guid}' " + $"WHERE device_number = '{tb.device_number}'"; @@ -237,7 +275,7 @@ namespace FrontendWebApi.ApiControllers { sqlString = $"UPDATE {TenantBilltable} " + - $"set bill_id = {tb.bill_id} ,tenant_name = '{tb.tenant_name}', start_timestamp = '{start_timestamp}',end_timestamp = '{end_timestamp}' , " + + $"set tenant_name = (SELECT tenant_name from archive_electric_meter_tenant_list WHERE tenant_guid = '{tb.tenant_guid}'), start_timestamp = '{start_timestamp}',end_timestamp = '{end_timestamp}' , " + $"result= " + $"(SELECT sum(sub_result) " + $"FROM ( " + @@ -253,7 +291,6 @@ namespace FrontendWebApi.ApiControllers $"GROUP BY device_number) ," + $"bill = " + $"ROUND(result *(SELECT {bill_per} from {TenantListtable} WHERE tenant_guid = '{tb.tenant_guid}') ), " + - $"updated_by = '{tb.updated_by}', " + $"updated_at = '{updated_at}', " + $"tenant_guid = '{tb.tenant_guid}' " + $"WHERE device_number = '{tb.device_number}'"; @@ -270,40 +307,187 @@ namespace FrontendWebApi.ApiControllers catch (Exception exception) { apiResult.Code = "9999"; - apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。" + exception.Message; //Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); } return apiResult; } + [HttpPost] - public async Task>> OutputTenantBill() + public async Task OutputTenantBill() { - ApiResult> apiResult = new ApiResult>(); List outputBill = new List(); try { string sqlString = - $"SELECT distinct a.tenant_guid,b.tenant_name,start_timestamp,end_timestamp,bill_perKWH,bill_perRCV,sum(result) as name_result,sum(bill) as name_bill " + - $"from archive_electric_meter_tenant_bill a join archive_electric_meter_tenant_list b on a.tenant_guid = b.tenant_guid " + - $"WHERE a.tenant_guid = '37639e92-20ce-4064-956b-b6b0eaa7d7d2' " + - $"group by a.device_name_tag"; + $@"SELECT + a.tenant_name,a.start_timestamp,a.end_timestamp,bill_perKWH,bill_perRCV, + SUM(CASE WHEN device_name_tag = 'E4' THEN result ELSE 0 END) AS elec_result, + SUM(CASE WHEN device_name_tag = 'W1' THEN result ELSE 0 END) AS water_result, + SUM(CASE WHEN device_name_tag = 'E4' THEN bill ELSE 0 END) AS elec_bill, + SUM(CASE WHEN device_name_tag = 'W1' THEN bill ELSE 0 END) AS water_bill, + SUM(bill) AS total_bill + FROM archive_electric_meter_tenant_bill a + JOIN archive_electric_meter_tenant_list b on a.tenant_guid = b.tenant_guid + GROUP BY a.tenant_name + HAVING SUM(bill) != 0"; outputBill = await backendRepository.GetAllAsync(sqlString); + string filePath = CreateOutputForm(outputBill); - apiResult.Code = "0000"; - apiResult.Data = outputBill; + byte[] file = System.IO.File.ReadAllBytes(filePath); + + + return new FileContentResult(file, "application/pdf") + { + FileDownloadName = "水電報表.pdf" + }; } catch (Exception exception) + { + _logger.LogError(exception.ToString()); + } + return new FileContentResult(new byte[0], "application/pdf") { - apiResult.Code = "9999"; - apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; - //Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + FileDownloadName = "Empty.pdf" + }; + } + + public string CreateOutputForm(List outputBill) + { + try + { + string htmlStr = this.getOutputFormHtmlStr(outputBill); + + string filepath = Configuration.GetValue("FilePath:OutputForm"); + if (!Directory.Exists(filepath)) + { + Directory.CreateDirectory(filepath); + _logger.LogInformation("file CreateOutputForm path: " + filepath); + } + var nowString = DateTime.UtcNow.AddHours(8).ToString("yyyyMMdd_HHmmss"); + + //Random r1 = new System.Random(); + //string r2 = r1.Next(0, 999).ToString("0000"); + //string r2 = RandomNumberGenerator.GetInt32(0, 999).ToString("0000"); + + filepath += $"{nowString}_水電報表.pdf"; + + var doc = new HtmlToPdfDocument() + { + GlobalSettings = { + ColorMode = ColorMode.Color, + //Orientation = Orientation.Landscape, + PaperSize = PaperKind.A4, + Out = filepath, + Margins = new MarginSettings + { + Unit = Unit.Millimeters, + Top = 10, + Bottom = 10, + Right = 0, + Left = 0 + }, + }, + Objects = { + new ObjectSettings() { + HtmlContent=htmlStr, + WebSettings = { DefaultEncoding = "utf-8"}, + FooterSettings = new FooterSettings() { + Center = "第 [page] 頁 共 [topage] 頁", + FontName = "DFKai-sb", + }, + LoadSettings = new LoadSettings() { + JSDelay = 1000, + StopSlowScript = false, + BlockLocalFileAccess = false, + DebugJavascript = true + } + //HeaderSettings = { FontSize = 9, Right = "Page [page] of [toPage]", Line = true, Spacing = 2.812 } + } + } + }; + + // _converter.Warning += ConvertWarning; + + _converter.Convert(doc); + //IntPtr converter = _converter.CreateConverter(doc); + //_converter.Tools.DestroyConverter(); + return filepath; + } + catch (Exception ex) + { + throw new Exception(ex.ToString()); + } + } + + private string getOutputFormHtmlStr(List outputBill) + { + + try + { + string path = Configuration.GetValue("FilePath:OutputFormTemplate"); + //string path = _webHostEnvironment.ContentRootPath + "\\StaticFiles\\import.html"; + if (!File.Exists(path)) + { + return ""; + } + //string cssroot = _webHostEnvironment.ContentRootPath + "\\StaticFiles\\css\\"; + string htmlStr = System.IO.File.ReadAllText(path); + //string vendorscss = System.IO.File.ReadAllText(cssroot + "vendors.bundle.css"); + //string appBundelCss = System.IO.File.ReadAllText(cssroot + "app.bundle.css"); + //string skinmasterCss = System.IO.File.ReadAllText(cssroot + "skins\\skin-master.css"); + string bill = ""; + foreach (var item in outputBill) + { + bill += $"
" + + $"
" + + $" \"Taipei " + + $"

水電費用明細

" + + $"
" + + $"
" + + $"

費用資訊

" + + $"

用戶: {item.tenant_name}

" + + $"

起訖時間: {item.start_timestamp} ~ {item.end_timestamp}

" + + $" " + + $" " + + $" " + + $" " + + $" " + + $" " + + $" " + + $" " + + $" " + + $" " + + $" " + + $"
用電量: {item.elec_result}度單價: {item.bill_perKWH}元/度電費總計: {item.elec_bill}元
用水量: {item.water_result}度單價: {item.bill_perRCV}元/度水費總計: {item.water_bill}元
" + + $"
" + + $"
" + + $"
" + + $"

總計金額

" + + $"
" + + $" {item.total_bill}元 " + + $"
" + + $"
" + + $"
" + + $"
"; + + } + + + htmlStr = htmlStr.Replace("{{bill}}", bill); + + + return htmlStr; + } + catch (Exception ex) + { + throw new Exception(ex.ToString()); } - return apiResult; } } } \ No newline at end of file diff --git a/FrontendWebApi/Models/Bill.cs b/FrontendWebApi/Models/Bill.cs index d933d4d..298f933 100644 --- a/FrontendWebApi/Models/Bill.cs +++ b/FrontendWebApi/Models/Bill.cs @@ -7,7 +7,7 @@ namespace FrontendWebApi.Models public class TenantList { public string tenant_guid { get; set; } - public int list_id { get; set; } + public string list_id { get; set; } public string tenant_name { get; set; } public decimal bill_perKWH { get; set; } public decimal bill_perRCV { get; set; } @@ -42,15 +42,18 @@ namespace FrontendWebApi.Models public class OutputBill { public string tenant_name { get; set; } + public string device_name_tag { get; set; } public string start_timestamp { get; set; } public string end_timestamp { get; set; } - public decimal kwh_total { get; set; } + public decimal elec_result { get; set; } + public int elec_bill { get; set; } + public decimal water_result { get; set; } + public int water_bill { get; set; } public decimal bill_perKWH { get; set; } - public int electric_total { get; set; } - public decimal rcv_total { get; set; } public decimal bill_perRCV { get; set; } - public int water_total { get; set; } - public int all_total { get; set; } + public int total_bill { get; set; } + + } diff --git a/FrontendWebApi/StaticFiles/import.html b/FrontendWebApi/StaticFiles/import.html new file mode 100644 index 0000000..c8755e3 --- /dev/null +++ b/FrontendWebApi/StaticFiles/import.html @@ -0,0 +1,104 @@ + + + + + + + 費用明細 + + + + + {{bill}} + + + \ No newline at end of file diff --git a/FrontendWebApi/appsettings.Development.json b/FrontendWebApi/appsettings.Development.json index 0e905a9..fedd6f3 100644 --- a/FrontendWebApi/appsettings.Development.json +++ b/FrontendWebApi/appsettings.Development.json @@ -12,8 +12,12 @@ "SignKey": "TaipeiDome123456", //ñ��//�̤�16�r�� "JwtLifeSeconds": 3600 }, + "FilePath": { + "OutputForm": "D:\\jay.chang\\FrontendWebApi\\wwwroot\\upload\\OutputForm\\", //水電報表 檔案儲存位置 + "OutputFormTemplate": "D:\\jay.chang\\FrontendWebApi\\wwwroot\\upload\\OutputFormTemplate\\import.html" // 水電報表範本檔位置 + }, "DBConfig": { - "MySqlDBConfig": { + "MySqlDBConfig": { "Server": "CYGthbCeGtAXT4s1NOSJHQ==", //0.132 "Port": "mkF51jVbg40V5K5eTh2Ckw==", //"Database": "VJB2XC+lAtzuHObDGMVOAA==", //30 @@ -25,27 +29,27 @@ "Root": "SzdxEgaJJ7tcTCrUl2zKsA==", "Password": "FVAPxztxpY4gJJKQ/se4bQ==" } - //"MSSqlDBConfig": { - // "Server": "avZg8PA8C9GVgYZBgEKzCg==", - // "Port": "lJA0KPkG6RvFfTgWiXFyUw==", - // "Database": "VvfWH/59gQguY2eA2xBCug==", - // "Root": "sD8GZ9UPiIQGU6dU011/4A==", - // "Password": "2gi7rOmGha2VdXC5vtHxhg==" - //} + //"MSSqlDBConfig": { + // "Server": "avZg8PA8C9GVgYZBgEKzCg==", + // "Port": "lJA0KPkG6RvFfTgWiXFyUw==", + // "Database": "VvfWH/59gQguY2eA2xBCug==", + // "Root": "sD8GZ9UPiIQGU6dU011/4A==", + // "Password": "2gi7rOmGha2VdXC5vtHxhg==" + //} - //"MSSqlDBConfig": { //172.16.220.250 - // "Server": "zp3Nilx0PISEEC4caZWqCg==", - // "Port": "7puf4kd9qJ/q0fq2QASWeQ==", - // "Database": "VvfWH/59gQguY2eA2xBCug==", - // "Root": "sD8GZ9UPiIQGU6dU011/4A==", - // "Password": "Jue6jMFRi11meN6xbdKwDA==" - //} - //"MSSqlDBConfig": { - // "Server": "FPhyer7n0h/pw/yCMzKcPQ==", - // "Port": "7puf4kd9qJ/q0fq2QASWeQ==", - // "Database": "VvfWH/59gQguY2eA2xBCug==", - // "Root": "sD8GZ9UPiIQGU6dU011/4A==", - // "Password": "Jue6jMFRi11meN6xbdKwDA==" - //} - } + //"MSSqlDBConfig": { //172.16.220.250 + // "Server": "zp3Nilx0PISEEC4caZWqCg==", + // "Port": "7puf4kd9qJ/q0fq2QASWeQ==", + // "Database": "VvfWH/59gQguY2eA2xBCug==", + // "Root": "sD8GZ9UPiIQGU6dU011/4A==", + // "Password": "Jue6jMFRi11meN6xbdKwDA==" + //} + //"MSSqlDBConfig": { + // "Server": "FPhyer7n0h/pw/yCMzKcPQ==", + // "Port": "7puf4kd9qJ/q0fq2QASWeQ==", + // "Database": "VvfWH/59gQguY2eA2xBCug==", + // "Root": "sD8GZ9UPiIQGU6dU011/4A==", + // "Password": "Jue6jMFRi11meN6xbdKwDA==" + //} } +} diff --git a/FrontendWebApi/wwwroot/upload/OutputFormTemplate/import.html b/FrontendWebApi/wwwroot/upload/OutputFormTemplate/import.html new file mode 100644 index 0000000..fdb43b5 --- /dev/null +++ b/FrontendWebApi/wwwroot/upload/OutputFormTemplate/import.html @@ -0,0 +1,104 @@ + + + + + + + 費用明細 + + + + + {{bill}} + + + \ No newline at end of file From 34635571a95f3ddb333314196427a1be1849af2f Mon Sep 17 00:00:00 2001 From: "jay.chang" Date: Mon, 29 Jan 2024 18:24:35 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E6=9A=AB=E6=99=82=E9=97=9C=E9=96=89?= =?UTF-8?q?=E8=AA=87=E6=9C=88=E6=9F=A5=E8=A9=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/TenantBillController.cs | 64 ++++++++++--------- FrontendWebApi/appsettings.Development.json | 4 +- 2 files changed, 35 insertions(+), 33 deletions(-) diff --git a/FrontendWebApi/ApiControllers/TenantBillController.cs b/FrontendWebApi/ApiControllers/TenantBillController.cs index 5e7b31f..cc131b3 100644 --- a/FrontendWebApi/ApiControllers/TenantBillController.cs +++ b/FrontendWebApi/ApiControllers/TenantBillController.cs @@ -75,7 +75,7 @@ namespace FrontendWebApi.ApiControllers catch (Exception exception) { apiResult.Code = "9999"; - apiResult.Msg = "系統內部錯誤,請聯絡管理者。" + exception.Message; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; //Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); } @@ -106,7 +106,7 @@ namespace FrontendWebApi.ApiControllers catch (Exception exception) { apiResult.Code = "9999"; - apiResult.Msg = "系統內部錯誤,請聯絡管理者。" + exception.Message; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; if (exception.Message.Contains($" for key 'PRIMARY'")) { apiResult.Msg = "已有相同使用者。"; @@ -140,7 +140,7 @@ namespace FrontendWebApi.ApiControllers catch (Exception exception) { apiResult.Code = "9999"; - apiResult.Msg = "系統內部錯誤,請聯絡管理者。" + exception.Message; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; if (exception.Message.Contains($"a foreign key constraint")) { apiResult.Msg = "水電報表仍有該用戶,無法修改名稱。"; @@ -167,7 +167,7 @@ namespace FrontendWebApi.ApiControllers catch (Exception exception) { apiResult.Code = "9999"; - apiResult.Msg = "系統內部錯誤,請聯絡管理者。" + exception.Message; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; if (exception.Message.Contains($"a foreign key constraint")) { apiResult.Msg = "水電報表仍有該用戶,無法刪除。"; @@ -222,7 +222,7 @@ namespace FrontendWebApi.ApiControllers catch (Exception exception) { apiResult.Code = "9999"; - apiResult.Msg = "系統內部錯誤,請聯絡管理者。" + exception.Message; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; //Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); } @@ -273,27 +273,29 @@ namespace FrontendWebApi.ApiControllers } else { - sqlString = - $"UPDATE {TenantBilltable} " + - $"set tenant_name = (SELECT tenant_name from archive_electric_meter_tenant_list WHERE tenant_guid = '{tb.tenant_guid}'), start_timestamp = '{start_timestamp}',end_timestamp = '{end_timestamp}' , " + - $"result= " + - $"(SELECT sum(sub_result) " + - $"FROM ( " + - $" SELECT start_timestamp,device_number, sub_result " + - $" FROM archive_electric_water_meter_day_{startMonth} " + - $" WHERE device_number = '{tb.device_number}' " + - $" UNION ALL " + - $" SELECT start_timestamp,device_number, sub_result " + - $" FROM archive_electric_water_meter_day_{endMonth} " + - $" WHERE device_number = '{tb.device_number}' " + - $") combined_result " + - $"WHERE start_timestamp BETWEEN '{start_timestamp}' and '{end_timestamp}' " + - $"GROUP BY device_number) ," + - $"bill = " + - $"ROUND(result *(SELECT {bill_per} from {TenantListtable} WHERE tenant_guid = '{tb.tenant_guid}') ), " + - $"updated_at = '{updated_at}', " + - $"tenant_guid = '{tb.tenant_guid}' " + - $"WHERE device_number = '{tb.device_number}'"; + //sqlString = + // $"UPDATE {TenantBilltable} " + + // $"set tenant_name = (SELECT tenant_name from archive_electric_meter_tenant_list WHERE tenant_guid = '{tb.tenant_guid}'), start_timestamp = '{start_timestamp}',end_timestamp = '{end_timestamp}' , " + + // $"result= " + + // $"(SELECT sum(sub_result) " + + // $"FROM ( " + + // $" SELECT start_timestamp,device_number, sub_result " + + // $" FROM archive_electric_water_meter_day_{startMonth} " + + // $" WHERE device_number = '{tb.device_number}' " + + // $" UNION ALL " + + // $" SELECT start_timestamp,device_number, sub_result " + + // $" FROM archive_electric_water_meter_day_{endMonth} " + + // $" WHERE device_number = '{tb.device_number}' " + + // $") combined_result " + + // $"WHERE start_timestamp BETWEEN '{start_timestamp}' and '{end_timestamp}' " + + // $"GROUP BY device_number) ," + + // $"bill = " + + // $"ROUND(result *(SELECT {bill_per} from {TenantListtable} WHERE tenant_guid = '{tb.tenant_guid}') ), " + + // $"updated_at = '{updated_at}', " + + // $"tenant_guid = '{tb.tenant_guid}' " + + // $"WHERE device_number = '{tb.device_number}'"; + apiResult.Code = "9999"; + apiResult.Msg = "請選擇同一個月份"; } @@ -307,7 +309,7 @@ namespace FrontendWebApi.ApiControllers catch (Exception exception) { apiResult.Code = "9999"; - apiResult.Msg = "系統內部錯誤,請聯絡管理者。" + exception.Message; + apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; //Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); } @@ -347,8 +349,8 @@ namespace FrontendWebApi.ApiControllers }; } catch (Exception exception) - { - _logger.LogError(exception.ToString()); + { + //Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); } return new FileContentResult(new byte[0], "application/pdf") { @@ -431,7 +433,7 @@ namespace FrontendWebApi.ApiControllers { string path = Configuration.GetValue("FilePath:OutputFormTemplate"); //string path = _webHostEnvironment.ContentRootPath + "\\StaticFiles\\import.html"; - if (!File.Exists(path)) + if (!System.IO.File.Exists(path)) { return ""; } @@ -445,7 +447,7 @@ namespace FrontendWebApi.ApiControllers { bill += $"
" + $"
" + - $" \"Taipei " + + $" \"Taipei " + $"

水電費用明細

" + $"
" + $"
" + diff --git a/FrontendWebApi/appsettings.Development.json b/FrontendWebApi/appsettings.Development.json index fedd6f3..cf16b64 100644 --- a/FrontendWebApi/appsettings.Development.json +++ b/FrontendWebApi/appsettings.Development.json @@ -13,8 +13,8 @@ "JwtLifeSeconds": 3600 }, "FilePath": { - "OutputForm": "D:\\jay.chang\\FrontendWebApi\\wwwroot\\upload\\OutputForm\\", //水電報表 檔案儲存位置 - "OutputFormTemplate": "D:\\jay.chang\\FrontendWebApi\\wwwroot\\upload\\OutputFormTemplate\\import.html" // 水電報表範本檔位置 + "OutputForm": "C:\\jay.chang\\ibms\\FrontendWebApi\\wwwroot\\upload\\OutputForm\\", //水電報表 檔案儲存位置 + "OutputFormTemplate": "C:\\jay.chang\\ibms\\FrontendWebApi\\wwwroot\\upload\\OutputFormTemplate\\import.html" // 水電報表範本檔位置 }, "DBConfig": { "MySqlDBConfig": { From 3de2b9da17d49ae099b1a32aa91e5b0e9e5d9be3 Mon Sep 17 00:00:00 2001 From: "jay.chang" Date: Tue, 30 Jan 2024 11:13:46 +0800 Subject: [PATCH 6/6] =?UTF-8?q?appsetting=E6=96=B0=E5=A2=9E=E5=9C=96?= =?UTF-8?q?=E7=89=87=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/TenantBillController.cs | 22 ++++++++++--------- FrontendWebApi/appsettings.Development.json | 5 +++-- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/FrontendWebApi/ApiControllers/TenantBillController.cs b/FrontendWebApi/ApiControllers/TenantBillController.cs index cc131b3..e62d20c 100644 --- a/FrontendWebApi/ApiControllers/TenantBillController.cs +++ b/FrontendWebApi/ApiControllers/TenantBillController.cs @@ -29,8 +29,8 @@ namespace FrontendWebApi.ApiControllers { //[Route("api/[controller]")] //[ApiController] - public class TenantBillController - //public class TenantBillController : MyBaseApiController + //public class TenantBillController + public class TenantBillController : MyBaseApiController { private readonly IBackendRepository backendRepository; private readonly ILogger _logger; @@ -76,7 +76,7 @@ namespace FrontendWebApi.ApiControllers { apiResult.Code = "9999"; apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; - //Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); } return apiResult; @@ -111,7 +111,7 @@ namespace FrontendWebApi.ApiControllers { apiResult.Msg = "已有相同使用者。"; } - //Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); } return apiResult; @@ -145,7 +145,7 @@ namespace FrontendWebApi.ApiControllers { apiResult.Msg = "水電報表仍有該用戶,無法修改名稱。"; } - //Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); } return apiResult; @@ -172,7 +172,7 @@ namespace FrontendWebApi.ApiControllers { apiResult.Msg = "水電報表仍有該用戶,無法刪除。"; } - //Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); } return apiResult; @@ -223,7 +223,7 @@ namespace FrontendWebApi.ApiControllers { apiResult.Code = "9999"; apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; - //Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); } return apiResult; @@ -310,7 +310,7 @@ namespace FrontendWebApi.ApiControllers { apiResult.Code = "9999"; apiResult.Msg = "系統內部錯誤,請聯絡管理者。"; - //Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); } return apiResult; @@ -350,7 +350,7 @@ namespace FrontendWebApi.ApiControllers } catch (Exception exception) { - //Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); } return new FileContentResult(new byte[0], "application/pdf") { @@ -432,6 +432,8 @@ namespace FrontendWebApi.ApiControllers try { string path = Configuration.GetValue("FilePath:OutputFormTemplate"); + string image = Configuration.GetValue("FilePath:Image"); + //string path = _webHostEnvironment.ContentRootPath + "\\StaticFiles\\import.html"; if (!System.IO.File.Exists(path)) { @@ -447,7 +449,7 @@ namespace FrontendWebApi.ApiControllers { bill += $"
" + $"
" + - $" \"Taipei " + + $" \"Taipei " + $"

水電費用明細

" + $"
" + $"
" + diff --git a/FrontendWebApi/appsettings.Development.json b/FrontendWebApi/appsettings.Development.json index cf16b64..8f75e9e 100644 --- a/FrontendWebApi/appsettings.Development.json +++ b/FrontendWebApi/appsettings.Development.json @@ -13,8 +13,9 @@ "JwtLifeSeconds": 3600 }, "FilePath": { - "OutputForm": "C:\\jay.chang\\ibms\\FrontendWebApi\\wwwroot\\upload\\OutputForm\\", //水電報表 檔案儲存位置 - "OutputFormTemplate": "C:\\jay.chang\\ibms\\FrontendWebApi\\wwwroot\\upload\\OutputFormTemplate\\import.html" // 水電報表範本檔位置 + "OutputForm": "D:\\jay.chang\\dome\\FrontendWebApi\\wwwroot\\upload\\OutputForm\\", //水電報表 檔案儲存位置 + "OutputFormTemplate": "D:\\jay.chang\\dome\\FrontendWebApi\\wwwroot\\upload\\OutputFormTemplate\\import.html", // 水電報表範本檔位置 + "Image": "D:\\jay.chang\\dome\\FrontendWebApi\\wwwroot\\upload\\OutputFormTemplate\\dome.png" // 明細的圖片 }, "DBConfig": { "MySqlDBConfig": {