1
647556386
2025-12-02 ee6b82936b52250e46b57fcf12484a6f40c4dc50
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
using Autofac.Core;
using MailKit.Search;
using Microsoft.Extensions.Logging;
using SqlSugar;
using SqlSugar.Extensions;
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Common.AllocateEnum;
using WIDESEA_Common.OrderEnum;
using WIDESEA_Core;
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.BaseServices;
using WIDESEA_Core.CodeConfigEnum;
using WIDESEA_Core.DB;
using WIDESEA_Core.Enums;
using WIDESEA_Core.Helper;
using WIDESEA_Core.Seed;
using WIDESEA_IAllocateService;
using WIDESEA_IInboundService;
using WIDESEA_IOutboundService;
using WIDESEA_Model.Models;
 
 
namespace WIDESEA_AllocateService
{
 
    public partial class AllocateService : ServiceBase<Dt_AllocateOrder, IRepository<Dt_AllocateOrder>>, IAllocateService
    {
        public readonly IUnitOfWorkManage _unitOfWorkManage;
        public readonly IInboundService _inboundService;
        public readonly IOutboundService _outboundService;
        public readonly IRepository<Dt_AllocateOrder> _allocateOrderRepository;
        public readonly IRepository<Dt_AllocateOrderDetail> _allocateOrderDetailRepository;
 
        public readonly IRepository<Dt_InboundOrderDetail> _inboundOrderDetailRepository;
 
        private readonly ILogger<AllocateService> _logger;
        public AllocateService(IRepository<Dt_AllocateOrder> BaseDal,
            IUnitOfWorkManage unitOfWorkManage,
            IInboundService inboundService,
            IOutboundService outboundService,
            IRepository<Dt_AllocateOrder> allocateOrderRepository,
            IRepository<Dt_AllocateOrderDetail> allocateOrderDetailRepository,
            IRepository<Dt_InboundOrderDetail> inboundOrderDetailRepository,
            ILogger<AllocateService> logger) : base(BaseDal)
        {
            _unitOfWorkManage = unitOfWorkManage;
            _inboundService = inboundService;
            _outboundService = outboundService;
            _allocateOrderRepository = allocateOrderRepository;
            _allocateOrderDetailRepository = allocateOrderDetailRepository;
            _logger = logger;
            _inboundOrderDetailRepository = inboundOrderDetailRepository;
        }
 
