示例#1
0
 //
 //POST: /WIP/LotQuery/GetLotDefect
 public async Task <ActionResult> GetLotDefectWS(string lotNumber)
 {
     using (LotQueryServiceClient client = new LotQueryServiceClient())
     {
         await Task.Run(() =>
         {
             PagingConfig cfg = new PagingConfig()
             {
                 IsPaging = false,
                 Where    = string.Format(@" EXISTS(FROM LotTransaction as p
                                                 WHERE p.Key=self.Key.TransactionKey
                                                 AND p.LotNumber='{0}'
                                                 AND p.UndoFlag=0
                                                 AND p.Activity='{1}')"
                                          , lotNumber
                                          , Convert.ToInt32(EnumLotActivity.Defect)),
                 OrderBy = "EditTime"
             };
             MethodReturnResult <IList <LotTransactionDefect> > result = client.GetLotTransactionDefect(ref cfg);
             if (result.Code == 0)
             {
                 ViewBag.DefectList = result.Data;
             }
         });
     }
     return(PartialView("_DefectListPartial_ws"));
 }
示例#2
0
        public ActionResult Query(LotDefectQueryViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (LotQueryServiceClient client = new LotQueryServiceClient())
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        OrderBy = "EditTime",
                        Where   = GetQueryCondition(model)
                    };
                    MethodReturnResult <IList <LotTransactionDefect> > result = client.GetLotTransactionDefect(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.PagingConfig = cfg;
                        ViewBag.List         = result.Data;
                    }
                }
            }
            if (Request.IsAjaxRequest())
            {
                return(PartialView("_ListPartial"));
            }
            else
            {
                return(View(model));
            }
        }
示例#3
0
        public List <string> GetLotDefect(string lotNumber)
        {
            string where = null;
            List <string> XY = new List <string>();

            using (LotQueryServiceClient client = new LotQueryServiceClient())
            {
                if (!string.IsNullOrEmpty(lotNumber))
                {
                    where = string.Format(@"  EXISTS( From LotTransaction as p 
                                                      WHERE p.Key=self.Key.TransactionKey 
                                                      AND p.LotNumber='{0}')"
                                          , lotNumber);
                }
                PagingConfig cfg = new PagingConfig()
                {
                    OrderBy = "EditTime",
                    Where   = where
                };
                MethodReturnResult <IList <LotTransactionDefect> > result = client.GetLotTransactionDefect(ref cfg);
                if (result.Code == 0)
                {
                    List <LotTransactionDefect> list = result.Data.ToList <LotTransactionDefect>();
                    foreach (var item in list)
                    {
                        StringBuilder lie = new  StringBuilder();
                        using (LotDefectServiceClient LotQueryServiceClient = new LotDefectServiceClient())
                        {
                            MethodReturnResult <DataSet> rt = LotQueryServiceClient.GetXY(item.Key.TransactionKey);
                            if (rt.Code == 0 && rt.Data.Tables[0] != null && rt.Data.Tables[0].Rows.Count > 0)
                            {
                                foreach (DataRow i in rt.Data.Tables[0].Rows)
                                {
                                    lie.Append("  " + i[0].ToString() + ";  ");
                                }
                            }
                            XY.Add(item.Key.ReasonCodeName + "   " + lie.ToString());
                            lie = null;
                        }
                    }
                }
            }
            return(XY);
        }
