Example #1
0
        public WIPMoveDetailGetParameter GetQueryCondition(WIPMoveDetailQueryViewModel model)
        {
            WIPMoveDetailGetParameter p = new WIPMoveDetailGetParameter()
            {
                LocationName       = model.LocationName,
                MaterialCode       = model.MaterialCode,
                OrderNumber        = model.OrderNumber,
                ShiftName          = model.ShiftName,
                StartDate          = model.StartDate,
                EndDate            = model.EndDate,
                Activity           = -1000,
                RouteOperationName = string.Empty,
                PageNo             = model.PageNo,
                PageSize           = model.PageSize
            };

            if (model.Date != "合计")
            {
                p.StartDate = Convert.ToDateTime(model.Date);
                p.EndDate   = Convert.ToDateTime(model.Date);
            }
            if (model.RouteOperationName != "合计")
            {
                p.RouteOperationName = model.RouteOperationName;
            }
            p.Activity = Convert.ToInt32(model.Activity);
            return(p);
        }
Example #2
0
        //
        // GET: /RPT/WIPMove/Detail
        public ActionResult Detail(WIPMoveDetailQueryViewModel model)
        {
            WIPMoveDetailGetParameter p = GetQueryCondition(model);

            //获取工序MOVE明细数据。
            using (WIPMoveServiceClient client = new WIPMoveServiceClient())
            {
                MethodReturnResult <DataSet> rst = client.GetDetail(ref p);
                if (rst.Code <= 0 && rst.Data != null && rst.Data.Tables.Count > 0)
                {
                    ViewBag.List         = rst.Data.Tables[0];
                    ViewBag.PagingConfig = new PagingConfig()
                    {
                        PageNo   = model.PageNo,
                        PageSize = model.PageSize,
                        Records  = p.TotalRecords
                    };
                }
            }
            model.TotalRecords = p.TotalRecords;
            if (Request.IsAjaxRequest())
            {
                return(PartialView("_DetailListPartial"));
            }
            else
            {
                return(View(model));
            }
        }
Example #3
0
        public ActionResult ExportToExcel(WIPMoveDetailQueryViewModel model)
        {
            WIPMoveDetailGetParameter p = GetQueryCondition(model);

            p.PageSize = model.TotalRecords;
            DataTable dtData = new DataTable();

            using (WIPMoveServiceClient client = new WIPMoveServiceClient())
            {
                MethodReturnResult <DataSet> rst = client.GetDetail(ref p);
                if (rst.Code <= 0 && rst.Data != null && rst.Data.Tables.Count > 0)
                {
                    dtData = rst.Data.Tables[0];
                }
            }
            //创建工作薄。
            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);

            ISheet ws = null;

            for (int j = 0; j < dtData.Rows.Count; j++)
            {
                if (j % 65535 == 0)
                {
                    ws = wb.CreateSheet();
                    IRow row = ws.CreateRow(0);
                    #region //列名
                    ICell cell = null;
                    foreach (DataColumn dc in dtData.Columns)
                    {
                        cell           = row.CreateCell(row.Cells.Count);
                        cell.CellStyle = style;
                        cell.SetCellValue(dc.Caption);
                    }
                    #endregion
                    font.Boldweight = 5;
                }

                IRow rowData = ws.CreateRow(j + 1);

                #region //数据
                ICell cellData = null;
                foreach (DataColumn dc in dtData.Columns)
                {
                    cellData           = rowData.CreateCell(rowData.Cells.Count);
                    cellData.CellStyle = style;
                    if (dc.DataType == typeof(double) || dc.DataType == typeof(float))
                    {
                        cellData.SetCellValue(Convert.ToDouble(dtData.Rows[j][dc]));
                    }
                    else if (dc.DataType == typeof(int))
                    {
                        cellData.SetCellValue(Convert.ToInt32(dtData.Rows[j][dc]));
                    }
                    else
                    {
                        cellData.SetCellValue(Convert.ToString(dtData.Rows[j][dc]));
                    }
                }
                #endregion
            }
            MemoryStream ms = new MemoryStream();
            wb.Write(ms);
            ms.Flush();
            ms.Position = 0;
            return(File(ms, "application/vnd.ms-excel", "WIPMoveDetailData.xls"));
        }