        public IRepository<Dt_AllocateOrder> Repository => BaseDal;
 
 
        public async Task<WebResponseContent> ReceiveAllocateOrder(Dt_AllocateOrder allocateOrder, int operateType)
        {
            try
            {
                return operateType switch
                {
                    1 => await AddAllocateOrder(allocateOrder),
                    2 => await UpdateAllocateOrder(allocateOrder),
                    3 => await DeleteAllocateOrder(allocateOrder),
 
                    _ => WebResponseContent.Instance.OK(),
                };
            }
            catch (Exception ex)
            {
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
 
        public async Task<WebResponseContent> AddAllocateOrder(Dt_AllocateOrder allocateOrder)
        {
            try
            {
                if (BaseDal.QueryFirst(x => x.UpperOrderNo == allocateOrder.UpperOrderNo) != null)
                {
                    return WebResponseContent.Instance.Error($"调拨单号重复");
                }
                allocateOrder.OrderNo = CreateCodeByRule(nameof(RuleCodeEnum.AllocateOrderCodeRule));
                Db.InsertNav(allocateOrder).Include(x => x.Details).ExecuteCommand();
                await AddInOutData(allocateOrder);
                return WebResponseContent.Instance.OK();
            }
            catch (Exception ex)
            {
                _logger.LogInformation("AllocateService AddAllocateOrder  err:  " + ex.Message);
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
 
        private async Task AddInOutData(Dt_AllocateOrder allocateOrder)
        {
            if (Enum.TryParse<BusinessTypeEnum>(allocateOrder.BusinessType, out var businessType))
            {
                if (businessType == BusinessTypeEnum.外部仓库调智仓)
                {
                    allocateOrder.OrderType = (int)InOrderTypeEnum.AllocatInbound;
                    var inboundOrders = ConvertToInboundOrders(allocateOrder);
                    await _inboundService.InbounOrderService.ReceiveInboundOrder(inboundOrders, 1);
                }
                else if (businessType == BusinessTypeEnum.智仓调外部仓库 || businessType == BusinessTypeEnum.智仓调智仓)
                {
                    if (businessType == BusinessTypeEnum.智仓调外部仓库)
                    {
                        allocateOrder.OrderType = (int)InOrderTypeEnum.AllocatOutbound;
                    }
                    else if (businessType == BusinessTypeEnum.智仓调智仓)
                    {
                        allocateOrder.OrderType = (int)InOrderTypeEnum.InternalAllocat;
                    }
 
                    var outboundOrders = ConvertToOutboundOrders(allocateOrder);
                    await _outboundService.OutboundOrderService.ReceiveOutboundOrder(outboundOrders, 1);
                }
                else
                {
                    // 处理未定义的枚举值(如未来新增但未实现的类型)
                    throw new NotSupportedException($"不支持的业务类型枚举值: {businessType}");
                }
            }
        }
 
        public async Task<WebResponseContent> UpdateAllocateOrder(Dt_AllocateOrder model)
        {
            try
            {
                var allocateOrder = Db.Queryable<Dt_AllocateOrder>().Where(x => x.UpperOrderNo == model.UpperOrderNo).Includes(x => x.Details).First();
                if (allocateOrder == null)
                {
                    return WebResponseContent.Instance.Error($"未找到调拨单信息");
                }
                if (allocateOrder.Details == null || allocateOrder.Details.Count == 0)
                {
                    return WebResponseContent.Instance.Error($"未找到调拨单明细信息");
                }
                List<Dt_AllocateOrderDetail> allocateOrderDetails = new List<Dt_AllocateOrderDetail>();
                List<Dt_AllocateOrderDetail> updateAllocateOrderDetails = new List<Dt_AllocateOrderDetail>();
                List<int> detailIds = new List<int>();
                foreach (var item in model.Details)
                {
                    if (string.IsNullOrEmpty(item.Barcode))
                    {
 
                    }
                    else
                    {
                        Dt_AllocateOrderDetail? allocateOrderDetail = allocateOrder.Details.FirstOrDefault(x => x.Barcode == item.Barcode);
                        if (allocateOrderDetail == null)
                        {
                            allocateOrderDetail = new Dt_AllocateOrderDetail()
                            {
                                OrderId = allocateOrder.Id,
                                MaterielCode = item.MaterielCode,
                                LineNo = item.LineNo,
                                BatchNo = item.BatchNo,
                                Unit = item.Unit,
                                WarehouseCode = item.WarehouseCode,
                                Barcode = item.Barcode,
                                BarcodeUnit = item.BarcodeUnit,
                                BarcodeQty = (decimal)item.BarcodeQty,
                                OrderQuantity = item.OrderQuantity
                            };
                            allocateOrderDetails.Add(allocateOrderDetail);
                        }
                        else
                        {
                            allocateOrderDetail.LineNo = item.LineNo;
                            allocateOrderDetail.MaterielCode = item.MaterielCode;
                            allocateOrderDetail.BatchNo = item.BatchNo;
                            allocateOrderDetail.Unit = item.Unit;
                            allocateOrderDetail.WarehouseCode = item.WarehouseCode;
                            allocateOrderDetail.Barcode = item.Barcode;
                            allocateOrderDetail.BarcodeUnit = item.BarcodeUnit;
                            allocateOrderDetail.BarcodeQty = item.BarcodeQty;
                            allocateOrderDetail.OrderQuantity = item.OrderQuantity;
 
 
                            updateAllocateOrderDetails.Add(allocateOrderDetail);
                            detailIds.Add(allocateOrderDetail.Id);
                        }
                    }
                }
 
                allocateOrder.UpperOrderNo = model.UpperOrderNo;
                allocateOrder.BusinessType = model.BusinessType;
                allocateOrder.IsBatch = model.IsBatch;
                allocateOrder.FactoryArea = model.FactoryArea;
 
                List<Dt_AllocateOrderDetail> deletePurchaseOrderDetails = allocateOrder.Details.Where(x => !detailIds.Contains(x.Id)).ToList();
 
                _unitOfWorkManage.BeginTran();
                foreach (var item in deletePurchaseOrderDetails)
                {
                    // _allocateOrderDetailRepository.DeleteAndMoveIntoHty(item, OperateTypeEnum.自动删除);
                    _allocateOrderDetailRepository.DeleteData(item);
                }
 
                _allocateOrderDetailRepository.UpdateData(updateAllocateOrderDetails);
                _allocateOrderDetailRepository.AddData(allocateOrderDetails);
 
                BaseDal.UpdateData(allocateOrder);
 
                DeleteInOutData(model.UpperOrderNo, allocateOrder);
                await AddInOutData(allocateOrder);
 
                _unitOfWorkManage.CommitTran();
 
 
                return WebResponseContent.Instance.OK();
            }
            catch (Exception ex)
            {
                _unitOfWorkManage.RollbackTran();
                _logger.LogInformation("AllocateService UpdateAllocateOrder  err:  " + ex.Message);
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
 
        public async Task<WebResponseContent> DeleteAllocateOrder(Dt_AllocateOrder model)
        {
            try
            {
                var allocateOrder = Db.Queryable<Dt_AllocateOrder>().Where(x => x.UpperOrderNo == model.UpperOrderNo).Includes(x => x.Details).First();
                if (allocateOrder == null)
                {
                    return WebResponseContent.Instance.Error($"未找到调拨单信息");
                }
                if (allocateOrder.Details == null || allocateOrder.Details.Count == 0)
                {
                    return WebResponseContent.Instance.Error($"未找到调拨单明细信息");
                }
                //Db.DeleteNav(Allocate).Include(x => x.Details).ExecuteCommand();
                _unitOfWorkManage.BeginTran();
                // BaseDal.DeleteAndMoveIntoHty(allocateOrder, OperateTypeEnum.自动删除);
                foreach (var item in allocateOrder.Details)
                {
                    // _allocateOrderDetailRepository.DeleteAndMoveIntoHty(item, OperateTypeEnum.自动删除);
                    _allocateOrderDetailRepository.DeleteData(item);
                }
                BaseDal.DeleteData(allocateOrder);
 
                DeleteInOutData(model.UpperOrderNo, allocateOrder);
 
                _unitOfWorkManage.CommitTran();
                return WebResponseContent.Instance.OK();
            }
            catch (Exception ex)
            {
                _unitOfWorkManage.RollbackTran();
                _logger.LogInformation("AllocateService DeleteAllocateOrder  err:  " + ex.Message);
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
 
        private void DeleteInOutData(string upperOrderNo, Dt_AllocateOrder allocateOrder)
        {
            if (Enum.TryParse<BusinessTypeEnum>(allocateOrder.BusinessType, out var businessType))
            {
                if (businessType == BusinessTypeEnum.外部仓库调智仓)
                {
                    _inboundService.InbounOrderService.Db.Deleteable<Dt_InboundOrder>().Where(x => x.UpperOrderNo == upperOrderNo).ExecuteCommand();
 
                    _inboundService.InboundOrderDetailService.Db.Deleteable<Dt_InboundOrderDetail>()
                     .Where(p => SqlFunc.Subqueryable<Dt_InboundOrder>().Where(s => s.Id == p.OrderId && s.UpperOrderNo == upperOrderNo).Any()).ExecuteCommand();
                }
                else if (businessType == BusinessTypeEnum.智仓调外部仓库 || businessType == BusinessTypeEnum.智仓调智仓)
                {
                    _outboundService.OutboundOrderService.Db.Deleteable<Dt_OutboundOrder>().Where(x => x.UpperOrderNo == upperOrderNo).ExecuteCommand();
                    _outboundService.OutboundOrderDetailService.Db.Deleteable<Dt_OutboundOrderDetail>()
                     .Where(p => SqlFunc.Subqueryable<Dt_OutboundOrder>().Where(s => s.Id == p.OrderId && s.UpperOrderNo == upperOrderNo).Any()).ExecuteCommand();
                }
            }
        }
 
        public List<Dt_InboundOrder> ConvertToInboundOrders(Dt_AllocateOrder allocateOrder)
        {
            var distinctDetails = allocateOrder.Details
                .GroupBy(d => d.Barcode)
                .Select(g => g.First())
                .ToList();
 
            return new List<Dt_InboundOrder>()
            {
                new Dt_InboundOrder(){
                   WarehouseId= allocateOrder.WarehouseId,
                   InboundOrderNo=allocateOrder.OrderNo,
                   UpperOrderNo=allocateOrder.UpperOrderNo,
                   SupplierId=allocateOrder.SupplierId,
                   OrderType= allocateOrder.OrderType ,
                   OrderStatus=allocateOrder.OrderStatus,
                   CreateType=allocateOrder.CreateType,
                   BusinessType=allocateOrder.BusinessType,
                   IsBatch=allocateOrder.IsBatch,
                   FactoryArea=allocateOrder.FactoryArea,
                   Remark=allocateOrder.Remark,
                   Details=distinctDetails.Select(detail=>new Dt_InboundOrderDetail
                   {
                       OrderId= 0,
                       MaterielCode=detail.MaterielCode,
                       MaterielName="",
                       BatchNo=detail.BatchNo,
                       OrderQuantity=detail.OrderQuantity,
                       ReceiptQuantity=detail.ReceiptQuantity,
                       OverInQuantity=detail.OverInQuantity,
                       OrderDetailStatus=detail.OrderDetailStatus,
                       Unit=detail.Unit,
                       RowNo=0,
                       lineNo=detail.LineNo,
                       SupplyCode=detail.SupplyCode,
                       WarehouseCode=detail.WarehouseCode,
                       Barcode=detail.Barcode,
                       OutBoxbarcodes="",
                       BarcodeQty=(decimal)detail.BarcodeQty,
                       BarcodeUnit=detail.BarcodeUnit
                   }).ToList()
                }
            };
        }
 
        public Dt_OutboundOrder ConvertToOutboundOrders(Dt_AllocateOrder allocateOrder)
        {
 
            var distinctDetails = allocateOrder.Details
            .GroupBy(d => string.IsNullOrEmpty(d.Barcode)
                ? $"{d.MaterielCode}_{d.BatchNo}_{d.SupplyCode}_{d.WarehouseCode}"
                : d.Barcode)
            .Select(g => new
            {
                Detail = g.First(),
                //汇总分组内的数量
                Qty = g.Sum(x => x.BarcodeQty ?? x.OrderQuantity)
            }).ToList();
 
            return new Dt_OutboundOrder()
            {
                WarehouseId = allocateOrder.WarehouseId,
                OrderNo = allocateOrder.OrderNo,
                UpperOrderNo = allocateOrder.UpperOrderNo,
                OrderType = allocateOrder.OrderType,
                OrderStatus = allocateOrder.OrderStatus,
                CreateType = allocateOrder.CreateType,
                BusinessType = allocateOrder.BusinessType,
                IsBatch = allocateOrder.IsBatch,
                FactoryArea = allocateOrder.FactoryArea,
                Remark = allocateOrder.Remark,
                DepartmentCode = "",
                DepartmentName = "",
                Details = distinctDetails.Select(item => new Dt_OutboundOrderDetail
                {
                    OrderId = 0,
                    MaterielCode = item.Detail.MaterielCode,
                    MaterielName = "",
                    BatchNo = item.Detail.BatchNo,
                    OrderQuantity = item.Detail.OrderQuantity,
                    BarcodeQty =  item.Detail.BarcodeQty??0,
                    BarcodeUnit = item.Detail.BarcodeUnit??"",
                    LockQuantity = 0,
                    lineNo = item.Detail.LineNo,
                    OverOutQuantity = 0,
                    OrderDetailStatus = item.Detail.OrderDetailStatus,
                    Unit = item.Detail.Unit,
                    RowNo = 0,
                    SupplyCode = item.Detail.SupplyCode,
                    WarehouseCode = item.Detail.WarehouseCode,
 
                }).ToList()
            };
        }
 
        static object lock_code = new object();
        public string CreateCodeByRule(string ruleCode)
        {
            lock (lock_code)
            {
 
                string code = string.Empty;
                DateTime dateTime = DateTime.Now;
                DateTime now = DateTime.Now;
                try
                {
                    if (string.IsNullOrEmpty(ruleCode))
                        throw new ArgumentNullException(nameof(ruleCode));
                    SqlSugarClient sugarClient = new SqlSugarClient(new ConnectionConfig
                    {
                        IsAutoCloseConnection = true,
                        DbType = DbType.SqlServer,
                        ConnectionString = DBContext.ConnectionString
                    });
                    Dt_CodeRuleConfig codeRuleConfig = sugarClient.Queryable<Dt_CodeRuleConfig>().Where(x => x.RuleCode == ruleCode).First();
                    if (codeRuleConfig == null)
                        throw new ArgumentNullException(nameof(codeRuleConfig));
                    if (codeRuleConfig.ModifyDate != null)
                    {
                        dateTime = Convert.ToDateTime(codeRuleConfig.ModifyDate);
                    }
                    else
                    {
                        dateTime = Convert.ToDateTime(codeRuleConfig.CreateDate);
                    }
 
                    if (now.Year == dateTime.Year && now.Month == dateTime.Month && now.Day == dateTime.Day)
                    {
                        now = dateTime;
                        codeRuleConfig.CurrentVal = Convert.ToInt32(codeRuleConfig.CurrentVal) + 1;
                    }
                    else
                    {
                        codeRuleConfig.CurrentVal = 1;
                    }
                    codeRuleConfig.ModifyDate = DateTime.Now;
                    code = codeRuleConfig.StartStr + codeRuleConfig.Format;
                    code = code.Replace($"[{CodeFormatTypeEnum.YYYY}]", now.Year.ToString().PadLeft(4, '0'));
                    code = code.Replace($"[{CodeFormatTypeEnum.MM}]", now.Month.ToString().PadLeft(2, '0'));
                    code = code.Replace($"[{CodeFormatTypeEnum.DD}]", now.Day.ToString().PadLeft(2, '0'));
                    code = code.Replace($"[{CodeFormatTypeEnum.ST}]", codeRuleConfig.StartStr?.ToString() ?? "");
                    code = code.Replace($"[{CodeFormatTypeEnum.NUM}]", codeRuleConfig.CurrentVal.ToString().PadLeft(codeRuleConfig.Length, '0'));
                    Dictionary<string, object> keyValuePairs = new Dictionary<string, object>() { { nameof(codeRuleConfig.CurrentVal), codeRuleConfig.CurrentVal }, { nameof(codeRuleConfig.Id), codeRuleConfig.Id }, { nameof(codeRuleConfig.ModifyDate), DateTime.Now } };
                    sugarClient.Updateable(keyValuePairs).AS(MainDb.CodeRuleConfig).WhereColumns(nameof(codeRuleConfig.Id)).ExecuteCommand();
                    sugarClient.Updateable(codeRuleConfig);
 
                }
                catch (Exception ex)
                {
 
                }
                return code;
            }
        }
 
        public override PageGridData<Dt_InboundOrderDetail> GetDetailPage(PageDataOptions options)
        {
            string wheres = ValidatePageOptions(options);
            //获取排序字段
            Dictionary<string, SqlSugar.OrderByType> orderbyDic = GetPageDataSort(options, TProperties);
            List<OrderByModel> orderByModels = new List<OrderByModel>();
            foreach (var item in orderbyDic)
            {
                OrderByModel orderByModel = new()
                {
                    FieldName = item.Key,
                    OrderByType = item.Value
                };
                orderByModels.Add(orderByModel);
            }
 
 
            int totalCount = 0;
            List<SearchParameters> searchParametersList = new List<SearchParameters>();
            if (!string.IsNullOrEmpty(options.Wheres))
            {
                try
                {
                    searchParametersList = options.Wheres.DeserializeObject<List<SearchParameters>>();
                    options.Filter = searchParametersList;
                }
                catch { }
            }
            //var data = BaseDal.Db.Queryable<Dt_AllocateOrderDetail>()
            //    .WhereIF(!wheres.IsNullOrEmpty(), wheres)
            //    .OrderBy(orderByModels)
            //    .ToPageList(options.Page, options.Rows, ref totalCount);
            //Dt_AllocateOrder allocateOrder = _allocateOrderRepository.QueryFirst(x => x.Id == (int)options.Value);
            //Dt_InboundOrder _InboundOrder = SqlSugarHelper.DbWMS.Queryable<Dt_InboundOrder>().Where(x => x.UpperOrderNo == allocateOrder.UpperOrderNo).First();
            //var details = _inboundOrderDetailRepository.QueryData(x => x.OrderId == _InboundOrder.Id );
            //foreach (var item in data)
            //{
            //    var detail = details.Where(x => x.MaterielCode == item.MaterielCode).FirstOrDefault();
            //    if (detail != null)
            //    {
            //        item.OrderQuantity = detail.OrderQuantity;
            //        item.ReceiptQuantity = detail.ReceiptQuantity;
            //        item.OverInQuantity = detail.OverInQuantity;
            //        item.OrderDetailStatus = detail.OrderDetailStatus;
            //    }
            //}
            //return new PageGridData<Dt_AllocateOrderDetail>(totalCount, data);
 
            Dt_AllocateOrder allocateOrder = _allocateOrderRepository.QueryFirst(x => x.Id == (int)options.Value);
            Dt_InboundOrder _InboundOrder = SqlSugarHelper.DbWMS.Queryable<Dt_InboundOrder>().Where(x => x.UpperOrderNo == allocateOrder.UpperOrderNo).First();
 
            var data = BaseDal.Db.Queryable<Dt_InboundOrderDetail>()
                .WhereIF(!wheres.IsNullOrEmpty(), wheres)
                .WhereIF(!_InboundOrder.IsNullOrEmpty(), x => x.OrderId == _InboundOrder.Id)
                .OrderBy(orderByModels)
                .ToPageList(options.Page, options.Rows, ref totalCount);
 
 
            return new PageGridData<Dt_InboundOrderDetail>(totalCount, data);
        }
    }
}