1. 暫時遷入
This commit is contained in:
parent
c7a3fc3302
commit
c2c9df6f36
@ -2,6 +2,7 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SolarPower.Models;
|
||||
using SolarPower.Models.PowerStation;
|
||||
using SolarPower.Models.Role;
|
||||
using SolarPower.Repository.Interface;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -31,7 +32,7 @@ namespace SolarPower.Controllers
|
||||
try
|
||||
{
|
||||
var powerStations = new List<PowerStation>();
|
||||
if (IsPlatformLayer(myUser.Role.Layer))
|
||||
if (myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin)
|
||||
{
|
||||
powerStations = await powerStationRepository.GetAllAsync();
|
||||
}
|
||||
|
||||
@ -42,7 +42,8 @@ namespace SolarPower.Controllers
|
||||
try
|
||||
{
|
||||
|
||||
List<int> powerStationIds = await powerStationRepository.GetPowerStationIdsByUserRole(myUser);
|
||||
//List<int> powerStationIds = await powerStationRepository.GetPowerStationIdsByUserRole(myUser);
|
||||
List<int> powerStationIds = myUser.PowerStationSummaries.SelectMany(x => x.MyPowerStations.Select(y=> y.PowerStationId)).ToList();
|
||||
var overview = await overviewRepository.GetOverviewByPowerStationIds(powerStationIds);
|
||||
mapOverview.Today_kwh = overview.Today_kwh;
|
||||
mapOverview.Total_kwh = overview.Total_kwh;
|
||||
|
||||
@ -122,6 +122,7 @@ namespace SolarPower.Controllers
|
||||
|
||||
//取得當前使用者可以查看的電站
|
||||
var myPowerStationSummaries = powerStationRepository.GetMyPowerStationSummary(myUser);
|
||||
myUser.PowerStationSummaries = myPowerStationSummaries;
|
||||
ViewBag.myPowerStationSummaries = myPowerStationSummaries;
|
||||
|
||||
if (controllerName == "PowerStation" && actionName == "Edit")
|
||||
|
||||
@ -248,6 +248,29 @@ namespace SolarPower.Controllers
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ApiResult<List<FirmlSelectItemList>>> GetFirmSelectOptionList(int powerStationId)
|
||||
{
|
||||
ApiResult<List<FirmlSelectItemList>> apiResult = new ApiResult<List<FirmlSelectItemList>>();
|
||||
try
|
||||
{
|
||||
var powerStation = await powerStationRepository.GetOneAsync(powerStationId);
|
||||
|
||||
var firmSelectItemLists = await powerStationRepository.GetFimlSelectOptionListAsync(powerStationId, powerStation.SiteDB);
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = firmSelectItemLists;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取得單一電站基本資料
|
||||
/// </summary>
|
||||
|
||||
@ -51,6 +51,7 @@ namespace SolarPower.Models
|
||||
public string Email { get; set; }
|
||||
public MyCompany Company { get; set; } //公司資訊
|
||||
public MyRole Role { get; set; } //角色資訊
|
||||
public List<MyPowerStationSummary> PowerStationSummaries { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -559,6 +559,13 @@ namespace SolarPower.Models.PowerStation
|
||||
public string Text { get; set; }
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
||||
public class FirmlSelectItemList
|
||||
{
|
||||
public string Text { get; set; }
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 控制器
|
||||
/// </summary>
|
||||
|
||||
@ -36,11 +36,11 @@ namespace SolarPower.Repository.Implement
|
||||
FROM power_station ps
|
||||
LEFT JOIN city c ON ps.CityId = c.Id";
|
||||
|
||||
if (myUser.Role.Layer == 2)
|
||||
if (myUser.Role.Layer == (int)RoleLayerEnum.CompanyAdmin)
|
||||
{ //公司管理員
|
||||
sql += @" WHERE ps.Deleted = 0 AND ps.CompanyId = @CompanyId";
|
||||
}
|
||||
else if (myUser.Role.Layer == 3)
|
||||
else if (myUser.Role.Layer == (int)RoleLayerEnum.PlatformUser || myUser.Role.Layer == (int)RoleLayerEnum.CompanyUser)
|
||||
{
|
||||
sql += @" LEFT JOIN power_station_operation_personnel op ON ps.Id = op.PowerStationId
|
||||
WHERE ps.Deleted = 0 AND op.Deleted = 0 AND op.UserId = @UserId ";
|
||||
@ -1568,6 +1568,29 @@ namespace SolarPower.Repository.Implement
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<FirmlSelectItemList>> GetFirmlSelectOptionListAsync(int powerStationId)
|
||||
{
|
||||
List<FirmlSelectItemList> result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = @$"SELECT u.Id AS Value, u.Name AS Text
|
||||
FROM power_station_operation_personnel op
|
||||
LEFT JOIN user u ON op.UserId = u.Id
|
||||
WHERE op.Deleted = 0 AND op.PowerStationId = @PowerStationId";
|
||||
|
||||
result = (await conn.QueryAsync<OperationPersonnelSelectItemList>(sql, new { PowerStationId = powerStationId })).ToList();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增控制器
|
||||
/// </summary>
|
||||
|
||||
@ -34,6 +34,7 @@ namespace SolarPower.Repository.Interface
|
||||
Task<List<AreaSelectItemList>> GetAreaSelectOptionListAsync(int cityId);
|
||||
|
||||
Task<List<OperationPersonnelSelectItemList>> GetOperationPersonnelSelectOptionListAsync(int powerStationId);
|
||||
Task<List<FirmlSelectItemList>> GetFimlSelectOptionListAsync(int powerStationId, string siteDB);
|
||||
|
||||
/// <summary>
|
||||
/// 取得下拉式公司選單,須為Deleted: 0、Status: 1
|
||||
|
||||
@ -200,6 +200,14 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3 fix-div">
|
||||
<div class="col-lg-6">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="fix_firm_modal">負責廠商</label>
|
||||
<select></select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col-lg-12">
|
||||
@ -315,7 +323,7 @@
|
||||
ids.push(String(rel.data[i].cityId));
|
||||
Allids.push(String(rel.data[i].cityId));
|
||||
}
|
||||
$('#Allcity').trigger("click");
|
||||
|
||||
var send_data = {
|
||||
cityid: ids
|
||||
}
|
||||
@ -345,7 +353,9 @@
|
||||
//預設查詢第一個
|
||||
$("#power_station_select_modal").val($("#power_station_select_modal option:first").val()).trigger('change');
|
||||
|
||||
$('#Allcity').trigger("click");
|
||||
operationRecodeTable.ajax.reload();
|
||||
|
||||
})
|
||||
})
|
||||
//#endregion
|
||||
@ -378,6 +388,28 @@
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//查詢該電站的廠商
|
||||
var url_power_station_firm = "/PowerStation/GetFirmSelectOptionList";
|
||||
|
||||
$.post(url_power_station_firm, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
$("#work_person_select_modal").empty();
|
||||
if (rel.data.length > 0) {
|
||||
|
||||
$.each(rel.data, function (index, val) {
|
||||
$("#work_person_select_modal").append($("<option />").val(val.value).text(val.text));
|
||||
});
|
||||
|
||||
if (recode != null || recode != undefined) {
|
||||
$("#work_person_select_modal").val(recode.workPersonId);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
//#endregion
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user