wankeda
2026-01-19 e83c793bebdb1b9ecdcd79fab8d83fd167baa817
盘点流程
已添加8个文件
已删除1个文件
已修改13个文件
661 ■■■■■ 文件已修改
WMS/WIDESEA_WMSServer/.vs/ProjectEvaluation/widesea_wmsserver.strings.v9.bin 补丁 | 查看 | 原始文档 | blame | 历史
WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.995.13737/CodeChunks.db 补丁 | 查看 | 原始文档 | blame | 历史
WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.995.13737/SemanticSymbols.db 补丁 | 查看 | 原始文档 | blame | 历史
WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/46068755-0c27-498e-b4ef-d2ee7f39e8af.vsidx 补丁 | 查看 | 原始文档 | blame | 历史
WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/475e0097-8d79-4ade-8115-2df3f6920ebc.vsidx 补丁 | 查看 | 原始文档 | blame | 历史
WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/495dcb7d-0808-4295-8344-22604b0512d1.vsidx 补丁 | 查看 | 原始文档 | blame | 历史
WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/8243996f-363c-4613-87cd-1d30cb87c16e.vsidx 补丁 | 查看 | 原始文档 | blame | 历史
WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/b8266b88-93a1-4523-87b3-6859ba57591b.vsidx 补丁 | 查看 | 原始文档 | blame | 历史
WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/c62f823c-87b1-4254-8b92-340321c32c9b.vsidx 补丁 | 查看 | 原始文档 | blame | 历史
WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Base/PalletTypeInfoService.cs 75 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Service/AssignLocation/LocationInfoService_FL.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Service/LocationInfoService_Common.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
WMS/WIDESEA_WMSServer/WIDESEA_IBasicService/IPalletTypeInfoService.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WMS/WIDESEA_WMSServer/WIDESEA_IInboundService/IInboundOrderService.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WMS/WIDESEA_WMSServer/WIDESEA_IStockService/IStockInfoService.cs 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Base/InboundOrderService.cs 44 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WMS/WIDESEA_WMSServer/WIDESEA_Model/Models/Basic/Dt_PrintSetting.cs 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/Service/OutboundOrderDetailService.cs 33 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WMS/WIDESEA_WMSServer/WIDESEA_StockService/Service/StockInfoService.cs 107 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs 322 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Inbound/InboundOrderController.cs 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WMS/WIDESEA_WMSServer/.vs/ProjectEvaluation/widesea_wmsserver.strings.v9.bin
Binary files differ
WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.995.13737/CodeChunks.db
Binary files differ
WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.995.13737/SemanticSymbols.db
Binary files differ
WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/46068755-0c27-498e-b4ef-d2ee7f39e8af.vsidx
Binary files differ
WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/475e0097-8d79-4ade-8115-2df3f6920ebc.vsidx
Binary files differ
WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/495dcb7d-0808-4295-8344-22604b0512d1.vsidx
Binary files differ
WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/8243996f-363c-4613-87cd-1d30cb87c16e.vsidx
Binary files differ
WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/b8266b88-93a1-4523-87b3-6859ba57591b.vsidx
Binary files differ
WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/c62f823c-87b1-4254-8b92-340321c32c9b.vsidx
Binary files differ
WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Base/PalletTypeInfoService.cs
@@ -1,9 +1,13 @@
using System;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Core;
using WIDESEA_Core.BaseServices;
using WIDESEA_Core.Const;
using WIDESEA_IBasicRepository;
using WIDESEA_IBasicService;
using WIDESEA_Model.Models;
@@ -15,5 +19,74 @@
        public PalletTypeInfoService(IPalletTypeInfoRepository BaseDal) : base(BaseDal)
        {
        }
        /// <summary>
        /// æ‰“印托盘码
        /// </summary>
        /// <param name="num"></param>
        /// <returns></returns>
        public WebResponseContent PrintPalletCode(int num, string palletCodeType)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                List<string> PalletCodes = new List<string>();
                for (int i = 0; i < num; i++)
                {
                    //PalletCodes.Add(GetOrderPintCode("PalletCodes"),palletCodeType);
                }
                content= PrintPallet(PalletCodes);
                return content.OK();
            }
            catch (Exception ex)
            {
                return content.Error("未知错误,请联系管理员");
            }
        }
        /// <summary>
        /// èŽ·å–è®¢å•ç¼–å·
        /// </summary>
        /// <param name="printCode"></param>
        /// <returns></returns>
        public string GetOrderPintCode(string printCode,string palletCodeType)
        {
            string PrintCode = "";
            //var PrintSetting = SqlSugarHelper.DbWMS.Queryable<Dt_PrintSetting>().Where(x => x.PrintCode == printCode).ToList().FirstOrDefault();
            //if (PrintSetting.Spare1 == DateTime.Now.ToString("yyyyMMdd"))
            //{
            //    PrintCode = PrintSetting.Spare1 + PrintSetting.PrintNo.ToString().PadLeft(PrintSetting.Spare2, '0');
            //    PrintSetting.PrintNo = PrintSetting.PrintNo + 1;
            //}
            //else
            //{
            //    PrintSetting.Spare1 = DateTime.Now.ToString("yyyyMMdd");
            //    PrintSetting.PrintNo = 2;
            //    PrintCode = PrintSetting.Spare1 + 1.ToString().PadLeft(PrintSetting.Spare2, '0');
            //}
            //SqlSugarHelper.DbWMS.Updateable(PrintSetting).ExecuteCommand();
            return PrintCode;
        }
        /// <summary>
        /// è°ƒç”¨æ‰“印托盘码接口
        /// </summary>
        /// <param name="palletCodes"></param>
        /// <returns></returns>
        /// <exception cref="InvalidOperationException"></exception>
        public WebResponseContent PrintPallet(List<string> palletCodes)
        {
            var Base = "";
            var ipAddress = "";
            if (Base == null || ipAddress == null)
            {
                throw new InvalidOperationException("WMS IP æœªé…ç½®");
            }
            var IpAddress = Base + ipAddress;
            //var result = HttpsClient.PostAsync(palletCodes.ToJsonString()).Result;
            //return JsonConvert.DeserializeObject<WebResponseContent>();
            return WebResponseContent.Instance.OK();
        }
    }
}
WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Service/AssignLocation/LocationInfoService_FL.cs
@@ -90,7 +90,7 @@
                if (palletTypeInfo.LocaitonCount == 2)
                {
                    if (roadwayNo != "SC01_FL")
                    if (roadwayNo != "SC01_DW")
                        definedTypeEmptyLocations = definedTypeEmptyLocations.Where(x => x.Column % 2 == 1).ToList();
                    else
                        definedTypeEmptyLocations = definedTypeEmptyLocations.Where(x => x.Column % 2 == 0).ToList();
@@ -122,7 +122,7 @@
                {
                    if (palletTypeInfo.LocaitonCount == 2)
                    {
                        if (roadwayNo != "SC01_FL")
                        if (roadwayNo != "SC01_DW")
                            undefinedTypeEmptyLocations = undefinedTypeEmptyLocations.Where(x => x.Column % 2 == 1).ToList();
                        else
                            undefinedTypeEmptyLocations = undefinedTypeEmptyLocations.Where(x => x.Column % 2 == 0).ToList();
WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Service/LocationInfoService_Common.cs
@@ -52,7 +52,7 @@
                "SC01_CP" => AssignLocation_CP(roadwayNo, palletType, palletTypeInfo, beRelocationCode, heightType),
                "SC02_CP" => AssignLocation_CP(roadwayNo, palletType, palletTypeInfo, beRelocationCode, heightType),
                "SC01_YS" => AssignLocation_YS(roadwayNo, palletType, palletTypeInfo, beRelocationCode, heightType),
                "SC01_FL" => AssignLocation_FL(roadwayNo, palletType, palletTypeInfo, beRelocationCode, heightType),
                "SC01_DW" => AssignLocation_FL(roadwayNo, palletType, palletTypeInfo, beRelocationCode, heightType),
                //"HA58" => AssignLocation_PP(roadwayNo, palletType, palletTypeInfo, beRelocationCode),
                //"HA152" => AssignLocation_GM(roadwayNo, palletType, palletTypeInfo, beRelocationCode),
                //"HA64" => AssignLocation_CSJ(roadwayNo, palletType, palletTypeInfo, beRelocationCode),
WMS/WIDESEA_WMSServer/WIDESEA_IBasicService/IPalletTypeInfoService.cs
@@ -3,6 +3,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Core;
using WIDESEA_Core.BaseServices;
using WIDESEA_Model.Models;
@@ -10,5 +11,8 @@
{
    public interface IPalletTypeInfoService : IService<Dt_PalletTypeInfo>
    {
        WebResponseContent PrintPalletCode(int num, string palletCodeType);
        string GetOrderPintCode(string printCode,string palletCodeType);
    }
}
WMS/WIDESEA_WMSServer/WIDESEA_IInboundService/IInboundOrderService.cs
@@ -21,6 +21,7 @@
        //WebResponseContent MaterielGroup(MaterielGroupDTO materielGroupDTO);
        WebResponseContent MaterielGroup(SaveModel saveModel);
         WebResponseContent NewMaterielGroup(SaveModel saveModel);
        WebResponseContent CPMaterielGroup(SaveModel saveModel);
WMS/WIDESEA_WMSServer/WIDESEA_IStockService/IStockInfoService.cs
@@ -31,5 +31,8 @@
        List<StockSelectViewDTO> GetStockSelectViews(string materielCode);
        List<Dt_StockInfo> GetOutboundStocks(List<Dt_StockInfo> stockInfos, string materielCode, decimal needQuantity, out decimal residueQuantity);
        public List<Dt_StockInfo> DWANDYSGetOutboundStocks(List<Dt_StockInfo> stockInfos, string materielCode, string batchNo, decimal needQuantity, out decimal residueQuantity);
    }
}
WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Base/InboundOrderService.cs
@@ -349,7 +349,7 @@
        }
        //药水,低温仓组盘
        public WebResponseContent NEWMaterielGroup(SaveModel saveModel)
        public WebResponseContent NewMaterielGroup(SaveModel saveModel)
        {
            WebResponseContent content = new WebResponseContent();
            try
@@ -461,43 +461,8 @@
                }
                else
                {
                    //if (stockInfo.StockStatus != StockStatusEmun.组盘暂存.ObjToInt())
                    //{
                    return WebResponseContent.Instance.Error($"托盘号重复,该托盘已组过物料");
                    //}
                    //beforeQuantity = stockInfo.Details.Sum(x => x.StockQuantity);
                }
                if (warehouse.WarehouseCode == WarehouseEnum.SC01_BC.ToString())
                {
                    stockInfo.Remark = Initiallife.ToString();
                    string batchNo = models.FirstOrDefault()?.LotNo ?? "";
                    //Dt_StockInfoDetail existDetail = _stockRepository.StockInfoDetailRepository.QueryFirst(x => x.BatchNo == batchNo);
                    //if (existDetail != null)
                    //{
                    //    return WebResponseContent.Instance.Error($"{batchNo}测试架已存在");
                    //}
                    if (models.Count >= 2)
                    {
                        return WebResponseContent.Instance.Error($"组盘明细不唯一");
                    }
                    //if (palletCode.Substring(0, 1) == "6")
                    //{
                    //    stockInfo.PalletType = PalletTypeEnum.MediumPallet.ObjToInt();
                    //}
                    //else
                    //{
                    //    stockInfo.PalletType = PalletTypeEnum.LargestPallet.ObjToInt();
                    //}
                }
                else if (warehouse.WarehouseCode == WarehouseEnum.SC01_BC.ToString())
                {
                    if (models.Count >= 2)
                    {
                        return WebResponseContent.Instance.Error($"组盘明细不唯一");
                    }
                }
                List<Dt_StockInfoDetail> stockInfoDetails = new List<Dt_StockInfoDetail>();
                foreach (var model in models)
                {
@@ -517,7 +482,7 @@
                        OrderNo = inboundOrder.OrderNo,
                        BatchNo = notGroupDetail.BatchNo,
                        LinId = notGroupDetail.LinId,
                        StockQuantity = (quantitys.FirstOrDefault()),
                        StockQuantity = model.Quantity,
                        Status = (int)StockStatusEmun.组盘暂存,
                        Creater = "WMS",
                        CreateDate = DateTime.Now,
@@ -537,9 +502,9 @@
                    stockInfoDetails.Add(stockInfoDetail);
                    decimal decimalReceiptQuantity = Convert.ToDecimal(notGroupDetail.ReceiptQuantity);
                    decimal decimalModelQuantity = Convert.ToDecimal((quantitys.FirstOrDefault()));
                    decimal decimalModelQuantity = Convert.ToDecimal(notGroupDetail.OrderQuantity);
                    decimal decimalOrderQuantity = Convert.ToDecimal(notGroupDetail.OrderQuantity);
                    decimalReceiptQuantity += decimalModelQuantity;
                    decimalReceiptQuantity += model.Quantity;
                    // æ£€æŸ¥æ˜¯å¦è¶…出订单数量
                    if (decimalReceiptQuantity > decimalOrderQuantity)
                    {
@@ -1311,6 +1276,7 @@
                            if (inboundOrderDetailOld != null)
                            {
                                inboundOrderDetailOld.OrderQuantity += item.OrderQuantity;
                                inboundOrderDetailOld.OrderDetailStatus = OrderDetailStatusEnum.Inbounding.ObjToInt();
                                _inboundRepository.InboundOrderDetailRepository.UpdateData(inboundOrderDetailOld);
                            }
                            else
WMS/WIDESEA_WMSServer/WIDESEA_Model/Models/Basic/Dt_PrintSetting.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,54 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Core.DB.Models;
namespace WIDESEA_Model.Models
{
    /// <summary>
    /// æ‰“印配置
    ///</summary>
    [SugarTable("Dt_PrintSetting")]
    public class Dt_PrintSetting : BaseEntity
    {
        /// <summary>
        /// å¤‡  æ³¨:区域ID
        /// é»˜è®¤å€¼:
        ///</summary>
        [SugarColumn(ColumnName = "Id", IsPrimaryKey = true, IsIdentity = true)]
        public int Id { get; set; }
        /// <summary>
        /// å¤‡  æ³¨:打印编码
        /// é»˜è®¤å€¼:
        ///</summary>
        [SugarColumn(ColumnName = "PrintCode")]
        public string PrintCode { get; set; }
        /// <summary>
        /// å¤‡  æ³¨:打印数量
        /// é»˜è®¤å€¼:
        ///</summary>
        [SugarColumn(ColumnName = "PrintNo")]
        public int PrintNo { get; set; }
        /// <summary>
        /// å¤‡  æ³¨:备用
        /// é»˜è®¤å€¼:
        ///</summary>
        [SugarColumn(ColumnName = "Spare1")]
        public string? Spare1 { get; set; }
        /// <summary>
        /// å¤‡  æ³¨:备用
        /// é»˜è®¤å€¼:
        ///</summary>
        [SugarColumn(ColumnName = "Spare2")]
        public int Spare2 { get; set; }
    }
}
WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/Service/OutboundOrderDetailService.cs
@@ -355,11 +355,21 @@
                {
                    throw new Exception($"未找到可分配库存");
                }
                List<Dt_StockInfo> autoAssignStocks = _stockService.StockInfoService.GetOutboundStocks(stockInfos, item.MaterielCode, needQuantity, out decimal residueQuantity);
                item.LockQuantity += needQuantity - residueQuantity;
                List<Dt_StockInfo> autoAssignStocks = new List<Dt_StockInfo>();
                decimal newResidueQuantity = 0;
                if (warehouse.Any(x => x.WarehouseCode.Contains("DW")) || warehouse.Any(x => x.WarehouseCode.Contains("YS")))
                {
                    autoAssignStocks = _stockService.StockInfoService.DWANDYSGetOutboundStocks(stockInfos, item.MaterielCode, item.BatchNo, needQuantity,out decimal residueQuantity);
                    newResidueQuantity = residueQuantity;
                }
                else
                {
                    autoAssignStocks = _stockService.StockInfoService.GetOutboundStocks(stockInfos, item.MaterielCode, needQuantity, out decimal residueQuantity);
                    newResidueQuantity = residueQuantity;
                }
                item.LockQuantity += needQuantity - newResidueQuantity;
                outStocks.AddRange(autoAssignStocks);
                decimal assignQuantity = needQuantity - residueQuantity;
                decimal assignQuantity = needQuantity - newResidueQuantity;
                List<Dt_OutboundOrderDetail> details = outboundOrderDetails.Where(x => !string.IsNullOrEmpty(x.BatchNo) ? x.BatchNo == item.BatchNo : true && x.MaterielCode == item.MaterielCode).ToList();
@@ -375,7 +385,17 @@
                        {
                            palletAssignQuantity = outStockLockInfos.Where(x => x.MaterielCode == item.MaterielCode && x.PalletCode == autoAssignStocks[j].PalletCode).Sum(x => x.AssignQuantity);//出库详情已分配数量
                        }
                        decimal palletOutboundQuantity = autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity);
                        decimal palletOutboundQuantity = 0;
                        if (warehouse.Any(x => x.WarehouseCode.Contains("DW")) || warehouse.Any(x => x.WarehouseCode.Contains("YS")))
                        {
                            palletOutboundQuantity = autoAssignStocks[j].Details.Where(x => x.BatchNo == item.BatchNo).Sum(x => x.OutboundQuantity);
                        }
                        else
                        {
                             palletOutboundQuantity = autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity);
                        }
                        if (palletAssignQuantity < palletOutboundQuantity)//如果出库详情已分配数量小于托盘已分配数量,则可以继续添加该托盘出库信息
                        {
                            decimal orderDetailNeedQuantity = details[i].OrderQuantity - detailAssignQuantity;
@@ -506,7 +526,8 @@
                    using (client = new HttpClient())
                    {
                        // 2. å‘送请求
                        var response = HttpHelper.Post<WebResponseContent>(ToCancelOutFeedbackERP, postContent, "出库明细取消回传ERP");
                        string url = $"{ToCancelOutFeedbackERP}?ids={Uri.EscapeDataString(ids)}";
                        var response = HttpHelper.Post<WebResponseContent>(url, "出库明细取消回传ERP");
                        if (response.Code !=0)
                        {
WMS/WIDESEA_WMSServer/WIDESEA_StockService/Service/StockInfoService.cs
@@ -1,6 +1,7 @@
using AutoMapper;
using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Excel;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
using SqlSugar;
using System;
@@ -192,6 +193,112 @@
            return outStocks;
        }
        //低温、药水分配库存
        public List<Dt_StockInfo> DWANDYSGetOutboundStocks(List<Dt_StockInfo> stockInfos, string materielCode,string batchNo ,decimal needQuantity, out decimal residueQuantity)
        {
            List<Dt_StockInfo> outStocks = new List<Dt_StockInfo>();
            decimal stockTotalQuantity = stockInfos.SelectMany(x => x.Details).Where(d => d.BatchNo == batchNo).Sum(v => v.StockQuantity - v.OutboundQuantity);
            stockInfos = stockInfos.Where(x => x.Details.Any(x => x.BatchNo == batchNo)).OrderBy(x => x.Id).ToList();
            if (stockTotalQuantity >= needQuantity)//库存够
            {
                int index = 0;
                while (needQuantity > 0)
                {
                    Dt_StockInfo stockInfo = stockInfos[index];
                    Dt_StockInfoDetail dt_StockInfoDetail = new Dt_StockInfoDetail();
                    foreach(var detail in stockInfo.Details)
                    {
                        if(detail.BatchNo == batchNo && detail.MaterielCode == materielCode)
                        {
                            dt_StockInfoDetail = detail;
                        }
                    }
                    decimal useableStockQuantity = dt_StockInfoDetail.StockQuantity - dt_StockInfoDetail.OutboundQuantity;
                    if (useableStockQuantity < needQuantity)
                    {
                        stockInfo.Details.ForEach(x =>
                        {
                            if(x.MaterielCode == materielCode && x.BatchNo == batchNo)
                            {
                                x.OutboundQuantity = x.StockQuantity;
                            }
                        });
                        needQuantity -= useableStockQuantity;
                    }
                    else
                    {
                        stockInfo.Details.ForEach(x =>
                        {
                            if (x.StockQuantity > x.OutboundQuantity && x.MaterielCode == materielCode && x.BatchNo == batchNo)
                            {
                                if (x.StockQuantity - x.OutboundQuantity >= needQuantity)
                                {
                                    x.OutboundQuantity += needQuantity;
                                    needQuantity = 0;
                                }
                                else
                                {
                                    needQuantity -= (x.StockQuantity - x.OutboundQuantity);
                                    x.OutboundQuantity = x.StockQuantity;
                                }
                            }
                        });
                    }
                    outStocks.Add(stockInfo);
                    index++;
                }
            }
            else
            {
                for (int i = 0; i < stockInfos.Count; i++)
                {
                    Dt_StockInfo stockInfo = stockInfos[i];
                    decimal useableStockQuantity = 0;
                    foreach (var detail in stockInfo.Details)
                    {
                        if(detail.MaterielCode == materielCode && detail.BatchNo == batchNo)
                        {
                            useableStockQuantity = detail.StockQuantity - detail.OutboundQuantity;
                        }
                    }
                    if (useableStockQuantity < needQuantity)
                    {
                        stockInfo.Details.ForEach(x => {
                            if(x.MaterielCode == materielCode && x.BatchNo == batchNo)
                            {
                                x.OutboundQuantity = x.StockQuantity;
                            }
                        });
                        needQuantity -= useableStockQuantity;
                    }
                    else
                    {
                        stockInfo.Details.ForEach(x =>
                        {
                            if (x.StockQuantity > x.OutboundQuantity && x.MaterielCode == materielCode && x.BatchNo == batchNo)
                            {
                                if (x.StockQuantity - x.OutboundQuantity >= needQuantity)
                                {
                                    x.OutboundQuantity += needQuantity;
                                    needQuantity = 0;
                                }
                                else
                                {
                                    needQuantity -= (x.StockQuantity - x.OutboundQuantity);
                                    x.OutboundQuantity = x.StockQuantity;
                                }
                            }
                        });
                    }
                    outStocks.Add(stockInfo);
                }
            }
            residueQuantity = needQuantity;
            return outStocks;
        }
        //导出
        public override WebResponseContent Export(PageDataOptions options)
        {
WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
@@ -889,6 +889,158 @@
                            }
                        }
                    }
                    else if (warehouse.WarehouseCode.Contains("DW") || warehouse.WarehouseCode.Contains("YS"))
                    {
                        Dt_InboundOrder? inboundOrder = _inboundService.InbounOrderService.Db.Queryable<Dt_InboundOrder>().Where(x => x.OrderNo == dt_StockInfo.Details.FirstOrDefault().OrderNo).Includes(x => x.Details).First();
                        //Dt_InboundOrderDetail? inboundOrderDetail = null;
                        //出库入库逻辑
                        if (task.TaskType == TaskTypeEnum.Inbound.ObjToInt())
                        {
                            int lastStatus = dt_LocationInfo.LocationStatus;
                            dt_LocationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt();
                            // æ ¹æ®æ‰˜ç›˜æ˜Žç»†èŽ·å–å¯¹åº”çš„å…¥åº“å•æ˜Žç»†
                            List<Dt_InboundOrderDetail> inboundOrderDetails = new List<Dt_InboundOrderDetail>();
                            // å¤„理多个库存明细的情况
                            foreach (var stockDetail in dt_StockInfo.Details)
                            {
                                if (!string.IsNullOrEmpty(stockDetail.OrderNo))
                                {
                                    var detail = inboundOrder.Details.FirstOrDefault(x => x.LinId == stockDetail.LinId && x.BatchNo == stockDetail.BatchNo);
                                    if (detail != null && !inboundOrderDetails.Any(x => x.Id == detail.Id))
                                    {
                                        inboundOrderDetails.Add(detail);
                                    }
                                }
                            }
                            if (!inboundOrderDetails.Any())
                            {
                                return WebResponseContent.Instance.Error($"未找到对应的入库单明细");
                            }
                            // æ›´æ–°å…¥åº“单明细状态
                            foreach (var inboundOrderDetail in inboundOrderDetails)
                            {
                                // æ£€æŸ¥è¯¥æ˜Žç»†æ˜¯å¦å·²å…¨éƒ¨å…¥åº“
                                decimal totalStockQuantity = dt_StockInfo.Details
                                    .Where(x => x.LinId == inboundOrderDetail.LinId && x.BatchNo == inboundOrderDetail.BatchNo)
                                    .Sum(x => x.StockQuantity);
                                decimal orderQuantity = Convert.ToDecimal(inboundOrderDetail.OrderQuantity);
                                decimal receiptQuantity = Convert.ToDecimal(inboundOrderDetail.ReceiptQuantity);
                                decimal overInQuantity = Convert.ToDecimal(inboundOrderDetail.OverInQuantity);
                                // æ›´æ–°æ”¶è´§æ•°é‡
                                inboundOrderDetail.OverInQuantity = totalStockQuantity += overInQuantity;
                                // æ£€æŸ¥æ˜¯å¦å…¨éƒ¨å®Œæˆ
                                if (inboundOrderDetail.OverInQuantity == inboundOrderDetail.OrderQuantity)
                                {
                                    inboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt();
                                }
                                else
                                {
                                    inboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Inbounding.ObjToInt();
                                }
                            }
                            ///更新库存状态
                            dt_StockInfo.StockStatus = StockStatusEmun.入库完成.ObjToInt();
                            // æ›´æ–°åº“存明细状态
                            dt_StockInfo.Details.ForEach(x => x.Status = StockStatusEmun.入库完成.ObjToInt());
                            try
                            {
                                _unitOfWorkManage.BeginTran();
                                // æ›´æ–°ä»»åŠ¡çŠ¶æ€
                                UpdateTaskStatus(task);
                                // æ›´æ–°è´§ä½çŠ¶æ€
                                UpdateLocationStatus(dt_LocationInfo, lastStatus);
                                // æ›´æ–°åº“存信息
                                UpdateStockInfo(dt_StockInfo);
                                // æ·»åŠ è®°å½•
                                AddRecords(task, dt_StockInfo, dt_LocationInfo, lastStatus);
                                // æ›´æ–°å…¥åº“单明细
                                if (inboundOrderDetails.Any())
                                {
                                    BaseDal.Db.Updateable(inboundOrderDetails).ExecuteCommand();
                                    // æ£€æŸ¥å…¥åº“单是否全部完成
                                    bool allCompleted = inboundOrder.Details.All(x =>
                                        x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt());
                                    if (allCompleted)
                                    {
                                        inboundOrder.OrderStatus = InboundStatusEnum.入库完成.ObjToInt();
                                    }
                                    else
                                    {
                                        inboundOrder.OrderStatus = InboundStatusEnum.入库中.ObjToInt();
                                    }
                                }
                                // æ›´æ–°å…¥åº“单
                                UpdateInboundOrder(inboundOrder, inboundOrderDetails.FirstOrDefault());
                                // å•据数量全部上架完成,处理WMS回传
                                if (inboundOrderDetails.Any(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()) && inboundOrder.System.Equals("ERP"))
                                {
                                    if(inboundOrder.OrderStatus == InboundStatusEnum.入库完成.ObjToInt())
                                    {
                                        bool allCompleted = inboundOrder.Details.All(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt());
                                        if (allCompleted)
                                        {
                                            foreach (var detail in inboundOrder.Details)
                                            {
                                                FeedBackInboundERP(inboundOrder.UpperOrderNo, detail.LinId);
                                            }
                                        }
                                    }
                                }
                                if (inboundOrder.OrderStatus == InboundStatusEnum.入库完成.ObjToInt() && inboundOrder.OrderType == 0 && inboundOrder.System.Equals("SMOM"))
                                {
                                }
                                else if (inboundOrder.OrderStatus == InboundStatusEnum.入库完成.ObjToInt() && inboundOrder.OrderType == 2 && inboundOrder.System.Equals("SMOM"))
                                {
                                    SendAllocateInfoToWMS(task, inboundOrder, dt_StockInfo);
                                }
                                _unitOfWorkManage.CommitTran();
                                return WebResponseContent.Instance.OK();
                            }
                            catch (Exception ex)
                            {
                                _unitOfWorkManage.RollbackTran();
                                throw new Exception($"入库处理失败:{ex.Message}", ex);
                            }
                        }
                        if (task.TaskType == TaskTypeEnum.SurplusReturn.ObjToInt() || task.TaskType == TaskTypeEnum.ReverseIn.ObjToInt())
                        {
                            return ReturnInbound(task, dt_StockInfo, dt_LocationInfo);
                        }
                        if (task.TaskType == TaskTypeEnum.InInventory.ObjToInt())
                        {
                            int lastStatus = dt_LocationInfo.LocationStatus;
                            dt_LocationInfo.LocationStatus = LocationStatusEnum.InStock.ObjToInt();
                            dt_StockInfo.StockStatus = StockStatusEmun.入库完成.ObjToInt();
                            // æ›´æ–°åº“存明细状态
                            dt_StockInfo.Details.ForEach(x => x.Status = StockStatusEmun.入库完成.ObjToInt());
                            _unitOfWorkManage.BeginTran();
                            UpdateTaskStatus(task);
                            UpdateLocationStatus(dt_LocationInfo, lastStatus);
                            UpdateStockInfo(dt_StockInfo);
                            AddRecords(task, dt_StockInfo, dt_LocationInfo, lastStatus);
                            _unitOfWorkManage.CommitTran();
                            return WebResponseContent.Instance.OK();
                        }
                    }
                    else
                    {
                        Dt_InboundOrder? inboundOrder = _inboundService.InbounOrderService.Db.Queryable<Dt_InboundOrder>().Where(x => x.OrderNo == dt_StockInfo.Details.FirstOrDefault().OrderNo).Includes(x => x.Details).First();
@@ -1786,6 +1938,41 @@
                            return WebResponseContent.Instance.Error($"处理失败: {ex.Message}");
                        }
                    }
                    else if(warehouse.WarehouseCode.Contains("DW") || warehouse.WarehouseCode.Contains("YS"))
                    {
                        Dt_OutboundOrder inboundOrder = _outboundService.OutboundOrderService.Db.Queryable<Dt_OutboundOrder>()
                        .Where(x => x.OrderNo == task.OrderNo)
                        .Includes(x => x.Details)
                        .First();
                        if (inboundOrder == null) return WebResponseContent.Instance.Error("未找到出库单信息");
                        Dt_OutboundOrderDetail outboundOrderDetail = new Dt_OutboundOrderDetail();
                        foreach(var detail in stockInfo.Details)
                        {
                            outboundOrderDetail = _outboundService.OutboundOrderService.Db.Queryable<Dt_OutboundOrderDetail>()
                            .Where(x => x.OrderId == inboundOrder.Id && x.BatchNo == detail.BatchNo)
                            .First();
                            if(outboundOrderDetail != null) break;
                        }
                        if (outboundOrderDetail.LocationName != null && outboundOrderDetail.LocationName != "")
                        {
                          foreach(var detail in stockInfo.Details)
                          {
                                outboundOrderDetail = _outboundService.OutboundOrderService.Db.Queryable<Dt_OutboundOrderDetail>()
                                .Where(x => x.OrderId == inboundOrder.Id && x.BatchNo == detail.BatchNo && x.LocationName == stockInfo.LocationCode)
                                .First();
                                if (outboundOrderDetail != null) break;
                           }
                        }
                        if (outboundOrderDetail == null) return WebResponseContent.Instance.Error("未找到出库单信息");
                        DWANDYSUpdateOutboundOrderDetails(stockInfo, inboundOrder, ref outboundOrderDetail);
                        // 3. æ‰§è¡Œæ ¸å¿ƒå‡ºåº“逻辑
                        return ExecuteOutboundLogic(task, stockInfo, locationInfo, outboundOrderDetail, inboundOrder);
                    }
                    else
                    {
                        Dt_OutboundOrder inboundOrder = _outboundService.OutboundOrderService.Db.Queryable<Dt_OutboundOrder>()
@@ -1879,7 +2066,14 @@
                _outboundService.OutboundOrderDetailService.Repository.UpdateData(outboundOrderDetails);
                // æ›´æ–°åº“存状态 å›žåº“单
                if(locationInfo.RoadwayNo.Contains("DW") || locationInfo.RoadwayNo.Contains("YS"))
                {
                    AddDWANDYSRetrueOrder(stockInfo, inboundOrder);
                }
                else
                {
                AddRetrueOrder(stockInfo, inboundOrder);
                }
                // åŒºåˆ†å•据数据来源更新货位状态
                if (inboundOrder.System == null)
@@ -1958,6 +2152,39 @@
                {
                    inboundOrderDetail.OrderDetailStatus = OutboundStatusEnum.出库中.ObjToInt();
                    inboundOrder.OrderStatus = OutboundStatusEnum.出库中.ObjToInt();
                }
            }
            if (inboundOrder.Details.Count == overCount)
            {
                inboundOrder.OrderStatus = OutboundStatusEnum.出库完成.ObjToInt();
            }
        }
        //低温、药水
        private void DWANDYSUpdateOutboundOrderDetails(Dt_StockInfo stockInfo, Dt_OutboundOrder inboundOrder, ref Dt_OutboundOrderDetail inboundOrderDetail)
        {
            string BatchNo = inboundOrderDetail.BatchNo;
            int overCount = inboundOrder.Details.Where(x => x.BatchNo == BatchNo).Count(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt());
            //inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.BatchNo == stockInfo.Details.FirstOrDefault()?.BatchNo&&x.LPNNo==stockInfo.PalletCode);
            foreach (var item in stockInfo.Details)
            {
                if (inboundOrderDetail == null) continue;
                if(inboundOrderDetail.BatchNo == item.BatchNo)
                {
                    inboundOrderDetail.OverOutQuantity += item.OutboundQuantity;
                    if (inboundOrderDetail.OverOutQuantity == inboundOrderDetail.OrderQuantity)
                    {
                        inboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt();
                        overCount++;
                    }
                    else if (inboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt())
                    {
                        inboundOrderDetail.OrderDetailStatus = OutboundStatusEnum.出库中.ObjToInt();
                        inboundOrder.OrderStatus = OutboundStatusEnum.出库中.ObjToInt();
                    }
                }
            }
            if (inboundOrder.Details.Count == overCount)
@@ -2228,8 +2455,7 @@
        private void AddRetrueOrder(Dt_StockInfo stockInfo, Dt_OutboundOrder outboundOrder)
        {
            Dt_StockInfoDetail stockInfoDetail = _stockService.StockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
           .Where(x => x.StockId == stockInfo.Id)
           .First();
           .Where(x => x.StockId == stockInfo.Id).First();
            if (stockInfoDetail == null)
            {
                throw new Exception("建立回库单时,未找到该库存信息");
@@ -2289,6 +2515,95 @@
                    DeleteAndMoveIntoHtStockStatus(stockInfo);
                }
            }
        }
        //低温、药水回库单
        private void AddDWANDYSRetrueOrder(Dt_StockInfo stockInfo, Dt_OutboundOrder outboundOrder)
        {
            List<Dt_StockInfoDetail> stockInfoDetails = _stockService.StockInfoDetailService.Db.Queryable<Dt_StockInfoDetail>()
           .Where(x => x.StockId == stockInfo.Id).ToList();
            Dt_ReturnOrder? lastReturnOrder = null;
            foreach (var stockInfoDetail in stockInfoDetails)
            {
                if (stockInfoDetail == null)
                {
                    throw new Exception("建立回库单时,未找到该库存信息");
                }
                if (outboundOrder.OrderType == OrderTypeEnum.反拣出库单.ObjToInt())
                {
                    Dt_ReturnOrder returnOrder = _returnOrderRepository.QueryFirst(x => x.LPNNo == stockInfo.PalletCode && x.LocationCode == stockInfo.LocationCode && x.OrderStatus == InOrderStatusEnum.未开始.ObjToInt());
                    if (returnOrder == null)
                    {
                        throw new Exception("反拣出库后,未找到对应反拣回库单信息");
                    }
                    stockInfo.LocationCode = "";
                    stockInfo.StockStatus = StockStatusEmun.反拣入库.ObjToInt();
                    stockInfo.Remark = "反拣入库";
                    stockInfoDetail.OutboundQuantity = 0;
                    stockInfoDetail.StockQuantity += returnOrder.OrderQuantity;
                    stockInfoDetail.OrderNo = returnOrder.OrderNo;
                }
                else
                {
                    bool allowCompeted = stockInfo.Details.All(x => x.StockQuantity == x.OutboundQuantity);
                    if (allowCompeted)
                    {
                        DeleteAndMoveIntoHtStockStatus(stockInfo);
                    }
                    else
                    {
                        decimal returnQuantity = stockInfoDetail.StockQuantity - stockInfoDetail.OutboundQuantity;
                        if (returnQuantity > 0)
                        {
                            Dt_ReturnOrder returnOrder = new Dt_ReturnOrder
                            {
                                MaterielCode = stockInfoDetail.MaterielCode,
                                MaterielName = stockInfoDetail.MaterielName,
                                BatchNo = stockInfoDetail.BatchNo,
                                OrderQuantity = returnQuantity,
                                ReceiptQuantity = returnQuantity,
                                OrderStatus = InOrderStatusEnum.未开始.ObjToInt(),
                                LinId = stockInfoDetail.LinId,
                                LPNNo = stockInfo.PalletCode,
                                Creater = "LK",
                                CreateDate = DateTime.Now,
                                OrderType = OrderTypeEnum.余料回库单.ObjToInt(),
                                System = "WMS",
                                Remark = stockInfoDetail.BatchNo
                            };
                            if(lastReturnOrder != null)
                            {
                                lastReturnOrder.Remark = lastReturnOrder.Remark + $", {returnOrder.BatchNo}";
                                _returnOrderRepository.UpdateData(lastReturnOrder);
                            }
                            if (outboundOrder.System == "SMOM" && stockInfo.LocationCode != null)
                            {
                                returnOrder.LocationCode = stockInfo.LocationCode;
                            }
                            _unitOfWorkManage.BeginTran();
                            if(lastReturnOrder == null)
                            {
                                _returnOrderRepository.AddData(returnOrder);
                                lastReturnOrder = returnOrder;
                            }
                            stockInfo.LocationCode = "";
                            stockInfo.StockStatus = StockStatusEmun.余料退库.ObjToInt();
                            stockInfo.Remark = "余料退库";
                            stockInfoDetail.OutboundQuantity = 0;
                            stockInfoDetail.StockQuantity = returnQuantity;
                            stockInfoDetail.OrderNo = lastReturnOrder.OrderNo;
                            _stockService.StockInfoService.Repository.UpdateData(stockInfo);
                            _stockService.StockInfoDetailService.Repository.UpdateData(stockInfoDetail);
                            _unitOfWorkManage.CommitTran();
                        }
                    }
                }
            }
        }
