天津投入产出系统后端
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.

131 lines
4.4 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using QMAPP.FJC.Entity.SendPlan;
using QMAPP.FJC.Web.Models.SendPlanManage;
using QMFrameWork.WebUI.Attribute;
using QMAPP.Common.Web.Controllers;
using QMAPP.KB.Entity;
using QMFrameWork.Data;
using QMAPP.ServicesAgent;
using QMFrameWork.WebUI.DataSource;
using QMFrameWork.Common.Serialization;
using System.Data;
namespace QMAPP.FJC.Web.Controllers
{
/// <summary>
/// 模块编号:M8-2
/// 作 用:发车统计分析控制层
/// 作 者:王丹丹
/// 编写日期:2015年06月26日
///</summary>
public class SendStatisticsController : QController
{
#region 初始化
/// <summary>
/// 初始化
/// </summary>
/// <returns>结果</returns>
[HandleException]
public ActionResult Init()
{
SendStatisticsModel seachModel = new SendStatisticsModel();
return View("SendStatisticsList", seachModel);
}
#endregion
#region 获取列表
/// <summary>
/// 加载列表
/// </summary>
/// <returns>结果</returns>
[HandleException]
public ActionResult List()
{
SendStatisticsModel seachModel = null;
DataResult<IList<SendPlanInfo>> listResult = new DataResult<IList<SendPlanInfo>>();
DataPage page = new DataPage();
ServiceAgent wcfAgent = this.GetServiceAgent();
SendPlanInfo condition = null;
try
{
//获取查询对象
seachModel = GetModel<SendStatisticsModel>();
condition = CopyToModel<SendPlanInfo, SendStatisticsModel>(seachModel);
#region wcf服务统一接口
listResult = wcfAgent.InvokeServiceFunction<DataResult<IList<SendPlanInfo>>>(QMAPP.ServicesAgent.B9IPCService.SendPlanInfoBLL_GetSendStatisticsList.ToString(), condition);
#endregion
if (listResult.IsSuccess == false)
{
SetMessage(listResult.Msg);
return View("SendStatisticsList", seachModel);
}
object[] arr = new object[listResult.Result.Count];
for (int i = 0; i < listResult.Result.Count; i++)
{
arr.SetValue(
new
{
PeiZhi = listResult.Result[i].VERSION + "-" + listResult.Result[i].COLORCODE,
Count = listResult.Result[i].Counts
}, i
);
}
seachModel.arr = JsonConvertHelper.GetSerializes(arr);
if (listResult.Result.Count == 0)
{
SetMessage("未查到相关数据!");
} 
return View("SendStatisticsList", seachModel);
 
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 导出excel
/// <summary>
/// 导出excel
/// </summary>
/// <returns>结果</returns>
[HttpPost]
public ActionResult ExportExcel()
{
SendStatisticsModel seachModel = null;
SendPlanInfo condition = null;
ServiceAgent wcfAgent = this.GetServiceAgent();
DataResult<DataTable> result = new DataResult<DataTable>();
try
{
//获取查询对象
seachModel = GetModel<SendStatisticsModel>();
condition = CopyToModel<SendPlanInfo, SendStatisticsModel>(seachModel);
//获取数据
result = wcfAgent.InvokeServiceFunction<DataResult<DataTable>>(QMAPP.ServicesAgent.B9IPCService.SendPlanInfoBLL_GetSendStatisticsExportData.ToString(), condition);
//导出
QMFrameWork.WebUI.Util.IEFileTool efTool = new QMFrameWork.WebUI.Util.IEFileTool();
return efTool.GetExcelFileResult("SendStatisticsExp", "统计分析表.xlsx", result.Result);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}
}