username@email.com
2025-09-23 389b4da5feedfc0b49d7c6540bc836267d7bbee0
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CY.BLL;
using CY.BLL.Sys;
using CY.Model;
using CY.Infrastructure.Query;
using CY.Infrastructure.Common;
using CY.BLL.EC;
using CY.Model.Inquiry;
 
namespace CY.WebForm.Pages.business
{
    //吴辉
    //行政管理
    public partial class DeliverWorkBookPandian : BasePage
    {
        CoreCmsPlanOrderBLL bll_CoreCmsPlanOrderBLL = null;
        CoreCmsPlanOrderItemBLL bll_CoreCmsPlanOrderItemBLL = null;
        CoreCmsPlanOrderFahuoBLL bll_coreCmsPlanOrderFahuoBLL = null;
        EC_OrderBasicBLL _eC_OrderBasicBLL = null;
        EC_OrderPrintParameterBLL _eC_OrderPrintParameterBLL = null;
 
 
 
        //初始化
        public DeliverWorkBookPandian()
        {
            bll_CoreCmsPlanOrderBLL = new CoreCmsPlanOrderBLL();
            bll_CoreCmsPlanOrderItemBLL = new CoreCmsPlanOrderItemBLL();
            bll_coreCmsPlanOrderFahuoBLL = new CoreCmsPlanOrderFahuoBLL();
            _eC_OrderBasicBLL = new EC_OrderBasicBLL();
            _eC_OrderPrintParameterBLL = new EC_OrderPrintParameterBLL();
        }
 
        //页面加载
        protected void Page_Load(object sender, EventArgs e)
        {
            
            if (!IsPostBack)
            {
                 
 
                BindList();
            }
             
        }
 
