Merge branch 'master' of https://github.com/shanghohui-Company/SolarPower
This commit is contained in:
commit
42e94fd43b
@ -121,6 +121,7 @@ namespace SolarPower.Models
|
||||
public int WorkType { get; set; }
|
||||
public string StartTime { get; set; }
|
||||
public string EndTime { get; set; }
|
||||
public string Notice { get; set; }
|
||||
}
|
||||
|
||||
public class OperationRecord : UserInfo
|
||||
|
||||
@ -185,6 +185,7 @@ namespace SolarPower.Models
|
||||
public double Temp { get; set; }
|
||||
public double DiffSOLARHOUR { get; set; }
|
||||
public string TOTALTIME { get; set; }
|
||||
public double KWHKWP { get; set; }
|
||||
}
|
||||
|
||||
public class ExceptionEmailInfo
|
||||
|
||||
@ -1,10 +1,13 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Quartz;
|
||||
using SolarPower.Models;
|
||||
using SolarPower.Repository.Interface;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -17,13 +20,15 @@ namespace SolarPower.Quartz.Jobs
|
||||
private readonly IOverviewRepository overviewRepository;
|
||||
private readonly INoticeScheduleRepository noticeScheduleRepository;
|
||||
private readonly IUserRepository userRepository;
|
||||
private readonly IPowerStationRepository powerStationRepository;
|
||||
|
||||
public ExceptionSchedule(ILogger<ExceptionSchedule> logger, IOverviewRepository overviewRepository,INoticeScheduleRepository noticeScheduleRepository,IUserRepository userRepository)
|
||||
public ExceptionSchedule(ILogger<ExceptionSchedule> logger, IOverviewRepository overviewRepository,INoticeScheduleRepository noticeScheduleRepository,IUserRepository userRepository,IPowerStationRepository powerStationRepository)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.overviewRepository = overviewRepository;
|
||||
this.noticeScheduleRepository = noticeScheduleRepository;
|
||||
this.userRepository = userRepository;
|
||||
this.powerStationRepository = powerStationRepository;
|
||||
}
|
||||
|
||||
public async Task Execute(IJobExecutionContext context)
|
||||
@ -71,6 +76,12 @@ namespace SolarPower.Quartz.Jobs
|
||||
"ExceptionId"
|
||||
};
|
||||
await noticeScheduleRepository.AddOneAsync(DaySchedule, properties);
|
||||
|
||||
var powerstation = await powerStationRepository.GetOneAsync(Exception.PowerStationId);
|
||||
if(powerstation.line_token != null)
|
||||
{
|
||||
CallLineToken(Content, powerstation.line_token);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -80,5 +91,33 @@ namespace SolarPower.Quartz.Jobs
|
||||
logger.LogError("【{0}】{1}", nameof(logger), exception.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public string CallLineToken(string message, string LineToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
HttpWebRequest Postrequest = (HttpWebRequest)WebRequest.Create("https://notify-api.line.me/api/notify?message=" + message);
|
||||
Postrequest.Method = "POST";
|
||||
Postrequest.Headers.Add("Authorization", "Bearer " + LineToken);
|
||||
Postrequest.PreAuthenticate = true;
|
||||
HttpWebResponse response = (HttpWebResponse)Postrequest.GetResponse();
|
||||
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
|
||||
var final = JObject.Parse(responseString);
|
||||
var get = final["status"].ToString();
|
||||
if (get != "200")
|
||||
{
|
||||
logger.LogError("CallLineToken發送Line接收失敗");
|
||||
//Logger.LogError("【" + controllerName + "/" + actionName + "】" + "CallLineToken發送Line接收失敗");
|
||||
}
|
||||
return get;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError("【{0}】CallLineToken: {1}", nameof(logger), ex.Message);
|
||||
//Logger.LogError("【" + controllerName + "/" + actionName + "】" + "CallLineToken:" + ex);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -105,7 +105,8 @@ namespace SolarPower.Quartz.Jobs
|
||||
PowerStationId = a.PowerStationId,
|
||||
StartTime = a.StartTime,
|
||||
CreatedBy = a.CreatedBy,
|
||||
EndTime = endtime
|
||||
EndTime = endtime,
|
||||
Notice = a.Description
|
||||
};
|
||||
List<string> properties2 = new List<string>()
|
||||
{
|
||||
@ -113,7 +114,8 @@ namespace SolarPower.Quartz.Jobs
|
||||
"PowerStationId",
|
||||
"StartTime",
|
||||
"CreatedBy",
|
||||
"EndTime"
|
||||
"EndTime",
|
||||
"Notice"
|
||||
};
|
||||
|
||||
await operationRepository.AddToRecord(record, properties2);
|
||||
|
||||
@ -634,7 +634,7 @@ namespace SolarPower.Repository.Implement
|
||||
(
|
||||
SELECT DENSE_RANK() OVER(ORDER BY C.TIMESTAMP) AS ROWID
|
||||
, (DENSE_RANK() OVER(ORDER BY C.TIMESTAMP)) - 1 AS PreROWID,
|
||||
C.TIMESTAMP,{kwh} AS KWH,C.SOLARHOUR,C.PR,P.Irradiance,P.Temperature AS Temp
|
||||
C.TIMESTAMP,{kwh} AS KWH,C.SOLARHOUR,C.PR,P.Irradiance,P.Temperature AS Temp ,C.KWHKWP
|
||||
FROM {usedb} C
|
||||
LEFT JOIN {pyrdb} P ON DATE_FORMAT(P.TIMESTAMP,'{timeGroup}') = DATE_FORMAT(C.TIMESTAMP,'{timeGroup}') AND P.PowerStationId = C.PowerStationId
|
||||
WHERE C.PowerStationId = {post.PowerstationId}{range2} GROUP BY C.TIMESTAMP ORDER BY C.TIMESTAMP
|
||||
|
||||
@ -214,7 +214,7 @@
|
||||
<div class="row mb-3">
|
||||
<div class="col-lg-12">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="notice_textarea_modal">巡檢注意事項</label>
|
||||
<label class="form-label" for="notice_textarea_modal">項目內容</label>
|
||||
<textarea class="form-control" id="notice_textarea_modal" rows="5"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
@ -684,6 +684,10 @@
|
||||
$("#record-form").trigger("reset");
|
||||
$("input[name=status_modal][value='" + 0 + "']").prop('checked', true); //狀態
|
||||
$("#record_files_div > .row").empty();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$("#record-form-modal").modal();
|
||||
}
|
||||
@ -1011,6 +1015,9 @@
|
||||
CreateRecordFileBox(RecordFileBox, value, true);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
$("#record-form-modal").modal();
|
||||
}, 'json');
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user