計畫完成

This commit is contained in:
b110212000 2021-06-25 10:50:31 +08:00
parent dc08866e85
commit 31dbf9289b
2 changed files with 233 additions and 95 deletions

View File

@ -63,19 +63,28 @@ namespace SolarPower.Repository.Implement
List<OperationPlanTable> result;
var count = 0;
string Wheresql = "oc.PowerStationId = ";
foreach (int too in id)
if( id != null)
{
foreach (int too in id)
{
if(count == id.Count-1)
{
Wheresql += too.ToString();
if (count == id.Count - 1)
{
Wheresql += too.ToString();
}
else
{
Wheresql += too.ToString() + " OR oc.PowerStationId = ";
}
count++;
}
else
{
Wheresql += too.ToString() + " OR oc.PowerStationId = ";
}
count++;
}
else
{
Wheresql += "0";
}
using (IDbConnection conn = this._databaseHelper.GetConnection())
{
try

View File

@ -36,7 +36,7 @@
<div class="row mb-3 d-flex align-items-center px-3">
<div class="pr-3">
<button type="button" class="btn btn-secondary waves-effect waves-themed">全部縣市</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed" onclick="Allcity()">全部縣市</button>
</div>
<div class="pr-3">
<div class="frame-wrap" id="citytest" style="display:none">
@ -44,22 +44,6 @@
新北市
<span class="badge bg-success-700 ml-2" id="acount">4</span>
</button>
@*<button type="button" class="btn btn-outline-success waves-effect waves-themed">
台北市
<span class="badge bg-success-700 ml-2">4</span>
</button>
<button type="button" class="btn btn-success waves-effect waves-themed">
新竹市
<span class="badge bg-success-700 ml-2">4</span>
</button>
<button type="button" class="btn btn-outline-success waves-effect waves-themed">
苗栗縣
<span class="badge bg-success-700 ml-2">4</span>
</button>
<button type="button" class="btn btn-outline-success waves-effect waves-themed">
台中市
<span class="badge bg-success-700 ml-2">4</span>
</button>*@
</div>
<div class="frame-wrap" id="city">
@ -69,34 +53,11 @@
<div class="row mb-5 d-flex align-items-center px-3">
<div class="pr-3">
<button type="button" class="btn btn-secondary waves-effect waves-themed">全選</button>
<button type="button" class="btn btn-secondary waves-effect waves-themed" onclick="Allpowerstation()">全選</button>
</div>
<div class="pr-3">
<div class="frame-wrap">
<div class="custom-control custom-checkbox custom-control-inline">
<input type="checkbox" class="custom-control-input" id="defaultInline6">
<label class="custom-control-label" for="defaultInline6">新竹交大站</label>
</div>
<div class="custom-control custom-checkbox custom-control-inline">
<input type="checkbox" class="custom-control-input" id="defaultInline7" checked="">
<label class="custom-control-label" for="defaultInline7">新竹巨城站</label>
</div>
<div class="custom-control custom-checkbox custom-control-inline">
<input type="checkbox" class="custom-control-input" id="defaultInline8" checked="">
<label class="custom-control-label" for="defaultInline8">新竹動物園站</label>
</div>
<div class="custom-control custom-checkbox custom-control-inline">
<input type="checkbox" class="custom-control-input" id="defaultInline9" checked="">
<label class="custom-control-label" for="defaultInline9">新竹城隍廟站</label>
</div>
<div class="custom-control custom-checkbox custom-control-inline">
<input type="checkbox" class="custom-control-input" id="defaultInline10" checked="">
<label class="custom-control-label" for="defaultInline10">新竹清大站</label>
</div>
<div class="custom-control custom-checkbox custom-control-inline">
<input type="checkbox" class="custom-control-input" id="defaultInline11" checked="">
<label class="custom-control-label" for="defaultInline11">新竹高鐵站</label>
</div>
<div class="frame-wrap" id="CheckPowerStation">
</div>
</div>
</div>
@ -145,17 +106,6 @@
</tr>
</thead>
<tbody id="NoViewbody">
<tr>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
<td>1</td>
</tr>
</tbody>
</table>
</div>
@ -179,14 +129,14 @@
<div class="modal-body">
<form class="operation-form" id="Operation-form">
<div class="row mb-3">
<div class="col-lg-6">
<div class="col-lg-7">
<div class="form-group">
<label class="form-label" for="operation_powerStationselect_modal">電站名</label>
<select class="form-control" id="operation_powerStationselect_modal">
</select>
</div>
</div>
<div class="col-lg-6">
<div class="col-lg-5">
<div class="form-group">
<label class="form-label" for="operation_type_modal">項目</label>
<select class="form-control" id="operation_type_modal">
@ -197,7 +147,7 @@
</div>
</div>
<div class="row mb-3">
<div class="col-lg-6">
<div class="col-lg-7">
<div class="form-group">
<div class="row d-flex justify-content-start align-items-center">
<div class="col-4">自動排程 每</div>
@ -228,7 +178,7 @@
<div class="form-group">
<div class="row d-flex justify-content-start align-items-center">
<div class="col-3">開始時間</div>
<div class="col">
<div class="col-5">
<input type="date" id="operation_startTime_modal" class="form-control" placeholder="2000-01-01">
</div>
<div class="col">~<span id="operation_endTime_modal"></span></div>
@ -236,7 +186,7 @@
</div>
</div>
</div>
<div class="col-lg-6">
<div class="col-lg-5">
<div class="form-group">
<label class="form-label" for="operation_description_modal">描述</label>
<textarea class="form-control" id="operation_description_modal" rows="5"></textarea>
@ -244,7 +194,7 @@
</div>
</div>
<div class="row mb-3">
<div class="col-lg-6">
<div class="col-lg-7">
<div class="form-group">
<label class="form-label" for="operation_emailType_modal">email提醒</label>
<select class="form-control" id="operation_emailType_modal">
@ -272,23 +222,77 @@
<script>
var selected_id = 0;
var type = 9;
var type = 9;//全部,清洗,巡檢
var ids = new Array(0);//當前選擇縣市
var powerids = new Array(0);//當前選擇電站
var Allids = new Array(0);//全部縣市
var Allpowerids = new Array(0);//全部電站
//#region Array.Remove
Array.prototype.remove = function (val) {
var index = this.indexOf(val);
if (index > -1) {
this.splice(index, 1);
}
};
//#endregion
$(function () {
//#region 電站下拉式選單select_option
var url_operation_select_option = "/Operation/GetPowerStationSelectOption";
$.get(url_operation_select_option, function (rel) {
if (rel.data.code != "0000") {
if (rel.code != "0000") {
toast_error(rel.data.msg);
return;
}
$("#operation_powerStationselect_modal").empty();
$.each(rel.data.data, function (index, val) {
$.each(rel.data, function (index, val) {
$("#operation_powerStationselect_modal").append($("<option />").val(val.value).text(val.text));
});
});
//#endregion
//#region 載入縣市
var Nurl = "/PowerStation/GetSolarCitySummary";
$.post(Nurl, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
for (var i = 0; i < rel.data.length; i++) {
$('#city').append("<button type='button' class='btn btn-success waves-effect waves-themed ml-2' id='" + 'cityID_' + rel.data[i].cityId + "'>" +
rel.data[i].city +
"<span class= 'badge bg-success-700 ml-2' >" + rel.data[i].amount + "</span >" +
"</button >");
ids.push(String(rel.data[i].cityId));
Allids.push(String(rel.data[i].cityId));
}
var send_data = {
cityid: ids
}
ids.sort();
var Nurl = "/PowerStation/GetSolarByCity";
$.post(Nurl, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
$('#CheckPowerStation').empty();
$.each(rel.data, function (index, val) {
$('#CheckPowerStation').append("<div class='custom-control custom-checkbox custom-control-inline' id='station_" + val.id + "' > ");
$('#station_' + val.id).append("<input type='checkbox' class='custom-control-input' id='check_" + val.id + "' checked>");
$('#station_' + val.id).append("<label class='custom-control-label' for='check_" + val.id + "'>" + val.name + "</label>");
powerids.push(String(val.id));
Allpowerids.push(String(val.id));
});
})
})
//#endregion
//#region 定時計畫列表 DataTable
OperationPlanTable = $("#OperationPlan_table").DataTable({
"pageLength": 20,
@ -356,7 +360,8 @@
"url": "/Operation/OperationPlanTable",
"type": "POST",
"data": function (d) {
d.id = [1, 2],
/* d.id = powerids,*/
d.id = [1],
d.type = type
},
"dataSrc": function (rel) {
@ -373,38 +378,128 @@
}
});
//#endregion
var Nurl = "/PowerStation/GetSolarCitySummary";
var ids = new Array(0);
$.post(Nurl, function (rel)
{
})
//#region 縣市全選
function Allcity()
{
var Newpowerids = new Array(0);
ids = [];
$.each(Allids, function (index, val) {
var cityid = 'cityID_' + val;
document.getElementById(cityid).setAttribute("class", 'btn btn-success waves-effect waves-themed ml-2');
ids.push(val);
});
alert(ids + "..........." + powerids);
var send_data = {
cityid: ids
}
var Nurl = "/PowerStation/GetSolarByCity";
$.post(Nurl, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
$('#CheckPowerStation').empty();
Allpowerids = [];
$.each(rel.data, function (index, val) {
ids.push(val.cityId);
$('#citytest').find('button').attr('id', 'cityID' + val.cityId).clone().appendTo($('#city'));
var name = 'cityID' + val.cityId;
document.getElementById(name).innerHTML = val.city;
/* $('#cityID1').text = val.city;*/
$('#cityID' + val.cityId).find('#acount').text(val.amount);
document.getElementById('cityspan' + String(val.cityId)).innerHTML = val.amount;
if (powerids.includes(String(val.id))) {
$('#CheckPowerStation').append("<div class='custom-control custom-checkbox custom-control-inline' id='station_" + val.id + "' > ");
$('#station_' + val.id).append("<input type='checkbox' class='custom-control-input' id='check_" + val.id + "' checked>");
$('#station_' + val.id).append("<label class='custom-control-label' for='check_" + val.id + "'>" + val.name + "</label>");
Newpowerids.push(String(val.id));
}
else {
$('#CheckPowerStation').append("<div class='custom-control custom-checkbox custom-control-inline' id='station_" + val.id + "' > ");
$('#station_' + val.id).append("<input type='checkbox' class='custom-control-input' id='check_" + val.id + "'>");
$('#station_' + val.id).append("<label class='custom-control-label' for='check_" + val.id + "'>" + val.name + "</label>");
}
Allpowerids.push(String(val.id));
});
powerids = [];
powerids = Newpowerids;
})
//for (var i = 0; i < rel.data.length; i++)
//{
}
//#endregion
//#region 縣市全選
function Allpowerstation() {
powerids = [];
$.each(Allpowerids, function (index,val) {
$('#check_' + val).prop("checked", true);
powerids.push(val);
})
OperationPlanTable.ajax.reload();
}
//#endregion
// $('#city').append(h[i]);
// //$('#city').append("<button type='button' class='btn btn-outline-success waves-effect waves-themed ' style='margin - right: 40px;' >" +
// // rel.data[i].city +
// // "<span class= 'badge bg-success-700 ml-2' >" + rel.data[i].amount + "</span >" +
// // "</button >");
//}
//#region 選擇縣市
$('#city').on("click", "button", function () {
var clickid = $(this).attr('id');
var classid = clickid.split("_");
var Newpowerids = new Array(0);
var value = document.getElementById(clickid).className;
ids.sort(function (a, b) {
return a - b;
});
var send_data = {
cityid: ids
}
if (value == 'btn btn-outline-success waves-effect waves-themed ml-2') { //選擇
document.getElementById(clickid).setAttribute("class", 'btn btn-success waves-effect waves-themed ml-2');
ids.push(classid[1]);
}
else { //取消
document.getElementById(clickid).setAttribute("class", 'btn btn-outline-success waves-effect waves-themed ml-2');
ids.remove(classid[1]);
}
ids.sort();
var Nurl = "/PowerStation/GetSolarByCity";
$.post(Nurl, send_data, function (rel) {
if (rel.code != "0000") {
toast_error(rel.msg);
return;
}
$('#CheckPowerStation').empty();
Allpowerids = [];
$.each(rel.data, function (index, val) {
if (powerids.includes(String(val.id))) {
$('#CheckPowerStation').append("<div class='custom-control custom-checkbox custom-control-inline' id='station_" + val.id + "' > ");
$('#station_' + val.id).append("<input type='checkbox' class='custom-control-input' id='check_" + val.id + "' checked>");
$('#station_' + val.id).append("<label class='custom-control-label' for='check_" + val.id + "'>" + val.name + "</label>");
Newpowerids.push(String(val.id));
}
else
{
$('#CheckPowerStation').append("<div class='custom-control custom-checkbox custom-control-inline' id='station_" + val.id + "' > ");
$('#station_' + val.id).append("<input type='checkbox' class='custom-control-input' id='check_" + val.id + "'>");
$('#station_' + val.id).append("<label class='custom-control-label' for='check_" + val.id + "'>" + val.name + "</label>");
}
Allpowerids.push(String(val.id));
});
powerids = [];
powerids = Newpowerids;
})
})
//#endregion
//#region 選擇電站checkbox
$('#CheckPowerStation').on("click", "input", function () {
var clickid = $(this).attr('id');
var classid = clickid.split("_");
var job = document.getElementById(clickid);
if (job.checked == true) {
powerids.push(classid[1]); }
else
{
powerids.remove(classid[1]);
}
OperationPlanTable.ajax.reload();
})
//#endregion
//#region 更改項目
function ChangeType(Num) {
type = Num;
OperationPlanTable.ajax.reload();
@ -427,6 +522,7 @@
document.getElementById("button9").setAttribute("class", "btn btn-secondary waves-effect waves-themed");
}
}
//#endregion
//#region 新增計畫基本資料
function AddOperationPlan() {
@ -437,13 +533,41 @@
$("#Operation-modal").modal();
}
//#endregion
//#region 結束時間顯示
$('#operation_startTime_modal').change(function () {
var dat = new Date($('#operation_startTime_modal').val());
var day = new Date(dat.setDate(dat.getDate() + Number($('#operation_workDay_modal').val()))).toISOString().split("T");
var day = new Date(dat.setDate(dat.getDate() + Number($('#operation_workDay_modal').val()) - 1)).toISOString().split("T");
document.getElementById("operation_endTime_modal").innerHTML = day[0];
//var type = $('#operation_scheduleType_modal').val();
//if (type == '0') {
// var dat = new Date($('#operation_startTime_modal').val());
// var day = new Date(dat.setDate(dat.getDate() + Number($('#operation_workDay_modal').val()))).toISOString().split("T");
// document.getElementById("operation_endTime_modal").innerHTML = day[0];
//}
//else if (type == '1') {
// var dat = new Date($('#operation_startTime_modal').val());
// var day = new Date(dat.setDate(dat.getDate() + Number($('#operation_workDay_modal').val()) * 7 )).toISOString().split("T");
// document.getElementById("operation_endTime_modal").innerHTML = day[0];
//}
//else if (type == '2') {
// var dat = new Date($('#operation_startTime_modal').val());
// var day = new Date(dat.setMonth(dat.getMonth() + Number($('#operation_workDay_modal').val()))).toISOString().split("T");
// document.getElementById("operation_endTime_modal").innerHTML = day[0];
//}
//else if (type == '3') {
// var dat = new Date($('#operation_startTime_modal').val());
// var day = new Date(dat.setMonth(dat.getMonth() + Number($('#operation_workDay_modal').val()) * 3 )).toISOString().split("T");
// document.getElementById("operation_endTime_modal").innerHTML = day[0];
//}
//else if (type == '4') {
// var dat = new Date($('#operation_startTime_modal').val());
// var day = new Date(dat.setYear(dat.getYear() + Number($('#operation_workDay_modal').val()))).toISOString().split("T");
// document.getElementById("operation_endTime_modal").innerHTML = day[0];
//}
});
//#endregion
//#region 儲存定時計畫資料
function SaveOperationPlan() {
var url = "/Operation/SaveOperationPlan";
@ -472,6 +596,7 @@
}, 'json');
}
//#endregion
//#region 刪除定時計畫資料
$('#OperationPlan_table').on("click", "button.del-btn", function () {
@ -504,6 +629,7 @@
});
});
//#endregion
//#region 取一筆定時計畫
$('#OperationPlan_table').on("click", "button.edit-btn", function () {
$("#Operation-modal .modal-title").html("定時計劃 - 編輯");
@ -544,6 +670,7 @@
});
//#endregion
//#region 儲存Excel
function saveToExcel() {
var url = "/Operation/OperationPlanTable";
@ -590,6 +717,8 @@
}
//#endregion
</script>
}