合併衝突
This commit is contained in:
commit
6174a0d452
@ -71,41 +71,98 @@ namespace SolarPower.Controllers
|
|||||||
ApiResult<string> apiResult = new ApiResult<string>();
|
ApiResult<string> apiResult = new ApiResult<string>();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var now = DateTime.Now.ToString("yyyy-MM-dd");
|
|
||||||
var finalid = await operationRepository.GetCurrentSerialNumber("operation_plan_create", $"PowerStationId = {post.PowerStationId} AND CreatedAt LIKE '%{now}%'");
|
|
||||||
var newSerialNumber = GetLastSerialNumber(finalid);
|
|
||||||
var OperationPlan = new OperationCreatePlan()
|
|
||||||
{
|
|
||||||
EmailType = post.EmailType,
|
|
||||||
ScheduleNum = post.ScheduleNum,
|
|
||||||
Description = post.Description,
|
|
||||||
WorkDay = post.WorkDay,
|
|
||||||
ScheduleType = post.ScheduleType,
|
|
||||||
SerialNumber = newSerialNumber,
|
|
||||||
StartTime = post.StartTime,
|
|
||||||
PowerStationId = post.PowerStationId,
|
|
||||||
Type = post.Type,
|
|
||||||
PlanId = DateTime.Now.ToString("yyyyMMdd") + newSerialNumber,
|
|
||||||
CreatedBy = myUser.Id
|
|
||||||
};
|
|
||||||
List<string> properties = new List<string>()
|
|
||||||
{
|
|
||||||
"EmailType",
|
|
||||||
"ScheduleNum",
|
|
||||||
"Description",
|
|
||||||
"WorkDay",
|
|
||||||
"ScheduleType",
|
|
||||||
"SerialNumber",
|
|
||||||
"StartTime",
|
|
||||||
"PowerStationId",
|
|
||||||
"Type",
|
|
||||||
"PlanId",
|
|
||||||
"CreatedBy"
|
|
||||||
};
|
|
||||||
await operationRepository.AddOperationPlan(OperationPlan, properties);
|
|
||||||
|
|
||||||
apiResult.Code = "0000";
|
if (post.Id == 0)
|
||||||
apiResult.Msg = "新增成功";
|
{
|
||||||
|
var now = DateTime.Now.ToString("yyyy-MM-dd");
|
||||||
|
var finalid = await operationRepository.GetCurrentSerialNumber("operation_plan_create", $"PowerStationId = {post.PowerStationId} AND CreatedAt LIKE '%{now}%'");
|
||||||
|
var newSerialNumber = GetLastSerialNumber(finalid);
|
||||||
|
var OperationPlan = new OperationCreatePlan()
|
||||||
|
{
|
||||||
|
EmailType = post.EmailType,
|
||||||
|
ScheduleNum = post.ScheduleNum,
|
||||||
|
Description = post.Description,
|
||||||
|
WorkDay = post.WorkDay,
|
||||||
|
ScheduleType = post.ScheduleType,
|
||||||
|
SerialNumber = newSerialNumber,
|
||||||
|
StartTime = post.StartTime,
|
||||||
|
PowerStationId = post.PowerStationId,
|
||||||
|
Type = post.Type,
|
||||||
|
PlanId = DateTime.Now.ToString("yyyyMMdd") + newSerialNumber,
|
||||||
|
CreatedBy = myUser.Id
|
||||||
|
};
|
||||||
|
List<string> properties = new List<string>()
|
||||||
|
{
|
||||||
|
"EmailType",
|
||||||
|
"ScheduleNum",
|
||||||
|
"Description",
|
||||||
|
"WorkDay",
|
||||||
|
"ScheduleType",
|
||||||
|
"SerialNumber",
|
||||||
|
"StartTime",
|
||||||
|
"PowerStationId",
|
||||||
|
"Type",
|
||||||
|
"PlanId",
|
||||||
|
"CreatedBy"
|
||||||
|
};
|
||||||
|
await operationRepository.AddOperationPlan(OperationPlan, properties);
|
||||||
|
|
||||||
|
var record = new PlanToRecord()
|
||||||
|
{
|
||||||
|
WorkType = post.Type,
|
||||||
|
PowerStationId = post.PowerStationId,
|
||||||
|
StartTime = post.StartTime,
|
||||||
|
CreatedBy = myUser.Id,
|
||||||
|
EndTime = post.EndTime
|
||||||
|
};
|
||||||
|
List<string> properties2 = new List<string>()
|
||||||
|
{
|
||||||
|
"WorkType",
|
||||||
|
"PowerStationId",
|
||||||
|
"StartTime",
|
||||||
|
"CreatedBy",
|
||||||
|
"EndTime"
|
||||||
|
};
|
||||||
|
await operationRepository.AddToRecord(record, properties2);
|
||||||
|
|
||||||
|
apiResult.Code = "0000";
|
||||||
|
apiResult.Msg = "新增成功";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var OperationPlan = new OperationCreatePlan()
|
||||||
|
{
|
||||||
|
Id = post.Id,
|
||||||
|
EmailType = post.EmailType,
|
||||||
|
ScheduleNum = post.ScheduleNum,
|
||||||
|
Description = post.Description,
|
||||||
|
WorkDay = post.WorkDay,
|
||||||
|
ScheduleType = post.ScheduleType,
|
||||||
|
StartTime = post.StartTime,
|
||||||
|
PowerStationId = post.PowerStationId,
|
||||||
|
Type = post.Type,
|
||||||
|
UpdatedBy = myUser.Id
|
||||||
|
};
|
||||||
|
List<string> properties = new List<string>()
|
||||||
|
{
|
||||||
|
"Id",
|
||||||
|
"EmailType",
|
||||||
|
"ScheduleNum",
|
||||||
|
"Description",
|
||||||
|
"WorkDay",
|
||||||
|
"ScheduleType",
|
||||||
|
"StartTime",
|
||||||
|
"PowerStationId",
|
||||||
|
"Type",
|
||||||
|
"UpdatedBy"
|
||||||
|
};
|
||||||
|
await operationRepository.UpdateOperationPlan(OperationPlan, properties);
|
||||||
|
apiResult.Code = "0000";
|
||||||
|
apiResult.Msg = "編輯成功";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
@ -162,7 +219,7 @@ namespace SolarPower.Controllers
|
|||||||
a.Schedule = "每" + a.ScheduleNum.ToString() + "年";
|
a.Schedule = "每" + a.ScheduleNum.ToString() + "年";
|
||||||
}
|
}
|
||||||
|
|
||||||
a.StartTimeString = a.StartTime.ToString("yyyy-MM-dd");
|
a.StartTimeString = a.StartTime;
|
||||||
var crst = a.CreatedAt.Split(" ");
|
var crst = a.CreatedAt.Split(" ");
|
||||||
a.CreateTimeString = crst[0];
|
a.CreateTimeString = crst[0];
|
||||||
|
|
||||||
@ -239,6 +296,25 @@ namespace SolarPower.Controllers
|
|||||||
return apiResult;
|
return apiResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<ApiResult<OperationCreatePlan>> GetOneOperationPlan(int Id)
|
||||||
|
{
|
||||||
|
ApiResult<OperationCreatePlan> apiResult = new ApiResult<OperationCreatePlan>();
|
||||||
|
OperationCreatePlan operationCreatePlan = new OperationCreatePlan();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
apiResult.Code = "0000";
|
||||||
|
operationCreatePlan = await operationRepository.GetOneOperation(Id);
|
||||||
|
apiResult.Data = operationCreatePlan;
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
apiResult.Code = "9999";
|
||||||
|
apiResult.Msg = exception.ToString();
|
||||||
|
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Id=" + Id);
|
||||||
|
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||||
|
}
|
||||||
|
return apiResult;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 運維作業記錄列表
|
/// 運維作業記錄列表
|
||||||
|
|||||||
@ -1840,6 +1840,51 @@ namespace SolarPower.Controllers
|
|||||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return apiResult;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 取得該使用者可看的所有電站分佈縣市以及各縣市電站數量
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<ApiResult<List<SolarCityAmount>>> GetSolarCitySummary()
|
||||||
|
{
|
||||||
|
ApiResult<List<SolarCityAmount>> apiResult = new ApiResult<List<SolarCityAmount>>();
|
||||||
|
List<SolarCityAmount> solaramount = new List<SolarCityAmount>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
apiResult.Code = "0000";
|
||||||
|
solaramount = await powerStationRepository.GetSolarCitySummary(myUser);
|
||||||
|
apiResult.Data = solaramount;
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
apiResult.Code = "9999";
|
||||||
|
apiResult.Msg = exception.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 取得該使用者可看的所有電站分佈縣市以及各縣市電站數量
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<ApiResult<List<PowerStation>>> GetSolarByCity(List<int> cityid)
|
||||||
|
{
|
||||||
|
ApiResult<List<PowerStation>> apiResult = new ApiResult<List<PowerStation>>();
|
||||||
|
List<PowerStation> solaramount = new List<PowerStation>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
apiResult.Code = "0000";
|
||||||
|
solaramount = await powerStationRepository.GetSolarByCity(myUser, cityid);
|
||||||
|
apiResult.Data = solaramount;
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
apiResult.Code = "9999";
|
||||||
|
apiResult.Msg = exception.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
return apiResult;
|
return apiResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,14 +28,43 @@ namespace SolarPower.Models
|
|||||||
}
|
}
|
||||||
public class OperationCreatePlanModal : Created
|
public class OperationCreatePlanModal : Created
|
||||||
{
|
{
|
||||||
|
private string startTime = "", endTime = "";
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public int PowerStationId { get; set; }
|
public int PowerStationId { get; set; }
|
||||||
public int Type { get; set; }
|
public int Type { get; set; }
|
||||||
public int ScheduleNum { get; set; }
|
public int ScheduleNum { get; set; }
|
||||||
public int ScheduleType { get; set; }
|
public int ScheduleType { get; set; }
|
||||||
public int WorkDay { get; set; }
|
public int WorkDay { get; set; }
|
||||||
public DateTime StartTime { get; set; }
|
public string StartTime
|
||||||
public DateTime EndTime { get; set; }
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(startTime))
|
||||||
|
{
|
||||||
|
return Convert.ToDateTime(startTime).ToString("yyyy-MM-dd");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set { startTime = value; }
|
||||||
|
}
|
||||||
|
public string EndTime
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(endTime))
|
||||||
|
{
|
||||||
|
return Convert.ToDateTime(endTime).ToString("yyyy-MM-dd");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set { endTime = value; }
|
||||||
|
}
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
public int EmailType { get; set; }
|
public int EmailType { get; set; }
|
||||||
}
|
}
|
||||||
@ -43,6 +72,10 @@ namespace SolarPower.Models
|
|||||||
{
|
{
|
||||||
public string PlanId { get; set; }
|
public string PlanId { get; set; }
|
||||||
public string SerialNumber { get; set; }
|
public string SerialNumber { get; set; }
|
||||||
|
|
||||||
|
private string updatedAt;
|
||||||
|
public int UpdatedBy { get; set; } //修改者
|
||||||
|
public string UpdatedAt { get { return Convert.ToDateTime(updatedAt).ToString("yyyy-MM-dd HH:mm:ss"); } set { updatedAt = value; } } //修改時間
|
||||||
}
|
}
|
||||||
public class OperationPlanTable : OperationCreatePlan
|
public class OperationPlanTable : OperationCreatePlan
|
||||||
{
|
{
|
||||||
@ -57,6 +90,14 @@ namespace SolarPower.Models
|
|||||||
public string CreateTimeString { get; set; }
|
public string CreateTimeString { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class PlanToRecord : Created
|
||||||
|
{
|
||||||
|
public int PowerStationId { get; set; }
|
||||||
|
public int WorkType { get; set; }
|
||||||
|
public string StartTime { get; set; }
|
||||||
|
public string EndTime { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 運維作業記錄的搜尋條件
|
/// 運維作業記錄的搜尋條件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -77,7 +118,8 @@ namespace SolarPower.Models
|
|||||||
public string PowerStationName { get; set; } //電站名稱
|
public string PowerStationName { get; set; } //電站名稱
|
||||||
public string FormId { get; set; } //表單號
|
public string FormId { get; set; } //表單號
|
||||||
public byte WorkType { get; set; } //工作項目
|
public byte WorkType { get; set; } //工作項目
|
||||||
public string WorkTypeText {
|
public string WorkTypeText
|
||||||
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
Dictionary<int, string> pairs = new Dictionary<int, string>()
|
Dictionary<int, string> pairs = new Dictionary<int, string>()
|
||||||
@ -92,7 +134,8 @@ namespace SolarPower.Models
|
|||||||
} //工作項目名稱
|
} //工作項目名稱
|
||||||
public string FixDo { get; set; } //維修項目
|
public string FixDo { get; set; } //維修項目
|
||||||
public byte Status { get; set; } //狀態
|
public byte Status { get; set; } //狀態
|
||||||
public string StatusText {
|
public string StatusText
|
||||||
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
Dictionary<int, string> pairs = new Dictionary<int, string>()
|
Dictionary<int, string> pairs = new Dictionary<int, string>()
|
||||||
@ -107,7 +150,8 @@ namespace SolarPower.Models
|
|||||||
}
|
}
|
||||||
} //狀態名稱
|
} //狀態名稱
|
||||||
public string WorkPersonName { get; set; } //處理人員
|
public string WorkPersonName { get; set; } //處理人員
|
||||||
public string StartTime {
|
public string StartTime
|
||||||
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(startTime))
|
if (!string.IsNullOrEmpty(startTime))
|
||||||
@ -121,7 +165,8 @@ namespace SolarPower.Models
|
|||||||
}
|
}
|
||||||
set { startTime = value; }
|
set { startTime = value; }
|
||||||
} //開始時間
|
} //開始時間
|
||||||
public string EndTime {
|
public string EndTime
|
||||||
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(endTime))
|
if (!string.IsNullOrEmpty(endTime))
|
||||||
@ -135,7 +180,8 @@ namespace SolarPower.Models
|
|||||||
}
|
}
|
||||||
set { endTime = value; }
|
set { endTime = value; }
|
||||||
} // 結束時間
|
} // 結束時間
|
||||||
public string OperationPredict {
|
public string OperationPredict
|
||||||
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return StartTime + " ~ " + EndTime;
|
return StartTime + " ~ " + EndTime;
|
||||||
|
|||||||
@ -457,4 +457,14 @@ namespace SolarPower.Models.PowerStation
|
|||||||
public string Image { get; set; }
|
public string Image { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 電站縣市分佈
|
||||||
|
/// </summary>
|
||||||
|
public class SolarCityAmount
|
||||||
|
{
|
||||||
|
public int CityId { get; set; }
|
||||||
|
public string City { get; set; }
|
||||||
|
public int Amount { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -80,7 +80,9 @@ namespace SolarPower.Repository.Implement
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var sql = @$"SELECT *,ps.Name AS PowerStationName ,us.Name AS CreatedPerson FROM operation_plan_create oc LEFT JOIN power_station ps
|
var sql = @$"SELECT oc.Id,oc.PlanId,oc.PowerStationId,oc.Type,
|
||||||
|
oc.ScheduleNum,oc.ScheduleType,oc.WorkDay,oc.StartTime,
|
||||||
|
oc.EmailType,oc.Description,oc.CreatedAt,ps.Name AS PowerStationName ,us.Name AS CreatedPerson FROM operation_plan_create oc LEFT JOIN power_station ps
|
||||||
ON oc.PowerStationId = ps.Id LEFT JOIN user us
|
ON oc.PowerStationId = ps.Id LEFT JOIN user us
|
||||||
ON us.Id = oc.CreatedBy WHERE {Wheresql} AND oc.Deleted = 0";
|
ON us.Id = oc.CreatedBy WHERE {Wheresql} AND oc.Deleted = 0";
|
||||||
result = (await conn.QueryAsync<OperationPlanTable>(sql)).ToList();
|
result = (await conn.QueryAsync<OperationPlanTable>(sql)).ToList();
|
||||||
@ -117,6 +119,57 @@ namespace SolarPower.Repository.Implement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task UpdateOperationPlan(OperationCreatePlan OperationPlan, List<string> properties)
|
||||||
|
{
|
||||||
|
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||||
|
{
|
||||||
|
conn.Open();
|
||||||
|
var trans = conn.BeginTransaction();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var sql = GenerateUpdateQuery(properties);
|
||||||
|
await conn.ExecuteAsync(sql, OperationPlan, trans);
|
||||||
|
|
||||||
|
trans.Commit();
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
trans.Rollback();
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
conn.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task AddToRecord(PlanToRecord record, List<string> properties2)
|
||||||
|
{
|
||||||
|
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||||
|
{
|
||||||
|
conn.Open();
|
||||||
|
var trans = conn.BeginTransaction();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string sql = GenerateInsertQueryWithCustomTable(properties2, "operation_record");
|
||||||
|
await conn.ExecuteAsync(sql, record);
|
||||||
|
trans.Commit();
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
trans.Rollback();
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
conn.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 透過搜尋條件,查詢過濾後的運維作業記錄
|
/// 透過搜尋條件,查詢過濾後的運維作業記錄
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -10,6 +10,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
using SolarPower.Models;
|
||||||
|
|
||||||
namespace SolarPower.Repository.Implement
|
namespace SolarPower.Repository.Implement
|
||||||
{
|
{
|
||||||
@ -620,7 +621,7 @@ namespace SolarPower.Repository.Implement
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
string sql = @$"SELECT * FROM variable WHERE name = @name";
|
string sql = @$"SELECT * FROM variable WHERE name = @name";
|
||||||
var json = await conn.QueryFirstOrDefaultAsync<Variable>(sql, new { name = "Type" });
|
var json = await conn.QueryFirstOrDefaultAsync<SolarPower.Models.PowerStation.Variable>(sql, new { name = "Type" });
|
||||||
Root jsonfor = JsonSerializer.Deserialize<Root>(json.value);
|
Root jsonfor = JsonSerializer.Deserialize<Root>(json.value);
|
||||||
foreach (Models.PowerStation.Type a in jsonfor.Type)
|
foreach (Models.PowerStation.Type a in jsonfor.Type)
|
||||||
{
|
{
|
||||||
@ -1275,6 +1276,90 @@ namespace SolarPower.Repository.Implement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public async Task<List<SolarCityAmount>> GetSolarCitySummary(MyUser User)
|
||||||
|
{
|
||||||
|
using IDbConnection conn = _databaseHelper.GetConnection();
|
||||||
|
List<SolarCityAmount> solaramount = new List<SolarCityAmount>();
|
||||||
|
conn.Open();
|
||||||
|
var trans = conn.BeginTransaction();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (User.Role.Layer == 0 || User.Role.Layer == 1)
|
||||||
|
{
|
||||||
|
var sql = "SELECT city.Id AS CityId, city.Name AS City,COUNT(*) AS Amount FROM power_station LEFT JOIN city ON power_station.CityId = city.Id GROUP BY power_station.CityId";
|
||||||
|
solaramount = (await conn.QueryAsync<SolarCityAmount>(sql)).ToList();
|
||||||
|
trans.Commit();
|
||||||
|
}
|
||||||
|
else if (User.Role.Layer == 2)
|
||||||
|
{
|
||||||
|
var sql = "SELECT city.Id AS CityId, city.Name AS City,COUNT(*) AS Amount FROM power_station LEFT JOIN city ON power_station.CityId = city.Id WHERE CompanyId = @CompanyId GROUP BY power_station.CityId ORDER BY power_station.CityId ";
|
||||||
|
solaramount = (await conn.QueryAsync<SolarCityAmount>(sql, new { CompanyId = User.CompanyId })).ToList();
|
||||||
|
trans.Commit();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var sql = "SELECT city.Id AS CityId, city.Name AS City,COUNT(*) AS Amount FROM power_station LEFT JOIN city ON power_station.CityId = city.Id LEFT JOIN power_station_operation_personnel ON power_station.Id = power_station_operation_personnel.PowerStationId WHERE UserId = @UserId GROUP BY power_station.CityId ORDER BY power_station.CityId";
|
||||||
|
solaramount = (await conn.QueryAsync<SolarCityAmount>(sql, new { UserId = User.Id })).ToList();
|
||||||
|
trans.Commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
trans.Rollback();
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
conn.Close();
|
||||||
|
}
|
||||||
|
return solaramount;
|
||||||
|
}
|
||||||
|
public async Task<List<PowerStation>> GetSolarByCity(MyUser User, List<int> CityId)
|
||||||
|
{
|
||||||
|
using IDbConnection conn = _databaseHelper.GetConnection();
|
||||||
|
List<PowerStation> powerstation = new List<PowerStation>();
|
||||||
|
conn.Open();
|
||||||
|
var trans = conn.BeginTransaction();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var ids = "";
|
||||||
|
foreach(var id in CityId)
|
||||||
|
{
|
||||||
|
ids = ids + id + ",";
|
||||||
|
}
|
||||||
|
if (ids.Length != 0)
|
||||||
|
{
|
||||||
|
ids = ids.Substring(0, ids.Length - 1);
|
||||||
|
}
|
||||||
|
if (User.Role.Layer == 0 || User.Role.Layer == 1)
|
||||||
|
{
|
||||||
|
var sql = "SELECT * FROM power_station WHERE CityId IN(@Ids)";
|
||||||
|
powerstation = (await conn.QueryAsync<PowerStation>(sql, new { Ids = ids })).ToList();
|
||||||
|
trans.Commit();
|
||||||
|
}
|
||||||
|
else if (User.Role.Layer == 2)
|
||||||
|
{
|
||||||
|
var sql = "SELECT * FROM power_station WHERE CityId IN(@Ids) AND CompanyId=@CompanyId";
|
||||||
|
powerstation = (await conn.QueryAsync<PowerStation>(sql, new { Ids = ids ,CompanyId = User.CompanyId })).ToList();
|
||||||
|
trans.Commit();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var sql = "SELECT power_station.* FROM power_station LEFT JOIN power_station_operation_personnel ON power_station.Id = power_station_operation_personnel.PowerStationId WHERE CityId IN(@Ids) AND Userid = @UserId";
|
||||||
|
powerstation = (await conn.QueryAsync<PowerStation>(sql, new { UserId = User.Id })).ToList();
|
||||||
|
trans.Commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
trans.Rollback();
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
conn.Close();
|
||||||
|
}
|
||||||
|
return powerstation;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,6 +12,9 @@ namespace SolarPower.Repository.Interface
|
|||||||
Task AddOperationPlan(OperationCreatePlan OperationPlan, List<string> properties);
|
Task AddOperationPlan(OperationCreatePlan OperationPlan, List<string> properties);
|
||||||
Task<List<OperationPlanTable>> OperationPlanTable(List<int> id);
|
Task<List<OperationPlanTable>> OperationPlanTable(List<int> id);
|
||||||
Task<OperationCreatePlan> GetOneOperation(int id);
|
Task<OperationCreatePlan> GetOneOperation(int id);
|
||||||
|
Task UpdateOperationPlan(OperationCreatePlan OperationPlan, List<string> properties);
|
||||||
|
Task AddToRecord(PlanToRecord record, List<string> properties2);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 透過搜尋條件,查詢過濾後的運維作業記錄
|
/// 透過搜尋條件,查詢過濾後的運維作業記錄
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using SolarPower.Models.PowerStation;
|
using SolarPower.Models;
|
||||||
|
using SolarPower.Models.PowerStation;
|
||||||
using SolarPower.Models.User;
|
using SolarPower.Models.User;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -325,5 +326,20 @@ namespace SolarPower.Repository.Interface
|
|||||||
/// <param name="db_name"></param>
|
/// <param name="db_name"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task DeleteOnePowerStationSingleLine(int id, string db_name);
|
Task DeleteOnePowerStationSingleLine(int id, string db_name);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 取得電站分佈縣市以及數量
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="User"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<SolarCityAmount>> GetSolarCitySummary(MyUser User);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 透過縣市取得電站卡片資訊
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="User"></param>
|
||||||
|
/// <param name="CityId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<PowerStation>> GetSolarByCity(MyUser User, List<int> CityId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
@{
|
@{
|
||||||
ViewData["MainNum"] = "5";
|
ViewData["MainNum"] = "6";
|
||||||
ViewData["SubNum"] = "1";
|
ViewData["SubNum"] = "1";
|
||||||
ViewData["Title"] = "運維管理";
|
ViewData["Title"] = "運維管理";
|
||||||
}
|
}
|
||||||
@ -359,13 +359,14 @@
|
|||||||
var url = "/Operation/SaveOperationPlan";
|
var url = "/Operation/SaveOperationPlan";
|
||||||
|
|
||||||
var send_data = {
|
var send_data = {
|
||||||
|
id: selected_id,
|
||||||
PowerStationId: $("#operation_powerStationselect_modal").val(),
|
PowerStationId: $("#operation_powerStationselect_modal").val(),
|
||||||
Type: $("#operation_type_modal").val(),
|
Type: $("#operation_type_modal").val(),
|
||||||
ScheduleNum: $("#operation_scheduleNum_modal").val(),
|
ScheduleNum: $("#operation_scheduleNum_modal").val(),
|
||||||
ScheduleType: $("#operation_scheduleType_modal").val(),
|
ScheduleType: $("#operation_scheduleType_modal").val(),
|
||||||
WorkDay: $('#operation_workDay_modal').val(),
|
WorkDay: $('#operation_workDay_modal').val(),
|
||||||
StartTime: $("#operation_startTime_modal").val(),
|
StartTime: $("#operation_startTime_modal").val(),
|
||||||
EndTime: $("#operation_endTime_modal").val(),
|
EndTime: document.getElementById("operation_endTime_modal").innerHTML,
|
||||||
Description: $("#operation_description_modal").val(),
|
Description: $("#operation_description_modal").val(),
|
||||||
EmailType: $('#operation_emailType_modal').val()
|
EmailType: $('#operation_emailType_modal').val()
|
||||||
}
|
}
|
||||||
@ -413,6 +414,44 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
//#endregion
|
//#endregion
|
||||||
|
//#region 取一筆定時計畫
|
||||||
|
$('#OperationPlan_table').on("click", "button.edit-btn", function () {
|
||||||
|
$("#Operation-modal .modal-title").html("定時計劃 - 編輯");
|
||||||
|
|
||||||
|
selected_id = $(this).parents('tr').attr('data-id');
|
||||||
|
|
||||||
|
//取得單一異常設定資料
|
||||||
|
var url = "/Operation/GetOneOperationPlan/";
|
||||||
|
|
||||||
|
var send_data = {
|
||||||
|
id: selected_id
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$.post(url, send_data, function (rel) {
|
||||||
|
if (rel.code != "0000") {
|
||||||
|
toast_error(rel.msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#operation_powerStationselect_modal").val(rel.data.powerStationId);
|
||||||
|
$("#operation_type_modal").val(rel.data.type);
|
||||||
|
$("#operation_scheduleNum_modal").val(rel.data.scheduleNum);
|
||||||
|
$("#operation_scheduleType_modal").val(rel.data.scheduleType);
|
||||||
|
$("#operation_workDay_modal").val(rel.data.workDay);
|
||||||
|
var start = rel.data.startTime.split(' ');
|
||||||
|
$("#operation_startTime_modal").val(start[0]);
|
||||||
|
$("#operation_description_modal").val(rel.data.description);
|
||||||
|
$("#operation_emailType_modal").val(rel.data.emailType);
|
||||||
|
|
||||||
|
var dat = new Date(start);
|
||||||
|
var day = new Date(dat.setDate(dat.getDate() + Number(rel.data.workDay))).toISOString().split("T");
|
||||||
|
document.getElementById("operation_endTime_modal").innerHTML = day[0];
|
||||||
|
|
||||||
|
$("#Operation-modal").modal();
|
||||||
|
}, 'json');
|
||||||
|
|
||||||
|
});
|
||||||
|
//#endregion
|
||||||
</script>
|
</script>
|
||||||
}
|
}
|
||||||
@ -410,7 +410,49 @@
|
|||||||
$(function () {
|
$(function () {
|
||||||
|
|
||||||
var localurl = this.location.href;
|
var localurl = this.location.href;
|
||||||
//電站區域Tab要佳LI
|
|
||||||
|
//#region 電站區域Tab
|
||||||
|
|
||||||
|
|
||||||
|
//var url = "/PowerStation/GetSolarCitySummary";
|
||||||
|
//$.post(url, function (rel) {
|
||||||
|
// if (rel.code != "0000") {
|
||||||
|
// toast_error(rel.msg);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// $.each(rel.data, function (index, val) {
|
||||||
|
// alert(val.city + val.amount);
|
||||||
|
// });
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
//}, 'json');
|
||||||
|
|
||||||
|
var url = "/PowerStation/GetSolarByCity";
|
||||||
|
var ids = [1, 3];
|
||||||
|
var send_data = {
|
||||||
|
cityid: ids
|
||||||
|
}
|
||||||
|
$.post(url, send_data, function (rel) {
|
||||||
|
if (rel.code != "0000") {
|
||||||
|
toast_error(rel.msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$.each(rel.data, function (index, val) {
|
||||||
|
alert(val.name);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}, 'json');
|
||||||
|
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
//電站區域
|
||||||
$('#templateAreaTab').find('li').attr('id', 'AreaTabnewtaipei').clone().appendTo($('#areaTab'));
|
$('#templateAreaTab').find('li').attr('id', 'AreaTabnewtaipei').clone().appendTo($('#areaTab'));
|
||||||
$('#AreaTabnewtaipei').find('a').attr('href', '#tab-newtaipei');
|
$('#AreaTabnewtaipei').find('a').attr('href', '#tab-newtaipei');
|
||||||
$('#AreaTabnewtaipei').find('a').attr('class', 'nav-link fs-lg px-4');
|
$('#AreaTabnewtaipei').find('a').attr('class', 'nav-link fs-lg px-4');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user