1
huangxiaoqiang
2025-11-21 97a9ad53c6d1ac097f46f0b5d4d4d53547c9efe4
ÏîÄ¿´úÂë/WMS/WIDESEA_WMSServer/WIDESEA_StorageBasicServices/Stock/ERPStockInfoService.cs
@@ -1,4 +1,5 @@
using SharpCompress.Compressors.ADC;
using MailKit.Search;
using SharpCompress.Compressors.ADC;
using SqlSugar;
using System;
using System.Collections.Generic;
@@ -6,17 +7,26 @@
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_DTO.ERP;
using WIDESEA_IOrderRepository;
using WIDESEA_IOrderServices;
using WIDESEA_IStorageBasicServices.Stock;
using WIDESEA_Model.Models.ERP;
using WIDESEA_Model.Models.Order;
using WIDESEA_OrderRepository;
namespace WIDESEA_StorageBasicServices
{
    public partial class ERPStockInfoService: IERPStockInfoService
    {
        private readonly IUnitOfWorkManage _unitOfWorkManage;
        public ERPStockInfoService(IUnitOfWorkManage unitOfWorkManage)
        private readonly IDt_InboundOrderService _inboundOrderService;
        private readonly IDt_InboundOrderRepository _inboundOrderRepository;
        public ERPStockInfoService(IUnitOfWorkManage unitOfWorkManage, IDt_InboundOrderService inboundOrderService, IDt_InboundOrderRepository inboundOrderRepository)
        {
            _unitOfWorkManage = unitOfWorkManage;
            _inboundOrderService = inboundOrderService;
            _inboundOrderRepository = inboundOrderRepository;
        }
        public virtual PageGridData<WMS_用友库存一览表_ST> GetPageData(PageDataOptions options)
        {
@@ -28,5 +38,103 @@
                .ToPageList(options.Page, options.Rows, ref totalCount);
            return new PageGridData<WMS_用友库存一览表_ST>(totalCount, data);
        }
        public WebResponseContent printOrderNo(List<WMS_用友库存一览表_ST> models)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                List<Dt_InboundOrder> inboundOrders = new List<Dt_InboundOrder>();
                foreach (var model in models)
                {
                    Dt_InboundOrder inboundOrder = new Dt_InboundOrder()
                    {
                        OrderNo = _inboundOrderService.GetOrderPintCode("OrderNoIn"),
                        UpperOrderNo = "",
                        DemandClassification = "",
                        OrderType = "手动建单",
                        WareHouseId = model.仓库编码,
                        WarehouseName = model.仓库名称,
                        Datetime = DateTime.Now.ToString(),
                        LineNumber = 0,
                        ProductDrawingNumber = model.产品图号,
                        MaterialNo = model.料号,
                        MaterialName = model.品名,
                        Weight = model.单重,
                        Specs = model.规格,
                        Unit = model.单位,
                        Texture = model.用友材质,
                        Quantity = model.库存数量
                    };
                    inboundOrders.Add(inboundOrder);
                }
                _inboundOrderRepository.AddData(inboundOrders);
                _inboundOrderService.PrintInbound(inboundOrders);
                return content.OK("打印成功");
            }
            catch (Exception ex)
            {
                return content.Error("打印失败,请联系管理员");
            }
        }
        public WebResponseContent SplitprintOrderNo(int num, WMS_用友库存一览表_ST model)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                if (model == null || model.库存数量 < num || model.库存数量 - num == 0)
                {
                    return content.Error("拆分不合法");
                }
                List<Dt_InboundOrder> inboundOrders = new List<Dt_InboundOrder>()
                {
                    new Dt_InboundOrder()
                    {
                        OrderNo = _inboundOrderService.GetOrderPintCode("OrderNoIn"),
                        UpperOrderNo = "",
                        DemandClassification = "",
                        OrderType = "手动建单",
                        WareHouseId = model.仓库编码,
                        WarehouseName = model.仓库名称,
                        Datetime = DateTime.Now.ToString(),
                        LineNumber = 0,
                        ProductDrawingNumber = model.产品图号,
                        MaterialNo = model.料号,
                        MaterialName = model.品名,
                        Weight = model.单重,
                        Specs = model.规格,
                        Unit = model.单位,
                        Texture = model.用友材质,
                        Quantity = model.库存数量-num
                    },
                    new Dt_InboundOrder()
                    {
                        OrderNo = _inboundOrderService.GetOrderPintCode("OrderNoIn"),
                        UpperOrderNo = "",
                        DemandClassification = "",
                        OrderType = "手动建单",
                        WareHouseId = model.仓库编码,
                        WarehouseName = model.仓库名称,
                        Datetime = DateTime.Now.ToString(),
                        LineNumber = 0,
                        ProductDrawingNumber = model.产品图号,
                        MaterialNo = model.料号,
                        MaterialName = model.品名,
                        Weight = model.单重,
                        Specs = model.规格,
                        Unit = model.单位,
                        Texture = model.用友材质,
                        Quantity = num
                    }
                };
                _inboundOrderRepository.AddData(inboundOrders);
                _inboundOrderService.PrintInbound(inboundOrders);
                return content.OK("打印成功");
            }
            catch (Exception ex)
            {
                return content.Error("打印失败,请联系管理员");
            }
        }
    }
}