[성현모] Web.Operation CPMeta 기능 추가

This commit is contained in:
SHM
2025-11-03 14:27:54 +09:00
parent d6c033f149
commit 8198f0b7bb
14 changed files with 384 additions and 5 deletions

View File

@ -0,0 +1,13 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "9.0.10",
"commands": [
"dotnet-ef"
],
"rollForward": false
}
}
}

View File

@ -16,7 +16,7 @@
<body>
<Routes />
<script src="_framework/blazor.web.js"></script>
<script src="js/script.js"></script>
<script src="_framework/blazor.web.js"></script>
<script src="_content/Radzen.Blazor/Radzen.Blazor.js?v=@(typeof(Radzen.Colors).Assembly.GetName().Version)"></script>
</body>

View File

@ -1,7 +1,79 @@
@page "/CpMeta"
@rendermode InteractiveServer
@using Web.Operation.Module;
@using Web.Operation.Services
@using Packet
@inject CPMetaService _cpMetaService
@inject PopupService PopupService
<h3>CPMeta</h3>
@code {
<RadzenFieldset Style="margin-bottom: 10px;" Text="Server Info">
<div style="margin-bottom: 10px;">
<RadzenLabel Style="width: 130px;" Text="Server Address"></RadzenLabel>
<RadzenTextBox Style="margin-right: 10px;" @bind-Value="@ServerAddress"></RadzenTextBox>
</div>
</RadzenFieldset>
}
<RadzenFieldset Style="margin-bottom: 10px;" Text="View Options">
<div style="margin-bottom: 10px;">
<RadzenLabel Style="margin-right: 5px;" Text="ProductID"></RadzenLabel>
<RadzenTextBox Style="margin-right: 10px;width: 30rem;" @bind-Value="@SearchProductID"></RadzenTextBox>
<RadzenButton Style="margin-right: 30px;" Click="@(() => SearchByProductID())">Search</RadzenButton>
<RadzenLabel Style="margin-right: 5px;" Text="MacAddress"></RadzenLabel>
<RadzenTextBox Style="margin-right: 10px; width: 30rem;" @bind-Value="@SearchProductMacAddress"></RadzenTextBox>
<RadzenButton Style="margin-right: 30px;" Click="@(() => SearchByMacAddress())">Search</RadzenButton>
</div>
</RadzenFieldset>
<br />
<!--count-->
@* <div style="display: flex; justify-content: space-between; margin-bottom: 0.7rem;">
<div style="display: flex; align-items:center;">
<RadzenLabel Style="color:#BA68C8; font-weight: 600; font-size: 1.1rem; margin-right: 1.2rem;" Text=@($"Total Count: {history.Count}")></RadzenLabel>
<RadzenLabel Style="color:#64B5F6; font-weight: 600; font-size: 1.1rem;" Text=@($"Filter Count: {grid.View.Count()}")></RadzenLabel>
</div>
<div>
<RadzenButton Style="background: #7E57C2; margin-right: 0.5rem;" Text="Export CSV(Full Data)" Click="@(() => OnClickExportCSV(false))"></RadzenButton>
<RadzenButton Style="background: #1976D2;" Text="Export CSV(Filter Data)" Click="@(() => OnClickExportCSV(true))"></RadzenButton>
</div>
</div> *@
<OperationGrid TDataModel="tWbms" DataList="@response.Wbms">
</OperationGrid>
@code {
private string ServerAddress = "192.168.0.126:9000";
private string SearchProductID = string.Empty;
private string SearchProductMacAddress = string.Empty;
Response_GetWbmsMeta response = new Response_GetWbmsMeta();
protected override async Task OnInitializedAsync()
{
}
private async Task SearchByProductID()
{
PopupService.OpenIndicator("");
if (string.IsNullOrEmpty(SearchProductID) == false)
response = await _cpMetaService.GetWbmsMetaByProductID(SearchProductID, ServerAddress);
await Task.Delay(300);
PopupService.CloseIndicator();
}
private async Task SearchByMacAddress()
{
PopupService.OpenIndicator("");
if (string.IsNullOrEmpty(SearchProductMacAddress) == false)
response = await _cpMetaService.GetWbmsMetaByMacAddress(SearchProductMacAddress, ServerAddress);
await Task.Delay(300);
PopupService.CloseIndicator();
}
}

View File

@ -1,4 +1,6 @@
<Router AppAssembly="typeof(Program).Assembly">
@rendermode InteractiveServer
<Router AppAssembly="typeof(Program).Assembly">
<Found Context="routeData">
<RouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)" />
<FocusOnNavigate RouteData="routeData" Selector="h1" />

View File

@ -0,0 +1,58 @@
.message {
/* change color here */
color: #f8b26a;
text-align: center;
font-size: 1.5rem;
}
.lds-ring {
/* change color here */
color: #f8b26a;
}
.lds-ring,
.lds-ring div {
box-sizing: border-box;
}
.lds-ring {
display: inline-block;
position: relative;
width: 80px;
height: 80px;
}
.lds-ring div {
box-sizing: border-box;
display: block;
position: absolute;
width: 64px;
height: 64px;
margin: 8px;
border: 8px solid currentColor;
border-radius: 50%;
animation: lds-ring 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
border-color: currentColor transparent transparent transparent;
}
.lds-ring div:nth-child(1) {
animation-delay: -0.45s;
}
.lds-ring div:nth-child(2) {
animation-delay: -0.3s;
}
.lds-ring div:nth-child(3) {
animation-delay: -0.15s;
}
@keyframes lds-ring {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}

View File

