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

200 lines
7.8 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using QMAPP.Common.Web.Controllers;
using QMAPP.Entity;
using QMAPP.FJC.Entity.Basic;
using QMAPP.FJC.Entity.EM;
using QMAPP.FJC.Web.Models.Basic;
using QMAPP.FJC.Web.Models.EM;
using QMAPP.ServicesAgent;
using QMFrameWork.Common.Serialization;
using QMFrameWork.Data;
using QMFrameWork.WebUI.Attribute;
using QMFrameWork.WebUI.DataSource;
namespace QMAPP.FJC.Web.Controllers
{
public class EmMeterReadingsController : QController
{
#region 获取列表
/// <summary>
/// 加载列表
/// </summary>
/// <returns>结果</returns>
[HandleException]
public ActionResult List(bool? callBack)
{
EmMeterReadingsModel seachModel = new EmMeterReadingsModel();
seachModel.STARTCREATEDATE = DateTime.Now.Date.AddMonths(-1).ToString("yyyy-MM-dd HH:mm:ss");
seachModel.ENDCREATEDATE = DateTime.Now.Date.AddDays(1).ToString("yyyy-MM-dd HH:mm:ss");
if (callBack == true)
TryGetSelectBuffer<EmMeterReadingsModel>(out seachModel);
seachModel.rownumbers = false;
seachModel.url = "/EmMeterReadings/GetList";
return View("EmMeterReadingsList", seachModel);
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="callBack">是否回调</param>
/// <returns>列表</returns>
[HandleException]
public ActionResult GetList(bool? callBack)
{
EmMeterReadingsModel seachModel = null;
DataPage page = null;
ServiceAgent wcfAgent = this.GetServiceAgent();
EmMeterReadings condition = null;
DataResult<DataPage> pageResult = new DataResult<DataPage>();
try
{
//获取查询对象
seachModel = GetModel<EmMeterReadingsModel>();
if (string.IsNullOrEmpty(seachModel.STARTCREATEDATE) || string.IsNullOrEmpty(seachModel.ENDCREATEDATE))
{
seachModel.STARTCREATEDATE = DateTime.Now.Date.AddMonths(-1).ToString("yyyy-MM-dd HH:mm:ss");
seachModel.ENDCREATEDATE = DateTime.Now.Date.AddDays(1).ToString("yyyy-MM-dd HH:mm:ss");
}
#region 获取缓存值
if (callBack != null)
{
TryGetSelectBuffer<EmMeterReadingsModel>(out seachModel);
}
else
{
//保存搜索条件
SetSelectBuffer<EmMeterReadingsModel>(seachModel);
}
#endregion
//获取前台分页设置信息
page = this.GetDataPage(seachModel);
//page.PageSize = 15;
condition = CopyToModel<EmMeterReadings, EmMeterReadingsModel>(seachModel);
#region wcf服务统一接口
pageResult = wcfAgent.InvokeServiceFunction<DataResult<DataPage>>("EmMeterReadingsBLL_GetList", condition, page);
if (pageResult.IsSuccess == false)
{
SetMessage(pageResult.Msg);
return List(true);
}
if (pageResult.IsSuccess)
{
page = pageResult.Result;
}
DateGridResult<EmMeterReadings> result = new DateGridResult<EmMeterReadings>();
result.Total = page.RecordCount;
result.Rows = JsonConvertHelper.GetDeserialize<List<EmMeterReadings>>(page.Result.ToString());
#endregion
return Content(result.GetJsonSource());
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 统计
/// </summary>
/// <returns>结果</returns>
[HandleException]
public ActionResult Count(bool? callBack)
{
EmMeterCountModel seachModel = new EmMeterCountModel();
if (callBack == true)
TryGetSelectBuffer<EmMeterCountModel>(out seachModel);
seachModel.rownumbers = false;
string ids = Request.Params["PID"];
string stime = Request.Params["STARTCREATEDATE"];
string etime = Request.Params["ENDCREATEDATE"];
string ftime = Request.Params["FLAG_TIME"];
seachModel.url = "/EmMeterReadings/GetCountList?PID=" + ids + "&STARTCREATEDATE=" + stime + "&ENDCREATEDATE=" + etime + "&FLAG_TIME=" + ftime;
return View("EmMeterReadingsCountList", seachModel);
}
/// <summary>
/// 获取统计列表
/// </summary>
/// <param name="callBack">是否回调</param>
/// <returns>列表</returns>
[HandleException]
public ActionResult GetCountList(bool? callBack)
{
EmMeterCountModel seachModel = null;
DataPage page = null;
ServiceAgent wcfAgent = this.GetServiceAgent();
EmMeterReadings condition = null;
DataResult<DataPage> pageResult = new DataResult<DataPage>();
try
{
//获取查询对象
seachModel = GetModel<EmMeterCountModel>();
#region 获取缓存值
if (callBack != null)
{
TryGetSelectBuffer<EmMeterCountModel>(out seachModel);
}
else
{
//保存搜索条件
SetSelectBuffer<EmMeterCountModel>(seachModel);
}
#endregion
//获取前台分页设置信息
page = this.GetDataPage(seachModel);
condition = CopyToModel<EmMeterReadings, EmMeterCountModel>(seachModel);
string ids = Request.Params["PID"];
ids = ids.Replace(",", "");
string stime = Request.Params["STARTCREATEDATE"];
string etime = Request.Params["ENDCREATEDATE"];
string ftime = Request.Params["FLAG_TIME"];
condition.PID = ids;
condition.STARTCREATEDATE = stime;
condition.ENDCREATEDATE = etime;
condition.FLAG_TIME = ftime;
#region wcf服务统一接口
pageResult = wcfAgent.InvokeServiceFunction<DataResult<DataPage>>("EmMeterReadingsBLL_GetCountList", condition, page);
if (pageResult.IsSuccess == false)
{
SetMessage(pageResult.Msg);
return List(true);
}
DateGridResult<EmMeterReadings> result = new DateGridResult<EmMeterReadings>();
result.Total = pageResult.Result.RecordCount;
result.Rows = JsonConvertHelper.GetDeserialize<List<EmMeterReadings>>(pageResult.Result.Result.ToString());
#endregion
return Content(result.GetJsonSource());
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取统计标识下拉列表
/// <summary>
/// 获取统计标识下拉列表
/// </summary>
/// <returns></returns>
public ContentResult GetFlagTimeComboxSource()
{
ComboboxResult model = new ComboboxResult();
model.Add(new ComboboxItem { ID = "", Text = new DictController().EmptyItemTitle });
model.Add(new ComboboxItem { ID = "0", Text = "年" });
model.Add(new ComboboxItem { ID = "1", Text = "月" });
model.Add(new ComboboxItem { ID = "2", Text = "日" });
return Content(model.ToString());
}
#endregion
}
}