        //绑定数据
        private void BindList()
        {
            string orderIdStr = Request["orderId"];
            this.hideOrderId.Value = orderIdStr;
 
 
            var eC_OrderBasic = _eC_OrderBasicBLL.SelectModelById(orderIdStr.ToInt32().Value);
            if (eC_OrderBasic != null)
            {
                spanBuyerName.InnerText = eC_OrderBasic.BuyerName;
            }
 
            //var cmsPlanOrderItems = bll_CoreCmsPlanOrderItemBLL.GetModelsByZongOrderid(orderIdStr.ToInt32().Value);
 
            var coreDeliverOrderItems = bll_CoreCmsPlanOrderItemBLL.GetDeliverModelsByZongOrderid(orderIdStr.ToInt32().Value).Where(x=>x.OrderState == 2);
 
            var coreCmsPlanOrderFahuos = bll_coreCmsPlanOrderFahuoBLL.GetModelsByOrderid(orderIdStr.ToInt32().Value);
 
 
            ////订单数量统计
            //var cmsPlanOrderItemsgroup = cmsPlanOrderItems.GroupBy(p => new { p.name, p.specification }) // 多个字段作为匿名类型分组键
            //.Select(g => new CoreCmsPlanOrderItem
            //{
            //    // 分组字段
            //    name = g.Key.name,
            //    specification = g.Key.specification,
            //    // 统计结果
            //    //Count = g.Count(), // 每组人数
            //    //AverageSalary = g.Average(p => p.Salary), // 平均工资
            //    nums = g.Sum(p => p.nums) // 工资总和
            //}).ToList();
 
 
            EC_OrderPrintParameter _eC_OrderPrintParameter = _eC_OrderPrintParameterBLL.GetModel(orderIdStr.ToInt32().Value);
            InquiryCommonModel _inquiryCommonModel = null;
            if (null == _eC_OrderPrintParameter)
            {
                _inquiryCommonModel = new InquiryCommonModel();
            }
            else
            {
                _inquiryCommonModel = SerializationHelper.DeSerialize(typeof(InquiryCommonModel), _eC_OrderPrintParameter.PrintParameter) as InquiryCommonModel;
 
            }
            var inquiryWorkBookModels = _inquiryCommonModel.InquiryWorkBookList.OrderBy(x => x.WorkBookNameTxt).ThenBy(x => x.WorkBookSizeTxt);
 
            var cmsPlanOrderItemsgroup = new List<CoreCmsPlanOrderItem>();
            foreach (var inquiryWorkBookModel in inquiryWorkBookModels)
            {
                var coreCmsPlanOrder = new CoreCmsPlanOrderItem();
               // biaotou += " <th style=\"text-align:center\"> " + inquiryWorkBookModel.WorkBookSizeTxt + inquiryWorkBookModel.WorkBookNameTxt + " </th> ";
 
                coreCmsPlanOrder.name = inquiryWorkBookModel.WorkBookNameTxt;
                coreCmsPlanOrder.specification = inquiryWorkBookModel.WorkBookSizeTxt;
                var sss = inquiryWorkBookModel.WorkBookCount.ToInt32();
                coreCmsPlanOrder.nums = sss.HasValue ? sss.Value : 0;
                cmsPlanOrderItemsgroup.Add(coreCmsPlanOrder);
 
            }
 
 
 
            //发货数量统计
            var coreCmsPlanOrderFahuosgroup = coreCmsPlanOrderFahuos.GroupBy(p => new { p.name, p.specification }) // 多个字段作为匿名类型分组键
            .Select(g => new CoreCmsPlanOrderFahuo
            {
                // 分组字段
                name = g.Key.name,
                specification = g.Key.specification,
                // 统计结果
                //Count = g.Count(), // 每组人数
                //AverageSalary = g.Average(p => p.Salary), // 平均工资
                nums = g.Sum(p => p.nums) // 工资总和
            }).ToList();
 
 
            //送货数量统计
            var coreDeliverOrderItemsgroup = coreDeliverOrderItems.GroupBy(p => new { p.ZYBName, p.ZYBSpecification }) // 多个字段作为匿名类型分组键
            .Select(g => new CoreDeliverOrderItem
            {
                // 分组字段
                ZYBName = g.Key.ZYBName,
                ZYBSpecification = g.Key.ZYBSpecification,
                // 统计结果
                //Count = g.Count(), // 每组人数
                //AverageSalary = g.Average(p => p.Salary), // 平均工资
                Number = g.Sum(p => p.Number) // 工资总和
            }).ToList();
 
 
 
 
            foreach(var cmsPlanOrderItem in cmsPlanOrderItemsgroup)
            {
                var coreCmsPlanOrderFahuo = coreCmsPlanOrderFahuosgroup.FirstOrDefault(x => x.name == cmsPlanOrderItem.name && x.specification == cmsPlanOrderItem.specification);
                if (coreCmsPlanOrderFahuo != null)
                {
                    cmsPlanOrderItem.fahuonums = coreCmsPlanOrderFahuo.nums;
                }
                cmsPlanOrderItem.weifahuonums = cmsPlanOrderItem.nums - cmsPlanOrderItem.fahuonums;
 
                var coreDeliverOrderItem = coreDeliverOrderItemsgroup.FirstOrDefault(x => x.ZYBName == cmsPlanOrderItem.name && x.ZYBSpecification == cmsPlanOrderItem.specification);
                if (coreDeliverOrderItem != null)
                {
                    cmsPlanOrderItem.songhuonums = coreDeliverOrderItem.Number;
                }
                    
              
                cmsPlanOrderItem.kucunnums = cmsPlanOrderItem.fahuonums - cmsPlanOrderItem.songhuonums;
 
 
                cmsPlanOrderItem.weisonghuonums = cmsPlanOrderItem.nums - cmsPlanOrderItem.songhuonums;
            }
 
 
 
 
 
 
 
 
 
            this.RepClientList.DataSource = cmsPlanOrderItemsgroup;
            this.RepClientList.DataBind();
            
        }
 
 
      
 
 
      
    }
}