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.
277 lines
13 KiB
277 lines
13 KiB
using NPOI.HSSF.UserModel;
|
|
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.MultipleTest;
|
|
using Warehouse.WebApi;
|
|
using Warehouse.WebApi.Model;
|
|
|
|
namespace JHReport.WebApi.Report
|
|
{ //多次测试数据
|
|
[RoutePrefix("api/MultipleTestDetailNew")]
|
|
public class MultipleTestDetailNewController : BaseController
|
|
{
|
|
MultipleTest multipletest = new MultipleTest();
|
|
[Route("QueryDataNew")]
|
|
[HttpPost]
|
|
public IHttpActionResult QueryDataNew(MultipleTestDetailReportSeerchModel model)
|
|
{
|
|
//得到数据
|
|
var res = multipletest.QueryStockInfoByPalletNew(model);
|
|
var list = new List<dynamic>();
|
|
res.ForEach(x => {
|
|
list.Add(new
|
|
{
|
|
wks_visit_date = x.wks_visit_date.ToString() ?? "-",
|
|
serial_nbr = x.serial_nbr.ToString() ?? "-",
|
|
wks_id = x.wks_id.ToString() ?? "-",
|
|
workorder = x.workorder.ToString() ?? "-",
|
|
cell_uop = x.cell_uop.ToString() ?? "-",
|
|
cell_eff = x.cell_eff.ToString() ?? "-",
|
|
pmax = x.pmax.ToString() ?? "-", //.ToString("yyyy-MM-dd HH:mm:ss")
|
|
isc = x.isc.ToString() ?? "-",
|
|
voc = x.voc.ToString() ?? "-",
|
|
ipm = x.ipm.ToString() ?? "-",
|
|
vpm = x.vpm.ToString() ?? "-",
|
|
ff = x.ff.ToString() ?? "-",
|
|
rs = x.rs.ToString() ?? "-",
|
|
rsh = x.rsh ?? "-",
|
|
eff = x.eff ?? "-",
|
|
env_temp = x.env_temp ?? "-",
|
|
surf_temp = x.surf_temp ?? "-",
|
|
temp = x.temp ?? "-",
|
|
ivfile_path = x.ivfile_path ?? "-",
|
|
product_code = x.product_code ?? "-",
|
|
cell_part_nbr = x.cell_part_nbr ?? "-",
|
|
cell_lot_nbr = x.cell_lot_nbr ?? "-",
|
|
cell_supplier_code = x.cell_supplier_code ?? "-",
|
|
glass_part_nbr = x.glass_part_nbr ?? "-",
|
|
glass_supplier_code = x.glass_supplier_code.ToString() ?? "-",
|
|
eva_part_nbr = x.eva_part_nbr.ToString() ?? "-",
|
|
eva_supplier_code = x.eva_supplier_code.ToString() ?? "-",
|
|
eva_lot_nbr = x.eva_lot_nbr.ToString() ?? "-",
|
|
bks_part_nbr = x.bks_part_nbr.ToString() ?? "-",
|
|
bks_supplier_code = x.bks_supplier_code.ToString() ?? "-",
|
|
bks_lot_nbr = x.bks_lot_nbr.ToString() ?? "-",
|
|
frame_part_nbr = x.frame_part_nbr.ToString() ?? "-",
|
|
frame_supplier_code = x.frame_supplier_code.ToString() ?? "-",
|
|
frame_lot_nbr = x.frame_lot_nbr.ToString() ?? "-",
|
|
jbox_part_nbr = x.jbox_part_nbr.ToString() ?? "-",
|
|
jbox_supplier_code = x.jbox_supplier_code.ToString() ?? "-",
|
|
jbox_lot_nbr = x.jbox_lot_nbr.ToString() ?? "-",
|
|
huiliu_part_nbr = x.huiliu_part_nbr.ToString() ?? "-",
|
|
huiliu_supplier_code = x.huiliu_supplier_code.ToString() ?? "-",
|
|
huiliu_lot_nbr = x.huiliu_lot_nbr.ToString() ?? "-",
|
|
hulian_part_nbr = x.hulian_part_nbr.ToString() ?? "-",
|
|
hulian_supplier_code = x.hulian_supplier_code.ToString() ?? "-",
|
|
});
|
|
});
|
|
//返回数据
|
|
return Success(new
|
|
{
|
|
data = list
|
|
});
|
|
}
|
|
#region 下载
|
|
[HttpPost, Route("DownloadMultipleTestDetailReportGet")]
|
|
public HttpResponseMessage DownloadMultipleTestDetailReportGet(MultipleTestDetailReportSeerchModel 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> {
|
|
"测试时间",
|
|
"组件序列号",
|
|
"机台号",
|
|
"工单号",
|
|
"电池片功率",
|
|
"电池片效率",
|
|
"pmx",
|
|
"isc",
|
|
"voc",
|
|
"ipm",
|
|
"vpm",
|
|
"ff",
|
|
"rs",
|
|
"rsh",
|
|
"eff",
|
|
"env_temp",
|
|
"surf_temp",
|
|
"temp",
|
|
"ivfile_path",
|
|
"组件类型",
|
|
"电池料号",
|
|
"电池批号",
|
|
"电池供应商",
|
|
"玻璃料号",
|
|
"玻璃供应商",
|
|
"EVA料号",
|
|
"EVA供应商",
|
|
"EVA批号",
|
|
"背板料号",
|
|
"背板供应商",
|
|
"背板批号",
|
|
"型材料号",
|
|
"型材供应商",
|
|
"型材批号",
|
|
"接线盒料号",
|
|
"接线盒供应商",
|
|
"接线盒批号",
|
|
"汇流条料号",
|
|
"汇流条供应商",
|
|
"汇流条批号",
|
|
"汇联条批号",
|
|
"汇联条供应商"
|
|
};
|
|
|
|
//设置第一列列宽
|
|
sheet.SetColumnWidth(0, 20 * 256);
|
|
//设置第一列之后的列宽
|
|
for (int i = 1; i < thList.Count; i++)
|
|
{
|
|
sheet.SetColumnWidth(i, 20 * 256);
|
|
}
|
|
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 = multipletest.QueryStockInfoByPalletNew(model);
|
|
foreach (var item in res.ToList())
|
|
{
|
|
var rowCount1 = sheet.LastRowNum + 1;
|
|
row = sheet.CreateRow(rowCount1);
|
|
row.CreateCell(0).SetCellValue(item.wks_visit_date.ToString());
|
|
row.GetCell(0).CellStyle = style;
|
|
row.CreateCell(1).SetCellValue(item.serial_nbr.ToString());
|
|
row.GetCell(1).CellStyle = style;
|
|
row.CreateCell(2).SetCellValue(item.wks_id.ToString());
|
|
row.GetCell(2).CellStyle = style;
|
|
row.CreateCell(3).SetCellValue(item.workorder.ToString());
|
|
row.GetCell(3).CellStyle = style;
|
|
row.CreateCell(4).SetCellValue(item.cell_uop.ToString());
|
|
row.GetCell(4).CellStyle = style;
|
|
row.CreateCell(5).SetCellValue(item.cell_eff.ToString());
|
|
row.GetCell(5).CellStyle = style;
|
|
row.CreateCell(6).SetCellValue(item.pmax.ToString());
|
|
row.GetCell(6).CellStyle = style;
|
|
row.CreateCell(7).SetCellValue(item.isc.ToString());
|
|
row.GetCell(7).CellStyle = style;
|
|
row.CreateCell(8).SetCellValue(item.voc.ToString());
|
|
row.GetCell(8).CellStyle = style;
|
|
row.CreateCell(9).SetCellValue(item.ipm.ToString());
|
|
row.GetCell(9).CellStyle = style;
|
|
row.CreateCell(10).SetCellValue(item.vpm.ToString());
|
|
row.GetCell(10).CellStyle = style;
|
|
row.CreateCell(11).SetCellValue(item.ff.ToString());
|
|
row.GetCell(11).CellStyle = style;
|
|
row.CreateCell(12).SetCellValue(item.rs.ToString());
|
|
row.GetCell(12).CellStyle = style;
|
|
row.CreateCell(13).SetCellValue(item.rsh.ToString());
|
|
row.GetCell(13).CellStyle = style;
|
|
row.CreateCell(14).SetCellValue(item.eff.ToString());
|
|
row.GetCell(14).CellStyle = style;
|
|
row.CreateCell(15).SetCellValue(item.env_temp.ToString());
|
|
row.GetCell(15).CellStyle = style;
|
|
row.CreateCell(16).SetCellValue(item.surf_temp.ToString());
|
|
row.GetCell(16).CellStyle = style;
|
|
row.CreateCell(17).SetCellValue(item.temp.ToString());
|
|
row.GetCell(17).CellStyle = style;
|
|
row.CreateCell(18).SetCellValue(item.ivfile_path.ToString());
|
|
row.GetCell(18).CellStyle = style;
|
|
row.CreateCell(19).SetCellValue(item.product_code.ToString());
|
|
row.GetCell(19).CellStyle = style;
|
|
row.CreateCell(20).SetCellValue(item.cell_part_nbr.ToString());
|
|
row.GetCell(20).CellStyle = style;
|
|
row.CreateCell(21).SetCellValue(item.cell_lot_nbr.ToString());
|
|
row.GetCell(21).CellStyle = style;
|
|
row.CreateCell(22).SetCellValue(item.cell_supplier_code.ToString());
|
|
row.GetCell(22).CellStyle = style;
|
|
row.CreateCell(23).SetCellValue(item.glass_part_nbr.ToString());
|
|
row.GetCell(23).CellStyle = style;
|
|
row.CreateCell(24).SetCellValue(item.glass_supplier_code.ToString());
|
|
row.GetCell(24).CellStyle = style;
|
|
row.CreateCell(25).SetCellValue(item.eva_part_nbr.ToString());
|
|
row.GetCell(25).CellStyle = style;
|
|
row.CreateCell(26).SetCellValue(item.eva_supplier_code.ToString());
|
|
row.GetCell(26).CellStyle = style;
|
|
row.CreateCell(27).SetCellValue(item.eva_lot_nbr.ToString());
|
|
row.GetCell(27).CellStyle = style;
|
|
row.CreateCell(28).SetCellValue(item.bks_part_nbr.ToString());
|
|
row.GetCell(28).CellStyle = style;
|
|
row.CreateCell(29).SetCellValue(item.bks_supplier_code.ToString());
|
|
row.GetCell(29).CellStyle = style;
|
|
row.CreateCell(30).SetCellValue(item.bks_lot_nbr.ToString());
|
|
row.GetCell(30).CellStyle = style;
|
|
row.CreateCell(31).SetCellValue(item.frame_part_nbr.ToString());
|
|
row.GetCell(31).CellStyle = style;
|
|
row.CreateCell(32).SetCellValue(item.frame_supplier_code.ToString());
|
|
row.GetCell(32).CellStyle = style;
|
|
row.CreateCell(33).SetCellValue(item.frame_lot_nbr.ToString());
|
|
row.GetCell(33).CellStyle = style;
|
|
row.CreateCell(34).SetCellValue(item.jbox_part_nbr.ToString());
|
|
row.GetCell(34).CellStyle = style;
|
|
row.CreateCell(35).SetCellValue(item.jbox_supplier_code.ToString());
|
|
row.GetCell(35).CellStyle = style;
|
|
row.CreateCell(36).SetCellValue(item.jbox_lot_nbr.ToString());
|
|
row.GetCell(36).CellStyle = style;
|
|
row.CreateCell(37).SetCellValue(item.huiliu_part_nbr.ToString());
|
|
row.GetCell(37).CellStyle = style;
|
|
row.CreateCell(38).SetCellValue(item.huiliu_supplier_code.ToString());
|
|
row.GetCell(38).CellStyle = style;
|
|
row.CreateCell(39).SetCellValue(item.huiliu_lot_nbr.ToString());
|
|
row.GetCell(39).CellStyle = style;
|
|
row.CreateCell(40).SetCellValue(item.hulian_part_nbr.ToString());
|
|
row.GetCell(40).CellStyle = style;
|
|
row.CreateCell(41).SetCellValue(item.hulian_supplier_code.ToString());
|
|
row.GetCell(41).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
|
|
}
|
|
}
|
|
|