From 5bf10c1dafe485d506ec534f98e5220a3b83dd17 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期四, 16 四月 2026 23:16:46 +0800
Subject: [PATCH] feat(WCS&WMS): 机械手扫码NG处理与线体条码读取与添加批量MES绑定解绑接口
---
Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockSerivce.cs | 146 ++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 139 insertions(+), 7 deletions(-)
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockSerivce.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockSerivce.cs
index 6b13364..8fde2b8 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockSerivce.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockSerivce.cs
@@ -1,4 +1,5 @@
-锘縰sing SqlSugar;
+锘縰sing Newtonsoft.Json;
+using SqlSugar;
using WIDESEA_Common.Constants;
using WIDESEA_Common.StockEnum;
using WIDESEA_Core;
@@ -41,6 +42,11 @@
public IWarehouseService _warehouseService { get; }
/// <summary>
+ /// SqlSugar瀹㈡埛绔紙鐢ㄤ簬涓存椂琛ㄦ搷浣滐級
+ /// </summary>
+ public ISqlSugarClient SqlSugarClient { get; }
+
+ /// <summary>
/// Mes鎺ュ彛鏈嶅姟
/// </summary>
public IMesService _mesService { get; }
@@ -58,7 +64,8 @@
IStockInfoDetail_HtyService stockInfoDetail_HtyService,
IStockInfo_HtyService stockInfo_HtyService,
IMesService mesService,
- IWarehouseService warehouseService)
+ IWarehouseService warehouseService,
+ ISqlSugarClient sqlSugarClient)
{
StockInfoDetailService = stockInfoDetailService;
StockInfoService = stockInfoService;
@@ -66,6 +73,7 @@
StockInfo_HtyService = stockInfo_HtyService;
_mesService = mesService;
_warehouseService = warehouseService;
+ SqlSugarClient = sqlSugarClient;
}
/// <summary>
@@ -179,11 +187,11 @@
result = StockInfoService.Repository.AddData(entity, x => x.Details);
if (!result) return content.Error("缁勭洏澶辫触");
- //var mesResult = _mesService.BindContainer(bindRequest);
- //if (mesResult == null || mesResult.Data == null || !mesResult.Data.IsSuccess)
- //{
- // return content.Error($"缁勭洏鎴愬姛锛屼絾MES缁戝畾澶辫触: {mesResult?.Data?.Msg ?? mesResult?.ErrorMessage ?? "鏈煡閿欒"}");
- //}
+ var mesResult = _mesService.BindContainer(bindRequest);
+ if (mesResult == null || mesResult.Data == null || !mesResult.Data.IsSuccess)
+ {
+ return content.Error($"缁勭洏鎴愬姛锛屼絾MES缁戝畾澶辫触: {mesResult?.Data?.Msg ?? mesResult?.ErrorMessage ?? "鏈煡閿欒"}");
+ }
return content.OK("缁勭洏鎴愬姛");
});
}
@@ -303,6 +311,30 @@
{
if (stock == null || string.IsNullOrWhiteSpace(stock.SourcePalletNo))
return content.Error("婧愭墭鐩樺彿涓嶈兘涓虹┖");
+
+ // 骞傜瓑鍐欏叆锛氭鏌ヤ复鏃惰〃鏄惁宸叉湁璇ユ墭鐩樿褰曪紝鏃犲垯鍐欏叆
+ var existingTemp = SqlSugarClient.Queryable<Dt_SplitTemp>()
+ .Where(t => t.PalletCode == stock.SourcePalletNo)
+ .First();
+ if (existingTemp == null)
+ {
+ // 鏌ヨ璇ユ墭鐩樺綋鍓嶆墍鏈夌數鑺紝瀛樺叆涓存椂琛�
+ var sourceStockForTemp = StockInfoService.Repository.QueryFirst(s => s.PalletCode == stock.SourcePalletNo);
+ if (sourceStockForTemp != null)
+ {
+ var allDetails = StockInfoDetailService.Repository.QueryData(d => d.StockId == sourceStockForTemp.Id);
+ if (allDetails != null && allDetails.Any())
+ {
+ var sfcListJson = JsonConvert.SerializeObject(allDetails.Select(d => d.SerialNumber).ToList());
+ await SqlSugarClient.Insertable(new Dt_SplitTemp
+ {
+ PalletCode = stock.SourcePalletNo,
+ SfcList = sfcListJson,
+ CreateTime = DateTime.Now
+ }).ExecuteCommandAsync();
+ }
+ }
+ }
return await ExecuteWithinTransactionAsync(async () =>
{
@@ -426,5 +458,105 @@
OutboundDate = s.OutboundDate
}).ToList();
}
+
+ /// <summary>
+ /// 鎵归噺鎷嗙洏纭 - 涓�娆℃�ц皟鐢∕ES瑙g粦鏁翠釜鎵樼洏
+ /// </summary>
+ /// <param name="palletCode">婧愭墭鐩樺彿</param>
+ /// <returns>鎿嶄綔缁撴灉</returns>
+ public async Task<WebResponseContent> SplitPalletConfirmAsync(string palletCode)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ if (string.IsNullOrWhiteSpace(palletCode))
+ return content.Error("鎵樼洏鍙蜂笉鑳戒负绌�");
+
+ // 1. 浠庝复鏃惰〃璇诲彇鐢佃姱鍒楄〃
+ var tempRecord = SqlSugarClient.Queryable<Dt_SplitTemp>()
+ .Where(t => t.PalletCode == palletCode)
+ .First();
+ if (tempRecord == null)
+ return content.Error("鏈壘鍒版媶鐩樹复鏃惰褰曪紝璇峰厛鎵ц鎷嗙洏鎿嶄綔");
+
+ var sfcList = JsonConvert.DeserializeObject<List<string>>(tempRecord.SfcList);
+ if (sfcList == null || !sfcList.Any())
+ return content.Error("涓存椂琛ㄤ腑鐢佃姱鍒楄〃涓虹┖");
+
+ // 2. 璋冪敤MES瑙g粦
+ var unbindRequest = new UnBindContainerRequest
+ {
+ EquipmentCode = StockConstants.MES_EQUIPMENT_CODE,
+ ResourceCode = StockConstants.MES_RESOURCE_CODE,
+ LocalTime = DateTime.Now,
+ ContainCode = palletCode,
+ SfcList = sfcList
+ };
+ var unbindResult = _mesService.UnBindContainer(unbindRequest);
+ if (unbindResult == null || unbindResult.Data == null || !unbindResult.Data.IsSuccess)
+ {
+ return content.Error($"MES瑙g粦澶辫触: {unbindResult?.Data?.Msg ?? unbindResult?.ErrorMessage ?? "鏈煡閿欒"}");
+ }
+
+ // 3. 鍒犻櫎涓存椂琛ㄨ褰�
+ await SqlSugarClient.Deleteable<Dt_SplitTemp>().Where(t => t.PalletCode == palletCode).ExecuteCommandAsync();
+
+ return content.OK("鎵归噺鎷嗙洏纭鎴愬姛");
+ }
+ catch (Exception ex)
+ {
+ return content.Error($"鎵归噺鎷嗙洏纭澶辫触: {ex.Message}");
+ }
+ }
+
+ /// <summary>
+ /// 鎵归噺缁勭洏纭 - 涓�娆℃�ц皟鐢∕ES缁戝畾鏁翠釜鎵樼洏
+ /// </summary>
+ /// <param name="palletCode">鐩爣鎵樼洏鍙�</param>
+ /// <returns>鎿嶄綔缁撴灉</returns>
+ public async Task<WebResponseContent> GroupPalletConfirmAsync(string palletCode)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ if (string.IsNullOrWhiteSpace(palletCode))
+ return content.Error("鎵樼洏鍙蜂笉鑳戒负绌�");
+
+ // 1. 鏌ヨ璇ユ墭鐩樹笅鐨勬墍鏈夌數鑺槑缁�
+ var stockInfo = StockInfoService.Repository.QueryFirst(s => s.PalletCode == palletCode);
+ if (stockInfo == null)
+ return content.Error("鎵樼洏涓嶅瓨鍦�");
+
+ var details = StockInfoDetailService.Repository.QueryData(d => d.StockId == stockInfo.Id);
+ if (details == null || !details.Any())
+ return content.Error("鎵樼洏涓嬫棤鐢佃姱鏁版嵁");
+
+ // 2. 璋冪敤MES缁戝畾
+ var bindRequest = new BindContainerRequest
+ {
+ ContainerCode = palletCode,
+ EquipmentCode = StockConstants.MES_EQUIPMENT_CODE,
+ ResourceCode = StockConstants.MES_RESOURCE_CODE,
+ LocalTime = DateTime.Now,
+ OperationType = StockConstants.MES_BIND_OPERATION_TYPE,
+ ContainerSfcList = details.Select(d => new ContainerSfcItem
+ {
+ Sfc = d.SerialNumber,
+ Location = d.InboundOrderRowNo.ToString()
+ }).ToList()
+ };
+ var bindResult = _mesService.BindContainer(bindRequest);
+ if (bindResult == null || bindResult.Data == null || !bindResult.Data.IsSuccess)
+ {
+ return content.Error($"MES缁戝畾澶辫触: {bindResult?.Data?.Msg ?? bindResult?.ErrorMessage ?? "鏈煡閿欒"}");
+ }
+
+ return content.OK("鎵归噺缁勭洏纭鎴愬姛");
+ }
+ catch (Exception ex)
+ {
+ return content.Error($"鎵归噺缁勭洏纭澶辫触: {ex.Message}");
+ }
+ }
}
}
\ No newline at end of file
--
Gitblit v1.9.3