歸屬月份
This commit is contained in:
parent
80e966507e
commit
52fb2cb3b6
@ -94,7 +94,8 @@ namespace SolarPower.Controllers
|
|||||||
Kwh = post.Kwh,
|
Kwh = post.Kwh,
|
||||||
Money = post.Money,
|
Money = post.Money,
|
||||||
PowerstationId = post.PowerstationId,
|
PowerstationId = post.PowerstationId,
|
||||||
StartAt = post.StartAt
|
StartAt = post.StartAt,
|
||||||
|
Month = post.Month
|
||||||
};
|
};
|
||||||
List<string> properties = new List<string>()
|
List<string> properties = new List<string>()
|
||||||
{
|
{
|
||||||
@ -103,7 +104,8 @@ namespace SolarPower.Controllers
|
|||||||
"Kwh",
|
"Kwh",
|
||||||
"Money",
|
"Money",
|
||||||
"PowerstationId",
|
"PowerstationId",
|
||||||
"StartAt"
|
"StartAt",
|
||||||
|
"Month"
|
||||||
};
|
};
|
||||||
await electricitySoldRecordRepository.AddAsync(record, properties);
|
await electricitySoldRecordRepository.AddAsync(record, properties);
|
||||||
|
|
||||||
@ -119,7 +121,8 @@ namespace SolarPower.Controllers
|
|||||||
UpdatedBy = myUser.Id,
|
UpdatedBy = myUser.Id,
|
||||||
Kwh = post.Kwh,
|
Kwh = post.Kwh,
|
||||||
Money = post.Money,
|
Money = post.Money,
|
||||||
StartAt = post.StartAt
|
StartAt = post.StartAt,
|
||||||
|
Month = post.Month
|
||||||
};
|
};
|
||||||
List<string> properties = new List<string>()
|
List<string> properties = new List<string>()
|
||||||
{
|
{
|
||||||
@ -128,7 +131,8 @@ namespace SolarPower.Controllers
|
|||||||
"UpdatedBy",
|
"UpdatedBy",
|
||||||
"Kwh",
|
"Kwh",
|
||||||
"Money",
|
"Money",
|
||||||
"StartAt"
|
"StartAt",
|
||||||
|
"Month"
|
||||||
};
|
};
|
||||||
await electricitySoldRecordRepository.Update(record, properties);
|
await electricitySoldRecordRepository.Update(record, properties);
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
|
|||||||
@ -2198,6 +2198,10 @@ ALTER TABLE `power_station`
|
|||||||
ALTER TABLE `operation_firm`
|
ALTER TABLE `operation_firm`
|
||||||
ADD COLUMN `TaxIDNumber` VARCHAR(8) NULL DEFAULT NULL COMMENT '統一編號' AFTER `Email`,
|
ADD COLUMN `TaxIDNumber` VARCHAR(8) NULL DEFAULT NULL COMMENT '統一編號' AFTER `Email`,
|
||||||
ADD COLUMN `Remark` VARCHAR(255) NULL DEFAULT NULL COMMENT '備註' AFTER `TaxIDNumber`;
|
ADD COLUMN `Remark` VARCHAR(255) NULL DEFAULT NULL COMMENT '備註' AFTER `TaxIDNumber`;
|
||||||
|
-- 售電紀錄-歸屬月份 20210911
|
||||||
|
ALTER TABLE `electricity_sold_record`
|
||||||
|
ADD COLUMN `Month` VARCHAR(10) NULL DEFAULT NULL COMMENT '歸屬月份' AFTER `Deleted`;
|
||||||
|
|
||||||
|
|
||||||
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
|
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
|
||||||
/*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */;
|
/*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */;
|
||||||
|
|||||||
@ -15,6 +15,7 @@ namespace SolarPower.Models
|
|||||||
public int Kwh { get; set; }//購電度數
|
public int Kwh { get; set; }//購電度數
|
||||||
public float Money { get; set; }//售出金額
|
public float Money { get; set; }//售出金額
|
||||||
public int Deleted { get; set; }
|
public int Deleted { get; set; }
|
||||||
|
public string Month { get; set; }// 歸屬月份
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ElectricitySoldRecordTable : ElectricitySoldRecord
|
public class ElectricitySoldRecordTable : ElectricitySoldRecord
|
||||||
|
|||||||
@ -26,7 +26,6 @@ namespace SolarPower.Repository.Implement
|
|||||||
ids.Add(Convert.ToInt32(id.Value));
|
ids.Add(Convert.ToInt32(id.Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
switch (post.SearchType)
|
switch (post.SearchType)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
@ -34,28 +33,33 @@ namespace SolarPower.Repository.Implement
|
|||||||
post.Time = post.Time.Replace("-", "~");
|
post.Time = post.Time.Replace("-", "~");
|
||||||
post.Time = post.Time.Replace("/", "-");
|
post.Time = post.Time.Replace("/", "-");
|
||||||
var time = post.Time.Split("~");
|
var time = post.Time.Split("~");
|
||||||
|
var time1 = Convert.ToDateTime(time[0]).ToString("yyyy-MM");
|
||||||
|
var time2 = Convert.ToDateTime(time[1]).ToString("yyyy-MM");
|
||||||
|
|
||||||
sql = @$"SELECT es.*,ps.Name AS PowerStationName FROM electricity_sold_record es
|
sql = @$"SELECT es.*,ps.Name AS PowerStationName FROM electricity_sold_record es
|
||||||
LEFT JOIN power_station ps ON es.PowerstationId = ps.Id
|
LEFT JOIN power_station ps ON es.PowerstationId = ps.Id
|
||||||
WHERE es.StartAt BETWEEN '{time[0]}' AND '{time[1]}' AND es.PowerstationId IN @ids AND es.Deleted = 0";
|
WHERE es.Month BETWEEN '{time1}' AND '{time2}' AND es.PowerstationId IN @ids AND es.Deleted = 0";
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
post.Time = post.Time.Replace(" ", "");
|
post.Time = post.Time.Replace(" ", "");
|
||||||
post.Time = post.Time.Replace("-", "~");
|
post.Time = post.Time.Replace("-", "~");
|
||||||
post.Time = post.Time.Replace("/", "-");
|
post.Time = post.Time.Replace("/", "-");
|
||||||
var time1 = post.Time.Split("~");
|
var timea = post.Time.Split("~");
|
||||||
|
var timeb = Convert.ToDateTime(timea[0]).ToString("yyyy-MM");
|
||||||
|
var timec = Convert.ToDateTime(timea[1]).ToString("yyyy-MM");
|
||||||
sql = @$"SELECT es.*,ps.Name AS PowerStationName FROM electricity_sold_record es
|
sql = @$"SELECT es.*,ps.Name AS PowerStationName FROM electricity_sold_record es
|
||||||
LEFT JOIN power_station ps ON es.PowerstationId = ps.Id
|
LEFT JOIN power_station ps ON es.PowerstationId = ps.Id
|
||||||
WHERE es.StartAt BETWEEN '{time1[0]}' AND '{time1[1]}' AND es.PowerstationId IN @ids AND es.Deleted = 0";
|
WHERE es.Month BETWEEN '{timeb}' AND '{timec}' AND es.PowerstationId IN @ids AND es.Deleted = 0";
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
sql = @$"SELECT es.*,ps.Name AS PowerStationName FROM electricity_sold_record es
|
sql = @$"SELECT es.*,ps.Name AS PowerStationName FROM electricity_sold_record es
|
||||||
LEFT JOIN power_station ps ON es.PowerstationId = ps.Id
|
LEFT JOIN power_station ps ON es.PowerstationId = ps.Id
|
||||||
WHERE DATE_FORMAT(es.StartAt , '%Y-%m') = '{post.Time}' AND es.PowerstationId IN @ids AND es.Deleted = 0";
|
WHERE DATE_FORMAT(STR_TO_DATE(es.Month , '%Y-%m'),'%Y-%m') = '{post.Time}' AND es.PowerstationId IN @ids AND es.Deleted = 0";
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
sql = @$"SELECT es.*,ps.Name AS PowerStationName FROM electricity_sold_record es
|
sql = @$"SELECT es.*,ps.Name AS PowerStationName FROM electricity_sold_record es
|
||||||
LEFT JOIN power_station ps ON es.PowerstationId = ps.Id
|
LEFT JOIN power_station ps ON es.PowerstationId = ps.Id
|
||||||
WHERE DATE_FORMAT(es.StartAt , '%Y') = '{post.Time}' AND es.PowerstationId IN @ids AND es.Deleted = 0";
|
WHERE DATE_FORMAT(STR_TO_DATE(es.Month , '%Y'),'%Y') = '{post.Time}' AND es.PowerstationId IN @ids AND es.Deleted = 0";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||||
|
|||||||
@ -218,7 +218,7 @@ namespace SolarPower.Repository.Implement
|
|||||||
conn.Open();
|
conn.Open();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string sql = @$"SELECT LeaseRate,Landowner from {post.SiteDB}.land_building WHERE PowerStationId = {post.PowerstationId}";
|
string sql = @$"SELECT LeaseRate,Landowner from {post.SiteDB}.land_building WHERE PowerStationId = {post.PowerstationId} and Deleted = 0";
|
||||||
result = (await conn.QueryAsync<Landinfo>(sql)).ToList();
|
result = (await conn.QueryAsync<Landinfo>(sql)).ToList();
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
|
|||||||
@ -174,6 +174,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>編號</th>
|
<th>編號</th>
|
||||||
<th>電站名稱</th>
|
<th>電站名稱</th>
|
||||||
|
<th>歸屬月份</th>
|
||||||
<th>開始日期</th>
|
<th>開始日期</th>
|
||||||
<th>結束日期</th>
|
<th>結束日期</th>
|
||||||
<th>購電度數</th>
|
<th>購電度數</th>
|
||||||
@ -228,6 +229,11 @@
|
|||||||
<label class="form-label" for="Money_modal"><span class="text-danger">*</span>售出電費</label>
|
<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">
|
<input type="number" id="Money_modal" name="Money_modal" class="form-control">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-lg-6">
|
||||||
|
<label class="form-label" for="Month_modal"><span class="text-danger">*</span>歸屬月份</label>
|
||||||
|
<input type="month" id="Month_modal" name="Month_modal" class="form-control">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@ -496,7 +502,8 @@
|
|||||||
EndAt: $("#EndTime_modal").val(),
|
EndAt: $("#EndTime_modal").val(),
|
||||||
Kwh: $("#BuyKwh_modal").val(),
|
Kwh: $("#BuyKwh_modal").val(),
|
||||||
Money: $("#Money_modal").val(),
|
Money: $("#Money_modal").val(),
|
||||||
PowerstationId: $("#PowerStationId_modal").val()
|
PowerstationId: $("#PowerStationId_modal").val(),
|
||||||
|
Month: $('#Month_modal').val()
|
||||||
}
|
}
|
||||||
|
|
||||||
$.post(url, send_data, function (rel) {
|
$.post(url, send_data, function (rel) {
|
||||||
@ -528,6 +535,8 @@
|
|||||||
"data": "id"
|
"data": "id"
|
||||||
}, {
|
}, {
|
||||||
"data": "powerStationName"
|
"data": "powerStationName"
|
||||||
|
},{
|
||||||
|
"data": "month"
|
||||||
}, {
|
}, {
|
||||||
"data": "startAt"
|
"data": "startAt"
|
||||||
}, {
|
}, {
|
||||||
@ -611,7 +620,7 @@
|
|||||||
$("#Record-modal .modal-title").html("台電售電紀錄 - 編輯");
|
$("#Record-modal .modal-title").html("台電售電紀錄 - 編輯");
|
||||||
selected_id = $(this).parents('tr').attr('data-id');
|
selected_id = $(this).parents('tr').attr('data-id');
|
||||||
var powerstationName = $(this).parents('tr').attr('powerstation-Name');
|
var powerstationName = $(this).parents('tr').attr('powerstation-Name');
|
||||||
//取得單一運維基本資料
|
//取得單一售電紀錄基本資料
|
||||||
var url = "/ElectricitySoldRecord/GetOnePowerStation/";
|
var url = "/ElectricitySoldRecord/GetOnePowerStation/";
|
||||||
var send_data = {
|
var send_data = {
|
||||||
Id: selected_id
|
Id: selected_id
|
||||||
@ -628,6 +637,7 @@
|
|||||||
$("#BuyKwh_modal").val(rel.data.kwh);
|
$("#BuyKwh_modal").val(rel.data.kwh);
|
||||||
$("#EndTime_modal").val(rel.data.endAt);
|
$("#EndTime_modal").val(rel.data.endAt);
|
||||||
$("#Money_modal").val(rel.data.money);
|
$("#Money_modal").val(rel.data.money);
|
||||||
|
$("#Month_modal").val(rel.data.month);
|
||||||
$("#Record-modal").modal();
|
$("#Record-modal").modal();
|
||||||
}, 'json');
|
}, 'json');
|
||||||
});
|
});
|
||||||
@ -688,6 +698,9 @@
|
|||||||
Money_modal: {
|
Money_modal: {
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
Month_modal: {
|
||||||
|
required: true,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user