Пример #1
0
        private async Task HandleMidDocument(List <SalesOrder> salesOrderList)
        {
            string guid = "SalesOrder_" + Guid.NewGuid();

            Logger.Writer(guid, QueueStatus.Open, $"已获取{salesOrderList.Count}条销售订单,正在处理。。");

            #region 应收发票
            var newINSalesOrderList = soService.MergeSalesOrder(soService.PackingSalesOrder(salesOrderList.Where(c => c.IsINSync == "N").ToList()));
            Logger.Writer(guid, QueueStatus.Open, $"已合并成[{newINSalesOrderList.Count}[条应生成发票的销售订单");
            foreach (var item in newINSalesOrderList)
            {
                StringBuilder str = new StringBuilder();
                try
                {
                    item.SalesOrders.ForEach(c => { str.Append("'"); str.Append(c.DocEntry); str.Append("',"); });
                    var rt = IN_SalesOrder.CreateInvoice(item);
                    await soService.HandleSalesOrderResult(rt, str.ToString().Trim(','), true);
                }
                catch (Exception ex)
                {
                    Logger.Writer(guid, QueueStatus.Open, $"create new Invoice document error:{ex.Message}");
                    await soService.HandleSalesOrderResult(new Result()
                    {
                        ResultCode = -1, Message = ex.Message
                    }, str.ToString().Trim(','), true);
                }
            }
            #endregion

            #region 分录
            var newJESalesOrderList = soService.MergeSalesOrder(soService.PackingSalesOrder(salesOrderList.Where(c => c.IsJESync == "N").ToList()));
            Logger.Writer(guid, QueueStatus.Open, $"已合并成[{newINSalesOrderList.Count}[条应生成分录的销售订单");
            foreach (var item in newJESalesOrderList)
            {
                StringBuilder str = new StringBuilder();
                try
                {
                    item.SalesOrders.ForEach(c => { str.Append("'"); str.Append(c.DocEntry); str.Append("',"); });
                    var rt = JE_SalesOrder.CreateJournalEntry(item);
                    await soService.HandleSalesOrderResult(rt, str.ToString().Trim(','), false);
                }
                catch (Exception ex)
                {
                    Logger.Writer(guid, QueueStatus.Open, $"create journal entry document error:{ex.Message}");
                    await soService.HandleSalesOrderResult(new Result()
                    {
                        ResultCode = -1, Message = ex.Message
                    }, str.ToString().Trim(','), false);
                }
            }
            #endregion

            Logger.Writer(guid, QueueStatus.Close, "sales order has been handled.");
        }
Пример #2
0
        public async Task HandleMidDocument(List <SalesOrder> salesOrderList)
        {
            string guid = "SalesOrder_" + Guid.NewGuid();

            Logger.Writer(guid, QueueStatus.Open, $"已获取销售订单{salesOrderList.Count}条,正在处理。。");
            var newSalesOrderList = soService.MergeSalesOrder(soService.PackingSalesOrder(salesOrderList));

            Logger.Writer(guid, QueueStatus.Open, $"已合并成[{newSalesOrderList.Count}[条销售订单");
            foreach (var item in newSalesOrderList)
            {
                StringBuilder str = new StringBuilder();
                try
                {
                    item.SalesOrders.ForEach(c => { str.Append("'"); str.Append(c.DocEntry); str.Append("',"); });
                    var rt = CreateInvoice(item);
                    await soService.HandleSalesOrderResult(rt, str.ToString().Trim(','), true);
                }
                catch (Exception ex)
                {
                    Logger.Writer(guid, QueueStatus.Open, $"销售订单[{item.DocEntry}]生成单据发生异常:{ex.Message}");
                    await soService.HandleSalesOrderResult(new Result()
                    {
                        ResultCode = -1, Message = ex.Message
                    }, str.ToString().Trim(','), true);
                }
            }
            Logger.Writer(guid, QueueStatus.Close, "销售订单已处理完成。");
        }
Пример #3
0
        public async Task HandleMidDocument(List <SalesOrder> salesOrderList)
        {
            string guid = "SalesOrder_" + Guid.NewGuid();

            Logger.Writer(guid, QueueStatus.Open, $"已获取销售订单{salesOrderList.Count}条,正在处理。。");
            //按条件合并订单
            var newSalesOrderList = _soService.MergeSalesOrder(_soService.PackingSalesOrder(salesOrderList));

            Logger.Writer(guid, QueueStatus.Open, $"已合并成[{newSalesOrderList.Count}[条销售订单");
            foreach (var item in newSalesOrderList)
            {
                //获取合并订单的DocEntry,批量处理订单的生成状态
                StringBuilder str = new StringBuilder();
                item.SalesOrders.ForEach(c => { str.Append("'"); str.Append(c.DocEntry); str.Append("',"); });
                var rt = CreateJournalEntry(item);//销售订单生成分录
                //处理订单生成的结果
                await _soService.HandleSalesOrderResult(rt, str.ToString().Trim(','), false);
            }
            Logger.Writer(guid, QueueStatus.Close, "销售订单已处理完成。");
        }