Example #4
0
        public WIPMoveDetailGetParameter GetQueryCondition(WIPMoveDetailQueryViewModel model)
        {
            WIPMoveDetailGetParameter p = new WIPMoveDetailGetParameter()
            {
                LocationName       = model.LocationName,
                MaterialCode       = model.MaterialCode,
                OrderNumber        = model.OrderNumber,
                ShiftName          = model.ShiftName,
                StartDate          = Convert.ToDateTime(model.StartDate),
                EndDate            = Convert.ToDateTime(model.EndDate),
                Activity           = -1000,
                RouteOperationName = string.Empty,
                PageNo             = model.PageNo,
                PageSize           = model.PageSize
            };

            if (model.ShiftName == "合计")
            {
                DateTime start = Convert.ToDateTime(model.Date);
                start = start.AddHours(+8);
                if (start < Convert.ToDateTime(model.StartDate))
                {
                    p.StartDate = Convert.ToDateTime(model.StartDate);
                }
                else if (start >= Convert.ToDateTime(model.StartDate) && start <= Convert.ToDateTime(model.EndDate))
                {
                    p.StartDate = start;
                }
                else
                {
                    p.StartDate = Convert.ToDateTime(model.EndDate);
                }

                DateTime end = Convert.ToDateTime(model.Date);
                end = start.AddDays(+1);
                if (end < Convert.ToDateTime(model.StartDate))
                {
                    p.EndDate = Convert.ToDateTime(model.StartDate);
                }
                else if (end >= Convert.ToDateTime(model.StartDate) && end <= Convert.ToDateTime(model.EndDate))
                {
                    p.EndDate = end;
                }
                else
                {
                    p.EndDate = Convert.ToDateTime(model.EndDate);
                }
            }
            else if (model.ShiftName == "白班")
            {
                DateTime start = Convert.ToDateTime(model.Date);
                start = start.AddHours(+8);
                if (start < Convert.ToDateTime(model.StartDate))
                {
                    p.StartDate = Convert.ToDateTime(model.StartDate);
                }
                else if (start >= Convert.ToDateTime(model.StartDate) && start <= Convert.ToDateTime(model.EndDate))
                {
                    p.StartDate = start;
                }
                else
                {
                    p.StartDate = Convert.ToDateTime(model.EndDate);
                }

                DateTime end = Convert.ToDateTime(model.Date);
                end = end.AddHours(+20);
                if (end < Convert.ToDateTime(model.StartDate))
                {
                    p.EndDate = Convert.ToDateTime(model.StartDate);
                }
                else if (end >= Convert.ToDateTime(model.StartDate) && end <= Convert.ToDateTime(model.EndDate))
                {
                    p.EndDate = end;
                }
                else
                {
                    p.EndDate = Convert.ToDateTime(model.EndDate);
                }
            }
            else
            {
                DateTime start = Convert.ToDateTime(model.Date);
                start = start.AddDays(+1).AddHours(-4);
                if (start < Convert.ToDateTime(model.StartDate))
                {
                    p.StartDate = Convert.ToDateTime(model.StartDate);
                }
                else if (start >= Convert.ToDateTime(model.StartDate) && start <= Convert.ToDateTime(model.EndDate))
                {
                    p.StartDate = start;
                }
                else
                {
                    p.StartDate = Convert.ToDateTime(model.EndDate);
                }

                DateTime end = Convert.ToDateTime(model.Date);
                end = end.AddDays(+1).AddHours(+8);
                if (end < Convert.ToDateTime(model.StartDate))
                {
                    p.EndDate = Convert.ToDateTime(model.StartDate);
                }
                else if (end >= Convert.ToDateTime(model.StartDate) && end <= Convert.ToDateTime(model.EndDate))
                {
                    p.EndDate = end;
                }
                else
                {
                    p.EndDate = Convert.ToDateTime(model.EndDate);
                }
            }

            p.RouteOperationName = model.RouteOperationName;
            p.Activity           = Convert.ToInt32(model.Activity);
            return(p);
        }