using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using QMAPP.MESReport.Web.Models.LineQTY;
using QMAPP.Common.Web.Controllers;
using QMFrameWork.WebUI.Attribute;
using QMFrameWork.Data;
using QMAPP.MD.Entity;
using QMAPP.Entity;
using QMAPP.ServicesAgent;
using QMFrameWork.WebUI.DataSource;
using QMFrameWork.Common.Serialization;
using QMAPP.MESReport.Entity.LineQTY;
using System.Collections;
using System.Reflection;
using QMFrameWork.ServiceInterface;
using System.Data.SqlClient;
using System.Data;
using QMAPP.Common.Web.Util;
using QMAPP.MESReport.BLL;
using QMAPP.MESReport.BLL.LineQTY;
namespace QMAPP.MESReport.Web.Controllers
{
///
/// 模块:生产日报
/// 于子清
/// 2017-10-7
///
public class LineDWQTYCountController : QController
{
public string EmptyItemTitle = " ";
#region 获取信息
///
/// 加载列表
///
/// 结果
[HandleException]
public ActionResult DWQTYList(bool? callback)
{
LineDWQTYModel seachModel = new LineDWQTYModel();
seachModel.START_DATE = DateTime.Now.Date.AddDays(-30).ToString("yyyy-MM-dd HH:mm:ss");
seachModel.END_DATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
if (callback == true)
TryGetSelectBuffer(out seachModel);
seachModel.rownumbers = false;
seachModel.checkbox = false;
seachModel.url = "/LineDWQTYCount/GetList";
return View("DWQTYList", seachModel);
}
#endregion
public ActionResult GetList(bool? callBack)
{
LineDWQTYModel seachModel = null;
DataPage page = null;
ServiceAgent wcfAgent = this.GetServiceAgent();
LineDayQTYCount condition = null;
DataResult pageResult = new DataResult();
try
{
//获取查询对象
seachModel = GetModel();
#region 获取缓存值
if (callBack != null)
{
TryGetSelectBuffer(out seachModel);
}
else
{
//保存搜索条件
SetSelectBuffer(seachModel);
}
#endregion
DateGridResult result = new DateGridResult();
if (string.IsNullOrEmpty(seachModel.START_DATE) || string.IsNullOrEmpty(seachModel.END_DATE))
{
seachModel.START_DATE = DateTime.Now.Date.AddDays(-30).ToString("yyyy-MM-dd HH:mm:ss");
seachModel.END_DATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
//获取前台分页设置信息
page = this.GetDataPage(seachModel);
condition = CopyToModel(seachModel);
#region wcf服务统一接口
pageResult = wcfAgent.InvokeServiceFunction>("LineDWQTYCountBLL_GetList", condition, page);
if (pageResult.IsSuccess == false)
{
SetMessage(pageResult.Msg);
return DWQTYList(true);
}
result.Total = pageResult.Result.RecordCount;
List nli = JsonConvertHelper.GetDeserialize>(pageResult.Result.Result.ToString());
foreach (LineDayQTYCount item in nli)
{
if (string.IsNullOrEmpty(item.QTY)||string.IsNullOrEmpty(item.OK_QTY))
{
item.OK_QTY_LV = "0%";
continue;
}
item.OK_QTY_LV = (Convert.ToDouble(item.OK_QTY) * 100 / Convert.ToDouble(item.QTY)).ToString("f2") + "%";
}
result.Rows = nli;
#endregion
return Content(result.GetJsonSource());
}
catch (Exception ex)
{
throw ex;
}
}
#region 导出excel
///
/// 导出excel
///
/// 结果
[HttpPost]
[HandleException]
public ActionResult ExportExcel()
{
LineDWQTYModel seachModel = null;
LineDayQTYCount condition = null;
DataTable exportDt = new DataTable();
QMAPP.ServicesAgent.ServiceAgent agent = this.GetServiceAgent();
PowerUtil pu = new PowerUtil();
string selectKey = Request.Form["selectKey"];
try
{
//获取查询对象
seachModel = GetModel();
condition = CopyToModel(seachModel);
//获取数据
exportDt = agent.InvokeServiceFunction("LineDWQTYCountBLL_GetExportData", condition);
//导出
QMFrameWork.WebUI.Util.IEFileTool efTool = new QMFrameWork.WebUI.Util.IEFileTool();
return efTool.GetExportDataResult("生产日报.xls", exportDt);
//return efTool.GetExcelFileResult("生产日报", "生产日报.xls", exportDt);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}
}