台電售電紀錄
This commit is contained in:
parent
196b00595a
commit
ca631fc115
@ -153,10 +153,33 @@ namespace SolarPower.Controllers
|
||||
apiResult.Code = "9999";
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Id=" + id);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
|
||||
}
|
||||
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
public async Task<ApiResult<string>> DeleteRecord(int id)
|
||||
{
|
||||
ApiResult<string> apiResult = new ApiResult<string>();
|
||||
try
|
||||
{
|
||||
await electricitySoldRecordRepository.DeleteOne(id);
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "刪除成功";
|
||||
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Id=" + id);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
return apiResult;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1181,7 +1181,7 @@ namespace SolarPower.Controllers
|
||||
{
|
||||
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");
|
||||
var n = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "upload", "report", Datename, "FIC太陽能監控平台" + "_" + name + "報表" + "_" + postObject.Userid + Datename + ".xlsx");
|
||||
FileStream FS = new FileStream(n, FileMode.Create, FileAccess.Write);
|
||||
workbook.Write(FS);
|
||||
FS.Close();
|
||||
|
||||
@ -36,7 +36,7 @@ namespace SolarPower.Repository.Implement
|
||||
var time = post.Time.Split("~");
|
||||
sql = @$"SELECT es.`*`,ps.Name AS PowerStationName FROM electricity_sold_record es
|
||||
LEFT JOIN power_station ps ON es.PowerstationId = ps.Id
|
||||
WHERE es.StartAt BETWEEN '{time[0]}' AND '{time[1]}' AND es.PowerstationId IN @ids";
|
||||
WHERE es.StartAt BETWEEN '{time[0]}' AND '{time[1]}' AND es.PowerstationId IN @ids AND es.Deleted = 0";
|
||||
break;
|
||||
case 1:
|
||||
post.Time = post.Time.Replace(" ", "");
|
||||
@ -45,18 +45,18 @@ namespace SolarPower.Repository.Implement
|
||||
var time1 = post.Time.Split("~");
|
||||
sql = @$"SELECT es.`*`,ps.Name AS PowerStationName FROM electricity_sold_record es
|
||||
LEFT JOIN power_station ps ON es.PowerstationId = ps.Id
|
||||
WHERE es.StartAt BETWEEN '{time1[0]}' AND '{time1[1]}' AND es.PowerstationId IN @ids";
|
||||
WHERE es.StartAt BETWEEN '{time1[0]}' AND '{time1[1]}' AND es.PowerstationId IN @ids AND es.Deleted = 0";
|
||||
sql = "";
|
||||
break;
|
||||
case 2:
|
||||
sql = @$"SELECT es.`*`,ps.Name AS PowerStationName FROM electricity_sold_record es
|
||||
LEFT JOIN power_station ps ON es.PowerstationId = ps.Id
|
||||
WHERE DATE_FORMAT(es.StartAt , '%Y-%m') = '{post.Time}' AND es.PowerstationId IN @ids";
|
||||
WHERE DATE_FORMAT(es.StartAt , '%Y-%m') = '{post.Time}' AND es.PowerstationId IN @ids AND es.Deleted = 0";
|
||||
break;
|
||||
case 3:
|
||||
sql = @$"SELECT es.`*`,ps.Name AS PowerStationName FROM electricity_sold_record es
|
||||
LEFT JOIN power_station ps ON es.PowerstationId = ps.Id
|
||||
WHERE DATE_FORMAT(es.StartAt , '%Y') = '{post.Time}' AND es.PowerstationId IN @ids";
|
||||
WHERE DATE_FORMAT(es.StartAt , '%Y') = '{post.Time}' AND es.PowerstationId IN @ids AND es.Deleted = 0";
|
||||
break;
|
||||
}
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
|
||||
@ -491,6 +491,7 @@
|
||||
if ($("#Record-form").valid()) {
|
||||
var url = "/ElectricitySoldRecord/SaveSoldMoney";
|
||||
var send_data = {
|
||||
Id: selected_id,
|
||||
StartAt: $("#StartTime_modal").val(),
|
||||
EndAt: $("#EndTime_modal").val(),
|
||||
Kwh: $("#BuyKwh_modal").val(),
|
||||
@ -505,8 +506,8 @@
|
||||
}
|
||||
else {
|
||||
toast_ok(rel.msg);
|
||||
//$('#ShareDevice-modal').modal('hide');
|
||||
//ShareDeviceTable.ajax.reload();
|
||||
$('#Record-modal').modal('hide');
|
||||
RecordTable.ajax.reload();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -604,17 +605,14 @@
|
||||
}
|
||||
|
||||
$('#RecordTable').on("click", "button.edit-btn", function () {
|
||||
$("#Operation-modal .modal-title").html("運維廠商資料 - 編輯");
|
||||
|
||||
$("#Record-modal .modal-title").html("台電售電紀錄 - 編輯");
|
||||
selected_id = $(this).parents('tr').attr('data-id');
|
||||
var powerstationName = $(this).parents('tr').attr('powerstation-Name');
|
||||
//取得單一運維基本資料
|
||||
var url = "/ElectricitySoldRecord/GetOnePowerStation/";
|
||||
|
||||
var send_data = {
|
||||
Id: selected_id
|
||||
}
|
||||
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
@ -622,18 +620,66 @@
|
||||
}
|
||||
$('#PowerStationId_modal').empty();
|
||||
$("#PowerStationId_modal").attr("disabled", true);
|
||||
|
||||
$("#PowerStationId_modal").append($("<option />").val(999).text(powerstationName));
|
||||
|
||||
$("#StartTime_modal").val(rel.data.startAt);
|
||||
$("#BuyKwh_modal").val(rel.data.kwh);
|
||||
$("#EndTime_modal").val(rel.data.endAt);
|
||||
$("#Money_modal").val(rel.data.money);
|
||||
|
||||
$("#Record-modal").modal();
|
||||
}, 'json');
|
||||
|
||||
});
|
||||
|
||||
$('#RecordTable').on("click", "button.del-btn", function () {
|
||||
selected_id = $(this).parents('tr').attr('data-id');
|
||||
Swal.fire(
|
||||
{
|
||||
title: "刪除",
|
||||
text: "你確定是否刪除此筆資料?",
|
||||
type: "warning",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: "是",
|
||||
cancelButtonText: "否"
|
||||
}).then(function (result) {
|
||||
if (result.value) {
|
||||
var url = "/ElectricitySoldRecord/DeleteRecord/";
|
||||
|
||||
var send_data = {
|
||||
Id: selected_id
|
||||
}
|
||||
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
toast_ok(rel.msg);
|
||||
RecordTable.ajax.reload();
|
||||
}, 'json');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$("#Record-form").validate({
|
||||
rules: {
|
||||
PowerStationId_modal: {
|
||||
required: true,
|
||||
},
|
||||
StartTime_modal: {
|
||||
required: true
|
||||
},
|
||||
EndTime_modal: {
|
||||
required: true,
|
||||
},
|
||||
BuyKwh_modal: {
|
||||
required: true,
|
||||
},
|
||||
Money_modal: {
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user