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

259 lines
9.2 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using QMFrameWork.WebUI.Attribute;
using QMAPP.Common.Web.Controllers;
using QMAPP.FJC.Web.Models.SendManage;
using QMFrameWork.Data;
using QMAPP.ServicesAgent;
using QMAPP.KB.Entity;
using QMAPP.FJC.Entity.SendManage;
using QMFrameWork.Common.Serialization;
using QMFrameWork.WebUI.DataSource;
using System.Data;
using Common.AssemblyUtil;
using QMAPP.FJC.Entity.Operation;
using QMAPP.FJC.Entity.FileCopy.FIS;
namespace QMAPP.FJC.Web.Controllers
{
public class SendPlanRecordController : QController
{
/// <summary>
/// 模块编号:
/// 作 用:
/// 作 者:
/// 编写日期:
///</summary>
#region 获取列表
[HandleException]
public ActionResult List(bool? callBack)
{
PastCardModel searchmodel = new PastCardModel();
searchmodel.STARTCREATEDATE = DateTime.Now.AddDays(-10).ToString("yyyy-MM-dd");
searchmodel.ENDCREATEDATE = DateTime.Now.ToString("yyyy-MM-dd");
searchmodel.ImmediateSearch = false;
if (callBack == true)
TryGetSelectBuffer<PastCardModel>(out searchmodel);
searchmodel.rownumbers = true;
searchmodel.url = "/SendPlanRecord/GetList";
return View("SendPlanRecordList", searchmodel);
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="callBack">是否回调</param>
/// <returns>列表</returns>
[HandleException]
public ActionResult GetList(bool? callBack)
{
PastCardModel searchmodel = null;
DataPage page = null;
ServiceAgent wcfAgent = this.GetServiceAgent();
PastCard condition = null;
DataResult<DataPage> pageResult = new DataResult<DataPage>();
try
{
searchmodel = GetModel<PastCardModel>();
if (callBack != null)
{
TryGetSelectBuffer<PastCardModel>(out searchmodel);
}
else
{
//保存搜索条件
SetSelectBuffer<PastCardModel>(searchmodel);
}
page = this.GetDataPage(searchmodel);
condition = CopyToModel<PastCard, PastCardModel>(searchmodel);
#region wcf服务统一接口
pageResult = wcfAgent.InvokeServiceFunction<DataResult<DataPage>>(QMAPP.ServicesAgent.B9IPCService.SendPlanRecordBLL_GetList.ToString(), condition, page);
DateGridResult<PastCard> result = new DateGridResult<PastCard>();
result.Total = pageResult.Result.RecordCount;
result.Rows = JsonConvertHelper.GetDeserialize<List<PastCard>>(pageResult.Result.Result.ToString());
#endregion
return Content(result.GetJsonSource());
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取列表
/// <summary>
/// 获取详细列表
/// </summary>
/// <param name="callBack">是否回调</param>
/// <returns>列表</returns>
[HandleException]
public ActionResult DetailedInformation(bool? callBack)
{
PastCardModel seachModel = new PastCardModel();
TryGetSelectBuffer<PastCardModel>(out seachModel);
ServiceAgent wcfAgent = this.GetServiceAgent();
PastCard condition = new PastCard();
DataResult<DataTable> dataResult = new DataResult<DataTable>();
List<PastCardDetail> pastcarddetail=new List<PastCardDetail>();
try
{
//获取查询对象
seachModel = GetModel<PastCardModel>();
#region 获取缓存值
if (callBack != null)
{
TryGetSelectBuffer<PastCardModel>(out seachModel);
}
else
{
//保存搜索条件
SetSelectBuffer<PastCardModel>(seachModel);
}
#endregion
condition = CopyToModel<PastCard, PastCardModel>(seachModel);
#region wcf服务统一接口,获取详细信息
dataResult = wcfAgent.InvokeServiceFunction<DataResult<DataTable>>(QMAPP.ServicesAgent.B9IPCService.SendPlanRecordBLL_GetItem.ToString(), condition);
pastcarddetail = EntityFactory.GetEntities<PastCardDetail>(dataResult.Result);
foreach (PastCardDetail li in pastcarddetail)
{
li.ONLINEDATE = li.M100_ONLINEDATE.ToString("yyyy-MM-dd HH:mm:ss");
}
#endregion
return Json(new { Msg = dataResult.Msg, IsSuccess = dataResult.IsSuccess.ToString(), Result = pastcarddetail });
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 导出excel
/// <summary>
/// 导出excel
/// </summary>
/// <returns>结果</returns>
[HttpPost]
public ActionResult ExportExcel()
{
PastCardModel seachModel = null;
PastCard condition = null;
ServiceAgent wcfAgent = this.GetServiceAgent();
DataResult<DataTable> result = new DataResult<DataTable>();
string selectKey = Request.Form["selectKey"];
try
{
//获取查询对象
seachModel = GetModel<PastCardModel>();
condition = CopyToModel<PastCard, PastCardModel>(seachModel);
//获取数据
result = wcfAgent.InvokeServiceFunction<DataResult<DataTable>>(QMAPP.ServicesAgent.B9IPCService.SendPlanRecordBLL_GetExportData.ToString(), condition);
//根据所选信息进行导出
if (!String.IsNullOrEmpty(selectKey))
{
DataView dv = new DataView(result.Result);
string strWhere = "";
string[] list = selectKey.Split(":".ToCharArray());
foreach (string ID in list)
{
strWhere += " PASTECARDNO='" + ID + "' or";
}
if (strWhere != "")
{
strWhere = strWhere.Remove((strWhere.Length - 2), 2);
}
dv.RowFilter = strWhere;
result.Result = dv.ToTable();
}
//导出
QMFrameWork.WebUI.Util.IEFileTool efTool = new QMFrameWork.WebUI.Util.IEFileTool();
return efTool.GetExcelFileResult("SendPlanRecordExp", "SendPlanRecordExp.xlsx", result.Result);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 导出详细信息excel
/// <summary>
/// 导出excel
/// </summary>
/// <returns>结果</returns>
[HttpPost]
public ActionResult ExportExcel2()
{
PastCardDetailModel seachModel = null;
PastCardDetail condition = null;
DataTable exportDt = new DataTable();
ServiceAgent wcfAgent = this.GetServiceAgent();
try
{
//获取查询对象
seachModel = GetModel<PastCardDetailModel>();
condition = CopyToModel<PastCardDetail, PastCardDetailModel>(seachModel);
condition.PASTECARDNO_List = "('" + Request.Form["selectKey"].Replace(";", "','") + "')";
//获取数据
exportDt = wcfAgent.InvokeServiceFunction<DataTable>("SendPlanRecordBLL_GetExportData2", condition);
//导出
QMFrameWork.WebUI.Util.IEFileTool efTool = new QMFrameWork.WebUI.Util.IEFileTool();
return efTool.GetExcelFileResult("PastCardDetailExp", "PastCardDetailExp.xlsx", exportDt);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 删除
/// <summary>
/// 删除
/// </summary>
/// <returns>结果</returns>
[HttpPost]
[HandleException]
public ActionResult Delete(PastCardModel model)
{
string selectKey = Request.Form["selectKey"];
ServiceAgent wcfAgent = this.GetServiceAgent();
DataResult<int> result = new DataResult<int>();
try
{
result = wcfAgent.InvokeServiceFunction<DataResult<int>>("SendPlanRecordBLL_Delete", selectKey);
if (result.IsSuccess == false)
{
SetMessage(result.Msg);
return List(true);
}
SetMessage(AppResource.DeleteMessage);
return List(true);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}
}