From e354b5938f49ac90b237289923dcde923d22daf5 Mon Sep 17 00:00:00 2001
From: heshaofeng <heshaofeng@hnkhzn.com>
Date: 星期四, 20 十一月 2025 09:08:27 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/ZhongRui/ALDbanyunxiangmu
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutStockLockInfoService.cs | 190 ++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 177 insertions(+), 13 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutStockLockInfoService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutStockLockInfoService.cs"
index a48a488..0e84c80 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutStockLockInfoService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutStockLockInfoService.cs"
@@ -1,4 +1,5 @@
-锘縰sing System;
+锘縰sing Microsoft.AspNetCore.Http;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -10,6 +11,7 @@
using WIDESEA_Core.BaseServices;
using WIDESEA_Core.Enums;
using WIDESEA_Core.Helper;
+using WIDESEA_DTO.Outbound;
using WIDESEA_IRecordService;
using WIDESEA_IStockService;
using WIDESEA_Model.Models;
@@ -32,11 +34,58 @@
_recordService = recordService;
}
- public Dt_OutStockLockInfo GetOutStockLockInfo(Dt_OutboundOrder outboundOrder, Dt_OutboundOrderDetail outboundOrderDetail, Dt_StockInfo outStock, decimal assignQuantity, int? taskNum = null)
- {
- Dt_OutStockLockInfo outStockLockInfo = new Dt_OutStockLockInfo()
+ /// <summary>
+ /// 鍒涘缓鍑哄簱閿佸畾
+ /// </summary>
+ public Dt_OutStockLockInfo GetOutStockLockInfo(
+ Dt_OutboundOrder outboundOrder,
+ Dt_OutboundOrderDetail outboundOrderDetail,
+ Dt_StockInfo outStock,
+ decimal assignQuantity,
+ string barcode = null)
+ {
+ // 鑾峰彇搴撳瓨鏄庣粏淇℃伅
+ var stockDetails = outStock.Details
+ .Where(x => x.MaterielCode == outboundOrderDetail.MaterielCode)
+ .ToList();
+
+ if (!stockDetails.Any())
{
+ throw new Exception($"鏈壘鍒扮墿鏂橻{outboundOrderDetail.MaterielCode}]鐨勫簱瀛樻槑缁�");
+ }
+
+ // 纭畾鏉$爜
+ string targetBarcode;
+ if (!string.IsNullOrEmpty(barcode))
+ {
+ // 楠岃瘉鎸囧畾鐨勬潯鐮佹槸鍚﹀瓨鍦�
+ var specifiedBarcodeDetail = stockDetails.FirstOrDefault(x => x.Barcode == barcode);
+ if (specifiedBarcodeDetail == null)
+ {
+ throw new Exception($"鎸囧畾鐨勬潯鐮乕{barcode}]鍦ㄥ簱瀛樹腑涓嶅瓨鍦�");
+ }
+ targetBarcode = barcode;
+ }
+ else
+ {
+ // 浣跨敤绗竴涓彲鐢ㄦ潯鐮�
+ var firstAvailableDetail = stockDetails
+ .Where(x => x.StockQuantity > x.OutboundQuantity)
+ .OrderBy(x => x.CreateDate)
+ .FirstOrDefault();
+
+ if (firstAvailableDetail == null)
+ {
+ throw new Exception($"鐗╂枡[{outboundOrderDetail.MaterielCode}]娌℃湁鍙敤搴撳瓨");
+ }
+ targetBarcode = firstAvailableDetail.Barcode;
+ }
+
+ return new Dt_OutStockLockInfo()
+ {
+ lineNo= outboundOrderDetail.lineNo,
+
PalletCode = outStock.PalletCode,
AssignQuantity = assignQuantity,
MaterielCode = outboundOrderDetail.MaterielCode,
@@ -45,18 +94,133 @@
MaterielName = outboundOrderDetail.MaterielName,
OrderDetailId = outboundOrderDetail.Id,
OrderNo = outboundOrder.OrderNo,
- OrderType = outboundOrder.OrderType,
- OriginalQuantity = outStock.Details.Where(x => x.MaterielCode == outboundOrderDetail.MaterielCode).Sum(x => x.StockQuantity),
- Status = taskNum == null ? OutLockStockStatusEnum.宸插垎閰�.ObjToInt() : OutLockStockStatusEnum.鍑哄簱涓�.ObjToInt(),
- StockId = outStock.Id,
- TaskNum = taskNum,
OrderQuantity = outboundOrderDetail.OrderQuantity,
+ OriginalQuantity = outStock.Details
+ .Where(x => x.MaterielCode == outboundOrderDetail.MaterielCode)
+ .Sum(x => x.StockQuantity),
+ Status = (int)OutLockStockStatusEnum.宸插垎閰�,
+ StockId = outStock.Id,
Unit = outboundOrderDetail.Unit,
- //ProductionDate = outStock.Details.Where(x => x.MaterielCode == outboundOrderDetail.MaterielCode).FirstOrDefault()?.ProductionDate,
- //EffectiveDate = outStock.Details.Where(x => x.MaterielCode == outboundOrderDetail.MaterielCode).FirstOrDefault()?.EffectiveDate
+ FactoryArea = outboundOrder.FactoryArea,
+ OrderType=outboundOrder.OrderType,
+ SupplyCode = outboundOrderDetail.SupplyCode,
+ WarehouseCode = outboundOrderDetail.WarehouseCode,
+ // 鏂板瀛楁
+ CurrentBarcode = targetBarcode,
+ OriginalLockQuantity = assignQuantity,
+ IsSplitted = 0
};
-
- return outStockLockInfo;
}
+ /// <summary>
+ /// 鏍规嵁璁㈠崟鏄庣粏ID鑾峰彇鍑哄簱閿佸畾淇℃伅
+ /// </summary>
+ public async Task<List<Dt_OutStockLockInfo>> GetByOrderDetailId(int orderDetailId)
+ {
+ return await Db.Queryable<Dt_OutStockLockInfo>()
+ .Where(x => x.OrderDetailId == orderDetailId)
+ .OrderBy(x => x.Id)
+ .ToListAsync();
+ }
+
+ public async Task<LockInfoDetailDto> GetLockInfoDetail(int lockInfoId)
+ {
+ var lockInfo = await Db.Queryable<Dt_OutStockLockInfo>()
+ .LeftJoin<Dt_OutboundOrderDetail>((lockInfo, detail) => lockInfo.OrderDetailId == detail.Id)
+ .Where((lockInfo, detail) => lockInfo.Id == lockInfoId)
+ .Select((lockInfo, detail) => new LockInfoDetailDto
+ {
+ Id = lockInfo.Id,
+ OrderNo = lockInfo.OrderNo,
+ OrderDetailId = lockInfo.OrderDetailId,
+ BatchNo = lockInfo.BatchNo,
+ MaterielCode = lockInfo.MaterielCode,
+ StockId = lockInfo.StockId,
+ OrderQuantity = lockInfo.OrderQuantity,
+ OriginalQuantity = lockInfo.OriginalQuantity,
+ AssignQuantity = lockInfo.AssignQuantity,
+ PickedQty = lockInfo.PickedQty,
+ LocationCode = lockInfo.LocationCode,
+ PalletCode = lockInfo.PalletCode,
+ Status = lockInfo.Status,
+ IsSplitted = lockInfo.IsSplitted,
+ ParentLockId = lockInfo.ParentLockId,
+
+ MaterielName = detail.MaterielName,
+ Unit = detail.Unit
+ })
+ .FirstAsync();
+
+ return lockInfo;
+ }
+
+ /// <summary>
+ /// 鏍规嵁鎵樼洏缂栧彿鑾峰彇鍑哄簱閿佸畾淇℃伅
+ /// </summary>
+ public async Task<List<Dt_OutStockLockInfo>> GetByPalletCode(string palletCode, int? status = null)
+ {
+ var query = Db.Queryable<Dt_OutStockLockInfo>()
+ .Where(x => x.PalletCode == palletCode);
+
+ if (status.HasValue)
+ {
+ query = query.Where(x => x.Status == status.Value);
+ }
+
+ return await query.OrderBy(x => x.Id).ToListAsync();
+ }
+
+ /// <summary>
+ /// 鑾峰彇鎵樼洏鐨勯攣瀹氫俊鎭�
+ /// </summary>
+ public async Task<List<Dt_OutStockLockInfo>> GetPalletLockInfos(string palletCode)
+ {
+ return await Db.Queryable<Dt_OutStockLockInfo>()
+ .Where(x => x.PalletCode == palletCode && x.Status == (int)OutLockStockStatusEnum.鍑哄簱涓�)
+ .ToListAsync();
+ }
+
+ /// <summary>
+ /// 鏇存柊鍑哄簱閿佸畾淇℃伅鐨勬潯鐮侊紙鐢ㄤ簬鎷嗗寘鎿嶄綔锛�
+ /// </summary>
+ public async Task<WebResponseContent> UpdateLockInfoBarcode(int lockInfoId, string newBarcode)
+ {
+ try
+ {
+ var lockInfo = await Db.Queryable<Dt_OutStockLockInfo>()
+ .Where(x => x.Id == lockInfoId)
+ .FirstAsync();
+
+ if (lockInfo == null)
+ return WebResponseContent.Instance.Error("鏈壘鍒板嚭搴撻攣瀹氫俊鎭�");
+
+ // 楠岃瘉鏂版潯鐮佹槸鍚﹀瓨鍦�
+ var stockDetail = await Db.Queryable<Dt_StockInfoDetail>()
+ .Where(x => x.Barcode == newBarcode &&
+ x.StockId == lockInfo.StockId &&
+ x.MaterielCode == lockInfo.MaterielCode)
+ .FirstAsync();
+
+ if (stockDetail == null)
+ return WebResponseContent.Instance.Error("鏂版潯鐮佸湪搴撳瓨涓笉瀛樺湪");
+
+ // 鏇存柊鏉$爜鍜屾媶鍖呯姸鎬�
+ lockInfo.CurrentBarcode = newBarcode;
+ lockInfo.IsSplitted = 1;
+
+ await Db.Updateable(lockInfo).ExecuteCommandAsync();
+
+ return WebResponseContent.Instance.OK("鏇存柊鏉$爜鎴愬姛");
+ }
+ catch (Exception ex)
+ {
+ return WebResponseContent.Instance.Error($"鏇存柊鏉$爜澶辫触: {ex.Message}");
+ }
+ }
+
+ public List<Dt_OutStockLockInfo> GetByOrderDetailId(int orderDetailId, OutLockStockStatusEnum? outStockStatus)
+ {
+ return BaseDal.QueryData(x => x.OrderDetailId == orderDetailId && outStockStatus == null ? true : x.Status == outStockStatus.ObjToInt());
+ }
+
}
}
--
Gitblit v1.9.3