huangxiaoqiang
2025-11-17 b07472f884708a6bfdf63d999004bbf0bb5f00a8
ÏîÄ¿´úÂë/WMS/WIDESEA_WMSServer/WIDESEA_OrderServices/Dt_InboundOrderService.cs
@@ -1,11 +1,13 @@
using MailKit.Search;
using Masuit.Tools;
using Newtonsoft.Json;
using WIDESEA_Common;
using WIDESEA_Core;
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.BaseServices;
using WIDESEA_Core.Const;
using WIDESEA_Core.Helper;
using WIDESEA_IBusinessesRepository;
using WIDESEA_IOrderRepository;
using WIDESEA_IOrderServices;
using WIDESEA_IServices;
@@ -21,14 +23,31 @@
    {
        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);
        }
        public WebResponseContent GetInboundOrderInfo(string OrderNo)
@@ -62,12 +81,59 @@
                        inboundOrders.Add(InboundOrder);
                    }
                }
                PrintInbound(inboundOrders);
                return content.OK("成功");
                content=PrintInbound(inboundOrders);
                return content;
            }
            catch (Exception ex)
            {
                return content.Error(ex.Message);
                return content.Error("未知错误,请联系管理员");
            }
        }
        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)
                {
                    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("未知错误,请联系管理员");
            }
        }
@@ -81,12 +147,12 @@
                {
                    PalletCodes.Add(GetOrderPintCode("PalletCodes"));
                }
                PrintPallet(PalletCodes);
                 content= PrintPallet(PalletCodes);
                return content.OK();
            }
            catch (Exception ex)
            {
                return content.Error(ex.Message);
                return content.Error("未知错误,请联系管理员");
            }
        }
        public string GetOrderPintCode(string printCode)
@@ -108,7 +174,7 @@
            SqlSugarHelper.DbWMS.Updateable(PrintSetting).ExecuteCommand();
            return PrintCode;
        }
        public void PrintPallet(List<string> palletCodes)
        public WebResponseContent PrintPallet(List<string> palletCodes)
        {
            var configs = _configService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
            var Base = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.PrintIPAddress)?.ConfigValue;
@@ -119,9 +185,10 @@
            }
            var IpAddress = Base + ipAddress;
            var result = HttpsClient.PostAsync(IpAddress, palletCodes.ToJsonString()).Result;
            return JsonConvert.DeserializeObject<WebResponseContent>(result);
        }
        public void PrintInbound(List<Dt_InboundOrder> orders)
        public WebResponseContent PrintInbound(List<Dt_InboundOrder> orders)
        {
            var configs = _configService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
            var Base = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.PrintIPAddress)?.ConfigValue;
@@ -132,6 +199,7 @@
            }
            var IpAddress = Base + ipAddress;
            var result = HttpsClient.PostAsync(IpAddress, orders.ToJsonString()).Result;
            return JsonConvert.DeserializeObject<WebResponseContent>(result);
        }
    }
}