旧版报表、仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

342 lines
14 KiB

2 years ago
using NPOI.HSSF.UserModel;
using NPOI.SS.Formula.Functions;
using NPOI.SS.UserModel;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Web.Http;
using Warehouse.DAL.PackOutput;
using Warehouse.DAL.Report;
using Warehouse.WebApi.Model;
//namespace Warehouse.WebApi
//{
// public class ProductionReportNewController : BaseController
// {
// ProductionReportDal DT = new ProductionReportDal();
// [Route("api/ProductionReportNew/StationNbrAndGoingNew")]
// [HttpPost]
// public IHttpActionResult QueryInfo(ProductionReportModel model)
// {
// try
// {
// var res = DT.StationNbrAndGoing(model.TestTimeBegin, model.TestTimeEnd, model.WorkShop, model.WorkOrder, model.Station, model.Sales,model.worktime);
// var list = new List<dynamic>();
// res.ForEach(x =>
// {
// list.Add(new
// {
// process_code = x.process_code.ToString() ?? "-",
// descriptions = x.descriptions.ToString() ?? "-",
// workshop = x.workshop.ToString() ?? "-",
// station_nbr = x.station_nbr ?? "-",
// going_nbr = x.going_nbr ?? "-",
// });
// });
// return Success(new
// {
// data = list
// });
// }
// catch (Exception e)
// {
// }
// return Failure("查询异常");
// }
// #region 下载
// [Route("api/ProductionReportNew/ProductionReportNewReportGet")]
// [HttpPost]
// public HttpResponseMessage DownloadBatchReportGet(StationNbrAndGoingWKSNew model)
// {
// try
// {
// HSSFWorkbook hssfworkbook = new HSSFWorkbook();
// hssfworkbook.CreateSheet("站点过站报表");
// ICellStyle style = hssfworkbook.CreateCellStyle();
// //设置单元格的样式:水平对齐居中
// style.Alignment = HorizontalAlignment.Center;
// ISheet sheet = null;
// sheet = hssfworkbook.GetSheetAt(0);
// IRow row = null;
// #region 添加表头
// var thList = new List<string> {
// "站点编码 ",
// "站点",
// "车间",
// "过站数量",
// "在制数量",
// };
// //设置第一列列宽
// // sheet.SetColumnWidth(0, 20 * 256);
// //设置第一列之后的列宽
// for (int i = 1; i < thList.Count; i++)
// {
// sheet.SetColumnWidth(i, 10 * 500);
// }
// var rowCount = sheet.LastRowNum;
// row = sheet.CreateRow(rowCount);
// //添加表头并设置样式字体居中
// for (int i = 0; i < thList.Count; i++)
// {
// row.CreateCell(i).SetCellValue(thList[i]);
// row.GetCell(i).CellStyle = style;
// }
// #endregion
// //获取数据
// var res = DT.StationNbrAndGoing(model.TestTimeBegin, model.TestTimeEnd, model.WorkShop, model.WorkOrder, model.Station, model.Sales,model.worktime);
// foreach (var item in res.ToList())
// {
// var rowCount1 = sheet.LastRowNum + 1;
// row = sheet.CreateRow(rowCount1);
// row.CreateCell(0).SetCellValue(item.process_code.ToString());
// row.GetCell(0).CellStyle = style;
// row.CreateCell(1).SetCellValue(item.descriptions.ToString());
// row.GetCell(1).CellStyle = style;
// row.CreateCell(2).SetCellValue(item.workshop.ToString());
// row.GetCell(2).CellStyle = style;
// row.CreateCell(3).SetCellValue(item.station_nbr.ToString());
// row.GetCell(3).CellStyle = style;
// row.CreateCell(4).SetCellValue(item.going_nbr.ToString());
// row.GetCell(4).CellStyle = style;
// }
// MemoryStream ms = new MemoryStream(); //创建内存流用于写入文件
// hssfworkbook.Write(ms);//将Excel写入流
// ms.Flush();
// ms.Position = 0;
// HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
// result.Content = new StreamContent(ms);
// result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
// result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
// {
// FileName = "站点过站报表.xls"
// };
// return result;
// }
// catch (Exception)
// {
// }
// return new HttpResponseMessage(HttpStatusCode.NoContent);
// }
// #endregion
// [Route("api/ProductionReportNew/StationNbrAndGoingWKSNew")]
// [HttpPost]
// public IHttpActionResult QueryInfoWKS(StationNbrAndGoingWKSNew model)
// {
// var res = DT.StationNbrAndGoingtest(model.TestTimeBegin, model.TestTimeEnd, model.WorkShop, model.Station,model.Machine, model.WorkOrder,model.Sales);
// return Json(res);
// //return Json<dynamic>(new { AA = "aa", BB = "cc" });
// }
// #region 下载
// [Route("api/ProductionReportNew/StationNbrAndGoingWKSNewGet")]
// [HttpPost]
// public HttpResponseMessage DownloadQueryInfoWKSGet(StationNbrAndGoingWKSNew model)
// {
// try
// {
// HSSFWorkbook hssfworkbook = new HSSFWorkbook();
// hssfworkbook.CreateSheet("站点过站报表");
// ICellStyle style = hssfworkbook.CreateCellStyle();
// //设置单元格的样式:水平对齐居中
// style.Alignment = HorizontalAlignment.Center;
// ISheet sheet = null;
// sheet = hssfworkbook.GetSheetAt(0);
// IRow row = null;
// #region 添加表头
// var thList = new List<string> {
// "车间",
// "站点",
// "机台",
// "过站数量",
// };
// //设置第一列列宽
// // sheet.SetColumnWidth(0, 20 * 256);
// //设置第一列之后的列宽
// for (int i = 1; i < thList.Count; i++)
// {
// sheet.SetColumnWidth(i, 10 * 500);
// }
// var rowCount = sheet.LastRowNum;
// row = sheet.CreateRow(rowCount);
// //添加表头并设置样式字体居中
// for (int i = 0; i < thList.Count; i++)
// {
// row.CreateCell(i).SetCellValue(thList[i]);
// row.GetCell(i).CellStyle = style;
// }
// #endregion
// //获取数据
// var res = DT.StationNbrAndGoingtest(model.TestTimeBegin, model.TestTimeEnd, model.WorkShop, model.Station, model.Machine, model.WorkOrder, model.Sales);
// foreach (var item in res.ToList())
// {
// var rowCount1 = sheet.LastRowNum + 1;
// row = sheet.CreateRow(rowCount1);
// row.CreateCell(0).SetCellValue(item.workshop.ToString());
// row.GetCell(0).CellStyle = style;
// row.CreateCell(1).SetCellValue(item.descriptions.ToString());
// row.GetCell(1).CellStyle = style;
// row.CreateCell(2).SetCellValue(item.wks_id.ToString());
// row.GetCell(2).CellStyle = style;
// row.CreateCell(3).SetCellValue(item.wke_nbr.ToString());
// row.GetCell(3).CellStyle = style;
// }
// MemoryStream ms = new MemoryStream(); //创建内存流用于写入文件
// hssfworkbook.Write(ms);//将Excel写入流
// ms.Flush();
// ms.Position = 0;
// HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
// result.Content = new StreamContent(ms);
// result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
// result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
// {
// FileName = "站点过站报表.xls"
// };
// return result;
// }
// catch (Exception)
// {
// }
// return new HttpResponseMessage(HttpStatusCode.NoContent);
// }
// #endregion
// [Route("api/ProductionReportNew/StationDetailedNew")]
// [HttpPost]
// public IHttpActionResult QueryStatus(StationNbrAndGoingWKSNew model)
// {
// var res = DT.StationDetailednew(model.TestTimeBegin, model.TestTimeEnd, model.WorkShop, model.Station, model.Machine, model.WorkOrder, model.Sales);
// return Json(res);
// }
// #region 下载
// [Route("api/ProductionReportNew/StationDetailedNewGet")]
// [HttpPost]
// public HttpResponseMessage DownloadStationDetailedWKSGet(StationNbrAndGoingWKSNew model)
// {
// try
// {
// HSSFWorkbook hssfworkbook = new HSSFWorkbook();
// hssfworkbook.CreateSheet("站点过站报表");
// ICellStyle style = hssfworkbook.CreateCellStyle();
// //设置单元格的样式:水平对齐居中
// style.Alignment = HorizontalAlignment.Center;
// ISheet sheet = null;
// sheet = hssfworkbook.GetSheetAt(0);
// IRow row = null;
// #region 添加表头
// var thList = new List<string> {
// "车间",
// "站点",
// "序列号",
// "工单",
// "机台",
// "EL等级",
// "最终等级",
// "过站时间",
// "操作人员",
// "状态",
// "不良描述",
// };
// //设置第一列列宽
// // sheet.SetColumnWidth(0, 20 * 256);
// //设置第一列之后的列宽
// for (int i = 1; i < thList.Count; i++)
// {
// sheet.SetColumnWidth(i, 10 * 500);
// }
// var rowCount = sheet.LastRowNum;
// row = sheet.CreateRow(rowCount);
// //添加表头并设置样式字体居中
// for (int i = 0; i < thList.Count; i++)
// {
// row.CreateCell(i).SetCellValue(thList[i]);
// row.GetCell(i).CellStyle = style;
// }
// #endregion
// //获取数据
// var res = DT.StationDetailednew(model.TestTimeBegin, model.TestTimeEnd, model.WorkShop, model.Station, model.Machine, model.WorkOrder, model.Sales);
// foreach (var item in res.ToList())
// {
// var rowCount1 = sheet.LastRowNum + 1;
// row = sheet.CreateRow(rowCount1);
// row.CreateCell(0).SetCellValue(item.descriptions.ToString());
// row.GetCell(0).CellStyle = style;
// row.CreateCell(1).SetCellValue(item.process_code.ToString());
// row.GetCell(1).CellStyle = style;
// row.CreateCell(2).SetCellValue(item.serial_nbr.ToString());
// row.GetCell(2).CellStyle = style;
// row.CreateCell(3).SetCellValue(item.workorder.ToString());
// row.GetCell(3).CellStyle = style;
// row.CreateCell(4).SetCellValue(item.wks_id.ToString());
// row.GetCell(4).CellStyle = style;
// row.CreateCell(5).SetCellValue(item.el_grade.ToString());
// row.GetCell(5).CellStyle = style;
// row.CreateCell(6).SetCellValue(item.final_grade.ToString());
// row.GetCell(6).CellStyle = style;
// row.CreateCell(7).SetCellValue(item.wks_visit_date.ToString());
// row.GetCell(7).CellStyle = style;
// row.CreateCell(8).SetCellValue(item.Worker.ToString());
// row.GetCell(8).CellStyle = style;
// row.CreateCell(9).SetCellValue(item.ZT.ToString());
// row.GetCell(9).CellStyle = style;
// row.CreateCell(10).SetCellValue(item.MS.ToString());
// row.GetCell(10).CellStyle = style;
// }
// MemoryStream ms = new MemoryStream(); //创建内存流用于写入文件
// hssfworkbook.Write(ms);//将Excel写入流
// ms.Flush();
// ms.Position = 0;
// HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
// result.Content = new StreamContent(ms);
// result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
// result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
// {
// FileName = "站点过站报表.xls"
// };
// return result;
// }
// catch (Exception)
// {
// }
// return new HttpResponseMessage(HttpStatusCode.NoContent);
// }
// #endregion
// }
//}