[webApi] 修改jwt authorize, 修改圖資, 撰寫運維廠商
This commit is contained in:
parent
e24d040703
commit
263db72b35
@ -61,7 +61,7 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<ApiResult<List<Variable>>> SubSysList(int main_system_id)
|
public async Task<ApiResult<List<Variable>>> SubSysList(int main_system_tag)
|
||||||
{
|
{
|
||||||
ApiResult<List<Variable>> apiResult = new ApiResult<List<Variable>>();
|
ApiResult<List<Variable>> apiResult = new ApiResult<List<Variable>>();
|
||||||
List<Variable> sub_system_list = new List<Variable>();
|
List<Variable> sub_system_list = new List<Variable>();
|
||||||
@ -71,10 +71,10 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
var sqlString = @$"SELECT v2.*
|
var sqlString = @$"SELECT v2.*
|
||||||
FROM variable v2
|
FROM variable v2
|
||||||
JOIN variable v1 ON v2.system_parent_id = v1.id AND v1.system_type = @graph_manage_layer1 AND v1.deleted = 0
|
JOIN variable v1 ON v2.system_parent_id = v1.id AND v1.system_type = @graph_manage_layer1 AND v1.deleted = 0
|
||||||
WHERE v2.system_type = @graph_manage_layer2 AND v2.deleted = 0 AND v1.id = @main_system_id
|
WHERE v2.system_type = @graph_manage_layer2 AND v2.deleted = 0 AND v1.system_value = @main_system_tag
|
||||||
ORDER BY v2.system_priority, v2.created_at desc";
|
ORDER BY v2.system_priority, v2.created_at desc";
|
||||||
|
|
||||||
var param = new { @graph_manage_layer1 = graph_manage_layer1, @graph_manage_layer2 = graph_manage_layer2 };
|
var param = new { @graph_manage_layer1 = graph_manage_layer1, @graph_manage_layer2 = graph_manage_layer2, @main_system_tag = main_system_tag };
|
||||||
sub_system_list = await backendRepository.GetAllAsync<Variable>(sqlString, param);
|
sub_system_list = await backendRepository.GetAllAsync<Variable>(sqlString, param);
|
||||||
|
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
@ -99,18 +99,19 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
{
|
{
|
||||||
var sqlString = @$"SELECT *
|
var sqlString = @$"SELECT *
|
||||||
FROM graph_manage gm
|
FROM graph_manage gm
|
||||||
JOIN variable v2 ON gm.sub_system_id = v2.id AND v2.system_type = @graph_manage_layer2 AND v2.deleted = 0
|
JOIN variable v1 ON v1.system_value = @main_system_tag and v1.system_type = @graph_manage_layer1 and v1.deleted = 0
|
||||||
WHERE v2.id in @sub_system_id AND gm.deleted = 0
|
JOIN variable v2 ON v1.id = v2.system_parent_id AND v2.system_type = @graph_manage_layer2 AND v2.deleted = 0
|
||||||
|
WHERE v2.system_value in @sub_system_tag AND gm.deleted = 0
|
||||||
ORDER BY gm.priority, gm.created_at desc";
|
ORDER BY gm.priority, gm.created_at desc";
|
||||||
|
|
||||||
|
|
||||||
var param = new { @graph_manage_layer1 = graph_manage_layer1, graph_manage_layer2 = graph_manage_layer2, @sub_system_id = gi.sub_system_id };
|
var param = new { @graph_manage_layer1 = graph_manage_layer1, graph_manage_layer2 = graph_manage_layer2, @sub_system_tag = gi.sub_system_tag, @main_system_tag = gi.main_system_tag };
|
||||||
|
|
||||||
graManList = await backendRepository.GetAllAsync<GraphList>(sqlString, param);
|
graManList = await backendRepository.GetAllAsync<GraphList>(sqlString, param);
|
||||||
|
|
||||||
if (gi.keyWord != null)
|
if (gi.keyWord != null)
|
||||||
{
|
{
|
||||||
var wParam = new { @graph_manage_layer1 = graph_manage_layer1, graph_manage_layer2 = graph_manage_layer2, @sub_system_id = gi.sub_system_id, @keyWord = gi.keyWord };
|
var wParam = new { @graph_manage_layer1 = graph_manage_layer1, graph_manage_layer2 = graph_manage_layer2, @sub_system_tag = gi.sub_system_tag, @main_system_tag = gi.main_system_tag, @keyWord = gi.keyWord };
|
||||||
graManList = await backendRepository.GetAllAsync<GraphList>(@$"SELECT *
|
graManList = await backendRepository.GetAllAsync<GraphList>(@$"SELECT *
|
||||||
FROM graph_manage gm
|
FROM graph_manage gm
|
||||||
JOIN variable v2 ON gm.sub_system_id = v2.id AND v2.system_type = @graph_manage_layer2 AND v2.deleted = 0
|
JOIN variable v2 ON gm.sub_system_id = v2.id AND v2.system_type = @graph_manage_layer2 AND v2.deleted = 0
|
||||||
@ -139,9 +140,9 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var sqlString = @$"UPDATE graph_manage SET deleted = 0 WHERE code = @code AND sub_system_id = @sub_system_id";
|
var sqlString = @$"UPDATE graph_manage SET deleted = 0 WHERE code = @code AND sub_system_tag = @sub_system_tag AND main_system_tag = @main_system_tag";
|
||||||
|
|
||||||
var param = new { @code = gi.code, @sub_system_id = gi.sub_system_id };
|
var param = new { @code = gi.code, @sub_system_tag = gi.sub_system_tag, @main_system_tag = gi.main_system_tag };
|
||||||
|
|
||||||
await backendRepository.ExecuteSql(sqlString, param);
|
await backendRepository.ExecuteSql(sqlString, param);
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
@ -164,8 +165,8 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var sWhere = @$"deleted = 0 AND code = @code AND sub_system_id = @sub_system_id";
|
var sWhere = @$"deleted = 0 AND code = @code AND sub_system_tag = @sub_system_tag AND main_system_tag = @main_system_tag";
|
||||||
var gm = await backendRepository.GetOneAsync<GraphInsInfo>("graph_manage", sWhere, new { @code = gii.code, @sub_system_id = gii.sub_system_id});
|
var gm = await backendRepository.GetOneAsync<GraphInsInfo>("graph_manage", sWhere, new { @code = gii.code, @sub_system_tag = gii.sub_system_tag, @main_system_tag = gii.main_system_tag});
|
||||||
|
|
||||||
if (gm == null)
|
if (gm == null)
|
||||||
{
|
{
|
||||||
@ -226,9 +227,11 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
graph_manage.Add("@name", gii.name);
|
graph_manage.Add("@name", gii.name);
|
||||||
|
graph_manage.Add("@main_system_tag", gii.main_system_tag);
|
||||||
|
graph_manage.Add("@sub_system_tag", gii.sub_system_tag);
|
||||||
//graph_manage.Add("@priority", gii.priority);
|
//graph_manage.Add("@priority", gii.priority);
|
||||||
|
|
||||||
await backendRepository.UpdateOneByCustomTable(graph_manage, "graph_manage", "code='" + gii.code + "'" + "sub_system_id ='" + gii.sub_system_id + "'");
|
await backendRepository.UpdateOneByCustomTable(graph_manage, "graph_manage", "code='" + gm.code + "'" + " and sub_system_tag ='" + gm.sub_system_tag + "' and main_system_tag = '" + gm.main_system_tag + "'");
|
||||||
apiResult.Code = "0000";
|
apiResult.Code = "0000";
|
||||||
apiResult.Data = "修改成功";
|
apiResult.Data = "修改成功";
|
||||||
}
|
}
|
||||||
@ -251,8 +254,8 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var sWhere = @$"deleted = 0 AND code = @code AND sub_system_id = @sub_system_id";
|
var sWhere = @$"deleted = 0 AND code = @code AND sub_system_tag = @sub_system_tag AND main_system_tag = @main_system_tag";
|
||||||
var gm = await backendRepository.GetOneAsync<GraphInsInfo>("graph_manage", sWhere, new { @code = gii.code, @sub_system_id = gii.sub_system_id });
|
var gm = await backendRepository.GetOneAsync<GraphInsInfo>("graph_manage", sWhere, new { @code = gii.code, @sub_system_tag = gii.sub_system_tag, @main_system_tag = gii.main_system_tag });
|
||||||
|
|
||||||
if (gm != null)
|
if (gm != null)
|
||||||
{
|
{
|
||||||
@ -305,6 +308,8 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
var newPriority = await backendRepository.GetCurrentPriority("graph_manage");
|
var newPriority = await backendRepository.GetCurrentPriority("graph_manage");
|
||||||
|
graph_manage.Add("@main_system_tag", gii.main_system_tag);
|
||||||
|
graph_manage.Add("@sub_system_tag", gii.sub_system_tag);
|
||||||
graph_manage.Add("@name", gii.name);
|
graph_manage.Add("@name", gii.name);
|
||||||
graph_manage.Add("@deleted", 0);
|
graph_manage.Add("@deleted", 0);
|
||||||
graph_manage.Add("@priority", newPriority + 1);
|
graph_manage.Add("@priority", newPriority + 1);
|
||||||
|
@ -15,6 +15,8 @@ using System.Linq;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
|
using System.Net;
|
||||||
|
|
||||||
namespace FrontendWebApi.ApiControllers
|
namespace FrontendWebApi.ApiControllers
|
||||||
{
|
{
|
||||||
@ -44,7 +46,6 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
ctx.Response.Headers.Add("Access-Control-Allow-Headers", "*");
|
ctx.Response.Headers.Add("Access-Control-Allow-Headers", "*");
|
||||||
ctx.Response.Headers.Add("Access-Control-Allow-Credentials", "true");
|
ctx.Response.Headers.Add("Access-Control-Allow-Credentials", "true");
|
||||||
EDFunction edFunction = new EDFunction();
|
EDFunction edFunction = new EDFunction();
|
||||||
var a = User.Claims.Select(p => new { Type = p.Type, Value = p.Value }).ToList();
|
|
||||||
myUser = new JwtGet()
|
myUser = new JwtGet()
|
||||||
{
|
{
|
||||||
account = User.Claims.Where(a => a.Type == "account").Select(e => e.Value).FirstOrDefault(),
|
account = User.Claims.Where(a => a.Type == "account").Select(e => e.Value).FirstOrDefault(),
|
||||||
@ -59,6 +60,7 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
{
|
{
|
||||||
jwt_str = "Jwt Token不合法";
|
jwt_str = "Jwt Token不合法";
|
||||||
jwtlife = false;
|
jwtlife = false;
|
||||||
|
filterContext.Result = new JsonResult(new { HttpStatusCode.Unauthorized });
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
406
FrontendWebApi/ApiControllers/OperationController.cs
Normal file
406
FrontendWebApi/ApiControllers/OperationController.cs
Normal file
@ -0,0 +1,406 @@
|
|||||||
|
using FrontendWebApi.Models;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using NPOI.SS.UserModel;
|
||||||
|
using NPOI.XSSF.UserModel;
|
||||||
|
using Repository.BackendRepository.Interface;
|
||||||
|
using Repository.FrontendRepository.Interface;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace FrontendWebApi.ApiControllers
|
||||||
|
{
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
public class OperationController : MyBaseApiController<OperationController>
|
||||||
|
{
|
||||||
|
private readonly IBackendRepository backendRepository;
|
||||||
|
private string operationFileSaveAsPath = "";
|
||||||
|
|
||||||
|
public OperationController(IBackendRepository backendRepository)
|
||||||
|
{
|
||||||
|
this.backendRepository = backendRepository;
|
||||||
|
operationFileSaveAsPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "upload", "operation");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ApiResult<List<Variable>>> MaiSysList()
|
||||||
|
{
|
||||||
|
ApiResult<List<Variable>> apiResult = new ApiResult<List<Variable>>();
|
||||||
|
List<Variable> main_system_list = new List<Variable>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var sqlString = @$"SELECT *
|
||||||
|
FROM variable
|
||||||
|
WHERE system_type = @main_system_type AND deleted = 0
|
||||||
|
ORDER BY system_priority, created_at desc";
|
||||||
|
|
||||||
|
var param = new { @main_system_type = main_system_type };
|
||||||
|
main_system_list = await backendRepository.GetAllAsync<Variable>(sqlString, param);
|
||||||
|
|
||||||
|
apiResult.Code = "0000";
|
||||||
|
apiResult.Data = main_system_list;
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
apiResult.Code = "9999";
|
||||||
|
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
|
||||||
|
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ApiResult<List<Variable>>> SubSysList(string main_system_tag)
|
||||||
|
{
|
||||||
|
ApiResult<List<Variable>> apiResult = new ApiResult<List<Variable>>();
|
||||||
|
List<Variable> sub_system_list = new List<Variable>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var sqlString = @$"SELECT v2.*
|
||||||
|
FROM variable v2
|
||||||
|
JOIN variable v1 ON v2.system_parent_id = v1.id AND v1.system_type = @main_system_type AND v1.deleted = 0
|
||||||
|
WHERE v2.system_type = @sub_system_type AND v2.deleted = 0 AND v1.system_type = @main_system_tag
|
||||||
|
ORDER BY v2.system_priority, v2.created_at desc";
|
||||||
|
|
||||||
|
var param = new { @main_system_type = main_system_type, @sub_system_type = sub_system_type, @main_system_tag = main_system_tag };
|
||||||
|
sub_system_list = await backendRepository.GetAllAsync<Variable>(sqlString, param);
|
||||||
|
|
||||||
|
apiResult.Code = "0000";
|
||||||
|
apiResult.Data = sub_system_list;
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
apiResult.Code = "9999";
|
||||||
|
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
|
||||||
|
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResult;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 廠商資料列表(搜寻)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ofl"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<ApiResult<List<Operation_Firm>>> OpeFirList(OperationFindList ofl)
|
||||||
|
{
|
||||||
|
ApiResult<List<Operation_Firm>> apiResult = new ApiResult<List<Operation_Firm>>();
|
||||||
|
List<Operation_Firm> opList = new List<Operation_Firm>();
|
||||||
|
string sWhere = "";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (ofl.start_created_at != null || ofl.end_created_at != null)
|
||||||
|
{
|
||||||
|
sWhere += $@" and (of.created_at >= isnull(@start_created_at, of.created_at) AND of.created_at <= isnull(@end_created_at, of.created_at))";
|
||||||
|
}
|
||||||
|
else if (ofl.today)
|
||||||
|
{
|
||||||
|
sWhere += $@" and convert(of.created_at, DATE) = convert(NOW(), DATE)";
|
||||||
|
}
|
||||||
|
else if (ofl.yesterday)
|
||||||
|
{
|
||||||
|
sWhere += $@" and convert(of.created_at, DATE) = convert(ADDDATE(NOW(), -1), DATE)";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ofl.sub_system_tag != null || ofl.main_system_tag != null)
|
||||||
|
{
|
||||||
|
sWhere += $@" and (of.device_system_category_layer2 = isnull(@main_system_tag, device_system_category_layer2) AND of.device_system_category_layer3 = isnull(@sub_system_tag, device_system_category_layer3))";
|
||||||
|
}
|
||||||
|
|
||||||
|
var sqlString = @$"select of.*, v2.system_key
|
||||||
|
from operation_firm of
|
||||||
|
left join variable v1 on of.device_system_category_layer2 = v1.system_value and v1.system_type = @main_system_type and v1.delted = 0
|
||||||
|
left join variable v2 on v1.id = v2.system_parent_id and of.device_system_category_layer3 = v2.system_value and v2.system_type = @sub_system_type and v2.deleted = 0
|
||||||
|
where of.deleted = 0" + sWhere;
|
||||||
|
|
||||||
|
|
||||||
|
var param = new { @sub_system_type = sub_system_type, @start_created_at = ofl.start_created_at, @end_created_at = ofl.end_created_at, @today = ofl.today, @yesterday = ofl.yesterday, @sub_system_tag = ofl.sub_system_tag, @main_system_tag = ofl.main_system_tag };
|
||||||
|
opList = await backendRepository.GetAllAsync<Operation_Firm>(sqlString, param);
|
||||||
|
|
||||||
|
apiResult.Code = "0000";
|
||||||
|
apiResult.Data = opList;
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
apiResult.Code = "9999";
|
||||||
|
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
|
||||||
|
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 新增一笔廠商資料
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="of"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<ApiResult<string>> SaveOpeFirm(Operation_Firm of)
|
||||||
|
{
|
||||||
|
ApiResult<string> apiResult = new ApiResult<string>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (of.tax_id_number != null)
|
||||||
|
{
|
||||||
|
var sWhere = "deleted = 0 AND tax_id_number = @tax_id_number";
|
||||||
|
var ofo = await backendRepository.GetOneAsync<Operation_Firm>("operation_firm", sWhere, new { @tax_id_number = of.tax_id_number });
|
||||||
|
if (ofo != null)
|
||||||
|
{
|
||||||
|
apiResult.Code = "0002";
|
||||||
|
apiResult.Data = "已有相同的统一编号";
|
||||||
|
return apiResult;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Dictionary<string, object> operation_firm = new Dictionary<string, object>()
|
||||||
|
{
|
||||||
|
{ "@deleted", 0 },
|
||||||
|
{ "@device_system_category_layer2", of.device_system_category_layer2 },
|
||||||
|
{ "@device_system_category_layer3", of.device_system_category_layer3 },
|
||||||
|
{ "@name", of.name },
|
||||||
|
{ "@contact_person", of.contact_person },
|
||||||
|
{ "@phone", of.phone },
|
||||||
|
{ "@email", of.email },
|
||||||
|
{ "@tax_id_number", of.tax_id_number },
|
||||||
|
{ "@remark", of.remark },
|
||||||
|
{ "@created_by", myUser.userinfo_guid },
|
||||||
|
{ "@created_at", DateTime.Now }
|
||||||
|
};
|
||||||
|
|
||||||
|
await backendRepository.AddOneByCustomTable(operation_firm, "operation_firm");
|
||||||
|
apiResult.Code = "0000";
|
||||||
|
apiResult.Data = "新增成功";
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
apiResult.Code = "9999";
|
||||||
|
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
|
||||||
|
string json = System.Text.Json.JsonSerializer.Serialize(of);
|
||||||
|
Logger.LogError("【" + controllerName + "/" + actionName + "】" + json);
|
||||||
|
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 编辑一笔廠商資料
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="of"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<ApiResult<string>> EdtOneOpeFirm(Operation_Firm of)
|
||||||
|
{
|
||||||
|
ApiResult<string> apiResult = new ApiResult<string>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var sWhere = @$"deleted = 0 and id = @id";
|
||||||
|
var gm = await backendRepository.GetOneAsync<Operation_Firm>("operation_firm", sWhere, new { @id = of.id });
|
||||||
|
|
||||||
|
if (gm == null)
|
||||||
|
{
|
||||||
|
apiResult.Code = "0001";
|
||||||
|
apiResult.Data = "無法找到厂商";
|
||||||
|
return apiResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (of.tax_id_number != null)
|
||||||
|
{
|
||||||
|
sWhere = "deleted = 0 AND tax_id_number = @tax_id_number and id != @id";
|
||||||
|
var ofo = await backendRepository.GetOneAsync<Operation_Firm>("operation_firm", sWhere, new { @tax_id_number = of.tax_id_number, @id = of.id });
|
||||||
|
if (ofo != null)
|
||||||
|
{
|
||||||
|
apiResult.Code = "0002";
|
||||||
|
apiResult.Data = "已有相同的统一编号";
|
||||||
|
return apiResult;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Dictionary<string, object> operation_firm = new Dictionary<string, object>()
|
||||||
|
{
|
||||||
|
{ "@deleted", of.deleted },
|
||||||
|
{ "@device_system_category_layer2", of.device_system_category_layer2 },
|
||||||
|
{ "@device_system_category_layer3", of.device_system_category_layer3 },
|
||||||
|
{ "@name", of.name },
|
||||||
|
{ "@contact_person", of.contact_person },
|
||||||
|
{ "@phone", of.phone },
|
||||||
|
{ "@email", of.email },
|
||||||
|
{ "@tax_id_number", of.tax_id_number },
|
||||||
|
{ "@remark", of.remark },
|
||||||
|
{ "updated_by", myUser.userinfo_guid },
|
||||||
|
{ "updated_at", DateTime.Now }
|
||||||
|
};
|
||||||
|
|
||||||
|
await backendRepository.UpdateOneByCustomTable(operation_firm, "operation_firm", "id = '" + of.id + "'");
|
||||||
|
apiResult.Code = "0000";
|
||||||
|
apiResult.Data = "修改成功";
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
apiResult.Code = "9999";
|
||||||
|
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
|
||||||
|
string json = System.Text.Json.JsonSerializer.Serialize(of);
|
||||||
|
Logger.LogError("【" + controllerName + "/" + actionName + "】" + json);
|
||||||
|
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 汇出excel
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public FileResult ExportExcel()
|
||||||
|
{
|
||||||
|
var workbook = new XSSFWorkbook();
|
||||||
|
#region excel設定
|
||||||
|
IFont font12 = workbook.CreateFont();
|
||||||
|
font12.FontName = "新細明體";
|
||||||
|
font12.FontHeightInPoints = 12;
|
||||||
|
ICellStyle style12 = workbook.CreateCellStyle();
|
||||||
|
style12.SetFont(font12);
|
||||||
|
style12.Alignment = HorizontalAlignment.Center;
|
||||||
|
style12.VerticalAlignment = VerticalAlignment.Center;
|
||||||
|
IFont font12Times = workbook.CreateFont();
|
||||||
|
font12Times.FontName = "Times New Roman";
|
||||||
|
font12Times.FontHeightInPoints = 12;
|
||||||
|
IFont font18 = workbook.CreateFont();
|
||||||
|
font18.FontName = "新細明體";
|
||||||
|
font18.FontHeightInPoints = 18;
|
||||||
|
font18.IsBold = true;
|
||||||
|
ICellStyle styleTitle18 = workbook.CreateCellStyle();
|
||||||
|
styleTitle18.SetFont(font18);
|
||||||
|
styleTitle18.Alignment = HorizontalAlignment.Center;
|
||||||
|
styleTitle18.VerticalAlignment = VerticalAlignment.Center;
|
||||||
|
ICellStyle styleLeft12 = workbook.CreateCellStyle();
|
||||||
|
styleLeft12.SetFont(font12);
|
||||||
|
styleLeft12.Alignment = HorizontalAlignment.Left;
|
||||||
|
styleLeft12.VerticalAlignment = VerticalAlignment.Center;
|
||||||
|
ICellStyle styleLine12 = workbook.CreateCellStyle();
|
||||||
|
styleLine12.SetFont(font12);
|
||||||
|
styleLine12.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
|
||||||
|
styleLine12.VerticalAlignment = VerticalAlignment.Center;
|
||||||
|
styleLine12.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||||
|
styleLine12.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||||
|
styleLine12.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||||
|
styleLine12.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||||
|
ICellStyle stylein12 = workbook.CreateCellStyle();
|
||||||
|
stylein12.SetFont(font12Times);
|
||||||
|
stylein12.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Left;
|
||||||
|
stylein12.VerticalAlignment = VerticalAlignment.Center;
|
||||||
|
stylein12.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||||
|
stylein12.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||||
|
stylein12.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||||
|
stylein12.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||||
|
stylein12.WrapText = true;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
var sqlString = $@"select of.*, v2.system_key
|
||||||
|
from operation_firm of
|
||||||
|
left join variable v1 on of.device_system_category_layer2 = v1.system_value and v1.system_type = @main_system_type and v1.delted = 0
|
||||||
|
left join variable v2 on v1.id = v2.system_parent_id and of.device_system_category_layer3 = v2.system_value and v2.system_type = @sub_system_type and v2.deleted = 0
|
||||||
|
where of.deleted = 0";
|
||||||
|
var sheet = workbook.CreateSheet("廠商資料");
|
||||||
|
var operation_firm = backendRepository.GetAllAsync<Operation_Firm>(sqlString, null);
|
||||||
|
int RowPosition = 0;
|
||||||
|
IRow row = sheet.CreateRow(RowPosition);
|
||||||
|
sheet.SetColumnWidth(0, 4 * 160 * 12);
|
||||||
|
sheet.SetColumnWidth(1, 4 * 160 * 12);
|
||||||
|
sheet.SetColumnWidth(3, 4 * 160 * 12);
|
||||||
|
sheet.SetColumnWidth(4, 4 * 160 * 12);
|
||||||
|
sheet.SetColumnWidth(5, 4 * 160 * 12);
|
||||||
|
sheet.SetColumnWidth(6, 4 * 160 * 12);
|
||||||
|
sheet.SetColumnWidth(7, 4 * 160 * 12);
|
||||||
|
ICell cell = row.CreateCell(0);
|
||||||
|
cell.SetCellValue("廠商類別");
|
||||||
|
cell.CellStyle = styleLine12;
|
||||||
|
cell = row.CreateCell(1);
|
||||||
|
cell.SetCellValue("廠商名稱");
|
||||||
|
cell.CellStyle = styleLine12;
|
||||||
|
cell = row.CreateCell(2);
|
||||||
|
cell.SetCellValue("聯絡人");
|
||||||
|
cell.CellStyle = styleLine12;
|
||||||
|
cell = row.CreateCell(3);
|
||||||
|
cell.SetCellValue("電話");
|
||||||
|
cell.CellStyle = styleLine12;
|
||||||
|
cell = row.CreateCell(4);
|
||||||
|
cell.SetCellValue("郵箱");
|
||||||
|
cell.CellStyle = styleLine12;
|
||||||
|
cell = row.CreateCell(5);
|
||||||
|
cell.SetCellValue("統一編號");
|
||||||
|
cell.CellStyle = styleLine12;
|
||||||
|
cell = row.CreateCell(6);
|
||||||
|
cell.SetCellValue("備注");
|
||||||
|
cell.CellStyle = styleLine12;
|
||||||
|
cell = row.CreateCell(2);
|
||||||
|
cell.SetCellValue("建立時間");
|
||||||
|
cell.CellStyle = styleLine12;
|
||||||
|
|
||||||
|
foreach (var of in operation_firm.Result)
|
||||||
|
{
|
||||||
|
RowPosition += 1;
|
||||||
|
row = sheet.CreateRow(RowPosition);
|
||||||
|
for (var a = 0; a < 8; a++)
|
||||||
|
{
|
||||||
|
cell = row.CreateCell(a);
|
||||||
|
if (a == 0)
|
||||||
|
{
|
||||||
|
cell.SetCellValue(of.system_key);
|
||||||
|
}
|
||||||
|
if (a == 1)
|
||||||
|
{
|
||||||
|
cell.SetCellValue(of.name);
|
||||||
|
}
|
||||||
|
if (a == 2)
|
||||||
|
{
|
||||||
|
cell.SetCellValue(of.contact_person);
|
||||||
|
}
|
||||||
|
if (a == 3)
|
||||||
|
{
|
||||||
|
cell.SetCellValue(of.phone);
|
||||||
|
}
|
||||||
|
if (a == 4)
|
||||||
|
{
|
||||||
|
cell.SetCellValue(of.email);
|
||||||
|
}
|
||||||
|
if (a == 5)
|
||||||
|
{
|
||||||
|
cell.SetCellValue(of.tax_id_number);
|
||||||
|
}
|
||||||
|
if (a == 2)
|
||||||
|
{
|
||||||
|
cell.SetCellValue(of.remark);
|
||||||
|
}
|
||||||
|
if (a == 7)
|
||||||
|
{
|
||||||
|
cell.SetCellValue(of.Created_at);
|
||||||
|
}
|
||||||
|
|
||||||
|
cell.CellStyle = style12;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var ms = new NpoiMemoryStream
|
||||||
|
{
|
||||||
|
AllowClose = false
|
||||||
|
};
|
||||||
|
workbook.Write(ms);
|
||||||
|
ms.Flush();
|
||||||
|
ms.Seek(0, SeekOrigin.Begin);
|
||||||
|
|
||||||
|
return File(ms, "application/vnd.ms-excel", "廠商資料.xlsx");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -35,8 +35,8 @@ namespace FrontendWebApi.Jwt
|
|||||||
//claims.Add(new Claim(JwtRegisteredClaimNames.NameId, login.CustomerNo.ToString()));
|
//claims.Add(new Claim(JwtRegisteredClaimNames.NameId, login.CustomerNo.ToString()));
|
||||||
//claims.Add(new Claim(JwtRegisteredClaimNames.Sub, login.Username)); // User.Identity.Name
|
//claims.Add(new Claim(JwtRegisteredClaimNames.Sub, login.Username)); // User.Identity.Name
|
||||||
//claims.Add(new Claim(JwtRegisteredClaimNames.Aud, "The Audience"));
|
//claims.Add(new Claim(JwtRegisteredClaimNames.Aud, "The Audience"));
|
||||||
//claims.Add(new Claim(JwtRegisteredClaimNames.Exp, DateTimeOffset.UtcNow.AddSeconds(expireSeconds).ToUnixTimeSeconds().ToString()));
|
claims.Add(new Claim(JwtRegisteredClaimNames.Exp, DateTimeOffset.UtcNow.AddSeconds(lifeseconds).ToUnixTimeSeconds().ToString()));
|
||||||
//claims.Add(new Claim(JwtRegisteredClaimNames.Nbf, DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString())); // 必須為數字
|
claims.Add(new Claim(JwtRegisteredClaimNames.Nbf, DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString())); // 必須為數字
|
||||||
//claims.Add(new Claim(JwtRegisteredClaimNames.Iat, DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString())); // 必須為數字
|
//claims.Add(new Claim(JwtRegisteredClaimNames.Iat, DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString())); // 必須為數字
|
||||||
//claims.Add(new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString())); // JWT ID
|
//claims.Add(new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString())); // JWT ID
|
||||||
|
|
||||||
@ -69,13 +69,24 @@ namespace FrontendWebApi.Jwt
|
|||||||
var tokenHandler = new JwtSecurityTokenHandler();
|
var tokenHandler = new JwtSecurityTokenHandler();
|
||||||
|
|
||||||
var jst = new JwtSecurityToken(
|
var jst = new JwtSecurityToken(
|
||||||
issuer: issuer,//Token釋出者
|
issuer: issuer,//Token釋出者
|
||||||
//audience: _options.Value.Audience,//Token接受者
|
//audience: _options.Value.Audience,//Token接受者
|
||||||
claims: claims,//攜帶的負載
|
claims: claims,//攜帶的負載
|
||||||
notBefore: now,//當前時間token生成時間
|
notBefore: now,//當前時間token生成時間
|
||||||
expires: expires,//過期時間
|
expires: expires,//過期時間
|
||||||
signingCredentials: signingCredentials
|
signingCredentials: signingCredentials
|
||||||
);
|
);
|
||||||
|
//var jst = new SecurityTokenDescriptor
|
||||||
|
//{
|
||||||
|
// Issuer = issuer,//Token釋出者
|
||||||
|
// //Claims = claims,//攜帶的負載
|
||||||
|
// //audience: _options.Value.Audience,//Token接受者
|
||||||
|
// NotBefore = now,//當前時間token生成時間
|
||||||
|
// Expires = expires,//過期時間
|
||||||
|
// SigningCredentials = signingCredentials,
|
||||||
|
// Subject = userClaimsIdentity
|
||||||
|
//};
|
||||||
|
|
||||||
var serializeToken = tokenHandler.WriteToken(jst);
|
var serializeToken = tokenHandler.WriteToken(jst);
|
||||||
|
|
||||||
var data = new TnToken();
|
var data = new TnToken();
|
||||||
|
@ -9,7 +9,8 @@ namespace FrontendWebApi.Models
|
|||||||
public class GraphList
|
public class GraphList
|
||||||
{
|
{
|
||||||
public string code { get; set; }
|
public string code { get; set; }
|
||||||
public int sub_system_id { get; set; }
|
public string main_system_tag { get; set; }
|
||||||
|
public int sub_system_tag { get; set; }
|
||||||
public string name { get; set; }
|
public string name { get; set; }
|
||||||
public string oriOrgName { get; set; }
|
public string oriOrgName { get; set; }
|
||||||
public string oriSavName { get; set; }
|
public string oriSavName { get; set; }
|
||||||
@ -20,7 +21,8 @@ namespace FrontendWebApi.Models
|
|||||||
public class GraphInsInfo
|
public class GraphInsInfo
|
||||||
{
|
{
|
||||||
public string code { get; set; }
|
public string code { get; set; }
|
||||||
public int sub_system_id { get; set; }
|
public string main_system_tag { get; set; }
|
||||||
|
public string sub_system_tag { get; set; }
|
||||||
public string name { get; set; }
|
public string name { get; set; }
|
||||||
public string oriOrgName { get; set; }
|
public string oriOrgName { get; set; }
|
||||||
public string oriSavName { get; set; }
|
public string oriSavName { get; set; }
|
||||||
@ -34,7 +36,8 @@ namespace FrontendWebApi.Models
|
|||||||
public class GraphInfo
|
public class GraphInfo
|
||||||
{
|
{
|
||||||
public string code { get; set; }
|
public string code { get; set; }
|
||||||
public List<int> sub_system_id { get; set; }
|
public string main_system_tag { get; set; }
|
||||||
|
public List<int> sub_system_tag { get; set; }
|
||||||
public string keyWord { get; set; }
|
public string keyWord { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,32 @@ namespace FrontendWebApi.Models
|
|||||||
Fix = 2, //維修
|
Fix = 2, //維修
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class Operation_Firm : Actor
|
||||||
|
{
|
||||||
|
public int id { get; set; }
|
||||||
|
public byte deleted { get; set; }
|
||||||
|
public string device_system_category_layer2 { get; set; }//系統類別(第2層)
|
||||||
|
public string device_system_category_layer3 { get; set; }//系統類別(第3層)
|
||||||
|
public string name { get; set; }//名称
|
||||||
|
public string contact_person { get; set; }//联络人
|
||||||
|
public string phone { get; set; }//电话
|
||||||
|
public string email { get; set; }//Email
|
||||||
|
public string tax_id_number { get; set; }//统一编号
|
||||||
|
public string remark { get; set; }//备注
|
||||||
|
public string system_key { get; set; }//類別名稱
|
||||||
|
}
|
||||||
|
|
||||||
|
public class OperationFindList
|
||||||
|
{
|
||||||
|
public string serial_number { get; set; } //表单号
|
||||||
|
public DateTime? start_created_at { get; set; }//开始建立时间
|
||||||
|
public DateTime? end_created_at { get; set; }//结束建立时间
|
||||||
|
public bool today { get; set; }//今天建立时间
|
||||||
|
public bool yesterday { get; set; }//昨天建立时间
|
||||||
|
public string main_system_tag { get; set; }//大类tag
|
||||||
|
public string sub_system_tag { get; set; }//小类tag
|
||||||
|
}
|
||||||
|
|
||||||
public class Operation : Actor
|
public class Operation : Actor
|
||||||
{
|
{
|
||||||
public int Id { get; set; }//流水號
|
public int Id { get; set; }//流水號
|
||||||
|
@ -58,6 +58,7 @@ namespace FrontendWebApi
|
|||||||
// This method gets called by the runtime. Use this method to add services to the container.
|
// This method gets called by the runtime. Use this method to add services to the container.
|
||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
|
services.AddSingleton<JwtHelpers>();
|
||||||
services.AddControllersWithViews();
|
services.AddControllersWithViews();
|
||||||
//services.AddControllers();
|
//services.AddControllers();
|
||||||
|
|
||||||
@ -102,7 +103,7 @@ namespace FrontendWebApi
|
|||||||
// 當驗證失敗時,回應標頭會包含 WWW-Authenticate 標頭,這裡會顯示失敗的詳細錯誤原因
|
// 當驗證失敗時,回應標頭會包含 WWW-Authenticate 標頭,這裡會顯示失敗的詳細錯誤原因
|
||||||
options.IncludeErrorDetails = true; // 預設值為 true,有時會特別關閉
|
options.IncludeErrorDetails = true; // 預設值為 true,有時會特別關閉
|
||||||
|
|
||||||
options.TokenValidationParameters = new TokenValidationParameters()
|
options.TokenValidationParameters = new TokenValidationParameters
|
||||||
{
|
{
|
||||||
// 透過這項宣告,就可以從 "sub" 取值並設定給 User.Identity.Name
|
// 透過這項宣告,就可以從 "sub" 取值並設定給 User.Identity.Name
|
||||||
NameClaimType = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier",
|
NameClaimType = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier",
|
||||||
@ -140,7 +141,6 @@ namespace FrontendWebApi
|
|||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
|
||||||
{
|
{
|
||||||
|
|
||||||
loggerFactory.AddFile("Logs/log-{Date}.txt");
|
loggerFactory.AddFile("Logs/log-{Date}.txt");
|
||||||
|
|
||||||
if (env.IsDevelopment())
|
if (env.IsDevelopment())
|
||||||
|
Loading…
Reference in New Issue
Block a user