示例#4
0
        public async Task <ActionResult> PagingQuery(string where, string orderBy, int?currentPageNo, int?currentPageSize)
        {
            if (ModelState.IsValid)
            {
                int pageNo   = currentPageNo ?? 0;
                int pageSize = currentPageSize ?? 20;
                if (Request["PageNo"] != null)
                {
                    pageNo = Convert.ToInt32(Request["PageNo"]);
                }
                if (Request["PageSize"] != null)
                {
                    pageSize = Convert.ToInt32(Request["PageSize"]);
                }

                using (LotQueryServiceClient client = new LotQueryServiceClient())
                {
                    await Task.Run(() =>
                    {
                        PagingConfig cfg = new PagingConfig()
                        {
                            PageNo   = pageNo,
                            PageSize = pageSize,
                            Where    = where ?? string.Empty,
                            OrderBy  = orderBy ?? string.Empty
                        };
                        MethodReturnResult <IList <LotTransactionDefect> > result = client.GetLotTransactionDefect(ref cfg);
                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }
示例#5
0
        public async Task <ActionResult> ExportToExcel(LotDefectQueryViewModel model)
        {
            IList <LotTransactionDefect> lst = new List <LotTransactionDefect>();

            using (LotQueryServiceClient client = new LotQueryServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        OrderBy  = "EditTime",
                        Where    = GetQueryCondition(model)
                    };
                    MethodReturnResult <IList <LotTransactionDefect> > result = client.GetLotTransactionDefect(ref cfg);

                    if (result.Code == 0)
                    {
                        lst = result.Data;
                    }
                });
            }
            //创建工作薄。
            IWorkbook wb = new HSSFWorkbook();
            //设置EXCEL格式
            ICellStyle style = wb.CreateCellStyle();

            style.FillForegroundColor = 10;
            //有边框
            style.BorderBottom = BorderStyle.THIN;
            style.BorderLeft   = BorderStyle.THIN;
            style.BorderRight  = BorderStyle.THIN;
            style.BorderTop    = BorderStyle.THIN;
            IFont font = wb.CreateFont();

            font.Boldweight = 10;
            style.SetFont(font);
            ICell  cell = null;
            IRow   row  = null;
            ISheet ws   = null;

            for (int j = 0; j < lst.Count; j++)
            {
                if (j % 65535 == 0)
                {
                    ws  = wb.CreateSheet();
                    row = ws.CreateRow(0);
                    #region //列名
                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(StringResource.ItemNo);  //项目号

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(WIPResources.StringResource.LotNumber);  //批次号

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("工单号");  //工单号

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("工序");  //工序

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("线别");  //线别

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(WIPResources.StringResource.LotDefectViewModel_DefectQuantity);  //数量

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(WIPResources.StringResource.ReasonCodeCategoryName);  //原因代码组

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(WIPResources.StringResource.ReasonCodeName);  //原因代码

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(WIPResources.StringResource.ReasonDescription);  //原因描述

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(WIPResources.StringResource.LotDefectViewModel_RouteOperationName);  //责任工序

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(WIPResources.StringResource.LotDefectViewModel_ResponsiblePerson);  //责任人

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue(StringResource.Description);  //描述

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("操作时间");  //操作时间

                    cell           = row.CreateCell(row.Cells.Count);
                    cell.CellStyle = style;
                    cell.SetCellValue("操作人");  //操作人
                    #endregion
                    font.Boldweight = 5;
                }
                LotTransactionDefect  obj       = lst[j];
                LotTransaction        transObj  = null;
                LotTransactionHistory lotHisObj = null;
                using (LotQueryServiceClient client = new LotQueryServiceClient())
                {
                    MethodReturnResult <LotTransaction> result = client.GetTransaction(obj.Key.TransactionKey);
                    if (result.Code == 0)
                    {
                        transObj = result.Data;
                    }

                    MethodReturnResult <LotTransactionHistory> result1 = client.GetLotTransactionHistory(obj.Key.TransactionKey);
                    if (result1.Code == 0)
                    {
                        lotHisObj = result1.Data;
                    }
                }
                row = ws.CreateRow(j + 1);

                #region //数据
                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(j + 1);  //项目号

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(transObj.LotNumber);  //批次号

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(transObj.OrderNumber);  //工单号

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(transObj.RouteStepName);  //工序

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(lotHisObj != null ? lotHisObj.LineCode : string.Empty);  //线别

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.Quantity);  //数量

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.Key.ReasonCodeCategoryName);  //原因代码组

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.Key.ReasonCodeName);  //原因代码

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.Description);  //原因描述

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.RouteOperationName);  //责任工序

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.ResponsiblePerson);  //责任人

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.Description);  //描述

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(string.Format("{0:yyyy-MM-dd HH:mm:ss}", obj.EditTime));  //操作时间

                cell           = row.CreateCell(row.Cells.Count);
                cell.CellStyle = style;
                cell.SetCellValue(obj.Editor);  //操作人
                #endregion
            }

            MemoryStream ms = new MemoryStream();
            wb.Write(ms);
            ms.Flush();
            ms.Position = 0;
            return(File(ms, "application/vnd.ms-excel", "LotDefectData.xls"));
        }