修改電站管理 - 上傳圖片
This commit is contained in:
parent
eaf6a4e9c6
commit
35f92baf93
@ -48,7 +48,7 @@ namespace SolarPower.Controllers
|
||||
{
|
||||
var companySelectItemLists = new List<CompanySelectItemList>();
|
||||
|
||||
if (myUser.IsGod != 1 && !IsPlatformLayer(myUser.Role.Layer))
|
||||
if (!IsPlatformLayer(myUser.Role.Layer))
|
||||
{
|
||||
companySelectItemLists = await companyRepository.GetCompanySelectOptionListAsync(myUser.CompanyId);
|
||||
}
|
||||
@ -88,7 +88,7 @@ namespace SolarPower.Controllers
|
||||
try
|
||||
{
|
||||
|
||||
if (myUser.IsGod != 1 && !IsPlatformLayer(myUser.Role.Layer))
|
||||
if (!IsPlatformLayer(myUser.Role.Layer))
|
||||
{ //如果只是身分公司管理員 或 公司使用者,就只能看自己公司的資料
|
||||
post.SelectedCompanyId = myUser.CompanyId;
|
||||
}
|
||||
@ -112,8 +112,8 @@ namespace SolarPower.Controllers
|
||||
|
||||
company.RegisterRatio = registerNumber.ToString() + " / " + company.RegisterUpperLimit.ToString();
|
||||
|
||||
if (myUser.IsGod == 1 || IsPlatformLayer(myUser.Role.Layer))
|
||||
{ //只有超級使用者 及 平台 可以使用
|
||||
if (IsPlatformLayer(myUser.Role.Layer))
|
||||
{ //平台 可以使用
|
||||
if(company.Id == 1)
|
||||
{ //平台公司不能被刪
|
||||
company.Function = @"
|
||||
@ -183,7 +183,7 @@ namespace SolarPower.Controllers
|
||||
}
|
||||
else if (company.Id != myUser.CompanyId)
|
||||
{
|
||||
if (myUser.IsGod != 0 && !IsPlatformLayer(myUser.Role.Layer))
|
||||
if (!IsPlatformLayer(myUser.Role.Layer))
|
||||
{
|
||||
apiResult.Code = "9993";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
@ -273,7 +273,7 @@ namespace SolarPower.Controllers
|
||||
"CreatedBy",
|
||||
};
|
||||
|
||||
if (myUser.IsGod == 1 || IsPlatformLayer(myUser.Role.Layer))
|
||||
if (IsPlatformLayer(myUser.Role.Layer))
|
||||
{ //超級使用者 或 平台人員可以修改 公司的註冊上限人數
|
||||
properties.Add("RegisterUpperLimit");
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ namespace SolarPower.Controllers
|
||||
myUser.Role = roleRepository.GetMyRoleInfoById(myUser.RoleId);
|
||||
|
||||
List<string> auth_arr = new List<string>();
|
||||
if (myUser.IsGod != 1 || myUser.Role.Layer != 0) //判斷是否神級使用者或平台管理員
|
||||
if (myUser.Role.Layer != 0) //判斷是否平台管理員
|
||||
{
|
||||
foreach (var auth in myUser.Role.Auths)
|
||||
{
|
||||
|
||||
@ -20,6 +20,7 @@ namespace SolarPower.Controllers
|
||||
private readonly IUserRepository userRepository;
|
||||
private readonly IPowerStationRepository powerStationRepository;
|
||||
private string boeFilePath = "/upload/power_station/boe_file/";
|
||||
private string stationImageFilePath = "/upload/power_station/";
|
||||
private string powerSationSaveAsPath = "";
|
||||
|
||||
public PowerStationController(
|
||||
@ -309,6 +310,33 @@ namespace SolarPower.Controllers
|
||||
await powerStationRepository.AddOneLandBuildingInfo(landBuilding, landBuildingProperties);
|
||||
#endregion
|
||||
|
||||
#region 新增運維人員
|
||||
//找出要新增的
|
||||
if (post.OperationPersonnelIds != null)
|
||||
{
|
||||
List<PowerStationOperationPersonnel> insertOperationPersonnels = new List<PowerStationOperationPersonnel>();
|
||||
|
||||
foreach (var op in post.OperationPersonnelIds)
|
||||
{
|
||||
PowerStationOperationPersonnel operationPersonnel = new PowerStationOperationPersonnel();
|
||||
operationPersonnel.PowerStationId = id;
|
||||
operationPersonnel.UserId = op;
|
||||
operationPersonnel.CreatedBy = myUser.Id;
|
||||
|
||||
insertOperationPersonnels.Add(operationPersonnel);
|
||||
}
|
||||
|
||||
List<string> operationPersonnelProperties = new List<string>()
|
||||
{
|
||||
"PowerStationId",
|
||||
"UserId",
|
||||
"CreatedBy",
|
||||
};
|
||||
|
||||
await powerStationRepository.AddOperationPersonnelAsync(insertOperationPersonnels, properties);
|
||||
}
|
||||
#endregion
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "儲存成功";
|
||||
apiResult.Data = await powerStationRepository.GetOneAsync(id);
|
||||
@ -375,6 +403,59 @@ namespace SolarPower.Controllers
|
||||
|
||||
await powerStationRepository.UpdatePowerStationInfo(update, properties);
|
||||
|
||||
List<int> origOperationPersonnels = null; //原先的運維人員
|
||||
|
||||
origOperationPersonnels = await powerStationRepository.GetOperationPersonnelIdsByPowerStatioinId(powerStation.Id);
|
||||
|
||||
//判斷新進來的資料是否要歸類到新增 or 刪除
|
||||
#region 刪除電站運維人員編號
|
||||
|
||||
//找出要刪除的
|
||||
List<int> deleteOperationPersonnelIds = origOperationPersonnels.Where(x => !post.OperationPersonnelIds.Contains(x)).ToList();
|
||||
|
||||
List<PowerStationOperationPersonnel> deleteOperationPersonnels = new List<PowerStationOperationPersonnel>();
|
||||
foreach (var opId in deleteOperationPersonnelIds)
|
||||
{
|
||||
PowerStationOperationPersonnel operationPersonnel = new PowerStationOperationPersonnel();
|
||||
operationPersonnel.PowerStationId = powerStation.Id;
|
||||
operationPersonnel.UserId = opId;
|
||||
|
||||
deleteOperationPersonnels.Add(operationPersonnel);
|
||||
}
|
||||
|
||||
//刪除運維人員
|
||||
await powerStationRepository.DeleteOperationPersonnel(deleteOperationPersonnels);
|
||||
#endregion
|
||||
|
||||
#region 新增電站運維人員
|
||||
//找出要新增的
|
||||
if (post.OperationPersonnelIds != null)
|
||||
{
|
||||
List<int> insertOperationPersonnelIds = post.OperationPersonnelIds.Where(x => !origOperationPersonnels.Contains(x)).ToList();
|
||||
|
||||
List<PowerStationOperationPersonnel> insertOperationPersonnels = new List<PowerStationOperationPersonnel>();
|
||||
|
||||
foreach (var op in insertOperationPersonnelIds)
|
||||
{
|
||||
PowerStationOperationPersonnel operationPersonnel = new PowerStationOperationPersonnel();
|
||||
operationPersonnel.PowerStationId = powerStation.Id;
|
||||
operationPersonnel.UserId = op;
|
||||
operationPersonnel.CreatedBy = myUser.Id;
|
||||
|
||||
insertOperationPersonnels.Add(operationPersonnel);
|
||||
}
|
||||
|
||||
List<string> operationPersonnelProperties = new List<string>()
|
||||
{
|
||||
"PowerStationId",
|
||||
"UserId",
|
||||
"CreatedBy",
|
||||
};
|
||||
|
||||
await powerStationRepository.AddOperationPersonnelAsync(insertOperationPersonnels, operationPersonnelProperties);
|
||||
}
|
||||
#endregion
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "儲存成功";
|
||||
apiResult.Data = await powerStationRepository.GetOneAsync(powerStation.Id);
|
||||
@ -725,7 +806,7 @@ namespace SolarPower.Controllers
|
||||
{
|
||||
apiResult.Code = "0000";
|
||||
operationTable = await powerStationRepository.OperationTable(stationId);
|
||||
foreach(OperationTable a in operationTable)
|
||||
foreach (OperationTable a in operationTable)
|
||||
{
|
||||
a.Function = @"
|
||||
<button type='button' class='btn btn-primary btn-pills waves-effect waves-themed edit-btn'>修改</button>
|
||||
@ -734,7 +815,7 @@ namespace SolarPower.Controllers
|
||||
{
|
||||
a.TypeName = "施工";
|
||||
}
|
||||
else if(a.Type == 1)
|
||||
else if (a.Type == 1)
|
||||
{
|
||||
a.TypeName = "清洗";
|
||||
}
|
||||
@ -853,7 +934,7 @@ namespace SolarPower.Controllers
|
||||
Remark = Device.Remark,
|
||||
TableName = Device.TableName,
|
||||
Type = Device.Type,
|
||||
UID = powerStation.Code + "-" + Device.Type + "-" + tempSerialNumber.ToString().PadLeft(3,'0'),
|
||||
UID = powerStation.Code + "-" + Device.Type + "-" + tempSerialNumber.ToString().PadLeft(3, '0'),
|
||||
CreatedBy = myUser.Id,
|
||||
TypeName = Device.TypeName,
|
||||
SerialNumber = tempSerialNumber.ToString().PadLeft(3, '0')
|
||||
@ -875,7 +956,7 @@ namespace SolarPower.Controllers
|
||||
"TypeName",
|
||||
"SerialNumber"
|
||||
};
|
||||
await powerStationRepository.AddDevice(DeviceInfo,properties);
|
||||
await powerStationRepository.AddDevice(DeviceInfo, properties);
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "新增成功";
|
||||
@ -971,7 +1052,7 @@ namespace SolarPower.Controllers
|
||||
|
||||
if (landBuilding == null)
|
||||
{
|
||||
apiResult.Code = "9996";
|
||||
apiResult.Code = "9991";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
@ -1140,7 +1221,7 @@ namespace SolarPower.Controllers
|
||||
a.Function = @"
|
||||
<button type='button' class='btn btn-primary btn-pills waves-effect waves-themed edit-btn'>修改</button>
|
||||
<button type='button' class='btn btn-danger btn-pills waves-effect waves-themed del-btn'>刪除</button>";
|
||||
if(a.Type == 1)
|
||||
if (a.Type == 1)
|
||||
{
|
||||
a.TypeName = "PR值";
|
||||
}
|
||||
@ -1185,6 +1266,7 @@ namespace SolarPower.Controllers
|
||||
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 刪除一筆異常設定
|
||||
/// </summary>
|
||||
@ -1220,5 +1302,463 @@ namespace SolarPower.Controllers
|
||||
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 取得所有電站圖片
|
||||
/// </summary>
|
||||
/// <param name="powerStationId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult<List<PowerStationImage>>> GetAllPowerStationImage(int powerStationId)
|
||||
{
|
||||
ApiResult<List<PowerStationImage>> apiResult = new ApiResult<List<PowerStationImage>>();
|
||||
|
||||
List<PowerStationImage> powerStationImages = null;
|
||||
|
||||
try
|
||||
{
|
||||
var powerStation = await powerStationRepository.GetOneAsync(powerStationId);
|
||||
|
||||
if (powerStation == null)
|
||||
{
|
||||
apiResult.Code = "9992";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
else
|
||||
{
|
||||
powerStationImages = await powerStationRepository.GetAllPowerStationImageAsync(powerStationId);
|
||||
|
||||
foreach (var stationImage in powerStationImages)
|
||||
{
|
||||
stationImage.Image = Path.Combine(stationImageFilePath, powerStation.Id.ToString()) + "/" + stationImage.Image;
|
||||
}
|
||||
}
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = powerStationImages;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "PowerStationId=" + powerStationId);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增 電站圖片
|
||||
/// </summary>
|
||||
/// <param name="post"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult<List<PowerStationImage>>> SavePowerStationImages([FromForm] PostPowerStationImage post)
|
||||
{
|
||||
ApiResult<List<PowerStationImage>> apiResult = new ApiResult<List<PowerStationImage>>();
|
||||
|
||||
PowerStation powerStation = null;
|
||||
|
||||
try
|
||||
{
|
||||
powerStation = await powerStationRepository.GetOneAsync(post.PowerStationId);
|
||||
|
||||
if (powerStation == null)
|
||||
{
|
||||
apiResult.Code = "9992";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (powerStation.CompanyId != myUser.CompanyId)
|
||||
{
|
||||
apiResult.Code = "9993";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
#region 新增圖片
|
||||
List<PowerStationImage> powerStationImages;
|
||||
|
||||
if (post.StationImages != null && post.StationImages.Length > 0)
|
||||
{
|
||||
FolderFunction folderFunction = new FolderFunction();
|
||||
|
||||
var imageSaveAsPath = Path.Combine(powerSationSaveAsPath, powerStation.Id.ToString());
|
||||
|
||||
folderFunction.CreateFolder(imageSaveAsPath, 0);
|
||||
|
||||
powerStationImages = new List<PowerStationImage>();
|
||||
|
||||
foreach (var image in post.StationImages)
|
||||
{
|
||||
var split = image.FileName.Split(".");
|
||||
|
||||
var fileName = Guid.NewGuid() + "." + split[split.Length - 1];
|
||||
|
||||
var fullPath = Path.Combine(imageSaveAsPath, fileName);
|
||||
|
||||
using (var stream = new FileStream(fullPath, FileMode.Create))
|
||||
{
|
||||
image.CopyTo(stream);
|
||||
}
|
||||
|
||||
PowerStationImage powerStationImage = new PowerStationImage()
|
||||
{
|
||||
PowerStationId = powerStation.Id,
|
||||
Image = fileName,
|
||||
CreatedBy = myUser.Id
|
||||
};
|
||||
|
||||
powerStationImages.Add(powerStationImage);
|
||||
}
|
||||
|
||||
List<string> properties = new List<string>()
|
||||
{
|
||||
"PowerStationId",
|
||||
"Image",
|
||||
"CreatedBy"
|
||||
};
|
||||
|
||||
await powerStationRepository.AddPowerStationImageAsync(powerStationImages, properties);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 重新取得圖片資訊
|
||||
powerStationImages = null;
|
||||
powerStationImages = await powerStationRepository.GetAllPowerStationImageAsync(powerStation.Id);
|
||||
|
||||
foreach (var stationImage in powerStationImages)
|
||||
{
|
||||
stationImage.Image = Path.Combine(stationImageFilePath, powerStation.Id.ToString()) + "/" + stationImage.Image;
|
||||
}
|
||||
#endregion
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "儲存成功";
|
||||
apiResult.Data = powerStationImages;
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
string json = System.Text.Json.JsonSerializer.Serialize(post);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + json);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 軟刪除 單一電站圖片
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ApiResult<string>> DeletePowerStationImage(int id)
|
||||
{
|
||||
ApiResult<string> apiResult = new ApiResult<string>();
|
||||
|
||||
PowerStationImage powerStationImage;
|
||||
|
||||
try
|
||||
{
|
||||
powerStationImage = await powerStationRepository.GetOnePowerStationImageAsync(id);
|
||||
|
||||
if (powerStationImage == null)
|
||||
{
|
||||
apiResult.Code = "9990";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
await powerStationRepository.DeleteOnePowerStationImage(id);
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "刪除成功";
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Id=" + id);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 變更主要卡片顯示
|
||||
/// </summary>
|
||||
/// <param name="post"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ApiResult<string>> ChangeMainDisplay(PostChangeMainDisplay post)
|
||||
{
|
||||
ApiResult<string> apiResult = new ApiResult<string>();
|
||||
|
||||
PowerStationImage powerStationImage;
|
||||
|
||||
try
|
||||
{
|
||||
powerStationImage = await powerStationRepository.GetOnePowerStationImageAsync(post.TargetImageId);
|
||||
|
||||
if (powerStationImage == null)
|
||||
{
|
||||
apiResult.Code = "9990";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
UpdataPowerStationImage updata = new UpdataPowerStationImage();
|
||||
List<string> properties = new List<string>();
|
||||
|
||||
//找出原本的圖片
|
||||
var origMainDisplay = await powerStationRepository.GetMainDisplayAsync(post.PowerStationId);
|
||||
if (origMainDisplay != null)
|
||||
{
|
||||
updata = new UpdataPowerStationImage()
|
||||
{
|
||||
Id=origMainDisplay.Id,
|
||||
IsMainDisplay = 0,
|
||||
UpdatedBy = myUser.Id
|
||||
};
|
||||
|
||||
properties = new List<string>()
|
||||
{
|
||||
"Id",
|
||||
"IsMainDisplay",
|
||||
"UpdatedBy"
|
||||
};
|
||||
|
||||
await powerStationRepository.UpdatePowerStationImage(updata, properties);
|
||||
}
|
||||
|
||||
// 更新被選擇的圖維卡片顯示圖
|
||||
updata = new UpdataPowerStationImage()
|
||||
{
|
||||
Id = post.TargetImageId,
|
||||
IsMainDisplay = 1,
|
||||
UpdatedBy = myUser.Id
|
||||
};
|
||||
|
||||
properties = new List<string>()
|
||||
{
|
||||
"Id",
|
||||
"IsMainDisplay",
|
||||
"UpdatedBy"
|
||||
};
|
||||
|
||||
await powerStationRepository.UpdatePowerStationImage(updata, properties);
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "修改卡片顯示圖成功";
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
string json = System.Text.Json.JsonSerializer.Serialize(post);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + json);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 取得所有單線圖
|
||||
/// </summary>
|
||||
/// <param name="powerStationId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult<List<PowerStationSingleLine>>> GetAllPowerStationSingleLine(int powerStationId)
|
||||
{
|
||||
ApiResult<List<PowerStationSingleLine>> apiResult = new ApiResult<List<PowerStationSingleLine>>();
|
||||
|
||||
List<PowerStationSingleLine> powerStationSingleLines = null;
|
||||
|
||||
try
|
||||
{
|
||||
var powerStation = await powerStationRepository.GetOneAsync(powerStationId);
|
||||
|
||||
if (powerStation == null)
|
||||
{
|
||||
apiResult.Code = "9992";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
else
|
||||
{
|
||||
powerStationSingleLines = await powerStationRepository.GetAllPowerStationSingleLineAsync(powerStationId);
|
||||
|
||||
foreach (var singleLine in powerStationSingleLines)
|
||||
{
|
||||
singleLine.Image = Path.Combine(stationImageFilePath, powerStation.Id.ToString()) + "/" + singleLine.Image;
|
||||
}
|
||||
}
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Data = powerStationSingleLines;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "PowerStationId=" + powerStationId);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增 單線圖
|
||||
/// </summary>
|
||||
/// <param name="post"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ApiResult<List<PowerStationSingleLine>>> SavePowerStationSingleLine([FromForm] PostPowerStationSingleLine post)
|
||||
{
|
||||
ApiResult<List<PowerStationSingleLine>> apiResult = new ApiResult<List<PowerStationSingleLine>>();
|
||||
|
||||
PowerStation powerStation = null;
|
||||
|
||||
try
|
||||
{
|
||||
powerStation = await powerStationRepository.GetOneAsync(post.PowerStationId);
|
||||
|
||||
if (powerStation == null)
|
||||
{
|
||||
apiResult.Code = "9992";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (powerStation.CompanyId != myUser.CompanyId)
|
||||
{
|
||||
apiResult.Code = "9993";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
#region 新增圖片
|
||||
List<PowerStationSingleLine> powerStationSingleLines;
|
||||
|
||||
if (post.SingleLineImages != null && post.SingleLineImages.Length > 0)
|
||||
{
|
||||
FolderFunction folderFunction = new FolderFunction();
|
||||
|
||||
var imageSaveAsPath = Path.Combine(powerSationSaveAsPath, powerStation.Id.ToString());
|
||||
|
||||
folderFunction.CreateFolder(imageSaveAsPath, 0);
|
||||
|
||||
powerStationSingleLines = new List<PowerStationSingleLine>();
|
||||
|
||||
foreach (var image in post.SingleLineImages)
|
||||
{
|
||||
var split = image.FileName.Split(".");
|
||||
|
||||
var fileName = Guid.NewGuid() + "." + split[split.Length - 1];
|
||||
|
||||
var fullPath = Path.Combine(imageSaveAsPath, fileName);
|
||||
|
||||
using (var stream = new FileStream(fullPath, FileMode.Create))
|
||||
{
|
||||
image.CopyTo(stream);
|
||||
}
|
||||
|
||||
PowerStationSingleLine powerStationSingleLine = new PowerStationSingleLine()
|
||||
{
|
||||
PowerStationId = powerStation.Id,
|
||||
Image = fileName,
|
||||
CreatedBy = myUser.Id
|
||||
};
|
||||
|
||||
powerStationSingleLines.Add(powerStationSingleLine);
|
||||
}
|
||||
|
||||
List<string> properties = new List<string>()
|
||||
{
|
||||
"PowerStationId",
|
||||
"Image",
|
||||
"CreatedBy"
|
||||
};
|
||||
|
||||
await powerStationRepository.AddPowerStationSingleLineAsync(powerStationSingleLines, properties);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 重新取得圖片資訊
|
||||
powerStationSingleLines = null;
|
||||
powerStationSingleLines = await powerStationRepository.GetAllPowerStationSingleLineAsync(powerStation.Id);
|
||||
|
||||
foreach (var singleLine in powerStationSingleLines)
|
||||
{
|
||||
singleLine.Image = Path.Combine(stationImageFilePath, powerStation.Id.ToString()) + "/" + singleLine.Image;
|
||||
}
|
||||
#endregion
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "儲存成功";
|
||||
apiResult.Data = powerStationSingleLines;
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
string json = System.Text.Json.JsonSerializer.Serialize(post);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + json);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 軟刪除 單一單線圖
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ApiResult<string>> DeletePowerStationSingleLine(int id)
|
||||
{
|
||||
ApiResult<string> apiResult = new ApiResult<string>();
|
||||
|
||||
PowerStationSingleLine powerStationSingleLine;
|
||||
|
||||
try
|
||||
{
|
||||
powerStationSingleLine = await powerStationRepository.GetOnePowerStationSingleLineAsync(id);
|
||||
|
||||
if (powerStationSingleLine == null)
|
||||
{
|
||||
apiResult.Code = "9990";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
await powerStationRepository.DeleteOnePowerStationSingleLine(id);
|
||||
|
||||
apiResult.Code = "0000";
|
||||
apiResult.Msg = "刪除成功";
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
apiResult.Code = "9999";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + "Id=" + id);
|
||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||
}
|
||||
|
||||
return apiResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -170,8 +170,8 @@ namespace SolarPower.Controllers
|
||||
}
|
||||
|
||||
|
||||
if(myUser.IsGod != 1 && !IsPlatformLayer(myUser.Role.Layer) && myUser.CompanyId != post.SelectedCompanyId)
|
||||
{ //非超級使用者或平台人員,就只能新增自己公司的角色
|
||||
if(!IsPlatformLayer(myUser.Role.Layer) && myUser.CompanyId != post.SelectedCompanyId)
|
||||
{ //非平台人員,就只能新增自己公司的角色
|
||||
apiResult.Code = "9993";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
@ -212,8 +212,8 @@ namespace SolarPower.Controllers
|
||||
{
|
||||
#region 修改公司角色
|
||||
|
||||
if (myUser.IsGod != 1 && !IsPlatformLayer(myUser.Role.Layer) && myUser.CompanyId != post.SelectedCompanyId)
|
||||
{ //非超級使用者或平台人員,就只能修改自己公司的角色
|
||||
if (!IsPlatformLayer(myUser.Role.Layer) && myUser.CompanyId != post.SelectedCompanyId)
|
||||
{ //非平台人員,就只能修改自己公司的角色
|
||||
apiResult.Code = "9993";
|
||||
apiResult.Msg = errorCode.GetString(apiResult.Code);
|
||||
return apiResult;
|
||||
|
||||
@ -819,7 +819,8 @@ INSERT INTO `variable` (`id`, `name`, `value`, `remark`) VALUES
|
||||
/******************************
|
||||
** 後續SQL修改從以下開始新增 **
|
||||
*******************************/
|
||||
ALTER TABLE `device` ADD COLUMN `SerialNumber` VARCHAR(3) NULL DEFAULT NULL COMMENT '單一設備流水號' COLLATE 'utf8mb4_unicode_ci' AFTER `PowerStationId`;/* 設備流水號 - 2021/6/18 12:21:00 */
|
||||
-- 設備流水號 - 2021/6/18 12:21:00
|
||||
ALTER TABLE `device` ADD COLUMN `SerialNumber` VARCHAR(3) NULL DEFAULT NULL COMMENT '單一設備流水號' COLLATE 'utf8mb4_unicode_ci' AFTER `PowerStationId`;
|
||||
|
||||
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ namespace SolarPower.Helper
|
||||
var passwordStr = ed.DESDecrypt(dbConfig.Password);
|
||||
|
||||
//var connStr = $"server={serverStr};database={databaseStr};user={rootStr};password={passwordStr};charset=utf8;";
|
||||
var connStr = @"server=127.0.0.1;port=3308;database=solar_power;user=root;password=00000000;charset=utf8;";
|
||||
var connStr = @"server=127.0.0.1;database=solar_power;user=root;password=000000;charset=utf8;";
|
||||
|
||||
this._connectionString = connStr;
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@ namespace SolarPower.Models
|
||||
{
|
||||
{ "0000", "OK" },
|
||||
{ "0001", "傳入參數錯誤。" },
|
||||
{ "9990", "查無該圖片"},
|
||||
{ "9991", "查無該土地房屋資訊"},
|
||||
{ "9992", "查無該電站資訊"},
|
||||
{ "9993", "無此權限操作"},
|
||||
|
||||
@ -36,7 +36,6 @@ namespace SolarPower.Models
|
||||
public int Id { get; set; } //編號
|
||||
public byte Status { get; set; } //狀態
|
||||
public string Name { get; set; } //姓名
|
||||
public byte IsGod { get; set; } //神級使用者
|
||||
public int CompanyId { get; set; } //公司編號
|
||||
public int RoleId { get; set; } //角色編號
|
||||
public string Email { get; set; }
|
||||
|
||||
@ -38,6 +38,7 @@ namespace SolarPower.Models.PowerStation
|
||||
public int EstimatedRecoveryTime { get; set; } //預計回收年限
|
||||
public double GeneratingCapacity { get; set; } //發電容量
|
||||
public double PowerRate { get; set; } //授電費率
|
||||
public List<int> OperationPersonnelIds { get; set; } //運維人員編號
|
||||
public string Coordinate { get; set; } //座標
|
||||
public string InverterBrand { get; set; } //逆變器廠牌
|
||||
public string InverterProductModel { get; set; } //逆變器型號
|
||||
@ -134,6 +135,12 @@ namespace SolarPower.Models.PowerStation
|
||||
|
||||
}
|
||||
|
||||
public class PowerStationOperationPersonnel : Created
|
||||
{
|
||||
public int PowerStationId { get; set; }
|
||||
public int UserId { get; set; }
|
||||
}
|
||||
|
||||
public class PostPowerStationInfo
|
||||
{
|
||||
public int Id { get; set; }
|
||||
@ -149,6 +156,7 @@ namespace SolarPower.Models.PowerStation
|
||||
public double GeneratingCapacity { get; set; } //發電容量
|
||||
public double PowerRate { get; set; } //授電費率
|
||||
public string Coordinate { get; set; } //座標
|
||||
public List<int> OperationPersonnelIds { get; set; } //運維人員編號
|
||||
public string InverterBrand { get; set; } //逆變器廠牌
|
||||
public string InverterProductModel { get; set; } //逆變器型號
|
||||
public int InverterAmount { get; set; } //逆變器數量
|
||||
@ -279,16 +287,19 @@ namespace SolarPower.Models.PowerStation
|
||||
public string Phone { get; set; }//電話
|
||||
public string Email { get; set; }//Email
|
||||
}
|
||||
|
||||
public class OperationStationId
|
||||
{
|
||||
public int stationId { get; set; }
|
||||
}
|
||||
|
||||
public class OperationTable : OperationInfo
|
||||
{
|
||||
public string CreatedName { get; set; }//建立者名稱
|
||||
public string Function { get; set; }//功能
|
||||
public string TypeName { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 設備裝置下拉選單
|
||||
/// </summary>
|
||||
@ -297,10 +308,12 @@ namespace SolarPower.Models.PowerStation
|
||||
public string Name { get; set; }
|
||||
public string EName { get; set; }
|
||||
}
|
||||
|
||||
public class Root
|
||||
{
|
||||
public List<Type> Type { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 表Variable 取來解析
|
||||
/// </summary>
|
||||
@ -309,6 +322,7 @@ namespace SolarPower.Models.PowerStation
|
||||
public string name { get; set; }
|
||||
public string value { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 設備
|
||||
/// </summary>
|
||||
@ -326,12 +340,14 @@ namespace SolarPower.Models.PowerStation
|
||||
public string Remark { get; set; }
|
||||
public string TypeName { get; set; }//類型名稱
|
||||
}
|
||||
|
||||
public class Device : DeviceInfo
|
||||
{
|
||||
public string UID { get; set; }//設備編號
|
||||
public int CreatedBy { get; set; }//建立者
|
||||
public string SerialNumber { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///設備dataTable
|
||||
/// </summary>
|
||||
@ -340,6 +356,7 @@ namespace SolarPower.Models.PowerStation
|
||||
public string UID { get; set; }//設備編號
|
||||
public string Function { get; set; }//功能
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 異常modal
|
||||
/// </summary>
|
||||
@ -352,6 +369,7 @@ namespace SolarPower.Models.PowerStation
|
||||
public decimal LowerLimit { get; set; }
|
||||
public byte Alarm { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 異常設定Table
|
||||
/// </summary>
|
||||
@ -364,4 +382,64 @@ namespace SolarPower.Models.PowerStation
|
||||
public string AlarmName { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 上傳電站圖片
|
||||
/// </summary>
|
||||
public class PostPowerStationImage
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int PowerStationId { get; set; }
|
||||
public IFormFile[] StationImages { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 電站圖片資訊
|
||||
/// </summary>
|
||||
public class PowerStationImage : Created
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int PowerStationId { get; set; }
|
||||
public byte IsMainDisplay { get; set; }
|
||||
public string Image { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 上傳卡片顯示圖
|
||||
/// </summary>
|
||||
public class PostChangeMainDisplay
|
||||
{
|
||||
public int PowerStationId { get; set; }
|
||||
public int TargetImageId { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新電站圖片
|
||||
/// </summary>
|
||||
public class UpdataPowerStationImage: Updated
|
||||
{
|
||||
public int PowerStationId { get; set; }
|
||||
public byte IsMainDisplay { get; set; }
|
||||
public string Image { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 上傳單線圖
|
||||
/// </summary>
|
||||
public class PostPowerStationSingleLine
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int PowerStationId { get; set; }
|
||||
public IFormFile[] SingleLineImages { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 單線圖片資訊
|
||||
/// </summary>
|
||||
public class PowerStationSingleLine : Created
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int PowerStationId { get; set; }
|
||||
public string Image { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -59,7 +59,6 @@ namespace SolarPower.Models.User
|
||||
public string Name { get; set; } //姓名
|
||||
public string Account { get; set; } //帳號
|
||||
public byte Status { get; set; } //狀態
|
||||
public byte IsGod { get; set; } //神級帳號
|
||||
public int CompanyId { get; set; } //公司編號
|
||||
public string Email { get; set; } //信箱
|
||||
public string Phone { get; set; } //手機
|
||||
|
||||
@ -44,7 +44,7 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查詢縣市列表
|
||||
/// 查詢地區列表
|
||||
/// </summary>
|
||||
/// <param name="cityId"></param>
|
||||
/// <returns></returns>
|
||||
@ -55,7 +55,7 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = $"SELECT Id AS Value, Name AS Text FROM Area WHERE CityId = @CityId";
|
||||
var sql = $"SELECT Id AS Value, Name AS Text FROM area WHERE CityId = @CityId";
|
||||
|
||||
result = (await conn.QueryAsync<AreaSelectItemList>(sql, new { CityId = cityId })).ToList();
|
||||
}
|
||||
@ -167,7 +167,6 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 透過電站編號,取得單一電站資訊(覆寫)
|
||||
/// </summary>
|
||||
@ -191,6 +190,9 @@ namespace SolarPower.Repository.Implement
|
||||
|
||||
if(result!= null)
|
||||
{
|
||||
var sql_operation_personnel = @"SELECT UserId FROM power_station_operation_personnel op WHERE Deleted = 0 AND op.PowerStationId = @PowerStationId";
|
||||
result.OperationPersonnelIds = (await conn.QueryAsync<int>(sql_operation_personnel, new { PowerStationId = result.Id })).ToList();
|
||||
|
||||
var sql_land_building = @$"SELECT lb.*, u.Name AS CreatorName FROM land_building lb
|
||||
LEFT JOIN user u ON lb.CreatedBy = u.Id
|
||||
WHERE lb.Deleted = 0 AND PowerStationId = @PowerStationId";
|
||||
@ -809,5 +811,381 @@ namespace SolarPower.Repository.Implement
|
||||
}
|
||||
return Num;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 透過電站編號,取得該電站的運維人員編號
|
||||
/// </summary>
|
||||
/// <param name="powerStationId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<int>> GetOperationPersonnelIdsByPowerStatioinId(int powerStationId)
|
||||
{
|
||||
List<int> result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
var sql = @$"SELECT UserId FROM power_station_operation_personnel WHERE Deleted = 0 AND PowerStationId = @PowerStationId";
|
||||
|
||||
result = (await conn.QueryAsync<int>(sql, new { PowerStationId = powerStationId })).ToList();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增電站運維人員
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<int> AddOperationPersonnelAsync(List<PowerStationOperationPersonnel> entity, List<string> properties)
|
||||
{
|
||||
int count;
|
||||
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
string sql = GenerateInsertQueryWithCustomTable(properties, "power_station_operation_personnel");
|
||||
|
||||
count = await conn.ExecuteAsync(sql, entity);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 軟刪除電站運維人員
|
||||
/// </summary>
|
||||
/// <param name="operationPersonnels"></param>
|
||||
/// <returns></returns>
|
||||
public async Task DeleteOperationPersonnel(List<PowerStationOperationPersonnel> operationPersonnels)
|
||||
{
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
using (var trans = conn.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = $"UPDATE power_station_operation_personnel SET deleted = 1 WHERE PowerStationId = @PowerStationId AND UserId = @UserId";
|
||||
|
||||
await conn.ExecuteAsync(sql, operationPersonnels, trans);
|
||||
|
||||
trans.Commit();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
trans.Rollback();
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 電站管理 新增電站圖片
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<int> AddPowerStationImageAsync(List<PowerStationImage> entity, List<string> properties)
|
||||
{
|
||||
int count;
|
||||
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
string sql = GenerateInsertQueryWithCustomTable(properties, "power_station_image");
|
||||
|
||||
count = await conn.ExecuteAsync(sql, entity);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 電站管理 取得所有電站圖片的資料
|
||||
/// </summary>
|
||||
/// <param name="powerStationId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<PowerStationImage>> GetAllPowerStationImageAsync(int powerStationId)
|
||||
{
|
||||
List<PowerStationImage> result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = $"SELECT * FROM power_station_image WHERE Deleted = 0 AND PowerStationId = @PowerStationId";
|
||||
|
||||
result = (await conn.QueryAsync<PowerStationImage>(sql, new { PowerStationId = powerStationId })).ToList();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 電站管理 取得單一電站圖片的資料
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<PowerStationImage> GetOnePowerStationImageAsync(int id)
|
||||
{
|
||||
PowerStationImage result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = $"SELECT * FROM power_station_image WHERE Deleted = 0 AND Id = @Id";
|
||||
|
||||
result = await conn.QueryFirstOrDefaultAsync<PowerStationImage>(sql, new { Id = id });
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 軟刪除 單一電站圖片
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async Task DeleteOnePowerStationImage(int id)
|
||||
{
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
using (var trans = conn.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = $"UPDATE power_station_image SET deleted = 1 WHERE id = @Id";
|
||||
|
||||
await conn.ExecuteAsync(sql, new { Id = id }, trans);
|
||||
|
||||
trans.Commit();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
trans.Rollback();
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 電站管理 取得主要卡片顯示圖
|
||||
/// </summary>
|
||||
/// <param name="powerStationId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<PowerStationImage> GetMainDisplayAsync(int powerStationId)
|
||||
{
|
||||
PowerStationImage result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = $"SELECT * FROM power_station_image WHERE Deleted = 0 AND IsMainDisplay = 1 AND PowerStationId = @PowerStationId";
|
||||
|
||||
result = await conn.QueryFirstOrDefaultAsync<PowerStationImage>(sql, new { PowerStationId = powerStationId });
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 電站管理 更新上傳圖片
|
||||
/// </summary>
|
||||
/// <param name="image"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <returns></returns>
|
||||
public async Task UpdatePowerStationImage(UpdataPowerStationImage image, List<string> properties)
|
||||
{
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
using (var trans = conn.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = GenerateUpdateQueryWithCustomTable(properties, "power_station_image");
|
||||
|
||||
await conn.ExecuteAsync(sql, image, trans);
|
||||
|
||||
trans.Commit();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
trans.Rollback();
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 電站管理 新增單線圖
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<int> AddPowerStationSingleLineAsync(List<PowerStationSingleLine> entity, List<string> properties)
|
||||
{
|
||||
int count;
|
||||
using (IDbConnection conn = _databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
string sql = GenerateInsertQueryWithCustomTable(properties, "power_station_single_line_diagram");
|
||||
|
||||
count = await conn.ExecuteAsync(sql, entity);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 電站管理 取得所有單線圖的資料
|
||||
/// </summary>
|
||||
/// <param name="powerStationId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<PowerStationSingleLine>> GetAllPowerStationSingleLineAsync(int powerStationId)
|
||||
{
|
||||
List<PowerStationSingleLine> result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = $"SELECT * FROM power_station_single_line_diagram WHERE Deleted = 0 AND PowerStationId = @PowerStationId";
|
||||
|
||||
result = (await conn.QueryAsync<PowerStationSingleLine>(sql, new { PowerStationId = powerStationId })).ToList();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 電站管理 取得單一單線圖的資料
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<PowerStationSingleLine> GetOnePowerStationSingleLineAsync(int id)
|
||||
{
|
||||
PowerStationSingleLine result;
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = $"SELECT * FROM power_station_single_line_diagram WHERE Deleted = 0 AND Id = @Id";
|
||||
|
||||
result = await conn.QueryFirstOrDefaultAsync<PowerStationSingleLine>(sql, new { Id = id });
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 軟刪除 單一單線圖
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async Task DeleteOnePowerStationSingleLine(int id)
|
||||
{
|
||||
using (IDbConnection conn = this._databaseHelper.GetConnection())
|
||||
{
|
||||
conn.Open();
|
||||
using (var trans = conn.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
var sql = $"UPDATE power_station_single_line_diagram SET deleted = 1 WHERE id = @Id";
|
||||
|
||||
await conn.ExecuteAsync(sql, new { Id = id }, trans);
|
||||
|
||||
trans.Commit();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
trans.Rollback();
|
||||
throw exception;
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -188,5 +188,100 @@ namespace SolarPower.Repository.Interface
|
||||
/// <param name="Type"></param>
|
||||
/// <returns></returns>
|
||||
Task<string> GetFinalSerialNumber(int PowerStationId, string Type);
|
||||
|
||||
/// <summary>
|
||||
/// 透過電站編號,取得該電站的運維人員編號
|
||||
/// </summary>
|
||||
/// <param name="powerStationId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<int>> GetOperationPersonnelIdsByPowerStatioinId(int powerStationId);
|
||||
|
||||
/// <summary>
|
||||
/// 新增電站運維人員
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> AddOperationPersonnelAsync(List<PowerStationOperationPersonnel> entity, List<string> properties);
|
||||
|
||||
/// <summary>
|
||||
/// 軟刪除電站運維人員
|
||||
/// </summary>
|
||||
/// <param name="operationPersonnels"></param>
|
||||
/// <returns></returns>
|
||||
Task DeleteOperationPersonnel(List<PowerStationOperationPersonnel> operationPersonnels);
|
||||
|
||||
/// <summary>
|
||||
/// 電站管理 新增電站圖片
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> AddPowerStationImageAsync(List<PowerStationImage> entity, List<string> properties);
|
||||
|
||||
/// <summary>
|
||||
/// 電站管理 取得所有電站圖片的資料
|
||||
/// </summary>
|
||||
/// <param name="powerStationId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<PowerStationImage>> GetAllPowerStationImageAsync(int powerStationId);
|
||||
|
||||
/// <summary>
|
||||
/// 電站管理 取得單一電站圖片的資料
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<PowerStationImage> GetOnePowerStationImageAsync(int id);
|
||||
|
||||
/// <summary>
|
||||
/// 軟刪除 單一電站圖片
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task DeleteOnePowerStationImage(int id);
|
||||
|
||||
/// <summary>
|
||||
/// 電站管理 取得主要卡片顯示圖
|
||||
/// </summary>
|
||||
/// <param name="powerStationId"></param>
|
||||
/// <returns></returns>
|
||||
Task<PowerStationImage> GetMainDisplayAsync(int powerStationId);
|
||||
|
||||
/// <summary>
|
||||
/// 電站管理 更新上傳圖片
|
||||
/// </summary>
|
||||
/// <param name="image"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <returns></returns>
|
||||
Task UpdatePowerStationImage(UpdataPowerStationImage image, List<string> properties);
|
||||
|
||||
/// <summary>
|
||||
/// 電站管理 新增單線圖
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <param name="properties"></param>
|
||||
/// <returns></returns>
|
||||
Task<int> AddPowerStationSingleLineAsync(List<PowerStationSingleLine> entity, List<string> properties);
|
||||
|
||||
/// <summary>
|
||||
/// 電站管理 取得所有單線圖的資料
|
||||
/// </summary>
|
||||
/// <param name="powerStationId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<PowerStationSingleLine>> GetAllPowerStationSingleLineAsync(int powerStationId);
|
||||
|
||||
/// <summary>
|
||||
/// 電站管理 取得單一單線圖的資料
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<PowerStationSingleLine> GetOnePowerStationSingleLineAsync(int id);
|
||||
|
||||
/// <summary>
|
||||
/// 軟刪除 單一單線圖
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task DeleteOnePowerStationSingleLine(int id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,8 +54,8 @@
|
||||
</div>
|
||||
<div class="panel-container show">
|
||||
<div class="panel-content">
|
||||
@*只有超級使用者及平台人員可以新增公司*@
|
||||
@if (ViewBag.myUser.IsGod == 1 || ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformUser)
|
||||
@*只有平台人員可以新增公司*@
|
||||
@if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformUser)
|
||||
{
|
||||
<button type="button" class="btn btn-success waves-effect waves-themed mb-3" onclick="AddCompany()">
|
||||
<span class="fal fa-plus mr-1"></span>
|
||||
|
||||
@ -91,6 +91,8 @@
|
||||
var selectedLandBuildingId;
|
||||
var isLandBuildingLock = false;
|
||||
var selected_id = 0;
|
||||
var countPowerStationImage = 0; var countPowerStationSingleLine = 0;
|
||||
|
||||
$(function () {
|
||||
|
||||
var url = new URL(location.href);
|
||||
@ -262,6 +264,7 @@
|
||||
}
|
||||
});
|
||||
//#endregion
|
||||
|
||||
//#region 異常設定列表 DataTable
|
||||
ExceptionTable = $("#Exception_table").DataTable({
|
||||
"paging": true,
|
||||
@ -429,8 +432,9 @@
|
||||
$("#power_station_operation_personnel").append($("<option />").val(val.value).text(val.text));
|
||||
});
|
||||
|
||||
//預設查詢第一個
|
||||
$("#power_station_operation_personnel").val($("#power_station_operation_personnel option:first").val());
|
||||
if (powerStationData) {
|
||||
$("#power_station_operation_personnel").val(powerStationData.operationPersonnelIds);
|
||||
}
|
||||
});
|
||||
|
||||
$('.js-example-basic-multiple').select2();
|
||||
@ -503,7 +507,59 @@
|
||||
$.each(rel.data, function (index, val) {
|
||||
$("#Device_Type_modal").append($("<option />").val(val.value).text(val.text));
|
||||
});
|
||||
})
|
||||
});
|
||||
//#endregion
|
||||
|
||||
//#region 載入上傳資料 - 電站圖片
|
||||
var url_image = "/PowerStation/GetAllPowerStationImage";
|
||||
var send_data = {
|
||||
powerStationId: stationId
|
||||
};
|
||||
|
||||
$.post(url_image, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
var powerStationImages = rel.data;
|
||||
|
||||
countPowerStationImage = powerStationImages.length;
|
||||
|
||||
powerStationSingleLineCard = $("#power-station-image-card > .row");
|
||||
powerStationSingleLineCard.empty();
|
||||
rel.data.forEach(function (value, index) {
|
||||
CreatePowerStationSingleLineBox(powerStationSingleLineCard, value);
|
||||
});
|
||||
|
||||
}, 'json');
|
||||
//#endregion
|
||||
|
||||
//#region 載入上傳資料 - 單線圖
|
||||
var url_image = "/PowerStation/GetAllPowerStationSingleLine";
|
||||
var send_data = {
|
||||
powerStationId: stationId
|
||||
};
|
||||
|
||||
$.post(url_image, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
var powerStationSingleLines = rel.data;
|
||||
|
||||
countPowerStationSingleLine = powerStationSingleLines.length;
|
||||
|
||||
powerStationSingleLineCard = $("#power-station-single-line-card > .row");
|
||||
powerStationSingleLineCard.empty();
|
||||
rel.data.forEach(function (value, index) {
|
||||
CreatePowerStationSingleLineBox(powerStationSingleLineCard, value);
|
||||
});
|
||||
|
||||
|
||||
|
||||
}, 'json');
|
||||
//#endregion
|
||||
|
||||
});
|
||||
@ -537,6 +593,7 @@
|
||||
EscrowName: $('#check_escrow').is(':checked') ? $("#escrow_name").val() : "",
|
||||
PowerRate: $("#power_rate").val(),
|
||||
Coordinate: $("#coordinate").val(),
|
||||
OperationPersonnelIds: $("#power_station_operation_personnel").val(),
|
||||
InverterBrand: $("#inverter_brand").val(),
|
||||
InverterProductModel: $("#inverter_product_model").val(),
|
||||
InverterAmount: $("#inverter_amount").val(),
|
||||
@ -689,6 +746,7 @@
|
||||
$("#escrow_name").hide();
|
||||
$("#power_rate").hide();
|
||||
$("#coordinate").hide();
|
||||
$("#power_station_operation_personnel").attr("disabled", true);
|
||||
|
||||
//逆變器
|
||||
$("#inverter_brand").hide();
|
||||
@ -748,6 +806,7 @@
|
||||
$("#escrow_name").show();
|
||||
$("#power_rate").show();
|
||||
$("#coordinate").show();
|
||||
$("#power_station_operation_personnel").attr("disabled", false);
|
||||
|
||||
//逆變器
|
||||
$("#inverter_brand").show();
|
||||
@ -928,13 +987,14 @@
|
||||
$("#power_station_name_text").html(powerStationData.name);
|
||||
$("#electricity_meter_at_text").html(powerStationData.electricityMeterAt);
|
||||
$("#estimated_recovery_time_text").html(powerStationData.estimatedRecoveryTime);
|
||||
$("#created_by_text").html(powerStationData.CreatorName);
|
||||
$("#created_by_text").html(powerStationData.creatorName);
|
||||
|
||||
$("#generating_capacity_text").html(powerStationData.generatingCapacity);
|
||||
$("#escrow_name_text").html(powerStationData.escrowName);
|
||||
$("#power_rate_text").html(powerStationData.powerRate);
|
||||
$("#coordinate_text").html(powerStationData.coordinate);
|
||||
$("#created_at_text").html(powerStationData.createdAt);
|
||||
$("#power_station_operation_personnel").val(powerStationData.operationPersonnelIds).trigger("change");
|
||||
|
||||
//逆變器
|
||||
$("#inverter_brand_text").html(powerStationData.inverterBrand);
|
||||
@ -1043,17 +1103,17 @@
|
||||
'<div class="card-header bg-fusion-50 pr-3 d-flex align-items-center flex-wrap justify-content-between">' +
|
||||
'<div class="card-title font-weight-bold">土地房屋資料</div>' +
|
||||
'<div class="text-right">' +
|
||||
'<button class="btn btn-sm btn-success ml-auto waves-effect waves-themed save-land-building-info-btn" style="display:none" data-land-building-id="' + value.id + '" id="save-land-building-info-btn-' + value.id + '">' +
|
||||
'<span class="fal fa-cog mr-1"></span> 儲存' +
|
||||
'<button class="btn btn-sm btn-warning ml-auto waves-effect waves-themed save-land-building-info-btn" style="display:none" data-land-building-id="' + value.id + '" id="save-land-building-info-btn-' + value.id + '">' +
|
||||
'<span class="fal fa-save mr-1"></span> 儲存' +
|
||||
'</button>' +
|
||||
'<button class="btn btn-sm btn-info ml-auto waves-effect waves-themed edit-land-building-info-btn" data-land-building-id="' + value.id + '" id="edit-land-building-info-btn-' + value.id + '">' +
|
||||
'<span class="fal fa-cog mr-1"></span> 修改' +
|
||||
'</button>' +
|
||||
'<button class="btn btn-sm btn-primary ml-auto waves-effect waves-themed canecl-land-building-info-btn" style="display:none" data-land-building-id="' + value.id + '" id="canecl-land-building-info-btn-' + value.id + '">' +
|
||||
'<span class="fal fa-cog mr-1"></span> 取消' +
|
||||
'<button class="btn btn-sm btn-dark ml-auto waves-effect waves-themed canecl-land-building-info-btn" style="display:none" data-land-building-id="' + value.id + '" id="canecl-land-building-info-btn-' + value.id + '">' +
|
||||
'<span class="fal fa-redo mr-1"></span> 取消' +
|
||||
'</button>' +
|
||||
'<button class="btn btn-sm btn-danger ml-auto waves-effect waves-themed del-land-building-info-btn" data-land-building-id="' + value.id + '" id="del-land-building-info-btn-' + value.id + '">' +
|
||||
'<span class="fal fa-cog mr-1"></span> 刪除' +
|
||||
'<span class="fal fa-trash-alt mr-1"></span> 刪除' +
|
||||
'</button>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
@ -1147,15 +1207,15 @@
|
||||
'<div class="card-header bg-fusion-50 pr-3 d-flex align-items-center flex-wrap justify-content-between">' +
|
||||
'<div class="card-title font-weight-bold">土地房屋資料</div>' +
|
||||
'<div class="text-right">' +
|
||||
'<button class="btn btn-sm btn-info ml-auto waves-effect waves-themed" id="add-land-building-info-btn">' +
|
||||
'<span class="fal fa-cog mr-1"></span> 新增' +
|
||||
'<button class="btn btn-sm btn-success ml-auto waves-effect waves-themed" id="add-land-building-info-btn">' +
|
||||
'<span class="fal fa-plus mr-1"></span> 新增' +
|
||||
'</button>' +
|
||||
'<div aria-expanded="true">' +
|
||||
'<button class="btn btn-sm btn-success ml-auto waves-effect waves-themed save-land-building-info-btn" style="display:none" data-land-building-id="0" id="save-land-building-info-btn-0">' +
|
||||
'<span class="fal fa-cog mr-1"></span> 儲存' +
|
||||
'<button class="btn btn-sm btn-warning ml-auto waves-effect waves-themed save-land-building-info-btn" style="display:none" data-land-building-id="0" id="save-land-building-info-btn-0">' +
|
||||
'<span class="fal fa-save mr-1"></span> 儲存' +
|
||||
'</button>' +
|
||||
'<button class="btn btn-sm btn-primary ml-auto waves-effect waves-themed" style="display:none" id="cancel-add-land-building-info-btn">' +
|
||||
'<span class="fal fa-cog mr-1"></span> 取消' +
|
||||
'<button class="btn btn-sm btn-dark ml-auto waves-effect waves-themed" style="display:none" id="cancel-add-land-building-info-btn">' +
|
||||
'<span class="fal fa-redo mr-1"></span> 取消' +
|
||||
'</button>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
@ -1298,7 +1358,6 @@
|
||||
|
||||
//取消
|
||||
$('#land_buildingPart').on("click", "#add-land-building-card button#cancel-add-land-building-info-btn", function () {
|
||||
alert("bbb");
|
||||
$("#add-land-building-card > .card-body").collapse('hide');
|
||||
|
||||
$("#add-land-building-card button#add-land-building-info-btn").show();
|
||||
@ -1603,5 +1662,256 @@
|
||||
|
||||
});
|
||||
//#endregion
|
||||
|
||||
//#region 上傳資料 tab
|
||||
|
||||
Dropzone.autoDiscover = false;
|
||||
|
||||
//#region 電站圖片 Dropzone
|
||||
var powerStationImagsDropzone = new Dropzone("#power-station-images-form", {
|
||||
url: "/PowerStation/SavePowerStationImages",
|
||||
paramName: "StationImage",
|
||||
acceptedFiles: "image/*",
|
||||
autoProcessQueue: false,
|
||||
parallelUploads: 5,
|
||||
maxFiles: 5,
|
||||
addRemoveLinks: true,
|
||||
uploadMultiple: true,
|
||||
dictRemoveFile: "移除",
|
||||
init: function (e) {
|
||||
|
||||
var myDropzone = this;
|
||||
$("#upload-station-image").click(function (e) {
|
||||
myDropzone.processQueue();
|
||||
});
|
||||
|
||||
myDropzone.on("sending", function (file, xhr, data) {
|
||||
if ((countPowerStationImage + myDropzone.files.length) > 5) {
|
||||
toast_warning("圖片總數量不可超過 5 張");
|
||||
myDropzone.removeFile(file);
|
||||
return;
|
||||
} else {
|
||||
data.append("PowerStationId", stationId);
|
||||
data.append("StationImages", file);
|
||||
}
|
||||
});
|
||||
|
||||
myDropzone.on("successmultiple", function (file, rel) {
|
||||
if (rel.code == "9999") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
toast_ok(rel.msg);
|
||||
countPowerStationImage = rel.data.length;
|
||||
powerStationImagsDropzone.removeAllFiles();
|
||||
|
||||
powerStationImageCard = $("#power-station-image-card > .row");
|
||||
powerStationImageCard.empty();
|
||||
rel.data.forEach(function (value, index) {
|
||||
CreatePowerStationImageBox(powerStationImageCard, value);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
//#endregion
|
||||
|
||||
//#region 創建電站圖片box
|
||||
function CreatePowerStationImageBox(dom, value) {
|
||||
var str = '<div class="col-xl">' +
|
||||
'<div class="card border m-auto m-lg-0" style="padding: 9.5px;">' +
|
||||
'<img src="' + value.image + '" class="card-img-top" alt="...">' +
|
||||
'<a href="javascript:void(0);" class="btn btn-danger btn-lg btn-icon rounded-circle waves-effect waves-themed position-absolute pos-top pos-right del-power-station-image-btn" data-id="' + value.id + '">' +
|
||||
'<i class="fal fa-times"></i>' +
|
||||
'</a>' +
|
||||
'<div class="card-body">' +
|
||||
'<div class="custom-control custom-checkbox">';
|
||||
if (value.isMainDisplay == 1) {
|
||||
str += '<input type="checkbox" class="custom-control-input ckeck-main-display" data-id="' + value.id + '" id="ckeck_main_display_' + value.id + '" checked>';
|
||||
}
|
||||
else {
|
||||
str += '<input type="checkbox" class="custom-control-input ckeck-main-display" data-id="' + value.id + '" id="ckeck_main_display_' + value.id + '">';
|
||||
}
|
||||
str += '<label class="custom-control-label" for="ckeck_main_display_' + value.id + '">卡片顯示圖</label>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
|
||||
dom.append(str);
|
||||
}
|
||||
//#endregion
|
||||
|
||||
//#region 刪除電站圖片
|
||||
$('#power-station-image-card').on("click", "a.del-power-station-image-btn", function () {
|
||||
|
||||
var selectedImageId = $(this).attr("data-id");
|
||||
|
||||
var div = $(this).parents(".col-xl");
|
||||
|
||||
Swal.fire({
|
||||
title: "刪除",
|
||||
text: "你確定是否刪除此筆資料?",
|
||||
type: "warning",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: "是",
|
||||
cancelButtonText: "否"
|
||||
}).then(function (result) {
|
||||
if (result.value) {
|
||||
|
||||
var url = "/PowerStation/DeletePowerStationImage";
|
||||
|
||||
var send_data = {
|
||||
Id: selectedImageId
|
||||
}
|
||||
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
toast_ok(rel.msg);
|
||||
countPowerStationImage -= 1;
|
||||
div.remove();
|
||||
}, 'json');
|
||||
}
|
||||
});
|
||||
});
|
||||
//#endregion
|
||||
|
||||
//#region 卡片顯示圖
|
||||
$("#power-station-image-card").on("click", ".ckeck-main-display", function () {
|
||||
|
||||
if (!this.checked) {
|
||||
return
|
||||
}
|
||||
|
||||
var selectedImageId = $(this).attr("data-id");
|
||||
|
||||
var url = "/PowerStation/ChangeMainDisplay";
|
||||
|
||||
var send_data = {
|
||||
PowerStationId: stationId,
|
||||
TargetImageId: selectedImageId
|
||||
}
|
||||
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
toast_ok(rel.msg);
|
||||
}, 'json');
|
||||
});
|
||||
//#endregion
|
||||
|
||||
//#region 單線圖 Dropzone
|
||||
var powerStationSingleLineDropzone = new Dropzone("#power-station-single-line-form", {
|
||||
url: "/PowerStation/SavePowerStationSingleLine",
|
||||
acceptedFiles: "image/*",
|
||||
autoProcessQueue: false,
|
||||
parallelUploads: 1,
|
||||
maxFiles: 1,
|
||||
addRemoveLinks: true,
|
||||
uploadMultiple: true,
|
||||
dictRemoveFile: "移除",
|
||||
init: function (e) {
|
||||
|
||||
var myDropzone = this;
|
||||
$("#upload-station-single-line").click(function (e) {
|
||||
myDropzone.processQueue();
|
||||
});
|
||||
|
||||
myDropzone.on("sending", function (file, xhr, data) {
|
||||
if ((countPowerStationSingleLine + myDropzone.files.length) > 1) {
|
||||
toast_warning("請先刪除原本圖片");
|
||||
myDropzone.removeFile(file);
|
||||
return;
|
||||
} else {
|
||||
data.append("PowerStationId", stationId);
|
||||
data.append("SingleLineImages", file);
|
||||
}
|
||||
});
|
||||
|
||||
myDropzone.on("successmultiple", function (file, rel) {
|
||||
if (rel.code == "9999") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
toast_ok(rel.msg);
|
||||
countPowerStationSingleLine = rel.data.length;
|
||||
powerStationSingleLineDropzone.removeAllFiles();
|
||||
|
||||
powerStationSingleLineCard = $("#power-station-single-line-card > .row");
|
||||
powerStationSingleLineCard.empty();
|
||||
rel.data.forEach(function (value, index) {
|
||||
CreatePowerStationSingleLineBox(powerStationSingleLineCard, value);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
//#endregion
|
||||
|
||||
//#region 創建單線圖box
|
||||
function CreatePowerStationSingleLineBox(dom, value) {
|
||||
var str = '<div class="col-xl">' +
|
||||
'<div class="card border m-auto m-lg-0" style="padding: 9.5px;">' +
|
||||
'<img src="' + value.image + '" class="card-img-top" alt="...">' +
|
||||
'<a href="javascript:void(0);" class="btn btn-danger btn-lg btn-icon rounded-circle waves-effect waves-themed position-absolute pos-top pos-right del-power-station-single-line-btn" data-id="' + value.id + '">' +
|
||||
'<i class="fal fa-times"></i>' +
|
||||
'</a>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
|
||||
dom.append(str);
|
||||
}
|
||||
//#endregion
|
||||
|
||||
//#region 刪除單線圖
|
||||
$('#power-station-single-line-card').on("click", "a.del-power-station-single-line-btn", function () {
|
||||
|
||||
var selectedImageId = $(this).attr("data-id");
|
||||
|
||||
var div = $(this).parents(".col-xl");
|
||||
|
||||
Swal.fire({
|
||||
title: "刪除",
|
||||
text: "你確定是否刪除此筆資料?",
|
||||
type: "warning",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: "是",
|
||||
cancelButtonText: "否"
|
||||
}).then(function (result) {
|
||||
if (result.value) {
|
||||
|
||||
var url = "/PowerStation/DeletePowerStationSingleLine";
|
||||
|
||||
var send_data = {
|
||||
Id: selectedImageId
|
||||
}
|
||||
|
||||
$.post(url, send_data, function (rel) {
|
||||
if (rel.code != "0000") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
}
|
||||
|
||||
toast_ok(rel.msg);
|
||||
countPowerStationSingleLine -= 1;
|
||||
div.remove();
|
||||
}, 'json');
|
||||
}
|
||||
});
|
||||
});
|
||||
//#endregion
|
||||
|
||||
//#endregion
|
||||
</script>
|
||||
}
|
||||
@ -5,14 +5,14 @@
|
||||
<!-- we wrap header title inside a div tag with utility padding -->
|
||||
<div class="card-title font-weight-bold">電站基本資料</div>
|
||||
<div class="text-right">
|
||||
<a href="javascript:;" class="btn btn-sm btn-success ml-auto waves-effect waves-themed" id="add-station-info-btn" onclick="SaveStationInfo()">
|
||||
<span class="fal fa-plus mr-1"></span> 儲存
|
||||
<a href="javascript:;" class="btn btn-sm btn-warning ml-auto waves-effect waves-themed" id="add-station-info-btn" onclick="SaveStationInfo()">
|
||||
<span class="fal fa-save mr-1"></span> 儲存
|
||||
</a>
|
||||
<a href="javascript:;" class="btn btn-sm btn-info ml-auto waves-effect waves-themed" id="edit-station-info-btn" onclick="ChangeMode('station_info', 'edit')">
|
||||
<span class="fal fa-cog mr-1"></span> 修改
|
||||
</a>
|
||||
<a href="javascript:;" class="btn btn-sm btn-primary ml-auto waves-effect waves-themed" id="canecl-station-info-btn" onclick="ChangeMode('station_info', 'view')">
|
||||
<span class="fal fa-cog mr-1"></span> 取消
|
||||
<a href="javascript:;" class="btn btn-sm btn-dark ml-auto waves-effect waves-themed" id="canecl-station-info-btn" onclick="ChangeMode('station_info', 'view')">
|
||||
<span class="fal fa-redo mr-1"></span> 取消
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@ -209,14 +209,14 @@
|
||||
<!-- we wrap header title inside a div tag with utility padding -->
|
||||
<div class="card-title font-weight-bold">經濟部能源局與台電資訊</div>
|
||||
<div class="text-right">
|
||||
<a href="javascript:;" class="btn btn-sm btn-success ml-auto waves-effect waves-themed" id="add-boe-tpc-btn" onclick="SaveBoETPCInfo()">
|
||||
<span class="fal fa-plus mr-1"></span> 儲存
|
||||
<a href="javascript:;" class="btn btn-sm btn-warning ml-auto waves-effect waves-themed" id="add-boe-tpc-btn" onclick="SaveBoETPCInfo()">
|
||||
<span class="fal fa-save mr-1"></span> 儲存
|
||||
</a>
|
||||
<a href="javascript:;" class="btn btn-sm btn-info ml-auto waves-effect waves-themed" id="edit-boe-tpc-btn" onclick="ChangeMode('BOE_TPC', 'edit')">
|
||||
<span class="fal fa-cog mr-1"></span> 修改
|
||||
</a>
|
||||
<a href="javascript:;" class="btn btn-sm btn-primary ml-auto waves-effect waves-themed" id="canecl-boe-tpc-btn" onclick="ChangeMode('BOE_TPC', 'view')">
|
||||
<span class="fal fa-cog mr-1"></span> 取消
|
||||
<a href="javascript:;" class="btn btn-sm btn-dark ml-auto waves-effect waves-themed" id="canecl-boe-tpc-btn" onclick="ChangeMode('BOE_TPC', 'view')">
|
||||
<span class="fal fa-redo mr-1"></span> 取消
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@ -319,133 +319,4 @@
|
||||
|
||||
</div>
|
||||
<div class="row mb-5" id="land_buildingPart">
|
||||
<!--<div class="card border mb-g w-100">-->
|
||||
<!-- notice the additions of utility paddings and display properties on .card-header -->
|
||||
<!--<div class="card-header bg-fusion-50 pr-3 d-flex align-items-center flex-wrap justify-content-between">-->
|
||||
<!-- we wrap header title inside a div tag with utility padding -->
|
||||
<!--<div class="card-title font-weight-bold">土地房屋資料</div>
|
||||
<div class="text-right">
|
||||
<a href="javascript:;" class="btn btn-sm btn-success ml-auto waves-effect waves-themed">
|
||||
<span class="fal fa-plus mr-1"></span> 新增
|
||||
</a>
|
||||
<a href="javascript:;" class="btn btn-sm btn-info ml-auto waves-effect waves-themed">
|
||||
<span class="fal fa-cog mr-1"></span> 修改
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row d-flex justify-content-between card-land-building" data-id="xxx">
|
||||
<div class="col-xl">
|
||||
<div class="row">
|
||||
<label class="col-xl-4 form-label" for="land_building_address">地址</label>
|
||||
<div class="col-xl-8">
|
||||
<p id="land_building_address_text" class="color-info-600">台北市內湖區中山路一段1001號</p>
|
||||
<input type="text" id="land_building_address" name="land_building_address" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label class="col-xl-4 form-label" for="land_building_coordinate">經緯度</label>
|
||||
<div class="col-xl-8">
|
||||
<p id="land_building_coordinate_text" class="color-info-600">台北市內湖區中山路一段1001號</p>
|
||||
<input type="text" id="land_building_coordinate" name="land_building_coordinate" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xl">
|
||||
<div class="row">
|
||||
<label class="col-xl-4 form-label" for="lease_notarization_at">租約公證日期</label>
|
||||
<div class="col-xl-8">
|
||||
<p id="lease_notarization_at_text" class="color-info-600">2021-12-01</p>
|
||||
<input type="text" id="lease_notarization_at" name="lease_notarization_at" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label class="col-xl-4 form-label" for="land_building_lease_Rate">租金比例 (%)</label>
|
||||
<div class="col-xl-8">
|
||||
<p id="land_building_coordinate_text" class="color-info-600">台北市內湖區中山路一段1001號</p>
|
||||
<input type="text" id="land_building_lease_Rate" name="land_building_coordinate" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xl">
|
||||
<div class="row">
|
||||
<label class="col-xl-4 form-label" for="land_building_lease_Rate">地主姓名</label>
|
||||
<div class="col-xl-8">
|
||||
<p id="land_building_coordinate_text" class="color-info-600">鋼鐵人</p>
|
||||
<input type="text" id="land_building_landowner" name="land_building_coordinate" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label class="col-xl-4 form-label" for="land_building_lease_Rate">電話</label>
|
||||
<div class="col-xl-8">
|
||||
<p id="land_building_coordinate_text" class="color-info-600">0828-123456</p>
|
||||
<input type="text" id="land_building_lease_Rate" name="land_building_coordinate" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xl">
|
||||
<div class="row">
|
||||
<label class="col-xl-4 form-label" for="land_building_lease_Rate">房屋用途</label>
|
||||
<div class="col-xl-8">
|
||||
<p id="land_building_coordinate_text" class="color-info-600">0828-123456</p>
|
||||
<input type="text" id="land_building_lease_Rate" name="land_building_coordinate" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xl">
|
||||
<div class="row">
|
||||
<label class="col-xl-4 form-label" for="land_building_lease_Rate">資料建立</label>
|
||||
<div class="col-xl-8">
|
||||
<p id="land_building_coordinate_text" class="color-info-600">蜘蛛人</p>
|
||||
<input type="text" id="land_building_lease_Rate" name="land_building_coordinate" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<label class="col-xl-4 form-label" for="land_building_lease_Rate">建立時間</label>
|
||||
<div class="col-xl-8">
|
||||
<p id="land_building_coordinate_text" class="color-info-600">2018-10-01 12:00</p>
|
||||
<input type="text" id="land_building_lease_Rate" name="land_building_coordinate" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="card-body">
|
||||
<div class="row d-flex justify-content-between">
|
||||
<div class="col-xl">
|
||||
<p>地址 <span class="color-info-600">台北市內湖區中山路一段1001號</span></p>
|
||||
<p>經緯度 <span class="color-info-600">25.0726625,121.5725953</span></p>
|
||||
</div>
|
||||
<div class="col-xl">
|
||||
<p>租約公證日期 <span class="color-info-600">新竹巨城站</span></p>
|
||||
<p>租金比例 (%) <span class="color-info-600">10</span></p>
|
||||
</div>
|
||||
<div class="col-xl">
|
||||
<p>地主姓名 <span class="color-info-600">鋼鐵人</span></p>
|
||||
<p>電話 <span class="color-info-600">0828-123456</span></p>
|
||||
</div>
|
||||
<div class="col-xl">
|
||||
<p>房屋用途 <span class="color-info-600">工廠</span></p>
|
||||
</div>
|
||||
<div class="col-xl">
|
||||
<p>資料建立 <span class="color-info-600">蜘蛛人</span></p>
|
||||
<p>建立時間 <span class="color-info-600">2018-10-01 12:00</span></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-12 text-right">
|
||||
<a href="javascript:;" class="btn btn-sm btn-success ml-auto waves-effect waves-themed">
|
||||
<span class="fal fa-plus mr-1"></span> 新增
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>-->
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@ -5,14 +5,14 @@
|
||||
<!-- we wrap header title inside a div tag with utility padding -->
|
||||
<div class="card-title font-weight-bold">圖片上傳</div>
|
||||
<div class="text-right">
|
||||
<a href="javascript:;" class="btn btn-sm btn-success ml-auto waves-effect waves-themed">
|
||||
<a href="javascript:;" class="btn btn-sm btn-success ml-auto waves-effect waves-themed" id="upload-station-image">
|
||||
<span class="fal fa-plus mr-1"></span> 上傳圖片
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="card-body" id="power-station-image-card">
|
||||
<div class="row d-flex justify-content-between">
|
||||
<div class="col-xl">
|
||||
@*<div class="col-xl">
|
||||
<div class="card border m-auto m-lg-0" style="padding: 9.5px;">
|
||||
<img src="~/img/card-backgrounds/cover-3-lg.png" class="card-img-top" alt="...">
|
||||
<a href="javascript:void(0);" class="btn btn-danger btn-lg btn-icon rounded-circle waves-effect waves-themed position-absolute pos-top pos-right">
|
||||
@ -69,19 +69,22 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>*@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<div class="card-body">
|
||||
<form action="/upload" class="dropzone needsclick dz-clickable" style="min-height: 7rem;">
|
||||
<form id="power-station-images-form" enctype="multipart/form-data" class="dropzone needsclick dz-clickable" style="min-height: 7rem;">
|
||||
<div class="fallback">
|
||||
<input name="StationImage" type="file" multiple />
|
||||
</div>
|
||||
<div class="dz-message needsclick">
|
||||
<i class="fal fa-cloud-upload text-muted mb-3"></i> <br>
|
||||
<span class="text-uppercase">Drop files here or click to upload.</span>
|
||||
<span class="text-uppercase">將圖片拖曳至這裡或點擊選擇圖片.</span>
|
||||
<br>
|
||||
<span class="fs-sm text-muted">This is just a demo dropzone. Selected files are <strong>not</strong> actually uploaded.</span>
|
||||
<span class="fs-sm text-muted">僅供預覽,並未實際上傳。</span>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@ -90,20 +93,20 @@
|
||||
</div>
|
||||
|
||||
<div class="row mb-5">
|
||||
<div class="card border mb-g w-100">
|
||||
<div class="card border mb-g w-100" >
|
||||
<!-- notice the additions of utility paddings and display properties on .card-header -->
|
||||
<div class="card-header bg-fusion-50 pr-3 d-flex align-items-center flex-wrap justify-content-between">
|
||||
<!-- we wrap header title inside a div tag with utility padding -->
|
||||
<div class="card-title font-weight-bold">單線圖</div>
|
||||
<div class="text-right">
|
||||
<a href="javascript:;" class="btn btn-sm btn-success ml-auto waves-effect waves-themed">
|
||||
<a href="javascript:;" class="btn btn-sm btn-success ml-auto waves-effect waves-themed" id="upload-station-single-line">
|
||||
<span class="fal fa-plus mr-1"></span> 上傳圖片
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="card-body" id="power-station-single-line-card">
|
||||
<div class="row d-flex justify-content-between">
|
||||
<div class="col-xl">
|
||||
@*<div class="col-xl">
|
||||
<div class="card border m-auto m-lg-0" style="padding: 9.5px;">
|
||||
<img src="~/img/card-backgrounds/cover-3-lg.png" class="card-img-top" alt="...">
|
||||
<a href="javascript:void(0);" class="btn btn-danger btn-lg btn-icon rounded-circle waves-effect waves-themed position-absolute pos-top pos-right">
|
||||
@ -160,19 +163,22 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>*@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<div class="card-body">
|
||||
<form action="/upload" class="dropzone needsclick dz-clickable" style="min-height: 7rem;">
|
||||
<form id="power-station-single-line-form" action="/upload" class="dropzone needsclick dz-clickable" style="min-height: 7rem;">
|
||||
<div class="fallback">
|
||||
<input name="" type="file" multiple />
|
||||
</div>
|
||||
<div class="dz-message needsclick">
|
||||
<i class="fal fa-cloud-upload text-muted mb-3"></i> <br>
|
||||
<span class="text-uppercase">Drop files here or click to upload.</span>
|
||||
<span class="text-uppercase">將圖片拖曳至這裡或點擊選擇圖片.</span>
|
||||
<br>
|
||||
<span class="fs-sm text-muted">This is just a demo dropzone. Selected files are <strong>not</strong> actually uploaded.</span>
|
||||
<span class="fs-sm text-muted">僅供預覽,並未實際上傳。</span>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@ -29,6 +29,10 @@
|
||||
<link rel="stylesheet" media="screen, print" href="~/css/notifications/toastr/toastr.css">
|
||||
|
||||
<link rel="stylesheet" media="screen, print" href="~/css/formplugins/dropzone/dropzone.css">
|
||||
|
||||
<!--Select2-->
|
||||
<link rel="stylesheet" media="screen, print" href="~/css//formplugins/select2/select2.bundle.css"/>
|
||||
|
||||
<!--Custome CSS-->
|
||||
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
||||
|
||||
@ -1131,13 +1135,15 @@
|
||||
<!--Toast-->
|
||||
<script src="~/js/toast.js"></script>
|
||||
|
||||
<!-- Select2 JS -->
|
||||
@*<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>*@
|
||||
<script src="~/js/formplugins/select2/select2.bundle.js"></script>
|
||||
|
||||
<script src="~/js/formplugins/dropzone/dropzone.js"></script>
|
||||
<!-- Custome JS -->
|
||||
<script src="~/js/site.js" asp-append-version="true"></script>
|
||||
|
||||
<!--Select2-->
|
||||
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
|
||||
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
|
||||
|
||||
|
||||
@*各頁面的JavaScript*@
|
||||
@RenderSection("Scripts", required: false)
|
||||
|
||||
@ -16,3 +16,9 @@ html {
|
||||
label.error {
|
||||
color: red;
|
||||
}
|
||||
|
||||
/* 隱藏圖片上傳 progress bar */
|
||||
|
||||
#power-station-images-form .dz-preview .dz-progress, #power-station-single-line-form .dz-preview .dz-progress {
|
||||
display: none;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user