示例#1
0
        /// <summary>
        /// 列表基本参数
        /// </summary>
        /// <param name="dataReader"></param>
        /// <param name="rowNum"></param>
        /// <returns></returns>
        public Pro_SchedulingGoods MapRowByCreateNextBom(IDataReader dataReader, int rowNum)
        {
            Pro_SchedulingGoods model = new Pro_SchedulingGoods();

            model.GoodNo         = Convert.ToString(dataReader["GoodNo"]);
            model.GoodName       = Convert.ToString(dataReader["GoodName"]);
            model.ParentGoodNo   = Convert.ToString(dataReader["ParentGoodNo"]);
            model.ParentGoodName = Convert.ToString(dataReader["ParentGoodName"]);
            model.ShipTo         = Convert.ToString(dataReader["ShipTo"]);
            model.ShipToName     = Convert.ToString(dataReader["ShipToName"]);
            model.BiLi           = Convert.ToDecimal(dataReader["BiLi"]);
            return(model);
        }
示例#2
0
        public JsonResult AddPro_SchedulingGoods(string model, int SLineId, DateTime Date)
        {
            DateTime  begin                     = DateTime.Now;
            var       allGoodsList              = Newtonsoft.Json.JsonConvert.DeserializeObject <List <List <string> > >(model);
            var       goodsNumBizService        = Smart.Instance.Pro_SchedulingGoodsNumBizService;
            var       schedulingGoodsBizService = Smart.Instance.Pro_SchedulingGoodsBizService;
            DataTable dt = GetTableSchema();

            for (int i = 0; i < allGoodsList.Count; i = i + 4)
            {
                var xuqiu = allGoodsList[i];
                var zao   = allGoodsList[i + 1];
                var zhong = allGoodsList[i + 2];
                var wan   = allGoodsList[i + 3];

                var morningNum = zao[5] == null ? 0 : Convert.ToInt32(zao[5]);
                var middleNum  = zhong[5] == null ? 0 : Convert.ToInt32(zhong[5]);
                var eveningNum = wan[5] == null ? 0 : Convert.ToInt32(wan[5]);

                var goodModel = new Pro_SchedulingGoods();
                goodModel.SLineId        = SLineId;
                goodModel.GoodNo         = zhong[0];
                goodModel.GoodName       = zhong[1];
                goodModel.ShipTo         = zhong[2];
                goodModel.ShipToName     = zhong[3];
                goodModel.StockNum       = Convert.ToInt32(zhong[6]);
                goodModel.PackNum        = zhong[30] == "" ? 0 : Convert.ToInt32(zhong[30]);
                goodModel.MorningNum     = morningNum;
                goodModel.MiddleNum      = middleNum;
                goodModel.EveningNum     = eveningNum;
                goodModel.ParentGoodNo   = zhong[28];
                goodModel.ParentGoodName = zhong[29];


                var id = schedulingGoodsBizService.AddGetId(goodModel);
                for (var colIndex = 7; colIndex < 28; colIndex++)
                {
                    var xu_val = 0;
                    int.TryParse(xuqiu[colIndex], out xu_val);

                    //4.保存 产线对应日期的数量
                    if (xu_val != 0)
                    {
                        DataRow r = dt.NewRow();
                        r[0] = id;
                        r[1] = 1;
                        r[2] = Date.AddDays(colIndex - 7);
                        r[3] = xu_val;
                        dt.Rows.Add(r);
                    }
                    var zao_val = 0;
                    int.TryParse(zao[colIndex], out zao_val);
                    if (zao_val != 0)
                    {
                        DataRow r = dt.NewRow();
                        r[0] = id;
                        r[1] = 2;
                        r[2] = Date.AddDays(colIndex - 7);
                        r[3] = zao_val;
                        dt.Rows.Add(r);
                    }
                    var zhong_val = 0;
                    int.TryParse(zhong[colIndex], out zhong_val);
                    if (zhong_val != 0)
                    {
                        DataRow r = dt.NewRow();
                        r[0] = id;
                        r[1] = 3;
                        r[2] = Date.AddDays(colIndex - 7);
                        r[3] = zhong_val;
                        dt.Rows.Add(r);
                    }
                    var wan_val = 0;
                    int.TryParse(wan[colIndex], out wan_val);
                    if (wan_val != 0)
                    {
                        DataRow r = dt.NewRow();
                        r[0] = id;
                        r[1] = 4;
                        r[2] = Date.AddDays(colIndex - 7);
                        r[3] = wan_val;
                        dt.Rows.Add(r);
                    }
                }
            }


            //DataTable dt = GetTableSchema();
            //foreach (var good in model)
            //{
            //    var id = 0;// schedulingGoodsBizService.AddGetId(good);

            //    if (good.Items != null)
            //    {

            //        foreach (var item in good.Items)
            //        {
            //            item.SGoodId = id;
            //            item.SDate = good.Date.AddDays(item.Index);

            //            DataRow r = dt.NewRow();
            //            r[0] = item.SGoodId;
            //            r[1] = item.SType;
            //            r[2] = item.SDate;
            //            r[3] = item.SNum;
            //            dt.Rows.Add(r);
            //        }
            //    }
            //}
            goodsNumBizService.BatchAdd(dt);
            var      endTime = DateTime.Now;
            TimeSpan ts      = endTime - begin;

            LogHelper.WriteLog(string.Format("用时:{0}s,数据:{1},{2}-{3}", ts.TotalSeconds, dt.Rows.Count, begin, endTime));
            return(Json(new { Mess = "success" }));
        }