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

149 lines
6.4 KiB

3 years ago
using System;
using System.Collections.Generic;
using System.Web.Mvc;
using QMAPP.Common.Web.Controllers;
using QMAPP.FJC.Web.Models.CompleteStatistics;
using QMAPP.ServicesAgent;
using QMFrameWork.Common.Serialization;
using QMFrameWork.Data;
using QMFrameWork.WebUI.Attribute;
using QMFrameWork.WebUI.DataSource;
using QMAPP.Entity;
using QMAPP.FJC.Entity.CompleteStatistics;
using QMFrameWork.Log;
using QMFrameWork.Common.ExcelOperation;
using System.Data;
namespace QMAPP.FJC.Web.Controllers
{
public class CompleteStatisticsController : QController
{
//
// GET: /CompleteStatistics/
[HandleException]
public ActionResult CompleteStatisticsList(bool? callBack)
{
CompleteStatisticsModel searchModel = new CompleteStatisticsModel();
if (callBack == true)
this.TryGetSelectBuffer<CompleteStatisticsModel>(out searchModel);
searchModel.rownumbers = false;
searchModel.url = "/CompleteStatistics/GetList";
return this.View("CompleteStatisticsList", searchModel);
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="callBack">是否回调</param>
/// <returns>用户列表</returns>
[HandleException]
public ActionResult GetList(bool? callBack)
{
ServiceAgent wcfAgent = this.GetServiceAgent();
CompleteStatisticsModel searchModel = this.GetModel<CompleteStatisticsModel>();
if (callBack == true) {
this.TryGetSelectBuffer(out searchModel);
}
else {
this.SetSelectBuffer(searchModel);
}
//获取前台分页设置信息
DataPage page = this.GetDataPage(searchModel);
CompleteStatisticsEntity condition = this.CopyToModel<CompleteStatisticsEntity, CompleteStatisticsModel>(searchModel);
condition.DELFLAG = searchModel.DOESEXPORT;
DataResult<DataPage> pageResult = wcfAgent.InvokeServiceFunction<DataResult<DataPage>>("CompleteStatisticsBLL_GetList", condition, page);
if (pageResult.IsSuccess == false) {
this.SetMessage(pageResult.Msg);
return this.CompleteStatisticsList(true);
}
DataGridResult<CompleteStatisticsEntity> result = new DataGridResult<CompleteStatisticsEntity>
{
Total = pageResult.Result.RecordCount,
Rows = JsonConvertHelper.GetDeserialize<List<CompleteStatisticsEntity>>(pageResult.Result.Result.ToString())
};
return this.Content(result.GetJsonSource());
}
[HttpPost]
[HandleException]
public ActionResult ExportCompleteStatistics()
{
CompleteStatisticsModel searchModel = this.GetModel<CompleteStatisticsModel>();
CompleteStatisticsEntity condition = this.CopyToModel<CompleteStatisticsEntity, CompleteStatisticsModel>(searchModel);
DataResult result = this.GetServiceAgent().InvokeServiceFunction<DataResult>("CompleteStatisticsBLL_ExportCompleteStatistics", condition);
this.SetMessage(result.Msg);
return this.CompleteStatisticsList(true);
}
[HttpPost]
[HandleException]
public ActionResult Delete()
{
string selectKey = this.Request.Form["selectKey"];
ServiceAgent wcfAgent = this.GetServiceAgent();
//删除
DataResult<int> serviceResult = wcfAgent.InvokeServiceFunction<DataResult<int>>("", selectKey);
this.SetMessage(string.IsNullOrEmpty(serviceResult.Msg) ? AppResource.DeleteMessage : serviceResult.Msg);
return this.CompleteStatisticsList(true);
}
[HttpPost]
[HandleException]
public ActionResult Save(CompleteStatisticsModel saveModel)
{
CompleteStatisticsEntity model = this.CopyToModel<CompleteStatisticsEntity, CompleteStatisticsModel>(saveModel);
ServiceAgent wcfAgent = this.GetServiceAgent();
DataResult<int> serviceResult = wcfAgent.InvokeServiceFunction<DataResult<int>>(string.IsNullOrEmpty(model.PID) ? "CompleteStatisticsBLL_Insert" : "CompleteStatisticsBLL_Update", model);
this.SetMessage(string.IsNullOrEmpty(serviceResult.Msg) ? AppResource.SaveMessge : serviceResult.Msg);
return this.GetJsViewResult(string.Format("parent.List(1);parent.showTitle('{0}');parent.closeAppWindow1();", AppResource.SaveMessge));
}
/// <summary>
/// 编辑载入
/// </summary>
/// <returns>处理结果</returns>
[HandleException]
public ActionResult CompleteStatisticsEdit()
{
CompleteStatisticsModel model = new CompleteStatisticsModel();
string pid = this.Request.Params["PID"];
if (!string.IsNullOrEmpty(pid)) {
ServiceAgent serviceAgent = this.GetServiceAgent();
CompleteStatisticsEntity entity = serviceAgent.InvokeServiceFunction<CompleteStatisticsEntity>("CompleteStatisticsBLL_GetById", pid);
model = this.CopyToModel<CompleteStatisticsModel, CompleteStatisticsEntity>(entity);
}
return this.View(model);
}
/// <summary>
/// 导出excel
/// </summary>
/// <returns>结果</returns>
[HandleException]
public ActionResult ExportExcel()
{
try
{
CompleteStatisticsModel searchModel = this.GetModel<CompleteStatisticsModel>();
CompleteStatisticsEntity condition = this.CopyToModel<CompleteStatisticsEntity, CompleteStatisticsModel>(searchModel);
DataResult<DataTable> result = this.GetServiceAgent().InvokeServiceFunction<DataResult<DataTable>>("CompleteStatisticsBLL_ExportExcelData", condition);
//导出
QMFrameWork.WebUI.Util.IEFileTool efTool = new QMFrameWork.WebUI.Util.IEFileTool();
return efTool.GetExcelFileResult("CompleteStatisticsExp", "完工数量统计.xlsx", result.Result);
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo { ErrorInfo = ex, Info = "导出excel", Tag = "完工数量统计" });
this.SetMessage("导出excel失败");
return this.CompleteStatisticsList(true);
}
}
}
}