1
huangxiaoqiang
2025-11-21 97a9ad53c6d1ac097f46f0b5d4d4d53547c9efe4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
using MailKit.Search;
using SharpCompress.Compressors.ADC;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
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;
        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)
        {
            string wheres = options.ValidatePageOptions(typeof(WMS_用友库存一览表_ST).GetProperties());
            //获取排序字段
            int totalCount = 0;
            var data = SqlSugarHelper.DBERP.Queryable<WMS_用友库存一览表_ST>()
                .WhereIF(!wheres.IsNullOrEmpty(), wheres)
                .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("打印失败,请联系管理员");
            }
        }
    }
}