新增原料入场记录功能,包含免密接口和数据同步,更新相关控制器、实体和服务,支持条码/批次号生成及管理,优化用户体验和系统实时数据处理能力。
This commit is contained in:
@@ -51,6 +51,7 @@ public class MixerMaterialService : IMixerMaterialService, ISingletonDependency
|
||||
}
|
||||
|
||||
private string BaseUrl => (_configuration.GetValue<string>("JeecgIntegration:BaseUrl") ?? "http://localhost:8080/jeecg-boot").TrimEnd('/');
|
||||
private int DefaultTenantId => (int?)_configuration.GetValue<long?>("JeecgIntegration:DefaultTenantId") ?? 1002;
|
||||
private HttpClient CreateClient() => _httpClientFactory.CreateClient("JeecgApi");
|
||||
|
||||
private async Task LoadCacheAsync()
|
||||
@@ -84,7 +85,8 @@ public class MixerMaterialService : IMixerMaterialService, ISingletonDependency
|
||||
|
||||
public async Task SyncFromRemoteAsync(CancellationToken ct = default)
|
||||
{
|
||||
if (!await _syncLock.WaitAsync(0, ct).ConfigureAwait(false)) return;
|
||||
// 等待当前正在进行的同步结束,再执行本次同步(WaitAsync(0) 会静默跳过,导致 STOMP 通知丢失)
|
||||
await _syncLock.WaitAsync(ct).ConfigureAwait(false);
|
||||
try
|
||||
{
|
||||
var all = new List<MesMixerMaterial>();
|
||||
@@ -96,10 +98,15 @@ public class MixerMaterialService : IMixerMaterialService, ISingletonDependency
|
||||
var qs = HttpUtility.ParseQueryString(string.Empty);
|
||||
qs["pageNo"] = pageNo.ToString();
|
||||
qs["pageSize"] = pageSize.ToString();
|
||||
// mes_mixer_material 不在多租户隔离表中,不传 tenantId 可拉取全部记录
|
||||
var url = $"{BaseUrl}/mes/material/mixerMaterial/anon/list?{qs}";
|
||||
using var client = CreateClient();
|
||||
var resp = await client.GetAsync(url, ct).ConfigureAwait(false);
|
||||
if (!resp.IsSuccessStatusCode) break;
|
||||
if (!resp.IsSuccessStatusCode)
|
||||
{
|
||||
_logger.Warning($"[密炼物料] 同步请求失败,状态码:{(int)resp.StatusCode}");
|
||||
break;
|
||||
}
|
||||
|
||||
var json = await resp.Content.ReadAsStringAsync(ct).ConfigureAwait(false);
|
||||
using var doc = JsonDocument.Parse(json);
|
||||
@@ -119,6 +126,10 @@ public class MixerMaterialService : IMixerMaterialService, ISingletonDependency
|
||||
await SaveCacheAsync(all).ConfigureAwait(false);
|
||||
_logger.Information($"[密炼物料] 同步完成,共 {all.Count} 条");
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Warning("[密炼物料] 同步返回 0 条,可能是 tenantId 配置有误或网络异常,保留原缓存");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user