@@ -2363,8 +2678,7 @@
                        var matchedStockDetail = stockInfoDetails.FirstOrDefault(x => x.MaterielCode == outboundDetail.MaterielCode && x.BatchNo == outboundDetail.BatchNo);
                        if (matchedStockDetail == null)
                        {
                            matchedStockDetail = stockInfoDetails.FirstOrDefault(x =>
               x.MaterielCode == outboundDetail.MaterielCode);
                            matchedStockDetail = stockInfoDetails.FirstOrDefault(x =>x.MaterielCode == outboundDetail.MaterielCode);
                            if (matchedStockDetail == null)
                            {
WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Inbound/InboundOrderController.cs
@@ -45,6 +45,12 @@
            return Service.MaterielGroup(saveModel);
        }
        [HttpPost, HttpGet, Route("NewMaterielGroup")]
        public WebResponseContent NewMaterielGroup([FromBody] SaveModel saveModel)
        {
            return Service.NewMaterielGroup(saveModel);
        }
        [HttpPost, HttpGet, Route("CPMaterielGroup")]
        public WebResponseContent CPMaterielGroup([FromBody] SaveModel saveModel)
        {
WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json
@@ -18,8 +18,8 @@
    "ReceiveWMSTaskAllocatein": "http://172.30.0.190:1031/api/dataportal/invoke", //调拨任务数量回传WMS
    "ReceiveWMSTask": "http://192.168.110.172:9291/ReceiveWMSTask", //查询库存,确认入库站台
    "ReceiveERPTaskout": "http://172.30.0.192:99/external/asrs/api/OutMaterialWarehousingCallback", //立库出库数量信息回传ERP
    "CancelOutFeedbackERP": "http://172.30.0.192:99/external/asrs/api/CancelOutMaterialWarehousing", //出库单明细取消回传ERP
  "ReceiveERPTaskout": "http://172.30.0.184:99/external/asrs/api/OutMaterialWarehousingCallback", //立库出库数量信息回传ERP
  "CancelOutFeedbackERP": "http://172.30.0.184:99/external/asrs/api/CancelOutMaterialWarehousing", //出库单明细取消回传ERP
    "InMaterialWarehousingCallback": "http://172.30.0.184:99/external/asrs/api/InMaterialWarehousingCallback", //入库单完成回传ERP
    "CancelInMaterialWarehousing": "http://172.30.0.184:99/external/asrs/api/CancelInMaterialWarehousing", //入库单取消回传ERP
    "ConnectionStringsEncryption": false,
@@ -38,7 +38,7 @@
    },
    "ERP": "http://172.30.0.184:99",
    "WCS": "http://localhost:9291",
    "PrinterName": "192.168.99.3上的LenovoM7605D",
  "PrinterName": "SHARP MX-5148NC PCL6",
    "ApiName": "WIDESEA",
    "ExpMinutes": 120,
    "QuartzJobAutoStart": true