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.
106 lines
2.9 KiB
106 lines
2.9 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Net.Http;
|
|
using System.Web.Http;
|
|
using Warehouse.DAL.QC;
|
|
using OfficeOpenXml;
|
|
using System.Data;
|
|
using Dapper;
|
|
using System.Net.Http.Headers;
|
|
//using System.Web.Mvc;
|
|
using System.Data.SqlClient;
|
|
using System.IO;
|
|
|
|
|
|
namespace Warehouse.WebApi
|
|
{
|
|
[RoutePrefix("api/QC")]
|
|
public class QCController : BaseController
|
|
{
|
|
static DbUtility dbhelp = new DbUtility(System.Configuration.ConfigurationManager.ConnectionStrings["mesConn"].ToString(), DbProviderType.SqlServer);
|
|
|
|
QC qc = new QC();
|
|
[Route("QueryQCInfo")]
|
|
[HttpPost]
|
|
public IHttpActionResult QueryQCInfo(dynamic para)
|
|
{
|
|
var res = qc.QueryQCInfo(para);
|
|
return Json(res);
|
|
//return Json<dynamic>(new { AA = "aa", BB = "cc" });
|
|
}
|
|
|
|
[Route("QueryStatus")]
|
|
[HttpPost]
|
|
public IHttpActionResult QueryStatus()
|
|
{
|
|
|
|
var res = qc.QueryStatus();
|
|
return Json<dynamic>(res);
|
|
|
|
|
|
}
|
|
|
|
[HttpPost, Route("QueryStatusNew")]
|
|
public IHttpActionResult QueryStatusNew()
|
|
{
|
|
var res = qc.QueryStatus();
|
|
var keyList = new List<dynamic>();
|
|
keyList.Add(new
|
|
{
|
|
name = "全部",
|
|
id = ""
|
|
});
|
|
res.ForEach(x => {
|
|
keyList.Add(new
|
|
{
|
|
name = x.visit_type_desc,
|
|
id = x.visit_type
|
|
});
|
|
});
|
|
|
|
return Success(new
|
|
{
|
|
keyList
|
|
});
|
|
}
|
|
|
|
[Route("ExportExcel")]
|
|
[HttpPost]
|
|
public HttpResponseMessage ExportExcel()
|
|
{
|
|
|
|
|
|
var stream = new MemoryStream();
|
|
|
|
// processing the stream.
|
|
string sql = @"SELECT TOP 1000 *
|
|
FROM[mes_main].[dbo].[assembly_basis]";
|
|
DataTable dt = dbhelp.ExecuteDataTable(sql, null);
|
|
|
|
using (ExcelPackage pck = new ExcelPackage())
|
|
{
|
|
ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Accounts");
|
|
ws.Cells["A1"].LoadFromDataTable(dt, true);
|
|
pck.SaveAs(stream);
|
|
}
|
|
|
|
|
|
var result = new HttpResponseMessage(HttpStatusCode.OK)
|
|
{
|
|
//Content = new ByteArrayContent(stream.ToArray())
|
|
Content = new StreamContent(stream)
|
|
};
|
|
result.Content.Headers.ContentDisposition =
|
|
new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment")
|
|
{
|
|
FileName = "exceltst.xlsx"
|
|
};
|
|
result.Content.Headers.ContentType =
|
|
new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
|
return result;
|
|
}
|
|
}
|
|
}
|