@ -0,0 +1,26 @@
@using Radzen
@using Radzen.Blazor
@using WebClient.Library.Model
@typeparam TDataModel
<RadzenDataGrid class="rz-shadow-1" TItem="TDataModel" Data="@DataList" GridLines="DataGridGridLines.Both"
AllowFiltering FilterMode="FilterMode.Simple" AllowColumnResize
SelectionMode="DataGridSelectionMode.Single" Density="@Density.Default">
<Columns>
@foreach (var col in typeof(TDataModel).GetProperties())
{
<RadzenDataGridColumn Property="@col.Name" Title="@col.Name">
<Template>
<span>
@col.GetValue(context)
</span>
</Template>
</RadzenDataGridColumn>
}
</Columns>
</RadzenDataGrid>
@code {
[Parameter]
public IEnumerable<TDataModel> DataList { get; set; }
}

View File

@ -0,0 +1,55 @@
namespace Web.Operation.Packet
{
public class Request_SetWbmsMeta
{
//pk
public string ProductID { get; set; } = string.Empty;
//uk
public string MacAddress1 { get; set; } = string.Empty;
public string MacAddress2 { get; set; } = string.Empty;
//value
public string Type { get; set; } = string.Empty;
public string ProductNo { get; set; } = string.Empty;
public string SpareValue { get; set; } = string.Empty;
public int ShardID { get; set; } = 1;
}
public class Response_SetWbmsMeta
{
public string ProductID { get; set; } = string.Empty;
public string Result { get; set; } = string.Empty;
public string Message { get; set; } = string.Empty;
}
public class Request_GetWbmsMetaByProductID
{
public string ProductID { get; set; } = string.Empty;
public int ShardID { get; set; } = 1;
}
public class Request_GetWbmsMetaByMacAddress
{
public string MacAddress { get; set; } = string.Empty;
public int ShardID { get; set; } = 1;
}
public class Response_GetWbmsMeta
{
public List<tWbms> Wbms { get; set; }
public string Result { get; set; } = string.Empty;
public string Message { get; set; } = string.Empty;
}
public class tWbms
{
public string cProductID { get; set; } = null;
public string cMacAddress1 { get; set; }
public string cMacAddress2 { get; set; }
public string cType { get; set; }
public string cProductNo { get; set; }
public string cSpareValue { get; set; }
public DateTime cDateTime { get; set; }
}
}

View File

@ -33,6 +33,7 @@ builder.Services.AddSingleton<ConfigService<WebClientConfig>>();
//scoped
builder.Services.AddScoped<PopupService>();
builder.Services.AddScoped<CPMetaService>();
//db
builder.Services.AddSingleton<DbContextProvider>(); // Generic <20><><EFBFBD><EFBFBD>

View File

@ -0,0 +1,68 @@
using Newtonsoft.Json;
using System;
using SystemX.Core.Communication;
using SystemX.Core.Services;
using Web.Operation.Packet;
using WebClient.Library.Config;
namespace Web.Operation.Services
{
public class CPMetaService
{
private readonly IServiceScopeFactory _scopeFactory;
private readonly ConfigService<WebClientConfig>? _configService;
private string ApiHost = string.Empty;
public CPMetaService(IServiceProvider serviceProvider, IServiceScopeFactory scopeFactory, ConfigService<WebClientConfig> configService)
{
_scopeFactory = scopeFactory;
_configService = configService;
ApiHost = _configService.GetConfig()?.Api.Find(x => x.Id == 1)?.Host;
}
public async Task<Response_GetWbmsMeta> GetWbmsMeta(DateOnly? startDate, DateOnly? endDate, string host)
{
string requestUrl = $"https://{host}/CPMeta/GetWbmsMeta?";
requestUrl += $"startDate={startDate}&";
requestUrl += $"endDate={endDate}&";
requestUrl += $"ShardID=1";
Http http = new Http();
var res = await http.GetJsonAsync<Response_GetWbmsMeta>($"{requestUrl}");
LogXnet.WriteLine($"{res.ToJson()}", LogXLabel.HTTP);
return res;
}
public async Task<Response_GetWbmsMeta> GetWbmsMetaByProductID(string productId, string host)
{
string requestUrl = $"https://{host}/CPMeta/GetWbmsMetaByProductID?";
requestUrl += $"ProductID={productId}&";
requestUrl += $"ShardID=1";
Http http = new Http();
var res = await http.GetJsonAsync<Response_GetWbmsMeta>($"{requestUrl}");
LogXnet.WriteLine($"{res.ToJson()}", LogXLabel.HTTP);
return res;
}
public async Task<Response_GetWbmsMeta> GetWbmsMetaByMacAddress(string macAddress, string host)
{
string requestUrl = $"https://{host}/CPMeta/GetWbmsMetaByMacAddress?";
requestUrl += $"MacAddress={macAddress}&";
requestUrl += $"ShardID=1";
Http http = new Http();
var res = await http.GetJsonAsync<Response_GetWbmsMeta>($"{requestUrl}");
LogXnet.WriteLine($"{res.ToJson()}", LogXLabel.HTTP);
return res;
}
}
}

View File

@ -9,6 +9,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Web.Tra", "Web.Tra\Web.Tra.
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Config", "Config", "{C8D5274F-AC00-46C7-1F8D-E88E81087A52}"
ProjectSection(SolutionItems) = preProject
..\Config\WebClient.Operation.Config.json = ..\Config\WebClient.Operation.Config.json
..\Config\WebClient.Tra.Config.json = ..\Config\WebClient.Tra.Config.json
EndProjectSection
EndProject