コード例 #1
0
        /// <summary>
        /// 首页汇总数量
        /// </summary>
        /// <returns></returns>
        public virtual async Task <object> GetSummary()
        {
            //待审核实物订单
            var count1 = await FlowSheetManager.GetAll().Where(o => o.FormKey == "SDR" && o.OrderStatus == "待审核").CountAsync();

            //待审核报损报溢单
            var count2 = await FlowSheetManager.GetAll().Where(o => o.FormKey == "ICH" && o.OrderStatus == "待审核").CountAsync();

            //待审核发票
            var count3 = await InvoiceManager.GetAll().Where(o => o.InvoiceStatus == InvoiceStatus.待审核).CountAsync();

            return(new
            {
                count1, count2, count3
            });
        }
コード例 #2
0
        public override async Task Handle(FlowSheet flowSheet)
        {
            await base.Handle(flowSheet);

            //数据处理
            var formObj     = Newtonsoft.Json.JsonConvert.DeserializeObject <JObject>(flowSheet.FlowInstance.FormData);
            var sheetData   = formObj["sheetData"];
            var sheetHeader = sheetData["header"];

            flowSheet.SheetDate = sheetHeader["sheetDate"].ToObjectWithDefault <DateTime>();
            flowSheet.Remarks   = sheetHeader["remarks"].ToObjectWithDefault <string>();
            var storeId  = sheetHeader["storeId"].ToObject <int>(); //调出仓库id;
            var unitId   = sheetHeader["unitId"].ToObject <int>();  //供货商id
            var totalFee = sheetHeader["totalFee"].ToObjectWithDefault <decimal>();

            flowSheet.UnitId = unitId;
            flowSheet.SetPropertyValue("StoreName", sheetHeader["storeName"].ToObjectWithDefault <string>());
            flowSheet.SetPropertyValue("Fee", totalFee);
            //是否从实物订货过来
            var fromSDR = sheetHeader["fromSDR"].ToObjectWithDefault <string>();

            if (!fromSDR.IsNullOrEmpty())
            {
                var SDRSheet = await FlowSheetManager.GetAll().Where(o => o.SheetSN == fromSDR).FirstOrDefaultAsync();

                if (SDRSheet != null)
                {
                    //SDRSheet.SetPropertyValue("PRHSheetSN", flowSheet.SheetSN);
                    SDRSheet.SetPropertyValue("PRHSheetId", flowSheet.Id);
                    await FlowSheetManager.UpdateAsync(SDRSheet);
                }
            }

            //更改往来单位金额
            await UnitManager.ChangeFee(unitId, null, totalFee, flowSheet);

            foreach (var sheetItem in sheetData["body"])
            {
                var materialId = Convert.ToInt32(sheetItem["id"]);            //对应的物料Id

                var number = sheetItem["number"].ToObjectWithDefault <int>(); //入库数量
                //记录采购
                var materialBuy = new MaterialBuy()
                {
                    UnitId           = unitId,
                    MaterialId       = materialId,
                    FlowSheetId      = flowSheet.Id,
                    BuyNumber        = number,
                    Price            = sheetItem["price"].ToObjectWithDefault <decimal>(),
                    Discount         = sheetItem["discount"].ToObjectWithDefault <decimal>(),
                    FeatureCode      = sheetItem["featureCode"].ToObjectWithDefault <string>(),
                    MaterialBuyCodes = new List <MaterialBuyCode>()
                                       //CodeStartNumber= sheetItem["codeStartNumber"].ToObjectWithDefault<string>(),
                                       //CodeEndNumber = sheetItem["codeEndNumber"].ToObjectWithDefault<string>(),
                };
                //code记录
                var codeNumber = sheetItem["codeNumber"].ToObjectWithDefault <string>();
                if (!string.IsNullOrWhiteSpace(codeNumber))
                {
                    var codeArr = codeNumber.Split(new char[] { ';', ';' });
                    codeArr.ToList().ForEach(o =>
                    {
                        var startNumber = 0M;
                        var endNumber   = 0M;
                        if (o.IndexOf('~') < 0)
                        {
                            startNumber = decimal.Parse(o);
                            endNumber   = decimal.Parse(o);
                        }
                        else
                        {
                            startNumber = decimal.Parse(o.Split('~')[0]);
                            endNumber   = decimal.Parse(o.Split('~')[1]);
                        }
                        materialBuy.MaterialBuyCodes.Add(new MaterialBuyCode()
                        {
                            CodeStartNumber = startNumber,
                            CodeEndNumber   = endNumber
                        });
                    });
                }
                await MaterialBuyManager.InsertAsync(materialBuy);

                //库存变化
                await StoreMaterialManager.CountMaterial(storeId, materialId, number, flowSheet);
            }
        }