From f81c33a58bb17a84aae98d31fc3bcfdddd4f76fd Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期五, 06 三月 2026 17:11:50 +0800
Subject: [PATCH] feat: 添加自动出库任务配置模型类
---
Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockSerivce.cs | 80 ++++++++++++++++++++++++++++++----------
1 files changed, 60 insertions(+), 20 deletions(-)
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockSerivce.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockSerivce.cs
index 64f19fc..c7ad96a 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockSerivce.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockSerivce.cs
@@ -1,4 +1,5 @@
锘縰sing WIDESEA_Common.StockEnum;
+using WIDESEA_Core;
using WIDESEA_DTO.Stock;
using WIDESEA_IStockService;
using WIDESEA_Model.Models;
@@ -30,8 +31,9 @@
/// <summary>
/// 缁勭洏
/// </summary>
- public async Task<bool> GroupPallet(StockDTO stock)
+ public async Task<WebResponseContent> GroupPalletAsync(StockDTO stock)
{
+ WebResponseContent content = new WebResponseContent();
var now = DateTime.Now;
var details = stock.Details.Select(item => new Dt_StockInfoDetail
{
@@ -49,10 +51,13 @@
}).ToList();
var existingStock = StockInfoService.Repository.QueryFirst(s => s.PalletCode == stock.TargetPalletNo);
+ var result = false;
if (existingStock != null)
{
details.ForEach(d => d.StockId = existingStock.Id);
- return await StockInfoDetailService.Repository.AddDataAsync(details) > 0;
+ result = await StockInfoDetailService.Repository.AddDataAsync(details) > 0;
+ if (result) return content.OK("缁勭洏鎴愬姛");
+ return content.Error("缁勭洏澶辫触");
}
var entity = new Dt_StockInfo
@@ -64,24 +69,27 @@
Details = details
};
- return StockInfoService.Repository.AddData(entity, x => x.Details);
+ result = StockInfoService.Repository.AddData(entity, x => x.Details);
+ if (result) return content.OK("缁勭洏鎴愬姛");
+ return content.Error("缁勭洏澶辫触");
}
/// <summary>
/// 鎹㈢洏
/// </summary>
- public async Task<bool> ChangePallet(StockDTO stock)
+ public async Task<WebResponseContent> ChangePalletAsync(StockDTO stock)
{
+ WebResponseContent content = new WebResponseContent();
if (stock == null ||
string.IsNullOrWhiteSpace(stock.TargetPalletNo) ||
string.IsNullOrWhiteSpace(stock.SourcePalletNo) ||
string.Equals(stock.SourcePalletNo, stock.TargetPalletNo, StringComparison.OrdinalIgnoreCase))
{
- return false;
+ return content.Error("婧愭墭鐩樺彿涓庣洰鏍囨墭鐩樺彿鐩稿悓");
}
var sourceStock = StockInfoService.Repository.QueryFirst(s => s.PalletCode == stock.SourcePalletNo);
- if (sourceStock == null) return false;
+ if (sourceStock == null) return content.Error("婧愭墭鐩樹笉瀛樺湪");
var targetStock = StockInfoService.Repository.QueryFirst(s => s.PalletCode == stock.TargetPalletNo);
if (targetStock == null)
@@ -95,54 +103,86 @@
};
var newId = StockInfoService.Repository.AddData(newStock);
- if (newId <= 0) return false;
+ if (newId <= 0) return content.Error("鎹㈢洏澶辫触");
targetStock = newStock;
targetStock.Id = newId;
}
var serialNumbers = stock.Details.Select(d => d.CellBarcode).Distinct().ToList();
- if (!serialNumbers.Any()) return false;
+ if (!serialNumbers.Any()) return content.Error("鏈壘鍒版湁鏁堢殑搴忓垪鍙�");
var detailEntities = StockInfoDetailService.Repository.QueryData(
d => d.StockId == sourceStock.Id && serialNumbers.Contains(d.SerialNumber));
- if (!detailEntities.Any()) return false;
+ if (!detailEntities.Any()) return content.Error("鏈壘鍒版湁鏁堢殑搴撳瓨鏄庣粏");
if (await StockInfoDetail_HtyService.Repository.AddDataAsync(CreateDetailHistory(detailEntities, "鎹㈢洏")) <= 0)
- return false;
+ return content.Error("鎹㈢洏鍘嗗彶璁板綍淇濆瓨澶辫触");
if (await StockInfo_HtyService.Repository.AddDataAsync(CreateStockHistory(new[] { sourceStock, targetStock }, "鎹㈢洏")) <= 0)
- return false;
+ return content.Error("鎹㈢洏鍘嗗彶璁板綍淇濆瓨澶辫触");
detailEntities.ForEach(d => d.StockId = targetStock.Id);
- return await StockInfoDetailService.Repository.UpdateDataAsync(detailEntities);
+ var result = await StockInfoDetailService.Repository.UpdateDataAsync(detailEntities);
+ if (!result) return content.Error("鎹㈢洏澶辫触");
+ return content.OK("鎹㈢洏鎴愬姛");
}
/// <summary>
/// 鎷嗙洏
/// </summary>
- public async Task<bool> SplitPallet(StockDTO stock)
+ public async Task<WebResponseContent> SplitPalletAsync(StockDTO stock)
{
+ WebResponseContent content = new WebResponseContent();
if (stock == null || string.IsNullOrWhiteSpace(stock.SourcePalletNo))
- return false;
+ return content.Error("婧愭墭鐩樺彿涓嶈兘涓虹┖");
var sourceStock = StockInfoService.Repository.QueryFirst(s => s.PalletCode == stock.SourcePalletNo);
- if (sourceStock == null) return false;
+ if (sourceStock == null) return content.Error("婧愭墭鐩樹笉瀛樺湪");
var serialNumbers = stock.Details.Select(d => d.CellBarcode).Distinct().ToList();
- if (!serialNumbers.Any()) return false;
+ if (!serialNumbers.Any())
+ {
+ serialNumbers = sourceStock.Details
+ .Where(x => stock.Details.Any(d => d.Channel == x.InboundOrderRowNo))
+ .Select(x => x.SerialNumber)
+ .ToList();
+ }
var detailEntities = StockInfoDetailService.Repository.QueryData(
d => d.StockId == sourceStock.Id && serialNumbers.Contains(d.SerialNumber));
- if (!detailEntities.Any()) return false;
+ if (!detailEntities.Any()) return content.Error("鏈壘鍒版湁鏁堢殑搴撳瓨鏄庣粏");
if (await StockInfoDetail_HtyService.Repository.AddDataAsync(CreateDetailHistory(detailEntities, "鎷嗙洏")) <= 0)
- return false;
+ return content.Error("鎷嗙洏鍘嗗彶璁板綍淇濆瓨澶辫触");
if (await StockInfo_HtyService.Repository.AddDataAsync(CreateStockHistory(new[] { sourceStock }, "鎷嗙洏")) <= 0)
- return false;
+ return content.Error("鎷嗙洏鍘嗗彶璁板綍淇濆瓨澶辫触");
- return await StockInfoDetailService.Repository.DeleteDataAsync(detailEntities);
+ var result = await StockInfoDetailService.Repository.DeleteDataAsync(detailEntities);
+ if (!result) return content.Error("鎷嗙洏澶辫触");
+ return content.OK("鎷嗙洏鎴愬姛");
+ }
+
+ /// <summary>
+ /// 鍫嗗灈鏈烘崲鐩樺悗鏇存柊搴撳瓨淇℃伅锛堟竻绌哄簱浣嶄俊鎭級
+ /// </summary>
+ /// <param name="stock"></param>
+ /// <returns></returns>
+ public async Task<WebResponseContent> UpdateStockInfoAsync(StockInfoDTO stock)
+ {
+ WebResponseContent content = new WebResponseContent();
+ if (string.IsNullOrWhiteSpace(stock.PalletCode)) return content.Error("鎵樼洏鍙蜂笉鑳戒负绌�");
+
+ var existingStock = StockInfoService.Repository.QueryFirst(s => s.PalletCode == stock.PalletCode);
+ if (existingStock == null) return content.Error("鎵樼洏淇℃伅涓嶅瓨鍦�");
+
+ existingStock.LocationCode = "";
+ existingStock.LocationId = 0;
+
+ var result = await StockInfoService.Repository.UpdateDataAsync(existingStock);
+ if (!result) return content.Error("鏇存柊搴撳瓨淇℃伅澶辫触");
+ return content.OK("鏇存柊搴撳瓨淇℃伅鎴愬姛");
}
private static List<Dt_StockInfoDetail_Hty> CreateDetailHistory(IEnumerable<Dt_StockInfoDetail> details, string operateType)
--
Gitblit v1.9.3