新增列表, 修改excel

This commit is contained in:
dev02 2022-11-15 16:16:36 +08:00
parent f32af4ecde
commit 6be9be174c
2 changed files with 102 additions and 56 deletions

View File

@ -434,5 +434,55 @@ namespace FrontendWebApi.ApiControllers
} }
/// <summary>
/// 即時趨勢條件過濾條件面板
/// </summary>
/// <param name="account"></param>
/// <returns></returns>
[HttpPost]
[Route("api/Device/GetMainSub")]
public async Task<ActionResult<ApiResult<History_MainSubBuildFloor>>> GetMainSub()
{
ApiResult<History_MainSubBuildFloor> apiResult = new ApiResult<History_MainSubBuildFloor>(jwt_str);
if (!jwtlife)
{
apiResult.Code = "5000";
return BadRequest(apiResult);
}
try
{
var dbsub = await frontendRepository.GetAllAsync<HistoryDBMainSub>(
@$"select distinct v1.system_key main_name, v1.system_value main_system_tag, v2.system_key sub_name, v2.system_value sub_system_tag, v1.system_priority, v2.system_priority
from role_auth a
join auth_page b on a.AuthCode = b.AuthCode
join userinfo c on c.role_guid = a.role_guid
join variable v2 on b.ShowView = v2.id and v2.system_type = @sub_system_type
join variable v1 on v1.id = v2.system_parent_id and v1.system_type = @main_system_type
where c.account = @account
order by v1.system_priority, v2.system_priority", new { @account = myUser.account, @sub_system_type = sub_system_type, @main_system_type = main_system_type });
var mains = dbsub.GroupBy(a => a.main_system_tag).ToList();
apiResult.Data = new History_MainSubBuildFloor();
apiResult.Data.history_Main_Systems = new List<History_Main_system>();
foreach (var main in mains)
{
History_Main_system history_Main_System = new History_Main_system();
history_Main_System.main_system_tag = main.Select(a => a.main_system_tag).FirstOrDefault();
history_Main_System.full_name = main.Select(a => a.main_name).FirstOrDefault();
apiResult.Data.history_Main_Systems.Add(history_Main_System);
}
apiResult.Code = "0000";
}
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
return Ok(apiResult);
}
return Ok(apiResult);
}
} }
} }

View File

@ -428,57 +428,57 @@ namespace FrontendWebApi.ApiControllers
cell.CellStyle = styleLine12; cell.CellStyle = styleLine12;
#endregion #endregion
foreach (var or in operation_record.Result) foreach (var or in operation_record.Result)
{
RowPosition += 1;
row = sheet.CreateRow(RowPosition);
for (var i = 0; i < 10; i++)
{ {
cell = row.CreateCell(i); RowPosition += 1;
if (i == 0) row = sheet.CreateRow(RowPosition);
for (var i = 0; i < 10; i++)
{ {
cell.SetCellValue(or.work_type_name); cell = row.CreateCell(i);
} if (i == 0)
if (i == 1) {
{ cell.SetCellValue(or.work_type_name);
cell.SetCellValue(or.location); }
} if (i == 1)
if (i == 2) {
{ cell.SetCellValue(or.location);
cell.SetCellValue(or.formId); }
} if (i == 2)
if (i == 3) {
{ cell.SetCellValue(or.formId);
cell.SetCellValue(or.device_name); }
} if (i == 3)
if (i == 4) {
{ cell.SetCellValue(or.device_name);
cell.SetCellValue(or.status_name); }
} if (i == 4)
if (i == 5) {
{ cell.SetCellValue(or.status_name);
cell.SetCellValue(or.user_full_name); }
} if (i == 5)
if (i == 6) {
{ cell.SetCellValue(or.user_full_name);
cell.SetCellValue(or.start_time); }
} if (i == 6)
if (i == 7) {
{ cell.SetCellValue(or.start_time);
cell.SetCellValue(or.finish_time); // image }
} if (i == 7)
if (i == 8) {
{ cell.SetCellValue(or.finish_time); // image
cell.SetCellValue(or.finish_time); }
} if (i == 8)
if (i == 9) {
{ cell.SetCellValue(or.finish_time);
cell.SetCellValue(or.Created_at); }
} if (i == 9)
{
cell.SetCellValue(or.Created_at);
}
cell.CellStyle = style12; cell.CellStyle = style12;
}
} }
} }
}
} }
else if (work_type == 2) else if (work_type == 2)
{ {
@ -494,11 +494,11 @@ namespace FrontendWebApi.ApiControllers
if (operation_record.Result.Count > 0) if (operation_record.Result.Count > 0)
{ {
foreach(var or in operation_record.Result) foreach(var or in operation_record.Result)
{ {
sqlString = $@"select * from operation_record_file where record_id = @record_id"; sqlString = $@"select * from operation_record_file where record_id = @record_id";
var param = new { @record_id = or.id }; var param = new { @record_id = or.id };
operation_record_file = backendRepository.GetAllAsync<Operation_Record_File>(sqlString, param).Result; operation_record_file = backendRepository.GetAllAsync<Operation_Record_File>(sqlString, param).Result;
or.lorf = operation_record_file; or.lorf = operation_record_file;
} }
int RowPosition = 0; int RowPosition = 0;
@ -597,11 +597,7 @@ namespace FrontendWebApi.ApiControllers
var imageByte = System.IO.File.ReadAllBytes(fullPath); var imageByte = System.IO.File.ReadAllBytes(fullPath);
int format = 0; int format = 0;
var drawing = sheet.CreateDrawingPatriarch(); var drawing = sheet.CreateDrawingPatriarch();
foreach (var v in Enum.GetNames(typeof(PictureType))) format = Convert.ToInt32(Enum.Parse(typeof(PictureType), extName));
{
if (v == extName)
format = Convert.ToInt32(Enum.Parse(typeof(PictureType), v));
}
if (format != 0) if (format != 0)
{ {