public ActionResult GetData()
        {
            Stream stream = Request.InputStream;
            string json   = string.Empty;

            if (stream.Length != 0)
            {
                StreamReader streamreader = new StreamReader(stream);
                json = streamreader.ReadToEnd();
            }
            PageRequest <T_StockInfoEX> pageRequest = JsonConvert.DeserializeObject <PageRequest <T_StockInfoEX> >(json);

            List <T_StockInfoEX> modelList = new List <T_StockInfoEX>();
            DividPage            page      = new DividPage {
                CurrentPageRecordCounts = pageRequest.CurrentPageRecordCounts, CurrentPageShowCounts = pageRequest.CurrentPageShowCounts, PagesCount = pageRequest.PagesCount, RecordCounts = pageRequest.RecordCounts, CurrentPageNumber = pageRequest.CurrentPageNumber
            };
            T_StockInfoEX model    = pageRequest.model;
            string        strError = "";

            queryDB.GetStockDetInfo(model, ref page, ref modelList, ref strError);
            BaseModel <List <T_StockInfoEX> > returnmodel = new BaseModel <List <T_StockInfoEX> >()
            {
                Result = 1, ResultValue = strError, Data = modelList, PageData = new R_Pagedata()
                {
                    totalCount = page.RecordCounts, pageSize = page.CurrentPageShowCounts, currentPage = page.CurrentPageNumber, totalPages = page.PagesCount
                }
            };

            return(Json(returnmodel, JsonRequestBehavior.AllowGet));
        }
        /// <summary>
        /// 导出excel
        /// </summary>
        /// <param name="jsonString"></param>
        /// <returns></returns>
        public FileResult Excel(string jsonString)
        {
            T_StockInfoEX model = JsonConvert.DeserializeObject <T_StockInfoEX>(jsonString);

            string strErrMsg = string.Empty;
            List <T_StockInfoEX> lstExport = new List <T_StockInfoEX>();
            string    strError             = "";
            DividPage page = new DividPage
            {
                CurrentPageShowCounts = 1000000
            };

            queryDB.GetStockDetInfo(model, ref page, ref lstExport, ref strError);
            //创建Excel文件的对象
            NPOI.HSSF.UserModel.HSSFWorkbook book = new NPOI.HSSF.UserModel.HSSFWorkbook();
            //添加一个sheet
            NPOI.SS.UserModel.ISheet sheet1 = book.CreateSheet("Sheet1");
            //给sheet1添加第一行的头部标题
            NPOI.SS.UserModel.IRow row1 = sheet1.CreateRow(0);
            row1.CreateCell(0).SetCellValue("据点");
            row1.CreateCell(1).SetCellValue("物料号");
            row1.CreateCell(2).SetCellValue("物料名称");
            row1.CreateCell(3).SetCellValue("EAN");
            row1.CreateCell(4).SetCellValue("效期");
            row1.CreateCell(5).SetCellValue("序列号");
            row1.CreateCell(6).SetCellValue("批次");
            row1.CreateCell(7).SetCellValue("仓库");
            row1.CreateCell(8).SetCellValue("库区");
            row1.CreateCell(9).SetCellValue("库位");
            row1.CreateCell(10).SetCellValue("数量");
            row1.CreateCell(11).SetCellValue("项目跟踪号");
            //将数据逐步写入sheet1各个行
            for (int i = 0; i < lstExport.Count; i++)
            {
                NPOI.SS.UserModel.IRow rowtemp = sheet1.CreateRow(i + 1);

                rowtemp.CreateCell(0).SetCellValue(lstExport[i].StrongHoldCode == null ? "" : lstExport[i].StrongHoldCode.ToString());
                rowtemp.CreateCell(1).SetCellValue(lstExport[i].MaterialNo == null ? "" : lstExport[i].MaterialNo.ToString());
                rowtemp.CreateCell(2).SetCellValue(lstExport[i].MaterialDesc == null ? "" : lstExport[i].MaterialDesc.ToString());
                rowtemp.CreateCell(3).SetCellValue(lstExport[i].EAN == null ? "" : lstExport[i].EAN.ToString());
                rowtemp.CreateCell(4).SetCellValue(lstExport[i].EDate == null ? "" : lstExport[i].EDate.ToString());
                rowtemp.CreateCell(5).SetCellValue(lstExport[i].SerialNo == null ? "" : lstExport[i].SerialNo.ToString());
                rowtemp.CreateCell(6).SetCellValue(lstExport[i].BatchNo == null ? "" : lstExport[i].BatchNo.ToString());
                rowtemp.CreateCell(7).SetCellValue(lstExport[i].WarehouseNo == null ? "" : lstExport[i].WarehouseNo.ToString());
                rowtemp.CreateCell(8).SetCellValue(lstExport[i].HouseNo == null ? "" : lstExport[i].HouseNo.ToString());
                rowtemp.CreateCell(9).SetCellValue(lstExport[i].AreaNo == null ? "" : lstExport[i].AreaNo.ToString());
                rowtemp.CreateCell(10).SetCellValue(lstExport[i].Qty.ToString());
                rowtemp.CreateCell(11).SetCellValue(lstExport[i].TracNo == null ? "" : lstExport[i].TracNo.ToString());
            }
            // 写入到客户端
            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            book.Write(ms);
            ms.Seek(0, SeekOrigin.Begin);
            return(File(ms, "application/vnd.ms-excel", DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"));
        }
        public ActionResult GetModelList(DividPage page, T_StockInfoEX model)
        {
            List <T_StockInfoEX> modelList = new List <T_StockInfoEX>();
            string strError = "";

            queryDB.GetStockDetInfo(model, ref page, ref modelList, ref strError);
            ViewData["PageData"] = new PageData <T_StockInfoEX> {
                data = modelList, dividPage = page, link = Common.PageTag.ModelToUriParam(model, "/StockDetail/GetModelList")
            };
            return(View("GetModelList", model));
        }
        public FileResult Excel(string jsonString)
        {
            T_StockInfoEX model = JsonConvert.DeserializeObject <T_StockInfoEX>(jsonString);
            DividPage     page  = new DividPage();

            page.CurrentPageShowCounts = 1000000;
            List <T_StockInfoEX> list = new List <T_StockInfoEX>();
            string str = "";

            queryDB.GetStockCombineInfo(model, ref page, ref list, ref str);
            //创建Excel文件的对象
            NPOI.HSSF.UserModel.HSSFWorkbook book = new NPOI.HSSF.UserModel.HSSFWorkbook();
            //添加一个sheet
            NPOI.SS.UserModel.ISheet sheet1 = book.CreateSheet("Sheet1");
            //给sheet1添加第一行的头部标题
            NPOI.SS.UserModel.IRow row1 = sheet1.CreateRow(0);
            //row1.CreateCell(0).SetCellValue("序号");
            //row1.CreateCell(1).SetCellValue("据点编号");
            row1.CreateCell(0).SetCellValue("物料号");
            row1.CreateCell(1).SetCellValue("客户型号");
            row1.CreateCell(2).SetCellValue("批次");
            row1.CreateCell(3).SetCellValue("到期日期");
            row1.CreateCell(4).SetCellValue("数量");
            //row1.CreateCell(9).SetCellValue("检验状态");
            row1.CreateCell(5).SetCellValue("库位");
            row1.CreateCell(6).SetCellValue("库区");
            row1.CreateCell(7).SetCellValue("仓库");
            row1.CreateCell(8).SetCellValue("EAN");
            //将数据逐步写入sheet1各个行
            for (int i = 0; i < list.Count; i++)
            {
                NPOI.SS.UserModel.IRow rowtemp = sheet1.CreateRow(i + 1);
                //rowtemp.CreateCell(0).SetCellValue(list[i].XH);
                //rowtemp.CreateCell(1).SetCellValue(list[i].StrongHoldCode);
                rowtemp.CreateCell(0).SetCellValue(list[i].MaterialNo);
                rowtemp.CreateCell(1).SetCellValue(list[i].StoreCondition);
                rowtemp.CreateCell(2).SetCellValue(list[i].BatchNo);
                rowtemp.CreateCell(3).SetCellValue(list[i].EDate.ToString());
                rowtemp.CreateCell(4).SetCellValue(list[i].Qty.ToString());
                //rowtemp.CreateCell(7).SetCellValue( list[i].StatusName==null?"": list[i].StatusName);
                rowtemp.CreateCell(5).SetCellValue(list[i].AreaNo.ToString());
                rowtemp.CreateCell(6).SetCellValue(list[i].HouseNo.ToString());
                rowtemp.CreateCell(7).SetCellValue(list[i].WarehouseNo.ToString());
                rowtemp.CreateCell(8).SetCellValue(list[i].EAN.ToString());
            }
            string       fileName     = "库存合并列表" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
            MemoryStream memoryStream = new MemoryStream();

            book.Write(memoryStream);
            memoryStream.Seek(0, SeekOrigin.Begin);
            return(File(memoryStream, "application/vnd.ms-excel", fileName));
        }
Exemple #5
0
        private static string GetErpJson(T_StockInfoEX model)
        {
            string basejson = "{\"key\":\"f5458f5c0f9022db743a7c0710145903\",\"type\":\"sync\",\"host\":{\"prod\":\"" + ConfigurationManager.ConnectionStrings["prod"].ConnectionString + "\",\"ip\":\"10.40.71.91\",\"lang\":\"zh_CN\",\"acct\":\"tiptop\",\"timestamp\":\"20151211123204361\"},\"service\":{\"prod\":\"T100\",\"name\":\"return.inventory.info.get\",\"ip\":\"10.1.254.26\",\"id\":\"topprd\"},\"datakey\":{\"EntId\":\"10\",\"CompanyId\":\"CY1\"},\"payload\":{\"std_data\":{\"parameter\":@}}}";

            string[] matenos = model.MaterialNo.Split(',');
            string[] areanos = model.AreaNo.Split(',');
            string[] batchs  = model.BatchNo.Split(',');
            string[] judians = model.StrongHoldCode.Split(',');

            JObject jp  = new JObject();
            JArray  arr = new JArray();

            jp.Add(new JProperty("data", arr));

            foreach (string mate in matenos)
            {
                foreach (string area in areanos)
                {
                    foreach (string bat in batchs)
                    {
                        foreach (string ju in judians)
                        {
                            JObject content = new JObject();
                            content.Add(new JProperty("data_site", ju));
                            content.Add(new JProperty("data_item", mate));
                            content.Add(new JProperty("data_inv", model.WarehouseNo));
                            content.Add(new JProperty("data_location", area));
                            content.Add(new JProperty("data_batch", bat));
                            arr.Add(content);
                        }
                    }
                }
            }

            basejson = basejson.Replace("@", jp.ToString());

            string json = HttpPost(basejson);

            return(json);
        }
Exemple #6
0
        public bool GetErpStock(T_StockInfoEX model, ref List <CheckAnalyze> listerp, ref List <CheckAnalyze> listwms, ref string ErrMsg)
        {
            string json = GetErpJson(model);


            JObject jo          = JObject.Parse(json);
            JToken  jt          = jo["payload"]["std_data"]["execution"];
            string  code        = jt["code"].ToString();
            string  description = jt["description"].ToString();

            if (code != "0")
            {
                ErrMsg = "没有ERP数据";
                return(false);
            }

            JToken jt2 = jo["payload"]["std_data"]["parameter"]["data"];

            //得到erp数据
            foreach (JToken jtn in jt2)
            {
                CheckAnalyze erprow = new CheckAnalyze();
                erprow.STRONGHOLDCODE = jtn["Head"]["site_id"].ToDBString();
                erprow.MATERIALNO     = jtn["Head"]["item_no"].ToDBString();
                erprow.warehouseno    = jtn["Head"]["inv_id"].ToDBString();
                erprow.AREANO         = jtn["Head"]["location_id"].ToDBString();
                erprow.BatchNo        = jtn["Head"]["batch_no"].ToDBString();
                erprow.status         = jtn["Head"]["qc_code"].ToInt32();
                if (string.IsNullOrEmpty(jtn["Head"]["qc_code"].ToDBString()))
                {
                    erprow.status = 1;
                }
                switch (erprow.status)
                {
                case 1:
                    erprow.statusname = "合格";
                    break;

                case 0:
                    erprow.statusname = "待检";
                    break;

                case 2:
                    erprow.statusname = "不合格";
                    break;
                }
                erprow.QTY = jtn["Head"]["inv_amount"].ToDecimal();
                //erprow.EDATE = jtn["Head"]["valid_date"].ToDateTime();
                listerp.Add(erprow);
            }


            //去重,去除因为edate而重复的行
            List <CheckAnalyze> listerp2 = listerp;

            listerp = listerp2.Where((x, i) => listerp2.FindIndex(z => z.STRONGHOLDCODE == x.STRONGHOLDCODE && z.MATERIALNO == x.MATERIALNO && z.warehouseno == x.warehouseno && z.AREANO == x.AREANO && z.BatchNo == x.BatchNo && z.statusname == x.statusname && z.QTY == x.QTY) == i).ToList();


            //-------------------------------------获取type=2时的去除库位的整合数据
            if (model.XH == "2")
            {
                var le = from t in listerp
                         group t by new { t1 = t.STRONGHOLDCODE, t2 = t.MATERIALNO, t3 = t.warehouseno, t5 = t.BatchNo, t6 = t.status, t7 = t.statusname } into m
                    select new CheckAnalyze
                {
                    STRONGHOLDCODE = m.Key.t1,
                    MATERIALNO     = m.Key.t2,
                    warehouseno    = m.Key.t3,
                    BatchNo        = m.Key.t5,
                    status         = m.Key.t6,
                    statusname     = m.Key.t7,
                    QTY            = m.Sum(item => item.QTY),
                };
                listerp = le.ToList();
            }

            //-------------------------------------

            //获取wms数据,不带edate     ,s.EDATE   ,EDATE ,,and STRONGHOLDCODE = '" + model.StrongHoldCode + "'
            if (model.XH == "1")
            {
                string sql = "select s.STRONGHOLDCODE,s.MATERIALNO,v.warehouseno,v.AREANO,s.BatchNo,s.status,sum(s.QTY) as qty from t_stock s left join v_area v on s.areaid=v.id group by " +
                             "STRONGHOLDCODE,MATERIALNO,warehouseno,AREANO,BatchNo,status having 1=1  and warehouseno = '" + model.WarehouseNo + "'";
                if (model.MaterialNo != "" && !model.MaterialNo.Contains(','))
                {
                    sql += " and MaterialNo = '" + model.MaterialNo + "'";
                }
                else if (model.MaterialNo != "" && model.MaterialNo.Contains(','))
                {
                    string MaterialNo = model.MaterialNo;
                    Query_Func.ChangeQuery(ref MaterialNo);
                    sql += " and MaterialNo in(" + MaterialNo + ")";
                }

                if (model.AreaNo != "" && !model.AreaNo.Contains(','))
                {
                    sql += " and AreaNo = '" + model.AreaNo + "'";
                }
                else if (model.AreaNo != "" && model.AreaNo.Contains(','))
                {
                    string AreaNo = model.AreaNo;
                    Query_Func.ChangeQuery(ref AreaNo);
                    sql += " and AreaNo in(" + AreaNo + ")";
                }

                if (model.BatchNo != "" && !model.BatchNo.Contains(','))
                {
                    sql += " and BatchNo = '" + model.BatchNo + "'";
                }
                else if (model.BatchNo != "" && model.BatchNo.Contains(','))
                {
                    string BatchNo = model.BatchNo;
                    Query_Func.ChangeQuery(ref BatchNo);
                    sql += " and BatchNo in(" + BatchNo + ")";
                }

                if (model.StrongHoldCode != "" && !model.StrongHoldCode.Contains(','))
                {
                    sql += " and StrongHoldCode = '" + model.StrongHoldCode + "'";
                }
                else if (model.StrongHoldCode != "" && model.StrongHoldCode.Contains(','))
                {
                    string StrongHoldCode = model.StrongHoldCode;
                    Query_Func.ChangeQuery(ref StrongHoldCode);
                    sql += " and StrongHoldCode in(" + StrongHoldCode + ")";
                }

                //得到wms数据
                using (var dr = dbFactory.ExecuteReader(sql))
                {
                    while (dr.Read())
                    {
                        CheckAnalyze ca = new CheckAnalyze();
                        ca.SSTRONGHOLDCODE = dr["STRONGHOLDCODE"].ToDBString();
                        ca.SMATERIALNO     = dr["MATERIALNO"].ToDBString();
                        ca.swarehouseno    = dr["warehouseno"].ToDBString();
                        ca.SAREANO         = dr["AREANO"].ToDBString();
                        ca.SBatchNo        = dr["BatchNo"].ToDBString();
                        ca.sstatus         = dr["status"].ToInt32();
                        switch (ca.sstatus)
                        {
                        case 1:
                            ca.sstatusname = "待检";
                            break;

                        case 2:
                            ca.sstatusname = "待检";
                            break;

                        case 3:
                            ca.sstatusname = "合格";
                            break;

                        case 4:
                            ca.sstatusname = "不合格";
                            break;
                        }
                        ca.SQTY = dr["QTY"].ToDecimal();
                        //ca.SEDATE = dr["EDATE"].ToDateTime();
                        listwms.Add(ca);
                    }
                }
            }
            //类型2,仓库对比
            else if (model.XH == "2")
            {
                string sql = "select s.STRONGHOLDCODE,s.MATERIALNO,v.warehouseno,s.BatchNo,s.status,sum(s.QTY) as qty from t_stock s left join v_area v on s.areaid=v.id group by " +
                             "STRONGHOLDCODE,MATERIALNO,warehouseno,BatchNo,status having 1=1  and warehouseno = '" + model.WarehouseNo + "'";
                if (model.MaterialNo != "" && !model.MaterialNo.Contains(','))
                {
                    sql += " and MaterialNo = '" + model.MaterialNo + "'";
                }
                else if (model.MaterialNo != "" && model.MaterialNo.Contains(','))
                {
                    string MaterialNo = model.MaterialNo;
                    Query_Func.ChangeQuery(ref MaterialNo);
                    sql += " and MaterialNo in(" + MaterialNo + ")";
                }

                //if (model.AreaNo != "" && !model.AreaNo.Contains(','))
                //    sql += " and AreaNo = '" + model.AreaNo + "'";
                //else if (model.AreaNo != "" && model.AreaNo.Contains(','))
                //{
                //    string AreaNo = model.AreaNo;
                //    Query_Func.ChangeQuery(ref AreaNo);
                //    sql += " and AreaNo in(" + AreaNo + ")";
                //}

                if (model.BatchNo != "" && !model.BatchNo.Contains(','))
                {
                    sql += " and BatchNo = '" + model.BatchNo + "'";
                }
                else if (model.BatchNo != "" && model.BatchNo.Contains(','))
                {
                    string BatchNo = model.BatchNo;
                    Query_Func.ChangeQuery(ref BatchNo);
                    sql += " and BatchNo in(" + BatchNo + ")";
                }

                if (model.StrongHoldCode != "" && !model.StrongHoldCode.Contains(','))
                {
                    sql += " and StrongHoldCode = '" + model.StrongHoldCode + "'";
                }
                else if (model.StrongHoldCode != "" && model.StrongHoldCode.Contains(','))
                {
                    string StrongHoldCode = model.StrongHoldCode;
                    Query_Func.ChangeQuery(ref StrongHoldCode);
                    sql += " and StrongHoldCode in(" + StrongHoldCode + ")";
                }

                //得到wms数据
                using (var dr = dbFactory.ExecuteReader(sql))
                {
                    while (dr.Read())
                    {
                        CheckAnalyze ca = new CheckAnalyze();
                        ca.SSTRONGHOLDCODE = dr["STRONGHOLDCODE"].ToDBString();
                        ca.SMATERIALNO     = dr["MATERIALNO"].ToDBString();
                        ca.swarehouseno    = dr["warehouseno"].ToDBString();
                        //ca.SAREANO = dr["AREANO"].ToDBString();
                        ca.SBatchNo = dr["BatchNo"].ToDBString();
                        ca.sstatus  = dr["status"].ToInt32();
                        switch (ca.sstatus)
                        {
                        case 1:
                            ca.sstatusname = "待检";
                            break;

                        case 2:
                            ca.sstatusname = "待检";
                            break;

                        case 3:
                            ca.sstatusname = "合格";
                            break;

                        case 4:
                            ca.sstatusname = "不合格";
                            break;
                        }
                        ca.SQTY = dr["QTY"].ToDecimal();
                        //ca.SEDATE = dr["EDATE"].ToDateTime();
                        listwms.Add(ca);
                    }
                }
            }



            //if (listwms.Count == 0)
            //{
            //    ErrMsg = "没有WMS数据";
            //    return false;
            //}



            //合并数据
            //erprow.STRONGHOLDCODE = jtn["Head"]["site_id"].ToDBString();
            //  erprow.MATERIALNO = jtn["Head"]["item_no"].ToDBString();
            //  erprow.warehouseno = jtn["Head"]["inv_id"].ToDBString();
            //  erprow.AREANO = jtn["Head"]["location_id"].ToDBString();
            //  erprow.BatchNo = jtn["Head"]["batch_no"].ToDBString();
            //  erprow.status = jtn["Head"]["qc_code"].ToInt32();
            //  erprow.QTY = jtn["Head"]["inv_amount"].ToDecimal();
            List <CheckAnalyze> newlist = new List <CheckAnalyze>();
            decimal?            count = 0; decimal?count2 = 0;

            if (model.XH == "1")
            {
                int k = 1;
                foreach (CheckAnalyze erp in listerp)
                {
                    //关联时要通过状态链接,通过据点链接
                    //&&p.sstatusname==erp.statusname
                    var wms = listwms.Find(p => p.SMATERIALNO == erp.MATERIALNO && p.SAREANO == erp.AREANO && p.SBatchNo == erp.BatchNo && p.sstatusname == erp.statusname && p.SSTRONGHOLDCODE == erp.STRONGHOLDCODE);
                    if (wms == null)
                    {
                        erp.partno = k + "";
                        erp.remark = "赢";
                        newlist.Add(erp);
                        k++;
                    }
                    else
                    {
                        erp.partno          = k + "";
                        erp.SMATERIALNO     = wms.SMATERIALNO;
                        erp.SAREANO         = wms.SAREANO;
                        erp.SSTRONGHOLDCODE = wms.SSTRONGHOLDCODE;
                        erp.SBatchNo        = wms.SBatchNo;
                        erp.sstatusname     = wms.sstatusname;
                        erp.SQTY            = wms.SQTY;
                        if (erp.QTY > erp.SQTY)
                        {
                            erp.remark = "赢";
                        }
                        else if (erp.QTY == erp.SQTY)
                        {
                            erp.remark = "平";
                        }
                        else
                        {
                            erp.remark = "亏";
                        }
                        ////判断合格不同状态
                        //if (erp.statusname != erp.sstatusname)
                        //    erp.remark += "|质检差异";
                        ////判断合格不同状态
                        //if (erp.STRONGHOLDCODE != erp.SSTRONGHOLDCODE)
                        //    erp.remark += "|据点差异";
                        newlist.Add(erp);
                        k++;
                    }
                }
                foreach (CheckAnalyze wms in listwms)
                {
                    //&&p.sstatusname==wms.sstatusname
                    var w = newlist.Find(p => p.SMATERIALNO == wms.SMATERIALNO && p.SAREANO == wms.SAREANO && p.SBatchNo == wms.SBatchNo && p.sstatusname == wms.sstatusname && p.SSTRONGHOLDCODE == wms.SSTRONGHOLDCODE);
                    if (w == null)
                    {
                        wms.partno = k + "";
                        wms.remark = "亏";
                        //wms.STRONGHOLDCODE = wms.SSTRONGHOLDCODE;
                        wms.warehouseno = wms.swarehouseno;
                        newlist.Add(wms);
                        k++;
                    }
                }
            }
            else if (model.XH == "2")
            {
                int k = 1;
                foreach (CheckAnalyze erp in listerp)
                {
                    //关联时要通过状态链接,通过据点链接
                    //&&p.sstatusname==erp.statusname
                    var wms = listwms.Find(p => p.SMATERIALNO == erp.MATERIALNO && p.SBatchNo == erp.BatchNo && p.sstatusname == erp.statusname && p.SSTRONGHOLDCODE == erp.STRONGHOLDCODE);
                    if (wms == null)
                    {
                        erp.partno = k + "";
                        erp.remark = "赢";
                        newlist.Add(erp);
                        k++;
                    }
                    else
                    {
                        erp.partno      = k + "";
                        erp.SMATERIALNO = wms.SMATERIALNO;
                        //erp.SAREANO = wms.SAREANO;
                        erp.SSTRONGHOLDCODE = wms.SSTRONGHOLDCODE;
                        erp.SBatchNo        = wms.SBatchNo;
                        erp.sstatusname     = wms.sstatusname;
                        erp.SQTY            = wms.SQTY;
                        if (erp.QTY > erp.SQTY)
                        {
                            erp.remark = "赢";
                        }
                        else if (erp.QTY == erp.SQTY)
                        {
                            erp.remark = "平";
                        }
                        else
                        {
                            erp.remark = "亏";
                        }
                        ////判断合格不同状态
                        //if (erp.statusname != erp.sstatusname)
                        //    erp.remark += "|质检差异";
                        ////判断合格不同状态
                        //if (erp.STRONGHOLDCODE != erp.SSTRONGHOLDCODE)
                        //    erp.remark += "|据点差异";
                        newlist.Add(erp);
                        k++;
                    }
                }
                foreach (CheckAnalyze wms in listwms)
                {
                    //&&p.sstatusname==wms.sstatusname
                    var w = newlist.Find(p => p.SMATERIALNO == wms.SMATERIALNO && p.SBatchNo == wms.SBatchNo && p.sstatusname == wms.sstatusname && p.SSTRONGHOLDCODE == wms.SSTRONGHOLDCODE);
                    if (w == null)
                    {
                        wms.partno = k + "";
                        wms.remark = "亏";
                        //wms.STRONGHOLDCODE = wms.SSTRONGHOLDCODE;
                        wms.warehouseno = wms.swarehouseno;
                        newlist.Add(wms);
                        k++;
                    }
                }
            }



            listerp = newlist;
            foreach (var item in listerp)
            {
                count  += item.QTY.ToDecimal();
                count2 += item.SQTY.ToDecimal();
            }
            CheckAnalyze c = new CheckAnalyze();

            c.QTY    = count;
            c.SQTY   = count2;
            c.remark = "";
            listerp.Add(c);
            return(true);
        }
Exemple #7
0
        //保存盘点单
        public JsonResult SaveCheck(T_StockInfoEX model)
        {
            try
            {
                if (string.IsNullOrEmpty(model.WarehouseNo))
                {
                    return(Json(new { state = false }, JsonRequestBehavior.AllowGet));
                }
                T_WareHouse_DB TWareHouseDB       = new T_WareHouse_DB();
                string         StrongHoldCode     = "";
                string         StrongHoldCodeName = "";
                TWareHouseDB.GetStrongholdcode(model.WarehouseNo, ref StrongHoldCode, ref StrongHoldCodeName);

                Check_DB checkdb  = new Check_DB();
                string   ErrorMsg = "";
                if (!checkdb.CheckIsSvae(model.MaterialNo, model.WarehouseNo, ref ErrorMsg))
                {
                    return(Json(new { state = false, ErrMsg = "待发或者待收库区有该物料不能生成盘点单!【" + ErrorMsg + "】" }, JsonRequestBehavior.AllowGet));
                }


                string strErrMsg             = string.Empty;
                List <T_StockInfoEX> lsttask = new List <T_StockInfoEX>();
                Query_DB             db      = new Query_DB();
                if (!db.GetStockCombineInfo2(model, ref lsttask, ref strErrMsg))
                {
                    return(Json(new { Result = 0, ErrMsg = strErrMsg }, JsonRequestBehavior.AllowGet));
                }
                if (model.Check == "0")
                {
                    //检验WMS库存和U9是否一致
                    T_Material_Batch_Func FUNC      = new T_Material_Batch_Func();
                    List <U9Stock>        erp_stock = FUNC.GetStockInfo(model.WarehouseNo, StrongHoldCode, model.MaterialNo);
                    bool isOk = true;
                    lsttask.ForEach(itemWMS =>
                    {
                        if (erp_stock.FindAll(itemerp => { return(itemerp.MaterialNo == itemWMS.MaterialNo && itemerp.BatchNo == itemWMS.BatchNo && itemerp.Qty == itemWMS.Qty); }).Count != 1)
                        {
                            isOk = false;
                        }
                    });
                    if (!isOk)
                    {
                        return(Json(new { state = false, ErrMsg = "WMS库存和U9不匹配不能生成盘点单!" }, JsonRequestBehavior.AllowGet));
                    }
                }



                Check_Model cm = new Check_Model();
                //cm.REMARKS = strremark + txt_remarkD.Text + txt_remark.Text;
                cm.CHECKSTATUS = "新建";
                cm.CREATER     = currentUser.UserNo;
                cm.CHECKDESC   = "明盘";
                string ErrMsg = "";
                if (checkdb.SaveCheck2(cm, lsttask, ref ErrMsg))
                {
                    return(Json(new { state = true }, JsonRequestBehavior.AllowGet));
                }
                return(Json(new { state = false }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { state = false, ErrMsg = ex.ToString() }, JsonRequestBehavior.AllowGet));
            }
        }
Exemple #8
0
        // 获取盘点库存信息
        public JsonResult GetCheckStock(DividPage page, T_StockInfoEX model)
        {
            try
            {
                if (string.IsNullOrEmpty(model.WarehouseNo))
                {
                    return(Json(new { Result = 0, ResultValue = "仓库不能为空!" }, JsonRequestBehavior.AllowGet));
                }
                T_WareHouse_DB TWareHouseDB       = new T_WareHouse_DB();
                string         StrongHoldCode     = "";
                string         StrongHoldCodeName = "";
                TWareHouseDB.GetStrongholdcode(model.WarehouseNo, ref StrongHoldCode, ref StrongHoldCodeName);

                string strErrMsg = string.Empty;
                List <T_StockInfoEX> wms_stock = new List <T_StockInfoEX>();
                Query_DB             db        = new Query_DB();
                if (db.GetStockCombineInfo2(model, ref wms_stock, ref strErrMsg))
                {
                    if (wms_stock == null || wms_stock.Count == 0)
                    {
                        return(Json(new { Result = 0, ResultValue = "查询库存为空!" }, JsonRequestBehavior.AllowGet));
                    }
                    T_Material_Batch_Func FUNC      = new T_Material_Batch_Func();
                    List <U9Stock>        erp_stock = FUNC.GetStockInfo(model.WarehouseNo, StrongHoldCode, model.MaterialNo);
                    //wms数据和erp数据对账
                    for (int i = 0; i < wms_stock.Count; i++)
                    {
                        if (erp_stock != null && erp_stock.Count > 0)
                        {
                            for (int j = 0; j < erp_stock.Count; j++)
                            {
                                if (wms_stock[i].MaterialNo == erp_stock[j].MaterialNo && wms_stock[i].BatchNo == erp_stock[j].BatchNo)
                                {
                                    wms_stock[i].U9MaterialNo = erp_stock[i].MaterialNo;
                                    wms_stock[i].U9BatchNo    = erp_stock[i].BatchNo;
                                    wms_stock[i].U9Qty        = erp_stock[j].Qty;
                                    erp_stock[j].IsAmount     = 1;
                                }
                            }
                        }
                    }
                    if (erp_stock != null && erp_stock.Count > 0)
                    {
                        //没匹配的u9数据
                        for (int i = 0; i < erp_stock.Count; i++)
                        {
                            if (erp_stock[i].IsAmount != 1)
                            {
                                wms_stock.Add(new T_StockInfoEX()
                                {
                                    U9MaterialNo = erp_stock[i].MaterialNo,
                                    U9BatchNo    = erp_stock[i].BatchNo,
                                    U9Qty        = erp_stock[i].Qty,
                                    Qty          = 0
                                });
                            }
                        }
                    }
                    return(Json(new { Result = 1, Data = wms_stock }, JsonRequestBehavior.AllowGet));
                }
                return(Json(new { Result = 0, ResultValue = strErrMsg }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { Result = 0, ResultValue = ex.ToString() }, JsonRequestBehavior.AllowGet));
            }
        }
Exemple #9
0
        public bool PrintDeliveryTray(T_StockInfoEX model, List <T_StockInfoEX> list, string ipport, ref string ErrMsg)
        {
            Print_DB db = new Print_DB();

            return(db.PrintDeliveryTray(model, list, ipport, ref ErrMsg));
        }