衝突合併
This commit is contained in:
commit
d206d8c38a
133
SolarPower/Controllers/ElectricitySoldRecordController.cs
Normal file
133
SolarPower/Controllers/ElectricitySoldRecordController.cs
Normal file
@ -0,0 +1,133 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SolarPower.Models;
|
||||
using SolarPower.Models.PowerStation;
|
||||
using SolarPower.Repository.Interface;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SolarPower.Controllers
|
||||
{
|
||||
public class ElectricitySoldRecordController : MyBaseController<ElectricitySoldRecordController>
|
||||
{
|
||||
private readonly IElectricitySoldRecordRepository electricitySoldRecordRepository;
|
||||
private readonly IPowerStationRepository powerStationRepository;
|
||||
|
||||
public ElectricitySoldRecordController(IElectricitySoldRecordRepository electricitySoldRecordRepository, IPowerStationRepository powerStationRepository) : base()
|
||||
{
|
||||
this.electricitySoldRecordRepository = electricitySoldRecordRepository;
|
||||
this.powerStationRepository = powerStationRepository;
|
||||
}
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
public async Task<ApiResult<string>> SaveSoldMoney(ElectricitySoldRecord post)
|
||||
{
|
||||
ApiResult<string> apiResult = new ApiResult<string>();
|
||||
|
||||
PowerStation powerStation = null;
|
||||
|
||||
try
|
||||
{
|
||||
powerStation = await powerStationRepository.GetOneAsync(post.PowerstationId);
|
||||
|
||||
if (post.Id == 0)
|
||||
{
|
||||
ElectricitySoldRecord record = new ElectricitySoldRecord()
|
||||
{
|
||||
EndAt = post.EndAt,
|
||||
CreatedBy = myUser.Id,
|
||||
Kwh = post.Kwh,
|
||||
Money = post.Money,
|
||||
PowerstationId = post.PowerstationId,
|
||||
StartAt = post.StartAt
|
||||
};
|
||||
List<string> properties = new List<string>()
|
||||
{
|
||||
"EndAt",
|
||||
"CreatedBy",
|
||||
"Kwh",
|
||||
"Money",
|
||||
"PowerstationId",
|
||||
"StartAt"
|
||||
};
|
||||
await electricitySoldRecordRepository.AddAsync(record, properties);
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "新增成功";
|
||||
}
|
||||
else
|
||||
{
|
||||
ElectricitySoldRecord record = new ElectricitySoldRecord()
|
||||
{
|
||||
Id = post.Id,
|
||||
EndAt = post.EndAt,
|
||||
UpdatedBy = myUser.Id,
|
||||
Kwh = post.Kwh,
|
||||
Money = post.Money,
|
||||
PowerstationId = post.PowerstationId,
|
||||
StartAt = post.StartAt
|
||||
};
|
||||
List<string> properties = new List<string>()
|
||||
{
|
||||
"Id",
|
||||
"EndAt",
|
||||
"UpdatedBy",
|
||||
"Kwh",
|
||||
"Money",
|
||||
"PowerstationId",
|
||||
"StartAt"
|
||||
};
|
||||
await electricitySoldRecordRepository.Update(record, properties);
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "儲存成功";
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
string json = System.Text.Json.JsonSerializer.Serialize(post);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + json);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
public async Task<ActionResult> RecordTable(ElectricitySoldRecordTablePost info)
|
||||
{
|
||||
List<ElectricitySoldRecordTable> electricitySoldRecordTable = new List<ElectricitySoldRecordTable>();
|
||||
ApiResult<List<ElectricitySoldRecordTable>> apiResult = new ApiResult<List<ElectricitySoldRecordTable>>();
|
||||
try
|
||||
{
|
||||
electricitySoldRecordTable = await electricitySoldRecordRepository.RecordTable(info);
|
||||
foreach (ElectricitySoldRecordTable a in electricitySoldRecordTable)
|
||||
{
|
||||
a.Function = @"
|
||||
<button type='button' class='btn btn-primary btn-pills waves-effect waves-themed edit-btn'>修改</button>
|
||||
<button type='button' class='btn btn-danger btn-pills waves-effect waves-themed del-btn'>刪除</button>";
|
||||
}
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = electricitySoldRecordTable;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
apiResult.Msg = exception.ToString();
|
||||
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "info=" + System.Text.Json.JsonSerializer.Serialize(info));
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
var result = Json(new
|
||||
{
|
||||
data = apiResult
|
||||
});
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -79,6 +79,17 @@ namespace SolarPower.Controllers
|
||||
{
|
||||
ApiResult<InvAndMoney> apiResult = new ApiResult<InvAndMoney>();
|
||||
InvAndMoney inverter = new InvAndMoney();
|
||||
bool Showmoney;
|
||||
if(post.Userid == 0)
|
||||
{
|
||||
Showmoney = myUser.Role.Auths.Contains("ShowMoney");
|
||||
}
|
||||
else
|
||||
{
|
||||
Showmoney = await powerStationRepository.CheckShowMoney(post.Userid);
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
var powerStation = await powerStationRepository.GetOneAsync(post.PowerStation);
|
||||
@ -93,7 +104,7 @@ namespace SolarPower.Controllers
|
||||
{
|
||||
inverter.Inv[i] = "inv_" + inverter.Inv[i].Substring(inverter.Inv[i].Length - 4, 4);
|
||||
}
|
||||
if (myUser.Role.Auths.Contains("ShowMoney"))
|
||||
if (Showmoney)
|
||||
{
|
||||
inverter.ShowMoney = 1;
|
||||
}else
|
||||
@ -183,7 +194,8 @@ namespace SolarPower.Controllers
|
||||
FormType = postObject.FormType,
|
||||
SearchType = postObject.SearchType,
|
||||
Time = postObject.Time,
|
||||
PowerStation = Convert.ToInt32(powerstationid.Value)
|
||||
PowerStation = Convert.ToInt32(powerstationid.Value),
|
||||
Userid = postObject.Userid
|
||||
};
|
||||
var Formbody = GetForm(select_Table);//取body
|
||||
var Formhead = GetTableHead(select_Table);//取head
|
||||
@ -633,7 +645,8 @@ namespace SolarPower.Controllers
|
||||
workbook.Write(ms);
|
||||
ms.Flush();
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
return File(ms, "application/vnd.ms-excel", name+"報表.xlsx");
|
||||
var Datename = postObject.Time.Replace("-", "");
|
||||
return File(ms, "application/vnd.ms-excel", "FIC太陽能監控平台" + "_" + name + "報表" + "_" + postObject.Userid + Datename + ".xlsx");
|
||||
}
|
||||
|
||||
public string Checknull(string a)
|
||||
@ -666,5 +679,514 @@ namespace SolarPower.Controllers
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
public string ExportExcelBackDownload(string post)
|
||||
{
|
||||
var postObject = JsonConvert.DeserializeObject<Excel>(post);
|
||||
var workbook = new XSSFWorkbook();
|
||||
#region excel設定
|
||||
IFont font12 = workbook.CreateFont();
|
||||
font12.FontName = "新細明體";
|
||||
font12.FontHeightInPoints = 12;
|
||||
ICellStyle style12 = workbook.CreateCellStyle();
|
||||
style12.SetFont(font12);
|
||||
style12.Alignment = HorizontalAlignment.Center;
|
||||
style12.VerticalAlignment = VerticalAlignment.Center;
|
||||
IFont font12Times = workbook.CreateFont();
|
||||
font12Times.FontName = "Times New Roman";
|
||||
font12Times.FontHeightInPoints = 12;
|
||||
IFont font18 = workbook.CreateFont();
|
||||
font18.FontName = "新細明體";
|
||||
font18.FontHeightInPoints = 18;
|
||||
font18.IsBold = true;
|
||||
ICellStyle styleTitle18 = workbook.CreateCellStyle();
|
||||
styleTitle18.SetFont(font18);
|
||||
styleTitle18.Alignment = HorizontalAlignment.Center;
|
||||
styleTitle18.VerticalAlignment = VerticalAlignment.Center;
|
||||
ICellStyle styleLeft12 = workbook.CreateCellStyle();
|
||||
styleLeft12.SetFont(font12);
|
||||
styleLeft12.Alignment = HorizontalAlignment.Left;
|
||||
styleLeft12.VerticalAlignment = VerticalAlignment.Center;
|
||||
ICellStyle styleLine12 = workbook.CreateCellStyle();
|
||||
styleLine12.SetFont(font12);
|
||||
styleLine12.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
|
||||
styleLine12.VerticalAlignment = VerticalAlignment.Center;
|
||||
styleLine12.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
styleLine12.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
styleLine12.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
styleLine12.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
ICellStyle stylein12 = workbook.CreateCellStyle();
|
||||
stylein12.SetFont(font12Times);
|
||||
stylein12.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Left;
|
||||
stylein12.VerticalAlignment = VerticalAlignment.Center;
|
||||
stylein12.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
stylein12.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
stylein12.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
stylein12.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
stylein12.WrapText = true;
|
||||
#endregion
|
||||
foreach (var powerstationid in postObject.PowerStation)
|
||||
{
|
||||
var sheet = workbook.CreateSheet(powerstationid.Name);
|
||||
Select_table select_Table = new Select_table
|
||||
{
|
||||
FormType = postObject.FormType,
|
||||
SearchType = postObject.SearchType,
|
||||
Time = postObject.Time,
|
||||
PowerStation = Convert.ToInt32(powerstationid.Value),
|
||||
Userid = postObject.Userid
|
||||
};
|
||||
var Formbody = GetForm(select_Table);//取body
|
||||
var Formhead = GetTableHead(select_Table);//取head
|
||||
int RowPosition = 0;
|
||||
|
||||
switch (postObject.FormType)
|
||||
{
|
||||
case 0: //日報表
|
||||
#region 顯示head //RowPosition = 0
|
||||
IRow row = sheet.CreateRow(RowPosition);
|
||||
ICell cell = row.CreateCell(0);
|
||||
int index = 0;
|
||||
cell.SetCellValue("Date");
|
||||
cell.CellStyle = styleLine12;
|
||||
sheet.SetColumnWidth(index, 4 * 160 * 8);
|
||||
index++;
|
||||
|
||||
foreach (var head in Formhead.Result.Data.Inv)
|
||||
{
|
||||
cell = row.CreateCell(index);
|
||||
cell.SetCellValue(head);
|
||||
cell.CellStyle = styleLine12;
|
||||
sheet.SetColumnWidth(index, 4 * 160 * 6);
|
||||
index++;
|
||||
}
|
||||
|
||||
List<string> lasthead = new List<string>()
|
||||
{
|
||||
"小時發電量(kWh)",
|
||||
"小時發電量百分比(%)",
|
||||
"小時平均日照度(W/㎡)",
|
||||
"小時平均模組溫度(°C)"
|
||||
};
|
||||
if (Formhead.Result.Data.ShowMoney == 1)
|
||||
{
|
||||
lasthead.Add("小時售電金額(NTD)");
|
||||
}
|
||||
|
||||
|
||||
|
||||
foreach (var head in lasthead)
|
||||
{
|
||||
cell = row.CreateCell(index);
|
||||
cell.SetCellValue(head);
|
||||
cell.CellStyle = styleLine12;
|
||||
sheet.SetColumnWidth(index, 4 * 160 * 12);
|
||||
index++;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 顯示body //RowPosition = 1
|
||||
RowPosition++;
|
||||
var thour = ""; var tpr = ""; var tkwh = ""; var kWhkwp = ""; var ntd = ""; var ntdone = "";
|
||||
foreach (dynamic body in Formbody.Result.Data)
|
||||
{
|
||||
index = 0;
|
||||
var dbody = body as IDictionary<string, object>;
|
||||
thour = Checknull(Math.Round(Convert.ToDouble(dbody["tothour"]), 2).ToString());
|
||||
tpr = Checknull(Math.Round(Convert.ToDouble(dbody["pr"]), 2).ToString());
|
||||
tkwh = Checknull(Math.Round(Convert.ToDouble(dbody["totKWH"]), 2).ToString());
|
||||
kWhkwp = Checknull(Math.Round(Convert.ToDouble(dbody["totKWHKWP"]), 2).ToString());
|
||||
ntd = Checknull(Math.Round(Convert.ToDouble(dbody["totmoney"]), 2).ToString());
|
||||
|
||||
double onemoney = Convert.ToDouble(ntd) / Convert.ToDouble(tkwh);
|
||||
if (double.IsNaN(onemoney))
|
||||
{
|
||||
onemoney = 0;
|
||||
}
|
||||
ntdone = Checknull(Math.Round(onemoney, 2).ToString());
|
||||
|
||||
row = sheet.CreateRow(RowPosition);
|
||||
cell = row.CreateCell(index);
|
||||
var b = dbody["report_date"].ToString();
|
||||
cell.SetCellValue(b);
|
||||
cell.CellStyle = styleLine12;
|
||||
index++;
|
||||
foreach (var head in Formhead.Result.Data.Inv)
|
||||
{
|
||||
cell = row.CreateCell(index);
|
||||
cell.SetCellValue(dbody[head] == null ? "0" : dbody[head].ToString());
|
||||
cell.CellStyle = styleLine12;
|
||||
index++;
|
||||
}
|
||||
List<string> bodynames = new List<string>(){
|
||||
"hourKWH",
|
||||
"hourKWHp",
|
||||
"irradiance",
|
||||
"temperature"
|
||||
};
|
||||
if (Formhead.Result.Data.ShowMoney == 1)
|
||||
{
|
||||
bodynames.Add("hourmoney");
|
||||
}
|
||||
foreach (var bodyname in bodynames)
|
||||
{
|
||||
cell = row.CreateCell(index);
|
||||
if (dbody[bodyname] == null)
|
||||
{
|
||||
cell.SetCellValue("0");
|
||||
}
|
||||
else
|
||||
{
|
||||
var c = dbody[bodyname].ToString();
|
||||
cell.SetCellValue(c);
|
||||
}
|
||||
cell.CellStyle = styleLine12;
|
||||
index++;
|
||||
}
|
||||
RowPosition++;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 顯示總量//RowPosition = body + 2
|
||||
RowPosition += 2;//空兩行
|
||||
index = 0;
|
||||
row = sheet.CreateRow(RowPosition);
|
||||
cell = row.CreateCell(index);
|
||||
cell.SetCellValue("日照小時:");
|
||||
cell.CellStyle = styleLine12;
|
||||
cell = row.CreateCell(1);
|
||||
cell.SetCellValue(thour);
|
||||
cell.CellStyle = styleLine12;
|
||||
RowPosition++;
|
||||
|
||||
index = 0;
|
||||
row = sheet.CreateRow(RowPosition);
|
||||
cell = row.CreateCell(index);
|
||||
cell.SetCellValue("kWH/kWP:");
|
||||
cell.CellStyle = styleLine12;
|
||||
cell = row.CreateCell(1);
|
||||
cell.SetCellValue(kWhkwp);
|
||||
cell.CellStyle = styleLine12;
|
||||
RowPosition++;
|
||||
|
||||
index = 0;
|
||||
row = sheet.CreateRow(RowPosition);
|
||||
cell = row.CreateCell(index);
|
||||
cell.SetCellValue("PR%:");
|
||||
cell.CellStyle = styleLine12;
|
||||
cell = row.CreateCell(1);
|
||||
cell.SetCellValue(tpr);
|
||||
cell.CellStyle = styleLine12;
|
||||
RowPosition++;
|
||||
|
||||
|
||||
index = 0;
|
||||
row = sheet.CreateRow(RowPosition);
|
||||
cell = row.CreateCell(index);
|
||||
cell.SetCellValue("日發電量(kWh):");
|
||||
cell.CellStyle = styleLine12;
|
||||
cell = row.CreateCell(1);
|
||||
cell.SetCellValue(tkwh);
|
||||
cell.CellStyle = styleLine12;
|
||||
RowPosition++;
|
||||
|
||||
|
||||
if (Formhead.Result.Data.ShowMoney == 1)
|
||||
{
|
||||
index = 0;
|
||||
row = sheet.CreateRow(RowPosition);
|
||||
cell = row.CreateCell(index);
|
||||
cell.SetCellValue("日售電金額(NTD):");
|
||||
cell.CellStyle = styleLine12;
|
||||
cell = row.CreateCell(1);
|
||||
cell.SetCellValue(ntd);
|
||||
cell.CellStyle = styleLine12;
|
||||
RowPosition++;
|
||||
|
||||
index = 0;
|
||||
row = sheet.CreateRow(RowPosition);
|
||||
cell = row.CreateCell(index);
|
||||
cell.SetCellValue("日售電單價(NTD):");
|
||||
cell.CellStyle = styleLine12;
|
||||
cell = row.CreateCell(1);
|
||||
cell.SetCellValue(ntdone);
|
||||
cell.CellStyle = styleLine12;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
break;
|
||||
case 1: // 月報表
|
||||
#region 顯示head //RowPosition = 0
|
||||
IRow row2 = sheet.CreateRow(RowPosition);
|
||||
ICell cell2 = row2.CreateCell(0);
|
||||
int index2 = 0;
|
||||
cell2.SetCellValue("Date");
|
||||
cell2.CellStyle = styleLine12;
|
||||
sheet.SetColumnWidth(index2, 4 * 160 * 8);
|
||||
index2++;
|
||||
|
||||
foreach (var head in Formhead.Result.Data.Inv)
|
||||
{
|
||||
cell2 = row2.CreateCell(index2);
|
||||
cell2.SetCellValue(head);
|
||||
cell2.CellStyle = styleLine12;
|
||||
sheet.SetColumnWidth(index2, 4 * 160 * 8);
|
||||
index2++;
|
||||
}
|
||||
|
||||
List<string> lasthead2 = new List<string>()
|
||||
{
|
||||
"日發電量(kWh)",
|
||||
"日發電量百分比(%)",
|
||||
"日照小時(hr)",
|
||||
"kWH/kWP",
|
||||
"PR%",
|
||||
"日平均日照度(W/㎡)",
|
||||
"日平均模組溫度(°C)"
|
||||
|
||||
};
|
||||
if (Formhead.Result.Data.ShowMoney == 1)
|
||||
{
|
||||
lasthead2.Add("日售電金額(NTD)");
|
||||
}
|
||||
foreach (var head in lasthead2)
|
||||
{
|
||||
cell2 = row2.CreateCell(index2);
|
||||
cell2.SetCellValue(head);
|
||||
cell2.CellStyle = styleLine12;
|
||||
sheet.SetColumnWidth(index2, 4 * 160 * 12);
|
||||
index2++;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 顯示body //RowPosition = 1
|
||||
RowPosition++;
|
||||
var avghour = "0"; var avgKWHKWP = "0"; var avgdayKWH = "0"; var monthKWH = "0"; var monthmoney = "0"; var monthmoneyone = "0";
|
||||
var check_hire = false;
|
||||
var sitedb = "";
|
||||
foreach (dynamic body in Formbody.Result.Data)
|
||||
{
|
||||
index2 = 0;
|
||||
var dbody = body as IDictionary<string, object>;
|
||||
|
||||
avghour = (Convert.ToDouble(dbody["tothour"].ToString()) + Convert.ToDouble(avghour)).ToString();
|
||||
avgKWHKWP = (Convert.ToDouble(dbody["KWHKWP"].ToString()) + Convert.ToDouble(avgKWHKWP)).ToString();
|
||||
avgdayKWH = (Convert.ToDouble(dbody["dayKWH"].ToString()) + Convert.ToDouble(avgdayKWH)).ToString();
|
||||
monthKWH = dbody["monthKWH"] == null ? "0" : dbody["monthKWH"].ToString();
|
||||
monthmoney = dbody["monthmoney"] == null ? "0" : dbody["monthmoney"].ToString();
|
||||
monthmoneyone = (Convert.ToDouble(dbody["monthmoneyone"].ToString()) + Convert.ToDouble(monthmoneyone)).ToString();
|
||||
if (dbody["SolarType"].ToString() == "1" && Formhead.Result.Data.ShowMoney == 1)//檢驗是否為租用
|
||||
{
|
||||
check_hire = true;
|
||||
sitedb = dbody["SiteDB"].ToString();
|
||||
}
|
||||
|
||||
row2 = sheet.CreateRow(RowPosition);
|
||||
cell2 = row2.CreateCell(index2);
|
||||
var b = dbody["report_date"].ToString();
|
||||
cell2.SetCellValue(b);
|
||||
cell2.CellStyle = styleLine12;
|
||||
index2++;
|
||||
foreach (var head in Formhead.Result.Data.Inv)
|
||||
{
|
||||
cell2 = row2.CreateCell(index2);
|
||||
cell2.SetCellValue(dbody[head] == null ? "0" : dbody[head].ToString());
|
||||
cell2.CellStyle = styleLine12;
|
||||
index2++;
|
||||
}
|
||||
List<string> bodynames = new List<string>(){
|
||||
"dayKWH",
|
||||
"dayKWHp",
|
||||
"tothour",
|
||||
"KWHKWP",
|
||||
"PR",
|
||||
"irradiance",
|
||||
"temperature"
|
||||
};
|
||||
if (Formhead.Result.Data.ShowMoney == 1)
|
||||
{
|
||||
bodynames.Add("soldmoney");
|
||||
}
|
||||
foreach (var bodyname in bodynames)
|
||||
{
|
||||
cell2 = row2.CreateCell(index2);
|
||||
if (dbody[bodyname] == null)
|
||||
{
|
||||
cell2.SetCellValue("0");
|
||||
}
|
||||
else
|
||||
{
|
||||
var c = dbody[bodyname].ToString();
|
||||
cell2.SetCellValue(c);
|
||||
}
|
||||
cell2.CellStyle = styleLine12;
|
||||
index2++;
|
||||
}
|
||||
RowPosition++;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 顯示總量//RowPosition = body + 2
|
||||
RowPosition += 2;//空兩行
|
||||
index = 0;
|
||||
var Useday = Formbody.Result.Data.Count;
|
||||
row = sheet.CreateRow(RowPosition);
|
||||
|
||||
cell = row.CreateCell(index);
|
||||
cell.SetCellValue("日日照小時平均");
|
||||
cell.CellStyle = styleLine12;
|
||||
index++;
|
||||
cell = row.CreateCell(index);
|
||||
cell.SetCellValue("日kWH/kWP平均");
|
||||
cell.CellStyle = styleLine12;
|
||||
index++;
|
||||
cell = row.CreateCell(index);
|
||||
cell.SetCellValue("日發電量平均(kWh)");
|
||||
cell.CellStyle = styleLine12;
|
||||
index++;
|
||||
cell = row.CreateCell(index);
|
||||
cell.SetCellValue("月發電量(kWh)");
|
||||
cell.CellStyle = styleLine12;
|
||||
index++;
|
||||
if (Formhead.Result.Data.ShowMoney == 1)
|
||||
{
|
||||
cell = row.CreateCell(index);
|
||||
cell.SetCellValue("月售電金額(NTD)");
|
||||
cell.CellStyle = styleLine12;
|
||||
index++;
|
||||
cell = row.CreateCell(index);
|
||||
cell.SetCellValue("月售電單價(NTD)");
|
||||
cell.CellStyle = styleLine12;
|
||||
index++;
|
||||
}
|
||||
cell = row.CreateCell(index);
|
||||
cell.SetCellValue("月售電天數");
|
||||
cell.CellStyle = styleLine12;
|
||||
|
||||
|
||||
|
||||
index = 0;
|
||||
RowPosition++;
|
||||
row = sheet.CreateRow(RowPosition);
|
||||
|
||||
cell = row.CreateCell(index);
|
||||
cell.SetCellValue(Math.Round(Convert.ToDouble(avghour) / Useday, 2));
|
||||
cell.CellStyle = styleLine12;
|
||||
index++;
|
||||
cell = row.CreateCell(index);
|
||||
cell.SetCellValue(Math.Round(Convert.ToDouble(avgKWHKWP) / Useday, 2));
|
||||
cell.CellStyle = styleLine12;
|
||||
index++;
|
||||
cell = row.CreateCell(index);
|
||||
cell.SetCellValue(Math.Round(Convert.ToDouble(avgdayKWH) / Useday, 2));
|
||||
cell.CellStyle = styleLine12;
|
||||
index++;
|
||||
cell = row.CreateCell(index);
|
||||
cell.SetCellValue(monthKWH);
|
||||
cell.CellStyle = styleLine12;
|
||||
index++;
|
||||
if (Formhead.Result.Data.ShowMoney == 1)
|
||||
{
|
||||
cell = row.CreateCell(index);
|
||||
cell.SetCellValue(monthmoney);
|
||||
cell.CellStyle = styleLine12;
|
||||
index++;
|
||||
cell = row.CreateCell(index);
|
||||
cell.SetCellValue(Math.Round(Convert.ToDouble(monthmoneyone) / Useday, 2));
|
||||
cell.CellStyle = styleLine12;
|
||||
index++;
|
||||
}
|
||||
cell = row.CreateCell(index);
|
||||
cell.SetCellValue(Useday);
|
||||
cell.CellStyle = styleLine12;
|
||||
#endregion
|
||||
|
||||
#region 顯示租用//RowPosition = 總量 + 2
|
||||
if (check_hire == true)
|
||||
{
|
||||
RowPosition += 2;//空兩行
|
||||
PsIdAndSiteDB set = new PsIdAndSiteDB()
|
||||
{
|
||||
PowerstationId = Convert.ToInt32(powerstationid.Value),
|
||||
SiteDB = sitedb
|
||||
};
|
||||
var info = GetHireInfo(set);
|
||||
index = 0;
|
||||
row = sheet.CreateRow(RowPosition);
|
||||
|
||||
cell = row.CreateCell(index);
|
||||
cell.SetCellValue("出租人");
|
||||
cell.CellStyle = styleLine12;
|
||||
index++;
|
||||
cell = row.CreateCell(index);
|
||||
cell.SetCellValue("租金比例");
|
||||
cell.CellStyle = styleLine12;
|
||||
index++;
|
||||
cell = row.CreateCell(index);
|
||||
cell.SetCellValue("租金金額(未稅)");
|
||||
cell.CellStyle = styleLine12;
|
||||
index++;
|
||||
cell = row.CreateCell(index);
|
||||
cell.SetCellValue("租金金額(含稅)");
|
||||
cell.CellStyle = styleLine12;
|
||||
|
||||
foreach (var a in info.Result.Data)
|
||||
{
|
||||
RowPosition++;
|
||||
index = 0;
|
||||
row = sheet.CreateRow(RowPosition);
|
||||
|
||||
cell = row.CreateCell(index);
|
||||
cell.SetCellValue(a.Landowner);
|
||||
cell.CellStyle = styleLine12;
|
||||
index++;
|
||||
cell = row.CreateCell(index);
|
||||
cell.SetCellValue(a.LeaseRate + "%");
|
||||
cell.CellStyle = styleLine12;
|
||||
index++;
|
||||
cell = row.CreateCell(index);
|
||||
cell.SetCellValue(Math.Round(Convert.ToDouble(monthmoney) * Convert.ToDouble(a.LeaseRate) / 100, 2).ToString());
|
||||
cell.CellStyle = styleLine12;
|
||||
index++;
|
||||
cell = row.CreateCell(index);
|
||||
cell.SetCellValue(Math.Round(Convert.ToDouble(monthmoney) * Convert.ToDouble(a.LeaseRate) / 100 * 1.05, 2).ToString());
|
||||
cell.CellStyle = styleLine12;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
var name = "";
|
||||
if (postObject.FormType == 0)
|
||||
{
|
||||
name = "日";
|
||||
}
|
||||
else
|
||||
{
|
||||
name = "月";
|
||||
}
|
||||
var Datename = postObject.Time.Replace("-", "");
|
||||
|
||||
if (!Directory.Exists(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "upload", "report")))
|
||||
{
|
||||
Directory.CreateDirectory(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "upload", "report"));
|
||||
}
|
||||
|
||||
|
||||
if (!Directory.Exists(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "upload", "report", Datename)))
|
||||
{
|
||||
Directory.CreateDirectory(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "upload", "report", Datename));
|
||||
}
|
||||
var n = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "upload", "report", "FIC太陽能監控平台" + "_" + name + "報表" + "_" + postObject.Userid + Datename + ".xlsx");
|
||||
FileStream FS = new FileStream(n, FileMode.Create, FileAccess.Write);
|
||||
workbook.Write(FS);
|
||||
FS.Close();
|
||||
return Path.Combine("\\" + "upload" ,"report", Datename, "FIC太陽能監控平台" + "_" + name + "報表" + "_" + postObject.Userid+ Datename + ".xlsx");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -2089,7 +2089,24 @@ ALTER TABLE `power_station_operation_personnel`
|
||||
ADD COLUMN `EmailComplexReport` TINYINT(1) NOT NULL DEFAULT '1' COMMENT '接收Email綜合報告 0:不接收 1:接收' AFTER `EmailMonthReport`,
|
||||
ADD COLUMN `EmailException` TINYINT(1) NOT NULL DEFAULT '1' COMMENT '接收Email異常通知 0:不接收 1:接收' AFTER `EmailComplexReport`;
|
||||
|
||||
|
||||
-- 新增售電紀錄資料表 20210802
|
||||
CREATE TABLE `electricity_sold_record` (
|
||||
`Id` INT(10) NOT NULL AUTO_INCREMENT COMMENT '流水號',
|
||||
`PowerstationId` INT(4) NULL COMMENT '電站編號',
|
||||
`StartAt` TIMESTAMP NULL COMMENT '開始時間',
|
||||
`EndAt` TIMESTAMP NULL COMMENT '結束時間',
|
||||
`Kwh` INT(50) UNSIGNED NULL DEFAULT '0' COMMENT '售電度數',
|
||||
`Money` DOUBLE UNSIGNED NULL DEFAULT '0' COMMENT '售電金額',
|
||||
`CreatedBy` INT(10) NULL COMMENT '建立者',
|
||||
`CreatedAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP() COMMENT '建立時間',
|
||||
`UpdatedBy` INT(10) NULL COMMENT '修改者',
|
||||
`UpdatedAt` DATETIME NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP() COMMENT '修改時間',
|
||||
PRIMARY KEY (`Id`),
|
||||
INDEX `IDX_01` (`PowerstationId`, `StartAt`, `EndAt`)
|
||||
)
|
||||
COMMENT='台電售電紀錄'
|
||||
COLLATE='utf8mb4_unicode_ci'
|
||||
;
|
||||
|
||||
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */;
|
||||
|
||||
39
SolarPower/Models/ElectricitySoldRecord.cs
Normal file
39
SolarPower/Models/ElectricitySoldRecord.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SolarPower.Models
|
||||
{
|
||||
public class ElectricitySoldRecord:UserInfo
|
||||
{
|
||||
public int PowerstationId { get; set; }//電站編號
|
||||
private string startAt;
|
||||
public string StartAt { get { return Convert.ToDateTime(startAt).ToString("yyyy-MM-dd"); } set { startAt = value; } } //開始時間
|
||||
private string endAt;
|
||||
public string EndAt { get { return Convert.ToDateTime(endAt).ToString("yyyy-MM-dd"); } set { endAt = value; } } //結束時間
|
||||
public int Kwh { get; set; }//購電度數
|
||||
public float Money { get; set; }//售出金額
|
||||
}
|
||||
|
||||
public class ElectricitySoldRecordTable : ElectricitySoldRecord
|
||||
{
|
||||
public string PowerStationName { get; set; }
|
||||
public string Function { get; set; }
|
||||
public string CreatedDay { get; set; }
|
||||
}
|
||||
|
||||
public class Powerstationid
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Value { get; set; }
|
||||
}
|
||||
public class ElectricitySoldRecordTablePost
|
||||
{
|
||||
public List<Powerstationid> StationId { get; set; }
|
||||
public string Time { get; set; }
|
||||
public int SearchType { get; set; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -17,4 +17,14 @@ namespace SolarPower.Models
|
||||
public byte IsDelivery { get; set; }
|
||||
public string DeliveryAt { get; set; }
|
||||
}
|
||||
|
||||
public class OperationPersonnel
|
||||
{
|
||||
public int PowerStationId { get; set; }
|
||||
public int EmailDayReport { get; set; }
|
||||
public int EmailMonthReport { get; set; }
|
||||
public int EmailComplexReport { get; set; }
|
||||
public int EmailException { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,6 +30,7 @@ namespace SolarPower.Models
|
||||
public string Time { get; set; }
|
||||
public int PowerStation { get; set; }
|
||||
public int FormType { get; set; }
|
||||
public int Userid { get; set; }
|
||||
}
|
||||
public class Excel
|
||||
{
|
||||
@ -37,6 +38,7 @@ namespace SolarPower.Models
|
||||
public string Time { get; set; }
|
||||
public int FormType { get; set; }
|
||||
public List<Excelpowerstation> PowerStation { get; set; }
|
||||
public int Userid { get; set; }
|
||||
}
|
||||
public class Excelpowerstation
|
||||
{
|
||||
@ -68,4 +70,6 @@ namespace SolarPower.Models
|
||||
public string LeaseRate { get; set; }
|
||||
public string Landowner { get; set; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Quartz;
|
||||
using SolarPower.Models;
|
||||
using SolarPower.Models.PowerStation;
|
||||
using SolarPower.Repository.Interface;
|
||||
using System;
|
||||
@ -16,17 +17,108 @@ namespace SolarPower.Quartz.Jobs
|
||||
{
|
||||
private readonly ILogger<CalcAvgPowerStationJob> logger;
|
||||
private readonly IPowerStationRepository powerStationRepository;
|
||||
private readonly IUserRepository userRepository;
|
||||
private readonly INoticeScheduleRepository noticeScheduleRepository;
|
||||
private readonly IStationReportRepository stationReportRepository;
|
||||
|
||||
public CalcAvgPowerStationJob(ILogger<CalcAvgPowerStationJob> logger, IPowerStationRepository powerStationRepository)
|
||||
public CalcAvgPowerStationJob(ILogger<CalcAvgPowerStationJob> logger, IPowerStationRepository powerStationRepository,IUserRepository userRepository, INoticeScheduleRepository noticeScheduleRepository,IStationReportRepository stationReportRepository)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.powerStationRepository = powerStationRepository;
|
||||
this.userRepository = userRepository;
|
||||
this.noticeScheduleRepository = noticeScheduleRepository;
|
||||
this.stationReportRepository = stationReportRepository;
|
||||
}
|
||||
|
||||
public async Task Execute(IJobExecutionContext context)
|
||||
{
|
||||
try
|
||||
{
|
||||
#region 寄送日月報
|
||||
var users = userRepository.GetAllAsync();
|
||||
|
||||
foreach (var user in users.Result)
|
||||
{
|
||||
List<OperationPersonnel> powerstations = new List<OperationPersonnel>();
|
||||
powerstations = await noticeScheduleRepository.GetPowerStationOperationPersonnel(user.Id);
|
||||
if(powerstations.Count == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
List<Excelpowerstation> sentdaypowerstations = powerstations.Where(x => x.EmailDayReport == 1).Select(a => new Excelpowerstation {Name = a.Name,Value = a.PowerStationId.ToString()}).ToList();
|
||||
Controllers.StationReportController stationReportController = new Controllers.StationReportController(powerStationRepository, stationReportRepository);
|
||||
if (sentdaypowerstations.Count != 0)
|
||||
{
|
||||
Excel dayexcel = new Excel()
|
||||
{
|
||||
FormType = 0,
|
||||
PowerStation = sentdaypowerstations,
|
||||
SearchType = 0,
|
||||
Time = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"),
|
||||
Userid = user.Id
|
||||
};
|
||||
|
||||
var stationReportName = stationReportController.ExportExcelBackDownload(JsonConvert.SerializeObject(dayexcel, Formatting.Indented));
|
||||
NoticeSchedule DaySchedule = new NoticeSchedule()
|
||||
{
|
||||
RecipientEmail = user.Email,
|
||||
Subject = "日報表",
|
||||
Attachment = stationReportName,
|
||||
RecipientName = user.Name,
|
||||
Type = 1
|
||||
};
|
||||
List<string> properties = new List<string>()
|
||||
{
|
||||
"RecipientEmail",
|
||||
"Subject",
|
||||
"Attachment",
|
||||
"RecipientName",
|
||||
"Type"
|
||||
};
|
||||
await noticeScheduleRepository.AddOneAsync(DaySchedule, properties);
|
||||
}
|
||||
if(DateTime.Now.ToString("dd")=="01")
|
||||
{
|
||||
List<Excelpowerstation> sentmonthpowerstations = powerstations.Where(x => x.EmailMonthReport == 1).Select(a => new Excelpowerstation { Name = a.Name, Value = a.PowerStationId.ToString() }).ToList();
|
||||
if(sentmonthpowerstations.Count == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
Excel monthexcel = new Excel()
|
||||
{
|
||||
FormType = 1,
|
||||
PowerStation = sentmonthpowerstations,
|
||||
SearchType = 2,
|
||||
Time = DateTime.Now.AddDays(-1).ToString("yyyy-MM"),
|
||||
Userid = user.Id
|
||||
};
|
||||
var stationReportmonthName = stationReportController.ExportExcelBackDownload(JsonConvert.SerializeObject(monthexcel, Formatting.Indented));
|
||||
NoticeSchedule MonthSchedule = new NoticeSchedule()
|
||||
{
|
||||
RecipientEmail = user.Email,
|
||||
Subject = "月報表",
|
||||
Attachment = stationReportmonthName,
|
||||
RecipientName = user.Name,
|
||||
Type = 1
|
||||
};
|
||||
List<string> properties2 = new List<string>()
|
||||
{
|
||||
"RecipientEmail",
|
||||
"Subject",
|
||||
"Attachment",
|
||||
"RecipientName",
|
||||
"Type"
|
||||
};
|
||||
await noticeScheduleRepository.AddOneAsync(MonthSchedule, properties2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region step1. 找出所有電站
|
||||
logger.LogInformation("【CalcAvgPowerStationJob】【開始取得電站資料】");
|
||||
var powerStations = await powerStationRepository.GetAllAsync();
|
||||
@ -628,6 +720,10 @@ namespace SolarPower.Quartz.Jobs
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
||||
@ -0,0 +1,41 @@
|
||||
using SolarPower.Helper;
|
||||
using SolarPower.Models;
|
||||
using SolarPower.Repository.Interface;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SolarPower.Repository.Implement
|
||||
{
|
||||
public class ElectricitySoldRecordRepository: RepositoryBase<ElectricitySoldRecord>, IElectricitySoldRecordRepository
|
||||
{
|
||||
public ElectricitySoldRecordRepository(IDatabaseHelper databaseHelper) : base(databaseHelper)
|
||||
{
|
||||
tableName = "electricity_sold_record";
|
||||
}
|
||||
public async Task<List<ElectricitySoldRecordTable>> RecordTable (ElectricitySoldRecordTablePost post)
|
||||
{
|
||||
List<ElectricitySoldRecordTable> a = new List<ElectricitySoldRecordTable>();
|
||||
string sql = "";
|
||||
switch (post.SearchType)
|
||||
{
|
||||
//case 0:
|
||||
// post.Time.Replace("-","~").Replace("")
|
||||
// sql = "";
|
||||
// break;
|
||||
//case 1:
|
||||
// sql = "";
|
||||
// break;
|
||||
//case 2:
|
||||
// sql = "";
|
||||
// break;
|
||||
//case 3:
|
||||
// sql = "";
|
||||
// break;
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -64,5 +64,35 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<OperationPersonnel>> GetPowerStationOperationPersonnel(int Userid)
|
||||
{
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
var result = new List<OperationPersonnel>();
|
||||
using (var trans = conn.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = $@"SELECT p.*,ps.Name FROM power_station_operation_personnel p
|
||||
LEFT JOIN power_station ps ON p.PowerStationId = ps.Id
|
||||
WHERE p.UserId = {Userid} AND p.Deleted = 0 ";
|
||||
|
||||
result = (await conn.QueryAsync<OperationPersonnel>(sql)).ToList();
|
||||
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
trans.Rollback();
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2340,6 +2340,10 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -2429,6 +2433,10 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -2458,6 +2466,10 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -2518,6 +2530,10 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -2649,6 +2665,10 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -2775,6 +2795,10 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -2799,6 +2823,10 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -2823,6 +2851,7 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally { conn.Close(); }
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -2895,6 +2924,10 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -2944,6 +2977,10 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -3015,6 +3052,10 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -3034,6 +3075,10 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -3165,6 +3210,10 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -3246,6 +3295,10 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -3274,6 +3327,10 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -3322,6 +3379,10 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -3341,6 +3402,10 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -3381,6 +3446,10 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -3454,6 +3523,10 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -3503,6 +3576,10 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -3544,6 +3621,10 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -3644,6 +3725,10 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -3688,6 +3773,10 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -3732,6 +3821,10 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -3813,6 +3906,10 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -3857,6 +3954,10 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -3900,6 +4001,10 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -4052,6 +4157,10 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -4129,6 +4238,10 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -4360,5 +4473,41 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> CheckShowMoney(int userid)
|
||||
{
|
||||
bool result = true;
|
||||
string J;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = @$"SELECT ap.AuthCode FROM user u
|
||||
LEFT JOIN role_auth ra ON ra.Id = u.RoleId
|
||||
LEFT JOIN auth_page ap ON ap.AuthCode = ra.AuthCode
|
||||
WHERE u.Id = {userid} AND ap.AuthCode = 'J' ";
|
||||
|
||||
|
||||
J = await conn.QueryFirstOrDefaultAsync<string>(sql);
|
||||
if (J == null)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
using SolarPower.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SolarPower.Repository.Interface
|
||||
{
|
||||
public interface IElectricitySoldRecordRepository: IRepositoryBase<ElectricitySoldRecord>
|
||||
{
|
||||
Task<List<ElectricitySoldRecordTable>> RecordTable(ElectricitySoldRecordTablePost post);
|
||||
}
|
||||
}
|
||||
@ -10,5 +10,6 @@ namespace SolarPower.Repository.Interface
|
||||
{
|
||||
Task<List<NoticeSchedule>> GetNotYetDelivery();
|
||||
Task UpdateList(List<NoticeSchedule> noticeSchedules, List<string> properties);
|
||||
Task<List<OperationPersonnel>> GetPowerStationOperationPersonnel(int Userid);
|
||||
}
|
||||
}
|
||||
|
||||
@ -566,5 +566,6 @@ namespace SolarPower.Repository.Interface
|
||||
Task AddAfterPurgePyrheliometerHistoryHour(string startDate, string endDate, List<PyrheliometerHistory> entity, List<string> properties);
|
||||
Task AddAfterPurgeInverterHistoryHour(string startDate, string endDate, List<InverterHistory> entity, List<string> properties);
|
||||
Task AddAfterPurgeSensorAvgHistoryHour(string startDate, string endDate, List<SensorAvgHistory> entity, List<string> properties);
|
||||
Task<bool> CheckShowMoney(int userid);
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,6 +79,7 @@ namespace SolarPower
|
||||
services.AddTransient<IAnalysisStationCombineRepository,AnalysisStationCombineRepository>();
|
||||
services.AddTransient<IStationReportRepository, StationReportRepository>();
|
||||
services.AddTransient<INoticeScheduleRepository, NoticeScheduleRepository>();
|
||||
services.AddTransient<IElectricitySoldRecordRepository, ElectricitySoldRecordRepository>();
|
||||
#endregion
|
||||
|
||||
double loginExpireMinute = this.Configuration.GetValue<double>("LoginExpireMinute");
|
||||
|
||||
602
SolarPower/Views/ElectricitySoldRecord/Index.cshtml
Normal file
602
SolarPower/Views/ElectricitySoldRecord/Index.cshtml
Normal file
@ -0,0 +1,602 @@
|
||||
@{
|
||||
ViewData["MainNum"] = "4";
|
||||
ViewData["SubNum"] = "2";
|
||||
ViewData["Title"] = "台電售電記錄";
|
||||
}
|
||||
@using SolarPower.Models.Role
|
||||
@model RoleLayerEnum
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row flex-nowrap wrapper">
|
||||
<div class="col-md-2 col-1 pl-0 pr-0 collapse width border-right sidebar vh-100">
|
||||
|
||||
<div class="list-group border-0 card text-center text-md-left" id="sidebar">
|
||||
|
||||
<div class="border bg-light rounded-top">
|
||||
<div class="form-group p-2 m-0 rounded-top">
|
||||
<input type="text" class="form-control form-control-lg shadow-inset-2 m-0" id="js_list_accordion_filter" placeholder="">
|
||||
</div>
|
||||
<div id="js_list_accordion" class="accordion accordion-hover accordion-clean js-list-filter">
|
||||
<div class="card border-top-left-radius-0 border-top-right-radius-0">
|
||||
<div class="card-header">
|
||||
<a href="javascript:void(0);" class="card-title collapsed" data-toggle="collapse" data-target="#js_list_accordion-a" aria-expanded="true" data-filter-tags="settings">
|
||||
<i class="fal fa-globe width-2 fs-xl"></i>
|
||||
新北市
|
||||
<span class="ml-auto">
|
||||
<span class="collapsed-reveal">
|
||||
<i class="fal fa-chevron-up fs-xl"></i>
|
||||
</span>
|
||||
<span class="collapsed-hidden">
|
||||
<i class="fal fa-chevron-down fs-xl"></i>
|
||||
</span>
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
<div id="js_list_accordion-a" class="collapse" data-parent="#js_list_accordion" style="">
|
||||
<div class="card-body">
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item">
|
||||
<div class="d-flex justify-content-between">
|
||||
<h4 class="font-weight-bold"><i class="fal fa-charging-station"></i> 新竹交大站</h4>
|
||||
<div class="">
|
||||
<input type="checkbox" class="" id="defaultUnchecked">
|
||||
</div>
|
||||
</div>
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item pr-0 d-flex justify-content-between">
|
||||
<a href="#"><i class="fal fa-tachometer-alt-slow"></i> 電錶 R001</a>
|
||||
<div class="">
|
||||
<input type="checkbox" class="" id="defaultUnchecked">
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<div class="d-flex justify-content-between">
|
||||
<h4 class="font-weight-bold"><i class="fal fa-charging-station"></i> 新竹動物園站</h4>
|
||||
<div class="">
|
||||
<input type="checkbox" class="" id="defaultUnchecked">
|
||||
</div>
|
||||
</div>
|
||||
<li class="list-group-item">
|
||||
<div class="d-flex justify-content-between">
|
||||
<h4 class="font-weight-bold"><i class="fal fa-charging-station"></i> 新竹火車站</h4>
|
||||
<div class="">
|
||||
<input type="checkbox" class="" id="defaultUnchecked">
|
||||
</div>
|
||||
</div>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<a href="javascript:void(0);" class="card-title collapsed" data-toggle="collapse" data-target="#js_list_accordion-b" aria-expanded="false" data-filter-tags="merge">
|
||||
<i class="fal fa-globe width-2 fs-xl"></i>
|
||||
台南市
|
||||
<span class="ml-auto">
|
||||
<span class="collapsed-reveal">
|
||||
<i class="fal fa-chevron-up fs-xl"></i>
|
||||
</span>
|
||||
<span class="collapsed-hidden">
|
||||
<i class="fal fa-chevron-down fs-xl"></i>
|
||||
</span>
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
<div id="js_list_accordion-b" class="collapse" data-parent="#js_list_accordion">
|
||||
<div class="card-body">
|
||||
放台南市list
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<a href="javascript:void(0);" class="card-title collapsed" data-toggle="collapse" data-target="#js_list_accordion-c" aria-expanded="false" data-filter-tags="backup">
|
||||
<i class="fal fa-globe width-2 fs-xl"></i>
|
||||
屏東縣
|
||||
<span class="ml-auto">
|
||||
<span class="collapsed-reveal">
|
||||
<i class="fal fa-chevron-up fs-xl"></i>
|
||||
</span>
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
<div id="js_list_accordion-c" class="collapse" data-parent="#js_list_accordion">
|
||||
<div class="card-body">
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item">
|
||||
<span data-filter-tags="reports file">Reports</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<span class="filter-message js-filter-message"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto px-0">
|
||||
<a href="javascript:;" data-target=".sidebar" data-toggle="collapse" class="btn btn-default btn-xs btn-icon waves-effect waves-themed" style="border-radius: 0;"><i onclick="myfunc(this)" class="fal fa-angle-right fa-lg py-3" id="collapse"></i></a>
|
||||
</div>
|
||||
|
||||
<main class="col px-5 pl-md-2 main">
|
||||
<div class="subheader">
|
||||
<h1 class="subheader-title">
|
||||
<i class="subheader-icon fal fa-file-chart-line"></i> @ViewData["Title"]
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xl-12">
|
||||
<div id="panel-5" class="panel">
|
||||
<div class="panel-container show">
|
||||
<div class="panel-content">
|
||||
<div class="mb-3 d-flex justify-content-start">
|
||||
<div class="pr-3">
|
||||
<div class="btn-group btn-group-md">
|
||||
<button type="button" class="btn btn-success waves-effect waves-themed btn-change-searchType" id="Group0" onclick="changeType(0,this)">60天內</button>
|
||||
<button type="button" class="btn btn-secondary waves-effect waves-themed btn-change-searchType" id="Group1" onclick="changeType(1,this)">日區間</button>
|
||||
<button type="button" class="btn btn-secondary waves-effect waves-themed btn-change-searchType" id="Group2" onclick="changeType(2,this)">月</button>
|
||||
<button type="button" class="btn btn-secondary waves-effect waves-themed btn-change-searchType" id="Group3" onclick="changeType(3,this)">年</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pr-3">
|
||||
<div class="btn-group" id="DateGetdiv" role="group" aria-label="Button group with nested dropdown">
|
||||
<input type="date" class="form-control" id="DateGet" />
|
||||
</div>
|
||||
<div class="btn-group" id="DateGettextdiv" role="group" aria-label="Button group with nested dropdown">
|
||||
<input type="text" class="form-control" id="DateGettext" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="pr-3" id="quickSearchOption">
|
||||
<button type="button" class="btn btn-primary waves-effect waves-themed ml-1" onclick="Searchform()" id="daybtn">查詢</button>
|
||||
</div>
|
||||
<div class="pr-3">
|
||||
<button type="button" class="btn btn-primary waves-effect waves-themed" onclick="AddRecord()"><span class="fal fa-plus mr-1"></span> 新增</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-5">
|
||||
<div class="col-xl-12">
|
||||
<div class="card p-3 w-100 overflow-auto">
|
||||
<table class="table m-0" id="RecordTable">
|
||||
<thead id="tothead">
|
||||
<tr>
|
||||
<th>編號</th>
|
||||
<th>電站名稱</th>
|
||||
<th>開始日期</th>
|
||||
<th>結束日期</th>
|
||||
<th>購電度數</th>
|
||||
<th>售出電費</th>
|
||||
<th>建立日期</th>
|
||||
<th>功能</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="totbody">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="Record-modal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">
|
||||
台電售電紀錄-新增
|
||||
</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true"><i class="fal fa-times"></i></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form class="Record-form" id="Record-form">
|
||||
<div class="row">
|
||||
<div class="form-group col-lg-6">
|
||||
<label class="form-label" for="PowerStationId_modal"><span class="text-danger">*</span>電站名稱</label>
|
||||
<select class="form-control" id="PowerStationId_modal">
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-lg-6">
|
||||
<label class="form-label" for="StartTime_modal"><span class="text-danger">*</span>開始日期</label>
|
||||
<input type="date" id="StartTime_modal" name="StartTime_modal" class="form-control">
|
||||
</div>
|
||||
<div class="form-group col-lg-6">
|
||||
<label class="form-label" for="BuyKwh_modal"><span class="text-danger">*</span>購電度數</label>
|
||||
<input type="number" id="BuyKwh_modal" name="BuyKwh_modal" class="form-control">
|
||||
</div>
|
||||
<div class="form-group col-lg-6">
|
||||
<label class="form-label" for="EndTime_modal"><span class="text-danger">*</span>結束日期</label>
|
||||
<input type="date" id="EndTime_modal" name="EndTime_modal" class="form-control">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-lg-6">
|
||||
<label class="form-label" for="Money_modal"><span class="text-danger">*</span>售出電費</label>
|
||||
<input type="number" id="Money_modal" name="Money_modal" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
|
||||
<button type="button" class="btn btn-primary" onclick="SaveSoldMoney()">確定</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section Scripts{
|
||||
<script>
|
||||
var searchType = 0;//搜尋條件(日,日區間,月,年)
|
||||
var datepicker;
|
||||
var timerange;//選取時間
|
||||
var selecterd_powerstationId = [];
|
||||
var selected_id;
|
||||
//#region Date-Picker
|
||||
datepicker = $('#DateGettext').daterangepicker({
|
||||
autoUpdateInput: false,
|
||||
locale: { format: 'YYYY/MM/DD' },
|
||||
opens: 'left'
|
||||
});
|
||||
|
||||
$('#DateGettext').on('apply.daterangepicker', function (ev, picker) {
|
||||
$(this).val(picker.startDate.format('YYYY/MM/DD') + ' - ' + picker.endDate.format('YYYY/MM/DD'));
|
||||
$(this).trigger('change');
|
||||
});
|
||||
|
||||
$('#DateGettext').on('cancel.daterangepicker', function (ev, picker) {
|
||||
$(this).val('');
|
||||
$(this).trigger('change');
|
||||
});
|
||||
//#endregion
|
||||
$(function () {
|
||||
//#region 預設初始值
|
||||
var a = $('#collapse').trigger("click");
|
||||
document.getElementById("DateGetdiv").style.display = "none";//隱藏
|
||||
$('#DateGet').attr('style', 'width:205px');
|
||||
$('#DateGettext').attr('style', 'width:205px');
|
||||
//#endregion
|
||||
|
||||
//#region 載入左邊選單列表
|
||||
GetPowerStationCollapse("");
|
||||
//#endregion
|
||||
|
||||
var today = new Date();
|
||||
var dateLimit = new Date(new Date().setDate(today.getDate() - 60));
|
||||
var today_format = today.toISOString().slice(0, 10).replace(/-/g, "/");
|
||||
var dateLimit_format = dateLimit.toISOString().slice(0, 10).replace(/-/g, "/");
|
||||
datepicker.data('daterangepicker').setStartDate(dateLimit_format);
|
||||
datepicker.data('daterangepicker').setEndDate(today_format);
|
||||
document.getElementById("DateGettextdiv").style.display = "";//隱藏
|
||||
document.getElementById("DateGetdiv").style.display = "none";//隱藏
|
||||
//#endregion
|
||||
$('#DateGettext').val(dateLimit_format + ' - ' + today_format);
|
||||
$("#PowerStationId_modal").append($("<option />").val(0).text("請先選擇電站"));
|
||||
$("#PowerStationId_modal").attr("disabled", true);
|
||||
})
|
||||
|
||||
//#region 左邊的搜索欄位
|
||||
function myfunc(div) {
|
||||
var className = div.getAttribute("class");
|
||||
if (className == "fal fa-angle-left fa-lg py-3") {
|
||||
div.className = "fal fa-angle-right fa-lg py-3";
|
||||
}
|
||||
else {
|
||||
div.className = "fal fa-angle-left fa-lg py-3";
|
||||
}
|
||||
}
|
||||
|
||||
$("#js_list_accordion_filter").change(function (e) {
|
||||
GetPowerStationCollapse($(this).val());
|
||||
});
|
||||
|
||||
$('#js_list_accordion').on("change", 'input[name="selectedInverterLayer2[]"]', function (event) {
|
||||
var getstation =
|
||||
{
|
||||
name: $(this).attr('valuename'),
|
||||
value: this.value
|
||||
}
|
||||
|
||||
if (this.checked) {
|
||||
selecterd_powerstationId.push(getstation);
|
||||
} else {
|
||||
var a = selecterd_powerstationId.filter(function (n, i) {
|
||||
|
||||
if (n.name === getstation.name && n.value === getstation.value) {
|
||||
selecterd_powerstationId.splice(i, 1);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
$('#PowerStationId_modal').empty();
|
||||
$("#PowerStationId_modal").attr("disabled", false);
|
||||
$.each(selecterd_powerstationId, function (index, val) {
|
||||
$("#PowerStationId_modal").append($("<option />").val(parseInt(val.value)).text(val.name));
|
||||
});
|
||||
if (selecterd_powerstationId.length == 0) {
|
||||
$("#PowerStationId_modal").append($("<option />").val(0).text("請先選擇電站"));
|
||||
$("#PowerStationId_modal").attr("disabled", true);
|
||||
}
|
||||
|
||||
|
||||
console.log(selecterd_powerstationId);
|
||||
});
|
||||
|
||||
|
||||
function GetPowerStationCollapse(filter) {
|
||||
var url = "/StationReport/GetPowerStationNameList"
|
||||
|
||||
var send_data = {
|
||||
Filter: filter
|
||||
}
|
||||
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.data.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
var inverterCollapse = rel.data;
|
||||
|
||||
|
||||
|
||||
$('#js_list_accordion').empty();
|
||||
|
||||
if (inverterCollapse.length <= 0) {
|
||||
$('#js_list_accordion').append("<div>查無結果</div>");
|
||||
}
|
||||
|
||||
var str = "";
|
||||
|
||||
Object.keys(inverterCollapse).map(function (key, index) {
|
||||
str += '<div class="card border-top-left-radius-0 border-top-right-radius-0" id="templateCard">' +
|
||||
'<div class="card-header">' +
|
||||
'<a href="javascript:void(0);" class="card-title collapsed" data-toggle="collapse" data-target="#js_list_accordion-' + index + '" aria-expanded="false" data-filter-tags="settings">' +
|
||||
'<i class="fal fa-globe width-2 fs-xl"></i>' +
|
||||
'<span class="city-name">' + key + '</span>' +
|
||||
'<span class="ml-auto">' +
|
||||
'<span class="collapsed-reveal"><i class="fal fa-chevron-up fs-xl"></i></span>' +
|
||||
'<span class="collapsed-hidden"><i class="fal fa-chevron-down fs-xl"></i></span>' +
|
||||
'</span>' +
|
||||
'</a>' +
|
||||
'</div>' +
|
||||
'<div id="js_list_accordion-' + index + '" class="collapse" data-parent="#js_list_accordion-' + index + '" style="">' +
|
||||
'<div class="card-body">' +
|
||||
'<ul class="list-group list-group-flush">';
|
||||
$.each(inverterCollapse[key], function (index, inverter) {
|
||||
var getstation =
|
||||
{
|
||||
name: inverter.powerStationName,
|
||||
value: String(inverter.powerStationId)
|
||||
}
|
||||
var on = false;
|
||||
var a = selecterd_powerstationId.find(function (n, i) {
|
||||
if (n.name === getstation.name && n.value === getstation.value) {
|
||||
on = true;
|
||||
}
|
||||
});
|
||||
if (on == true) {
|
||||
str += '<li class="list-group-item">' +
|
||||
'<div class="d-flex justify-content-between">' +
|
||||
'<h4 class="font-weight-bold"><i class="fal fa-charging-station"></i> ' + inverter.powerStationName + '</h4>' +
|
||||
'<div class="">' +
|
||||
'<input type="checkbox" class="" name="selectedInverterLayer2[]" value="' + inverter.powerStationId + '" valueName ="' + inverter.powerStationName + '" checked>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</li>';
|
||||
}
|
||||
else {
|
||||
str += '<li class="list-group-item">' +
|
||||
'<div class="d-flex justify-content-between">' +
|
||||
'<h4 class="font-weight-bold"><i class="fal fa-charging-station"></i> ' + inverter.powerStationName + '</h4>' +
|
||||
'<div class="">' +
|
||||
'<input type="checkbox" class="" name="selectedInverterLayer2[]" value="' + inverter.powerStationId + '" valueName ="' + inverter.powerStationName + '">' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</li>';
|
||||
}
|
||||
});
|
||||
|
||||
str += '</ul>';
|
||||
str += '</div>';
|
||||
str += '</div>';
|
||||
|
||||
});
|
||||
|
||||
$('#js_list_accordion').append(str);
|
||||
$('#js_list_accordion').find('.card').first().addClass(" border-top-left-radius-0 border-top-right-radius-0");
|
||||
|
||||
$('input[name="selectedInverterLayer2[]"]').each(function () {
|
||||
if ($.inArray(this.value, selecterd_powerstationId) > -1) {
|
||||
$(this).prop('checked', true);
|
||||
}
|
||||
});
|
||||
$("#js_list_accordion .collapse").collapse('show');
|
||||
|
||||
|
||||
}, 'json');
|
||||
}
|
||||
//#endregion
|
||||
|
||||
function changeType(type, e) {
|
||||
searchType = type;
|
||||
if ($(".btn-change-searchType").hasClass("btn-success")) {
|
||||
$(".btn-change-searchType").removeClass("btn-success").addClass("btn-secondary");
|
||||
}
|
||||
document.getElementById("DateGettextdiv").style.display = "none";//隱藏
|
||||
document.getElementById("DateGetdiv").style.display = "";//隱藏
|
||||
$(e).removeClass("btn-secondary").addClass("btn-success");
|
||||
switch (type) {
|
||||
case 0:
|
||||
//#region 預設近60天
|
||||
var today = new Date();
|
||||
var dateLimit = new Date(new Date().setDate(today.getDate() - 60));
|
||||
var today_format = today.toISOString().slice(0, 10).replace(/-/g, "/");
|
||||
var dateLimit_format = dateLimit.toISOString().slice(0, 10).replace(/-/g, "/");
|
||||
datepicker.data('daterangepicker').setStartDate(dateLimit_format);
|
||||
datepicker.data('daterangepicker').setEndDate(today_format);
|
||||
document.getElementById("DateGettextdiv").style.display = "";//隱藏
|
||||
document.getElementById("DateGetdiv").style.display = "none";//隱藏
|
||||
//#endregion
|
||||
$('#DateGettext').val(dateLimit_format + ' - ' + today_format);
|
||||
break;
|
||||
break;
|
||||
case 1:
|
||||
//#region 預設近7天
|
||||
$('#DateGettext').val("");
|
||||
document.getElementById("DateGettextdiv").style.display = "";//隱藏
|
||||
document.getElementById("DateGetdiv").style.display = "none";//隱藏
|
||||
//#endregion
|
||||
break;
|
||||
case 2:
|
||||
$('#DateGet').prop({ 'type': 'month' });
|
||||
var now_month = new Date().toISOString().substring(0, 7);
|
||||
$('#DateGet').val(now_month);
|
||||
|
||||
break;
|
||||
case 3:
|
||||
var now_year = new Date().toISOString().substring(0, 4);
|
||||
$('#DateGet').prop({ 'type': 'number', 'min': 1900, 'max': now_year, 'step': 1 });
|
||||
$('#DateGet').val(now_year);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function AddRecord() {
|
||||
selected_id = 0;
|
||||
$("#Record-modal .modal-title").html("台電售電紀錄-新增");
|
||||
$("#Record-form").trigger("reset");
|
||||
$("#Record-modal").modal();
|
||||
}
|
||||
|
||||
function SaveSoldMoney()
|
||||
{
|
||||
if ($("#Record-form").valid()) {
|
||||
var url = "/ElectricitySoldRecord/SaveSoldMoney";
|
||||
var send_data = {
|
||||
StartAt: $("#StartTime_modal").val(),
|
||||
EndAt: $("#EndTime_modal").val(),
|
||||
Kwh: $("#BuyKwh_modal").val(),
|
||||
Money: $("#Money_modal").val(),
|
||||
PowerstationId: $("#PowerStationId_modal").val()
|
||||
}
|
||||
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
toast_ok(rel.msg);
|
||||
//$('#ShareDevice-modal').modal('hide');
|
||||
//ShareDeviceTable.ajax.reload();
|
||||
return;
|
||||
}
|
||||
|
||||
}, 'json');
|
||||
}
|
||||
}
|
||||
|
||||
function DataTable() {
|
||||
RecordTable = $("#RecordTable").DataTable({
|
||||
"paging": true,
|
||||
"lengthChange": false,
|
||||
"searching": false,
|
||||
"ordering": true,
|
||||
"info": true,
|
||||
"autoWidth": false,
|
||||
"responsive": true,
|
||||
"columns": [{
|
||||
"data": "id"
|
||||
}, {
|
||||
"data": "powerStationName"
|
||||
}, {
|
||||
"data": "startAt"
|
||||
}, {
|
||||
"data": "endAt"
|
||||
}, {
|
||||
"data": "kwh"
|
||||
}, {
|
||||
"data": "money"
|
||||
}, {
|
||||
"data": "createdDay"
|
||||
}, {
|
||||
"data": "function"
|
||||
}],
|
||||
"language": {
|
||||
"emptyTable": "查無資料",
|
||||
"processing": "處理中...",
|
||||
"loadingRecords": "載入中...",
|
||||
"lengthMenu": "顯示 _MENU_ 項結果",
|
||||
"zeroRecords": "沒有符合的結果",
|
||||
"info": "顯示第 _START_ 至 _END_ 項結果,共 _TOTAL_ 項",
|
||||
"infoEmpty": "顯示第 0 至 0 項結果,共 0 項",
|
||||
"infoFiltered": "(從 _MAX_ 項結果中過濾)",
|
||||
"infoPostFix": "",
|
||||
"search": "搜尋:",
|
||||
"paginate": {
|
||||
"first": "第一頁",
|
||||
"previous": "上一頁",
|
||||
"next": "下一頁",
|
||||
"last": "最後一頁"
|
||||
},
|
||||
"aria": {
|
||||
"sortAscending": ": 升冪排列",
|
||||
"sortDescending": ": 降冪排列"
|
||||
}
|
||||
},
|
||||
'createdRow': function (row, data, dataIndex) {
|
||||
$(row).attr('data-id', data.id);
|
||||
},
|
||||
"ajax": {
|
||||
"url": "/ElectricitySoldRecord/RecordTable",
|
||||
"type": "POST",
|
||||
"data": function (d) {
|
||||
d.stationId = selecterd_powerstationId,
|
||||
d.time = timerange,
|
||||
d.searchType = searchType
|
||||
},
|
||||
"dataSrc": function (rel) {
|
||||
if (rel.data.code == "9999") {
|
||||
toast_error(rel.data.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
data = rel.data.data;
|
||||
|
||||
if (data == null || data.length == 0) {
|
||||
this.data = [];
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function Searchform() {
|
||||
if (searchType == 0 || searchType == 1) {
|
||||
timerange = $('#DateGettext').val();
|
||||
}
|
||||
else {
|
||||
timerange = $('#DateGet').val();
|
||||
}
|
||||
DataTable();
|
||||
}
|
||||
</script>
|
||||
}
|
||||
@ -266,9 +266,9 @@
|
||||
<span class="nav-link-text" data-i18n="nav.utilities_disabled_item">電站報表</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="">
|
||||
<a href="javascript:void(0);" title="電站發電收入" data-filter-tags="utilities disabled item">
|
||||
<span class="nav-link-text" data-i18n="nav.utilities_disabled_item">電站發電收入</span>
|
||||
<li class="@(ViewData["MainNum"] == "4" && ViewData["SubNum"].ToString() == "2" ? "active" : "")">
|
||||
<a asp-controller="ElectricitySoldRecord" asp-action="Index" title="台電售電記錄" data-filter-tags="utilities disabled item">
|
||||
<span class="nav-link-text" data-i18n="nav.utilities_disabled_item">台電售電記錄</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="">
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"LoginExpireMinute": 60, //登入到期時間,單位(分)
|
||||
"LoginExpireMinute": 60, //?n?J???????A???(??)
|
||||
"DBConfig": {
|
||||
"Server": "MVgHWzR3rGDgD57TUoFunA==",
|
||||
"port": "r4AoXMUDodcQjIzofGNCcg==",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user