// // 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)); } }
// // GET: /RPT/Test/ public ActionResult Index() { using (WIPMoveServiceClient client = new WIPMoveServiceClient()) { MethodReturnResult <DataSet> result = client.GetPackageYield(); ViewBag.Key = Guid.NewGuid().ToString(); this.HttpContext.Cache[ViewBag.Key] = result.Data; } return(View()); }
public ActionResult GetHighchartsResult(WIPMoveForStepDataViewModel model) { string lineName = "102B-D线"; //1 进站 2 出站 5 报废 6 不良 7 补料 DataTable dtMoveDataForStepData = new DataTable(); WIPMoveGetParameter Parameter = new WIPMoveGetParameter() { StartTime = model.StartTime, EndTime = model.EndTime, MaterialCode = model.MaterialCode, StepName = model.StepName, LocationName = model.LocationName, ShiftName = model.ShiftName, OrderNumber = model.OrderNumber }; IList <ProductionLine> lst = new List <ProductionLine>(); PagingConfig cfg = new PagingConfig() { IsPaging = false, Where = string.Format("Name!='{0}'", lineName) }; using (ProductionLineServiceClient client = new ProductionLineServiceClient()) { MethodReturnResult <IList <ProductionLine> > result = client.Get(ref cfg); if (result.Code <= 0 && result.Data != null) { lst = result.Data; } } using (WIPMoveServiceClient client = new WIPMoveServiceClient()) { MethodReturnResult <DataSet> rst = client.GetWipMoveForStep(Parameter); if (rst.Code <= 0 && rst.Data != null && rst.Data.Tables.Count > 0) { dtMoveDataForStepData = rst.Data.Tables[0]; } } if (dtMoveDataForStepData != null && dtMoveDataForStepData.Rows.Count > 0) { sl = AssembleSpline(dtMoveDataForStepData, lst); } return(Json(sl, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult> GetLotInformation(LotQueryViewModel model) { if (model.LotNumber != null) { using (WIPMoveServiceClient client = new WIPMoveServiceClient()) { await Task.Run(() => { MethodReturnResult <DataSet> result = client.GetLotInformation(model.LotNumber); if (result.Code == 0) { ViewBag.List = result.Data.Tables[0]; } }); } } return(PartialView("_LotListPartial")); }
public ActionResult QueryForCharts(WIPMoveForStepDataViewModel model) { DataTable dtData = new DataTable(); //获取工序MOVE数据。 using (WIPMoveServiceClient client = new WIPMoveServiceClient()) { MethodReturnResult <DataSet> rst = client.GetDailyQuantityOfWIP(new QMSemiProductionGetParameter() { LocationName = model.LocationName, StartDate = model.StartDate, }); if (rst.Code <= 0 && rst.Data != null && rst.Data.Tables.Count > 0) { dtData = rst.Data.Tables[0]; } } AssembleSplineForWIP(dtData); return(Json(sl, JsonRequestBehavior.AllowGet)); }
public ActionResult Query(WIPMoveQueryViewModel model) { DataTable dtData = new DataTable(); //获取工序MOVE数据。 using (WIPMoveServiceClient client = new WIPMoveServiceClient()) { MethodReturnResult <DataSet> rst = client.Get(new WIPMoveGetParameter() { LocationName = model.LocationName, MaterialCode = model.MaterialCode, OrderNumber = model.OrderNumber, ShiftName = model.ShiftName, StartDate = model.StartDate, EndDate = model.EndDate }); if (rst.Code <= 0 && rst.Data != null && rst.Data.Tables.Count > 0) { dtData = rst.Data.Tables[0]; } } //获取工序数据。 IList <RouteOperation> lstRouteOperation = new List <RouteOperation>(); using (RouteOperationServiceClient client = new RouteOperationServiceClient()) { PagingConfig cfg = new PagingConfig() { IsPaging = false, Where = "Status=1", OrderBy = "SortSeq" }; MethodReturnResult <IList <RouteOperation> > rst = client.Get(ref cfg); if (rst.Code <= 0 && rst.Data != null) { lstRouteOperation = rst.Data; } } //获取班次数据。 IList <Shift> lstShift = new List <Shift>(); using (ShiftServiceClient client = new ShiftServiceClient()) { PagingConfig cfg = new PagingConfig() { IsPaging = false }; if (!string.IsNullOrEmpty(model.ShiftName)) { cfg.Where = string.Format("Key='{0}'", model.ShiftName); } MethodReturnResult <IList <Shift> > rst = client.Get(ref cfg); if (rst.Code <= 0) { lstShift = rst.Data; } } string [] columns = new string[] { "CUR_DAY", "SHIFT_NAME", "ACTIVITY" }; //组织新表数据结构 DataTable dtNew = new DataTable(); for (int i = 0; i < columns.Length; i++) { DataColumn dc = dtNew.Columns.Add(columns[i]); dc.Caption = dicColumn[dc.ColumnName]; } //添加工序列 for (int i = 0; i < lstRouteOperation.Count; i++) { string colName = lstRouteOperation[i].Key; DataColumn col = new DataColumn(colName); col.DataType = typeof(double); dtNew.Columns.Add(col); } //添加合计列 DataColumn dcSum = dtNew.Columns.Add("SUM_VALUE"); dcSum.DataType = typeof(double); dcSum.Caption = dicColumn[dcSum.ColumnName]; //填充数据 //添加合计行。 foreach (Shift shift in lstShift) { for (int i = 0; i < activities.Length; i++) { DataRow dr = dtNew.NewRow(); dr["CUR_DAY"] = "合计"; dr["SHIFT_NAME"] = shift.Key; dr["ACTIVITY"] = Convert.ToInt32(activities[i]); dtNew.Rows.Add(dr); } } //添加日期行。 for (DateTime start = model.StartDate; start <= model.EndDate; start = start.AddDays(1)) { foreach (Shift shift in lstShift) { for (int i = 0; i < activities.Length; i++) { DataRow dr = dtNew.NewRow(); dr["CUR_DAY"] = start; dr["SHIFT_NAME"] = shift.Key; dr["ACTIVITY"] = Convert.ToInt32(activities[i]); dtNew.Rows.Add(dr); } } } for (int i = 0; i < dtNew.Rows.Count; i++) { string curDay = Convert.ToString(dtNew.Rows[i]["CUR_DAY"]); string shiftName = Convert.ToString(dtNew.Rows[i]["SHIFT_NAME"]); int activity = Convert.ToInt32(dtNew.Rows[i]["ACTIVITY"]); double sumQty = 0; for (int j = 0; j < lstRouteOperation.Count; j++) { string colName = lstRouteOperation[j].Key; double qty = 0; if (curDay == "合计") { var lnq = from row in dtData.AsEnumerable() where Convert.ToString(row["SHIFT_NAME"]) == shiftName && Convert.ToInt32(row["ACTIVITY"]) == activity && Convert.ToString(row["ROUTE_STEP_NAME"]) == colName select Convert.ToDouble(row["QUANTITY"]); qty = lnq.Sum(); } else { var lnq = from row in dtData.AsEnumerable() where Convert.ToString(row["CUR_DAY"]) == curDay && Convert.ToString(row["SHIFT_NAME"]) == shiftName && Convert.ToInt32(row["ACTIVITY"]) == activity && Convert.ToString(row["ROUTE_STEP_NAME"]) == colName select Convert.ToDouble(row["QUANTITY"]); qty = lnq.Sum(); } dtNew.Rows[i][colName] = qty; sumQty += qty; } dtNew.Rows[i]["SUM_VALUE"] = sumQty; } //缓存数据。 string key = Convert.ToString(Session.SessionID); string routeOperationKey = string.Format("{0}_RouteOperation", key); HttpContext.Cache[key] = dtData; HttpContext.Cache[routeOperationKey] = lstRouteOperation; ViewBag.ListData = dtNew; ViewBag.Key = key; if (Request.IsAjaxRequest()) { return(PartialView("_ListPartial", model)); } else { return(View(model)); } }
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")); }