修改水電報表Api
This commit is contained in:
parent
5c8abc1f19
commit
61d9b8f2c0
@ -18,8 +18,8 @@ namespace FrontendWebApi.ApiControllers
|
||||
{
|
||||
//[Route("api/[controller]")]
|
||||
//[ApiController]
|
||||
//public class TenantBillController
|
||||
public class TenantBillController : MyBaseApiController<TenantBillController>
|
||||
public class TenantBillController
|
||||
//public class TenantBillController : MyBaseApiController<TenantBillController>
|
||||
{
|
||||
private readonly IBackendRepository backendRepository;
|
||||
|
||||
@ -41,7 +41,7 @@ namespace FrontendWebApi.ApiControllers
|
||||
List<TenantList> tenantList = new List<TenantList>();
|
||||
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<TenantList>(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<TenantBill>(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 ( " +
|
||||
|
@ -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; }
|
||||
|
@ -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 htmlÂàPDF ª`¤J
|
||||
services.AddSingleton(typeof(IConverter), new SynchronizedConverter(new PdfTools()));
|
||||
#endregion
|
||||
|
||||
|
||||
#region DBHelper ª`¤J
|
||||
services.Configure<DBConfig>(Configuration.GetSection("DBConfig"));
|
||||
services.AddTransient<Repository.Helper.IDatabaseHelper, Repository.Helper.DatabaseHelper>();
|
||||
|
Loading…
Reference in New Issue
Block a user