1
yangpeixing
2025-11-25 5bbb8e206ae8328a5e1233eb43ed4ecb2a02a98e
ÏîÄ¿´úÂë/WMS/WIDESEA_WMSServer/WIDESEA_OrderServices/Dt_InboundOrderService.cs
@@ -1,4 +1,5 @@
using MailKit.Search;
using AngleSharp.Dom;
using MailKit.Search;
using Masuit.Tools;
using Newtonsoft.Json;
using WIDESEA_Common;
@@ -7,6 +8,7 @@
using WIDESEA_Core.BaseServices;
using WIDESEA_Core.Const;
using WIDESEA_Core.Helper;
using WIDESEA_IBusinessesRepository;
using WIDESEA_IOrderRepository;
using WIDESEA_IOrderServices;
using WIDESEA_IServices;
@@ -22,16 +24,38 @@
    {
        private readonly IUnitOfWorkManage _unitOfWorkManage;
        private readonly ISys_ConfigService _configService;
        private readonly IDt_WareAreaInfoRepository _wareAreaInfoRepository;
        public Dt_InboundOrderService(IDt_InboundOrderRepository BaseDal,
                                        IUnitOfWorkManage unitOfWorkManage,
                                        ISys_ConfigService configService) : base(BaseDal)
                                        ISys_ConfigService configService,
                                        IDt_WareAreaInfoRepository wareAreaInfoRepository) : base(BaseDal)
        {
            _unitOfWorkManage = unitOfWorkManage;
            _configService = configService;
            _wareAreaInfoRepository = wareAreaInfoRepository;
        }
        public override WebResponseContent UpdateData(SaveModel saveModel)
        {
            var quantity = saveModel.MainData["quantity"].ToString();
            var wareHouseId = saveModel.MainData["wareHouseId"].ToString();
            Dt_WareAreaInfo? wareinfo = _wareAreaInfoRepository.QueryFirst(x => x.WareAreaCode == wareHouseId);
            if (wareinfo == null)
            {
                return WebResponseContent.Instance.Error("未找到仓库信息!");
            }
            saveModel.MainData.Add("warehouseName", wareinfo.WareAreaName.ToString());
            return base.UpdateData(saveModel);
        }
        /// <summary>
        /// æŸ¥è¯¢å…¥åº“单据信息
        /// </summary>
        /// <param name="OrderNo"></param>
        /// <returns></returns>
        public WebResponseContent GetInboundOrderInfo(string OrderNo)
        {
            WebResponseContent content=new WebResponseContent();
@@ -49,6 +73,12 @@
                return content.Error(ex.Message);
            }
        }
        /// <summary>
        /// æ‰“印
        /// </summary>
        /// <param name="keys"></param>
        /// <returns></returns>
        public WebResponseContent PrintOrder(int[] keys)
        {
            WebResponseContent content = new WebResponseContent();
@@ -63,7 +93,7 @@
                        inboundOrders.Add(InboundOrder);
                    }
                }
                content=PrintInbound(inboundOrders);
                content = PrintInbound(inboundOrders);
                return content;
            }
            catch (Exception ex)
@@ -72,6 +102,94 @@
            }
        }
        /// <summary>
        /// å¤šæ¬¡æ‰“印
        /// </summary>
        /// <param name="keys"></param>
        /// <param name="num"></param>
        /// <returns></returns>
        public WebResponseContent MultiplePrintOrder(int keys,int num)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                List<Dt_InboundOrder> inboundOrders = new List<Dt_InboundOrder>();
                var InboundOrder = BaseDal.QueryFirst(x => x.Id == keys);
                for (int i = 0; i < num; i++)
                {
                    if (InboundOrder != null)
                    {
                        inboundOrders.Add(InboundOrder);
                    }
                }
                content = PrintInbound(inboundOrders);
                return content;
            }
            catch (Exception ex)
            {
                return content.Error("未知错误,请联系管理员");
            }
        }
        /// <summary>
        /// æ‹†åˆ†
        /// </summary>
        /// <param name="id"></param>
        /// <param name="num"></param>
        /// <returns></returns>
        public WebResponseContent SplitOrder(int id,int num)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                var originalOrder = BaseDal.QueryFirst(x => x.Id == id);
                if (originalOrder == null)
                {
                    return content.Error("未找到该入库单信息");
                }
                if(originalOrder.Quantity < num || num <= 0 || originalOrder.Quantity - num == 0)
                {
                    return content.Error("拆分数量不合法");
                }
                Dt_InboundOrder orderNew = new Dt_InboundOrder()
                {
                    OrderNo = GetOrderPintCode("OrderNoIn"),
                    UpperOrderNo = originalOrder.UpperOrderNo,
                    DemandClassification = originalOrder.DemandClassification,
                    OrderType = originalOrder.OrderType,
                    WarehouseName = originalOrder.WarehouseName,
                    Datetime = originalOrder.Datetime,
                    LineNumber = originalOrder.LineNumber,
                    ProductDrawingNumber = originalOrder.ProductDrawingNumber,
                    MaterialNo = originalOrder.MaterialNo,
                    MaterialName = originalOrder.MaterialName,
                    Weight = originalOrder.Weight,
                    WareHouseId = originalOrder.WareHouseId,
                    Specs = originalOrder.Specs,
                    Unit = originalOrder.Unit,
                    Texture = originalOrder.Texture,
                    Quantity = num,
                    OrderStatus = originalOrder.OrderStatus,
                };
                originalOrder.Quantity = originalOrder.Quantity - num;
                BaseDal.AddData(orderNew);
                BaseDal.UpdateData(originalOrder);
                return content.OK();
            }
            catch (Exception ex)
            {
                return content.Error("未知错误,请联系管理员");
            }
        }
        /// <summary>
        /// æ‰“印托盘码
        /// </summary>
        /// <param name="num"></param>
        /// <returns></returns>
        public WebResponseContent PrintPalletCode(int num)
        {
            WebResponseContent content = new WebResponseContent();
@@ -90,6 +208,12 @@
                return content.Error("未知错误,请联系管理员");
            }
        }
        /// <summary>
        /// èŽ·å–è®¢å•ç¼–å·
        /// </summary>
        /// <param name="printCode"></param>
        /// <returns></returns>
        public string GetOrderPintCode(string printCode)
        {
            string PrintCode = "";
@@ -109,6 +233,13 @@
            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 configs = _configService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
@@ -123,9 +254,14 @@
            return JsonConvert.DeserializeObject<WebResponseContent>(result);
        }
        /// <summary>
        /// è°ƒç”¨æ‰“印单据接口
        /// </summary>
        /// <param name="orders"></param>
        /// <returns></returns>
        /// <exception cref="InvalidOperationException"></exception>
        public WebResponseContent PrintInbound(List<Dt_InboundOrder> orders)
        {
            WebResponseContent content = new WebResponseContent();
            var configs = _configService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
            var Base = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.PrintIPAddress)?.ConfigValue;
            var ipAddress = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.PrintInboundOrder)?.ConfigValue;
@@ -137,5 +273,6 @@
            var result = HttpsClient.PostAsync(IpAddress, orders.ToJsonString()).Result;
            return JsonConvert.DeserializeObject<WebResponseContent>(result);
        }
    }
}